SysNoticeController.java 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. package com.ruoyi.project.system.controller;
  2. import java.util.List;
  3. import org.springframework.beans.factory.annotation.Autowired;
  4. import org.springframework.security.access.prepost.PreAuthorize;
  5. import org.springframework.validation.annotation.Validated;
  6. import org.springframework.web.bind.annotation.DeleteMapping;
  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.PutMapping;
  11. import org.springframework.web.bind.annotation.RequestBody;
  12. import org.springframework.web.bind.annotation.RequestMapping;
  13. import org.springframework.web.bind.annotation.RestController;
  14. import com.ruoyi.common.utils.SecurityUtils;
  15. import com.ruoyi.framework.aspectj.lang.annotation.Log;
  16. import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
  17. import com.ruoyi.framework.web.controller.BaseController;
  18. import com.ruoyi.framework.web.domain.AjaxResult;
  19. import com.ruoyi.framework.web.page.TableDataInfo;
  20. import com.ruoyi.project.system.domain.SysNotice;
  21. import com.ruoyi.project.system.service.ISysNoticeService;
  22. /**
  23. * 公告 信息操作处理
  24. *
  25. * @author ruoyi
  26. */
  27. @RestController
  28. @RequestMapping("/system/notice")
  29. public class SysNoticeController extends BaseController
  30. {
  31. @Autowired
  32. private ISysNoticeService noticeService;
  33. /**
  34. * 获取通知公告列表
  35. */
  36. @PreAuthorize("@ss.hasPermi('system:notice:list')")
  37. @GetMapping("/list")
  38. public TableDataInfo list(SysNotice notice)
  39. {
  40. notice.setUserId(getUserId());
  41. startPage();
  42. List<SysNotice> list = noticeService.selectNoticeList(notice);
  43. return getDataTable(list);
  44. }
  45. /**
  46. * 获取通知公告列表
  47. */
  48. @PreAuthorize("@ss.hasPermi('system:notice:list')")
  49. @GetMapping("/unList")
  50. public List<SysNotice> unlist(SysNotice notice)
  51. {
  52. notice.setUserId(getUserId());
  53. List<SysNotice> list = noticeService.selectNoticeUnList(notice);
  54. return list;
  55. }
  56. /**
  57. * 根据通知公告编号获取详细信息
  58. */
  59. @PreAuthorize("@ss.hasPermi('system:notice:query')")
  60. @GetMapping(value = "/{noticeId}")
  61. public AjaxResult getInfo(@PathVariable Long noticeId)
  62. {
  63. return AjaxResult.success(noticeService.selectNoticeById(noticeId));
  64. }
  65. /**
  66. * 新增通知公告
  67. */
  68. @PreAuthorize("@ss.hasPermi('system:notice:add')")
  69. @Log(title = "通知公告", businessType = BusinessType.INSERT)
  70. @PostMapping
  71. public AjaxResult add(@Validated @RequestBody SysNotice notice)
  72. {
  73. notice.setCreateBy(SecurityUtils.getUsername());
  74. return toAjax(noticeService.insertNotice(notice));
  75. }
  76. /**
  77. * 修改通知公告
  78. */
  79. @PreAuthorize("@ss.hasPermi('system:notice:edit')")
  80. @Log(title = "通知公告", businessType = BusinessType.UPDATE)
  81. @PutMapping
  82. public AjaxResult edit(@Validated @RequestBody SysNotice notice)
  83. {
  84. notice.setUpdateBy(SecurityUtils.getUsername());
  85. return toAjax(noticeService.updateNotice(notice));
  86. }
  87. /**
  88. * 删除通知公告
  89. */
  90. @PreAuthorize("@ss.hasPermi('system:notice:remove')")
  91. @Log(title = "通知公告", businessType = BusinessType.DELETE)
  92. @DeleteMapping("/{noticeIds}")
  93. public AjaxResult remove(@PathVariable Long[] noticeIds)
  94. {
  95. return toAjax(noticeService.deleteNoticeByIds(noticeIds));
  96. }
  97. }