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


import com.aliyun.facebody20191230.models.RecognizeFaceRequest;
import com.aliyun.facebody20191230.models.RecognizeFaceResponse;
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.ARecognizeFaceRequest;
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/RecognizeFace
 * 人脸属性识别
 */
@Component
@Slf4j
@CustomPath("faceProperty")
public class ARecognizeFaceHandle extends AlibabaBaseHandle<ARecognizeFaceRequest, RecognizeFaceResponse> {


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

    @Override
    public String check(ARecognizeFaceRequest aRecognizeFaceRequest) {
        return checkUrlBase64(aRecognizeFaceRequest);
    }



    @Override
    public RecognizeFaceResponse run(ARecognizeFaceRequest aRecognizeFaceRequest, RuntimeOptions runtime) throws Exception {
        RecognizeFaceRequest recognizeFaceRequest = new RecognizeFaceRequest();
        recognizeFaceRequest.setImageURL(aRecognizeFaceRequest.getImageUrl());
        // 复制代码运行请自行打印 API 的返回值
        return client.recognizeFaceWithOptions(recognizeFaceRequest, runtime);
    }
}
