model

package
v0.0.0-...-9a7bc8d Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const RepoName = "ghost_open"

RepoName of MySQL

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessScope

type AccessScope struct {
	gorm.Model
	AppID string

	// AppID:<scope>:<access> e.g. self:group:r
	Name   string `gorm:"not null;unique"`
	Detail string `gorm:"not null"`
}

AccessScope Model

type App

type App struct {
	meta.Model        // ID is app_id
	Key        string `gorm:"not null;unique"` // app_key (公匙/账号)
	Secret     string `gorm:"not null"`        // app_secret (私钥/密码)

	Name  string `gorm:"not null;unique"`
	Icon  string `gorm:"not null"`
	Intro string `gorm:"not null"`
	URL   string `gorm:"not null"` // <url>?token=<jwt>

	OwnerID    string        `gorm:"not null"`                   // "" => core TODO: change
	Managers   []User        `gorm:"many2many:app_managers;"`    // 管理者 TODO: change
	Developers []User        `gorm:"many2many:app_developers;"`  // 开发者 TODO: change
	Users      []User        `gorm:"many2many:app_users;"`       // 用户
	Scopes     []AccessScope `gorm:"ForeignKey:AppID"`           // 可申请范围
	AccessList []AccessScope `gorm:"many2many:app_access_list;"` // 申请范围
}

App Model

func (*App) BeforeCreate

func (*App) BeforeCreate(scope *gorm.Scope) error

BeforeCreate for gorm

type Group

type Group struct {
	meta.Model

	Name   string `gorm:"not null"`
	Icon   string `gorm:"not null"`
	Detail string `gorm:"not null"`

	MasterID string // UUID
	Master   User
	Users    []User `gorm:"many2many:group_users;"`
}

Group Model

type Org

type Org struct {
	meta.Model
	FatherID string

	Name   string `gorm:"not null"`
	Icon   string `gorm:"not null"`
	Detail string `gorm:"not null"`

	MasterID string // UUID
	Master   User
	Users    []User `gorm:"many2many:org_users;"`
}

Org Model

type User

type User struct {
	meta.Model

	Name  string `gorm:"not null;unique"`
	Phone string `gorm:"not null;unique"`
	Email string `gorm:"not null;unique"`
	Pass  string `gorm:"not null"`

	Nick     string `gorm:"not null"`
	Avatar   string `gorm:"not null"`
	Motto    string `gorm:"not null"`
	Homepage string `gorm:"not null"`

	MyApps []App `gorm:"ForeignKey:OwnerID"`   // 创建的应用
	Apps   []App `gorm:"many2many:app_users;"` // 桌面应用
}

User Model

func (*User) TokenPayload

func (u *User) TokenPayload() *pb.TokenPayload

TokenPayload of User

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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