apiutils

package
v0.0.0-...-9d5241d Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: AGPL-3.0 Imports: 15 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var OAuthOptionsCreater = func(ctx echo.Context, typ Type, generators ...sdk_options.URLValuesGenerator) OAuthOption {
	return NewOptions(ctx, TypeOAuth, generators...)
}

Functions

func AsRawData

func AsRawData(resp *sdk_options.Response) *echo.RawData

func Decrypt

func Decrypt(decrypted string, secret string) string

func Encrypt

func Encrypt(raw string, secret string) string

func GetCodeAndMsgFromAPIData

func GetCodeAndMsgFromAPIData(data map[string]any) (code, msg any)

func GetOAuthProviderTitle

func GetOAuthProviderTitle(list []*OAuthProvider, name string) string

func MakeFormValueGetter

func MakeFormValueGetter(ctx echo.Context) func(string) string

Types

type AppInfo

type AppInfo interface {
	GetAppSecret() string
	GetAppId() string
	IsOfficial() bool
}

type AppInfoFromAccount

type AppInfoFromAccount struct {
	Account   *dbschema.OfficialCommonApiAccount
	URLPrefix string
}

func (AppInfoFromAccount) GetApiEndpoint

func (a AppInfoFromAccount) GetApiEndpoint() string

func (AppInfoFromAccount) GetAppID

func (a AppInfoFromAccount) GetAppID() string

func (AppInfoFromAccount) GetAppSecret

func (a AppInfoFromAccount) GetAppSecret() string

type AppInfoFromOpenApp

type AppInfoFromOpenApp struct {
	App       AppInfo
	URLPrefix string
}

func (AppInfoFromOpenApp) GetApiEndpoint

func (a AppInfoFromOpenApp) GetApiEndpoint() string

func (AppInfoFromOpenApp) GetAppID

func (a AppInfoFromOpenApp) GetAppID() string

func (AppInfoFromOpenApp) GetAppSecret

func (a AppInfoFromOpenApp) GetAppSecret() string

type AppInfoGetter

type AppInfoGetter func(ctx echo.Context, cond db.Compound) (appInfo AppInfo, err error)
var AppInfoDefaultGetter AppInfoGetter = func(ctx echo.Context, cond db.Compound) (appInfo AppInfo, err error) {
	err = ctx.NewError(code.Unsupported, `尚未设置App信息获取方式`)
	return
}

type OAuthOption

type OAuthOption interface {
	GetAccountID() uint64
	ApplySetting() (err error)
	GetAppID() string
	OAuthProviderListURL() (string, error)
}

type OAuthProvider

type OAuthProvider struct {
	Name      string `json:"name" xml:"name"`
	English   string `json:"english" xml:"english"`
	IconClass string `json:"iconClass" xml:"iconClass"`
	IconImage string `json:"iconImage" xml:"iconImage"`
	WrapClass string `json:"wrapClass" xml:"wrapClass"`
	LoginURL  string `json:"loginURL" xml:"loginURL"`
}

func GetOAuthProvider

func GetOAuthProvider(list []*OAuthProvider, name string) *OAuthProvider

func OAuthProviders

func OAuthProviders(ctx echo.Context) ([]*OAuthProvider, error)

func OAuthProvidersFrom

func OAuthProvidersFrom(accounts []oauth2.Account) []*OAuthProvider

type OAuthProvidersResponse

type OAuthProvidersResponse struct {
	List []*OAuthProvider `json:"list"`
}

type Options

type Options struct {
	*sdk_options.Options
	// contains filtered or unexported fields
}

func NewOptions

func NewOptions(ctx echo.Context, typ Type, generators ...sdk_options.URLValuesGenerator) *Options

func (*Options) ApplySetting

func (o *Options) ApplySetting() (err error)

func (*Options) Context

func (o *Options) Context() echo.Context

func (*Options) GetAccountID

func (o *Options) GetAccountID() uint64

func (*Options) SetAppID

func (o *Options) SetAppID(appID string) *Options

func (*Options) SetAppInfoGetter

func (o *Options) SetAppInfoGetter(appInfoGetter AppInfoGetter) *Options

type Type

type Type = sdk_options.Type
const (
	// TypeOAuth 社区登录类型
	TypeOAuth Type = sdk_options.TypeOAuth
	// TypePayment 支付类型
	TypePayment Type = sdk_options.TypePayment
)

Jump to

Keyboard shortcuts

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