package com.ruoyi.sim.controller;

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

import com.ruoyi.sim.service.impl.SimService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
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.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.sim.domain.Sim;
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")
public class SimController extends BaseController {
    @Autowired
    private SimService simService;

    // @PreAuthorize("@ss.hasPermi('sim:sim:list')")
    @GetMapping("/list")
    @ApiOperation("[分页]查询模拟器列表")
    public TableDataInfo list(Sim sim) {
        startPage();
        List<Sim> list = simService.selectSimList(sim);
        return getDataTable(list);
    }

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

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

    /**
     * 新增模拟器
     */
    // @PreAuthorize("@ss.hasPermi('sim:sim:add')")
    // @Log(title = "模拟器", businessType = BusinessType.INSERT)
    // @PostMapping
    public AjaxResult add(@RequestBody Sim sim) {
        return toAjax(simService.insertSim(sim));
    }

    /**
     * 修改模拟器
     */
    // @PreAuthorize("@ss.hasPermi('sim:sim:edit')")
    // @Log(title = "模拟器", businessType = BusinessType.UPDATE)
    // @PutMapping
    public AjaxResult edit(@RequestBody Sim sim) {
        return toAjax(simService.updateSim(sim));
    }

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