cooperation_contract_by_undertaker_dto.go 1.9 KB
package dto

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

type CooperationContractByUndertakerDto struct {
	// 承接人ID
	UndertakerId int64 `json:"undertakerId,string"`
	// 承接人编号
	UndertakerCode string `json:"undertakerCode"`
	// 承接人姓名
	UndertakerName string `json:"undertakerName"`
	// 承接人电话
	UndertakerPhone string `json:"undertakerPhone"`
	// 项目合约编号
	CooperationContractNumber string `json:"cooperationContractNumber"`
	// 项目合约名称
	CooperationContractName string `json:"cooperationContractName"`
	// 合同附件
	Attachment []*domain.Attachment `json:"attachment"`
	// 发起人姓名
	SponsorName string `json:"sponsorName"`
	// 发起部门名称
	DepartmentName string `json:"departmentName"`
	// 共创模式名称
	CooperationModeName string `json:"cooperationModeName"`
	// 组织机构名称
	OrgName string `json:"orgName"`
}

func (dto *CooperationContractByUndertakerDto) LoadDto(contractByUndertaker *models.CooperationContractByUndertaker) error {
	dto.UndertakerId = contractByUndertaker.CooperationContractUndertakerId
	dto.UndertakerCode = contractByUndertaker.UndertakerCode
	dto.UndertakerName = contractByUndertaker.UndertakerName
	dto.UndertakerPhone = contractByUndertaker.UndertakerPhone
	dto.CooperationContractNumber = contractByUndertaker.CooperationContractNumber
	dto.CooperationContractName = contractByUndertaker.CooperationContractName
	dto.Attachment = contractByUndertaker.ContractAttachment
	dto.SponsorName = contractByUndertaker.CooperationContractSponsor.UserName
	if contractByUndertaker.Department != nil {
		dto.DepartmentName = contractByUndertaker.Department.DepartmentName
	}
	dto.CooperationModeName = contractByUndertaker.CooperationModeName
	if contractByUndertaker.Org != nil {
		dto.OrgName = contractByUndertaker.Org.OrgName
	}
	return nil
}