package cn.ey.biz.module.system.api.codeblock;

import cn.ey.biz.common.pojo.R;
import cn.ey.biz.module.system.api.codeblock.dto.*;
import cn.ey.biz.module.system.enums.ApiConstants;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import javax.validation.constraints.NotBlank;
import java.util.Collection;
import java.util.List;

@FeignClient(name = ApiConstants.NAME)
@Api(tags = "RPC 服务 - 编码表查询")
public interface CodeBlockApi {

    String PREFIX = ApiConstants.PREFIX + "/code/block";

    @PostMapping(PREFIX + "/list")
    @ApiOperation("编码表查询")
    R<CodeBlockWideTableDTO> getCodeBlockList(@RequestBody CodeBlockWideTableReqDTO blockWideTableReqDTO);


    @PostMapping(PREFIX + "/legal/entity/list")
    @ApiOperation("法律实体过滤列表")
    R<CodeBlockWideTableDTO> filterList(@Validated @RequestBody CodeBlockWideTableReqDTO reqDTO);


    @PostMapping(PREFIX + "/get/codeblock/gpn")
    @ApiOperation("获取用户npn codeblock")
    R<List<CodeBlockUserGpnDTO>> getCodeblockGpn(@RequestParam("app") String app);


    @PostMapping(PREFIX + "/legal/entity/effective")
    @ApiOperation("获取合法有效的code block")
    R<CodeBlockLegalRespDTO> getLegalEffective(@Validated @RequestBody CodeBlockReqDTO reqDTO);

    @GetMapping(PREFIX + "/get/codeblock/info")
    @ApiOperation("获取code block")
    R<CodeBlockInfoRespDTO> getCodeBlockInfo(@NotBlank(message = "codeBlock不能为空") @RequestParam("codeBlock") String codeBlock);

    @GetMapping(PREFIX + "/get/codeblock/infos")
    @ApiOperation("批量获取获取code block详情。")
    R<List<CodeBlockInfoRespDTO>> getCodeBlockInfos(@RequestBody Collection<String> codeBlocks);



    @GetMapping(PREFIX + "/get/treeCodeList")
    @ApiOperation("业务线树形")
    R<List<CodeBlockTreeValueDTO>> treeCodeList();


    @GetMapping(PREFIX + "/get/treeCityCodeList")
    @ApiOperation("地区树形结构")
    R<List<CodeBlockTreeValueDTO>> treeCityCodeList();

    @PostMapping(PREFIX + "/get/gpn/codeblock")
    @ApiOperation("根据gpn获取信息")
    R<List<CodeBlockGpnRespDTO>> getGpnCodeblock(@RequestParam("app") String app, @RequestParam("gpn") String gpn);

    @PostMapping(PREFIX + "/get/gpn/codeblock/config-type")
    @ApiOperation("根据gpn获取信息")
    R<List<CodeBlockGpnRespDTO>> getGpnCodeblock(@RequestParam("app") String app, @RequestParam("gpn") String gpn, @RequestParam(required = false, name="configType") String configType);

    @PostMapping(PREFIX + "/get/gpn-list/codeblock/config-type")
    @ApiOperation("根据codeblock获取gpn")
    R<List<String>> getGpnListByCodeblock(@RequestParam("app") String app, @RequestParam("codeBlock") String codeBlock, @RequestParam(required = false, name="configType") String configType);

}
