- GetPlaces support keyword.

This commit is contained in:
gazebo
2018-09-19 09:56:45 +08:00
parent 8593e8b44b
commit 57b60208e2
5 changed files with 110 additions and 47 deletions

View File

@@ -29,40 +29,6 @@ var (
ErrCanNotFindVendor = errors.New("vendorID参数不合法")
)
func GetPlaces(parentCode int, includeDisabled bool) ([]*model.Place, error) {
db := dao.GetDB()
places := []*model.Place{}
cond := map[string]interface{}{
"ParentCode": parentCode,
}
if !includeDisabled {
cond["Enabled"] = 1
}
return places, dao.GetEntities(db, &places, cond, false)
}
func UpdatePlaces(places []map[string]interface{}, userName string) (num int64, err error) {
if len(places) == 0 {
return 0, ErrMissingInput
}
for _, place := range places {
if place["code"] == nil {
return 0, ErrMissingInput
}
placeid := &model.Place{}
valid := dao.NormalMakeMapByFieldList(place, []string{"jdCode", "enabled", "mtpsPrice"}, userName)
if num, err = dao.UpdateEntityByKV(nil, placeid, valid, utils.Params2Map("Code", place["code"])); err != nil {
return num, err
}
}
return num, err
}
func UpdatePlace(placeCode int, payload map[string]interface{}, userName string) (num int64, err error) {
payload["code"] = placeCode
return UpdatePlaces([]map[string]interface{}{payload}, userName)
}
// todo 门店绑定信息可以考虑以数组形式返回,而不是现在这样
func GetStores(keyword string, params map[string]interface{}, offset, pageSize int) (retVal *StoresInfo, err error) {
sqlFrom := `