package jnpf.model.cultivate.dto.casebase.app;

import jnpf.model.cultivate.dto.offline.FtbCultivateOfflineFileDTO;
import jnpf.model.cultivate.po.casebase.FtbCultivateCaseBase;
import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.Size;
import java.util.List;

/**
 * @Title:
 * @Author: peng.hao
 * @create: 2024/7/22:15:10
 */
@Data
public class FtbCultivateCaseBaseCreatDTO {

    private String id;

    /** 案例名称 */
    @Size(max = 20, message = "案例名称长度不能超过20个字符")
    private String caseName;

    /** 案例描述 */
    @Size(max = 500, message = "案例描述长度不能超过500个字符")
    private String caseDescription;

    /** 状态 0:草稿 1:待审核 */
    private Integer status;

    /**
     * 附件信息上限1个
     */
    @Size(max = 1, message = "附件信息上限1个")
    @Valid
    private List<FtbCultivateOfflineFileDTO> files;

    public static FtbCultivateCaseBase covert(FtbCultivateCaseBaseCreatDTO dto) {
        if (dto == null) {
            return null;
        }
        FtbCultivateCaseBase ftbCultivateCaseBase = new FtbCultivateCaseBase();
        ftbCultivateCaseBase.setId(dto.getId());
        ftbCultivateCaseBase.setCaseName(dto.getCaseName());
        ftbCultivateCaseBase.setCaseDescription(dto.getCaseDescription());
        ftbCultivateCaseBase.setStatus(dto.getStatus());
        return ftbCultivateCaseBase;
    }
}
