Documentation
¶
Index ¶
- func CreateConstraint(db *gorm.DB, constraint *Constraint) error
- func CreateTag(db *gorm.DB, tag *Tag) error
- func CreateTask(db *gorm.DB, task *Task) error
- func CreateTimeLog(db *gorm.DB, tl *TimeLog) error
- func DeleteConstraint(db *gorm.DB, id uint) error
- func DeleteTag(db *gorm.DB, id uint) error
- func DeleteTask(db *gorm.DB, id uint) error
- func DeleteTimeLog(db *gorm.DB, id uint) error
- func GetSingaporeLocation() *time.Location
- func GetTaskStats(db *gorm.DB, date time.Time) (map[string]interface{}, error)
- func InitDao(cfg *config.Config, loggerInstance logger.Logger)
- func MarkConstraintAsActive(db *gorm.DB, constraintID uint) error
- func MarkConstraintAsCompleted(db *gorm.DB, constraintID uint, endReason string) error
- func MarkTaskAsCompleted(db *gorm.DB, taskID uint) error
- func MarkTaskAsIncomplete(db *gorm.DB, taskID uint) error
- func SuspendTask(db *gorm.DB, taskID uint) error
- func UnsuspendTask(db *gorm.DB, taskID uint) error
- func UpdateConstraint(db *gorm.DB, constraint *Constraint) error
- func UpdateTag(db *gorm.DB, tag *Tag) error
- func UpdateTask(db *gorm.DB, task *Task) error
- func UpdateTimeLog(db *gorm.DB, tl *TimeLog) error
- type Constraint
- type DBProvider
- type Dao
- type Model
- type Tag
- type Task
- func GetAllTasks(db *gorm.DB, includeSuspended bool, includeCompleted bool) ([]Task, error)
- func GetCompletedTasksInDateRange(db *gorm.DB, startDate, endDate time.Time) ([]Task, error)
- func GetTaskByID(db *gorm.DB, id uint) (*Task, error)
- func GetTasksByDate(db *gorm.DB, date time.Time, includeSuspended bool, includeCompleted bool) ([]Task, error)
- func GetTasksByDateRange(db *gorm.DB, startDate, endDate time.Time) ([]Task, error)
- type TimeLog
- func GetTimeLogByID(db *gorm.DB, id uint) (*TimeLog, error)
- func ListTimeLogs(db *gorm.DB, conds ...interface{}) ([]TimeLog, error)
- func ListTimeLogsByLocalDateRange(db *gorm.DB, startDateStr, endDateStr string) ([]TimeLog, error)
- func ListTimeLogsWithOptions(db *gorm.DB, limit int, orderBy string, conds ...interface{}) ([]TimeLog, error)
- type TxDao
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateConstraint ¶
func CreateConstraint(db *gorm.DB, constraint *Constraint) error
CreateConstraint 创建约束
func DeleteConstraint ¶
DeleteConstraint 删除约束 (软删除)
func GetSingaporeLocation ¶
GetSingaporeLocation 返回新加坡时区,供其他包使用
func GetTaskStats ¶
GetTaskStats 获取任务统计信息
func MarkConstraintAsActive ¶
MarkConstraintAsActive 重新激活约束
func MarkConstraintAsCompleted ¶
MarkConstraintAsCompleted 标记约束为完成
func MarkTaskAsCompleted ¶
MarkTaskAsCompleted 标记任务为完成
func MarkTaskAsIncomplete ¶
MarkTaskAsIncomplete 标记任务为未完成
func UpdateConstraint ¶
func UpdateConstraint(db *gorm.DB, constraint *Constraint) error
UpdateConstraint 更新约束
Types ¶
type Constraint ¶
type Constraint struct {
ID uint `gorm:"primaryKey" json:"id"`
Description string `gorm:"column:description;not null;type:text" json:"description"`
EndReason string `gorm:"column:end_reason;type:text" json:"end_reason"`
PunishmentQuote string `gorm:"column:punishment_quote;not null;type:text" json:"punishment_quote"`
StartDate time.Time `gorm:"column:start_date;not null" json:"start_date"`
EndDate *time.Time `gorm:"column:end_date" json:"end_date"`
IsActive bool `gorm:"column:is_active;default:true" json:"is_active"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}
func GetActiveConstraints ¶
func GetActiveConstraints(db *gorm.DB) ([]Constraint, error)
GetActiveConstraints 获取活跃的约束
func GetAllConstraints ¶
func GetAllConstraints(db *gorm.DB) ([]Constraint, error)
GetAllConstraints 获取所有约束
func GetConstraintByID ¶
func GetConstraintByID(db *gorm.DB, id uint) (*Constraint, error)
GetConstraintByID 根据ID获取约束
func GetConstraintsByDateRange ¶
GetConstraintsByDateRange 根据日期范围获取约束
func (Constraint) TableName ¶
func (Constraint) TableName() string
type DBProvider ¶
type Dao ¶
func (*Dao) AdminGetAllCache ¶
func (d *Dao) AdminGetAllCache()
type Tag ¶
type Tag struct {
ID uint `gorm:"primaryKey" json:"id"`
Name string `gorm:"column:name;not null;unique" json:"name"`
Color string `gorm:"column:color" json:"color"`
Description string `gorm:"column:description" json:"description"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}
Tag 表示一个标签
type Task ¶
type Task struct {
ID uint `gorm:"primaryKey" json:"id"`
Title string `gorm:"column:title;not null;size:200" json:"title"`
Description string `gorm:"column:description;type:text" json:"description"`
TagID uint `gorm:"column:tag_id;not null" json:"tag_id"`
Tag Tag `gorm:"foreignKey:TagID" json:"tag"`
DueDate time.Time `gorm:"column:due_date;not null" json:"due_date"`
EstimatedMinutes int `gorm:"column:estimated_minutes;not null" json:"estimated_minutes"`
IsCompleted bool `gorm:"column:is_completed;default:false" json:"is_completed"`
CompletedAt *time.Time `gorm:"column:completed_at" json:"completed_at"`
IsSuspended bool `gorm:"column:is_suspended;default:false" json:"is_suspended"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}
func GetAllTasks ¶
GetAllTasks 获取所有任务 includeSuspended: 是否包含暂停的任务 includeCompleted: 是否包含已完成的任务
func GetCompletedTasksInDateRange ¶
GetCompletedTasksInDateRange 获取指定日期范围内的已完成任务
func GetTasksByDate ¶
func GetTasksByDate(db *gorm.DB, date time.Time, includeSuspended bool, includeCompleted bool) ([]Task, error)
GetTasksByDate 根据日期获取任务 includeSuspended: 是否包含暂停的任务 includeCompleted: 是否包含已完成的任务
func GetTasksByDateRange ¶
GetTasksByDateRange 根据日期范围获取任务
type TimeLog ¶
type TimeLog struct {
gorm.Model
UserID uint `gorm:"column:user_id" json:"user_id"`
StartTime time.Time `gorm:"column:start_time" json:"start_time"`
EndTime *time.Time `gorm:"column:end_time" json:"end_time"`
TagID uint `gorm:"column:tag_id" json:"tag_id"`
Tag Tag `gorm:"foreignKey:TagID" json:"tag"`
TaskID *uint `gorm:"column:task_id" json:"task_id,omitempty"`
Task *Task `gorm:"foreignKey:TaskID" json:"task,omitempty"`
Remark string `gorm:"column:remark" json:"remarks"`
}
func GetTimeLogByID ¶
GetTimeLogByID 根据ID获取时间日志
func ListTimeLogs ¶
ListTimeLogs 查询时间日志(可扩展条件)
func ListTimeLogsByLocalDateRange ¶
ListTimeLogsByLocalDateRange 根据本地日期范围查询时间日志 startDateStr 和 endDateStr 格式为 "YYYY-MM-DD",会被解析为新加坡时区 数据库存储的是 UTC 时间,该函数会自动转换