Feat: use RFC3339 time format in returned results (#811)

pull/831/head
HFO4 3 years ago
parent a1252c810b
commit 96712fb066

@ -1 +1 @@
Subproject commit 522a75c750ab78496e160b481a286013df4e0914
Subproject commit 08a301d53a39d0a67a2714caef9866c1eeaa4ee3

@ -5,6 +5,7 @@ import (
"fmt"
"path"
"strings"
"time"
model "github.com/cloudreve/Cloudreve/v3/models"
"github.com/cloudreve/Cloudreve/v3/pkg/filesystem/fsctx"
@ -20,14 +21,14 @@ import (
// Object 文件或者目录
type Object struct {
ID string `json:"id"`
Name string `json:"name"`
Path string `json:"path"`
Pic string `json:"pic"`
Size uint64 `json:"size"`
Type string `json:"type"`
Date string `json:"date"`
Key string `json:"key,omitempty"`
ID string `json:"id"`
Name string `json:"name"`
Path string `json:"path"`
Pic string `json:"pic"`
Size uint64 `json:"size"`
Type string `json:"type"`
Date time.Time `json:"date"`
Key string `json:"key,omitempty"`
}
// Rename 重命名对象
@ -349,7 +350,7 @@ func (fs *FileSystem) listObjects(ctx context.Context, parent string, files []mo
Pic: "",
Size: 0,
Type: "dir",
Date: subFolder.CreatedAt.Format("2006-01-02 15:04:05"),
Date: subFolder.CreatedAt,
})
}
@ -369,7 +370,7 @@ func (fs *FileSystem) listObjects(ctx context.Context, parent string, files []mo
Pic: file.PicInfo,
Size: file.Size,
Type: "file",
Date: file.CreatedAt.Format("2006-01-02 15:04:05"),
Date: file.CreatedAt,
}
if shareKey != "" {
newFile.Key = shareKey

@ -2,6 +2,7 @@ package serializer
import (
"path"
"time"
model "github.com/cloudreve/Cloudreve/v3/models"
"github.com/cloudreve/Cloudreve/v3/pkg/aria2/rpc"
@ -9,7 +10,7 @@ import (
// DownloadListResponse 下载列表响应条目
type DownloadListResponse struct {
UpdateTime int64 `json:"update"`
UpdateTime time.Time `json:"update"`
UpdateInterval int `json:"interval"`
Name string `json:"name"`
Status int `json:"status"`
@ -31,8 +32,8 @@ type FinishedListResponse struct {
Files []rpc.FileInfo `json:"files"`
TaskStatus int `json:"task_status"`
TaskError string `json:"task_error"`
CreateTime string `json:"create"`
UpdateTime string `json:"update"`
CreateTime time.Time `json:"create"`
UpdateTime time.Time `json:"update"`
}
// BuildFinishedListResponse 构建已完成任务条目
@ -59,8 +60,8 @@ func BuildFinishedListResponse(tasks []model.Download) Response {
Total: tasks[i].TotalSize,
Files: tasks[i].StatusInfo.Files,
TaskStatus: -1,
UpdateTime: tasks[i].UpdatedAt.Format("2006-01-02 15:04:05"),
CreateTime: tasks[i].CreatedAt.Format("2006-01-02 15:04:05"),
UpdateTime: tasks[i].UpdatedAt,
CreateTime: tasks[i].CreatedAt,
}
if tasks[i].Task != nil {
@ -92,7 +93,7 @@ func BuildDownloadingResponse(tasks []model.Download) Response {
}
resp = append(resp, DownloadListResponse{
UpdateTime: tasks[i].UpdatedAt.Unix(),
UpdateTime: tasks[i].UpdatedAt,
UpdateInterval: interval,
Name: fileName,
Status: tasks[i].Status,

@ -1,6 +1,9 @@
package serializer
import model "github.com/cloudreve/Cloudreve/v3/models"
import (
model "github.com/cloudreve/Cloudreve/v3/models"
"time"
)
// SiteConfig 站点全局设置序列
type SiteConfig struct {
@ -22,11 +25,11 @@ type SiteConfig struct {
}
type task struct {
Status int `json:"status"`
Type int `json:"type"`
CreateDate string `json:"create_date"`
Progress int `json:"progress"`
Error string `json:"error"`
Status int `json:"status"`
Type int `json:"type"`
CreateDate time.Time `json:"create_date"`
Progress int `json:"progress"`
Error string `json:"error"`
}
// BuildTaskList 构建任务列表响应
@ -36,7 +39,7 @@ func BuildTaskList(tasks []model.Task, total int) Response {
res = append(res, task{
Status: t.Status,
Type: t.Type,
CreateDate: t.CreatedAt.Format("2006-01-02 15:04:05"),
CreateDate: t.CreatedAt,
Progress: t.Progress,
Error: t.Error,
})

@ -12,7 +12,7 @@ type Share struct {
Key string `json:"key"`
Locked bool `json:"locked"`
IsDir bool `json:"is_dir"`
CreateDate string `json:"create_date,omitempty"`
CreateDate time.Time `json:"create_date,omitempty"`
Downloads int `json:"downloads"`
Views int `json:"views"`
Expire int64 `json:"expire"`
@ -37,7 +37,7 @@ type myShareItem struct {
Key string `json:"key"`
IsDir bool `json:"is_dir"`
Password string `json:"password"`
CreateDate string `json:"create_date,omitempty"`
CreateDate time.Time `json:"create_date,omitempty"`
Downloads int `json:"downloads"`
RemainDownloads int `json:"remain_downloads"`
Views int `json:"views"`
@ -55,7 +55,7 @@ func BuildShareList(shares []model.Share, total int) Response {
Key: hashid.HashID(shares[i].ID, hashid.ShareID),
IsDir: shares[i].IsDir,
Password: shares[i].Password,
CreateDate: shares[i].CreatedAt.Format("2006-01-02 15:04:05"),
CreateDate: shares[i].CreatedAt,
Downloads: shares[i].Downloads,
Views: shares[i].Views,
Preview: shares[i].PreviewEnabled,
@ -99,7 +99,7 @@ func BuildShareResponse(share *model.Share, unlocked bool) Share {
Nick: creator.Nick,
GroupName: creator.Group.Name,
},
CreateDate: share.CreatedAt.Format("2006-01-02 15:04:05"),
CreateDate: share.CreatedAt,
}
// 未解锁时只返回基本信息

@ -6,6 +6,7 @@ import (
model "github.com/cloudreve/Cloudreve/v3/models"
"github.com/cloudreve/Cloudreve/v3/pkg/hashid"
"github.com/duo-labs/webauthn/webauthn"
"time"
)
// CheckLogin 检查登录
@ -18,17 +19,17 @@ func CheckLogin() Response {
// User 用户序列化器
type User struct {
ID string `json:"id"`
Email string `json:"user_name"`
Nickname string `json:"nickname"`
Status int `json:"status"`
Avatar string `json:"avatar"`
CreatedAt int64 `json:"created_at"`
PreferredTheme string `json:"preferred_theme"`
Anonymous bool `json:"anonymous"`
Policy policy `json:"policy"`
Group group `json:"group"`
Tags []tag `json:"tags"`
ID string `json:"id"`
Email string `json:"user_name"`
Nickname string `json:"nickname"`
Status int `json:"status"`
Avatar string `json:"avatar"`
CreatedAt time.Time `json:"created_at"`
PreferredTheme string `json:"preferred_theme"`
Anonymous bool `json:"anonymous"`
Policy policy `json:"policy"`
Group group `json:"group"`
Tags []tag `json:"tags"`
}
type policy struct {
@ -94,7 +95,7 @@ func BuildUser(user model.User) User {
Nickname: user.Nick,
Status: user.Status,
Avatar: user.Avatar,
CreatedAt: user.CreatedAt.Unix(),
CreatedAt: user.CreatedAt,
PreferredTheme: user.OptionsSerialized.PreferredTheme,
Anonymous: user.IsAnonymous(),
Policy: policy{

Loading…
Cancel
Save