rexDatabase

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

*

@author: taco
@Date: 2023/8/15
@Time: 10:37

*

Index

Constants

View Source
const (
	BootstrapStatusPending = iota + 1
	BootstrapStatusInProgress
	BootstrapStatusCompleted
)
View Source
const (
	ArchiveDefaultNameImage        string = "图片"
	ArchiveDefaultNameVideo        string = "视频"
	ArchiveDefaultNameAudio        string = "音频"
	ArchiveDefaultNameDocument     string = "文档"
	ArchiveDefaultNamePDF          string = "PDF"
	ArchiveDefaultNameCompressed   string = "压缩包"
	ArchiveDefaultNameExternalLink string = "外部链接"
	ArchiveDefaultNameOther        string = "其他"
)
View Source
const (
	DefaultCoverArchiveTypeImage        = "https://cdn.lilsite.com/default_folder_cover/file_coll_default_images_cover.png"
	DefaultCoverArchiveTypeVideo        = "https://cdn.lilsite.com/default_folder_cover/file_coll_default_videos_cover.png"
	DefaultCoverArchiveTypeAudio        = "https://cdn.lilsite.com/default_folder_cover/file_coll_default_media_cover.png"
	DefaultCoverArchiveTypeDocument     = "https://cdn.lilsite.com/default_folder_cover/file_coll_default_docs_cover.png"
	DefaultCoverArchiveTypePDF          = "https://cdn.lilsite.com/default_folder_cover/file_coll_default_pdf_cover.png"
	DefaultCoverArchiveTypeCompressed   = "https://cdn.lilsite.com/default_folder_cover/file_coll_default_zip_cover.png"
	DefaultCoverArchiveTypeExternalLink = "https://cdn.lilsite.com/default_folder_cover/file_coll_default_link_cover.png"
	DefaultCoverArchiveTypeOther        = "https://cdn.lilsite.com/default_folder_cover/file_coll_default_others_cover.png"
)
View Source
const (
	DefaultUploadDirTypeImage  = "images"
	DefaultUploadDirVideo      = "videos"
	DefaultUploadDirAudio      = "audios"
	DefaultUploadDirDocument   = "documents"
	DefaultUploadDirPDF        = "pdfs"
	DefaultUploadDirCompressed = "compressed"
	DefaultUploadDirLinks      = "links"
	DefaultUploadDirOther      = "other"
)
View Source
const (
	OauthMetaLoginTypeExistingUser    = "EXISTING_USER"
	OauthMetaLoginTypeAutoRegister    = "AUTO_REGISTER"
	OauthMetaLoginTypeFirstLogin      = "FIRST_LOGIN"
	OauthMetaLoginTypeAccountLinked   = "ACCOUNT_LINKED"
	OauthMetaLoginTypeInvitedRegister = "INVITED_REGISTER"
)

Variables

This section is empty.

Functions

func Close

func Close(db *sql.DB)

func DefaultFileCover added in v1.1.4

func DefaultFileCover(archiveType ArchiveType) string

func NewDbClient

func NewDbClient(c *DbConfig) (*gorm.DB, error)

func NewGormZapLogger

func NewGormZapLogger() gormLogger.Interface

func NewPgDbClient

func NewPgDbClient(c *PgDbConfig) (*gorm.DB, error)

Types

type ArchiveType added in v1.1.4

type ArchiveType string
const (
	ArchiveTypeImage        ArchiveType = "image"
	ArchiveTypeVideo        ArchiveType = "video"
	ArchiveTypeAudio        ArchiveType = "audio"
	ArchiveTypeDocument     ArchiveType = "document"
	ArchiveTypePDF          ArchiveType = "pdf"
	ArchiveTypeCompressed   ArchiveType = "compressed"
	ArchiveTypeExternalLink ArchiveType = "external_link"
	ArchiveTypeOther        ArchiveType = "other"
)

func FormatArchiveType added in v1.1.4

func FormatArchiveType(uploadType UploadType, fileExt string) (archiveType ArchiveType)

