package schema

import (
	"github.guxuan/haibei/pkg/util"
)

// Defining the `ProductCategory` struct.
type ProductCategory struct {
	util.BaseModel
	ParentID  uint   `json:"parentId" gorm:"index;comment:上级分类id"`
	Name      string `json:"name" gorm:"size:255;not null;index;comment:分类名称"`
	Introduce string `json:"introduce" gorm:"size:2048;comment:分类介绍"`
	Icon      string `json:"icon" gorm:"size:2048;comment:分类icon"`
	Status    string `json:"status" gorm:"size:20;index;comment:分类状态"`
}

// Defining the query parameters for the `ProductCategory` struct.
type ProductCategoryQueryParam struct {
	util.PaginationParam
}

// Defining the query options for the `ProductCategory` struct.
type ProductCategoryQueryOptions struct {
	util.QueryOptions
	Status string `json:"status" `
}

// Defining the query result for the `ProductCategory` struct.
type ProductCategoryQueryResult struct {
	Data       ProductCategories
	PageResult *util.PaginationResult
}

// Defining the slice of `ProductCategory` struct.
type ProductCategories []*ProductCategory

// Defining the data structure for creating a `ProductCategory` struct.
type ProductCategoryForm struct {
	ParentID  uint   `json:"parentId" `
	Name      string `json:"name" `
	Introduce string `json:"introduce" `
	Icon      string `json:"icon"`
	Status    string `json:"status" `
}

// A validation function for the `ProductCategoryForm` struct.
func (a *ProductCategoryForm) Validate() error {
	return nil
}

// Convert `ProductCategoryForm` to `ProductCategory` object.
func (a *ProductCategoryForm) FillTo(productCategory *ProductCategory) error {
	productCategory.ParentID = a.ParentID
	productCategory.Name = a.Name
	productCategory.Introduce = a.Introduce
	productCategory.Icon = a.Icon
	productCategory.Status = a.Status
	return nil
}
