package com.ruoyi.frequency.bondamounrecord.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.bondamounrecord.entity.BondAmountRecord;
import com.ruoyi.frequency.bondamounrecord.service.BondAmountRecordService;
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/bondamounrecord")
public class BondAmountRecordController extends BaseController
{
    @Autowired
    private BondAmountRecordService bondAmountRecordService;

    /**
     * 查询缴纳保证金列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:bondamounrecord:list')")
    @PostMapping("/list")
    public TableDataInfo<BondAmountRecord> list(@RequestBody BondAmountRecord bondAmountRecord)
    {
        startPage();
        List<BondAmountRecord> list = bondAmountRecordService.selectBondAmountRecordList(bondAmountRecord);
        return getDataTable(list);
    }

    /**
     * 导出缴纳保证金列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:bondamounrecord:export')")
    @Log(title = "缴纳保证金", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BondAmountRecord bondAmountRecord)
    {
        List<BondAmountRecord> list = bondAmountRecordService.selectBondAmountRecordList(bondAmountRecord);
        ExcelUtil<BondAmountRecord> util = new ExcelUtil<BondAmountRecord>(BondAmountRecord.class);
        return util.exportExcel(list, "缴纳保证金数据");
    }

    /**
     * 获取缴纳保证金详细信息
     */
    @PreAuthorize("@ss.hasPermi('frequency:bondamounrecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult<BondAmountRecord> getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(bondAmountRecordService.selectBondAmountRecordById(id));
    }

    /**
     * 新增缴纳保证金
     */
    @PreAuthorize("@ss.hasPermi('frequency:bondamounrecord:add')")
    @Log(title = "缴纳保证金", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BondAmountRecord bondAmountRecord)
    {
        return toAjax(bondAmountRecordService.insertBondAmountRecord(bondAmountRecord));
    }

    /**
     * 修改缴纳保证金
     */
    @PreAuthorize("@ss.hasPermi('frequency:bondamounrecord:edit')")
    @Log(title = "缴纳保证金", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BondAmountRecord bondAmountRecord)
    {
        return toAjax(bondAmountRecordService.updateBondAmountRecord(bondAmountRecord));
    }

    /**
     * 删除缴纳保证金
     */
    @PreAuthorize("@ss.hasPermi('frequency:bondamounrecord:remove')")
    @Log(title = "缴纳保证金", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}/{delFlag}")
    public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFalg)
    {
        return toAjax(bondAmountRecordService.deleteBondAmountRecordByIds(ids,delFalg));
    }
}
