1
This commit is contained in:
parent
07c63649d9
commit
6b3f3014ce
@ -22,3 +22,7 @@ node ../../tools/pbtools/app.js
|
|||||||
# go代码风格
|
# go代码风格
|
||||||
|
|
||||||
main包里所有的函数、字段都小写开头
|
main包里所有的函数、字段都小写开头
|
||||||
|
|
||||||
|
# 参考
|
||||||
|
|
||||||
|
https://gorm.io/zh_CN/docs/
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
package middleware
|
package middleware
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"f5"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Auth() gin.HandlerFunc {
|
func Auth() gin.HandlerFunc {
|
||||||
return func(c *gin.Context) {
|
return func(c *gin.Context) {
|
||||||
token := c.Request.Header.Get("Authorization")
|
token := c.Request.Header.Get("Authorization")
|
||||||
|
f5.GetSysLog().Info("auth")
|
||||||
if token == "" {
|
if token == "" {
|
||||||
/*
|
/*
|
||||||
response.FailWithDetailed(gin.H{"reload": true}, "未登录或非法访问", c)*/
|
response.FailWithDetailed(gin.H{"reload": true}, "未登录或非法访问", c)*/
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"f5"
|
"f5"
|
||||||
//. "main/global"
|
//. "main/global"
|
||||||
"main/router/system"
|
"main/router/system"
|
||||||
|
"main/middleware"
|
||||||
)
|
)
|
||||||
|
|
||||||
type routerMgr struct {
|
type routerMgr struct {
|
||||||
@ -12,8 +13,10 @@ type routerMgr struct {
|
|||||||
|
|
||||||
|
|
||||||
func (this* routerMgr) Init() {
|
func (this* routerMgr) Init() {
|
||||||
router := f5.GetApp().GetGinEngine().Group("api/v1")
|
priGroup := f5.GetApp().GetGinEngine().Group("api/v1")
|
||||||
this.system.InitUserRouter(router)
|
pubGroup := f5.GetApp().GetGinEngine().Group("api/v1")
|
||||||
|
priGroup.Use(middleware.Auth())
|
||||||
|
this.system.InitUserRouter(priGroup, pubGroup)
|
||||||
f5.GetSysLog().Info("routerMgr.init")
|
f5.GetSysLog().Info("routerMgr.init")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,13 +7,15 @@ import (
|
|||||||
|
|
||||||
type UserRouter struct{}
|
type UserRouter struct{}
|
||||||
|
|
||||||
func (this *UserRouter) InitUserRouter(Router *gin.RouterGroup) {
|
func (this *UserRouter) InitUserRouter(priRouter *gin.RouterGroup,
|
||||||
userRouter := Router.Group("user")
|
pubRouter *gin.RouterGroup) {
|
||||||
|
priUserRouter := priRouter.Group("user")
|
||||||
|
pubUserRouter := pubRouter.Group("user")
|
||||||
userApi := v1.ApiGroupApp.SystemApiGroup.UserApi
|
userApi := v1.ApiGroupApp.SystemApiGroup.UserApi
|
||||||
{
|
{
|
||||||
userRouter.POST("login", userApi.Login)
|
pubUserRouter.POST("login", userApi.Login)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
userRouter.GET("info", userApi.Info)
|
priUserRouter.GET("info", userApi.Info)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
third_party/f5
vendored
2
third_party/f5
vendored
@ -1 +1 @@
|
|||||||
Subproject commit d42efe492e859605f238a5954be108742da2e6b2
|
Subproject commit 6c73845a87c1d4c8dc9234abb4dd16e6b75b6582
|
Loading…
x
Reference in New Issue
Block a user