Browse Source

暂存3

master
yinzuomei 5 years ago
parent
commit
4353141e85
  1. 9
      epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/common/redis/RedisKeys.java
  2. 42
      epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/redis/ScanRedis.java
  3. 10
      epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/service/impl/ScanServiceImpl.java

9
epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/common/redis/RedisKeys.java

@ -26,4 +26,13 @@ public class RedisKeys {
public static String getWhiteList () {
return rootPrefix.concat("openapi:scan:whitelist");
}
/**
* desc: 语音检测任务异步回调需要根据taskId获取存储seed的Key
* @param taskId 提交检测任务API接口返回的taskId eg:1001
* @return epmet:openapi:scan:voice:seed:1001
*/
public static String getVoiceScanSeedKey(String taskId){
return rootPrefix.concat("openapi:scan:voice:seed:").concat(taskId);
}
}

42
epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/redis/ScanRedis.java

@ -1,42 +0,0 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.openapi.scan.redis;
import com.epmet.commons.tools.redis.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 用户居民端注册信息表 用户在居民端完善的个人信息
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-03-30
*/
@Component
public class ScanRedis {
@Autowired
private RedisUtils redisUtils;
public void test(){
redisUtils.set("yinzuomei", "尹作梅测试用",RedisUtils.MINUTE_THIRTY_EXPIRE);
}
public void setVoiceScanKey(String taskId, String seed) {
redisUtils.set(taskId, seed,RedisUtils.HOUR_FOUR_EXPIRE);
}
}

10
epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/service/impl/ScanServiceImpl.java

@ -14,8 +14,8 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.openapi.scan.common.constant.SysConstant;
import com.epmet.openapi.scan.common.enu.*;
import com.epmet.openapi.scan.common.exception.ExecuteHttpException;
import com.epmet.openapi.scan.common.redis.RedisKeys;
import com.epmet.openapi.scan.common.util.IAcsClientUtil;
import com.epmet.openapi.scan.redis.ScanRedis;
import com.epmet.openapi.scan.support.param.*;
import com.epmet.openapi.scan.support.result.*;
import lombok.extern.slf4j.Slf4j;
@ -24,6 +24,8 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
@ -44,7 +46,7 @@ public class ScanServiceImpl implements ScanService {
@Value("${aliyun.green.bizType}")
private String bizType;
@Autowired
private ScanRedis scanRedis;
private RedisTemplate redisTemplate;
@Override
public Result<SyncScanResult> sendTextScan(TextScanParam textScanParam) {
//默认参数
@ -308,8 +310,10 @@ public class ScanServiceImpl implements ScanService {
if (StringUtils.isNotBlank(voiceAsyncScanParam.getCallback())) {
// 存储seed和 任务id、dataId的关系 用于回调鉴权
log.info("need to save seed and taskId、dataId的关系");
ValueOperations valueOperations=redisTemplate.opsForValue();
taskList.forEach(task -> {
scanRedis.setVoiceScanKey(task.getTaskId(), voiceAsyncScanParam.getSeed());
String seedKey = RedisKeys.getVoiceScanSeedKey(task.getTaskId());
valueOperations.set(seedKey,voiceAsyncScanParam.getSeed());
});
}
return new Result<VoiceAsyncScanTaskResult>().ok(resultDto);

Loading…
Cancel
Save