auth

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	gorm.Model

	AppID       string `gorm:"column:app_id" json:"app_id"`             // Application ID
	AppName     string `gorm:"column:app_name" json:"app_name"`         // Application Name
	AppSecret   string `gorm:"column:app_secret" json:"app_secret"`     // Application Secret Key
	RedirectUri string `gorm:"column:redirect_uri" json:"redirect_uri"` // Redirect URI after authorization
	Description string `gorm:"column:description" json:"description"`   // Description
	Status      int8   `gorm:"column:status" json:"status"`             // 1: Active; 2: Disabled
}

func (*App) BatchInsert added in v1.4.0

func (a *App) BatchInsert(ctx context.Context, db *gorm.DB, apps []App) error

BatchInsert inserts multiple apps into the database in a single batch operation.

Parameters: - ctx: context.Context for managing request-scoped values, cancellation signals, and deadlines. - db: *gorm.DB database connection. - apps: slice of App instances to be inserted.

Returns: - error: error if the batch insert operation fails, otherwise nil.

func (*App) Count added in v1.4.0

func (a *App) Count(ctx context.Context, db *gorm.DB) (int64, error)

Count counts the number of apps matching the criteria in the database.

Parameters: - ctx: context.Context for managing request-scoped values, cancellation signals, and deadlines. - db: *gorm.DB database connection.

Returns: - int64: count of matching apps. - error: error if the count operation fails, otherwise nil.

func (*App) CountByArgs added in v1.4.0

func (a *App) CountByArgs(ctx context.Context, db *gorm.DB, query interface{}, args ...interface{}) (int64, error)

CountByArgs counts the number of apps matching the specified query and arguments in the database.

Parameters: - ctx: context.Context for managing request-scoped values, cancellation signals, and deadlines. - db: *gorm.DB database connection. - query: SQL query string. - args: variadic arguments for the SQL query.

Returns: - int64: count of matching apps. - error: error if the count operation fails, otherwise nil.

func (*App) Create

func (a *App) Create(ctx context.Context, db *gorm.DB) (uint, error)

Create inserts a new app into the database and returns the ID of the created App.

Parameters: - ctx: context.Context for managing request-scoped values, cancellation signals, and deadlines. - db: *gorm.DB database connection.

Returns: - uint: ID of the created app. - error: error if the insert operation fails, otherwise nil.

func (*App) Delete

func (a *App) Delete(ctx context.Context, db *gorm.DB) error

Delete removes the app from the database.

Parameters: - ctx: context.Context for managing request-scoped values, cancellation signals, and deadlines. - db: *gorm.DB database connection.

Returns: - error: error if the delete operation fails, otherwise nil.

func (*App) FindWithPagination added in v1.4.0

func (a *App) FindWithPagination(ctx context.Context, db *gorm.DB, page, size int) ([]App, error)

FindWithPagination retrieves apps matching the criteria from the database with pagination support.

Parameters: - ctx: context.Context for managing request-scoped values, cancellation signals, and deadlines. - db: *gorm.DB database connection. - page: page number for pagination (1-based). - size: number of apps per page.

Returns: - []App: slice of retrieved apps. - error: error if the query fails, otherwise nil.

func (*App) FindWithSort added in v1.4.0

func (a *App) FindWithSort(ctx context.Context, db *gorm.DB, sort string) ([]App, error)

FindWithSort retrieves apps matching the criteria from the database with sorting support.

Parameters: - ctx: context.Context for managing request-scoped values, cancellation signals, and deadlines. - db: *gorm.DB database connection. - sort: sorting criteria (e.g., "id desc").

Returns: - []App: slice of retrieved apps. - error: error if the query fails, otherwise nil.

func (*App) First

func (a *App) First(ctx context.Context, db *gorm.DB) (*App, error)

First retrieves the first app matching the criteria from the database.

Parameters: - ctx: context.Context for managing request-scoped values, cancellation signals, and deadlines. - db: *gorm.DB database connection.

Returns: - *App: pointer to the retrieved app, or nil if not found. - error: error if the query fails, otherwise nil.

func (*App) Last added in v1.4.0

