Browse Source

add master Auth

master
DengBiao 1 year ago
parent
commit
130e737ddc
7 changed files with 247 additions and 88 deletions
  1. +5
    -0
      internal/business/api/business_int.go
  2. +5
    -0
      internal/business/app/auth_app.go
  3. +17
    -0
      internal/business/domain/user/service/auth.go
  4. +4
    -3
      pkg/gerrors/define.go
  5. +18
    -0
      pkg/interceptor/interceptor.go
  6. +192
    -85
      pkg/pb/business.int.pb.go
  7. +6
    -0
      pkg/proto/business.int.proto

+ 5
- 0
internal/business/api/business_int.go View File

@@ -8,6 +8,11 @@ import (


type BusinessIntServer struct{} type BusinessIntServer struct{}


func (s *BusinessIntServer) MasterAuth(ctx context.Context, req *pb.MasterAuthReq) (*pb.Empty, error) {
//TODO implement me
return &pb.Empty{}, app.AuthApp.AuthMaster(ctx, req.MasterId)
}

func (*BusinessIntServer) Auth(ctx context.Context, req *pb.AuthReq) (*pb.Empty, error) { func (*BusinessIntServer) Auth(ctx context.Context, req *pb.AuthReq) (*pb.Empty, error) {
return &pb.Empty{}, app.AuthApp.Auth(ctx, req.UserId, req.DeviceId, req.Token) return &pb.Empty{}, app.AuthApp.Auth(ctx, req.UserId, req.DeviceId, req.Token)
} }


+ 5
- 0
internal/business/app/auth_app.go View File

@@ -18,3 +18,8 @@ func (*authApp) SignIn(ctx context.Context, phoneNumber, code string, masterId,
func (*authApp) Auth(ctx context.Context, userId, deviceId int64, token string) error { func (*authApp) Auth(ctx context.Context, userId, deviceId int64, token string) error {
return service.AuthService.Auth(ctx, userId, deviceId, token) return service.AuthService.Auth(ctx, userId, deviceId, token)
} }

// AuthMaster 验证站长权限
func (*authApp) AuthMaster(ctx context.Context, masterId string) error {
return service.AuthService.AuthMaster(ctx, masterId)
}

+ 17
- 0
internal/business/domain/user/service/auth.go View File

@@ -4,6 +4,7 @@ import (
"context" "context"
"errors" "errors"
"gim/internal/business/comm/db" "gim/internal/business/comm/db"
"gim/internal/business/comm/utils"
"gim/internal/business/domain/user/model" "gim/internal/business/domain/user/model"
"gim/internal/business/domain/user/repo" "gim/internal/business/domain/user/repo"
"gim/pkg/gerrors" "gim/pkg/gerrors"
@@ -106,3 +107,19 @@ func (*authService) Auth(ctx context.Context, userId, deviceId int64, token stri
} }
return nil return nil
} }

// AuthMaster 验证站长权限
func (*authService) AuthMaster(ctx context.Context, masterId string) error {
master, err := repo.MasterRepo.Get(utils.StrToInt64(masterId))
if err != nil {
return err
}
if master == nil {
return gerrors.ErrMasterUnauthorized
}
packageExpireTime, _ := utils.StrToTime(master.PackageExpireTime)
if packageExpireTime < time.Now().Unix() {
return gerrors.ErrMasterUnauthorized
}
return nil
}

+ 4
- 3
pkg/gerrors/define.go View File

@@ -6,9 +6,10 @@ import (
) )


