event_agree_contract_application_service.go 1.9 KB
package domain_service

import (
	coreDomain "github.com/linmadan/egglib-go/core/domain"
	pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/event"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
)

type AgreeContractApplicationService struct {
	coreDomain.BaseEventPublisher
	//transactionContext *pgTransaction.TransactionContext
}

// 同意申请
func (service *AgreeContractApplicationService) Agree(data []service.AgreeData) error {
	cooperationApplicationAgreedEvent := new(event.CooperationApplicationAgreed)
	for _, cooperationApplicationAgreedData := range data {
		cooperationApplicationAgreedEvent.CooperationApplicationAgreedData = append(cooperationApplicationAgreedEvent.CooperationApplicationAgreedData, event.CooperationApplicationAgreedData{
			CreationProjectId:     cooperationApplicationAgreedData.CreationProjectId,
			CreationProjectName:   cooperationApplicationAgreedData.CreationProjectName,
			CreationProjectNumber: cooperationApplicationAgreedData.CreationProjectNumber,
			UserId:                cooperationApplicationAgreedData.UserId,
			UserBaseId:            cooperationApplicationAgreedData.UserBaseId,
			OrgId:                 cooperationApplicationAgreedData.OrgId,
			CompanyId:             cooperationApplicationAgreedData.CompanyId,
		})
	}
	if err := service.Publish(cooperationApplicationAgreedEvent); err != nil {
		return err
	}
	return nil
}

func NewAgreeContractApplicationService(transactionContext *pgTransaction.TransactionContext) (*AgreeContractApplicationService, error) {
	//if transactionContext == nil {
	//	return nil, fmt.Errorf("transactionContext参数不能为nil")
	//} else {
	//	return &AgreeContractApplicationService{
	//		transactionContext: transactionContext,
	//	}, nil
	//}
	return &AgreeContractApplicationService{}, nil
}