package com.entity.view; import com.entity.NewsEntity; import com.baomidou.mybatisplus.annotations.TableName; import org.apache.commons.beanutils.BeanUtils; import java.lang.reflect.InvocationTargetException; import java.io.Serializable; /** * 公告信息 * 后端返回视图实体辅助类 * (通常后端关联的表或者自定义的字段需要返回使用) /** * 公告信息 * 后端返回视图实体辅助类 * (通常后端关联的表或者自定义的字段需要返回使用) * @author * @email * @date 2023-02-21 09:46:06 */ @TableName("news") // 指定该类对应的数据库表名为 "news" public class NewsView extends NewsEntity implements Serializable { private static final long serialVersionUID = 1L; // 序列化版本号 // 默认构造函数 public NewsView() { } // 构造函数,接受一个 NewsEntity 对象并复制其属性 public NewsView(NewsEntity newsEntity) { try { BeanUtils.copyProperties(this, newsEntity); // 使用 BeanUtils 复制属性 } catch (IllegalAccessException | InvocationTargetException e) { // 捕获并处理属性复制过程中的异常 e.printStackTrace(); // 打印异常堆栈跟踪 } } }