package com.ruoyi.business.controller;

import com.ruoyi.business.domain.HwDeviceModeFunction;
import com.ruoyi.business.service.IHwDeviceModeService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 设备模型功能Controller
 *
 * @author xins
 * @date 2023-09-05
 */
@RestController
@RequestMapping("/deviceModeFunction")
public class HwDeviceModeFunctionController extends BaseController {
    @Autowired
    private IHwDeviceModeService hwDeviceModeService;

    /**
     * 新增设备模型功能
     */
    @RequiresPermissions("business:deviceModeFunction:add")
    @Log(title = "设备模型功能", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HwDeviceModeFunction hwDeviceModeFunction) {
        return success(hwDeviceModeService.insertHwDeviceModeFunction(hwDeviceModeFunction));
    }

    /**
     * 修改设备模型功能
     */
    @RequiresPermissions("business:deviceModeFunction:edit")
    @Log(title = "设备模型功能", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HwDeviceModeFunction hwDeviceModeFunction) {
        return toAjax(hwDeviceModeService.updateHwDeviceModeFunction(hwDeviceModeFunction));
    }

    /**
     * 删除设备模型功能
     */
    @RequiresPermissions("business:deviceModeFunction:remove")
    @Log(title = "设备模型功能", businessType = BusinessType.DELETE)
    @DeleteMapping("/{modeFunctionId}")
    public AjaxResult remove(@PathVariable Long modeFunctionId) {
        return toAjax(hwDeviceModeService.deleteHwDeviceModeFunctionByModeFunctionId(modeFunctionId));
    }

    @GetMapping("/getDeviceModeParameters/{modeFunctionId}")
    public AjaxResult getDeviceModeParameters(@PathVariable("modeFunctionId") Long modeFunctionId) {
        return success(hwDeviceModeService.selectDeviceModeParametersByModeFunctionId(modeFunctionId));
    }
}
