Documentation ¶
Index ¶
- Variables
- func CreateDictData(ctx context.Context, db *gorm.DB, dictData entity.DictData) error
- func CreateDictType(ctx context.Context, db *gorm.DB, name string, code string) error
- func GetDict(ctx context.Context, db *gorm.DB, id uint, preload bool) (entity.Dict, bool, error)
- func GetDictByCode(ctx context.Context, db *gorm.DB, code string, preload bool) (entity.Dict, bool, error)
- func GetDictData(ctx context.Context, db *gorm.DB, dId uint) (entity.DictData, bool, error)
- func GetDictDataByKey(ctx context.Context, db *gorm.DB, code string, key string) (entity.DictData, bool, error)
- func ListPageDictData(ctx context.Context, db *gorm.DB, option dict.DictDataPageOption) ([]entity.DictData, error)
- func ListPageDictType(ctx context.Context, db *gorm.DB, option dict.DictPageOption) ([]entity.Dict, error)
- func RemoveDictData(ctx context.Context, db *gorm.DB, ddId uint, force bool) error
- func RemoveDictType(ctx context.Context, db *gorm.DB, id uint) error
- func UpdateDictData(ctx context.Context, db *gorm.DB, dictData entity.DictData) error
- func UpdateDictType(ctx context.Context, db *gorm.DB, id uint, name string, code string) error
- type APIKeyHandler
- type ApiKey
- type AuthHandler
- type Authenticator
- func (a Authenticator) ChangePassword(ctx context.Context, newPassword string, code string) error
- func (a Authenticator) RefreshToken(ctx context.Context, accessToken string, refreshToken string) (authen.Token, error)
- func (a Authenticator) TryLogin(ctx context.Context, userName string, password string, persistent bool) (authen.Token, error)
- func (a Authenticator) TryLogout(ctx context.Context, tokenId string) error
- func (a Authenticator) TryRegisterNewUser(ctx context.Context, username string, password string, code string) error
- type DictHandler
- func (d DictHandler) CreateDict(ctx *gin.Context)
- func (d DictHandler) CreateDictData(ctx *gin.Context)
- func (d DictHandler) GetDictInfo(ctx *gin.Context)
- func (d DictHandler) ListDict(ctx *gin.Context)
- func (d DictHandler) ListDictData(ctx *gin.Context)
- func (d DictHandler) RemoveDict(ctx *gin.Context)
- func (d DictHandler) RemoveDictData(ctx *gin.Context)
- func (d DictHandler) UpdateDict(ctx *gin.Context)
- func (d DictHandler) UpdateDictData(ctx *gin.Context)
- type DictResolver
- func (d DictResolver) CreateDict(ctx context.Context, createOpt dict.DictSaveOption) error
- func (d DictResolver) CreateDictData(ctx context.Context, option dict.DictDataSaveOption) error
- func (d DictResolver) GetDictInfo(ctx context.Context, code string) ([]dict.DictDataInfo, error)
- func (d DictResolver) ListPageDict(ctx context.Context, option dict.DictPageOption) ([]dict.DictDetail, error)
- func (d DictResolver) ListPageDictData(ctx context.Context, option dict.DictDataPageOption) ([]dict.DictDataDetail, error)
- func (d DictResolver) RemoveDict(ctx context.Context, id uint) error
- func (d DictResolver) RemoveDictData(ctx context.Context, id uint) error
- func (d DictResolver) UpdateDict(ctx context.Context, updateOpt dict.DictUpdateOption) error
- func (d DictResolver) UpdateDictData(ctx context.Context, option dict.DictDataUpdateOption) error
- type Handler
- type HandlerRouter
- type PingApp
- type PingHandler
- type RoleEnforcer
- func (r RoleEnforcer) CreatePerm(option roleType.CreatePermOption) error
- func (r RoleEnforcer) CreateRole(option roleType.CreateRoleOption) error
- func (r RoleEnforcer) ListPerms(option roleType.PageOption) ([]roleType.PermInfo, error)
- func (r RoleEnforcer) ListRole(page roleType.PageOption) ([]roleType.RoleInfo, error)
- func (r RoleEnforcer) ListRolePerms(roleId uint) ([]roleType.PermGroup, error)
- func (r RoleEnforcer) RemovePerm(permId uint) error
- func (r RoleEnforcer) RemoveRole(roleId uint) error
- func (r RoleEnforcer) UpdatePerm(option roleType.UpdatePermOption) error
- func (r RoleEnforcer) UpdateRole(option roleType.UpdateRoleOption) error
- func (r RoleEnforcer) UpdateRolePerms(option roleType.GrantOption) error
- type RoleHandler
- func (r RoleHandler) CreatePermission(ctx *gin.Context)
- func (r RoleHandler) CreateRole(ctx *gin.Context)
- func (r RoleHandler) GetPermList(ctx *gin.Context)
- func (r RoleHandler) GetRoleList(ctx *gin.Context)
- func (r RoleHandler) GetRolePerms(ctx *gin.Context)
- func (r RoleHandler) GrantRolePerms(ctx *gin.Context)
- func (r RoleHandler) RemovePermission(ctx *gin.Context)
- func (r RoleHandler) RemoveRole(ctx *gin.Context)
- func (r RoleHandler) UpdatePermission(ctx *gin.Context)
- func (r RoleHandler) UpdateRole(ctx *gin.Context)
Constants ¶
This section is empty.
Variables ¶
var SystemProviderSet = wire.NewSet( NewPingHandler, NewPingLogic, NewAuthenticator, NewAuthHandler, NewRoleEnforcer, NewRoleHandler, NewAPIKey, NewAPIKeyHandler, NewDictResolver, NewDictHandler, )
var SystemRouterSet = wire.NewSet( SystemProviderSet, wire.Struct(new(Handler), "*"), SetupRouter, )
Functions ¶
func CreateDictData ¶
func CreateDictType ¶
func GetDictByCode ¶
func GetDictData ¶
func GetDictDataByKey ¶
func ListPageDictData ¶
func ListPageDictType ¶
func RemoveDictData ¶
func UpdateDictData ¶
Types ¶
type APIKeyHandler ¶
type APIKeyHandler struct {
// contains filtered or unexported fields
}
func NewAPIKeyHandler ¶
func NewAPIKeyHandler(apikey ApiKey) APIKeyHandler
func (APIKeyHandler) CreateAPIKey ¶
func (a APIKeyHandler) CreateAPIKey(ctx *gin.Context)
CreateAPIKey @Summary CreateAPIKey @Description create specified user api key @Tags key @Accept json @Produce json @Param KeyCreateOption body auth.KeyCreateOption true "KeyCreateOption" @Success 200 {object} types.Response @Router /key/create [POST] @security BearerAuth
func (APIKeyHandler) ListAPIKeys ¶
func (a APIKeyHandler) ListAPIKeys(ctx *gin.Context)
ListAPIKeys @Summary ListAPIKeys @Description list specified user api keys @Tags key @Accept json @Produce json @Success 200 {object} types.Response{data=[]auth.APIKey} @Router /key/list [GET] @security BearerAuth
func (APIKeyHandler) RemoveAPIKey ¶
func (a APIKeyHandler) RemoveAPIKey(ctx *gin.Context)
RemoveAPIKey @Summary RemoveAPIKey @Description remove specified api key @Tags key @Accept json @Produce json @Param KeyRemoveOption query auth.KeyRemoveOption true "KeyRemoveOption" @Success 200 {object} types.Response @Router /key/remove [DELETE] @security BearerAuth
type ApiKey ¶
func NewAPIKey ¶
func NewAPIKey(source *data.DataSource) ApiKey
func (ApiKey) CreateAPiKey ¶
func (ApiKey) ListApiKey ¶
type AuthHandler ¶
type AuthHandler struct {
// contains filtered or unexported fields
}
func NewAuthHandler ¶
func NewAuthHandler(authen Authenticator) AuthHandler
func (AuthHandler) ForgotPassword ¶
func (a AuthHandler) ForgotPassword(ctx *gin.Context)
ForgotPassword @Summary ForgotPassword @Description [guest] @Description forgot password @Tags auth @Accept json @Produce json @Param form body auth.ForgotPasswordOption true "Account ID" @Success 200 {object} types.Response @Router /auth/forgotpwd [POST]
func (AuthHandler) Login ¶
func (a AuthHandler) Login(ctx *gin.Context)
Login @Summary Login @Description [guest] @Description if login success, return jwt token @Tags auth @Accept json @Produce json @Param loginBody body auth.LoginOption true "comment" @Success 200 {object} types.Response{data=auth.Token} @Router /auth/login [POST]
func (AuthHandler) Logout ¶
func (a AuthHandler) Logout(ctx *gin.Context)
Logout @Summary Logout @Description user @Description user logout @Tags auth @Accept json @Produce json @Success 200 {object} types.Response @Router /auth/logout [DELETE] @security BearerAuth
func (AuthHandler) Refresh ¶
func (a AuthHandler) Refresh(ctx *gin.Context)
Refresh @Summary Refresh @Description [guest] @Description carry refresh token in query params, access token in header @Description if refresh-token expired , TokenRefresher will not refresh token [4012] @Description else if access-token has expired after delay duration, TokenRefresher will not refresh token [4012] @Description else if access-token has expired before delay duration, TokenRefresher will issue a new access-token [2005] @Description else if access-token has not expired, TokenRefresher will renewal the 1/10 access-token ttl per time [2005] @Description else if access-token has not expired, and ttl >= 2 * conf.JwtConf.Exp, TokenRefresher will not refresh token [4013] @Tags auth @Accept json @Produce json @Param refresh query string true "refresh token" @Success 200 {object} types.Response{data=auth.Token} @Router /auth/refresh [GET]
func (AuthHandler) Register ¶
func (a AuthHandler) Register(ctx *gin.Context)
Register @Summary Register @Description [guest] @Description user register api @Tags auth @Accept json @Produce json @Param registerBody body auth.RegisterOption true "comment" @Success 200 {object} types.Response @Router /auth/register [POST]
type Authenticator ¶
type Authenticator struct {
// contains filtered or unexported fields
}
func NewAuthenticator ¶
func NewAuthenticator(cfg *conf.AppConf, ds *data.DataSource, codeCache cache.RedisEmailCodeCache) Authenticator
func (Authenticator) ChangePassword ¶
func (Authenticator) RefreshToken ¶
func (Authenticator) TryLogout ¶
func (a Authenticator) TryLogout(ctx context.Context, tokenId string) error
func (Authenticator) TryRegisterNewUser ¶
type DictHandler ¶
type DictHandler struct {
// contains filtered or unexported fields
}
func NewDictHandler ¶
func NewDictHandler(dt DictResolver) DictHandler
func (DictHandler) CreateDict ¶
func (d DictHandler) CreateDict(ctx *gin.Context)
CreateDict @Summary CreateDict @Description create dict @Tags dict @Accept json @Produce json @Param DictSaveOption body dict.DictSaveOption true "DictSaveOption" @Success 200 {object} types.Response @Router /dict/create [POST] @security BearerAuth
func (DictHandler) CreateDictData ¶
func (d DictHandler) CreateDictData(ctx *gin.Context)
CreateDictData @Summary CreateDictData @Description get string by ID @Tags dict @Accept json @Produce json @Param DictDataSaveOption body dict.DictDataSaveOption true "DictDataSaveOption" @Success 200 {object} types.Response @Router /dict/data/create [POST] @security BearerAuth
func (DictHandler) GetDictInfo ¶
func (d DictHandler) GetDictInfo(ctx *gin.Context)
GetDictInfo @Summary GetDictInfo @Description get dict data info by code @Tags dict @Accept json @Produce json @Param code query dict.CodeOption true "dict id" @Success 200 {object} types.Response{data=[]dict.DictDataInfo} @Router /dict/info [GET] @security BearerAuth
func (DictHandler) ListDict ¶
func (d DictHandler) ListDict(ctx *gin.Context)
ListDict @Summary ListDict @Description list dict pages @Tags dict @Accept json @Produce json @Param page query dict.DictPageOption true "DictPageOption" @Success 200 {object} types.Response{data=[]dict.DictDetail} @Router /dict/list [GET] @security BearerAuth
func (DictHandler) ListDictData ¶
func (d DictHandler) ListDictData(ctx *gin.Context)
ListDictData @Summary ListDictData @Description list dict data @Tags dict @Accept json @Produce json @Param code query dict.DictDataPageOption true "dict code" @Success 200 {object} types.Response{data=[]dict.DictDataDetail} @Router /dict/data/list [GET] @security BearerAuth
func (DictHandler) RemoveDict ¶
func (d DictHandler) RemoveDict(ctx *gin.Context)
RemoveDict @Summary RemoveDict @Description remove dict @Tags dict @Accept json @Produce json @Param id query system.Id true "dict id" @Success 200 {object} types.Response @Router /dict/remove [DELETE] @security BearerAuth
func (DictHandler) RemoveDictData ¶
func (d DictHandler) RemoveDictData(ctx *gin.Context)
RemoveDictData @Summary RemoveDictData @Description get string by ID @Tags dict @Accept json @Produce json @Param system.Id query system.Id true "id" @Success 200 {object} types.Response @Router /dict/data/remove [DELETE] @security BearerAuth
func (DictHandler) UpdateDict ¶
func (d DictHandler) UpdateDict(ctx *gin.Context)
UpdateDict @Summary UpdateDict @Description update dict @Tags dict @Accept json @Produce json @Param DictUpdateOption body dict.DictUpdateOption true "DictUpdateOption" @Success 200 {object} types.Response @Router /dict/update [POST] @security BearerAuth
func (DictHandler) UpdateDictData ¶
func (d DictHandler) UpdateDictData(ctx *gin.Context)
UpdateDictData @Summary UpdateDictData @Description get string by ID @Tags dict @Accept json @Produce json @Param DictDataUpdateOption body dict.DictDataUpdateOption true "DictDataUpdateOption" @Success 200 {object} types.Response @Router /dict/data/update [POST] @security BearerAuth
type DictResolver ¶
type DictResolver struct {
// contains filtered or unexported fields
}
func NewDictResolver ¶
func NewDictResolver(ds *data.DataSource) DictResolver
func (DictResolver) CreateDict ¶
func (d DictResolver) CreateDict(ctx context.Context, createOpt dict.DictSaveOption) error
func (DictResolver) CreateDictData ¶
func (d DictResolver) CreateDictData(ctx context.Context, option dict.DictDataSaveOption) error
func (DictResolver) GetDictInfo ¶
func (d DictResolver) GetDictInfo(ctx context.Context, code string) ([]dict.DictDataInfo, error)
func (DictResolver) ListPageDict ¶
func (d DictResolver) ListPageDict(ctx context.Context, option dict.DictPageOption) ([]dict.DictDetail, error)
func (DictResolver) ListPageDictData ¶
func (d DictResolver) ListPageDictData(ctx context.Context, option dict.DictDataPageOption) ([]dict.DictDataDetail, error)
func (DictResolver) RemoveDict ¶
func (d DictResolver) RemoveDict(ctx context.Context, id uint) error
func (DictResolver) RemoveDictData ¶
func (d DictResolver) RemoveDictData(ctx context.Context, id uint) error
func (DictResolver) UpdateDict ¶
func (d DictResolver) UpdateDict(ctx context.Context, updateOpt dict.DictUpdateOption) error
func (DictResolver) UpdateDictData ¶
func (d DictResolver) UpdateDictData(ctx context.Context, option dict.DictDataUpdateOption) error
type Handler ¶
type Handler struct { Ping PingHandler Auth AuthHandler Role RoleHandler Key APIKeyHandler Dict DictHandler }
type HandlerRouter ¶
HandlerRouter just for wire injection, no real influence
func SetupRouter ¶
func SetupRouter(api *ginx.RouterGroup, handler Handler) HandlerRouter
type PingApp ¶
type PingApp struct {
// contains filtered or unexported fields
}
func NewPingLogic ¶
type PingHandler ¶
type PingHandler struct {
PingLogic PingApp
}
func NewPingHandler ¶
func NewPingHandler(logic PingApp) PingHandler
func (PingHandler) Ping ¶
func (p PingHandler) Ping(ctx *gin.Context)
Ping @Summary Ping @Description [guest] @Description test app api if is accessible @Tags system @Accept json @Produce json @Param name query system.PingRequest true "ping name" @Success 200 {object} types.Response{data=system.PingReply} @Router /ping [GET]
func (PingHandler) Pong ¶
func (p PingHandler) Pong(ctx *gin.Context)
Pong @Summary Pong @Description [guest] @Description test app api authentication if is work @Tags system @Accept json @Produce json @Param name query system.PingRequest true "pong name" @Success 200 {object} types.Response @Router /pong [GET]
type RoleEnforcer ¶
type RoleEnforcer struct {
// contains filtered or unexported fields
}
func NewRoleEnforcer ¶
func NewRoleEnforcer(source *data.DataSource) RoleEnforcer
func (RoleEnforcer) CreatePerm ¶
func (r RoleEnforcer) CreatePerm(option roleType.CreatePermOption) error
func (RoleEnforcer) CreateRole ¶
func (r RoleEnforcer) CreateRole(option roleType.CreateRoleOption) error
func (RoleEnforcer) ListPerms ¶
func (r RoleEnforcer) ListPerms(option roleType.PageOption) ([]roleType.PermInfo, error)
func (RoleEnforcer) ListRole ¶
func (r RoleEnforcer) ListRole(page roleType.PageOption) ([]roleType.RoleInfo, error)
func (RoleEnforcer) ListRolePerms ¶
func (r RoleEnforcer) ListRolePerms(roleId uint) ([]roleType.PermGroup, error)
func (RoleEnforcer) RemovePerm ¶
func (r RoleEnforcer) RemovePerm(permId uint) error
func (RoleEnforcer) RemoveRole ¶
func (r RoleEnforcer) RemoveRole(roleId uint) error
func (RoleEnforcer) UpdatePerm ¶
func (r RoleEnforcer) UpdatePerm(option roleType.UpdatePermOption) error
func (RoleEnforcer) UpdateRole ¶
func (r RoleEnforcer) UpdateRole(option roleType.UpdateRoleOption) error
func (RoleEnforcer) UpdateRolePerms ¶
func (r RoleEnforcer) UpdateRolePerms(option roleType.GrantOption) error
type RoleHandler ¶
type RoleHandler struct {
// contains filtered or unexported fields
}
func NewRoleHandler ¶
func NewRoleHandler(enforcer RoleEnforcer) RoleHandler
func (RoleHandler) CreatePermission ¶
func (r RoleHandler) CreatePermission(ctx *gin.Context)
CreatePermission @Summary CreatePermission @Description [admin] @Description create a new permission @Tags role @Accept json @Produce json @Param createPerm body role.CreatePermOption true "create perm" @Success 200 {object} types.Response @Router /perm/create [POST] @security BearerAuth
func (RoleHandler) CreateRole ¶
func (r RoleHandler) CreateRole(ctx *gin.Context)
CreateRole @Summary CreateRole @Description [admin] @Description create a new role @Tags role @Accept json @Produce json @Param createRole body role.CreateRoleOption true "create role" @Success 200 {object} types.Response @Router /role/create [POST] @security BearerAuth
func (RoleHandler) GetPermList ¶
func (r RoleHandler) GetPermList(ctx *gin.Context)
GetPermList @Summary GetPermList @Description [admin] @Description Get Permission list by page @Tags role @Accept json @Produce json @Param page query role.PageOption true "page option" @Success 200 {object} types.Response{data=[]role.PermInfo} @Router /perm/list [GET] @security BearerAuth
func (RoleHandler) GetRoleList ¶
func (r RoleHandler) GetRoleList(ctx *gin.Context)
GetRoleList @Summary GetRoleList @Description [admin] @Description get role list by page @Tags role @Accept json @Produce json @Param page query role.PageOption true "page option" @Success 200 {object} types.Response{data=[]role.RoleInfo} @Router /role/list [GET] @security BearerAuth
func (RoleHandler) GetRolePerms ¶
func (r RoleHandler) GetRolePerms(ctx *gin.Context)
GetRolePerms @Summary GetRolePerms @Description [admin] @Description get permissions list belong to role @Tags role @Accept json @Produce json @Param queryOpt query system.Id true "role perms query opt" @Success 200 {object} types.Response{data=[]role.PermGroup} @Router /role/perms [GET] @security BearerAuth
func (RoleHandler) GrantRolePerms ¶
func (r RoleHandler) GrantRolePerms(ctx *gin.Context)
GrantRolePerms @Summary GrantRolePerms @Description [admin] @Description grant permissions for the specified role @Tags role @Accept json @Produce json @Param GrantOption body role.GrantOption true "grant role" @Success 200 {object} types.Response @Router /role/grant [POST] @security BearerAuth
func (RoleHandler) RemovePermission ¶
func (r RoleHandler) RemovePermission(ctx *gin.Context)
RemovePermission @Summary RemovePermission @Description [admin] @Description remove the specified permission @Tags role @Accept json @Produce json @Param id query system.Id true "perm id" @Success 200 {object} types.Response @Router /perm/remove [DELETE] @security BearerAuth
func (RoleHandler) RemoveRole ¶
func (r RoleHandler) RemoveRole(ctx *gin.Context)
RemoveRole @Summary RemoveRole @Description [admin] @Description remove a role,and its permission record will be deleted too @Tags role @Accept json @Produce json @Param id query system.Id true "roleD id" @Success 200 {object} types.Response @Router /role/remove [DELETE] @security BearerAuth
func (RoleHandler) UpdatePermission ¶
func (r RoleHandler) UpdatePermission(ctx *gin.Context)
UpdatePermission @Summary UpdatePermission @Description [admin] @Description update the specified permission info @Tags role @Accept json @Produce json @Param updatePermOpt body role.UpdatePermOption true "update perm" @Success 200 {object} types.Response @Router /perm/update [POST] @security BearerAuth
func (RoleHandler) UpdateRole ¶
func (r RoleHandler) UpdateRole(ctx *gin.Context)
UpdateRole @Summary UpdateRole @Description [admin] @Description update the specified role info @Tags role @Accept json @Produce json @Param updateRole body role.UpdateRoleOption true "update role" @Success 200 {object} types.Response @Router /role/update [POST] @security BearerAuth