package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.system.domain.ManageDeviceDictionary;
import com.ruoyi.system.service.IManageDeviceDictionaryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * Device product enumController
 *
 * @author ruoyi
 * @date 2024-09-03
 */
@RestController
@RequestMapping("/system/dictionary")
public class ManageDeviceDictionaryController extends BaseController
{
    @Autowired
    private IManageDeviceDictionaryService manageDeviceDictionaryService;

    /**
     * 查询Device product enum列表
     */
    // @PreAuthorize("@ss.hasPermi('system:dictionary:list')")
    @GetMapping("/list")
    public TableDataInfo list(ManageDeviceDictionary manageDeviceDictionary)
    {
        startPage();
        List<ManageDeviceDictionary> list = manageDeviceDictionaryService.selectManageDeviceDictionaryList(manageDeviceDictionary);
        return getDataTable(list);
    }

    /**
     * 导出Device product enum列表
     */
    // @PreAuthorize("@ss.hasPermi('system:dictionary:export')")
    @Log(title = "Device product enum", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ManageDeviceDictionary manageDeviceDictionary)
    {
        List<ManageDeviceDictionary> list = manageDeviceDictionaryService.selectManageDeviceDictionaryList(manageDeviceDictionary);
        ExcelUtil<ManageDeviceDictionary> util = new ExcelUtil<ManageDeviceDictionary>(ManageDeviceDictionary.class);
        util.exportExcel(response, list, "Device product enum数据");
    }

    /**
     * 获取Device product enum详细信息
     */
    // @PreAuthorize("@ss.hasPermi('system:dictionary:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(manageDeviceDictionaryService.selectManageDeviceDictionaryById(id));
    }

    /**
     * 新增Device product enum
     */
    // @PreAuthorize("@ss.hasPermi('system:dictionary:add')")
    @Log(title = "Device product enum", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ManageDeviceDictionary manageDeviceDictionary)
    {
        return toAjax(manageDeviceDictionaryService.insertManageDeviceDictionary(manageDeviceDictionary));
    }

    /**
     * 修改Device product enum
     */
    // @PreAuthorize("@ss.hasPermi('system:dictionary:edit')")
    @Log(title = "Device product enum", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ManageDeviceDictionary manageDeviceDictionary)
    {
        return toAjax(manageDeviceDictionaryService.updateManageDeviceDictionary(manageDeviceDictionary));
    }

    /**
     * 删除Device product enum
     */
    // @PreAuthorize("@ss.hasPermi('system:dictionary:remove')")
    @Log(title = "Device product enum", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(manageDeviceDictionaryService.deleteManageDeviceDictionaryByIds(ids));
    }
}
