Files
gozerosandCursor bd427b57a1 feat: 换到 Gin 主流栈并补齐运维能力
HTTP 用 Gin,配置用 Viper,日志用 zap,数据用 sqlx;保留原有接口与会商行为。
顺带补上就绪探活、请求号、滚动日志、systemd 与 Dockerfile。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-04 09:51:41 +08:00

29 lines
750 B
Go

package api
import (
"net/http"
"github.com/gin-gonic/gin"
)
// ApiResponse 与 Java 一致:{ code, message, data };成功 code=0。
//
// 探活 /health、/ready 不走这个外壳,编排系统要直接读 ok 字段。
type ApiResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data"`
}
func OK(c *gin.Context, data interface{}) {
c.JSON(http.StatusOK, ApiResponse{Code: 0, Message: "ok", Data: data})
}
func Created(c *gin.Context, data interface{}) {
c.JSON(http.StatusCreated, ApiResponse{Code: 0, Message: "ok", Data: data})
}
func Fail(c *gin.Context, httpStatus, code int, msg string) {
c.JSON(httpStatus, ApiResponse{Code: code, Message: msg, Data: nil})
}