package com.cmvr.web.controller.device;

import java.util.List;

import com.cmvr.device.domain.vo.ProfileVo;
import com.cmvr.device.domain.vo.TeMechanicalArmVo;
import com.cmvr.edge.client.service.EdgeSystemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import com.cmvr.common.annotation.Log;
import com.cmvr.common.core.controller.BaseController;
import com.cmvr.common.core.domain.AjaxResult;
import com.cmvr.common.enums.BusinessType;
import com.cmvr.device.domain.DeDeviceProfile;
import com.cmvr.device.service.IDeDeviceProfileService;
import com.cmvr.common.core.page.TableDataInfo;

/**
 * 设备配置信息Controller
 * 
 * @author cmvr-iot
 * @date 2025-05-09
 */
@RestController
@RequestMapping("/device/profile")
@RequiredArgsConstructor
@Api(tags = "设备--配置信息")
public class DeDeviceProfileController extends BaseController
{

    private final IDeDeviceProfileService deDeviceProfileService;

    private final EdgeSystemService systemService;

    /**
     * 查询设备配置信息列表
     */
    @PreAuthorize("@ss.hasPermi('device:profile:list')")
    @GetMapping("/list")
    @ApiOperation("查询设备信息列表")
    public TableDataInfo list(DeDeviceProfile deDeviceProfile)
    {
        startPage();
        List<ProfileVo> list = deDeviceProfileService.selectDeDeviceProfileList(deDeviceProfile);
        return getDataTable(list);
    }


    /**
     * 根据设备id获取设备详细配置信息
     */
    @PreAuthorize("@ss.hasPermi('device:profile:query')")
    @GetMapping("/{id}")
    @ApiOperation("根据设备id获取当前设备配置信息")
    public AjaxResult getInfo(@PathVariable String id)
    {
        return success(deDeviceProfileService.selectDeDeviceProfileById(id));
    }

    /**
     * 根据设备id和备注获取设备详细配置信息
     */
    @PreAuthorize("@ss.hasPermi('device:profile:query')")
    @GetMapping("/parameterInfo")
    @ApiOperation("根据设备id获取当前设备配置信息")
    public AjaxResult getParameterInfo(@RequestParam String id, @RequestParam String remark)
    {
        return success(deDeviceProfileService.selectProfileByIdAndRemark(id,remark));
    }

    /**
     * 新增设备配置信息
     */
    @PreAuthorize("@ss.hasPermi('device:profile:add')")
    @Log(title = "设备配置信息", businessType = BusinessType.INSERT)
    @ApiOperation("新增设备信息")
    @PostMapping
    public AjaxResult add(@RequestBody List<DeDeviceProfile> deDeviceProfiles)
    {

        return toAjax(deDeviceProfileService.insertDeDeviceProfile(deDeviceProfiles));
    }

    /**
     * 修改设备配置信息
     */
    @PreAuthorize("@ss.hasPermi('device:profile:edit')")
    @Log(title = "设备配置信息", businessType = BusinessType.UPDATE)
    @ApiOperation("修改设备信息")
    @PutMapping
    public AjaxResult edit(@RequestBody List<DeDeviceProfile> deDeviceProfiles)
    {
        return toAjax(deDeviceProfileService.updateDeDeviceProfile(deDeviceProfiles));
    }

    /**
     * 删除设备配置信息
     */
    @PreAuthorize("@ss.hasPermi('device:profile:remove')")
    @Log(title = "设备配置信息", businessType = BusinessType.DELETE)
    @ApiOperation("删除设备配置信息")
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(deDeviceProfileService.deleteDeDeviceProfileByIds(ids));
    }





}
