package handler import ( "github.com/gin-gonic/gin" "github.com/sirupsen/logrus" "youngee_m_api/consts" "youngee_m_api/db" "youngee_m_api/model/http_model" "youngee_m_api/util" ) func WrapCreateJobHandler(ctx *gin.Context) { handler := newCreateJobHandler(ctx) BaseRun(handler) } type CreateJobHandler struct { ctx *gin.Context req *http_model.CreateJobRequest resp *http_model.CommonResponse } func (c CreateJobHandler) getContext() *gin.Context { return c.ctx } func (c CreateJobHandler) getResponse() interface{} { return c.resp } func (c CreateJobHandler) getRequest() interface{} { return c.req } func (c CreateJobHandler) run() { data := http_model.CreateJobRequest{} data = *c.req res, err := db.CreateJob(c.ctx, &data) if err != nil { logrus.Errorf("[CreateJobHandler] call CreateJob err:%+v\n", err) util.HandlerPackErrorResp(c.resp, consts.ErrorInternal, "") logrus.Info("CreateJobHandler fail,req:%+v", c.req) return } c.resp.Message = "成功创建岗位" c.resp.Data = res } func (c CreateJobHandler) checkParam() error { return nil } func newCreateJobHandler(ctx *gin.Context) *CreateJobHandler { return &CreateJobHandler{ ctx: ctx, req: http_model.NewCreateJobRequest(), resp: http_model.NewCreateJobResponse(), } }