SysNoticeController.java 3.0 KB

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