feat 包命名规范
This commit is contained in:
@@ -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
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user