package com.ruoyi.sim.controller;

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

import com.ruoyi.sim.service.impl.SimMsgService;
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.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.sim.domain.SimMsg;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 模拟器报文Controller
 *
 * @author tom
 * @date 2024-12-11
 */
@RestController
@RequestMapping("/sim/sim_msg")
public class SimMsgController extends BaseController {
    @Autowired
    private SimMsgService simMsgService;

    /**
     * 查询模拟器报文列表
     */
    // @PreAuthorize("@ss.hasPermi('sim:sim_msg:list')")
    @GetMapping("/list")
    @ApiOperation("查询模拟器报文列表")
    public TableDataInfo list(SimMsg simMsg) {
        startPage();
        List<SimMsg> list = simMsgService.selectSimMsgList(simMsg);
        return getDataTable(list);
    }

    /**
     * 导出模拟器报文列表
     */
    // @PreAuthorize("@ss.hasPermi('sim:sim_msg:export')")
    @Log(title = "模拟器报文", businessType = BusinessType.EXPORT)
    // @PostMapping("/export")
    public void export(HttpServletResponse response, SimMsg simMsg) {
        List<SimMsg> list = simMsgService.selectSimMsgList(simMsg);
        ExcelUtil<SimMsg> util = new ExcelUtil<SimMsg>(SimMsg.class);
        util.exportExcel(response, list, "模拟器报文数据");
    }

    /**
     * 获取模拟器报文详细信息
     */
    // @PreAuthorize("@ss.hasPermi('sim:sim_msg:query')")
    // @GetMapping(value = "/{simMsgId}")
    public AjaxResult getInfo(@PathVariable("simMsgId") Long simMsgId) {
        return success(simMsgService.selectSimMsgBySimMsgId(simMsgId));
    }

    /**
     * 新增模拟器报文
     */
    // @PreAuthorize("@ss.hasPermi('sim:sim_msg:add')")
    @Log(title = "模拟器报文", businessType = BusinessType.INSERT)
    // @PostMapping
    public AjaxResult add(@RequestBody SimMsg simMsg) {
        return toAjax(simMsgService.insertSimMsg(simMsg));
    }

    /**
     * 修改模拟器报文
     */
    // @PreAuthorize("@ss.hasPermi('sim:sim_msg:edit')")
    @Log(title = "模拟器报文", businessType = BusinessType.UPDATE)
    // @PutMapping
    public AjaxResult edit(@RequestBody SimMsg simMsg) {
        return toAjax(simMsgService.updateSimMsg(simMsg));
    }

    /**
     * 删除模拟器报文
     */
    // @PreAuthorize("@ss.hasPermi('sim:sim_msg:remove')")
    @Log(title = "模拟器报文", businessType = BusinessType.DELETE)
    // @DeleteMapping("/{simMsgIds}")
    public AjaxResult remove(@PathVariable Long[] simMsgIds) {
        return toAjax(simMsgService.deleteSimMsgBySimMsgIds(simMsgIds));
    }
}
