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


import com.aliyun.imageenhan20190930.models.GenerateSuperResolutionImageRequest;
import com.aliyun.imageenhan20190930.models.GenerateSuperResolutionImageResponse;
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.imageenhan.AGenerateSuperResolutionImageRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * https://next.api.aliyun.com/api/imageenhan/2019-09-30/GenerateSuperResolutionImage?tab=DOC&lang=JAVA
 * <p>
 * 生成式图像超分
 * <p>
 * GenerateSuperResolutionImage
 */
@Component
@Slf4j
@CustomPath("generateSuperResolutionImage")
public class AGenerateSuperResolutionImageHandle extends AlibabaBaseHandle<AGenerateSuperResolutionImageRequest, GenerateSuperResolutionImageResponse> {

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


    @Override
    public String check(AGenerateSuperResolutionImageRequest aGenerateSuperResolutionImageRequest) {
        return checkUrlBase64(aGenerateSuperResolutionImageRequest);
    }



    @Override
    public GenerateSuperResolutionImageResponse run(AGenerateSuperResolutionImageRequest aGenerateSuperResolutionImageRequest, RuntimeOptions runtime) throws Exception {

        GenerateSuperResolutionImageRequest generateSuperResolutionImageRequest = new GenerateSuperResolutionImageRequest();
        generateSuperResolutionImageRequest.setImageUrl(aGenerateSuperResolutionImageRequest.getImageUrl());
        generateSuperResolutionImageRequest.setOutputFormat(aGenerateSuperResolutionImageRequest.getOutputFormat());
        generateSuperResolutionImageRequest.setScale(aGenerateSuperResolutionImageRequest.getScale());
        generateSuperResolutionImageRequest.setOutputQuality(aGenerateSuperResolutionImageRequest.getOutputQuality());

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