TmDepartmentController.java 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. package com.fdkankan.fusion.controller;
  2. import cn.hutool.core.util.ObjectUtil;
  3. import com.fdkankan.fusion.common.ResultCode;
  4. import com.fdkankan.fusion.common.ResultData;
  5. import com.fdkankan.fusion.entity.CaseEntity;
  6. import com.fdkankan.fusion.entity.TmDepartment;
  7. import com.fdkankan.fusion.entity.TmProject;
  8. import com.fdkankan.fusion.exception.BusinessException;
  9. import com.fdkankan.fusion.service.ICaseService;
  10. import com.fdkankan.fusion.service.ITmDepartmentService;
  11. import com.fdkankan.fusion.service.ITmProjectService;
  12. import org.apache.commons.lang3.StringUtils;
  13. import org.springframework.beans.factory.annotation.Autowired;
  14. import org.springframework.util.CollectionUtils;
  15. import org.springframework.validation.annotation.Validated;
  16. import org.springframework.web.bind.annotation.*;
  17. import java.util.ArrayList;
  18. import java.util.List;
  19. import java.util.stream.Collectors;
  20. /**
  21. * <p>
  22. * 前端控制器
  23. * </p>
  24. *
  25. * @author
  26. * @since 2023-07-27
  27. */
  28. @RestController
  29. @RequestMapping("/web/department")
  30. public class TmDepartmentController {
  31. @Autowired
  32. private ITmDepartmentService departmentService;
  33. @Autowired
  34. private ICaseService caseService;
  35. @Autowired
  36. ITmProjectService tmProjectService;
  37. /**
  38. * 根据部门编号获取详细信息
  39. */
  40. @GetMapping(value = "deptId/{deptId}")
  41. public ResultData getInfo(@PathVariable String deptId)
  42. {
  43. return ResultData.ok(departmentService.getById(deptId));
  44. }
  45. /**
  46. * 获取部门下拉树列表
  47. */
  48. @GetMapping("/treeselect")
  49. public ResultData treeselect(@RequestParam(required = false) String deptId) {
  50. if(StringUtils.isNotBlank(deptId)){
  51. return ResultData.ok(departmentService.getDeptList(deptId));
  52. }
  53. return ResultData.ok(departmentService.getDeptList());
  54. }
  55. /**
  56. * 新增部门
  57. */
  58. @PostMapping("/add")
  59. public ResultData add(@Validated @RequestBody TmDepartment dept) {
  60. departmentService.insertDept(dept);
  61. return ResultData.ok();
  62. }
  63. /**
  64. * 修改部门
  65. */
  66. @PostMapping("/edit")
  67. public ResultData edit(@Validated @RequestBody TmDepartment dept) {
  68. departmentService.updateDept(dept);
  69. return ResultData.ok();
  70. }
  71. /**
  72. * 删除部门
  73. */
  74. @PostMapping("/del/{deptId}")
  75. public ResultData remove(@PathVariable String deptId) {
  76. departmentService.deleteDeptById(deptId);
  77. return ResultData.ok();
  78. }
  79. }