修改文件下载的逻辑

This commit is contained in:
wangkang
2017-12-19 10:31:45 +08:00
parent 275f1b9b7e
commit 64a55127a1
3 changed files with 10 additions and 8 deletions
@@ -39,7 +39,12 @@ public class DownLoadProcessAspect {
public static final String DOWNLOAD_CACHE_PREFIX = ":DOWNLOAD_CACHE:";
/**
* DOWNLOAD_CACHE_EXPIRATION
* DOWNLOAD_WAITING_CACHE_EXPIRATION(待执行,执行中,缓存过期时间为1天)
*/
public static final long DOWNLOAD_WAITING_CACHE_EXPIRATION = 60 * 24;
/**
* DOWNLOAD_CACHE_EXPIRATION(执行完成,执行错误,缓存过期时间为10分钟)
*/
public static final long DOWNLOAD_CACHE_EXPIRATION = 10;
@@ -85,7 +90,7 @@ public class DownLoadProcessAspect {
try {
//更新缓存
info.setStatus(DownConstant.DOWNLOAD_PROCESS_STATUS.STATUS_2.value());
redisTemplate.opsForValue().set(key, info, DOWNLOAD_CACHE_EXPIRATION, TimeUnit.MINUTES);
redisTemplate.opsForValue().set(key, info, DOWNLOAD_WAITING_CACHE_EXPIRATION, TimeUnit.MINUTES);
//执行
result = proceedingJoinPoint.proceed();
//获得本地文件
@@ -1,9 +1,6 @@
package org.itkk.udf.file.aliyun.oss.service;
package org.itkk.udf.file.aliyun.oss.api.download;
import org.itkk.udf.cache.redis.CacheRedisProperties;
import org.itkk.udf.file.aliyun.oss.api.download.DownConstant;
import org.itkk.udf.file.aliyun.oss.api.download.DownLoadProcessAspect;
import org.itkk.udf.file.aliyun.oss.api.download.DownloadInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
@@ -44,7 +41,7 @@ public class DownLoadProcessService {
info.setId(id);
info.setStatus(DownConstant.DOWNLOAD_PROCESS_STATUS.STATUS_1.value());
//更新缓存
redisTemplate.opsForValue().set(key, info, DownLoadProcessAspect.DOWNLOAD_CACHE_EXPIRATION, TimeUnit.MINUTES);
redisTemplate.opsForValue().set(key, info, DownLoadProcessAspect.DOWNLOAD_WAITING_CACHE_EXPIRATION, TimeUnit.MINUTES);
//返回ID
return id;
}
@@ -11,7 +11,7 @@ import org.itkk.udf.core.domain.aliyun.oss.OssParam;
import org.itkk.udf.file.aliyun.oss.api.OssWarpper;
import org.itkk.udf.file.aliyun.oss.api.domain.PolicyResult;
import org.itkk.udf.file.aliyun.oss.api.download.DownloadInfo;
import org.itkk.udf.file.aliyun.oss.service.DownLoadProcessService;
import org.itkk.udf.file.aliyun.oss.api.download.DownLoadProcessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;