service

package
v2.6.12 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2025 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OauthActionTypeLogin = "login"
	OauthActionTypeBind  = "bind"
)

Variables

View Source
var (
	ErrLdapNotEnabled        = errors.New("LdapNotEnabled")
	ErrLdapUserDisabled      = errors.New("UserDisabledAtLdap")
	ErrLdapUserNotFound      = errors.New("UserNotFound")
	ErrLdapMailNotMatch      = errors.New("MailNotMatch")
	ErrLdapConnectFailed     = errors.New("LdapConnectFailed")
	ErrLdapSearchFailed      = errors.New("LdapSearchRequestFailed")
	ErrLdapTlsFailed         = errors.New("LdapStartTLSFailed")
	ErrLdapBindService       = errors.New("LdapBindServiceFailed")
	ErrLdapBindFailed        = errors.New("LdapBindFailed")
	ErrLdapToLocalUserFailed = errors.New("LdapToLocalUserFailed")
	ErrLdapCreateUserFailed  = errors.New("LdapCreateUserFailed")
)
View Source
var AllService = New()
View Source
var OauthCache = &sync.Map{}

Functions

func CommonEnable

func CommonEnable() func(db *gorm.DB) *gorm.DB

func Paginate

func Paginate(page, pageSize uint) func(db *gorm.DB) *gorm.DB

Types

type AddressBookService

type AddressBookService struct {
}

func (*AddressBookService) AddAddressBook

func (s *AddressBookService) AddAddressBook(ab *model.AddressBook) error

AddAddressBook

func (*AddressBookService) BatchUpdateTags

func (s *AddressBookService) BatchUpdateTags(abs []*model.AddressBook, tags []string) error

func (*AddressBookService) CheckCollectionOwner

func (s *AddressBookService) CheckCollectionOwner(uid uint, cid uint) bool

CheckCollectionOwner 检查Collection的所有者

func (*AddressBookService) CheckUserFullControlPrivilege

func (s *AddressBookService) CheckUserFullControlPrivilege(user *model.User, uid, cid uint) bool

func (*AddressBookService) CheckUserReadPrivilege

func (s *AddressBookService) CheckUserReadPrivilege(user *model.User, uid, cid uint) bool

func (*AddressBookService) CheckUserWritePrivilege

func (s *AddressBookService) CheckUserWritePrivilege(user *model.User, uid, cid uint) bool

func (*AddressBookService) CollectionInfoById

func (s *AddressBookService) CollectionInfoById(id uint) *model.AddressBookCollection

func (*AddressBookService) CollectionReadRules

func (s *AddressBookService) CollectionReadRules(user *model.User) (res []*model.AddressBookCollectionRule)

func (*AddressBookService) Create

func (s *AddressBookService) Create(u *model.AddressBook) error

Create 创建

func (*AddressBookService) CreateCollection

func (s *AddressBookService) CreateCollection(t *model.AddressBookCollection) error

func (*AddressBookService) CreateRule

func (*AddressBookService) Delete

func (s *AddressBookService) Delete(u *model.AddressBook) error

func (*AddressBookService) DeleteCollection

func (s *AddressBookService) DeleteCollection(t *model.AddressBookCollection) error

func (*AddressBookService) DeleteRule

func (*AddressBookService) FromPeer

func (s *AddressBookService) FromPeer(peer *model.Peer) (a *model.AddressBook)

func (*AddressBookService) Info

func (*AddressBookService) InfoByRowId

func (s *AddressBookService) InfoByRowId(id uint) *model.AddressBook

func (*AddressBookService) InfoByUserIdAndId

func (s *AddressBookService) InfoByUserIdAndId(userid uint, id string) *model.AddressBook

func (*AddressBookService) InfoByUserIdAndIdAndCid

func (s *AddressBookService) InfoByUserIdAndIdAndCid(userid uint, id string, cid uint) *model.AddressBook

func (*AddressBookService) List

func (s *AddressBookService) List(page, pageSize uint, where func(tx *gorm.DB)) (res *model.AddressBookList)

func (*AddressBookService) ListByUserId

func (s *AddressBookService) ListByUserId(userId, page, pageSize uint) (res *model.AddressBookList)

func (*AddressBookService) ListByUserIdAndCollectionId

func (s *AddressBookService) ListByUserIdAndCollectionId(userId, cid, page, pageSize uint) (res *model.AddressBookList)

