Merge remote-tracking branch 'origin/feature/dify' into feature/dify
This commit is contained in:
commit
c586a2239e
7
pom.xml
7
pom.xml
@ -221,6 +221,13 @@
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>io.fabric8</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
|
@ -0,0 +1,63 @@
|
||||
package com.zsc.edu.dify.modules.dify.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.zsc.edu.dify.modules.dify.dto.SpiderDto;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/spider")
|
||||
public class SpiderController {
|
||||
|
||||
@Resource
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
private static final String SPIDER_URL = "http://47.112.173.8:6806/api/v1";
|
||||
private static final String API_KEY = "77c068fd-d5b6-4c33-97d8-db5511a09b26";
|
||||
|
||||
@PostMapping("/run")
|
||||
public JSONObject run(@RequestBody SpiderDto dto) throws JsonProcessingException {
|
||||
dto.setLlm_api_key(API_KEY);
|
||||
String body = objectMapper.writeValueAsString(dto);
|
||||
return WebClient.create(SPIDER_URL).post().uri("/start_crawl")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.bodyValue(body)
|
||||
.retrieve()
|
||||
.bodyToMono(JSONObject.class)
|
||||
.block();
|
||||
}
|
||||
|
||||
@PostMapping("/status")
|
||||
public JSONObject status() {
|
||||
return WebClient.create(SPIDER_URL).post().uri("/crawl_status")
|
||||
.retrieve()
|
||||
.bodyToMono(JSONObject.class)
|
||||
.block();
|
||||
}
|
||||
|
||||
@PostMapping("/logs")
|
||||
public JSONObject logs() {
|
||||
return WebClient.create(SPIDER_URL).post().uri("/logs")
|
||||
.retrieve()
|
||||
.bodyToMono(JSONObject.class)
|
||||
.block();
|
||||
}
|
||||
|
||||
@PostMapping("/stop")
|
||||
public JSONObject stop() {
|
||||
return WebClient.create(SPIDER_URL).post().uri("/stop_crawl")
|
||||
.retrieve()
|
||||
.bodyToMono(JSONObject.class)
|
||||
.block();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.zsc.edu.dify.modules.dify.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SpiderDto {
|
||||
@NotBlank
|
||||
private String publish_start_time;
|
||||
@NotBlank
|
||||
private String publish_end_time;
|
||||
private String keyword;
|
||||
private Integer[] site_codes;
|
||||
private String llm_api_key;
|
||||
}
|
Loading…
Reference in New Issue
Block a user