feat(lyra): 搭建基础骨架与配置响应组件

- 使用 Viper 加载 TOML 配置
- 定义统一响应、业务错误码及响应辅助函数
- 添加分层职责约束并同步架构文档
This commit is contained in:
2026-10-16 23:36:34 +08:00
parent e4fc4af912
commit 8b320817ed
19 changed files with 418 additions and 22 deletions
@@ -0,0 +1,27 @@
package httpx
import (
"lyra/internal/api"
"net/http"
"github.com/gin-gonic/gin"
)
// OK 成功响应
func OK(c *gin.Context, data any) {
c.JSON(http.StatusOK, api.Response{
Success: true,
Data: data,
})
}
// Fail 错误响应
func Fail(c *gin.Context, status int, code api.ErrorCode, message string) {
if message == "" {
message = code.Message()
}
c.JSON(status, api.Response{
Success: false,
Error: &api.ErrorInfo{Code: code, Message: message},
})
}