func (*AddressBookService) ListByUserIds

func (s *AddressBookService) ListByUserIds(userIds []uint, page, pageSize uint) (res *model.AddressBookList)

func (*AddressBookService) ListCollection

func (s *AddressBookService) ListCollection(page, pageSize uint, where func(tx *gorm.DB)) (res *model.AddressBookCollectionList)

func (*AddressBookService) ListCollectionByIds

func (s *AddressBookService) ListCollectionByIds(ids []uint) (res []*model.AddressBookCollection)

func (*AddressBookService) ListCollectionByUserId

func (s *AddressBookService) ListCollectionByUserId(userId uint) (res *model.AddressBookCollectionList)

func (*AddressBookService) ListRules

func (s *AddressBookService) ListRules(page uint, size uint, f func(tx *gorm.DB)) *model.AddressBookCollectionRuleList

func (*AddressBookService) PlatformFromOs

func (s *AddressBookService) PlatformFromOs(os string) string

PlatformFromOs

func (*AddressBookService) RuleInfoById

func (*AddressBookService) RulePersonalInfoByToIdAndCid

func (s *AddressBookService) RulePersonalInfoByToIdAndCid(toid, cid uint) *model.AddressBookCollectionRule

func (*AddressBookService) ShareByWebClient

func (s *AddressBookService) ShareByWebClient(m *model.ShareRecord) error

ShareByWebClient 分享

func (*AddressBookService) SharedPeer

func (s *AddressBookService) SharedPeer(shareToken string) *model.ShareRecord

SharedPeer

func (*AddressBookService) Update

func (s *AddressBookService) Update(u *model.AddressBook) error

Update 更新

func (*AddressBookService) UpdateAddressBook

func (s *AddressBookService) UpdateAddressBook(abs []*model.AddressBook, userId uint) error

UpdateAddressBook

func (*AddressBookService) UpdateAll

func (s *AddressBookService) UpdateAll(u *model.AddressBook) error

UpdateAll 更新

func (*AddressBookService) UpdateByMap

func (s *AddressBookService) UpdateByMap(u *model.AddressBook, data map[string]interface{}) error

UpdateByMap 更新

func (*AddressBookService) UpdateCollection

func (s *AddressBookService) UpdateCollection(t *model.AddressBookCollection) error

func (*AddressBookService) UpdateRule

func (*AddressBookService) UserMaxRule

func (s *AddressBookService) UserMaxRule(user *model.User, uid, cid uint) int

type AuditService

type AuditService struct {
}

func (*AuditService) AuditConnList

func (as *AuditService) AuditConnList(page, pageSize uint, where func(tx *gorm.DB)) (res *model.AuditConnList)

func (*AuditService) AuditFileList

func (as *AuditService) AuditFileList(page, pageSize uint, where func(tx *gorm.DB)) (res *model.AuditFileList)

func (*AuditService) BatchDeleteAuditConn

func (as *AuditService) BatchDeleteAuditConn(ids []uint) error

func (*AuditService) BatchDeleteAuditFile

func (as *AuditService) BatchDeleteAuditFile(ids []uint) error

func (*AuditService) ConnInfoById

func (as *AuditService) ConnInfoById(id uint) (res *model.AuditConn)

ConnInfoById

func (*AuditService) CreateAuditConn

func (as *AuditService) CreateAuditConn(u *model.AuditConn) error

Create 创建

func (*AuditService) CreateAuditFile

func (as *AuditService) CreateAuditFile(u *model.AuditFile) error

CreateAuditFile

func (*AuditService) DeleteAuditConn

func (as *AuditService) DeleteAuditConn(u *model.AuditConn) error

func (*AuditService) DeleteAuditFile

func (as *AuditService) DeleteAuditFile(u *model.AuditFile) error

func (*AuditService) FileInfoById

func (as *AuditService) FileInfoById(id uint) (res *model.AuditFile)

FileInfoById

func (*AuditService) InfoByPeerIdAndConnId

func (as *AuditService) InfoByPeerIdAndConnId(peerId string, connId int64) (res *model.AuditConn)

InfoByPeerIdAndConnId

func (*AuditService) UpdateAuditConn

func (as *AuditService) UpdateAuditConn(u *model.AuditConn) error

Update 更新

func (*AuditService) UpdateAuditFile

func (as *AuditService) UpdateAuditFile(u *model.AuditFile) error

