发布代码生成、更新20+表单组件,优化数据字典,gf版本更新到2.3.1

This commit is contained in:
孟帅
2023-01-18 16:23:39 +08:00
parent 50207ded90
commit 87c27a17a3
386 changed files with 27926 additions and 44297 deletions

View File

@@ -26,7 +26,7 @@ func (s *sMiddleware) AdminAuth(r *ghttp.Request) {
)
// 替换掉模块前缀
routerPrefix, _ := g.Cfg().Get(ctx, "router.admin.prefix", "/admin")
routerPrefix := g.Cfg().MustGet(ctx, "router.admin.prefix", "/admin")
path := gstr.Replace(r.URL.Path, routerPrefix.String(), "", 1)
/// 不需要验证登录的路由地址

View File

@@ -24,7 +24,7 @@ func (s *sMiddleware) ApiAuth(r *ghttp.Request) {
)
// 替换掉模块前缀
routerPrefix, _ := g.Cfg().Get(ctx, "router.api.prefix", "/api")
routerPrefix := g.Cfg().MustGet(ctx, "router.api.prefix", "/api")
path := gstr.Replace(r.URL.Path, routerPrefix.String(), "", 1)
/// 不需要验证登录的路由地址
@@ -39,9 +39,9 @@ func (s *sMiddleware) ApiAuth(r *ghttp.Request) {
}
//// 验证路由访问权限
//verify := adminService.Role.Verify(ctx, customCtx.User.Id, path)
//verify := service.AdminRole().Verify(ctx, path, r.Method)
//if !verify {
// response.JsonExit(r, gcode.CodeSecurityReason.Code(), "你没有访问权限!")
// response.JsonExit(r, consts.CodeSecurityReason, "你没有访问权限!")
// return
//}

View File

@@ -75,7 +75,7 @@ func (s *sMiddleware) CORS(r *ghttp.Request) {
// DemoLimit 演示系統操作限制
func (s *sMiddleware) DemoLimit(r *ghttp.Request) {
isDemo, _ := g.Cfg().Get(r.Context(), "hotgo.isDemo", false)
isDemo := g.Cfg().MustGet(r.Context(), "hotgo.isDemo", false)
if !isDemo.Bool() {
r.Middleware.Next()
return
@@ -86,7 +86,7 @@ func (s *sMiddleware) DemoLimit(r *ghttp.Request) {
r.Middleware.Next()
return
}
response.JsonExit(r, gcode.CodeInvalidRequest.Code(), "演示系禁止操作!")
response.JsonExit(r, gcode.CodeNotSupported.Code(), "演示系禁止操作!")
return
}
@@ -109,7 +109,7 @@ func inspectAuth(r *ghttp.Request, appName string) error {
// 获取jwtToken
jwtToken := consts.RedisJwtToken + gmd5.MustEncryptString(authorization)
jwtSign, _ := g.Cfg().Get(ctx, "jwt.sign", "hotgo")
jwtSign := g.Cfg().MustGet(ctx, "jwt.sign", "hotgo")
data, ParseErr := jwt.ParseToken(authorization, jwtSign.Bytes())
if ParseErr != nil {
@@ -131,7 +131,7 @@ func inspectAuth(r *ghttp.Request, appName string) error {
}
// 是否开启多端登录
if multiPort, _ := g.Cfg().Get(ctx, "jwt.multiPort", true); !multiPort.Bool() {
if multiPort := g.Cfg().MustGet(ctx, "jwt.multiPort", true); !multiPort.Bool() {
key := consts.RedisJwtUserBind + appName + ":" + gconv.String(user.Id)
originJwtToken, originErr := c.Get(ctx, key)
if originErr != nil {
@@ -151,6 +151,10 @@ func inspectAuth(r *ghttp.Request, appName string) error {
if user != nil {
customCtx.User = &model.Identity{
Id: user.Id,
Pid: user.Pid,
DeptId: user.DeptId,
RoleId: user.RoleId,
RoleKey: user.RoleKey,
Username: user.Username,
RealName: user.RealName,
Avatar: user.Avatar,
@@ -159,8 +163,6 @@ func inspectAuth(r *ghttp.Request, appName string) error {
VisitCount: user.VisitCount,
LastTime: user.LastTime,
LastIp: user.LastIp,
Role: user.Role,
RoleKey: user.RoleKey,
Exp: user.Exp,
Expires: user.Expires,
App: user.App,

View File

@@ -8,9 +8,9 @@ package middleware
import (
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/net/ghttp"
"hotgo/internal/consts"
"hotgo/internal/library/contexts"
"hotgo/internal/library/response"
"hotgo/utility/charset"
@@ -35,15 +35,6 @@ func (s *sMiddleware) ResponseHandler(r *ghttp.Request) {
return
}
if err := r.GetError(); err != nil {
g.Log().Print(ctx, err)
// 记录到自定义错误日志文件
//g.Log("exception").Error(err)
////返回固定的友好信息
//r.Response.ClearBuffer()
//r.Response.Writeln("服务器居然开小差了,请稍后再试吧!")
}
// 已存在响应内容且是comResponse返回的时中断运行
if r.Response.BufferLength() > 0 && comResponse != nil {
return
@@ -51,26 +42,15 @@ func (s *sMiddleware) ResponseHandler(r *ghttp.Request) {
if err = r.GetError(); err != nil {
// 记录到自定义错误日志文件
g.Log("exception").Print(r.Context(), "exception:", err)
g.Log("exception").Print(ctx, "exception:", err)
code = consts.CodeInternalError
message = "服务器居然开小差了,请稍后再试吧!"
code = gerror.Code(err).Code()
message = err.Error()
// 是否输出错误到页面
if debug, _ := g.Cfg().Get(ctx, "hotgo.debug", true); debug.Bool() {
if g.Cfg().MustGet(ctx, "hotgo.debug", true).Bool() {
data = charset.GetStack(err)
message = err.Error()
}
//} else if data, err = r.GetHandlerResponse(); err != nil {
// errCode := gerror.Code(err)
// if errCode == gcode.CodeNil {
// errCode = gcode.CodeInternalError
// }
// code = errCode.Code()
// message = err.Error()
//}
} else {
data = r.GetHandlerResponse()
}

View File

@@ -24,7 +24,7 @@ func (s *sMiddleware) WebSocketToken(r *ghttp.Request) {
)
// 替换掉模块前缀
routerPrefix, _ := g.Cfg().Get(ctx, "router.ws.prefix", "/socket")
routerPrefix := g.Cfg().MustGet(ctx, "router.ws.prefix", "/socket")
path := gstr.Replace(r.URL.Path, routerPrefix.String(), "", 1)
/// 不需要验证登录的路由地址