cooperation_application.go 3.6 KB
package transform

import (
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models"
)

func TransformToCooperationApplicationDomainModelFromPgModels(
	cooperationApplicationModel *models.CooperationApplication,
	cooperationProject *models.CooperationProject,
	cooperationMode *models.CooperationMode) (*domain.CooperationApplication, error) {
	return &domain.CooperationApplication{
		CooperationApplicationId:                cooperationApplicationModel.CooperationApplicationId,
		CooperationApplicationApplicant:         cooperationApplicationModel.CooperationApplicationApplicant,
		CooperationApplicationAttachment:        cooperationApplicationModel.CooperationApplicationAttachment,
		CooperationApplicationDescription:       cooperationApplicationModel.CooperationApplicationDescription,
		CooperationApplicationStatus:            cooperationApplicationModel.CooperationApplicationStatus,
		CooperationApplicationVerifier:          cooperationApplicationModel.CooperationApplicationVerifier,
		CooperationApplicationVerifyDescription: cooperationApplicationModel.CooperationApplicationVerifyDescription,
		CooperationApplicationVerifyTime:        cooperationApplicationModel.CooperationApplicationVerifyTime,
		CooperationApplyTime:                    cooperationApplicationModel.CooperationApplyTime,
		CooperationProject: &domain.CooperationProject{
			CooperationProjectId:              cooperationProject.CooperationProjectId,
			CooperationProjectNumber:          cooperationProject.CooperationProjectNumber,
			CooperationProjectDescription:     cooperationProject.CooperationProjectDescription,
			CooperationProjectName:            cooperationProject.CooperationProjectName,
			CooperationProjectPublishTime:     cooperationProject.CooperationProjectPublishTime,
			CooperationProjectPublisher:       cooperationProject.CooperationProjectPublisher,
			CooperationProjectSponsor:         cooperationProject.CooperationProjectSponsor,
			Department:                        cooperationProject.Department,
			CooperationProjectUndertakerTypes: cooperationProject.CooperationProjectUndertakerTypes,
			CooperationMode: &domain.CooperationMode{
				CooperationModeId:     cooperationMode.CooperationModeId,
				CooperationModeNumber: cooperationMode.CooperationModeNumber,
				CooperationModeName:   cooperationMode.CooperationModeName,
				Status:                cooperationMode.Status,
				Org:                   cooperationMode.Org,
				Company:               cooperationMode.Company,
				Remarks:               cooperationMode.Remarks,
				Operator:              cooperationMode.Operator,
				OperateTime:           cooperationMode.OperateTime,
				UpdatedAt:             cooperationMode.UpdatedAt,
				DeletedAt:             cooperationMode.DeletedAt,
				CreatedAt:             cooperationMode.CreatedAt,
			},
			Org:         cooperationProject.Org,
			Attachment:  cooperationProject.Attachment,
			Company:     cooperationProject.Company,
			Operator:    cooperationProject.Operator,
			OperateTime: cooperationProject.OperateTime,
			Status:      cooperationProject.Status,
			UpdatedAt:   cooperationProject.UpdatedAt,
			DeletedAt:   cooperationProject.DeletedAt,
			CreatedAt:   cooperationProject.CreatedAt,
		},
		Org:        cooperationApplicationModel.Org,
		IsCanceled: cooperationApplicationModel.IsCanceled,
		Company:    cooperationApplicationModel.Company,
		CreatedAt:  cooperationApplicationModel.CreatedAt,
		DeletedAt:  cooperationApplicationModel.DeletedAt,
		UpdatedAt:  cooperationApplicationModel.UpdatedAt,
	}, nil
}