|
|
|
@ -1,14 +1,13 @@ |
|
|
|
|
package com.daqing.financial.hrauth.controller; |
|
|
|
|
|
|
|
|
|
import com.daqing.financial.hrauth.service.RolePermissionService; |
|
|
|
|
import com.daqing.framework.domain.hrms.DeptPositionEntity; |
|
|
|
|
import com.daqing.framework.domain.hrms.PermissionEntity; |
|
|
|
|
import com.daqing.framework.domain.hrms.RoleEntity; |
|
|
|
|
import com.daqing.framework.domain.hrms.request.RolePermissionRequest; |
|
|
|
|
import com.daqing.framework.domain.hrms.response.HrmsCode; |
|
|
|
|
import com.daqing.framework.domain.hrms.response.RolePermissionResponse; |
|
|
|
|
import com.daqing.framework.exception.ExceptionCast; |
|
|
|
|
import com.daqing.framework.model.response.ResponseResult; |
|
|
|
|
import com.daqing.framework.utils.PageUtils; |
|
|
|
|
import com.daqing.framework.utils.SnowflakeIdUtils; |
|
|
|
|
import io.swagger.annotations.Api; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
@ -76,7 +75,10 @@ public class RolePermissionController { |
|
|
|
|
rolePermission.setCreateTime(date); |
|
|
|
|
rolePermission.setMotifyTime(date); |
|
|
|
|
//此处要判重,新增的角色名称要唯一
|
|
|
|
|
|
|
|
|
|
int count = permissionService.uniqueRoleName(rolePermission.getName()); |
|
|
|
|
if(count >0){ |
|
|
|
|
ExceptionCast.cast(HrmsCode.ROLE_NAME_EXIST); |
|
|
|
|
} |
|
|
|
|
//新增角色到角色表
|
|
|
|
|
int request = permissionService.addHrmsRole(rolePermission); |
|
|
|
|
//根据选中的permissionId批量新增数据到hrms_role_permission
|
|
|
|
@ -123,14 +125,17 @@ public class RolePermissionController { |
|
|
|
|
@Transactional |
|
|
|
|
@PostMapping("/delRolePermission") |
|
|
|
|
public ResponseResult delRolePermission(@RequestBody RolePermissionRequest rolePermission) { |
|
|
|
|
//查询该角色是否有用户关联
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//没有关联则删除hrms_role表对应记录
|
|
|
|
|
|
|
|
|
|
//根据角色Id查询该角色是否有用户关联
|
|
|
|
|
int count = permissionService.queryCountByRoleId(rolePermission.getRoleId()); |
|
|
|
|
if(count >0){ |
|
|
|
|
ExceptionCast.cast(HrmsCode.ROLE_EMP_EXIST); |
|
|
|
|
} |
|
|
|
|
//没有关联则根据roleId删除hrms_role表对应记录
|
|
|
|
|
permissionService.deleteHrmsRoleByRoleId(rolePermission.getRoleId()); |
|
|
|
|
//根据角色id删除对应所有权限
|
|
|
|
|
boolean result = permissionService.deleteHrmsRolePermission(rolePermission.getRoleId()); |
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
|
return result ? ResponseResult.SUCCESS() : ResponseResult.FAIL(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|