package com.sunxung.factoring.entity.sys.systemMsg;

import com.alibaba.fastjson.annotation.JSONField;
import com.sunxung.factoring.component.annotation.ObjectValidator;
import com.sunxung.factoring.entity.PinYinEntity;
import com.sunxung.factoring.entity.sys.Dictionary;
import com.sunxung.factoring.entity.sys.User;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.NotEmpty;

import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;

/**
 * @description:消息实体类
 * @author:吴端丽
 * @e-mail:1912942707@qq.com
 * @date:2018年3月20日 下午2:52:10
 */
public class SystemMsg extends PinYinEntity {

    private static final long serialVersionUID = 1L;
    /** 业务ID **/
    private Long businessId;
    /** 业务类型(SystemBusinessModuleDict) **/
    private Dictionary businessType;
    /** 消息类型 */
    @ObjectValidator(message = "消息类型不能为空")
    private Dictionary msgType;
    /** 发送类型 **/
    @NotEmpty(message = "发送类型不能为空", groups = {
            Add.class, Update.class
    })
    private String sendType;
    /** 发件人 */
    private User senderUser;
    /** 发件人名称 **/
    private String senderName;
    @NotBlank(message = "标题不能为空", groups = {
            Add.class, Update.class
    })
    @Length(min = 1, max = 250, message = "消息标题最多可输入250字", groups = {
            Add.class, Update.class
    })
    private String title;
    /** 内容 */
    @NotBlank(message = "内容不能为空", groups = {
            Add.class, Update.class
    })
    @Length(min = 1, max = 1500, message = "内容最多可输入1500字", groups = {
            Add.class, Update.class
    })
    private String content;
    /** 推送时间 */
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @NotNull(message = "推送时间不能为空", groups = {
            Add.class, Update.class
    })
    private Date pushTime;
    /** 消息状态(1-已发送，0-待发送) */
    @NotNull(message = "消息状态不能为空", groups = {
            Add.class, Update.class
    })
    private Boolean pushState;
    /** 是否删除 **/
    private Boolean remove;
    /** 是否阅读 */
    private Boolean readState;
    /** 阅读情况 **/
    private String readingSituation; // 仅做数据展示，不保存在数据库
    /** 发送范围 **/
    private List<User> userList; // 指定发送范围用户集合
    private List<Long> departmentList; // 指定发送范围部门集合
    /** 流程业务待处理任务ID，注：仅涉及到流程待业务且消息类型为待办消息，该字段才可能有值 **/
    private String taskId;

    public SystemMsg(){
        super();
    }

    /*
     * public SystemMsg(SystemMsg msg){ this.msgType = msg.getMsgType(); this.receiver = msg.getReceiver(); this.title =
     * msg.getTitle(); this.content = msg.getContent(); this.pushTime = msg.getPushTime(); this.org = msg.getOrg(); }
     */
    /**
     * 系统消息构造器
     * 
     * @param msgType 消息类型
     * @param receiver 接收人
     * @param title 标题
     * @param content 内容
     */
    /*
     * public SystemMsg(Dictionary msgType, User receiver, String title, String content){ this.msgType = msgType;
     * this.receiver = receiver; this.title = title; this.content = content; }
     */
    public Dictionary getMsgType() {
        return msgType;
    }

    public void setMsgType(Dictionary msgType) {
        this.msgType = msgType;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Date getPushTime() {
        return pushTime;
    }

    public void setPushTime(Date pushTime) {
        this.pushTime = pushTime;
    }

    public Long getBusinessId() {
        return businessId;
    }

    public void setBusinessId(Long businessId) {
        this.businessId = businessId;
    }

    public User getSenderUser() {
        return senderUser;
    }

    public void setSenderUser(User senderUser) {
        this.senderUser = senderUser;
    }

    public String getSenderName() {
        return senderName;
    }

    public void setSenderName(String senderName) {
        this.senderName = senderName;
    }

    public Boolean getReadState() {
        return readState;
    }

    public void setReadState(Boolean readState) {
        this.readState = readState;
    }

    public Boolean getPushState() {
        return pushState;
    }

    public void setPushState(Boolean pushState) {
        this.pushState = pushState;
    }

    public Boolean getRemove() {
        return remove;
    }

    public void setRemove(Boolean remove) {
        this.remove = remove;
    }

    @Override
    public String getName() {
        return this.title;
    }

    public String getReadingSituation() {
        return readingSituation;
    }

    public void setReadingSituation(String readingSituation) {
        this.readingSituation = readingSituation;
    }

    public String getSendType() {
        return sendType;
    }

    public void setSendType(String sendType) {
        this.sendType = sendType;
    }

    public List<User> getUserList() {
        return userList;
    }

    public void setUserList(List<User> userList) {
        this.userList = userList;
    }

    public List<Long> getDepartmentList() {
        return departmentList;
    }

    public void setDepartmentList(List<Long> departmentList) {
        this.departmentList = departmentList;
    }

    public Dictionary getBusinessType() {
        return businessType;
    }

    public void setBusinessType(Dictionary businessType) {
        this.businessType = businessType;
    }

    public String getTaskId() {
        return taskId;
    }

    public void setTaskId(String taskId) {
        this.taskId = taskId;
    }
}
