use of com.github.liuweijw.business.admin.domain.UserRole in project fw-cloud-framework by liuweijw.
the class UserServiceImpl method updateUserAndRole.
@Override
@Transactional
public boolean updateUserAndRole(UserForm userForm) {
if (null == userForm.getUserId() || userForm.getUserId() <= 0)
return Boolean.FALSE;
User user = userRepository.findUserByUserId(userForm.getUserId());
if (null == user)
return false;
user.setStatu(userForm.getStatu());
user.setUpdateTime(new Date());
user.setUserId(userForm.getUserId());
user.setUsername(userForm.getUsername());
userRepository.save(user);
QUserRole qUserRole = QUserRole.userRole;
this.queryFactory.delete(qUserRole).where(qUserRole.userId.eq(userForm.getUserId())).execute();
UserRole uRole = new UserRole();
uRole.setRoleId(userForm.getRoleId());
uRole.setUserId(userForm.getUserId());
this.userRoleRepository.saveAndFlush(uRole);
return true;
}
use of com.github.liuweijw.business.admin.domain.UserRole in project fw-cloud-framework by liuweijw.
the class UserServiceImpl method addUserAndRole.
@Override
@Transactional
public boolean addUserAndRole(User user, Integer roleId) {
User dbUser = this.userRepository.saveAndFlush(user);
UserRole uRole = new UserRole();
uRole.setRoleId(roleId);
uRole.setUserId(dbUser.getUserId());
this.userRoleRepository.saveAndFlush(uRole);
return true;
}
use of com.github.liuweijw.business.admin.domain.UserRole in project fw-cloud-framework by liuweijw.
the class UserServiceImpl method updateUserAndRoleDept.
@Override
@Transactional
@CacheEvict(allEntries = true)
public boolean updateUserAndRoleDept(UserForm userForm) {
if (null == userForm.getUserId() || userForm.getUserId() <= 0)
return Boolean.FALSE;
User user = userRepository.findUserByUserId(userForm.getUserId());
if (null == user)
return false;
user.setStatu(userForm.getStatu());
user.setUpdateTime(new Date());
user.setUserId(userForm.getUserId());
user.setDeptId(userForm.getDeptId());
user.setUsername(userForm.getUsername());
user.setMobile(userForm.getMobile());
userRepository.save(user);
QUserRole qUserRole = QUserRole.userRole;
this.queryFactory.delete(qUserRole).where(qUserRole.userId.eq(userForm.getUserId())).execute();
UserRole uRole = new UserRole();
uRole.setRoleId(userForm.getRoleId());
uRole.setUserId(userForm.getUserId());
this.userRoleRepository.saveAndFlush(uRole);
return true;
}
use of com.github.liuweijw.business.admin.domain.UserRole in project fw-cloud-framework by liuweijw.
the class UserServiceImpl method addUserAndRoleDept.
@Override
@Transactional
@CacheEvict(allEntries = true)
public boolean addUserAndRoleDept(UserForm userForm) {
User user = new User();
user.setCreateTime(new Date());
user.setStatu(0);
user.setDeptId(userForm.getDeptId());
user.setPassword(new BCryptPasswordEncoder().encode(userForm.getPassword().trim()));
user.setUpdateTime(new Date());
user.setUsername(userForm.getUsername().trim());
user.setMobile(userForm.getMobile());
User dbUser = this.userRepository.saveAndFlush(user);
UserRole uRole = new UserRole();
uRole.setRoleId(userForm.getRoleId());
uRole.setUserId(dbUser.getUserId());
this.userRoleRepository.saveAndFlush(uRole);
return true;
}
Aggregations