dao

package
v1.17.21 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB

Functions

This section is empty.

Types

type App

type App struct {
	ID        uint `gorm:"primarykey"`
	CreatedAt int64
	// User.ID 拥有者
	UID            uint   `gorm:"column:uid;index"`
	User           *User  `gorm:"foreignKey:UID;constraint:OnDelete:SET NULL"`
	Name           string `gorm:"not null;uniqueIndex;type:varchar(20)"`
	AppCode        string `gorm:"not null;uniqueIndex;type:varchar(36)"`
	AppSecret      string `gorm:"not null"`
	Callback       string `gorm:"not null"`
	PermitAllGroup bool
	// 以下仅用于导航标识
	LinkOff bool   `gorm:"index"`
	Views   uint64 `gorm:"index"`
	// LoginRecord.ID 统计用,无需约束
	ViewsID uint
}

func (*App) DeleteByIdForUID

func (a *App) DeleteByIdForUID(tx *gorm.DB) error

func (*App) Exist added in v1.16.25

func (a *App) Exist(tx *gorm.DB) (bool, error)

func (*App) FirstAppCodeByID

func (a *App) FirstAppCodeByID(tx *gorm.DB) error

func (*App) FirstAppKeyPairByAppCode added in v1.17.2

func (a *App) FirstAppKeyPairByAppCode(tx *gorm.DB) error

func (*App) FirstAppKeyPairByID

func (a *App) FirstAppKeyPairByID(tx *gorm.DB) error

func (*App) FirstByAppCode

func (a *App) FirstByAppCode(tx *gorm.DB) error

func (*App) FirstByID

func (a *App) FirstByID(tx *gorm.DB) error

func (*App) FirstCallbackByID

func (a *App) FirstCallbackByID(tx *gorm.DB) error

func (*App) FirstDetailedByIdAndUID

func (a *App) FirstDetailedByIdAndUID(tx *gorm.DB) (*dto.AppShowDetail, error)

func (*App) GetAccessible

func (a *App) GetAccessible(tx *gorm.DB) ([]dto.AppShowWithGroup, error)

func (*App) GetAllWithGroup

func (a *App) GetAllWithGroup(tx *gorm.DB) ([]dto.AppShowWithGroup, error)

func (*App) GetAppCode

func (a *App) GetAppCode(tx *gorm.DB) ([]string, error)

func (*App) GetByUIDForAction

func (a *App) GetByUIDForAction(tx *gorm.DB) ([]App, error)

func (*App) GetByUIDForShow

func (a *App) GetByUIDForShow(tx *gorm.DB) ([]dto.AppShowOwner, error)

func (*App) GetByUIDForShowDetailed

func (a *App) GetByUIDForShowDetailed(tx *gorm.DB) ([]dto.AppShowDetail, error)

func (*App) GetForUpdateView

func (a *App) GetForUpdateView(tx *gorm.DB) ([]App, error)

func (*App) GetPermitAll

func (a *App) GetPermitAll(tx *gorm.DB) ([]dto.AppShow, error)

func (*App) Insert

func (a *App) Insert(tx *gorm.DB) error

func (*App) UpdateLinkOff

func (a *App) UpdateLinkOff(tx *gorm.DB) error

func (*App) UpdateViewByID

func (a *App) UpdateViewByID(tx *gorm.DB) error

func (*App) UpdatesByID

func (a *App) UpdatesByID(tx *gorm.DB) error

func (*App) UserAccessible

func (a *App) UserAccessible(tx *gorm.DB) (bool, error)

type AppGroup

type AppGroup struct {
	ID uint `gorm:"primarykey"`
	// App.ID
	AID uint `gorm:"column:aid;not null;index;index:app_group_idx,unique"`
	App *App `gorm:"foreignKey:AID;constraint:OnDelete:CASCADE"`
	// BaseGroup.ID
	GID       uint       `gorm:"column:gid;not null;index;index:app_group_idx,unique"`
	BaseGroup *BaseGroup `gorm:"foreignKey:GID;constraint:OnDelete:CASCADE"`
}

func (*AppGroup) DeleteByAID

func (a *AppGroup) DeleteByAID(tx *gorm.DB) error

