package request

import (
	"jaecoo-be/app/database/entity"
	"jaecoo-be/utils/paginator"
)

type ApprovalHistoriesQueryRequest struct {
	paginator.Pagination
	ModuleType *string `json:"module_type" query:"module_type"`
	ModuleId   *uint   `json:"module_id" query:"module_id"`
	StatusId   *int    `json:"status_id" query:"status_id"`
	Action     *string `json:"action" query:"action"`
	ApprovedBy *uint   `json:"approved_by" query:"approved_by"`
}

type ApprovalHistoriesCreateRequest struct {
	ModuleType string  `json:"module_type" validate:"required"`
	ModuleId   uint    `json:"module_id" validate:"required"`
	StatusId   int     `json:"status_id" validate:"required"`
	Action     string  `json:"action" validate:"required"`
	ApprovedBy *uint   `json:"approved_by"`
	Message    *string `json:"message"`
}

func (req *ApprovalHistoriesCreateRequest) ToEntity() *entity.ApprovalHistories {
	return &entity.ApprovalHistories{
		ModuleType: req.ModuleType,
		ModuleId:   req.ModuleId,
		StatusId:   req.StatusId,
		Action:     req.Action,
		ApprovedBy: req.ApprovedBy,
		Message:    req.Message,
	}
}
