package controllers import ( "github.com/gogf/gf/v2/net/ghttp" "yx-dataset-server/app/bll" "yx-dataset-server/library/gplus" "yx-dataset-server/library/robot" ) type Robot struct { RobotConfigBll bll.IRobotConfig } func NewRobot(bRobotConfig bll.IRobotConfig) *Robot { return &Robot{ RobotConfigBll: bRobotConfig, } } // Create 创建数据 // @Tags API-RobotConfig // @Summary 创建数据 // @Param body schema.RobotConfig true "提交的数据" // @Success 200 schema.RobotConfig // @Failure 400 schema.HTTPError "{error:{code:0,message:无效的请求参数}}" // @Failure 401 schema.HTTPError "{error:{code:0,message:未授权}}" // @Failure 500 schema.HTTPError "{error:{code:0,message:服务器错误}}" // @Router /robot/v1/robots/receive/{id} func (a *Robot) ReceiveMessage(r *ghttp.Request) { var data robot.DingTalkRobotMessage if err := gplus.ParseJson(r, &data); err != nil { gplus.ResError(r, err) } id := r.Get("id").String() ctx := gplus.NewContext(r) err := a.RobotConfigBll.ReceiveMessage(ctx, id, data) if err != nil { gplus.ResError(r, err) } ResSuccess(r, nil) }