models

package
v0.2.55 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountDB

type AccountDB interface {
	Create(context.Context, *User) error
	ChangePassword(context.Context, *User) error
}

AccountDB represents account related database interface (repository)

type Action

type Action struct {
	ID        int64  `json:"id"`
	CreatedAt int64  `json:"created_at"`
	UpdatedAt int64  `json:"updated_at"`
	DeletedAt int64  `json:"deleted_at"`
	UserID    int64  // 个人或者团体
	Action    int16  // 点赞, 评论, 转发, 收藏, 喜欢, 打赏, 标记, 订阅, 举报, 分享, ...
	Payload   string // 动作数据
	ResType   string `json:"res_type"` // 资源类型
	ResID     int64  `json:"res_id"`   // 资源ID
}

用户对某一资源进行动作,以及所带有的数据 点赞, 评论, 转发, 收藏, 喜欢, 打赏, 标记, 订阅, 举报, 分享, ... 登陆 所有的动作都会被记录下来

type AuthUser

type AuthUser struct {
	ID         int
	CompanyID  int
	LocationID int
	Username   string
	Email      string
}

AuthUser represents data stored in JWT token for user

type BaseModel

type BaseModel struct {
	ID        uint64    `gorm:"column:id;AUTO_INCREMENT;primary_key" json:"id"`
	CreatedAt time.Time `gorm:"column:created_at;index" json:"created_at"`
	UpdatedAt time.Time `gorm:"column:updated_at;index" json:"updated_at"`
	DeletedAt time.Time `gorm:"column:deleted_at" json:"deleted_at"`
	Status    int8      `gorm:"column:status" json:"status"`   // 记录状态: -1=删除 0=可正常使用
	Version   int8      `gorm:"column:version" json:"version"` // 数据库版本
}

func (*BaseModel) BeforeCreate

func (model *BaseModel) BeforeCreate()

func (*BaseModel) BeforeDelete

func (model *BaseModel) BeforeDelete()

func (*BaseModel) BeforeUpdate

func (model *BaseModel) BeforeUpdate()

type Comment

type Comment struct {
	ID        int64  `json:"id"`
	CreatedAt int64  `json:"created_at"`
	UpdatedAt int64  `json:"updated_at"`
	DeletedAt int64  `json:"deleted_at"`
	Namespace string `json:"category"` // 目录命名
	UserId    string // 评论者

	// 评论的对象
	ResType string
	ResID   string

	// 所有的评论都要带上这个ID
	GID       uint64 // hash(ResType,ResID)
	Format    string // image file url 物理格式
	Language  string // zh-CN ...
	SourceUrl string // url
}

user comment some resource some context

type DMB

type DMB struct {
	Title        string
	Creator      string
	Description  string
	Abstract     string `json:"abstract"` // 文章摘要
	Publisher    string
	Type         string
	Contributors []string
	Format       string
	Language     string
	License      string // 最好是一个url
	Source       string
	Subject      string `json:"subject"`

	GID     string
	PID     string
	ID      uint64
	Version int8

	Modified string
	Medium   string

	CreatedAt time.Time `gorm:"column:created_at" json:"created_at"`
	UpdatedAt time.Time `gorm:"column:updated_at" json:"updated_at"`
	DeletedAt time.Time `gorm:"column:deleted_at" json:"deleted_at"`
	Status    int8      `gorm:"column:status" json:"status"` // 记录状态: -1=删除 0=可正常使用
}

Dublin Metadata base

type HugoMatter

