|
@@ -428,7 +428,7 @@ func (cooperationContractService *CooperationContractService) RemoveCooperationC |
|
@@ -428,7 +428,7 @@ func (cooperationContractService *CooperationContractService) RemoveCooperationC |
|
428
|
}
|
428
|
}
|
|
429
|
}
|
429
|
}
|
|
430
|
|
430
|
|
|
431
|
-// BatchRemoveCooperationContract TODO 批量移除共创合约
|
431
|
+// BatchRemoveCooperationContract 批量移除共创合约
|
|
432
|
func (cooperationContractService *CooperationContractService) BatchRemoveCooperationContract(batchRemoveCooperationContractCommand *command.BatchRemoveCooperationContractCommand) (interface{}, error) {
|
432
|
func (cooperationContractService *CooperationContractService) BatchRemoveCooperationContract(batchRemoveCooperationContractCommand *command.BatchRemoveCooperationContractCommand) (interface{}, error) {
|
|
433
|
if err := batchRemoveCooperationContractCommand.ValidateCommand(); err != nil {
|
433
|
if err := batchRemoveCooperationContractCommand.ValidateCommand(); err != nil {
|
|
434
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
434
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
|
@@ -443,10 +443,33 @@ func (cooperationContractService *CooperationContractService) BatchRemoveCoopera |
|
@@ -443,10 +443,33 @@ func (cooperationContractService *CooperationContractService) BatchRemoveCoopera |
|
443
|
defer func() {
|
443
|
defer func() {
|
|
444
|
_ = transactionContext.RollbackTransaction()
|
444
|
_ = transactionContext.RollbackTransaction()
|
|
445
|
}()
|
445
|
}()
|
|
446
|
- if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
|
447
|
- return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
446
|
+ var cooperationContractRepository domain.CooperationContractRepository
|
|
|
|
447
|
+ if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
|
|
|
|
448
|
+ "transactionContext": transactionContext,
|
|
|
|
449
|
+ }); err != nil {
|
|
|
|
450
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
|
451
|
+ } else {
|
|
|
|
452
|
+ cooperationContractRepository = value
|
|
|
|
453
|
+ }
|
|
|
|
454
|
+ cooperationContractIds, _ := utils.SliceAtoi(batchRemoveCooperationContractCommand.CooperationContractIds)
|
|
|
|
455
|
+ if count, cooperationContracts, err := cooperationContractRepository.Find(map[string]interface{}{
|
|
|
|
456
|
+ "cooperationContractIds": cooperationContractIds,
|
|
|
|
457
|
+ }); err != nil {
|
|
|
|
458
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
|
459
|
+ } else {
|
|
|
|
460
|
+ if count > 0 {
|
|
|
|
461
|
+ cooperationContractsRemoved, err := cooperationContractRepository.BatchRemove(cooperationContracts)
|
|
|
|
462
|
+ if err != nil {
|
|
|
|
463
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
|
464
|
+ }
|
|
|
|
465
|
+ if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
|
466
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
|
467
|
+ }
|
|
|
|
468
|
+ return cooperationContractsRemoved, nil
|
|
|
|
469
|
+ } else {
|
|
|
|
470
|
+ return map[string]interface{}{}, nil
|
|
|
|
471
|
+ }
|
|
448
|
}
|
472
|
}
|
|
449
|
- return nil, nil
|
|
|
|
450
|
}
|
473
|
}
|
|
451
|
|
474
|
|
|
452
|
// OperateCooperationContract 暂停或恢复共创合约
|
475
|
// OperateCooperationContract 暂停或恢复共创合约
|
|
@@ -527,17 +550,18 @@ func (cooperationContractService *CooperationContractService) BatchOperateCooper |
|
@@ -527,17 +550,18 @@ func (cooperationContractService *CooperationContractService) BatchOperateCooper |
|
527
|
for i, _ := range cooperationContracts {
|
550
|
for i, _ := range cooperationContracts {
|
|
528
|
cooperationContracts[i].Status = batchOperateCooperationContractCommand.Action
|
551
|
cooperationContracts[i].Status = batchOperateCooperationContractCommand.Action
|
|
529
|
}
|
552
|
}
|
|
530
|
- if cooperationContractsReturn, err := cooperationContractRepository.UpdateMany(cooperationContracts); err != nil {
|
|
|
|
531
|
- if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
|
532
|
- return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
|
533
|
- }
|
|
|
|
534
|
- return cooperationContractsReturn, nil
|
553
|
+ cooperationContractsOperated, err := cooperationContractRepository.UpdateMany(cooperationContracts)
|
|
|
|
554
|
+ if err != nil {
|
|
|
|
555
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
535
|
}
|
556
|
}
|
|
|
|
557
|
+ if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
|
558
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
|
559
|
+ }
|
|
|
|
560
|
+ return cooperationContractsOperated, nil
|
|
536
|
} else {
|
561
|
} else {
|
|
537
|
return map[string]interface{}{}, nil
|
562
|
return map[string]interface{}{}, nil
|
|
538
|
}
|
563
|
}
|
|
539
|
}
|
564
|
}
|
|
540
|
- return nil, nil
|
|
|
|
541
|
}
|
565
|
}
|
|
542
|
|
566
|
|
|
543
|
// SearchCooperationContract 查询共创合约
|
567
|
// SearchCooperationContract 查询共创合约
|