mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Feat: list tasks
This commit is contained in:
@@ -54,3 +54,21 @@ func GetTasksByID(id interface{}) (*Task, error) {
|
||||
result := DB.Where("id = ?", id).First(task)
|
||||
return task, result.Error
|
||||
}
|
||||
|
||||
// ListTasks 列出用户所属的任务
|
||||
func ListTasks(uid uint, page, pageSize int, order string) ([]Task, int) {
|
||||
var (
|
||||
tasks []Task
|
||||
total int
|
||||
)
|
||||
dbChain := DB
|
||||
dbChain = dbChain.Where("user_id = ?", uid)
|
||||
|
||||
// 计算总数用于分页
|
||||
dbChain.Model(&Share{}).Count(&total)
|
||||
|
||||
// 查询记录
|
||||
dbChain.Limit(pageSize).Offset((page - 1) * pageSize).Order(order).Find(&tasks)
|
||||
|
||||
return tasks, total
|
||||
}
|
||||
|
||||
@@ -54,9 +54,8 @@ type User struct {
|
||||
|
||||
// UserOption 用户个性化配置字段
|
||||
type UserOption struct {
|
||||
ProfileOn int `json:"profile_on"`
|
||||
ProfileOff int `json:"profile_off,omitempty"`
|
||||
PreferredPolicy uint `json:"preferred_policy"`
|
||||
WebDAVKey string `json:"webdav_key"`
|
||||
PreferredTheme string `json:"preferred_theme"`
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user