Search in sources :

Example 1 with RoleDept

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;
}
Also used : Role(com.github.liuweijw.business.admin.domain.Role) QRole(com.github.liuweijw.business.admin.domain.QRole) RoleDept(com.github.liuweijw.business.admin.domain.RoleDept) QRoleDept(com.github.liuweijw.business.admin.domain.QRoleDept) QRoleDept(com.github.liuweijw.business.admin.domain.QRoleDept) CacheEvict(org.springframework.cache.annotation.CacheEvict) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

QRole (com.github.liuweijw.business.admin.domain.QRole)1 QRoleDept (com.github.liuweijw.business.admin.domain.QRoleDept)1 Role (com.github.liuweijw.business.admin.domain.Role)1 RoleDept (com.github.liuweijw.business.admin.domain.RoleDept)1 CacheEvict (org.springframework.cache.annotation.CacheEvict)1 Transactional (org.springframework.transaction.annotation.Transactional)1