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
+24 -4
View File
@@ -1,7 +1,7 @@
// package system
// @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 system
@@ -9,6 +9,7 @@ import (
"context"
"errors"
"fmt"
"io"
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/consts"
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/dao"
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/library/contexts"
@@ -19,7 +20,6 @@ import (
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/service"
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/utility/hash"
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/utility/uuid32"
"io"
"net/http"
"os"
"path/filepath"
@@ -56,7 +56,10 @@ func (s *sSysOss) Model(ctx context.Context, option ...*handler.Option) *gdb.Mod
FilterAuth: true,
})
}
return handler.Model(dao.SysOss.Ctx(ctx), option...)
return handler.Model(dao.SysOss.Ctx(ctx), option...).
WhereNotIn(dao.SysOss.Columns().OssId, dao.TExportTask.Ctx(ctx).Fields(dao.TExportTask.Columns().OssId).WhereGT(dao.TExportTask.Columns().OssId, 0)).
Where("LOWER(REPLACE(COALESCE(path, ''), CHAR(92), '/')) NOT REGEXP ?", `(^|/)private-export(/|$)|(^|/)user/file/([^/]+/)?export(/|$)`).
Where("LOWER(REPLACE(COALESCE(url, ''), CHAR(92), '/')) NOT REGEXP ?", `(^|/)private-export(/|$)|(^|/)user/file/([^/]+/)?export(/|$)`)
}
func (s *sSysOss) List(ctx context.Context, param *model.SysOssListParam, pageInfo *request.PageInfo) (items []*model.SysOssListModel, total int, err error) {
@@ -683,7 +686,7 @@ func joinUploadURL(base string, suffix string) string {
return base + "/" + suffix
}
func (s *sSysOss) DownloadLocal(ctx context.Context, file *entity.SysOss) (err error) {
func (s *sSysOss) DownloadLocal(ctx context.Context, file *entity.SysOss, beforeSend ...func() error) (err error) {
if file == nil {
err = errors.New("文件必须")
return
@@ -697,6 +700,23 @@ func (s *sSysOss) DownloadLocal(ctx context.Context, file *entity.SysOss) (err e
err = gerror.New("ctx not http request")
return
}
localFile, err := os.Open(finalPath)
if err != nil {
return gerror.Wrap(err, "本地文件不可读")
}
defer localFile.Close()
info, err := localFile.Stat()
if err != nil {
return gerror.Wrap(err, "获取本地文件信息失败")
}
if !info.Mode().IsRegular() {
return gerror.New("本地文件不是普通文件")
}
for _, callback := range beforeSend {
if err = callback(); err != nil {
return err
}
}
r.Response.ServeFileDownload(finalPath)
r.Response.Status = http.StatusOK
r.Response.Flush()