package com.simuwang.manage.api.fund;

import com.simuwang.base.common.support.MybatisPage;
import com.simuwang.base.pojo.dto.query.FundAliasPageQuery;
import com.simuwang.base.pojo.vo.FundAliasVO;
import com.simuwang.base.pojo.vo.IdListVO;
import com.simuwang.base.pojo.vo.IdVO;
import com.simuwang.manage.service.FundAliasService;
import com.smppw.common.pojo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 基金别名管理
 * Author:   chenjianhua
 * Date:     2024/9/14 14:05
 * Description: ${DESCRIPTION}
 */
@RestController
@RequestMapping("/v1/alias")
public class FunAliasController {

    @Autowired
    private FundAliasService fundAliasService;

    /**
     * 查询基金别名列表
     * @param fundAliasPageQuery
     * @return
     */
    @GetMapping("/fund-alias-list")
    public MybatisPage<FundAliasVO> searchFundAlias(FundAliasPageQuery fundAliasPageQuery){
        MybatisPage<FundAliasVO> result = fundAliasService.searchFundAlias(fundAliasPageQuery);
        return result;
    }

    /**
     * 根据ID查询基金别名
     * @param idVO
     * @return
     */
    @GetMapping("/search-fund-alias")
    public ResultVo<FundAliasVO> searchFundAlias(IdVO idVO){
        FundAliasVO result = fundAliasService.searchFundAliasById(idVO.getId());
        return ResultVo.ok(result);
    }

    /**
     * 保存基金别名
     * @param fundAliasVO
     * @return
     */
    @PostMapping("/save-fund-alias")
    public ResultVo saveFundAlias(@RequestBody FundAliasVO fundAliasVO){
        fundAliasService.saveFundAlias(fundAliasVO);
        return ResultVo.ok(true);
    }

    /**
     * 删除基金别名
     * @param idListVO
     * @return
     */
    @PostMapping("/delete-fund-alias")
    public ResultVo deleteFundAlias(@RequestBody IdListVO idListVO){
        fundAliasService.deleteFundAlias(idListVO);
        return ResultVo.ok(true);
    }


}
