gormservice

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2024 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommonService

type CommonService struct {
	*gorm.Client
	// contains filtered or unexported fields
}

func NewCommonService

func NewCommonService(name string, client *gorm.Client) *CommonService

func (CommonService) AppAuthorization

func (c CommonService) AppAuthorization(ctx context.Context, key string, secret string) (id string, err error)

func (CommonService) Authorization

func (c CommonService) Authorization(ctx context.Context, roles []string, method string) bool

func (CommonService) AutoMigrate

func (c CommonService) AutoMigrate(ctx context.Context) error

func (CommonService) BatchPatchI18n

func (c CommonService) BatchPatchI18n(ctx context.Context, i18ns []models.I18nTranslate) (err error)

func (CommonService) CreateAppKey

func (c CommonService) CreateAppKey(ctx context.Context, appId, name string) (*models.AppKey, error)

func (CommonService) CreateOrUpdateRoleByName

func (c CommonService) CreateOrUpdateRoleByName(ctx context.Context, role *models.Role) error

func (CommonService) CreatePage

func (c CommonService) CreatePage(ctx context.Context, page *models.PageConfig) error

func (*CommonService) CreatePageData

func (c *CommonService) CreatePageData(ctx context.Context, pageId string, data *json.RawMessage) error

func (*CommonService) CreateRole

func (c *CommonService) CreateRole(ctx context.Context, role *models.Role) (err error)

func (*CommonService) CreateTOTP

func (c *CommonService) CreateTOTP(ctx context.Context, id string, secret string) error

func (*CommonService) DeleteAppAccessControl

func (c *CommonService) DeleteAppAccessControl(ctx context.Context, ids ...string) error

func (CommonService) DeleteAppKeys

func (c CommonService) DeleteAppKeys(ctx context.Context, appId string, id []string) (affected int64, err error)

func (*CommonService) DeleteAppProxy

func (c *CommonService) DeleteAppProxy(ctx context.Context, ids ...string) error

func (*CommonService) DeleteI18nBySourceId

func (c *CommonService) DeleteI18nBySourceId(ctx context.Context, ids ...string) error

func (CommonService) DeletePages

func (c CommonService) DeletePages(ctx context.Context, ids []string) error

func (CommonService) DeleteRoles

func (c CommonService) DeleteRoles(ctx context.Context, ids []string) error

func (CommonService) FindAppByKeywords added in v1.4.0

func (c CommonService) FindAppByKeywords(ctx context.Context, keywords string, skip int64, limit int64) (ids []string, count int64)

func (CommonService) GetAppAccessControl

func (c CommonService) GetAppAccessControl(ctx context.Context, appId string, o ...opts.WithGetAppOptions) (users models.AppUsers, roles models.AppRoles, err error)

func (CommonService) GetAppKeyFromKey

func (c CommonService) GetAppKeyFromKey(ctx context.Context, key string) (*models.AppKey, error)

func (CommonService) GetAppKeys

func (c CommonService) GetAppKeys(ctx context.Context, appId string, current, pageSize int64) (count int64, keyPairs []*models.AppKey, err error)

func (CommonService) GetAppOAuthConfig added in v1.4.0

func (c CommonService) GetAppOAuthConfig(ctx context.Context, id string) (*models.AppOAuth2, error)

func (CommonService) GetAppProxyConfig

func (c CommonService) GetAppProxyConfig(ctx context.Context, appId string) (proxy *models.AppProxy, err error)

func (CommonService) GetAppRoleByUserId

func (c CommonService) GetAppRoleByUserId(ctx context.Context, appId string, userId string) (role *models.AppRole, err error)

func (CommonService) GetAppRoles

func (c CommonService) GetAppRoles(ctx context.Context, appId string) (roles models.AppRoles, err error)

func (CommonService) GetFileInfoFromId

func (c CommonService) GetFileInfoFromId(ctx context.Context, id string) (fileName, mimiType, filePath string, err error)

func (CommonService) GetFilesByOwner

func (c CommonService) GetFilesByOwner(ctx context.Context, owner string, current int64, pageSize int64) (count int64, files []*models.Model, err error)

func (*CommonService) GetI18n

func (c *CommonService) GetI18n(ctx context.Context, source string, sourceId string, field string) (map[string]string, error)

