瀏覽代碼

Merge branch 'os-v3' of http://git.qjit.cn/yxh/gfast-open into os-v3

yxh 3 年之前
父節點
當前提交
6ca6d94c2a

+ 8 - 0
api/v1/system/sys_login.go

@@ -27,3 +27,11 @@ type UserLoginRes struct {
 	MenuList    []*model.UserMenus  `json:"menuList"`
 	Permissions []string            `json:"permissions"`
 }
+
+type UserLoginOutReq struct {
+	g.Meta        `path:"/loginOut" tags:"登录" method:"delete" summary:"退出登录"`
+	Authorization string `p:"Authorization" in:"header" dc:"Bearer {{token}}"`
+}
+
+type UserLoginOutRes struct {
+}

+ 1 - 1
go.mod

@@ -12,7 +12,7 @@ require (
 	github.com/mssola/user_agent v0.5.3
 	github.com/shirou/gopsutil v3.21.11+incompatible
 	github.com/tiger1103/gfast-cache v0.0.7
-	github.com/tiger1103/gfast-token v0.0.9
+	github.com/tiger1103/gfast-token v0.1.0
 	github.com/tklauser/go-sysconf v0.3.10 // indirect
 	github.com/yusufpapurcu/wmi v1.2.2 // indirect
 	go.opentelemetry.io/otel/sdk v1.6.1 // indirect

+ 2 - 2
go.sum

@@ -116,8 +116,8 @@ github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMT
 github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
 github.com/tiger1103/gfast-cache v0.0.7 h1:YRuSFxFdvNlIsHAndS7XjYRLd4tmXGWhvHt9rK0LVT0=
 github.com/tiger1103/gfast-cache v0.0.7/go.mod h1:s6cRWyr87wz6IJNGKRV6Ahq9hcuVz8h2PAtGrO66JO8=
-github.com/tiger1103/gfast-token v0.0.9 h1:+cKNu4zAMZpqaeILy3QIjuEO0HQMXtMSqVGPmhKAP90=
-github.com/tiger1103/gfast-token v0.0.9/go.mod h1:RnVRqmWD3h4qfTU1vJNXNhQjh2L5ht1vxLnjwShwGuY=
+github.com/tiger1103/gfast-token v0.1.0 h1:C41f0lZ5nLizHtgfRNvE3nf7hVQ+IO0dCCgg3a9/Oa4=
+github.com/tiger1103/gfast-token v0.1.0/go.mod h1:RnVRqmWD3h4qfTU1vJNXNhQjh2L5ht1vxLnjwShwGuY=
 github.com/tklauser/go-sysconf v0.3.10 h1:IJ1AZGZRWbY8T5Vfk04D9WOA5WSejdflXxP03OUqALw=
 github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk=
 github.com/tklauser/numcpus v0.4.0 h1:E53Dm1HjH1/R2/aoCtXtPgzmElmn51aOkhCFSuZq//o=

+ 1 - 1
internal/app/common/service/cache.go

@@ -38,5 +38,5 @@ func Cache() ICache {
 	} else {
 		ch.GfCache = cache.New(prefix)
 	}
-	return ICache(&ch)
+	return &ch
 }

+ 1 - 1
internal/app/common/service/captcha.go

@@ -32,7 +32,7 @@ var (
 )
 
 func Captcha() ICaptcha {
-	return ICaptcha(&captcha)
+	return &captcha
 }
 
 // GetVerifyImgString 获取字母数字混合验证码

+ 1 - 1
internal/app/common/service/middleware.go

