|
|
@@ -0,0 +1,34 @@
|
|
|
+package task
|
|
|
+
|
|
|
+import (
|
|
|
+ "github.com/gin-gonic/gin"
|
|
|
+ "go.uber.org/zap"
|
|
|
+ "log-server/global"
|
|
|
+ "log-server/model/common/response"
|
|
|
+ taskRes "log-server/model/task/response"
|
|
|
+ "strconv"
|
|
|
+)
|
|
|
+
|
|
|
+type UploadFileApi struct {
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+func (b *UploadFileApi) UploadFile(c *gin.Context) {
|
|
|
+
|
|
|
+ _, header, err := c.Request.FormFile("file")
|
|
|
+ if err != nil {
|
|
|
+ global.GVA_LOG.Error("接收文件失败!", zap.Error(err))
|
|
|
+ response.FailWithMessage("接收文件失败", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ gameID := c.PostForm("game_id")
|
|
|
+ var fileRes taskRes.UploadFileResponse
|
|
|
+ gameId, _ := strconv.Atoi(gameID)
|
|
|
+ fileRes, err = uploadFileService.UploadFile(gameId, header) // 文件上传后拿到文件路径
|
|
|
+ if err != nil {
|
|
|
+ global.GVA_LOG.Error("修改数据库链接失败!", zap.Error(err))
|
|
|
+ response.FailWithMessage("修改数据库链接失败", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ response.OkWithDetailed(taskRes.InfoResponse{fileRes}, "上传成功", c)
|
|
|
+}
|