func (a *App) Last(ctx context.Context, db *gorm.DB) (*App, error)

Last retrieves the last app matching the criteria from the database, ordered by ID in descending order.

Parameters: - ctx: context.Context for managing request-scoped values, cancellation signals, and deadlines. - db: *gorm.DB database connection.

Returns: - *App: pointer to the retrieved app, or nil if not found. - error: error if the query fails, otherwise nil.

func (*App) List added in v1.4.0

func (a *App) List(ctx context.Context, db *gorm.DB) ([]App, error)

List retrieves all apps matching the criteria from the database.

Parameters: - ctx: context.Context for managing request-scoped values, cancellation signals, and deadlines. - db: *gorm.DB database connection.

Returns: - []App: slice of retrieved apps. - error: error if the query fails, otherwise nil.

func (*App) ListByArgs added in v1.4.0

func (a *App) ListByArgs(ctx context.Context, db *gorm.DB, query interface{}, args ...interface{}) ([]App, error)

ListByArgs retrieves apps matching the specified query and arguments from the database, ordered by ID in descending order.

Parameters: - ctx: context.Context for managing request-scoped values, cancellation signals, and deadlines. - db: *gorm.DB database connection. - query: SQL query string. - args: variadic arguments for the SQL query.

Returns: - []App: slice of retrieved apps. - error: error if the query fails, otherwise nil.

func (*App) TableName

func (a *App) TableName() string

TableName specifies the table name for the App model.

func (*App) Updates

func (a *App) Updates(ctx context.Context, db *gorm.DB, updates map[string]interface{}) error

Updates applies the specified updates to the app in the database.

Parameters: - ctx: context.Context for managing request-scoped values, cancellation signals, and deadlines. - db: *gorm.DB database connection. - updates: map[string]interface{} containing the updates to apply.

Returns: - error: error if the update operation fails, otherwise nil.

type MgoApp added in v1.4.0

type MgoApp struct {
	ID          primitive.ObjectID `json:"id" bson:"_id,omitempty"`
	AppName     string             `bson:"app_name" json:"app_name"`
	AppID       string             `bson:"app_id" json:"app_id"`
	AppSecret   string             `bson:"app_secret" json:"app_secret"`
	RedirectUri string             `bson:"redirect_uri" json:"redirect_uri"`
	Description string             `bson:"description" json:"description"`
	Status      uint8              `bson:"status" json:"status"`
}

func (*MgoApp) CollectionName added in v1.4.0

func (a *MgoApp) CollectionName() string

func (*MgoApp) Count added in v1.4.0

func (a *MgoApp) Count(ctx context.Context, db *qmgo.Database) (int64, error)

func (*MgoApp) Create added in v1.4.0

func (a *MgoApp) Create(ctx context.Context, db *qmgo.Database) (string, error)

func (*MgoApp) Creates added in v1.4.0

func (a *MgoApp) Creates(ctx context.Context, db *qmgo.Database, apps []MgoApp) ([]primitive.ObjectID, error)

func (*MgoApp) Delete added in v1.4.0

func (a *MgoApp) Delete(ctx context.Context, db *qmgo.Database) error

func (*MgoApp) FindWithSort added in v1.4.0

func (a *MgoApp) FindWithSort(ctx context.Context, db *qmgo.Database, sort string) ([]MgoApp, error)

func (*MgoApp) First added in v1.4.0

func (a *MgoApp) First(ctx context.Context, db *qmgo.Database) (*MgoApp, error)

func (*MgoApp) Last added in v1.4.0

func (a *MgoApp) Last(ctx context.Context, db *qmgo.Database) (*MgoApp, error)

func (*MgoApp) List added in v1.4.0

func (a *MgoApp) List(ctx context.Context, db *qmgo.Database) ([]MgoApp, error)

func (*MgoApp) Pagination added in v1.4.0

func (a *MgoApp) Pagination(ctx context.Context, db *qmgo.Database, page, size int) ([]MgoApp, error)

func (*MgoApp) Updates added in v1.4.0

func (a *MgoApp) Updates(ctx context.Context, db *qmgo.Database, updates bson.M) error

Jump to

Keyboard shortcuts

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