style(system): 短信查询相关员工电话号码功能修正;安眼健康监测大屏跳转时,获取token方式调整为统一认证直接获取
This commit is contained in:
+46
-2
@@ -258,8 +258,11 @@ public class AnYanClientExecutor implements AnYanClient {
|
||||
return token;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthResult publicNetworkTokenNoCache() {
|
||||
/**
|
||||
* @description: 旧版公网获取token实现(SM4 + AnYanResult 包裹解密),保留备份
|
||||
* @author PengJ
|
||||
*/
|
||||
public AuthResult publicNetworkTokenNoCacheBAK() {
|
||||
JSONObject param = new JSONObject();
|
||||
String password = anYanProperties.getPublicPassWrod();
|
||||
String userName = anYanProperties.getPublicUserNmae();
|
||||
@@ -289,6 +292,47 @@ public class AnYanClientExecutor implements AnYanClient {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 公网获取token(密码模式,调用方式与 getAuthTokenByPassword 保持一致)
|
||||
* 表单提交 + 公网 host + QUERY_AUTH_TOKEN,仅 RSA 加密密码,不写 Redis(缓存由调用方负责)
|
||||
* @author PengJ
|
||||
*/
|
||||
@Override
|
||||
public AuthResult publicNetworkTokenNoCache() {
|
||||
String username = anYanProperties.getPublicUserNmae();
|
||||
String password = anYanProperties.getPublicPassWrod();
|
||||
try {
|
||||
// 仅 RSA 加密密码,与 getAuthTokenByPassword 保持一致
|
||||
String encryptPassword = StringUtils.encryptByPublicKey(publicKey, password);
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
|
||||
MultiValueMap<String, String> formData = new LinkedMultiValueMap<>();
|
||||
formData.add("grant_type", "password");
|
||||
formData.add("username", username);
|
||||
formData.add("password", encryptPassword);
|
||||
formData.add("client_id", anYanProperties.getClientId());
|
||||
formData.add("client_secret", anYanProperties.getClientSecret());
|
||||
ResponseEntity<AuthResult> authResult = RestTemplateUtil.postExchangeForGetTokenByPassword(AnYanApiEnum.QUERY_AUTH_TOKEN, formData, headers, AuthResult.class);
|
||||
if (HttpStatus.OK.equals(authResult.getStatusCode())
|
||||
&& ObjectUtils.isNotEmpty(authResult.getBody())) {
|
||||
return authResult.getBody();
|
||||
} else {
|
||||
log.error("------安眼系统获取公网token失败{}------", authResult.getBody());
|
||||
ExceptionAssertsUtil.fail("------安眼系统获取公网token失败------" + authResult.getBody());
|
||||
return null;
|
||||
}
|
||||
} catch (HttpClientErrorException e) {
|
||||
log.error("------安眼系统获取公网token失败{}------", e.getMessage());
|
||||
String replace = Objects.requireNonNull(e.getMessage()).replace("401 Unauthorized: ", "");
|
||||
replace = replace.replace("\"", "");
|
||||
AuthResult bean = JSONUtil.toBean(replace, AuthResult.class);
|
||||
ExceptionAssertsUtil.fail(bean.getMessage());
|
||||
} catch (Exception e) {
|
||||
ExceptionAssertsUtil.fail(e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 根据token获取用户信息
|
||||
* @author PengJ
|
||||
|
||||
+10
-1
@@ -1,5 +1,6 @@
|
||||
package com.renkang.anyan.config;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.renkang.anyan.enums.AnYanApiEnum;
|
||||
import com.renkang.anyan.model.vo.AnYanResult;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -81,7 +82,15 @@ public class RestTemplateUtil {
|
||||
public static <T> ResponseEntity<T> postExchangeForGetToken(AnYanApiEnum api, Object requestBody, Class<T> responseType) {
|
||||
String url = getProperties().getPublicHost() + api.getMethodPath() + api.getMethodParam();
|
||||
HttpEntity<Object> requestEntity = new HttpEntity<>(requestBody);
|
||||
return getRestTemplate().exchange(url, api.getHttpMethod(), requestEntity, responseType);
|
||||
// 打印请求入参,便于排查
|
||||
String bodyJson = JSON.toJSONString(requestBody);
|
||||
log.info("安眼获取token请求入参: url={}, body={}", url, bodyJson);
|
||||
// 打印等价 curl(application/json),便于本地手动调试
|
||||
log.info("安眼获取token等价curl: curl -X POST '{}' -H 'Content-Type: application/json' -d '{}'", url, bodyJson);
|
||||
ResponseEntity<T> response = getRestTemplate().exchange(url, api.getHttpMethod(), requestEntity, responseType);
|
||||
// 打印返回信息(状态码 + 响应体)
|
||||
log.info("安眼获取token返回信息: statusCode={}, body={}", response.getStatusCode(), JSON.toJSONString(response.getBody()));
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ public class SysMessageController extends JeecgController<SysMessage, ISysMessag
|
||||
// 员工电话: esContent中手机号以"3位~4位~4位"(全角波浪线)格式存储,
|
||||
// 前端传入纯数字手机号,此处还原为存储格式后对 esContent 做模糊查询
|
||||
if (employeePhone != null && !employeePhone.trim().isEmpty()) {
|
||||
queryWrapper.like("esContent", buildEmployeePhoneLikeValue(employeePhone));
|
||||
queryWrapper.like("ES_CONTENT", buildEmployeePhoneLikeValue(employeePhone));
|
||||
}
|
||||
Page<SysMessage> page = new Page<SysMessage>(pageNo, pageSize);
|
||||
IPage<SysMessage> pageList = sysMessageService.page(page, queryWrapper);
|
||||
|
||||
Reference in New Issue
Block a user