package schema

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

// Defining the `Activity` struct.
type HouseArticle struct {
	util.BaseModel
	HouseID uint   `json:"houseId" gorm:"index;comment:房源id"`
	Title   string `json:"title" gorm:"size:128;not null;index;comment:标题"`
	Cover   string `json:"cover" gorm:"size:2048;not null;comment:封面"`
	Name    string `json:"name" gorm:"size:1024;comment:作者名字"`
	PushAt  string `json:"pushAt" gorm:"index;comment:发布时间"`
	Content string `json:"content" gorm:"type:text;comment:内容详情"`
	Status  string `json:"status" gorm:"size:20;index;comment:状态"`
}

// Defining the query parameters for the `Activity` struct.
type HouseArticleQueryParam struct {
	util.PaginationParam
	LikeName  string `form:"name" `
	LikeTitle string `form:"title" `
	Status    string `form:"status" `
	AreaID    uint   `form:"areaId"`
}

// Defining the query options for the `Activity` struct.
type HouseArticleQueryOptions struct {
	util.QueryOptions
}

// Defining the query result for the `Activity` struct.
type HouseArticleQueryResult struct {
	Data       HouseArticles
	PageResult *util.PaginationResult
}

// Defining the slice of `Activity` struct.
type HouseArticles []*HouseArticle

// Defining the data structure for creating a `Activity` struct.
type HouseArticleForm struct {
	HouseID uint   `json:"houseId"`
	Title   string `json:"title"`
	Cover   string `json:"cover"`
	Name    string `json:"name"`
	PushAt  string `json:"pushAt"`
	Content string `json:"content"`
	Status  string `json:"status"`
}

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

// Convert `ActivityForm` to `Activity` object.
func (a *HouseArticleForm) FillTo(houseArticle *HouseArticle) error {
	houseArticle.Name = a.Name
	houseArticle.Title = a.Title
	houseArticle.Cover = a.Cover
	houseArticle.PushAt = a.PushAt
	houseArticle.Content = a.Content
	houseArticle.Status = a.Status
	return nil
}
