From d9a9a2afb50afc1deafb7d20d046f60a4045bd70 Mon Sep 17 00:00:00 2001 From: pz2femycj <1468034451@qq.com> Date: Mon, 28 Apr 2025 21:45:34 +0800 Subject: [PATCH] Update YonghuVO.java --- YonghuVO.java | 117 ++++++++++++-------------------------------------- 1 file changed, 28 insertions(+), 89 deletions(-) diff --git a/YonghuVO.java b/YonghuVO.java index 3f7bced..c4fccd2 100644 --- a/YonghuVO.java +++ b/YonghuVO.java @@ -1,124 +1,83 @@ // 包声明 - package com.entity; +package com.entity.vo; -// 导入Java核心库 -import java.io.Serializable; -import java.lang.reflect.InvocationTargetException; -import java.util.Date; +// 导入原用户实体类 +import com.entity.YonghuEntity; -// 导入校验相关注解 -import javax.validation.constraints.*; +// 导入MyBatis Plus表字段注解 +import com.baomidou.mybatisplus.annotations.TableField; +import com.baomidou.mybatisplus.annotations.TableName; -// 导入Jackson注解 -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +// 导入Jackson日期格式化注解 import com.fasterxml.jackson.annotation.JsonFormat; -// 导入Apache工具类 -import org.apache.tools.ant.util.DateUtils; -import org.apache.commons.beanutils.BeanUtils; +// 导入Java核心库 +import java.io.Serializable; +import java.util.Date; -// 导入Spring框架注解 +// 导入Spring日期格式化注解 import org.springframework.format.annotation.DateTimeFormat; -// 导入MyBatis Plus注解 -import com.baomidou.mybatisplus.annotations.TableField; -import com.baomidou.mybatisplus.annotations.TableId; -import com.baomidou.mybatisplus.annotations.TableName; -import com.baomidou.mybatisplus.enums.IdType; -import com.baomidou.mybatisplus.enums.FieldFill; - -// 导入自定义注解和工具类 -import com.annotation.ColumnInfo; -import com.utils.DateUtil; - -// 用户实体类(对应数据库表yonghu) +// 用户手机端接口返回实体辅助类(精简字段) @TableName("yonghu") -public class YonghuEntity implements Serializable { +public class YonghuVO implements Serializable { // 序列化版本UID private static final long serialVersionUID = 1L; - // 无参构造方法 - public YonghuEntity() { - } - - // 带泛型参数的构造方法(通过BeanUtils进行属性拷贝) - public YonghuEntity(T t) { - try { - BeanUtils.copyProperties(this, t); - } catch (IllegalAccessException | InvocationTargetException e) { - // 异常处理(打印堆栈跟踪) - e.printStackTrace(); - } - } - - // 主键(自增) - @TableId(type = IdType.AUTO) - @ColumnInfo(comment = "主键", type = "int(11)") + // 主键字段 @TableField(value = "id") private Integer id; - // 用户账户 - @ColumnInfo(comment = "账户", type = "varchar(200)") + // 用户登录账户 @TableField(value = "username") private String username; - // 登录密码 - @ColumnInfo(comment = "密码", type = "varchar(200)") + // 用户登录密码 @TableField(value = "password") private String password; // 用户真实姓名 - @ColumnInfo(comment = "用户名称", type = "varchar(200)") @TableField(value = "yonghu_name") private String yonghuName; // 用户手机号码 - @ColumnInfo(comment = "用户手机号", type = "varchar(200)") @TableField(value = "yonghu_phone") private String yonghuPhone; // 用户身份证号码 - @ColumnInfo(comment = "用户身份证号", type = "varchar(200)") @TableField(value = "yonghu_id_number") private String yonghuIdNumber; // 用户头像存储路径 - @ColumnInfo(comment = "用户头像", type = "varchar(200)") @TableField(value = "yonghu_photo") private String yonghuPhoto; - // 性别(0=未知,1=男,2=女) - @ColumnInfo(comment = "性别", type = "int(11)") + // 性别类型(0=未知,1=男,2=女) @TableField(value = "sex_types") private Integer sexTypes; // 用户电子邮箱 - @ColumnInfo(comment = "用户邮箱", type = "varchar(200)") @TableField(value = "yonghu_email") private String yonghuEmail; - // 账户余额(十进制类型) - @ColumnInfo(comment = "现有余额", type = "decimal(10,2)") + // 用户账户余额 @TableField(value = "new_money") private Double newMoney; // 逻辑删除标记(0=正常,1=删除) - @ColumnInfo(comment = "逻辑删除", type = "int(11)") @TableField(value = "data_delete") private Integer dataDelete; - // 数据插入时间(自动填充) + // 数据插入时间(带格式化注解) @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat - @ColumnInfo(comment = "添加时间", type = "timestamp") - @TableField(value = "insert_time", fill = FieldFill.INSERT) + @TableField(value = "insert_time") private Date insertTime; - // 记录创建时间(自动填充) + // 记录创建时间(带格式化注解) @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat - @ColumnInfo(comment = "创建时间", type = "timestamp") - @TableField(value = "create_time", fill = FieldFill.INSERT) + @TableField(value = "create_time") private Date createTime; // 获取主键ID @@ -131,12 +90,12 @@ public class YonghuEntity implements Serializable { this.id = id; } - // 获取用户账户 + // 获取登录账户 public String getUsername() { return username; } - // 设置用户账户 + // 设置登录账户 public void setUsername(String username) { this.username = username; } @@ -161,12 +120,12 @@ public class YonghuEntity implements Serializable { this.yonghuName = yonghuName; } - // 获取用户手机号 + // 获取手机号码 public String getYonghuPhone() { return yonghuPhone; } - // 设置用户手机号 + // 设置手机号码 public void setYonghuPhone(String yonghuPhone) { this.yonghuPhone = yonghuPhone; } @@ -201,12 +160,12 @@ public class YonghuEntity implements Serializable { this.sexTypes = sexTypes; } - // 获取用户邮箱 + // 获取电子邮箱 public String getYonghuEmail() { return yonghuEmail; } - // 设置用户邮箱 + // 设置电子邮箱 public void setYonghuEmail(String yonghuEmail) { this.yonghuEmail = yonghuEmail; } @@ -250,24 +209,4 @@ public class YonghuEntity implements Serializable { public void setCreateTime(Date createTime) { this.createTime = createTime; } - - // 重写toString方法(返回对象字符串表示) - @Override - public String toString() { - return "Yonghu{" + - ", id=" + id + - ", username=" + username + - ", password=" + password + - ", yonghuName=" + yonghuName + - ", yonghuPhone=" + yonghuPhone + - ", yonghuIdNumber=" + yonghuIdNumber + - ", yonghuPhoto=" + yonghuPhoto + - ", sexTypes=" + sexTypes + - ", yonghuEmail=" + yonghuEmail + - ", newMoney=" + newMoney + - ", dataDelete=" + dataDelete + - ", insertTime=" + DateUtil.convertString(insertTime, "yyyy-MM-dd") + - ", createTime=" + DateUtil.convertString(createTime, "yyyy-MM-dd") + - "}"; - } } \ No newline at end of file