| | |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.secure.BladeUser; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.Func; |
| | | 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.mgcx.entity.Mgcx; |
| | | import org.springblade.modules.mgcx.service.IMgcxService; |
| | | import org.springblade.modules.system.entity.User; |
| | | import org.springblade.modules.system.service.IUserService; |
| | | import org.springblade.modules.words.DemoApplication; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.Valid; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author zhongrj |
| | |
| | | public class ArticleController { |
| | | |
| | | private final ArticleService articleService; |
| | | |
| | | private final IUserService userService; |
| | | private final IMgcxService mgcxService; |
| | | |
| | | /** |
| | | * |
| | |
| | | |
| | | /** |
| | | * |
| | | * 敏感词预警 |
| | | * @param response |
| | | * @param article 资讯对象 |
| | | * @param query 查询参数 |
| | | * @return |
| | | */ |
| | | @GetMapping("/pageWords") |
| | | public R<IPage<Article>> pageWords(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.pageWords(Condition.getPage(query),article)); |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * 查询资讯分页信息(角色权限) |
| | | * @param response |
| | | * @param article 资讯对象 |
| | |
| | | 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)); |
| | | } |
| | | |
| | | /** |
| | |
| | | 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)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 资讯详情 |
| | |
| | | @PostMapping("/submit") |
| | | @ApiOperationSupport(order = 6) |
| | | @ApiOperation(value = "新增或修改", notes = "传入article") |
| | | public R submit(@Valid @RequestBody Article article) { |
| | | public R submit(@Valid @RequestBody ArticleVo article) { |
| | | if (null==article.getId()){ |
| | | if (null==article.getCreateTime()){ |
| | | article.setCreateTime(new Date()); |
| | | } |
| | | } |
| | | //默认为正常 |
| | | article.setIswords("0"); |
| | | |
| | | if (article.getContent() != null && article.getContent() != ""){ |
| | | Map<String,String> content = new HashMap(); |
| | | content = DemoApplication.interceptWords(article.getContent()); |
| | | System.out.println(content.get("iswords")); |
| | | if (content.get("iswords") == "true"){ |
| | | article.setContent(content.get("content")); |
| | | article.setIswords("1"); |
| | | article.setWordsContent(content.get("words")); |
| | | //获取登录信息 |
| | | String userid = article.getUserid(); |
| | | User user = new User(); |
| | | user.setId(Long.parseLong(userid)); |
| | | User detail = userService.getOne(Condition.getQueryWrapper(user)); |
| | | Mgcx mgcx = new Mgcx(); |
| | | mgcx.setUid(userid); |
| | | Mgcx one = mgcxService.getOne(Condition.getQueryWrapper(mgcx)); |
| | | if (one==null){ |
| | | mgcx.setUid(userid); |
| | | mgcx.setPhone(detail.getPhone()); |
| | | mgcx.setCardid(detail.getCardid()); |
| | | mgcx.setCountx(10); |
| | | mgcx.setCounts(1); |
| | | mgcxService.save(mgcx); |
| | | } |
| | | else { |
| | | Integer counts = one.getCounts(); |
| | | int i = counts + 1; |
| | | one.setCounts(i); |
| | | mgcxService.updateById(one); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | article.setUpdateTime(new Date()); |
| | | return R.status(articleService.saveOrUpdate(article)); |
| | | } |