package request

import (
	"narasi-ahli-be/app/database/entity"
	"narasi-ahli-be/utils/paginator"
	"time"
)

type UserRoleLevelDetailsGeneric interface {
	ToEntity()
}

type UserRoleLevelDetailsQueryRequest struct {
	UserRoleId  uint                  `json:"userRoleId" validate:"required"`
	UserLevelId uint                  `json:"userLevelId" validate:"required"`
	Pagination  *paginator.Pagination `json:"pagination"`
}

type UserRoleLevelDetailsCreateRequest struct {
	UserRoleId  uint  `json:"userRoleId" validate:"required"`
	UserLevelId uint  `json:"userLevelId" validate:"required"`
	IsActive    *bool `json:"isActive" validate:"required"`
}

func (req UserRoleLevelDetailsCreateRequest) ToEntity() *entity.UserRoleLevelDetails {
	return &entity.UserRoleLevelDetails{
		UserRoleId:  req.UserRoleId,
		UserLevelId: req.UserLevelId,
		IsActive:    req.IsActive,
	}
}

type UserRoleLevelDetailsUpdateRequest struct {
	ID          uint      `json:"id" validate:"required"`
	UserRoleId  uint      `json:"userRoleId" validate:"required"`
	UserLevelId uint      `json:"userLevelId" validate:"required"`
	IsActive    *bool     `json:"isActive" validate:"required"`
	CreatedAt   time.Time `json:"createdAt"`
	UpdatedAt   time.Time `json:"updatedAt"`
}

func (req UserRoleLevelDetailsUpdateRequest) ToEntity() *entity.UserRoleLevelDetails {
	return &entity.UserRoleLevelDetails{
		ID:          req.ID,
		UserRoleId:  req.UserRoleId,
		UserLevelId: req.UserLevelId,
		IsActive:    req.IsActive,
		CreatedAt:   req.CreatedAt,
		UpdatedAt:   req.UpdatedAt,
	}
}
