package incheon.product.common.config;

import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * GeoView 제품 공통 설정.
 * 기존 하드코딩 값들을 application.yml에서 관리하도록 외부화한다.
 *
 * <pre>
 * geoview:
 *   gis-server:
 *     url: ${gis.server.url}
 *     workspace: incheon
 *     storage: iccom
 *     sync-wait-millis: 3000
 *     fallback-bbox:
 *       minx: 746110.2599834986
 *       miny: 1881540.2538266997
 *       maxx: 937637.2836452124
 *       maxy: 2001987.241769713
 *   coordinate:
 *     default-srid: 5181
 *     service-srid: 3857
 *   layer:
 *     service-prefix: incheon
 *     image-max-size: 4000
 *     image-default-size: 1920
 *     batch-chunk-size: 1000
 *   download:
 *     excel-max-rows: 100000
 *     streaming-fetch-size: 10000
 *     cleanup-delay-millis: 10000
 * </pre>
 */
@Component
@ConfigurationProperties(prefix = "geoview")
@Getter @Setter
public class GeoViewProperties {

    private GisServer gisServer = new GisServer();
    private Coordinate coordinate = new Coordinate();
    private Layer layer = new Layer();
    private Download download = new Download();

    @Getter @Setter
    public static class GisServer {
        private String url;
        private String workspace = "incheon";
        private String storage = "iccom";
        private long syncWaitMillis = 3000L;
        private BoundingBox fallbackBbox = new BoundingBox();
    }

    @Getter @Setter
    public static class BoundingBox {
        private double minx = 746110.2599834986;
        private double miny = 1881540.2538266997;
        private double maxx = 937637.2836452124;
        private double maxy = 2001987.241769713;
    }

    @Getter @Setter
    public static class Coordinate {
        private int defaultSrid = 5181;
        private int serviceSrid = 3857;
    }

    @Getter @Setter
    public static class Layer {
        private String servicePrefix = "incheon";
        private int imageMaxSize = 4000;
        private int imageDefaultSize = 1920;
        private int batchChunkSize = 1000;
    }

    @Getter @Setter
    public static class Download {
        private int excelMaxRows = 100000;
        private int streamingFetchSize = 10000;
        private long cleanupDelayMillis = 10_000L;
    }
}
