package net.northking.cctp.testbug.feign.client;

import io.swagger.annotations.ApiOperation;
import net.northking.cctp.common.db.DefaultPagination;
import net.northking.cctp.common.feign.FeignCctpConfig;
import net.northking.cctp.common.http.QueryByPage;
import net.northking.cctp.common.http.ResultWrapper;
import net.northking.cctp.testbug.dto.platform.CpNotice;
import net.northking.cctp.testbug.dto.platform.CpTemplatePropertiesDetailDto;
import net.northking.cctp.testbug.dto.platform.UserQueryDto;
import net.northking.cctp.testbug.pub.bug.dto.CpAttachAddDto;
import net.northking.cctp.testbug.pub.bug.dto.PubDto;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author: puchao.ma
 * @date: 2021/11/10 10:36
 */
@FeignClient(name = "cctp-platform", path = "/cctp-platform", configuration = {FeignCctpConfig.class})
public interface PlatFormFeignClient {

    /**
     * 根据字典编码查询字典详情
     *
     * @param catalogCodeList
     * @return
     */
    @PostMapping("/v1/query/dict-catalog-item")
    ResultWrapper<Map<String, Object>> query(@RequestBody List<String> catalogCodeList);

    @ApiOperation(value = "根据用户姓名模糊查询用户id")
    @PostMapping(value = "/v1/query/selectUserId",
            produces = MediaType.APPLICATION_JSON_UTF8_VALUE,
            consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public List<String> findUserIdByName(@RequestBody UserQueryDto query);

    @ApiOperation(value = "获取：模板系统属性表")
    @PostMapping(
            value = "/v1/CpTemplatePropertiess/getSysProperties/{templateType}",
            produces = MediaType.APPLICATION_JSON_UTF8_VALUE,
            consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public ResultWrapper<List<CpTemplatePropertiesDetailDto>> getSysProperties(
            @PathVariable("templateType") Integer templateType);

    @ApiOperation(value = "发送待办")
    @PostMapping(
            value = "/v1/sendNoticeMQ",
            produces = MediaType.APPLICATION_JSON_UTF8_VALUE,
            consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public ResultWrapper<String> sendNoticeMQ(
            @RequestBody List<CpNotice> cpNotice);

    @ApiOperation(value = "附件：批量查询附件数量")
    @PostMapping(value = "/v1/batch/query/count",
            produces = MediaType.APPLICATION_JSON_UTF8_VALUE,
            consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public ResultWrapper<Map<String, Integer>> batchQueryCount(@RequestBody List<String> resourceIds);

    @ApiOperation(value = "分页查询用户的常用信息")
    @PostMapping(value = "/v1/pagine/query/common",
            produces = MediaType.APPLICATION_JSON_UTF8_VALUE,
            consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public ResultWrapper<DefaultPagination<UserInfoDto>> queryUserInfo(@RequestBody QueryByPage<UserQueryDto> query);

    /**
     * Restful接口-post： 新增附件信息表
     *
     * @param inputDto 接口数据传输对象
     * @return 主键
     */
    @ApiOperation(value = "新增：附件信息")
    @PostMapping(
            value = "/pub/attach/add",
            produces = MediaType.APPLICATION_JSON_UTF8_VALUE,
            consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public ResultWrapper<Integer> add(@RequestBody @Validated CpAttachAddDto inputDto);


    /**
     * 外部查询：查询获取字典条目
     *
     * @param pubDto 字典code集合
     * @return 数据列表
     */
    @ApiOperation(value = "获取字典条目")
    @PostMapping(value = "/pub/query/dict-catalog-item",
            produces = MediaType.APPLICATION_JSON_UTF8_VALUE,
            consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public ResultWrapper<Map<String, Object>> getPubDictByCode(@RequestBody PubDto pubDto);

    @ApiOperation(value = "获取用户姓名")
    @PostMapping(value = "/pub/getName/")
    public String getUser(@RequestParam("operCode") String operCode);
}
