- dao.GetLastTotalRowCount

This commit is contained in:
gazebo
2018-12-21 11:07:18 +08:00
parent acb073cb92
commit c7577e6005
5 changed files with 26 additions and 40 deletions

View File

@@ -384,21 +384,18 @@ func GetSkuNames(ctx *jxcontext.Context, keyword string, params map[string]inter
// globals.SugarLogger.Debug(sqlData)
// globals.SugarLogger.Debug(utils.Format4Output(sqlParams, false))
if err = dao.GetRows(db, &skuNamesInfo.SkuNames, sqlData, sqlParams...); err == nil {
countInfo := &struct{ Ct int }{}
if err = dao.GetRow(db, countInfo, "SELECT FOUND_ROWS() ct"); err == nil {
skuNamesInfo.TotalCount = countInfo.Ct
for _, skuName := range skuNamesInfo.SkuNames {
if skuName.SkusStr != "" {
if err = utils.UnmarshalUseNumber([]byte(skuName.SkusStr), &skuName.Skus); err != nil {
dao.Rollback(db)
return nil, err
}
skuNamesInfo.TotalCount = dao.GetLastTotalRowCount(db)
for _, skuName := range skuNamesInfo.SkuNames {
if skuName.SkusStr != "" {
if err = utils.UnmarshalUseNumber([]byte(skuName.SkusStr), &skuName.Skus); err != nil {
dao.Rollback(db)
return nil, err
}
if skuName.PlacesStr != "" {
if err = utils.UnmarshalUseNumber([]byte(skuName.PlacesStr), &skuName.Places); err != nil {
dao.Rollback(db)
return nil, err
}
}
if skuName.PlacesStr != "" {
if err = utils.UnmarshalUseNumber([]byte(skuName.PlacesStr), &skuName.Places); err != nil {
dao.Rollback(db)
return nil, err
}
}
}

View File

@@ -220,10 +220,7 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa
// globals.SugarLogger.Debug(utils.Format4Output(sqlParams, false))
// globals.SugarLogger.Debug(sql)
if err = dao.GetRows(db, &retVal.Stores, sql, sqlParams...); err == nil {
countInfo := &struct{ Ct int }{}
if err = dao.GetRow(db, countInfo, "SELECT FOUND_ROWS() ct"); err == nil {
retVal.TotalCount = countInfo.Ct
}
retVal.TotalCount = dao.GetLastTotalRowCount(db)
for _, v := range retVal.Stores {
if v.StoreMapStr != "" {
if err = utils.UnmarshalUseNumber([]byte(v.StoreMapStr), &v.StoreMaps); err != nil {
@@ -498,14 +495,11 @@ func TmpGetJxBadCommentsByStoreId(ctx *jxcontext.Context, storeID, page, size, c
}()
globals.SugarLogger.Debug(sql)
if err = dao.GetRows(db, &commentList, sql, utils.Int2Str(storeID), size, (page-1)*size); err == nil {
countInfo := &struct{ Ct int }{}
if err = dao.GetRow(db, countInfo, "SELECT FOUND_ROWS() ct"); err == nil {
dao.Commit(db)
retVal = map[string]interface{}{
"total": countInfo.Ct,
"list": commentList,
}
retVal = map[string]interface{}{
"total": dao.GetLastTotalRowCount(db),
"list": commentList,
}
dao.Commit(db)
}
return retVal, err
}

View File

@@ -628,12 +628,10 @@ func GetJdPromotions(ctx *jxcontext.Context, keyword string, params map[string]i
}
}
}
pagedInfo = &model.PagedInfo{}
countInfo := &struct{ Ct int }{}
if err = dao.GetRow(db, countInfo, "SELECT FOUND_ROWS() ct"); err == nil {
pagedInfo.TotalCount = countInfo.Ct
pagedInfo = &model.PagedInfo{
TotalCount: dao.GetLastTotalRowCount(db),
Data: promotionList,
}
pagedInfo.Data = promotionList
}
dao.Commit(db)
return pagedInfo, err