|
@@ -11,8 +11,10 @@ import com.ruoyi.common.utils.ServletUtils;
|
|
|
import com.ruoyi.generator.domain.Community.*;
|
|
|
import com.ruoyi.generator.mapper.community.*;
|
|
|
import com.ruoyi.generator.service.ICommunityArticleService;
|
|
|
+import com.ruoyi.generator.service.ICommunityCollectionService;
|
|
|
import com.ruoyi.generator.vo.CommunityArticleVo;
|
|
|
import com.ruoyi.generator.vo.CommunityCircleVo;
|
|
|
+import com.ruoyi.generator.vo.CommunityCollectionArticleVo;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.apache.logging.log4j.util.Strings;
|
|
@@ -53,9 +55,12 @@ public class CommunityArticleController extends BaseController {
|
|
|
|
|
|
@Autowired
|
|
|
private CommunityClassCircleMapper communityClassCircleMapper;
|
|
|
+
|
|
|
@Autowired
|
|
|
private CommunityUserInfoMapper communityUserInfoMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ICommunityCollectionService communityCollectionService;
|
|
|
|
|
|
/**
|
|
|
* 获取文章列表信息
|
|
@@ -277,7 +282,7 @@ public class CommunityArticleController extends BaseController {
|
|
|
if (!circleIds.isEmpty()) {
|
|
|
communityCircles = communityCircleMapper.selectBatchIds(circleIds);
|
|
|
}
|
|
|
- return AjaxResult.success(communityCircles);
|
|
|
+ return AjaxResult.success("获取成功!", communityCircles);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -392,4 +397,80 @@ public class CommunityArticleController extends BaseController {
|
|
|
communityUserInfoMapper.updateById(communityUserInfo);
|
|
|
return AjaxResult.success("背景图片上传成功!");
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用户新增合集
|
|
|
+ *
|
|
|
+ * @param communityCollection 新增合集数据
|
|
|
+ * @return 是否成功
|
|
|
+ */
|
|
|
+ @ApiOperation("用户新增合集")
|
|
|
+ @PostMapping("/createCollection")
|
|
|
+ public AjaxResult createCollection(@RequestBody CommunityCollection communityCollection) {
|
|
|
+
|
|
|
+ if (Objects.isNull(communityCollection.getCollectionName())) {
|
|
|
+ return AjaxResult.error("合集名称不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Objects.isNull(communityCollection.getImages())) {
|
|
|
+ return AjaxResult.error("合集图片不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ CommunityCollection collection = communityCollectionService
|
|
|
+ .getOne(new QueryWrapper<CommunityCollection>()
|
|
|
+ .eq("collection_name", communityCollection.getCollectionName())
|
|
|
+ .eq("user_id", SecurityUtils.getLoginUser().getUserId()));
|
|
|
+
|
|
|
+ if (!Objects.isNull(collection)) {
|
|
|
+ return AjaxResult.error("合集名称不能重复!");
|
|
|
+ }
|
|
|
+
|
|
|
+ communityCollection.setUserId(SecurityUtils.getLoginUser().getUserId());
|
|
|
+ communityCollection.setCreateBy(SecurityUtils.getLoginUser().getUserId());
|
|
|
+ communityCollection.setCreateTime(DateUtils.parseDate(DateUtils.getTime()));
|
|
|
+ communityCollectionService.save(communityCollection);
|
|
|
+
|
|
|
+ return AjaxResult.success(communityCollection);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用户新增合集
|
|
|
+ *
|
|
|
+ * @param collectionArticle 用户新增合集
|
|
|
+ * @return 是否成功
|
|
|
+ */
|
|
|
+ @ApiOperation("合集内新增文章")
|
|
|
+ @PostMapping("/addArticleToCollection")
|
|
|
+ public AjaxResult addArticleToCollection(@RequestBody CommunityCollectionArticle collectionArticle) {
|
|
|
+ if (Objects.isNull(collectionArticle.getArticleId())) {
|
|
|
+ return AjaxResult.error("未选中文章或该文章不存在!");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Objects.isNull(collectionArticle.getCollectionId())) {
|
|
|
+ return AjaxResult.error("该合集不存在!");
|
|
|
+ }
|
|
|
+
|
|
|
+ collectionArticle.setCreateBy(SecurityUtils.getLoginUser().getUserId());
|
|
|
+ collectionArticle.setCreateTime(DateUtils.parseDate(DateUtils.getTime()));
|
|
|
+ communityCollectionService.addArticleToCollection(collectionArticle);
|
|
|
+
|
|
|
+ return AjaxResult.success("加入合集成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询合集下文章信息
|
|
|
+ *
|
|
|
+ * @param collectionId 合集id
|
|
|
+ * @return 合集下文章信息
|
|
|
+ */
|
|
|
+ @ApiOperation("查询用户合集")
|
|
|
+ @GetMapping("/getCollection")
|
|
|
+ public AjaxResult getCollection(Long collectionId) {
|
|
|
+ if (Objects.isNull(collectionId)) {
|
|
|
+ return AjaxResult.error("合集不存在!");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<CommunityCollectionArticleVo> collectionArticleVos = communityCollectionService.selectArticleInfoInCollection(collectionId);
|
|
|
+ return AjaxResult.success(collectionArticleVos);
|
|
|
+ }
|
|
|
}
|