feat:完善项目信息

This commit is contained in:
henry
2022-01-06 10:43:27 +08:00
parent 7488e9526b
commit 1b0f71735b
15 changed files with 146 additions and 342 deletions

View File

@ -135,7 +135,7 @@ func registerAdminAPI(app *gin.Engine) {
v1 := g.Group("/v1")
// 登录验证
g.Use(NeedLogin(config.RedisKeyForAccountAdmin, session.NewAdmin(), AddSkipperURL([]string{
v1.Use(NeedLogin(config.RedisKeyForAccountAdmin, session.NewAdmin(), AddSkipperURL([]string{
apiPrefix + "/v1/captcha",
apiPrefix + "/v1/account/login",
apiPrefix + "/v1/account/logout",
@ -240,14 +240,14 @@ func registerEnterpriseAPI(app *gin.Engine) {
apiPrefix := "/enterprise"
g := app.Group(apiPrefix)
g.Use(NeedLogin(config.RedisKeyForAccountEnterprise, session.NewEnterprise(), AddSkipperURL([]string{
v1 := g.Group("/v1")
v1.Use(NeedLogin(config.RedisKeyForAccountEnterprise, session.NewEnterprise(), AddSkipperURL([]string{
apiPrefix + "/v1/account/login",
apiPrefix + "/v1/account/register",
apiPrefix + "/v1/account/authorize",
}...)))
v1 := g.Group("/v1")
// Upload 上传管理
v1.POST("/upload", new(api.Upload).Upload)
// Config 配置管理

View File

@ -5,6 +5,7 @@ import (
"SciencesServer/app/service"
"SciencesServer/config"
"SciencesServer/utils"
"fmt"
"github.com/gin-gonic/gin"
"net/http"
)
@ -31,6 +32,7 @@ func NeedLogin(key string, session logic.ISession, skipperURL ...SkipperURL) gin
return
}
token := c.GetHeader(config.APIRequestToken)
fmt.Println(token)
if token == "" {
c.JSON(http.StatusUnauthorized, gin.H{"message": "Token异常"})
@ -44,6 +46,7 @@ func NeedLogin(key string, session logic.ISession, skipperURL ...SkipperURL) gin
c.Abort()
return
}
fmt.Println(utils.AnyToJSON(session))
c.Set(config.TokenForSession, session)
c.Next()
}