From 8862a71adac77004161697ffb2d69836275709b3 Mon Sep 17 00:00:00 2001 From: esensar Date: Thu, 23 Mar 2017 22:50:41 +0100 Subject: [PATCH] Add course and membership type models --- .../repository/CoursesJpaRepository.java | 12 ++++++ .../MembershipTypesJpaRepository.java | 12 ++++++ .../repository/UserRolesJpaRepository.java | 4 -- .../repository/UsersJpaRepository.java | 1 - .../ba/steleks/repository/model/Course.java | 37 +++++++++++++++++++ .../repository/model/MembershipType.java | 37 +++++++++++++++++++ .../ba/steleks/repository/model/User.java | 28 +++++++++----- 7 files changed, 116 insertions(+), 15 deletions(-) create mode 100644 users/src/main/java/ba/steleks/repository/CoursesJpaRepository.java create mode 100644 users/src/main/java/ba/steleks/repository/MembershipTypesJpaRepository.java create mode 100644 users/src/main/java/ba/steleks/repository/model/Course.java create mode 100644 users/src/main/java/ba/steleks/repository/model/MembershipType.java diff --git a/users/src/main/java/ba/steleks/repository/CoursesJpaRepository.java b/users/src/main/java/ba/steleks/repository/CoursesJpaRepository.java new file mode 100644 index 0000000..b749077 --- /dev/null +++ b/users/src/main/java/ba/steleks/repository/CoursesJpaRepository.java @@ -0,0 +1,12 @@ +package ba.steleks.repository; + +/** + * Created by ensar on 22/03/17. + */ + +import ba.steleks.repository.model.Course; +import org.springframework.data.repository.PagingAndSortingRepository; + + +public interface CoursesJpaRepository extends PagingAndSortingRepository { +} diff --git a/users/src/main/java/ba/steleks/repository/MembershipTypesJpaRepository.java b/users/src/main/java/ba/steleks/repository/MembershipTypesJpaRepository.java new file mode 100644 index 0000000..5eafc2b --- /dev/null +++ b/users/src/main/java/ba/steleks/repository/MembershipTypesJpaRepository.java @@ -0,0 +1,12 @@ +package ba.steleks.repository; + +/** + * Created by ensar on 22/03/17. + */ + +import ba.steleks.repository.model.MembershipType; +import org.springframework.data.repository.PagingAndSortingRepository; + + +public interface MembershipTypesJpaRepository extends PagingAndSortingRepository { +} diff --git a/users/src/main/java/ba/steleks/repository/UserRolesJpaRepository.java b/users/src/main/java/ba/steleks/repository/UserRolesJpaRepository.java index 0ef2ebe..4997577 100644 --- a/users/src/main/java/ba/steleks/repository/UserRolesJpaRepository.java +++ b/users/src/main/java/ba/steleks/repository/UserRolesJpaRepository.java @@ -6,11 +6,7 @@ package ba.steleks.repository; 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 UserRolesJpaRepository extends PagingAndSortingRepository { - List findByUsername(@Param("username") String username); } diff --git a/users/src/main/java/ba/steleks/repository/UsersJpaRepository.java b/users/src/main/java/ba/steleks/repository/UsersJpaRepository.java index 1114ca8..4aa5d61 100644 --- a/users/src/main/java/ba/steleks/repository/UsersJpaRepository.java +++ b/users/src/main/java/ba/steleks/repository/UsersJpaRepository.java @@ -8,5 +8,4 @@ import ba.steleks.repository.model.UserRole; import org.springframework.data.repository.PagingAndSortingRepository; public interface UsersJpaRepository extends PagingAndSortingRepository { - } diff --git a/users/src/main/java/ba/steleks/repository/model/Course.java b/users/src/main/java/ba/steleks/repository/model/Course.java new file mode 100644 index 0000000..e500d94 --- /dev/null +++ b/users/src/main/java/ba/steleks/repository/model/Course.java @@ -0,0 +1,37 @@ +package ba.steleks.repository.model;/** + * Created by ensar on 23/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 Course { + private static final Logger logger = + Logger.getLogger(Course.class.getName()); + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + private String courseName; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getCourseName() { + return courseName; + } + + public void setCourseName(String courseName) { + this.courseName = courseName; + } +} diff --git a/users/src/main/java/ba/steleks/repository/model/MembershipType.java b/users/src/main/java/ba/steleks/repository/model/MembershipType.java new file mode 100644 index 0000000..8442a71 --- /dev/null +++ b/users/src/main/java/ba/steleks/repository/model/MembershipType.java @@ -0,0 +1,37 @@ +package ba.steleks.repository.model;/** + * Created by ensar on 23/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 MembershipType { + private static final Logger logger = + Logger.getLogger(MembershipType.class.getName()); + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + private String membershipTypeName; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getMembershipTypeName() { + return membershipTypeName; + } + + public void setMembershipTypeName(String membershipTypeName) { + this.membershipTypeName = membershipTypeName; + } +} diff --git a/users/src/main/java/ba/steleks/repository/model/User.java b/users/src/main/java/ba/steleks/repository/model/User.java index 93f275d..ed06425 100644 --- a/users/src/main/java/ba/steleks/repository/model/User.java +++ b/users/src/main/java/ba/steleks/repository/model/User.java @@ -22,10 +22,18 @@ public class User { private String email; private String contactNumber; private String passwordHash; + private String username; + private String profilePictureUrl; - private long courseId; - private long membershipTypeId; + + @ManyToMany + @JoinColumn + private Set courses; + + @ManyToMany + @JoinColumn + private Set membershipTypes; @ManyToMany @JoinColumn @@ -111,20 +119,20 @@ public class User { this.profilePictureUrl = profilePictureUrl; } - public long getCourseId() { - return courseId; + public Set getCourses() { + return courses; } - public void setCourseId(long courseId) { - this.courseId = courseId; + public void setCourses(Set courses) { + this.courses = courses; } - public long getMembershipTypeId() { - return membershipTypeId; + public Set getMembershipTypes() { + return membershipTypes; } - public void setMembershipTypeId(long membershipTypeId) { - this.membershipTypeId = membershipTypeId; + public void setMembershipTypes(Set membershipTypes) { + this.membershipTypes = membershipTypes; } public Set getUserRoles() {