package com.heyu.api.alibaba.handle.imageenhan;


import com.aliyun.teautil.models.RuntimeOptions;
import com.aliyun.viapi20230117.models.GetAsyncJobResultRequest;
import com.aliyun.viapi20230117.models.GetAsyncJobResultResponse;
import com.heyu.api.alibaba.AlibabaBaseHandle;
import com.heyu.api.alibaba.request.imageenhan.AGetAsyncJobResultRequest;
import com.heyu.api.data.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * https://next.api.aliyun.com/api/viapi/2023-01-17/GetAsyncJobResult?RegionId=cn-shanghai&tab=DOC&params={%22JobId%22:%22309CC798-49B8-500E-9F73-28C55478464F%22}&lang=JAVA
 *
 *
 * 查询异步任务结果 GetAsyncJobResult
 *
 */
@Component
@Slf4j
public class AGetAsyncJobResultHandle  extends AlibabaBaseHandle<AGetAsyncJobResultRequest, GetAsyncJobResultResponse> {


    @Autowired
    private  com.aliyun.viapi20230117.Client client;

    @Override
    public String check(AGetAsyncJobResultRequest p) {
        if(StringUtils.isEmpty(p.getJobId())){

            return "任务id不能为空";
        }
        return null;
    }

    @Override
    public GetAsyncJobResultResponse run(AGetAsyncJobResultRequest ap, RuntimeOptions runtime) throws Exception {
        GetAsyncJobResultRequest request = new GetAsyncJobResultRequest();
        request.setJobId(ap.getJobId());
        // 复制代码运行请自行打印 API 的返回值
        return client.getAsyncJobResultWithOptions(request, runtime);

    }
}
