package com.ruoyi.system.controller; import java.util.List; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.system.domain.NewsInfo; import com.ruoyi.system.service.INewsInfoService; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.core.page.TableDataInfo; /** * 文章管理Controller * * @author ruoyi * @date 2021-12-28 */ @Controller @RequestMapping("/system/info") public class NewsInfoController extends BaseController { private String prefix = "system/info"; @Autowired private INewsInfoService newsInfoService; @RequiresPermissions("system:info:view") @GetMapping() public String info() { return prefix + "/info"; } /** * 查询文章管理列表 */ @RequiresPermissions("system:info:list") @PostMapping("/list") @ResponseBody public TableDataInfo list(NewsInfo newsInfo) { startPage(); List list = newsInfoService.selectNewsInfoList(newsInfo); return getDataTable(list); } /** * 导出文章管理列表 */ @RequiresPermissions("system:info:export") @Log(title = "文章管理", businessType = BusinessType.EXPORT) @PostMapping("/export") @ResponseBody public AjaxResult export(NewsInfo newsInfo) { List list = newsInfoService.selectNewsInfoList(newsInfo); ExcelUtil util = new ExcelUtil(NewsInfo.class); return util.exportExcel(list, "文章管理数据"); } /** * 新增文章管理 */ @GetMapping("/add") public String add() { return prefix + "/add"; } /** * 新增保存文章管理 */ @RequiresPermissions("system:info:add") @Log(title = "文章管理", businessType = BusinessType.INSERT) @PostMapping("/add") @ResponseBody public AjaxResult addSave(NewsInfo newsInfo) { return toAjax(newsInfoService.insertNewsInfo(newsInfo)); } /** * 修改文章管理 */ @RequiresPermissions("system:info:edit") @GetMapping("/edit/{newsInfoId}") public String edit(@PathVariable("newsInfoId") Long newsInfoId, ModelMap mmap) { NewsInfo newsInfo = newsInfoService.selectNewsInfoByNewsInfoId(newsInfoId); mmap.put("newsInfo", newsInfo); return prefix + "/edit"; } /** * 修改保存文章管理 */ @RequiresPermissions("system:info:edit") @Log(title = "文章管理", businessType = BusinessType.UPDATE) @PostMapping("/edit") @ResponseBody public AjaxResult editSave(NewsInfo newsInfo) { return toAjax(newsInfoService.updateNewsInfo(newsInfo)); } /** * 删除文章管理 */ @RequiresPermissions("system:info:remove") @Log(title = "文章管理", businessType = BusinessType.DELETE) @PostMapping( "/remove") @ResponseBody public AjaxResult remove(String ids) { return toAjax(newsInfoService.deleteNewsInfoByNewsInfoIds(ids)); } }