From 7848c33ad21162b073d1d11aa412822c75b46889 Mon Sep 17 00:00:00 2001 From: esensar Date: Wed, 22 Mar 2017 00:58:38 +0100 Subject: [PATCH] Basic user repository --- .../repository/UsersJpaRepository.java | 18 +++ .../ba/steleks/repository/model/User.java | 127 ++++++++++++++++++ 2 files changed, 145 insertions(+) create mode 100644 users/src/main/java/ba/steleks/repository/UsersJpaRepository.java create mode 100644 users/src/main/java/ba/steleks/repository/model/User.java diff --git a/users/src/main/java/ba/steleks/repository/UsersJpaRepository.java b/users/src/main/java/ba/steleks/repository/UsersJpaRepository.java new file mode 100644 index 0000000..854eb90 --- /dev/null +++ b/users/src/main/java/ba/steleks/repository/UsersJpaRepository.java @@ -0,0 +1,18 @@ +package ba.steleks.repository; + +/** + * Created by ensar on 22/03/17. + */ + +import ba.steleks.repository.model.User; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.data.repository.query.Param; + +import java.util.List; + + +public interface UsersJpaRepository extends PagingAndSortingRepository { + + List findByUsername(@Param("username") String username); + User findById(@Param("id") Long id); +} diff --git a/users/src/main/java/ba/steleks/repository/model/User.java b/users/src/main/java/ba/steleks/repository/model/User.java new file mode 100644 index 0000000..9b6300f --- /dev/null +++ b/users/src/main/java/ba/steleks/repository/model/User.java @@ -0,0 +1,127 @@ +package ba.steleks.repository.model;/** + * Created by ensar on 22/03/17. + */ + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import java.util.logging.Logger; + +@Entity +public class User { + private static final Logger logger = + Logger.getLogger(User.class.getName()); + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + private int cardNumber; + private String firstName; + private String lastName; + private String registrationDate; + private String email; + private String contactNumber; + private String passwordHash; + private String username; + private String profilePictureUrl; + private long courseId; + private long membershipTypeId; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public int getCardNumber() { + return cardNumber; + } + + public void setCardNumber(int cardNumber) { + this.cardNumber = cardNumber; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getRegistrationDate() { + return registrationDate; + } + + public void setRegistrationDate(String registrationDate) { + this.registrationDate = registrationDate; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getContactNumber() { + return contactNumber; + } + + public void setContactNumber(String contactNumber) { + this.contactNumber = contactNumber; + } + + public String getPasswordHash() { + return passwordHash; + } + + public void setPasswordHash(String passwordHash) { + this.passwordHash = passwordHash; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getProfilePictureUrl() { + return profilePictureUrl; + } + + public void setProfilePictureUrl(String profilePictureUrl) { + this.profilePictureUrl = profilePictureUrl; + } + + public long getCourseId() { + return courseId; + } + + public void setCourseId(long courseId) { + this.courseId = courseId; + } + + public long getMembershipTypeId() { + return membershipTypeId; + } + + public void setMembershipTypeId(long membershipTypeId) { + this.membershipTypeId = membershipTypeId; + } +}