From 9509e003ca16b4116b850a742516f2704f840089 Mon Sep 17 00:00:00 2001 From: chen <1251790704@qq.com> Date: Mon, 22 Feb 2021 11:44:02 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=94=A8=E6=88=B7=E8=A7=92?= =?UTF-8?q?=E8=89=B2bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../daqing/financial/hrms/controller/RoleController.java | 2 +- .../main/java/com/daqing/financial/hrms/dao/RoleDao.java | 2 ++ .../daqing/financial/hrms/service/impl/RoleServiceImpl.java | 6 +++++- 3 files changed, 8 insertions(+), 2 deletions(-) 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; }