package com.ruoyi.frequency.bondwithdrawalrecord.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.frequency.bondwithdrawalrecord.entity.BondWithdrawalRecord;
import com.ruoyi.frequency.bondwithdrawalrecord.model.result.BondWithdrawalRecordCount;
import com.ruoyi.frequency.bondwithdrawalrecord.service.BondWithdrawalRecordService;
import com.ruoyi.frequency.withdrawalrecord.entity.WithdrawalRecord;
import com.ruoyi.frequency.withdrawalrecord.model.result.WithdrawalRecordCount;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 保证金提现记录Controller
 *
 * @author liwenlong
 * @date 2023-10-31
 */
@RestController
@RequestMapping("/frequency/bondwithdrawalrecord")
public class BondWithdrawalRecordController extends BaseController
{
    @Autowired
    private BondWithdrawalRecordService bondWithdrawalRecordService;

    /**
     * 查询保证金提现记录列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:bondwithdrawalrecord:list')")
    @PostMapping("/list")
    public TableDataInfo<BondWithdrawalRecord> list(@RequestBody BondWithdrawalRecord bondWithdrawalRecord)
    {
        startPage();
        List<BondWithdrawalRecord> list = bondWithdrawalRecordService.selectBondWithdrawalRecordList(bondWithdrawalRecord);
        return getDataTable(list);
    }

    /**
     * 统计
     */
    @PostMapping("/statistics")
    public AjaxResult statistics(@RequestBody BondWithdrawalRecord bondWithdrawalRecord)
    {
        BondWithdrawalRecordCount count = bondWithdrawalRecordService.statistics(bondWithdrawalRecord);
        return AjaxResult.success(count);
    }

    /**
     * 导出保证金提现记录列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:bondwithdrawalrecord:export')")
    @Log(title = "保证金提现记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BondWithdrawalRecord bondWithdrawalRecord)
    {
        List<BondWithdrawalRecord> list = bondWithdrawalRecordService.selectBondWithdrawalRecordList(bondWithdrawalRecord);
        ExcelUtil<BondWithdrawalRecord> util = new ExcelUtil<BondWithdrawalRecord>(BondWithdrawalRecord.class);
        return util.exportExcel(list, "保证金提现记录数据");
    }

    /**
     * 获取保证金提现记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('frequency:bondwithdrawalrecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult<BondWithdrawalRecord> getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(bondWithdrawalRecordService.selectBondWithdrawalRecordById(id));
    }

    /**
     * 新增保证金提现记录
     */
    @PreAuthorize("@ss.hasPermi('frequency:bondwithdrawalrecord:add')")
    @Log(title = "保证金提现记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BondWithdrawalRecord bondWithdrawalRecord)
    {
        return toAjax(bondWithdrawalRecordService.insertBondWithdrawalRecord(bondWithdrawalRecord));
    }

    /**
     * 修改保证金提现记录
     */
    @PreAuthorize("@ss.hasPermi('frequency:bondwithdrawalrecord:edit')")
    @Log(title = "保证金提现记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BondWithdrawalRecord bondWithdrawalRecord)
    {
        return toAjax(bondWithdrawalRecordService.updateBondWithdrawalRecord(bondWithdrawalRecord));
    }

    /**
     * 删除保证金提现记录
     */
    @PreAuthorize("@ss.hasPermi('frequency:bondwithdrawalrecord:remove')")
    @Log(title = "保证金提现记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}/{delFlag}")
    public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFalg)
    {
        return toAjax(bondWithdrawalRecordService.deleteBondWithdrawalRecordByIds(ids,delFalg));
    }

    /**
     * 提现审核
     */
    @PreAuthorize("@ss.hasPermi('frequency:bondwithdrawalrecord:process')")
    @Log(title = "保证金提现记录", businessType = BusinessType.UPDATE)
    @PostMapping("/process")
    public AjaxResult process(@RequestBody BondWithdrawalRecord bondWithdrawalRecord)
    {
        return bondWithdrawalRecordService.process(bondWithdrawalRecord);
    }
}
