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.
hotels/back/src/main/java/com/entity/StoreupEntity.java

188 lines
6.3 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.

// 声明该类所属的包为 com.entity通常用于存放数据库实体相关的类
package com.entity;
// 导入 MyBatis-Plus 框架的 TableId 注解,用于标识数据库表的主键字段
import com.baomidou.mybatisplus.annotations.TableId;
// 导入 MyBatis-Plus 框架的 TableName 注解,用于指定该实体类对应的数据库表名
import com.baomidou.mybatisplus.annotations.TableName;
// 导入 JSR-303 验证框架中的 NotBlank 注解,用于确保字符串字段不为空且去除首尾空格后长度大于 0
import javax.validation.constraints.NotBlank;
// 导入 JSR-303 验证框架中的 NotEmpty 注解,用于确保集合、数组或字符串等不为空
import javax.validation.constraints.NotEmpty;
// 导入 JSR-303 验证框架中的 NotNull 注解,用于确保对象字段不为空
import javax.validation.constraints.NotNull;
// 导入 Jackson 库的 JsonIgnoreProperties 注解,用于在序列化和反序列化时忽略指定属性
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
// 导入反射操作中可能抛出的 InvocationTargetException 异常类
import java.lang.reflect.InvocationTargetException;
// 导入 Serializable 接口,实现该接口的类的对象可进行序列化和反序列化操作
import java.io.Serializable;
// 导入 Date 类,用于处理日期和时间相关的数据
import java.util.Date;
// 导入 List 接口,用于表示一组对象的集合(当前代码未实际使用该接口相关功能,但导入了对应的包)
import java.util.List;
// 导入 Spring 框架的 DateTimeFormat 注解,用于指定日期在接收参数时的格式
import org.springframework.format.annotation.DateTimeFormat;
// 导入 Jackson 库的 JsonFormat 注解,用于指定日期在序列化时的格式
import com.fasterxml.jackson.annotation.JsonFormat;
// 导入 Apache Commons BeanUtils 工具类,用于复制 JavaBean 的属性
import org.apache.commons.beanutils.BeanUtils;
// 导入 MyBatis-Plus 框架的 TableField 注解,用于设置字段在数据库表中的相关属性(当前代码未实际使用该注解,但导入了对应的包)
import com.baomidou.mybatisplus.annotations.TableField;
// 导入 MyBatis-Plus 框架的 FieldFill 枚举,用于指定字段的填充策略(当前代码未实际使用该枚举,但导入了对应的包)
import com.baomidou.mybatisplus.enums.FieldFill;
// 导入 MyBatis-Plus 框架的 IdType 枚举,用于指定主键的生成策略
import com.baomidou.mybatisplus.enums.IdType;
/**
* 收藏表
* 数据库通用操作实体类(普通增删改查)
* @author 作者信息未填写
* @email 邮箱信息未填写
* @date 2022-04-04 00:20:04
*/
// 使用 TableName 注解指定该实体类对应的数据库表名为 "storeup"
@TableName("storeup")
// 定义 StoreupEntity 类,使用泛型 T实现 Serializable 接口
public class StoreupEntity<T> implements Serializable {
// 定义序列化版本号,用于在序列化和反序列化过程中保持类的版本一致性
private static final long serialVersionUID = 1L;
// 无参构造函数,用于创建 StoreupEntity 对象时不传入任何参数
public StoreupEntity() {
}
// 带参数的构造函数,通过传入的泛型对象 t 复制属性到当前对象
public StoreupEntity(T t) {
try {
// 使用 BeanUtils 的 copyProperties 方法将 t 对象的属性复制到当前对象
BeanUtils.copyProperties(this, t);
} catch (IllegalAccessException | InvocationTargetException e) {
// 如果在复制属性过程中出现非法访问异常或反射调用目标异常
// 简单打印异常堆栈信息,后续可根据实际情况完善异常处理逻辑
e.printStackTrace();
}
}
// 使用 TableId 注解标识该字段为主键
// 主键 id用于唯一标识数据库表中的每条记录
@TableId
private Long id;
// 用户 id 字段,用于存储收藏操作对应的用户的 id
private Long userid;
// 收藏 id 字段,用于标识被收藏的具体对象的 id
private Long refid;
// 表名字段,用于记录收藏对象所在的表名
private String tablename;
// 收藏名称字段,用于存储被收藏对象的名称
private String name;
// 收藏图片字段,用于存储与收藏对象相关的图片信息(如图片路径等)
private String picture;
// 类型字段用于标识操作类型1:收藏,21:赞,22:踩)
private String type;
// 推荐类型字段,用于记录收藏的推荐类型相关信息
private String inteltype;
// 使用 JsonFormat 注解指定日期在序列化时的格式为 "yyyy-MM-dd HH:mm:ss",时区为 GMT+8
// 使用 DateTimeFormat 注解,用于处理日期格式相关的转换
@JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat
private Date addtime;
// 获取记录添加时间的方法
public Date getAddtime() {
return addtime;
}
// 设置记录添加时间的方法
public void setAddtime(Date addtime) {
this.addtime = addtime;
}
// 获取主键 id 的方法
public Long getId() {
return id;
}
// 设置主键 id 的方法
public void setId(Long id) {
this.id = id;
}
// 设置用户 id 的方法
public void setUserid(Long userid) {
this.userid = userid;
}
// 获取用户 id 的方法
public Long getUserid() {
return userid;
}
// 设置收藏 id 的方法
public void setRefid(Long refid) {
this.refid = refid;
}
// 获取收藏 id 的方法
public Long getRefid() {
return refid;
}
// 设置表名的方法
public void setTablename(String tablename) {
this.tablename = tablename;
}
// 获取表名的方法
public String getTablename() {
return tablename;
}
// 设置收藏名称的方法
public void setName(String name) {
this.name = name;
}
// 获取收藏名称的方法
public String getName() {
return name;
}
// 设置收藏图片的方法
public void setPicture(String picture) {
this.picture = picture;
}
// 获取收藏图片的方法
public String getPicture() {
return picture;
}
// 设置类型的方法
public void setType(String type) {
this.type = type;
}
// 获取类型的方法
public String getType() {
return type;
}
// 设置推荐类型的方法
public void setInteltype(String inteltype) {
this.inteltype = inteltype;
}
// 获取推荐类型的方法
public String getInteltype() {
return inteltype;
}
}