作者 linmadan

添加领域事件订阅处理,同步问题系统

... ... @@ -49,7 +49,6 @@ func (subscriber *AbilityServiceSubscriber) HandleEvent(domainEvent domain.Domai
}
data, err := abilityServiceGateway.CommitQuestionSolution(referenceResourceItem.ReferenceResourceId, taskAcceptancedEvent.Sponsor.Uid, solveUid, taskAcceptancedEvent.SolveReport, scoreSolve, taskAcceptancedEvent.SolvePictureUrls, partners)
if err != nil {
fmt.Println(err.Error())
return err
}
fmt.Println(data)
... ...
... ... @@ -4,6 +4,7 @@ import (
"fmt"
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/utils/tool_funs"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/event/subscriber"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/factory"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/task/command"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/task/query"
... ... @@ -171,6 +172,7 @@ func (taskService *TaskService) ReleaseTask(releaseTaskCommand *command.ReleaseT
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
releaseTaskService = value
releaseTaskService.Subscribe(&subscriber.AbilityServiceSubscriber{})
}
if task, err := releaseTaskService.Release(releaseTaskCommand.TaskId, releaseTaskCommand.Operator); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -237,6 +239,7 @@ func (taskService *TaskService) AcceptanceTask(acceptanceTaskCommand *command.Ac
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
acceptanceTaskService = value
acceptanceTaskService.Subscribe(&subscriber.AbilityServiceSubscriber{})
}
if task, err := acceptanceTaskService.Acceptance(acceptanceTaskCommand.TaskId, acceptanceTaskCommand.Operator, acceptanceTaskCommand.Participators, acceptanceTaskCommand.TaskPercentage, acceptanceTaskCommand.ReferenceResourceScore, acceptanceTaskCommand.SolveReport, acceptanceTaskCommand.SolvePictureUrls); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ...
package service
import "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
import (
coreDomain "github.com/linmadan/egglib-go/core/domain"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
)
type AcceptanceTaskService interface {
coreDomain.DomainEventPublisher
Acceptance(taskId int64, operatorUid int64, participators []int64, taskPercentage []*domain.TaskPercentageItem, referenceResourceScore []*domain.ReferenceResourceItem, solveReport string, solvePictureUrls []string) (*domain.Task, error)
}
... ...
package service
import "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
import (
coreDomain "github.com/linmadan/egglib-go/core/domain"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
)
type ApplyCompleteTaskService interface {
coreDomain.DomainEventPublisher
ApplyComplete(taskId int64, receiverUid int64) (*domain.Task, error)
}
... ...
package service
import "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
import (
coreDomain "github.com/linmadan/egglib-go/core/domain"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
)
type BidTaskService interface {
coreDomain.DomainEventPublisher
Bid(taskId int64, bidderUid int64) (*domain.Task, error)
}
... ...
package service
import "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
import (
coreDomain "github.com/linmadan/egglib-go/core/domain"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
)
type ChooseSuccessfulBidderService interface {
coreDomain.DomainEventPublisher
Choose(taskId int64, successfulBidderUid int64, operatorUid int64) (*domain.Task, error)
}
... ...
package service
import "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
import (
coreDomain "github.com/linmadan/egglib-go/core/domain"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
)
type ExchangeSuMoneyService interface {
coreDomain.DomainEventPublisher
Exchange(uid int64, operatorUid int64, suMoney float64, recordDescription string) (*domain.SuMoneyTransactionRecord, error)
}
... ...
package service
import "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
import (
coreDomain "github.com/linmadan/egglib-go/core/domain"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
)
type OffTaskService interface {
coreDomain.DomainEventPublisher
Off(taskId int64, operatorUid int64, offReason string) (*domain.Task, error)
}
... ...
package service
import "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
import (
coreDomain "github.com/linmadan/egglib-go/core/domain"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
)
type ReleaseTaskService interface {
coreDomain.DomainEventPublisher
Release(taskId int64, operatorUid int64) (*domain.Task, error)
}
... ...
package service
import "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
import (
coreDomain "github.com/linmadan/egglib-go/core/domain"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
)
type RobTaskService interface {
coreDomain.DomainEventPublisher
Rob(taskId int64, receiverUid int64) (*domain.Task, error)
}
... ...
... ... @@ -5,6 +5,7 @@ import (
coreDomain "github.com/linmadan/egglib-go/core/domain"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain/event"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/repository"
"time"
... ... @@ -93,6 +94,23 @@ func (service *AcceptanceTaskService) Acceptance(taskId int64, operatorUid int64
if task, err := taskRepository.Save(task); err != nil {
return nil, err
} else {
taskAcceptancedEvent := new(event.TaskAcceptanced)
taskAcceptancedEvent.OccurredOn = time.Now()
taskAcceptancedEvent.TaskId = task.TaskId
taskAcceptancedEvent.CompanyId = task.CompanyId
taskAcceptancedEvent.TaskName = task.TaskName
taskAcceptancedEvent.TaskType = task.TaskType
taskAcceptancedEvent.Sponsor = task.Sponsor
taskAcceptancedEvent.TaskStatus = task.TaskStatus
taskAcceptancedEvent.ReferenceResource = task.ReferenceResource
taskAcceptancedEvent.AcceptanceStandard = task.AcceptanceStandard
taskAcceptancedEvent.Participators = task.Participators
taskAcceptancedEvent.TaskPercentage = task.TaskPercentage
taskAcceptancedEvent.SolveReport = task.SolveReport
taskAcceptancedEvent.SolvePictureUrls = task.SolvePictureUrls
if err := service.Publish(taskAcceptancedEvent); err != nil {
println(err.Error())
}
return task, nil
}
}
... ...
... ... @@ -5,7 +5,9 @@ import (
coreDomain "github.com/linmadan/egglib-go/core/domain"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain/event"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/repository"
"time"
)
type ReleaseTaskService struct {
... ... @@ -53,6 +55,24 @@ func (service *ReleaseTaskService) Release(taskId int64, operatorUid int64) (*do
if task, err := taskRepository.Save(task); err != nil {
return nil, err
} else {
taskReleasedEvent := new(event.TaskReleased)
taskReleasedEvent.OccurredOn = time.Now()
taskReleasedEvent.TaskId = task.TaskId
taskReleasedEvent.CompanyId = task.CompanyId
taskReleasedEvent.TaskName = task.TaskName
taskReleasedEvent.TaskType = task.TaskType
taskReleasedEvent.Sponsor = task.Sponsor
taskReleasedEvent.TaskStatus = task.TaskStatus
taskReleasedEvent.ReferenceResource = task.ReferenceResource
taskReleasedEvent.CustomerValue = task.CustomerValue
taskReleasedEvent.TaskNature = task.TaskNature
taskReleasedEvent.SuMoney = task.SuMoney
taskReleasedEvent.AcceptanceStandard = task.AcceptanceStandard
taskReleasedEvent.TaskDescription = task.TaskDescription
taskReleasedEvent.BidInfo = task.BidInfo
if err := service.Publish(taskReleasedEvent); err != nil {
println(err.Error())
}
return task, nil
}
}
... ...