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


import com.aliyun.imageseg20191230.models.SegmentHairRequest;
import com.aliyun.imageseg20191230.models.SegmentHairResponse;
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.ASegmentHairRequest;
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/SegmentHair?tab=DEMO&lang=JAVA
 * <p>
 * <p>
 * 头发分割
 * <p>
 * SegmentHair
 */
@Component
@Slf4j
@CustomPath("segmentHair")
public class ASegmentHairHandle extends AlibabaBaseHandle<ASegmentHairRequest, SegmentHairResponse> {


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


    @Override
    public String check(ASegmentHairRequest aSegmentHairRequest) {
        return checkUrlBase64(aSegmentHairRequest);
    }

    @Override
    public SegmentHairResponse run(ASegmentHairRequest aSegmentHairRequest, RuntimeOptions runtime) throws Exception {
        SegmentHairRequest segmentHairRequest = new SegmentHairRequest();
        segmentHairRequest.setImageURL(aSegmentHairRequest.getImageUrl());
        // 复制代码运行请自行打印 API 的返回值
        return client.segmentHairWithOptions(segmentHairRequest, runtime);
    }
}
