正在显示
9 个修改的文件
包含
333 行增加
和
7 行删除
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type BatchOperateCooperationModeCommand struct { | ||
12 | + // 共创模式ID | ||
13 | + CooperationModeIds []string `cname:"共创模式id" json:"cooperationModeIds" valid:"Required"` | ||
14 | + // 共创模式状态,1启用,2禁用 | ||
15 | + Status int32 `cname:"状态" json:"status" valid:"Required"` | ||
16 | + // 公司ID,通过集成REST上下文获取 | ||
17 | + CompanyId int64 `cname:"公司ID" json:"companyId,string" valid:"Required"` | ||
18 | + // 组织机构ID | ||
19 | + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"` | ||
20 | + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员 | ||
21 | + UserId int64 `cname:"用户ID" json:"userId,string" valid:"Required"` | ||
22 | + // 用户基础数据id | ||
23 | + UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId,string"` | ||
24 | +} | ||
25 | + | ||
26 | +func (batchOperateCooperationModeCommand *BatchOperateCooperationModeCommand) Valid(validation *validation.Validation) { | ||
27 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
28 | +} | ||
29 | + | ||
30 | +func (batchOperateCooperationModeCommand *BatchOperateCooperationModeCommand) ValidateCommand() error { | ||
31 | + valid := validation.Validation{} | ||
32 | + b, err := valid.Valid(batchOperateCooperationModeCommand) | ||
33 | + if err != nil { | ||
34 | + return err | ||
35 | + } | ||
36 | + if !b { | ||
37 | + elem := reflect.TypeOf(batchOperateCooperationModeCommand).Elem() | ||
38 | + for _, validErr := range valid.Errors { | ||
39 | + field, isExist := elem.FieldByName(validErr.Field) | ||
40 | + if isExist { | ||
41 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
42 | + } else { | ||
43 | + return fmt.Errorf(validErr.Message) | ||
44 | + } | ||
45 | + } | ||
46 | + } | ||
47 | + return nil | ||
48 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type BatchRemoveCooperationModeCommand struct { | ||
12 | + // 共创模式ID数组 | ||
13 | + CooperationModeIds []string `cname:"共创模式ID数组" json:"cooperationModeIds,string" valid:"Required"` | ||
14 | + // 公司ID,通过集成REST上下文获取 | ||
15 | + CompanyId int64 `cname:"公司ID" json:"companyId,string" valid:"Required"` | ||
16 | + // 组织机构ID | ||
17 | + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"` | ||
18 | + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员 | ||
19 | + UserId int64 `cname:"用户ID" json:"userId,string" valid:"Required"` | ||
20 | + // 用户基础数据id | ||
21 | + UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId,string"` | ||
22 | +} | ||
23 | + | ||
24 | +func (batchRemoveCooperationModeCommand *BatchRemoveCooperationModeCommand) Valid(validation *validation.Validation) { | ||
25 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
26 | +} | ||
27 | + | ||
28 | +func (batchRemoveCooperationModeCommand *BatchRemoveCooperationModeCommand) ValidateCommand() error { | ||
29 | + valid := validation.Validation{} | ||
30 | + b, err := valid.Valid(batchRemoveCooperationModeCommand) | ||
31 | + if err != nil { | ||
32 | + return err | ||
33 | + } | ||
34 | + if !b { | ||
35 | + elem := reflect.TypeOf(batchRemoveCooperationModeCommand).Elem() | ||
36 | + for _, validErr := range valid.Errors { | ||
37 | + field, isExist := elem.FieldByName(validErr.Field) | ||
38 | + if isExist { | ||
39 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
40 | + } else { | ||
41 | + return fmt.Errorf(validErr.Message) | ||
42 | + } | ||
43 | + } | ||
44 | + } | ||
45 | + return nil | ||
46 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type OperateCooperationModeCommand struct { | ||
12 | + // 共创模式ID | ||
13 | + CooperationModeId string `cname:"共创模式id" json:"cooperationModeId" valid:"Required"` | ||
14 | + // 共创模式状态,1启用,2禁用 | ||
15 | + Status int32 `cname:"状态" json:"status" valid:"Required"` | ||
16 | + // 公司ID,通过集成REST上下文获取 | ||
17 | + CompanyId int64 `cname:"公司ID" json:"companyId,string" valid:"Required"` | ||
18 | + // 组织机构ID | ||
19 | + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"` | ||
20 | + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员 | ||
21 | + UserId int64 `cname:"用户ID" json:"userId,string" valid:"Required"` | ||
22 | + // 用户基础数据id | ||
23 | + UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId,string"` | ||
24 | +} | ||
25 | + | ||
26 | +func (operateCooperationModeCommand *OperateCooperationModeCommand) Valid(validation *validation.Validation) { | ||
27 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
28 | +} | ||
29 | + | ||
30 | +func (operateCooperationModeCommand *OperateCooperationModeCommand) ValidateCommand() error { | ||
31 | + valid := validation.Validation{} | ||
32 | + b, err := valid.Valid(operateCooperationModeCommand) | ||
33 | + if err != nil { | ||
34 | + return err | ||
35 | + } | ||
36 | + if !b { | ||
37 | + elem := reflect.TypeOf(operateCooperationModeCommand).Elem() | ||
38 | + for _, validErr := range valid.Errors { | ||
39 | + field, isExist := elem.FieldByName(validErr.Field) | ||
40 | + if isExist { | ||
41 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
42 | + } else { | ||
43 | + return fmt.Errorf(validErr.Message) | ||
44 | + } | ||
45 | + } | ||
46 | + } | ||
47 | + return nil | ||
48 | +} |
@@ -9,6 +9,7 @@ import ( | @@ -9,6 +9,7 @@ import ( | ||
9 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory" | 9 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory" |
10 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" | 10 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" |
11 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service" | 11 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service" |
12 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils" | ||
12 | "strconv" | 13 | "strconv" |
13 | "time" | 14 | "time" |
14 | ) | 15 | ) |
@@ -231,6 +232,49 @@ func (cooperationModeService *CooperationModeService) RemoveCooperationMode(remo | @@ -231,6 +232,49 @@ func (cooperationModeService *CooperationModeService) RemoveCooperationMode(remo | ||
231 | } | 232 | } |
232 | } | 233 | } |
233 | 234 | ||
235 | +// BatchRemoveCooperationMode 移除共创模式服务 | ||
236 | +func (cooperationModeService *CooperationModeService) BatchRemoveCooperationMode(batchRemoveCooperationModeCommand *command.BatchRemoveCooperationModeCommand) (interface{}, error) { | ||
237 | + if err := batchRemoveCooperationModeCommand.ValidateCommand(); err != nil { | ||
238 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
239 | + } | ||
240 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
241 | + if err != nil { | ||
242 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
243 | + } | ||
244 | + if err := transactionContext.StartTransaction(); err != nil { | ||
245 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
246 | + } | ||
247 | + defer func() { | ||
248 | + _ = transactionContext.RollbackTransaction() | ||
249 | + }() | ||
250 | + var cooperationModeRepository domain.CooperationModeRepository | ||
251 | + if value, err := factory.CreateCooperationModeRepository(map[string]interface{}{ | ||
252 | + "transactionContext": transactionContext, | ||
253 | + }); err != nil { | ||
254 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
255 | + } else { | ||
256 | + cooperationModeRepository = value | ||
257 | + } | ||
258 | + cooperationModeIds, _ := utils.SliceAtoi(batchRemoveCooperationModeCommand.CooperationModeIds) | ||
259 | + if count, cooperationModes, err := cooperationModeRepository.Find(map[string]interface{}{ | ||
260 | + "cooperationModeIds": cooperationModeIds, | ||
261 | + }); err != nil { | ||
262 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
263 | + } else { | ||
264 | + if count > 0 { | ||
265 | + if cooperationMode, err := cooperationModeRepository.BatchRemove(cooperationModes); err != nil { | ||
266 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
267 | + } else { | ||
268 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
269 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
270 | + } | ||
271 | + return cooperationMode, nil | ||
272 | + } | ||
273 | + } | ||
274 | + } | ||
275 | + return map[string]interface{}{}, nil | ||
276 | +} | ||
277 | + | ||
234 | // SearchCooperationMode 查询共创模式 | 278 | // SearchCooperationMode 查询共创模式 |
235 | func (cooperationModeService *CooperationModeService) SearchCooperationMode(searchCooperationModeQuery *query.SearchCooperationModeQuery) (interface{}, error) { | 279 | func (cooperationModeService *CooperationModeService) SearchCooperationMode(searchCooperationModeQuery *query.SearchCooperationModeQuery) (interface{}, error) { |
236 | if err := searchCooperationModeQuery.ValidateQuery(); err != nil { | 280 | if err := searchCooperationModeQuery.ValidateQuery(); err != nil { |
@@ -312,6 +356,72 @@ func (cooperationModeService *CooperationModeService) UpdateCooperationMode(upda | @@ -312,6 +356,72 @@ func (cooperationModeService *CooperationModeService) UpdateCooperationMode(upda | ||
312 | } | 356 | } |
313 | } | 357 | } |
314 | 358 | ||
359 | +// OperateCooperationMode 更新共创模式服务 | ||
360 | +func (cooperationModeService *CooperationModeService) OperateCooperationMode(operateCooperationModeCommand *command.OperateCooperationModeCommand) (interface{}, error) { | ||
361 | + if err := operateCooperationModeCommand.ValidateCommand(); err != nil { | ||
362 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
363 | + } | ||
364 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
365 | + if err != nil { | ||
366 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
367 | + } | ||
368 | + if err := transactionContext.StartTransaction(); err != nil { | ||
369 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
370 | + } | ||
371 | + defer func() { | ||
372 | + _ = transactionContext.RollbackTransaction() | ||
373 | + }() | ||
374 | + var cooperationModeRepository domain.CooperationModeRepository | ||
375 | + if value, err := factory.CreateCooperationModeRepository(map[string]interface{}{ | ||
376 | + "transactionContext": transactionContext, | ||
377 | + }); err != nil { | ||
378 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
379 | + } else { | ||
380 | + cooperationModeRepository = value | ||
381 | + } | ||
382 | + cooperationModeId, _ := strconv.ParseInt(operateCooperationModeCommand.CooperationModeId, 10, 64) | ||
383 | + cooperationMode, err := cooperationModeRepository.FindOne(map[string]interface{}{"cooperationModeId": cooperationModeId}) | ||
384 | + if err != nil { | ||
385 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
386 | + } | ||
387 | + if cooperationMode == nil { | ||
388 | + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(cooperationModeId, 10))) | ||
389 | + } | ||
390 | + if err := cooperationMode.Update(tool_funs.SimpleStructToMap(operateCooperationModeCommand)); err != nil { | ||
391 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
392 | + } | ||
393 | + if cooperationMode, err := cooperationModeRepository.Save(cooperationMode); err != nil { | ||
394 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
395 | + } else { | ||
396 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
397 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
398 | + } | ||
399 | + return cooperationMode, nil | ||
400 | + } | ||
401 | +} | ||
402 | + | ||
403 | +// BatchOperateCooperationMode 更新共创模式服务 | ||
404 | +func (cooperationModeService *CooperationModeService) BatchOperateCooperationMode(batchOperateCooperationModeCommand *command.BatchOperateCooperationModeCommand) (interface{}, error) { | ||
405 | + if err := batchOperateCooperationModeCommand.ValidateCommand(); err != nil { | ||
406 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
407 | + } | ||
408 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
409 | + if err != nil { | ||
410 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
411 | + } | ||
412 | + if err := transactionContext.StartTransaction(); err != nil { | ||
413 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
414 | + } | ||
415 | + defer func() { | ||
416 | + _ = transactionContext.RollbackTransaction() | ||
417 | + }() | ||
418 | + | ||
419 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
420 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
421 | + } | ||
422 | + return nil, nil | ||
423 | +} | ||
424 | + | ||
315 | func NewCooperationModeService(options map[string]interface{}) *CooperationModeService { | 425 | func NewCooperationModeService(options map[string]interface{}) *CooperationModeService { |
316 | newCooperationModeService := &CooperationModeService{} | 426 | newCooperationModeService := &CooperationModeService{} |
317 | return newCooperationModeService | 427 | return newCooperationModeService |
@@ -33,6 +33,7 @@ type CooperationMode struct { | @@ -33,6 +33,7 @@ type CooperationMode struct { | ||
33 | type CooperationModeRepository interface { | 33 | type CooperationModeRepository interface { |
34 | Save(cooperationMode *CooperationMode) (*CooperationMode, error) | 34 | Save(cooperationMode *CooperationMode) (*CooperationMode, error) |
35 | Remove(cooperationMode *CooperationMode) (*CooperationMode, error) | 35 | Remove(cooperationMode *CooperationMode) (*CooperationMode, error) |
36 | + BatchRemove(cooperationModes []*CooperationMode) ([]*CooperationMode, error) | ||
36 | FindOne(queryOptions map[string]interface{}) (*CooperationMode, error) | 37 | FindOne(queryOptions map[string]interface{}) (*CooperationMode, error) |
37 | Find(queryOptions map[string]interface{}) (int64, []*CooperationMode, error) | 38 | Find(queryOptions map[string]interface{}) (int64, []*CooperationMode, error) |
38 | } | 39 | } |
@@ -3,7 +3,6 @@ package repository | @@ -3,7 +3,6 @@ package repository | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | "github.com/go-pg/pg/v10" | 5 | "github.com/go-pg/pg/v10" |
6 | - | ||
7 | "github.com/linmadan/egglib-go/persistent/pg/sqlbuilder" | 6 | "github.com/linmadan/egglib-go/persistent/pg/sqlbuilder" |
8 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | 7 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" |
9 | "github.com/linmadan/egglib-go/utils/snowflake" | 8 | "github.com/linmadan/egglib-go/utils/snowflake" |
@@ -131,6 +130,21 @@ func (repository *CooperationModeRepository) Remove(cooperationMode *domain.Coop | @@ -131,6 +130,21 @@ func (repository *CooperationModeRepository) Remove(cooperationMode *domain.Coop | ||
131 | return cooperationMode, nil | 130 | return cooperationMode, nil |
132 | } | 131 | } |
133 | 132 | ||
133 | +// BatchRemove 批量删除 | ||
134 | +func (repository *CooperationModeRepository) BatchRemove(cooperationModes []*domain.CooperationMode) ([]*domain.CooperationMode, error) { | ||
135 | + tx := repository.transactionContext.PgTx | ||
136 | + var cooperationModeModels []*models.CooperationMode | ||
137 | + for _, cooperationMode := range cooperationModes { | ||
138 | + cooperationModeModels = append(cooperationModeModels, &models.CooperationMode{ | ||
139 | + CooperationModeId: cooperationMode.Identify().(int64), | ||
140 | + }) | ||
141 | + } | ||
142 | + if _, err := tx.Model(&cooperationModeModels).WherePK().Delete(); err != nil { | ||
143 | + return cooperationModes, err | ||
144 | + } | ||
145 | + return cooperationModes, nil | ||
146 | +} | ||
147 | + | ||
134 | func (repository *CooperationModeRepository) FindOne(queryOptions map[string]interface{}) (*domain.CooperationMode, error) { | 148 | func (repository *CooperationModeRepository) FindOne(queryOptions map[string]interface{}) (*domain.CooperationMode, error) { |
135 | tx := repository.transactionContext.PgTx | 149 | tx := repository.transactionContext.PgTx |
136 | cooperationModeModel := new(models.CooperationMode) | 150 | cooperationModeModel := new(models.CooperationMode) |
1 | package utils | 1 | package utils |
2 | 2 | ||
3 | +import "strconv" | ||
4 | + | ||
3 | // Intersect 返回两个数组的交集 | 5 | // Intersect 返回两个数组的交集 |
4 | func Intersect(nums1 []int64, nums2 []int64) []int64 { | 6 | func Intersect(nums1 []int64, nums2 []int64) []int64 { |
5 | if len(nums1) > len(nums2) { | 7 | if len(nums1) > len(nums2) { |
@@ -54,3 +56,15 @@ func Difference(slice1, slice2 []int64) []int64 { | @@ -54,3 +56,15 @@ func Difference(slice1, slice2 []int64) []int64 { | ||
54 | } | 56 | } |
55 | return nn | 57 | return nn |
56 | } | 58 | } |
59 | + | ||
60 | +func SliceAtoi(sa []string) ([]int64, error) { | ||
61 | + si := make([]int64, 0, len(sa)) | ||
62 | + for _, a := range sa { | ||
63 | + i, err := strconv.ParseInt(a, 10, 64) | ||
64 | + if err != nil { | ||
65 | + return si, err | ||
66 | + } | ||
67 | + si = append(si, i) | ||
68 | + } | ||
69 | + return si, nil | ||
70 | +} |
@@ -71,6 +71,20 @@ func (controller *CooperationModeController) RemoveCooperationMode() { | @@ -71,6 +71,20 @@ func (controller *CooperationModeController) RemoveCooperationMode() { | ||
71 | controller.Response(data, err) | 71 | controller.Response(data, err) |
72 | } | 72 | } |
73 | 73 | ||
74 | +func (controller *CooperationModeController) BatchRemoveCooperationMode() { | ||
75 | + cooperationModeService := service.NewCooperationModeService(nil) | ||
76 | + batchRemoveCooperationModeCommand := &command.BatchRemoveCooperationModeCommand{} | ||
77 | + _ = controller.Unmarshal(batchRemoveCooperationModeCommand) | ||
78 | + // 解析头部信息 | ||
79 | + header := controller.GetRequestHeader(controller.Ctx) | ||
80 | + batchRemoveCooperationModeCommand.CompanyId = header.CompanyId | ||
81 | + batchRemoveCooperationModeCommand.OrgId = header.OrgId | ||
82 | + batchRemoveCooperationModeCommand.UserId = header.UserId | ||
83 | + batchRemoveCooperationModeCommand.UserBaseId = header.UserBaseId | ||
84 | + data, err := cooperationModeService.BatchRemoveCooperationMode(batchRemoveCooperationModeCommand) | ||
85 | + controller.Response(data, err) | ||
86 | +} | ||
87 | + | ||
74 | func (controller *CooperationModeController) SearchCooperationMode() { | 88 | func (controller *CooperationModeController) SearchCooperationMode() { |
75 | cooperationModeService := service.NewCooperationModeService(nil) | 89 | cooperationModeService := service.NewCooperationModeService(nil) |
76 | searchCooperationModeQuery := &query.SearchCooperationModeQuery{} | 90 | searchCooperationModeQuery := &query.SearchCooperationModeQuery{} |
@@ -101,3 +115,31 @@ func (controller *CooperationModeController) ListCooperationMode() { | @@ -101,3 +115,31 @@ func (controller *CooperationModeController) ListCooperationMode() { | ||
101 | data, err := cooperationModeService.ListCooperationMode(listCooperationModeQuery) | 115 | data, err := cooperationModeService.ListCooperationMode(listCooperationModeQuery) |
102 | controller.Response(data, err) | 116 | controller.Response(data, err) |
103 | } | 117 | } |
118 | + | ||
119 | +func (controller *CooperationModeController) OperateCooperationMode() { | ||
120 | + cooperationModeService := service.NewCooperationModeService(nil) | ||
121 | + operateCooperationModeCommand := &command.OperateCooperationModeCommand{} | ||
122 | + _ = controller.Unmarshal(operateCooperationModeCommand) | ||
123 | + // 解析头部信息 | ||
124 | + header := controller.GetRequestHeader(controller.Ctx) | ||
125 | + operateCooperationModeCommand.CompanyId = header.CompanyId | ||
126 | + operateCooperationModeCommand.OrgId = header.OrgId | ||
127 | + operateCooperationModeCommand.UserId = header.UserId | ||
128 | + operateCooperationModeCommand.UserBaseId = header.UserBaseId | ||
129 | + data, err := cooperationModeService.OperateCooperationMode(operateCooperationModeCommand) | ||
130 | + controller.Response(data, err) | ||
131 | +} | ||
132 | + | ||
133 | +func (controller *CooperationModeController) BatchOperateCooperationMode() { | ||
134 | + cooperationModeService := service.NewCooperationModeService(nil) | ||
135 | + batchOperateCooperationModeCommand := &command.BatchOperateCooperationModeCommand{} | ||
136 | + _ = controller.Unmarshal(batchOperateCooperationModeCommand) | ||
137 | + // 解析头部信息 | ||
138 | + header := controller.GetRequestHeader(controller.Ctx) | ||
139 | + batchOperateCooperationModeCommand.CompanyId = header.CompanyId | ||
140 | + batchOperateCooperationModeCommand.OrgId = header.OrgId | ||
141 | + batchOperateCooperationModeCommand.UserId = header.UserId | ||
142 | + batchOperateCooperationModeCommand.UserBaseId = header.UserBaseId | ||
143 | + data, err := cooperationModeService.BatchOperateCooperationMode(batchOperateCooperationModeCommand) | ||
144 | + controller.Response(data, err) | ||
145 | +} |
@@ -6,10 +6,13 @@ import ( | @@ -6,10 +6,13 @@ import ( | ||
6 | ) | 6 | ) |
7 | 7 | ||
8 | func init() { | 8 | func init() { |
9 | - web.Router("/cooperation-modes/", &controllers.CooperationModeController{}, "Post:CreateCooperationMode") | ||
10 | - web.Router("/cooperation-modes/:cooperationModeId", &controllers.CooperationModeController{}, "Put:UpdateCooperationMode") | ||
11 | - web.Router("/cooperation-modes/:cooperationModeId", &controllers.CooperationModeController{}, "Get:GetCooperationMode") | ||
12 | - web.Router("/cooperation-modes/:cooperationModeId", &controllers.CooperationModeController{}, "Delete:RemoveCooperationMode") | ||
13 | - web.Router("/cooperation-modes/search", &controllers.CooperationModeController{}, "Post:SearchCooperationMode") | ||
14 | - web.Router("/cooperation-modes/", &controllers.CooperationModeController{}, "Get:ListCooperationMode") | 9 | + web.Router("/cooperation-modes/", &controllers.CooperationModeController{}, "Post:CreateCooperationMode") // 创建共创模式 |
10 | + web.Router("/cooperation-modes/:cooperationModeId", &controllers.CooperationModeController{}, "Put:UpdateCooperationMode") // 编辑共创模式 | ||
11 | + web.Router("/cooperation-modes/:cooperationModeId", &controllers.CooperationModeController{}, "Get:GetCooperationMode") // 获取共创模式详情 | ||
12 | + web.Router("/cooperation-modes/:cooperationModeId", &controllers.CooperationModeController{}, "Delete:RemoveCooperationMode") // 删除共创模式 | ||
13 | + web.Router("/cooperation-modes/batch-remove", &controllers.CooperationModeController{}, "Post:BatchRemoveCooperationMode") // 批量删除共创模式 | ||
14 | + web.Router("/cooperation-modes/operate", &controllers.CooperationModeController{}, "Post:OperateCooperationMode") // 启用或禁用共创模式 | ||
15 | + web.Router("/cooperation-modes/batch-operate", &controllers.CooperationModeController{}, "Post:BatchOperateCooperationMode") // 批量启用或禁用共创模式 | ||
16 | + web.Router("/cooperation-modes/search", &controllers.CooperationModeController{}, "Post:SearchCooperationMode") // 查找共创模式 | ||
17 | + web.Router("/cooperation-modes/", &controllers.CooperationModeController{}, "Get:ListCooperationMode") // 返回共创模式列表 | ||
15 | } | 18 | } |
-
请 注册 或 登录 后发表评论