package com.ruoyi.project.asset.controller;

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

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.project.asset.domain.TSpecdevTypemgr;
import com.ruoyi.project.asset.service.ITSpecdevTypemgrService;
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;

/**
 * 设备类型管理Controller
 *
 * @author ruoyi
 * @date 2023-08-08
 */
@RestController
@RequestMapping("/sems/typemgr")
public class TSpecdevTypemgrController extends BaseController
{
    @Autowired
    private ITSpecdevTypemgrService tSpecdevTypemgrService;

    /**
     * 查询设备类型管理列表
     */
    @PreAuthorize("@ss.hasPermi('sems:typemgr:list')")
    @GetMapping("/list")
    public TableDataInfo list(TSpecdevTypemgr tSpecdevTypemgr)
    {
        startPage();
        List<TSpecdevTypemgr> list = tSpecdevTypemgrService.selectTSpecdevTypemgrList(tSpecdevTypemgr);
        return getDataTable(list);
    }
    @PreAuthorize("@ss.hasPermi('sems:typemgr:list')")
    @GetMapping("/listAll")
    public AjaxResult listAll(TSpecdevTypemgr tSpecdevTypemgr)
    {
        return AjaxResult.success(tSpecdevTypemgrService.selectTSpecdevTypemgrList(tSpecdevTypemgr));
    }

    /**
     * 导出设备类型管理列表
     */
    @PreAuthorize("@ss.hasPermi('sems:typemgr:export')")
    @Log(title = "设备类型管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TSpecdevTypemgr tSpecdevTypemgr)
    {
        List<TSpecdevTypemgr> list = tSpecdevTypemgrService.selectTSpecdevTypemgrList(tSpecdevTypemgr);
        ExcelUtil<TSpecdevTypemgr> util = new ExcelUtil<TSpecdevTypemgr>(TSpecdevTypemgr.class);
        util.exportExcel( list, "设备类型管理数据");
    }

    /**
     * 获取设备类型管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('sems:typemgr:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tSpecdevTypemgrService.selectTSpecdevTypemgrById(id));
    }

    /**
     * 新增设备类型管理
     */
    @PreAuthorize("@ss.hasPermi('sems:typemgr:add')")
    @Log(title = "设备类型管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TSpecdevTypemgr tSpecdevTypemgr)
    {
        return toAjax(tSpecdevTypemgrService.insertTSpecdevTypemgr(tSpecdevTypemgr));
    }

    /**
     * 修改设备类型管理
     */
    @PreAuthorize("@ss.hasPermi('sems:typemgr:edit')")
    @Log(title = "设备类型管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TSpecdevTypemgr tSpecdevTypemgr)
    {
        return toAjax(tSpecdevTypemgrService.updateTSpecdevTypemgr(tSpecdevTypemgr));
    }

    /**
     * 删除设备类型管理
     */
    @PreAuthorize("@ss.hasPermi('sems:typemgr:remove')")
    @Log(title = "设备类型管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tSpecdevTypemgrService.deleteTSpecdevTypemgrByIds(ids));
    }
}
