use of com.github.liuweijw.business.admin.domain.RoleDept in project fw-cloud-framework by liuweijw.
the class RoleServiceImpl method saveRoleAndDept.
@Override
@Transactional
@CacheEvict(allEntries = true)
public Role saveRoleAndDept(Role role) {
if (null == role || null == role.getDeptId() || role.getDeptId() < 0)
return null;
Role dbRole = this.roleRepository.saveAndFlush(role);
// 删除之前保存的部门角色关系
QRoleDept qRoleDept = QRoleDept.roleDept;
this.queryFactory.delete(qRoleDept).where(qRoleDept.roleId.eq(dbRole.getRoleId())).execute();
RoleDept roleDept = new RoleDept();
roleDept.setDeptId(role.getDeptId());
roleDept.setRoleId(dbRole.getRoleId());
roleDeptRepository.saveAndFlush(roleDept);
return dbRole;
}
Aggregations