Skip to content

Commit c85ca9b

Browse files
Merge remote-tracking branch 'origin/dev' into dev
# Conflicts: # ocean-note-service/src/main/java/com/oriole/ocean/controller/NoteController.java # ocean-note-service/src/main/java/com/oriole/ocean/dao/NoteCommentDao.java # ocean-note-service/src/main/java/com/oriole/ocean/service/NoteServiceImpl.java
2 parents b3b1011 + 578dfb3 commit c85ca9b

File tree

15 files changed

+526
-231
lines changed

15 files changed

+526
-231
lines changed

ocean-common/src/main/java/com/oriole/ocean/common/po/mongo/comment/NoteCommentEntity.java

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package com.oriole.ocean.common.po.mysql;
2+
3+
import com.baomidou.mybatisplus.annotation.TableField;
4+
import lombok.Data;
5+
6+
import java.util.Date;
7+
8+
@Data
9+
public class NoteCommentEntity implements java.io.Serializable {
10+
@TableField("id")
11+
private String id;
12+
13+
@TableField("note_id")
14+
private String noteId;
15+
16+
@TableField("content")
17+
private String content;
18+
19+
@TableField("build_username")
20+
private String buildUsername;
21+
22+
@TableField("like_num")
23+
private Integer likeNum;
24+
25+
@TableField("build_date")
26+
private Date buildDate;
27+
28+
@TableField("is_deleted")
29+
private Byte isDeleted;
30+
31+
@TableField("reply_id")
32+
private String replyId;
33+
34+
@TableField("reply_username")
35+
private String replyUsername;
36+
37+
/**
38+
* Whether the current user has liked this comment.
39+
* This field is not mapped to the database, only used for data transfer
40+
*/
41+
@TableField(exist = false)
42+
private Boolean isLikedByCurrentUser;
43+
44+
public NoteCommentEntity(
45+
String noteId, String buildUsername,
46+
String content, String replyId, String replyUsername) {
47+
this.noteId = noteId;
48+
this.content = content;
49+
this.buildUsername = buildUsername;
50+
this.replyId = replyId;
51+
this.replyUsername = replyUsername;
52+
}
53+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package com.oriole.ocean.common.po.mysql;
2+
3+
import com.baomidou.mybatisplus.annotation.IdType;
4+
import com.baomidou.mybatisplus.annotation.TableField;
5+
import com.baomidou.mybatisplus.annotation.TableId;
6+
import com.baomidou.mybatisplus.annotation.TableName;
7+
import lombok.Data;
8+
9+
import java.util.Date;
10+
11+
/**
12+
* Note like record entity
13+
* Records the like relationship between users and notes
14+
*/
15+
@Data
16+
@TableName("`note_like`")
17+
public class NoteCommentLikeEntity implements java.io.Serializable {
18+
19+
@TableId(value = "id", type = IdType.ASSIGN_ID)
20+
private String id;
21+
22+
@TableField("username")
23+
private String username;
24+
25+
@TableField("comment_id")
26+
private String commentId;
27+
28+
@TableField("like_time")
29+
private Date likeTime;
30+
31+
/**
32+
* Default constructor
33+
*/
34+
public NoteCommentLikeEntity() {
35+
this.likeTime = new Date();
36+
}
37+
38+
/**
39+
* Constructor with username and commentId
40+
* @param username The username who likes the comment
41+
* @param commentId The ID of the liked comment
42+
*/
43+
public NoteCommentLikeEntity(String username, String commentId) {
44+
this.username = username;
45+
this.commentId = commentId;
46+
this.likeTime = new Date();
47+
}
48+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package com.oriole.ocean.common.service;
2+
3+
import com.oriole.ocean.common.po.mongo.FavorEntity;
4+
import com.oriole.ocean.common.po.mysql.NoteCommentEntity;
5+
import com.oriole.ocean.common.po.mysql.NoteCommentLikeEntity;
6+
import com.oriole.ocean.common.po.mysql.NoteEntity;
7+
import com.oriole.ocean.common.po.mysql.NoteLikeEntity;
8+
9+
import java.util.List;
10+
11+
/**
12+
* Note service interface
13+
* Provides business logic for note operations
14+
*/
15+
public interface NoteCommentService {
16+
17+
/**
18+
* Check if user is the creator of a comment
19+
* @param commentId Comment ID
20+
* @param username Username to check
21+
* @return true if user is creator, false otherwise
22+
*/
23+
boolean isCommentCreator(String commentId, String username);
24+
25+
/**
26+
* Delete a note comment
27+
* @param commentId Comment ID
28+
*/
29+
void deleteNoteComment(String commentId);
30+
31+
/**
32+
* Get note comments by note ID
33+
* @param noteId Note ID
34+
* @return List of note comments
35+
*/
36+
List<NoteCommentEntity> getNoteCommentsByNoteIdWithLikeStatus(String noteId);
37+
38+
/**
39+
* Get note comments by comment ID
40+
* @param commentId comment ID
41+
* @return note comment
42+
*/
43+
NoteCommentEntity getNoteComment(String commentId);
44+
45+
/**
46+
* Create a new note comment
47+
* @param noteCommentEntity Note comment entity to create
48+
* @return Created note comment entity
49+
*/
50+
NoteCommentEntity createNoteComment(NoteCommentEntity noteCommentEntity);
51+
52+
53+
/**
54+
* Like or unlike a note
55+
* @param username Username who likes/unlikes
56+
* @param commentId Note ID to like/unlike
57+
* @param isLike true to like, false to unlike
58+
* @return NoteLikeEntity if liked, null if unliked
59+
*/
60+
NoteCommentLikeEntity likeNoteComment(String username, String commentId, boolean isLike);
61+
62+
/**
63+
* Check if a user has liked a specific note
64+
* @param username Username to check
65+
* @param commentId Note ID to check
66+
* @return true if liked, false otherwise
67+
*/
68+
boolean hasUserLikedNoteComment(String username, String commentId);
69+
70+
/**
71+
* Get like record for a user and note
72+
* @param username Username
73+
* @param commentId Note ID
74+
* @return NoteLikeEntity if exists, null otherwise
75+
*/
76+
NoteCommentLikeEntity getNoteCommentLike(String username, String commentId);
77+
}

ocean-common/src/main/java/com/oriole/ocean/common/service/NoteService.java

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.oriole.ocean.common.service;
22

33
import com.oriole.ocean.common.po.mongo.FavorEntity;
4-
import com.oriole.ocean.common.po.mongo.comment.NoteCommentEntity;
4+
import com.oriole.ocean.common.po.mysql.NoteCommentEntity;
55
import com.oriole.ocean.common.po.mysql.NoteEntity;
66
import com.oriole.ocean.common.po.mysql.NoteLikeEntity;
77
import java.util.List;
@@ -53,12 +53,6 @@ public interface NoteService {
5353
*/
5454
NoteEntity getNoteByIdWithLikeStatus(String noteID, String username);
5555

56-
/**
57-
* Delete a note comment
58-
* @param commentId Comment ID
59-
*/
60-
void deleteNoteComment(String commentId);
61-
6256
/**
6357
* Get user behavior (favorites) for a specific note
6458
* @param username Username
@@ -126,29 +120,13 @@ public interface NoteService {
126120
*/
127121
List<NoteEntity> getNotesByTagWithLikeStatus(String tag, String username);
128122

129-
/**
130-
* Get note comments by note ID
131-
* @param noteId Note ID
132-
* @param pageNo Page number
133-
* @param pageSize Page size
134-
* @return List of note comments
135-
*/
136-
List<NoteCommentEntity> getNoteCommentsByNoteId(String noteId, int pageNo, int pageSize);
137-
138123
/**
139124
* Create a new note
140125
* @param noteEntity Note entity to create
141126
* @return Created note entity
142127
*/
143128
NoteEntity createNote(NoteEntity noteEntity);
144129

145-
/**
146-
* Create a new note comment
147-
* @param noteCommentEntity Note comment entity to create
148-
* @return Created note comment entity
149-
*/
150-
NoteCommentEntity createNoteComment(NoteCommentEntity noteCommentEntity);
151-
152130
// === Like functionality ===
153131

154132
/**

0 commit comments

Comments
 (0)