type HugoMatter struct {
	Slug                      string
	Tags                      []string `yaml:",flow"`
	KeyWords                  []string `yaml:"keywords,flow"`
	Title                     string   `yaml:",omitempty"`
	Date                      string   `yaml:",omitempty"`
	Lastmod                   string   `yaml:",omitempty"`
	Author                    string   `yaml:",omitempty"`
	Audio                     string   `yaml:",omitempty"`
	PostMetaInFooter          bool     `yaml:",omitempty"`
	ContentCopyright          bool     `yaml:",omitempty"`
	Reward                    bool     `yaml:",omitempty"`
	Mathjax                   bool     `yaml:",omitempty"`
	MathjaxEnableSingleDollar bool     `yaml:",omitempty"`
	MathjaxEnableAutoNumber   bool     `yaml:",omitempty"`
	FlowchartDiagrams         struct {
		Enable  bool   `yaml:",omitempty"`
		Options string `yaml:",omitempty"`
	} `yaml:",omitempty"`
	SequenceDiagrams struct {
		Enable  bool   `yaml:",omitempty"`
		Options string `yaml:",omitempty"`
	} `yaml:",omitempty"`
	Published   string   `yaml:",omitempty"`
	Categories  []string `yaml:",flow,omitempty"`
	Images      []string `yaml:",flow,omitempty"`
	Toc         bool
	Draft       bool
	Headless    bool
	WordCount   int    `yaml:",omitempty"`
	Description string `yaml:",omitempty"`
	Format      string `yaml:",omitempty"` // 数据格式,图片,json,yaml等
	Kind        string `yaml:",omitempty"` // 输出格式 ,展现出来的格式,列表,脑图等
	Layout      string `yaml:",omitempty"` // 输出格式 ,展现出来的格式,列表,脑图等
	Type        string `yaml:",omitempty"` // 业务格式,逻辑格式,文章评论,爱心列表
	Media       map[string]struct {
		Format string `yaml:",omitempty"`
		URL    string `yaml:",omitempty"`
	} `yaml:",omitempty"` // 文章内部的资源
	Weight     int    `yaml:",omitempty"`
	ID         string `yaml:",omitempty"`
	Comments   bool   `yaml:",omitempty"`
	MinHash    string `yaml:",omitempty"`
	Namespaces string `yaml:",omitempty"`
	Path       string `yaml:",omitempty"`
	Platform   map[string]struct {
		ID        string `yaml:",omitempty"`
		Published string `yaml:",omitempty"`
		Updated   string `yaml:",omitempty"`
		URL       string `yaml:",omitempty"`
	} `yaml:",omitempty"`
}

func (*HugoMatter) String

func (t *HugoMatter) String() string

type Matter

type Matter struct {
	Slug     string
	Tags     []string `yaml:",flow"`
	KeyWords []string `yaml:",flow"`
	Title    string   `yaml:",omitempty"`
	Created  string   `yaml:",omitempty"`
	Modified string   `yaml:",omitempty"`

	Published  string   `yaml:",omitempty"`
	Categories []string `yaml:",flow,omitempty"`
	Toc        bool
	IsDraft    bool
	WordCount  int    `yaml:",omitempty"`
	Abstract   string `yaml:",omitempty"`
	Format     string `yaml:",omitempty"` // 数据格式,图片,json,yaml等
	Kind       string `yaml:",omitempty"` // 输出格式 ,展现出来的格式,列表,脑图等
	Type       string `yaml:",omitempty"` // 业务格式,逻辑格式,文章评论,爱心列表
	Media      map[string]struct {
		Format string `yaml:",omitempty"`
		URL    string `yaml:",omitempty"`
	} `yaml:",omitempty"` // 文章内部的资源
	Weight     int    `yaml:",omitempty"`
	ID         string `yaml:",omitempty"`
	Comments   bool   `yaml:",omitempty"`
	MinHash    string `yaml:",omitempty"`
	Namespaces string `yaml:",omitempty"`
	Path       string `yaml:",omitempty"`
	Platform   map[string]struct {
		ID        string `yaml:",omitempty"`
		Published string `yaml:",omitempty"`
		Updated   string `yaml:",omitempty"`
		URL       string `yaml:",omitempty"`
	} `yaml:",omitempty"`
}

type Permission

type Permission struct {
	Status    int8   `json:"status"`  // 记录状态: -1=删除 0=可正常使用
	Version   int8   `json:"version"` // 版本
	ID        int64  `json:"id"`
	CreatedAt int64  `json:"created_at"`
	UpdatedAt int64  `json:"updated_at"`
	DeletedAt int64  `json:"deleted_at"`
	Slug      string `json:"slug"` // unique_index 人类可读的ID

	// 评论的对象
	ResType int16
	ResID   int64

	Public int8 `json:"public"` // 公开的状态
	// 用户操作判断判断
	IsManager int    `json:"is_manager"`
	IsDonate  int    `json:"is_donate"`
	NeedAuth  string `json:"need_auth,omitempty"`
	IsManage  int    `json:"is_manage"`  //
	IsRead    int    `json:"is_read"`    //
	IsCollect int    `json:"is_collect"` //
	//public - 公开级别 [0 - 私密, 1 - 公开]
	//status - 状态 [0 - 草稿, 1 - 发布]
	// 支付
	PayStatus int `json:"pay_status"` //1:已支付 2:通过企业支付 3:企业订阅 4:个人支付  5 是否是
}

