package com.simuwang.manage.api.navAsset;

import com.simuwang.base.common.support.MybatisPage;
import com.simuwang.base.pojo.dto.query.DistributionPageQuery;
import com.simuwang.base.pojo.dto.query.FundNavAssetPageQuery;
import com.simuwang.base.pojo.vo.*;
import com.simuwang.manage.service.FundNavAssetService;
import com.smppw.common.pojo.ResultVo;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * 净值规模管理
 * Author:   chenjianhua
 * Date:     2024/9/15 16:46
 * Description: ${DESCRIPTION}
 */
@RestController
@RequestMapping("/v1/nav-asset")
public class FundNavAssetController {

    @Autowired
    private FundNavAssetService fundNavAssetService;

    /**
     * 基金净值规模页面展示查询
     * @param fundNavAssetPageQuery
     * @return
     */
    @RequestMapping("search-nav-asset-list")
    public MybatisPage<FundNavAssetVO> searchNavAssetList(FundNavAssetPageQuery fundNavAssetPageQuery){
        MybatisPage<FundNavAssetVO> result = fundNavAssetService.searchNavAssetList(fundNavAssetPageQuery);
        return result;
    }

    /**
     * 新增基金规模
     * @param fundAssetVO
     * @return
     */
    @PostMapping("/save-fund-asset")
    public ResultVo saveFundAsset(@RequestBody FundAssetVO fundAssetVO){
        fundNavAssetService.saveFundAsset(fundAssetVO);
        return ResultVo.ok(true);
    }

    /**
     * 新增基金规模
     * @param fundNavVO
     * @return
     */
    @PostMapping("/save-fund-nav")
    public ResultVo saveFundNav(@RequestBody FundNavVO fundNavVO){
        fundNavAssetService.saveFundNav(fundNavVO);
        return ResultVo.ok(true);
    }

    @RequestMapping("/delete-fund-nav-asset")
    public ResultVo deleteFundNavAsset(@RequestBody FundNavAssetDelListVO fundNavAssetDelListVO){
        fundNavAssetService.deleteFundNavAsset(fundNavAssetDelListVO);
        return ResultVo.ok(true);
    }

    /**
     * 上传分红信息
     * @param file
     * @param response
     * @param request
     * @return
     */
    @RequestMapping("upload-nav-asset")
    public ResultVo uploadNavAsset(@RequestParam(value = "file",required = false) MultipartFile file, HttpServletResponse response, HttpServletRequest request){
        ResultVo vo = fundNavAssetService.uploadNavAsset(file);
        return vo;
    }
}
