diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml
new file mode 100644
index 0000000..55afae8
--- /dev/null
+++ b/.idea/dataSources.xml
@@ -0,0 +1,12 @@
+
+
+
+
+ redis
+ true
+ jdbc.RedisDriver
+ jdbc:redis://localhost:6379/0
+ $ProjectFileDir$
+
+
+
\ No newline at end of file
diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml
new file mode 100644
index 0000000..2b63946
--- /dev/null
+++ b/.idea/uiDesigner.xml
@@ -0,0 +1,124 @@
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 55c451f..50b70af 100644
--- a/pom.xml
+++ b/pom.xml
@@ -264,12 +264,40 @@
weixin-java-miniapp
4.6.0
+
+
+ com.github.binarywang
+ wx-java-mp-spring-boot-starter
+ 4.6.0
+
com.aliyun.oss
aliyun-sdk-oss
- 3.17.0
+ 3.18.1
+
+
+ com.aliyun
+ sts20150401
+ 1.1.6
+
+
+ com.aliyun
+ credentials-java
+ 0.3.4
+
+
+
+ com.aliyun.mns
+ aliyun-sdk-mns
+ 1.1.11
+
+
+
+ com.aliyun.kms
+ kms-transfer-client
+ 0.1.0
diff --git a/src/main/java/com/gxwebsoft/cms/controller/ArticleCheckController.java b/src/main/java/com/gxwebsoft/cms/controller/ArticleCheckController.java
new file mode 100644
index 0000000..a8dd5ad
--- /dev/null
+++ b/src/main/java/com/gxwebsoft/cms/controller/ArticleCheckController.java
@@ -0,0 +1,178 @@
+package com.gxwebsoft.cms.controller;
+
+import cn.binarywang.wx.miniapp.api.WxMaService;
+import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage;
+import cn.hutool.core.date.DateUtil;
+import com.gxwebsoft.cms.entity.Article;
+import com.gxwebsoft.cms.service.ArticleService;
+import com.gxwebsoft.common.core.security.JwtUtil;
+import com.gxwebsoft.common.core.utils.RequestUtil;
+import com.gxwebsoft.common.core.web.BaseController;
+import com.gxwebsoft.cms.service.ArticleCheckService;
+import com.gxwebsoft.cms.entity.ArticleCheck;
+import com.gxwebsoft.cms.param.ArticleCheckParam;
+import com.gxwebsoft.common.core.web.ApiResult;
+import com.gxwebsoft.common.core.web.PageResult;
+import com.gxwebsoft.common.core.web.PageParam;
+import com.gxwebsoft.common.core.web.BatchParam;
+import com.gxwebsoft.common.core.annotation.OperationLog;
+import com.gxwebsoft.common.system.entity.User;
+import com.gxwebsoft.shop.controller.WeChatController;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import me.chanjar.weixin.common.error.WxErrorException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 控制器
+ *
+ * @author 科技小王子
+ * @since 2024-11-19 22:01:03
+ */
+@Api(tags = "管理")
+@RestController
+@RequestMapping("/api/cms/article-check")
+public class ArticleCheckController extends BaseController {
+ @Resource
+ private ArticleCheckService articleCheckService;
+ @Resource
+ private ArticleService articleService;
+
+ @Autowired
+ private WeChatController weChatController;
+ @Autowired
+ private RequestUtil requestUtil;
+
+ @ApiOperation("分页查询")
+ @GetMapping("/page")
+ public ApiResult> page(ArticleCheckParam param) {
+ // 使用关联查询
+ return success(articleCheckService.pageRel(param));
+ }
+
+ @ApiOperation("查询全部")
+ @GetMapping()
+ public ApiResult> list() {
+ ArticleCheckParam param = new ArticleCheckParam();
+ param.setUserId(getLoginUserId());
+ param.setStatus(0);
+ // 使用关联查询
+ List list = articleCheckService.listRel(param);
+ for (ArticleCheck articleCheck : list) {
+ articleCheck.setArticle(articleService.getByIdRel(articleCheck.getArticleId()));
+ }
+ return success(list);
+ }
+
+ @PreAuthorize("hasAuthority('cms:articleCheck:list')")
+ @ApiOperation("根据id查询")
+ @GetMapping("/{id}")
+ public ApiResult get(@PathVariable("id") Integer id) {
+ // 使用关联查询
+ return success(articleCheckService.getByIdRel(id));
+ }
+
+ @ApiOperation("添加")
+ @PostMapping()
+ public ApiResult> save(@RequestBody ArticleCheck articleCheck) {
+ // 记录当前登录用户id
+ User loginUser = getLoginUser();
+ if (loginUser != null) {
+ articleCheck.setUserId(loginUser.getUserId());
+ }
+ if (articleCheckService.save(articleCheck)) {
+ return success("添加成功");
+ }
+ return fail("添加失败");
+ }
+
+ @ApiOperation("修改")
+ @PutMapping()
+ public ApiResult> update(@RequestBody ArticleCheck articleCheck, HttpServletRequest request) throws WxErrorException {
+ if (articleCheckService.updateById(articleCheck)) {
+ ArticleCheck articleCheck1 = articleCheckService.getByIdRel(articleCheck.getId());
+ List articleCheckList = articleCheckService.listByArticleId(articleCheck1.getArticleId());
+ Article article = articleService.getById(articleCheck1.getArticleId());
+ boolean sendMsg = false;
+ String result = "";
+ if (articleCheck.getStatus().equals(2)) {
+ article.setStatus(2);
+ articleService.updateById(article);
+ sendMsg = true;
+ result = "驳回";
+ } else if (articleCheck.getStatus().equals(1)) {
+ int passNum = 0;
+ for (ArticleCheck articleCheck2 : articleCheckList) {
+ if (articleCheck2.getStatus().equals(1)) {
+ passNum++;
+ }
+ }
+ if (passNum == articleCheckList.size()) {
+ article.setStatus(0);
+ articleService.updateById(article);
+ sendMsg = true;
+ result = "通过";
+ }
+ }
+ if (sendMsg) {
+ requestUtil.setTenantId(getTenantId().toString());
+ requestUtil.setAccessToken(JwtUtil.getAccessToken(request));
+ User user = requestUtil.getByUserId(article.getUserId());
+ if (user != null) {
+ List data = new ArrayList<>();
+ data.add(new WxMaSubscribeMessage.MsgData("thing5", article.getTitle()));
+ data.add(new WxMaSubscribeMessage.MsgData("thing2", result));
+ data.add(new WxMaSubscribeMessage.MsgData("time4", DateUtil.format(DateUtil.date(), "yyyy-MM-dd HH:mm:ss")));
+ weChatController.sendMessage(user.getOpenid(), "NLnexmnhiVl_e4fiC6OwfbTlpssAuvXWoPNwITyTcC4", "package/user/myTv",
+ data);
+ }
+ }
+ return success("修改成功");
+ }
+ return fail("修改失败");
+ }
+
+ @ApiOperation("删除")
+ @DeleteMapping("/{id}")
+ public ApiResult> remove(@PathVariable("id") Integer id) {
+ if (articleCheckService.removeById(id)) {
+ return success("删除成功");
+ }
+ return fail("删除失败");
+ }
+
+ @ApiOperation("批量添加")
+ @PostMapping("/batch")
+ public ApiResult> saveBatch(@RequestBody List list) {
+ if (articleCheckService.saveBatch(list)) {
+ return success("添加成功");
+ }
+ return fail("添加失败");
+ }
+
+ @ApiOperation("批量修改")
+ @PutMapping("/batch")
+ public ApiResult> removeBatch(@RequestBody BatchParam batchParam) {
+ if (batchParam.update(articleCheckService, "id")) {
+ return success("修改成功");
+ }
+ return fail("修改失败");
+ }
+
+ @ApiOperation("批量删除")
+ @DeleteMapping("/batch")
+ public ApiResult> removeBatch(@RequestBody List ids) {
+ if (articleCheckService.removeByIds(ids)) {
+ return success("删除成功");
+ }
+ return fail("删除失败");
+ }
+
+}
diff --git a/src/main/java/com/gxwebsoft/cms/controller/ArticleCommentController.java b/src/main/java/com/gxwebsoft/cms/controller/ArticleCommentController.java
index 77a7c2a..72623e4 100644
--- a/src/main/java/com/gxwebsoft/cms/controller/ArticleCommentController.java
+++ b/src/main/java/com/gxwebsoft/cms/controller/ArticleCommentController.java
@@ -1,5 +1,7 @@
package com.gxwebsoft.cms.controller;
+import com.gxwebsoft.cms.entity.Article;
+import com.gxwebsoft.cms.service.ArticleService;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.cms.service.ArticleCommentService;
import com.gxwebsoft.cms.entity.ArticleComment;
@@ -10,6 +12,7 @@ import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.BatchParam;
import com.gxwebsoft.common.core.annotation.OperationLog;
import com.gxwebsoft.common.system.entity.User;
+import com.gxwebsoft.common.system.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -30,8 +33,11 @@ import java.util.List;
public class ArticleCommentController extends BaseController {
@Resource
private ArticleCommentService articleCommentService;
+ @Resource
+ private UserService userService;
+ @Resource
+ private ArticleService articleService;
- @PreAuthorize("hasAuthority('cms:articleComment:list')")
@ApiOperation("分页查询文章评论表")
@GetMapping("/page")
public ApiResult> page(ArticleCommentParam param) {
@@ -42,7 +48,6 @@ public class ArticleCommentController extends BaseController {
//return success(articleCommentService.pageRel(param));
}
- @PreAuthorize("hasAuthority('cms:articleComment:list')")
@ApiOperation("查询全部文章评论表")
@GetMapping()
public ApiResult> list(ArticleCommentParam param) {
@@ -53,7 +58,6 @@ public class ArticleCommentController extends BaseController {
//return success(articleCommentService.listRel(param));
}
- @PreAuthorize("hasAuthority('cms:articleComment:list')")
@ApiOperation("根据id查询文章评论表")
@GetMapping("/{id}")
public ApiResult get(@PathVariable("id") Integer id) {
@@ -62,16 +66,20 @@ public class ArticleCommentController extends BaseController {
//return success(articleCommentService.getByIdRel(id));
}
- @PreAuthorize("hasAuthority('cms:articleComment:save')")
@ApiOperation("添加文章评论表")
@PostMapping()
public ApiResult> save(@RequestBody ArticleComment articleComment) {
// 记录当前登录用户id
User loginUser = getLoginUser();
if (loginUser != null) {
- articleComment.setUserId(loginUser.getUserId());
+ articleComment.setUserId(loginUser.getUserId());
+ articleComment.setAvatar(loginUser.getAvatar());
+ articleComment.setNickname(loginUser.getNickname());
}
if (articleCommentService.save(articleComment)) {
+ Article article = articleService.getById(articleComment.getArticleId());
+ article.setCommentNumbers(article.getCommentNumbers() + 1);
+ articleService.updateById(article);
return success("添加成功");
}
return fail("添加失败");
@@ -87,11 +95,14 @@ public class ArticleCommentController extends BaseController {
return fail("修改失败");
}
- @PreAuthorize("hasAuthority('cms:articleComment:remove')")
@ApiOperation("删除文章评论表")
@DeleteMapping("/{id}")
public ApiResult> remove(@PathVariable("id") Integer id) {
+ ArticleComment articleComment = articleCommentService.getById(id);
if (articleCommentService.removeById(id)) {
+ Article article = articleService.getById(articleComment.getArticleId());
+ article.setCommentNumbers(article.getCommentNumbers() - 1);
+ articleService.updateById(article);
return success("删除成功");
}
return fail("删除失败");
diff --git a/src/main/java/com/gxwebsoft/cms/controller/ArticleController.java b/src/main/java/com/gxwebsoft/cms/controller/ArticleController.java
index 871d321..f312aab 100644
--- a/src/main/java/com/gxwebsoft/cms/controller/ArticleController.java
+++ b/src/main/java/com/gxwebsoft/cms/controller/ArticleController.java
@@ -1,28 +1,42 @@
package com.gxwebsoft.cms.controller;
+import com.aliyun.mns.client.CloudAccount;
+import com.aliyun.mns.client.CloudQueue;
+import com.aliyun.mns.client.MNSClient;
+import com.aliyun.mns.model.Message;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.gxwebsoft.cms.entity.Article;
import com.gxwebsoft.cms.entity.ArticleCategory;
+import com.gxwebsoft.cms.entity.ArticleCheck;
import com.gxwebsoft.cms.entity.ArticleContent;
import com.gxwebsoft.cms.param.ArticleParam;
import com.gxwebsoft.cms.service.ArticleCategoryService;
+import com.gxwebsoft.cms.service.ArticleCheckService;
import com.gxwebsoft.cms.service.ArticleContentService;
import com.gxwebsoft.cms.service.ArticleService;
+import com.gxwebsoft.common.core.security.JwtUtil;
+import com.gxwebsoft.common.core.utils.RequestUtil;
import com.gxwebsoft.common.core.web.ApiResult;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.common.core.web.BatchParam;
import com.gxwebsoft.common.core.web.PageResult;
+import com.gxwebsoft.common.system.controller.AliOssController;
import com.gxwebsoft.common.system.entity.User;
+import com.gxwebsoft.common.system.entity.UserRole;
+import com.gxwebsoft.open.service.OfficeMpServiceImpl;
import com.gxwebsoft.shop.entity.Goods;
import com.gxwebsoft.shop.param.GoodsParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
+import me.chanjar.weixin.common.error.WxErrorException;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@@ -44,103 +58,163 @@ public class ArticleController extends BaseController {
private ArticleCategoryService articleCategoryService;
@Resource
private ArticleContentService articleContentService;
+ @Resource
+ private ArticleCheckService articleCheckService;
+ @Resource
+ private OfficeMpServiceImpl officeMpService;
+
+ @Autowired
+ private RequestUtil requestUtil;
+ @Autowired
+ private AliOssController aliOssController;
@ApiOperation("分页查询文章")
@GetMapping("/page")
- public ApiResult> page(ArticleParam param) {
+ public ApiResult> page(ArticleParam param) {
// 使用关联查询
+ if (getLoginUser() != null) {
+ param.setLoginUserId(getLoginUserId());
+ }
+ if (param.getMinData() != null) return success(articleService.pageMinData(param));
return success(articleService.pageRel(param));
}
+ @GetMapping("/user-list")
+ public ApiResult> userList(ArticleParam param) {
+ // 使用关联查询
+ if (getLoginUser() != null) {
+ param.setUserId(getLoginUserId());
+ }
+ return success(articleService.listRel(param));
+ }
+
@ApiOperation("查询全部文章")
@GetMapping()
- public ApiResult> list(ArticleParam param) {
+ public ApiResult> list(ArticleParam param) {
// 使用关联查询
+ if (getLoginUser() != null) {
+ param.setLoginUserId(getLoginUserId());
+ }
+ if (param.getMinData() != null) return success(articleService.listMinData(param));
return success(articleService.listRel(param));
}
@ApiOperation("根据id查询文章")
@GetMapping("/{id}")
public ApiResult get(@PathVariable("id") Integer id) {
- // 使用关联查询
- Article article = articleService.getByIdRel(id);
- // 更新阅读数量
- article.setActualViews(article.getActualViews() + 1);
- articleService.updateById(article);
- // 附加文字内容
- ArticleContent content = articleContentService.getOne(new LambdaQueryWrapper().eq(ArticleContent::getArticleId,article.getArticleId()).last("limit 1"));
- if(content != null){
- article.setContent(content.getContent());
- }
- return success(article);
+ // 使用关联查询
+ Article article = articleService.getByIdRel(id);
+ // 更新阅读数量
+ article.setActualViews(article.getActualViews() + 1);
+ articleService.updateById(article);
+ // 附加文字内容
+ ArticleContent content = articleContentService.getOne(new LambdaQueryWrapper().eq(ArticleContent::getArticleId, article.getArticleId()).last("limit 1"));
+ if (content != null) {
+ article.setContent(content.getContent());
+ }
+ return success(article);
}
@ApiOperation("读取上一篇")
@GetMapping("/getPrevious/{id}")
public ApiResult getPrevious(@PathVariable("id") Integer id) {
- LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>();
- wrapper.lt(Article::getArticleId,id);
- wrapper.eq(Article::getStatus,0);
- wrapper.eq(Article::getType,0);
- wrapper.orderByDesc(Article::getArticleId);
- wrapper.last("limit 1");
- final Article article = articleService.getOne(wrapper);
- return success(article);
+ LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>();
+ wrapper.lt(Article::getArticleId, id);
+ wrapper.eq(Article::getStatus, 0);
+ wrapper.eq(Article::getType, 0);
+ wrapper.orderByDesc(Article::getArticleId);
+ wrapper.last("limit 1");
+ final Article article = articleService.getOne(wrapper);
+ return success(article);
}
@ApiOperation("读取下一篇")
@GetMapping("/getNext/{id}")
public ApiResult getNext(@PathVariable("id") Integer id) {
- LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>();
- wrapper.gt(Article::getArticleId,id);
- wrapper.eq(Article::getStatus,0);
- wrapper.eq(Article::getType,0);
- wrapper.orderByAsc(Article::getArticleId);
- wrapper.last("limit 1");
- final Article article = articleService.getOne(wrapper);
- return success(article);
+ LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>();
+ wrapper.gt(Article::getArticleId, id);
+ wrapper.eq(Article::getStatus, 0);
+ wrapper.eq(Article::getType, 0);
+ wrapper.orderByAsc(Article::getArticleId);
+ wrapper.last("limit 1");
+ final Article article = articleService.getOne(wrapper);
+ return success(article);
}
@PreAuthorize("hasAuthority('cms:article:save')")
@ApiOperation("添加文章")
@Transactional(rollbackFor = {Exception.class})
@PostMapping()
- public ApiResult> save(@RequestBody Article article) {
+ public ApiResult> save(@RequestBody Article article, HttpServletRequest request) throws WxErrorException {
// 记录当前登录用户id
User loginUser = getLoginUser();
if (loginUser != null) {
- article.setUserId(loginUser.getUserId());
+ article.setUserId(loginUser.getUserId());
+ article.setUserAvatar(loginUser.getAvatar());
+ article.setUsername(loginUser.getNickname());
}
// 同步类型
// final ArticleCategory category = articleCategoryService.getById(article.getCategoryId());
// article.setType(category.getType());
if (articleService.save(article)) {
- // 保存文章内容
- final ArticleContent content = new ArticleContent();
- content.setArticleId(article.getArticleId());
- content.setContent(article.getContent());
- articleContentService.save(content);
- return success("添加成功");
+ if (article.getBucket() != null) aliOssController.videoTrans(article.getBucket());
+ // 保存文章内容
+ final ArticleContent content = new ArticleContent();
+ content.setArticleId(article.getArticleId());
+ content.setContent(article.getContent());
+ articleContentService.save(content);
+
+ if (article.getIsFront() != null && article.getIsFront()) {
+ requestUtil.setTenantId(getTenantId().toString());
+ requestUtil.setAccessToken(JwtUtil.getAccessToken(request));
+ List userRoleList = requestUtil.getUserListByRole(1114);
+ if (userRoleList != null && !userRoleList.isEmpty()) {
+ for (UserRole userRole : userRoleList) {
+ User user = requestUtil.getByUserId(userRole.getUserId());
+ ArticleCheck articleCheck = new ArticleCheck();
+ articleCheck.setArticleId(article.getArticleId());
+ articleCheck.setUserId(userRole.getUserId());
+ articleCheckService.save(articleCheck);
+
+ if (user != null && user.getOfficeOpenid() != null && !user.getOfficeOpenid().isEmpty()) {
+ officeMpService.sendTVCheckMessage(user.getOfficeOpenid(), article.getTitle(), loginUser.getNickname());
+ }
+ }
+ }
+ }
+ return success("添加成功");
}
return fail("添加失败");
}
- @PreAuthorize("hasAuthority('cms:article:update')")
+ @PostMapping("/trans")
+ public ApiResult> trans(@RequestBody Article article) {
+// aliOssController.videoTrans(article.getVideo());
+ return success();
+ }
+
+ @ApiOperation("转码拉取消息")
+ @PostMapping("/trans-pull")
+ public ApiResult> transNotify() {
+ aliOssController.pullVideoTrans();
+ return success();
+ }
+
@ApiOperation("修改文章")
@Transactional(rollbackFor = {Exception.class})
@PutMapping()
- public ApiResult> update(@RequestBody Article article) {
+ public ApiResult> update(@RequestBody Article article, HttpServletRequest request) {
if (articleService.updateById(article)) {
// 更新文章内容
ArticleContent content = new ArticleContent();
content.setArticleId(article.getArticleId());
content.setContent(article.getContent());
ArticleContent one = articleContentService.getOne(new LambdaQueryWrapper().eq(ArticleContent::getArticleId, article.getArticleId()).last("limit 1"));
- if(one != null){
- one.setContent(article.getContent());
- articleContentService.updateById(one);
- }else {
- articleContentService.save(content);
+ if (one != null) {
+ one.setContent(article.getContent());
+ articleContentService.updateById(one);
+ } else {
+ articleContentService.save(content);
}
// 更新时间
article.setUpdateTime(new Date());
@@ -155,6 +229,9 @@ public class ArticleController extends BaseController {
@DeleteMapping("/{id}")
public ApiResult> remove(@PathVariable("id") Integer id) {
if (articleService.removeById(id)) {
+ articleCheckService.removeByMap(new HashMap<>() {{
+ put("article_id", id);
+ }});
return success("删除成功");
}
return fail("删除失败");
@@ -190,33 +267,33 @@ public class ArticleController extends BaseController {
return fail("删除失败");
}
- @ApiOperation("统计信息")
- @GetMapping("/data")
- public ApiResult