Files
fm_be/internal/transport/http/dto/facility_dto.go
2026-07-16 22:16:45 +07:00

100 lines
4.0 KiB
Go

package dto
// JSON:API Facility DTOs
type FacilityAttributes struct {
Category string `json:"category" example:"heslo-rope-label"`
Name string `json:"name" example:"Fuel Truck Rope Label"`
Type string `json:"type" example:"Sling"`
SortKey *int `json:"sortkey" example:"1"`
Length string `json:"length,omitempty" example:"10m"`
Weight string `json:"weight,omitempty" example:"10kg"`
Electric string `json:"electric" example:"available"`
Note string `json:"note,omitempty" example:"Dry lease fuel truck"`
IsActive bool `json:"is_active" example:"true"`
CreatedBy string `json:"created_by,omitempty" example:"018f3a5c-7a6f-7c2a-8d4a-4b5b1f6c8e9d"`
UpdatedBy string `json:"updated_by,omitempty" example:"018f3a5c-7a6f-7c2a-8d4a-4b5b1f6c8e9d"`
CreatedAt string `json:"created_at,omitempty" example:"2026-03-12T03:04:05Z"`
UpdatedAt string `json:"updated_at,omitempty" example:"2026-03-12T03:04:05Z"`
}
type FacilityResource struct {
Type string `json:"type" example:"facility"`
ID string `json:"id" example:"018f3a5c-7a6f-7c2a-8d4a-4b5b1f6c8e9d"`
Attributes FacilityAttributes `json:"attributes"`
}
type FacilityResponse struct {
Data FacilityResource `json:"data"`
}
type FacilityDeleteResponse struct {
Data struct {
Type string `json:"type" example:"facility_delete"`
Attributes struct {
Deleted bool `json:"deleted" example:"true"`
} `json:"attributes"`
} `json:"data"`
}
type FacilityListResponse struct {
Data []FacilityResource `json:"data"`
Meta struct {
PageNumber int `json:"page_number" example:"1"`
PageSize int `json:"page_size" example:"20"`
Total int64 `json:"total" example:"120"`
} `json:"meta"`
}
type FacilityDataTableResponse struct {
Data []FacilityResource `json:"data"`
Meta struct {
Draw int `json:"draw" example:"1"`
RecordsTotal int64 `json:"records_total" example:"120"`
RecordsFiltered int64 `json:"records_filtered" example:"12"`
} `json:"meta"`
}
type FacilityCreateAttributes struct {
Category string `json:"category" validate:"required" example:"heslo-rope-label"`
Name string `json:"name" validate:"required" example:"Fuel Truck Rope Label"`
Type string `json:"type" example:"Sling"`
SortKey *int `json:"sortkey" example:"1"`
Length *string `json:"length,omitempty" example:"10m"`
Weight *string `json:"weight,omitempty" example:"10kg"`
Electric *string `json:"electric,omitempty" example:"available"`
Note *string `json:"note,omitempty" example:"Dry lease fuel truck"`
IsActive *bool `json:"is_active,omitempty" example:"true"`
}
type FacilityCreateData struct {
Type string `json:"type" validate:"required,oneof=facility_create facility" example:"facility_create"`
Attributes FacilityCreateAttributes `json:"attributes" validate:"required"`
}
type FacilityCreateRequest struct {
Data FacilityCreateData `json:"data" validate:"required"`
}
type FacilityUpdateAttributes struct {
Category *string `json:"category,omitempty" example:"heslo-rope-label"`
Name *string `json:"name,omitempty" example:"Fuel Truck Rope Label"`
Type *string `json:"type,omitempty" example:"Sling"`
SortKey NullInt `json:"sortkey,omitempty" swaggertype:"integer" example:"1"`
Length *string `json:"length,omitempty" example:"10m"`
Weight *string `json:"weight,omitempty" example:"10kg"`
Electric *string `json:"electric,omitempty" example:"available"`
Note *string `json:"note,omitempty" example:"Dry lease fuel truck"`
IsActive *bool `json:"is_active,omitempty" example:"true"`
}
type FacilityUpdateData struct {
Type string `json:"type" validate:"required,oneof=facility_update facility" example:"facility_update"`
ID string `json:"id" example:"018f3a5c-7a6f-7c2a-8d4a-4b5b1f6c8e9d"`
Attributes FacilityUpdateAttributes `json:"attributes" validate:"required"`
}
type FacilityUpdateRequest struct {
Data FacilityUpdateData `json:"data" validate:"required"`
}