feat: Go 重写后端,替换 Python FastAPI
用 Go (Gin + GORM + SQLite) 重写整个后端: - 单二进制部署,不依赖 Python/pip/SDK - net/http 原生客户端,无 Cloudflare TLS 指纹问题 - 多阶段 Dockerfile:Node 构建前端 + Go 构建后端 + Alpine 运行 - 内存占用从 ~95MB 降至 ~3MB - 完整保留所有 API 路由、JWT 认证、API Key 权限、审计日志
This commit is contained in:
44
handlers/transactions.go
Normal file
44
handlers/transactions.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"airwallex-admin/models"
|
||||
"airwallex-admin/services"
|
||||
)
|
||||
|
||||
func ListTransactions(c *gin.Context) {
|
||||
pageNum, _ := strconv.Atoi(c.DefaultQuery("page_num", "0"))
|
||||
pageSize, _ := strconv.Atoi(c.DefaultQuery("page_size", "20"))
|
||||
cardID := c.Query("card_id")
|
||||
fromCreatedAt := c.Query("from_created_at")
|
||||
toCreatedAt := c.Query("to_created_at")
|
||||
|
||||
result, err := services.ListTransactions(models.DB, pageNum, pageSize, cardID, fromCreatedAt, toCreatedAt)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"detail": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
func ListAuthorizations(c *gin.Context) {
|
||||
pageNum, _ := strconv.Atoi(c.DefaultQuery("page_num", "0"))
|
||||
pageSize, _ := strconv.Atoi(c.DefaultQuery("page_size", "20"))
|
||||
cardID := c.Query("card_id")
|
||||
status := c.Query("status")
|
||||
fromCreatedAt := c.Query("from_created_at")
|
||||
toCreatedAt := c.Query("to_created_at")
|
||||
|
||||
result, err := services.ListAuthorizations(models.DB, pageNum, pageSize, cardID, status, fromCreatedAt, toCreatedAt)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"detail": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, result)
|
||||
}
|
||||
Reference in New Issue
Block a user