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


import com.aliyun.facebody20191230.models.DetectCelebrityRequest;
import com.aliyun.facebody20191230.models.DetectCelebrityResponse;
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.facebody.ADetectCelebrityRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * https://next.api.aliyun.com/api/facebody/2019-12-30/DetectCelebrity?tab=DEMO&lang=JAVA
 * 明星识别
 */
@Component
@Slf4j
@CustomPath("detectCelebrity")
public class ADetectCelebrityHandle extends AlibabaBaseHandle<ADetectCelebrityRequest, DetectCelebrityResponse> {

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

    @Override
    public String check(ADetectCelebrityRequest aDetectCelebrityRequest) {
        return checkUrlBase64(aDetectCelebrityRequest);
    }

    @Override
    public DetectCelebrityResponse run(ADetectCelebrityRequest aDetectCelebrityRequest, RuntimeOptions runtime) throws Exception {
        DetectCelebrityRequest detectCelebrityRequest = new DetectCelebrityRequest();

        detectCelebrityRequest.setImageURL(aDetectCelebrityRequest.getImageUrl());
        // 复制代码运行请自行打印 API 的返回值
        return client.detectCelebrityWithOptions(detectCelebrityRequest, runtime);
    }
}
