package com.hdkj.lt.si.controller.recon;


import com.hdkj.hussar.ApiResponse;
import com.hdkj.lt.core.mvc.BaseController;
import com.hdkj.lt.modle.vo.recon.ReconSaveResultVO;
import com.hdkj.lt.modle.vo.recon.ReconstructionParam;
import com.hdkj.lt.si.service.recon.ReconResultService;
import lombok.RequiredArgsConstructor;
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;

/**
 * @author liuaini
 * 重构结果入库接口.
 * 接收算法服务响应 (含 raw_result), 取 raw_result 入库.
 */
@RestController
@RequestMapping("/recon")
@RequiredArgsConstructor
public class ReconResultController extends BaseController {

    private final ReconResultService reconResultService;

    @PostMapping("/trigger")
    public ApiResponse<ReconSaveResultVO> triggerReconfiguration(@RequestBody ReconstructionParam param) {
        try {
            return data(reconResultService.saveReconResult(param.getEventId(),param.getParams()));
        } catch (Exception e) {
            e.printStackTrace();
            return fail("重构数据处理失败: " + e.getMessage());
        }
    }
}