package edu.whut.smilepicturebackend.api.imagesearch;
import edu.whut.smilepicturebackend.api.imagesearch.model.ImageSearchResult;
import edu.whut.smilepicturebackend.api.imagesearch.sub.GetImageFirstUrlApi;
import edu.whut.smilepicturebackend.api.imagesearch.sub.GetImageListApi;
import edu.whut.smilepicturebackend.api.imagesearch.sub.GetImagePageUrlApi;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

@Slf4j
public class ImageSearchApiFacade {

    /**
     * 搜索图片
     * @param localImagePath
     * @return
     */
    public static List<ImageSearchResult> searchImage(String localImagePath) {
        String imagePageUrl = GetImagePageUrlApi.getImagePageUrl(localImagePath);
        String imageFirstUrl = GetImageFirstUrlApi.getImageFirstUrl(imagePageUrl);
        List<ImageSearchResult> imageList = GetImageListApi.getImageList(imageFirstUrl);
        return imageList;
    }

    public static void main(String[] args) {
        List<ImageSearchResult> imageList = searchImage("https://www.codefather.cn/logo.png");
        System.out.println("结果列表" + imageList);
    }
}
