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

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yfd.platform.config.ResponseResult;
import com.yfd.platform.modules.algorithm.domain.AlgorithmClassComponent;
import com.yfd.platform.modules.algorithm.domain.AlgorithmDevice;
import com.yfd.platform.modules.algorithm.service.IAlgorithmClassComponentService;
import com.yfd.platform.modules.auxcontrol.domain.DeviceSignal;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

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

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

    @Resource
    private IAlgorithmClassComponentService algorithmClassComponentService;

    @GetMapping("/getAlgorithmClassComponentPage")
    @ApiOperation("算法关联主设备部件")
    public ResponseResult getAlgorithmClassComponentPage(String algorithmId,String stationCode, Page<AlgorithmClassComponent> page) {
        Page<AlgorithmClassComponent> algorithmClassComponentPage =
                algorithmClassComponentService.getAlgorithmClassComponentPage(algorithmId,stationCode, page);
        return ResponseResult.successData(algorithmClassComponentPage);
    }

    @PostMapping("/deleteAlgorithmClassComponent")
    @ApiOperation("删除算法关联主设备部件")
    public ResponseResult deleteAlgorithmClassComponent(String id) {
        boolean isOK = algorithmClassComponentService.deleteAlgorithmClassComponent(id);
        if (isOK) {
            return ResponseResult.success();
        } else {
            return ResponseResult.error();
        }
    }

    @PostMapping("/batchAddAlgorithmClassComponent")
    @ApiOperation("批量新增算法关联主设备部件")
    public ResponseResult batchAddAlgorithmClassComponent(@RequestBody List<AlgorithmClassComponent> algorithmClassComponentList) {
        boolean isOK = algorithmClassComponentService.batchAddAlgorithmClassComponent(algorithmClassComponentList);
        if (isOK) {
            return ResponseResult.success();
        } else {
            return ResponseResult.error();
        }
    }
}
