feat: 完成基本的 model
This commit is contained in:
46
internal/model/todo.go
Normal file
46
internal/model/todo.go
Normal file
@ -0,0 +1,46 @@
|
||||
package model
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
type TodoStatus string
|
||||
|
||||
const (
|
||||
TodoStatusPlaned TodoStatus = "planned"
|
||||
TodoStatusPaused TodoStatus = "paused"
|
||||
TodoStatusDoing TodoStatus = "doing"
|
||||
TodoStatusDone TodoStatus = "done"
|
||||
TodoStatusCancel TodoStatus = "cancel"
|
||||
)
|
||||
|
||||
var (
|
||||
TodoStatusMap = map[TodoStatus]string{
|
||||
TodoStatusPlaned: "已计划",
|
||||
TodoStatusPaused: "暂停中",
|
||||
TodoStatusDoing: "进行中",
|
||||
TodoStatusDone: "已完成",
|
||||
TodoStatusCancel: "已取消",
|
||||
}
|
||||
)
|
||||
|
||||
func (t TodoStatus) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(TodoStatusMap[t])
|
||||
}
|
||||
|
||||
type Todo struct {
|
||||
Id int64 `json:"id" gorm:"column:id,primaryKey;autoIncrement"`
|
||||
CreatedAt int64 `json:"created_at" gorm:"column:created_at,autoCreateTime:milli"`
|
||||
UpdatedAt int64 `json:"updated_at" gorm:"column:updated_at,autoUpdateTime:milli"`
|
||||
DeletedAt int64 `json:"deleted_at" gorm:"column:deleted_at"`
|
||||
ShouldDoneAt int64 `json:"should_done_at" gorm:"column:should_done_at"`
|
||||
DoneAt int64 `json:"done_at" gorm:"column:done_at"`
|
||||
Title string `json:"title" gorm:"column:title;type:varchar(255);not null"`
|
||||
Content string `json:"content" gorm:"column:content;type:text;not null"`
|
||||
Comment string `json:"comment" gorm:"column:comment;type:text;not null"`
|
||||
Progress int64 `json:"progress" gorm:"column:progress"`
|
||||
Level int64 `json:"level" gorm:"column:level,default:0"`
|
||||
Status TodoStatus `json:"status" gorm:"column:status"`
|
||||
PId int64 `json:"pid" gorm:"column:pid"`
|
||||
UserId int64 `json:"user_id" gorm:"column:user_id"`
|
||||
CollectionId int64 `json:"collection_id" gorm:"column:collection_id"`
|
||||
Weight int64 `json:"weight" gorm:"column:weight"`
|
||||
}
|
Reference in New Issue
Block a user