forked from mtusi2026/mtusi2026lab2
42 lines
867 B
Go
42 lines
867 B
Go
package users
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gitflic.ru/project/bulla-max/mtusi2026lab1/internal/common"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type User struct {
|
|
ID uuid.UUID `json:"id"`
|
|
Username string `json:"username"`
|
|
DisplayName string `json:"display_name"`
|
|
CreatedAt common.RFCFormTime `json:"created_at"`
|
|
}
|
|
|
|
type CreateUserRequest struct {
|
|
Username string `json:"username" validate:"required"`
|
|
DisplayName string `json:"display_name" validate:"required"`
|
|
}
|
|
|
|
func NewUser(req CreateUserRequest) User {
|
|
return User{
|
|
ID: uuid.New(),
|
|
Username: req.Username,
|
|
DisplayName: req.DisplayName,
|
|
CreatedAt: common.NowUTC(),
|
|
}
|
|
}
|
|
|
|
func (u User) GetID() uuid.UUID {
|
|
return u.ID
|
|
}
|
|
|
|
func (u User) GetCreatedAt() time.Time {
|
|
return time.Time(u.CreatedAt)
|
|
}
|
|
|
|
func (u User) GetUsername() string {
|
|
return u.Username
|
|
}
|