功能特性: - 用户端充值记录页面,从使用日志中分离 - 充值记录中的去开发票功能 - 管理员发票管理页面 - 发票申请、处理、邮件通知功能 - 侧边栏菜单更新 - UI优化和控制台清理 - Docker部署配置 - 生产环境安全配置
30 lines
736 B
Go
30 lines
736 B
Go
package middleware
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/gin-gonic/gin"
|
|
"one-api/common"
|
|
)
|
|
|
|
func abortWithOpenAiMessage(c *gin.Context, statusCode int, message string) {
|
|
userId := c.GetInt("id")
|
|
c.JSON(statusCode, gin.H{
|
|
"error": gin.H{
|
|
"message": common.MessageWithRequestId(message, c.GetString(common.RequestIdKey)),
|
|
"type": "new_api_error",
|
|
},
|
|
})
|
|
c.Abort()
|
|
common.LogError(c.Request.Context(), fmt.Sprintf("user %d | %s", userId, message))
|
|
}
|
|
|
|
func abortWithMidjourneyMessage(c *gin.Context, statusCode int, code int, description string) {
|
|
c.JSON(statusCode, gin.H{
|
|
"description": description,
|
|
"type": "new_api_error",
|
|
"code": code,
|
|
})
|
|
c.Abort()
|
|
common.LogError(c.Request.Context(), description)
|
|
}
|