| | |
| | | package org.springblade.jfpt.article.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.core.mp.support.Condition; |
| | |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.jfpt.article.entity.Article; |
| | | import org.springblade.jfpt.article.service.ArticleService; |
| | | import org.springblade.jfpt.article.vo.ArticleVo; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.Valid; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @author zhongrj |
| | |
| | | * @return |
| | | */ |
| | | @GetMapping("/page") |
| | | public R<IPage<Article>> page(HttpServletResponse response, Article article, Query query){ |
| | | public R<IPage<Article>> page(HttpServletResponse response, ArticleVo article, Query query){ |
| | | response.setHeader("Access-Control-Allow-Origin", "*"); |
| | | response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); |
| | | response.setHeader("Access-Control-Allow-Credentials","true"); |
| | |
| | | * @param response |
| | | */ |
| | | @GetMapping("/detail") |
| | | @ApiOperationSupport(order = 1) |
| | | @ApiOperation(value = "详情", notes = "传入articleoy") |
| | | public R<Article> detail(Article article, HttpServletResponse response) { |
| | | response.setHeader("Access-Control-Allow-Origin", "*"); |
| | | response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); |
| | |
| | | * @param article 资讯对象 |
| | | */ |
| | | @PostMapping("/save") |
| | | @ApiOperationSupport(order = 4) |
| | | @ApiOperation(value = "新增", notes = "传入article") |
| | | public R save(@Valid Article article) { |
| | | return R.status(articleService.save(article)); |
| | | } |
| | |
| | | * @param article 资讯对象 |
| | | */ |
| | | @PostMapping("/update") |
| | | @ApiOperationSupport(order = 5) |
| | | @ApiOperation(value = "修改", notes = "传入article") |
| | | public R update(@Valid @RequestBody Article article) { |
| | | return R.status(articleService.updateById(article)); |
| | | } |
| | |
| | | * @param article 资讯对象信息 |
| | | */ |
| | | @PostMapping("/submit") |
| | | @ApiOperationSupport(order = 6) |
| | | @ApiOperation(value = "新增或修改", notes = "传入article") |
| | | public R submit(@Valid @RequestBody Article article) { |
| | | //创建时间 |
| | | if (null == article.getId()) { |
| | | article.setCreateTime(new Date()); |
| | | } |
| | | article.setUpdateTime(new Date()); |
| | | return R.status(articleService.saveOrUpdate(article)); |
| | | } |
| | | |
| | |
| | | * @param ids 资讯主键id,id集合 |
| | | */ |
| | | @PostMapping("/remove") |
| | | @ApiOperationSupport(order = 8) |
| | | @ApiOperation(value = "删除", notes = "传入ids") |
| | | public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
| | | return R.status(articleService.removeByIds(Func.toLongList(ids))); |
| | | } |