package com.simuwang.manage.api.fund;

import com.simuwang.base.common.support.MybatisPage;
import com.simuwang.base.pojo.dto.query.FundFilePageQuery;
import com.simuwang.base.pojo.dto.query.FundInfoPageQuery;
import com.simuwang.base.pojo.dto.query.FundInputPageQuery;
import com.simuwang.base.pojo.vo.FundFileInfoVO;
import com.simuwang.base.pojo.vo.FundInformationVO;
import com.simuwang.base.pojo.vo.FundReportFrequencyVO;
import com.simuwang.manage.service.EmailFundInfoService;
import com.simuwang.manage.service.FundInformationService;
import com.simuwang.manage.service.FundReportFrequencyService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 基金管理
 * Author:   chenjianhua
 * Date:     2024/9/6 15:01
 * Description: ${DESCRIPTION}
 */
@RestController
@RequestMapping("/v1/fund")
public class FundInformationController{
    private static final Logger logger = LoggerFactory.getLogger(FundInformationController.class);

    @Autowired
    private FundInformationService fundInformationService;

    @Autowired
    private FundReportFrequencyService fundReportFrequencyService;

    @Autowired
    private EmailFundInfoService emailFundInfoService;
    /**
     * 基金搜索输入框查询
     * @param fundInputPageQuery
     * @return
     */
    @RequestMapping("search-info")
    public MybatisPage<Map<String,String>> searchFundInfo(FundInputPageQuery fundInputPageQuery){
        MybatisPage<Map<String,String>> result = fundInformationService.searchFundInfo(fundInputPageQuery);
        return result;
    }

    /**
     *  页面展示查询
     * @param fundInfoPageQuery
     * @return
     */
    @RequestMapping("search-list")
    public MybatisPage<FundInformationVO> searchFundInfoList(FundInfoPageQuery fundInfoPageQuery){
        MybatisPage<FundInformationVO> result = fundInformationService.searchFundInfoList(fundInfoPageQuery);
        return result;
    }

    /**
     * 保存基金报送频率
     * @param fundReportFrequency
     * @return
     */
    @PostMapping("/save-frequency")
    public boolean saveFundReportFrequency(@RequestBody FundReportFrequencyVO fundReportFrequency){
        fundReportFrequencyService.saveFundReportFrequency(fundReportFrequency);
        return true;
    }

    /**
     * 查询基金关联的数据文件
     * @param fundFilePageQuery
     * @return
     */
    @GetMapping("/search-fund-file")
    public MybatisPage<FundFileInfoVO> searchFundFileInfo(FundFilePageQuery fundFilePageQuery){
        MybatisPage<FundFileInfoVO> result = emailFundInfoService.searchFundFileInfo(fundFilePageQuery);
        return result;
    }

}