type AuditByStringModel

type AuditByStringModel struct {
	CreatedBy string `gorm:"index:idx_created_by;column:created_by;comment:创建者;type: varchar(255)" json:"created_by"`
	UpdatedBy string `gorm:"index:idx_updated_by;column:updated_by;comment:更新者;type: varchar(255)" json:"updated_by"`
	DeletedBy string `gorm:"index:idx_deleted_by;column:deleted_by;comment:删除者;type: varchar(255)" json:"-"`
}

note: 审计字段新版实现

type AuditByUintModel

type AuditByUintModel struct {
	CreatedBy uint `gorm:"index:idx_created_by;column:created_by;comment:创建者;type:int" json:"created_by"`
	UpdatedBy uint `gorm:"index:idx_updated_by;column:updated_by;comment:更新者;type:int" json:"updated_by"`
	DeletedBy uint `gorm:"index:idx_deleted_by;column:deleted_by;comment:删除者;type:int" json:"-"`
}

type AuditRpcByStringModel

type AuditRpcByStringModel struct {
	CreatedBy string `gorm:"index:idx_created_by;column:created_by;comment:创建者;type: varchar(255)" json:"createdBy"`
	UpdatedBy string `gorm:"index:idx_updated_by;column:updated_by;comment:更新者;type: varchar(255)" json:"updatedBy"`
	DeletedBy string `gorm:"index:idx_deleted_by;column:deleted_by;comment:删除者;type: varchar(255)" json:"-"`
}

type AuditRpcByUintModel

type AuditRpcByUintModel struct {
	CreatedBy string `gorm:"index:idx_created_by;column:created_by;comment:创建者;type:int" json:"createdBy"`
	UpdatedBy string `gorm:"index:idx_updated_by;column:updated_by;comment:更新者;type:int" json:"updatedBy"`
	DeletedBy string `gorm:"index:idx_deleted_by;column:deleted_by;comment:删除者;type:int" json:"-"`
}

type AuditTenantByUintModel

type AuditTenantByUintModel struct {
	CreatedTenantBy uint `gorm:"index:idx_created_tenant_by;column:created_tenant_by;comment:创建数据的租户;type:int" json:"created_tenant_by"`
	UpdatedTenantBy uint `gorm:"index:idx_updated_tenant_by;column:updated_tenant_by;comment:更新数据的租户;type:int" json:"updated_tenant_by"`
	DeletedTenantBy uint `gorm:"index:idx_deleted_tenant_by;column:deleted_tenant_by;comment:删除数据的租户;type:int" json:"-"`
}

type AuditTenantRpcByStringModel

type AuditTenantRpcByStringModel struct {
	CreatedTenantBy string `` /* 131-byte string literal not displayed */
	UpdatedTenantBy string `` /* 131-byte string literal not displayed */
	DeletedTenantBy string `gorm:"index:idx_deleted_tenant_by;column:deleted_tenant_by;comment:删除数据的租户;type: varchar(255)" json:"-"`
}

type AuditTenantRpcByUintModel

type AuditTenantRpcByUintModel struct {
	CreatedTenantBy uint `gorm:"index:idx_created_tenant_by;column:created_tenant_by;comment:创建数据的租户;type:int" json:"createdTenantBy"`
	UpdatedTenantBy uint `gorm:"index:idx_updated_tenant_by;column:updated_tenant_by;comment:更新数据的租户;type:int" json:"updatedTenantBy"`
	DeletedTenantBy uint `gorm:"index:idx_deleted_tenant_by;column:deleted_tenant_by;comment:删除数据的租户;type:int" json:"-"`
}

type AuditUserByStringModel added in v1.0.50

type AuditUserByStringModel struct {
	CreatedUserBy string `` /* 127-byte string literal not displayed */
	UpdatedUserBy string `` /* 127-byte string literal not displayed */
	DeletedUserBy string `gorm:"index:idx_deleted_user_by;column:deleted_user_by;comment:删除数据的用户;type: varchar(255)" json:"-"`
}