func (*AppGroup) DeleteByGidForApp

func (a *AppGroup) DeleteByGidForApp(tx *gorm.DB, gids ...uint) error

type BaseGroup

type BaseGroup struct {
	ID   uint   `gorm:"primarykey"`
	Name string `gorm:"not null;uniqueIndex;type:varchar(10)"`
}

BaseGroup 该模型仅用于添加数据库约束,请勿用于创建含写入操作的 CRUD 接口

func (*BaseGroup) CreateGroups

func (a *BaseGroup) CreateGroups(tx *gorm.DB, groups []BaseGroup) error

func (*BaseGroup) GetAll

func (a *BaseGroup) GetAll(tx *gorm.DB) ([]BaseGroup, error)

func (*BaseGroup) GetAllForShow

func (a *BaseGroup) GetAllForShow(tx *gorm.DB) ([]dto.Group, error)

func (*BaseGroup) GetByAppIdsRelatedForShow

func (a *BaseGroup) GetByAppIdsRelatedForShow(tx *gorm.DB, apps ...uint) ([]dto.GroupRelateApp, error)

func (*BaseGroup) GetByIdsForShow

func (a *BaseGroup) GetByIdsForShow(tx *gorm.DB, ids ...uint) ([]dto.Group, error)

type FeishuGroups

type FeishuGroups struct {
	ID               uint   `gorm:"primarykey"`
	Name             string `gorm:"not null;unique"`
	OpenDepartmentId string `gorm:"not null;uniqueInde;type:varchar(255)"`
	// BaseGroup.ID
	GID   uint       `gorm:"uniqueIndex;not null;column:gid"`
	Group *BaseGroup `gorm:"foreignKey:GID;constraint:OnDelete:CASCADE"`
}

func (*FeishuGroups) CreateAll

func (a *FeishuGroups) CreateAll(tx *gorm.DB, data []FeishuGroups) error

func (*FeishuGroups) DeleteByIDSlice

func (a *FeishuGroups) DeleteByIDSlice(tx *gorm.DB, ids []uint) error

func (*FeishuGroups) GetAll

func (a *FeishuGroups) GetAll(tx *gorm.DB) ([]FeishuGroups, error)

func (*FeishuGroups) GetByOpenIDSlice

func (a *FeishuGroups) GetByOpenIDSlice(tx *gorm.DB, openID []string) ([]FeishuGroups, error)

func (*FeishuGroups) GetGroupsByOpenIDSlice

func (a *FeishuGroups) GetGroupsByOpenIDSlice(tx *gorm.DB, openID []string) ([]BaseGroup, error)

type LoginRecord

type LoginRecord struct {
	ID        uint `gorm:"primarykey"`
	CreatedAt int64
	// User.ID
	UID  uint  `gorm:"not null;index;column:uid"`
	User *User `gorm:"foreignKey:UID;constraint:OnDelete:CASCADE"`
	IP   string
	// App.ID 为 null 或 0 表示登录的是后台
	AID *uint `gorm:"column:aid;index"`
	App *App  `gorm:"foreignKey:AID;constraint:OnDelete:CASCADE"`
}

func (*LoginRecord) GetByUID

func (a *LoginRecord) GetByUID(tx *gorm.DB, limit int) ([]dto.LoginRecord, error)

func (*LoginRecord) GetLastMonth

func (a *LoginRecord) GetLastMonth(tx *gorm.DB) ([]LoginRecord, error)

func (*LoginRecord) GetMultipleViewsIds

func (a *LoginRecord) GetMultipleViewsIds(tx *gorm.DB, apps []App) ([]dto.ViewID, error)

func (*LoginRecord) GetViewIds

func (a *LoginRecord) GetViewIds(tx *gorm.DB, startAt uint) ([]uint, error)

func (*LoginRecord) Insert

func (a *LoginRecord) Insert(tx *gorm.DB) error

type SiteWhiteList

type SiteWhiteList struct {
	ID           uint `gorm:"primarykey"`
	CreatedAt    int64
	DomainSuffix string `gorm:"not null;uniqueIndex;type:varchar(50)"`
}