var ( var (
ErrUnknown = status.New(codes.Unknown, "服务器异常").Err() // 服务器未知错误
ErrUnauthorized = newError(10000, "请重新登录")
ErrBadRequest = newError(10001, "请求参数错误")
ErrUnknown = status.New(codes.Unknown, "服务器异常").Err() // 服务器未知错误
ErrUnauthorized = newError(10000, "请重新登录")
ErrBadRequest = newError(10001, "请求参数错误")
ErrMasterUnauthorized = newError(10002, "站长权限不足")


ErrBadCode = newError(10010, "验证码错误") ErrBadCode = newError(10010, "验证码错误")
ErrNotInGroup = newError(10011, "用户没有在群组中") ErrNotInGroup = newError(10011, "用户没有在群组中")


+ 18
- 0
pkg/interceptor/interceptor.go View File

@@ -21,6 +21,10 @@ func NewInterceptor(name string, urlWhitelist map[string]int) grpc.UnaryServerIn
defer gerrors.LogPanic(name, ctx, req, info, &err) defer gerrors.LogPanic(name, ctx, req, info, &err)


md, _ := metadata.FromIncomingContext(ctx) md, _ := metadata.FromIncomingContext(ctx)
resp, err = handleMasterAuth(ctx, req, info, handler)
logger.Logger.Debug(name, zap.Any("method", info.FullMethod), zap.Any("md", md), zap.Any("req", req),
zap.Any("resp", resp), zap.Error(err))

resp, err = handleWithAuth(ctx, req, info, handler, urlWhitelist) resp, err = handleWithAuth(ctx, req, info, handler, urlWhitelist)
logger.Logger.Debug(name, zap.Any("method", info.FullMethod), zap.Any("md", md), zap.Any("req", req), logger.Logger.Debug(name, zap.Any("method", info.FullMethod), zap.Any("md", md), zap.Any("req", req),
zap.Any("resp", resp), zap.Error(err)) zap.Any("resp", resp), zap.Error(err))
@@ -62,3 +66,17 @@ func handleWithAuth(ctx context.Context, req interface{}, info *grpc.UnaryServer
} }
return handler(ctx, req) return handler(ctx, req)
} }

// handleMasterAuth 处理站长权限
func handleMasterAuth(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
serverName := strings.Split(info.FullMethod, "/")[1]
if !strings.HasSuffix(serverName, "Int") {
masterId, err := grpclib.GetCtxMasterId(ctx)
_, err = rpc.GetBusinessIntClient().MasterAuth(ctx, &pb.MasterAuthReq{MasterId: masterId})
if err != nil {
return nil, err
}
}

return handler(ctx, req)
}

+ 192
- 85
pkg/pb/business.int.pb.go View File

@@ -1,8 +1,8 @@
// Code generated by protoc-gen-go. DO NOT EDIT. // Code generated by protoc-gen-go. DO NOT EDIT.
// versions: // versions:
// protoc-gen-go v1.26.0
// protoc v3.14.0
// source: business.int.proto_back
// protoc-gen-go v1.28.1
// protoc v3.20.0--rc1
// source: business.int.proto


package pb package pb


@@ -24,6 +24,53 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
) )


type MasterAuthReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields

MasterId string `protobuf:"bytes,1,opt,name=master_id,json=masterId,proto3" json:"master_id,omitempty"`
}

