60 lines
1.8 KiB
Go
60 lines
1.8 KiB
Go
package model
|
|
|
|
import (
|
|
"database/sql"
|
|
"time"
|
|
)
|
|
|
|
type User struct {
|
|
ID int64 `db:"id" json:"id"`
|
|
Email string `db:"email" json:"email"`
|
|
Username string `db:"username" json:"username"`
|
|
PasswordHash string `db:"password_hash" json:"-"`
|
|
EmailVerified bool `db:"email_verified" json:"email_verified"`
|
|
TelegramChatID sql.NullInt64 `db:"telegram_chat_id" json:"-"`
|
|
TelegramChatIDValue *int64 `db:"-" json:"telegram_chat_id"`
|
|
NotificationsEnabled bool `db:"notifications_enabled" json:"notifications_enabled"`
|
|
Timezone string `db:"timezone" json:"timezone"`
|
|
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
|
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
|
|
}
|
|
|
|
func (u *User) ProcessForJSON() {
|
|
if u.TelegramChatID.Valid {
|
|
u.TelegramChatIDValue = &u.TelegramChatID.Int64
|
|
}
|
|
}
|
|
|
|
type RegisterRequest struct {
|
|
Email string `json:"email"`
|
|
Username string `json:"username"`
|
|
Password string `json:"password"`
|
|
}
|
|
|
|
type LoginRequest struct {
|
|
Email string `json:"email"`
|
|
Password string `json:"password"`
|
|
}
|
|
|
|
type UpdateProfileRequest struct {
|
|
Username *string `json:"username,omitempty"`
|
|
TelegramChatID *int64 `json:"telegram_chat_id,omitempty"`
|
|
NotificationsEnabled *bool `json:"notifications_enabled,omitempty"`
|
|
Timezone *string `json:"timezone,omitempty"`
|
|
}
|
|
|
|
type ChangePasswordRequest struct {
|
|
OldPassword string `json:"old_password"`
|
|
NewPassword string `json:"new_password"`
|
|
}
|
|
|
|
type AuthResponse struct {
|
|
User *User `json:"user"`
|
|
AccessToken string `json:"access_token"`
|
|
RefreshToken string `json:"refresh_token"`
|
|
}
|
|
|
|
type RefreshRequest struct {
|
|
RefreshToken string `json:"refresh_token"`
|
|
}
|