package cn.estsh.i3plus.pojo.platform.bean;

import cn.estsh.i3plus.pojo.base.annotation.AnnoOutputColumn;
import cn.estsh.i3plus.pojo.base.bean.BaseBean;
import cn.estsh.i3plus.pojo.base.enumutil.ImppEnumUtil;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

/**
 * @Description : 关系-用户消息
 * @Reference :
 * @Author : yunhao
 * @CreateDate : 2018-11-15 20:35
 * @Modify:
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name="SYS_REF_USER_MESSAGE")
@Api(value="关系-用户消息",description = "关系-用户消息")
public class SysRefUserMessage extends BaseBean {

    private static final long serialVersionUID = 555705651072659162L;
    @Column(name="MESSAGE_ID")
    @ApiParam(value ="消息id" ,example = "-1")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long messageId;

    @Column(name="MESSAGE_TITLE_RDD")
    @ApiParam(value ="冗余消息标题")
    private String messageTitleRdd;

    @Column(name="MESSAGE_SOFT_TYPE")
    @ApiParam(value ="消息所属模块")
    private Integer messageSoftType;

    @Column(name="MESSAGE_TYPE_RDD")
    @ApiParam(value ="冗余消息类型")
    private Integer messageTypeRdd;

    @Column(name="MESSAGE_SENDER_NAME_RDD")
    @ApiParam(value ="冗余发件人名称")
    private String messageSenderNameRdd;

    @Column(name="RECEIVER_ID")
    @ApiParam(value ="接收者ID" ,example = "-1")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long receiverId;

    @Column(name="RECEIVER_NAME_RDD")
    @ApiParam(value ="接收者名称" ,example = "-1")
    private String receiverNameRdd;

    @Column(name="RECEIVER_TIME")
    @ApiParam(value = "接收时间")
    private String receiverTime;

    @Column(name="IS_URGENT")
    @ApiParam(value ="是否紧急")
    private Integer isUrgent;

    @Column(name="MESSAGE_STATUS")
    @ApiParam(value = "消息状态")
    @AnnoOutputColumn(refClass = ImppEnumUtil.MESSAGE_STATUS.class)
    private Integer messageStatus;

    public int getMessageStatusValue() {
        if(this.messageStatus == null){
            return ImppEnumUtil.MESSAGE_STATUS.UNREAD.getValue();
        } else {
            return messageStatus.intValue();
        }
    }

    public String getMessageStatusTxt() {
        return ImppEnumUtil.MESSAGE_STATUS.valueOfDescription(getMessageStatusValue());
    }
}
