作者 唐旭辉

bug 修复

... ... @@ -27,11 +27,18 @@ func (service OrderInfoService) PageListOrderBase(listOrderQuery query.ListOrder
if err != nil {
return nil, 0, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error())
}
if err = transactionContext.StartTransaction(); err != nil {
return nil, 0, err
}
defer func() {
transactionContext.RollbackTransaction()
}()
var (
orderRepository domain.OrderBaseRepository
orders []domain.OrderBase
cnt int
)
if value, err := factory.CreateOrderBaseRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
... ... @@ -68,6 +75,7 @@ func (service OrderInfoService) PageListOrderBase(listOrderQuery query.ListOrder
}
orders[i].PartnerInfo = partnerData.Partner
}
transactionContext.CommitTransaction()
return orders, cnt, nil
}
... ...
... ... @@ -246,9 +246,9 @@ func (PartnerInfoService *PartnerInfoService) ListPartnerInfo(listPartnerInfoQue
return 0, nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error())
}
defer func() {
if err != nil {
transactionContext.RollbackTransaction()
}
}()
var (
partnerInfoRepository domain.PartnerInfoRepository
... ...
... ... @@ -96,7 +96,7 @@ func (repository *PartnerInfoRepository) Save(dm *domain.PartnerInfo) error {
}
func (repository *PartnerInfoRepository) FindOne(queryOptions domain.PartnerFindOneQuery) (*domain.PartnerInfo, error) {
tx := repository.transactionContext.PgDd
tx := repository.transactionContext.PgTx
PartnerInfoModel := new(models.PartnerInfo)
query := tx.Model(PartnerInfoModel)
if len(queryOptions.AccountEqual) > 0 {
... ... @@ -116,7 +116,7 @@ func (repository *PartnerInfoRepository) FindOne(queryOptions domain.PartnerFind
}
func (repository *PartnerInfoRepository) Find(queryOption domain.PartnerFindQuery) ([]domain.PartnerInfo, error) {
db := repository.transactionContext.PgDd
db := repository.transactionContext.PgTx
partnerModels := []models.PartnerInfo{}
query := db.Model(&partnerModels)
if len(queryOption.PartnerName) > 0 {
... ... @@ -168,7 +168,7 @@ func (repository *PartnerInfoRepository) Find(queryOption domain.PartnerFindQuer
}
func (repository PartnerInfoRepository) CountAll(queryOption domain.PartnerFindQuery) (int, error) {
db := repository.transactionContext.PgDd
db := repository.transactionContext.PgTx
partnerModels := models.PartnerInfo{}
query := db.Model(&partnerModels)
if len(queryOption.PartnerName) > 0 {
... ...