func (*SiteWhiteList) Get

func (a *SiteWhiteList) Get(db *gorm.DB) ([]string, error)

func (*SiteWhiteList) Insert

func (a *SiteWhiteList) Insert(db *gorm.DB) error

type User

type User struct {
	ID        uint           `gorm:"primarykey"`
	DeletedAt gorm.DeletedAt `gorm:"index"`

	Name      string `gorm:"not null"`
	Phone     string `gorm:"not null;uniqueIndex;type:varchar(15)"`
	AvatarUrl string

	MFA       string
	PreferU2F string `gorm:"column:prefer_u2f"`
}

func (*User) DelMfa

func (a *User) DelMfa(tx *gorm.DB) error

func (*User) Exist added in v1.17.7

func (a *User) Exist(tx *gorm.DB) (bool, error)

func (*User) FirstByID

func (a *User) FirstByID(tx *gorm.DB) error

func (*User) FirstByPhone

func (a *User) FirstByPhone(tx *gorm.DB) error

func (*User) FirstForPasskey

func (a *User) FirstForPasskey(tx *gorm.DB) error

func (*User) FirstMfa

func (a *User) FirstMfa(tx *gorm.DB) error

func (*User) FirstPhoneByID

func (a *User) FirstPhoneByID(tx *gorm.DB) error

func (*User) FirstProfileByID

func (a *User) FirstProfileByID(tx *gorm.DB) (*dto.UserProfile, error)

func (*User) FrozeByIDSlice

func (a *User) FrozeByIDSlice(tx *gorm.DB, ids []uint) error

func (*User) FrozeByPhone

func (a *User) FrozeByPhone(tx *gorm.DB) *gorm.DB

func (*User) GetNoSshDevIds

func (a *User) GetNoSshDevIds(tx *gorm.DB) ([]uint, error)

GetNoSshDevIds 获取没有分发 ssh 账号的研发部门用户

func (*User) GetNotInPhoneSlice

func (a *User) GetNotInPhoneSlice(tx *gorm.DB, phone []string) ([]User, error)

func (*User) GetUnscopedByPhoneSlice

func (a *User) GetUnscopedByPhoneSlice(tx *gorm.DB, phone []string) ([]User, error)

func (*User) Insert

func (a *User) Insert(tx *gorm.DB) error

func (*User) InsertAll

func (a *User) InsertAll(tx *gorm.DB, users []User) error

func (*User) U2fStatus

func (a *User) U2fStatus(tx *gorm.DB) (*dto.UserU2fStatus, error)

func (*User) UnfrozeByIDSlice

func (a *User) UnfrozeByIDSlice(tx *gorm.DB, ids []uint) error

func (*User) UpdateAllInfoByID

func (a *User) UpdateAllInfoByID(tx *gorm.DB) *gorm.DB

func (*User) UpdateMfa

func (a *User) UpdateMfa(tx *gorm.DB) error

func (*User) UpdateU2fPreferByID

func (a *User) UpdateU2fPreferByID(tx *gorm.DB) error

type UserGroups

type UserGroups struct {
	ID uint `gorm:"primarykey"`
	// User.ID
	UID  uint  `gorm:"index;index:user_group_idx,unique;not null;column:uid;"`
	User *User `gorm:"foreignKey:UID;constraint:OnDelete:CASCADE"`
	// BaseGroup.ID
	GID       uint       `gorm:"index;index:user_group_idx,unique;not null;column:gid"`
	BaseGroup *BaseGroup `gorm:"foreignKey:GID;constraint:OnDelete:CASCADE"`
}

func (*UserGroups) DeleteByIDSlice

func (a *UserGroups) DeleteByIDSlice(tx *gorm.DB, ids []uint) error

func (*UserGroups) DeleteNotInGidSliceByUID

func (a *UserGroups) DeleteNotInGidSliceByUID(tx *gorm.DB, ids []uint) *gorm.DB

func (*UserGroups) ExistByName

func (a *UserGroups) ExistByName(tx *gorm.DB, groupName string) (bool, error)

func (*UserGroups) GetAllNotFrozen

func (a *UserGroups) GetAllNotFrozen(tx *gorm.DB) ([]UserGroups, error)