note: 审计模型租户版

type AuditUserByUintModel added in v1.0.65

type AuditUserByUintModel struct {
	CreatedUserBy uint `gorm:"index:idx_created_user_by;column:created_user_by;comment:创建数据的用户;" json:"created_user_by"`
	UpdatedUserBy uint `gorm:"index:idx_updated_user_by;column:updated_user_by;comment:更新数据的用户;" json:"updated_user_by"`
	DeletedUserBy uint `gorm:"index:idx_deleted_user_by;column:deleted_user_by;comment:删除数据的用户;" json:"-"`
}

type BaseAdminModel

type BaseAdminModel struct {
	CreatedBy uint `gorm:"column:created_by;comment:创建者;type: int" json:"created_by"`
	UpdatedBy uint `gorm:"column:updated_by;comment:更新者;type: int" json:"updated_by"`
	DeletedBy uint `gorm:"column:deleted_by;comment:删除者;type: int" json:"-"`
}

type BaseModel

type BaseModel struct {
	ID        uint           `gorm:"primarykey" json:"id"`
	CreatedAt time.Time      `gorm:"column:created_at;comment:创建时间;" json:"created_at"`
	UpdatedAt time.Time      `gorm:"column:updated_at;comment:更新时间;" json:"updated_at"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}

note: 兼容实现

type BaseRpcModel

type BaseRpcModel struct {
	ID        uint           `gorm:"primarykey" json:"id"`
	CreatedAt time.Time      `gorm:"column:created_at;comment:创建时间;" json:"createdAt"`
	UpdatedAt time.Time      `gorm:"column:updated_at;comment:更新时间;" json:"updatedAt"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}

note: rpc新版实现

type BaseTenantModel

type BaseTenantModel struct {
	CreatedTenantBy string `` /* 133-byte string literal not displayed */
	UpdatedTenantBy string `` /* 133-byte string literal not displayed */
	DeletedTenantBy string `gorm:"index:idx_deleted_tenant_by;column:deleted_tenant_by;comment:删除数据的租户;type: varchar(255)" json:"-"`
}

type CommonBootstrapStatus added in v1.0.94

type CommonBootstrapStatus int8

type CommonContentStatus added in v1.0.82

type CommonContentStatus int8
const (
	ContentStatusDraft CommonContentStatus = iota + 1
	ContentStatusSubmitted
	ContentStatusRejected
	ContentStatusUnPublished
	ContentStatusPublished
	ContentStatusPinnedOnly
	ContentStatusPinned
)

type CommonSessionStatus added in v1.0.82

type CommonSessionStatus int8
const (
	SessionStatusAnonymous CommonSessionStatus = iota + 1
	SessionStatusAuthenticated
	SessionStatusRevoked
)

type CommonStatus added in v1.0.25

type CommonStatus int8
const (
	AllStatusDisable CommonStatus = iota + 1
	AllStatusEnable
)

type CommonVerifiedStatus added in v1.0.82

type CommonVerifiedStatus int8
const (
	VerifiedStatusUnSubmitted CommonVerifiedStatus = iota + 1
	VerifiedStatusDraft
	VerifiedStatusSubmitted
	VerifiedStatusRejected
	VerifiedStatusVerified
)

type ConfAreaVal added in v1.0.96

type ConfAreaVal string
const (
	ConfAreaValShow ConfAreaVal = "show"
	ConfAreaValHide ConfAreaVal = "hide"
)

type CreatorType added in v1.1.4

type CreatorType string
const (
	CreatorTypeSystem CreatorType = "system"
	CreatorTypeTenant CreatorType = "tenant"
)

type CropperExtraOptions added in v1.0.97

