package request

import (
	"go-humas-be/app/database/entity"
	"go-humas-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  int  `json:"article_id" validate:"required"`
	CategoryId int  `json:"category_id" validate:"required"`
	IsActive   bool `json:"is_active" validate:"required"`
}

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

type ArticleCategoryDetailsUpdateRequest struct {
	ID         uint      `json:"id" validate:"required"`
	ArticleId  int       `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() *entity.ArticleCategoryDetails {
	return &entity.ArticleCategoryDetails{
		ID:         req.ID,
		ArticleId:  req.ArticleId,
		CategoryId: req.CategoryId,
		IsActive:   req.IsActive,
		CreatedAt:  req.CreatedAt,
		UpdatedAt:  req.UpdatedAt,
	}
}
