Browse Source

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

- 修改了 ShopUserController 中的 get 接口路径变量名为 userId- 更新了 ShopUser 实体类,将主键字段从 user_id 改为 id 并添加相应注解
- 在 ShopUserMapper.xml 中增加了根据 id 查询的条件判断
- 为 ShopUserParam 参数类添加了 id 字段及其查询注解
- 确保所有
dev3
科技小王子 1 week ago
parent
commit
a86e6c37c3
  1. 8
      src/main/java/com/gxwebsoft/shop/controller/ShopUserController.java
  2. 5
      src/main/java/com/gxwebsoft/shop/entity/ShopUser.java
  3. 3
      src/main/java/com/gxwebsoft/shop/mapper/xml/ShopUserMapper.xml
  4. 4
      src/main/java/com/gxwebsoft/shop/param/ShopUserParam.java

8
src/main/java/com/gxwebsoft/shop/controller/ShopUserController.java

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

5
src/main/java/com/gxwebsoft/shop/entity/ShopUser.java

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

3
src/main/java/com/gxwebsoft/shop/mapper/xml/ShopUserMapper.xml

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

4
src/main/java/com/gxwebsoft/shop/param/ShopUserParam.java

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

Loading…
Cancel
Save