package serializer import ( "fmt" "github.com/HFO4/cloudreve/models" ) // CheckLogin 检查登录 func CheckLogin() Response { return Response{ Code: CodeCheckLogin, Msg: "未登录", } } // User 用户序列化器 type User struct { ID uint `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"` Policy struct { } `json:"policy"` } // BuildUser 序列化用户 func BuildUser(user model.User) User { fmt.Println(user) return User{ ID: user.ID, Email: user.Email, Nickname: user.Nick, Status: user.Status, Avatar: user.Avatar, CreatedAt: user.CreatedAt.Unix(), PreferredTheme: user.OptionsSerialized.PreferredTheme, } } // BuildUserResponse 序列化用户响应 func BuildUserResponse(user model.User) Response { return Response{ Data: BuildUser(user), } }