12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- package v1
- import (
- "fmt"
- "git.getensh.com/common/gopkgs/logger"
- "git.getensh.com/common/gopkgs/tasker/httptasker"
- "git.getensh.com/common/gopkgs/util"
- "github.com/gin-gonic/gin"
- "go.uber.org/zap"
- "xingjia-official-gateway/errors"
- param_v1 "xingjia-official-gateway/param/v1"
- "xingjia-official-gateway/parser"
- )
- //
- // @Summary 获取文件
- // @Description 获取文件
- // @Tags download
- // @Accept json
- // @Produce json
- // @Param token header string true "jwt token"
- // @Param obj query string true " "
- // @Success 200 {object} v1.UploadResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/file [get]
- func (c Controller) DownLoad(ctx *gin.Context) {
- // 解析参数
- req := param_v1.DownLoadRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, nil, nil, &req.DownLoadQuery, nil)
- if err != nil {
- fmt.Printf("upload get file:%v\n", err)
- logger.Error("func",
- zap.String("call", "ctx.FormFile"),
- zap.String("error", err.Error()))
- return errors.SystemError
- }
- ctx.File(parser.Conf.ObjPath + req.Obj)
- return nil
- }
- httptasker.Exec(ctx, parseParamTask)
- }
|