package com.microservices.pms.project.domain.vo;

import com.microservices.common.core.utils.bean.BeanUtils;
import com.microservices.pms.project.domain.PmsProjectTestcase;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 测试用例管理对象 pms_project_testcase
 *
 * @author otto
 * @date 2023-11-22
 */
@Data
@ApiModel("测试用例更新对象")
public class PmsProjectTestcaseUpdateVo {

    /**
     * 用例ID
     */
    @ApiModelProperty(value = "用例ID", required = true)
    @NotNull
    private Long id;
    /**
     * 用例标题
     */
    @ApiModelProperty(value = "用例标题")
    @Size(max = 100, message = "长度需要小于100")
    private String title;

    @ApiModelProperty(value = "产品需求规格id")
    private Long productReqSpecsId;

    /**
     * 用例维护人Gitlink ID
     */
    @ApiModelProperty(value = "用例维护人Gitlink ID")
    private Long assigneeGitlinkId;

    /**
     * 用例类型ID
     */
    @ApiModelProperty(value = "用例类型ID")
    private Long typeId;
    /**
     * 标记Id列表，使用逗号分割的字符串
     */
    @ApiModelProperty(value = "标记Id列表，使用逗号分割的字符串，置空可传空字符串")
    private String tags;

    /**
     * 关联模块ID
     */
    @ApiModelProperty(value = "关联模块ID")
    private Long pmsModuleId;

    /**
     * 附件标识列表
     */
    @ApiModelProperty(value = "附件标识列表")
    private String fileIdentifiers;

    /**
     * 前置条件
     */
    @ApiModelProperty(value = "前置条件")
    @Size(max = 500, message = "长度需要小于500")
    private String preconditions;

    /**
     * 备注
     */
    @ApiModelProperty(value = "备注")
    @Size(max = 500, message = "长度需要小于500")
    private String remark;

    /**
     * 测试步骤列表
     */
    @ApiModelProperty(value = "测试步骤列表（置空需传一个空数组）")
    private List<PmsProjectTestcaseStepInputVo> testcaseStepInputVoList;

    public PmsProjectTestcase toPmsProjectTestcase() {
        PmsProjectTestcase target = new PmsProjectTestcase();
        BeanUtils.copyProperties(this, target);
        if (testcaseStepInputVoList != null) {
            target.setTestcaseStepList(testcaseStepInputVoList.stream().map(PmsProjectTestcaseStepInputVo::toPmsProjectTestcaseStep).collect(Collectors.toList()));
        }
        return target;
    }


}
