package com.dsk.web.controller.search.macroMarket;

import com.dsk.common.core.domain.AjaxResult;
import com.dsk.common.dtos.*;
import com.dsk.system.service.EconomicService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;


/**
 * @ClassName RegionalEconomicDataController
 * @Description 区域经济大全
 * @Author Dgm
 * @Date 2023/5/18 10:09
 * @Version 1.0.0
 */
@Slf4j
@RestController
@RequestMapping(value ="/economic")
public class RegionalEconomicDataController {

    @Autowired
    private EconomicService economicService;

    /***
     *@Description: 全国经济大全分页列表
     *@Param:
     *@return: com.dsk.common.core.domain.AjaxResult
     *@Author: Dgm
     *@date: 2023/5/18 10:29
     */
    @PostMapping("/national/nationalPage")
    public AjaxResult nationalPage(@RequestBody @Valid OpRegionalEconomicDataV1PageDto dto) {
        return economicService.nationalPage(dto);
    }

    /***
     *@Description: 获取年份
     *@Param:
     *@return: com.dsk.acc.security.common.msg.RestResponse
     *@Author: Dgm
     *@date: 2023/5/18 10:29
     */
    @PostMapping("/years/list")
    public AjaxResult yearsList(@RequestBody OpRegionalEconomicDataYearsListDto dto) {
        return economicService.yearsList(dto);
    }


    /***
     *@Description: 全国经济大全详情
     *@Param:
     *@return: com.dsk.common.core.domain.AjaxResult
     *@Author: Dgm
     *@date: 2023/5/18 10:29
     */
    @PostMapping("/details")
    public AjaxResult details(@RequestBody @Valid OpRegionalEconomicDataDetailsDto detailsDto) {
        return economicService.details(detailsDto);
    }

    /***
     *@Description: 获取当前地区
     *@Param:
     *@return: com.dsk.common.core.domain.AjaxResult
     *@Author: Dgm
     *@date: 2023/5/18 10:29
     */
    @PostMapping(value = "location")
    public AjaxResult location(@RequestBody OpRegionalLocalDto vo, HttpServletRequest request){
        String ip = IpUtil.getIpAddr(request);
        vo.setIp(ip);
        return economicService.location(vo);
    }


    /***
     *@Description: 地区经济-统计
     *@Param:
     *@return: com.dsk.common.core.domain.AjaxResult
     *@Author: Dgm
     *@date: 2023/5/18 10:29
     */
    @PostMapping("/statistics/regional")
    public AjaxResult statisticsRegional(@RequestBody OpRegionalEconomicDataStatisticsRegionalDto dto) {
        return economicService.statisticsRegional(dto);
    }

    /***
     *@Description: 地区经济-主要指标列表
     *@Param:
     *@return: com.dsk.common.core.domain.AjaxResult
     *@Author: Dgm
     *@date: 2023/5/18 10:29
     */
    @PostMapping("/regional/list")
    public AjaxResult regionalList(@RequestBody OpRegionalEconomicDataRegionalListDto dto) {
        return economicService.regionalList(dto);
    }

    /***
     *@Description: 地区经济
     *@Param:
     *@return: com.dsk.acc.security.common.msg.RestResponse
     *@Author: Dgm
     *@date: 2023/5/18 10:29
     */
    @PostMapping("/regional/compare")
    public AjaxResult regionalCompare(@RequestBody OpRegionalEconomicDataStatisticsRegionalDto dto) {
        return economicService.regionalCompare(dto);
    }

    /***
     *@Description: 地区经济-对比
     *@Param:
     *@return: com.dsk.acc.security.common.msg.RestResponse
     *@Author: Dgm
     *@date: 2023/5/18 10:29
     */
    @PostMapping("/regional/multipleCompare")
    public AjaxResult regionalMultipleCompare(@RequestBody OpRegionalEconomicRegionalCompareDto compareDto) {
        return economicService.regionalMultipleCompare(compareDto);
    }

}
