models

package
v0.2.31 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountDB added in v0.2.30

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

AccountDB represents account related database interface (repository)

type Action added in v0.2.19

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 added in v0.2.30

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

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" 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 added in v0.2.19

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 Permission added in v0.2.19

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 Resource added in v0.2.19

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 added in v0.2.19

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 added in v0.2.30

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:"-"`

	Role *Role `json:"role,omitempty"`

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

User represents user domain model

func (*User) UpdateLastLogin added in v0.2.30

func (u *User) UpdateLastLogin()

UpdateLastLogin updates last login field

type UserDB added in v0.2.30

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