feat(points): 支持后台上传积分商品图片

This commit is contained in:
yml2213
2026-11-04 19:28:40 +08:00
parent 27c66548a2
commit 46c682cb78
3 changed files with 112 additions and 4 deletions
+4 -2
View File
@@ -109,7 +109,7 @@ func normalizeContentType(contentType string, data []byte) string {
func fileURLForScene(scene string, key string) string {
fileURL := "/api/files/object?key=" + url.QueryEscape(key)
if scene == "home-banner" || scene == "avatar" || scene == "announcement" || scene == "mohong" || scene == "crash" || scene == "aw-recycle" || scene == "cooperation-feedback" || scene == "support-qrcode" {
if scene == "home-banner" || scene == "avatar" || scene == "announcement" || scene == "mohong" || scene == "crash" || scene == "aw-recycle" || scene == "cooperation-feedback" || scene == "support-qrcode" || scene == "points-mall" {
fileURL = "/api/public/files/object?key=" + url.QueryEscape(key)
}
return fileURL
@@ -118,12 +118,14 @@ func fileURLForScene(scene string, key string) string {
func normalizeScene(scene string) string {
scene = strings.TrimSpace(strings.ToLower(scene))
switch scene {
case "listing", "handoff", "dispute", "realname", "avatar", "home-banner", "chat", "payment-cert", "announcement", "qrcode", "support-qrcode", "mohong", "crash", "aw-recycle", "cooperation-feedback", "manual-disbursement", "operating-expense":
case "listing", "handoff", "dispute", "realname", "avatar", "home-banner", "chat", "payment-cert", "announcement", "qrcode", "support-qrcode", "mohong", "crash", "aw-recycle", "cooperation-feedback", "manual-disbursement", "operating-expense", "points-mall":
return scene
case "listing_screenshot", "listing-screenshot":
return "listing"
case "operating_expense":
return "operating-expense"
case "points_mall":
return "points-mall"
default:
return "misc"
}
@@ -87,6 +87,16 @@ func TestSupportQrcodeSceneUsesPublicFileURL(t *testing.T) {
}
}
func TestPointsMallSceneUsesPublicFileURL(t *testing.T) {
if got := normalizeScene("points_mall"); got != "points-mall" {
t.Fatalf("normalize points_mall scene = %q, want points-mall", got)
}
got := fileURLForScene("points-mall", "points-mall/2026/11/04/example.webp")
if !strings.HasPrefix(got, "/api/public/files/object?") {
t.Fatalf("points-mall file url = %q, want public file endpoint", got)
}
}
func TestNormalizeSceneListingScreenshotAndOperatingExpense(t *testing.T) {
if got := normalizeScene("listing_screenshot"); got != "listing" {
t.Fatalf("normalize listing_screenshot scene = %q, want listing", got)