feat(user): 新增用户关注列表查询功能
- 新增查询用户关注列表接口,支持分页查询 - 新增批量查询用户信息接口,提升查询效率 - 优化 MQ 消费模式为顺序消费,确保关注/取关操作有序性 - 完善用户信息 DTO,新增简介字段 - 新增分页响应封装类,支持分页查询结果返回 - 优化 Redis 查询逻辑,支持从缓存中分页获取关注列表 - 新增 Lua 脚本结果类型设置,确保脚本执行结果正确解析 - 添加 HTTP 接口测试用例,覆盖关注列表及批量查询接口 - 实现缓存与数据库双写一致性,提高数据查询性能
This commit is contained in:
@@ -2,16 +2,15 @@ package com.hanserwei.hannote.user.api;
|
||||
|
||||
import com.hanserwei.framework.common.response.Response;
|
||||
import com.hanserwei.hannote.user.constant.ApiConstants;
|
||||
import com.hanserwei.hannote.user.dto.req.FindUserByEmailReqDTO;
|
||||
import com.hanserwei.hannote.user.dto.req.FindUserByIdReqDTO;
|
||||
import com.hanserwei.hannote.user.dto.req.RegisterUserReqDTO;
|
||||
import com.hanserwei.hannote.user.dto.req.UpdateUserPasswordReqDTO;
|
||||
import com.hanserwei.hannote.user.dto.req.*;
|
||||
import com.hanserwei.hannote.user.dto.resp.FindUserByEmailRspDTO;
|
||||
import com.hanserwei.hannote.user.dto.resp.FindUserByIdRspDTO;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@FeignClient(name = ApiConstants.SERVICE_NAME)
|
||||
public interface UserFeignApi {
|
||||
|
||||
@@ -52,4 +51,13 @@ public interface UserFeignApi {
|
||||
*/
|
||||
@PostMapping(value = PREFIX + "/findById")
|
||||
Response<FindUserByIdRspDTO> findById(@RequestBody FindUserByIdReqDTO findUserByIdReqDTO);
|
||||
|
||||
/**
|
||||
* 批量查询用户信息
|
||||
*
|
||||
* @param findUsersByIdsReqDTO 批量查询信息请求
|
||||
* @return 响应
|
||||
*/
|
||||
@PostMapping(value = PREFIX + "/findByIds")
|
||||
Response<List<FindUserByIdRspDTO>> findByIds(@RequestBody FindUsersByIdsReqDTO findUsersByIdsReqDTO);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.hanserwei.hannote.user.dto.req;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class FindFollowingListReqVO {
|
||||
|
||||
@NotNull(message = "查询用户 ID 不能为空")
|
||||
private Long userId;
|
||||
|
||||
@NotNull(message = "页码不能为空")
|
||||
private Integer pageNo = 1; // 默认值为第一页
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.hanserwei.hannote.user.dto.req;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class FindUsersByIdsReqDTO {
|
||||
|
||||
@NotNull(message = "用户 ID 集合不能为空")
|
||||
@Size(min = 1, max = 10, message = "用户 ID 集合大小必须大于等于 1, 小于等于 10")
|
||||
private List<Long> ids;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.hanserwei.hannote.user.dto.resp;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class FindFollowingUserRspVO {
|
||||
|
||||
private Long userId;
|
||||
|
||||
private String avatar;
|
||||
|
||||
private String nickname;
|
||||
|
||||
private String introduction;
|
||||
|
||||
}
|
||||
@@ -25,4 +25,9 @@ public class FindUserByIdRspDTO {
|
||||
* 头像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 简介
|
||||
*/
|
||||
private String introduction;
|
||||
}
|
||||
Reference in New Issue
Block a user