104 lines
3.0 KiB
Java
104 lines
3.0 KiB
Java
package com.ruoyi.web.bst;
|
|
|
|
import com.ruoyi.bst.article.domain.Article;
|
|
import com.ruoyi.bst.article.domain.ArticleQuery;
|
|
import com.ruoyi.bst.article.domain.ArticleVO;
|
|
import com.ruoyi.bst.article.service.ArticleService;
|
|
import com.ruoyi.bst.article.service.ArticleService;
|
|
import com.ruoyi.common.annotation.Log;
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
import com.ruoyi.common.enums.BusinessType;
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* 文章Controller
|
|
*
|
|
* @author ruoyi
|
|
* @date 2025-03-27
|
|
*/
|
|
@RestController
|
|
@RequestMapping("/bst/article")
|
|
public class ArticleController extends BaseController
|
|
{
|
|
@Autowired
|
|
private ArticleService articleService;
|
|
|
|
/**
|
|
* 查询文章列表
|
|
*/
|
|
@PreAuthorize("@ss.hasPermi('bst:article:list')")
|
|
@GetMapping("/list")
|
|
public TableDataInfo list(ArticleQuery query)
|
|
{
|
|
startPage();
|
|
startOrderBy();
|
|
query.setScope(true);
|
|
List<ArticleVO> list = articleService.selectArticleList(query);
|
|
return getDataTable(list);
|
|
}
|
|
|
|
/**
|
|
* 导出文章列表
|
|
*/
|
|
@PreAuthorize("@ss.hasPermi('bst:article:export')")
|
|
@Log(title = "文章", businessType = BusinessType.EXPORT)
|
|
@PostMapping("/export")
|
|
public void export(HttpServletResponse response, ArticleQuery query)
|
|
{
|
|
List<ArticleVO> list = articleService.selectArticleList(query);
|
|
ExcelUtil<ArticleVO> util = new ExcelUtil<ArticleVO>(ArticleVO.class);
|
|
util.exportExcel(response, list, "文章数据");
|
|
}
|
|
|
|
/**
|
|
* 获取文章详细信息
|
|
*/
|
|
@PreAuthorize("@ss.hasPermi('bst:article:query')")
|
|
@GetMapping(value = "/{id}")
|
|
public AjaxResult getInfo(@PathVariable("id") Long id)
|
|
{
|
|
return success(articleService.selectArticleById(id));
|
|
}
|
|
|
|
/**
|
|
* 新增文章
|
|
*/
|
|
@PreAuthorize("@ss.hasPermi('bst:article:add')")
|
|
@Log(title = "文章", businessType = BusinessType.INSERT)
|
|
@PostMapping
|
|
public AjaxResult add(@RequestBody Article article)
|
|
{
|
|
return toAjax(articleService.insertArticle(article));
|
|
}
|
|
|
|
/**
|
|
* 修改文章
|
|
*/
|
|
@PreAuthorize("@ss.hasPermi('bst:article:edit')")
|
|
@Log(title = "文章", businessType = BusinessType.UPDATE)
|
|
@PutMapping
|
|
public AjaxResult edit(@RequestBody Article article)
|
|
{
|
|
return toAjax(articleService.updateArticle(article));
|
|
}
|
|
|
|
/**
|
|
* 删除文章
|
|
*/
|
|
@PreAuthorize("@ss.hasPermi('bst:article:remove')")
|
|
@Log(title = "文章", businessType = BusinessType.DELETE)
|
|
@DeleteMapping("/{ids}")
|
|
public AjaxResult remove(@PathVariable Long[] ids)
|
|
{
|
|
return toAjax(articleService.deleteArticleByIds(ids));
|
|
}
|
|
}
|