NewsInfoController.java 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. package com.ruoyi.system.controller;
  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.enums.BusinessType;
  14. import com.ruoyi.system.domain.NewsInfo;
  15. import com.ruoyi.system.service.INewsInfoService;
  16. import com.ruoyi.common.core.controller.BaseController;
  17. import com.ruoyi.common.core.domain.AjaxResult;
  18. import com.ruoyi.common.utils.poi.ExcelUtil;
  19. import com.ruoyi.common.core.page.TableDataInfo;
  20. /**
  21. * 文章管理Controller
  22. *
  23. * @author ruoyi
  24. * @date 2021-12-28
  25. */
  26. @Controller
  27. @RequestMapping("/system/info")
  28. public class NewsInfoController extends BaseController
  29. {
  30. private String prefix = "system/info";
  31. @Autowired
  32. private INewsInfoService newsInfoService;
  33. @RequiresPermissions("system:info:view")
  34. @GetMapping()
  35. public String info()
  36. {
  37. return prefix + "/info";
  38. }
  39. /**
  40. * 查询文章管理列表
  41. */
  42. @RequiresPermissions("system:info:list")
  43. @PostMapping("/list")
  44. @ResponseBody
  45. public TableDataInfo list(NewsInfo newsInfo)
  46. {
  47. startPage();
  48. List<NewsInfo> list = newsInfoService.selectNewsInfoList(newsInfo);
  49. return getDataTable(list);
  50. }
  51. /**
  52. * 导出文章管理列表
  53. */
  54. @RequiresPermissions("system:info:export")
  55. @Log(title = "文章管理", businessType = BusinessType.EXPORT)
  56. @PostMapping("/export")
  57. @ResponseBody
  58. public AjaxResult export(NewsInfo newsInfo)
  59. {
  60. List<NewsInfo> list = newsInfoService.selectNewsInfoList(newsInfo);
  61. ExcelUtil<NewsInfo> util = new ExcelUtil<NewsInfo>(NewsInfo.class);
  62. return util.exportExcel(list, "文章管理数据");
  63. }
  64. /**
  65. * 新增文章管理
  66. */
  67. @GetMapping("/add")
  68. public String add()
  69. {
  70. return prefix + "/add";
  71. }
  72. /**
  73. * 新增保存文章管理
  74. */
  75. @RequiresPermissions("system:info:add")
  76. @Log(title = "文章管理", businessType = BusinessType.INSERT)
  77. @PostMapping("/add")
  78. @ResponseBody
  79. public AjaxResult addSave(NewsInfo newsInfo)
  80. {
  81. return toAjax(newsInfoService.insertNewsInfo(newsInfo));
  82. }
  83. /**
  84. * 修改文章管理
  85. */
  86. @RequiresPermissions("system:info:edit")
  87. @GetMapping("/edit/{newsInfoId}")
  88. public String edit(@PathVariable("newsInfoId") Long newsInfoId, ModelMap mmap)
  89. {
  90. NewsInfo newsInfo = newsInfoService.selectNewsInfoByNewsInfoId(newsInfoId);
  91. mmap.put("newsInfo", newsInfo);
  92. return prefix + "/edit";
  93. }
  94. /**
  95. * 修改保存文章管理
  96. */
  97. @RequiresPermissions("system:info:edit")
  98. @Log(title = "文章管理", businessType = BusinessType.UPDATE)
  99. @PostMapping("/edit")
  100. @ResponseBody
  101. public AjaxResult editSave(NewsInfo newsInfo)
  102. {
  103. return toAjax(newsInfoService.updateNewsInfo(newsInfo));
  104. }
  105. /**
  106. * 删除文章管理
  107. */
  108. @RequiresPermissions("system:info:remove")
  109. @Log(title = "文章管理", businessType = BusinessType.DELETE)
  110. @PostMapping( "/remove")
  111. @ResponseBody
  112. public AjaxResult remove(String ids)
  113. {
  114. return toAjax(newsInfoService.deleteNewsInfoByNewsInfoIds(ids));
  115. }
  116. }