entity

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: May 1, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TableNamePrefix = "wpm_"
)

表名前缀

Variables

This section is empty.

Functions

func HasDeletedAt added in v0.1.2

func HasDeletedAt(at gorm.DeletedAt) bool

HasDeletedAt 判断是否被软删除

func ListPrototypes

func ListPrototypes() []any

ListPrototypes 罗列出所有的 entity 原型

func SortContentTypeArray added in v0.1.1

func SortContentTypeArray(list []*ContentType, fn ContentTypeLessFn)

SortContentTypeArray 对 ContentType 数组进行排序

Types

type Adapter added in v0.1.2

type Adapter struct {
	ContentType    *ContentType
	Executable     *Executable
	IntentTemplate *IntentTemplate
	Media          *Media
	Package        *SoftwarePackage
	Project        *Project
	Repository     *LocalRepository
	Remote         *RemoteRepository
	Setting        *Setting
	Source         *Namespace
	User           *User
	Worktree       *Worktree
}

Adapter 用来适配各种不同类型的 entity

type Base

type Base struct {
	UUID dxo.UUID `gorm:"index:,unique"`

	// ID        uint           `gorm:"primaryKey"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`

	Committer dxo.UserID
	Creator   dxo.UserID
	Owner     dxo.UserID

	Referer string // a URL, refer to owner document of this entity

	Installation dxo.InstallationID // 用来跟踪软件包安装资源项 ,  >0 表示已安装
}

Base ...

func (*Base) PrepareInsert added in v0.1.10

func (inst *Base) PrepareInsert()

type ContentType added in v0.1.1

type ContentType struct {
	ID  dxo.ContentTypeID  `gorm:"primaryKey"`
	URN dxo.ContentTypeURN `gorm:"index:,unique"`

	Base

	Name     dxo.ContentTypeName
	Patterns dxo.StringList

	Label       string
	Icon        string
	Description string

	Priority  int // 优先级,数值越高越先处理
	AsFile    bool
	AsDir     bool
	AsProject bool // true 表示这是一个项目类型
}

ContentType ...

func (ContentType) TableName added in v0.1.1

func (ContentType) TableName() string

TableName ...

type ContentTypeLessFn added in v0.1.1

type ContentTypeLessFn func(o1, o2 *ContentType) bool

ContentTypeLessFn ...

type Example

type Example struct {
	ID dxo.ExampleID `gorm:"primaryKey"`
	Base
}

Example ...

type Executable

type Executable struct {
	ID  dxo.ExecutableID  `gorm:"primaryKey"`
	URN dxo.ExecutableURN // 同名,不同location的多个实体表示 同一个应用的不同版本

	Base

	Name             string
	Aliases          dxo.StringList
	Namespace        string
	Title            string
	IconURL          string
	Description      string
	Size             int64
	SHA256SUM        util.Hex
	OpenWithPriority int // 如果 value<=0, 表示 disable

	OS      string
	Arch    string
	Version string

	Path string `gorm:"index:,unique"`
}

Executable ...

func (Executable) TableName

func (Executable) TableName() string

TableName ...

type Holder added in v0.1.2

type Holder struct {
	ID        int64
	TableName string
	Meta      Base
	Target    *Adapter
}

Holder 用来包装各种不同类型的 entity

func (*Holder) Get added in v0.1.2

func (inst *Holder) Get() interface{}

Get 取 target, 以 interface {} 的形式返回

func (*Holder) SetContentType added in v0.1.2

func (inst *Holder) SetContentType(o *ContentType)

SetContentType ...

func (*Holder) SetExecutable added in v0.1.2

func (inst *Holder) SetExecutable(o *Executable)

SetExecutable ...

func (*Holder) SetIntentTemplate added in v0.1.2

func (inst *Holder) SetIntentTemplate(o *IntentTemplate)

SetIntentTemplate ...

func (*Holder) SetLocalRepository added in v0.1.2

