package com.muyu.domain.message;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

import java.util.Date;

/**
 * 站内信
 * @Author：weiran
 * @Package：com.muyu.cloud.faultmanage.domain.message
 * @Project：cloud-server-8
 * @name：Message
 * @Date：2024/9/22 10:40
 */

@Tag(name = "站内信")
@Data
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
@TableName(value = "car_fault_message",autoResultMap = true)
public class Message {
    /**
     * id
     */
    @TableId(value = "id",type = IdType.AUTO)
    private Long id;

    /**
     * 发送者
     */
    private String sender;

    /**
     * 接收者
     */
    private String receiver;

    /**
     * 消息内容
     */
    private String content;

    /**
     * 消息状态
     */
    private Integer status;

    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Schema(description = "消息创建时间",defaultValue = "2024-8-9 10:47:57",type = "Date")
    private Date createTime;
    /**
     * 登录人Id
     */
    private long userId;


    public static Message messageBuilder(Message message) {
        return Message.builder()
                .id(message.getId())
                .sender(message.getSender())
                .receiver(message.getReceiver())
                .content(message.getContent())
                .status(message.getStatus())
                .createTime(message.getCreateTime())
                .userId(message.getUserId())
                .build();
    }
}
