mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-14 13:47:09 +00:00
(improvement)(chat) add chat plugin webservice demo (#1317)
Co-authored-by: lxwcodemonkey
This commit is contained in:
@@ -75,7 +75,7 @@ public abstract class PluginSemanticQuery {
|
||||
webBaseResult.setUrl(webPage.getUrl());
|
||||
Map<String, Object> elementValueMap = getElementMap(pluginParseResult);
|
||||
List<ParamOption> paramOptions = Lists.newArrayList();
|
||||
if (!CollectionUtils.isEmpty(webPage.getParamOptions()) && !CollectionUtils.isEmpty(elementValueMap)) {
|
||||
if (!CollectionUtils.isEmpty(webPage.getParamOptions())) {
|
||||
for (ParamOption paramOption : webPage.getParamOptions()) {
|
||||
if (paramOption.getDataSetId() != null
|
||||
&& !parseInfo.getDataSetId().equals(paramOption.getDataSetId())) {
|
||||
|
||||
@@ -61,7 +61,7 @@ public class WebServiceQuery extends PluginSemanticQuery {
|
||||
if (data.get("columns") != null) {
|
||||
queryResult.setQueryColumns((List<QueryColumn>) data.get("columns"));
|
||||
}
|
||||
queryResult.setTextResult(String.valueOf(data.get("textInfo")));
|
||||
queryResult.setTextResult(String.valueOf(data.get("data")));
|
||||
queryResult.setQueryState(QueryState.SUCCESS);
|
||||
} catch (Exception e) {
|
||||
log.info("webServiceResponse result has an exception:{}", e.getMessage());
|
||||
@@ -80,7 +80,8 @@ public class WebServiceQuery extends PluginSemanticQuery {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
HttpEntity<String> entity = new HttpEntity<>(JSON.toJSONString(params), headers);
|
||||
URI requestUrl = UriComponentsBuilder.fromHttpUrl(webBase.getUrl()).build().encode().toUri();
|
||||
String url = webBase.getUrl() + "?queryText=" + pluginParseResult.getQueryText();
|
||||
URI requestUrl = UriComponentsBuilder.fromHttpUrl(url).build().encode().toUri();
|
||||
ResponseEntity responseEntity = null;
|
||||
Object objectResponse = null;
|
||||
restTemplate = ContextUtils.getBean(RestTemplate.class);
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
package com.tencent.supersonic.chat.server.rest;
|
||||
|
||||
import com.tencent.supersonic.auth.api.authentication.annotation.AuthenticationIgnore;
|
||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||
import com.tencent.supersonic.auth.api.authentication.utils.UserHolder;
|
||||
import com.tencent.supersonic.chat.api.pojo.request.PluginQueryReq;
|
||||
import com.tencent.supersonic.chat.server.plugin.ChatPlugin;
|
||||
import com.tencent.supersonic.chat.server.service.PluginService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
@@ -61,4 +64,11 @@ public class PluginController {
|
||||
return pluginService.queryWithAuthCheck(pluginQueryReq, user);
|
||||
}
|
||||
|
||||
@AuthenticationIgnore
|
||||
@PostMapping("/pluginDemo")
|
||||
public String pluginDemo(@RequestParam("queryText") String queryText,
|
||||
@RequestBody Object object) {
|
||||
return String.format("已收到您的问题:%s, 但这只是一个demo~", queryText);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user