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

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yfd.platform.config.ResponseResult;
import com.yfd.platform.modules.algorithm.domain.AlgorithmLogs;
import com.yfd.platform.modules.algorithm.service.IAlgorithmLogsService;
import com.yfd.platform.utils.wrapper.QueryCondition;
import com.yfd.platform.utils.wrapper.QueryWrapperBuilder;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

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

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhengsl
 * @since 2025-05-20
 */
@RestController
@RequestMapping("/algorithm/algorithm-logs")
@Api(value = "AlgorithmLogsController", tags = "算法分析日志")
public class AlgorithmLogsController {

    @Resource
    private IAlgorithmLogsService algorithmLogsService;

    // 算法分类，区域，间隔，部件
    @GetMapping("/getAlgorithmLogsPage")
    @ApiOperation("分页查询算法分析日志")
    public ResponseResult getAlgorithmLogsPage(String stationCode, String algorithmId, String areaId, String bayId,
                                               String mainDeviceId, String componentId, String componentName,
                                               Page<AlgorithmLogs> page) {
        Page<Map<String, Object>> pageMaps = algorithmLogsService.getAlgorithmLogsPage(stationCode, algorithmId, areaId,
                bayId, mainDeviceId, componentId, componentName, page);
        return ResponseResult.successData(pageMaps);
    }

    // 算法分类，区域，间隔，部件
    @PostMapping("/testQueryWrapperBuilder")
    @ApiOperation("测试构造器")
    public ResponseResult testQueryWrapperBuilder(@RequestBody QueryCondition queryCondition) {
        Page<AlgorithmLogs> page = new Page<>();
        page.setSize(queryCondition.getSize());
        page.setCurrent(queryCondition.getCurrent());
        QueryWrapper<AlgorithmLogs> queryWrapper = QueryWrapperBuilder.build(queryCondition, AlgorithmLogs.class);
        Page<AlgorithmLogs> algorithmLogsPage = algorithmLogsService.page(page, queryWrapper);
        return ResponseResult.successData(algorithmLogsPage);
    }

}
