解决用户角色bug

master
chen 4 years ago
parent 600ae2b7d1
commit 9509e003ca
  1. 2
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/controller/RoleController.java
  2. 2
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/dao/RoleDao.java
  3. 6
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/impl/RoleServiceImpl.java

@ -107,7 +107,7 @@ public class RoleController {
public ResponseResult updateUserRole(@RequestBody UserRoleVO userRoleVO){
List<String> userIds = userRoleVO.getUserIds();
if (userIds.size()==0){
return ResponseResult.FAIL(20000,"不能不选择用户");
return ResponseResult.FAIL(20000,"请至少选择一个用户!");
}
boolean save = roleService.saveUserRole(userRoleVO);
return ResponseResult.SUCCESS(save);

@ -26,4 +26,6 @@ public interface RoleDao extends BaseMapper<RoleEntity> {
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);
}

@ -42,7 +42,11 @@ public class RoleServiceImpl extends ServiceImpl<RoleDao, RoleEntity> implements
List<String> 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;
}

Loading…
Cancel
Save