From 57812bf484ee4c79ad0cf2b5dd26a3adc69dff90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Thu, 3 Dec 2020 11:43:37 +0800 Subject: [PATCH] a --- business/model/dao/dao_job.go | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/business/model/dao/dao_job.go b/business/model/dao/dao_job.go index 1d6e5a3dc..bfa2b78a0 100644 --- a/business/model/dao/dao_job.go +++ b/business/model/dao/dao_job.go @@ -436,7 +436,7 @@ func GetStationInfoList(db *DaoDB, stationName string, cityCode int, lat, lng fl SELECT SQL_CALC_FOUND_ROWS * ` if distanceFlag { - sql += `, ROUND(POWER((POWER(longitude-?,2))+(POWER(latitude-?,2)),1/2)) distance2` + sql += `, getDistance(?, ?, longitude, latitude) distance` sqlParams = append(sqlParams, lng, lat) } sql += ` @@ -457,9 +457,9 @@ func GetStationInfoList(db *DaoDB, stationName string, cityCode int, lat, lng fl } if sortType != 0 { if sortType == 1 { - sql += " ORDER BY distance2" + sql += " ORDER BY distance" } else if sortType == -1 { - sql += " ORDER BY distance2 DESC" + sql += " ORDER BY distance DESC" } else if sortType == 2 { sql += " ORDER BY star_num" } else if sortType == -2 { @@ -474,18 +474,18 @@ func GetStationInfoList(db *DaoDB, stationName string, cityCode int, lat, lng fl if err = GetRows(db, &stations, sql, sqlParams...); err == nil { pagedInfo = &model.PagedInfo{ TotalCount: GetLastTotalRowCount(db), - // Data: stations, + Data: stations, } - for _, v := range stations { - var distance float64 - if v.Longitude != 0 && v.Latitude != 0 { - distance = jxutils.EarthDistance(lng, lat, v.Longitude, v.Latitude) - } else { - distance = 0 - } - v.Distance = distance - } - pagedInfo.Data = stations + // for _, v := range stations { + // var distance float64 + // if v.Longitude != 0 && v.Latitude != 0 { + // distance = jxutils.EarthDistance(lng, lat, v.Longitude, v.Latitude) + // } else { + // distance = 0 + // } + // v.Distance = distance + // } + // pagedInfo.Data = stations } return pagedInfo, err }