sync: 同步 v1.0.4 并脱敏配置与镜像

This commit is contained in:
MiFaZhan
2026-10-29 14:36:49 +08:00
parent 743e8e6e6e
commit 2206a393f7
516 changed files with 18119 additions and 2253 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
// package router
// @Link https://github.com/xiujiecn/xiu-admin
// @Copyright Copyright (c) 2025 LiXiujie
// @Author Lxj <li@xiujie.cn>
// @Author Lxj <xxx@example.com>
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
package router
+1 -1
View File
@@ -1,7 +1,7 @@
// package router
// @Link https://github.com/xiujiecn/xiu-admin
// @Copyright Copyright (c) 2025 LiXiujie
// @Author Lxj <li@xiujie.cn>
// @Author Lxj <xxx@example.com>
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
package router
@@ -0,0 +1,28 @@
package router
import (
"testing"
"github.com/gogf/gf/v2/util/gmeta"
v1 "git.5iot.com/iotlcm-public/iotlcm-admin-svr/api/iot/v1"
)
func TestFullSyncMonitorPermissionDeclarations(t *testing.T) {
// A slice of pairs rather than a map: request structs may contain slice
// fields (for example the channel scope), which are not hashable.
checks := []struct {
request any
want string
}{
{v1.FullSyncRunsListReq{}, "cpm:iot:fullSyncRuns:view"},
{v1.FullSyncRunDetailReq{}, "cpm:iot:fullSyncRuns:view"},
{v1.FullSyncRunFailuresReq{}, "cpm:iot:fullSyncRuns:failures"},
{v1.FullSyncRunStartReq{}, "cpm:iot:fullSyncRuns:start"},
{v1.FullSyncChannelOptionsReq{}, "cpm:iot:fullSyncRuns:view"},
}
for _, check := range checks {
if got := gmeta.Get(check.request, "x-check-permission").String(); got != check.want {
t.Fatalf("%T permission = %q, want %q", check.request, got, check.want)
}
}
}
@@ -0,0 +1,20 @@
package router
import (
"strings"
"testing"
"github.com/gogf/gf/v2/util/gmeta"
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/api/iot/v1"
)
func TestFullSyncReplayPermissionDeclarations(t *testing.T) {
post := gmeta.Get(v1.FullSyncReplayReq{}, "x-check-permission").String()
get := gmeta.Get(v1.FullSyncReplayStatusReq{}, "x-check-permission").String()
if post != "cpm:iot:fullSyncRuns:replay" || get != "cpm:iot:fullSyncRuns:replay:view" {
t.Fatalf("permission metadata = %q, %q", post, get)
}
if strings.TrimSpace(post) == "" || strings.TrimSpace(get) == "" {
t.Fatal("missing permission")
}
}
+1 -1
View File
@@ -1,7 +1,7 @@
// package router
// @Link https://github.com/xiujiecn/xiu-admin
// @Copyright Copyright (c) 2025 LiXiujie
// @Author Lxj <li@xiujie.cn>
// @Author Lxj <xxx@example.com>
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
package router
+1 -1
View File
@@ -1,7 +1,7 @@
// package router
// @Link https://github.com/xiujiecn/xiu-admin
// @Copyright Copyright (c) 2025 LiXiujie
// @Author Lxj <li@xiujie.cn>
// @Author Lxj <xxx@example.com>
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
package router
+1 -1
View File
@@ -1,7 +1,7 @@
// package genrouter
// @Link https://github.com/xiujiecn/xiu-admin
// @Copyright Copyright (c) 2025 LiXiujie
// @Author Lxj <li@xiujie.cn>
// @Author Lxj <xxx@example.com>
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
package genrouter
@@ -1,7 +1,7 @@
// Package genrouter
// @Link https://github.com/xiujiecn/xiu-admin
// @Copyright Copyright (c) 2025 LiXiujie
// @Author Lxj <li@xiujie.cn>
// @Author Lxj <xxx@example.com>
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
// @AutoGenerate Version
package genrouter
+1 -1
View File
@@ -1,7 +1,7 @@
// package router
// @Link https://github.com/xiujiecn/xiu-admin
// @Copyright Copyright (c) 2025 LiXiujie
// @Author Lxj <li@xiujie.cn>
// @Author Lxj <xxx@example.com>
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
package router
@@ -0,0 +1,36 @@
package router
import (
"testing"
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/api/common/v1"
"github.com/gogf/gf/v2/util/gmeta"
)
// 右上角未读消息提醒依赖这三个接口,路径、方法或权限码被改动都会导致提醒静默失效。
// 权限码必须是 cpc:current:user:没有菜单权限的登录用户也要能获取自己的未读消息。
func TestMessageLogUnreadNotificationDeclarations(t *testing.T) {
cases := []struct {
name string
request interface{}
path string
method string
permission string
}{
{"unreadList", v1.TMessageLogUnreadListReq{}, "/tMessageLog/unreadList", "get", "cpc:current:user"},
{"read", v1.TMessageLogReadReq{}, "/tMessageLog/read", "post", "cpc:current:user"},
{"readAll", v1.TMessageLogReadAllReq{}, "/tMessageLog/readAll", "post", "cpc:current:user"},
}
for _, check := range cases {
if got := gmeta.Get(check.request, "path").String(); got != check.path {
t.Errorf("%s path = %q, want %q", check.name, got, check.path)
}
if got := gmeta.Get(check.request, "method").String(); got != check.method {
t.Errorf("%s method = %q, want %q", check.name, got, check.method)
}
if got := gmeta.Get(check.request, "x-check-permission").String(); got != check.permission {
t.Errorf("%s permission = %q, want %q", check.name, got, check.permission)
}
}
}
+1 -1
View File
@@ -1,7 +1,7 @@
// package router
// @Link https://github.com/xiujiecn/xiu-admin
// @Copyright Copyright (c) 2025 LiXiujie
// @Author Lxj <li@xiujie.cn>
// @Author Lxj <xxx@example.com>
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
package router
+14 -1
View File
@@ -1,23 +1,36 @@
// package router
// @Link https://github.com/xiujiecn/xiu-admin
// @Copyright Copyright (c) 2025 LiXiujie
// @Author Lxj <li@xiujie.cn>
// @Author Lxj <xxx@example.com>
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
package router
import (
"context"
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/service"
"net/http"
"os"
"path"
"path/filepath"
"regexp"
"strings"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/net/ghttp"
)
var legacyExportStaticPath = regexp.MustCompile(`(?i)^/(?:app/)?upload/(?:[^/]+/)?user/file/(?:[^/]+/)?export(?:/|$)`)
// InitRouter 初始化路由
func InitRouter(ctx context.Context, s *ghttp.Server) {
// Run before static serving as well as API routing; legacy export files must
// never bypass download-center authorization through the upload mount.
s.BindHookHandler("/*", ghttp.HookBeforeServe, func(r *ghttp.Request) {
if legacyExportStaticPath.MatchString(path.Clean(strings.ReplaceAll(r.URL.Path, `\`, "/"))) {
r.Response.WriteStatus(http.StatusNotFound)
r.ExitAll()
}
})
uploadPath := g.Cfg().MustGet(ctx, "system.upload.local.path").String()
if uploadPath != "" {
s.AddStaticPath("/upload", resolveUploadStaticPath(uploadPath))
+1 -1
View File
@@ -1,7 +1,7 @@
// package router
// @Link https://github.com/xiujiecn/xiu-admin
// @Copyright Copyright (c) 2025 LiXiujie
// @Author Lxj <li@xiujie.cn>
// @Author Lxj <xxx@example.com>
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
package router