From 1133684e3bfb5302ec8efab1b90fa2680d7d049f 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, 14 Oct 2020 09:18:59 +0800 Subject: [PATCH] job --- business/model/dao/job.go | 19 +++++++++++++++++++ business/model/job.go | 2 +- controllers/job_controller.go | 15 +++++++++++++++ routers/commentsRouter_controllers.go | 18 ++++++++++++++++++ 4 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 business/model/dao/job.go diff --git a/business/model/dao/job.go b/business/model/dao/job.go new file mode 100644 index 000000000..ca5c1ad09 --- /dev/null +++ b/business/model/dao/job.go @@ -0,0 +1,19 @@ +package dao + +import ( + "git.rosy.net.cn/baseapi/utils" + "git.rosy.net.cn/jx-callback/business/model" +) + +func GetJobCategories(db *DaoDB, name string) (jobCategories []*model.JobCategory, err error) { + sql := ` + SELECT * FROM job_category WHERE deleted_at = ? + ` + sqlParams := []interface{}{utils.DefaultTimeValue} + if name != "" { + sql += ` AND name LIKE ?` + sqlParams = append(sqlParams, "%"+name+"%") + } + err = GetRows(db, &jobCategories, sql, sqlParams) + return jobCategories, err +} diff --git a/business/model/job.go b/business/model/job.go index 5a4160105..98a2d8b2e 100644 --- a/business/model/job.go +++ b/business/model/job.go @@ -30,7 +30,7 @@ type Job struct { func (v *Job) TableIndex() [][]string { return [][]string{ - []string{"ThingID"}, + []string{"UserID"}, []string{"CreatedAt"}, } } diff --git a/controllers/job_controller.go b/controllers/job_controller.go index 2ceb8d5ac..ba18ec753 100644 --- a/controllers/job_controller.go +++ b/controllers/job_controller.go @@ -4,6 +4,7 @@ import ( "git.rosy.net.cn/jx-callback/business/jxstore/cms" "git.rosy.net.cn/jx-callback/business/jxutils" "git.rosy.net.cn/jx-callback/business/model" + "git.rosy.net.cn/jx-callback/business/model/dao" "github.com/astaxie/beego" ) @@ -27,3 +28,17 @@ func (c *JobController) PublishJob() { return retVal, "", err }) } + +// @Title 查看任务类型 +// @Description 查看任务类型 +// @Param token header string true "认证token" +// @Param name query string false "分类名" +// @Success 200 {object} controllers.CallResult +// @Failure 200 {object} controllers.CallResult +// @router /GetJobCategories [get] +func (c *JobController) GetJobCategories() { + c.callGetJobCategories(func(params *tJobGetJobCategoriesParams) (retVal interface{}, errCode string, err error) { + retVal, err = dao.GetJobCategories(dao.GetDB(), params.Name) + return retVal, "", err + }) +} diff --git a/routers/commentsRouter_controllers.go b/routers/commentsRouter_controllers.go index 9a9f16eb6..6ee1c1a23 100644 --- a/routers/commentsRouter_controllers.go +++ b/routers/commentsRouter_controllers.go @@ -151,6 +151,24 @@ func init() { Filters: nil, Params: nil}) + beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:JobController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:JobController"], + beego.ControllerComments{ + Method: "GetJobCategories", + Router: `/GetJobCategories`, + AllowHTTPMethods: []string{"get"}, + MethodParams: param.Make(), + Filters: nil, + Params: nil}) + + beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:JobController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:JobController"], + beego.ControllerComments{ + Method: "PublishJob", + Router: `/PublishJob`, + AllowHTTPMethods: []string{"post"}, + MethodParams: param.Make(), + Filters: nil, + Params: nil}) + beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"], beego.ControllerComments{ Method: "CreateOrder",