func (inst *Holder) SetLocalRepository(o *LocalRepository)

SetLocalRepository ...

func (*Holder) SetMedia added in v0.1.2

func (inst *Holder) SetMedia(o *Media)

SetMedia ...

func (*Holder) SetProject added in v0.1.2

func (inst *Holder) SetProject(o *Project)

SetProject ...

func (*Holder) SetRemoteRepository added in v0.1.2

func (inst *Holder) SetRemoteRepository(o *RemoteRepository)

SetRemoteRepository ...

func (*Holder) SetSoftwarePackage added in v0.1.2

func (inst *Holder) SetSoftwarePackage(o *SoftwarePackage)

SetSoftwarePackage ...

type InstalledFile added in v0.1.8

type InstalledFile struct {
	ID dxo.InstalledFileID `gorm:"primaryKey"`

	Base

	Name         string // the file name
	Path         string `gorm:"index:,unique"`
	Size         int64
	SHA256SUM    util.Hex
	IsFile       bool
	IsDir        bool
	OwnerPackage dxo.SoftwarePackageURN
}

InstalledFile ...

func (InstalledFile) TableName added in v0.1.8

func (InstalledFile) TableName() string

TableName ...

type IntentTemplate

type IntentTemplate struct {
	ID dxo.IntentTemplateID `gorm:"primaryKey"`
	Base

	Name        string
	Title       string
	Group       string
	Description string
	IconURL     string

	Selector    dxo.IntentTemplateSelector `gorm:"index:,unique"` // 根据(Action + TargetType + ExecutableName)生成
	Method      string
	ContentType string // project-type|content-type|target-type
	// Target      string            // the type of target: file|folder|repository|worktree|...|
	Executable dxo.ExecutableURN // the URN of exe

	Command   string
	Arguments dxo.StringListCRLF // as []string
	Env       dxo.StringMap      // as map[string]string
	WD        string
}

IntentTemplate ...

func (IntentTemplate) TableName

func (IntentTemplate) TableName() string

TableName ...

type LocalRepository

type LocalRepository struct {
	ID dxo.LocalRepositoryID `gorm:"primaryKey"`
	Base

	Name        string
	DisplayName string
	Description string
	Bare        bool

	ConfigFile     string
	RepositoryPath string // the parent of ConfigFile
	DotGitPath     string // can be empty
	WorkingPath    string // can be empty

	Path     string         // this.Path == Location.Path == ConfigFile
	Location dxo.LocationID `gorm:"index:,unique"`
	Class    dxo.LocationClass
}

LocalRepository ...

func (LocalRepository) ListPathFields added in v0.1.1

func (LocalRepository) ListPathFields() []string

ListPathFields ...

func (LocalRepository) TableName

func (LocalRepository) TableName() string

TableName ...

type Location added in v0.1.1

type Location struct {
	ID dxo.LocationID `gorm:"primaryKey"`
	Base

	Path string `gorm:"index:,unique"` // the normalized full-path

	Class  dxo.LocationClass
	AsFile bool // 表示该路径可以是一个普通文件
	AsDir  bool // 表示该路径可以是一个目录

}

Location ...

func (Location) ListPathFields added in v0.1.1

func (Location) ListPathFields() []string

ListPathFields ...

func (Location) TableName added in v0.1.1

func (Location) TableName() string

TableName ...

type Media

type Media struct {
	ID dxo.MediaID `gorm:"primaryKey"`
	Base

	Name   string
	URL    string `gorm:"index:,unique"`
	Source string // Source 表示资源的原始来源URL,如果本地没有该资源,可以通过此URL下载
	Bucket string
	Label  string

	ContentType   string
	ContentLength int64

	SHA256SUM util.Hex
}

Media ...

func (Media) TableName

func (Media) TableName() string

TableName ...

type Namespace added in v0.1.1

