|
@@ -1,22 +1,26 @@
|
|
|
package com.sf.user.controller;
|
|
|
|
|
|
+import com.sf.book.client.BookFeign;
|
|
|
+import com.sf.book.dto.BookCommentRespDto;
|
|
|
+import com.sf.core.dto.PageReqDto;
|
|
|
+import com.sf.core.dto.PageRespDto;
|
|
|
import com.sf.core.dto.RestResp;
|
|
|
import com.sf.user.dto.req.UserLoginReqDto;
|
|
|
import com.sf.user.dto.req.UserRegisterReqDto;
|
|
|
-import com.sf.user.dto.resp.ImgVerifyCodeRespDto;
|
|
|
-import com.sf.user.dto.resp.UserInfoRespDto;
|
|
|
-import com.sf.user.dto.resp.UserLoginRespDto;
|
|
|
-import com.sf.user.dto.resp.UserRegisterRespDto;
|
|
|
+import com.sf.user.dto.resp.*;
|
|
|
import com.sf.user.entity.UserInfo;
|
|
|
import com.sf.user.service.IUserInfoService;
|
|
|
import com.sf.user.util.UserHolder;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -28,11 +32,11 @@ import java.io.IOException;
|
|
|
*/
|
|
|
@Tag(name = "UserInfoController", description = "用户信息模块")
|
|
|
@RestController
|
|
|
-//@RequestMapping("/userInfo")
|
|
|
+@RequiredArgsConstructor
|
|
|
public class UserInfoController {
|
|
|
|
|
|
- @Autowired
|
|
|
- private IUserInfoService userInfoService;
|
|
|
+ private final IUserInfoService userInfoService;
|
|
|
+ private final BookFeign bookFeign;
|
|
|
|
|
|
// @Autowired
|
|
|
// private IBookCommentService bookCommentService;
|
|
@@ -92,13 +96,27 @@ public class UserInfoController {
|
|
|
return RestResp.ok(userInfoRespDto);
|
|
|
}
|
|
|
|
|
|
-// // 查询我的评论
|
|
|
-// @Operation(summary = "查询我的评论接口")
|
|
|
-// @GetMapping("/api/front/user/comments")
|
|
|
-// public RestResp<PageRespDto<UserCommentRespDto>> listComments(PageReqDto pageReqDto) {
|
|
|
-// Long userId = UserHolder.getUserId();
|
|
|
+ // 查询我的评论
|
|
|
+ @Operation(summary = "查询我的评论接口")
|
|
|
+ @GetMapping("/api/front/user/comments")
|
|
|
+ public RestResp<PageRespDto<UserCommentRespDto>> listComments(PageReqDto pageReqDto) {
|
|
|
+ Long userId = UserHolder.getUserId();
|
|
|
+ // 将原来直接从book_comment表中匹配的数据 变成调用novel_book微服务
|
|
|
// PageRespDto<UserCommentRespDto> commentList = bookCommentService.getCommentList(userId, pageReqDto);
|
|
|
// return RestResp.ok(commentList);
|
|
|
-// }
|
|
|
+ RestResp<PageRespDto<BookCommentRespDto>> listComments =
|
|
|
+ bookFeign.listCommentsByUserId(userId, pageReqDto.getPageNum(), pageReqDto.getPageSize());
|
|
|
+ // 做一个类型转换
|
|
|
+ PageRespDto<BookCommentRespDto> data = listComments.getData();
|
|
|
+ List<? extends BookCommentRespDto> list = data.getList();
|
|
|
+ List<UserCommentRespDto> respDtoList = list.stream().map(bookCommentRespDto -> {
|
|
|
+ UserCommentRespDto userCommentRespDto = new UserCommentRespDto();
|
|
|
+ BeanUtils.copyProperties(bookCommentRespDto, userCommentRespDto);
|
|
|
+ return userCommentRespDto;
|
|
|
+ }).toList();
|
|
|
+ PageRespDto<UserCommentRespDto> userCommentRespDtos = PageRespDto.of(
|
|
|
+ data.getPageNum(), data.getPageSize(), data.getTotal(), respDtoList);
|
|
|
+ return RestResp.ok(userCommentRespDtos);
|
|
|
+ }
|
|
|
|
|
|
}
|