Files
main-tbbank/backend/internal/admin/mini_slider/dto.go

65 lines
1.3 KiB
Go

package mini_slider
import (
"database/sql/driver"
"encoding/json"
"fmt"
"time"
)
type DataMiniSliderDTO struct {
MiniSliders []MiniSliderListItemDTO `json:"miniSliders"`
Count int `json:"count"`
}
type Language struct {
Tm string `json:"tm"`
Ru string `json:"ru"`
En string `json:"en"`
}
func (l Language) Value() (driver.Value, error) {
return json.Marshal(l)
}
func (l *Language) Scan(src interface{}) error {
if src == nil {
*l = Language{}
return nil
}
var b []byte
switch v := src.(type) {
case []byte:
b = v
case string:
b = []byte(v)
default:
return fmt.Errorf("unsupported language type %T", src)
}
return json.Unmarshal(b, l)
}
type MiniSliderListItemDTO struct {
Id int `json:"Id"`
Title Language `json:"title"`
Image string `json:"imagePath"`
CreatedAt time.Time `json:"createdAt"`
}
type GetMiniSliderDTO struct {
Id int `json:"Id"`
Title Language `json:"title"`
Image string `json:"imagePath"`
CreatedAt time.Time `json:"createdAt"`
}
type AddMiniSliderDTO struct {
Title Language `json:"title" binding:"required"`
Image string `json:"imagePath"`
}
type UpdateMiniSliderDTO struct {
Title Language `json:"title" binding:"required"`
Image string `json:"imagePath"`
}