cooperation_application.go
4.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package service
import (
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/cooperationApplication/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/cooperationApplication/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
)
// 共创申请管理
type CooperationApplicationService struct {
}
// 审核共创申请
func (cooperationApplicationService *CooperationApplicationService) AuditCooperationApplication(
auditCooperationApplicationCommand *command.AuditCooperationApplicationCommand) (interface{}, error) {
if err := auditCooperationApplicationCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
auditCooperationApplicationCommand.Operator)
_, err := creationCooperationGateway.CooperationApplicationsBatchApproval(allied_creation_cooperation.ReqCooperationApplicationBatchApproval{
CooperationApplicationIds: auditCooperationApplicationCommand.CooperationApplicationId,
CooperationApplicationDescription: auditCooperationApplicationCommand.CooperationApplicationVerifyDescription,
Action: auditCooperationApplicationCommand.CooperationApplicationStatus,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return auditCooperationApplicationCommand, nil
}
// 返回共创申请管理
func (cooperationApplicationService *CooperationApplicationService) GetCooperationApplication(getCooperationApplicationQuery *query.GetCooperationApplicationQuery) (interface{}, error) {
if err := getCooperationApplicationQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(getCooperationApplicationQuery.Operator)
applicationResult, err := creationCooperationGateway.CooperationApplicationGet(allied_creation_cooperation.ReqCooperationApplicationGet{
CooperationApplicationId: getCooperationApplicationQuery.CooperationApplicationId,
})
//if err != nil {
// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
//}
//objectResult, err := creationCooperationGateway.CooperationProjectGet(allied_creation_cooperation.ReqCooperationProjectGet{
// CooperationProjectId: applicationResult.CooperationProject.CooperationProjectID,
//})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
//return dto.ToCooperationApplicationInfo(&applicationResult.CooperationApplication, &objectResult.CooperationProject), nil
return applicationResult, nil
}
// 返回共创申请管理列表
func (cooperationApplicationService *CooperationApplicationService) ListCooperationApplication(
listCooperationApplicationQuery *query.ListCooperationApplicationQuery) (int64, interface{}, error) {
if err := listCooperationApplicationQuery.ValidateQuery(); err != nil {
return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
cooperationApplicationStatus := 0
if listCooperationApplicationQuery.WaitAuditOnly {
cooperationApplicationStatus = 1
}
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(listCooperationApplicationQuery.Operator)
result, err := creationCooperationGateway.CooperationApplicationsSearch(allied_creation_cooperation.ReqCooperationApplicationSearch{
ApplicantName: listCooperationApplicationQuery.ApplicantName,
CooperationApplicationStatus: cooperationApplicationStatus,
CooperationProjectName: listCooperationApplicationQuery.ProjectName,
PageNumber: listCooperationApplicationQuery.PageNumber,
PageSize: listCooperationApplicationQuery.PageSize,
})
if err != nil {
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
//var dataList []dto.CooperationApplicationItem
//for i := range result.Grid.List {
// item := dto.ToCooperationApplicationItem(&result.Grid.List[i])
// dataList = append(dataList, *item)
//}
return int64(result.Grid.Total), result.Grid.List, nil
}
func NewCooperationApplicationService(options map[string]interface{}) *CooperationApplicationService {
newCooperationApplicationService := &CooperationApplicationService{}
return newCooperationApplicationService
}