package com.cmvr.web.controller.device;

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

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.common.utils.poi.ExcelUtil;
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.cmvr.device.domain.DeRobotConfig;
import com.cmvr.device.service.IDeRobotConfigService;

import static com.cmvr.common.core.domain.AjaxResult.success;

/**
 * 机器人配置Controller
 * 
 * @author cmvr-iot
 * @date 2025-09-09
 */
@RestController
@RequestMapping("/device/robot")
public class DeRobotConfigController extends BaseController
{
    @Autowired
    private IDeRobotConfigService deRobotConfigService;

    /**
     * 查询机器人配置列表
     */
    @PreAuthorize("@ss.hasPermi('device:robot:list')")
    @GetMapping("/list")
    public AjaxResult list(DeRobotConfig deRobotConfig)
    {
        List<DeRobotConfig> list = deRobotConfigService.selectDeRobotConfigList(deRobotConfig);
        return success(list);
    }

    /**
     * 导出机器人配置列表
     */
    @PreAuthorize("@ss.hasPermi('device:robot:export')")
    @Log(title = "机器人配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DeRobotConfig deRobotConfig)
    {
        List<DeRobotConfig> list = deRobotConfigService.selectDeRobotConfigList(deRobotConfig);
        ExcelUtil<DeRobotConfig> util = new ExcelUtil<DeRobotConfig>(DeRobotConfig.class);
        util.exportExcel(response, list, "机器人配置数据");
    }

    /**
     * 获取机器人配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('device:robot:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(deRobotConfigService.selectDeRobotConfigById(id));
    }

    /**
     * 新增机器人配置
     */
    @PreAuthorize("@ss.hasPermi('device:robot:add')")
    @Log(title = "机器人配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DeRobotConfig deRobotConfig)
    {
        return toAjax(deRobotConfigService.insertDeRobotConfig(deRobotConfig));
    }

    /**
     * 修改机器人配置
     */
    @PreAuthorize("@ss.hasPermi('device:robot:edit')")
    @Log(title = "机器人配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DeRobotConfig deRobotConfig)
    {
        return toAjax(deRobotConfigService.updateDeRobotConfig(deRobotConfig));
    }

    /**
     * 删除机器人配置
     */
    @PreAuthorize("@ss.hasPermi('device:robot:remove')")
    @Log(title = "机器人配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(deRobotConfigService.deleteDeRobotConfigByIds(ids));
    }
}
