package com.aegis.resource.procurement.assembler;

import com.aegis.resource.procurement.domain.Procurement;
import com.aegis.resource.procurement.dto.ProcurementDTO;

/**
 * 采购申请对象转换器（Assembler）
 * 负责 DTO 和领域对象之间的转换（基础设施层职责）
 *
 * @author aegis
 */
public class ProcurementAssembler {

    /**
     * 将 DTO 转换为领域对象
     */
    public static Procurement toDomain(ProcurementDTO dto) {
        Procurement procurement = new Procurement();
        procurement.setId(dto.getId());
        procurement.setProcurementNo(dto.getProcurementNo());
        procurement.setTitle(dto.getTitle());
        procurement.setUrgency(dto.getUrgency());
        procurement.setStatus(dto.getStatus());
        procurement.setAwardedSupplierId(dto.getAwardedSupplierId());
        procurement.setAwardedAt(dto.getAwardedAt());
        procurement.setApproverId(dto.getApproverId());
        procurement.setApproverName(dto.getApproverName());
        procurement.setApprovedAt(dto.getApprovedAt());
        procurement.setApprovalComment(dto.getApprovalComment());
        procurement.setRemark(dto.getRemark());
        return procurement;
    }

    /**
     * 将领域对象转换为 DTO
     */
    public static ProcurementDTO toDTO(Procurement procurement) {
        ProcurementDTO dto = new ProcurementDTO();
        dto.setId(procurement.getId());
        dto.setProcurementNo(procurement.getProcurementNo());
        dto.setTitle(procurement.getTitle());
        dto.setUrgency(procurement.getUrgency());
        dto.setStatus(procurement.getStatus());
        dto.setAwardedSupplierId(procurement.getAwardedSupplierId());
        dto.setAwardedAt(procurement.getAwardedAt());
        dto.setApproverId(procurement.getApproverId());
        dto.setApproverName(procurement.getApproverName());
        dto.setApprovedAt(procurement.getApprovedAt());
        dto.setApprovalComment(procurement.getApprovalComment());
        dto.setRemark(procurement.getRemark());
        dto.setAwardedSupplierName(procurement.getAwardedSupplierName());
        return dto;
    }
}