Update 更新

type GroupService

type GroupService struct {
}

func (*GroupService) Create

func (us *GroupService) Create(u *model.Group) error

Create 创建

func (*GroupService) Delete

func (us *GroupService) Delete(u *model.Group) error

func (*GroupService) InfoById

func (us *GroupService) InfoById(id uint) *model.Group

InfoById 根据用户id取用户信息

func (*GroupService) List

func (us *GroupService) List(page, pageSize uint, where func(tx *gorm.DB)) (res *model.GroupList)

func (*GroupService) Update

func (us *GroupService) Update(u *model.Group) error

Update 更新

type LdapService

type LdapService struct {
}

LdapService is responsible for LDAP authentication and user synchronization.

func (*LdapService) Authenticate

func (ls *LdapService) Authenticate(username, password string) (*model.User, error)

Authenticate checks the provided username and password against LDAP. Returns the corresponding *model.User if successful, or an error if not.

func (*LdapService) GetUserInfoByEmailLdap

func (ls *LdapService) GetUserInfoByEmailLdap(email string) (*LdapUser, error)

GetUserInfoByEmailLdap returns the user info from LDAP for the given email.

func (*LdapService) GetUserInfoByEmailLocal

func (ls *LdapService) GetUserInfoByEmailLocal(email string) (*model.User, error)

GetUserInfoByEmailLocal returns the user info from LDAP for the given email. if the user exists, it will synchronize the user information to local database.

func (*LdapService) GetUserInfoByUsernameLdap

func (ls *LdapService) GetUserInfoByUsernameLdap(username string) (*LdapUser, error)

GetUserInfoByUsernameLdap returns the user info from LDAP for the given username.

func (*LdapService) GetUserInfoByUsernameLocal

func (ls *LdapService) GetUserInfoByUsernameLocal(username string) (*model.User, error)

GetUserInfoByUsernameLocal returns the user info from LDAP for the given username. If the user exists, it will sync the user info to the local database.

func (*LdapService) IsEmailExists

func (ls *LdapService) IsEmailExists(email string) bool

IsEmailExists checks if an email exists in LDAP (can be useful for local registration checks).

func (*LdapService) IsUsernameExists

func (ls *LdapService) IsUsernameExists(username string) bool

IsUsernameExists checks if a username exists in LDAP (can be useful for local registration checks).

type LdapUser

type LdapUser struct {
	Dn              string
	Username        string
	Email           string
	FirstName       string
	LastName        string
	MemberOf        []string
	EnableAttrValue string
	Enabled         bool
}

LdapUser represents the user attributes retrieved from LDAP.

func (*LdapUser) Name

func (lu *LdapUser) Name() string

Name returns the full name of an LDAP user.

func (*LdapUser) ToUser

func (lu *LdapUser) ToUser(u *model.User) *model.User

ToUser merges the LdapUser data into a provided *model.User. If 'u' is nil, it creates and returns a new *model.User.

type LoginLogService

type LoginLogService struct {
}

func (*LoginLogService) BatchDelete

func (us *LoginLogService) BatchDelete(ids []uint) error

func (*LoginLogService) BatchSoftDelete

func (us *LoginLogService) BatchSoftDelete(uid uint, ids []uint) error

func (*LoginLogService) Create

func (us *LoginLogService) Create(u *model.LoginLog) error

Create 创建

func (*LoginLogService) Delete

func (us *LoginLogService) Delete(u *model.LoginLog) error

func (*LoginLogService) InfoById

func (us *LoginLogService) InfoById(id uint) *model.LoginLog

InfoById 根据用户id取用户信息

func (*LoginLogService) List

func (us *LoginLogService) List(page, pageSize uint, where func(tx *gorm.DB)) (res *model.LoginLogList)

func (*LoginLogService) SoftDelete

func (us *LoginLogService) SoftDelete(l *model.LoginLog) error

func (*LoginLogService) Update

func (us *LoginLogService) Update(u *model.LoginLog) error

Update 更新

type OauthCacheItem

type OauthCacheItem struct {
	UserId     uint   `json:"user_id"`
	Id         string `json:"id"` //rustdesk的设备ID
	Op         string `json:"op"`
	Action     string `json:"action"`
	Uuid       string `json:"uuid"`
	DeviceName string `json:"device_name"`
	DeviceOs   string `json:"device_os"`
	DeviceType string `json:"device_type"`
	OpenId     string `json:"open_id"`
	Username   string `json:"username"`
	Name       string `json:"name"`
	Email      string `json:"email"`
	Verifier   string `json:"verifier"` // used for oauth pkce
}

