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


import com.aliyun.imagerecog20190930.models.TaggingImageRequest;
import com.aliyun.imagerecog20190930.models.TaggingImageResponse;
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.imagerecog.ATaggingImageRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * https://next.api.aliyun.com/api/imagerecog/2019-09-30/TaggingImage?tab=DEMO&lang=JAVA
 * <p>
 * 通用图像打标 TaggingImage
 */
@Component
@Slf4j
@CustomPath("taggingImage")
public class ATaggingImageHandle extends AlibabaBaseHandle<ATaggingImageRequest, TaggingImageResponse> {

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


    @Override
    public String check(ATaggingImageRequest aTaggingImageRequest) {
        return checkUrlBase64(aTaggingImageRequest);
    }

    @Override
    public TaggingImageResponse run(ATaggingImageRequest aTaggingImageRequest, RuntimeOptions runtime) throws Exception {
        TaggingImageRequest taggingAdImageRequest = new TaggingImageRequest();
        taggingAdImageRequest.setImageURL(aTaggingImageRequest.getImageUrl());
        // 复制代码运行请自行打印 API 的返回值
        return client.taggingImageWithOptions(taggingAdImageRequest, runtime);
    }
}
