models

package
v0.0.0-...-47484d2 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var WorkStatsMap = map[string]WorkStatus{"any": 0, "doing": 1, "todo": 2, "done": 3, "drop": 4}

WorkStatsMap .

View Source
var WorkStatsMapJSON = map[WorkStatus]string{1: "doing", 2: "todo", 3: "done", 4: "drop"}

WorkStatsMapJSON .

Functions

This section is empty.

Types

type BaseModel

type BaseModel struct {
	ID        uint64     `json:"id" gorm:"type:bigint(20) unsigned auto_increment;not null;primary_key;comment:'主键id'"`
	CreatedAt time.Time  `json:"createdAt" gorm:"comment:'创建时间'"`
	UpdatedAt time.Time  `json:"updatedAt" gorm:"comment:'更新时间'"`
	DeletedAt *time.Time `json:"-" gorm:"index;comment:'删除时间'"`
}

BaseModel extends gorm.Model, but change ID to sortable uuid

type GoalModel

type GoalModel struct {
	BaseModel
	Title       string `gorm:"not null;size:80"`
	Description string
	Status      WorkStatus `gorm:"index:idx_status;"`
	Minutes     uint64
	Missions    []MissionModel `gorm:"foreignkey:GoalID"`
	User        UserModel      `gorm:"foreignkey:UserID;save_associations:false"`
	UserID      uint64         `gorm:"index"`
}

GoalModel defines user info

func (GoalModel) MarshalJSON

func (g GoalModel) MarshalJSON() ([]byte, error)

MarshalJSON .

type MissionModel

type MissionModel struct {
	BaseModel
	User        UserModel `gorm:"foreignkey:UserID;save_associations:false"`
	UserID      uint64    `gorm:"index"`
	Goal        GoalModel `gorm:"foreignkey:GoalID;save_associations:false"`
	GoalID      uint64    `gorm:"index"`
	Title       string
	Description string
	Status      WorkStatus `gorm:"index"`
	Minutes     uint64
}

MissionModel defines mission

func (MissionModel) MarshalJSON

func (m MissionModel) MarshalJSON() ([]byte, error)

MarshalJSON .

type RecordModel

type RecordModel struct {
	BaseModel
	Content   string
	Review    string
	Mood      string `gorm:"not null;size:10"`
	Minutes   uint16
	Goal      GoalModel    `gorm:"foreignkey:GoalID;save_associations:false"`
	GoalID    uint64       `gorm:"index"`
	Mission   MissionModel `gorm:"foreignkey:MissionID;save_associations:false"`
	MissionID uint64       `gorm:"index"`
	User      UserModel    `gorm:"foreignkey:UserID;save_associations:false"`
	UserID    uint64       `gorm:"index"`
}

RecordModel is for user finished job. Record is not editable, since it will send to user's follower's timeline in next vision. For Minutes, one record can only have max minutes 480, which 8 hours

func (RecordModel) MarshalJSON

func (t RecordModel) MarshalJSON() ([]byte, error)

MarshalJSON .

type Roadmap

type Roadmap struct {
	Title string
}

Roadmap .

type TodoModel

type TodoModel struct {
	BaseModel
	WorkStats
	Content   string
	Goal      GoalModel    `gorm:"foreignkey:GoalID;save_associations:false"`
	GoalID    uint64       `gorm:"index"`
	Mission   MissionModel `gorm:"foreignkey:MissionID;save_associations:false"`
	MissionID uint64       `gorm:"index"`
	User      UserModel    `gorm:"foreignkey:UserID;save_associations:false"`
	UserID    uint64       `gorm:"index"`
}

TodoModel .

func (TodoModel) MarshalJSON

func (t TodoModel) MarshalJSON() ([]byte, error)

MarshalJSON .

type UserModel

type UserModel struct {
	BaseModel
	Name         string `json:"name" gorm:"type:varchar(80)"`
	AvatarURL    string `json:"avatarUrl" gorm:"type:text"`
	Minutes      uint64 `json:"minutes"`
	GithubToken  string `json:"-" gorm:"type:char(40);"`
	GithubID     uint64 `json:"-" gorm:"unique_index;type:BIGINT"`
	RefreshToken string `json:"-" gorm:"type:char(40);"`
}

UserModel defines user info

func (UserModel) MarshalJSON

func (u UserModel) MarshalJSON() ([]byte, error)

MarshalJSON implementation.

type WorkStats

type WorkStats struct {
	Status WorkStatus `gorm:"comment:'0:any, 1:doing, 2:todo, 3:done, 4:drop'"`
}

WorkStats .

type WorkStatus

type WorkStatus uint8

WorkStatus is the enum of status for Goal and Mission

const (
	// StatusAny .
	StatusAny WorkStatus = iota
	// StatusDoing .
	StatusDoing
	// StatusTodo .
	StatusTodo
	// StatusDone .
	StatusDone
	// StatusDrop .
	StatusDrop
)

Jump to

Keyboard shortcuts

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