package com.slodon.b2b2c.vo.seller;

import com.slodon.b2b2c.core.config.DomainUrlUtil;
import com.slodon.b2b2c.system.pojo.SysMedia;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

@Data
public class MediaListVo {

    private Long id;

    private String name;

    private String path;

    private String type;

    private Integer status;

    private String fileType;

    private Long storeId;

    private Long createId;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    private Long updateId;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    @ApiModelProperty("多媒体文件(图片等)路径")
    private String url;

    private String storeName;

    private String tplTypeName;

    public MediaListVo(SysMedia sysMedia) {
        id = sysMedia.getId();
        name = sysMedia.getName();
        path = sysMedia.getPath();
        type = sysMedia.getType();
        status = sysMedia.getStatus();
        fileType = sysMedia.getFileType();
        storeId = sysMedia.getStoreId();
        createId = sysMedia.getCreateId();
        createTime = sysMedia.getCreateTime();
        updateId = sysMedia.getUpdateId();
        updateTime = sysMedia.getUpdateTime();
        url = "video".equals(sysMedia.getFileType()) ? sysMedia.getPath() : DomainUrlUtil.SLD_IMAGE_RESOURCES + sysMedia.getPath();
        storeName = sysMedia.getStoreName();
        tplTypeName = sysMedia.getTplTypeName();
    }
}
