feat(dependencies): 更新 go.mod 和 go.sum 文件,添加新依赖并优化现有依赖版本

在 go.mod 中添加了多个新依赖,包括用于微服务架构、数据库支持、缓存和消息队列的库。同时,更新了 go.sum 文件以反映这些更改。README.md 文件也进行了相应的更新,增加了微服务架构的描述和功能模块的详细信息,确保文档与代码保持一致。
This commit is contained in:
2025-09-27 00:41:27 +08:00
parent 25386cf0e1
commit 9f70704081
7 changed files with 549 additions and 48 deletions

View File

@@ -13,6 +13,7 @@ type Reply struct {
Result any `json:"result"`
}
// Success writes a normalized success payload with code=0.
func (reply *Reply) Success(ctx *gin.Context, data any) {
reply.Code = 0
reply.Result = data
@@ -22,6 +23,9 @@ func (reply *Reply) Success(ctx *gin.Context, data any) {
}
ctx.JSON(200, reply)
}
// Error converts an error (including gRPC status) to a normalized payload.
// Error converts an error (including gRPC status) to a normalized payload.
func (reply *Reply) Error(ctx *gin.Context, err error) {
reply.Code = 500
reply.Result = ""
@@ -29,8 +33,10 @@ func (reply *Reply) Error(ctx *gin.Context, err error) {
e, ok := status.FromError(err)
if ok {
reply.Code = int32(e.Code())
reply.Message = e.Message()
} else {
reply.Message = err.Error()
}
reply.Message = e.Message()
// Send error
ctx.JSON(200, reply)