| | |
| | | import org.springblade.modules.article.entity.Article; |
| | | import org.springblade.modules.article.service.ArticleService; |
| | | import org.springblade.modules.article.vo.ArticleVo; |
| | | import org.springblade.modules.words.DemoApplication; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.Valid; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @author zhongrj |
| | |
| | | response.setHeader("Access-Control-Allow-Credentials","true"); |
| | | return R.data(articleService.selectArticlePage(Condition.getPage(query),article)); |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * 查询资讯分页信息(角色权限) |
| | | * @param response |
| | | * @param article 资讯对象 |
| | | * @param query 查询参数 |
| | | * @return |
| | | */ |
| | | @GetMapping("/pageDate") |
| | | public R<IPage<Article>> pageDate(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"); |
| | | return R.data(articleService.pageDate(Condition.getPage(query),article)); |
| | | } |
| | | |
| | | @GetMapping("/pageCollectList") |
| | | public R<IPage<Article>> pageCollectList(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"); |
| | | return R.data(articleService.pageCollectList(Condition.getPage(query),article)); |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * 查询资讯分页信息(角色权限)附带点赞评论数 |
| | | * @param response |
| | | * @param article 资讯对象 |
| | | * @param query 查询参数 |
| | | * @return |
| | | */ |
| | | @GetMapping("/pageLikes") |
| | | public R<IPage<Article>> pageLikes(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"); |
| | | return R.data(articleService.pageLikes(Condition.getPage(query),article)); |
| | | } |
| | | |
| | | /** |
| | | * 查询已收藏的资讯 |
| | | */ |
| | | @GetMapping("/pageCollect") |
| | | public R<IPage<Article>> pageCollect(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"); |
| | | return R.data(articleService.pageCollect(Condition.getPage(query),article)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 资讯详情 |
| | |
| | | @ApiOperationSupport(order = 6) |
| | | @ApiOperation(value = "新增或修改", notes = "传入article") |
| | | public R submit(@Valid @RequestBody Article article) { |
| | | if (null==article.getId()){ |
| | | if (null==article.getCreateTime()){ |
| | | article.setCreateTime(new Date()); |
| | | } |
| | | } |
| | | |
| | | if (article.getContent() != null && article.getContent() != ""){ |
| | | String content = ""; |
| | | content = DemoApplication.interceptWords(article.getContent()); |
| | | article.setContent(content); |
| | | } |
| | | article.setUpdateTime(new Date()); |
| | | return R.status(articleService.saveOrUpdate(article)); |
| | | } |
| | | |
| | |
| | | public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
| | | return R.status(articleService.removeByIds(Func.toLongList(ids))); |
| | | } |
| | | |
| | | /** |
| | | * 批量修改评论区状态 |
| | | */ |
| | | @PostMapping("/upcomment") |
| | | public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids,String type) { |
| | | String[] split = ids.split(","); |
| | | String strArrays = ""; |
| | | for (int i = 0; i < split.length; i++) { |
| | | strArrays += "'" + split[i] + "',"; |
| | | } |
| | | String code = strArrays.substring(0, strArrays.length() - 1); |
| | | return R.status(articleService.upcomment(code,type)); |
| | | } |
| | | } |