Merge remote-tracking branch 'origin/master'

master
shijie 4 years ago
commit b7fc81ae1c
  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){ public ResponseResult updateUserRole(@RequestBody UserRoleVO userRoleVO){
List<String> userIds = userRoleVO.getUserIds(); List<String> userIds = userRoleVO.getUserIds();
if (userIds.size()==0){ if (userIds.size()==0){
return ResponseResult.FAIL(20000,"不能不选择用户"); return ResponseResult.FAIL(20000,"请至少选择一个用户!");
} }
boolean save = roleService.saveUserRole(userRoleVO); boolean save = roleService.saveUserRole(userRoleVO);
return ResponseResult.SUCCESS(save); return ResponseResult.SUCCESS(save);

@ -26,4 +26,6 @@ public interface RoleDao extends BaseMapper<RoleEntity> {
void saveUserRole(@Param("roleId") String roleId,@Param("userId") String userId); void saveUserRole(@Param("roleId") String roleId,@Param("userId") String userId);
int removeUserRole(@Param("roleId") String roleId); 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(); List<String> userIds = userRoleVO.getUserIds();
userIds.forEach(userId -> { userIds.forEach(userId -> {
baseMapper.saveUserRole(roleId,userId); //添加前判断是否重复
int count = baseMapper.selectUserRole(roleId, userId);
if (count==0){
baseMapper.saveUserRole(roleId,userId);
}
}); });
return true; return true;
} }

Loading…
Cancel
Save