139 lines
4.6 KiB
Go
139 lines
4.6 KiB
Go
package dto
|
|
|
|
import (
|
|
"base/pkg/validation"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type CreateAssetRequest struct {
|
|
ProfileID string `json:"profile_id"`
|
|
AssetCategoryID string `json:"asset_category_id"`
|
|
Title string `json:"title"`
|
|
Description string `json:"description"`
|
|
Link string `json:"link"`
|
|
}
|
|
|
|
func (*CreateAssetRequest) Schema() validation.Schema {
|
|
return validation.Schema{
|
|
"profile_id": validation.Rule{Field: "profile_id", Type: validation.ValidationTypeString, Required: true},
|
|
"asset_category_id": validation.Rule{Field: "asset_category_id", Type: validation.ValidationTypeString, Required: true},
|
|
"title": validation.Rule{Field: "title", Type: validation.ValidationTypeString, Required: true},
|
|
}
|
|
}
|
|
|
|
type UpdateAssetRequest struct {
|
|
ID string `uri:"id"`
|
|
AssetCategoryID string `json:"asset_category_id"`
|
|
Title string `json:"title"`
|
|
Description string `json:"description"`
|
|
Link string `json:"link"`
|
|
Status *int `json:"status"`
|
|
}
|
|
|
|
func (*UpdateAssetRequest) Schema() validation.Schema {
|
|
return validation.Schema{
|
|
"id": validation.Rule{Field: "id", Type: validation.ValidationTypeString, Required: true},
|
|
}
|
|
}
|
|
|
|
type GetAssetRequest struct {
|
|
ID string `uri:"id"`
|
|
}
|
|
|
|
func (*GetAssetRequest) Schema() validation.Schema {
|
|
return validation.Schema{
|
|
"id": validation.Rule{Field: "id", Type: validation.ValidationTypeString, Required: true},
|
|
}
|
|
}
|
|
|
|
type ListAssetsByProfileRequest struct {
|
|
ProfileID string `uri:"id"`
|
|
}
|
|
|
|
func (*ListAssetsByProfileRequest) Schema() validation.Schema {
|
|
return validation.Schema{
|
|
"ProfileID": validation.Rule{Field: "profile_id", Type: validation.ValidationTypeString, Required: true},
|
|
}
|
|
}
|
|
|
|
type DeleteAssetRequest struct {
|
|
ID string `uri:"id"`
|
|
}
|
|
|
|
func (*DeleteAssetRequest) Schema() validation.Schema {
|
|
return validation.Schema{
|
|
"id": validation.Rule{Field: "id", Type: validation.ValidationTypeString, Required: true},
|
|
}
|
|
}
|
|
|
|
type AssetResponse struct {
|
|
ID uuid.UUID `json:"id"`
|
|
ProfileID uuid.UUID `json:"profile_id"`
|
|
OwnerID *uuid.UUID `json:"owner_id,omitempty"`
|
|
AssetCategoryID uuid.UUID `json:"asset_category_id"`
|
|
Title string `json:"title"`
|
|
Description string `json:"description"`
|
|
Link string `json:"link"`
|
|
CoverImage string `json:"cover_image,omitempty"`
|
|
Status int `json:"status"`
|
|
Category CategoryDTO `json:"category"`
|
|
CreatedAt string `json:"created_at"`
|
|
UpdatedAt string `json:"updated_at"`
|
|
}
|
|
|
|
type CategoryDTO struct {
|
|
ID uuid.UUID `json:"id"`
|
|
Name string `json:"name"`
|
|
Icon string `json:"icon"`
|
|
Color string `json:"color"`
|
|
CardType string `json:"card_type"`
|
|
Featured bool `json:"featured"`
|
|
Description string `json:"description"`
|
|
}
|
|
|
|
type ListAssetsResponse struct {
|
|
Assets []AssetResponse `json:"assets"`
|
|
}
|
|
|
|
// ListAssetsByCategoryIDResponse is paginated assets for a single category (Phase 2 of two-phase loading).
|
|
type ListAssetsByCategoryIDResponse struct {
|
|
Category CategoryDTO `json:"category"`
|
|
Assets []AssetResponse `json:"assets"`
|
|
Total int `json:"total"`
|
|
Page int `json:"page"`
|
|
PageSize int `json:"page_size"`
|
|
TotalPages int `json:"total_pages"`
|
|
}
|
|
|
|
type ListCategoriesResponse struct {
|
|
Categories []CategoryDTO `json:"categories"`
|
|
}
|
|
|
|
// CategoriesPreviewRequest holds the request body for POST /assets/categories/preview.
|
|
type CategoriesPreviewRequest struct {
|
|
CategoryIDs []string `json:"category_ids"`
|
|
AssetsPerCategory int `json:"assets_per_category"`
|
|
FeaturedOnly bool `json:"featured_only"`
|
|
}
|
|
|
|
func (*CategoriesPreviewRequest) Schema() validation.Schema {
|
|
return validation.Schema{
|
|
"category_ids": validation.Rule{Field: "category_ids", Type: validation.ValidationTypeArray, Required: false},
|
|
"assets_per_category": validation.Rule{Field: "assets_per_category", Type: validation.ValidationTypeInt, Required: false},
|
|
"featured_only": validation.Rule{Field: "featured_only", Type: validation.ValidationTypeBool, Required: false},
|
|
}
|
|
}
|
|
|
|
// CategoryWithPreviewAssetsDTO groups a category with up to N sample assets.
|
|
type CategoryWithPreviewAssetsDTO struct {
|
|
Category CategoryDTO `json:"category"`
|
|
Assets []AssetResponse `json:"assets"`
|
|
TotalAssets int `json:"total_assets,omitempty"`
|
|
HasMore bool `json:"has_more,omitempty"`
|
|
}
|
|
|
|
// CategoriesPreviewResponse is the response for POST /assets/categories/preview.
|
|
type CategoriesPreviewResponse struct {
|
|
Categories []CategoryWithPreviewAssetsDTO `json:"categories"`
|
|
}
|