实现 MinIO 对象存储图片流水线(可迁移 OSS)

- 新增 S3 兼容 Storage 抽象与 MinIO 实现,compose 启动 MinIO
- 上传接口:校验 → 缩放 → WebP → 主图/缩略图入库
- 消息图片 content 改为对象 URL,拒绝 base64
- 工作台/访客端改为先上传再发消息
This commit is contained in:
yml2213
2026-07-15 12:21:31 +08:00
parent 85b407fddf
commit ec2f12c6ed
20 changed files with 907 additions and 108 deletions
+10 -1
View File
@@ -2,10 +2,12 @@ package handler
import (
"github.com/gin-gonic/gin"
"kefu-sys/server/internal/config"
"kefu-sys/server/internal/middleware"
"kefu-sys/server/internal/storage"
)
func SetupRoutes(r *gin.Engine) {
func SetupRoutes(r *gin.Engine, store storage.ObjectStorage, storageCfg config.StorageConfig) {
auth := NewAuthHandler()
session := NewSessionHandler()
customer := NewCustomerHandler()
@@ -16,6 +18,9 @@ func SetupRoutes(r *gin.Engine) {
settings := NewSettingsHandler()
ws := NewWsHandler()
widget := NewWidgetHandler()
upload := NewUploadHandler(store, storageCfg)
SetImagePublicBase(storageCfg.PublicBase)
api := r.Group("/api")
@@ -31,6 +36,7 @@ func SetupRoutes(r *gin.Engine) {
widgetApi.GET("/messages", widget.GetMessages)
widgetApi.GET("/ws", widget.Connect)
widgetApi.POST("/rating", widget.SubmitRating)
widgetApi.POST("/upload", upload.WidgetUploadImage)
// 需要认证的接口
authRequired := api.Group("")
@@ -39,6 +45,9 @@ func SetupRoutes(r *gin.Engine) {
// WebSocket
authRequired.GET("/ws", ws.Connect)
// 上传
authRequired.POST("/uploads", upload.UploadImage)
// 会话管理
authRequired.GET("/agents/available", session.ListAvailableAgents)
sessions := authRequired.Group("/sessions")