正在显示
3 个修改的文件
包含
18 行增加
和
2 行删除
| @@ -78,6 +78,7 @@ type DividendsEstimateRepository interface { | @@ -78,6 +78,7 @@ type DividendsEstimateRepository interface { | ||
| 78 | SaveMany(dividendsEstimates []*DividendsEstimate) ([]*DividendsEstimate, error) | 78 | SaveMany(dividendsEstimates []*DividendsEstimate) ([]*DividendsEstimate, error) |
| 79 | UpdateMany(dividendsEstimates []*DividendsEstimate) ([]*DividendsEstimate, error) | 79 | UpdateMany(dividendsEstimates []*DividendsEstimate) ([]*DividendsEstimate, error) |
| 80 | Remove(dividendsEstimate *DividendsEstimate) (*DividendsEstimate, error) | 80 | Remove(dividendsEstimate *DividendsEstimate) (*DividendsEstimate, error) |
| 81 | + BatchRemove(dividendsEstimates []*DividendsEstimate) ([]*DividendsEstimate, error) | ||
| 81 | FindOne(queryOptions map[string]interface{}) (*DividendsEstimate, error) | 82 | FindOne(queryOptions map[string]interface{}) (*DividendsEstimate, error) |
| 82 | Find(queryOptions map[string]interface{}) (int64, []*DividendsEstimate, error) | 83 | Find(queryOptions map[string]interface{}) (int64, []*DividendsEstimate, error) |
| 83 | } | 84 | } |
| @@ -93,7 +93,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | @@ -93,7 +93,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | ||
| 93 | orderGoodIds = append(orderGoodIds, dividendsEstimatesRelative[i].OrderGoodId) | 93 | orderGoodIds = append(orderGoodIds, dividendsEstimatesRelative[i].OrderGoodId) |
| 94 | orderGoodMaps[dividendsEstimatesRelative[i].OrderOrReturnedOrderNum] = append(orderGoodMaps[dividendsEstimatesRelative[i].OrderOrReturnedOrderNum], dividendsEstimatesRelative[i].OrderGoodId) | 94 | orderGoodMaps[dividendsEstimatesRelative[i].OrderOrReturnedOrderNum] = append(orderGoodMaps[dividendsEstimatesRelative[i].OrderOrReturnedOrderNum], dividendsEstimatesRelative[i].OrderGoodId) |
| 95 | } | 95 | } |
| 96 | - dividendsEstimatesRelativeCanceled, err3 := dividendsEstimateRepository.UpdateMany(dividendsEstimatesRelative) | 96 | + dividendsEstimatesRelativeCanceled, err3 := dividendsEstimateRepository.BatchRemove(dividendsEstimatesRelative) |
| 97 | if err3 != nil { | 97 | if err3 != nil { |
| 98 | return nil, err3 | 98 | return nil, err3 |
| 99 | } | 99 | } |
| @@ -119,7 +119,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | @@ -119,7 +119,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | ||
| 119 | dividendsEstimatesRelative[i].IsCanceled = true | 119 | dividendsEstimatesRelative[i].IsCanceled = true |
| 120 | dividendsEstimatesRelative[i].Operator = operator | 120 | dividendsEstimatesRelative[i].Operator = operator |
| 121 | } | 121 | } |
| 122 | - dividendsEstimatesRelativeCanceled, err4 := dividendsEstimateRepository.UpdateMany(dividendsEstimatesRelative) | 122 | + dividendsEstimatesRelativeCanceled, err4 := dividendsEstimateRepository.BatchRemove(dividendsEstimatesRelative) |
| 123 | if err4 != nil { | 123 | if err4 != nil { |
| 124 | return nil, err4 | 124 | return nil, err4 |
| 125 | } | 125 | } |
| @@ -293,6 +293,21 @@ func (repository *DividendsEstimateRepository) Remove(dividendsEstimate *domain. | @@ -293,6 +293,21 @@ func (repository *DividendsEstimateRepository) Remove(dividendsEstimate *domain. | ||
| 293 | return dividendsEstimate, nil | 293 | return dividendsEstimate, nil |
| 294 | } | 294 | } |
| 295 | 295 | ||
| 296 | +func (repository *DividendsEstimateRepository) BatchRemove(dividendsEstimates []*domain.DividendsEstimate) ([]*domain.DividendsEstimate, error) { | ||
| 297 | + tx := repository.transactionContext.PgTx | ||
| 298 | + var dividendsEstimateModels []*models.DividendsEstimate | ||
| 299 | + for _, dividendsEstimate := range dividendsEstimates { | ||
| 300 | + dividendsEstimateModels = append(dividendsEstimateModels, &models.DividendsEstimate{ | ||
| 301 | + DividendsEstimateId: dividendsEstimate.Identify().(int64), | ||
| 302 | + }) | ||
| 303 | + } | ||
| 304 | + if _, err := tx.Model(÷ndsEstimateModels).WherePK().Delete(); err != nil { | ||
| 305 | + return dividendsEstimates, err | ||
| 306 | + } else { | ||
| 307 | + return dividendsEstimates, nil | ||
| 308 | + } | ||
| 309 | +} | ||
| 310 | + | ||
| 296 | func (repository *DividendsEstimateRepository) FindOne(queryOptions map[string]interface{}) (*domain.DividendsEstimate, error) { | 311 | func (repository *DividendsEstimateRepository) FindOne(queryOptions map[string]interface{}) (*domain.DividendsEstimate, error) { |
| 297 | tx := repository.transactionContext.PgTx | 312 | tx := repository.transactionContext.PgTx |
| 298 | dividendsEstimateModel := new(models.DividendsEstimate) | 313 | dividendsEstimateModel := new(models.DividendsEstimate) |
-
请 注册 或 登录 后发表评论