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 {