package seriessetmaster import ( "time" "cardverse/internal/pkg/utils" ) type ListSeriesQuery struct { Search string `form:"search"` } type ListSetQuery struct { Search string `form:"search"` ParentID uint `form:"parent_id"` } type CreateSeriesRequest struct { Name string `json:"name" binding:"required,min=2,max=150"` Image string `json:"image" binding:"omitempty,max=255"` } type CreateSetRequest struct { ParentID uint `json:"parent_id" binding:"required"` SetCode string `json:"set_code" binding:"required,max=50"` SetName string `json:"set_name" binding:"required,max=150"` Image string `json:"image" binding:"omitempty,max=255"` Logo string `json:"logo" binding:"omitempty,max=255"` ReleaseDate *time.Time `json:"release_date" binding:"omitempty"` } type UpdateSeriesRequest struct { Name string `json:"name" binding:"omitempty,min=2,max=150"` Image string `json:"image" binding:"omitempty,max=255"` } type UpdateSetRequest struct { ParentID *uint `json:"parent_id" binding:"omitempty"` SetCode string `json:"set_code" binding:"omitempty,max=50"` SetName string `json:"set_name" binding:"omitempty,max=150"` Image string `json:"image" binding:"omitempty,max=255"` Logo string `json:"logo" binding:"omitempty,max=255"` ReleaseDate *time.Time `json:"release_date" binding:"omitempty"` } type SeriesSetMasterResponse struct { ID uint `json:"id"` ParentID *uint `json:"parent_id,omitempty"` SetCode string `json:"set_code,omitempty"` SetName string `json:"set_name,omitempty"` SeriesName string `json:"series_name"` Image string `json:"image,omitempty"` Logo string `json:"logo,omitempty"` ReleaseDate *time.Time `json:"release_date,omitempty"` TotalCards int `json:"total_cards"` ExpansionCount int `json:"expansion_count"` CardCount int `json:"card_count"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` CreatedBy *uint `json:"created_by,omitempty"` UpdatedBy *uint `json:"updated_by,omitempty"` Children []SeriesSetMasterResponse `json:"children,omitempty"` } func ToSeriesSetMasterResponse(m SeriesSetMaster) SeriesSetMasterResponse { var children []SeriesSetMasterResponse if len(m.Children) > 0 { children = ToSeriesSetMasterResponseList(m.Children) } return SeriesSetMasterResponse{ ID: m.ID, ParentID: m.ParentID, SetCode: m.SetCode, SetName: m.SetName, SeriesName: m.SeriesName, Image: utils.FormatMediaURL(m.Image), Logo: utils.FormatMediaURL(m.Logo), ReleaseDate: m.ReleaseDate, TotalCards: m.TotalCards, ExpansionCount: m.ExpansionCount, CardCount: m.CardCount, CreatedAt: m.CreatedAt, UpdatedAt: m.UpdatedAt, CreatedBy: m.CreatedBy, UpdatedBy: m.UpdatedBy, Children: children, } } func ToSeriesSetMasterResponseList(list []SeriesSetMaster) []SeriesSetMasterResponse { res := make([]SeriesSetMasterResponse, len(list)) for i, m := range list { res[i] = ToSeriesSetMasterResponse(m) } return res }