|
@@ -7,6 +7,7 @@ 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.core.text.Convert;
|
|
|
+import com.ruoyi.common.exception.user.ProjectException;
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
import com.ruoyi.common.utils.ServletUtils;
|
|
@@ -94,11 +95,16 @@ public class CommunityArticleController extends BaseController {
|
|
|
int pageNum = Convert.toInt(ServletUtils.getParameter("pageNum"), 1);
|
|
|
int pageSize = Convert.toInt(ServletUtils.getParameter("pageSize"), 10);
|
|
|
int searchType = Convert.toInt(ServletUtils.getParameter("searchType"), 0);
|
|
|
- TableDataInfo rspData = new TableDataInfo();
|
|
|
- List<CommunityArticleVo> list = communityArticleService.selectCommunityArticleList(rspData,communityArticle, pageNum, pageSize, searchType);
|
|
|
- rspData.setCode(HttpStatus.SUCCESS);
|
|
|
- rspData.setMsg("查询成功");
|
|
|
- rspData.setRows(list);
|
|
|
+ TableDataInfo rspData = null;
|
|
|
+ try {
|
|
|
+ rspData = new TableDataInfo();
|
|
|
+ List<CommunityArticleVo> list = communityArticleService.selectCommunityArticleList(rspData, communityArticle, pageNum, pageSize, searchType);
|
|
|
+ rspData.setCode(HttpStatus.SUCCESS);
|
|
|
+ rspData.setMsg("查询成功");
|
|
|
+ rspData.setRows(list);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new ProjectException();
|
|
|
+ }
|
|
|
return rspData;
|
|
|
}
|
|
|
|
|
@@ -171,7 +177,7 @@ public class CommunityArticleController extends BaseController {
|
|
|
System.out.println("communityArticleComment: " + communityArticleComment);
|
|
|
Long userId = SecurityUtils.getUserId();
|
|
|
//调用方法去判断当前评论的用户 是不是文章作者的关注列表
|
|
|
- Boolean aBoolean = communityArticleService.checkCommentPermission(userId,null,communityArticleComment.getArticleId());
|
|
|
+ Boolean aBoolean = communityArticleService.checkCommentPermission(userId, null, communityArticleComment.getArticleId());
|
|
|
communityArticleComment.setUserId(SecurityUtils.getUserId());
|
|
|
if (!aBoolean) { // 当 aBoolean 为 false 时,进入这个条件
|
|
|
return AjaxResult.success("您没有权限评论此文章,因为只允许关注的人评论您!");
|
|
@@ -541,7 +547,7 @@ public class CommunityArticleController extends BaseController {
|
|
|
*/
|
|
|
@ApiOperation("用户合集")
|
|
|
@GetMapping("/userCollection")
|
|
|
- public AjaxResult createCollection(Long userId,Long articleId) {
|
|
|
+ public AjaxResult createCollection(Long userId, Long articleId) {
|
|
|
if (Objects.isNull(userId)) {
|
|
|
return AjaxResult.error("参数异常!");
|
|
|
}
|
|
@@ -552,7 +558,7 @@ public class CommunityArticleController extends BaseController {
|
|
|
// .or()
|
|
|
// .isNull("is_delete"));
|
|
|
|
|
|
- List<CommunityCollectionVo> communityCollectionVos = communityCollectionService.selectUserCollection(userId,articleId);
|
|
|
+ List<CommunityCollectionVo> communityCollectionVos = communityCollectionService.selectUserCollection(userId, articleId);
|
|
|
|
|
|
return AjaxResult.success(communityCollectionVos);
|
|
|
}
|
|
@@ -649,8 +655,8 @@ public class CommunityArticleController extends BaseController {
|
|
|
|
|
|
//查询当前文章是不是属于该用户的
|
|
|
List<CommunityArticle> communityArticles = communityArticleMapper.selectList(new QueryWrapper<CommunityArticle>()
|
|
|
- .eq("user_id",userId)
|
|
|
- .eq("id",articleId)
|
|
|
+ .eq("user_id", userId)
|
|
|
+ .eq("id", articleId)
|
|
|
.and((wrapper) -> {
|
|
|
wrapper.ne("is_delete", 1).or().isNull("is_delete");
|
|
|
}));
|
|
@@ -662,7 +668,7 @@ public class CommunityArticleController extends BaseController {
|
|
|
//查询当前用户有没有这个合集
|
|
|
List<CommunityCollection> communityCollections = communityCollectionMapper.selectList(new QueryWrapper<CommunityCollection>()
|
|
|
.eq("user_id", userId)
|
|
|
- .eq("id",collectionId)
|
|
|
+ .eq("id", collectionId)
|
|
|
.and((wrapper) -> {
|
|
|
wrapper.ne("is_delete", 1).or().isNull("is_delete");
|
|
|
}));
|
|
@@ -675,7 +681,7 @@ public class CommunityArticleController extends BaseController {
|
|
|
//根据创建人ID,合集ID,文章ID保持唯一性 查询表如果没有则插入,有了则更新ID
|
|
|
List<CommunityCollectionArticle> communityCollectionArticles = communityCollectionArticleMapper.selectList(new QueryWrapper<CommunityCollectionArticle>()
|
|
|
.eq("create_by", userId)
|
|
|
- .eq("article_id",articleId)
|
|
|
+ .eq("article_id", articleId)
|
|
|
.and((wrapper) -> {
|
|
|
wrapper.ne("is_delete", 1).or().isNull("is_delete");
|
|
|
}));
|
|
@@ -736,6 +742,4 @@ public class CommunityArticleController extends BaseController {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
}
|