mirror of
https://github.com/aykhans/slash-e.git
synced 2025-07-03 20:21:40 +00:00
feat: refactor code structure
This commit is contained in:
@ -1,9 +1,9 @@
|
||||
package api
|
||||
|
||||
type Signup struct {
|
||||
Email string `json:"email"`
|
||||
Name string `json:"name"`
|
||||
Password string `json:"password"`
|
||||
Email string `json:"email"`
|
||||
DisplayName string `json:"displayName"`
|
||||
Password string `json:"password"`
|
||||
}
|
||||
|
||||
type Signin struct {
|
||||
|
24
api/user.go
24
api/user.go
@ -16,7 +16,7 @@ type User struct {
|
||||
|
||||
// Domain specific fields
|
||||
Email string `json:"email"`
|
||||
Name string `json:"name"`
|
||||
DisplayName string `json:"displayName"`
|
||||
PasswordHash string `json:"-"`
|
||||
OpenID string `json:"openId"`
|
||||
UserSettingList []*UserSetting `json:"userSettingList"`
|
||||
@ -24,20 +24,20 @@ type User struct {
|
||||
|
||||
type UserCreate struct {
|
||||
Email string `json:"email"`
|
||||
Name string `json:"name"`
|
||||
DisplayName string `json:"displayName"`
|
||||
Password string `json:"password"`
|
||||
PasswordHash string
|
||||
OpenID string
|
||||
PasswordHash string `json:"-"`
|
||||
OpenID string `json:"-"`
|
||||
}
|
||||
|
||||
func (create UserCreate) Validate() error {
|
||||
if !common.ValidateEmail(create.Email) {
|
||||
return fmt.Errorf("invalid email format")
|
||||
}
|
||||
if len(create.Email) < 6 {
|
||||
if len(create.Email) < 3 {
|
||||
return fmt.Errorf("email is too short, minimum length is 6")
|
||||
}
|
||||
if len(create.Password) < 6 {
|
||||
if len(create.Password) < 3 {
|
||||
return fmt.Errorf("password is too short, minimum length is 6")
|
||||
}
|
||||
|
||||
@ -52,11 +52,11 @@ type UserPatch struct {
|
||||
|
||||
// Domain specific fields
|
||||
Email *string `json:"email"`
|
||||
Name *string `json:"name"`
|
||||
DisplayName *string `json:"displayName"`
|
||||
Password *string `json:"password"`
|
||||
ResetOpenID *bool `json:"resetOpenId"`
|
||||
PasswordHash *string
|
||||
OpenID *string
|
||||
PasswordHash *string `json:"-"`
|
||||
OpenID *string `json:"-"`
|
||||
}
|
||||
|
||||
type UserFind struct {
|
||||
@ -66,9 +66,9 @@ type UserFind struct {
|
||||
RowStatus *RowStatus `json:"rowStatus"`
|
||||
|
||||
// Domain specific fields
|
||||
Email *string `json:"email"`
|
||||
Name *string `json:"name"`
|
||||
OpenID *string `json:"openId"`
|
||||
Email *string `json:"email"`
|
||||
DisplayName *string `json:"displayName"`
|
||||
OpenID *string `json:"openId"`
|
||||
}
|
||||
|
||||
type UserDelete struct {
|
||||
|
@ -21,15 +21,13 @@ func (e Role) String() string {
|
||||
}
|
||||
|
||||
type WorkspaceUser struct {
|
||||
WorkspaceID int `json:"workspaceId"`
|
||||
UserID int `json:"userId"`
|
||||
Role Role `json:"role"`
|
||||
CreatedTs int64 `json:"createdTs"`
|
||||
UpdatedTs int64 `json:"updatedTs"`
|
||||
WorkspaceID int `json:"workspaceId"`
|
||||
UserID int `json:"userId"`
|
||||
Role Role `json:"role"`
|
||||
|
||||
// Related fields
|
||||
Email string `json:"email"`
|
||||
Name string `json:"name"`
|
||||
Email string `json:"email"`
|
||||
DisplayName string `json:"displayName"`
|
||||
}
|
||||
|
||||
type WorkspaceUserUpsert struct {
|
||||
|
Reference in New Issue
Block a user