判重返回处理

master
cheney 2 years ago
parent 7e6b38c828
commit af76be07c9
  1. 1
      src/main/java/com/huoran/iasf/common/exception/code/BaseResponseCode.java
  2. 4
      src/main/java/com/huoran/iasf/controller/UserGroupController.java
  3. 7
      src/main/java/com/huoran/iasf/entity/SysDept.java
  4. 1
      src/main/java/com/huoran/iasf/entity/UserGroup.java
  5. 8
      src/main/java/com/huoran/iasf/mapper/xml/SysFilesMapper.xml
  6. 22
      src/main/java/com/huoran/iasf/service/impl/DeptServiceImpl.java

@ -45,6 +45,7 @@ public enum BaseResponseCode implements ResponseCodeInterface {
ROLE_PERMISSION_RELATION(401009, "该菜单权限存在子集关联,不允许删除"), ROLE_PERMISSION_RELATION(401009, "该菜单权限存在子集关联,不允许删除"),
OLD_PASSWORD_ERROR(401010, "旧密码不正确"), OLD_PASSWORD_ERROR(401010, "旧密码不正确"),
NOT_PERMISSION_DELETED_DEPT(401011, "该组织机构下还关联着用户,不允许删除"), NOT_PERMISSION_DELETED_DEPT(401011, "该组织机构下还关联着用户,不允许删除"),
DELETE_SUB_DEPARTMENTS_FIRST(401018, "请先删除子级部门!"),
OPERATION_MENU_PERMISSION_CATALOG_ERROR(401012, "操作后的菜单类型是目录,所属菜单必须为默认顶级菜单或者目录"), OPERATION_MENU_PERMISSION_CATALOG_ERROR(401012, "操作后的菜单类型是目录,所属菜单必须为默认顶级菜单或者目录"),
OPERATION_MENU_PERMISSION_MENU_ERROR(401013, "操作后的菜单类型是菜单,所属菜单必须为目录类型"), OPERATION_MENU_PERMISSION_MENU_ERROR(401013, "操作后的菜单类型是菜单,所属菜单必须为目录类型"),
OPERATION_MENU_PERMISSION_BTN_ERROR(401013, "操作后的菜单类型是按钮,所属菜单必须为菜单类型"), OPERATION_MENU_PERMISSION_BTN_ERROR(401013, "操作后的菜单类型是按钮,所属菜单必须为菜单类型"),

@ -45,7 +45,7 @@ public class UserGroupController {
UserGroup one = userGroupService.getOne(new QueryWrapper<UserGroup>(). UserGroup one = userGroupService.getOne(new QueryWrapper<UserGroup>().
eq("group_name", userGroup.getGroupName())); eq("group_name", userGroup.getGroupName()));
if (ObjectUtil.isNotNull(one)){ if (ObjectUtil.isNotNull(one)){
R.fail("用户组已存在"); return R.fail("用户组已存在");
} }
userGroupService.save(userGroup); userGroupService.save(userGroup);
return R.success(); return R.success();
@ -73,7 +73,7 @@ public class UserGroupController {
queryWrapper.last(" and id != " + userGroup.getId()); queryWrapper.last(" and id != " + userGroup.getId());
List<UserGroup> groups = userGroupService.list(queryWrapper); List<UserGroup> groups = userGroupService.list(queryWrapper);
if (ObjectUtil.isNotNull(groups) && groups.size()>0){ if (ObjectUtil.isNotNull(groups) && groups.size()>0){
R.fail("用户组已存在"); return R.fail("用户组已存在");
} }
userGroupService.updateById(userGroup); userGroupService.updateById(userGroup);
return R.success(); return R.success();

@ -1,9 +1,6 @@
package com.huoran.iasf.entity; package com.huoran.iasf.entity;
import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@ -60,7 +57,7 @@ public class SysDept implements Serializable {
@TableField(fill = FieldFill.INSERT_UPDATE) @TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateTime; private Date updateTime;
@TableField(fill = FieldFill.INSERT) @TableLogic
private Integer deleted; private Integer deleted;
} }

@ -47,6 +47,7 @@ public class UserGroup extends BaseEntity implements Serializable {
private Date updateTime; private Date updateTime;
@ApiModelProperty(value = "是否删除(1未删除;0已删除)") @ApiModelProperty(value = "是否删除(1未删除;0已删除)")
@TableLogic
private Integer deleted; private Integer deleted;
} }

@ -24,13 +24,13 @@
FROM FROM
sys_files f sys_files f
LEFT JOIN sys_user u ON f.uploader = u.id LEFT JOIN sys_user u ON f.uploader = u.id
WHERE WHERE f.deleted = 1
AND f.site = 1
AND f.deleted = 1
AND f.is_release = 1 AND f.is_release = 1
AND f.is_del = 0 AND f.is_del = 0
and f.quote is not null and f.quote is not null
<if test="req.site != '' and req.site != null">
AND f.site = #{req.site}
</if>
<if test="req.type != '' and req.type != null"> <if test="req.type != '' and req.type != null">
AND f.type = #{req.type} AND f.type = #{req.type}
</if> </if>

@ -86,12 +86,12 @@ public class DeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impleme
} }
sysDeptMapper.updateById(vo); sysDeptMapper.updateById(vo);
//说明层级发生了变化 //说明层级发生了变化
if (!StringUtils.isEmpty(vo.getPid()) && !vo.getPid().equals(sysDept.getPid())) { /*if (!StringUtils.isEmpty(vo.getPid()) && !vo.getPid().equals(sysDept.getPid())) {
SysDept parent = sysDeptMapper.selectById(vo.getPid()); SysDept parent = sysDeptMapper.selectById(vo.getPid());
if (!"0".equals(vo.getPid()) && null == parent) { if (!"0".equals(vo.getPid()) && null == parent) {
throw new BusinessException(BaseResponseCode.DATA_ERROR); throw new BusinessException(BaseResponseCode.DATA_ERROR);
} }
/*SysDept oldParent = sysDeptMapper.selectById(sysDept.getPid()); *//*SysDept oldParent = sysDeptMapper.selectById(sysDept.getPid());
String oldRelationCode; String oldRelationCode;
String newRelationCode; String newRelationCode;
//根目录降到其他目录 //根目录降到其他目录
@ -104,16 +104,16 @@ public class DeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impleme
} else { } else {
oldRelationCode = oldParent.getRelationCode(); oldRelationCode = oldParent.getRelationCode();
newRelationCode = parent.getRelationCode(); newRelationCode = parent.getRelationCode();
}*/ }*//*
/*LambdaQueryWrapper<SysDept> wrapper = Wrappers.lambdaQuery(); *//*LambdaQueryWrapper<SysDept> wrapper = Wrappers.lambdaQuery();
wrapper.likeLeft(SysDept::getDeptNo, sysDept.getDeptNo()); wrapper.likeLeft(SysDept::getDeptNo, sysDept.getDeptNo());
List<SysDept> list = sysDeptMapper.selectList(wrapper); List<SysDept> list = sysDeptMapper.selectList(wrapper);
list.parallelStream().forEach(entity -> { list.parallelStream().forEach(entity -> {
String relationCode = entity.getRelationCode().replace(oldRelationCode, newRelationCode); String relationCode = entity.getRelationCode().replace(oldRelationCode, newRelationCode);
entity.setRelationCode(relationCode); entity.setRelationCode(relationCode);
sysDeptMapper.updateById(entity); sysDeptMapper.updateById(entity);
});*/ });*//*
} }*/
} }
@Override @Override
@ -124,10 +124,20 @@ public class DeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impleme
} }
List<Object> deptIds = sysDeptMapper.selectObjs(Wrappers.<SysDept>lambdaQuery().select(SysDept::getId).likeRight(SysDept::getRelationCode, sysDept.getRelationCode())); List<Object> deptIds = sysDeptMapper.selectObjs(Wrappers.<SysDept>lambdaQuery().select(SysDept::getId).likeRight(SysDept::getRelationCode, sysDept.getRelationCode()));
if (deptIds!=null&&deptIds.size()>0){
List<UserDept> list = userDeptMapper.selectList(Wrappers.<UserDept>lambdaQuery().in(UserDept::getDeptId, deptIds)); List<UserDept> list = userDeptMapper.selectList(Wrappers.<UserDept>lambdaQuery().in(UserDept::getDeptId, deptIds));
if (!CollectionUtils.isEmpty(list)) { if (!CollectionUtils.isEmpty(list)) {
throw new BusinessException(BaseResponseCode.NOT_PERMISSION_DELETED_DEPT); throw new BusinessException(BaseResponseCode.NOT_PERMISSION_DELETED_DEPT);
} }
}else {
//查询是否有子级部门
QueryWrapper<SysDept> deptQueryWrapper = new QueryWrapper<>();
deptQueryWrapper.eq("pid",sysDept.getId());
List<SysDept> sysDepts = sysDeptMapper.selectList(deptQueryWrapper);
if (sysDepts!=null&& sysDepts.size()>0){
throw new BusinessException(BaseResponseCode.DELETE_SUB_DEPARTMENTS_FIRST);
}
}
sysDeptMapper.deleteById(id); sysDeptMapper.deleteById(id);
} }

Loading…
Cancel
Save