feat 包命名规范
This commit is contained in:
@@ -6,7 +6,7 @@ import (
|
|||||||
"git.hlsq.asia/mmorpg/service-common/log"
|
"git.hlsq.asia/mmorpg/service-common/log"
|
||||||
"git.hlsq.asia/mmorpg/service-common/module"
|
"git.hlsq.asia/mmorpg/service-common/module"
|
||||||
"git.hlsq.asia/mmorpg/service-user/config"
|
"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"
|
"github.com/judwhite/go-svc"
|
||||||
"sync"
|
"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.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.DB{Cfg: config.Get().DB, AppName: config.Get().App.Name})
|
||||||
p.moduleList = append(p.moduleList, &module.Snowflake{})
|
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.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.Tracer{Cfg: config.Get().Metric, ServiceName: common.KeyDiscoverServiceNameUser})
|
||||||
p.moduleList = append(p.moduleList, &module.Discover{})
|
p.moduleList = append(p.moduleList, &module.Discover{})
|
||||||
|
|||||||
2
go.mod
2
go.mod
@@ -3,7 +3,7 @@ module git.hlsq.asia/mmorpg/service-user
|
|||||||
go 1.24.0
|
go 1.24.0
|
||||||
|
|
||||||
require (
|
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
|
github.com/judwhite/go-svc v1.2.1
|
||||||
google.golang.org/grpc v1.77.0
|
google.golang.org/grpc v1.77.0
|
||||||
gorm.io/gen v0.3.27
|
gorm.io/gen v0.3.27
|
||||||
|
|||||||
4
go.sum
4
go.sum
@@ -1,7 +1,7 @@
|
|||||||
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
||||||
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
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-20260211064821-558677bc3a2e h1:MNVS1NXNVn4DeTZPcvvA8YFM8afCzZedLPUYMffNgZs=
|
||||||
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/go.mod h1:mMhZcumphj6gaVTppVYsMTkd+5HupmQgAc53Pd4MH9I=
|
||||||
github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0=
|
github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0=
|
||||||
github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||||
github.com/IBM/sarama v1.46.3 h1:njRsX6jNlnR+ClJ8XmkO+CM4unbrNr/2vB5KK6UA+IE=
|
github.com/IBM/sarama v1.46.3 h1:njRsX6jNlnR+ClJ8XmkO+CM4unbrNr/2vB5KK6UA+IE=
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package grpc_server
|
package grpcserver
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.hlsq.asia/mmorpg/service-common/db/redis"
|
"git.hlsq.asia/mmorpg/service-common/db/redis"
|
||||||
"git.hlsq.asia/mmorpg/service-common/net/http/http_resp"
|
"git.hlsq.asia/mmorpg/service-common/net/http/httpresp"
|
||||||
"git.hlsq.asia/mmorpg/service-common/proto/rs/grpc_pb"
|
"git.hlsq.asia/mmorpg/service-common/proto/rs/rspb"
|
||||||
"git.hlsq.asia/mmorpg/service-common/utils"
|
"git.hlsq.asia/mmorpg/service-common/utils"
|
||||||
"git.hlsq.asia/mmorpg/service-user/internal/dao/model"
|
"git.hlsq.asia/mmorpg/service-user/internal/dao/model"
|
||||||
"git.hlsq.asia/mmorpg/service-user/internal/dao/repository"
|
"git.hlsq.asia/mmorpg/service-user/internal/dao/repository"
|
||||||
@@ -14,7 +14,7 @@ import (
|
|||||||
"gorm.io/gorm"
|
"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())
|
userDao := repository.NewUserDao(ctx, s.query, redis.GetCacheClient())
|
||||||
user, err := userDao.FindByPhone(req.Phone)
|
user, err := userDao.FindByPhone(req.Phone)
|
||||||
if err != nil {
|
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,
|
USN: user.Sn,
|
||||||
Name: user.Name,
|
Name: user.Name,
|
||||||
}, nil
|
}, 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)
|
session, err := wechat.MiniCode2Session(req.Code)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, utils.ErrorsWrap(err)
|
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,
|
USN: user.Sn,
|
||||||
Name: user.Name,
|
Name: user.Name,
|
||||||
}, nil
|
}, 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) {
|
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())
|
userDao := repository.NewUserDao(ctx, s.query, redis.GetCacheClient())
|
||||||
user, err := userDao.FindBySn(req.USN)
|
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 nil, utils.ErrorsWrap(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &grpc_pb.GetUserInfoResp{
|
return &rspb.GetUserInfoResp{
|
||||||
USN: user.Sn,
|
USN: user.Sn,
|
||||||
Name: user.Name,
|
Name: user.Name,
|
||||||
}, nil
|
}, nil
|
||||||
@@ -1,17 +1,17 @@
|
|||||||
package grpc_server
|
package grpcserver
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.hlsq.asia/mmorpg/service-common/config"
|
"git.hlsq.asia/mmorpg/service-common/config"
|
||||||
"git.hlsq.asia/mmorpg/service-common/discover/common"
|
"git.hlsq.asia/mmorpg/service-common/discover/common"
|
||||||
"git.hlsq.asia/mmorpg/service-common/net/grpc/service"
|
"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/query"
|
||||||
"git.hlsq.asia/mmorpg/service-user/internal/dao/repository"
|
"git.hlsq.asia/mmorpg/service-user/internal/dao/repository"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Server struct {
|
type Server struct {
|
||||||
grpc_pb.UnimplementedUserServer
|
rspb.UnimplementedUserServer
|
||||||
service.Base
|
service.Base
|
||||||
query *query.Query
|
query *query.Query
|
||||||
}
|
}
|
||||||
@@ -35,7 +35,7 @@ func (s *Server) OnCustomGrpcServerOption() []grpc.ServerOption {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) OnInit(serve *grpc.Server) {
|
func (s *Server) OnInit(serve *grpc.Server) {
|
||||||
grpc_pb.RegisterUserServer(serve, s)
|
rspb.RegisterUserServer(serve, s)
|
||||||
s.query = repository.Query()
|
s.query = repository.Query()
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user