feat(shop): 调整用户查询逻辑以支持根据userId查询

- 修改了 ShopUserController 中的 get 接口路径变量名为 userId- 更新了 ShopUser 实体类,将主键字段从 user_id 改为 id 并添加相应注解
- 在 ShopUserMapper.xml 中增加了根据 id 查询的条件判断
- 为 ShopUserParam 参数类添加了 id 字段及其查询注解
- 确保所有
This commit is contained in:
2025-10-05 11:11:52 +08:00
parent f91ada195a
commit a86e6c37c3
4 changed files with 18 additions and 8 deletions

View File

@@ -47,11 +47,11 @@ public class ShopUserController extends BaseController {
} }
@PreAuthorize("hasAuthority('shop:shopUser:list')") @PreAuthorize("hasAuthority('shop:shopUser:list')")
@Operation(summary = "根据id查询用户记录表") @Operation(summary = "根据userId查询用户记录表")
@GetMapping("/{id}") @GetMapping("/{userId}")
public ApiResult<ShopUser> get(@PathVariable("id") Integer id) { public ApiResult<ShopUser> get(@PathVariable("userId") Integer userId) {
// 使用关联查询 // 使用关联查询
return success(shopUserService.getByIdRel(id)); return success(shopUserService.getByIdRel(userId));
} }
@PreAuthorize("hasAuthority('shop:shopUser:save')") @PreAuthorize("hasAuthority('shop:shopUser:save')")
@@ -125,4 +125,4 @@ public class ShopUserController extends BaseController {
return fail("删除失败"); return fail("删除失败");
} }
} }

View File

@@ -24,8 +24,11 @@ import java.time.LocalDateTime;
public class ShopUser implements Serializable { public class ShopUser implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Schema(description = "id")
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@Schema(description = "用户id") @Schema(description = "用户id")
@TableId(value = "user_id", type = IdType.AUTO)
private Integer userId; private Integer userId;
@Schema(description = "用户类型 0个人用户 1企业用户 2其他") @Schema(description = "用户类型 0个人用户 1企业用户 2其他")
@@ -248,4 +251,4 @@ public class ShopUser implements Serializable {
@Schema(description = "修改时间") @Schema(description = "修改时间")
private LocalDateTime updateTime; private LocalDateTime updateTime;
} }

View File

@@ -7,6 +7,9 @@
SELECT a.* SELECT a.*
FROM shop_user a FROM shop_user a
<where> <where>
<if test="param.id != null">
AND a.id = #{param.id}
</if>
<if test="param.userId != null"> <if test="param.userId != null">
AND a.user_id = #{param.userId} AND a.user_id = #{param.userId}
</if> </if>

View File

@@ -23,6 +23,10 @@ import java.math.BigDecimal;
public class ShopUserParam extends BaseParam { public class ShopUserParam extends BaseParam {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Schema(description = "id")
@QueryField(type = QueryType.EQ)
private Integer id;
@Schema(description = "用户id") @Schema(description = "用户id")
@QueryField(type = QueryType.EQ) @QueryField(type = QueryType.EQ)
private Integer userId; private Integer userId;
@@ -269,4 +273,4 @@ public class ShopUserParam extends BaseParam {
@QueryField(type = QueryType.EQ) @QueryField(type = QueryType.EQ)
private Integer deleted; private Integer deleted;
} }