123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- 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<NewsInfo> 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<NewsInfo> list = newsInfoService.selectNewsInfoList(newsInfo);
- ExcelUtil<NewsInfo> util = new ExcelUtil<NewsInfo>(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));
- }
- }
|