2021-12-08 18:43:14 +03:00
|
|
|
package api
|
|
|
|
|
2022-05-15 05:57:54 +03:00
|
|
|
// Role is the type of a role.
|
|
|
|
type Role string
|
|
|
|
|
|
|
|
const (
|
2022-07-08 17:16:18 +03:00
|
|
|
// Host is the HOST role.
|
|
|
|
Host Role = "HOST"
|
2022-05-15 05:57:54 +03:00
|
|
|
// NormalUser is the USER role.
|
|
|
|
NormalUser Role = "USER"
|
|
|
|
)
|
|
|
|
|
2022-05-19 13:32:04 +03:00
|
|
|
func (e Role) String() string {
|
|
|
|
switch e {
|
2022-07-08 17:16:18 +03:00
|
|
|
case Host:
|
|
|
|
return "HOST"
|
2022-05-19 13:32:04 +03:00
|
|
|
case NormalUser:
|
|
|
|
return "USER"
|
|
|
|
}
|
|
|
|
return "USER"
|
|
|
|
}
|
|
|
|
|
2022-02-03 10:32:03 +03:00
|
|
|
type User struct {
|
2022-05-03 06:49:10 +03:00
|
|
|
ID int `json:"id"`
|
|
|
|
|
|
|
|
// Standard fields
|
2022-05-19 13:32:04 +03:00
|
|
|
RowStatus RowStatus `json:"rowStatus"`
|
|
|
|
CreatedTs int64 `json:"createdTs"`
|
|
|
|
UpdatedTs int64 `json:"updatedTs"`
|
2022-02-03 10:32:03 +03:00
|
|
|
|
2022-05-03 06:49:10 +03:00
|
|
|
// Domain specific fields
|
2022-08-13 09:35:33 +03:00
|
|
|
Email string `json:"email"`
|
|
|
|
Role Role `json:"role"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
PasswordHash string `json:"-"`
|
|
|
|
OpenID string `json:"openId"`
|
|
|
|
UserSettingList []*UserSetting `json:"userSettingList"`
|
2021-12-08 18:43:14 +03:00
|
|
|
}
|
|
|
|
|
2022-02-03 10:32:03 +03:00
|
|
|
type UserCreate struct {
|
2022-05-03 06:49:10 +03:00
|
|
|
// Domain specific fields
|
2022-05-16 17:19:39 +03:00
|
|
|
Email string `json:"email"`
|
|
|
|
Role Role `json:"role"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
Password string `json:"password"`
|
2022-02-06 11:19:20 +03:00
|
|
|
PasswordHash string
|
2022-05-15 05:57:54 +03:00
|
|
|
OpenID string
|
2021-12-09 17:02:57 +03:00
|
|
|
}
|
|
|
|
|
2022-02-03 10:32:03 +03:00
|
|
|
type UserPatch struct {
|
2022-05-02 21:05:43 +03:00
|
|
|
ID int
|
2021-12-14 15:40:24 +03:00
|
|
|
|
2022-05-19 13:32:04 +03:00
|
|
|
// Standard fields
|
|
|
|
RowStatus *RowStatus `json:"rowStatus"`
|
|
|
|
|
2022-05-03 06:49:10 +03:00
|
|
|
// Domain specific fields
|
2022-05-15 05:57:54 +03:00
|
|
|
Email *string `json:"email"`
|
2022-05-03 06:49:10 +03:00
|
|
|
Name *string `json:"name"`
|
|
|
|
Password *string `json:"password"`
|
|
|
|
ResetOpenID *bool `json:"resetOpenId"`
|
2022-05-15 05:57:54 +03:00
|
|
|
PasswordHash *string
|
|
|
|
OpenID *string
|
2021-12-14 15:40:24 +03:00
|
|
|
}
|
|
|
|
|
2022-02-03 10:32:03 +03:00
|
|
|
type UserFind struct {
|
2022-05-02 21:05:43 +03:00
|
|
|
ID *int `json:"id"`
|
2021-12-09 17:02:57 +03:00
|
|
|
|
2022-05-19 13:32:04 +03:00
|
|
|
// Standard fields
|
|
|
|
RowStatus *RowStatus `json:"rowStatus"`
|
|
|
|
|
2022-05-03 06:49:10 +03:00
|
|
|
// Domain specific fields
|
2022-05-15 05:57:54 +03:00
|
|
|
Email *string `json:"email"`
|
|
|
|
Role *Role
|
2022-02-06 11:19:20 +03:00
|
|
|
Name *string `json:"name"`
|
2022-05-02 21:05:43 +03:00
|
|
|
OpenID *string
|
2021-12-08 18:43:14 +03:00
|
|
|
}
|
2022-07-26 16:41:20 +03:00
|
|
|
|
|
|
|
type UserDelete struct {
|
|
|
|
ID int
|
|
|
|
}
|