Feat: User/Me

This commit is contained in:
HFO4
2019-11-12 15:34:54 +08:00
parent 80f30465e9
commit 589c399488
9 changed files with 148 additions and 17 deletions

View File

@@ -1,7 +1,40 @@
package serializer
// UserOption 用户个性化配置字段
type UserOption struct {
ProfileOn int `json:"profile_on"`
WebDAVKey string `json:"webdav_key"`
import "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"`
}
// BuildUser 序列化用户
func BuildUser(user model.User) User {
return User{
ID: user.ID,
Email: user.Email,
Nickname: user.Nick,
Status: user.Status,
Avatar: user.Avatar,
CreatedAt: user.CreatedAt.Unix(),
}
}
// BuildUserResponse 序列化用户响应
func BuildUserResponse(user model.User) Response {
return Response{
Data: BuildUser(user),
}
}