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


import com.aliyun.imageseg20191230.models.SegmentHDCommonImageRequest;
import com.aliyun.imageseg20191230.models.SegmentHDCommonImageResponse;
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.imageseg.ASegmentHDCommonImageRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * https://next.api.aliyun.com/api/imageseg/2019-12-30/SegmentCommodity
 * <p>
 * <p>
 * 商品分割
 * <p>
 * SegmentCommodity
 */

@Component
@Slf4j
@CustomPath("segmentHDCommonImage")
public class ASegmentHDCommonImageHandle extends AlibabaBaseHandle<ASegmentHDCommonImageRequest, SegmentHDCommonImageResponse> {

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

    @Override
    public String check(ASegmentHDCommonImageRequest aSegmentHDCommonImageRequest) {
        return checkUrlBase64(aSegmentHDCommonImageRequest);
    }


    @Override
    public SegmentHDCommonImageResponse run(ASegmentHDCommonImageRequest aSegmentHDCommonImageRequest, RuntimeOptions runtime) throws Exception {
        SegmentHDCommonImageRequest segmentHDCommonImageRequest = new SegmentHDCommonImageRequest();
        segmentHDCommonImageRequest.setImageUrl(aSegmentHDCommonImageRequest.getImageUrl());
        // 复制代码运行请自行打印 API 的返回值
        return client.segmentHDCommonImageWithOptions(segmentHDCommonImageRequest, runtime);
    }
}
