package shop.alien.store.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import shop.alien.entity.result.R;
import shop.alien.store.service.StoreCommentAppealSupplementJobService;

/**
 * 评论申诉-用户补充定时任务回调（供 alien-job 通过 Feign 调用）
 */
@Slf4j
@Api(tags = {"评论申诉用户补充定时任务"})
@RestController
@RequestMapping("/storeCommentAppealSupplement/job")
@RequiredArgsConstructor
public class StoreCommentAppealSupplementJobController {

    private final StoreCommentAppealSupplementJobService supplementJobService;

    @ApiOperation("提交待处理申诉至 AI 分析（getStoreCommentAppealSupplementAppealJob）")
    @PostMapping("/submitAppealAnalyze")
    public R<String> submitAppealAnalyze() {
        log.info("storeCommentAppealSupplement job: submitAppealAnalyze 开始");
        R<String> result = supplementJobService.submitAppealAnalyze();
        log.info("storeCommentAppealSupplement job: submitAppealAnalyze 结束");
        return result;
    }

    @ApiOperation("轮询 AI 分析完成结果（getStoreCommentAppealSupplementCompletedResult）")
    @PostMapping("/pollCompletedResult")
    public R<String> pollCompletedResult() {
        log.info("storeCommentAppealSupplement job: pollCompletedResult 开始");
        R<String> result = supplementJobService.pollCompletedResult();
        log.info("storeCommentAppealSupplement job: pollCompletedResult 结束");
        return result;
    }
}
