feat 结构调整
This commit is contained in:
21
Server/user/internal/grpc_server/server/server.go
Normal file
21
Server/user/internal/grpc_server/server/server.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"common/log"
|
||||
"common/proto/ss/grpc_pb"
|
||||
"context"
|
||||
"user/internal/dao/repository"
|
||||
)
|
||||
|
||||
func (s *Server) Login(ctx context.Context, req *grpc_pb.LoginReq) (*grpc_pb.LoginResp, error) {
|
||||
log.Infof("Login req: %+v", req)
|
||||
|
||||
user, err := repository.NewUserDao(ctx).FindBySn(857527344353)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &grpc_pb.LoginResp{
|
||||
UID: int32(user.Sn),
|
||||
}, nil
|
||||
}
|
||||
32
Server/user/internal/grpc_server/server/server_init.go
Normal file
32
Server/user/internal/grpc_server/server/server_init.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"common/discover/common"
|
||||
"common/net/grpc/service"
|
||||
"common/proto/ss/grpc_pb"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
grpc_pb.UnimplementedUserServer
|
||||
service.Base
|
||||
}
|
||||
|
||||
func NewServer(ttl int64) *Server {
|
||||
s := &Server{
|
||||
Base: service.Base{
|
||||
Target: common.KeyDiscoverUser,
|
||||
EtcdTTL: ttl,
|
||||
},
|
||||
}
|
||||
s.Base.OnInit = s.OnInit
|
||||
s.Base.OnClose = s.OnClose
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *Server) OnInit(serve *grpc.Server) {
|
||||
grpc_pb.RegisterUserServer(serve, s)
|
||||
}
|
||||
|
||||
func (s *Server) OnClose() {
|
||||
}
|
||||
Reference in New Issue
Block a user