mirror of
https://github.com/201206030/novel.git
synced 2025-04-27 07:30:50 +00:00
feat: 增加删除评论接口
This commit is contained in:
parent
85c6d9119d
commit
f163c77cf6
@ -80,6 +80,14 @@ public class UserController {
|
||||
return bookService.saveComment(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除评论接口
|
||||
* */
|
||||
@DeleteMapping("comment/{id}")
|
||||
public RestResp<Void> deleteComment(@PathVariable Long id) {
|
||||
return bookService.deleteComment(UserHolder.getUserId(),id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询书架状态接口
|
||||
* 0-不在书架
|
||||
|
@ -27,6 +27,8 @@ public class BookCommentRespDto {
|
||||
@Builder
|
||||
public static class CommentInfo {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String commentContent;
|
||||
|
||||
@JsonSerialize(using = UsernameSerializer.class)
|
||||
|
@ -133,4 +133,12 @@ public interface BookService {
|
||||
* @return 小说最新评论数据
|
||||
*/
|
||||
RestResp<BookCommentRespDto> listNewestComments(Long bookId);
|
||||
|
||||
/**
|
||||
* 删除评论
|
||||
* @param userId 评论用户ID
|
||||
* @param commentId 评论ID
|
||||
* @return void
|
||||
* */
|
||||
RestResp<Void> deleteComment(Long userId, Long commentId);
|
||||
}
|
||||
|
@ -247,6 +247,7 @@ public class BookServiceImpl implements BookService {
|
||||
Map<Long, String> userInfoMap = userInfos.stream().collect(Collectors.toMap(UserInfo::getId, UserInfo::getUsername));
|
||||
List<BookCommentRespDto.CommentInfo> commentInfos = bookComments.stream()
|
||||
.map(v -> BookCommentRespDto.CommentInfo.builder()
|
||||
.id(v.getId())
|
||||
.commentUser(userInfoMap.get(v.getUserId()))
|
||||
.commentContent(v.getCommentContent())
|
||||
.commentTime(v.getCreateTime()).build()).toList();
|
||||
@ -257,6 +258,15 @@ public class BookServiceImpl implements BookService {
|
||||
return RestResp.ok(bookCommentRespDto);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestResp<Void> deleteComment(Long userId, Long commentId) {
|
||||
QueryWrapper<BookComment> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq(DatabaseConsts.CommonColumnEnum.ID.getName(), commentId)
|
||||
.eq(DatabaseConsts.BookCommentTable.COLUMN_USER_ID,userId);
|
||||
bookCommentMapper.delete(queryWrapper);
|
||||
return RestResp.ok();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestResp<BookContentAboutRespDto> getBookContentAbout(Long chapterId) {
|
||||
// 查询章节信息
|
||||
|
Loading…
x
Reference in New Issue
Block a user