package com.devjob.job.dto;

import com.devjob.job.domain.Job;
import com.devjob.job.domain.JobStatus;
import com.devjob.job.repository.JobSpecification;
import java.time.LocalDate;
import org.springframework.data.jpa.domain.Specification;

public record JobSearchRequest(
        String keyword,
        String location,
        JobStatus status,
        Integer minSalary,
        Integer maxSalary,
        LocalDate deadlineBefore
) {
    public Specification<Job> toSpecification() {
        return Specification.where(JobSpecification.withKeyword(keyword))
                .and(JobSpecification.withLocation(location))
                .and(JobSpecification.withStatus(status))
                .and(JobSpecification.withSalaryGoe(minSalary))
                .and(JobSpecification.withSalaryLoe(maxSalary))
                .and(JobSpecification.withDeadlineBefore(deadlineBefore));
    }
}
