diff --git a/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/controller/RoleController.java b/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/controller/RoleController.java index 6015a503..e6f98d10 100644 --- a/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/controller/RoleController.java +++ b/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/controller/RoleController.java @@ -107,7 +107,7 @@ public class RoleController { public ResponseResult updateUserRole(@RequestBody UserRoleVO userRoleVO){ List userIds = userRoleVO.getUserIds(); if (userIds.size()==0){ - return ResponseResult.FAIL(20000,"不能不选择用户"); + return ResponseResult.FAIL(20000,"请至少选择一个用户!"); } boolean save = roleService.saveUserRole(userRoleVO); return ResponseResult.SUCCESS(save); diff --git a/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/dao/RoleDao.java b/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/dao/RoleDao.java index 172a5f18..014ff699 100644 --- a/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/dao/RoleDao.java +++ b/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/dao/RoleDao.java @@ -26,4 +26,6 @@ public interface RoleDao extends BaseMapper { void saveUserRole(@Param("roleId") String roleId,@Param("userId") String userId); int removeUserRole(@Param("roleId") String roleId); + + int selectUserRole(@Param("roleId") String roleId,@Param("userId") String userId); } diff --git a/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/impl/RoleServiceImpl.java b/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/impl/RoleServiceImpl.java index 72eb962a..12400896 100644 --- a/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/impl/RoleServiceImpl.java +++ b/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/impl/RoleServiceImpl.java @@ -42,7 +42,11 @@ public class RoleServiceImpl extends ServiceImpl implements List userIds = userRoleVO.getUserIds(); userIds.forEach(userId -> { - baseMapper.saveUserRole(roleId,userId); + //添加前判断是否重复 + int count = baseMapper.selectUserRole(roleId, userId); + if (count==0){ + baseMapper.saveUserRole(roleId,userId); + } }); return true; }