type CropperExtraOptions struct {
	DefaultImage string                     `gorm:"column:default_image;comment:默认图片;type: varchar(255)" json:"default_image"`
	Circled      CropperExtraOptionsCircled `gorm:"column:circled;comment:是否圆形;type:smallint;default:1" json:"circled"`
	MaxMode      CropperExtraOptionsMaxMode `gorm:"column:max_mode;comment:最大尺寸限制模式;type:smallint;default:1" json:"max_mode"`
	MaxWidth     int64                      `gorm:"column:max_width;comment:最大宽度;type: bigint;default:0" json:"max_width"`
	MaxHeight    int64                      `gorm:"column:max_height;comment:最大高度;type: bigint;default:0" json:"max_height"`
	BorderRadius float64                    `` /* 149-byte string literal not displayed */
}

type CropperExtraOptionsCircled added in v1.0.97

type CropperExtraOptionsCircled int8
const (
	// 圆
	CropperExtraOptionsCircledNo CropperExtraOptionsCircled = iota + 1
	// 非圆
	CropperExtraOptionsCircledYes
)

type CropperExtraOptionsMaxMode added in v1.0.98

type CropperExtraOptionsMaxMode int8
const (
	// 圆
	CropperExtraOptionsMaxModeNo CropperExtraOptionsMaxMode = iota + 1
	// 非圆
	CropperExtraOptionsMaxModeYes
)

type CropperOptions added in v1.0.97

type CropperOptions struct {
	ViewMode                         CropperOptionsViewMode    `gorm:"column:view_mode;comment:视图模式;type:smallint;default:1" json:"view_mode"`
	DragMode                         CropperOptionsDragMode    `gorm:"column:drag_mode;comment:拖动模式;type:varchar(12);default:crop" json:"drag_mode"`
	CropperOptionsInitialAspectRatio CropperOptionsAspectRatio `gorm:"embedded;embeddedPrefix:initial_aspect_ratio_" json:"initial_aspect_ratio"`
	CropperOptionsAspectRatio        CropperOptionsAspectRatio `gorm:"embedded;embeddedPrefix:aspect_ratio_" json:"aspect_ratio"`
	//InitialAspectRatioWidth          float64                          `gorm:"column:initial_aspect_ratio_width;comment:初始纵横比宽度;type:float;default:1" json:"initial_aspect_ratio_width"`
	//InitialAspectRatioHeight         float64                          `gorm:"column:initial_aspect_ratio_height;comment:初始纵横比高度;type:float;default:1" json:"initial_aspect_ratio_height"`
	//AspectRatioWidth  float64 `gorm:"column:aspect_ratio_width;comment:纵横比宽度;type:float;default:1" json:"aspect_ratio_width"`
	//AspectRatioHeight float64 `gorm:"column:aspect_ratio_height;comment:纵横比高度;type:float;default:1" json:"aspect_ratio_height"`
	//Data                     []byte                 `gorm:"-" json:"-"`
	//Preview                  []byte                 `gorm:"-" json:"-"`
	Responsive               bool                `gorm:"column:responsive;comment:响应式设计;type:boolean;default:true" json:"responsive"`
	Restore                  bool                `` /* 129-byte string literal not displayed */
	CheckCrossOrigin         bool                `gorm:"column:check_cross_origin;comment:检查跨域;type:boolean;default:true" json:"check_cross_origin"`
	CheckOrientation         bool                `gorm:"column:check_orientation;comment:检查方向;type:boolean;default:true" json:"check_orientation"`
	Modal                    bool                `` /* 131-byte string literal not displayed */
	Guides                   bool                `gorm:"column:guides;comment:指南;type:boolean;default:true" json:"guides"`
	Center                   bool                `gorm:"column:center;comment:中心;type:boolean;default:true" json:"center"`
	Highlight                bool                `` /* 150-byte string literal not displayed */
	Background               bool                `gorm:"column:background;comment:背景,显示容器的网格背景;type:boolean;default:true" json:"background"`
	AutoCrop                 bool                `gorm:"column:auto_crop;comment:自动裁剪;type:boolean;default:true" json:"auto_crop"`
	AutoCropArea             bool                `gorm:"column:auto_crop_area;comment:自动裁剪区域,0-1;type:boolean;default:true" json:"auto_crop_area"`
	Movable                  bool                `gorm:"column:movable;comment:活动,启用此功能可移动图像;type:boolean;default:true" json:"movable"`
	Rotatable                bool                `gorm:"column:rotatable;comment:可旋转;type:boolean;default:true" json:"rotatable"`
	Scalable                 bool                `gorm:"column:scalable;comment:可扩展;type:boolean;default:true" json:"scalable"`
	Zoomable                 bool                `gorm:"column:zoomable;comment:可缩放;type:boolean;default:true" json:"zoomable"`
	ZoomOnTouch              bool                `gorm:"column:zoom_on_touch;comment:触摸缩放;type:boolean;default:true" json:"zoom_on_touch"`
	ZoomOnWheel              bool                `gorm:"column:zoom_on_wheel;comment:车轮上的缩放;type:boolean;default:true" json:"zoom_on_wheel"`
	WheelZoomRatio           bool                `` /* 159-byte string literal not displayed */
	CropBoxMovable           bool                `` /* 168-byte string literal not displayed */
	CropBoxResizable         bool                `` /* 138-byte string literal not displayed */
	ToggleDragModeOnDblclick bool                `` /* 137-byte string literal not displayed */
	MinContainerWidth        int64               `gorm:"column:min_container_width;comment:最小容器宽度;type: bigint;default:200" json:"min_container_width"`
	MinContainerHeight       int64               `gorm:"column:min_container_height;comment:最小容器高度;type: bigint;default:100" json:"min_container_height"`
	MinCanvasWidth           int64               `gorm:"column:min_canvas_width;comment:最小canvas宽度;type: bigint;default:0" json:"min_canvas_width"`
	MinCanvasHeight          int64               `gorm:"column:min_canvas_height;comment:最小canvas高度;type: bigint;default:0" json:"min_canvas_height"`
	MinCropBoxWidth          int64               `gorm:"column:min_crop_box_width;comment:最小裁切框宽度;type: bigint;default:0" json:"min_crop_box_width"`
	MinCropBoxHeight         int64               `gorm:"column:min_crop_box_height;comment:最小裁切框高度;type: bigint;default:0" json:"min_crop_box_height"`
	CropperExtraOptions      CropperExtraOptions `gorm:"embedded;embeddedPrefix:extra_" json:"extra"`
}

