From ee27ffdeefd48374b78b5bbabe4bcccf9bbbfc17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Wed, 16 Dec 2020 18:24:29 +0800 Subject: [PATCH] a --- business/model/dao/dao_job.go | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/business/model/dao/dao_job.go b/business/model/dao/dao_job.go index f583d4c2f..72e9ac26b 100644 --- a/business/model/dao/dao_job.go +++ b/business/model/dao/dao_job.go @@ -14,6 +14,7 @@ import ( const ( sortTypeDistance = 1 //距离 + sortTypeTime = 2 //发布时间 sortTypeAvgPrice = 4 //奖励高低 ) @@ -122,6 +123,10 @@ func GetJobs(db *DaoDB, userIDs []string, categoryIDs, statuss, vendorIDs, types sql += ` ORDER BY a.avg_price` } else if sortType == -sortTypeAvgPrice { sql += ` ORDER BY a.avg_price DESC` + } else if sortType == sortTypeTime { + sql += ` ORDER BY a.created_at` + } else if sortType == -sortTypeTime { + sql += ` ORDER BY a.created_at DESC` } } sql += " LIMIT ? OFFSET ?" @@ -140,19 +145,19 @@ func GetJobs(db *DaoDB, userIDs []string, categoryIDs, statuss, vendorIDs, types v.JobSteps = jobSteps } } - var ( - distance float64 - ) + // var ( + // distance float64 + // ) if jobImgs, err := GetJobImgs(db, v.ID); err == nil && len(jobImgs) > 0 { v.JobImgs = jobImgs v.IndexImg = jobImgs[0].Img } - if v.Lng != 0 && v.Lat != 0 { - distance = jxutils.EarthDistance(lng, lat, jxutils.IntCoordinate2Standard(v.Lng), jxutils.IntCoordinate2Standard(v.Lat)) - } else { - distance = 0 - } - v.Distance = distance + // if v.Lng != 0 && v.Lat != 0 { + // distance = jxutils.EarthDistance(lng, lat, jxutils.IntCoordinate2Standard(v.Lng), jxutils.IntCoordinate2Standard(v.Lat)) + // } else { + // distance = 0 + // } + // v.Distance = distance } pagedInfo.Data = jobs }