40 lines
1.3 KiB
Java
40 lines
1.3 KiB
Java
|
package eu.eudat.dao.entities;
|
||
|
|
||
|
import eu.eudat.dao.DatabaseAccess;
|
||
|
import eu.eudat.dao.DatabaseAccessLayer;
|
||
|
import eu.eudat.dao.databaselayer.service.DatabaseService;
|
||
|
import eu.eudat.entities.UserInfo;
|
||
|
import eu.eudat.entities.UserRole;
|
||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||
|
import org.springframework.stereotype.Component;
|
||
|
|
||
|
import java.util.List;
|
||
|
import java.util.UUID;
|
||
|
|
||
|
/**
|
||
|
* Created by ikalyvas on 1/30/2018.
|
||
|
*/
|
||
|
@Component("userRoleDao")
|
||
|
public class UserRoleDaoImpl extends DatabaseAccess<UserRole> implements UserRoleDao{
|
||
|
|
||
|
@Autowired
|
||
|
public UserRoleDaoImpl(DatabaseService<UserRole> databaseService) {
|
||
|
this.setDatabaseService(databaseService);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public UserRole createOrUpdate(UserRole item) {
|
||
|
return this.getDatabaseService().createOrUpdate(item,UserRole.class);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public UserRole find(UUID id) {
|
||
|
return this.getDatabaseService().getQueryable(UserRole.class).where((builder, root) -> builder.equal(root.get("id"),id)).getSingleOrDefault();
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public List<UserRole> getUserRoles(UserInfo userInfo) {
|
||
|
return this.getDatabaseService().getQueryable(UserRole.class).where((builder, root) -> builder.equal(root.get("userInfo"),userInfo)).toList();
|
||
|
}
|
||
|
}
|