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.logging.SystemLog;
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}
 */
@SystemLog(value = "净值规模管理")
@RestController
@RequestMapping("/v1/nav-asset")
public class FundNavAssetController {

    @Autowired
    private FundNavAssetService fundNavAssetService;

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

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

    /**
     * 新增基金规模
     * @param fundNavVO
     * @return
     */
    @SystemLog(value = "新增基金规模", type = SystemLog.Type.INSERT)
    @PostMapping("/save-fund-nav")
    public ResultVo saveFundNav(@RequestBody FundNavVO fundNavVO){
        fundNavAssetService.saveFundNav(fundNavVO);
        return ResultVo.ok(true);
    }
    @SystemLog(value = "删除基金规模", type = SystemLog.Type.DELETE)
    @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
     */
    @SystemLog(value = "上传规模", type = SystemLog.Type.UPLOAD_OR_IMPORT)
    @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;
    }
}
