From 8a935489c704ab94828e3c745bb71bcf130a3f02 Mon Sep 17 00:00:00 2001 From: Ryan SU <1137661202@qq.com> Date: Fri, 21 Oct 2022 18:52:18 +0800 Subject: [PATCH] feat: force log out --- api/api_desc/base.api | 2 +- api/api_desc/token.api | 15 +++- api/api_desc/user.api | 12 +++ api/internal/handler/routes.go | 10 +++ api/internal/handler/token/logouthandler.go | 40 +++++++++ api/internal/handler/user/logouthandler.go | 29 ++++++ api/internal/logic/token/logoutlogic.go | 35 ++++++++ api/internal/logic/user/getuserlistlogic.go | 5 +- api/internal/logic/user/logoutlogic.go | 36 ++++++++ api/internal/types/types.go | 4 +- rpc/core.proto | 1 + rpc/coreclient/core.go | 6 ++ rpc/internal/logic/blockuseralltokenlogic.go | 60 +++++++++++++ rpc/internal/logic/initdatabaselogic.go | 12 +++ rpc/internal/server/coreserver.go | 5 ++ rpc/types/core/core.pb.go | 95 ++++++++++---------- rpc/types/core/core_grpc.pb.go | 36 ++++++++ 17 files changed, 354 insertions(+), 49 deletions(-) create mode 100644 api/internal/handler/token/logouthandler.go create mode 100644 api/internal/handler/user/logouthandler.go create mode 100644 api/internal/logic/token/logoutlogic.go create mode 100644 api/internal/logic/user/logoutlogic.go create mode 100644 rpc/internal/logic/blockuseralltokenlogic.go diff --git a/api/api_desc/base.api b/api/api_desc/base.api index 5eb500a1..5a3b68c2 100644 --- a/api/api_desc/base.api +++ b/api/api_desc/base.api @@ -76,7 +76,7 @@ type UUIDReq { // UUID // Required: true // Max length: 36 - UUID string `json:"UUID" path:"UUID" validate:"len=36"` + UUID string `json:"UUID" validate:"len=36"` } // The base response data | 基础信息 diff --git a/api/api_desc/token.api b/api/api_desc/token.api index 5b2c4af7..4efaf271 100644 --- a/api/api_desc/token.api +++ b/api/api_desc/token.api @@ -104,7 +104,6 @@ type ( // Max length: 100 Email string `json:"email" validate:"omitempty,email,max=100"` } - ) @server( @@ -169,4 +168,18 @@ service core { // 500: SimpleMsg @handler setTokenStatus post /token/status (SetBooleanStatusReq) returns (SimpleMsg) + + // swagger:route POST /token/logout token logout + // Force logging out by user UUID | 根据UUID强制用户退出 + // Parameters: + // + name: body + // require: true + // in: body + // type: UUIDReq + // Responses: + // 200: SimpleMsg + // 401: SimpleMsg + // 500: SimpleMsg + @handler logout + post /token/logout (UUIDReq) returns (SimpleMsg) } diff --git a/api/api_desc/user.api b/api/api_desc/user.api index 5ab9290e..92aba745 100644 --- a/api/api_desc/user.api +++ b/api/api_desc/user.api @@ -154,6 +154,9 @@ type ( // User's id | 用户Id Id int64 `json:"id"` + // User's UUID | 用户的UUID + UUID string `json:"UUID"` + // User Name | 用户名 Username string `json:"username"` @@ -458,4 +461,13 @@ service core { // 500: SimpleMsg @handler updateUserProfile post /user/profile (ProfileReq) returns (SimpleMsg) + + // swagger:route GET /user/logout user logout + // Log out | 退出登陆 + // Responses: + // 200: SimpleMsg + // 401: SimpleMsg + // 500: SimpleMsg + @handler logout + get /user/logout returns (SimpleMsg) } diff --git a/api/internal/handler/routes.go b/api/internal/handler/routes.go index 3b41cd7a..a0c7d5af 100644 --- a/api/internal/handler/routes.go +++ b/api/internal/handler/routes.go @@ -123,6 +123,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { Path: "/user/profile", Handler: user.UpdateUserProfileHandler(serverCtx), }, + { + Method: http.MethodGet, + Path: "/user/logout", + Handler: user.LogoutHandler(serverCtx), + }, }..., ), rest.WithJwt(serverCtx.Config.Auth.AccessSecret), @@ -337,6 +342,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { Path: "/token/status", Handler: token.SetTokenStatusHandler(serverCtx), }, + { + Method: http.MethodPost, + Path: "/token/logout", + Handler: token.LogoutHandler(serverCtx), + }, }..., ), rest.WithJwt(serverCtx.Config.Auth.AccessSecret), diff --git a/api/internal/handler/token/logouthandler.go b/api/internal/handler/token/logouthandler.go new file mode 100644 index 00000000..7e128d69 --- /dev/null +++ b/api/internal/handler/token/logouthandler.go @@ -0,0 +1,40 @@ +package token + +import ( + "net/http" + + "github.com/suyuan32/simple-admin-core/api/internal/logic/token" + "github.com/suyuan32/simple-admin-core/api/internal/svc" + "github.com/suyuan32/simple-admin-core/api/internal/types" + "github.com/zeromicro/go-zero/rest/httpx" +) + +// swagger:route POST /token/logout token logout +// Force logging out by user UUID | 根据UUID强制用户退出 +// Parameters: +// + name: body +// require: true +// in: body +// type: UUIDReq +// Responses: +// 200: SimpleMsg +// 401: SimpleMsg +// 500: SimpleMsg + +func LogoutHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.UUIDReq + if err := httpx.Parse(r, &req); err != nil { + httpx.Error(w, err) + return + } + + l := token.NewLogoutLogic(r.Context(), svcCtx) + resp, err := l.Logout(&req) + if err != nil { + httpx.Error(w, err) + } else { + httpx.OkJson(w, resp) + } + } +} diff --git a/api/internal/handler/user/logouthandler.go b/api/internal/handler/user/logouthandler.go new file mode 100644 index 00000000..220b14a7 --- /dev/null +++ b/api/internal/handler/user/logouthandler.go @@ -0,0 +1,29 @@ +package user + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + + "github.com/suyuan32/simple-admin-core/api/internal/logic/user" + "github.com/suyuan32/simple-admin-core/api/internal/svc" +) + +// swagger:route GET /user/logout user logout +// Log out | 退出登陆 +// Responses: +// 200: SimpleMsg +// 401: SimpleMsg +// 500: SimpleMsg + +func LogoutHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + l := user.NewLogoutLogic(r.Context(), svcCtx) + resp, err := l.Logout() + if err != nil { + httpx.Error(w, err) + } else { + httpx.OkJson(w, resp) + } + } +} diff --git a/api/internal/logic/token/logoutlogic.go b/api/internal/logic/token/logoutlogic.go new file mode 100644 index 00000000..db06be50 --- /dev/null +++ b/api/internal/logic/token/logoutlogic.go @@ -0,0 +1,35 @@ +package token + +import ( + "context" + + "github.com/suyuan32/simple-admin-core/api/internal/svc" + "github.com/suyuan32/simple-admin-core/api/internal/types" + "github.com/suyuan32/simple-admin-core/rpc/types/core" + + "github.com/zeromicro/go-zero/core/logx" +) + +type LogoutLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewLogoutLogic(ctx context.Context, svcCtx *svc.ServiceContext) *LogoutLogic { + return &LogoutLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *LogoutLogic) Logout(req *types.UUIDReq) (resp *types.SimpleMsg, err error) { + result, err := l.svcCtx.CoreRpc.BlockUserAllToken(context.Background(), &core.UUIDReq{UUID: req.UUID}) + + if err != nil { + return nil, err + } + + return &types.SimpleMsg{Msg: result.Msg}, nil +} diff --git a/api/internal/logic/user/getuserlistlogic.go b/api/internal/logic/user/getuserlistlogic.go index e3384b10..70d82a55 100644 --- a/api/internal/logic/user/getuserlistlogic.go +++ b/api/internal/logic/user/getuserlistlogic.go @@ -2,11 +2,13 @@ package user import ( "context" + "github.com/suyuan32/simple-admin-core/rpc/types/core" + "github.com/zeromicro/go-zero/core/logx" + "github.com/suyuan32/simple-admin-core/api/internal/svc" "github.com/suyuan32/simple-admin-core/api/internal/types" - "github.com/zeromicro/go-zero/core/logx" ) type GetUserListLogic struct { @@ -49,6 +51,7 @@ func (l *GetUserListLogic) GetUserList(req *types.GetUserListReq) (resp *types.U Status: v.Status, CreateAt: v.CreateAt, UpdateAt: v.UpdateAt, + UUID: v.UUID, }) } resp = &types.UserListResp{} diff --git a/api/internal/logic/user/logoutlogic.go b/api/internal/logic/user/logoutlogic.go new file mode 100644 index 00000000..35e2aba7 --- /dev/null +++ b/api/internal/logic/user/logoutlogic.go @@ -0,0 +1,36 @@ +package user + +import ( + "context" + + "github.com/suyuan32/simple-admin-core/api/internal/svc" + "github.com/suyuan32/simple-admin-core/api/internal/types" + "github.com/suyuan32/simple-admin-core/rpc/types/core" + + "github.com/zeromicro/go-zero/core/logx" +) + +type LogoutLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewLogoutLogic(ctx context.Context, svcCtx *svc.ServiceContext) *LogoutLogic { + return &LogoutLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *LogoutLogic) Logout() (resp *types.SimpleMsg, err error) { + result, err := l.svcCtx.CoreRpc.BlockUserAllToken(context.Background(), + &core.UUIDReq{UUID: l.ctx.Value("userId").(string)}) + + if err != nil { + return nil, err + } + + return &types.SimpleMsg{Msg: result.Msg}, nil +} diff --git a/api/internal/types/types.go b/api/internal/types/types.go index 822bb251..316417e8 100644 --- a/api/internal/types/types.go +++ b/api/internal/types/types.go @@ -125,7 +125,7 @@ type UUIDReq struct { // UUID // Required: true // Max length: 36 - UUID string `json:"UUID" path:"UUID" validate:"len=36"` + UUID string `json:"UUID" validate:"len=36"` } // The base response data | 基础信息 @@ -275,6 +275,8 @@ type ChangePasswordReq struct { type UserInfoResp struct { // User's id | 用户Id Id int64 `json:"id"` + // User's UUID | 用户的UUID + UUID string `json:"UUID"` // User Name | 用户名 Username string `json:"username"` // User's nickname | 用户的昵称 diff --git a/rpc/core.proto b/rpc/core.proto index bbbc5726..5102a22b 100644 --- a/rpc/core.proto +++ b/rpc/core.proto @@ -418,4 +418,5 @@ service core { rpc deleteToken (IDReq) returns (BaseResp); rpc getTokenList (TokenListReq) returns (TokenListResp); rpc setTokenStatus (SetStatusReq) returns (BaseResp); + rpc blockUserAllToken (UUIDReq) returns (BaseResp); } \ No newline at end of file diff --git a/rpc/coreclient/core.go b/rpc/coreclient/core.go index c0cca563..40ae00d0 100644 --- a/rpc/coreclient/core.go +++ b/rpc/coreclient/core.go @@ -111,6 +111,7 @@ type ( DeleteToken(ctx context.Context, in *IDReq, opts ...grpc.CallOption) (*BaseResp, error) GetTokenList(ctx context.Context, in *TokenListReq, opts ...grpc.CallOption) (*TokenListResp, error) SetTokenStatus(ctx context.Context, in *SetStatusReq, opts ...grpc.CallOption) (*BaseResp, error) + BlockUserAllToken(ctx context.Context, in *UUIDReq, opts ...grpc.CallOption) (*BaseResp, error) } defaultCore struct { @@ -332,3 +333,8 @@ func (m *defaultCore) SetTokenStatus(ctx context.Context, in *SetStatusReq, opts client := core.NewCoreClient(m.cli.Conn()) return client.SetTokenStatus(ctx, in, opts...) } + +func (m *defaultCore) BlockUserAllToken(ctx context.Context, in *UUIDReq, opts ...grpc.CallOption) (*BaseResp, error) { + client := core.NewCoreClient(m.cli.Conn()) + return client.BlockUserAllToken(ctx, in, opts...) +} diff --git a/rpc/internal/logic/blockuseralltokenlogic.go b/rpc/internal/logic/blockuseralltokenlogic.go new file mode 100644 index 00000000..06103302 --- /dev/null +++ b/rpc/internal/logic/blockuseralltokenlogic.go @@ -0,0 +1,60 @@ +package logic + +import ( + "context" + "errors" + "time" + + "github.com/zeromicro/go-zero/core/errorx" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "gorm.io/gorm" + + "github.com/suyuan32/simple-admin-core/common/logmessage" + "github.com/suyuan32/simple-admin-core/rpc/internal/model" + "github.com/suyuan32/simple-admin-core/rpc/internal/svc" + "github.com/suyuan32/simple-admin-core/rpc/types/core" + + "github.com/zeromicro/go-zero/core/logx" +) + +type BlockUserAllTokenLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewBlockUserAllTokenLogic(ctx context.Context, svcCtx *svc.ServiceContext) *BlockUserAllTokenLogic { + return &BlockUserAllTokenLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *BlockUserAllTokenLogic) BlockUserAllToken(in *core.UUIDReq) (*core.BaseResp, error) { + result := l.svcCtx.DB.Model(&model.Token{}).Where("uuid = ?", in.UUID).Update("status", 0) + if result.Error != nil && !errors.Is(result.Error, gorm.ErrRecordNotFound) { + logx.Errorw(logmessage.DatabaseError, logx.Field("Detail", result.Error.Error())) + return nil, status.Error(codes.Internal, errorx.DatabaseError) + } + + var tokens []model.Token + tokenData := l.svcCtx.DB.Where("uuid = ?", in.UUID).Where("status = ?", 0). + Where("expire_at > ?", time.Now()).Find(&tokens) + + if tokenData.Error != nil && !errors.Is(tokenData.Error, gorm.ErrRecordNotFound) { + logx.Errorw(logmessage.DatabaseError, logx.Field("Detail", result.Error.Error())) + return nil, status.Error(codes.Internal, errorx.DatabaseError) + } + + for _, v := range tokens { + err := l.svcCtx.Redis.Set("token_"+v.Token, "1") + if err != nil { + logx.Errorw(logmessage.RedisError, logx.Field("Detail", err.Error())) + return nil, status.Error(codes.Internal, errorx.RedisError) + } + } + + return &core.BaseResp{Msg: errorx.UpdateSuccess}, nil +} diff --git a/rpc/internal/logic/initdatabaselogic.go b/rpc/internal/logic/initdatabaselogic.go index c87303cb..063e781c 100644 --- a/rpc/internal/logic/initdatabaselogic.go +++ b/rpc/internal/logic/initdatabaselogic.go @@ -263,6 +263,12 @@ func (l *InitDatabaseLogic) insertApiData() error { ApiGroup: "user", Method: "POST", }, + { + Path: "/user/logout", + Description: "api_desc.logout", + ApiGroup: "user", + Method: "GET", + }, // role { Path: "/role", @@ -469,6 +475,12 @@ func (l *InitDatabaseLogic) insertApiData() error { ApiGroup: "token", Method: "POST", }, + { + Path: "/token/logout", + Description: "sys.user.forceLoggingOut", + ApiGroup: "token", + Method: "POST", + }, } result := l.svcCtx.DB.CreateInBatches(apis, 100) if result.Error != nil { diff --git a/rpc/internal/server/coreserver.go b/rpc/internal/server/coreserver.go index e3a6366e..03822b5b 100644 --- a/rpc/internal/server/coreserver.go +++ b/rpc/internal/server/coreserver.go @@ -230,3 +230,8 @@ func (s *CoreServer) SetTokenStatus(ctx context.Context, in *core.SetStatusReq) l := logic.NewSetTokenStatusLogic(ctx, s.svcCtx) return l.SetTokenStatus(in) } + +func (s *CoreServer) BlockUserAllToken(ctx context.Context, in *core.UUIDReq) (*core.BaseResp, error) { + l := logic.NewBlockUserAllTokenLogic(ctx, s.svcCtx) + return l.BlockUserAllToken(in) +} diff --git a/rpc/types/core/core.pb.go b/rpc/types/core/core.pb.go index 3d22eab0..470b19ea 100644 --- a/rpc/types/core/core.pb.go +++ b/rpc/types/core/core.pb.go @@ -3840,7 +3840,7 @@ var file_core_proto_rawDesc = []byte{ 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x55, 0x55, 0x49, 0x44, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x55, - 0x55, 0x49, 0x44, 0x32, 0xd1, 0x11, 0x0a, 0x04, 0x63, 0x6f, 0x72, 0x65, 0x12, 0x2b, 0x0a, 0x0c, + 0x55, 0x49, 0x44, 0x32, 0x85, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x72, 0x65, 0x12, 0x2b, 0x0a, 0x0c, 0x69, 0x6e, 0x69, 0x74, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x12, 0x0b, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x0e, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x28, 0x0a, 0x05, 0x6c, 0x6f, 0x67, @@ -3981,8 +3981,11 @@ var file_core_proto_rawDesc = []byte{ 0x70, 0x12, 0x34, 0x0a, 0x0e, 0x73, 0x65, 0x74, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x12, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x53, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x0e, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x42, - 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x42, 0x08, 0x5a, 0x06, 0x2e, 0x2f, 0x63, 0x6f, 0x72, - 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x32, 0x0a, 0x11, 0x62, 0x6c, 0x6f, 0x63, 0x6b, + 0x55, 0x73, 0x65, 0x72, 0x41, 0x6c, 0x6c, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x0d, 0x2e, 0x63, + 0x6f, 0x72, 0x65, 0x2e, 0x55, 0x55, 0x49, 0x44, 0x52, 0x65, 0x71, 0x1a, 0x0e, 0x2e, 0x63, 0x6f, + 0x72, 0x65, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x42, 0x08, 0x5a, 0x06, 0x2e, + 0x2f, 0x63, 0x6f, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -4105,48 +4108,50 @@ var file_core_proto_depIdxs = []int32{ 1, // 54: core.core.deleteToken:input_type -> core.IDReq 46, // 55: core.core.getTokenList:input_type -> core.TokenListReq 24, // 56: core.core.setTokenStatus:input_type -> core.SetStatusReq - 3, // 57: core.core.initDatabase:output_type -> core.BaseResp - 6, // 58: core.core.login:output_type -> core.LoginResp - 3, // 59: core.core.changePassword:output_type -> core.BaseResp - 3, // 60: core.core.createOrUpdateUser:output_type -> core.BaseResp - 9, // 61: core.core.getUserById:output_type -> core.UserInfoResp - 10, // 62: core.core.getUserList:output_type -> core.UserListResp - 3, // 63: core.core.deleteUser:output_type -> core.BaseResp - 3, // 64: core.core.updateProfile:output_type -> core.BaseResp - 3, // 65: core.core.createOrUpdateMenu:output_type -> core.BaseResp - 3, // 66: core.core.deleteMenu:output_type -> core.BaseResp - 16, // 67: core.core.getMenuListByRole:output_type -> core.MenuInfoList - 16, // 68: core.core.getMenuByPage:output_type -> core.MenuInfoList - 3, // 69: core.core.createOrUpdateMenuParam:output_type -> core.BaseResp - 3, // 70: core.core.deleteMenuParam:output_type -> core.BaseResp - 21, // 71: core.core.geMenuParamListByMenuId:output_type -> core.MenuParamListResp - 3, // 72: core.core.createOrUpdateRole:output_type -> core.BaseResp - 3, // 73: core.core.deleteRole:output_type -> core.BaseResp - 22, // 74: core.core.getRoleById:output_type -> core.RoleInfo - 23, // 75: core.core.getRoleList:output_type -> core.RoleListResp - 3, // 76: core.core.setRoleStatus:output_type -> core.BaseResp - 3, // 77: core.core.createOrUpdateApi:output_type -> core.BaseResp - 3, // 78: core.core.deleteApi:output_type -> core.BaseResp - 29, // 79: core.core.getApiList:output_type -> core.ApiListResp - 32, // 80: core.core.getMenuAuthority:output_type -> core.RoleMenuAuthorityResp - 3, // 81: core.core.createOrUpdateMenuAuthority:output_type -> core.BaseResp - 3, // 82: core.core.createOrUpdateDictionary:output_type -> core.BaseResp - 3, // 83: core.core.deleteDictionary:output_type -> core.BaseResp - 35, // 84: core.core.getDictionaryList:output_type -> core.DictionaryList - 36, // 85: core.core.getDetailByDictionaryName:output_type -> core.DictionaryDetailList - 3, // 86: core.core.createOrUpdateDictionaryDetail:output_type -> core.BaseResp - 3, // 87: core.core.deleteDictionaryDetail:output_type -> core.BaseResp - 3, // 88: core.core.createOrUpdateProvider:output_type -> core.BaseResp - 3, // 89: core.core.deleteProvider:output_type -> core.BaseResp - 42, // 90: core.core.getProviderList:output_type -> core.ProviderListResp - 40, // 91: core.core.oauthLogin:output_type -> core.OauthRedirectResp - 6, // 92: core.core.oauthCallback:output_type -> core.LoginResp - 3, // 93: core.core.createOrUpdateToken:output_type -> core.BaseResp - 3, // 94: core.core.deleteToken:output_type -> core.BaseResp - 45, // 95: core.core.getTokenList:output_type -> core.TokenListResp - 3, // 96: core.core.setTokenStatus:output_type -> core.BaseResp - 57, // [57:97] is the sub-list for method output_type - 17, // [17:57] is the sub-list for method input_type + 2, // 57: core.core.blockUserAllToken:input_type -> core.UUIDReq + 3, // 58: core.core.initDatabase:output_type -> core.BaseResp + 6, // 59: core.core.login:output_type -> core.LoginResp + 3, // 60: core.core.changePassword:output_type -> core.BaseResp + 3, // 61: core.core.createOrUpdateUser:output_type -> core.BaseResp + 9, // 62: core.core.getUserById:output_type -> core.UserInfoResp + 10, // 63: core.core.getUserList:output_type -> core.UserListResp + 3, // 64: core.core.deleteUser:output_type -> core.BaseResp + 3, // 65: core.core.updateProfile:output_type -> core.BaseResp + 3, // 66: core.core.createOrUpdateMenu:output_type -> core.BaseResp + 3, // 67: core.core.deleteMenu:output_type -> core.BaseResp + 16, // 68: core.core.getMenuListByRole:output_type -> core.MenuInfoList + 16, // 69: core.core.getMenuByPage:output_type -> core.MenuInfoList + 3, // 70: core.core.createOrUpdateMenuParam:output_type -> core.BaseResp + 3, // 71: core.core.deleteMenuParam:output_type -> core.BaseResp + 21, // 72: core.core.geMenuParamListByMenuId:output_type -> core.MenuParamListResp + 3, // 73: core.core.createOrUpdateRole:output_type -> core.BaseResp + 3, // 74: core.core.deleteRole:output_type -> core.BaseResp + 22, // 75: core.core.getRoleById:output_type -> core.RoleInfo + 23, // 76: core.core.getRoleList:output_type -> core.RoleListResp + 3, // 77: core.core.setRoleStatus:output_type -> core.BaseResp + 3, // 78: core.core.createOrUpdateApi:output_type -> core.BaseResp + 3, // 79: core.core.deleteApi:output_type -> core.BaseResp + 29, // 80: core.core.getApiList:output_type -> core.ApiListResp + 32, // 81: core.core.getMenuAuthority:output_type -> core.RoleMenuAuthorityResp + 3, // 82: core.core.createOrUpdateMenuAuthority:output_type -> core.BaseResp + 3, // 83: core.core.createOrUpdateDictionary:output_type -> core.BaseResp + 3, // 84: core.core.deleteDictionary:output_type -> core.BaseResp + 35, // 85: core.core.getDictionaryList:output_type -> core.DictionaryList + 36, // 86: core.core.getDetailByDictionaryName:output_type -> core.DictionaryDetailList + 3, // 87: core.core.createOrUpdateDictionaryDetail:output_type -> core.BaseResp + 3, // 88: core.core.deleteDictionaryDetail:output_type -> core.BaseResp + 3, // 89: core.core.createOrUpdateProvider:output_type -> core.BaseResp + 3, // 90: core.core.deleteProvider:output_type -> core.BaseResp + 42, // 91: core.core.getProviderList:output_type -> core.ProviderListResp + 40, // 92: core.core.oauthLogin:output_type -> core.OauthRedirectResp + 6, // 93: core.core.oauthCallback:output_type -> core.LoginResp + 3, // 94: core.core.createOrUpdateToken:output_type -> core.BaseResp + 3, // 95: core.core.deleteToken:output_type -> core.BaseResp + 45, // 96: core.core.getTokenList:output_type -> core.TokenListResp + 3, // 97: core.core.setTokenStatus:output_type -> core.BaseResp + 3, // 98: core.core.blockUserAllToken:output_type -> core.BaseResp + 58, // [58:99] is the sub-list for method output_type + 17, // [17:58] is the sub-list for method input_type 17, // [17:17] is the sub-list for extension type_name 17, // [17:17] is the sub-list for extension extendee 0, // [0:17] is the sub-list for field type_name diff --git a/rpc/types/core/core_grpc.pb.go b/rpc/types/core/core_grpc.pb.go index 8634a3f8..40e36d5c 100644 --- a/rpc/types/core/core_grpc.pb.go +++ b/rpc/types/core/core_grpc.pb.go @@ -72,6 +72,7 @@ type CoreClient interface { DeleteToken(ctx context.Context, in *IDReq, opts ...grpc.CallOption) (*BaseResp, error) GetTokenList(ctx context.Context, in *TokenListReq, opts ...grpc.CallOption) (*TokenListResp, error) SetTokenStatus(ctx context.Context, in *SetStatusReq, opts ...grpc.CallOption) (*BaseResp, error) + BlockUserAllToken(ctx context.Context, in *UUIDReq, opts ...grpc.CallOption) (*BaseResp, error) } type coreClient struct { @@ -442,6 +443,15 @@ func (c *coreClient) SetTokenStatus(ctx context.Context, in *SetStatusReq, opts return out, nil } +func (c *coreClient) BlockUserAllToken(ctx context.Context, in *UUIDReq, opts ...grpc.CallOption) (*BaseResp, error) { + out := new(BaseResp) + err := c.cc.Invoke(ctx, "/core.core/blockUserAllToken", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // CoreServer is the server API for Core service. // All implementations must embed UnimplementedCoreServer // for forward compatibility @@ -496,6 +506,7 @@ type CoreServer interface { DeleteToken(context.Context, *IDReq) (*BaseResp, error) GetTokenList(context.Context, *TokenListReq) (*TokenListResp, error) SetTokenStatus(context.Context, *SetStatusReq) (*BaseResp, error) + BlockUserAllToken(context.Context, *UUIDReq) (*BaseResp, error) mustEmbedUnimplementedCoreServer() } @@ -623,6 +634,9 @@ func (UnimplementedCoreServer) GetTokenList(context.Context, *TokenListReq) (*To func (UnimplementedCoreServer) SetTokenStatus(context.Context, *SetStatusReq) (*BaseResp, error) { return nil, status.Errorf(codes.Unimplemented, "method SetTokenStatus not implemented") } +func (UnimplementedCoreServer) BlockUserAllToken(context.Context, *UUIDReq) (*BaseResp, error) { + return nil, status.Errorf(codes.Unimplemented, "method BlockUserAllToken not implemented") +} func (UnimplementedCoreServer) mustEmbedUnimplementedCoreServer() {} // UnsafeCoreServer may be embedded to opt out of forward compatibility for this service. @@ -1356,6 +1370,24 @@ func _Core_SetTokenStatus_Handler(srv interface{}, ctx context.Context, dec func return interceptor(ctx, in, info, handler) } +func _Core_BlockUserAllToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UUIDReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(CoreServer).BlockUserAllToken(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/core.core/blockUserAllToken", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(CoreServer).BlockUserAllToken(ctx, req.(*UUIDReq)) + } + return interceptor(ctx, in, info, handler) +} + // Core_ServiceDesc is the grpc.ServiceDesc for Core service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -1523,6 +1555,10 @@ var Core_ServiceDesc = grpc.ServiceDesc{ MethodName: "setTokenStatus", Handler: _Core_SetTokenStatus_Handler, }, + { + MethodName: "blockUserAllToken", + Handler: _Core_BlockUserAllToken_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "core.proto",