|
@@ -2,29 +2,29 @@ package com.ruoyi.generator.controller;
|
|
|
|
|
|
import com.ruoyi.common.annotation.Anonymous;
|
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
|
+import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
import com.ruoyi.generator.domain.Community.CommunityArticle;
|
|
|
+import com.ruoyi.generator.domain.Community.CommunityLike;
|
|
|
import com.ruoyi.generator.service.ICommunityArticleService;
|
|
|
import com.ruoyi.generator.vo.CommunityArticleVo;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
/**
|
|
|
* 社区文章管理
|
|
|
- *
|
|
|
+ *
|
|
|
* @author fangzhen
|
|
|
*/
|
|
|
@Api(tags = "社区文章管理")
|
|
|
@RestController
|
|
|
@RequestMapping("/community/article")
|
|
|
-public class CommunityArticleController extends BaseController
|
|
|
-{
|
|
|
+public class CommunityArticleController extends BaseController {
|
|
|
@Autowired
|
|
|
private ICommunityArticleService communityArticleService;
|
|
|
|
|
@@ -35,10 +35,35 @@ public class CommunityArticleController extends BaseController
|
|
|
@ApiOperation("获取文章列表")
|
|
|
@GetMapping("/list")
|
|
|
//@Anonymous
|
|
|
- public TableDataInfo genList(CommunityArticle communityArticle)
|
|
|
- {
|
|
|
+ public TableDataInfo communityList(CommunityArticle communityArticle) {
|
|
|
startPage();
|
|
|
List<CommunityArticleVo> list = communityArticleService.selectCommunityArticleList(communityArticle);
|
|
|
return getDataTable(list);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取文章列表信息
|
|
|
+ */
|
|
|
+ @ApiOperation("文章点赞")
|
|
|
+ @PostMapping("/like")
|
|
|
+ //@Anonymous
|
|
|
+ public AjaxResult like(@RequestBody CommunityLike communityLike) {
|
|
|
+ if (Objects.isNull(communityLike.getArticleId()) || Objects.isNull(communityLike.getUserId())) {
|
|
|
+ AjaxResult.error("文章或用户信息异常!");
|
|
|
+ }
|
|
|
+ boolean isSuccess = true;
|
|
|
+ CommunityLike like = communityArticleService.selectCommunityLikeById(communityLike);
|
|
|
+ if (Objects.isNull(like)) {
|
|
|
+ //新增点赞
|
|
|
+ isSuccess = communityArticleService.insertCommunityLikeById(communityLike);
|
|
|
+ } else {
|
|
|
+ //删除点赞
|
|
|
+ isSuccess = communityArticleService.deleteCommunityLikeById(like);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!isSuccess) {
|
|
|
+ return AjaxResult.error("点赞失败!");
|
|
|
+ }
|
|
|
+ return AjaxResult.success("操作成功!");
|
|
|
+ }
|
|
|
}
|