正在显示
3 个修改的文件
包含
13 行增加
和
5 行删除
@@ -27,11 +27,18 @@ func (service OrderInfoService) PageListOrderBase(listOrderQuery query.ListOrder | @@ -27,11 +27,18 @@ func (service OrderInfoService) PageListOrderBase(listOrderQuery query.ListOrder | ||
27 | if err != nil { | 27 | if err != nil { |
28 | return nil, 0, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) | 28 | return nil, 0, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) |
29 | } | 29 | } |
30 | + if err = transactionContext.StartTransaction(); err != nil { | ||
31 | + return nil, 0, err | ||
32 | + } | ||
33 | + defer func() { | ||
34 | + transactionContext.RollbackTransaction() | ||
35 | + }() | ||
30 | var ( | 36 | var ( |
31 | orderRepository domain.OrderBaseRepository | 37 | orderRepository domain.OrderBaseRepository |
32 | orders []domain.OrderBase | 38 | orders []domain.OrderBase |
33 | cnt int | 39 | cnt int |
34 | ) | 40 | ) |
41 | + | ||
35 | if value, err := factory.CreateOrderBaseRepository(map[string]interface{}{ | 42 | if value, err := factory.CreateOrderBaseRepository(map[string]interface{}{ |
36 | "transactionContext": transactionContext, | 43 | "transactionContext": transactionContext, |
37 | }); err != nil { | 44 | }); err != nil { |
@@ -68,6 +75,7 @@ func (service OrderInfoService) PageListOrderBase(listOrderQuery query.ListOrder | @@ -68,6 +75,7 @@ func (service OrderInfoService) PageListOrderBase(listOrderQuery query.ListOrder | ||
68 | } | 75 | } |
69 | orders[i].PartnerInfo = partnerData.Partner | 76 | orders[i].PartnerInfo = partnerData.Partner |
70 | } | 77 | } |
78 | + transactionContext.CommitTransaction() | ||
71 | return orders, cnt, nil | 79 | return orders, cnt, nil |
72 | } | 80 | } |
73 | 81 |
@@ -246,9 +246,9 @@ func (PartnerInfoService *PartnerInfoService) ListPartnerInfo(listPartnerInfoQue | @@ -246,9 +246,9 @@ func (PartnerInfoService *PartnerInfoService) ListPartnerInfo(listPartnerInfoQue | ||
246 | return 0, nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) | 246 | return 0, nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) |
247 | } | 247 | } |
248 | defer func() { | 248 | defer func() { |
249 | - if err != nil { | 249 | + |
250 | transactionContext.RollbackTransaction() | 250 | transactionContext.RollbackTransaction() |
251 | - } | 251 | + |
252 | }() | 252 | }() |
253 | var ( | 253 | var ( |
254 | partnerInfoRepository domain.PartnerInfoRepository | 254 | partnerInfoRepository domain.PartnerInfoRepository |
@@ -96,7 +96,7 @@ func (repository *PartnerInfoRepository) Save(dm *domain.PartnerInfo) error { | @@ -96,7 +96,7 @@ func (repository *PartnerInfoRepository) Save(dm *domain.PartnerInfo) error { | ||
96 | } | 96 | } |
97 | 97 | ||
98 | func (repository *PartnerInfoRepository) FindOne(queryOptions domain.PartnerFindOneQuery) (*domain.PartnerInfo, error) { | 98 | func (repository *PartnerInfoRepository) FindOne(queryOptions domain.PartnerFindOneQuery) (*domain.PartnerInfo, error) { |
99 | - tx := repository.transactionContext.PgDd | 99 | + tx := repository.transactionContext.PgTx |
100 | PartnerInfoModel := new(models.PartnerInfo) | 100 | PartnerInfoModel := new(models.PartnerInfo) |
101 | query := tx.Model(PartnerInfoModel) | 101 | query := tx.Model(PartnerInfoModel) |
102 | if len(queryOptions.AccountEqual) > 0 { | 102 | if len(queryOptions.AccountEqual) > 0 { |
@@ -116,7 +116,7 @@ func (repository *PartnerInfoRepository) FindOne(queryOptions domain.PartnerFind | @@ -116,7 +116,7 @@ func (repository *PartnerInfoRepository) FindOne(queryOptions domain.PartnerFind | ||
116 | } | 116 | } |
117 | 117 | ||
118 | func (repository *PartnerInfoRepository) Find(queryOption domain.PartnerFindQuery) ([]domain.PartnerInfo, error) { | 118 | func (repository *PartnerInfoRepository) Find(queryOption domain.PartnerFindQuery) ([]domain.PartnerInfo, error) { |
119 | - db := repository.transactionContext.PgDd | 119 | + db := repository.transactionContext.PgTx |
120 | partnerModels := []models.PartnerInfo{} | 120 | partnerModels := []models.PartnerInfo{} |
121 | query := db.Model(&partnerModels) | 121 | query := db.Model(&partnerModels) |
122 | if len(queryOption.PartnerName) > 0 { | 122 | if len(queryOption.PartnerName) > 0 { |
@@ -168,7 +168,7 @@ func (repository *PartnerInfoRepository) Find(queryOption domain.PartnerFindQuer | @@ -168,7 +168,7 @@ func (repository *PartnerInfoRepository) Find(queryOption domain.PartnerFindQuer | ||
168 | } | 168 | } |
169 | 169 | ||
170 | func (repository PartnerInfoRepository) CountAll(queryOption domain.PartnerFindQuery) (int, error) { | 170 | func (repository PartnerInfoRepository) CountAll(queryOption domain.PartnerFindQuery) (int, error) { |
171 | - db := repository.transactionContext.PgDd | 171 | + db := repository.transactionContext.PgTx |
172 | partnerModels := models.PartnerInfo{} | 172 | partnerModels := models.PartnerInfo{} |
173 | query := db.Model(&partnerModels) | 173 | query := db.Model(&partnerModels) |
174 | if len(queryOption.PartnerName) > 0 { | 174 | if len(queryOption.PartnerName) > 0 { |
-
请 注册 或 登录 后发表评论