func (*CommonService) GetPage

func (c *CommonService) GetPage(ctx context.Context, id string) (cfg *models.PageConfig, err error)

func (*CommonService) GetPageData

func (c *CommonService) GetPageData(ctx context.Context, pageId string, id string) (*models.PageData, error)

func (*CommonService) GetPageDatas

func (c *CommonService) GetPageDatas(ctx context.Context, filters map[string]string, keywords string, current int64, pageSize int64) (count int64, datas []*models.PageData, err error)

func (CommonService) GetPages

func (c CommonService) GetPages(ctx context.Context, filter map[string]interface{}, keywords string, current int64, pageSize int64) (count int64, pages []*models.PageConfig, err error)

func (CommonService) GetPermissions

func (c CommonService) GetPermissions(ctx context.Context, keywords string, current int64, pageSize int64) (count int64, permissions []*models.Permission, err error)

func (CommonService) GetProxyConfig

func (c CommonService) GetProxyConfig(ctx context.Context, host string) (*models.AppProxyConfig, error)

func (*CommonService) GetRoles

func (c *CommonService) GetRoles(ctx context.Context, keywords string, current, pageSize int64) (count int64, roles []*models.Role, err error)

func (CommonService) GetSystemConfig

func (c CommonService) GetSystemConfig(ctx context.Context, prefix string) (map[string]interface{}, error)

func (*CommonService) GetTOTPSecrets

func (c *CommonService) GetTOTPSecrets(ctx context.Context, ids []string) (secrets []string, err error)

func (*CommonService) GetUserExtendedData

func (c *CommonService) GetUserExtendedData(ctx context.Context, id string) (*models.UserExt, error)

func (*CommonService) GetUsersExtendedData

func (c *CommonService) GetUsersExtendedData(ctx context.Context, id []string) ([]*models.UserExt, error)

func (CommonService) InsertWeakPassword

func (c CommonService) InsertWeakPassword(ctx context.Context, passwords ...string) error

func (CommonService) Name

func (c CommonService) Name() string

func (CommonService) PatchAppOAuthConfig added in v1.4.0

func (c CommonService) PatchAppOAuthConfig(ctx context.Context, auth2 *models.AppOAuth2) error

func (CommonService) PatchAppRole

func (c CommonService) PatchAppRole(ctx context.Context, role *models.AppRole) error

PatchAppRole

@Description[en-US]: Update App Role.
@Description[zh-CN]: 更新应用角色。
@param ctx     context.Context
@param dn      string
@param patch   *models.AppRole
@return err    error

func (*CommonService) PatchPageDatas

func (c *CommonService) PatchPageDatas(ctx context.Context, patch []models.PageData) error

func (*CommonService) PatchPages

func (c *CommonService) PatchPages(ctx context.Context, patch []map[string]interface{}) error

func (CommonService) PatchSystemConfig

func (c CommonService) PatchSystemConfig(ctx context.Context, prefix string, patch map[string]interface{}) error

func (*CommonService) PatchUserExtData

func (c *CommonService) PatchUserExtData(ctx context.Context, id string, patch map[string]interface{}) error

func (CommonService) RecordUploadFile

func (c CommonService) RecordUploadFile(ctx context.Context, name string, path string, contentType string, size int64) (id string, err error)

func (CommonService) RegisterPermission

func (c CommonService) RegisterPermission(ctx context.Context, permissions models.Permissions) error

func (CommonService) UpdateAppAccessControl

func (c CommonService) UpdateAppAccessControl(ctx context.Context, app *models.App) (err error)

func (CommonService) UpdateAppProxyConfig

func (c CommonService) UpdateAppProxyConfig(ctx context.Context, proxy *models.AppProxy) (err error)

func (CommonService) UpdateFileOwner

func (c CommonService) UpdateFileOwner(ctx context.Context, fileId string, owner string) (err error)

func (*CommonService) UpdateLoginTime

func (c *CommonService) UpdateLoginTime(ctx context.Context, id string) error

UpdateLoginTime

@Description[en-US]: Update the user's last login time.
@Description[zh-CN]: 更新用户最后一次登陆时间。
@param ctx 	context.Context
@param id 	string
@return error

func (CommonService) UpdatePage

