-
Notifications
You must be signed in to change notification settings - Fork 0
/
user.go
56 lines (46 loc) · 1.75 KB
/
user.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright 2023 m01i0ng <alley.ma@qq.com>. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file. The original repo for
// this file is https://github.com/m01i0ng/mblog.
package v1
type CreateUserRequest struct {
Username string `json:"username" valid:"alphanum,required,stringlength(1|255)"`
Password string `json:"password" valid:"required,stringlength(6|18)"`
Nickname string `json:"nickname" valid:"required,stringlength(1|255)"`
Email string `json:"email" valid:"required,email"`
Phone string `json:"phone" valid:"required,stringlength(11|11)"`
}
type LoginRequest struct {
Username string `json:"username" valid:"alphanum,required,stringlength(1|255)"`
Password string `json:"password" valid:"required,stringlength(6|18)"`
}
type LoginResponse struct {
Token string `json:"token"`
}
type ChangePasswordRequest struct {
OldPassword string `json:"oldPassword" valid:"required,stringlength(6|18)"`
NewPassword string `json:"newPassword" valid:"required,stringlength(6|18)"`
}
type GetUserResponse UserInfo
type UserInfo struct {
Username string `json:"username"`
Nickname string `json:"nickname"`
Email string `json:"email"`
Phone string `json:"phone"`
PostCount int64 `json:"postCount"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
}
type ListUserRequest struct {
Offset int `form:"offset"`
Limit int `form:"limit"`
}
type ListUserResponse struct {
TotalCount int64 `json:"totalCount"`
Users []*UserInfo `json:"users"`
}
type UpdateUserRequest struct {
Nickname *string `json:"nickname" valid:"stringlength(1|255)"`
Email *string `json:"email" valid:"email"`
Phone *string `json:"phone" valid:"stringlength(11|11)"`
}