From ea4884b44a6b44c8c4a2948fc643bdea6656a210 Mon Sep 17 00:00:00 2001 From: lidongdong <1459917685@qq.com> Date: 星期日, 09 十月 2022 16:16:16 +0800 Subject: [PATCH] 修改登录测试 --- flower_city/src/main/java/com/dg/core/controller/OrganizationController.java | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 51 insertions(+), 3 deletions(-) diff --git a/flower_city/src/main/java/com/dg/core/controller/OrganizationController.java b/flower_city/src/main/java/com/dg/core/controller/OrganizationController.java index a5b5346..c8229b2 100644 --- a/flower_city/src/main/java/com/dg/core/controller/OrganizationController.java +++ b/flower_city/src/main/java/com/dg/core/controller/OrganizationController.java @@ -1,11 +1,9 @@ package com.dg.core.controller; -import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.dg.core.ResultData; import com.dg.core.annotation.Authorization; import com.dg.core.annotation.CurrentUser; -import com.dg.core.db.gen.entity.ClassifyAdministration; import com.dg.core.db.gen.entity.OrganizationChartEntity; import com.dg.core.db.gen.entity.SysUser; import com.dg.core.service.IOrganizationChartService; @@ -18,6 +16,7 @@ import org.springframework.web.bind.annotation.*; import java.time.LocalDateTime; +import java.util.ArrayList; import java.util.List; @@ -85,10 +84,16 @@ */ @ApiOperation("删除机构") @DeleteMapping("/delete") - @Authorization +// @Authorization public ResultData deleteConfigById(@RequestParam(value = "Id",required = false) String Id) { Assert.notNull(Id, "Id 不能为空"); + List<OrganizationChartEntity> list=iOrganizationChartService.selectParentList(Id,""); + + if(list!=null && list.size()>0) + { + return ResultData.error("该机构下存在其他部门!请先删除子部门"); + } return toAjax(iOrganizationChartService.deleteConfigById(Id)); } @@ -127,4 +132,47 @@ } + /** + * 通过父级id查询对应机构下的全部部门id + * @param departmentId + * @return + */ + @ApiOperation(value = "通过父级id查询对应机构下的全部部门",response = OrganizationChartEntity.class) + @GetMapping("/getdepartment") + public TableDataInfo getOrganizations(@RequestParam(value = "department",required = false) String departmentId) + { + List<OrganizationChartEntity> ids=new ArrayList<>(); + List<OrganizationChartEntity> lists = iOrganizationChartService.selectParentList(departmentId,""); + if(lists.size()<1) + { + lists.add(iOrganizationChartService.selectConfigById(departmentId)); + } + ids=disposestreet(lists); + if(ids.size()<1) + { + return null; + } + ids.add(iOrganizationChartService.selectConfigById(departmentId)); + return getDataTable(ids); + } + + //递归取id + private List<OrganizationChartEntity> disposestreet(List<OrganizationChartEntity> lists) + { + List<OrganizationChartEntity> ids=new ArrayList<>(); + for (OrganizationChartEntity sysStreet:lists) + { + ids.add(sysStreet); + if(sysStreet.getChild()!=null && sysStreet.getChild().size()>0) + { + ids.addAll(disposestreet(sysStreet.getChild())); + } + else + { + ids.add(sysStreet); + } + } + return ids; + } + } -- Gitblit v1.7.1