userapp

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 2, 2025 License: Apache-2.0 Imports: 23 Imported by: 0

README

UserApp

提供用户相关的基础功能

支持功能

目前支持功能:

  • 注册/登录
  • 登录日志查看
  • 手机/邮箱验证码发送
  • 第三方登录,如wechat/qq等
  • 用户管理的功能

Swagger-API

API文档地址: http://127.0.0.1:40101/swagger/userservice/doc.json

使用说明

用户管理站AuthHandler

主要用于实现对接其他系统的授权体系

可通过userapp/App下的AdminAuthOption选项配置对应的授权检查handler

示例:

设置为adminApp模块提供的AuthHandler


userApp.ApiServer.AdminAuthOption.AuthHandler = adminApp.ApiServer.OptAuthHandler()

自定义授权handler


userApp.ApiServer.AdminAuthOption.AuthHandler = func(ctx *gin.Context) {
		d, _ := ctx.Get(consts.AuthInfoContextKey)
		logger.Info("%+v", d)

		token:=ctx.GetHeader("x-token")
		if token!="xxx"{
			ctx.AbortWithStatusJSON(http.StatusOK, respdata.CAuthDenied)
			return
		}
		
		gin_http.SetAuth(ctx,&dto.AuthDataPacket{Auth: dto.AuthInfo{Id: 2,}})
	}
用户AuthHandler

可通过userapp/App下的AuthOption选项获取userApp的C端用户AuthHandler

xxAdmin.AuthOption.AuthHandler=userApp.ApiServer.AuthOption.OptAuthHandler()

Documentation

Overview

@externalDocs.description OpenAPI @externalDocs.url https://swagger.io/resources/open-api/

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConfig

func NewConfig() *configstc.UserAppConfig

NewConfig godoc @Summary CONFIG-配置 @Description CONFIG-配置内容 @Tags user @Produce json @Success 200 {array} configstc.UserAppConfig @Router /-user-config [post]

Types

type ApiServer

type ApiServer struct {
	*apps.ApiServer

	gin_http.AuthOption    //auth相关选项配置
	gin_http.SwaggerOption //swagger相关选项配置
	gin_http.PProfOption   //pprof选项配置
	gin_http.OperateLogOption

	AdminAuthOption gin_http.AuthOption //auth相关选项配置
	// contains filtered or unexported fields
}

func NewApiServer

func NewApiServer(di *dig.Container, conf *configstc.UserAppConfig, logger v1log.ILog) *ApiServer

func (*ApiServer) InitRouter

func (s *ApiServer) InitRouter()

func (*ApiServer) InitRouterForGin

func (s *ApiServer) InitRouterForGin(engine *gin.Engine)

func (*ApiServer) Name

func (s *ApiServer) Name() string

func (*ApiServer) Start

func (s *ApiServer) Start() error

func (*ApiServer) Stop

func (s *ApiServer) Stop() error

type App

type App struct {
	*apps.App

	ApiServer *ApiServer
	RpcServer *RpcServer
	// contains filtered or unexported fields
}

func NewApp

func NewApp(di *dig.Container, conf *configstc.UserAppConfig, logger v1log.ILog) *App

type RpcServer

type RpcServer struct {
	// contains filtered or unexported fields
}

func NewRpcServer

func NewRpcServer(di *dig.Container, conf *configstc.UserAppConfig, logger v1log.ILog) *RpcServer

func (*RpcServer) RegisterService

func (s *RpcServer) RegisterService() error

func (*RpcServer) RegisterServiceForGRpc

func (s *RpcServer) RegisterServiceForGRpc(server *grpc.Server) error

func (*RpcServer) Start

func (s *RpcServer) Start() error

func (*RpcServer) Stop

func (s *RpcServer) Stop() error

func (*RpcServer) WithModule

func (s *RpcServer) WithModule(t bool)

Directories

Path Synopsis
controllers
Package docs Code generated by swaggo/swag.
Package docs Code generated by swaggo/swag.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL