entity

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// AcceptAll accept 的"允许全部"取值
	AcceptAll = "*"
	// AcceptNone accept 的"不允许任何类型"取值(空串)
	AcceptNone = ""
	// MaxSizeUnlimited max_size 的"不限"取值
	MaxSizeUnlimited uint32 = 4294967295

	// MaxDepth 目录限深
	MaxDepth = 10
	// MaxNameLen 目录名最大字符数(CHAR_LENGTH 语义,一个汉字算 1 个字符)
	MaxNameLen = 64
)

accept 取值与 max_size 哨兵(目录策略的领域常量)

View Source
const (
	ExportStatusPending uint8 = 0 // 待执行
	ExportStatusRunning uint8 = 1 // 执行中
	ExportStatusSuccess uint8 = 2 // 成功
	ExportStatusFailed  uint8 = 3 // 失败
	ExportStatusExpired uint8 = 4 // 已过期
)

导出任务状态

View Source
const (
	CdnAuthNone      = "none"       // 公有读
	CdnAuthTypeA     = "cdn_a"      // CDN Type-A:路径 /{YYYYMMDDHHMM}/{md5}/{key} 签名
	CdnAuthTypeB     = "cdn_b"      // CDN Type-B:query ?auth_key={ts}-0-0-{md5} 签名
	CdnAuthTypeC     = "cdn_c"      // CDN Type-C:路径 /{md5}/{hex(ts)}/{key} 签名
	CdnAuthS3Presign = "s3_presign" // 厂商 SigV4 预签名
)

store.cdn_auth_type 的取值

Variables

This section is empty.

Functions

func ValidateName added in v1.2.4

func ValidateName(name string) error

ValidateName 校验目录 / 文件名文法:非空、≤64 字符、不含 /、非 . 与 ..、无控制字符与四字节字符(proto 表达不了)。

Types

type AppConfig added in v1.2.4

type AppConfig struct {
	App                string  `json:"app"                gorm:"column:app"`                  // 应用标识
	StoreKeyword       string  `json:"storeKeyword"       gorm:"column:store_keyword"`        // 上传落地的存储后端
	ExportStoreKeyword string  `json:"exportStoreKeyword" gorm:"column:export_store_keyword"` // 导出产物的存储后端;必填,不为空
	DefaultAccept      *string `json:"defaultAccept"      gorm:"column:default_accept"`       // 默认允许后缀:'*'全部|”不允许任何类型|后缀白名单;” 是合法零值,用指针避免更新被跳过
	DefaultMaxSize     uint32  `json:"defaultMaxSize"     gorm:"column:default_max_size"`     // 默认单文件上限(MB);4294967295 = 不限
	TempUrlTtl         uint32  `json:"tempUrlTtl"         gorm:"column:temp_url_ttl"`         // 临时URL有效期(秒)
	ExportTtl          uint32  `json:"exportTtl"          gorm:"column:export_ttl"`           // 导出产物保留期(秒)
	Quota              *uint64 `json:"quota"              gorm:"column:quota"`                // 存储配额(字节);0=不限;0 是合法值,用指针避免更新被跳过
	UsedBytes          uint64  `json:"usedBytes"          gorm:"column:used_bytes"`           // 已用量(字节);仅经原子表达式维护,不走 Updates
	Status             *uint8  `json:"status"             gorm:"column:status"`               // 状态:1启用 0停用;0 是合法零值,用指针避免更新被跳过
	UpdatedBy          uint32  `json:"updatedBy"          gorm:"column:updated_by"`           // 最后修改人
	model.BaseModel
}

AppConfig 应用存储配置

type Directory

type Directory struct {
	App       string  `json:"app"       gorm:"column:app"`        // 应用标识
	Name      string  `json:"name"      gorm:"column:name"`       // 目录名
	Path      string  `json:"path"      gorm:"column:path"`       // 物化路径,形如 /图片/头像(限深 10)
	Accept    *string `json:"accept"    gorm:"column:accept"`     // 允许后缀:'*'全部|”不允许任何类型|后缀白名单;” 是合法零值,用指针避免更新被跳过
	MaxSize   uint32  `json:"maxSize"   gorm:"column:max_size"`   // 单文件上限(MB);4294967295 = 不限(0 非法)
	UpdatedBy uint32  `json:"updatedBy" gorm:"column:updated_by"` // 最后修改人
	model.BaseModel
}

Directory 应用目录树(物化路径,无 parent_id)

func (*Directory) AllowExt added in v1.2.4

func (d *Directory) AllowExt(ext string) bool

AllowExt 目录当前 accept 策略是否允许该后缀(上传策略判定,非参数校验)。

func (*Directory) WithinSize added in v1.2.4

func (d *Directory) WithinSize(bytes uint64) bool

WithinSize 字节数是否在目录单文件上限内(MaxSizeUnlimited 表示不限)。

type Export

type Export struct {
	App    string `json:"app"    gorm:"column:app"`     // 应用标识
	TaskId uint32 `json:"taskId" gorm:"column:task_id"` // 导出产出物ID
	UserId uint32 `json:"userId" gorm:"column:user_id"` // 发起用户ID,0 = 系统
	Name   string `json:"name"   gorm:"column:name"`    // 用户可见名称
	model.BaseModel
}

Export 用户导出请求记录

type ExportTask added in v1.2.4

type ExportTask struct {
	App          string  `json:"app"          gorm:"column:app"`           // 应用标识
	Md5          string  `json:"md5"          gorm:"column:md5"`           // 产出规格摘要
	StoreKeyword string  `json:"storeKeyword" gorm:"column:store_keyword"` // 产出物实际落地的存储后端
	Size         uint64  `json:"size"         gorm:"column:size"`          // 产出物大小(字节)
	Status       uint8   `json:"status"       gorm:"column:status"`        // 状态:0待执行 1执行中 2成功 3失败 4已过期
	Retry        uint8   `json:"retry"        gorm:"column:retry"`         // 已尝试次数(含首次),领取时 +1
	Reason       *string `json:"reason"       gorm:"column:reason"`        // 最后一次失败原因;成功时 NULL
	ExpiredAt    int64   `json:"expiredAt"    gorm:"column:expired_at"`    // 产出物过期时间(Unix 秒);0 = 未成功
	LeasedAt     int64   `json:"leasedAt"     gorm:"column:leased_at"`     // worker 最后一次领取或心跳时间(Unix 秒);0 = 从未领取
	FailedAt     int64   `json:"failedAt"     gorm:"column:failed_at"`     // 本轮退避计时起点(Unix 秒);0 = 本轮未失败过
	model.BaseModel
}

ExportTask 导出产出物与生产状态

type File

type File struct {
	App         string  `json:"app"         gorm:"column:app"`              // 应用标识
	UserId      uint32  `json:"userId"      gorm:"column:user_id"`          // 上传用户ID,必须 > 0
	DirectoryId uint32  `json:"directoryId" gorm:"column:directory_id"`     // 目录ID
	Name        string  `json:"name"        gorm:"column:name"`             // 业务文件名
	ObjectId    uint32  `json:"objectId"    gorm:"column:object_id"`        // 物理对象ID
	UploadId    *string `json:"uploadId"    gorm:"column:upload_id"`        // 上传会话ID;NULL = 秒传
	Status      *uint8  `json:"status"      gorm:"column:status;default:1"` // 1正常 2待删除(软删,后台回收);指针避免 Updates 跳过,建行 nil 时取 DB 默认 1
	model.BaseModel
}

File 业务文件条目

type Object added in v1.2.4

type Object struct {
	StoreKeyword string `json:"storeKeyword" gorm:"column:store_keyword"` // 存储后端标识
	Md5          string `json:"md5"          gorm:"column:md5"`           // 内容摘要(分片摘要的摘要),32位小写hex
	Ext          string `json:"ext"          gorm:"column:ext"`           // 后缀,小写字母数字;空串 = 无后缀
	Size         uint64 `json:"size"         gorm:"column:size"`          // 对象大小(字节)
	model.BaseModel
}

Object 物理对象(内容寻址)

type Store added in v1.2.4

type Store struct {
	Keyword       string  `json:"keyword"       gorm:"column:keyword"`         // 后端标识
	Provider      string  `json:"provider"      gorm:"column:provider"`        // 厂商标识:aws|bos|oss|cos|obs|minio|uss
	Name          string  `json:"name"          gorm:"column:name"`            // 显示名称
	Endpoint      string  `json:"endpoint"      gorm:"column:endpoint"`        // 厂商API域名(归一化后的形态)
	Region        string  `json:"region"        gorm:"column:region"`          // 地域
	Bucket        string  `json:"bucket"        gorm:"column:bucket"`          // 桶名
	AK            string  `json:"ak"            gorm:"column:ak"`              // 访问密钥ID
	SK            string  `json:"sk"            gorm:"column:sk"`              // 访问密钥;永不进响应
	PublicBaseUrl string  `json:"publicBaseUrl" gorm:"column:public_base_url"` // 公网访问地址前缀
	CdnAuthType   string  `json:"cdnAuthType"   gorm:"column:cdn_auth_type"`   // 临时URL鉴权方式:none|cdn_a|cdn_b|cdn_c|s3_presign
	CdnAuthKey    *string `json:"cdnAuthKey"    gorm:"column:cdn_auth_key"`    // CDN 鉴权 key;NULL = 未配置
	Status        *uint8  `json:"status"        gorm:"column:status"`          // 状态:1启用 0停用;0 是合法零值,用指针避免更新被跳过
	Description   *string `json:"description"   gorm:"column:description"`     // 备注;NULL = 无
	UpdatedBy     uint32  `json:"updatedBy"     gorm:"column:updated_by"`      // 最后修改人
	model.BaseModel
}

Store 对象存储后端

func (*Store) CheckCDN added in v1.2.4

func (s *Store) CheckCDN() error

CheckCDN 校验 endpoint / public_base_url / cdn_auth_type 跨字段自洽性(proto 表达不了,在 app 层调用)。

type Upload added in v1.2.4

type Upload struct {
	StoreKeyword string `json:"storeKeyword" gorm:"column:store_keyword"` // 存储后端标识
	Md5          string `json:"md5"          gorm:"column:md5"`           // 内容摘要(分片摘要的摘要)
	Ext          string `json:"ext"          gorm:"column:ext"`           // 后缀
	UserId       uint32 `json:"userId"       gorm:"column:user_id"`       // 发起用户ID,必须 > 0
	DirectoryId  uint32 `json:"directoryId"  gorm:"column:directory_id"`  // 目标目录ID
	Name         string `json:"name"         gorm:"column:name"`          // 业务文件名
	UploadId     string `json:"uploadId"     gorm:"column:upload_id"`     // 厂商分片上传ID
	TotalSize    uint64 `json:"totalSize"    gorm:"column:total_size"`    // 声明总大小(字节)
	model.BaseModel
}

Upload 分片上传会话

Jump to

Keyboard shortcuts

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