587 lines
22 KiB
Go
587 lines
22 KiB
Go
// Code generated by gorm.io/gen. DO NOT EDIT.
|
|
// Code generated by gorm.io/gen. DO NOT EDIT.
|
|
// Code generated by gorm.io/gen. DO NOT EDIT.
|
|
|
|
package dbgen
|
|
|
|
import (
|
|
"context"
|
|
|
|
"git.mstar.dev/mstar/linstrom/storage-new/models"
|
|
"gorm.io/gorm"
|
|
"gorm.io/gorm/clause"
|
|
"gorm.io/gorm/schema"
|
|
|
|
"gorm.io/gen"
|
|
"gorm.io/gen/field"
|
|
|
|
"gorm.io/plugin/dbresolver"
|
|
)
|
|
|
|
func newRole(db *gorm.DB, opts ...gen.DOOption) role {
|
|
_role := role{}
|
|
|
|
_role.roleDo.UseDB(db, opts...)
|
|
_role.roleDo.UseModel(&models.Role{})
|
|
|
|
tableName := _role.roleDo.TableName()
|
|
_role.ALL = field.NewAsterisk(tableName)
|
|
_role.ID = field.NewUint(tableName, "id")
|
|
_role.CreatedAt = field.NewTime(tableName, "created_at")
|
|
_role.UpdatedAt = field.NewTime(tableName, "updated_at")
|
|
_role.DeletedAt = field.NewField(tableName, "deleted_at")
|
|
_role.Name = field.NewString(tableName, "name")
|
|
_role.Priority = field.NewUint32(tableName, "priority")
|
|
_role.IsUserRole = field.NewBool(tableName, "is_user_role")
|
|
_role.IsBuiltIn = field.NewBool(tableName, "is_built_in")
|
|
_role.CanSendMedia = field.NewBool(tableName, "can_send_media")
|
|
_role.CanSendCustomEmotes = field.NewBool(tableName, "can_send_custom_emotes")
|
|
_role.CanSendCustomReactions = field.NewBool(tableName, "can_send_custom_reactions")
|
|
_role.CanSendPublicNotes = field.NewBool(tableName, "can_send_public_notes")
|
|
_role.CanSendLocalNotes = field.NewBool(tableName, "can_send_local_notes")
|
|
_role.CanSendFollowerOnlyNotes = field.NewBool(tableName, "can_send_follower_only_notes")
|
|
_role.CanSendPrivateNotes = field.NewBool(tableName, "can_send_private_notes")
|
|
_role.CanSendReplies = field.NewBool(tableName, "can_send_replies")
|
|
_role.CanQuote = field.NewBool(tableName, "can_quote")
|
|
_role.CanBoost = field.NewBool(tableName, "can_boost")
|
|
_role.CanIncludeLinks = field.NewBool(tableName, "can_include_links")
|
|
_role.CanIncludeSurvey = field.NewBool(tableName, "can_include_survey")
|
|
_role.CanFederateFedi = field.NewBool(tableName, "can_federate_fedi")
|
|
_role.CanFederateBsky = field.NewBool(tableName, "can_federate_bsky")
|
|
_role.CanChangeDisplayName = field.NewBool(tableName, "can_change_display_name")
|
|
_role.CanSubmitReports = field.NewBool(tableName, "can_submit_reports")
|
|
_role.CanLogin = field.NewBool(tableName, "can_login")
|
|
_role.CanMentionOthers = field.NewBool(tableName, "can_mention_others")
|
|
_role.HasMentionCountLimit = field.NewBool(tableName, "has_mention_count_limit")
|
|
_role.MentionLimit = field.NewUint32(tableName, "mention_limit")
|
|
_role.AutoNsfwMedia = field.NewBool(tableName, "auto_nsfw_media")
|
|
_role.AutoCwPosts = field.NewBool(tableName, "auto_cw_posts")
|
|
_role.AutoCwPostsText = field.NewString(tableName, "auto_cw_posts_text")
|
|
_role.ScanCreatedPublicNotes = field.NewBool(tableName, "scan_created_public_notes")
|
|
_role.ScanCreatedLocalNotes = field.NewBool(tableName, "scan_created_local_notes")
|
|
_role.ScanCreatedFollowerOnlyNotes = field.NewBool(tableName, "scan_created_follower_only_notes")
|
|
_role.ScanCreatedPrivateNotes = field.NewBool(tableName, "scan_created_private_notes")
|
|
_role.DisallowInteractionsWith = field.NewField(tableName, "disallow_interactions_with")
|
|
_role.WithholdNotesForManualApproval = field.NewBool(tableName, "withhold_notes_for_manual_approval")
|
|
_role.WithholdNotesBasedOnRegex = field.NewBool(tableName, "withhold_notes_based_on_regex")
|
|
_role.WithholdNotesRegexes = field.NewField(tableName, "withhold_notes_regexes")
|
|
_role.FullAdmin = field.NewBool(tableName, "full_admin")
|
|
_role.CanAffectOtherAdmins = field.NewBool(tableName, "can_affect_other_admins")
|
|
_role.CanDeleteNotes = field.NewBool(tableName, "can_delete_notes")
|
|
_role.CanConfirmWithheldNotes = field.NewBool(tableName, "can_confirm_withheld_notes")
|
|
_role.CanAssignRoles = field.NewBool(tableName, "can_assign_roles")
|
|
_role.CanSupressInteractionsBetweenUsers = field.NewBool(tableName, "can_supress_interactions_between_users")
|
|
_role.CanOverwriteDisplayNames = field.NewBool(tableName, "can_overwrite_display_names")
|
|
_role.CanManageCustomEmotes = field.NewBool(tableName, "can_manage_custom_emotes")
|
|
_role.CanViewDeletedNotes = field.NewBool(tableName, "can_view_deleted_notes")
|
|
_role.CanRecoverDeletedNotes = field.NewBool(tableName, "can_recover_deleted_notes")
|
|
_role.CanManageAvatarDecorations = field.NewBool(tableName, "can_manage_avatar_decorations")
|
|
_role.CanManageAds = field.NewBool(tableName, "can_manage_ads")
|
|
_role.CanSendAnnouncements = field.NewBool(tableName, "can_send_announcements")
|
|
_role.CanDeleteAccounts = field.NewBool(tableName, "can_delete_accounts")
|
|
|
|
_role.fillFieldMap()
|
|
|
|
return _role
|
|
}
|
|
|
|
type role struct {
|
|
roleDo
|
|
|
|
ALL field.Asterisk
|
|
ID field.Uint
|
|
CreatedAt field.Time
|
|
UpdatedAt field.Time
|
|
DeletedAt field.Field
|
|
Name field.String
|
|
Priority field.Uint32
|
|
IsUserRole field.Bool
|
|
IsBuiltIn field.Bool
|
|
CanSendMedia field.Bool
|
|
CanSendCustomEmotes field.Bool
|
|
CanSendCustomReactions field.Bool
|
|
CanSendPublicNotes field.Bool
|
|
CanSendLocalNotes field.Bool
|
|
CanSendFollowerOnlyNotes field.Bool
|
|
CanSendPrivateNotes field.Bool
|
|
CanSendReplies field.Bool
|
|
CanQuote field.Bool
|
|
CanBoost field.Bool
|
|
CanIncludeLinks field.Bool
|
|
CanIncludeSurvey field.Bool
|
|
CanFederateFedi field.Bool
|
|
CanFederateBsky field.Bool
|
|
CanChangeDisplayName field.Bool
|
|
CanSubmitReports field.Bool
|
|
CanLogin field.Bool
|
|
CanMentionOthers field.Bool
|
|
HasMentionCountLimit field.Bool
|
|
MentionLimit field.Uint32
|
|
AutoNsfwMedia field.Bool
|
|
AutoCwPosts field.Bool
|
|
AutoCwPostsText field.String
|
|
ScanCreatedPublicNotes field.Bool
|
|
ScanCreatedLocalNotes field.Bool
|
|
ScanCreatedFollowerOnlyNotes field.Bool
|
|
ScanCreatedPrivateNotes field.Bool
|
|
DisallowInteractionsWith field.Field
|
|
WithholdNotesForManualApproval field.Bool
|
|
WithholdNotesBasedOnRegex field.Bool
|
|
WithholdNotesRegexes field.Field
|
|
FullAdmin field.Bool
|
|
CanAffectOtherAdmins field.Bool
|
|
CanDeleteNotes field.Bool
|
|
CanConfirmWithheldNotes field.Bool
|
|
CanAssignRoles field.Bool
|
|
CanSupressInteractionsBetweenUsers field.Bool
|
|
CanOverwriteDisplayNames field.Bool
|
|
CanManageCustomEmotes field.Bool
|
|
CanViewDeletedNotes field.Bool
|
|
CanRecoverDeletedNotes field.Bool
|
|
CanManageAvatarDecorations field.Bool
|
|
CanManageAds field.Bool
|
|
CanSendAnnouncements field.Bool
|
|
CanDeleteAccounts field.Bool
|
|
|
|
fieldMap map[string]field.Expr
|
|
}
|
|
|
|
func (r role) Table(newTableName string) *role {
|
|
r.roleDo.UseTable(newTableName)
|
|
return r.updateTableName(newTableName)
|
|
}
|
|
|
|
func (r role) As(alias string) *role {
|
|
r.roleDo.DO = *(r.roleDo.As(alias).(*gen.DO))
|
|
return r.updateTableName(alias)
|
|
}
|
|
|
|
func (r *role) updateTableName(table string) *role {
|
|
r.ALL = field.NewAsterisk(table)
|
|
r.ID = field.NewUint(table, "id")
|
|
r.CreatedAt = field.NewTime(table, "created_at")
|
|
r.UpdatedAt = field.NewTime(table, "updated_at")
|
|
r.DeletedAt = field.NewField(table, "deleted_at")
|
|
r.Name = field.NewString(table, "name")
|
|
r.Priority = field.NewUint32(table, "priority")
|
|
r.IsUserRole = field.NewBool(table, "is_user_role")
|
|
r.IsBuiltIn = field.NewBool(table, "is_built_in")
|
|
r.CanSendMedia = field.NewBool(table, "can_send_media")
|
|
r.CanSendCustomEmotes = field.NewBool(table, "can_send_custom_emotes")
|
|
r.CanSendCustomReactions = field.NewBool(table, "can_send_custom_reactions")
|
|
r.CanSendPublicNotes = field.NewBool(table, "can_send_public_notes")
|
|
r.CanSendLocalNotes = field.NewBool(table, "can_send_local_notes")
|
|
r.CanSendFollowerOnlyNotes = field.NewBool(table, "can_send_follower_only_notes")
|
|
r.CanSendPrivateNotes = field.NewBool(table, "can_send_private_notes")
|
|
r.CanSendReplies = field.NewBool(table, "can_send_replies")
|
|
r.CanQuote = field.NewBool(table, "can_quote")
|
|
r.CanBoost = field.NewBool(table, "can_boost")
|
|
r.CanIncludeLinks = field.NewBool(table, "can_include_links")
|
|
r.CanIncludeSurvey = field.NewBool(table, "can_include_survey")
|
|
r.CanFederateFedi = field.NewBool(table, "can_federate_fedi")
|
|
r.CanFederateBsky = field.NewBool(table, "can_federate_bsky")
|
|
r.CanChangeDisplayName = field.NewBool(table, "can_change_display_name")
|
|
r.CanSubmitReports = field.NewBool(table, "can_submit_reports")
|
|
r.CanLogin = field.NewBool(table, "can_login")
|
|
r.CanMentionOthers = field.NewBool(table, "can_mention_others")
|
|
r.HasMentionCountLimit = field.NewBool(table, "has_mention_count_limit")
|
|
r.MentionLimit = field.NewUint32(table, "mention_limit")
|
|
r.AutoNsfwMedia = field.NewBool(table, "auto_nsfw_media")
|
|
r.AutoCwPosts = field.NewBool(table, "auto_cw_posts")
|
|
r.AutoCwPostsText = field.NewString(table, "auto_cw_posts_text")
|
|
r.ScanCreatedPublicNotes = field.NewBool(table, "scan_created_public_notes")
|
|
r.ScanCreatedLocalNotes = field.NewBool(table, "scan_created_local_notes")
|
|
r.ScanCreatedFollowerOnlyNotes = field.NewBool(table, "scan_created_follower_only_notes")
|
|
r.ScanCreatedPrivateNotes = field.NewBool(table, "scan_created_private_notes")
|
|
r.DisallowInteractionsWith = field.NewField(table, "disallow_interactions_with")
|
|
r.WithholdNotesForManualApproval = field.NewBool(table, "withhold_notes_for_manual_approval")
|
|
r.WithholdNotesBasedOnRegex = field.NewBool(table, "withhold_notes_based_on_regex")
|
|
r.WithholdNotesRegexes = field.NewField(table, "withhold_notes_regexes")
|
|
r.FullAdmin = field.NewBool(table, "full_admin")
|
|
r.CanAffectOtherAdmins = field.NewBool(table, "can_affect_other_admins")
|
|
r.CanDeleteNotes = field.NewBool(table, "can_delete_notes")
|
|
r.CanConfirmWithheldNotes = field.NewBool(table, "can_confirm_withheld_notes")
|
|
r.CanAssignRoles = field.NewBool(table, "can_assign_roles")
|
|
r.CanSupressInteractionsBetweenUsers = field.NewBool(table, "can_supress_interactions_between_users")
|
|
r.CanOverwriteDisplayNames = field.NewBool(table, "can_overwrite_display_names")
|
|
r.CanManageCustomEmotes = field.NewBool(table, "can_manage_custom_emotes")
|
|
r.CanViewDeletedNotes = field.NewBool(table, "can_view_deleted_notes")
|
|
r.CanRecoverDeletedNotes = field.NewBool(table, "can_recover_deleted_notes")
|
|
r.CanManageAvatarDecorations = field.NewBool(table, "can_manage_avatar_decorations")
|
|
r.CanManageAds = field.NewBool(table, "can_manage_ads")
|
|
r.CanSendAnnouncements = field.NewBool(table, "can_send_announcements")
|
|
r.CanDeleteAccounts = field.NewBool(table, "can_delete_accounts")
|
|
|
|
r.fillFieldMap()
|
|
|
|
return r
|
|
}
|
|
|
|
func (r *role) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
|
_f, ok := r.fieldMap[fieldName]
|
|
if !ok || _f == nil {
|
|
return nil, false
|
|
}
|
|
_oe, ok := _f.(field.OrderExpr)
|
|
return _oe, ok
|
|
}
|
|
|
|
func (r *role) fillFieldMap() {
|
|
r.fieldMap = make(map[string]field.Expr, 53)
|
|
r.fieldMap["id"] = r.ID
|
|
r.fieldMap["created_at"] = r.CreatedAt
|
|
r.fieldMap["updated_at"] = r.UpdatedAt
|
|
r.fieldMap["deleted_at"] = r.DeletedAt
|
|
r.fieldMap["name"] = r.Name
|
|
r.fieldMap["priority"] = r.Priority
|
|
r.fieldMap["is_user_role"] = r.IsUserRole
|
|
r.fieldMap["is_built_in"] = r.IsBuiltIn
|
|
r.fieldMap["can_send_media"] = r.CanSendMedia
|
|
r.fieldMap["can_send_custom_emotes"] = r.CanSendCustomEmotes
|
|
r.fieldMap["can_send_custom_reactions"] = r.CanSendCustomReactions
|
|
r.fieldMap["can_send_public_notes"] = r.CanSendPublicNotes
|
|
r.fieldMap["can_send_local_notes"] = r.CanSendLocalNotes
|
|
r.fieldMap["can_send_follower_only_notes"] = r.CanSendFollowerOnlyNotes
|
|
r.fieldMap["can_send_private_notes"] = r.CanSendPrivateNotes
|
|
r.fieldMap["can_send_replies"] = r.CanSendReplies
|
|
r.fieldMap["can_quote"] = r.CanQuote
|
|
r.fieldMap["can_boost"] = r.CanBoost
|
|
r.fieldMap["can_include_links"] = r.CanIncludeLinks
|
|
r.fieldMap["can_include_survey"] = r.CanIncludeSurvey
|
|
r.fieldMap["can_federate_fedi"] = r.CanFederateFedi
|
|
r.fieldMap["can_federate_bsky"] = r.CanFederateBsky
|
|
r.fieldMap["can_change_display_name"] = r.CanChangeDisplayName
|
|
r.fieldMap["can_submit_reports"] = r.CanSubmitReports
|
|
r.fieldMap["can_login"] = r.CanLogin
|
|
r.fieldMap["can_mention_others"] = r.CanMentionOthers
|
|
r.fieldMap["has_mention_count_limit"] = r.HasMentionCountLimit
|
|
r.fieldMap["mention_limit"] = r.MentionLimit
|
|
r.fieldMap["auto_nsfw_media"] = r.AutoNsfwMedia
|
|
r.fieldMap["auto_cw_posts"] = r.AutoCwPosts
|
|
r.fieldMap["auto_cw_posts_text"] = r.AutoCwPostsText
|
|
r.fieldMap["scan_created_public_notes"] = r.ScanCreatedPublicNotes
|
|
r.fieldMap["scan_created_local_notes"] = r.ScanCreatedLocalNotes
|
|
r.fieldMap["scan_created_follower_only_notes"] = r.ScanCreatedFollowerOnlyNotes
|
|
r.fieldMap["scan_created_private_notes"] = r.ScanCreatedPrivateNotes
|
|
r.fieldMap["disallow_interactions_with"] = r.DisallowInteractionsWith
|
|
r.fieldMap["withhold_notes_for_manual_approval"] = r.WithholdNotesForManualApproval
|
|
r.fieldMap["withhold_notes_based_on_regex"] = r.WithholdNotesBasedOnRegex
|
|
r.fieldMap["withhold_notes_regexes"] = r.WithholdNotesRegexes
|
|
r.fieldMap["full_admin"] = r.FullAdmin
|
|
r.fieldMap["can_affect_other_admins"] = r.CanAffectOtherAdmins
|
|
r.fieldMap["can_delete_notes"] = r.CanDeleteNotes
|
|
r.fieldMap["can_confirm_withheld_notes"] = r.CanConfirmWithheldNotes
|
|
r.fieldMap["can_assign_roles"] = r.CanAssignRoles
|
|
r.fieldMap["can_supress_interactions_between_users"] = r.CanSupressInteractionsBetweenUsers
|
|
r.fieldMap["can_overwrite_display_names"] = r.CanOverwriteDisplayNames
|
|
r.fieldMap["can_manage_custom_emotes"] = r.CanManageCustomEmotes
|
|
r.fieldMap["can_view_deleted_notes"] = r.CanViewDeletedNotes
|
|
r.fieldMap["can_recover_deleted_notes"] = r.CanRecoverDeletedNotes
|
|
r.fieldMap["can_manage_avatar_decorations"] = r.CanManageAvatarDecorations
|
|
r.fieldMap["can_manage_ads"] = r.CanManageAds
|
|
r.fieldMap["can_send_announcements"] = r.CanSendAnnouncements
|
|
r.fieldMap["can_delete_accounts"] = r.CanDeleteAccounts
|
|
}
|
|
|
|
func (r role) clone(db *gorm.DB) role {
|
|
r.roleDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
return r
|
|
}
|
|
|
|
func (r role) replaceDB(db *gorm.DB) role {
|
|
r.roleDo.ReplaceDB(db)
|
|
return r
|
|
}
|
|
|
|
type roleDo struct{ gen.DO }
|
|
|
|
type IRoleDo interface {
|
|
gen.SubQuery
|
|
Debug() IRoleDo
|
|
WithContext(ctx context.Context) IRoleDo
|
|
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
|
ReplaceDB(db *gorm.DB)
|
|
ReadDB() IRoleDo
|
|
WriteDB() IRoleDo
|
|
As(alias string) gen.Dao
|
|
Session(config *gorm.Session) IRoleDo
|
|
Columns(cols ...field.Expr) gen.Columns
|
|
Clauses(conds ...clause.Expression) IRoleDo
|
|
Not(conds ...gen.Condition) IRoleDo
|
|
Or(conds ...gen.Condition) IRoleDo
|
|
Select(conds ...field.Expr) IRoleDo
|
|
Where(conds ...gen.Condition) IRoleDo
|
|
Order(conds ...field.Expr) IRoleDo
|
|
Distinct(cols ...field.Expr) IRoleDo
|
|
Omit(cols ...field.Expr) IRoleDo
|
|
Join(table schema.Tabler, on ...field.Expr) IRoleDo
|
|
LeftJoin(table schema.Tabler, on ...field.Expr) IRoleDo
|
|
RightJoin(table schema.Tabler, on ...field.Expr) IRoleDo
|
|
Group(cols ...field.Expr) IRoleDo
|
|
Having(conds ...gen.Condition) IRoleDo
|
|
Limit(limit int) IRoleDo
|
|
Offset(offset int) IRoleDo
|
|
Count() (count int64, err error)
|
|
Scopes(funcs ...func(gen.Dao) gen.Dao) IRoleDo
|
|
Unscoped() IRoleDo
|
|
Create(values ...*models.Role) error
|
|
CreateInBatches(values []*models.Role, batchSize int) error
|
|
Save(values ...*models.Role) error
|
|
First() (*models.Role, error)
|
|
Take() (*models.Role, error)
|
|
Last() (*models.Role, error)
|
|
Find() ([]*models.Role, error)
|
|
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Role, err error)
|
|
FindInBatches(result *[]*models.Role, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
|
Pluck(column field.Expr, dest interface{}) error
|
|
Delete(...*models.Role) (info gen.ResultInfo, err error)
|
|
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
|
|
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
|
|
Updates(value interface{}) (info gen.ResultInfo, err error)
|
|
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
|
|
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
|
|
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
|
|
UpdateFrom(q gen.SubQuery) gen.Dao
|
|
Attrs(attrs ...field.AssignExpr) IRoleDo
|
|
Assign(attrs ...field.AssignExpr) IRoleDo
|
|
Joins(fields ...field.RelationField) IRoleDo
|
|
Preload(fields ...field.RelationField) IRoleDo
|
|
FirstOrInit() (*models.Role, error)
|
|
FirstOrCreate() (*models.Role, error)
|
|
FindByPage(offset int, limit int) (result []*models.Role, count int64, err error)
|
|
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
|
|
Scan(result interface{}) (err error)
|
|
Returning(value interface{}, columns ...string) IRoleDo
|
|
UnderlyingDB() *gorm.DB
|
|
schema.Tabler
|
|
}
|
|
|
|
func (r roleDo) Debug() IRoleDo {
|
|
return r.withDO(r.DO.Debug())
|
|
}
|
|
|
|
func (r roleDo) WithContext(ctx context.Context) IRoleDo {
|
|
return r.withDO(r.DO.WithContext(ctx))
|
|
}
|
|
|
|
func (r roleDo) ReadDB() IRoleDo {
|
|
return r.Clauses(dbresolver.Read)
|
|
}
|
|
|
|
func (r roleDo) WriteDB() IRoleDo {
|
|
return r.Clauses(dbresolver.Write)
|
|
}
|
|
|
|
func (r roleDo) Session(config *gorm.Session) IRoleDo {
|
|
return r.withDO(r.DO.Session(config))
|
|
}
|
|
|
|
func (r roleDo) Clauses(conds ...clause.Expression) IRoleDo {
|
|
return r.withDO(r.DO.Clauses(conds...))
|
|
}
|
|
|
|
func (r roleDo) Returning(value interface{}, columns ...string) IRoleDo {
|
|
return r.withDO(r.DO.Returning(value, columns...))
|
|
}
|
|
|
|
func (r roleDo) Not(conds ...gen.Condition) IRoleDo {
|
|
return r.withDO(r.DO.Not(conds...))
|
|
}
|
|
|
|
func (r roleDo) Or(conds ...gen.Condition) IRoleDo {
|
|
return r.withDO(r.DO.Or(conds...))
|
|
}
|
|
|
|
func (r roleDo) Select(conds ...field.Expr) IRoleDo {
|
|
return r.withDO(r.DO.Select(conds...))
|
|
}
|
|
|
|
func (r roleDo) Where(conds ...gen.Condition) IRoleDo {
|
|
return r.withDO(r.DO.Where(conds...))
|
|
}
|
|
|
|
func (r roleDo) Order(conds ...field.Expr) IRoleDo {
|
|
return r.withDO(r.DO.Order(conds...))
|
|
}
|
|
|
|
func (r roleDo) Distinct(cols ...field.Expr) IRoleDo {
|
|
return r.withDO(r.DO.Distinct(cols...))
|
|
}
|
|
|
|
func (r roleDo) Omit(cols ...field.Expr) IRoleDo {
|
|
return r.withDO(r.DO.Omit(cols...))
|
|
}
|
|
|
|
func (r roleDo) Join(table schema.Tabler, on ...field.Expr) IRoleDo {
|
|
return r.withDO(r.DO.Join(table, on...))
|
|
}
|
|
|
|
func (r roleDo) LeftJoin(table schema.Tabler, on ...field.Expr) IRoleDo {
|
|
return r.withDO(r.DO.LeftJoin(table, on...))
|
|
}
|
|
|
|
func (r roleDo) RightJoin(table schema.Tabler, on ...field.Expr) IRoleDo {
|
|
return r.withDO(r.DO.RightJoin(table, on...))
|
|
}
|
|
|
|
func (r roleDo) Group(cols ...field.Expr) IRoleDo {
|
|
return r.withDO(r.DO.Group(cols...))
|
|
}
|
|
|
|
func (r roleDo) Having(conds ...gen.Condition) IRoleDo {
|
|
return r.withDO(r.DO.Having(conds...))
|
|
}
|
|
|
|
func (r roleDo) Limit(limit int) IRoleDo {
|
|
return r.withDO(r.DO.Limit(limit))
|
|
}
|
|
|
|
func (r roleDo) Offset(offset int) IRoleDo {
|
|
return r.withDO(r.DO.Offset(offset))
|
|
}
|
|
|
|
func (r roleDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IRoleDo {
|
|
return r.withDO(r.DO.Scopes(funcs...))
|
|
}
|
|
|
|
func (r roleDo) Unscoped() IRoleDo {
|
|
return r.withDO(r.DO.Unscoped())
|
|
}
|
|
|
|
func (r roleDo) Create(values ...*models.Role) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return r.DO.Create(values)
|
|
}
|
|
|
|
func (r roleDo) CreateInBatches(values []*models.Role, batchSize int) error {
|
|
return r.DO.CreateInBatches(values, batchSize)
|
|
}
|
|
|
|
// Save : !!! underlying implementation is different with GORM
|
|
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
|
func (r roleDo) Save(values ...*models.Role) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return r.DO.Save(values)
|
|
}
|
|
|
|
func (r roleDo) First() (*models.Role, error) {
|
|
if result, err := r.DO.First(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.Role), nil
|
|
}
|
|
}
|
|
|
|
func (r roleDo) Take() (*models.Role, error) {
|
|
if result, err := r.DO.Take(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.Role), nil
|
|
}
|
|
}
|
|
|
|
func (r roleDo) Last() (*models.Role, error) {
|
|
if result, err := r.DO.Last(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.Role), nil
|
|
}
|
|
}
|
|
|
|
func (r roleDo) Find() ([]*models.Role, error) {
|
|
result, err := r.DO.Find()
|
|
return result.([]*models.Role), err
|
|
}
|
|
|
|
func (r roleDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Role, err error) {
|
|
buf := make([]*models.Role, 0, batchSize)
|
|
err = r.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
|
defer func() { results = append(results, buf...) }()
|
|
return fc(tx, batch)
|
|
})
|
|
return results, err
|
|
}
|
|
|
|
func (r roleDo) FindInBatches(result *[]*models.Role, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
return r.DO.FindInBatches(result, batchSize, fc)
|
|
}
|
|
|
|
func (r roleDo) Attrs(attrs ...field.AssignExpr) IRoleDo {
|
|
return r.withDO(r.DO.Attrs(attrs...))
|
|
}
|
|
|
|
func (r roleDo) Assign(attrs ...field.AssignExpr) IRoleDo {
|
|
return r.withDO(r.DO.Assign(attrs...))
|
|
}
|
|
|
|
func (r roleDo) Joins(fields ...field.RelationField) IRoleDo {
|
|
for _, _f := range fields {
|
|
r = *r.withDO(r.DO.Joins(_f))
|
|
}
|
|
return &r
|
|
}
|
|
|
|
func (r roleDo) Preload(fields ...field.RelationField) IRoleDo {
|
|
for _, _f := range fields {
|
|
r = *r.withDO(r.DO.Preload(_f))
|
|
}
|
|
return &r
|
|
}
|
|
|
|
func (r roleDo) FirstOrInit() (*models.Role, error) {
|
|
if result, err := r.DO.FirstOrInit(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.Role), nil
|
|
}
|
|
}
|
|
|
|
func (r roleDo) FirstOrCreate() (*models.Role, error) {
|
|
if result, err := r.DO.FirstOrCreate(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.Role), nil
|
|
}
|
|
}
|
|
|
|
func (r roleDo) FindByPage(offset int, limit int) (result []*models.Role, count int64, err error) {
|
|
result, err = r.Offset(offset).Limit(limit).Find()
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
if size := len(result); 0 < limit && 0 < size && size < limit {
|
|
count = int64(size + offset)
|
|
return
|
|
}
|
|
|
|
count, err = r.Offset(-1).Limit(-1).Count()
|
|
return
|
|
}
|
|
|
|
func (r roleDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
|
count, err = r.Count()
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
err = r.Offset(offset).Limit(limit).Scan(result)
|
|
return
|
|
}
|
|
|
|
func (r roleDo) Scan(result interface{}) (err error) {
|
|
return r.DO.Scan(result)
|
|
}
|
|
|
|
func (r roleDo) Delete(models ...*models.Role) (result gen.ResultInfo, err error) {
|
|
return r.DO.Delete(models)
|
|
}
|
|
|
|
func (r *roleDo) withDO(do gen.Dao) *roleDo {
|
|
r.DO = *do.(*gen.DO)
|
|
return r
|
|
}
|