package net.northking.cctp.dw.api;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.northking.cctp.common.http.ResultWrapper;
import net.northking.cctp.dw.api.service.ProjectOverviewApiService;
import net.northking.cctp.dw.dto.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/v1/project")
@Api(tags = "系统概况")
public class MtProjectOverviewCtrl {

    @Autowired
    private ProjectOverviewApiService projectOverviewApiService;

    @PostMapping("/overview/query")
    @ApiOperation("系统概况查询")
    public ResultWrapper<ProjectOverviewDto> projectOverviewQuery(@RequestBody ProjectOverviewQueryDto projectOverviewQueryDto) {
        ResultWrapper<ProjectOverviewDto> wrapper = new ResultWrapper<>();
        ProjectOverviewDto projectOverviewDto = projectOverviewApiService.projectOverviewQuery(projectOverviewQueryDto);
        return wrapper.success(projectOverviewDto);
    }

    @PostMapping("/charge/query")
    @ApiOperation("我负责的信息查询")
    public ResultWrapper<ChargeInfoDto> chargeInfoQuery(@RequestBody ChargeInfoQueryDto chargeInfoQueryDto){
        ResultWrapper<ChargeInfoDto> wrapper = new ResultWrapper<>();
        ChargeInfoDto chargeInfoDto = projectOverviewApiService.chargeInfoQuery(chargeInfoQueryDto);
        return wrapper.success(chargeInfoDto);
    }

    @PostMapping("/modify/query")
    @ApiOperation("最近修改脚本/计划查询")
    public ResultWrapper<List<ModifyInfoDto>> modifyInfoQuery(@RequestBody ModifyInfoQueryDto modifyInfoQueryDto){
        ResultWrapper<List<ModifyInfoDto>> wrapper = new ResultWrapper<>();
        List<ModifyInfoDto> modifyInfoDtoList = projectOverviewApiService.modifyInfoQuery(modifyInfoQueryDto);
        return wrapper.success(modifyInfoDtoList);
    }

    @PostMapping("/fail/plan/query")
    @ApiOperation("系统失败的测试计划查询")
    public ResultWrapper<List<FailPlanInfoDto>> failPlanQuery(@RequestBody ModifyInfoQueryDto modifyInfoQueryDto){
        ResultWrapper<List<FailPlanInfoDto>> wrapper = new ResultWrapper<>();
        List<FailPlanInfoDto> failPlanInfoDtoList = projectOverviewApiService.failPlanQuery(modifyInfoQueryDto);
        return wrapper.success(failPlanInfoDtoList);
    }

    @PostMapping("/plan/query")
    @ApiOperation("系统失败的测试计划查询")
    public ResultWrapper<AxesDto> planQuery(@RequestBody PlanQueryDto planQueryDto){
        ResultWrapper<AxesDto> wrapper = new ResultWrapper<>();
        AxesDto axesDto = projectOverviewApiService.planQuery(planQueryDto);
        return wrapper.success(axesDto);
    }
}
