package shop.alien.job.second;

import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import shop.alien.entity.result.R;
import shop.alien.job.feign.SecondGoodsFeign;

/**
 * 商品审核定时任务
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class goodsCheckJob {

    private final SecondGoodsFeign secondGoodsFeign;

    /**
     * 获取AI商品审核结果
     * 通过Feign调用alien-second服务处理AI审核结果
     */
    @XxlJob("getAiGoodsCheckResult")
    public R<String> getAiGoodsCheckResult() {
        log.info("开始执行AI商品审核结果获取任务");
        try {
            R<String> result = secondGoodsFeign.getAiGoodsCheckResult();
            log.info("AI商品审核结果获取任务执行完成: {}", result.getData());
            return result;
        } catch (Exception e) {
            log.error("AI商品审核结果获取任务执行异常", e);
            return R.fail("任务执行异常: " + e.getMessage());
        }
    }
}
