package com.ecep.contract.util;

import java.time.LocalDate;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

public class ParamUtils {
    public static Map<String, Object> between(LocalDate begin, LocalDate end) {
        Map<String, Object> params = new HashMap<>();
        params.put("begin", begin);
        params.put("end", end);
        return params;
    }

    public static Map<String, Object> equal(String key, boolean value) {
        Map<String, Object> params = new HashMap<>();
        params.put(key, value);
        return params;
    }

    public static Map<String, Object> equal(String key, String value) {
        Map<String, Object> params = new HashMap<>();
        params.put(key, value);
        return params;
    }

    public static Map<String, Object> like(String key, String value) {
        Map<String, Object> params = new HashMap<>();
        params.put(key, "%" + value + "%");
        return params;
    }

    public static Map<String, Object> like(String key, LocalDate value) {
        Map<String, Object> params = new HashMap<>();
        params.put(key, "%" + value + "%");
        return params;
    }

    public static Map<String, Object> isNotNull(String key) {
        Map<String, Object> params = new HashMap<>();
        params.put(key, Map.of("isNotNull", true));
        return params;
    }

    public static Map<String, Object> lessThan(String key, LocalDate value) {
        Map<String, Object> params = new HashMap<>();
        params.put(key, Map.of("lessThan", value));
        return params;
    }

    public static Builder builder() {
        return new Builder();
    }

    public static class Builder {
        private Map<String, Object> params = new HashMap<>();

        private Builder() {
        }

        public Builder isNotNull(String key) {
            params.put(key, Map.of("isNotNull", true));
            return this;
        }

        public Builder lessThan(String key, LocalDate value) {
            params.put(key, Map.of("lessThan", value));
            return this;
        }

        public Builder equals(String key, Object value) {
            params.put(key, Map.of("equals", value));
            return this;
        }

        public Builder between(String key, LocalDate begin, LocalDate end) {
            params.put(key, Map.of("begin", begin, "end", end));
            return this;
        }

        public Map<String, Object> build() {
            return params;
        }

    }
}
