SysPostController.java 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. package com.ruoyi.web.controller.system;
  2. import java.util.List;
  3. import org.apache.shiro.authz.annotation.RequiresPermissions;
  4. import org.springframework.beans.factory.annotation.Autowired;
  5. import org.springframework.stereotype.Controller;
  6. import org.springframework.ui.ModelMap;
  7. import org.springframework.web.bind.annotation.GetMapping;
  8. import org.springframework.web.bind.annotation.PathVariable;
  9. import org.springframework.web.bind.annotation.PostMapping;
  10. import org.springframework.web.bind.annotation.RequestMapping;
  11. import org.springframework.web.bind.annotation.ResponseBody;
  12. import com.ruoyi.common.annotation.Log;
  13. import com.ruoyi.common.base.AjaxResult;
  14. import com.ruoyi.common.enums.BusinessType;
  15. import com.ruoyi.common.utils.ExcelUtil;
  16. import com.ruoyi.framework.util.ShiroUtils;
  17. import com.ruoyi.framework.web.page.TableDataInfo;
  18. import com.ruoyi.system.domain.SysPost;
  19. import com.ruoyi.system.service.ISysPostService;
  20. import com.ruoyi.framework.web.base.BaseController;
  21. /**
  22. * 岗位信息操作处理
  23. *
  24. * @author ruoyi
  25. */
  26. @Controller
  27. @RequestMapping("/system/post")
  28. public class SysPostController extends BaseController
  29. {
  30. private String prefix = "system/post";
  31. @Autowired
  32. private ISysPostService postService;
  33. @RequiresPermissions("system:post:view")
  34. @GetMapping()
  35. public String operlog()
  36. {
  37. return prefix + "/post";
  38. }
  39. @RequiresPermissions("system:post:list")
  40. @PostMapping("/list")
  41. @ResponseBody
  42. public TableDataInfo list(SysPost post)
  43. {
  44. startPage();
  45. List<SysPost> list = postService.selectPostList(post);
  46. return getDataTable(list);
  47. }
  48. @Log(title = "岗位管理", businessType = BusinessType.EXPORT)
  49. @RequiresPermissions("system:post:export")
  50. @PostMapping("/export")
  51. @ResponseBody
  52. public AjaxResult export(SysPost post)
  53. {
  54. List<SysPost> list = postService.selectPostList(post);
  55. ExcelUtil<SysPost> util = new ExcelUtil<SysPost>(SysPost.class);
  56. return util.exportExcel(list, "post");
  57. }
  58. @RequiresPermissions("system:post:remove")
  59. @Log(title = "岗位管理", businessType = BusinessType.DELETE)
  60. @PostMapping("/remove")
  61. @ResponseBody
  62. public AjaxResult remove(String ids)
  63. {
  64. try
  65. {
  66. return toAjax(postService.deletePostByIds(ids));
  67. }
  68. catch (Exception e)
  69. {
  70. return error(e.getMessage());
  71. }
  72. }
  73. /**
  74. * 新增岗位
  75. */
  76. @GetMapping("/add")
  77. public String add()
  78. {
  79. return prefix + "/add";
  80. }
  81. /**
  82. * 新增保存岗位
  83. */
  84. @RequiresPermissions("system:post:add")
  85. @Log(title = "岗位管理", businessType = BusinessType.INSERT)
  86. @PostMapping("/add")
  87. @ResponseBody
  88. public AjaxResult addSave(SysPost post)
  89. {
  90. post.setCreateBy(ShiroUtils.getLoginName());
  91. return toAjax(postService.insertPost(post));
  92. }
  93. /**
  94. * 修改岗位
  95. */
  96. @GetMapping("/edit/{postId}")
  97. public String edit(@PathVariable("postId") Long postId, ModelMap mmap)
  98. {
  99. mmap.put("post", postService.selectPostById(postId));
  100. return prefix + "/edit";
  101. }
  102. /**
  103. * 修改保存岗位
  104. */
  105. @RequiresPermissions("system:post:edit")
  106. @Log(title = "岗位管理", businessType = BusinessType.UPDATE)
  107. @PostMapping("/edit")
  108. @ResponseBody
  109. public AjaxResult editSave(SysPost post)
  110. {
  111. post.setUpdateBy(ShiroUtils.getLoginName());
  112. return toAjax(postService.updatePost(post));
  113. }
  114. /**
  115. * 校验岗位名称
  116. */
  117. @PostMapping("/checkPostNameUnique")
  118. @ResponseBody
  119. public String checkPostNameUnique(SysPost post)
  120. {
  121. return postService.checkPostNameUnique(post);
  122. }
  123. /**
  124. * 校验岗位编码
  125. */
  126. @PostMapping("/checkPostCodeUnique")
  127. @ResponseBody
  128. public String checkPostCodeUnique(SysPost post)
  129. {
  130. return postService.checkPostCodeUnique(post);
  131. }
  132. }