- remove coordinate from search

This commit is contained in:
gazebo
2018-10-30 19:55:21 +08:00
parent 57e2039b3b
commit 47d6c6cf13

View File

@@ -98,14 +98,16 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa
return nil, err return nil, err
} }
sqlVendorStoreCond := "" sqlVendorStoreCond := ""
if mapCond == "AND" {
sqlVendorStoreCond += " AND ( 1 = 1"
} else {
sqlVendorStoreCond += " AND ( 1 = 0"
}
for vendor, cond := range vendorStoreConds { for vendor, cond := range vendorStoreConds {
tableAlias := tableName + vendor tableAlias := tableName + vendor
if cond != 0 { if cond != 0 {
if sqlVendorStoreCond == "" {
if mapCond == "AND" {
sqlVendorStoreCond += " AND ( 1 = 1"
} else {
sqlVendorStoreCond += " AND ( 1 = 0"
}
}
sql += " LEFT JOIN " + tableName + " " + tableAlias + " ON " + tableAlias + ".vendor_id = ? AND " + tableAlias + ".store_id = t1.id AND " + tableAlias + ".deleted_at = ?" sql += " LEFT JOIN " + tableName + " " + tableAlias + " ON " + tableAlias + ".vendor_id = ? AND " + tableAlias + ".store_id = t1.id AND " + tableAlias + ".deleted_at = ?"
sqlParams = append(sqlParams, vendor, utils.DefaultTimeValue) sqlParams = append(sqlParams, vendor, utils.DefaultTimeValue)
if cond == 1 { if cond == 1 {
@@ -115,7 +117,7 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa
} }
} }
} }
if sqlVendorStoreCond != " AND ( 1 = 0" { if sqlVendorStoreCond != "" {
sqlWhere += sqlVendorStoreCond + ")" sqlWhere += sqlVendorStoreCond + ")"
} }
} }
@@ -135,8 +137,8 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa
sqlParams = append(sqlParams, keywordInt64, keywordInt64) sqlParams = append(sqlParams, keywordInt64, keywordInt64)
sqlWhere += " OR wx1.id IS NOT NULL OR wx2.id IS NOT NULL" sqlWhere += " OR wx1.id IS NOT NULL OR wx2.id IS NOT NULL"
} }
sqlWhere += " OR t1.id = ? OR t1.city_code = ? OR t1.district_code = ? OR t1.lng = ? OR t1.lat = ?" sqlWhere += " OR t1.id = ? OR t1.city_code = ? OR t1.district_code = ?"
sqlWhereParams = append(sqlWhereParams, keywordInt64, keywordInt64, keywordInt64, keywordInt64, keywordInt64) sqlWhereParams = append(sqlWhereParams, keywordInt64, keywordInt64, keywordInt64)
} }
sqlWhere += ")" sqlWhere += ")"
} }
@@ -201,6 +203,7 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa
panic(r) panic(r)
} }
}() }()
// globals.SugarLogger.Debug(utils.Format4Output(sqlParams, false))
// globals.SugarLogger.Debug(sql) // globals.SugarLogger.Debug(sql)
if err = dao.GetRows(db, &retVal.Stores, sql, sqlParams...); err == nil { if err = dao.GetRows(db, &retVal.Stores, sql, sqlParams...); err == nil {
countInfo := &struct{ Ct int }{} countInfo := &struct{ Ct int }{}