Commit bfcc6e65 by 李进峰

update

parent cd474350
......@@ -112,6 +112,34 @@ public class OkHttp3Utils {
return null;
}
public static String singleChat(String url, String requestJsonStr, Map<String, String> headers, String uid)
throws IOException {
log.info("#####->singleChat->url:{}, requestJsonStr:{}, uid:{}", url, requestJsonStr, uid);
Request.Builder builder = new Request.Builder();
Request request = builder.url(url).build();
HttpUrl.Builder urlBuild = request.url().newBuilder();
Headers.Builder headBuilder = request.headers().newBuilder();
Iterator<Map.Entry<String, String>> headIterator = headers.entrySet().iterator();
headIterator.forEachRemaining(e -> headBuilder.add(e.getKey(), e.getValue()));
urlBuild.addQueryParameter("uid", uid);
builder.url(urlBuild.build()).headers(headBuilder.build())
.post(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), requestJsonStr));
Response response = client.newCall(builder.build()).execute();
try (ResponseBody body = response.body()) {
return body.string();
} catch (SocketTimeoutException e) {
log.error("捕获到SocketTimeoutException:{}", e.toString());
client.dispatcher().cancelAll();
client.connectionPool().evictAll();
} catch (Exception e) {
log.error("doPostJsonStrForCentralWithUidParam error:" + e);
}
return null;
}
public static String doPostJsonStrForCentralWithUidParam(String url, String requestJsonStr, Map<String, String> headers,
String uid) throws IOException {
Request.Builder builder = new Request.Builder();
......
package ai.qiwu.com.xiaoduhome.controller;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import ai.qiwu.com.xiaoduhome.service.SingleBotService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@RestController
@RequestMapping("")
@Slf4j
@RequiredArgsConstructor(onConstructor_={@Autowired})
public class AudioSingleBotController {
private final StringRedisTemplate stringRedisTemplate;
@PostMapping("/xiaodu/single/bot")
public String xiaodu(HttpServletRequest request) {
String botAccount = request.getParameter("botAccount");
String serverCode = request.getParameter("serverCode");
if(StringUtils.isAnyBlank(botAccount, serverCode)) {
return "参数错误!";
}
try {
SingleBotService service = new SingleBotService(botAccount, serverCode, request, stringRedisTemplate);
service.enableVerify();
String str = service.run();
return str;
} catch (Exception e) {
log.info("AudioSingleBotController->xiaodu->e:{}", ExceptionUtils.getStackTrace(e));
}
return null;
}
}
......@@ -84,7 +84,7 @@ public class SpiritController {
@PostMapping(value = "/encryption") // 智能小说加密版
public ResultModel<TaskResult> story(@RequestBody String taskQuery) {
// log.info("天猫请求信息:{}",taskQuery);
log.info("天猫请求信息:{}",taskQuery);
TaskResult result;
try {
SecurityWrapperTaskQuery wrapperTaskQuery = MetaFormat.parseToWrapperQuery(taskQuery);
......@@ -100,7 +100,7 @@ public class SpiritController {
ResultModel<TaskResult> resultModel = new ResultModel<>();
resultModel.setReturnCode("0");
resultModel.setReturnValue(result);
// log.info("天猫响应信息:"+ JSON.toJSONString(resultModel));
log.info("天猫响应信息:"+ JSON.toJSONString(resultModel));
return resultModel;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment