|
@@ -7,19 +7,23 @@ import com.github.benmanes.caffeine.cache.Caffeine;
|
|
|
import com.sxtvs.api.youmei.dto.CheckWordResponse;
|
|
|
import com.sxtvs.api.youmei.entity.YoumeiAccount;
|
|
|
import com.sxtvs.api.youmei.mapper.YoumeiAccountMapper;
|
|
|
+import com.sxtvs.core.sls.AliyunLogger;
|
|
|
import lombok.Cleanup;
|
|
|
import lombok.SneakyThrows;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.hc.client5.http.classic.methods.HttpPost;
|
|
|
import org.apache.hc.client5.http.entity.UrlEncodedFormEntity;
|
|
|
+import org.apache.hc.client5.http.fluent.Content;
|
|
|
import org.apache.hc.client5.http.fluent.ContentResponseHandler;
|
|
|
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
|
|
|
import org.apache.hc.client5.http.impl.classic.HttpClients;
|
|
|
import org.apache.hc.core5.http.NameValuePair;
|
|
|
import org.apache.hc.core5.http.message.BasicNameValuePair;
|
|
|
import org.apache.http.Consts;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
@@ -29,12 +33,12 @@ import java.util.concurrent.TimeUnit;
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
public class YoumeiAccountServiceImpl extends ServiceImpl<YoumeiAccountMapper, YoumeiAccount> implements IYoumeiAccountService {
|
|
|
+ @Autowired
|
|
|
+ private ObjectMapper objectMapper;
|
|
|
|
|
|
- private final ObjectMapper objectMapper;
|
|
|
+ @Autowired
|
|
|
+ private AliyunLogger logger;
|
|
|
|
|
|
- public YoumeiAccountServiceImpl(ObjectMapper objectMapper) {
|
|
|
- this.objectMapper = objectMapper;
|
|
|
- }
|
|
|
|
|
|
private final HashMap<Integer, String> belongMap = new HashMap<>() {{
|
|
|
put(105, "涉国家统一、主权和领土完整");
|
|
@@ -78,7 +82,13 @@ public class YoumeiAccountServiceImpl extends ServiceImpl<YoumeiAccountMapper, Y
|
|
|
var httpPost = new HttpPost("https://api-open-wx-www.yqt365.com/dataapp/api/umei/fw/open/wbjc/article_correct_external");
|
|
|
httpPost.setEntity(params);
|
|
|
|
|
|
- var body = client.execute(httpPost, new ContentResponseHandler());
|
|
|
+ Content body;
|
|
|
+ try {
|
|
|
+ body = client.execute(httpPost, new ContentResponseHandler());
|
|
|
+ } catch (IOException e) {
|
|
|
+ logger.error("error", e);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
CheckWordResponse checkWordDto = objectMapper.readValue(body.asString(StandardCharsets.UTF_8), CheckWordResponse.class);
|
|
|
CheckWordResponse.DataDTO data = checkWordDto.getData();
|