package com.ruoyi.invest.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
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.CreditCardBill;
import com.ruoyi.invest.domain.vo.CreditCardBillVo;
import com.ruoyi.invest.domain.dto.CreditCardBillDto;
import com.ruoyi.invest.service.ICreditCardBillService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 信用卡账单Controller
 *
 * @author tianyongbao
 * @date 2024-03-19
 */
@Api(tags=" 信用卡账单")
@RestController
@RequestMapping("/creditCardBill")
public class CreditCardBillController extends BaseController
{
    @Resource
    private ICreditCardBillService creditCardBillService;

    /**
     * 查询信用卡账单列表
     */
    @ApiOperation(value="查询信用卡账单列表",response = CreditCardBillVo.class)
    @RequiresPermissions("invest:creditCardBill:list")
    @GetMapping("/list")
    public TableDataInfo list(CreditCardBillDto creditCardBillDto)
    {
        startPage();
        List<CreditCardBillVo> list = creditCardBillService.selectCreditCardBillList(creditCardBillDto);
        return getDataTable(list);
    }

    /**
     * 导出信用卡账单列表
     */
    @ApiOperation(value="导出信用卡账单列表")
    @RequiresPermissions("invest:creditCardBill:export")
    @Log(title = "信用卡账单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CreditCardBillDto creditCardBillDto)
    {
        List<CreditCardBillVo> list = creditCardBillService.selectCreditCardBillList(creditCardBillDto);
        ExcelUtil<CreditCardBillVo> util = new ExcelUtil<CreditCardBillVo>(CreditCardBillVo.class);
        util.exportExcel(response, list, "信用卡账单数据");
    }

    /**
     * 获取信用卡账单详细信息
     */
    @ApiOperation(value="获取信用卡账单详细信息")
    @RequiresPermissions("invest:creditCardBill:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(creditCardBillService.selectCreditCardBillById(id));
    }

    /**
     * 新增信用卡账单
     */
    @ApiOperation(value="新增信用卡账单")
    @RequiresPermissions("invest:creditCardBill:add")
    @Log(title = "信用卡账单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CreditCardBill creditCardBill)
    {
        return toAjax(creditCardBillService.insertCreditCardBill(creditCardBill));
    }

    /**
     * 修改信用卡账单
     */
    @ApiOperation(value="修改信用卡账单")
    @RequiresPermissions("invest:creditCardBill:edit")
    @Log(title = "信用卡账单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CreditCardBill creditCardBill)
    {
        return toAjax(creditCardBillService.updateCreditCardBill(creditCardBill));
    }

    /**
     * 删除信用卡账单
     */
    @ApiOperation(value="删除信用卡账单")
    @RequiresPermissions("invest:creditCardBill:remove")
    @Log(title = "信用卡账单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(creditCardBillService.deleteCreditCardBillByIds(ids));
    }
}
