From 95dc030ad8e77303207a1a42a3afd9a7a6612d75 Mon Sep 17 00:00:00 2001 From: xin <1099200748@qq.com> Date: Tue, 03 Jun 2025 18:43:34 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' into xin --- oying-system/src/main/java/com/oying/modules/system/rest/DeptController.java | 36 +++++++++++++++++++----------------- 1 files changed, 19 insertions(+), 17 deletions(-) diff --git a/oying-system/src/main/java/com/oying/modules/system/rest/DeptController.java b/oying-system/src/main/java/com/oying/modules/system/rest/DeptController.java index 3245954..68314fd 100644 --- a/oying-system/src/main/java/com/oying/modules/system/rest/DeptController.java +++ b/oying-system/src/main/java/com/oying/modules/system/rest/DeptController.java @@ -3,6 +3,7 @@ import cn.hutool.core.collection.CollectionUtil; import com.oying.modules.system.domain.Dept; import com.oying.modules.system.domain.dto.DeptQueryCriteria; +import com.oying.utils.R; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; @@ -16,14 +17,15 @@ import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; + import javax.servlet.http.HttpServletResponse; import java.util.*; import java.util.stream.Collectors; /** -* @author Z -* @date 2019-03-25 -*/ + * @author Z + * @date 2019-03-25 + */ @RestController @RequiredArgsConstructor @Api(tags = "系统:机构管理") @@ -43,22 +45,22 @@ @ApiOperation("查询机构") @GetMapping @PreAuthorize("@el.check('user:list','dept:list')") - public ResponseEntity<PageResult<Dept>> queryDept(DeptQueryCriteria criteria) throws Exception { + public ResponseEntity<Object> queryDept(DeptQueryCriteria criteria) throws Exception { List<Dept> depts = deptService.queryAll(criteria, true); - return new ResponseEntity<>(PageUtil.toPage(depts),HttpStatus.OK); + return new ResponseEntity<>(R.success(PageUtil.toPage(depts)), HttpStatus.OK); } @ApiOperation("查询机构:根据ID获取同级与上级数据") @PostMapping("/superior") @PreAuthorize("@el.check('user:list','dept:list')") public ResponseEntity<Object> getDeptSuperior(@RequestBody List<Long> ids, @RequestParam(defaultValue = "false") Boolean exclude) { - Set<Dept> deptSet = new LinkedHashSet<>(); + Set<Dept> deptSet = new LinkedHashSet<>(); for (Long id : ids) { Dept dept = deptService.findById(id); List<Dept> depts = deptService.getSuperior(dept, new ArrayList<>()); - if(exclude){ + if (exclude) { for (Dept data : depts) { - if(data.getId().equals(dept.getPid())) { + if (data.getId().equals(dept.getPid())) { data.setSubCount(data.getSubCount() - 1); } } @@ -67,46 +69,46 @@ } deptSet.addAll(depts); } - return new ResponseEntity<>(deptService.buildTree(new ArrayList<>(deptSet)),HttpStatus.OK); + return new ResponseEntity<>(R.success(deptService.buildTree(new ArrayList<>(deptSet))), HttpStatus.OK); } @Log("新增机构") @ApiOperation("新增机构") @PostMapping @PreAuthorize("@el.check('dept:add')") - public ResponseEntity<Object> createDept(@Validated @RequestBody Dept resources){ + public ResponseEntity<Object> createDept(@Validated @RequestBody Dept resources) { if (resources.getId() != null) { - throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID"); + throw new BadRequestException("A new " + ENTITY_NAME + " cannot already have an ID"); } deptService.create(resources); - return new ResponseEntity<>(HttpStatus.CREATED); + return new ResponseEntity<>(R.success(), HttpStatus.CREATED); } @Log("修改机构") @ApiOperation("修改机构") @PutMapping @PreAuthorize("@el.check('dept:edit')") - public ResponseEntity<Object> updateDept(@Validated(Dept.Update.class) @RequestBody Dept resources){ + public ResponseEntity<Object> updateDept(@Validated(Dept.Update.class) @RequestBody Dept resources) { deptService.update(resources); - return new ResponseEntity<>(HttpStatus.NO_CONTENT); + return new ResponseEntity<>(R.success(), HttpStatus.NO_CONTENT); } @Log("删除机构") @ApiOperation("删除机构") @DeleteMapping @PreAuthorize("@el.check('dept:del')") - public ResponseEntity<Object> deleteDept(@RequestBody Set<Long> ids){ + public ResponseEntity<Object> deleteDept(@RequestBody Set<Long> ids) { Set<Dept> depts = new HashSet<>(); for (Long id : ids) { List<Dept> deptList = deptService.findByPid(id); depts.add(deptService.findById(id)); - if(CollectionUtil.isNotEmpty(deptList)){ + if (CollectionUtil.isNotEmpty(deptList)) { depts = deptService.getDeleteDepts(deptList, depts); } } // 验证是否被角色或用户关联 deptService.verification(depts); deptService.delete(depts); - return new ResponseEntity<>(HttpStatus.OK); + return new ResponseEntity<>(R.success(),HttpStatus.OK); } } -- Gitblit v1.9.3