dto

package
v0.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 1, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAvatarFromMultipartForm

func GetAvatarFromMultipartForm(r *http.Request) (*models.File, error)

func GetRequestBody

func GetRequestBody[T any](r *http.Request) (*T, error)

func GetScanFromMultipartForm

func GetScanFromMultipartForm(r *http.Request) (*models.File, error)

Types

type AdminUserDetailResponse added in v0.0.5

type AdminUserDetailResponse struct {
	AdminUserResponse
	Predictions []PredictionResponse `json:"predictions"`
	Limit       int                  `json:"limit"`
	Offset      int                  `json:"offset"`
}

func NewAdminUserDetailResponse added in v0.0.5

func NewAdminUserDetailResponse(
	user models.User, predictions []*models.Prediction, limit, offset int,
) AdminUserDetailResponse

type AdminUserListResponse added in v0.0.5

type AdminUserListResponse struct {
	TotalCount int64               `json:"total_count"`
	Limit      int                 `json:"limit"`
	Offset     int                 `json:"offset"`
	Users      []AdminUserResponse `json:"users"`
}

func NewAdminUserListResponse added in v0.0.5

func NewAdminUserListResponse(users []models.User, totalCount int64, limit, offset int) AdminUserListResponse

type AdminUserParams added in v0.0.5

type AdminUserParams struct {
	Limit  int `query:"limit" validate:"min=1,max=100"`
	Offset int `query:"offset" validate:"min=0"`
}

type AdminUserResponse added in v0.0.5

type AdminUserResponse struct {
	ID        uuid.UUID   `json:"id"`
	Login     string      `json:"login"`
	Name      string      `json:"name"`
	Role      models.Role `json:"role"`
	Avatar    *string     `json:"avatar,omitempty"`
	Deleted   bool        `json:"deleted"`
	CreatedAt time.Time   `json:"created_at"`
	UpdatedAt time.Time   `json:"updated_at"`

	LastLoginAt *time.Time    `json:"last_login_at,omitempty"`
	Stat        *StatResponse `json:"stat,omitempty"`
}

func NewAdminUserResponse added in v0.0.5

func NewAdminUserResponse(user models.User) AdminUserResponse

type AuthRequest

type AuthRequest struct {
	Login    string `json:"login"`
	Password string `json:"password"`
}

type AuthResponse

type AuthResponse struct {
	User struct {
		ID    string `json:"id"`
		Login string `json:"login"`
	} `json:"user"`
}

func NewAuthResponse

func NewAuthResponse(user models.User, access, refresh string) AuthResponse

type ChangePasswordRequest

type ChangePasswordRequest struct {
	OldPassword string `json:"old_password" validate:"required,min=8,max=64"`
	NewPassword string `json:"new_password" validate:"required,min=8,max=64,nefield=OldPassword"`
}

type CreateAdminRequest added in v0.0.5

type CreateAdminRequest struct {
	Name     string      `json:"name" validate:"required,min=2,max=100"`
	Login    string      `json:"login" validate:"required,alphanum,min=3,max=50"`
	Password string      `json:"password" validate:"required,min=8"`
	Role     models.Role `json:"role" validate:"required"`
}

func (*CreateAdminRequest) ToModel added in v0.0.5

func (req *CreateAdminRequest) ToModel() *models.User

type HTTPResource

type HTTPResource interface {
	LoginUserRequest | ChangePasswordRequest | UpdateUserRequest
}

type LoginUserRequest

type LoginUserRequest struct {
	Login    string `json:"login" validate:"required,min=3,max=32,alphanum"`
	Password string `json:"password" validate:"required,min=8,max=64"`
	Name     string `json:"name,omitempty" validate:"omitempty,min=3,max=64,alphanum"`
}

func (*LoginUserRequest) ToModel

func (r *LoginUserRequest) ToModel() models.User

type PredictionResponse

type PredictionResponse models.Prediction

type StatResponse added in v0.0.5

type StatResponse models.Stat

type UpdateUserRequest added in v0.0.3

type UpdateUserRequest struct {
	Name string `json:"name" validate:"required,min=3,max=64,alphanum"`
}

type UploadAvatarRequest

type UploadAvatarRequest struct {
	Avatar string `json:"avatar" swaggertype:"string" format:"binary" example:"avatar.jpg" validate:"required"`
}

type UploadAvatarResponse

type UploadAvatarResponse struct {
	AvatarURL string `json:"avatar_url" example:"http://localhost:9000/trashscanner-images/user-id/avatars/avatar.jpg"`
}

type UserResponse

type UserResponse models.User

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL