package shop.alien.job.jobhandler;

import com.xxl.job.core.biz.model.ReturnT;
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;

/**
 * 视频审核任务XXL-JOB处理器
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class VideoModerationJobHandler {

    /**
     * 二级商品服务Feign客户端
     */
    private final SecondGoodsFeign secondGoodsFeign;
    
    /**
     * 视频审核结果拉取任务
     * 通过Feign调用alien-second服务处理视频审核结果
     */
    @XxlJob("videoModerationResultJobHandler")
    public ReturnT<String> videoModerationResultJobHandler(String param) {
        try {
            log.info("开始执行视频审核结果拉取任务");
            R<String> result = secondGoodsFeign.processVideoModerationResult();
            log.info("视频审核结果拉取任务执行完成: {}", result.getData());
            return ReturnT.SUCCESS;
        } catch (Exception e) {
            log.error("执行视频审核结果拉取任务时发生异常", e);
            return ReturnT.FAIL;
        }
    }
}
