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

import io.swagger.annotations.ApiOperation;
import net.northking.cctp.common.feign.FeignCctpConfig;
import net.northking.cctp.common.http.ResultWrapper;
import net.northking.cctp.testbug.dto.cases.MtProjectTemplateDetailDto;
import net.northking.cctp.testbug.dto.cases.MtProjectTemplateQueryDto;
import net.northking.cctp.testbug.dto.project.CpProjectDetailDto;
import net.northking.cctp.testbug.dto.project.CpProjectRuleQueryDto;
import net.northking.cctp.testbug.dto.project.RuleConfigValue;
import net.northking.cctp.testbug.dto.project.StatusRoleDto;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author: puchao.ma
 * @date: 2021/10/25 15:17
 */
@FeignClient(name = "cctp-projects", path = "/cctp-projects", configuration = {FeignCctpConfig.class})
public interface ProjectsFeignClient {

    /**
     * 分页查询 属性配置表 列表
     *
     * @param query 查询条件
     * @return 数据列表
     */
    @PostMapping(value = "/v1/paging/query/FeginMtProjectTemplates",
            produces = MediaType.APPLICATION_JSON_UTF8_VALUE,
            consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    ResultWrapper<List<MtProjectTemplateDetailDto>> feginPagingQuery(@RequestBody MtProjectTemplateQueryDto query);


    /**
     * 根据项目id集合查询项目列表
     *
     * @param projectIds
     * @return
     */
    @PostMapping(value = "/v1/list/CpProjects",
            produces = MediaType.APPLICATION_JSON_UTF8_VALUE,
            consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public ResultWrapper<List<CpProjectDetailDto>> listProject(@RequestBody List<String> projectIds);

    /**
     * 查询项目级的规则配置
     *
     * @param ruleQueryDto 查询参数
     * @return 数据列表
     */
    @ApiOperation(value = "查询项目级的规则配置")
    @PostMapping(value = "/v1/query/ruleConfig",
            produces = MediaType.APPLICATION_JSON_UTF8_VALUE,
            consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public ResultWrapper<RuleConfigValue> queryRuleConfig(@RequestBody CpProjectRuleQueryDto ruleQueryDto);

    /**
     * 查询项目配置的缺陷终态
     *
     * @param dto 查询参数
     * @return 数据列表
     */
    @ApiOperation(value = "查询项目配置的缺陷终态")
    @PostMapping(value = "/v1/process/status/special",
            produces = MediaType.APPLICATION_JSON_UTF8_VALUE,
            consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public ResultWrapper<List<String>> queryBugEndStatus(@RequestBody StatusRoleDto dto);

    /**
     * 查询所有的项目的项目id
     *
     * @return 数据列表
     */
    @ApiOperation(value = "查询所有的项目的项目id")
    @PostMapping(value = "/v1/view/CpProjectIdList",
            produces = MediaType.APPLICATION_JSON_UTF8_VALUE,
            consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public ResultWrapper<List<String>> queryProjectIdList();

    /**
     * 根据租户id查询租户下的所有项目id
     *
     * @return
     */
    @ApiOperation(value = "根据租户id查询租户下的所有项目id")
    @PostMapping(value = "/v1/feign/queryProjectId",
            produces = MediaType.APPLICATION_JSON_UTF8_VALUE,
            consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public ResultWrapper<List<String>> queryProjectId();

    /**
     * 已删除项目id
     *
     * @return
     */
    @ApiOperation(value = "根据租户id查询租户下的所有项目id")
    @PostMapping(value = "/v1/feign/queryDeletedProjectId",
            produces = MediaType.APPLICATION_JSON_UTF8_VALUE,
            consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    ResultWrapper<List<String>> queryDeletedProjectId();

    /**
     * 查询当前项目的叶子项目
     *
     * @param projectIdList 项目id集合
     * @return 数据列表
     */
    @ApiOperation(value = "根据项目id集合查询叶子项目列表")
    @PostMapping(value = "/v1/feign/getLeafProject",
            produces = MediaType.APPLICATION_JSON_UTF8_VALUE,
            consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public ResultWrapper<List<String>> listLeafProject(@RequestParam("projectIdList") List<String> projectIdList);

    /**
     * 外部接口： 查询项目配置的缺陷终态
     *
     * @param dto 查询参数
     * @return 数据列表
     */
    @ApiOperation(value = "查询项目配置的缺陷初态")
    @PostMapping(value = "/pub/process/status/special")
    public List<String> queryBugInitialStatus(@RequestBody StatusRoleDto dto);



    /**
     * 外部接口： 查询项目配置的缺陷终态
     *
     * @param statusRole 查询参数
     * @return 数据列表
     */
    @ApiOperation(value = "获取状态下可选角色")
    @PostMapping(value = "/pub/process/status/users")
    public List<UserInfo> queryAvailableRoles(@RequestBody StatusRoleDto statusRole);


    /**
     * 根据项目id查询项目基本信息
     *
     * @param projectId 项目id
     * @return 数据详情
     */
    @ApiOperation(value = "根据项目id查询项目基本信息")
    @GetMapping(value = "/v1/view/CpProject/{projectId}")
    public ResultWrapper<CpProject> viewProject(
            @PathVariable("projectId") String projectId);
}
