This commit is contained in:
2026-08-15 01:28:51 +08:00
parent 6698e59c3a
commit 2f165d3a45
26 changed files with 242 additions and 216 deletions
+7 -7
View File
@@ -16,12 +16,12 @@ import (
)
type Export struct {
system *service.SystemService
service *service.ExportService
settings *service.SettingsService
service *service.ExportService
}
func NewExport(system *service.SystemService, service *service.ExportService) *Export {
return &Export{system: system, service: service}
func NewExport(settings *service.SettingsService, export *service.ExportService) *Export {
return &Export{settings: settings, service: export}
}
type exportToken struct {
@@ -153,7 +153,7 @@ func (h *Export) Issue(blank bool) gin.HandlerFunc {
}
token := strings.ReplaceAll(uuid.NewString(), "-", "")
raw, _ := json.Marshal(exportToken{TemplateID: templateID, Params: exportParams(c.Request.URL.Query()), Blank: blank})
if err := h.system.CacheSet(c.Request.Context(), "export:"+token, string(raw), 30*time.Minute); err != nil {
if err := h.settings.CacheSet(c.Request.Context(), "export:"+token, string(raw), 30*time.Minute); err != nil {
httpx.Fail(c, "导出令牌创建失败")
return
}
@@ -196,7 +196,7 @@ func (h *Export) Download(expectBlank bool) gin.HandlerFunc {
httpx.Fail(c, "导出token不能为空")
return
}
raw, ok, err := h.system.CacheGet(c.Request.Context(), "export:"+token)
raw, ok, err := h.settings.CacheGet(c.Request.Context(), "export:"+token)
if err != nil || !ok {
httpx.Fail(c, "导出token无效或已过期")
return
@@ -210,7 +210,7 @@ func (h *Export) Download(expectBlank bool) gin.HandlerFunc {
httpx.Fail(c, "token类型错误")
return
}
_ = h.system.CacheDelete(c.Request.Context(), "export:"+token)
_ = h.settings.CacheDelete(c.Request.Context(), "export:"+token)
var data []byte
var name string
if expectBlank {