SysDeptPostController.java 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. package com.willalp.web.controller.system;
  2. import com.willalp.common.annotation.Log;
  3. import com.willalp.common.core.controller.BaseController;
  4. import com.willalp.common.core.domain.AjaxResult;
  5. import com.willalp.common.enums.BusinessType;
  6. import com.willalp.common.utils.DateUtils;
  7. import com.willalp.common.utils.SecurityUtils;
  8. import com.willalp.common.utils.poi.ExcelUtil;
  9. import com.willalp.system.domain.SysDeptPost;
  10. import com.willalp.system.service.ISysDeptPostService;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.security.access.prepost.PreAuthorize;
  13. import org.springframework.web.bind.annotation.*;
  14. import java.util.List;
  15. /**
  16. * 岗位设置2Controller
  17. *
  18. * @author songyu
  19. * @date 2022-02-11
  20. */
  21. @RestController
  22. @RequestMapping("/system/deptPost")
  23. public class SysDeptPostController extends BaseController
  24. {
  25. @Autowired
  26. private ISysDeptPostService sysDeptPostService;
  27. /**
  28. * 查询岗位设置2列表
  29. */
  30. @PreAuthorize("@ss.hasPermi('system:deptPost:list')")
  31. @GetMapping("/list")
  32. public AjaxResult list(SysDeptPost sysDeptPost)
  33. {
  34. sysDeptPost.setParentId(null);
  35. List<SysDeptPost> list = sysDeptPostService.selectSysDeptPostList(sysDeptPost);
  36. return AjaxResult.success(list);
  37. }
  38. /**
  39. * 导出岗位设置2列表
  40. */
  41. @PreAuthorize("@ss.hasPermi('system:deptPost:export')")
  42. @Log(title = "岗位设置2", businessType = BusinessType.EXPORT)
  43. @GetMapping("/export")
  44. public AjaxResult export(SysDeptPost sysDeptPost)
  45. {
  46. List<SysDeptPost> list = sysDeptPostService.selectSysDeptPostList(sysDeptPost);
  47. ExcelUtil<SysDeptPost> util = new ExcelUtil<SysDeptPost>(SysDeptPost.class);
  48. return util.exportExcel(list, "岗位设置2数据");
  49. }
  50. /**
  51. * 获取岗位设置2详细信息
  52. */
  53. @PreAuthorize("@ss.hasPermi('system:deptPost:query')")
  54. @GetMapping(value = "/{postId}")
  55. public AjaxResult getInfo(@PathVariable("postId") String postId)
  56. {
  57. return AjaxResult.success(sysDeptPostService.getById(postId));
  58. }
  59. /**
  60. * 新增岗位设置2
  61. */
  62. @PreAuthorize("@ss.hasPermi('system:deptPost:add')")
  63. @Log(title = "岗位设置2", businessType = BusinessType.INSERT)
  64. @PostMapping
  65. public AjaxResult add(@RequestBody SysDeptPost sysDeptPost)
  66. {
  67. sysDeptPost.setCreateBy(SecurityUtils.getUsername());
  68. sysDeptPost.setCreateTime(DateUtils.getNowDate());
  69. if (sysDeptPost.getParentId() != null && sysDeptPost.getParentId() != 0) {
  70. SysDeptPost parent = sysDeptPostService.selectById(sysDeptPost.getParentId());
  71. sysDeptPost.setAncestors(parent.getAncestors() + "," + sysDeptPost.getParentId());
  72. } else {
  73. sysDeptPost.setParentId(null);
  74. sysDeptPost.setAncestors("0");
  75. }
  76. return toAjax(sysDeptPostService.save(sysDeptPost));
  77. }
  78. /**
  79. * 修改岗位设置2
  80. */
  81. @PreAuthorize("@ss.hasPermi('system:deptPost:edit')")
  82. @Log(title = "岗位设置2", businessType = BusinessType.UPDATE)
  83. @PutMapping
  84. public AjaxResult edit(@RequestBody SysDeptPost sysDeptPost)
  85. {
  86. sysDeptPost.setUpdateBy(SecurityUtils.getUsername());
  87. sysDeptPost.setUpdateTime(DateUtils.getNowDate());
  88. return toAjax(sysDeptPostService.updateSysDeptPost(sysDeptPost));
  89. }
  90. /**
  91. * 删除岗位设置2
  92. */
  93. @PreAuthorize("@ss.hasPermi('system:deptPost:remove')")
  94. @Log(title = "岗位设置2", businessType = BusinessType.DELETE)
  95. @DeleteMapping("/{postIds}")
  96. public AjaxResult remove(@PathVariable Long postIds)
  97. {
  98. return toAjax(sysDeptPostService.deleteSysDeptPostByPostId(postIds));
  99. }
  100. }