From 0357b137bc56c5c7c33a2e17c11ff1e2e8bc199f Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Mon, 4 Dec 2023 18:34:37 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=AC=E5=AD=98=E6=8C=87=E5=AE=9A=E5=AF=B9?= =?UTF-8?q?=E5=BA=94=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/common/controller/common.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/modules/common/controller/common.go b/src/modules/common/controller/common.go index c7329cfa..a47d295d 100644 --- a/src/modules/common/controller/common.go +++ b/src/modules/common/controller/common.go @@ -77,13 +77,14 @@ func (s *CommontController) SysConfig(c *gin.Context) { c.JSON(200, result.OkData(data)) } -// 转存帮助文档 +// 转存指定对应文件 // -// POST /helpDoc -func (s *CommontController) HelpDoc(c *gin.Context) { +// POST /transferStaticFile +func (s *CommontController) TransferStaticFile(c *gin.Context) { language := ctx.AcceptLanguage(c) var body struct { UploadPath string `json:"uploadPath" binding:"required"` + StaticPath string `json:"staticPath" binding:"required"` Language string `json:"language" binding:"required"` } if err := c.ShouldBindBodyWith(&body, binding.JSON); err != nil { @@ -102,8 +103,9 @@ func (s *CommontController) HelpDoc(c *gin.Context) { return } - newFile := fmt.Sprintf("%s/helpDoc/%s_doc.pdf", dir, lang) - fmt.Println(newFile) + delPrefix := strings.Replace(body.StaticPath, static["prefix"].(string), "", 1) + staticPath := strings.Replace(delPrefix, "{language}", lang, 1) + newFile := fmt.Sprintf("%s%s", dir, staticPath) err = file.CopyUploadFile(body.UploadPath, newFile) if err != nil {