作者 陈志颖

feat:共创合约暂停和恢复服务调整

@@ -507,7 +507,7 @@ func (cooperationContractService *CooperationContractService) OperateCooperation @@ -507,7 +507,7 @@ func (cooperationContractService *CooperationContractService) OperateCooperation
507 }); err != nil { 507 }); err != nil {
508 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 508 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
509 } 509 }
510 - if cooperationContract, err := cooperationContractRepository.Save(cooperationContract); err != nil { 510 + if cooperationContract, err := cooperationContractRepository.UpdateOne(cooperationContract); err != nil {
511 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 511 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
512 } else { 512 } else {
513 if err := transactionContext.CommitTransaction(); err != nil { 513 if err := transactionContext.CommitTransaction(); err != nil {
@@ -50,7 +50,8 @@ type CooperationContract struct { @@ -50,7 +50,8 @@ type CooperationContract struct {
50 50
51 type CooperationContractRepository interface { 51 type CooperationContractRepository interface {
52 Save(cooperationContract *CooperationContract) (*CooperationContract, error) 52 Save(cooperationContract *CooperationContract) (*CooperationContract, error)
53 - UpdateMany(cooperationContract []*CooperationContract) ([]*CooperationContract, error) 53 + UpdateOne(cooperationContract *CooperationContract) (*CooperationContract, error)
  54 + UpdateMany(cooperationContracts []*CooperationContract) ([]*CooperationContract, error)
54 Remove(cooperationContract *CooperationContract) (*CooperationContract, error) 55 Remove(cooperationContract *CooperationContract) (*CooperationContract, error)
55 BatchRemove(cooperationContracts []*CooperationContract) ([]*CooperationContract, error) 56 BatchRemove(cooperationContracts []*CooperationContract) ([]*CooperationContract, error)
56 FindOne(queryOptions map[string]interface{}) (*CooperationContract, error) 57 FindOne(queryOptions map[string]interface{}) (*CooperationContract, error)
@@ -591,6 +591,33 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai @@ -591,6 +591,33 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
591 return cooperationContract, nil 591 return cooperationContract, nil
592 } 592 }
593 593
  594 +func (repository *CooperationContractRepository) UpdateOne(cooperationContract *domain.CooperationContract) (*domain.CooperationContract, error) {
  595 + tx := repository.transactionContext.PgTx
  596 + cooperationContractModel := new(models.CooperationContract)
  597 + cooperationContractModel = &models.CooperationContract{
  598 + CooperationContractId: cooperationContract.CooperationContractId,
  599 + CooperationContractDescription: cooperationContract.CooperationContractDescription,
  600 + CooperationContractName: cooperationContract.CooperationContractName,
  601 + CooperationContractNumber: cooperationContract.CooperationContractNumber,
  602 + CooperationProjectNumber: cooperationContract.CooperationProjectNumber,
  603 + CooperationContractUndertakerTypes: cooperationContract.CooperationContractUndertakerTypes,
  604 + CooperationContractSponsor: cooperationContract.CooperationContractSponsor,
  605 + CooperationModeNumber: cooperationContract.CooperationMode.CooperationModeNumber,
  606 + Status: cooperationContract.Status,
  607 + Org: cooperationContract.Org,
  608 + Company: cooperationContract.Company,
  609 + Operator: cooperationContract.Operator,
  610 + OperateTime: cooperationContract.OperateTime,
  611 + CreatedAt: cooperationContract.CreatedAt,
  612 + DeletedAt: cooperationContract.DeletedAt,
  613 + UpdatedAt: time.Now(),
  614 + }
  615 + if _, err := tx.Model(cooperationContractModel).WherePK().Update(); err != nil {
  616 + return nil, err
  617 + }
  618 + return cooperationContract, nil
  619 +}
  620 +
594 func (repository *CooperationContractRepository) UpdateMany(cooperationContracts []*domain.CooperationContract) ([]*domain.CooperationContract, error) { 621 func (repository *CooperationContractRepository) UpdateMany(cooperationContracts []*domain.CooperationContract) ([]*domain.CooperationContract, error) {
595 tx := repository.transactionContext.PgTx 622 tx := repository.transactionContext.PgTx
596 var cooperationContractModels []*models.CooperationContract 623 var cooperationContractModels []*models.CooperationContract