DeptController.java 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /**
  2. * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
  3. * <p>
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. * <p>
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. * <p>
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.springblade.modules.system.controller;
  17. import io.swagger.annotations.*;
  18. import lombok.AllArgsConstructor;
  19. import org.springblade.core.boot.ctrl.BladeController;
  20. import org.springblade.core.mp.support.Condition;
  21. import org.springblade.core.tool.api.R;
  22. import org.springblade.core.tool.node.INode;
  23. import org.springblade.core.tool.utils.Func;
  24. import org.springblade.modules.system.entity.Dept;
  25. import org.springblade.modules.system.service.IDeptService;
  26. import org.springblade.modules.system.vo.DeptVO;
  27. import org.springblade.modules.system.wrapper.DeptWrapper;
  28. import org.springframework.web.bind.annotation.*;
  29. import springfox.documentation.annotations.ApiIgnore;
  30. import javax.validation.Valid;
  31. import java.util.List;
  32. import java.util.Map;
  33. /**
  34. * 控制器
  35. *
  36. * @author Chill
  37. * @since 2018-12-24
  38. */
  39. @ApiIgnore
  40. @RestController
  41. @AllArgsConstructor
  42. @RequestMapping("/blade-system/dept")
  43. @Api(value = "部门", tags = "部门")
  44. public class DeptController extends BladeController {
  45. private IDeptService deptService;
  46. /**
  47. * 详情
  48. */
  49. @GetMapping("/detail")
  50. @ApiOperation(value = "详情", notes = "传入dept", position = 1)
  51. public R<DeptVO> detail(Dept dept) {
  52. Dept detail = deptService.getOne(Condition.getQueryWrapper(dept));
  53. DeptWrapper deptWrapper = new DeptWrapper(deptService);
  54. return R.data(deptWrapper.entityVO(detail));
  55. }
  56. /**
  57. * 列表
  58. */
  59. @GetMapping("/list")
  60. @ApiImplicitParams({
  61. @ApiImplicitParam(name = "deptName", value = "部门名称", paramType = "query", dataType = "string"),
  62. @ApiImplicitParam(name = "fullName", value = "部门全称", paramType = "query", dataType = "string")
  63. })
  64. @ApiOperation(value = "列表", notes = "传入dept", position = 2)
  65. public R<List<INode>> list(@ApiIgnore @RequestParam Map<String, Object> dept) {
  66. List<Dept> list = deptService.list(Condition.getQueryWrapper(dept, Dept.class));
  67. DeptWrapper deptWrapper = new DeptWrapper();
  68. return R.data(deptWrapper.listNodeVO(list));
  69. }
  70. /**
  71. * 获取部门树形结构
  72. *
  73. * @return
  74. */
  75. @GetMapping("/tree")
  76. @ApiOperation(value = "树形结构", notes = "树形结构", position = 3)
  77. public R<List<DeptVO>> tree() {
  78. List<DeptVO> tree = deptService.tree();
  79. return R.data(tree);
  80. }
  81. /**
  82. * 新增或修改
  83. */
  84. @PostMapping("/submit")
  85. @ApiOperation(value = "新增或修改", notes = "传入dept", position = 6)
  86. public R submit(@Valid @RequestBody Dept dept) {
  87. return R.status(deptService.saveOrUpdate(dept));
  88. }
  89. /**
  90. * 删除
  91. */
  92. @PostMapping("/remove")
  93. @ApiOperation(value = "物理删除", notes = "传入ids", position = 7)
  94. public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
  95. return R.status(deptService.removeByIds(Func.toIntList(ids)));
  96. }
  97. }