package com.ruoyi.web.controller.ss;

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

import com.ruoyi.ss.resetRecord.domain.SmResetRecordQuery;
import com.ruoyi.ss.resetRecord.domain.SmResetRecordVo;
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.PathVariable;
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.ss.resetRecord.service.ISmResetRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 归零记录Controller
 *
 * @author ruoyi
 * @date 2024-04-17
 */
@RestController
@RequestMapping("/system/resetRecord")
public class SmResetRecordController extends BaseController
{
    @Autowired
    private ISmResetRecordService smResetRecordService;

    /**
     * 查询归零记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:resetRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(SmResetRecordQuery smResetRecord)
    {
        startPage();
        List<SmResetRecordVo> list = smResetRecordService.selectSmResetRecordList(smResetRecord);
        return getDataTable(list);
    }

    /**
     * 导出归零记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:resetRecord:export')")
    @Log(title = "归零记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SmResetRecordQuery smResetRecord)
    {
        List<SmResetRecordVo> list = smResetRecordService.selectSmResetRecordList(smResetRecord);
        ExcelUtil<SmResetRecordVo> util = new ExcelUtil<SmResetRecordVo>(SmResetRecordVo.class);
        util.exportExcel(response, list, "归零记录数据");
    }

    /**
     * 获取归零记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:resetRecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(smResetRecordService.selectSmResetRecordById(id));
    }

}