@@ -18,7 +18,7 @@ type middlewareImpl struct{}
 var middleService = middlewareImpl{}
 
 func Middleware() IMiddleware {
-	return IMiddleware(&middleService)
+	return &middleService
 }
 
 func (s *middlewareImpl) MiddlewareCORS(r *ghttp.Request) {

+ 1 - 1
internal/app/common/service/sys_config.go

@@ -35,7 +35,7 @@ type configTmpl struct {
 var configService = configTmpl{}
 
 func Config() IConfig {
-	return IConfig(&configService)
+	return &configService
 }
 
 // List 系统参数列表

+ 1 - 1
internal/app/common/service/sys_dict_data.go

@@ -36,7 +36,7 @@ type dictDataImpl struct {
 var dictData = dictDataImpl{}
 
 func DictData() IDictData {
-	return IDictData(&dictData)
+	return &dictData
 }
 
 // GetDictWithDataByType 通过字典键类型获取选项

+ 1 - 1
internal/app/common/service/sys_dict_type.go

@@ -38,7 +38,7 @@ type dictTypeImpl struct {
 var dictTypeService = dictTypeImpl{}
 
 func DictType() IDictType {
-	return IDictType(&dictTypeService)
+	return &dictTypeService
 }
 
 // List 字典类型列表

+ 3 - 1
internal/app/common/service/token.go

@@ -20,6 +20,8 @@ type IGfToken interface {
 	Middleware(group *ghttp.RouterGroup) error
 	ParseToken(r *ghttp.Request) (*gftoken.CustomClaims, error)
 	IsLogin(r *ghttp.Request) (b bool, failed *gftoken.AuthFailed)
+	GetRequestToken(r *ghttp.Request) (token string)
+	RemoveToken(ctx context.Context, token string) (err error)
 }
 
 type gfTokenImpl struct {
@@ -45,5 +47,5 @@ func GfToken(options *model.TokenOptions) IGfToken {
 		gftoken.WithExcludePaths(options.ExcludePaths),
 		fun,
 	)
-	return IGfToken(&gT)
+	return &gT
 }

+ 6 - 0
internal/app/system/controller/sys_login.go

@@ -94,3 +94,9 @@ func (c *loginController) Login(ctx context.Context, req *system.UserLoginReq) (
 	}
 	return
 }
+
+// LoginOut 退出登录
+func (c *loginController) LoginOut(ctx context.Context, req *system.UserLoginOutReq) (res *system.UserLoginOutRes, err error) {
+	err = service.GfToken().RemoveToken(ctx, service.GfToken().GetRequestToken(g.RequestFromCtx(ctx)))
+	return
+}

+ 1 - 1
internal/app/system/service/context.go

@@ -28,7 +28,7 @@ var contextService = contextServiceImpl{}
 type contextServiceImpl struct{}
 
 func Context() IContext {
-	return IContext(&contextService)
+	return &contextService
 }
 
 // Init 初始化上下文对象指针到上下文对象中,以便后续的请求流程中可以修改。

+ 1 - 1
internal/app/system/service/middleware.go

@@ -28,7 +28,7 @@ type middlewareImpl struct{}
 var middleService = middlewareImpl{}
 
 func Middleware() IMiddleware {
-	return IMiddleware(&middleService)
+	return &middleService
 }
 
 // Ctx 自定义上下文对象

+ 1 - 1
internal/app/system/service/sys_auth_rule.go

@@ -43,7 +43,7 @@ type ruleImpl struct {
 var ruleService = ruleImpl{}
 
 func Rule() IRule {
-	return IRule(&ruleService)
+	return &ruleService
 }
 
 func (s *ruleImpl) GetMenuListSearch(ctx context.Context, req *system.RuleSearchReq) (res []*model.SysAuthRuleInfoRes, err error) {

+ 1 - 1
internal/app/system/service/sys_dept.go

@@ -35,7 +35,7 @@ type IDept interface {
 var deptService = deptImpl{}
 
 func Dept() IDept {
-	return IDept(&deptService)
+	return &deptService
 }
 
 type deptImpl struct {

+ 1 - 1
internal/app/system/service/sys_login_log.go

@@ -37,7 +37,7 @@ var (
 )
 
 func SysLoginLog() ISysLoginLog {
-	return ISysLoginLog(&sysLoginLogService)
+	return &sysLoginLogService
 }
 
 func (s *sysLoginLogImpl) Invoke(ctx context.Context, data *model.LoginLogParams) {

+ 1 - 1
internal/app/system/service/sys_post.go

@@ -33,7 +33,7 @@ type postImpl struct {
 var postService = postImpl{}
 
 func Post() IPost {
-	return IPost(&postService)
+	return &postService
 }
 
 // List 岗位列表

+ 1 - 1
internal/app/system/service/sys_role.go

@@ -37,7 +37,7 @@ type roleImpl struct {
 var roleService = roleImpl{}
 
 func Role() IRole {
-	return IRole(&roleService)
+	return &roleService
 }
 
 func (s *roleImpl) GetRoleListSearch(ctx context.Context, req *system.RoleListReq) (res *system.RoleListRes, err error) {

+ 1 - 1
internal/app/system/service/sys_user.go

@@ -58,7 +58,7 @@ var (
 )
 
 func User() IUser {
-	return IUser(&userService)
+	return &userService
 }
 
 func (s *userImpl) NotCheckAuthAdminIds(ctx context.Context) *gset.Set {