type Namespace struct {
	ID  dxo.NamespaceID  `gorm:"primaryKey"`
	URN dxo.NamespaceURN `gorm:"index:,unique"`

	Base

	Name string // like 'domain/path/to/file' format

	URL string // like 'https://domain/path/to/file' format

	Arch string
	OS   string
}

Namespace ...

func (Namespace) TableName added in v0.1.1

func (Namespace) TableName() string

TableName ...

type Project

type Project struct {
	ID dxo.ProjectID `gorm:"primaryKey"`
	Base

	Name           string
	PathInWorktree string
	Description    string
	IsFile         bool
	IsDir          bool
	// ProjectTypeName string
	ConfigFileName  string
	OwnerRepository dxo.LocalRepositoryID

	// FullPath        string `gorm:"index:,unique"`  [已废弃] 用 Path 代替
	ProjectDir string

	Path     string         // this.Path == Location.Path
	Location dxo.LocationID `gorm:"index:,unique"`
	Class    dxo.LocationClass

	Type dxo.ContentTypeName
}

Project ...

func (Project) ListPathFields added in v0.1.1

func (Project) ListPathFields() []string

ListPathFields 用于 FindByPath ...

func (Project) TableName

func (Project) TableName() string

TableName ...

type RemoteRepository

type RemoteRepository struct {
	ID dxo.RemoteRepositoryID `gorm:"primaryKey"`
	Base

	Name        string
	URL         string
	DisplayName string
}

RemoteRepository ...

func (RemoteRepository) TableName

func (RemoteRepository) TableName() string

TableName ...

type Setting added in v0.0.14

type Setting struct {
	ID dxo.SettingID `gorm:"primaryKey"`
	Base

	Name        string `gorm:"index:,unique"`
	Value       string
	Description string
	Type        string
}

Setting 表示一个设置项

func (Setting) TableName added in v0.0.14

func (Setting) TableName() string

TableName ...

type SoftwarePackage added in v0.1.1

type SoftwarePackage struct {
	ID  dxo.SoftwarePackageID  `gorm:"primaryKey"`
	URN dxo.SoftwarePackageURN `gorm:"index:,unique"`

	Base

	Namespace  string
	Name       string
	ModuleName string // = namespace + "#" + name
	FileName   string

	Icon        string
	Title       string
	Description string

	ContentType string
	Size        int64
	SHA256SUM   util.Hex

	WebPageURL  string
	DownloadURL string
	ResourceURL string

	OS        string
	Arch      string
	Version   string
	Revision  int
	ReleaseAt time.Time
}

SoftwarePackage ...

func (SoftwarePackage) TableName added in v0.1.1

func (SoftwarePackage) TableName() string

TableName ...

type SystemConfig

type SystemConfig struct {
	Name        string `gorm:"index:,unique"`
	ContentType string
}

type User

type User struct {
	ID dxo.UserID
	Base

	Name     dxo.UserName `gorm:"index:,unique"`
	Avatar   string
	Nickname string
	Home     string // the home dir path
}

User ...

func (User) TableName

func (User) TableName() string

TableName ...

type UserConfig

type UserConfig struct {
	Name        string `gorm:"index:,unique"`
	ContentType string
}

type Worktree added in v0.1.0

type Worktree struct {
	ID dxo.WorktreeID `gorm:"primaryKey"`
	Base

	Name string

	DotGitPath       string
	WorkingDirectory string

	Path     string         // this.Path == Location.Path == DotGitPath
	Location dxo.LocationID `gorm:"index:,unique"`
	Class    dxo.LocationClass

	OwnerRepository dxo.LocalRepositoryID
}

Worktree 表示一颗本地的工作树

func (Worktree) ListPathFields added in v0.1.1

func (Worktree) ListPathFields() []string

ListPathFields ...

func (Worktree) TableName added in v0.1.1

func (Worktree) TableName() string

TableName ...

Jump to

Keyboard shortcuts

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