更换应用名相关调整

This commit is contained in:
天墨雀丹红 2023-07-04 20:43:45 +08:00
parent 9113fc5297
commit a9046dd3c0
14 changed files with 98 additions and 63 deletions

View File

@ -7,17 +7,19 @@ package admin
import (
"context"
"sort"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/text/gstr"
"hotgo/api/admin/monitor"
"hotgo/internal/consts"
"hotgo/internal/model/input/form"
"hotgo/internal/websocket"
"hotgo/utility/simple"
"hotgo/utility/useragent"
"sort"
)
// Monitor 监控
@ -93,7 +95,7 @@ func (c *cMonitor) OnlineList(ctx context.Context, req *monitor.OnlineListReq) (
res.PerPage = req.PerPage
sort.Sort(monitor.OnlineModels(clients))
isDemo := g.Cfg().MustGet(ctx, "hotgo.isDemo", false).Bool()
isDemo := g.Cfg().MustGet(ctx, simple.AppName(ctx)+".isDemo", false).Bool()
_, perPage, offset := form.CalPage(ctx, req.Page, req.PerPage)
for k, v := range clients {

View File

@ -7,6 +7,10 @@ package admin
import (
"fmt"
"os"
"runtime"
"time"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/util/gconv"
@ -15,15 +19,14 @@ import (
"github.com/shirou/gopsutil/v3/host"
"github.com/shirou/gopsutil/v3/mem"
"github.com/shirou/gopsutil/v3/process"
"hotgo/internal/consts"
"hotgo/internal/model"
"hotgo/internal/service"
"hotgo/internal/websocket"
"hotgo/utility/file"
"hotgo/utility/format"
"os"
"runtime"
"time"
"hotgo/utility/simple"
)
var (
@ -76,7 +79,7 @@ func (c *cMonitor) RunInfo(client *websocket.Client, req *websocket.WRequest) {
"goSize": file.DirSize(pwd),
}
isDemo := g.Cfg().MustGet(client.Context(), "hotgo.isDemo", false).Bool()
isDemo := g.Cfg().MustGet(client.Context(), simple.AppName(client.Context())+".isDemo", false).Bool()
if isDemo {
data["rootPath"] = consts.DemoTips
data["pwd"] = consts.DemoTips

View File

@ -7,12 +7,15 @@ package casbin
import (
"context"
"net/http"
"strings"
"github.com/casbin/casbin/v2"
_ "github.com/gogf/gf/contrib/drivers/mysql/v2"
"github.com/gogf/gf/v2/frame/g"
"hotgo/internal/consts"
"net/http"
"strings"
"hotgo/utility/simple"
)
const (
@ -55,7 +58,7 @@ func loadPermissions(ctx context.Context) {
rules [][]string
polices []*Policy
err error
superRoleKey = g.Cfg().MustGet(ctx, "hotgo.admin.superRoleKey")
superRoleKey = g.Cfg().MustGet(ctx, simple.AppName(ctx)+".admin.superRoleKey")
)
err = g.Model("hg_admin_role r").

View File

@ -8,6 +8,12 @@ package location
import (
"context"
"fmt"
"io"
"net"
"net/http"
"strings"
"time"
"github.com/gogf/gf/v2/container/gmap"
"github.com/gogf/gf/v2/encoding/gcharset"
"github.com/gogf/gf/v2/frame/g"
@ -15,12 +21,9 @@ import (
"github.com/gogf/gf/v2/text/gstr"
"github.com/gogf/gf/v2/util/gconv"
"github.com/kayon/iploc"
"hotgo/utility/simple"
"hotgo/utility/validate"
"io"
"net"
"net/http"
"strings"
"time"
)
const (
@ -141,7 +144,7 @@ func GetLocation(ctx context.Context, ip string) (data *IpLocationData, err erro
return data1, nil
}
mode := g.Cfg().MustGet(ctx, "hotgo.ipMethod", "cz88").String()
mode := g.Cfg().MustGet(ctx, simple.AppName(ctx)+".ipMethod", "cz88").String()
switch mode {
case "whois":
data, err = WhoisLocation(ctx, ip)

View File

@ -8,6 +8,7 @@ package admin
import (
"context"
"fmt"
"github.com/gogf/gf/v2/crypto/gmd5"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/errors/gerror"
@ -16,6 +17,7 @@ import (
"github.com/gogf/gf/v2/text/gstr"
"github.com/gogf/gf/v2/util/gconv"
"github.com/gogf/gf/v2/util/grand"
"hotgo/internal/consts"
"hotgo/internal/dao"
"hotgo/internal/library/contexts"
@ -26,6 +28,7 @@ import (
"hotgo/internal/model/input/adminin"
"hotgo/internal/model/input/sysin"
"hotgo/internal/service"
"hotgo/utility/simple"
"hotgo/utility/tree"
"hotgo/utility/validate"
)
@ -718,7 +721,7 @@ func (s *sAdminMember) Select(ctx context.Context, in adminin.MemberSelectInp) (
// VerifySuperId 验证是否为超管
func (s *sAdminMember) VerifySuperId(ctx context.Context, verifyId int64) bool {
for _, id := range g.Cfg().MustGet(ctx, "hotgo.admin.superIds").Int64s() {
for _, id := range g.Cfg().MustGet(ctx, simple.AppName(ctx)+".admin.superIds").Int64s() {
if id == verifyId {
return true
}

View File

@ -7,10 +7,13 @@ package admin
import (
"context"
"sort"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/encoding/gjson"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/frame/g"
"hotgo/internal/consts"
"hotgo/internal/dao"
"hotgo/internal/library/casbin"
@ -21,8 +24,8 @@ import (
"hotgo/internal/model/input/form"
"hotgo/internal/service"
"hotgo/utility/convert"
"hotgo/utility/simple"
"hotgo/utility/tree"
"sort"
)
type sAdminRole struct{}
@ -39,7 +42,7 @@ func init() {
func (s *sAdminRole) Verify(ctx context.Context, path, method string) bool {
var (
user = contexts.Get(ctx).User
sk = g.Cfg().MustGet(ctx, "hotgo.admin.superRoleKey")
sk = g.Cfg().MustGet(ctx, simple.AppName(ctx)+".admin.superRoleKey")
err error
)
@ -272,7 +275,7 @@ func (s *sAdminRole) DataScopeSelect() (res form.Selects) {
func (s *sAdminRole) DataScopeEdit(ctx context.Context, in *adminin.DataScopeEditInp) (err error) {
var (
models *entity.AdminRole
sk = g.Cfg().MustGet(ctx, "hotgo.admin.superRoleKey")
sk = g.Cfg().MustGet(ctx, simple.AppName(ctx)+".admin.superRoleKey")
)
if err = dao.AdminRole.Ctx(ctx).Where("id", in.Id).Scan(&models); err != nil {

View File

@ -8,6 +8,9 @@ package middleware
import (
"context"
"fmt"
"net/http"
"strings"
"github.com/gogf/gf/v2/encoding/gjson"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/frame/g"
@ -16,6 +19,7 @@ import (
"github.com/gogf/gf/v2/os/gctx"
"github.com/gogf/gf/v2/text/gstr"
"go.opentelemetry.io/otel/attribute"
"hotgo/internal/consts"
"hotgo/internal/global"
"hotgo/internal/library/addons"
@ -24,9 +28,8 @@ import (
"hotgo/internal/library/token"
"hotgo/internal/model"
"hotgo/internal/service"
"hotgo/utility/simple"
"hotgo/utility/validate"
"net/http"
"strings"
)
type sMiddleware struct {
@ -92,7 +95,7 @@ func (s *sMiddleware) CORS(r *ghttp.Request) {
// DemoLimit 演示系統操作限制
func (s *sMiddleware) DemoLimit(r *ghttp.Request) {
isDemo := g.Cfg().MustGet(r.Context(), "hotgo.isDemo", false)
isDemo := g.Cfg().MustGet(r.Context(), simple.AppName(r.Context())+".isDemo", false)
if !isDemo.Bool() {
r.Middleware.Next()
return

View File

@ -11,6 +11,7 @@ import (
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/net/ghttp"
"github.com/gogf/gf/v2/util/gmeta"
"hotgo/internal/consts"
"hotgo/internal/library/contexts"
"hotgo/internal/library/response"
@ -75,7 +76,7 @@ func parseResponse(r *ghttp.Request) (code int, message string, resp interface{}
}
// 是否输出错误堆栈到页面
if g.Cfg().MustGet(ctx, "hotgo.debug", true).Bool() {
if g.Cfg().MustGet(ctx, simple.AppName(ctx)+".debug", true).Bool() {
message = gerror.Current(err).Error()
if getContentType(r) == consts.HTTPContentTypeHtml {
resp = charset.SerializeStack(err)

View File

@ -7,16 +7,19 @@ package sys
import (
"context"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/text/gstr"
"hotgo/internal/consts"
"hotgo/internal/dao"
"hotgo/internal/model/entity"
"hotgo/internal/model/input/sysin"
"hotgo/internal/service"
"hotgo/utility/simple"
)
var AddonsMaskDemoField []string
@ -55,7 +58,7 @@ func (s *sSysAddonsConfig) GetConfigByGroup(ctx context.Context, in sysin.GetAdd
return nil, err
}
isDemo := g.Cfg().MustGet(ctx, "hotgo.isDemo", false)
isDemo := g.Cfg().MustGet(ctx, simple.AppName(ctx)+".isDemo", false)
if len(models) > 0 {
res = new(sysin.GetAddonsConfigModel)
res.List = make(g.Map, len(models))

View File

@ -8,11 +8,13 @@ package sys
import (
"context"
"fmt"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/util/gconv"
"hotgo/internal/consts"
"hotgo/internal/dao"
"hotgo/internal/library/payment"
@ -174,13 +176,13 @@ func (s *sSysConfig) GetLoadToken(ctx context.Context) (conf *model.TokenConfig,
// GetLoadLog 获取本地日志配置
func (s *sSysConfig) GetLoadLog(ctx context.Context) (conf *model.LogConfig, err error) {
err = g.Cfg().MustGet(ctx, "hotgo.log").Scan(&conf)
err = g.Cfg().MustGet(ctx, simple.AppName(ctx)+".log").Scan(&conf)
return
}
// GetLoadServeLog 获取本地服务日志配置
func (s *sSysConfig) GetLoadServeLog(ctx context.Context) (conf *model.ServeLogConfig, err error) {
err = g.Cfg().MustGet(ctx, "hotgo.serveLog").Scan(&conf)
err = g.Cfg().MustGet(ctx, simple.AppName(ctx)+".serveLog").Scan(&conf)
return
}

View File

@ -8,6 +8,7 @@ package sys
import (
"context"
"encoding/json"
"github.com/gogf/gf/v2/encoding/gjson"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/frame/g"
@ -16,6 +17,7 @@ import (
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/text/gstr"
"github.com/gogf/gf/v2/util/gconv"
"hotgo/internal/consts"
"hotgo/internal/dao"
"hotgo/internal/library/contexts"
@ -241,7 +243,7 @@ func (s *sSysLog) View(ctx context.Context, in sysin.LogViewInp) (res *sysin.Log
return
}
if g.Cfg().MustGet(ctx, "hotgo.isDemo", false).Bool() {
if g.Cfg().MustGet(ctx, simple.AppName(ctx)+".isDemo", false).Bool() {
res.HeaderData = gjson.New(`{
"none": [
"` + consts.DemoTips + `"
@ -317,7 +319,7 @@ func (s *sSysLog) List(ctx context.Context, in sysin.LogListInp) (list []*sysin.
return
}
isDemo := g.Cfg().MustGet(ctx, "hotgo.isDemo", false).Bool()
isDemo := g.Cfg().MustGet(ctx, simple.AppName(ctx)+".isDemo", false).Bool()
for i := 0; i < len(list); i++ {
// 管理员
if list[i].AppId == consts.AppAdmin {

View File

@ -7,9 +7,11 @@ package view
import (
"context"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/util/gconv"
"hotgo/internal/model"
"hotgo/internal/service"
"hotgo/utility/charset"
@ -95,7 +97,7 @@ func (s *sView) Error(ctx context.Context, err error) {
)
// 是否输出错误堆栈到页面
if g.Cfg().MustGet(ctx, "hotgo.debug", true).Bool() {
if g.Cfg().MustGet(ctx, simple.AppName(ctx)+".debug", true).Bool() {
stack = charset.SerializeStack(err)
}

View File

@ -7,8 +7,11 @@ package form
import (
"context"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/util/gconv"
"hotgo/utility/simple"
)
var (
@ -21,7 +24,7 @@ func DefaultPageSize(ctx context.Context) int {
if pageSize > 0 {
return pageSize
}
pageSize = g.Cfg().MustGet(ctx, "hotgo.admin.defaultPageSize", 10).Int()
pageSize = g.Cfg().MustGet(ctx, simple.AppName(ctx)+".admin.defaultPageSize", 10).Int()
if pageSize <= 0 {
pageSize = 10
}
@ -33,7 +36,7 @@ func DefaultPage(ctx context.Context) int {
if page > 0 {
return page
}
page = g.Cfg().MustGet(ctx, "hotgo.admin.defaultPage", 1).Int()
page = g.Cfg().MustGet(ctx, simple.AppName(ctx)+".admin.defaultPage", 1).Int()
if page <= 0 {
page = 1
}
@ -118,7 +121,7 @@ type SelectInt64 struct {
// DefaultMaxSort 默认最大排序
func DefaultMaxSort(ctx context.Context, baseSort int) int {
return baseSort + g.Cfg().MustGet(ctx, "hotgo.admin.maxSortIncrement", 10).Int()
return baseSort + g.Cfg().MustGet(ctx, simple.AppName(ctx)+".admin.maxSortIncrement", 10).Int()
}
// AvatarGroup 头像组

View File

@ -7,6 +7,7 @@ package simple
import (
"context"
"github.com/gogf/gf/v2/crypto/gmd5"
"github.com/gogf/gf/v2/encoding/gbase64"
"github.com/gogf/gf/v2/errors/gerror"
@ -15,6 +16,7 @@ import (
"github.com/gogf/gf/v2/os/glog"
"github.com/gogf/gf/v2/os/grpool"
"github.com/gogf/gf/v2/util/gconv"
"hotgo/internal/consts"
"hotgo/utility/encrypt"
)
@ -35,7 +37,7 @@ func FilterMaskDemo(ctx context.Context, src g.Map) g.Map {
return nil
}
if !g.Cfg().MustGet(ctx, "hotgo.isDemo", false).Bool() {
if !g.Cfg().MustGet(ctx, AppName(ctx)+".isDemo", false).Bool() {
return src
}