- refactor GetSkuNames, remove skuID, nameID, jdID. add vendorSkuIDs.
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
)
|
||||
|
||||
type SkuNamesInfo struct {
|
||||
@@ -188,10 +189,6 @@ func GetSkuNames(ctx *jxcontext.Context, keyword string, params map[string]inter
|
||||
sql += ")"
|
||||
}
|
||||
|
||||
if params["nameID"] != nil {
|
||||
sql += " AND t1.id = ?"
|
||||
sqlParams = append(sqlParams, params["nameID"].(int))
|
||||
}
|
||||
if params["nameIDs"] != nil {
|
||||
var nameIDs []int
|
||||
if err = utils.UnmarshalUseNumber([]byte(params["nameIDs"].(string)), &nameIDs); err != nil {
|
||||
@@ -216,9 +213,15 @@ func GetSkuNames(ctx *jxcontext.Context, keyword string, params map[string]inter
|
||||
}
|
||||
sql += ")"
|
||||
}
|
||||
if params["jdID"] != nil {
|
||||
sql += " AND t1.jd_id = ?"
|
||||
sqlParams = append(sqlParams, params["jdID"].(int))
|
||||
if params["vendorSkuIDs"] != nil {
|
||||
var vendorSkuIDs []int
|
||||
if err = utils.UnmarshalUseNumber([]byte(params["vendorSkuIDs"].(string)), &vendorSkuIDs); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(vendorSkuIDs) > 0 {
|
||||
sql += " AND t2.jd_id IN (" + dao.GenQuestionMarks(len(vendorSkuIDs)) + ")"
|
||||
sqlParams = append(sqlParams, vendorSkuIDs)
|
||||
}
|
||||
}
|
||||
if params["name"] != nil {
|
||||
sql += " AND t1.name LIKE ?"
|
||||
@@ -254,10 +257,6 @@ func GetSkuNames(ctx *jxcontext.Context, keyword string, params map[string]inter
|
||||
sql += sqlPlaceCond + ")"
|
||||
}
|
||||
}
|
||||
if params["skuID"] != nil {
|
||||
sql += " AND t2.id = ?"
|
||||
sqlParams = append(sqlParams, params["skuID"].(int))
|
||||
}
|
||||
if params["skuIDs"] != nil {
|
||||
var skuIDs []int
|
||||
if err = utils.UnmarshalUseNumber([]byte(params["skuIDs"].(string)), &skuIDs); err != nil {
|
||||
@@ -329,6 +328,8 @@ func GetSkuNames(ctx *jxcontext.Context, keyword string, params map[string]inter
|
||||
panic(r)
|
||||
}
|
||||
}()
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user