权限, 职责

type PlatformLink struct {
	ID        string `json:"id"`
	PublishAt int    `json:"publish_at"`
	UpdateAt  int    `json:"update_at"`
	URL       string `json:"url"`
}
type ResLink struct {
	Slug         string                  `json:"slug"`
	Tags         []string                `json:"tags"`
	Title        string                  `json:"title"`
	Weight       string                  `json:"weight"`
	Format       string                  `json:"format"`
	Abstract     string                  `json:"abstract"`
	Basket       string                  `json:"basket"`
	Score        int                     `json:"score"`
	Content      string                  `json:"content"`
	ContentHash  string                  `json:"content_hash"`
	PushAt       int                     `json:"push_at"`
	Group        string                  `json:"group"`
	ID           string                  `json:"id"`
	MinHash      string                  `json:"min_hash"`
	PlatformLink map[string]PlatformLink `json:"platform"`
	UpdateAt     int                     `json:"update_at"`
	PublishAt    int                     `json:"publish_at"`
}

type Resource

type Resource struct {
	Status      int8   `json:"status"`  // 记录状态: -1=删除 0=可正常使用
	Version     int8   `json:"version"` // 版本
	ID          int64  `json:"id"`
	CreatedAt   int64  `json:"created_at"`
	UpdatedAt   int64  `json:"updated_at"`
	DeletedAt   int64  `json:"deleted_at"`
	Slug        string `json:"slug"`      // unique_index 人类可读的ID
	Namespace   string `json:"namespace"` // 目录命名
	Title       string `json:"title"`     // 文件名称
	CoverUrl    string // url 封面
	Abstract    string `json:"abstract"` // 文章摘要
	Description string // 描述
	//Type        string                 // 实际类型 逻辑类型格式 比如log 通讯录 文章等
	Format    string // image file url 物理格式
	Language  string // zh-CN ...
	SourceUrl string // url
	Creator   string // 创建者
	Tags      string
	Category  string

	// 地理位置
	Geo string

	// 来源链接
	OriginUrl string

	PublishTime int    `json:"publish_time"` // 文章的发布时间
	Publisher   string `json:"publisher"`    // 文章作者
	Group       string
	ContentHash string `json:"content_hash"` // 文章的hash值

	// 额外的数据
	Extra string
}

Resource model

type Statistic

type Statistic struct {
	Status    int8   `json:"status"`  // 记录状态: -1=删除 0=可正常使用
	Version   int8   `json:"version"` // 版本
	ID        int64  `json:"id"`
	CreatedAt int64  `json:"created_at"`
	UpdatedAt int64  `json:"updated_at"`
	DeletedAt int64  `json:"deleted_at"`
	Slug      string `json:"slug"` // unique_index 人类可读的ID

	// 对什么资源进行分析
	ResType int16
	ResID   int64
}

type User

type User struct {
	FirstName string     `json:"first_name"`
	LastName  string     `json:"last_name"`
	Username  string     `json:"username"`
	Password  string     `json:"-"`
	Email     string     `json:"email"`
	Mobile    string     `json:"mobile,omitempty"`
	Phone     string     `json:"phone,omitempty"`
	Address   string     `json:"address,omitempty"`
	LastLogin *time.Time `json:"last_login,omitempty"`
	Active    bool       `json:"active"`
	Token     string     `json:"-"`

	RoleID     int `json:"-"`
	CompanyID  int `json:"company_id"`
	LocationID int `json:"location_id"`
}

User represents user domain model

func (*User) UpdateLastLogin

func (u *User) UpdateLastLogin()

UpdateLastLogin updates last login field

type UserDB

type UserDB interface {
	View(context.Context, int) (*User, error)
	FindByUsername(context.Context, string) (*User, error)
	FindByToken(context.Context, string) (*User, error)
	UpdateLogin(context.Context, *User) error
	//List(context.Context, *ListQuery, *Pagination) ([]User, error)
	Delete(context.Context, *User) error
	Update(context.Context, *User) (*User, error)
}

UserDB represents user database interface (repository)

Jump to

Keyboard shortcuts

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