From 1c90e21050faf36ab2089c0acb866bf680ad42ad Mon Sep 17 00:00:00 2001 From: "DESKTOP-V763RJ7\\Administrator" <835606593@qq.com> Date: Wed, 14 Jan 2026 14:21:41 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E9=94=99=E8=AF=AF=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- net/grpc/grpc_conn/conn.go | 1 - net/grpc/resolver/conn.go | 1 - net/http/http_resp/code.go | 18 ++++++++++-------- net/http/http_resp/response.go | 8 ++++---- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/net/grpc/grpc_conn/conn.go b/net/grpc/grpc_conn/conn.go index 471957c..4ccf0f8 100644 --- a/net/grpc/grpc_conn/conn.go +++ b/net/grpc/grpc_conn/conn.go @@ -27,7 +27,6 @@ func NewGrpcConnection(sid string, address string) (*GrpcConnection, error) { PermitWithoutStream: true, }, ), - //grpc.WithStatsHandler(&StatsHandler{}), ) if err != nil { log.Errorf("create grpc err: %v, sid: %v, addr: %v", err, sid, address) diff --git a/net/grpc/resolver/conn.go b/net/grpc/resolver/conn.go index 8954899..c05a7c3 100644 --- a/net/grpc/resolver/conn.go +++ b/net/grpc/resolver/conn.go @@ -20,7 +20,6 @@ func NewGrpcConnection(target string) (*grpc.ClientConn, error) { PermitWithoutStream: true, }, ), - //grpc.WithStatsHandler(&StatsHandler{}), ) if err != nil { log.Errorf("create grpc err: %v, target: %v", err, target) diff --git a/net/http/http_resp/code.go b/net/http/http_resp/code.go index b697a9e..a050094 100644 --- a/net/http/http_resp/code.go +++ b/net/http/http_resp/code.go @@ -7,14 +7,16 @@ import ( ) var ( - OK = NewCode(0, "OK") - Failed = NewCode(1, "Failed") - TokenInvalid = NewCode(2, "Token无效") - ParamError = NewCode(1001, "参数错误") - NameEmpty = NewCode(1002, "名称不能为空") - NameDuplicate = NewCode(1003, "名称或编号不能重复") - ListEmpty = NewCode(1004, "列表不能为空") - RepeatCommit = NewCode(1005, "请勿重复提交") + OK = NewCode(0, "OK") + Failed = NewCode(1, "Failed") + TokenInvalid = NewCode(2, "Token Invalid") + MethodNotAllowed = NewCode(3, "Method Not Allowed") + NotFound = NewCode(4, "Not Found") + ParamError = NewCode(1001, "参数错误") + NameEmpty = NewCode(1002, "名称不能为空") + NameDuplicate = NewCode(1003, "名称或编号不能重复") + ListEmpty = NewCode(1004, "列表不能为空") + RepeatCommit = NewCode(1005, "请勿重复提交") ) type Code struct { diff --git a/net/http/http_resp/response.go b/net/http/http_resp/response.go index 25d5995..9dad6f6 100644 --- a/net/http/http_resp/response.go +++ b/net/http/http_resp/response.go @@ -35,13 +35,13 @@ func JsonBadRequest(c *gin.Context) { } func JsonMethodNotAllowed(c *gin.Context) { - c.JSON(http.StatusMethodNotAllowed, Error(NewCode(Failed.Code(), "Method Not Allowed"))) + c.JSON(http.StatusMethodNotAllowed, Error(MethodNotAllowed)) } func JsonNotFound(c *gin.Context) { - c.JSON(http.StatusNotFound, Error(NewCode(Failed.Code(), "Endpoint Not Found"))) + c.JSON(http.StatusNotFound, Error(NotFound)) } -func AbortUnauthorized(c *gin.Context) { - c.AbortWithStatusJSON(http.StatusUnauthorized, Error(NewCode(Failed.Code(), "Invalid Authorization"))) +func JsonUnauthorized(c *gin.Context) { + c.JSON(http.StatusUnauthorized, Error(TokenInvalid)) }