|
@@ -5,6 +5,7 @@ import com.ruoyi.common.core.controller.BaseController;
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
import com.ruoyi.generator.domain.Community.CommunityArticle;
|
|
import com.ruoyi.generator.domain.Community.CommunityArticle;
|
|
|
|
+import com.ruoyi.generator.domain.Community.CommunityArticleCollect;
|
|
import com.ruoyi.generator.domain.Community.CommunityLike;
|
|
import com.ruoyi.generator.domain.Community.CommunityLike;
|
|
import com.ruoyi.generator.service.ICommunityArticleService;
|
|
import com.ruoyi.generator.service.ICommunityArticleService;
|
|
import com.ruoyi.generator.vo.CommunityArticleVo;
|
|
import com.ruoyi.generator.vo.CommunityArticleVo;
|
|
@@ -52,18 +53,53 @@ public class CommunityArticleController extends BaseController {
|
|
AjaxResult.error("文章或用户信息异常!");
|
|
AjaxResult.error("文章或用户信息异常!");
|
|
}
|
|
}
|
|
boolean isSuccess = true;
|
|
boolean isSuccess = true;
|
|
|
|
+ String message = "";
|
|
CommunityLike like = communityArticleService.selectCommunityLikeById(communityLike);
|
|
CommunityLike like = communityArticleService.selectCommunityLikeById(communityLike);
|
|
if (Objects.isNull(like)) {
|
|
if (Objects.isNull(like)) {
|
|
//新增点赞
|
|
//新增点赞
|
|
isSuccess = communityArticleService.insertCommunityLikeById(communityLike);
|
|
isSuccess = communityArticleService.insertCommunityLikeById(communityLike);
|
|
|
|
+ message = "感谢点赞";
|
|
} else {
|
|
} else {
|
|
//删除点赞
|
|
//删除点赞
|
|
isSuccess = communityArticleService.deleteCommunityLikeById(like);
|
|
isSuccess = communityArticleService.deleteCommunityLikeById(like);
|
|
|
|
+ message = "取消点赞";
|
|
}
|
|
}
|
|
|
|
|
|
if (!isSuccess) {
|
|
if (!isSuccess) {
|
|
- return AjaxResult.error("点赞失败!");
|
|
|
|
|
|
+ message = "操作失败!";
|
|
|
|
+ return AjaxResult.error(message);
|
|
}
|
|
}
|
|
- return AjaxResult.success("操作成功!");
|
|
|
|
|
|
+ return AjaxResult.success(message);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取文章列表信息
|
|
|
|
+ */
|
|
|
|
+ @ApiOperation("文章收藏")
|
|
|
|
+ @PostMapping("/collect")
|
|
|
|
+ //@Anonymous
|
|
|
|
+ public AjaxResult collect(@RequestBody CommunityArticleCollect communityArticleCollect) {
|
|
|
|
+ if (Objects.isNull(communityArticleCollect.getArticleId()) || Objects.isNull(communityArticleCollect.getUserId())) {
|
|
|
|
+ AjaxResult.error("文章或用户信息异常!");
|
|
|
|
+ }
|
|
|
|
+ boolean isSuccess = true;
|
|
|
|
+ String message = "";
|
|
|
|
+ CommunityArticleCollect collect = communityArticleService.selectCommunityCollectById(communityArticleCollect);
|
|
|
|
+ if (Objects.isNull(collect)) {
|
|
|
|
+ //新增收藏
|
|
|
|
+ isSuccess = communityArticleService.insertCommunityCollectById(collect);
|
|
|
|
+ message = "收藏成功";
|
|
|
|
+ } else {
|
|
|
|
+ //删除收藏
|
|
|
|
+ isSuccess = communityArticleService.deleteCommunityCollectById(collect);
|
|
|
|
+ message = "取消收藏";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!isSuccess) {
|
|
|
|
+ message = "操作失败!";
|
|
|
|
+ return AjaxResult.error(message);
|
|
|
|
+ }
|
|
|
|
+ return AjaxResult.success(message);
|
|
}
|
|
}
|
|
}
|
|
}
|