SysNoticeController.java 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. package com.railway.web.controller.system;
  2. import com.railway.common.annotation.Log;
  3. import com.railway.common.core.controller.BaseController;
  4. import com.railway.common.core.domain.AjaxResult;
  5. import com.railway.common.core.page.TableDataInfo;
  6. import com.railway.common.enums.BusinessType;
  7. import com.railway.system.domain.SysNotice;
  8. import com.railway.system.service.ISysNoticeService;
  9. import io.swagger.annotations.Api;
  10. import java.util.List;
  11. import org.springframework.security.access.prepost.PreAuthorize;
  12. import org.springframework.validation.annotation.Validated;
  13. import org.springframework.web.bind.annotation.DeleteMapping;
  14. import org.springframework.web.bind.annotation.GetMapping;
  15. import org.springframework.web.bind.annotation.PathVariable;
  16. import org.springframework.web.bind.annotation.PostMapping;
  17. import org.springframework.web.bind.annotation.PutMapping;
  18. import org.springframework.web.bind.annotation.RequestBody;
  19. import org.springframework.web.bind.annotation.RequestMapping;
  20. import org.springframework.web.bind.annotation.RestController;
  21. /**
  22. * 公告 信息操作处理
  23. *
  24. * @author railway
  25. */
  26. @Api(tags = "公告")
  27. @RestController
  28. @RequestMapping("/system/notice")
  29. public class SysNoticeController extends BaseController {
  30. private final ISysNoticeService noticeService;
  31. public SysNoticeController(ISysNoticeService noticeService) {
  32. this.noticeService = noticeService;
  33. }
  34. /**
  35. * 获取通知公告列表
  36. */
  37. @PreAuthorize("@ss.hasPermi('system:notice:list')")
  38. @GetMapping("/list")
  39. public TableDataInfo list(SysNotice notice) {
  40. startPage();
  41. List<SysNotice> list = noticeService.selectNoticeList(notice);
  42. return getDataTable(list);
  43. }
  44. /**
  45. * 根据通知公告编号获取详细信息
  46. */
  47. @PreAuthorize("@ss.hasPermi('system:notice:query')")
  48. @GetMapping(value = "/{noticeId}")
  49. public AjaxResult getInfo(@PathVariable Long noticeId) {
  50. return AjaxResult.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. notice.setCreateBy(getUsername());
  60. return toAjax(noticeService.insertNotice(notice));
  61. }
  62. /**
  63. * 修改通知公告
  64. */
  65. @PreAuthorize("@ss.hasPermi('system:notice:edit')")
  66. @Log(title = "通知公告", businessType = BusinessType.UPDATE)
  67. @PutMapping
  68. public AjaxResult edit(@Validated @RequestBody SysNotice notice) {
  69. notice.setUpdateBy(getUsername());
  70. return toAjax(noticeService.updateNotice(notice));
  71. }
  72. /**
  73. * 删除通知公告
  74. */
  75. @PreAuthorize("@ss.hasPermi('system:notice:remove')")
  76. @Log(title = "通知公告", businessType = BusinessType.DELETE)
  77. @DeleteMapping("/{noticeIds}")
  78. public AjaxResult remove(@PathVariable Long[] noticeIds) {
  79. return toAjax(noticeService.deleteNoticeByIds(noticeIds));
  80. }
  81. }