package com.fastbee.data.controller.cardSwipeRecords;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.fastbee.common.annotation.Log;
import com.fastbee.common.core.controller.BaseController;
import com.fastbee.common.core.domain.AjaxResult;
import com.fastbee.common.enums.BusinessType;
import com.fastbee.iot.domain.NgCardSwipeRecords;
import com.fastbee.iot.service.INgCardSwipeRecordsService;
import com.fastbee.common.utils.poi.ExcelUtil;
import com.fastbee.common.core.page.TableDataInfo;

/**
 * 刷卡记录Controller
 *
 * @author kerwincui
 * @date 2024-12-30
 */
@RestController
@RequestMapping("/iot/swipe/records")
@Api(tags = "刷卡记录")
public class NgCardSwipeRecordsController extends BaseController
{
    @Autowired
    private INgCardSwipeRecordsService ngCardSwipeRecordsService;

    /**
     * 用户查询刷卡记录列表
     */
    @PreAuthorize("@ss.hasPermi('iot:records:list')")
    @GetMapping("/list/user")
    @ApiOperation("查询刷卡记录列表")
    public TableDataInfo userList(NgCardSwipeRecords ngCardSwipeRecords)
    {
        startPage();
        List<NgCardSwipeRecords> list = ngCardSwipeRecordsService.selectNgCardSwipeRecordsUserList(ngCardSwipeRecords);
        return getDataTable(list);
    }

    /**
     * 查询刷卡记录列表
     */
    @PreAuthorize("@ss.hasPermi('iot:records:list')")
    @GetMapping("/list")
    @ApiOperation("查询刷卡记录列表")
    public TableDataInfo list(NgCardSwipeRecords ngCardSwipeRecords)
    {
        startPage();
        List<NgCardSwipeRecords> list = ngCardSwipeRecordsService.selectNgCardSwipeRecordsList(ngCardSwipeRecords);
        return getDataTable(list);
    }


    /**
     * 导出刷卡记录列表
     */
    @ApiOperation("导出刷卡记录列表")
    @PreAuthorize("@ss.hasPermi('iot:records:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, NgCardSwipeRecords ngCardSwipeRecords)
    {
        List<NgCardSwipeRecords> list = ngCardSwipeRecordsService.selectNgCardSwipeRecordsList(ngCardSwipeRecords);
        ExcelUtil<NgCardSwipeRecords> util = new ExcelUtil<NgCardSwipeRecords>(NgCardSwipeRecords.class);
        util.exportExcel(response, list, "刷卡记录数据");
    }

    /**
     * 获取刷卡记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('iot:records:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取刷卡记录详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ngCardSwipeRecordsService.selectNgCardSwipeRecordsById(id));
    }

    /**
     * 新增刷卡记录
     */
    @PreAuthorize("@ss.hasPermi('iot:records:add')")
    @PostMapping
    @ApiOperation("新增刷卡记录")
    public AjaxResult add(@RequestBody NgCardSwipeRecords ngCardSwipeRecords)
    {
        return toAjax(ngCardSwipeRecordsService.insertNgCardSwipeRecords(ngCardSwipeRecords));
    }

    /**
     * 修改刷卡记录
     */
    @PreAuthorize("@ss.hasPermi('iot:records:edit')")
    @PutMapping
    @ApiOperation("修改刷卡记录")
    public AjaxResult edit(@RequestBody NgCardSwipeRecords ngCardSwipeRecords)
    {
        return toAjax(ngCardSwipeRecordsService.updateNgCardSwipeRecords(ngCardSwipeRecords));
    }

    /**
     * 删除刷卡记录
     */
    @PreAuthorize("@ss.hasPermi('iot:records:remove')")
    @DeleteMapping("/{ids}")
    @ApiOperation("删除刷卡记录")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ngCardSwipeRecordsService.deleteNgCardSwipeRecordsByIds(ids));
    }
}
