作者 陈志颖

feat:添加共创合约暂停或恢复服务

@@ -8,6 +8,8 @@ import ( @@ -8,6 +8,8 @@ import (
8 ) 8 )
9 9
10 type BatchOperateCooperationContractCommand struct { 10 type BatchOperateCooperationContractCommand struct {
  11 + // 共创合约id列表
  12 + CooperationContractIds []string `cname:"共创合约id" json:"cooperationContractIds" valid:"Required"`
11 // 公司ID,通过集成REST上下文获取 13 // 公司ID,通过集成REST上下文获取
12 CompanyId int64 `cname:"公司ID" json:"companyId,string" valid:"Required"` 14 CompanyId int64 `cname:"公司ID" json:"companyId,string" valid:"Required"`
13 // 组织机构ID 15 // 组织机构ID
@@ -8,6 +8,8 @@ import ( @@ -8,6 +8,8 @@ import (
8 ) 8 )
9 9
10 type BatchRemoveCooperationContractCommand struct { 10 type BatchRemoveCooperationContractCommand struct {
  11 + // 共创合约id列表
  12 + CooperationContractIds []string `cname:"共创合约id" json:"cooperationContractIds" valid:"Required"`
11 // 公司ID,通过集成REST上下文获取 13 // 公司ID,通过集成REST上下文获取
12 CompanyId int64 `cname:"公司ID" json:"companyId,string" valid:"Required"` 14 CompanyId int64 `cname:"公司ID" json:"companyId,string" valid:"Required"`
13 // 组织机构ID 15 // 组织机构ID
@@ -8,6 +8,10 @@ import ( @@ -8,6 +8,10 @@ import (
8 ) 8 )
9 9
10 type OperateCooperationContractCommand struct { 10 type OperateCooperationContractCommand struct {
  11 + // 共创合约id
  12 + CooperationContractId string `cname:"共创合约id" json:"cooperationContractId" valid:"Required"`
  13 + // 操作
  14 + Action int32 `cname:"操作" json:"action" valid:"Required"`
11 // 公司ID,通过集成REST上下文获取 15 // 公司ID,通过集成REST上下文获取
12 CompanyId int64 `cname:"公司ID" json:"companyId,string" valid:"Required"` 16 CompanyId int64 `cname:"公司ID" json:"companyId,string" valid:"Required"`
13 // 组织机构ID 17 // 组织机构ID
@@ -448,7 +448,7 @@ func (cooperationContractService *CooperationContractService) BatchRemoveCoopera @@ -448,7 +448,7 @@ func (cooperationContractService *CooperationContractService) BatchRemoveCoopera
448 return nil, nil 448 return nil, nil
449 } 449 }
450 450
451 -// OperateRemoveCooperationContract TODO 暂停或恢复共创合约 451 +// OperateCooperationContract 暂停或恢复共创合约
452 func (cooperationContractService *CooperationContractService) OperateCooperationContract(operateCooperationContractCommand *command.OperateCooperationContractCommand) (interface{}, error) { 452 func (cooperationContractService *CooperationContractService) OperateCooperationContract(operateCooperationContractCommand *command.OperateCooperationContractCommand) (interface{}, error) {
453 if err := operateCooperationContractCommand.ValidateCommand(); err != nil { 453 if err := operateCooperationContractCommand.ValidateCommand(); err != nil {
454 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 454 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -463,10 +463,34 @@ func (cooperationContractService *CooperationContractService) OperateCooperation @@ -463,10 +463,34 @@ func (cooperationContractService *CooperationContractService) OperateCooperation
463 defer func() { 463 defer func() {
464 _ = transactionContext.RollbackTransaction() 464 _ = transactionContext.RollbackTransaction()
465 }() 465 }()
466 - if err := transactionContext.CommitTransaction(); err != nil {  
467 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 466 + var cooperationContractRepository domain.CooperationContractRepository
  467 + if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
  468 + "transactionContext": transactionContext,
  469 + }); err != nil {
  470 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  471 + } else {
  472 + cooperationContractRepository = value
  473 + }
  474 + cooperationContract, err := cooperationContractRepository.FindOne(map[string]interface{}{"cooperationContractId": operateCooperationContractCommand.CooperationContractId})
  475 + if err != nil {
  476 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  477 + }
  478 + if cooperationContract == nil {
  479 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(operateCooperationContractCommand.CooperationContractId)))
  480 + }
  481 + if err := cooperationContract.Update(map[string]interface{}{
  482 + "action": operateCooperationContractCommand,
  483 + }); err != nil {
  484 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  485 + }
  486 + if cooperationContract, err := cooperationContractRepository.Save(cooperationContract); err != nil {
  487 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  488 + } else {
  489 + if err := transactionContext.CommitTransaction(); err != nil {
  490 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  491 + }
  492 + return cooperationContract, nil
468 } 493 }
469 - return nil, nil  
470 } 494 }
471 495
472 // BatchOperateCooperationContract TODO 批量暂停或恢复共创合约 496 // BatchOperateCooperationContract TODO 批量暂停或恢复共创合约
@@ -81,6 +81,9 @@ func (cooperationContract *CooperationContract) Update(data map[string]interface @@ -81,6 +81,9 @@ func (cooperationContract *CooperationContract) Update(data map[string]interface
81 if status, ok := data["status"]; ok { 81 if status, ok := data["status"]; ok {
82 cooperationContract.Status = status.(int32) 82 cooperationContract.Status = status.(int32)
83 } 83 }
  84 + if action, ok := data["action"]; ok {
  85 + cooperationContract.Status = action.(int32)
  86 + }
84 if operateTime, ok := data["operateTime"]; ok { 87 if operateTime, ok := data["operateTime"]; ok {
85 cooperationContract.OperateTime = operateTime.(time.Time) 88 cooperationContract.OperateTime = operateTime.(time.Time)
86 } 89 }