cooperation_applications.go
9.1 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
package service
import (
"strconv"
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/cooperation/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
)
// CooperationApplicationsService 共创申请服务
type CooperationApplicationsService struct {
}
/***** 企业端 *****/
// GetCooperationApplications 企业获取共创申请详情
func (srv CooperationApplicationsService) GetCooperationApplications(applicationQuery *command.GetCooperationApplicationQuery) (interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
applicationQuery.Operator)
resultApplication, err := creationCooperationGateway.CooperationApplicationGet(allied_creation_cooperation.ReqCooperationApplicationGet{
CooperationApplicationId: int(applicationQuery.CooperationApplicationId),
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
resultProject, err := creationCooperationGateway.CooperationProjectGet(allied_creation_cooperation.ReqCooperationProjectGet{
CooperationProjectId: resultApplication.CooperationProject.CooperationProjectID,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
//data := map[string]interface{}{
// "cooperationApplication": dto.ToCooperationApplication(&resultApplication.CooperationApplication),
// "cooperationProject": dto.ToCooperationProjectInfo(&resultProject.CooperationProject),
//}
resultApplication.CooperationProject.CooperationMode.CooperationModeNumber = resultProject.CooperationMode.CooperationModeNumber
resultApplication.CooperationProject.CooperationMode.CooperationModeName = resultProject.CooperationMode.CooperationModeName
resultApplication.CooperationProject.CooperationMode.CooperationModeId = resultProject.CooperationMode.CooperationModeId
return resultApplication, nil
}
// AuditCooperationApplications 企业审核共创申请
func (srv CooperationApplicationsService) AuditCooperationApplications(auditCommand *command.AuditCooperationApplicationCommand) (interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
auditCommand.Operator)
//applicationIds := []string{strconv.Itoa(auditCommand.CooperationApplicationId)}
//for _, v := range auditCommand.CooperationApplicationId {
// idStr := strconv.Itoa(v)
// applicationIds = append(applicationIds, idStr)
//}
_, err := creationCooperationGateway.CooperationApplicationsApproval(allied_creation_cooperation.ReqCooperationApplicationApproval{
CooperationApplicationId: strconv.Itoa(auditCommand.CooperationApplicationId),
CooperationApplicationDescription: auditCommand.CooperationApplicationVerifyDescription,
Action: auditCommand.CooperationApplicationStatus,
Code: "a1-2",
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return auditCommand, nil
}
// SearchCooperationApplications 企业获取共创申请列表
func (srv CooperationApplicationsService) SearchCooperationApplications(applicationQuery *command.ListCooperationApplicationQuery) (interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
applicationQuery.Operator)
resultApplications, err := creationCooperationGateway.CooperationApplicationsSearch(allied_creation_cooperation.ReqCooperationApplicationSearch{
PageNumber: applicationQuery.PageNumber,
PageSize: applicationQuery.PageSize,
CompanyId: int(applicationQuery.Operator.CompanyId),
CooperationApplicationStatus: applicationQuery.Status,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return resultApplications, nil
}
/***** 共创用户端 *****/
// CreateCooperationApplications 创建共创申请管理
func (srv CooperationApplicationsService) CreateCooperationApplications(createApplicationsCommand *command.CreateCooperationApplicationCommand) (interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
createApplicationsCommand.Operator)
result, err := creationCooperationGateway.CooperationApplicationAdd(allied_creation_cooperation.ReqCooperationApplicationAdd{
ApplicantUid: strconv.Itoa(int(createApplicationsCommand.Operator.UserId)),
CooperationApplicationDescription: createApplicationsCommand.CooperationApplicationDescription,
CooperationApplicationAttachment: createApplicationsCommand.Attachment,
CooperationProjectNumber: createApplicationsCommand.CooperationProjectNumber,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
data := struct {
CooperationApplicationId int `json:"cooperationApplicationId"`
command.CreateCooperationApplicationCommand
}{
CooperationApplicationId: result.CooperationApplicationId,
CreateCooperationApplicationCommand: *createApplicationsCommand,
}
return data, err
}
//PersonGetCooperationApplications 共创用户获取共创申请详情
func (srv CooperationApplicationsService) PersonGetCooperationApplications(applicationQuery *command.GetCooperationApplicationQuery) (interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
applicationQuery.Operator)
resultApplication, err := creationCooperationGateway.CooperationApplicationGet(allied_creation_cooperation.ReqCooperationApplicationGet{
CooperationApplicationId: int(applicationQuery.CooperationApplicationId),
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
//resultProject, err := creationCooperationGateway.CooperationProjectGet(allied_creation_cooperation.ReqCooperationProjectGet{
// CooperationProjectId: resultApplication.CooperationProject.CooperationProjectID,
//})
//if err != nil {
// return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
//}
//data := map[string]interface{}{
// "cooperationApplication": dto.ToCooperationApplication(&resultApplication.CooperationApplication),
// "cooperationProject": dto.ToCooperationProjectInfo(&resultProject.CooperationProject),
//}
return resultApplication, nil
}
// PersonCancelCooperationApplications 共创用户取消共创申请
func (srv CooperationApplicationsService) PersonCancelCooperationApplications(cancelCommand *command.CancelCooperationApplicationCommand) (interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
cancelCommand.Operator)
_, err := creationCooperationGateway.CooperationApplicationCancel(allied_creation_cooperation.ReqCooperationApplicationCancel{
ApplicationId: cancelCommand.CooperationApplicationId,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return cancelCommand, nil
}
// PersonSearchCooperationApplications 共创用户获取共创申请列表
func (srv CooperationApplicationsService) PersonSearchCooperationApplications(applicationQuery *command.ListCooperationApplicationQuery) (interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
applicationQuery.Operator)
resultApplications, err := creationCooperationGateway.CooperationApplicationsSearch(allied_creation_cooperation.ReqCooperationApplicationSearch{
PageNumber: applicationQuery.PageNumber,
PageSize: applicationQuery.PageSize,
CompanyId: int(applicationQuery.Operator.CompanyId),
CooperationApplicationStatus: applicationQuery.Status,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
// var dataList []dto.CooperationApplication
// for i := range resultApplications.Gride.List {
// item := dto.ToCooperationApplication(&resultApplications.Gride.List[i])
// dataList = append(dataList, *item)
// }
return resultApplications, nil
}
// CooperationApplicationsOneclickApproval 企业一键审核申请
func (srv CooperationApplicationsService) CooperationApplicationsOneclickApproval(auditCommand *command.AuditAllCooperationApplicationCommand) (interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
auditCommand.Operator)
_, err := creationCooperationGateway.CooperationApplicationsOneclickApproval(
allied_creation_cooperation.ReqCooperationApplicationOneclickApproval{
CooperationApplicationDescription: auditCommand.CooperationApplicationVerifyDescription,
Action: auditCommand.CooperationApplicationStatus,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return auditCommand, nil
}