30 lines
770 B
Go
30 lines
770 B
Go
package dto
|
|
|
|
import (
|
|
"high-loud-apps-labs/internal/domain"
|
|
)
|
|
|
|
const timeFormat = "2006-01-02T15:04:05.000000Z07:00"
|
|
|
|
type CreateUserRequest struct {
|
|
Username string `json:"username" binding:"required,min=3,max=32"`
|
|
DisplayName string `json:"display_name" binding:"required,min=1,max=100"`
|
|
Password string `json:"password" binding:"required,min=12,max=512"`
|
|
}
|
|
|
|
type UserResponse struct {
|
|
ID string `json:"id"`
|
|
Username string `json:"username"`
|
|
DisplayName string `json:"display_name"`
|
|
CreatedAt string `json:"created_at"`
|
|
}
|
|
|
|
func UserFromDomain(u *domain.User) UserResponse {
|
|
return UserResponse{
|
|
ID: u.ID,
|
|
Username: u.Username,
|
|
DisplayName: u.DisplayName,
|
|
CreatedAt: u.CreatedAt.UTC().Format(timeFormat),
|
|
}
|
|
}
|