From 2cc0e81445eab7cff21a66157ef47fe5f00b09d8 Mon Sep 17 00:00:00 2001 From: suyl <770236076@qq.com> Date: Thu, 24 Jun 2021 18:24:41 +0800 Subject: [PATCH] aa --- business/model/error_code.go | 18 +++----------- controllers/auth_contorller.go | 45 ++++++++++++++++++++++++++++++++++ routers/router.go | 11 +++++++-- 3 files changed, 58 insertions(+), 16 deletions(-) create mode 100644 controllers/auth_contorller.go diff --git a/business/model/error_code.go b/business/model/error_code.go index b5136c777..6a9b1ebed 100644 --- a/business/model/error_code.go +++ b/business/model/error_code.go @@ -5,21 +5,11 @@ import "errors" const ( ErrorCodeIgnore = "ignore" - ErrCodeSuccess = "0" - ErrCodePoint = "1" - ErrCodeGeneralFailed = "-1" - ErrCodeTokenIsInvalid = "-2" - ErrCodeUserNotExist = "-3" - ErrCodeUserAlreadyExist = "-4" // 用户已经存在错,但不能成功登录 + ErrCodeSuccess = "0" + ErrCodeGeneralFailed = "-1" + ErrCodeTokenIsInvalid = "-2" - ErrCodeJsonActSkuConflict = "-101" // 这个错误号表示description中的是一个json对象,不是错误文本 - ErrCodeJsonActPriceTooLarger = "-102" // 这个错误号表示description中的是一个json对象,不是错误文本 - ErrCodeJsonActEarningPriceIsZero = "-103" - ErrCodeJsonUserAlreadyExist = "-104" // 用户已经存在错,且能成功登录 - ErrCodeJsonSyncErr = "-105" - - ErrCodeAccountBalanceNotEnough = "-201" //余额不足 - ErrCodeNotAuthBindWeixin = "-202" //没有绑定微信认证方式 + ErrCodeJsonSyncErr = "-105" ) var ( diff --git a/controllers/auth_contorller.go b/controllers/auth_contorller.go new file mode 100644 index 000000000..0e035452d --- /dev/null +++ b/controllers/auth_contorller.go @@ -0,0 +1,45 @@ +package controllers + +import ( + "fmt" + "git.rosy.net.cn/jx-callback/business/model" + "github.com/astaxie/beego/server/web" + "strings" +) + +type AuthController struct { + web.Controller +} + +// @Title 注册用户 +// @Description 注册用户 +// @Param param formData string true "注册信息" +// @Success 200 {object} controllers.CallResult +// @Failure 200 {object} controllers.CallResult +// @router /RegisterUser [post] +func (c *AuthController) RegisterUser() { + var ( + err error + errCode = model.ErrCodeGeneralFailed + param string + ) + errParams := []string{} + if param = c.GetString("param", ""); param == "" { + errParams = append(errParams, "param") + } + if len(errParams) > 0 { + err = fmt.Errorf(strRequiredParamIsEmpty, strings.Join(errParams, ",")) + } + if err == nil { + c.Data["json"] = &CallResult{ + Code: model.ErrCodeSuccess, + Data: string(""), + } + } else { + c.Data["json"] = &CallResult{ + Code: errCode, + Desc: err.Error(), + } + } + c.ServeJSON() +} diff --git a/routers/router.go b/routers/router.go index 8d355b540..0b8004a88 100644 --- a/routers/router.go +++ b/routers/router.go @@ -14,20 +14,27 @@ import ( ) func init() { - ns := web.NewNamespace("/v2", - web.NSNamespace("/openapi"), + ns := web.NewNamespace("/openapi", web.NSNamespace("/print", web.NSInclude( &controllers.PrintController{}, ), ), + ) + ns2 := web.NewNamespace("/v2", web.NSNamespace("/task", web.NSInclude( &controllers.TaskController{}, ), ), + web.NSNamespace("/auth", + web.NSInclude( + &controllers.AuthController{}, + ), + ), ) web.AddNamespace(ns) + web.AddNamespace(ns2) // 如下都是用于检测存活的空接口 web.Any("/", func(ctx *beecontext.Context) {