package com.aucma.dms.controller;

//import com.hw.common.core.utils.poi.ExcelUtil;
//import com.hw.common.core.web.controller.BaseController;
//import com.hw.common.core.web.domain.AjaxResult;
//import com.hw.common.log.annotation.Log;
//import com.hw.common.log.enums.BusinessType;
//import com.hw.common.security.annotation.RequiresPermissions;
//import com.aucma.dms.domain.DmsBaseDeviceType;
//import com.aucma.dms.service.IDmsBaseDeviceTypeService;

import com.aucma.common.core.controller.BaseController;
import com.aucma.common.core.domain.AjaxResult;
import com.aucma.common.utils.poi.ExcelUtil;
import com.aucma.dms.domain.DmsBaseDeviceType;
import com.aucma.dms.service.IDmsBaseDeviceTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

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

/**
 * 设备类型信息Controller
 *
 * @author xins
 * @date 2023-12-27
 */
@RestController
@RequestMapping("/dms/devicetype")
public class DmsBaseDeviceTypeController extends BaseController
{
    @Autowired
    private IDmsBaseDeviceTypeService dmsBaseDeviceTypeService;

    /**
     * 查询设备类型信息列表
     */
    //@PreAuthorize("@ss.hasPermi('dms:devicetype:list')" )
    @GetMapping("/list")
    public AjaxResult list(DmsBaseDeviceType dmsBaseDeviceType)
    {
        List<DmsBaseDeviceType> list = dmsBaseDeviceTypeService.selectDmsBaseDeviceTypeList(dmsBaseDeviceType);
        return success(list);
    }

    /**
     * 导出设备类型信息列表
     */
    //@PreAuthorize("@ss.hasPermi('dms:devicetype:export')" )
    //@Log(title = "设备类型信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DmsBaseDeviceType dmsBaseDeviceType)
    {
        List<DmsBaseDeviceType> list = dmsBaseDeviceTypeService.selectDmsBaseDeviceTypeList(dmsBaseDeviceType);
        ExcelUtil<DmsBaseDeviceType> util = new ExcelUtil<DmsBaseDeviceType>(DmsBaseDeviceType.class);
        util.exportExcel(response, list, "设备类型信息数据");
    }

    /**
     * 获取设备类型信息详细信息
     */
    //@PreAuthorize("@ss.hasPermi('dms:devicetype:query')" )
    @GetMapping(value = "/{deviceTypeId}")
    public AjaxResult getInfo(@PathVariable("deviceTypeId") Long deviceTypeId)
    {
        return success(dmsBaseDeviceTypeService.selectDmsBaseDeviceTypeByDeviceTypeId(deviceTypeId));
    }

    /**
     * 新增设备类型信息
     */
    //@PreAuthorize("@ss.hasPermi('dms:devicetype:add')" )
    //@Log(title = "设备类型信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DmsBaseDeviceType dmsBaseDeviceType)
    {
        return toAjax(dmsBaseDeviceTypeService.insertDmsBaseDeviceType(dmsBaseDeviceType));
    }

    /**
     * 修改设备类型信息
     */
    //@PreAuthorize("@ss.hasPermi('dms:devicetype:edit')" )
    //@Log(title = "设备类型信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DmsBaseDeviceType dmsBaseDeviceType)
    {
        return toAjax(dmsBaseDeviceTypeService.updateDmsBaseDeviceType(dmsBaseDeviceType));
    }

    /**
     * 删除设备类型信息
     */
    //@PreAuthorize("@ss.hasPermi('dms:devicetype:remove')" )
    //@Log(title = "设备类型信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{deviceTypeIds}")
    public AjaxResult remove(@PathVariable Long[] deviceTypeIds)
    {
        return toAjax(dmsBaseDeviceTypeService.deleteDmsBaseDeviceTypeByDeviceTypeIds(deviceTypeIds));
    }
    //@PreAuthorize("@ss.hasPermi('dms:devicetype:list')" )
    @GetMapping("/selectDevicetypeByDeviceId")
    public AjaxResult selectDevicetypeByDeviceId(Long deviceId)
    {
        List<DmsBaseDeviceType> list = dmsBaseDeviceTypeService.selectDevicetypeByDeviceId(deviceId);
        return success(list);
    }

}
