PoNoticeController.java 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. package com.ruoyi.web.controller.system;
  2. import com.ruoyi.common.annotation.Log;
  3. import com.ruoyi.common.core.controller.BaseController;
  4. import com.ruoyi.common.core.domain.AjaxResult;
  5. import com.ruoyi.common.core.page.TableDataInfo;
  6. import com.ruoyi.common.enums.BusinessType;
  7. import com.ruoyi.common.utils.poi.ExcelUtil;
  8. import com.ruoyi.system.domain.PoNotice;
  9. import com.ruoyi.system.service.IPoNoticeService;
  10. import io.swagger.annotations.ApiOperation;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.security.access.prepost.PreAuthorize;
  13. import org.springframework.validation.annotation.Validated;
  14. import org.springframework.web.bind.annotation.*;
  15. import java.util.List;
  16. /**
  17. * 公告 信息操作处理
  18. *
  19. * @author ruoyi
  20. */
  21. @RestController
  22. @RequestMapping("/system/poNotice")
  23. public class PoNoticeController extends BaseController {
  24. @Autowired
  25. private IPoNoticeService poNoticeService;
  26. /**
  27. * 获取通知公告列表
  28. */
  29. @PreAuthorize("@ss.hasPermi('system:notice:list')")
  30. @GetMapping("/list")
  31. @ApiOperation("通知公告获取列表, 搜索")
  32. public TableDataInfo list(PoNotice poNotice) {
  33. startPage();
  34. List<PoNotice> list = poNoticeService.selectPoNoticeList(poNotice);
  35. return getDataTable(list);
  36. }
  37. /**
  38. * 导出通知公告列表
  39. */
  40. @PreAuthorize("@ss.hasPermi('system:notice:list')")
  41. @GetMapping("/export")
  42. @ApiOperation("导出通知公告")
  43. public AjaxResult export(PoNotice poNotice) {
  44. List<PoNotice> list = poNoticeService.selectPoNoticeList(poNotice);
  45. ExcelUtil<PoNotice> util = new ExcelUtil<>(PoNotice.class);
  46. return util.exportExcel(list, "通知公告列表");
  47. }
  48. /**
  49. * 根据通知公告编号获取详细信息
  50. */
  51. @PreAuthorize("@ss.hasPermi('system:notice:query')")
  52. @GetMapping(value = "/{poNoticeId}")
  53. @ApiOperation("获取通知公告详情")
  54. public AjaxResult getInfo(@PathVariable("poNoticeId") Long poNoticeId) {
  55. return success(poNoticeService.selectPoNoticeById(poNoticeId));
  56. }
  57. /**
  58. * 新增通知公告
  59. */
  60. @PreAuthorize("@ss.hasPermi('system:notice:add')")
  61. @Log(title = "通知公告", businessType = BusinessType.INSERT)
  62. @ApiOperation("添加通知公告")
  63. @PostMapping
  64. public AjaxResult add(@Validated @RequestBody PoNotice poNotice) {
  65. List<PoNotice> poNoticeList = poNoticeService.selectPoNoticeList(poNotice);
  66. if (poNoticeList == null || poNoticeList.isEmpty())
  67. return toAjax(poNoticeService.insertPoNotice(poNotice));
  68. return error("重复的公告");
  69. }
  70. /**
  71. * 修改通知公告
  72. */
  73. @PreAuthorize("@ss.hasPermi('system:notice:edit')")
  74. @Log(title = "通知公告", businessType = BusinessType.UPDATE)
  75. @ApiOperation("编辑通知公告")
  76. @PutMapping
  77. public AjaxResult edit(@Validated @RequestBody PoNotice poNotice) {
  78. List<PoNotice> poNotice1 = poNoticeService.selectPoNoticeList(poNotice);
  79. if (poNotice1 == null || poNotice1.isEmpty())
  80. return error("要修改的公告不存在");
  81. poNotice.setUpdateBy(getUsername());
  82. poNotice.setPublisherId(getUserId());
  83. return toAjax(poNoticeService.updatePoNotice(poNotice));
  84. }
  85. /**
  86. * 删除通知公告
  87. */
  88. @PreAuthorize("@ss.hasPermi('system:notice:remove')")
  89. @Log(title = "通知公告", businessType = BusinessType.DELETE)
  90. @ApiOperation("删除通知公告")
  91. @DeleteMapping("/{poNoticeIds}")
  92. public AjaxResult remove(@PathVariable Long[] poNoticeIds) {
  93. return toAjax(poNoticeService.deletePoNoticeByIds(poNoticeIds));
  94. }
  95. }