You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gym/JianshenkechengLiuyanEntity...

212 lines
7.7 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

// 包声明实体类包存放所有与数据库表映射的JavaBean对象
package com.entity;
// 字段描述注解:自定义数据库字段元数据
import com.annotation.ColumnInfo;
// 数据校验注解:提供非空、长度等验证规则
import javax.validation.constraints.*;
// JSON序列化配置忽略未定义属性
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
// 反射异常类:处理属性拷贝时的异常
import java.lang.reflect.InvocationTargetException;
// 序列化接口标识
import java.io.Serializable;
// 集合工具类
import java.util.*;
// Apache Ant日期工具代码中未使用建议移除
import org.apache.tools.ant.util.DateUtils;
// Spring日期参数绑定注解
import org.springframework.format.annotation.DateTimeFormat;
// Jackson日期格式化注解
import com.fasterxml.jackson.annotation.JsonFormat;
// Bean属性拷贝工具
import org.apache.commons.beanutils.BeanUtils;
// MyBatis Plus字段注解
import com.baomidou.mybatisplus.annotations.TableField;
// MyBatis Plus主键注解
import com.baomidou.mybatisplus.annotations.TableId;
// MyBatis Plus表名注解
import com.baomidou.mybatisplus.annotations.TableName;
// MyBatis Plus主键策略枚举
import com.baomidou.mybatisplus.enums.IdType;
// MyBatis Plus字段填充策略
import com.baomidou.mybatisplus.enums.FieldFill;
// 自定义日期格式化工具
import com.utils.DateUtil;
// 课程留言实体
// 映射数据库表 jianshenkecheng_liuyan
// 存储用户对健身课程的留言及管理员回复信息
@TableName("jianshenkecheng_liuyan") // 指定关联数据库表名
public class JianshenkechengLiuyanEntity<T> implements Serializable {
// 序列化版本标识(类版本控制)
private static final long serialVersionUID = 1L;
// 空构造器(持久层框架需要)
public JianshenkechengLiuyanEntity() {
}
// 泛型构造器:通过反射进行属性拷贝
public JianshenkechengLiuyanEntity(T t) {
try {
BeanUtils.copyProperties(this, t); // 使用Apache工具类拷贝属性
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace(); // 生产环境建议改为日志记录
}
}
// 主键字段(自增策略)
@TableId(type = IdType.AUTO) // 主键生成策略:数据库自增
@ColumnInfo(comment="主键",type="int(11)") // 字段注释主键数据库类型int(11)
@TableField("id") // 映射数据库字段名
private Integer id; // 唯一标识符
// 关联健身课程ID外键
@ColumnInfo(comment="健身课程",type="int(11)") // 关联jianshenkecheng表主键
@TableField("jianshenkecheng_id")
private Integer jianshenkechengId; // 被评论的课程ID
// 关联用户ID外键
@ColumnInfo(comment="用户",type="int(11)") // 关联yonghu表主键
@TableField("yonghu_id")
private Integer yonghuId; // 留言用户ID
// 留言内容(需考虑敏感词过滤)
@ColumnInfo(comment="留言内容",type="longtext") // 数据库类型longtext
@TableField("jianshenkecheng_liuyan_text")
private String jianshenkechengLiuyanText; // 用户留言正文
// 留言时间(自动填充)
@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; // 用户提交留言时间
// 管理员回复内容null表示未回复
@ColumnInfo(comment="回复内容",type="longtext")
@TableField("reply_text")
private String replyText; // 管理员回复正文
// 回复时间(更新时自动填充)
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ColumnInfo(comment="回复时间",type="timestamp")
@TableField(value = "update_time", fill = FieldFill.UPDATE) // 更新时自动填充
private Date updateTime; // 最后回复/更新时间
// 创建时间与insert_time可能存在冗余
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ColumnInfo(comment="创建时间",type="timestamp")
@TableField(value = "create_time", fill = FieldFill.INSERT)
private Date createTime; // 记录创建时间(建议确认业务需求)
// ----------------------------- Getter/Setter方法 -----------------------------
// 主键访问器
public Integer getId() {
return id;
}
// 主键修改器
public void setId(Integer id) {
this.id = id;
}
// 课程ID访问器
public Integer getJianshenkechengId() {
return jianshenkechengId;
}
// 课程ID修改器应校验课程存在性
public void setJianshenkechengId(Integer jianshenkechengId) {
this.jianshenkechengId = jianshenkechengId;
}
// 用户ID访问器
public Integer getYonghuId() {
return yonghuId;
}
// 用户ID修改器应校验用户存在性
public void setYonghuId(Integer yonghuId) {
this.yonghuId = yonghuId;
}
// 留言内容访问器
public String getJianshenkechengLiuyanText() {
return jianshenkechengLiuyanText;
}
// 留言内容修改器(建议添加敏感词过滤)
public void setJianshenkechengLiuyanText(String jianshenkechengLiuyanText) {
this.jianshenkechengLiuyanText = jianshenkechengLiuyanText;
}
// 留言时间访问器(通常自动生成)
public Date getInsertTime() {
return insertTime;
}
// 留言时间修改器(通常无需手动设置)
public void setInsertTime(Date insertTime) {
this.insertTime = insertTime;
}
// 回复内容访问器
public String getReplyText() {
return replyText;
}
// 回复内容修改器(需权限控制)
public void setReplyText(String replyText) {
this.replyText = replyText;
}
// 回复时间访问器
public Date getUpdateTime() {
return updateTime;
}
// 回复时间修改器(通常自动更新)
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
// 创建时间访问器注意与insert_time区别
public Date getCreateTime() {
return createTime;
}
// 创建时间修改器(需确认业务场景)
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
// 对象字符串表示(调试用)
@Override
public String toString() {
return "JianshenkechengLiuyan{" +
// 主键ID
", id=" + id +
// 关联课程ID
", jianshenkechengId=" + jianshenkechengId +
// 用户ID
", yonghuId=" + yonghuId +
// 留言内容(建议截断显示)
", jianshenkechengLiuyanText=" + jianshenkechengLiuyanText +
// 留言时间(格式化为日期)
", insertTime=" + DateUtil.convertString(insertTime,"yyyy-MM-dd") +
// 回复内容(建议截断显示)
", replyText=" + replyText +
// 最后更新时间(格式化为日期)
", updateTime=" + DateUtil.convertString(updateTime,"yyyy-MM-dd") +
// 记录创建时间
", createTime=" + DateUtil.convertString(createTime,"yyyy-MM-dd") +
"}";
}
}