跳至主要內容

Java SDK

小于 1 分钟

Java SDK

注意

Java SDK正在开发中,后续版本可能会更改API。欢迎贡献代码:https://github.com/gorse-io/gorse4jopen in new window

open in new windowMaven Central

安装

<dependency>
    <groupId>io.gorse</groupId>
    <artifactId>gorse-client</artifactId>
    <version>0.4.0</version>
</dependency>

用法

import io.gorse.gorse4j.*;

public class Main {

    public static void main(String[] args) {
        // Create a client.
        Gorse client = new Gorse("http://127.0.0.1:8087", "api_key");

        // Insert feedback.
        List<Feedback> feedbacks = List.of(
                new Feedback("read", "100", "300", "2022-11-20T13:55:27Z"),
                new Feedback("read", "100", "400", "2022-11-20T13:55:27Z")
        );
        client.insertFeedback(feedbacks);

        // Get recommendation.
        client.getRecommend("100");
    }
}