package com.ruoyi.frequency.bondrecord.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.bondrecord.entity.BondRecord;
import com.ruoyi.frequency.bondrecord.service.BondRecordService;
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-18
 */
@RestController
@RequestMapping("/frequency/bondrecord")
public class BondRecordController extends BaseController
{
    @Autowired
    private BondRecordService bondRecordService;

    /**
     * 查询保证金记录列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:bondrecord:list')")
    @PostMapping("/list")
    public TableDataInfo<BondRecord> list(@RequestBody BondRecord bondRecord)
    {
        startPage();
        List<BondRecord> list = bondRecordService.selectBondRecordList(bondRecord);
        return getDataTable(list);
    }

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

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

    /**
     * 新增保证金记录
     */
    @PreAuthorize("@ss.hasPermi('frequency:bondrecord:add')")
    @Log(title = "保证金记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BondRecord bondRecord)
    {
        return toAjax(bondRecordService.insertBondRecord(bondRecord));
    }

    /**
     * 修改保证金记录
     */
    @PreAuthorize("@ss.hasPermi('frequency:bondrecord:edit')")
    @Log(title = "保证金记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BondRecord bondRecord)
    {
        return toAjax(bondRecordService.updateBondRecord(bondRecord));
    }

    /**
     * 删除保证金记录
     */
    @PreAuthorize("@ss.hasPermi('frequency:bondrecord:remove')")
    @Log(title = "保证金记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bondRecordService.deleteBondRecordByIds(ids));
    }
}
