package com.siwei.spatial.api;

import com.siwei.common.core.constant.SecurityConstants;
import com.siwei.common.core.constant.ServiceNameConstants;
import com.siwei.common.core.domain.R;
import com.siwei.spatial.api.domain.file.TGeomDb;
import com.siwei.spatial.api.domain.file.TGeomDbDetails;
import com.siwei.spatial.api.factory.RemoteSpatialFilesDbFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@FeignClient(contextId = "remoteSpatialFilesDbService", value = ServiceNameConstants.SPATIAL_SERVICE, fallbackFactory = RemoteSpatialFilesDbFallbackFactory.class)
public interface RemoteSpatialFilesDbService {
    @PostMapping("/files/db/read/shp")
    public R<TGeomDb> readShp(@RequestParam("shpFileName") String shpFileName, @RequestParam("shpFilePath") String shpFilePath, @RequestParam("fromRoute") String fromRoute, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @PostMapping("/files/db/read/wkt")
    public R<TGeomDb> readWkt(@RequestParam("shpFileName") String shpFileName, @RequestParam("wkt") String wkt, @RequestParam("fromRoute") String fromRoute, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @PostMapping("/files/db/read/geom")
    public R<TGeomDb> readWkt(@RequestParam("shpFileName") String shpFileName, @RequestParam("geom") String geom, @RequestParam("fromRoute") String fromRoute, String fromType, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/files/db/query/geom")
    public R<TGeomDb> queryGeom(@RequestParam("id") String id, @RequestParam("isDetail") Integer isDetail, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/files/db/query/geom/details")
    public R<List<TGeomDbDetails>> queryGeomDetails(@RequestParam("id") String id, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/files/db/query/geom/details/page")
    public R<List<TGeomDbDetails>> queryGeomDetailsPage(@RequestParam("id") String id, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
}
