package com.dsk.cscec.controller;


import com.dsk.common.core.controller.BaseController;
import com.dsk.common.core.domain.PageQuery;
import com.dsk.common.core.domain.R;
import com.dsk.common.core.page.TableDataInfo;
import com.dsk.common.excel.ExcelUtils;
import com.dsk.cscec.domain.DCustomer;
import com.dsk.cscec.domain.bo.DCustomerDynamicRiskChangeVo;
import com.dsk.cscec.domain.bo.DCustomerDynamicRiskStatisticsVo;
import com.dsk.cscec.domain.bo.DCustomerDynamicRiskTypeVo;
import com.dsk.cscec.domain.bo.DCustomerSearchBo;
import com.dsk.cscec.domain.vo.DCustomerListVo;
import com.dsk.cscec.service.IDCustomerService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 组织维表(DCustomer)表控制层
 *
 * @author lcl
 * @since 2023-12-08 14:57:22
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/customer")
public class DCustomerController extends BaseController {
    /**
     * 服务对象
     */
    private final IDCustomerService baseService;

    /**
     * 供应商总台账筛选
     */
    @PostMapping("/all/searchList")
    public TableDataInfo<DCustomerListVo> allSearchList(@RequestBody DCustomerSearchBo bo,@RequestBody PageQuery query) {
        return baseService.allSearchList(bo,query);
    }

    /**
     * 供应商信息
     */
    @GetMapping("/info/{customerKey}")
    public R<DCustomer> info(@PathVariable String customerKey) {
        return R.ok(baseService.info(customerKey));
    }

    /**
     * 供应商信息
     */
    @PostMapping("/export")
    public void export(@RequestBody DCustomerSearchBo bo, HttpServletResponse response) {
        List<DCustomerListVo> list = baseService.exportList(bo);
        ExcelUtils<DCustomerListVo> util = new ExcelUtils<>(DCustomerListVo.class);
        util.exportExcel(response, list, "sheet1","大数据经营管理支撑服务平台供应商导出", true);
    }

    /***
     *@Description: 供应商风险动态-统计
     *@Param:
     *@return: com.dsk.common.core.domain.R
     *@Author: Dgm
     *@date: 2023/12/9 9:29
     */
    @PostMapping(value = "dynamicRisk/statistics")
    public R dynamicRiskStatistics(@RequestBody DCustomerDynamicRiskStatisticsVo riskStatisticsVo) {
        return baseService.dynamicRiskStatistics(riskStatisticsVo);
    }

    /***
     *@Description: 查询供应商风险类型分布
     *@Param:
     *@return: com.dsk.common.core.domain.R
     *@Author: Dgm
     *@date: 2023/12/9 9:29
     */
    @PostMapping(value = "risk/type")
    public R riskType(@RequestBody DCustomerDynamicRiskTypeVo riskTypeVo) {
        return baseService.riskType(riskTypeVo);
    }

    /***
     *@Description: 风险类型趋势
     *@Param:
     *@return: com.dsk.common.core.domain.R
     *@Author: Dgm
     *@date: 2023/12/9 9:29
     */
    @PostMapping(value = "risk/change")
    public R riskChange(@RequestBody DCustomerDynamicRiskChangeVo riskChangeVo) {
        return baseService.riskChange(riskChangeVo);
    }


}

