package cn.stylefeng.team.project.modular.filing.controller;

import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import cn.stylefeng.team.project.modular.filing.pojo.aidesign.aiparse.StopAiParseRequest;
import cn.stylefeng.team.project.modular.filing.pojo.aidesign.convertpng.ParseExcelResponse;
import cn.stylefeng.team.project.modular.filing.service.AIDesignService;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@ApiResource(name = "AI进行业务设计的接口")
public class AiDesignController {

    @Resource
    private AIDesignService aiDesignService;

    @PostResource(name = "将上传的Excel解析为图片", path = "/aiBusinessDesign/parseExcelToPng")
    public ResponseData<ParseExcelResponse> parseExcelToPng(@RequestPart("file") MultipartFile file) {
        ParseExcelResponse result = aiDesignService.parseExcelToPng(file);
        return new SuccessResponseData<>(result);
    }

    @PostResource(name = "停止AI分析", path = "/aiBusinessDesign/stopAiParse")
    public ResponseData<?> stopAiParse(@RequestBody @Validated StopAiParseRequest stopAiParseRequest) {
        aiDesignService.stopAiParse(stopAiParseRequest);
        return new SuccessResponseData<>();
    }

}