type CropperOptionsAspectRatio added in v1.0.97

type CropperOptionsAspectRatio struct {
	Width  float64 `gorm:"column:width;comment:纵横比宽度;type:float;default:1" json:"width"`
	Height float64 `gorm:"column:height;comment:纵横比高度;type:float;default:1" json:"height"`
}

type CropperOptionsDragMode added in v1.0.97

type CropperOptionsDragMode string
const (
	// 创建一个新的裁剪框
	SysCropperOptionsDragModeCrop CropperOptionsDragMode = "crop"
	// 移动画布
	SysCropperOptionsDragModeMove CropperOptionsDragMode = "move"
	// 什么也不做
	SysCropperOptionsDragModeNone CropperOptionsDragMode = "none"
)

type CropperOptionsViewMode added in v1.0.97

type CropperOptionsViewMode int8
const (
	// 0 -> 无限制
	SysCropperOptionsViewModeNoRestrictions CropperOptionsViewMode = iota
	// 1 -> 限制裁剪框的大小,使其不超过画布的大小
	SysCropperOptionsViewModeRestrictCropBox
	// 2 -> 限制画布的最小尺寸,使其能够容纳在容器内。如果画布和容器的比例不同,最小画布尺寸会在其中一个方向上留出额外的空白
	SysCropperOptionsViewModeRestrictCanvas
	// 3 -> 限制画布的最小尺寸,使其能够填满容器。如果画布和容器的比例不同,容器将无法在某个方向上完全容纳画布
	SysCropperOptionsViewModeRestrictCanvasFillContainer
)

type DbConfig

