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


import com.aliyun.imageenhan20190930.models.MakeSuperResolutionImageRequest;
import com.aliyun.imageenhan20190930.models.MakeSuperResolutionImageResponse;
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.AMakeSuperResolutionImageRequest;
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/ImageBlindPicWatermark?tab=DOC&lang=JAVA
 * <p>
 * 图像隐形图片水印
 * <p>
 * ImageBlindPicWatermark
 */
@Component
@Slf4j
@CustomPath("makeSuperResolutionImage")
public class AMakeSuperResolutionImageHandle extends AlibabaBaseHandle<AMakeSuperResolutionImageRequest, MakeSuperResolutionImageResponse> {

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


    @Override
    public String check(AMakeSuperResolutionImageRequest aMakeSuperResolutionImageRequest) {
        return checkUrlBase64(aMakeSuperResolutionImageRequest);
    }


    @Override
    public MakeSuperResolutionImageResponse run(AMakeSuperResolutionImageRequest aMakeSuperResolutionImageRequest, RuntimeOptions runtime) throws Exception {
        MakeSuperResolutionImageRequest makeSuperResolutionImageRequest = new MakeSuperResolutionImageRequest();
        makeSuperResolutionImageRequest.setUrl(aMakeSuperResolutionImageRequest.getImageUrl());
        makeSuperResolutionImageRequest.setMode(aMakeSuperResolutionImageRequest.getMode());
        makeSuperResolutionImageRequest.setOutputFormat(aMakeSuperResolutionImageRequest.getOutputFormat());
        makeSuperResolutionImageRequest.setOutputQuality(aMakeSuperResolutionImageRequest.getOutputQuality());
        makeSuperResolutionImageRequest.setUpscaleFactor(aMakeSuperResolutionImageRequest.getUpscaleFactor());
        // 复制代码运行请自行打印 API 的返回值
        return client.makeSuperResolutionImageWithOptions(makeSuperResolutionImageRequest, runtime);
    }


}
