作者 陈志颖

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

... ... @@ -507,7 +507,7 @@ func (cooperationContractService *CooperationContractService) OperateCooperation
}); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
if cooperationContract, err := cooperationContractRepository.Save(cooperationContract); err != nil {
if cooperationContract, err := cooperationContractRepository.UpdateOne(cooperationContract); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
... ...
... ... @@ -50,7 +50,8 @@ type CooperationContract struct {
type CooperationContractRepository interface {
Save(cooperationContract *CooperationContract) (*CooperationContract, error)
UpdateMany(cooperationContract []*CooperationContract) ([]*CooperationContract, error)
UpdateOne(cooperationContract *CooperationContract) (*CooperationContract, error)
UpdateMany(cooperationContracts []*CooperationContract) ([]*CooperationContract, error)
Remove(cooperationContract *CooperationContract) (*CooperationContract, error)
BatchRemove(cooperationContracts []*CooperationContract) ([]*CooperationContract, error)
FindOne(queryOptions map[string]interface{}) (*CooperationContract, error)
... ...
... ... @@ -591,6 +591,33 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
return cooperationContract, nil
}
func (repository *CooperationContractRepository) UpdateOne(cooperationContract *domain.CooperationContract) (*domain.CooperationContract, error) {
tx := repository.transactionContext.PgTx
cooperationContractModel := new(models.CooperationContract)
cooperationContractModel = &models.CooperationContract{
CooperationContractId: cooperationContract.CooperationContractId,
CooperationContractDescription: cooperationContract.CooperationContractDescription,
CooperationContractName: cooperationContract.CooperationContractName,
CooperationContractNumber: cooperationContract.CooperationContractNumber,
CooperationProjectNumber: cooperationContract.CooperationProjectNumber,
CooperationContractUndertakerTypes: cooperationContract.CooperationContractUndertakerTypes,
CooperationContractSponsor: cooperationContract.CooperationContractSponsor,
CooperationModeNumber: cooperationContract.CooperationMode.CooperationModeNumber,
Status: cooperationContract.Status,
Org: cooperationContract.Org,
Company: cooperationContract.Company,
Operator: cooperationContract.Operator,
OperateTime: cooperationContract.OperateTime,
CreatedAt: cooperationContract.CreatedAt,
DeletedAt: cooperationContract.DeletedAt,
UpdatedAt: time.Now(),
}
if _, err := tx.Model(cooperationContractModel).WherePK().Update(); err != nil {
return nil, err
}
return cooperationContract, nil
}
func (repository *CooperationContractRepository) UpdateMany(cooperationContracts []*domain.CooperationContract) ([]*domain.CooperationContract, error) {
tx := repository.transactionContext.PgTx
var cooperationContractModels []*models.CooperationContract
... ...