|
|
package com.entity.view;
|
|
|
|
|
|
// 导入公告信息实体类,NewsView 会继承该类
|
|
|
import com.entity.NewsEntity;
|
|
|
// 导入 MyBatis-Plus 用于指定数据库表名的注解
|
|
|
import com.baomidou.mybatisplus.annotations.TableName;
|
|
|
// 导入 Apache Commons BeanUtils 工具类,用于对象属性复制
|
|
|
import org.apache.commons.beanutils.BeanUtils;
|
|
|
// 导入反射调用可能抛出的异常类
|
|
|
import java.lang.reflect.InvocationTargetException;
|
|
|
// 导入 Spring 框架用于日期格式化的注解
|
|
|
import org.springframework.format.annotation.DateTimeFormat;
|
|
|
// 导入 Jackson 用于 JSON 序列化时日期格式化的注解
|
|
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
|
// 导入序列化接口
|
|
|
import java.io.Serializable;
|
|
|
// 导入日期类
|
|
|
import java.util.Date;
|
|
|
|
|
|
/**
|
|
|
* 公告信息
|
|
|
* 后端返回视图实体辅助类
|
|
|
* (通常后端关联的表或者自定义的字段需要返回使用)
|
|
|
*/
|
|
|
// 指定该类对应数据库中的 news 表
|
|
|
@TableName("news")
|
|
|
// NewsView 类继承自 NewsEntity 类,并实现 Serializable 接口,可进行序列化操作
|
|
|
public class NewsView extends NewsEntity implements Serializable {
|
|
|
// 序列化版本号,确保序列化和反序列化的兼容性
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
|
|
/**
|
|
|
* 公告类型的值
|
|
|
*/
|
|
|
// 存储公告类型的具体描述值,例如“紧急通知”“普通公告”等
|
|
|
private String newsValue;
|
|
|
|
|
|
// 无参构造函数,方便创建 NewsView 类的实例
|
|
|
public NewsView() {
|
|
|
|
|
|
}
|
|
|
|
|
|
// 带参构造函数,接收一个 NewsEntity 对象,将其属性复制到当前 NewsView 对象
|
|
|
public NewsView(NewsEntity newsEntity) {
|
|
|
try {
|
|
|
// 使用 BeanUtils 工具类复制属性
|
|
|
BeanUtils.copyProperties(this, newsEntity);
|
|
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
|
|
// 若复制属性过程中出现异常,打印异常堆栈信息
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取: 公告类型的值
|
|
|
*/
|
|
|
// 获取公告类型值的方法
|
|
|
public String getNewsValue() {
|
|
|
return newsValue;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 设置: 公告类型的值
|
|
|
*/
|
|
|
// 设置公告类型值的方法
|
|
|
public void setNewsValue(String newsValue) {
|
|
|
this.newsValue = newsValue;
|
|
|
}
|
|
|
} |