Update JianshenkechengCollectionEntity.java

王刚注释
pz2femycj 4 months ago
parent c88ddc02de
commit 68613f0b1e

@ -1,195 +1,170 @@
package com.entity; // 包声明实体类包存放所有与数据库表映射的JavaBean对象
package com.entity;
import com.annotation.ColumnInfo;
import javax.validation.constraints.*; // 字段注解:自定义数据库字段描述信息
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.annotation.ColumnInfo;
import java.lang.reflect.InvocationTargetException; // 数据校验注解:非空、范围等验证规则
import java.io.Serializable; import javax.validation.constraints.*;
import java.util.*; // JSON序列化注解忽略未定义字段
import org.apache.tools.ant.util.DateUtils; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.springframework.format.annotation.DateTimeFormat; // 反射异常类:用于处理属性拷贝时的异常
import com.fasterxml.jackson.annotation.JsonFormat; import java.lang.reflect.InvocationTargetException;
import org.apache.commons.beanutils.BeanUtils; // 序列化接口标识
import com.baomidou.mybatisplus.annotations.TableField; import java.io.Serializable;
import com.baomidou.mybatisplus.annotations.TableId; // 集合工具类
import com.baomidou.mybatisplus.annotations.TableName; import java.util.*;
import com.baomidou.mybatisplus.enums.IdType; // Apache Ant日期工具代码中未实际使用建议检查是否冗余
import com.baomidou.mybatisplus.enums.FieldFill; import org.apache.tools.ant.util.DateUtils;
import com.utils.DateUtil; // Spring日期格式注解请求参数绑定
import org.springframework.format.annotation.DateTimeFormat;
// Jackson日期格式注解响应数据格式化
/** import com.fasterxml.jackson.annotation.JsonFormat;
* // Bean工具类对象属性拷贝
* import org.apache.commons.beanutils.BeanUtils;
* @author // MyBatis Plus字段注解
* @email import com.baomidou.mybatisplus.annotations.TableField;
*/ // MyBatis Plus主键注解
@TableName("jianshenkecheng_collection") import com.baomidou.mybatisplus.annotations.TableId;
public class JianshenkechengCollectionEntity<T> implements Serializable { // MyBatis Plus表名注解
private static final long serialVersionUID = 1L; import com.baomidou.mybatisplus.annotations.TableName;
// MyBatis Plus主键策略枚举
import com.baomidou.mybatisplus.enums.IdType;
public JianshenkechengCollectionEntity() { // MyBatis Plus字段填充策略枚举
import com.baomidou.mybatisplus.enums.FieldFill;
} // 自定义日期工具类
import com.utils.DateUtil;
public JianshenkechengCollectionEntity(T t) {
try {
BeanUtils.copyProperties(this, t); @TableName("jianshenkecheng_collection") // 指定关联数据库表名
} catch (IllegalAccessException | InvocationTargetException e) { public class JianshenkechengCollectionEntity<T> implements Serializable {
// TODO Auto-generated catch block // 序列化版本UID类版本控制
e.printStackTrace(); private static final long serialVersionUID = 1L;
}
} // 空参构造器JPA/MyBatis等框架需要
public JianshenkechengCollectionEntity() {
/** }
*
*/ // 泛型构造器:通过反射将泛型对象属性拷贝到当前实体
@TableId(type = IdType.AUTO) public JianshenkechengCollectionEntity(T t) {
@ColumnInfo(comment="主键",type="int(11)") try {
@TableField(value = "id") // 使用Apache BeanUtils进行属性拷贝
BeanUtils.copyProperties(this, t);
private Integer id; } catch (IllegalAccessException | InvocationTargetException e) {
// 异常处理(建议生产环境改为日志记录)
e.printStackTrace();
/** }
* }
*/
@ColumnInfo(comment="健身课程",type="int(11)") // 主键字段
@TableField(value = "jianshenkecheng_id") @TableId(type = IdType.AUTO) // 主键自增策略
@ColumnInfo(comment="主键",type="int(11)") // 字段注释主键数据库类型int(11)
private Integer jianshenkechengId; @TableField(value = "id") // 映射数据库字段名(可省略,默认驼峰转下划线)
private Integer id;
/** // 关联健身课程ID外键
* @ColumnInfo(comment="健身课程",type="int(11)") // 字段注释:关联健身课程表
*/ @TableField(value = "jianshenkecheng_id") // 数据库字段名
@ColumnInfo(comment="用户",type="int(11)") private Integer jianshenkechengId;
@TableField(value = "yonghu_id")
// 关联用户ID外键
private Integer yonghuId; @ColumnInfo(comment="用户",type="int(11)") // 字段注释:关联用户表
@TableField(value = "yonghu_id") // 数据库字段名
private Integer yonghuId;
/**
* // 收藏类型(需配合字典表或枚举类使用)
*/ @ColumnInfo(comment="类型",type="int(11)") // 字段注释1-收藏 2-点赞等类型
@ColumnInfo(comment="类型",type="int(11)") @TableField(value = "jianshenkecheng_collection_types")
@TableField(value = "jianshenkecheng_collection_types") private Integer jianshenkechengCollectionTypes;
private Integer jianshenkechengCollectionTypes; // 收藏时间(插入时自动填充)
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") // 响应JSON格式
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") // 请求参数格式
/** @ColumnInfo(comment="收藏时间",type="timestamp") // 数据库类型timestamp
* @TableField(value = "insert_time",fill = FieldFill.INSERT) // 插入时自动填充
*/ private Date insertTime;
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
@DateTimeFormat // 创建时间与insert_time可能存在冗余
@ColumnInfo(comment="收藏时间",type="timestamp") @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
@TableField(value = "insert_time",fill = FieldFill.INSERT) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ColumnInfo(comment="创建时间",type="timestamp")
private Date insertTime; @TableField(value = "create_time",fill = FieldFill.INSERT) // 与insert_time同样使用插入填充需确认业务需求
private Date createTime;
/** // Getter/Setter方法
* // ----------------------------
*/
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") // 主键访问器
@DateTimeFormat public Integer getId() {
@ColumnInfo(comment="创建时间",type="timestamp") return id;
@TableField(value = "create_time",fill = FieldFill.INSERT) }
private Date createTime; // 主键修改器
public void setId(Integer id) {
this.id = id;
/** }
*
*/ // 健身课程ID访问器
public Integer getId() { public Integer getJianshenkechengId() {
return id; return jianshenkechengId;
} }
/**
* // 健身课程ID修改器
*/ public void setJianshenkechengId(Integer jianshenkechengId) {
this.jianshenkechengId = jianshenkechengId;
public void setId(Integer id) { }
this.id = id;
} // 用户ID访问器
/** public Integer getYonghuId() {
* return yonghuId;
*/ }
public Integer getJianshenkechengId() {
return jianshenkechengId; // 用户ID修改器
} public void setYonghuId(Integer yonghuId) {
/** this.yonghuId = yonghuId;
* }
*/
// 收藏类型访问器
public void setJianshenkechengId(Integer jianshenkechengId) { public Integer getJianshenkechengCollectionTypes() {
this.jianshenkechengId = jianshenkechengId; return jianshenkechengCollectionTypes;
} }
/**
* // 收藏类型修改器(建议使用枚举限定值)
*/ public void setJianshenkechengCollectionTypes(Integer jianshenkechengCollectionTypes) {
public Integer getYonghuId() { this.jianshenkechengCollectionTypes = jianshenkechengCollectionTypes;
return yonghuId; }
}
/** // 收藏时间访问器
* public Date getInsertTime() {
*/ return insertTime;
}
public void setYonghuId(Integer yonghuId) {
this.yonghuId = yonghuId; // 收藏时间修改器(通常自动填充,无需手动设置)
} public void setInsertTime(Date insertTime) {
/** this.insertTime = insertTime;
* }
*/
public Integer getJianshenkechengCollectionTypes() { // 创建时间访问器
return jianshenkechengCollectionTypes; public Date getCreateTime() {
} return createTime;
/** }
*
*/ // 创建时间修改器通常自动填充需确认与insert_time的区别
public void setCreateTime(Date createTime) {
public void setJianshenkechengCollectionTypes(Integer jianshenkechengCollectionTypes) { this.createTime = createTime;
this.jianshenkechengCollectionTypes = jianshenkechengCollectionTypes; }
}
/** // 对象字符串表示(调试用)
* @Override
*/ public String toString() {
public Date getInsertTime() { return "JianshenkechengCollection{" +
return insertTime; ", id=" + id +
} ", jianshenkechengId=" + jianshenkechengId +
/** ", yonghuId=" + yonghuId +
* ", jianshenkechengCollectionTypes=" + jianshenkechengCollectionTypes +
*/ // 使用自定义工具类格式化日期注意格式化为yyyy-MM-dd会丢失时间精度
", insertTime=" + DateUtil.convertString(insertTime,"yyyy-MM-dd") +
public void setInsertTime(Date insertTime) { ", createTime=" + DateUtil.convertString(createTime,"yyyy-MM-dd") +
this.insertTime = insertTime; "}";
} }
/** }
*
*/
public Date getCreateTime() {
return createTime;
}
/**
*
*/
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
@Override
public String toString() {
return "JianshenkechengCollection{" +
", id=" + id +
", jianshenkechengId=" + jianshenkechengId +
", yonghuId=" + yonghuId +
", jianshenkechengCollectionTypes=" + jianshenkechengCollectionTypes +
", insertTime=" + DateUtil.convertString(insertTime,"yyyy-MM-dd") +
", createTime=" + DateUtil.convertString(createTime,"yyyy-MM-dd") +
"}";
}
}
Loading…
Cancel
Save