package com.unis.projectManagement.modular.analysisInfo.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.unis.common.pojo.CommonResult;
import com.unis.projectManagement.modular.analysisInfo.entity.AnalysisCountParam;
import com.unis.projectManagement.modular.analysisInfo.entity.AnalysisPageListParam;
import com.unis.projectManagement.modular.analysisInfo.entity.AnalysisPageParam;
import com.unis.projectManagement.modular.analysisInfo.service.AnalysisService;
import com.unis.projectManagement.modular.pmApplication.entity.PmApplication;
import com.unis.projectManagement.modular.projectInfoPlan.entity.ProjectInfoPlan;
import com.unis.projectManagement.modular.projectInfoPlan.service.ProjectInfoPlanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author qingsong.han
 * @description:
 * @create 2024-05-31 17:11
 */
@Api(tags = "统计分析及年报")
@ApiSupport(author = "UNIS_TEAM", order = 8)
@RestController
@Validated
@RequestMapping("/analysis")
public class AnalysisController {
    @Resource
    private AnalysisService analysisService;
    @Resource
    private ProjectInfoPlanService projectInfoPlanService;

    @ApiOperationSupport(order = 1)
    @ApiOperation("获取分页")
    @GetMapping("/getPage")
    public CommonResult<Page<AnalysisPageListParam>> getPage(AnalysisPageParam param) {
        return CommonResult.data(analysisService.getPage(param));
    }

    @ApiOperationSupport(order = 2)
    @ApiOperation("详情列表数据")
    @GetMapping("/getDetailList/{pmApplicationId}")
    public CommonResult<List<ProjectInfoPlan>> getDetailList(@PathVariable("pmApplicationId") String pmApplicationId) {
        QueryWrapper<ProjectInfoPlan> wrapper = new QueryWrapper<>();
        wrapper.eq("pm_application_id", pmApplicationId);
        return CommonResult.data(projectInfoPlanService.list(wrapper));
    }

    @ApiOperationSupport(order = 3)
    @ApiOperation("获取统计(项目类型,资金来源)")
    @GetMapping("/getCount")
    public CommonResult<AnalysisCountParam> getCount() {
        return CommonResult.data(analysisService.getCount());
    }

}
