Merge branch 'master' of https://github.com/esensar/steleks_web_app
commit
26d383d3f1
|
@ -0,0 +1,16 @@
|
|||
package ba.steleks.repository;
|
||||
|
||||
/**
|
||||
* Created by ensar on 22/03/17.
|
||||
*/
|
||||
|
||||
import ba.steleks.repository.model.User;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public interface UserRolesJpaRepository extends CrudRepository<User, Long> {
|
||||
List<User> findByUsername(@Param("username") String username);
|
||||
}
|
|
@ -4,15 +4,9 @@ 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 ba.steleks.repository.model.UserRole;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
import java.util.List;
|
||||
public interface UsersJpaRepository extends CrudRepository<UserRole, Long> {
|
||||
|
||||
|
||||
public interface UsersJpaRepository extends PagingAndSortingRepository<User, Long> {
|
||||
|
||||
List<User> findByUsername(@Param("username") String username);
|
||||
User findById(@Param("id") Long id);
|
||||
}
|
||||
|
|
|
@ -2,10 +2,8 @@ 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 javax.persistence.*;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@Entity
|
||||
|
@ -29,6 +27,10 @@ public class User {
|
|||
private long courseId;
|
||||
private long membershipTypeId;
|
||||
|
||||
@ManyToMany
|
||||
@JoinColumn
|
||||
private Set<UserRole> userRoles;
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -124,4 +126,12 @@ public class User {
|
|||
public void setMembershipTypeId(long membershipTypeId) {
|
||||
this.membershipTypeId = membershipTypeId;
|
||||
}
|
||||
|
||||
public Set<UserRole> getUserRoles() {
|
||||
return userRoles;
|
||||
}
|
||||
|
||||
public void setUserRoles(Set<UserRole> userRoles) {
|
||||
this.userRoles = userRoles;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
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 UserRole {
|
||||
private static final Logger logger =
|
||||
Logger.getLogger(UserRole.class.getName());
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private long id;
|
||||
|
||||
private String roleName;
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getRoleName() {
|
||||
return roleName;
|
||||
}
|
||||
|
||||
public void setRoleName(String roleName) {
|
||||
this.roleName = roleName;
|
||||
}
|
||||
}
|
Reference in New Issue