Files
admin a950fd2ead
Docker Build (Gitea) / Build and Push Docker Image (push) Successful in 47s
rebrand: BEpusdt → VUPAY
展示层与标识符全量改名:
- module github.com/v03413/bepusdt → git.viaeon.com/admin/vupay(含全部 import)
- 二进制/镜像/容器/DB 名 bepusdt → vupay(Dockerfile、workflow IMAGE、compose、docs)
- 显示名 BEpusdt → VUPAY(前端 title、后端 banner、version 命令、通知文案)
- 默认路径 /var/lib/bepusdt → /var/lib/vupay,/var/log/bepusdt → /var/log/vupay
- Telegram 通知的频道按钮原来指向上游 t.me 群,改成站点链接(否则改名后是死链)

刻意保留(运行语义,改了会坏):
- api_type 取值 "epusdt" / "epusdt_order"(库里存量数据按此匹配)
- 表前缀 bep_(bep_order / bep_conf / …,改需 RENAME TABLE 迁移)
- 签名函数 EpusdtSign 与 handler 包名 epusdt(对外协议语义,非品牌)
- 所有加密/会话派生的字面量原样不动

验证:gofmt 通过、go build ./... 通过、全仓 grep -i bepusdt 归零
2026-11-25 09:06:06 +08:00

111 lines
1.9 KiB
Go

package base
import (
"fmt"
"git.viaeon.com/admin/vupay/app/log"
"github.com/gin-gonic/gin"
)
type Result struct {
Code int `json:"code,omitempty"` // 状态码
Msg string `json:"msg,omitempty"` // 状态消息
Total int64 `json:"total,omitempty"` // 总条数
Data interface{} `json:"data,omitempty"` // 数据
}
func Typer(i any) string {
var t string
switch i.(type) {
case string:
t = "string"
case int:
t = "int"
case int8:
t = "int8"
case int16:
t = "int16"
case int32:
t = "int32"
case int64:
t = "int64"
case uint:
t = "uint"
case uint8:
t = "uint8"
case uint16:
t = "uint16"
case uint32:
t = "uint32"
case uint64:
t = "uint64"
case map[string]string:
t = "map[string]string"
case map[int]string:
t = "map[int]string"
case map[string]int:
t = "map[string]int"
case map[int]int:
t = "map[int]int"
case []string:
t = "[]string"
case []int:
t = "[]int"
case [1]string:
t = "array [1] string"
case [2]string:
t = "array [1] string"
case [1]int:
t = "array [1] int"
case [2]int:
t = "array [2] int"
default:
t = "unknow"
}
return t
}
func Response(ctx *gin.Context, code int, data ...any) {
var d = Result{Code: code}
if len(data) > 0 {
if Typer(data[0]) == "string" {
d.Msg = data[0].(string)
} else {
d.Data = data[0]
}
if len(data) == 2 {
d.Total = data[1].(int64)
}
}
if code >= 500 && code <= 599 {
if len(data) > 0 {
err, ok := data[0].(error)
if ok {
log.Error(err.Error())
} else {
log.Error(fmt.Sprintf("%v", data[0]))
}
}
d.Msg = "服务器错误"
}
ctx.JSON(200, d)
}
func Ok(ctx *gin.Context, data ...any) {
Response(ctx, 200, data...)
}
// Error 500 服务器错误
func Error(ctx *gin.Context, err error) {
Response(ctx, 500, err)
}
// BadRequest 400 请求错误
func BadRequest(ctx *gin.Context, err string) {
Response(ctx, 400, err)
}