func (*OauthCacheItem) ToOauthUser

func (oci *OauthCacheItem) ToOauthUser() *model.OauthUser

func (*OauthCacheItem) UpdateFromOauthUser

func (oci *OauthCacheItem) UpdateFromOauthUser(oauthUser *model.OauthUser)

type OauthService

type OauthService struct {
}

func (*OauthService) BeginAuth

func (os *OauthService) BeginAuth(op string) (error error, state, verifier, url string)

func (*OauthService) BindOauthUser

func (os *OauthService) BindOauthUser(userId uint, oauthUser *model.OauthUser, op string) error

BindOauthUser: Bind third party account

func (*OauthService) Callback

func (os *OauthService) Callback(code, verifier, op string) (err error, oauthUser *model.OauthUser)

Callback: Get user information by code and op(Oauth provider)

func (*OauthService) Create

func (os *OauthService) Create(oauthInfo *model.Oauth) error

Create 创建

func (*OauthService) Delete

func (os *OauthService) Delete(oauthInfo *model.Oauth) error

func (*OauthService) DeleteOauthCache

func (os *OauthService) DeleteOauthCache(key string)

func (*OauthService) DeleteUserByUserId

func (os *OauthService) DeleteUserByUserId(userId uint) error

DeleteUserByUserId: When user is deleted, delete all third party bindings

func (*OauthService) FetchOidcEndpoint

func (os *OauthService) FetchOidcEndpoint(issuer string) (error, OidcEndpoint)

Method to fetch OIDC configuration dynamically

func (*OauthService) FetchOidcEndpointByOp

func (os *OauthService) FetchOidcEndpointByOp(op string) (error, OidcEndpoint)

func (*OauthService) GetOauthCache

func (os *OauthService) GetOauthCache(key string) *OauthCacheItem

func (*OauthService) GetOauthConfig

func (os *OauthService) GetOauthConfig(op string) (err error, oauthInfo *model.Oauth, oauthConfig *oauth2.Config)

GetOauthConfig retrieves the OAuth2 configuration based on the provider name

func (*OauthService) GetOauthProviders

func (os *OauthService) GetOauthProviders() []string

GetOauthProviders 获取所有的provider

func (*OauthService) GetTypeByOp

func (os *OauthService) GetTypeByOp(op string) (error, string)

GetTypeByOp 根据op获取OauthType

func (*OauthService) InfoById

func (os *OauthService) InfoById(id uint) *model.Oauth

InfoById 根据id获取Oauth信息

func (*OauthService) InfoByOp

func (os *OauthService) InfoByOp(op string) *model.Oauth

InfoByOp 根据op获取Oauth信息

func (*OauthService) IsOauthProviderExist

func (os *OauthService) IsOauthProviderExist(op string) bool

IsOauthProviderExist 验证Oauth提供者是否存在

func (*OauthService) List

func (os *OauthService) List(page, pageSize uint, where func(tx *gorm.DB)) (res *model.OauthList)

func (*OauthService) SetOauthCache

func (os *OauthService) SetOauthCache(key string, item *OauthCacheItem, expire uint)

func (*OauthService) UnBindOauthUser

func (os *OauthService) UnBindOauthUser(userId uint, op string) error

UnBindOauthUser: Unbind third party account

func (*OauthService) UnBindThird

func (os *OauthService) UnBindThird(op string, userId uint) error

UnBindThird: Unbind third party account

func (*OauthService) Update

func (os *OauthService) Update(oauthInfo *model.Oauth) error

Update 更新

func (*OauthService) UserThirdInfo

func (os *OauthService) UserThirdInfo(op string, openId string) *model.UserThird

func (*OauthService) ValidateOauthProvider

func (os *OauthService) ValidateOauthProvider(op string) error

ValidateOauthProvider 验证Oauth提供者是否正确

type OidcEndpoint

type OidcEndpoint struct {
	Issuer   string `json:"issuer"`
	AuthURL  string `json:"authorization_endpoint"`
	TokenURL string `json:"token_endpoint"`
	UserInfo string `json:"userinfo_endpoint"`
}

