update 联联接口返回值加密

This commit is contained in:
Lemon
2023-05-27 16:31:09 +08:00
parent f001414146
commit b0973e131a
3 changed files with 23 additions and 5 deletions

View File

@@ -28,7 +28,7 @@ public interface LianLianService {
* @param dto
* @return
*/
LianLianPageResponse query_stations_info(QueryStationInfoDTO dto);
Map<String, String> query_stations_info(String operatorId, QueryStationInfoDTO dto);
/**
* 设备接口状态查询

View File

@@ -211,7 +211,7 @@ public class LianLianServiceImpl implements LianLianService {
* @return
*/
@Override
public LianLianPageResponse query_stations_info(QueryStationInfoDTO dto) {
public Map<String, String> query_stations_info(String operatorId, QueryStationInfoDTO dto) {
List<StationInfo> resultList = new ArrayList<>();
int pageNo = dto.getPageNo() == null ? 1 : dto.getPageNo();
int pageSize = dto.getPageSize() == null ? 10 : dto.getPageSize();
@@ -222,6 +222,10 @@ public class LianLianServiceImpl implements LianLianService {
// 未查到数据
return null;
}
DockingPlatformConfig configInfo = dockingPlatformConfigService.getInfoByOperatorId(operatorId);
if (configInfo == null) {
return null;
}
PageInfo<PileStationInfo> pageInfo = new PageInfo<>(stationInfos);
for (PileStationInfo pileStationInfo : pageInfo.getList()) {
StationInfo stationInfo = new StationInfo();
@@ -272,7 +276,19 @@ public class LianLianServiceImpl implements LianLianService {
.ItemSize(resultList.size())
.list(resultList)
.build();
return pageResponse;
// 加密
Map<String, String> resultMap = Maps.newLinkedHashMap();
// 加密数据
byte[] encryptText = Cryptos.aesEncrypt(JSONObject.toJSONString(pageResponse).getBytes(),
configInfo.getOperatorSecret().getBytes(), configInfo.getDataSecretIv().getBytes());
String encryptData = Encodes.encodeBase64(encryptText);
resultMap.put("Data", encryptData);
// 生成sig
String resultSign = GBSignUtils.sign(resultMap, configInfo.getOperatorSecret());
resultMap.put("Sig", resultSign);
return resultMap;
}
/**