distance
This commit is contained in:
@@ -196,6 +196,17 @@ func GetJobs(ctx *jxcontext.Context, userIDs []string, categoryIDs, statuss, ven
|
|||||||
return dao.GetJobs(dao.GetDB(), userIDs, categoryIDs, statuss, vendorIDs, []int{model.JobTypeNormal}, includeStep, utils.Str2Time(fromTime), utils.Str2Time(toTime), pageSize, offset)
|
return dao.GetJobs(dao.GetDB(), userIDs, categoryIDs, statuss, vendorIDs, []int{model.JobTypeNormal}, includeStep, utils.Str2Time(fromTime), utils.Str2Time(toTime), pageSize, offset)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetJobDetail(ctx *jxcontext.Context, jobID int, lng, lat float64) (job *dao.GetJobsResult, err error) {
|
||||||
|
var (
|
||||||
|
db = dao.GetDB()
|
||||||
|
)
|
||||||
|
job, err = dao.GetJobDetail(db, jobID)
|
||||||
|
if job.Lng != 0 && job.Lat != 0 {
|
||||||
|
job.Distance = jxutils.EarthDistance(lng, lat, jxutils.IntCoordinate2Standard(job.Lng), jxutils.IntCoordinate2Standard(job.Lat))
|
||||||
|
}
|
||||||
|
return job, err
|
||||||
|
}
|
||||||
|
|
||||||
func AcceptJob(ctx *jxcontext.Context, jobID int) (errCode string, err error) {
|
func AcceptJob(ctx *jxcontext.Context, jobID int) (errCode string, err error) {
|
||||||
var (
|
var (
|
||||||
db = dao.GetDB()
|
db = dao.GetDB()
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ type GetJobsResult struct {
|
|||||||
model.Job
|
model.Job
|
||||||
CategoryName string `json:"categoryName"` //分类名
|
CategoryName string `json:"categoryName"` //分类名
|
||||||
IndexImg string `json:"indexImg"` //任务封面
|
IndexImg string `json:"indexImg"` //任务封面
|
||||||
|
Distance float64 `json:"distance"` //距用户距离
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetJobs(db *DaoDB, userIDs []string, categoryIDs, statuss, vendorIDs, types []int, includeStep bool, fromTime, toTime time.Time, pageSize, offset int) (pagedInfo *model.PagedInfo, err error) {
|
func GetJobs(db *DaoDB, userIDs []string, categoryIDs, statuss, vendorIDs, types []int, includeStep bool, fromTime, toTime time.Time, pageSize, offset int) (pagedInfo *model.PagedInfo, err error) {
|
||||||
@@ -182,7 +183,10 @@ func GetJobsNoPage(db *DaoDB, userIDs []string, categoryIDs, statuss, types []in
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetJobDetail(db *DaoDB, jobID int) (job *GetJobsResult, err error) {
|
func GetJobDetail(db *DaoDB, jobID int) (job *GetJobsResult, err error) {
|
||||||
var jobSteps []*model.JobStep
|
var (
|
||||||
|
jobImgs []*model.JobImg
|
||||||
|
jobSteps []*model.JobStep
|
||||||
|
)
|
||||||
sql := `
|
sql := `
|
||||||
SELECT a.*, b.name
|
SELECT a.*, b.name
|
||||||
FROM job a
|
FROM job a
|
||||||
@@ -205,6 +209,14 @@ func GetJobDetail(db *DaoDB, jobID int) (job *GetJobsResult, err error) {
|
|||||||
sqlParams2 := []interface{}{job.ID, utils.DefaultTimeValue}
|
sqlParams2 := []interface{}{job.ID, utils.DefaultTimeValue}
|
||||||
err = GetRows(db, &jobSteps, sql2, sqlParams2)
|
err = GetRows(db, &jobSteps, sql2, sqlParams2)
|
||||||
job.JobSteps = jobSteps
|
job.JobSteps = jobSteps
|
||||||
|
sql3 := `
|
||||||
|
SELECT *
|
||||||
|
FROM job_img
|
||||||
|
WHERE job_id = ?
|
||||||
|
`
|
||||||
|
sqlParams3 := []interface{}{job.ID}
|
||||||
|
err = GetRows(db, &jobImgs, sql3, sqlParams3)
|
||||||
|
job.JobImgs = jobImgs
|
||||||
} else {
|
} else {
|
||||||
return job, fmt.Errorf("未查到到该任务!")
|
return job, fmt.Errorf("未查到到该任务!")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,12 +93,14 @@ func (c *JobController) GetJobs() {
|
|||||||
// @Description 查看任务
|
// @Description 查看任务
|
||||||
// @Param token header string true "认证token"
|
// @Param token header string true "认证token"
|
||||||
// @Param jobID query int false "任务ID"
|
// @Param jobID query int false "任务ID"
|
||||||
|
// @Param lng query float64 false "经度"
|
||||||
|
// @Param lat query float64 false "维度"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// @Success 200 {object} controllers.CallResult
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// @Failure 200 {object} controllers.CallResult
|
||||||
// @router /GetJobDetail [get]
|
// @router /GetJobDetail [get]
|
||||||
func (c *JobController) GetJobDetail() {
|
func (c *JobController) GetJobDetail() {
|
||||||
c.callGetJobDetail(func(params *tJobGetJobDetailParams) (retVal interface{}, errCode string, err error) {
|
c.callGetJobDetail(func(params *tJobGetJobDetailParams) (retVal interface{}, errCode string, err error) {
|
||||||
retVal, err = dao.GetJobDetail(dao.GetDB(), params.JobID)
|
retVal, err = cms.GetJobDetail(params.Ctx, params.JobID, params.Lng, params.Lat)
|
||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user