func (*UserGroups) GetGetUserGroupIdsByUID

func (a *UserGroups) GetGetUserGroupIdsByUID(tx *gorm.DB) ([]uint, error)

func (*UserGroups) GetUserGroupNamesByUID

func (a *UserGroups) GetUserGroupNamesByUID(tx *gorm.DB) ([]string, error)

func (*UserGroups) GetUserGroupsForAppCodeByUID

func (a *UserGroups) GetUserGroupsForAppCodeByUID(tx *gorm.DB, appCode string) *gorm.DB

func (*UserGroups) GetUserGroupsForShowByUID

func (a *UserGroups) GetUserGroupsForShowByUID(tx *gorm.DB) ([]dto.Group, error)

func (*UserGroups) GetUserGroupsLimited

func (a *UserGroups) GetUserGroupsLimited(tx *gorm.DB, groups []string) ([]BaseGroup, error)

GetUserGroupsLimited 根据指定组范围获取用户所在组

func (*UserGroups) InsertAll

func (a *UserGroups) InsertAll(tx *gorm.DB, data []UserGroups) error

type UserSsh

type UserSsh struct {
	ID uint `gorm:"primarykey"`
	// User.ID
	UID  uint  `gorm:"uniqueIndex;not null;column:uid;"`
	User *User `gorm:"foreignKey:UID;constraint:OnDelete:RESTRICT"`

	PublicPem  string `gorm:"not null"`
	PrivatePem string `gorm:"not null"`

	PublicSsh  string `gorm:"not null"`
	PrivateSsh string `gorm:"not null"`
}

func (*UserSsh) DeleteByIds

func (a *UserSsh) DeleteByIds(tx *gorm.DB, id ...uint) error

func (*UserSsh) Exist

func (a *UserSsh) Exist(tx *gorm.DB) (bool, error)

func (*UserSsh) FirstForUserShow

func (a *UserSsh) FirstForUserShow(tx *gorm.DB) error

func (*UserSsh) GetAll

func (a *UserSsh) GetAll(tx *gorm.DB) ([]dto.SshDeploy, error)

func (*UserSsh) GetInvalid

func (a *UserSsh) GetInvalid(tx *gorm.DB) ([]UserSsh, error)

GetInvalid 获取应该清除的 user ssh

func (*UserSsh) Insert

func (a *UserSsh) Insert(tx *gorm.DB) error

func (*UserSsh) InsertAll

func (a *UserSsh) InsertAll(tx *gorm.DB, models []UserSsh) error

func (*UserSsh) UpdateByUid

func (a *UserSsh) UpdateByUid(tx *gorm.DB) error

type UserWebauthn

type UserWebauthn struct {
	ID         uint `gorm:"primarykey"`
	CreatedAt  int
	LastUsedAt int
	UID        uint  `gorm:"index;not null;column:uid"`
	User       *User `gorm:"foreignKey:UID;constraint:OnDelete:CASCADE"`

	CredID     string `gorm:"not null;index;type:varchar(255)"`
	Name       string `gorm:"type:varchar(30)"` // 设备名
	Credential string `gorm:"not null"`         // json marshaled
}

func (*UserWebauthn) Delete

func (a *UserWebauthn) Delete(tx *gorm.DB) *gorm.DB

func (*UserWebauthn) Exist

func (a *UserWebauthn) Exist(tx *gorm.DB) (bool, error)

func (*UserWebauthn) GetByUID

func (a *UserWebauthn) GetByUID(tx *gorm.DB) ([]string, error)

func (*UserWebauthn) GetByUidForShow

func (a *UserWebauthn) GetByUidForShow(tx *gorm.DB) ([]dto.UserCredential, error)

func (*UserWebauthn) Insert

func (a *UserWebauthn) Insert(tx *gorm.DB) error

func (*UserWebauthn) UpdateLastUsedAt

func (a *UserWebauthn) UpdateLastUsedAt(tx *gorm.DB) *gorm.DB

func (*UserWebauthn) UpdatesByID

func (a *UserWebauthn) UpdatesByID(tx *gorm.DB) error

Jump to

Keyboard shortcuts

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