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

import com.aliyun.objectdet20191230.models.DetectMainBodyRequest;
import com.aliyun.objectdet20191230.models.DetectMainBodyResponse;
import com.aliyun.teautil.models.RuntimeOptions;
import com.heyu.api.data.annotation.CustomPath;
import com.heyu.api.alibaba.AlibabaBaseHandle;
import com.heyu.api.alibaba.request.objectdet.ADetectMainBodyRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


/**
 * https://next.api.aliyun.com/api/objectdet/2019-12-30/DetectMainBody?tab=DEMO&lang=JAVA
 * <p>
 * 主体检测
 * <p>
 * DetectMainBody
 */

@Component
@Slf4j
@CustomPath("detectMainBody")
public class ADetectMainBodyHandle extends AlibabaBaseHandle<ADetectMainBodyRequest, DetectMainBodyResponse> {

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

    @Override
    public String check(ADetectMainBodyRequest aDetectMainBodyRequest) {

        return checkUrlBase64(aDetectMainBodyRequest);
    }



    @Override
    public DetectMainBodyResponse run(ADetectMainBodyRequest aDetectMainBodyRequest, RuntimeOptions runtime) throws Exception {

        DetectMainBodyRequest detectMainBodyRequest = new DetectMainBodyRequest();
        detectMainBodyRequest.setImageURL(aDetectMainBodyRequest.getImageUrl());

        // 复制代码运行请自行打印 API 的返回值
        return client.detectMainBodyWithOptions(detectMainBodyRequest, runtime);
    }
}