func (x *MasterAuthReq) Reset() {
*x = MasterAuthReq{}
if protoimpl.UnsafeEnabled {
mi := &file_business_int_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}

func (x *MasterAuthReq) String() string {
return protoimpl.X.MessageStringOf(x)
}

func (*MasterAuthReq) ProtoMessage() {}

func (x *MasterAuthReq) ProtoReflect() protoreflect.Message {
mi := &file_business_int_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}

// Deprecated: Use MasterAuthReq.ProtoReflect.Descriptor instead.
func (*MasterAuthReq) Descriptor() ([]byte, []int) {
return file_business_int_proto_rawDescGZIP(), []int{0}
}

func (x *MasterAuthReq) GetMasterId() string {
if x != nil {
return x.MasterId
}
return ""
}

type AuthReq struct { type AuthReq struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
@@ -37,7 +84,7 @@ type AuthReq struct {
func (x *AuthReq) Reset() { func (x *AuthReq) Reset() {
*x = AuthReq{} *x = AuthReq{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_business_int_proto_msgTypes[0]
mi := &file_business_int_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@@ -50,7 +97,7 @@ func (x *AuthReq) String() string {
func (*AuthReq) ProtoMessage() {} func (*AuthReq) ProtoMessage() {}


func (x *AuthReq) ProtoReflect() protoreflect.Message { func (x *AuthReq) ProtoReflect() protoreflect.Message {
mi := &file_business_int_proto_msgTypes[0]
mi := &file_business_int_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@@ -63,7 +110,7 @@ func (x *AuthReq) ProtoReflect() protoreflect.Message {


// Deprecated: Use AuthReq.ProtoReflect.Descriptor instead. // Deprecated: Use AuthReq.ProtoReflect.Descriptor instead.
func (*AuthReq) Descriptor() ([]byte, []int) { func (*AuthReq) Descriptor() ([]byte, []int) {
return file_business_int_proto_rawDescGZIP(), []int{0}
return file_business_int_proto_rawDescGZIP(), []int{1}
} }


func (x *AuthReq) GetUserId() int64 { func (x *AuthReq) GetUserId() int64 {
@@ -98,7 +145,7 @@ type GetUsersReq struct {
func (x *GetUsersReq) Reset() { func (x *GetUsersReq) Reset() {
*x = GetUsersReq{} *x = GetUsersReq{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_business_int_proto_msgTypes[1]
mi := &file_business_int_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@@ -111,7 +158,7 @@ func (x *GetUsersReq) String() string {
func (*GetUsersReq) ProtoMessage() {} func (*GetUsersReq) ProtoMessage() {}


func (x *GetUsersReq) ProtoReflect() protoreflect.Message { func (x *GetUsersReq) ProtoReflect() protoreflect.Message {
mi := &file_business_int_proto_msgTypes[1]
mi := &file_business_int_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@@ -124,7 +171,7 @@ func (x *GetUsersReq) ProtoReflect() protoreflect.Message {


// Deprecated: Use GetUsersReq.ProtoReflect.Descriptor instead. // Deprecated: Use GetUsersReq.ProtoReflect.Descriptor instead.
func (*GetUsersReq) Descriptor() ([]byte, []int) { func (*GetUsersReq) Descriptor() ([]byte, []int) {
return file_business_int_proto_rawDescGZIP(), []int{1}
return file_business_int_proto_rawDescGZIP(), []int{2}
} }


func (x *GetUsersReq) GetUserIds() map[int64]int32 { func (x *GetUsersReq) GetUserIds() map[int64]int32 {
@@ -145,7 +192,7 @@ type GetUsersResp struct {
func (x *GetUsersResp) Reset() { func (x *GetUsersResp) Reset() {
*x = GetUsersResp{} *x = GetUsersResp{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_business_int_proto_msgTypes[2]
mi := &file_business_int_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@@ -158,7 +205,7 @@ func (x *GetUsersResp) String() string {
func (*GetUsersResp) ProtoMessage() {} func (*GetUsersResp) ProtoMessage() {}


func (x *GetUsersResp) ProtoReflect() protoreflect.Message { func (x *GetUsersResp) ProtoReflect() protoreflect.Message {
mi := &file_business_int_proto_msgTypes[2]
mi := &file_business_int_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@@ -171,7 +218,7 @@ func (x *GetUsersResp) ProtoReflect() protoreflect.Message {


// Deprecated: Use GetUsersResp.ProtoReflect.Descriptor instead. // Deprecated: Use GetUsersResp.ProtoReflect.Descriptor instead.
func (*GetUsersResp) Descriptor() ([]byte, []int) { func (*GetUsersResp) Descriptor() ([]byte, []int) {
return file_business_int_proto_rawDescGZIP(), []int{2}
return file_business_int_proto_rawDescGZIP(), []int{3}
} }


func (x *GetUsersResp) GetUsers() map[int64]*User { func (x *GetUsersResp) GetUsers() map[int64]*User {
@@ -187,40 +234,45 @@ var file_business_int_proto_rawDesc = []byte{
0x0a, 0x12, 0x62, 0x75, 0x73, 0x69, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x2e, 0x70, 0x0a, 0x12, 0x62, 0x75, 0x73, 0x69, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x1a, 0x10, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x1a, 0x10, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e,
0x2e, 0x65, 0x78, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x12, 0x62, 0x75, 0x73, 0x69, 0x2e, 0x65, 0x78, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x12, 0x62, 0x75, 0x73, 0x69,
0x6e, 0x65, 0x73, 0x73, 0x2e, 0x65, 0x78, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x55,
0x0a, 0x07, 0x41, 0x75, 0x74, 0x68, 0x52, 0x65, 0x71, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65,
0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72,
0x49, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18,
0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x12,
0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05,
0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x82, 0x01, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65,
0x72, 0x73, 0x52, 0x65, 0x71, 0x12, 0x37, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64,
0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74,
0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x73,
0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x73, 0x1a, 0x3a,
0x0a, 0x0c, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10,
0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x6b, 0x65, 0x79,
0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52,
0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x85, 0x01, 0x0a, 0x0c, 0x47,
0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x12, 0x31, 0x0a, 0x05, 0x75,
0x73, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x70, 0x62, 0x2e,
0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x2e, 0x55, 0x73, 0x65,
0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, 0x1a, 0x42,
0x0a, 0x0a, 0x55, 0x73, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03,
0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x1e,
0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e,
0x70, 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02,
0x38, 0x01, 0x32, 0x88, 0x01, 0x0a, 0x0b, 0x42, 0x75, 0x73, 0x69, 0x6e, 0x65, 0x73, 0x73, 0x49,
0x6e, 0x74, 0x12, 0x1e, 0x0a, 0x04, 0x41, 0x75, 0x74, 0x68, 0x12, 0x0b, 0x2e, 0x70, 0x62, 0x2e,
0x41, 0x75, 0x74, 0x68, 0x52, 0x65, 0x71, 0x1a, 0x09, 0x2e, 0x70, 0x62, 0x2e, 0x45, 0x6d, 0x70,
0x74, 0x79, 0x12, 0x2a, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x12, 0x0e, 0x2e,
0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e,
0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x12, 0x2d,
0x0a, 0x08, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x12, 0x0f, 0x2e, 0x70, 0x62, 0x2e,
0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x10, 0x2e, 0x70, 0x62,
0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x42, 0x0d, 0x5a,
0x0b, 0x67, 0x69, 0x6d, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62, 0x2f, 0x62, 0x06, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x33,
0x6e, 0x65, 0x73, 0x73, 0x2e, 0x65, 0x78, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x2c,
0x0a, 0x0d, 0x4d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x41, 0x75, 0x74, 0x68, 0x52, 0x65, 0x71, 0x12,
0x1b, 0x0a, 0x09, 0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x08, 0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x49, 0x64, 0x22, 0x55, 0x0a, 0x07,
0x41, 0x75, 0x74, 0x68, 0x52, 0x65, 0x71, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f,
0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64,
0x12, 0x1b, 0x0a, 0x09, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20,
0x01, 0x28, 0x03, 0x52, 0x08, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x12, 0x14, 0x0a,
0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f,
0x6b, 0x65, 0x6e, 0x22, 0x82, 0x01, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73,
0x52, 0x65, 0x71, 0x12, 0x37, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x73, 0x18,
0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73,
0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x73, 0x45, 0x6e,
0x74, 0x72, 0x79, 0x52, 0x07, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x73, 0x1a, 0x3a, 0x0a, 0x0c,
0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03,
0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14,
0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76,
0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x85, 0x01, 0x0a, 0x0c, 0x47, 0x65, 0x74,
0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x12, 0x31, 0x0a, 0x05, 0x75, 0x73, 0x65,
0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x65,
0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x73,
0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, 0x1a, 0x42, 0x0a, 0x0a,
0x55, 0x73, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65,
0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x1e, 0x0a, 0x05,
0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x70, 0x62,
0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01,
0x32, 0xb4, 0x01, 0x0a, 0x0b, 0x42, 0x75, 0x73, 0x69, 0x6e, 0x65, 0x73, 0x73, 0x49, 0x6e, 0x74,
0x12, 0x2a, 0x0a, 0x0a, 0x4d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x41, 0x75, 0x74, 0x68, 0x12, 0x11,
0x2e, 0x70, 0x62, 0x2e, 0x4d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x41, 0x75, 0x74, 0x68, 0x52, 0x65,
0x71, 0x1a, 0x09, 0x2e, 0x70, 0x62, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x1e, 0x0a, 0x04,
0x41, 0x75, 0x74, 0x68, 0x12, 0x0b, 0x2e, 0x70, 0x62, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x52, 0x65,
0x71, 0x1a, 0x09, 0x2e, 0x70, 0x62, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x2a, 0x0a, 0x07,
0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x12, 0x0e, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74,
0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74,
0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x12, 0x2d, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x55,
0x73, 0x65, 0x72, 0x73, 0x12, 0x0f, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65,
0x72, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x10, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73,
0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x42, 0x0d, 0x5a, 0x0b, 0x67, 0x69, 0x6d, 0x2f, 0x70,
0x6b, 0x67, 0x2f, 0x70, 0x62, 0x2f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }


var ( var (
@@ -235,30 +287,33 @@ func file_business_int_proto_rawDescGZIP() []byte {
return file_business_int_proto_rawDescData return file_business_int_proto_rawDescData
} }


var file_business_int_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
var file_business_int_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
var file_business_int_proto_goTypes = []interface{}{ var file_business_int_proto_goTypes = []interface{}{
(*AuthReq)(nil), // 0: pb.AuthReq
(*GetUsersReq)(nil), // 1: pb.GetUsersReq
(*GetUsersResp)(nil), // 2: pb.GetUsersResp
nil, // 3: pb.GetUsersReq.UserIdsEntry
nil, // 4: pb.GetUsersResp.UsersEntry
(*User)(nil), // 5: pb.User
(*GetUserReq)(nil), // 6: pb.GetUserReq
(*Empty)(nil), // 7: pb.Empty
(*GetUserResp)(nil), // 8: pb.GetUserResp
(*MasterAuthReq)(nil), // 0: pb.MasterAuthReq
(*AuthReq)(nil), // 1: pb.AuthReq
(*GetUsersReq)(nil), // 2: pb.GetUsersReq
(*GetUsersResp)(nil), // 3: pb.GetUsersResp
nil, // 4: pb.GetUsersReq.UserIdsEntry
nil, // 5: pb.GetUsersResp.UsersEntry
(*User)(nil), // 6: pb.User
(*GetUserReq)(nil), // 7: pb.GetUserReq
(*Empty)(nil), // 8: pb.Empty
(*GetUserResp)(nil), // 9: pb.GetUserResp
} }
var file_business_int_proto_depIdxs = []int32{ var file_business_int_proto_depIdxs = []int32{
3, // 0: pb.GetUsersReq.user_ids:type_name -> pb.GetUsersReq.UserIdsEntry
4, // 1: pb.GetUsersResp.users:type_name -> pb.GetUsersResp.UsersEntry
5, // 2: pb.GetUsersResp.UsersEntry.value:type_name -> pb.User
0, // 3: pb.BusinessInt.Auth:input_type -> pb.AuthReq
6, // 4: pb.BusinessInt.GetUser:input_type -> pb.GetUserReq
1, // 5: pb.BusinessInt.GetUsers:input_type -> pb.GetUsersReq
7, // 6: pb.BusinessInt.Auth:output_type -> pb.Empty
8, // 7: pb.BusinessInt.GetUser:output_type -> pb.GetUserResp
2, // 8: pb.BusinessInt.GetUsers:output_type -> pb.GetUsersResp
6, // [6:9] is the sub-list for method output_type
3, // [3:6] is the sub-list for method input_type
4, // 0: pb.GetUsersReq.user_ids:type_name -> pb.GetUsersReq.UserIdsEntry
5, // 1: pb.GetUsersResp.users:type_name -> pb.GetUsersResp.UsersEntry
6, // 2: pb.GetUsersResp.UsersEntry.value:type_name -> pb.User
0, // 3: pb.BusinessInt.MasterAuth:input_type -> pb.MasterAuthReq
1, // 4: pb.BusinessInt.Auth:input_type -> pb.AuthReq
7, // 5: pb.BusinessInt.GetUser:input_type -> pb.GetUserReq
2, // 6: pb.BusinessInt.GetUsers:input_type -> pb.GetUsersReq
8, // 7: pb.BusinessInt.MasterAuth:output_type -> pb.Empty
8, // 8: pb.BusinessInt.Auth:output_type -> pb.Empty
9, // 9: pb.BusinessInt.GetUser:output_type -> pb.GetUserResp
3, // 10: pb.BusinessInt.GetUsers:output_type -> pb.GetUsersResp
7, // [7:11] is the sub-list for method output_type
3, // [3:7] is the sub-list for method input_type
3, // [3:3] is the sub-list for extension type_name 3, // [3:3] is the sub-list for extension type_name
3, // [3:3] is the sub-list for extension extendee 3, // [3:3] is the sub-list for extension extendee
0, // [0:3] is the sub-list for field type_name 0, // [0:3] is the sub-list for field type_name
@@ -273,7 +328,7 @@ func file_business_int_proto_init() {
file_business_ext_proto_init() file_business_ext_proto_init()
if !protoimpl.UnsafeEnabled { if !protoimpl.UnsafeEnabled {
file_business_int_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { file_business_int_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*AuthReq); i {
switch v := v.(*MasterAuthReq); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:
@@ -285,7 +340,7 @@ func file_business_int_proto_init() {
} }
} }
file_business_int_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { file_business_int_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetUsersReq); i {
switch v := v.(*AuthReq); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:
@@ -297,6 +352,18 @@ func file_business_int_proto_init() {
} }
} }
file_business_int_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { file_business_int_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetUsersReq); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_business_int_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetUsersResp); i { switch v := v.(*GetUsersResp); i {
case 0: case 0:
return &v.state return &v.state
@@ -315,7 +382,7 @@ func file_business_int_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_business_int_proto_rawDesc, RawDescriptor: file_business_int_proto_rawDesc,
NumEnums: 0, NumEnums: 0,
NumMessages: 5,
NumMessages: 6,
NumExtensions: 0, NumExtensions: 0,
NumServices: 1, NumServices: 1,
}, },
@@ -329,18 +396,17 @@ func file_business_int_proto_init() {
file_business_int_proto_depIdxs = nil file_business_int_proto_depIdxs = nil
} }


// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConnInterface

// This is a compile-time assertion to ensure that this generated comm
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against. // is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion6
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7


// BusinessIntClient is the client API for BusinessInt service. // BusinessIntClient is the client API for BusinessInt service.
// //
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type BusinessIntClient interface { type BusinessIntClient interface {
// 站长权限校验
MasterAuth(ctx context.Context, in *MasterAuthReq, opts ...grpc.CallOption) (*Empty, error)
// 权限校验 // 权限校验
Auth(ctx context.Context, in *AuthReq, opts ...grpc.CallOption) (*Empty, error) Auth(ctx context.Context, in *AuthReq, opts ...grpc.CallOption) (*Empty, error)
// 批量获取用户信息 // 批量获取用户信息
@@ -357,6 +423,15 @@ func NewBusinessIntClient(cc grpc.ClientConnInterface) BusinessIntClient {
return &businessIntClient{cc} return &businessIntClient{cc}
} }


func (c *businessIntClient) MasterAuth(ctx context.Context, in *MasterAuthReq, opts ...grpc.CallOption) (*Empty, error) {
out := new(Empty)
err := c.cc.Invoke(ctx, "/pb.BusinessInt/MasterAuth", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}

func (c *businessIntClient) Auth(ctx context.Context, in *AuthReq, opts ...grpc.CallOption) (*Empty, error) { func (c *businessIntClient) Auth(ctx context.Context, in *AuthReq, opts ...grpc.CallOption) (*Empty, error) {
out := new(Empty) out := new(Empty)
err := c.cc.Invoke(ctx, "/pb.BusinessInt/Auth", in, out, opts...) err := c.cc.Invoke(ctx, "/pb.BusinessInt/Auth", in, out, opts...)
@@ -385,7 +460,11 @@ func (c *businessIntClient) GetUsers(ctx context.Context, in *GetUsersReq, opts
} }


// BusinessIntServer is the server API for BusinessInt service. // BusinessIntServer is the server API for BusinessInt service.
// All implementations must embed UnimplementedBusinessIntServer
// for forward compatibility
type BusinessIntServer interface { type BusinessIntServer interface {
// 站长权限校验
MasterAuth(context.Context, *MasterAuthReq) (*Empty, error)
// 权限校验 // 权限校验
Auth(context.Context, *AuthReq) (*Empty, error) Auth(context.Context, *AuthReq) (*Empty, error)
// 批量获取用户信息 // 批量获取用户信息
@@ -394,22 +473,43 @@ type BusinessIntServer interface {
GetUsers(context.Context, *GetUsersReq) (*GetUsersResp, error) GetUsers(context.Context, *GetUsersReq) (*GetUsersResp, error)
} }


// UnimplementedBusinessIntServer can be embedded to have forward compatible implementations.
// UnimplementedBusinessIntServer must be embedded to have forward compatible implementations.
type UnimplementedBusinessIntServer struct { type UnimplementedBusinessIntServer struct {
} }


func (*UnimplementedBusinessIntServer) Auth(context.Context, *AuthReq) (*Empty, error) {
func (UnimplementedBusinessIntServer) MasterAuth(context.Context, *MasterAuthReq) (*Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method MasterAuth not implemented")
}
func (UnimplementedBusinessIntServer) Auth(context.Context, *AuthReq) (*Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method Auth not implemented") return nil, status.Errorf(codes.Unimplemented, "method Auth not implemented")
} }
func (*UnimplementedBusinessIntServer) GetUser(context.Context, *GetUserReq) (*GetUserResp, error) {
func (UnimplementedBusinessIntServer) GetUser(context.Context, *GetUserReq) (*GetUserResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetUser not implemented") return nil, status.Errorf(codes.Unimplemented, "method GetUser not implemented")
} }
func (*UnimplementedBusinessIntServer) GetUsers(context.Context, *GetUsersReq) (*GetUsersResp, error) {
func (UnimplementedBusinessIntServer) GetUsers(context.Context, *GetUsersReq) (*GetUsersResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetUsers not implemented") return nil, status.Errorf(codes.Unimplemented, "method GetUsers not implemented")
} }


func RegisterBusinessIntServer(s *grpc.Server, srv BusinessIntServer) {
s.RegisterService(&_BusinessInt_serviceDesc, srv)
func RegisterBusinessIntServer(s grpc.ServiceRegistrar, srv BusinessIntServer) {
s.RegisterService(&BusinessInt_ServiceDesc, srv)
}

func _BusinessInt_MasterAuth_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(MasterAuthReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(BusinessIntServer).MasterAuth(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/pb.BusinessInt/MasterAuth",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(BusinessIntServer).MasterAuth(ctx, req.(*MasterAuthReq))
}
return interceptor(ctx, in, info, handler)
} }


func _BusinessInt_Auth_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { func _BusinessInt_Auth_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
@@ -466,10 +566,17 @@ func _BusinessInt_GetUsers_Handler(srv interface{}, ctx context.Context, dec fun
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }


var _BusinessInt_serviceDesc = grpc.ServiceDesc{
// BusinessInt_ServiceDesc is the grpc.ServiceDesc for BusinessInt service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var BusinessInt_ServiceDesc = grpc.ServiceDesc{
ServiceName: "pb.BusinessInt", ServiceName: "pb.BusinessInt",
HandlerType: (*BusinessIntServer)(nil), HandlerType: (*BusinessIntServer)(nil),
Methods: []grpc.MethodDesc{ Methods: []grpc.MethodDesc{
{
MethodName: "MasterAuth",
Handler: _BusinessInt_MasterAuth_Handler,
},
{ {
MethodName: "Auth", MethodName: "Auth",
Handler: _BusinessInt_Auth_Handler, Handler: _BusinessInt_Auth_Handler,
@@ -484,5 +591,5 @@ var _BusinessInt_serviceDesc = grpc.ServiceDesc{
}, },
}, },
Streams: []grpc.StreamDesc{}, Streams: []grpc.StreamDesc{},
Metadata: "business.int.proto_back",
Metadata: "business.int.proto",
} }

+ 6
- 0
pkg/proto/business.int.proto View File

@@ -6,6 +6,8 @@ import "common.ext.proto";
import "business.ext.proto"; import "business.ext.proto";


service BusinessInt { service BusinessInt {
// 站长权限校验
rpc MasterAuth (MasterAuthReq) returns (Empty);
// 权限校验 // 权限校验
rpc Auth (AuthReq) returns (Empty); rpc Auth (AuthReq) returns (Empty);
// 批量获取用户信息 // 批量获取用户信息
@@ -14,6 +16,10 @@ service BusinessInt {
rpc GetUsers (GetUsersReq) returns (GetUsersResp); rpc GetUsers (GetUsersReq) returns (GetUsersResp);
} }


message MasterAuthReq {
string master_id = 1;
}

message AuthReq { message AuthReq {
int64 user_id = 1; int64 user_id = 1;
int64 device_id = 2; int64 device_id = 2;


Loading…
Cancel
Save