package com.kingtom.shengtai.api.model;

import java.util.List;
import java.util.Map;

import com.kingtom.shengtai.api.mapper.SrmMapper;
import com.kingtom.shengtai.app.srm.model.SrmCooperateDO;
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/21
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema(description = "供应商合作记录")
public class SrmCooperateDTO{

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

    @Schema(description = "供应商Id")
    private String supplierId;

    @Schema(description = "产品")
    private List<String> product;

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

    @Schema(description = "时间")
    private String time;

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

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

    @Schema(description = "扩展字段3")
    private Map<String, Object> ext3;

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

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

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


    @Schema(description = "供应商名称")
    private String supplierName;

    public static SrmCooperateDTO convert(SrmCooperateDO cooperateDO){
        if(cooperateDO == null || cooperateDO.getSupplier() == null){
            return null;
        }
        SrmCooperateDTO convert = SrmMapper.INSTANCE.convert(cooperateDO.getCooperate());
        if(convert == null){
            return null;
        }
        convert.setSupplierName(cooperateDO.getSupplier() == null ? null : cooperateDO.getSupplier().getName());
        return convert;
    }

}
