Browse Source

init初始化

Roc 3 years ago
parent
commit
88a2e2b5be

+ 2 - 1
.gitignore

@@ -8,4 +8,5 @@
 /conf
 /tests
 go.mod
-go.sum
+go.sum
+/routers

+ 15 - 0
controllers/approval.go

@@ -0,0 +1,15 @@
+package controllers
+
+type ApprovalCommon struct {
+	BaseAuth
+}
+
+// @Title 获取审批列表接口
+// @Description 获取审批列表接口
+// @Param	request	body admin.LoginReq true "type json string"
+// @Success 200 {object} admin3.LoginResp
+// @router /list [get]
+func (this *ApprovalCommon) List() {
+
+	this.OkDetailed("1", "获取成功")
+}

+ 13 - 0
controllers/base_auth.go

@@ -83,9 +83,22 @@ func (this *BaseAuth) Prepare() {
 
 			//如果不是登录绑定接口,同时报错信息不是用户未绑定的情况下,那么就返回异常
 			if !strings.Contains(uri, "/api/admin/login") && err != services.ERR_ADMIN_NOT_BIND {
+
+			}
+
+			//错误信息,账户未绑定,跳转到绑定页面
+			if err == services.ERR_ADMIN_NOT_BIND {
+				//如果不是登录接口
+				if !strings.Contains(uri, "/api/admin/login") {
+					this.BindMsgError("账户未绑定!", "获取admin_wx信息异常,Err:"+err.Error())
+					return
+				}
+			} else {
+				//其他错误信息
 				this.TokenMsgError("网络异常,请稍后重试!", "获取admin_wx信息异常,Err:"+err.Error())
 				return
 			}
+
 		}
 		if adminWx == nil {
 			this.TokenMsgError("网络异常,请稍后重试!", "admin is empty")

+ 9 - 0
controllers/base_common.go

@@ -114,6 +114,15 @@ func (this BaseCommon) BindError(data interface{}, message string) {
 	this.Result()
 }
 
+//账户绑定异常
+func (this BaseCommon) BindMsgError(message, errMessage string) {
+	this.Response.Code = BIND_ERROR
+	this.Response.Msg = message
+	this.Response.ErrMsg = errMessage
+	//this.Response.Data = data
+	this.Result()
+}
+
 //签名异常
 func (this BaseCommon) SignError(message string) {
 	this.Response.Code = SIGN_ERROR

+ 9 - 0
routers/commentsRouter_controllers.go

@@ -16,6 +16,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers:ApprovalCommon"] = append(beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers:ApprovalCommon"],
+        beego.ControllerComments{
+            Method: "List",
+            Router: "/list",
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers:BaseNotAuth"] = append(beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers:BaseNotAuth"],
         beego.ControllerComments{
             Method: "Test",

+ 6 - 1
routers/router.go

@@ -1,6 +1,6 @@
 // @APIVersion 1.0.0
 // @Title 弘则手机端管理后台接口
-// @Description 这是弘则手机端管理后台接口api文档,统一出、入参;出参格式:{"code":200,"data":{},"msg":"操作成功"},code是业务响应码,200 代表正常返回;400 代表业务处理失败,前端同学需要做额外逻辑处理;401 代表token异常,用户需要重新静默授权,获取最新的token;403代表用户需要进行绑定操作,需要跳转到输入账号密码绑定页面。同时如果出现其他返回值(没有在约定范围内),那么及时联系后端同事;msg是用来提示前端同学,一般只在code为 400 的情况下才会展示给用户去看;data是业务返回数据,给前端做逻辑处理。
+// @Description 这是弘则手机端管理后台接口api文档,统一出、入参;出参格式:{"code":200,"data":{},"msg":"操作成功","errMsg":"开发人员查看的错误信息"},code是业务响应码,200 代表正常返回;400 代表业务处理失败,前端同学需要做额外逻辑处理;401 代表token异常,用户需要重新静默授权,获取最新的token;403代表用户需要进行绑定操作,需要跳转到输入账号密码绑定页面。同时如果出现其他返回值(没有在约定范围内),那么及时联系后端同事;msg是用来提示前端同学,一般只在code为 400 的情况下才会展示给用户去看;data是业务返回数据,给前端做逻辑处理。
 // @Contact astaxie@gmail.com
 // @TermsOfServiceUrl http://beego.me/
 // @License Apache 2.0
@@ -25,6 +25,11 @@ func init() {
 				&controllers.AdminCommon{},
 			),
 		),
+		beego.NSNamespace("/approval",
+			beego.NSInclude(
+				&controllers.ApprovalCommon{},
+			),
+		),
 	)
 	beego.AddNamespace(ns)
 }