cooperation_mode.go
6.5 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
package service
import (
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/cooperationMode/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/cooperationMode/dto"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/cooperationMode/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
)
// 共创模式服务
type CooperationModeService struct {
}
//CreateCooperationMode 创建共创模式服务
func (cooperationModeService *CooperationModeService) CreateCooperationMode(createCooperationModeCommand *command.CreateCooperationModeCommand) (interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(createCooperationModeCommand.Operator)
result, err := creationCooperationGateway.CooperationModeAdd(allied_creation_cooperation.ReqCooperationModeAdd{
CooperationModeName: createCooperationModeCommand.CooperationModeName,
CooperationModeNumber: createCooperationModeCommand.CooperationModeNumber,
Remarks: createCooperationModeCommand.Remarks,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
data := struct {
CooperationModeId int `json:"cooperationModeId,string,"`
command.CreateCooperationModeCommand
}{
CooperationModeId: result.CooperationModeId,
CreateCooperationModeCommand: *createCooperationModeCommand,
}
return data, nil
}
//GetCooperationMode 返回共创模式服务
func (cooperationModeService *CooperationModeService) GetCooperationMode(getCooperationModeQuery *query.GetCooperationModeQuery) (interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(getCooperationModeQuery.Operator)
result, err := creationCooperationGateway.CooperationModeGet(allied_creation_cooperation.ReqCooperationModeGet{
CooperationModeId: getCooperationModeQuery.CooperationModeId,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
data := dto.CooperationModeItem{
CooperationModeId: result.CooperationModeId,
CooperationModeName: result.CooperationModeName,
Remarks: result.Remarks,
Status: result.Status,
CooperationModeNumber: result.CooperationModeNumber,
Org: result.Org,
}
return data, nil
}
//ListCooperationMode 返回共创模式服务列表
func (cooperationModeService *CooperationModeService) ListCooperationMode(listCooperationModeQuery *query.ListCooperationModeQuery) (int64, interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(listCooperationModeQuery.Operator)
result, err := creationCooperationGateway.CooperationModesSearch(allied_creation_cooperation.ReqCooperationModesSearch{
PageNumber: listCooperationModeQuery.PageNumber,
PageSize: listCooperationModeQuery.PageSize,
CooperationModeName: listCooperationModeQuery.CooperationModeName,
OrganizationName: listCooperationModeQuery.OrganizationName,
CompanyId: listCooperationModeQuery.Operator.CompanyId,
UserId: 0,
OrgIds: listCooperationModeQuery.Operator.OrgIds,
OrgId: 0,
UserBaseId: 0,
})
if err != nil {
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
var (
listData = make([]dto.CooperationModeItem, 0)
item dto.CooperationModeItem
)
for _, v := range result.List {
item = dto.CooperationModeItem{
CooperationModeId: v.CooperationModeId,
CooperationModeName: v.CooperationModeName,
Remarks: v.Remarks,
Status: v.Status,
CooperationModeNumber: v.CooperationModeNumber,
Org: v.Org,
}
listData = append(listData, item)
}
return int64(result.Total), listData, nil
}
//RemoveCooperationMode 移除共创模式服务
func (cooperationModeService *CooperationModeService) RemoveCooperationMode(removeCooperationModeCommand *command.RemoveCooperationModeCommand) (interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(removeCooperationModeCommand.Operator)
_, err := creationCooperationGateway.CooperationModeBatchRemove(allied_creation_cooperation.ReqCooperationModeBatchRemove{
CooperationModeIds: removeCooperationModeCommand.CooperationModeId,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return removeCooperationModeCommand, nil
}
//UpdateCooperationMode 更新共创模式
func (cooperationModeService *CooperationModeService) UpdateCooperationMode(updateCooperationModeCommand *command.UpdateCooperationModeCommand) (interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(updateCooperationModeCommand.Operator)
_, err := creationCooperationGateway.CooperationModeUpdate(allied_creation_cooperation.ReqCooperationModeUpdate{
CooperationModeId: updateCooperationModeCommand.CooperationModeId,
CooperationModeName: updateCooperationModeCommand.CooperationModeName,
Remarks: updateCooperationModeCommand.Remarks,
Status: updateCooperationModeCommand.Status,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return updateCooperationModeCommand, nil
}
// EnableCooperationMode 禁用启用共创模式
func (cooperationModeService *CooperationModeService) EnableCooperationMode(updateCooperationModeCommand *command.OperateCooperationModeCommand) (interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(updateCooperationModeCommand.Operator)
_, err := creationCooperationGateway.CooperationModeOperate(allied_creation_cooperation.ReqOperateCooperationMode{
CooperationModeId: updateCooperationModeCommand.CooperationModeId,
Status: updateCooperationModeCommand.Status,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return updateCooperationModeCommand, nil
}
func NewCooperationModeService(options map[string]interface{}) *CooperationModeService {
newCooperationModeService := &CooperationModeService{}
return newCooperationModeService
}