package com.yfd.platform.modules.algorithm.controller;

import com.yfd.platform.config.ResponseResult;
import com.yfd.platform.modules.algorithm.domain.AlgorithmClass;
import com.yfd.platform.modules.algorithm.domain.AlgorithmDevice;
import com.yfd.platform.modules.algorithm.service.IAlgorithmDeviceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *   算法分类部件点位关联
 *  前端控制器
 * </p>
 *
 * @author zhengsl
 * @since 2025-05-13
 */
@RestController
@RequestMapping("/algorithm/algorithm-device")
@Api(value = "AlgorithmDeviceController", tags = "算法分类部件点位关联")
public class AlgorithmDeviceController {

    @Resource
    private IAlgorithmDeviceService algorithmDeviceService;

    @PostMapping("/batchAddAlgorithmDevice")
    @ApiOperation("批量新增算法分类部件点位关联数据")
    public ResponseResult batchAddAlgorithmDevice(@RequestBody List<AlgorithmDevice> algorithmDeviceList) {
        boolean isOK = algorithmDeviceService.batchAddAlgorithmDevice(algorithmDeviceList);
        if (isOK) {
            return ResponseResult.success();
        } else {
            return ResponseResult.error();
        }
    }

    @PostMapping("/getAlgorithmDeviceParams")
    @ApiOperation("查询算法部件的参数")
    public ResponseResult getAlgorithmDeviceParams(String algorithmId, String componentId) {
        List<Map<String, Object>> algorithmDeviceParams = algorithmDeviceService.getAlgorithmDeviceParams(algorithmId
                , componentId);
        return ResponseResult.successData(algorithmDeviceParams);
    }

    @PostMapping("/getAlgorithmDeviceCurve")
    @ApiOperation("查询算法部件的参数曲线")
    public ResponseResult getAlgorithmDeviceCurve(String algorithmId, String componentId) {
        List<Map<String, Object>> algorithmDeviceCurveList = algorithmDeviceService.getAlgorithmDeviceCurve(algorithmId,
                componentId);
        return ResponseResult.successData(algorithmDeviceCurveList);
    }
}
