- add isFocused cond for GetStoreSkus.

This commit is contained in:
gazebo
2018-09-18 09:32:32 +08:00
parent 86c1b0957f
commit d592b4c29c
2 changed files with 10 additions and 4 deletions

View File

@@ -30,14 +30,19 @@ type StoreSkuBindInfo struct {
EbaiID int64 `json:"ebaiID"` EbaiID int64 `json:"ebaiID"`
} }
func GetStoreSkus(storeID int, keyword string, params map[string]interface{}, offset, pageSize int) (skuNamesInfo *StoreSkuNamesInfo, err error) { func GetStoreSkus(storeID int, isFocused bool, keyword string, params map[string]interface{}, offset, pageSize int) (skuNamesInfo *StoreSkuNamesInfo, err error) {
db := dao.GetDB() db := dao.GetDB()
sql := ` sql := `
FROM sku_name t1 FROM sku_name t1
LEFT JOIN sku t2 ON t1.id = t2.name_id AND t2.deleted_at = '1970-01-01 00:00:00' JOIN sku t2 ON t1.id = t2.name_id AND t2.deleted_at = '1970-01-01 00:00:00'
JOIN store_sku_bind t4 ON t4.sku_id = t2.id AND t4.deleted_at = '1970-01-01 00:00:00' AND t4.store_id = ? LEFT JOIN store_sku_bind t4 ON t4.sku_id = t2.id AND t4.deleted_at = '1970-01-01 00:00:00' AND t4.store_id = ?
WHERE t1.deleted_at = '1970-01-01 00:00:00' WHERE t1.deleted_at = '1970-01-01 00:00:00'
` `
if isFocused {
sql += " AND t4.sku_id IS NOT NULL"
} else {
sql += " AND t4.sku_id IS NULL"
}
sqlParams := []interface{}{ sqlParams := []interface{}{
storeID, storeID,
} }

View File

@@ -14,6 +14,7 @@ type StoreSkuController struct {
// @Description 得到商家商品信息,如下条件之间是与的关系 // @Description 得到商家商品信息,如下条件之间是与的关系
// @Param token header string true "认证token" // @Param token header string true "认证token"
// @Param storeID query int true "门店ID" // @Param storeID query int true "门店ID"
// @Param isFocused query bool true "是否已关注(认领)"
// @Param keyword query string false "查询关键字(可以为空,为空表示不限制)" // @Param keyword query string false "查询关键字(可以为空,为空表示不限制)"
// @Param nameID query int false "SkuName ID" // @Param nameID query int false "SkuName ID"
// @Param skuID query int false "Sku ID" // @Param skuID query int false "Sku ID"
@@ -31,7 +32,7 @@ type StoreSkuController struct {
// @router /GetStoreSkus [get] // @router /GetStoreSkus [get]
func (c *StoreSkuController) GetStoreSkus() { func (c *StoreSkuController) GetStoreSkus() {
c.callGetStoreSkus(func(params *tStoreSkuGetStoreSkusParams) (retVal interface{}, errCode string, err error) { c.callGetStoreSkus(func(params *tStoreSkuGetStoreSkusParams) (retVal interface{}, errCode string, err error) {
retVal, err = cms.GetStoreSkus(params.StoreID, params.Keyword, params.MapData, params.Offset, params.PageSize) retVal, err = cms.GetStoreSkus(params.StoreID, params.IsFocused, params.Keyword, params.MapData, params.Offset, params.PageSize)
return retVal, "", err return retVal, "", err
}) })
} }