Skip to content

Commit 22856f5

Browse files
committed
refactor: change type of CommentsAddDTO#copilotId from String to Long
1 parent c77be4f commit 22856f5

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/main/kotlin/plus/maa/backend/controller/request/comments/CommentsAddDTO.kt

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ data class CommentsAddDTO(
1313
@field:NotBlank(message = "请填写评论内容")
1414
val message: String,
1515
// 评论的作业id
16-
@field:NotBlank(message = "作业id不可为空")
17-
val copilotId: String,
16+
val copilotId: Long,
1817
// 子评论来源评论id(回复评论)
1918
val fromCommentId: String? = null,
2019
val notification: Boolean = true

src/main/kotlin/plus/maa/backend/service/CommentsAreaService.kt

+5-3
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class CommentsAreaService(
4848
* @param commentsAddDTO CommentsRequest
4949
*/
5050
fun addComments(userId: String, commentsAddDTO: CommentsAddDTO) {
51-
val copilotId = commentsAddDTO.copilotId.toLong()
51+
val copilotId = commentsAddDTO.copilotId
5252
val message = commentsAddDTO.message
5353
val copilotOptional = copilotRepository.findByCopilotId(copilotId)
5454
Assert.isTrue(StringUtils.isNotBlank(message), "评论不可为空")
@@ -171,8 +171,10 @@ class CommentsAreaService(
171171
val dislikeCountChange: Long
172172

173173
val ratingOptional =
174-
ratingRepository.findByTypeAndKeyAndUserId(Rating.KeyType.COMMENT,
175-
commentsArea.id!!, userId)
174+
ratingRepository.findByTypeAndKeyAndUserId(
175+
Rating.KeyType.COMMENT,
176+
commentsArea.id!!, userId
177+
)
176178
// 判断该用户是否存在评分
177179
if (ratingOptional != null) {
178180
// 如果评分发生变化则更新

0 commit comments

Comments
 (0)