package com.ruoyi.frequency.givewallerecord.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
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.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.frequency.givewallerecord.entity.GiveWalletRecord;
import com.ruoyi.frequency.givewallerecord.service.GiveWalletRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 抵用金钱包记录Controller
 * 
 * @author liwenlong
 * @date 2024-05-18
 */
@RestController
@RequestMapping("/frequency/givewallerecord")
public class GiveWalletRecordController extends BaseController
{
    @Autowired
    private GiveWalletRecordService giveWalletRecordService;

    /**
     * 查询抵用金钱包记录列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:givewallerecord:list')")
    @GetMapping("/list")
    public TableDataInfo<GiveWalletRecord> list(GiveWalletRecord giveWalletRecord)
    {
        startPage();
        List<GiveWalletRecord> list = giveWalletRecordService.selectGiveWalletRecordList(giveWalletRecord);
        return getDataTable(list);
    }

    /**
     * 导出抵用金钱包记录列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:givewallerecord:export')")
    @Log(title = "抵用金钱包记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(GiveWalletRecord giveWalletRecord)
    {
        List<GiveWalletRecord> list = giveWalletRecordService.selectGiveWalletRecordList(giveWalletRecord);
        ExcelUtil<GiveWalletRecord> util = new ExcelUtil<GiveWalletRecord>(GiveWalletRecord.class);
        return util.exportExcel(list, "抵用金钱包记录数据");
    }

    /**
     * 获取抵用金钱包记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('frequency:givewallerecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult<GiveWalletRecord> getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(giveWalletRecordService.selectGiveWalletRecordById(id));
    }

    /**
     * 新增抵用金钱包记录
     */
    @PreAuthorize("@ss.hasPermi('frequency:givewallerecord:add')")
    @Log(title = "抵用金钱包记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GiveWalletRecord giveWalletRecord)
    {
        return toAjax(giveWalletRecordService.insertGiveWalletRecord(giveWalletRecord));
    }

    /**
     * 修改抵用金钱包记录
     */
    @PreAuthorize("@ss.hasPermi('frequency:givewallerecord:edit')")
    @Log(title = "抵用金钱包记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GiveWalletRecord giveWalletRecord)
    {
        return toAjax(giveWalletRecordService.updateGiveWalletRecord(giveWalletRecord));
    }

    /**
     * 删除抵用金钱包记录
     */
    @PreAuthorize("@ss.hasPermi('frequency:givewallerecord:remove')")
    @Log(title = "抵用金钱包记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}/{delFlag}")
    public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag)
    {
        return toAjax(giveWalletRecordService.deleteGiveWalletRecordByIds(ids,delFlag));
    }
}