func (c CommonService) UpdatePage(ctx context.Context, page *models.PageConfig) error

func (*CommonService) UpdatePageData

func (c *CommonService) UpdatePageData(ctx context.Context, pageId string, id string, data *json.RawMessage) error

func (*CommonService) UpdateRole

func (c *CommonService) UpdateRole(ctx context.Context, role *models.Role) (err error)

func (CommonService) UpdateUserAccessControl

func (c CommonService) UpdateUserAccessControl(ctx context.Context, userId string, apps models.Apps) (err error)

func (*CommonService) VerifyAndRecordHistoryPassword

func (c *CommonService) VerifyAndRecordHistoryPassword(ctx context.Context, id string, password string) error

func (CommonService) VerifyWeakPassword

func (c CommonService) VerifyWeakPassword(ctx context.Context, password string) error

type EventBuffers

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

func (*EventBuffers) PutEvent

func (b *EventBuffers) PutEvent(ctx context.Context, eventId, userId, username, clientIP, loc, action, message string, status bool, took time.Duration, logItems ...interface{}) error

type LoggingService

type LoggingService struct {
	*gorm.Client
	// contains filtered or unexported fields
}

func NewLoggingService

func NewLoggingService(ctx context.Context, name string, client *gorm.Client) *LoggingService

func (*LoggingService) AutoMigrate

func (s *LoggingService) AutoMigrate(ctx context.Context) error

func (*LoggingService) GetEventLogs

func (s *LoggingService) GetEventLogs(ctx context.Context, filters map[string]string, keywords string, current int64, pageSize int64) (count int64, eventLogs []*models.EventLog, err error)

func (*LoggingService) GetEvents

func (s *LoggingService) GetEvents(ctx context.Context, filters map[string]string, keywords string, startTime time.Time, endTime time.Time, current int64, pageSize int64) (count int64, events []*models.Event, err error)

func (*LoggingService) Name

func (s *LoggingService) Name() string

func (*LoggingService) PostEventLog

func (s *LoggingService) PostEventLog(ctx context.Context, eventId, userId, username, clientIP, loc, action, message string, status bool, took time.Duration, logItems ...interface{}) error

func (*LoggingService) Pusher

func (s *LoggingService) Pusher(ctx context.Context)

type SessionService

type SessionService struct {
	*gorm.Client
	// contains filtered or unexported fields
}

func NewSessionService

func NewSessionService(ctx context.Context, name string, client *gorm.Client) *SessionService

func (SessionService) AutoMigrate

func (s SessionService) AutoMigrate(ctx context.Context) error

func (SessionService) Counter

func (s SessionService) Counter(ctx context.Context, seed string, expireTime *time.Time, num ...int64) (err error)

func (SessionService) CreateToken

func (s SessionService) CreateToken(ctx context.Context, token *models.Token) error

func (SessionService) DeleteToken

func (s SessionService) DeleteToken(ctx context.Context, tokenType models.TokenType, id string) (err error)

func (SessionService) GetCounter

func (s SessionService) GetCounter(ctx context.Context, seed string) (count int64, err error)

func (SessionService) GetSessions

func (s SessionService) GetSessions(ctx context.Context, userId string, current, pageSize int64) (total int64, sessions []*models.Token, err error)

func (SessionService) GetToken

func (s SessionService) GetToken(ctx context.Context, tokenId string, tokenType models.TokenType, relationId ...string) (*models.Token, error)

func (SessionService) Name

func (s SessionService) Name() string

func (SessionService) RefreshOAuthTokenByAuthorizationCode

func (s SessionService) RefreshOAuthTokenByAuthorizationCode(ctx context.Context, token, clientId, clientSecret string) (accessToken, refreshToken string, expiresIn int, err error)

func (SessionService) RefreshOAuthTokenByPassword

func (s SessionService) RefreshOAuthTokenByPassword(ctx context.Context, token, username, password string) (accessToken, refreshToken string, expiresIn int, err error)

func (SessionService) UpdateToken

func (s SessionService) UpdateToken(ctx context.Context, token *models.Token) error

func (SessionService) UpdateTokenExpires

func (s SessionService) UpdateTokenExpires(ctx context.Context, id string, expiry time.Time) error

type UserAndAppService

