package com.ruoyi.invest.controller;

import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.invest.domain.BankCardLend;
import com.ruoyi.invest.domain.dto.BankCardLendDto;
import com.ruoyi.invest.domain.vo.BankCardLendVo;
import com.ruoyi.invest.service.IBankCardLendService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 银行卡信息Controller
 *
 * @author tianyongbao
 * @date 2024-03-18
 */
@Api(tags=" 银行卡信息")
@RestController
@RequestMapping("/bankcardlend")
public class BankCardLendController extends BaseController
{
    @Resource
    private IBankCardLendService bankCardService;

    /**
     * 查询银行卡信息列表
     */
    @ApiOperation(value="查询银行卡信息列表",response = BankCardLendVo.class)
    @RequiresPermissions("invest:bankcard:list")
    @GetMapping("/list")
    public TableDataInfo list(BankCardLendDto bankCardLendDto)
    {
        startPage();
        List<BankCardLendVo> list = bankCardService.selectBankCardLendList(bankCardLendDto);
        return getDataTable(list);
    }

    /**
     * 导出银行卡信息列表
     */
    @ApiOperation(value="导出银行卡信息列表")
    @RequiresPermissions("invest:bankcard:export")
    @Log(title = "银行卡信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BankCardLendDto bankCardLendDto)
    {
        List<BankCardLendVo> list = bankCardService.selectBankCardLendList(bankCardLendDto);
        ExcelUtil<BankCardLendVo> util = new ExcelUtil<BankCardLendVo>(BankCardLendVo.class);
        util.exportExcel(response, list, "银行卡信息数据");
    }

    /**
     * 获取银行卡信息详细信息
     */
    @ApiOperation(value="获取银行卡信息详细信息")
    @RequiresPermissions("invest:bankcard:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bankCardService.selectBankCardLendById(id));
    }

    /**
     * 新增银行卡信息
     */
    @ApiOperation(value="新增银行卡信息")
    @RequiresPermissions("invest:bankcard:add")
    @Log(title = "银行卡信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BankCardLend bankCard)
    {
        return toAjax(bankCardService.insertBankCardLend(bankCard));
    }

    /**
     * 修改银行卡信息
     */
    @ApiOperation(value="修改银行卡信息")
    @RequiresPermissions("invest:bankcard:edit")
    @Log(title = "银行卡信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BankCardLend bankCard)
    {
        return toAjax(bankCardService.updateBankCardLend(bankCard));
    }

    /**
     * 删除银行卡信息
     */
    @ApiOperation(value="删除银行卡信息")
    @RequiresPermissions("invest:bankcard:remove")
    @Log(title = "银行卡信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bankCardService.deleteBankCardLendByIds(ids));
    }
}
