|
@@ -19,6 +19,7 @@ import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.apache.logging.log4j.util.Strings;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.text.ParseException;
|
|
@@ -80,6 +81,7 @@ public class CommunityArticleController extends BaseController {
|
|
|
*/
|
|
|
@ApiOperation("发布文章")
|
|
|
@PostMapping("/article")
|
|
|
+ @Transactional
|
|
|
//@Anonymous
|
|
|
public AjaxResult article(@RequestBody CommunityArticle communityArticle) {
|
|
|
communityArticleService.insertCommunityArticle(communityArticle);
|
|
@@ -110,6 +112,7 @@ public class CommunityArticleController extends BaseController {
|
|
|
|
|
|
@ApiOperation("文章评价")
|
|
|
@PostMapping("/comment")
|
|
|
+ @Transactional
|
|
|
public AjaxResult comment(@RequestBody CommunityArticleComment communityArticleComment) throws ParseException {
|
|
|
if (null == communityArticleComment.getArticleId()) {
|
|
|
return AjaxResult.error("文章不存在或异常!");
|
|
@@ -127,6 +130,7 @@ public class CommunityArticleController extends BaseController {
|
|
|
|
|
|
@ApiOperation("文章评价")
|
|
|
@DeleteMapping("/comment")
|
|
|
+ @Transactional
|
|
|
public AjaxResult deleteComment(@RequestBody CommunityArticleComment communityArticleComment) {
|
|
|
// if (null == communityArticleComment.getArticleId()) {
|
|
|
// return AjaxResult.error("文章不存在或异常!");
|
|
@@ -151,6 +155,7 @@ public class CommunityArticleController extends BaseController {
|
|
|
*/
|
|
|
@ApiOperation("文章点赞")
|
|
|
@PostMapping("/like")
|
|
|
+ @Transactional
|
|
|
//@Anonymous
|
|
|
public AjaxResult like(@RequestBody CommunityLike communityLike) {
|
|
|
if (Objects.isNull(communityLike.getArticleId()) || Objects.isNull(communityLike.getUserId())) {
|
|
@@ -186,6 +191,7 @@ public class CommunityArticleController extends BaseController {
|
|
|
*/
|
|
|
@ApiOperation("文章收藏")
|
|
|
@PostMapping("/collect")
|
|
|
+ @Transactional
|
|
|
//@Anonymous
|
|
|
public AjaxResult collect(@RequestBody CommunityArticleCollect communityArticleCollect) {
|
|
|
if (Objects.isNull(communityArticleCollect.getArticleId()) || Objects.isNull(communityArticleCollect.getUserId())) {
|
|
@@ -217,6 +223,7 @@ public class CommunityArticleController extends BaseController {
|
|
|
*/
|
|
|
@ApiOperation("评论点赞")
|
|
|
@PostMapping("/commentLike")
|
|
|
+ @Transactional
|
|
|
//@Anonymous
|
|
|
public AjaxResult commentLike(@RequestBody CommunityCommentLike commentLike) {
|
|
|
if (Objects.isNull(commentLike.getCommentId())) {
|
|
@@ -288,6 +295,7 @@ public class CommunityArticleController extends BaseController {
|
|
|
|
|
|
@ApiOperation("收藏/取关圈子")
|
|
|
@PostMapping("/circle")
|
|
|
+ @Transactional
|
|
|
//@Anonymous
|
|
|
public AjaxResult circle(@RequestBody CommunityUserCircle communityUserCircle) {
|
|
|
if (Objects.isNull(communityUserCircle.getCircleId())) {
|
|
@@ -333,6 +341,7 @@ public class CommunityArticleController extends BaseController {
|
|
|
|
|
|
@ApiOperation("关注/取关用户")
|
|
|
@PostMapping("/likeUser")
|
|
|
+ @Transactional
|
|
|
public AjaxResult userLike(@RequestParam("likeUserId") Long likeUserId) {
|
|
|
if (Objects.isNull(likeUserId)) {
|
|
|
return AjaxResult.error("参数失效!");
|
|
@@ -368,6 +377,12 @@ public class CommunityArticleController extends BaseController {
|
|
|
return AjaxResult.success(communityArticleService.selectUserFansList(SecurityUtils.getLoginUser().getUserId()));
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation("互相关注列表")
|
|
|
+ @GetMapping("/mutualAttention")
|
|
|
+ public AjaxResult mutualAttention() {
|
|
|
+ return AjaxResult.success(communityArticleService.selectMutualAttention(SecurityUtils.getLoginUser().getUserId()));
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperation("发送用户验证码")
|
|
|
@GetMapping("/sendSms")
|
|
|
//todo
|
|
@@ -383,6 +398,7 @@ public class CommunityArticleController extends BaseController {
|
|
|
*/
|
|
|
@ApiOperation("更新用户背景图片")
|
|
|
@PostMapping("/uploadBackImage")
|
|
|
+ @Transactional
|
|
|
public AjaxResult uploadBackImage(@RequestParam("backImage") String backImage) {
|
|
|
if (backImage == null) {
|
|
|
return AjaxResult.error("背景图不能为空");
|
|
@@ -398,6 +414,27 @@ public class CommunityArticleController extends BaseController {
|
|
|
return AjaxResult.success("背景图片上传成功!");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 用户合集
|
|
|
+ *
|
|
|
+ * @return 是否成功
|
|
|
+ */
|
|
|
+ @ApiOperation("用户合集")
|
|
|
+ @GetMapping("/userCollection")
|
|
|
+ public AjaxResult createCollection(Long userId) {
|
|
|
+ if (Objects.isNull(userId)) {
|
|
|
+ return AjaxResult.error("参数异常!");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<CommunityCollection> collections = communityCollectionService.list(new QueryWrapper<CommunityCollection>()
|
|
|
+ .eq("user_id", userId)
|
|
|
+ .ne("is_delete", true)
|
|
|
+ .or()
|
|
|
+ .isNull("is_delete"));
|
|
|
+ return AjaxResult.success(collections);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 用户新增合集
|
|
|
*
|
|
@@ -406,6 +443,7 @@ public class CommunityArticleController extends BaseController {
|
|
|
*/
|
|
|
@ApiOperation("用户新增合集")
|
|
|
@PostMapping("/createCollection")
|
|
|
+ @Transactional
|
|
|
public AjaxResult createCollection(@RequestBody CommunityCollection communityCollection) {
|
|
|
|
|
|
if (Objects.isNull(communityCollection.getCollectionName())) {
|
|
@@ -419,7 +457,10 @@ public class CommunityArticleController extends BaseController {
|
|
|
CommunityCollection collection = communityCollectionService
|
|
|
.getOne(new QueryWrapper<CommunityCollection>()
|
|
|
.eq("collection_name", communityCollection.getCollectionName())
|
|
|
- .eq("user_id", SecurityUtils.getLoginUser().getUserId()));
|
|
|
+ .eq("user_id", SecurityUtils.getLoginUser().getUserId())
|
|
|
+ .ne("is_delete", true)
|
|
|
+ .or()
|
|
|
+ .isNull("is_delete"));
|
|
|
|
|
|
if (!Objects.isNull(collection)) {
|
|
|
return AjaxResult.error("合集名称不能重复!");
|
|
@@ -428,26 +469,46 @@ public class CommunityArticleController extends BaseController {
|
|
|
communityCollection.setUserId(SecurityUtils.getLoginUser().getUserId());
|
|
|
communityCollection.setCreateBy(SecurityUtils.getLoginUser().getUserId());
|
|
|
communityCollection.setCreateTime(DateUtils.parseDate(DateUtils.getTime()));
|
|
|
+ communityCollection.setDelete(false);
|
|
|
communityCollectionService.save(communityCollection);
|
|
|
|
|
|
return AjaxResult.success(communityCollection);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 用户新增合集
|
|
|
+ * 用户删除合集
|
|
|
*
|
|
|
- * @param collectionArticle 用户新增合集
|
|
|
+ * @param collectionId 合集id
|
|
|
+ * @return 是否成功
|
|
|
+ */
|
|
|
+ @ApiOperation("用户删除合集")
|
|
|
+ @DeleteMapping("/deleteCollection")
|
|
|
+ @Transactional
|
|
|
+ public AjaxResult deleteCollection(Long collectionId) {
|
|
|
+ if (Objects.isNull(collectionId)) {
|
|
|
+ return AjaxResult.error("参数异常!");
|
|
|
+ }
|
|
|
+
|
|
|
+ communityCollectionService.deleteCollectionById(collectionId);
|
|
|
+ return AjaxResult.success("删除成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 合集内新增文章
|
|
|
+ *
|
|
|
+ * @param collectionArticle 合集内新增文章
|
|
|
* @return 是否成功
|
|
|
*/
|
|
|
@ApiOperation("合集内新增文章")
|
|
|
@PostMapping("/addArticleToCollection")
|
|
|
+ @Transactional
|
|
|
public AjaxResult addArticleToCollection(@RequestBody CommunityCollectionArticle collectionArticle) {
|
|
|
if (Objects.isNull(collectionArticle.getArticleId())) {
|
|
|
- return AjaxResult.error("未选中文章或该文章不存在!");
|
|
|
+ return AjaxResult.error("文章参数异常!");
|
|
|
}
|
|
|
|
|
|
if (Objects.isNull(collectionArticle.getCollectionId())) {
|
|
|
- return AjaxResult.error("该合集不存在!");
|
|
|
+ return AjaxResult.error("合集参数异常!");
|
|
|
}
|
|
|
|
|
|
collectionArticle.setCreateBy(SecurityUtils.getLoginUser().getUserId());
|
|
@@ -457,6 +518,25 @@ public class CommunityArticleController extends BaseController {
|
|
|
return AjaxResult.success("加入合集成功!");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 合集内删除文章
|
|
|
+ *
|
|
|
+ * @param collectionId 合集id
|
|
|
+ * @param articleId 文章id
|
|
|
+ * @return 是否成功
|
|
|
+ */
|
|
|
+ @ApiOperation("合集内删除文章")
|
|
|
+ @DeleteMapping("/deleteArticleInCollection")
|
|
|
+ @Transactional
|
|
|
+ public AjaxResult addArticleToCollection(Long collectionId, Long articleId) {
|
|
|
+ if (Objects.isNull(collectionId) || Objects.isNull(articleId)) {
|
|
|
+ return AjaxResult.error("参数异常!");
|
|
|
+ }
|
|
|
+
|
|
|
+ communityCollectionService.deleteArticleToCollection(collectionId, articleId);
|
|
|
+ return AjaxResult.success("文章删除成功!");
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 查询合集下文章信息
|
|
|
*
|