// Code scaffolded by goctl. Safe to edit.
// goctl 1.10.1

package file

import (
	"net/http"

	"github.com/zeromicro/go-zero/rest/httpx"
	"sundynix-micro-go/app/file/api/internal/logic/file"
	"sundynix-micro-go/app/file/api/internal/svc"
	"sundynix-micro-go/app/file/api/internal/types"
)

// 下载文件
func DownloadFileHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		var req types.FileIdReq
		if err := httpx.Parse(r, &req); err != nil {
			httpx.ErrorCtx(r.Context(), w, err)
			return
		}

		l := file.NewDownloadFileLogic(r.Context(), svcCtx)
		err := l.DownloadFile(w, &req)
		if err != nil {
			httpx.ErrorCtx(r.Context(), w, err)
		}
	}
}