Define a struct to parse the .well-known/openid-configuration response

type PeerService

type PeerService struct {
}

func (*PeerService) BatchDelete

func (ps *PeerService) BatchDelete(ids []uint) error

BatchDelete 批量删除, 同时也应该删除token

func (*PeerService) Create

func (ps *PeerService) Create(u *model.Peer) error

Create 创建

func (*PeerService) Delete

func (ps *PeerService) Delete(u *model.Peer) error

Delete 删除, 同时也应该删除token

func (*PeerService) EraseUserId

func (ps *PeerService) EraseUserId(userId uint) error

EraseUserId 清除用户id, 用于用户删除

func (*PeerService) FindById

func (ps *PeerService) FindById(id string) *model.Peer

FindById 根据id查找

func (*PeerService) FindByUserIdAndUuid

func (ps *PeerService) FindByUserIdAndUuid(uuid string, userId uint) *model.Peer

FindByUserIdAndUuid 根据用户id和uuid查找peer

func (*PeerService) FindByUuid

func (ps *PeerService) FindByUuid(uuid string) *model.Peer

func (*PeerService) GetUuidListByIDs

func (ps *PeerService) GetUuidListByIDs(ids []uint) ([]string, error)

GetUuidListByIDs 根据ids获取uuid列表

func (*PeerService) InfoByRowId

func (ps *PeerService) InfoByRowId(id uint) *model.Peer

func (*PeerService) List

func (ps *PeerService) List(page, pageSize uint, where func(tx *gorm.DB)) (res *model.PeerList)

func (*PeerService) ListByUserIds

func (ps *PeerService) ListByUserIds(userIds []uint, page, pageSize uint) (res *model.PeerList)

ListByUserIds 根据用户id取列表

func (*PeerService) ListFilterByUserId

func (ps *PeerService) ListFilterByUserId(page, pageSize uint, where func(tx *gorm.DB), userId uint) (res *model.PeerList)

ListFilterByUserId 根据用户id过滤Peer列表

func (*PeerService) Update

func (ps *PeerService) Update(u *model.Peer) error

Update 更新

func (*PeerService) UuidBindUserId

func (ps *PeerService) UuidBindUserId(deviceId string, uuid string, userId uint)

UuidBindUserId 绑定用户id

func (*PeerService) UuidUnbindUserId

func (ps *PeerService) UuidUnbindUserId(uuid string, userId uint)

UuidUnbindUserId 解绑用户id, 用于用户注销

type ServerCmdService

type ServerCmdService struct{}

func (*ServerCmdService) Create

func (is *ServerCmdService) Create(u *model.ServerCmd) error

Create

func (*ServerCmdService) Delete

func (is *ServerCmdService) Delete(u *model.ServerCmd) error

Delete

func (*ServerCmdService) Info

func (is *ServerCmdService) Info(id uint) *model.ServerCmd

Info

func (*ServerCmdService) List

func (is *ServerCmdService) List(page, pageSize uint) (res *model.ServerCmdList)

List

func (*ServerCmdService) SendCmd

func (is *ServerCmdService) SendCmd(target string, cmd string, arg string) (string, error)

SendCmd 发送命令

func (*ServerCmdService) SendSocketCmd

func (is *ServerCmdService) SendSocketCmd(ty string, port int, cmd string) (string, error)

SendSocketCmd

func (*ServerCmdService) Update

func (is *ServerCmdService) Update(f *model.ServerCmd) error

type Service

type Service struct {
	//AdminService     *AdminService
	//AdminRoleService *AdminRoleService
	*UserService
	*AddressBookService
	*TagService
	*PeerService
	*GroupService
	*OauthService
	*LoginLogService
	*AuditService
	*ShareRecordService
	*ServerCmdService
	*LdapService
}

func New

func New() *Service

type ShareRecordService

type ShareRecordService struct {
}

func (*ShareRecordService) BatchDelete

func (srs *ShareRecordService) BatchDelete(ids []uint) error

func (*ShareRecordService) Create

func (srs *ShareRecordService) Create(u *model.ShareRecord) error

Create 创建

func (*ShareRecordService) Delete

func (srs *ShareRecordService) Delete(u *model.ShareRecord) error

func (*ShareRecordService) InfoById

func (srs *ShareRecordService) InfoById(id uint) *model.ShareRecord

InfoById 根据用户id取用户信息

