package com.kingtom.shengtai.api.model;

import com.kingtom.shengtai.api.mapper.MsgMapper;
import com.kingtom.shengtai.app.message.model.MsgReceive;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 应用模块名称</p>
 * 代码描述</p>
 * Copyright: Copyright (C) 2023 , Inc. All rights reserved. <p>
 * Company: 成都诚唐科技有限责任公司</p>
 *
 * @author wany
 * @since 2023/12/27
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema(description = "消息摘要")
public class MsgSummaryDTO{

    @Schema(description = "主键")
    private String id;

    @Schema(description = "消息类型")
    private String type;

    @Schema(description = "消息标题")
    private String title;

    @Schema(description = "消息内容")
    private String content;

    @Schema(description = "发送人")
    private String sender;

    @Schema(description = "扩展字段1")
    private String ext1;

    @Schema(description = "扩展字段2")
    private String ext2;

    @Schema(description = "扩展字段3")
    private String ext3;

    @Schema(description = "创建时间")
    private String gmtCreate;

    @Schema(description = "更新时间")
    private String gmtModified;

    @Schema(description = "系统ID")
    private String sysId;

    @Schema(description = "阅读状态")
    private Integer read;

    public static MsgSummaryDTO convert(MsgReceive receive){
        if(receive == null || receive.getSummary() == null){
            return null;
        }
        MsgSummaryDTO convert = MsgMapper.INSTANCE.convert(receive.getSummary());
        convert.setRead(receive.getReadState());
        return convert;
    }

}
