package com.fastbee.data.controller.deviceModel;

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

import io.swagger.annotations.Api;
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.fastbee.common.annotation.Log;
import com.fastbee.common.core.controller.BaseController;
import com.fastbee.common.core.domain.AjaxResult;
import com.fastbee.common.enums.BusinessType;
import com.fastbee.deviceModel.domain.DeviceModel;
import com.fastbee.deviceModel.service.IDeviceModelService;
import com.fastbee.common.utils.poi.ExcelUtil;
import com.fastbee.common.core.page.TableDataInfo;

/**
 * 设备型号Controller
 *
 * @author kerwincui
 * @date 2024-12-17
 */
@RestController
@RequestMapping("/deviceModel/model")
@Api(tags = "设备型号")
public class DeviceModelController extends BaseController
{
    @Autowired
    private IDeviceModelService deviceModelService;

/**
 * 查询设备型号列表
 */
// @PreAuthorize("@ss.hasPermi('deviceModel:model:list')")
@GetMapping("/list")
@ApiOperation("查询设备型号列表")
    public TableDataInfo list(DeviceModel deviceModel)
    {
        startPage();
        List<DeviceModel> list = deviceModelService.selectDeviceModelList(deviceModel);
        return getDataTable(list);
    }

    /**
     * 导出设备型号列表
     */
    @ApiOperation("导出设备型号列表")
    // @PreAuthorize("@ss.hasPermi('deviceModel:model:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, DeviceModel deviceModel)
    {
        List<DeviceModel> list = deviceModelService.selectDeviceModelList(deviceModel);
        ExcelUtil<DeviceModel> util = new ExcelUtil<DeviceModel>(DeviceModel.class);
        util.exportExcel(response, list, "设备型号数据");
    }

    /**
     * 获取设备型号详细信息
     */
    // @PreAuthorize("@ss.hasPermi('deviceModel:model:query')")
    @GetMapping(value = "/{modelId}")
    @ApiOperation("获取设备型号详细信息")
    public AjaxResult getInfo(@PathVariable("modelId") Long modelId)
    {
        return success(deviceModelService.selectDeviceModelByModelId(modelId));
    }

    /**
     * 新增设备型号
     */
    @PreAuthorize("@ss.hasPermi('deviceModel:model:add')")
    @PostMapping
    @ApiOperation("新增设备型号")
    public AjaxResult add(@RequestBody DeviceModel deviceModel)
    {
        return toAjax(deviceModelService.insertDeviceModel(deviceModel));
    }

    /**
     * 修改设备型号
     */
    // @PreAuthorize("@ss.hasPermi('deviceModel:model:edit')")
    @PutMapping
    @ApiOperation("修改设备型号")
    public AjaxResult edit(@RequestBody DeviceModel deviceModel)
    {
        return toAjax(deviceModelService.updateDeviceModel(deviceModel));
    }

    /**
     * 删除设备型号
     */
    // @PreAuthorize("@ss.hasPermi('deviceModel:model:remove')")
    @DeleteMapping("/{modelIds}")
    @ApiOperation("删除设备型号")
    public AjaxResult remove(@PathVariable Long[] modelIds)
    {
        return toAjax(deviceModelService.deleteDeviceModelByModelIds(modelIds));
    }
}