func (*ShareRecordService) List

func (srs *ShareRecordService) List(page, pageSize uint, where func(tx *gorm.DB)) (res *model.ShareRecordList)

func (*ShareRecordService) Update

func (srs *ShareRecordService) Update(u *model.ShareRecord) error

Update 更新

type TagService

type TagService struct {
}

func (*TagService) Create

func (s *TagService) Create(u *model.Tag) error

Create 创建

func (*TagService) Delete

func (s *TagService) Delete(u *model.Tag) error

func (*TagService) Info

func (s *TagService) Info(id uint) *model.Tag

func (*TagService) InfoById

func (s *TagService) InfoById(id uint) *model.Tag

InfoById 根据用户id取用户信息

func (*TagService) InfoByUserIdAndNameAndCollectionId

func (s *TagService) InfoByUserIdAndNameAndCollectionId(userid uint, name string, cid uint) *model.Tag

func (*TagService) List

func (s *TagService) List(page, pageSize uint, where func(tx *gorm.DB)) (res *model.TagList)

func (*TagService) ListByUserId

func (s *TagService) ListByUserId(userId uint) (res *model.TagList)

func (*TagService) ListByUserIdAndCollectionId

func (s *TagService) ListByUserIdAndCollectionId(userId, cid uint) (res *model.TagList)

func (*TagService) Update

func (s *TagService) Update(u *model.Tag) error

Update 更新

func (*TagService) UpdateTags

func (s *TagService) UpdateTags(userId uint, tags map[string]uint)

type UserService

type UserService struct {
}

func (*UserService) AutoRefreshAccessToken

func (us *UserService) AutoRefreshAccessToken(ut *model.UserToken)

func (*UserService) BatchDeleteUserToken

func (us *UserService) BatchDeleteUserToken(ids []uint) error

func (*UserService) CheckUserEnable

func (us *UserService) CheckUserEnable(u *model.User) bool

CheckUserEnable 判断用户是否禁用

func (*UserService) Create

func (us *UserService) Create(u *model.User) error

Create 创建

func (*UserService) CurUser

func (us *UserService) CurUser(c *gin.Context) *model.User

CurUser 获取当前用户

func (*UserService) Delete

func (us *UserService) Delete(u *model.User) error

Delete 删除用户和oauth信息

func (*UserService) DeleteToken

func (us *UserService) DeleteToken(l *model.UserToken) error

func (*UserService) EncryptPassword

func (us *UserService) EncryptPassword(password string) string

EncryptPassword 加密密码

func (*UserService) FindLatestUserIdFromLoginLogByUuid

func (us *UserService) FindLatestUserIdFromLoginLogByUuid(uuid string) uint

FindLatestUserIdFromLoginLogByUuid 根据uuid查找最后登录的用户id

func (*UserService) FlushToken

func (us *UserService) FlushToken(u *model.User) error

FlushToken 清空token

func (*UserService) FlushTokenByUuid

func (us *UserService) FlushTokenByUuid(uuid string) error

FlushTokenByUuid 清空token

func (*UserService) FlushTokenByUuids

func (us *UserService) FlushTokenByUuids(uuids []string) error

FlushTokenByUuids 清空token

func (*UserService) GenerateToken

func (us *UserService) GenerateToken(u *model.User) string

GenerateToken 生成token

func (*UserService) GenerateUsernameByOauth

func (us *UserService) GenerateUsernameByOauth(name string) string

GenerateUsernameByOauth 生成用户名

func (*UserService) GetUuidByToken

func (us *UserService) GetUuidByToken(u *model.User, token string) string

GetUuidByToken 根据token和user取uuid

func (*UserService) InfoByAccessToken

func (us *UserService) InfoByAccessToken(token string) (*model.User, *model.UserToken)

InfoByAccesstoken 根据accesstoken取用户信息

func (*UserService) InfoByEmail

func (us *UserService) InfoByEmail(email string) *model.User

InfoByEmail 根据邮箱取用户信息

func (*UserService) InfoById

func (us *UserService) InfoById(id uint) *model.User

InfoById 根据用户id取用户信息

func (*UserService) InfoByOauthId

func (us *UserService) InfoByOauthId(op string, openId string) *model.User

InfoByOauthId 根据oauth的name和openId取用户信息

func (*UserService) InfoByOpenid

func (us *UserService) InfoByOpenid(openid string) *model.User

