event_reject_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 RejectContractApplicationService struct {
	coreDomain.BaseEventPublisher
	//transactionContext *pgTransaction.TransactionContext
}

// 拒绝申请
func (service *RejectContractApplicationService) Reject(data []service.RejectData) error {
	cooperationApplicationRejectedEvent := new(event.CooperationApplicationRejected)
	for _, cooperationApplicationRejectedData := range data {
		cooperationApplicationRejectedEvent.CooperationApplicationRejectedData = append(cooperationApplicationRejectedEvent.CooperationApplicationRejectedData, event.CooperationApplicationRejectedData{
			CreationProjectId:     cooperationApplicationRejectedData.CreationProjectId,
			CreationProjectName:   cooperationApplicationRejectedData.CreationProjectName,
			CreationProjectNumber: cooperationApplicationRejectedData.CreationProjectNumber,
			UserId:                cooperationApplicationRejectedData.UserId,
			UserBaseId:            cooperationApplicationRejectedData.UserBaseId,
			OrgId:                 cooperationApplicationRejectedData.OrgId,
			CompanyId:             cooperationApplicationRejectedData.CompanyId,
		})
	}
	if err := service.Publish(cooperationApplicationRejectedEvent); err != nil {
		return err
	}
	return nil
}

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