refactor(shop): 重构ShopUser实体类和相关组件
- 调整ShopUser实体类字段定义,将id改为userId作为主键 - 更新用户类型枚举描述,从"个人用户/企业用户/其他"改为"普通用户/企业用户/特殊用户" - 在birthday、settlementTime、createTime和updateTime字段添加@JsonFormat注解格式化输出 - 将offline字段类型从Boolean改为Integer以支持更多状态值 - 新增isDefault字段用于标识默认账号,解决多租户相同手机号问题 - 更新ShopUserController中的get方法参数从userId改为id并添加权限验证 - 注释掉ShopUserController中设置当前登录用户id的逻辑 - 修正ShopUserMapper.xml中查询条件的字段映射 - 在ShopUserParam中同步更新字段定义和查询条件配置 - 统一更新所有文件的since注释时间戳信息
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.shop.service.ShopUserService;
|
||||
import com.gxwebsoft.shop.entity.ShopUser;
|
||||
import com.gxwebsoft.shop.param.ShopUserParam;
|
||||
import com.gxwebsoft.shop.service.ShopUserService;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@@ -21,7 +21,7 @@ import java.util.List;
|
||||
* 用户记录表控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-10-03 13:41:09
|
||||
* @since 2026-02-10 00:37:07
|
||||
*/
|
||||
@Tag(name = "用户记录表管理")
|
||||
@RestController
|
||||
@@ -46,11 +46,12 @@ public class ShopUserController extends BaseController {
|
||||
return success(shopUserService.listRel(param));
|
||||
}
|
||||
|
||||
@Operation(summary = "根据userId查询用户记录表")
|
||||
@GetMapping("/{userId}")
|
||||
public ApiResult<ShopUser> get(@PathVariable("userId") Integer userId) {
|
||||
@PreAuthorize("hasAuthority('shop:shopUser:list')")
|
||||
@Operation(summary = "根据id查询用户记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<ShopUser> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(shopUserService.getByIdRel(userId));
|
||||
return success(shopUserService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:shopUser:save')")
|
||||
@@ -59,10 +60,10 @@ public class ShopUserController extends BaseController {
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody ShopUser shopUser) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
shopUser.setUserId(loginUser.getUserId());
|
||||
}
|
||||
// User loginUser = getLoginUser();
|
||||
// if (loginUser != null) {
|
||||
// shopUser.setUserId(loginUser.getUserId());
|
||||
// }
|
||||
if (shopUserService.save(shopUser)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
|
||||
@@ -1,37 +1,34 @@
|
||||
package com.gxwebsoft.shop.entity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import java.time.LocalDate;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import java.io.Serializable;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
/**
|
||||
* 用户记录表
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-10-03 13:41:09
|
||||
* @since 2026-02-10 00:37:07
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(description = "用户记录表")
|
||||
@Schema(name = "ShopUser对象", description = "用户记录表")
|
||||
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其他")
|
||||
@Schema(description = "用户类型 0普通用户 1企业用户 2特殊用户")
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "账号")
|
||||
@@ -71,6 +68,7 @@ public class ShopUser implements Serializable {
|
||||
private String idCard;
|
||||
|
||||
@Schema(description = "出生日期")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private LocalDate birthday;
|
||||
|
||||
@Schema(description = "所在国家")
|
||||
@@ -143,7 +141,7 @@ public class ShopUser implements Serializable {
|
||||
private Integer age;
|
||||
|
||||
@Schema(description = "是否线下会员")
|
||||
private Boolean offline;
|
||||
private Integer offline;
|
||||
|
||||
@Schema(description = "关注数")
|
||||
private Integer followers;
|
||||
@@ -178,6 +176,9 @@ public class ShopUser implements Serializable {
|
||||
@Schema(description = "是否管理员")
|
||||
private Boolean isAdmin;
|
||||
|
||||
@Schema(description = "默认账号(适用于不同租户存在相同的手机号码)")
|
||||
private Boolean isDefault;
|
||||
|
||||
@Schema(description = "是否企业管理员")
|
||||
private Boolean isOrganizationAdmin;
|
||||
|
||||
@@ -209,6 +210,7 @@ public class ShopUser implements Serializable {
|
||||
private Integer expireTime;
|
||||
|
||||
@Schema(description = "最后结算时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime settlementTime;
|
||||
|
||||
@Schema(description = "资质")
|
||||
@@ -246,9 +248,11 @@ public class ShopUser implements Serializable {
|
||||
private Integer tenantId;
|
||||
|
||||
@Schema(description = "注册时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "修改时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.util.List;
|
||||
* 用户记录表Mapper
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-10-03 13:41:09
|
||||
* @since 2026-02-10 00:37:07
|
||||
*/
|
||||
public interface ShopUserMapper extends BaseMapper<ShopUser> {
|
||||
|
||||
|
||||
@@ -7,9 +7,6 @@
|
||||
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>
|
||||
@@ -160,6 +157,9 @@
|
||||
<if test="param.isAdmin != null">
|
||||
AND a.is_admin = #{param.isAdmin}
|
||||
</if>
|
||||
<if test="param.isDefault != null">
|
||||
AND a.is_default = #{param.isDefault}
|
||||
</if>
|
||||
<if test="param.isOrganizationAdmin != null">
|
||||
AND a.is_organization_admin = #{param.isOrganizationAdmin}
|
||||
</if>
|
||||
|
||||
@@ -1,37 +1,32 @@
|
||||
package com.gxwebsoft.shop.param;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import java.math.BigDecimal;
|
||||
import com.gxwebsoft.common.core.annotation.QueryField;
|
||||
import com.gxwebsoft.common.core.annotation.QueryType;
|
||||
import com.gxwebsoft.common.core.web.BaseParam;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 用户记录表查询参数
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-10-03 13:41:08
|
||||
* @since 2026-02-10 00:37:06
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@Schema(description = "用户记录表查询参数")
|
||||
@Schema(name = "ShopUserParam对象", description = "用户记录表查询参数")
|
||||
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;
|
||||
|
||||
@Schema(description = "用户类型 0个人用户 1企业用户 2其他")
|
||||
@Schema(description = "用户类型 0普通用户 1企业用户 2特殊用户")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer type;
|
||||
|
||||
@@ -157,7 +152,7 @@ public class ShopUserParam extends BaseParam {
|
||||
|
||||
@Schema(description = "是否线下会员")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Boolean offline;
|
||||
private Integer offline;
|
||||
|
||||
@Schema(description = "关注数")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
@@ -199,6 +194,10 @@ public class ShopUserParam extends BaseParam {
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Boolean isAdmin;
|
||||
|
||||
@Schema(description = "默认账号(适用于不同租户存在相同的手机号码)")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Boolean isDefault;
|
||||
|
||||
@Schema(description = "是否企业管理员")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Boolean isOrganizationAdmin;
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.util.List;
|
||||
* 用户记录表Service
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-10-03 13:41:09
|
||||
* @since 2026-02-10 00:37:07
|
||||
*/
|
||||
public interface ShopUserService extends IService<ShopUser> {
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.gxwebsoft.shop.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.shop.mapper.ShopUserMapper;
|
||||
import com.gxwebsoft.shop.service.ShopUserService;
|
||||
import com.gxwebsoft.shop.entity.ShopUser;
|
||||
import com.gxwebsoft.shop.param.ShopUserParam;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.shop.entity.ShopUser;
|
||||
import com.gxwebsoft.shop.mapper.ShopUserMapper;
|
||||
import com.gxwebsoft.shop.param.ShopUserParam;
|
||||
import com.gxwebsoft.shop.service.ShopUserService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
@@ -15,7 +15,7 @@ import java.util.List;
|
||||
* 用户记录表Service实现
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-10-03 13:41:09
|
||||
* @since 2026-02-10 00:37:07
|
||||
*/
|
||||
@Service
|
||||
public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> implements ShopUserService {
|
||||
|
||||
Reference in New Issue
Block a user