package cn.com.ty.lift.push.websocket.dao.entity.model;

import cn.com.ty.lift.push.websocket.dao.entity.TimeyMessage;
import lombok.Data;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.beanutils.converters.DateConverter;

import java.lang.reflect.InvocationTargetException;
import java.math.BigDecimal;
import java.util.Date;

/**
 * @ClassName TimeyMessageVo
 * @Description
 * @Author huangyuan
 * @Date 2019-04-19 14:39
 **/
@Data
public class TimeyMessageVo {
    private String id;

    private String userId;//用户id

    private String content;//内容

    private String type;//类型

    private String objectId;//主体id

    private String viewFlag;//查看标识:1:已经查看, 0:未查看

    private Date createTime;

    public TimeyMessageVo(){}

    public TimeyMessageVo(TimeyMessage timeyMessage) {
        try {
            //info:进行beans拷贝，解决时间出现了空值而无法进行复制
            ConvertUtils.register(new DateConverter(null), Date.class);
            ConvertUtils.register(new DateConverter(null), BigDecimal.class);
            BeanUtils.copyProperties(this, timeyMessage);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }
}