type UserAndAppService struct {
	*gorm.Client
	// contains filtered or unexported fields
}

func NewUserAndAppService

func NewUserAndAppService(_ context.Context, name string, client *gorm.Client) *UserAndAppService

func (UserAndAppService) AutoMigrate

func (s UserAndAppService) AutoMigrate(ctx context.Context) error

func (UserAndAppService) CreateApp

func (s UserAndAppService) CreateApp(ctx context.Context, app *models.App) (err error)

CreateApp

@Description[en-US]: Create an app.
@Description[zh-CN]: 创建应用
@param ctx        context.Context
@param app        *models.App
@return error

func (UserAndAppService) CreateUser

func (s UserAndAppService) CreateUser(ctx context.Context, user *models.User) (err error)

CreateUser

@Description[en-US]: Create a user.
@Description[zh-CN]: 创建用户。
@param ctx 	context.Context
@param user 	*models.User
@return err	error

func (UserAndAppService) DeleteApp

func (s UserAndAppService) DeleteApp(ctx context.Context, id string) (err error)

DeleteApp

@Description[en-US]: Delete an app.
@Description[zh-CN]: 删除应用。
@param ctx 	context.Context
@param id 	string
@return err	error

func (UserAndAppService) DeleteApps

func (s UserAndAppService) DeleteApps(ctx context.Context, id ...string) (total int64, err error)

DeleteApps

@Description[en-US]: Delete apps in batch.
@Description[zh-CN]: 批量删除应用。
@param ctx     context.Context
@param ids     []string         : ID List
@return total  int64
@return err    error

func (UserAndAppService) DeleteUser

func (s UserAndAppService) DeleteUser(ctx context.Context, id string) (err error)

DeleteUser

@Description[en-US]: Delete a user.
@Description[zh-CN]: 删除用户。
@param ctx 	context.Context
@param id 	string
@return error

func (UserAndAppService) DeleteUsers

func (s UserAndAppService) DeleteUsers(ctx context.Context, id []string) (int64, error)

DeleteUsers

@Description[en-US]: Delete users in batch.
@Description[zh-CN]: 批量删除用户。
@param ctx 		context.Context
@param ids 		[]string
@return count	int64
@return err		error

func (UserAndAppService) GetAppInfo

func (s UserAndAppService) GetAppInfo(ctx context.Context, options ...opts.WithGetAppOptions) (app *models.App, err error)

GetAppInfo

@Description[en-US]: Use the ID or application name to get app info.
@Description[zh-CN]: 使用ID或应用名称获取应用信息。
@param ctx  context.Context
@param id   string          : App ID
@param name string          : App Name
@return app *models.App     : App Details
@return err error

func (UserAndAppService) GetApps

func (s UserAndAppService) GetApps(ctx context.Context, keywords string, filters map[string]interface{}, current, pageSize int64) (total int64, apps []*models.App, err error)

GetApps

@Description[en-US]: Get the application list. The application information does not include agent, role, user and other information.
@Description[zh-CN]: 获取应用列表,应用信息中不包含代理、角色、用户等信息。
@param ctx       context.Context
@param keywords  string
@param current   int64
@param pageSize  int64
@return total    int64
@return apps     []*models.App
@return err      error

func (UserAndAppService) GetUser

GetUser

@Description[en-US]: Get user info.
@Description[zh-CN]: 获取用户信息
@param ctx 	context.Context
@param options 	opts.GetUserOptions
@return userDetail	*models.User
@return err	error

func (UserAndAppService) GetUserInfo

func (s UserAndAppService) GetUserInfo(ctx context.Context, id string, username string) (*models.User, error)

GetUserInfo

@Description[en-US]: Obtain user information through ID or username.
@Description[zh-CN]: 通过ID或用户名获取用户信息。
@param ctx 	context.Context
@param id 	string
@param username 	string
@return userDetail	*models.User
@return err	error

func (UserAndAppService) GetUserInfoByUsernameAndEmail

func (s UserAndAppService) GetUserInfoByUsernameAndEmail(ctx context.Context, username, email string) (user *models.User, err error)

GetUserInfoByUsernameAndEmail

@Description[en-US]: Use username or email to obtain user information.
@Description[zh-CN]: 使用用户名或email获取用户信息。
@param ctx           context.Context
@param username      string
@param email         string
@return user   *models.User
@return err          error

