package request

import (
	"netidhub-saas-be/app/database/entity/article_category_details"
	"netidhub-saas-be/utils/paginator"
	"time"
)

type ArticleCategoryDetailsGeneric interface {
	ToEntity()
}

type ArticleCategoryDetailsQueryRequest struct {
	ArticleId  int                   `json:"article_id" validate:"required"`
	CategoryId int                   `json:"category_id" validate:"required"`
	IsActive   bool                  `json:"is_active" validate:"required"`
	Pagination *paginator.Pagination `json:"pagination"`
}

type ArticleCategoryDetailsCreateRequest struct {
	ArticleId  uint `json:"article_id" validate:"required"`
	CategoryId int  `json:"category_id" validate:"required"`
	IsActive   bool `json:"is_active" 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:"article_id" validate:"required"`
	CategoryId int       `json:"category_id" validate:"required"`
	IsActive   bool      `json:"is_active" validate:"required"`
	CreatedAt  time.Time `json:"created_at"`
	UpdatedAt  time.Time `json:"updated_at"`
}

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,
	}
}
