package schema

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

// Defining the `Company` struct.
type Company struct {
	util.BaseModel
	Name   string `json:"name" gorm:"size:128;not null;index"`
	Img    string `json:"img" gorm:"size:2048"`
	AreaID uint   `json:"areaId" gorm:"index;comment:城市id"`
	Status string `json:"status" gorm:"size:20;index"`
}

// Defining the query parameters for the `Company` struct.
type CompanyQueryParam struct {
	util.PaginationParam
	AreaID uint `form:"areaId"`
}

// Defining the query options for the `Company` struct.
type CompanyQueryOptions struct {
	util.QueryOptions
}

// Defining the query result for the `Company` struct.
type CompanyQueryResult struct {
	Data       Companies
	PageResult *util.PaginationResult
}

// Defining the slice of `Company` struct.
type Companies []*Company

// Defining the data structure for creating a `Company` struct.
type CompanyForm struct {
	Name   string `json:"name" `
	Img    string `json:"img" `
	AreaID uint   `json:"areaId" `

	Status string `json:"status" `
}

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

// Convert `CompanyForm` to `Company` object.
func (a *CompanyForm) FillTo(company *Company) error {
	company.Name = a.Name
	company.Img = a.Img
	company.AreaID = a.AreaID
	company.Status = a.Status
	return nil
}
