package cn.com.ty.lift.common.model;

import cn.com.ty.lift.common.constants.ApiConstants;
import cn.com.ty.lift.common.constants.WebSocketConstants;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 实时消息推送记录表
 */
@Data
public class TimeMessage implements Serializable {

    private static final long serialVersionUID = 4125096758372084309L;

    @TableId(value = "id", type = IdType.ID_WORKER)
    private Long id;
    @TableField("user_id")
    private Long userId;
    @TableField("content")
    private String content;
    @TableField("type")
    private Integer type;
    @TableField("view_flag")
    private Integer viewFlag;
    @TableField("device_model")
    private Integer deviceModel;
    @TableField("create_user_id")
    private Long createUserId;
    @TableField("create_time")
    private LocalDateTime createTime;

    /**
     * @param pushToUserId 要推送的用户id
     * @param msgType      消息类型
     * @param content      消息类型
     * @return 返回推送消息
     * @description 推送消息创建
     * @date 2020/4/30 5:13 下午
     */
    public static TimeMessage create(long pushToUserId, int msgType, String content) {
        TimeMessage TimeMessage = new TimeMessage();
        TimeMessage.setContent(content);
        TimeMessage.setUserId(pushToUserId);
        TimeMessage.setType(msgType);
        TimeMessage.setCreateTime(LocalDateTime.now());
        TimeMessage.setDeviceModel(ApiConstants.DeviceModel.PC);
        TimeMessage.setCreateUserId(10000L);
        TimeMessage.setViewFlag(WebSocketConstants.IS_NOT_VIEW);
        return TimeMessage;
    }

}
