Add course and membership type models
parent
188d45cd9a
commit
8862a71ada
|
@ -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<Course, Long> {
|
||||
}
|
|
@ -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<MembershipType, Long> {
|
||||
}
|
|
@ -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<User, Long> {
|
||||
List<User> findByUsername(@Param("username") String username);
|
||||
}
|
||||
|
|
|
@ -8,5 +8,4 @@ import ba.steleks.repository.model.UserRole;
|
|||
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||
|
||||
public interface UsersJpaRepository extends PagingAndSortingRepository<UserRole, Long> {
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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<Course> courses;
|
||||
|
||||
@ManyToMany
|
||||
@JoinColumn
|
||||
private Set<MembershipType> membershipTypes;
|
||||
|
||||
@ManyToMany
|
||||
@JoinColumn
|
||||
|
@ -111,20 +119,20 @@ public class User {
|
|||
this.profilePictureUrl = profilePictureUrl;
|
||||
}
|
||||
|
||||
public long getCourseId() {
|
||||
return courseId;
|
||||
public Set<Course> getCourses() {
|
||||
return courses;
|
||||
}
|
||||
|
||||
public void setCourseId(long courseId) {
|
||||
this.courseId = courseId;
|
||||
public void setCourses(Set<Course> courses) {
|
||||
this.courses = courses;
|
||||
}
|
||||
|
||||
public long getMembershipTypeId() {
|
||||
return membershipTypeId;
|
||||
public Set<MembershipType> getMembershipTypes() {
|
||||
return membershipTypes;
|
||||
}
|
||||
|
||||
public void setMembershipTypeId(long membershipTypeId) {
|
||||
this.membershipTypeId = membershipTypeId;
|
||||
public void setMembershipTypes(Set<MembershipType> membershipTypes) {
|
||||
this.membershipTypes = membershipTypes;
|
||||
}
|
||||
|
||||
public Set<UserRole> getUserRoles() {
|
||||
|
|
Reference in New Issue