type DbConfig struct {
	Host                 string
	Port                 uint
	DbName               string
	User                 string
	Password             string
	Charset              string
	MaxIdle              int
	MaxOpen              int
	LogMode              bool
	Loc                  string
	MaxLifetime          int64
	TablePrefix          string
	Debug                bool
	AllowNativePasswords bool
}

type IsAccelerate added in v1.1.4

type IsAccelerate int32
const (
	TypeIsAccelerateNo IsAccelerate = iota + 1
	TypeIsAccelerateYes
)

note: 是否开启传输加速,1->否,2-是

type PgDbConfig

type PgDbConfig struct {
	Host        string `json:",default=pg.xx.com"`
	User        string `json:",default=admin"`
	Password    string `json:",default=admin123"`
	DbName      string `json:",default=public"`
	Port        uint   `json:",default=5432"`
	SslMode     string `json:",default=disable"`
	MaxIdle     int    `json:",default=10"`
	MaxOpen     int    `json:",default=100"`
	Loc         string `json:",default=Asia/Shanghai"`
	Debug       bool   `json:",default=true"`
	TablePrefix string `json:",default=v1_"`
	MaxLifetime int64  `json:",default=300"`
}

type SeoBase added in v1.0.84

type SeoBase struct {
	// note: og设置
	OgTitle       string `json:"og_title"`
	OgDescription string `json:"og_description"`
	OgImage       string `json:"og_image"`
	OgUrl         string `json:"og_url"`
}

type SeoExtra added in v1.0.84

type SeoExtra struct {
	SeoBase
	Debug       bool   `gorm:"column:debug;comment:debug;type: boolean;default:false" json:"debug"`
	Card        string `gorm:"column:card;comment:分享卡片;type: varchar(255);" json:"card"`                    // 分享卡片
	CreatorSite string `gorm:"column:creator_site;comment:示例@xxxx;type: varchar(255);" json:"creator_site"` // 创建者站点
}

type SeoShareSetting added in v1.0.76

type SeoShareSetting struct {
	Debug         bool   `gorm:"column:debug;comment:debug;type: boolean;default:false" json:"debug"`
	OgTitle       string `gorm:"column:og_title;comment:og标题;type: varchar(255);" json:"og_title"`
	OgDescription string `gorm:"column:og_description;comment:og描述;type: varchar(255);" json:"og_description"`
	OgImage       string `gorm:"column:og_image;comment:og图片;type: varchar(255);" json:"og_image"`
	Url           string `gorm:"column:url;comment:分享链接;type: varchar(255);" json:"url"`                      // 分享链接
	Card          string `gorm:"column:card;comment:分享卡片;type: varchar(255);" json:"card"`                    // 分享卡片
	CreatorSite   string `gorm:"column:creator_site;comment:示例@xxxx;type: varchar(255);" json:"creator_site"` // 创建者站点
}

type UniqueIdAdminModel

type UniqueIdAdminModel struct {
	CreatedBy string `gorm:"index:idx_created_by;column:created_by;comment:创建者;type: varchar(255)" json:"created_by"`
	UpdatedBy string `gorm:"index:idx_updated_by;column:updated_by;comment:更新者;type: varchar(255)" json:"updated_by"`
	DeletedBy string `gorm:"index:idx_deleted_by;column:deleted_by;comment:删除者;type: varchar(255)" json:"-"`
}

type UploadStatus added in v1.1.4

type UploadStatus int8
const (
	FileStatusCreated UploadStatus = iota + 1
	FileStatusSign
	FileStatusUploaded
)

note: 状态,1->已创建未上传,2->已生成签名,3->已上传完毕

type UploadType added in v1.1.4

type UploadType string
const (
	UploadTypeObjectStorage UploadType = "ObjectStorage"
	UploadTypeServer        UploadType = "ServerUpload"
	UploadTypeExternalAdd   UploadType = "ExternalAdd"
)

上传类型,1->对象存储前端直传,2->服务器接口直传,3->外部添加

Jump to

Keyboard shortcuts

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