package com.aegis.resource.requisition.assembler;

import com.aegis.resource.requisition.domain.Requisition;
import com.aegis.resource.requisition.dto.RequisitionDTO;

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

    /**
     * 将 DTO 转换为领域对象
     */
    public static Requisition toDomain(RequisitionDTO dto) {
        Requisition requisition = new Requisition();
        requisition.setId(dto.getId());
        requisition.setTeamId(dto.getTeamId());
        requisition.setRequisitionNo(dto.getRequisitionNo());
        requisition.setReason(dto.getReason());
        requisition.setStatus(dto.getStatus());
        requisition.setStartAt(dto.getStartAt());
        requisition.setEndAt(dto.getEndAt());
        requisition.setApproverId(dto.getApproverId());
        requisition.setApproverName(dto.getApproverName());
        requisition.setApprovedAt(dto.getApprovedAt());
        requisition.setApprovalComment(dto.getApprovalComment());
        requisition.setRemark(dto.getRemark());
        return requisition;
    }

    /**
     * 将领域对象转换为 DTO
     */
    public static RequisitionDTO toDTO(Requisition requisition) {
        RequisitionDTO dto = new RequisitionDTO();
        dto.setId(requisition.getId());
        dto.setTeamId(requisition.getTeamId());
        dto.setTeamName(requisition.getTeamName());
        dto.setRequisitionNo(requisition.getRequisitionNo());
        dto.setReason(requisition.getReason());
        dto.setStatus(requisition.getStatus());
        dto.setStartAt(requisition.getStartAt());
        dto.setEndAt(requisition.getEndAt());
        dto.setApproverId(requisition.getApproverId());
        dto.setApproverName(requisition.getApproverName());
        dto.setApprovedAt(requisition.getApprovedAt());
        dto.setApprovalComment(requisition.getApprovalComment());
        dto.setRemark(requisition.getRemark());
        return dto;
    }
}

