diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index fa317b3..10e6a08 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -1,6 +1,8 @@
+
+
@@ -19,14 +21,11 @@
-
-
-
-
-
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
index d46a6c7..22e83c6 100644
--- a/.idea/jarRepositories.xml
+++ b/.idea/jarRepositories.xml
@@ -4,12 +4,12 @@
-
+
-
+
diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml
new file mode 100644
index 0000000..ee74011
--- /dev/null
+++ b/.idea/kotlinc.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/jodconverter_core.xml b/.idea/libraries/jodconverter_core.xml
new file mode 100644
index 0000000..1379096
--- /dev/null
+++ b/.idea/libraries/jodconverter_core.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/jodconverter_local.xml b/.idea/libraries/jodconverter_local.xml
new file mode 100644
index 0000000..4d7f264
--- /dev/null
+++ b/.idea/libraries/jodconverter_local.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/jodconverter_local_oo.xml b/.idea/libraries/jodconverter_local_oo.xml
new file mode 100644
index 0000000..c82aaf1
--- /dev/null
+++ b/.idea/libraries/jodconverter_local_oo.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/jodconverter_spring.xml b/.idea/libraries/jodconverter_spring.xml
new file mode 100644
index 0000000..5130eee
--- /dev/null
+++ b/.idea/libraries/jodconverter_spring.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/jodconverter_spring_boot_starter.xml b/.idea/libraries/jodconverter_spring_boot_starter.xml
new file mode 100644
index 0000000..688a9c1
--- /dev/null
+++ b/.idea/libraries/jodconverter_spring_boot_starter.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 4306692..24ef09d 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -16,7 +16,7 @@
-
+
\ No newline at end of file
diff --git a/.idea/validation.xml b/.idea/validation.xml
new file mode 100644
index 0000000..a7b9942
--- /dev/null
+++ b/.idea/validation.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ocean-collection-service/src/main/java/com/oriole/ocean/controller/UserCollectionController.java b/ocean-collection-service/src/main/java/com/oriole/ocean/controller/UserCollectionController.java
index 700d2a9..253341a 100644
--- a/ocean-collection-service/src/main/java/com/oriole/ocean/controller/UserCollectionController.java
+++ b/ocean-collection-service/src/main/java/com/oriole/ocean/controller/UserCollectionController.java
@@ -16,6 +16,7 @@
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.dubbo.config.annotation.DubboReference;
+import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -77,16 +78,20 @@ public MsgEntity deleteCollection(@AuthUser AuthUserEntity authUser,
// 需要一并清空用户的收藏情况记录
for (Integer itemID : collectionEntity.getItems()) { // 遍历被删除的收藏夹中的文件对应用户行为记录
UserBehaviorEntity userBehaviorEntityQuery = new UserBehaviorEntity(itemID, mainType, username, BehaviorType.DO_COLLECTION);
- JSONArray collectionList = (JSONArray) userBehaviorService.findBehaviorRecord(userBehaviorEntityQuery).getExtraInfo(IN_COLLECTION);
- collectionList.remove(collectionID);
- if (collectionList.isEmpty()) {//所有的收藏已经被全部删除了
- // 移除收藏量统计
- userCollectionService.collectionStatisticsChange(itemID, "-1", mainType);
- // 移除用户行为记录
- userBehaviorService.deleteBehaviorRecord(userBehaviorEntityQuery);
- } else { // 还有收藏记录存在,更新记录
- userBehaviorService.updateBehaviorRecordExtraInfo(userBehaviorEntityQuery, IN_COLLECTION, collectionList);
+ Object extraInfo = userBehaviorService.findBehaviorRecord(userBehaviorEntityQuery).getExtraInfo(IN_COLLECTION);
+ if (extraInfo instanceof List>) {
+ List collectionList = (List) extraInfo;
+ collectionList.removeIf(id -> id.equals(collectionID));
+
+ if (collectionList.isEmpty()) {//所有的收藏已经被全部删除了
+ // 移除文件收藏量统计
+ userCollectionService.collectionStatisticsChange(itemID, "-1", mainType);
+ // 移除用户行为记录
+ userBehaviorService.deleteBehaviorRecord(userBehaviorEntityQuery);
+ } else { // 还有收藏记录存在,更新记录
+ userBehaviorService.updateBehaviorRecordExtraInfo(userBehaviorEntityQuery, IN_COLLECTION, collectionList);
+ }
}
}
return new MsgEntity<>(SUCCESS);
@@ -148,11 +153,10 @@ public MsgEntity changeCollectionItem(@AuthUser AuthUserEn
@RequestMapping(value = "/deleteCollectionItem", method = RequestMethod.GET)
public MsgEntity deleteCollectedItem(@AuthUser AuthUserEntity authUser,
- @RequestParam(required = false) String username,
@RequestParam String collectionID,
@RequestParam Integer itemID,
@RequestParam MainType mainType) {
- username = authUser.getAllowOperationUsername(username);
+ String username = authUser.getUsername();
Integer removedItemID = userCollectionService.deleteOneCollectionItem(username, collectionID, itemID, mainType);
if (removedItemID == null) {
@@ -160,16 +164,20 @@ public MsgEntity deleteCollectedItem(@AuthUser AuthUserEntity authUser,
}
// 进行到了此处说明肯定有删除发生
UserBehaviorEntity userBehaviorEntityQuery = new UserBehaviorEntity(itemID, mainType, username, BehaviorType.DO_COLLECTION);
- JSONArray collectionList = (JSONArray) userBehaviorService.findBehaviorRecord(userBehaviorEntityQuery).getExtraInfo(IN_COLLECTION);
- collectionList.remove(collectionID);
- if (collectionList.isEmpty()) {//所有的收藏已经被全部删除了
- // 移除文件收藏量统计
- userCollectionService.collectionStatisticsChange(itemID, "-1", mainType);
- // 移除用户行为记录
- userBehaviorService.deleteBehaviorRecord(userBehaviorEntityQuery);
- } else { // 还有收藏记录存在,更新记录
- userBehaviorService.updateBehaviorRecordExtraInfo(userBehaviorEntityQuery, IN_COLLECTION, collectionList);
+ Object extraInfo = userBehaviorService.findBehaviorRecord(userBehaviorEntityQuery).getExtraInfo(IN_COLLECTION);
+ if (extraInfo instanceof List>) {
+ List collectionList = (List) extraInfo;
+ collectionList.removeIf(id -> id.equals(collectionID));
+
+ if (collectionList.isEmpty()) {//所有的收藏已经被全部删除了
+ // 移除文件收藏量统计
+ userCollectionService.collectionStatisticsChange(itemID, "-1", mainType);
+ // 移除用户行为记录
+ userBehaviorService.deleteBehaviorRecord(userBehaviorEntityQuery);
+ } else { // 还有收藏记录存在,更新记录
+ userBehaviorService.updateBehaviorRecordExtraInfo(userBehaviorEntityQuery, IN_COLLECTION, collectionList);
+ }
}
return new MsgEntity<>(SUCCESS);
}
@@ -182,6 +190,7 @@ public MsgEntity> getCollectionItemList(@AuthUser AuthUserEntity a
username = authUser.getAllowOperationUsername(username);
UserCollectionEntity.CollectionEntity collectionEntity = userCollectionService.getCollectionByUsernameAndCollectionID(username, collectionID, mainType);
+ if (collectionEntity == null) return new MsgEntity<>("SUCCESS", "2", null);
return new MsgEntity<>("SUCCESS", "1", collectionEntity.getItems());
}
}
diff --git a/ocean-collection-service/src/main/java/com/oriole/ocean/service/UserCollectionServiceImpl.java b/ocean-collection-service/src/main/java/com/oriole/ocean/service/UserCollectionServiceImpl.java
index 24f35b2..a54e3dc 100644
--- a/ocean-collection-service/src/main/java/com/oriole/ocean/service/UserCollectionServiceImpl.java
+++ b/ocean-collection-service/src/main/java/com/oriole/ocean/service/UserCollectionServiceImpl.java
@@ -68,6 +68,9 @@ public UserCollectionEntity.CollectionEntity getCollectionByUsernameAndCollectio
AggregationResults results = mongoTemplate.aggregate(aggregation,
getCollectionName(mainType), UserCollectionEntity.CollectionEntity.class);
+
+ System.out.println(results.getMappedResults());
+ if (results.getMappedResults().isEmpty()) return null;
return results.getMappedResults().get(0);
}
diff --git a/ocean-comment-service/src/main/java/com/oriole/ocean/controller/UserCommentController.java b/ocean-comment-service/src/main/java/com/oriole/ocean/controller/UserCommentController.java
index d8ad741..b0e53c5 100644
--- a/ocean-comment-service/src/main/java/com/oriole/ocean/controller/UserCommentController.java
+++ b/ocean-comment-service/src/main/java/com/oriole/ocean/controller/UserCommentController.java
@@ -23,11 +23,13 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
+import javax.xml.stream.events.Comment;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
+import static com.oriole.ocean.common.enumerate.BehaviorType.DO_COMMENT_LIKE;
import static com.oriole.ocean.common.enumerate.ResultCode.SUCCESS;
import static com.oriole.ocean.common.enumerate.ResultCode.UNAUTHORIZED_OPERATION;
@@ -115,16 +117,12 @@ public MsgEntity addComment(@AuthUser AuthUserEntity authUser,
String cid = RandomStringUtils.randomAlphanumeric(8).toUpperCase();
AbstractComment returnEntity;
//构建用户消息事件
- NotifyEntity notifyEntity = new NotifyEntity(NotifyType.REMIND,authUser.getUsername());
- notifyEntity.setTargetIDAndType(String.valueOf(bindID),mainType);
- notifyEntity.setContent(commentContent);
if (!isReply) {
CommentEntity commentEntity = new CommentEntity(cid, authUser.getUsername(), commentContent);
commentService.addComment(bindID, mainType, commentEntity);
+ notifyService.addNotifyByComment(bindID, mainType, commentEntity);
commentEntity.setBuildDate(handleTime(commentEntity.getBuildDate()));
returnEntity = commentEntity;
- notifyEntity.setAction(NotifyAction.NEW_COMMENT);// 新评论事件不面向任何其他评论
-
} else {
CommentReplyEntity fileCommentReplyEntity = new CommentReplyEntity(
replyInCommentID + "_" + cid, authUser.getUsername(),
@@ -132,14 +130,13 @@ public MsgEntity addComment(@AuthUser AuthUserEntity authUser,
replyToCommentReplyID,
commentContent);
commentService.addCommentReply(bindID, mainType, replyInCommentID, fileCommentReplyEntity);
- fileCommentReplyEntity.setBuildDate(handleTime(fileCommentReplyEntity.getBuildDate()));
- returnEntity = fileCommentReplyEntity;
- notifyEntity.setAction(NotifyAction.NEW_REPLY);
if(!replyToCommentReplyID.isEmpty()){
- notifyEntity.setCommentID(replyToCommentReplyID);
+ notifyService.addNotifyByReply(bindID, mainType, replyToCommentReplyID, fileCommentReplyEntity);
}else {
- notifyEntity.setCommentID(replyInCommentID);
+ notifyService.addNotifyByReply(bindID, mainType, replyInCommentID, fileCommentReplyEntity);
}
+ fileCommentReplyEntity.setBuildDate(handleTime(fileCommentReplyEntity.getBuildDate()));
+ returnEntity = fileCommentReplyEntity;
}
// 增加用户消息订阅事件:用户需要订阅自己发布的评论或回复的动态
List notifyActionList = new ArrayList<>();
@@ -148,9 +145,6 @@ public MsgEntity addComment(@AuthUser AuthUserEntity authUser,
notifySubscriptionService.setNotifySubscription(authUser.getUsername(), notifyActionList,
returnEntity.getId(), NotifySubscriptionTargetType.COMMENT);
- // 产生用户消息事件
- notifyService.addNotify(notifyEntity);
-
if (!isReply) {
// 只有评论才计入文章的评论量统计
commentService.commentStatisticsChange(bindID, "+1", mainType);
@@ -172,6 +166,7 @@ public MsgEntity getComment(@RequestParam Integer bindID,
}
List commentEntities = commentService.getComments(bindID, mainType, commentCount, replyCount, pageNum);
//处理评论
+ //commentEntities.removeIf( commentEntity -> commentEntity.getId() == null);
for (CommentEntity comment : commentEntities) {
//处理评论日期信息
comment.setBuildDate(handleTime(comment.getBuildDate()));
@@ -184,6 +179,24 @@ public MsgEntity getComment(@RequestParam Integer bindID,
return new MsgEntity<>("SUCCESS", "1", commentsListEntity);
}
+ @RequestMapping(value = "/getCommentById", method = RequestMethod.GET)
+ public MsgEntity getCommentById(
+ @RequestParam Integer bindID,
+ @RequestParam MainType mainType,
+ @RequestParam String commentID) {
+ CommentEntity commentEntity = commentService.getCommentByCommentID(bindID, mainType, commentID);
+ return new MsgEntity<>("SUCCESS", "1", commentEntity);
+ }
+
+ @RequestMapping(value = "/getCommentReplyByCommentReplyID", method = RequestMethod.GET)
+ public MsgEntity getCommentReplyByCommentReplyID(
+ @RequestParam Integer bindID,
+ @RequestParam MainType mainType,
+ @RequestParam String commentReplyID) {
+ CommentReplyEntity commentReplyEntity = commentService.getCommentReplyByCommentReplyID(bindID, mainType, commentReplyID);
+ return new MsgEntity<>("SUCCESS", "1", commentReplyEntity);
+ }
+
@RequestMapping(value = "/getCommentReply", method = RequestMethod.GET)
public MsgEntity getCommentReply(
@RequestParam Integer bindID,
@@ -217,6 +230,7 @@ public MsgEntity evaluateComment(@AuthUser AuthUserEntity authUser,
@RequestParam Boolean isLike) {
// 添加用户行为
UserBehaviorEntity userBehaviorEntity = new UserBehaviorEntity(bindID, mainType, authUser.getUsername(), null);
+ userBehaviorEntity.setExtraInfo(BehaviorExtraInfo.COMMENT_ID, commentID);
List evaluates = userBehaviorService.checkAndGetUserEvaluateBehavior(userBehaviorEntity, isCancel, isLike);
userBehaviorService.setUserEvaluateBehavior(userBehaviorEntity, evaluates);
@@ -225,6 +239,18 @@ public MsgEntity evaluateComment(@AuthUser AuthUserEntity authUser,
return new MsgEntity<>(SUCCESS);
}
+ @RequestMapping(value = "/findEvaluateRecord", method = RequestMethod.GET)
+ public MsgEntity findEvaluateRecord(@AuthUser AuthUserEntity authUser,
+ @RequestParam Integer bindID,
+ @RequestParam MainType mainType,
+ @RequestParam String commentID) {
+ UserBehaviorEntity userBehaviorEntity = new UserBehaviorEntity(bindID, mainType, authUser.getUsername(), DO_COMMENT_LIKE);
+ userBehaviorEntity.setExtraInfo(BehaviorExtraInfo.COMMENT_ID, commentID);
+
+ boolean ifExists = (userBehaviorService.findBehaviorRecord(userBehaviorEntity) != null);
+ return new MsgEntity<>("SUCCESS", "1", ifExists);
+ }
+
public String handleTime(String buildDate) {
long timeDifference = new Date().getTime() - Long.parseLong(buildDate);
diff --git a/ocean-comment-service/src/main/java/com/oriole/ocean/service/CommentServiceImpl.java b/ocean-comment-service/src/main/java/com/oriole/ocean/service/CommentServiceImpl.java
index af84916..32f1808 100644
--- a/ocean-comment-service/src/main/java/com/oriole/ocean/service/CommentServiceImpl.java
+++ b/ocean-comment-service/src/main/java/com/oriole/ocean/service/CommentServiceImpl.java
@@ -37,7 +37,7 @@ public class CommentServiceImpl {
private FileExtraService fileExtraService;
@DubboReference
- private FileService fileService ;
+ private FileService fileService;
public void commentStatisticsChange(Integer itemID, String addNumber, MainType mainType) {
switch (mainType){
@@ -76,7 +76,7 @@ public boolean isCanAddComment(Integer bindID, String username, MainType mainTyp
}
private String getCollectionName(MainType mainType){
- return "comments_" + mainType.toString();
+ return mainType.toString().toLowerCase() + "_comments";
}
public CommentsListEntity getCommentsListEntity(Integer bindID, MainType mainType) {
@@ -91,7 +91,9 @@ public CommentsListEntity getCommentsListEntity(Integer bindID, MainType mainTyp
public List getComments(Integer bindID, MainType mainType, Integer commentCount, Integer queryReplyCount, Integer pageNum) {
List operations = new ArrayList<>();
operations.add(Aggregation.match(Criteria.where("bindID").is(bindID)));
- operations.add(Aggregation.unwind("comments"));
+ operations.add(Aggregation.match(Criteria.where("comments").exists(true)));
+ operations.add(Aggregation.match(Criteria.where("comments").not().size(0)));
+ operations.add(Aggregation.unwind("comments", true));
operations.add(Aggregation.sort(Sort.by(new Sort.Order(Sort.Direction.DESC, "comments.hotValue")))
.and(Sort.by(new Sort.Order(Sort.Direction.DESC, "comments.likeNumber")))
.and(Sort.by(new Sort.Order(Sort.Direction.ASC, "comments.dislikeNumber"))));
diff --git a/ocean-common/pom.xml b/ocean-common/pom.xml
index e23ede0..a7800c0 100644
--- a/ocean-common/pom.xml
+++ b/ocean-common/pom.xml
@@ -31,7 +31,7 @@
com.baomidou
mybatis-plus
- 3.5.4.1
+ 3.3.2
diff --git a/ocean-common/src/main/java/com/oriole/ocean/common/po/mongo/FavorEntity.java b/ocean-common/src/main/java/com/oriole/ocean/common/po/mongo/FavorEntity.java
new file mode 100644
index 0000000..d288abb
--- /dev/null
+++ b/ocean-common/src/main/java/com/oriole/ocean/common/po/mongo/FavorEntity.java
@@ -0,0 +1,17 @@
+package com.oriole.ocean.common.po.mongo;
+
+import lombok.Data;
+import org.springframework.data.annotation.Id;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+import java.util.Map;
+
+@Data
+@Document(collection = "note_favor")
+public class FavorEntity implements java.io.Serializable {
+ @Id
+ private String id;
+
+ private String username;
+ private String noteId;
+}
diff --git a/ocean-common/src/main/java/com/oriole/ocean/common/po/mysql/NoteCommentEntity.java b/ocean-common/src/main/java/com/oriole/ocean/common/po/mysql/NoteCommentEntity.java
new file mode 100644
index 0000000..64f7be9
--- /dev/null
+++ b/ocean-common/src/main/java/com/oriole/ocean/common/po/mysql/NoteCommentEntity.java
@@ -0,0 +1,53 @@
+package com.oriole.ocean.common.po.mysql;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class NoteCommentEntity implements java.io.Serializable {
+ @TableField("id")
+ private String id;
+
+ @TableField("note_id")
+ private String noteId;
+
+ @TableField("content")
+ private String content;
+
+ @TableField("build_username")
+ private String buildUsername;
+
+ @TableField("like_num")
+ private Integer likeNum;
+
+ @TableField("build_date")
+ private Date buildDate;
+
+ @TableField("is_deleted")
+ private Byte isDeleted;
+
+ @TableField("reply_id")
+ private String replyId;
+
+ @TableField("reply_username")
+ private String replyUsername;
+
+ /**
+ * Whether the current user has liked this comment.
+ * This field is not mapped to the database, only used for data transfer
+ */
+ @TableField(exist = false)
+ private Boolean isLikedByCurrentUser;
+
+ public NoteCommentEntity(
+ String noteId, String buildUsername,
+ String content, String replyId, String replyUsername) {
+ this.noteId = noteId;
+ this.content = content;
+ this.buildUsername = buildUsername;
+ this.replyId = replyId;
+ this.replyUsername = replyUsername;
+ }
+}
diff --git a/ocean-common/src/main/java/com/oriole/ocean/common/po/mysql/NoteCommentLikeEntity.java b/ocean-common/src/main/java/com/oriole/ocean/common/po/mysql/NoteCommentLikeEntity.java
new file mode 100644
index 0000000..52e51f2
--- /dev/null
+++ b/ocean-common/src/main/java/com/oriole/ocean/common/po/mysql/NoteCommentLikeEntity.java
@@ -0,0 +1,48 @@
+package com.oriole.ocean.common.po.mysql;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * Note like record entity
+ * Records the like relationship between users and notes
+ */
+@Data
+@TableName("`note_like`")
+public class NoteCommentLikeEntity implements java.io.Serializable {
+
+ @TableId(value = "id", type = IdType.ASSIGN_ID)
+ private String id;
+
+ @TableField("username")
+ private String username;
+
+ @TableField("comment_id")
+ private String commentId;
+
+ @TableField("like_time")
+ private Date likeTime;
+
+ /**
+ * Default constructor
+ */
+ public NoteCommentLikeEntity() {
+ this.likeTime = new Date();
+ }
+
+ /**
+ * Constructor with username and commentId
+ * @param username The username who likes the comment
+ * @param commentId The ID of the liked comment
+ */
+ public NoteCommentLikeEntity(String username, String commentId) {
+ this.username = username;
+ this.commentId = commentId;
+ this.likeTime = new Date();
+ }
+}
diff --git a/ocean-common/src/main/java/com/oriole/ocean/common/po/mysql/NoteEntity.java b/ocean-common/src/main/java/com/oriole/ocean/common/po/mysql/NoteEntity.java
index d98556d..8305385 100644
--- a/ocean-common/src/main/java/com/oriole/ocean/common/po/mysql/NoteEntity.java
+++ b/ocean-common/src/main/java/com/oriole/ocean/common/po/mysql/NoteEntity.java
@@ -1,7 +1,9 @@
package com.oriole.ocean.common.po.mysql;
+import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.IdType;
import lombok.Data;
import java.time.DateTimeException;
@@ -10,19 +12,46 @@
@Data
@TableName("`note`")
public class NoteEntity implements java.io.Serializable {
- @TableId("note_id")
- private Integer noteID;
+ @TableId(value = "note_id", type = IdType.ASSIGN_ID)
+ private String id;
- private Integer noteType;
+ @TableField("build_username")
+ private String buildUsername;
+
+ @TableField("content")
private String content;
- private Integer likeNum;
- private Integer commentNum;
- private Integer readNum;
- private Date refreshDate;
+
+ @TableField("tag")
+ private String tag;
+
+ @TableField("build_date")
private Date buildDate;
- private String buildUsername;
+
+ @TableField("refresh_date")
+ private Date refreshDate;
+
+ @TableField("is_deleted")
+ private Byte isDeleted;
+
+ @TableField("is_anon")
private Byte isAnon;
- private Byte isApproved;
+
+ @TableField("is_allow_comment")
private Byte isAllowComment;
+ @TableField("like_num")
+ private Integer likeNum;
+
+ @TableField("comment_num")
+ private Integer commentNum;
+
+ @TableField("read_num")
+ private Integer readNum;
+
+ /**
+ * Whether the current user has liked this note
+ * This field is not mapped to database, only used for data transfer
+ */
+ @TableField(exist = false)
+ private Boolean isLikedByCurrentUser;
}
diff --git a/ocean-common/src/main/java/com/oriole/ocean/common/po/mysql/NoteLikeEntity.java b/ocean-common/src/main/java/com/oriole/ocean/common/po/mysql/NoteLikeEntity.java
new file mode 100644
index 0000000..3621733
--- /dev/null
+++ b/ocean-common/src/main/java/com/oriole/ocean/common/po/mysql/NoteLikeEntity.java
@@ -0,0 +1,48 @@
+package com.oriole.ocean.common.po.mysql;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.IdType;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * Note like record entity
+ * Records the like relationship between users and notes
+ */
+@Data
+@TableName("`note_like`")
+public class NoteLikeEntity implements java.io.Serializable {
+
+ @TableId(value = "id", type = IdType.ASSIGN_ID)
+ private String id;
+
+ @TableField("username")
+ private String username;
+
+ @TableField("note_id")
+ private String noteId;
+
+ @TableField("like_time")
+ private Date likeTime;
+
+ /**
+ * Default constructor
+ */
+ public NoteLikeEntity() {
+ this.likeTime = new Date();
+ }
+
+ /**
+ * Constructor with username and noteId
+ * @param username The username who likes the note
+ * @param noteId The ID of the liked note
+ */
+ public NoteLikeEntity(String username, String noteId) {
+ this.username = username;
+ this.noteId = noteId;
+ this.likeTime = new Date();
+ }
+}
diff --git a/ocean-common/src/main/java/com/oriole/ocean/common/po/mysql/NotifyEntity.java b/ocean-common/src/main/java/com/oriole/ocean/common/po/mysql/NotifyEntity.java
index 3560168..3eb7dac 100644
--- a/ocean-common/src/main/java/com/oriole/ocean/common/po/mysql/NotifyEntity.java
+++ b/ocean-common/src/main/java/com/oriole/ocean/common/po/mysql/NotifyEntity.java
@@ -24,7 +24,7 @@ public class NotifyEntity implements java.io.Serializable {
private NotifyType type;
@TableField(value = "target_id")
- private String targetID;
+ private String targetId;
private MainType targetType;
@TableField(value = "comment_id")
@@ -50,8 +50,8 @@ public NotifyEntity(NotifyType type, String buildUsername) {
this.buildDate = new Date();
}
- public void setTargetIDAndType(String targetID,MainType targetType) {
- this.targetID = targetID;
+ public void setTargetIdAndType(String targetId, MainType targetType) {
+ this.targetId = targetId;
this.targetType = targetType;
}
}
diff --git a/ocean-common/src/main/java/com/oriole/ocean/common/service/NoteCommentService.java b/ocean-common/src/main/java/com/oriole/ocean/common/service/NoteCommentService.java
new file mode 100644
index 0000000..02014f5
--- /dev/null
+++ b/ocean-common/src/main/java/com/oriole/ocean/common/service/NoteCommentService.java
@@ -0,0 +1,85 @@
+package com.oriole.ocean.common.service;
+
+import com.oriole.ocean.common.po.mongo.FavorEntity;
+import com.oriole.ocean.common.po.mysql.NoteCommentEntity;
+import com.oriole.ocean.common.po.mysql.NoteCommentLikeEntity;
+import com.oriole.ocean.common.po.mysql.NoteEntity;
+import com.oriole.ocean.common.po.mysql.NoteLikeEntity;
+
+import java.util.List;
+
+/**
+ * Note comment service interface
+ * Provides business logic for note comment operations
+ */
+public interface NoteCommentService {
+
+ /**
+ * Check if user is the creator of a comment
+ * @param commentId Comment ID
+ * @param username Username to check
+ * @return true if user is creator, false otherwise
+ */
+ boolean isCommentCreator(String commentId, String username);
+
+ /**
+ * Delete a note comment
+ * @param commentId Comment ID
+ */
+ void deleteNoteComment(String commentId);
+
+ /**
+ * Get note comments by note ID (for anonymous users)
+ * @param noteId Note ID
+ * @return List of note comments
+ */
+ List getNoteCommentsByNoteId(String noteId);
+
+ /**
+ * Get note comments by note ID with like status (for authenticated users)
+ * @param noteId Note ID
+ * @param username Current user's username
+ * @return List of note comments with like status
+ */
+ List getNoteCommentsByNoteIdWithLikeStatus(String noteId, String username);
+
+ /**
+ * Get note comments by comment ID
+ * @param commentId comment ID
+ * @return note comment
+ */
+ NoteCommentEntity getNoteComment(String commentId);
+
+ /**
+ * Create a new note comment
+ * @param noteCommentEntity Note comment entity to create
+ * @return Created note comment entity
+ */
+ NoteCommentEntity createNoteComment(NoteCommentEntity noteCommentEntity);
+
+
+ /**
+ * Like or unlike a comment
+ * @param username Username who likes/unlikes
+ * @param commentId Comment ID to like/unlike
+ * @param isLike true to like, false to unlike
+ * @return NoteCommentLikeEntity if liked, null if unliked
+ */
+ NoteCommentLikeEntity likeNoteComment(String username, String commentId, boolean isLike);
+
+ /**
+ * Check if a user has liked a specific comment
+ * @param username Username to check
+ * @param commentId Comment ID to check
+ * @return true if liked, false otherwise
+ */
+ boolean hasUserLikedNoteComment(String username, String commentId);
+
+ /**
+ * Get like record for a user and comment
+ * @param username Username
+ * @param commentId Comment ID
+ * @return NoteCommentLikeEntity if exists, null otherwise
+ */
+ NoteCommentLikeEntity getNoteCommentLike(String username, String commentId);
+}
diff --git a/ocean-common/src/main/java/com/oriole/ocean/common/service/NoteService.java b/ocean-common/src/main/java/com/oriole/ocean/common/service/NoteService.java
new file mode 100644
index 0000000..ab53ff3
--- /dev/null
+++ b/ocean-common/src/main/java/com/oriole/ocean/common/service/NoteService.java
@@ -0,0 +1,158 @@
+package com.oriole.ocean.common.service;
+
+import com.oriole.ocean.common.po.mongo.FavorEntity;
+import com.oriole.ocean.common.po.mysql.NoteCommentEntity;
+import com.oriole.ocean.common.po.mysql.NoteEntity;
+import com.oriole.ocean.common.po.mysql.NoteLikeEntity;
+import java.util.List;
+
+/**
+ * Note service interface
+ * Provides business logic for note operations
+ */
+public interface NoteService {
+
+ void changeNoteCommentNum(String noteId, int value);
+
+ /**
+ * Check if user is the creator of a note
+ * @param noteId Note ID
+ * @param username Username to check
+ * @return true if user is creator, false otherwise
+ */
+ boolean isNoteCreator(String noteId, String username);
+
+ void readNote(String noteId);
+
+ /**
+ * Delete a note (soft delete)
+ * @param noteID Note ID to delete
+ */
+ void deleteNote(String noteID);
+
+ /**
+ * Favorite/unfavorite a note
+ * @param username Username
+ * @param isFavor Whether to favor or unfavor
+ * @param noteID Note ID
+ * @param id Existing favor record ID (for unfavor operation)
+ * @return Favor entity or null
+ */
+ FavorEntity favoriteNote(String username, boolean isFavor, String noteID, String id);
+
+ /**
+ * Get note by ID
+ * @param noteID Note ID
+ * @return Note entity
+ */
+ NoteEntity getNoteById(String noteID);
+
+ /**
+ * Get note by ID with like status for current user
+ * @param noteID Note ID
+ * @param username Current user's username
+ * @return Note entity with like status
+ */
+ NoteEntity getNoteByIdWithLikeStatus(String noteID, String username);
+
+ /**
+ * Get user behavior (favorites) for a specific note
+ * @param username Username
+ * @param noteId Note ID
+ * @return Favor entity or null
+ */
+ FavorEntity getBehaviourByUsernameAndNoteId(String username, String noteId);
+
+ /**
+ * Get user behaviors (favorites) list
+ * @param username Username
+ * @param pageNo Page number
+ * @param pageSize Page size
+ * @return List of favor entities
+ */
+ List getBehaviourByUsername(String username, int pageNo, int pageSize);
+
+ /**
+ * Get latest notes
+ * @return List of latest notes
+ */
+ List getLatestNotes();
+
+ /**
+ * Get latest notes with like status for current user
+ * @param username Current user's username
+ * @return List of latest notes with like status
+ */
+ List getLatestNotesWithLikeStatus(String username);
+
+ /**
+ * Get notes by creator name
+ * @param username Current user's name
+ * @return list of notes created by that user
+ */
+ List getNotesByUsernameWithLikeStatus(String username);
+
+ /**
+ * Get notes by keywords
+ * @param searchString Search keywords
+ * @return List of matching notes
+ */
+ List getNotesByKeywords(String searchString);
+
+ /**
+ * Get notes by keywords with like status for current user
+ * @param searchString Search keywords
+ * @param username Current user's username
+ * @return List of matching notes with like status
+ */
+ List getNotesByKeywordsWithLikeStatus(String searchString, String username);
+
+ /**
+ * Get notes by tag
+ * @param tag Note tag
+ * @return List of notes with specified tag
+ */
+ List getNotesByTag(String tag);
+
+ /**
+ * Get notes by tag with like status for current user
+ * @param tag Note tag
+ * @param username Current user's username
+ * @return List of notes with specified tag and like status
+ */
+ List getNotesByTagWithLikeStatus(String tag, String username);
+
+ /**
+ * Create a new note
+ * @param noteEntity Note entity to create
+ * @return Created note entity
+ */
+ NoteEntity createNote(NoteEntity noteEntity);
+
+ // === Like functionality ===
+
+ /**
+ * Like or unlike a note
+ * @param username Username who likes/unlikes
+ * @param noteId Note ID to like/unlike
+ * @param isLike true to like, false to unlike
+ * @return NoteLikeEntity if liked, null if unliked
+ */
+ NoteLikeEntity likeNote(String username, String noteId, boolean isLike);
+
+ /**
+ * Check if a user has liked a specific note
+ * @param username Username to check
+ * @param noteId Note ID to check
+ * @return true if liked, false otherwise
+ */
+ boolean hasUserLikedNote(String username, String noteId);
+
+ /**
+ * Get like record for a user and note
+ * @param username Username
+ * @param noteId Note ID
+ * @return NoteLikeEntity if exists, null otherwise
+ */
+ NoteLikeEntity getNoteLike(String username, String noteId);
+}
diff --git a/ocean-common/src/main/java/com/oriole/ocean/common/service/NotifyService.java b/ocean-common/src/main/java/com/oriole/ocean/common/service/NotifyService.java
index 8a35f08..b144975 100644
--- a/ocean-common/src/main/java/com/oriole/ocean/common/service/NotifyService.java
+++ b/ocean-common/src/main/java/com/oriole/ocean/common/service/NotifyService.java
@@ -1,7 +1,16 @@
package com.oriole.ocean.common.service;
+import com.oriole.ocean.common.enumerate.MainType;
+import com.oriole.ocean.common.po.mongo.UserBehaviorEntity;
+import com.oriole.ocean.common.po.mongo.comment.CommentEntity;
+import com.oriole.ocean.common.po.mongo.comment.CommentReplyEntity;
import com.oriole.ocean.common.po.mysql.NotifyEntity;
public interface NotifyService {
void addNotify(NotifyEntity notifyEntity);
+ void addNotifyByComment(Integer bindID, MainType mainType,
+ CommentEntity fileCommentEntity);
+ void addNotifyByReply(Integer bindID, MainType mainType,
+ String replyInCommentID, CommentReplyEntity fileCommentReplyEntity);
+ void addNotifyByBehaviorRecord(UserBehaviorEntity userBehaviorEntity);
}
diff --git a/ocean-common/src/main/java/com/oriole/ocean/common/vo/OceanExceptionHandler.java b/ocean-common/src/main/java/com/oriole/ocean/common/vo/OceanExceptionHandler.java
index 86fc9d4..f0c2bc9 100644
--- a/ocean-common/src/main/java/com/oriole/ocean/common/vo/OceanExceptionHandler.java
+++ b/ocean-common/src/main/java/com/oriole/ocean/common/vo/OceanExceptionHandler.java
@@ -7,7 +7,7 @@
import java.util.Arrays;
import java.util.Date;
-@Slf4j
+ @Slf4j
public class OceanExceptionHandler {
@Data
diff --git a/ocean-docs-file-service/pom.xml b/ocean-docs-file-service/pom.xml
index 2ee87f3..e7aa5fe 100644
--- a/ocean-docs-file-service/pom.xml
+++ b/ocean-docs-file-service/pom.xml
@@ -148,5 +148,16 @@
org.apache.commons
commons-lang3
+
+
+ org.jodconverter
+ jodconverter-local
+ 4.4.8
+
+
+ org.jodconverter
+ jodconverter-core
+ 4.4.8
+
diff --git a/ocean-docs-file-service/src/main/java/com/oriole/ocean/utils/OpenOfficeUtils.java b/ocean-docs-file-service/src/main/java/com/oriole/ocean/utils/OpenOfficeUtils.java
index 3d35aa4..9fe1022 100644
--- a/ocean-docs-file-service/src/main/java/com/oriole/ocean/utils/OpenOfficeUtils.java
+++ b/ocean-docs-file-service/src/main/java/com/oriole/ocean/utils/OpenOfficeUtils.java
@@ -1,9 +1,9 @@
package com.oriole.ocean.utils;
-import org.jodconverter.OfficeDocumentConverter;
-import org.jodconverter.office.DefaultOfficeManagerBuilder;
-import org.jodconverter.office.OfficeException;
-import org.jodconverter.office.OfficeManager;
+import org.jodconverter.local.LocalConverter;
+import org.jodconverter.local.office.LocalOfficeManager;
+import org.jodconverter.core.office.OfficeException;
+import org.jodconverter.core.office.OfficeManager;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@@ -33,13 +33,14 @@ public OpenOfficeUtils(Boolean useOpenOffice) {
* @throws OfficeException
*/
private OfficeManager getOfficeManager() throws OfficeException {
- DefaultOfficeManagerBuilder builder = new DefaultOfficeManagerBuilder();
+ LocalOfficeManager.Builder builder = LocalOfficeManager.builder();
//此处填写OpenOffice安装路径
if (useOpenOffice) {
- builder.setOfficeHome(OPENOFFICE_PATH);
+ builder.officeHome(OPENOFFICE_PATH);
} else {
- builder.setOfficeHome(LIBREOFFICE_PATH);
+ builder.officeHome(LIBREOFFICE_PATH);
}
+ builder.install();
OfficeManager officeManager = builder.build();
//officeManager提供了开启OpenOffice的API服务
officeManager.start();
@@ -57,8 +58,8 @@ public Boolean openOfficeExperience(String path, String fileName, String suffix,
//设置转换后的文件存储路径,文件名
//使用OfficeDocumentConverter类转换文件,其实核心就这一句
- OfficeDocumentConverter converter = new OfficeDocumentConverter(manage);
- converter.convert(inputTempFile, outputTempFile);
+ LocalConverter converter = LocalConverter.make(manage);
+ converter.convert(inputTempFile).to(outputTempFile).execute();
return true;
} catch (Exception e) {
e.printStackTrace();
diff --git a/ocean-docs-service/src/main/java/com/oriole/ocean/controller/DocInfoController.java b/ocean-docs-service/src/main/java/com/oriole/ocean/controller/DocInfoController.java
index cc17eec..fe63f52 100644
--- a/ocean-docs-service/src/main/java/com/oriole/ocean/controller/DocInfoController.java
+++ b/ocean-docs-service/src/main/java/com/oriole/ocean/controller/DocInfoController.java
@@ -15,18 +15,25 @@
import com.oriole.ocean.common.vo.MsgEntity;
import com.oriole.ocean.service.FileCheckServiceImpl;
import com.oriole.ocean.service.FileServiceImpl;
+import com.oriole.ocean.model.FileInfo;
+import com.oriole.ocean.service.DocInfoService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
+import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
+import java.util.Map;
import static com.oriole.ocean.common.enumerate.ResultCode.*;
+/**
+ * Controller for handling document information related requests.
+ */
@RestController
//@Slf4j
@RequestMapping("/docInfoService")
@@ -41,6 +48,9 @@ public class DocInfoController {
@Autowired
FileCheckServiceImpl fileCheckService;
+ @Autowired
+ private DocInfoService docInfoService;
+
@RequestMapping(value = "/getFileList", method = RequestMethod.GET)
public MsgEntity> getFileList(@AuthUser AuthUserEntity authUser,
@RequestParam(required = false) String username,
@@ -185,4 +195,24 @@ public MsgEntity submitFolderInfo(@AuthUser String username, @RequestPar
fileService.saveOrUpdateFileInfo(new FileEntity(title, abstractContent, username, folderID));
return new MsgEntity<>(SUCCESS);
}
+
+ /**
+ * Retrieves a paginated list of files owned by the current user.
+ *
+ * @param authUser Current authenticated user
+ * @param isFolder Whether to fetch folders (false for files)
+ * @param pageNum Page number for pagination
+ * @param pageSize Number of items per page
+ * @return MsgEntity containing the list of files and pagination info
+ */
+ @GetMapping("/getMyFileList")
+ public MsgEntity