- GetPlaces don't support vendorID.
This commit is contained in:
@@ -29,20 +29,16 @@ var (
|
||||
ErrCanNotFindVendor = errors.New("vendorID参数不合法")
|
||||
)
|
||||
|
||||
func GetPlaces(parentCode int, vendorID int, includeDisabled bool) ([]*model.Place, error) {
|
||||
func GetPlaces(parentCode int, includeDisabled bool) ([]*model.Place, error) {
|
||||
db := dao.GetDB()
|
||||
places := []*model.Place{}
|
||||
sql := "SELECT * FROM place WHERE enabled = 1 "
|
||||
if includeDisabled {
|
||||
sql = "1 = 1 "
|
||||
cond := map[string]interface{}{
|
||||
"ParentCode": parentCode,
|
||||
}
|
||||
if vendorID >= 0 {
|
||||
if vendorID == model.VendorIDJD {
|
||||
return places, dao.GetRows(db, &places, sql+"AND jd_code <> 0 AND level >= 2")
|
||||
}
|
||||
return nil, ErrHaveNotImplementedYet
|
||||
if !includeDisabled {
|
||||
cond["Enabled"] = 1
|
||||
}
|
||||
return places, dao.GetRows(db, &places, sql+"AND parent_code = ?", parentCode)
|
||||
return places, dao.GetEntities(db, &places, cond, false)
|
||||
}
|
||||
|
||||
func UpdatePlaces(places []map[string]interface{}, userName string) (num int64, err error) {
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
@@ -16,21 +14,14 @@ type StoreController struct {
|
||||
// @Title 得到地点(省,城市,区)信息
|
||||
// @Description parentCode与vendorID必传入一个,vendorID的意思是得到所有与这个厂商相关的城市列表。地点级别:省为1,市为2,区为3,注意直辖市也要分省与市级
|
||||
// @Param token header string true "认证token"
|
||||
// @Param parentCode query int false "上级地点code,这个指的是国家标准CODE(中国为:100000,北京为:110000,北京市为:110100),不是数据库中的ID"
|
||||
// @Param vendorID query int false "得到所有与这个厂商相关的省与城市列表"
|
||||
// @Param parentCode query int true "上级地点code,这个指的是国家标准CODE(中国为:100000,北京为:110000,北京市为:110100),不是数据库中的ID"
|
||||
// @Param includeDisabled query bool false "是否包括禁用的城市(缺省不包括)"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /GetPlaces [get]
|
||||
func (c *StoreController) GetPlaces() {
|
||||
c.callGetPlaces(func(params *tStoreGetPlacesParams) (retVal interface{}, errCode string, err error) {
|
||||
if c.GetString("vendorID") == "" {
|
||||
params.VendorID = -1 // -1表示没有指定,因为0表示京东到家
|
||||
}
|
||||
if params.VendorID == -1 && params.ParentCode == 0 {
|
||||
return nil, "", errors.New("parentCode与vendorID至少要指定一个")
|
||||
}
|
||||
retVal, err = cms.GetPlaces(params.ParentCode, params.VendorID, params.IncludeDisabled)
|
||||
retVal, err = cms.GetPlaces(params.ParentCode, params.IncludeDisabled)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user