Merge branch 'develop' of gitee.com:hezhaohui123/gen2d into feat/AssertGeneration

Signed-off-by: 何朝晖 <hezhaohui0807@163.com>
This commit is contained in:
2026-05-25 05:29:13 +00:00
committed by Gitee
16 changed files with 441 additions and 155 deletions
+35
View File
@@ -0,0 +1,35 @@
package handler
import (
"net/http"
"gen2d/internal/model"
"gen2d/internal/service"
"github.com/gin-gonic/gin"
)
var storageSvc *service.StorageService
// InitStorageService 由 main 在启动时调用,注入七牛云存储服务。
func InitStorageService(svc *service.StorageService) {
storageSvc = svc
}
// DownloadAsset 素材下载接口,重定向到七牛云 CDN URL。
// GET /api/v1/assets/download?key=...
func DownloadAsset(c *gin.Context) {
key := c.Query("key")
if key == "" {
c.JSON(http.StatusBadRequest, model.Fail(http.StatusBadRequest, "缺少 key 参数"))
return
}
downloadURL, err := storageSvc.GetDownloadURL(c.Request.Context(), key)
if err != nil {
c.JSON(http.StatusInternalServerError, model.Fail(http.StatusInternalServerError, "生成下载链接失败"))
return
}
c.Redirect(http.StatusFound, downloadURL)
}