Add course and membership type models

master
esensar 2017-03-23 22:50:41 +01:00
parent 188d45cd9a
commit 8862a71ada
7 changed files with 116 additions and 15 deletions

View File

@ -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> {
}

View File

@ -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> {
}

View File

@ -6,11 +6,7 @@ package ba.steleks.repository;
import ba.steleks.repository.model.User; import ba.steleks.repository.model.User;
import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import java.util.List;
public interface UserRolesJpaRepository extends PagingAndSortingRepository<User, Long> { public interface UserRolesJpaRepository extends PagingAndSortingRepository<User, Long> {
List<User> findByUsername(@Param("username") String username);
} }

View File

@ -8,5 +8,4 @@ import ba.steleks.repository.model.UserRole;
import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.data.repository.PagingAndSortingRepository;
public interface UsersJpaRepository extends PagingAndSortingRepository<UserRole, Long> { public interface UsersJpaRepository extends PagingAndSortingRepository<UserRole, Long> {
} }

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -22,10 +22,18 @@ public class User {
private String email; private String email;
private String contactNumber; private String contactNumber;
private String passwordHash; private String passwordHash;
private String username; private String username;
private String profilePictureUrl; private String profilePictureUrl;
private long courseId;
private long membershipTypeId; @ManyToMany
@JoinColumn
private Set<Course> courses;
@ManyToMany
@JoinColumn
private Set<MembershipType> membershipTypes;
@ManyToMany @ManyToMany
@JoinColumn @JoinColumn
@ -111,20 +119,20 @@ public class User {
this.profilePictureUrl = profilePictureUrl; this.profilePictureUrl = profilePictureUrl;
} }
public long getCourseId() { public Set<Course> getCourses() {
return courseId; return courses;
} }
public void setCourseId(long courseId) { public void setCourses(Set<Course> courses) {
this.courseId = courseId; this.courses = courses;
} }
public long getMembershipTypeId() { public Set<MembershipType> getMembershipTypes() {
return membershipTypeId; return membershipTypes;
} }
public void setMembershipTypeId(long membershipTypeId) { public void setMembershipTypes(Set<MembershipType> membershipTypes) {
this.membershipTypeId = membershipTypeId; this.membershipTypes = membershipTypes;
} }
public Set<UserRole> getUserRoles() { public Set<UserRole> getUserRoles() {