refactor(cool): 修复Logger变量名拼写错误

将全局Logger变量从Loger修正为Logger,统一日志实例命名规范,
确保所有模块中日志记录的一致性。

BREAKING CHANGE: 全局日志实例变量名从Loger改为Logger
```
This commit is contained in:
2025-12-25 12:14:04 +08:00
parent ff199e339f
commit 164e70519f
30 changed files with 85 additions and 85 deletions

View File

@@ -31,7 +31,7 @@ func init() {
var (
ctx = gctx.GetInitCtx()
)
cool.Loger.Debug(ctx, "module base init start ...")
cool.Logger.Debug(ctx, "module base init start ...")
var t bool
cool.FillInitData(ctx, "base", &model.BaseSysMenu{}, &t)
@@ -80,7 +80,7 @@ func init() {
// -- 执行函数
// SELECT reset_all_sequences();`, nil) //重置所有序列
cool.Loger.Debug(ctx, "module base init finished ...")
cool.Logger.Debug(ctx, "module base init finished ...")
}
@@ -122,7 +122,7 @@ func ResetAllSequences(ctx context.Context) error {
maxValueRecord, err := g.DB("default").Query(ctx, maxValueQuery)
if err != nil {
cool.Loger.Warning(ctx, fmt.Sprintf("获取表 %s.%s 的最大值失败: %v",
cool.Logger.Warning(ctx, fmt.Sprintf("获取表 %s.%s 的最大值失败: %v",
schemaName, tableName, err))
continue
}
@@ -142,12 +142,12 @@ func ResetAllSequences(ctx context.Context) error {
_, err = g.DB("default").Exec(ctx, resetQuery)
if err != nil {
cool.Loger.Warning(ctx, fmt.Sprintf("重置序列 %s.%s 失败: %v",
cool.Logger.Warning(ctx, fmt.Sprintf("重置序列 %s.%s 失败: %v",
schemaName, sequenceName, err))
continue
}
cool.Loger.Info(ctx, fmt.Sprintf("序列 %s.%s 已重置为 %d",
cool.Logger.Info(ctx, fmt.Sprintf("序列 %s.%s 已重置为 %d",
schemaName, sequenceName, maxValue))
}

View File

@@ -81,5 +81,5 @@ func init() {
if jwtSecret == "cool-admin-go" {
Config.Jwt.Secret = cool.ProcessFlag
}
cool.Loger.Info(ctx, "jwt secret:", Config.Jwt.Secret)
cool.Logger.Info(ctx, "jwt secret:", Config.Jwt.Secret)
}

View File

@@ -42,13 +42,13 @@ type BaseOpenEpsReq struct {
// eps 接口
func (c *BaseOpen) Eps(ctx context.Context, req *BaseOpenEpsReq) (res *cool.BaseRes, err error) {
if !cool.Config.Eps {
cool.Loger.Error(ctx, "eps is not open")
cool.Logger.Error(ctx, "eps is not open")
res = cool.Ok(nil)
return
}
data, err := c.baseOpenService.AdminEPS(ctx)
if err != nil {
cool.Loger.Error(ctx, "eps error", err)
cool.Logger.Error(ctx, "eps error", err)
return cool.Fail(err.Error()), err
}
res = cool.Ok(data)

View File

@@ -34,14 +34,14 @@ type BaseCommControllerEpsReq struct {
// eps 接口
func (c *BaseCommController) Eps(ctx context.Context, req *BaseCommControllerEpsReq) (res *cool.BaseRes, err error) {
if !cool.Config.Eps {
cool.Loger.Error(ctx, "eps is not open")
cool.Logger.Error(ctx, "eps is not open")
res = cool.Ok(nil)
return
}
baseOpenService := service.NewBaseOpenService()
data, err := baseOpenService.AppEPS(ctx)
if err != nil {
cool.Loger.Error(ctx, "eps error", err)
cool.Logger.Error(ctx, "eps error", err)
return cool.Fail(err.Error()), err
}
res = cool.Ok(data)

View File

@@ -13,7 +13,7 @@ type BaseFuncClearLog struct {
// Func
func (f *BaseFuncClearLog) Func(ctx g.Ctx, param string) (err error) {
cool.Loger.Info(ctx, "清理日志 BaseFuncClearLog.Func", "param", param)
cool.Logger.Info(ctx, "清理日志 BaseFuncClearLog.Func", "param", param)
baseSysLogService := service.NewBaseSysLogService()
if param == "true" {
err = baseSysLogService.Clear(true)

View File

@@ -48,7 +48,7 @@ func BaseAuthorityMiddleware(r *ghttp.Request) {
return []byte(config.Config.Jwt.Secret), nil
})
if err != nil {
cool.Loger.Error(ctx, "BaseAuthorityMiddleware", err)
cool.Logger.Error(ctx, "BaseAuthorityMiddleware", err)
statusCode = 401
r.Response.WriteStatusExit(statusCode, g.Map{
"code": 1001,
@@ -56,7 +56,7 @@ func BaseAuthorityMiddleware(r *ghttp.Request) {
})
}
if !token.Valid {
cool.Loger.Error(ctx, "BaseAuthorityMiddleware", "token invalid")
cool.Logger.Error(ctx, "BaseAuthorityMiddleware", "token invalid")
statusCode = 401
r.Response.WriteStatusExit(statusCode, g.Map{
"code": 1001,
@@ -72,7 +72,7 @@ func BaseAuthorityMiddleware(r *ghttp.Request) {
// 超管拥有所有权限
if admin.UserId == 10001 && !admin.IsRefresh {
if tokenString != rtoken && config.Config.Jwt.Sso {
cool.Loger.Error(ctx, "BaseAuthorityMiddleware", "token invalid")
cool.Logger.Error(ctx, "BaseAuthorityMiddleware", "token invalid")
statusCode = 401
r.Response.WriteStatusExit(statusCode, g.Map{
"code": 1001,
@@ -91,7 +91,7 @@ func BaseAuthorityMiddleware(r *ghttp.Request) {
}
// 如果传的token是refreshToken则校验失败
if admin.IsRefresh {
cool.Loger.Error(ctx, "BaseAuthorityMiddleware", "token invalid")
cool.Logger.Error(ctx, "BaseAuthorityMiddleware", "token invalid")
statusCode = 401
r.Response.WriteStatusExit(statusCode, g.Map{
"code": 1001,
@@ -101,7 +101,7 @@ func BaseAuthorityMiddleware(r *ghttp.Request) {
// 判断密码版本是否正确
passwordV, _ := cool.CacheManager.Get(ctx, "admin:passwordVersion:"+gconv.String(admin.UserId))
if passwordV.Int32() != *admin.PasswordVersion {
cool.Loger.Error(ctx, "BaseAuthorityMiddleware", "passwordV invalid")
cool.Logger.Error(ctx, "BaseAuthorityMiddleware", "passwordV invalid")
statusCode = 401
r.Response.WriteStatusExit(statusCode, g.Map{
"code": 1001,
@@ -110,7 +110,7 @@ func BaseAuthorityMiddleware(r *ghttp.Request) {
}
// 如果rtoken为空
if rtoken == "" {
cool.Loger.Error(ctx, "BaseAuthorityMiddleware", "rtoken invalid")
cool.Logger.Error(ctx, "BaseAuthorityMiddleware", "rtoken invalid")
statusCode = 401
r.Response.WriteStatusExit(statusCode, g.Map{
"code": 1001,
@@ -119,7 +119,7 @@ func BaseAuthorityMiddleware(r *ghttp.Request) {
}
// 如果rtoken不等于token 且 sso 未开启
if tokenString != rtoken && !config.Config.Jwt.Sso {
cool.Loger.Error(ctx, "BaseAuthorityMiddleware", "token invalid")
cool.Logger.Error(ctx, "BaseAuthorityMiddleware", "token invalid")
statusCode = 401
r.Response.WriteStatusExit(statusCode, g.Map{
"code": 1001,
@@ -134,7 +134,7 @@ func BaseAuthorityMiddleware(r *ghttp.Request) {
perms := garray.NewStrArrayFrom(permsVar)
// 如果perms为空
if perms.Len() == 0 {
cool.Loger.Error(ctx, "BaseAuthorityMiddleware", "perms invalid")
cool.Logger.Error(ctx, "BaseAuthorityMiddleware", "perms invalid")
statusCode = 403
r.Response.WriteStatusExit(statusCode, g.Map{
"code": 1001,
@@ -154,7 +154,7 @@ func BaseAuthorityMiddleware(r *ghttp.Request) {
url = gstr.Join(urls, ":")
// 如果perms中不包含url 则无权限
if !perms.ContainsI(url) {
cool.Loger.Error(ctx, "BaseAuthorityMiddleware", "perms invalid")
cool.Logger.Error(ctx, "BaseAuthorityMiddleware", "perms invalid")
statusCode = 403
r.Response.WriteStatusExit(statusCode, g.Map{
"code": 1001,

View File

@@ -83,7 +83,7 @@ func (*BaseSysLoginService) Captcha(req *v1.BaseOpenCaptchaReq) (interface{}, er
result.Data = `data:image/svg+xml;base64,` + svgbase64
result.CaptchaId = guid.S()
cool.CacheManager.Set(ctx, "login:"+result.CaptchaId, captchaText, 1800*time.Second)
cool.Loger.Debug(ctx, "验证码", result.CaptchaId, captchaText)
cool.Logger.Debug(ctx, "验证码", result.CaptchaId, captchaText)
return result, err
}
@@ -143,7 +143,7 @@ func (s *BaseSysLoginService) RefreshToken(ctx context.Context, token string) (r
func (*BaseSysLoginService) generateToken(ctx context.Context, user *model.BaseSysUser, roleIds []string, exprire uint, isRefresh bool) (token string) {
err := cool.CacheManager.Set(ctx, "admin:passwordVersion:"+gconv.String(user.ID), gconv.String(user.PasswordV), 0)
if err != nil {
cool.Loger.Error(ctx, "生成token失败", err)
cool.Logger.Error(ctx, "生成token失败", err)
}
claims := &cool.Claims{
@@ -161,7 +161,7 @@ func (*BaseSysLoginService) generateToken(ctx context.Context, user *model.BaseS
token, err = tokenClaims.SignedString([]byte(config.Config.Jwt.Secret))
if err != nil {
cool.Loger.Error(ctx, "生成token失败", err)
cool.Logger.Error(ctx, "生成token失败", err)
}
return
}