package request

import (
	"campaign-pool-be/app/database/entity/article_category_details"
	"campaign-pool-be/utils/paginator"
	"time"
)

type ArticleCategoryDetailsGeneric interface {
	ToEntity()
}

type ArticleCategoryDetailsQueryRequest struct {
	ArticleId  int                   `json:"articleId" validate:"required"`
	CategoryId int                   `json:"categoryId" validate:"required"`
	IsActive   bool                  `json:"isActive" validate:"required"`
	Pagination *paginator.Pagination `json:"pagination"`
}

type ArticleCategoryDetailsCreateRequest struct {
	ArticleId  uint `json:"articleId" validate:"required"`
	CategoryId int  `json:"categoryId" validate:"required"`
	IsActive   bool `json:"isActive" validate:"required"`
}

func (req ArticleCategoryDetailsCreateRequest) ToEntity() *article_category_details.ArticleCategoryDetails {
	return &article_category_details.ArticleCategoryDetails{
		ArticleId:  req.ArticleId,
		CategoryId: req.CategoryId,
		IsActive:   req.IsActive,
	}
}

type ArticleCategoryDetailsUpdateRequest struct {
	ID         uint      `json:"id" validate:"required"`
	ArticleId  uint      `json:"articleId" validate:"required"`
	CategoryId int       `json:"categoryId" validate:"required"`
	IsActive   bool      `json:"isActive" validate:"required"`
	CreatedAt  time.Time `json:"createdAt"`
	UpdatedAt  time.Time `json:"updatedAt"`
}

func (req ArticleCategoryDetailsUpdateRequest) ToEntity() *article_category_details.ArticleCategoryDetails {
	return &article_category_details.ArticleCategoryDetails{
		ID:         req.ID,
		ArticleId:  req.ArticleId,
		CategoryId: req.CategoryId,
		IsActive:   req.IsActive,
		CreatedAt:  req.CreatedAt,
		UpdatedAt:  req.UpdatedAt,
	}
}
