diff --git a/app/app.go b/app/app.go index 35fe029..a813177 100644 --- a/app/app.go +++ b/app/app.go @@ -6,7 +6,7 @@ import ( "git.hlsq.asia/mmorpg/service-common/log" "git.hlsq.asia/mmorpg/service-common/module" "git.hlsq.asia/mmorpg/service-user/config" - "git.hlsq.asia/mmorpg/service-user/internal/grpc_server" + "git.hlsq.asia/mmorpg/service-user/internal/grpcserver" "github.com/judwhite/go-svc" "sync" ) @@ -19,7 +19,7 @@ func (p *Program) Init(_ svc.Environment) error { p.moduleList = append(p.moduleList, &module.Log{Cfg: config.Get().Log}) p.moduleList = append(p.moduleList, &module.DB{Cfg: config.Get().DB, AppName: config.Get().App.Name}) p.moduleList = append(p.moduleList, &module.Snowflake{}) - p.moduleList = append(p.moduleList, &module.Grpc{Server: grpc_server.NewServer(config.Get().Serve.Grpc)}) + p.moduleList = append(p.moduleList, &module.Grpc{Server: grpcserver.NewServer(config.Get().Serve.Grpc)}) p.moduleList = append(p.moduleList, &module.Prometheus{Cfg: config.Get().Metric}) p.moduleList = append(p.moduleList, &module.Tracer{Cfg: config.Get().Metric, ServiceName: common.KeyDiscoverServiceNameUser}) p.moduleList = append(p.moduleList, &module.Discover{}) diff --git a/go.mod b/go.mod index fa888a9..6a79cef 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module git.hlsq.asia/mmorpg/service-user go 1.24.0 require ( - git.hlsq.asia/mmorpg/service-common v0.0.0-20260207051302-0ca8a0ccbb14 + git.hlsq.asia/mmorpg/service-common v0.0.0-20260211064821-558677bc3a2e github.com/judwhite/go-svc v1.2.1 google.golang.org/grpc v1.77.0 gorm.io/gen v0.3.27 diff --git a/go.sum b/go.sum index 0813e47..a61c2a2 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= -git.hlsq.asia/mmorpg/service-common v0.0.0-20260207051302-0ca8a0ccbb14 h1:4r3tNWRzGVY3Xx6UiGjJJnwoMoWlVqbyGrljxl5d/nQ= -git.hlsq.asia/mmorpg/service-common v0.0.0-20260207051302-0ca8a0ccbb14/go.mod h1:mMhZcumphj6gaVTppVYsMTkd+5HupmQgAc53Pd4MH9I= +git.hlsq.asia/mmorpg/service-common v0.0.0-20260211064821-558677bc3a2e h1:MNVS1NXNVn4DeTZPcvvA8YFM8afCzZedLPUYMffNgZs= +git.hlsq.asia/mmorpg/service-common v0.0.0-20260211064821-558677bc3a2e/go.mod h1:mMhZcumphj6gaVTppVYsMTkd+5HupmQgAc53Pd4MH9I= github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0= github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/IBM/sarama v1.46.3 h1:njRsX6jNlnR+ClJ8XmkO+CM4unbrNr/2vB5KK6UA+IE= diff --git a/internal/grpc_server/server.go b/internal/grpcserver/server.go similarity index 73% rename from internal/grpc_server/server.go rename to internal/grpcserver/server.go index 6bcd7ac..0bb52c6 100644 --- a/internal/grpc_server/server.go +++ b/internal/grpcserver/server.go @@ -1,12 +1,12 @@ -package grpc_server +package grpcserver import ( "context" "errors" "fmt" "git.hlsq.asia/mmorpg/service-common/db/redis" - "git.hlsq.asia/mmorpg/service-common/net/http/http_resp" - "git.hlsq.asia/mmorpg/service-common/proto/rs/grpc_pb" + "git.hlsq.asia/mmorpg/service-common/net/http/httpresp" + "git.hlsq.asia/mmorpg/service-common/proto/rs/rspb" "git.hlsq.asia/mmorpg/service-common/utils" "git.hlsq.asia/mmorpg/service-user/internal/dao/model" "git.hlsq.asia/mmorpg/service-user/internal/dao/repository" @@ -14,7 +14,7 @@ import ( "gorm.io/gorm" ) -func (s *Server) PhoneLogin(ctx context.Context, req *grpc_pb.PhoneLoginReq) (*grpc_pb.PhoneLoginResp, error) { +func (s *Server) PhoneLogin(ctx context.Context, req *rspb.PhoneLoginReq) (*rspb.PhoneLoginResp, error) { userDao := repository.NewUserDao(ctx, s.query, redis.GetCacheClient()) user, err := userDao.FindByPhone(req.Phone) if err != nil { @@ -31,13 +31,13 @@ func (s *Server) PhoneLogin(ctx context.Context, req *grpc_pb.PhoneLoginReq) (*g } } - return &grpc_pb.PhoneLoginResp{ + return &rspb.PhoneLoginResp{ USN: user.Sn, Name: user.Name, }, nil } -func (s *Server) WxMiniLogin(ctx context.Context, req *grpc_pb.WxMiniLoginReq) (*grpc_pb.WxMiniLoginResp, error) { +func (s *Server) WxMiniLogin(ctx context.Context, req *rspb.WxMiniLoginReq) (*rspb.WxMiniLoginResp, error) { session, err := wechat.MiniCode2Session(req.Code) if err != nil { return nil, utils.ErrorsWrap(err) @@ -59,15 +59,15 @@ func (s *Server) WxMiniLogin(ctx context.Context, req *grpc_pb.WxMiniLoginReq) ( } } - return &grpc_pb.WxMiniLoginResp{ + return &rspb.WxMiniLoginResp{ USN: user.Sn, Name: user.Name, }, nil } -func (s *Server) GetUserInfo(ctx context.Context, req *grpc_pb.GetUserInfoReq) (*grpc_pb.GetUserInfoResp, error) { +func (s *Server) GetUserInfo(ctx context.Context, req *rspb.GetUserInfoReq) (*rspb.GetUserInfoResp, error) { if !utils.ShouldBindUsn(ctx, &req.USN) { - return nil, utils.ErrorsWrap(http_resp.ParamError) + return nil, utils.ErrorsWrap(httpresp.ParamError) } userDao := repository.NewUserDao(ctx, s.query, redis.GetCacheClient()) user, err := userDao.FindBySn(req.USN) @@ -75,7 +75,7 @@ func (s *Server) GetUserInfo(ctx context.Context, req *grpc_pb.GetUserInfoReq) ( return nil, utils.ErrorsWrap(err) } - return &grpc_pb.GetUserInfoResp{ + return &rspb.GetUserInfoResp{ USN: user.Sn, Name: user.Name, }, nil diff --git a/internal/grpc_server/server_init.go b/internal/grpcserver/server_init.go similarity index 85% rename from internal/grpc_server/server_init.go rename to internal/grpcserver/server_init.go index faebdf3..97c040b 100644 --- a/internal/grpc_server/server_init.go +++ b/internal/grpcserver/server_init.go @@ -1,17 +1,17 @@ -package grpc_server +package grpcserver import ( "git.hlsq.asia/mmorpg/service-common/config" "git.hlsq.asia/mmorpg/service-common/discover/common" "git.hlsq.asia/mmorpg/service-common/net/grpc/service" - "git.hlsq.asia/mmorpg/service-common/proto/rs/grpc_pb" + "git.hlsq.asia/mmorpg/service-common/proto/rs/rspb" "git.hlsq.asia/mmorpg/service-user/internal/dao/query" "git.hlsq.asia/mmorpg/service-user/internal/dao/repository" "google.golang.org/grpc" ) type Server struct { - grpc_pb.UnimplementedUserServer + rspb.UnimplementedUserServer service.Base query *query.Query } @@ -35,7 +35,7 @@ func (s *Server) OnCustomGrpcServerOption() []grpc.ServerOption { } func (s *Server) OnInit(serve *grpc.Server) { - grpc_pb.RegisterUserServer(serve, s) + rspb.RegisterUserServer(serve, s) s.query = repository.Query() }