func (UserAndAppService) GetUsers

func (s UserAndAppService) GetUsers(ctx context.Context, keywords string, status models.UserMeta_UserStatus, appId string, current, pageSize int64) (total int64, users []*models.User, err error)

GetUsers

@Description[en-US]: Get user list.
@Description[zh-CN]: 获取用户列表。
@param ctx       context.Context
@param keywords  string
@param status    models.UserMeta_UserStatus
@param appId     string
@param current   int64
@param pageSize  int64
@return total    int64
@return users    []*models.User
@return err      error

func (UserAndAppService) GetUsersById

func (s UserAndAppService) GetUsersById(ctx context.Context, id []string) (users models.Users, err error)

func (UserAndAppService) Name

func (s UserAndAppService) Name() string

func (UserAndAppService) PatchApp

func (s UserAndAppService) PatchApp(ctx context.Context, fields map[string]interface{}) (err error)

PatchApp

@Description[en-US]: Incremental update application.
@Description[zh-CN]: 增量更新应用。
@param ctx        context.Context
@param fields     map[string]interface{}
@return err       error

func (UserAndAppService) PatchApps

func (s UserAndAppService) PatchApps(ctx context.Context, patch []map[string]interface{}) (total int64, err error)

PatchApps

@Description[en-US]: Incrementally update information of multiple applications.
@Description[zh-CN]: 增量更新多个应用的信息。
@param ctx     context.Context
@param patch   []map[string]interface{}
@return total  int64
@return err    error

func (UserAndAppService) PatchUser

func (s UserAndAppService) PatchUser(ctx context.Context, patch map[string]interface{}) (err error)

PatchUser

@Description[en-US]: Incremental update user.
@Description[zh-CN]: 增量更新用户。
@param ctx 	context.Context
@param user 	map[string]interface{}
@return err	error

func (UserAndAppService) PatchUsers

func (s UserAndAppService) PatchUsers(ctx context.Context, patch []map[string]interface{}) (int64, error)

PatchUsers

@Description[en-US]: Incrementally update information of multiple users.
@Description[zh-CN]: 增量更新多个用户的信息。
@param ctx 		context.Context
@param patch 	[]map[string]interface{}
@return count	int64
@return err		error

func (UserAndAppService) ResetPassword

func (s UserAndAppService) ResetPassword(ctx context.Context, ids string, password string) error

ResetPassword

@Description[en-US]: Reset User Password.
@Description[zh-CN]: 重置用户密码。
@param ctx       context.Context
@param id        string
@param password  string           : New password.
@return err      error

func (UserAndAppService) UpdateApp

func (s UserAndAppService) UpdateApp(ctx context.Context, app *models.App, updateColumns ...string) (err error)

UpdateApp

@Description[en-US]: Update applies the value of the specified column. If no column is specified, all column information is updated.
@Description[zh-CN]: 更新应用指定列的值,如果未指定列,则表示更新所有列信息。
@param ctx           context.Context
@param app           *models.App
@param updateColumns ...string
@return err          error

func (UserAndAppService) UpdateUser

func (s UserAndAppService) UpdateUser(ctx context.Context, user *models.User, updateColumns ...string) (err error)

UpdateUser

@Description[en-US]: Update user information.
@Description[zh-CN]: 更新用户信息.
@param ctx	context.Context
@param user	*models.User
@param updateColumns	...string
@return err	error

func (UserAndAppService) VerifyPassword

func (s UserAndAppService) VerifyPassword(ctx context.Context, username string, password string) *models.User

VerifyPassword

@Description[en-US]: Verify password for user.
@Description[zh-CN]: 验证用户密码。
@param ctx 	context.Context
@param username 	string
@param password 	string
@return users	[]*models.User

func (UserAndAppService) VerifyPasswordById

func (s UserAndAppService) VerifyPasswordById(ctx context.Context, id, password string) *models.User

VerifyPasswordById

@Description[en-US]: Verify the user's password through ID.
@Description[zh-CN]: 通过ID验证用户密码。
@param ctx 	context.Context
@param id 	string
@param password 	string
@return users	[]*models.User

Jump to

Keyboard shortcuts

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