Merge remote-tracking branch '惠信/develop' into develop

This commit is contained in:
曹鹏飞 2025-02-15 16:46:46 +08:00
commit b480272178
6 changed files with 15 additions and 15 deletions

View File

@ -120,8 +120,8 @@ public class BaseAreaController extends ControllerBase {
@ApiMark(moduleName = "区域管理", apiName = "删除") @ApiMark(moduleName = "区域管理", apiName = "删除")
public ApiResult<Boolean> del(@RequestBody List<Long> ids){ public ApiResult<Boolean> del(@RequestBody List<Long> ids){
VUtils.trueThrow(CollUtil.isEmpty(ids)).throwMessage(STATE.ParamErr,"请选择要删除的行"); VUtils.trueThrow(CollUtil.isEmpty(ids)).throwMessage(STATE.ParamErr,"请选择要删除的行");
baseAreaService.getBaseMapper().deleteByIds(ids);
baseAreaService.delByIds(ids, AdminUserUtil.getUserNo(), AdminUserUtil.getUserName()); // baseAreaService.delByIds(ids, AdminUserUtil.getUserNo(), AdminUserUtil.getUserName());
return ApiResult.success(true); return ApiResult.success(true);
} }

View File

@ -139,11 +139,11 @@ public class DepartmentController extends ControllerBase {
@PostMapping("disable") @PostMapping("disable")
@MethodInfoMark(value = "禁用",menuName = "部门管理") @MethodInfoMark(value = "禁用",menuName = "部门管理")
@ApiMark(moduleName = "部门管理", apiName = "禁用") @ApiMark(moduleName = "部门管理", apiName = "禁用")
public ApiResult<Boolean> disable(@RequestBody List<Integer> ids ){ public ApiResult<Boolean> disable(@RequestBody List<Long> ids ){
VUtils.trueThrowBusinessError(CollUtil.isEmpty(ids)).throwMessage("请选择要启用的数据"); VUtils.trueThrowBusinessError(CollUtil.isEmpty(ids)).throwMessage("请选择要启用的数据");
List<TBaseDepartment> tBaseDepartments = departmentService.getBaseMapper().selectByIds(ids); List<TBaseDepartment> tBaseDepartments = departmentService.getBaseMapper().selectByIds(ids);
List<Integer> childIds=new ArrayList<>(); List<Long> childIds=new ArrayList<>();
childIds.addAll(ids); childIds.addAll(ids);
for (TBaseDepartment tBaseDepartment : tBaseDepartments) { for (TBaseDepartment tBaseDepartment : tBaseDepartments) {
adminDepartmentService.getAllChildIds(tBaseDepartment, childIds); adminDepartmentService.getAllChildIds(tBaseDepartment, childIds);

View File

@ -7,7 +7,7 @@ import javax.validation.constraints.NotBlank;
@Data @Data
public class DepartmentDTO { public class DepartmentDTO {
private Integer id; private Long id;
@NotBlank(message = "编码不能为空") @NotBlank(message = "编码不能为空")
private String deptCode; private String deptCode;
@ -16,5 +16,5 @@ public class DepartmentDTO {
private String deptName; private String deptName;
private Integer deptParentId=0; private Long deptParentId=0L;
} }

View File

@ -29,7 +29,7 @@ public class AdminDepartmentService {
List<BaseDepartmentVO> dataResult = Convert.toList(BaseDepartmentVO.class, result.getRecords()); List<BaseDepartmentVO> dataResult = Convert.toList(BaseDepartmentVO.class, result.getRecords());
if(StrUtil.isNotBlank(query.getDeptCodeOrName())){ if(StrUtil.isNotBlank(query.getDeptCodeOrName())){
List<BaseDepartmentVO> alldept = Convert.toList(BaseDepartmentVO.class,departmentService.lambdaQuery().eq(TBaseDepartment::getDataValidStatus,1).list()) ; List<BaseDepartmentVO> alldept = Convert.toList(BaseDepartmentVO.class,departmentService.lambdaQuery().eq(TBaseDepartment::getDataValidStatus,1).list()) ;
Map<Integer, BaseDepartmentVO> collect = alldept.stream().collect(Collectors.toMap(BaseDepartmentVO::getId, Function.identity())); Map<Long, BaseDepartmentVO> collect = alldept.stream().collect(Collectors.toMap(BaseDepartmentVO::getId, Function.identity()));
List<BaseDepartmentVO> allParents=new ArrayList<>(); List<BaseDepartmentVO> allParents=new ArrayList<>();
for (BaseDepartmentVO data:dataResult){ for (BaseDepartmentVO data:dataResult){
allParents.addAll(getAllParents(data, collect)) ; allParents.addAll(getAllParents(data, collect)) ;
@ -48,7 +48,7 @@ public class AdminDepartmentService {
} }
public List<Integer> getAllChildIds(TBaseDepartment vo ,List<Integer> ids){ public List<Long> getAllChildIds(TBaseDepartment vo ,List<Long> ids){
List<BaseDepartmentVO> immediateChildren = findChildDepartmentsByParentId(vo.getId()); List<BaseDepartmentVO> immediateChildren = findChildDepartmentsByParentId(vo.getId());
ids.addAll(immediateChildren.stream().map(u->u.getId()).collect(Collectors.toSet())); ids.addAll(immediateChildren.stream().map(u->u.getId()).collect(Collectors.toSet()));
for (BaseDepartmentVO child : immediateChildren) { for (BaseDepartmentVO child : immediateChildren) {
@ -68,15 +68,15 @@ public class AdminDepartmentService {
} }
} }
private List<BaseDepartmentVO> findChildDepartmentsByParentId(int parentId) { private List<BaseDepartmentVO> findChildDepartmentsByParentId(Long parentId) {
List<TBaseDepartment> depts = departmentService.lambdaQuery().eq(TBaseDepartment::getDeptParentId, parentId).eq(TBaseDepartment::getDataValidStatus,1).list(); List<TBaseDepartment> depts = departmentService.lambdaQuery().eq(TBaseDepartment::getDeptParentId, parentId).eq(TBaseDepartment::getDataValidStatus,1).list();
return Convert.toList(BaseDepartmentVO.class,depts); return Convert.toList(BaseDepartmentVO.class,depts);
} }
private List<BaseDepartmentVO> getAllParents(BaseDepartmentVO node, Map<Integer, BaseDepartmentVO> idToNodeMap) { private List<BaseDepartmentVO> getAllParents(BaseDepartmentVO node, Map<Long, BaseDepartmentVO> idToNodeMap) {
List<BaseDepartmentVO> parents = new ArrayList<>(); List<BaseDepartmentVO> parents = new ArrayList<>();
Integer parentId = node.getDeptParentId(); Long parentId = node.getDeptParentId();
while (parentId != null && parentId>0) { while (parentId != null && parentId>0) {
BaseDepartmentVO parentNode = idToNodeMap.get(parentId); BaseDepartmentVO parentNode = idToNodeMap.get(parentId);
if (parentNode == null) break; // 防止数据不一致导致无限循环 if (parentNode == null) break; // 防止数据不一致导致无限循环
@ -94,7 +94,7 @@ public class AdminDepartmentService {
*/ */
private List<BaseDepartmentVO> buildTree(List<BaseDepartmentVO> nodes) { private List<BaseDepartmentVO> buildTree(List<BaseDepartmentVO> nodes) {
// 使用Map存储id到Node的映射便于快速查找父节点 // 使用Map存储id到Node的映射便于快速查找父节点
Map<Integer, BaseDepartmentVO> idToNodeMap = nodes.stream() Map<Long, BaseDepartmentVO> idToNodeMap = nodes.stream()
.collect(Collectors.toMap(BaseDepartmentVO::getId, Function.identity())); .collect(Collectors.toMap(BaseDepartmentVO::getId, Function.identity()));
List<BaseDepartmentVO> roots = new ArrayList<>(); List<BaseDepartmentVO> roots = new ArrayList<>();

View File

@ -10,7 +10,7 @@ import java.util.List;
public class DepartmentSimpleVO { public class DepartmentSimpleVO {
// 部门id // 部门id
private Integer id; private Long id;
//部门名称 //部门名称
private String name; private String name;

View File

@ -29,7 +29,7 @@ public class TBaseDepartment implements Serializable {
* id 自增id * id 自增id
*/ */
@TableId(value = "id", type = IdType.AUTO) @TableId(value = "id", type = IdType.AUTO)
private Integer id; private Long id;
/** /**
* 部门编码 * 部门编码
@ -44,7 +44,7 @@ public class TBaseDepartment implements Serializable {
/** /**
* 部门父类ID * 部门父类ID
*/ */
private Integer deptParentId; private Long deptParentId;
/** /**
* 状态 0-禁用 1-启用 * 状态 0-禁用 1-启用