package com.ruoyi.frequency.onlinerecord.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.onlinerecord.entity.OnlineRecord;
import com.ruoyi.frequency.onlinerecord.service.OnlineRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 在线支付记录Controller
 * 
 * @author liwenlong
 * @date 2024-05-18
 */
@RestController
@RequestMapping("/frequency/onlinerecord")
public class OnlineRecordController extends BaseController
{
    @Autowired
    private OnlineRecordService onlineRecordService;

    /**
     * 查询在线支付记录列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:onlinerecord:list')")
    @GetMapping("/list")
    public TableDataInfo<OnlineRecord> list(OnlineRecord onlineRecord)
    {
        startPage();
        List<OnlineRecord> list = onlineRecordService.selectOnlineRecordList(onlineRecord);
        return getDataTable(list);
    }

    /**
     * 导出在线支付记录列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:onlinerecord:export')")
    @Log(title = "在线支付记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(OnlineRecord onlineRecord)
    {
        List<OnlineRecord> list = onlineRecordService.selectOnlineRecordList(onlineRecord);
        ExcelUtil<OnlineRecord> util = new ExcelUtil<OnlineRecord>(OnlineRecord.class);
        return util.exportExcel(list, "在线支付记录数据");
    }

    /**
     * 获取在线支付记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('frequency:onlinerecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult<OnlineRecord> getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(onlineRecordService.selectOnlineRecordById(id));
    }

    /**
     * 新增在线支付记录
     */
    @PreAuthorize("@ss.hasPermi('frequency:onlinerecord:add')")
    @Log(title = "在线支付记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OnlineRecord onlineRecord)
    {
        return toAjax(onlineRecordService.insertOnlineRecord(onlineRecord));
    }

    /**
     * 修改在线支付记录
     */
    @PreAuthorize("@ss.hasPermi('frequency:onlinerecord:edit')")
    @Log(title = "在线支付记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OnlineRecord onlineRecord)
    {
        return toAjax(onlineRecordService.updateOnlineRecord(onlineRecord));
    }

    /**
     * 删除在线支付记录
     */
    @PreAuthorize("@ss.hasPermi('frequency:onlinerecord:remove')")
    @Log(title = "在线支付记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}/{delFlag}")
    public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag)
    {
        return toAjax(onlineRecordService.deleteOnlineRecordByIds(ids,delFlag));
    }
}