InfoByOpenid 根据openid取用户信息

func (*UserService) InfoByUsername

func (us *UserService) InfoByUsername(un string) *model.User

InfoByUsername 根据用户名取用户信息

func (*UserService) InfoByUsernamePassword

func (us *UserService) InfoByUsernamePassword(username, password string) *model.User

InfoByUsernamePassword 根据用户名密码取用户信息

func (*UserService) IsAdmin

func (us *UserService) IsAdmin(u *model.User) bool

IsAdmin 是否管理员

func (*UserService) IsEmailExistsLdap

func (us *UserService) IsEmailExistsLdap(email string) bool

func (*UserService) IsPasswordEmptyById

func (us *UserService) IsPasswordEmptyById(id uint) bool

IsPasswordEmptyById 根据用户id判断密码是否为空,主要用于第三方登录的自动注册

func (*UserService) IsPasswordEmptyByUser

func (us *UserService) IsPasswordEmptyByUser(u *model.User) bool

IsPasswordEmptyByUser 判断密码是否为空,主要用于第三方登录的自动注册

func (*UserService) IsPasswordEmptyByUsername

func (us *UserService) IsPasswordEmptyByUsername(username string) bool

IsPasswordEmptyByUsername 根据用户id判断密码是否为空,主要用于第三方登录的自动注册

func (*UserService) IsUsernameExists

func (us *UserService) IsUsernameExists(username string) bool

IsUsernameExists 判断用户名是否存在, it will check the internal database and LDAP(if enabled)

func (*UserService) IsUsernameExistsLocal

func (us *UserService) IsUsernameExistsLocal(username string) bool

func (*UserService) List

func (us *UserService) List(page, pageSize uint, where func(tx *gorm.DB)) (res *model.UserList)

func (*UserService) ListByGroupId

func (us *UserService) ListByGroupId(groupId, page, pageSize uint) (res *model.UserList)

ListByGroupId 根据组id取用户列表

func (*UserService) ListByIds

func (us *UserService) ListByIds(ids []uint) (res []*model.User)

func (*UserService) ListIdAndNameByGroupId

func (us *UserService) ListIdAndNameByGroupId(groupId uint) (res []*model.User)

ListIdAndNameByGroupId 根据组id取用户id和用户名列表

func (*UserService) ListIdsByGroupId

func (us *UserService) ListIdsByGroupId(groupId uint) (ids []uint)

ListIdsByGroupId 根据组id取用户id列表

func (*UserService) Login

func (us *UserService) Login(u *model.User, llog *model.LoginLog) *model.UserToken

Login 登录

func (*UserService) Logout

func (us *UserService) Logout(u *model.User, token string) error

Logout 退出登录 -> 删除token, 解绑uuid

func (*UserService) RefreshAccessToken

func (us *UserService) RefreshAccessToken(ut *model.UserToken)

func (*UserService) Register

func (us *UserService) Register(username string, email string, password string) *model.User

Register 注册, 如果用户名已存在则返回nil

func (*UserService) RegisterByOauth

func (us *UserService) RegisterByOauth(oauthUser *model.OauthUser, op string) (error, *model.User)

RegisterByOauth 注册

func (*UserService) RouteNames

func (us *UserService) RouteNames(u *model.User) []string

RouteNames

func (*UserService) TokenInfoById

func (us *UserService) TokenInfoById(id uint) *model.UserToken

func (*UserService) TokenList

func (us *UserService) TokenList(page uint, size uint, f func(tx *gorm.DB)) *model.UserTokenList

func (*UserService) Update

func (us *UserService) Update(u *model.User) error

Update 更新

func (*UserService) UpdatePassword

func (us *UserService) UpdatePassword(u *model.User, password string) error

UpdatePassword 更新密码

func (*UserService) UserThirdInfo

func (us *UserService) UserThirdInfo(userId uint, op string) *model.UserThird

func (*UserService) UserThirdsByUserId

func (us *UserService) UserThirdsByUserId(userId uint) (res []*model.UserThird)

UserThirdsByUserId

func (*UserService) UserTokenExpireTimestamp

func (us *UserService) UserTokenExpireTimestamp() int64

UserTokenExpireTimestamp 生成用户token过期时间

func (*UserService) VerifyJWT

func (us *UserService) VerifyJWT(token string) (uint, error)

Jump to

Keyboard shortcuts

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