修复删除部门BUG以及部门ID编号自增过大问题
This commit is contained in:
@ -7,11 +7,8 @@
|
|||||||
* 一经发现盗用、分享等行为,将追究法律责任,后果自负
|
* 一经发现盗用、分享等行为,将追究法律责任,后果自负
|
||||||
*/
|
*/
|
||||||
package co.yixiang.modules.system.domain;
|
package co.yixiang.modules.system.domain;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.bean.copier.CopyOptions;
|
import cn.hutool.core.bean.copier.CopyOptions;
|
||||||
|
|
||||||
@ -29,7 +26,7 @@ import java.io.Serializable;
|
|||||||
public class Dept implements Serializable {
|
public class Dept implements Serializable {
|
||||||
|
|
||||||
/** ID */
|
/** ID */
|
||||||
@TableId
|
@TableId(value = "id",type= IdType.AUTO)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -109,16 +110,21 @@ public class DeptController {
|
|||||||
@PreAuthorize("@el.check('admin','dept:del')")
|
@PreAuthorize("@el.check('admin','dept:del')")
|
||||||
public ResponseEntity<Object> delete(@RequestBody Set<Long> ids){
|
public ResponseEntity<Object> delete(@RequestBody Set<Long> ids){
|
||||||
//if(StrUtil.isNotEmpty("22")) throw new BadRequestException("演示环境禁止操作");
|
//if(StrUtil.isNotEmpty("22")) throw new BadRequestException("演示环境禁止操作");
|
||||||
Set<DeptDto> deptDtos = new HashSet<>();
|
List<Long> deptIds = new ArrayList<>();
|
||||||
for (Long id : ids) {
|
for (Long id : ids) {
|
||||||
List<Dept> deptList = deptService.findByPid(id);
|
List<Dept> deptList = deptService.findByPid(id);
|
||||||
deptDtos.add(generator.convert(deptService.getOne(new QueryWrapper<Dept>().eq("id",id)),DeptDto.class));
|
Dept dept = deptService.getOne(new QueryWrapper<Dept>().eq("id",id));
|
||||||
|
if(null!=dept){
|
||||||
|
deptIds.add(dept.getId());
|
||||||
|
}
|
||||||
if(CollectionUtil.isNotEmpty(deptList)){
|
if(CollectionUtil.isNotEmpty(deptList)){
|
||||||
deptDtos = deptService.getDeleteDepts(deptList, deptDtos);
|
for(Dept d:deptList){
|
||||||
|
deptIds.add(d.getId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
deptService.removeByIds(deptDtos);
|
deptService.removeByIds(deptIds);
|
||||||
}catch (Throwable e){
|
}catch (Throwable e){
|
||||||
ThrowableUtil.throwForeignKeyException(e, "所选部门中存在岗位或者角色关联,请取消关联后再试");
|
ThrowableUtil.throwForeignKeyException(e, "所选部门中存在岗位或者角色关联,请取消关联后再试");
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ public interface DeptService extends BaseService<Dept>{
|
|||||||
* @param deptDtos /
|
* @param deptDtos /
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
Set<DeptDto> getDeleteDepts(List<Dept> deptList, Set<DeptDto> deptDtos);
|
/*Set<DeptDto> getDeleteDepts(List<Dept> deptList, Set<DeptDto> deptDtos);*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据角色ID查询
|
* 根据角色ID查询
|
||||||
|
@ -161,7 +161,7 @@ public class DeptServiceImpl extends BaseServiceImpl<DeptMapper, Dept> implement
|
|||||||
* @param deptDtos /
|
* @param deptDtos /
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
@Override
|
/* @Override
|
||||||
public Set<DeptDto> getDeleteDepts(List<Dept> deptList, Set<DeptDto> deptDtos) {
|
public Set<DeptDto> getDeleteDepts(List<Dept> deptList, Set<DeptDto> deptDtos) {
|
||||||
|
|
||||||
for (Dept dept : deptList) {
|
for (Dept dept : deptList) {
|
||||||
@ -172,7 +172,7 @@ public class DeptServiceImpl extends BaseServiceImpl<DeptMapper, Dept> implement
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return deptDtos;
|
return deptDtos;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据角色ID查询
|
* 根据角色ID查询
|
||||||
|
Reference in New Issue
Block a user