...
|
...
|
@@ -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
|
...
|
...
|
@@ -653,7 +680,7 @@ func (repository *CooperationContractRepository) Remove(cooperationContract *dom |
|
|
if err := cooperationContractUndertakerQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
if _, err := tx.Model(&cooperationContractUndertakerModels).WherePK().Delete(); err != nil {
|
|
|
if _, err := tx.Model(&cooperationContractUndertakerModels).Delete(); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -663,7 +690,7 @@ func (repository *CooperationContractRepository) Remove(cooperationContract *dom |
|
|
if err := cooperationContractRelevantQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
if _, err := tx.Model(&cooperationContractRelevantModels).WherePK().Delete(); err != nil {
|
|
|
if _, err := tx.Model(&cooperationContractRelevantModels).Delete(); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -710,7 +737,7 @@ func (repository *CooperationContractRepository) BatchRemove(cooperationContract |
|
|
if err := cooperationContractUndertakerQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
if _, err := tx.Model(&cooperationContractUndertakerModels).WherePK().Delete(); err != nil {
|
|
|
if _, err := tx.Model(&cooperationContractUndertakerModels).Delete(); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -720,7 +747,7 @@ func (repository *CooperationContractRepository) BatchRemove(cooperationContract |
|
|
if err := cooperationContractRelevantQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
if _, err := tx.Model(&cooperationContractRelevantModels).WherePK().Delete(); err != nil {
|
|
|
if _, err := tx.Model(&cooperationContractRelevantModels).Delete(); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
}
|
...
|
...
|
|