@@ -0,0 +1,47 @@
|
||||
package officialWebsiteser
|
||||
|
||||
import (
|
||||
"91porn-server/models/v/officialWebsitemod"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
)
|
||||
|
||||
type JobListReq struct {
|
||||
}
|
||||
|
||||
type JobListResp struct {
|
||||
Total int64 `json:"total"`
|
||||
List []JobInfo `json:"list"`
|
||||
}
|
||||
|
||||
type JobInfo struct {
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
Requirements string `json:"requirements"`
|
||||
Benefits string `json:"benefits"`
|
||||
JDUrl string `json:"jdUrl"`
|
||||
}
|
||||
|
||||
func JobList(req *JobListReq) (resp JobListResp, err error) {
|
||||
var filter = bson.M{"isActive": true}
|
||||
var jobMod = &officialWebsitemod.Job{}
|
||||
jobs, err := jobMod.FindMany(filter, options.Find().SetSort(bson.D{{Key: "isHot", Value: -1}, {Key: "sort", Value: -1}, {Key: "createdAt", Value: -1}}))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
resp = JobListResp{
|
||||
Total: int64(len(jobs)),
|
||||
List: make([]JobInfo, len(jobs)),
|
||||
}
|
||||
for i, job := range jobs {
|
||||
resp.List[i] = JobInfo{
|
||||
Title: job.Title,
|
||||
Description: job.Description,
|
||||
Requirements: job.Requirements,
|
||||
Benefits: job.Benefits,
|
||||
JDUrl: job.JDUrl,
|
||||
}
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
Reference in New Issue
Block a user