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

import com.microservices.common.core.utils.bean.BeanUtils;
import com.microservices.pms.product.domain.PmsProductReqOperationRecord;
import com.microservices.pms.product.domain.PmsProductRequirement;
import com.microservices.pms.product.domain.enums.ProductContentModifyOperation;
import com.microservices.pms.product.domain.enums.ProductReqOperationType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * 产品需求对象 pms_product_requirement
 *
 * @author otto
 * @date 2023-10-10
 */
@Data
@ApiModel("需求规格更新对象")
public class ProductReqSpecsUpdateVo extends ProductReqSpecsChangeVo {

    @ApiModelProperty(value = "关联产品模块ID")
    private Long pmsProductModuleId;

    @ApiModelProperty(value = "产品需求类型")
    private String type;

    @ApiModelProperty(value = "关联产品计划ID")
    private Long pmsProductPlanId;

    public PmsProductRequirement toPmsProductRequirement() {
        PmsProductRequirement target = new PmsProductRequirement();
        BeanUtils.copyProperties(this, target);
        return target;
    }

    public PmsProductReqOperationRecord toPmsProductReqOperationRecord(PmsProductRequirement pmsProductRequirement) {
        PmsProductReqOperationRecord record = new PmsProductReqOperationRecord();
        record.setProductRequirementId(pmsProductRequirement.getId());
        record.setType(ProductReqOperationType.CONTENT_MODIFY.getKey());
        record.setOperation(ProductContentModifyOperation.EDIT.getKey());
        record.setOperator(pmsProductRequirement.getUpdateBy());
        record.setOperatingTime(pmsProductRequirement.getUpdateTime());
        return record;
    }
}
