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

import com.microservices.pms.product.domain.PmsProductReqOperationRecord;
import com.microservices.pms.product.domain.PmsProductRequirement;
import com.microservices.pms.product.domain.enums.ProductReqOperationType;
import com.microservices.pms.project.domain.vo.PmsProjectIssuesInputVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 产品需求对象 pms_product_requirement
 *
 * @author otto
 * @date 2023-10-10
 */
@Data
@ApiModel("需求规格纳入计划对象")
public class ProductReqSpecsActivePlanVo {
    @ApiModelProperty(value = "需求Id", required = true)
    @NotNull
    private Long id;

    @ApiModelProperty(value = "项目Id", required = true)
    @NotNull
    private Long projectId;

    public PmsProjectIssuesInputVo toPmsProjectIssuesInputVo(PmsProductRequirement reqSpecs, List<String> forgeFileIdentifierList) {
        PmsProjectIssuesInputVo issue = new PmsProjectIssuesInputVo();
        issue.setSubject(reqSpecs.getTitle());
        issue.setPmProjectId(projectId);
        issue.setStatusId(1);
        issue.setPmIssueType(1);
        issue.setPriorityId(2);
        issue.setDescription(reqSpecs.getContent());
        issue.setAttachmentIds(forgeFileIdentifierList);
        return issue;
    }

    public PmsProductReqOperationRecord toPmsProductReqOperationRecord(PmsProductRequirement pmsProductRequirement) {
        PmsProductReqOperationRecord record = new PmsProductReqOperationRecord();
        record.setProductRequirementId(pmsProductRequirement.getId());
        record.setType(ProductReqOperationType.ACTIVE_PLAN.getKey());
        record.setOperation("激活");
        record.setOperator(pmsProductRequirement.getUpdateBy());
        record.setOperatingTime(pmsProductRequirement.getUpdateTime());
        return record;
    }
}
