package com.ruoyi.frequency.platformrecord.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.platformrecord.entity.PlatformRecord;
import com.ruoyi.frequency.platformrecord.model.result.PlatformRecordCount;
import com.ruoyi.frequency.platformrecord.service.PlatformRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 平台流水记录Controller
 *
 * @author liwenlong
 * @date 2023-12-01
 */
@RestController
@RequestMapping("/frequency/platformrecord")
public class PlatformRecordController extends BaseController
{
    @Autowired
    private PlatformRecordService platformRecordService;

    /**
     * 查询平台流水记录列表
     */
    //@PreAuthorize("@ss.hasPermi('frequency:platformrecord:list')")
    @PostMapping("/list")
    public TableDataInfo<PlatformRecord> list(@RequestBody PlatformRecord platformRecord)
    {
        startPage();
        List<PlatformRecord> list = platformRecordService.selectPlatformRecordList(platformRecord);
        return getDataTable(list);
    }

    /**
     * 统计
     */
    @PostMapping("/statistics")
    public AjaxResult statistics(@RequestBody PlatformRecord platformRecord)
    {
        PlatformRecordCount count = platformRecordService.statistics(platformRecord);
        return AjaxResult.success(count);
    }

    /**
     * 导出平台流水记录列表
     */
    //@PreAuthorize("@ss.hasPermi('frequency:platformrecord:export')")
    @Log(title = "平台流水记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(PlatformRecord platformRecord)
    {
        List<PlatformRecord> list = platformRecordService.selectPlatformRecordList(platformRecord);
        ExcelUtil<PlatformRecord> util = new ExcelUtil<PlatformRecord>(PlatformRecord.class);
        return util.exportExcel(list, "平台流水记录数据");
    }

    /**
     * 获取平台流水记录详细信息
     */
    //@PreAuthorize("@ss.hasPermi('frequency:platformrecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult<PlatformRecord> getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(platformRecordService.selectPlatformRecordById(id));
    }

    /**
     * 新增平台流水记录
     */
    //@PreAuthorize("@ss.hasPermi('frequency:platformrecord:add')")
    @Log(title = "平台流水记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PlatformRecord platformRecord)
    {
        return toAjax(platformRecordService.insertPlatformRecord(platformRecord));
    }

    /**
     * 修改平台流水记录
     */
    //@PreAuthorize("@ss.hasPermi('frequency:platformrecord:edit')")
    @Log(title = "平台流水记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PlatformRecord platformRecord)
    {
        return toAjax(platformRecordService.updatePlatformRecord(platformRecord));
    }

    /**
     * 删除平台流水记录
     */
    //@PreAuthorize("@ss.hasPermi('frequency:platformrecord:remove')")
    @Log(title = "平台流水记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}/{delFlag}")
    public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag)
    {
        return toAjax(platformRecordService.deletePlatformRecordByIds(ids,delFlag));
    }
}
