CompanyDeptController.java 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. package com.fs.company.controller;
  2. import java.util.List;
  3. import com.fs.common.utils.ServletUtils;
  4. import com.fs.core.security.LoginUser;
  5. import org.springframework.security.access.prepost.PreAuthorize;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.web.bind.annotation.GetMapping;
  8. import org.springframework.web.bind.annotation.PostMapping;
  9. import org.springframework.web.bind.annotation.PutMapping;
  10. import org.springframework.web.bind.annotation.DeleteMapping;
  11. import org.springframework.web.bind.annotation.PathVariable;
  12. import org.springframework.web.bind.annotation.RequestBody;
  13. import org.springframework.web.bind.annotation.RequestMapping;
  14. import org.springframework.web.bind.annotation.RestController;
  15. import com.fs.common.annotation.Log;
  16. import com.fs.common.core.controller.BaseController;
  17. import com.fs.common.core.domain.AjaxResult;
  18. import com.fs.common.enums.BusinessType;
  19. import com.fs.company.domain.CompanyDept;
  20. import com.fs.company.service.ICompanyDeptService;
  21. import com.fs.common.utils.poi.ExcelUtil;
  22. import com.fs.common.core.page.TableDataInfo;
  23. @RestController
  24. @RequestMapping("/company/companyDept")
  25. public class CompanyDeptController extends BaseController
  26. {
  27. @Autowired
  28. private ICompanyDeptService companyDeptService;
  29. /**
  30. * 查询部门列表
  31. */
  32. @PreAuthorize("@ss.hasPermi('company:companyDept:list')")
  33. @GetMapping("/list")
  34. public TableDataInfo list(CompanyDept companyDept)
  35. {
  36. startPage();
  37. List<CompanyDept> list = companyDeptService.selectCompanyDeptList(companyDept);
  38. return getDataTable(list);
  39. }
  40. /**
  41. * 导出部门列表
  42. */
  43. @PreAuthorize("@ss.hasPermi('company:companyDept:export')")
  44. @Log(title = "部门", businessType = BusinessType.EXPORT)
  45. @GetMapping("/export")
  46. public AjaxResult export(CompanyDept companyDept)
  47. {
  48. List<CompanyDept> list = companyDeptService.selectCompanyDeptList(companyDept);
  49. ExcelUtil<CompanyDept> util = new ExcelUtil<CompanyDept>(CompanyDept.class);
  50. return util.exportExcel(list, "companyDept");
  51. }
  52. /**
  53. * 获取部门详细信息
  54. */
  55. @PreAuthorize("@ss.hasPermi('company:companyDept:query')")
  56. @GetMapping(value = "/{deptId}")
  57. public AjaxResult getInfo(@PathVariable("deptId") Long deptId)
  58. {
  59. return AjaxResult.success(companyDeptService.selectCompanyDeptById(deptId));
  60. }
  61. /**
  62. * 新增部门
  63. */
  64. @PreAuthorize("@ss.hasPermi('company:companyDept:add')")
  65. @Log(title = "部门", businessType = BusinessType.INSERT)
  66. @PostMapping
  67. public AjaxResult add(@RequestBody CompanyDept companyDept)
  68. {
  69. return toAjax(companyDeptService.insertCompanyDept(companyDept));
  70. }
  71. /**
  72. * 修改部门
  73. */
  74. @PreAuthorize("@ss.hasPermi('company:companyDept:edit')")
  75. @Log(title = "部门", businessType = BusinessType.UPDATE)
  76. @PutMapping
  77. public AjaxResult edit(@RequestBody CompanyDept companyDept)
  78. {
  79. return toAjax(companyDeptService.updateCompanyDept(companyDept));
  80. }
  81. /**
  82. * 删除部门
  83. */
  84. @PreAuthorize("@ss.hasPermi('company:companyDept:remove')")
  85. @Log(title = "部门", businessType = BusinessType.DELETE)
  86. @DeleteMapping("/{deptIds}")
  87. public AjaxResult remove(@PathVariable Long[] deptIds)
  88. {
  89. return toAjax(companyDeptService.deleteCompanyDeptByIds(deptIds));
  90. }
  91. /**
  92. * 获取部门下拉树列表
  93. */
  94. @GetMapping("/treeselect")
  95. public AjaxResult treeselect(CompanyDept dept)
  96. {
  97. dept.setStatus("0");
  98. List<CompanyDept> depts = companyDeptService.selectCompanyDeptList(dept);
  99. return AjaxResult.success(companyDeptService.buildDeptTreeSelect(depts));
  100. }
  101. }