提交 0fe5fc7a authored 作者: 李秋林's avatar 李秋林

根据url中地址将文件保存到本地工具;新增返回报错信息;

上级 8f7792ad
package com.wangxiaolu.promotion.common.excel;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
/**
* @author : liqiulin
* @date : 2025-01-21 14
* @describe :
*/
public class FileUtils {
public static void downloadExcel(String urlS, String filePath) throws Exception {
// 保存文件
URL url = new URL(urlS);
URLConnection urlConnection = url.openConnection();
InputStream inputStream = urlConnection.getInputStream();
FileOutputStream fileOutputStream = new FileOutputStream(filePath);
// 调大小
byte[] buffer = new byte[102400];
int bytesRead;
while ((bytesRead = inputStream.read(buffer)) != -1) {
fileOutputStream.write(buffer, 0, bytesRead);
}
fileOutputStream.close();
inputStream.close();
}
}
......@@ -58,4 +58,13 @@ public interface RedisKeys {
String key;
}
@AllArgsConstructor
@Getter
enum Manage{
ACTIVITY_PLAN_UP("prom:manage:activity_plan_up:"),
;
String key;
}
}
......@@ -3,9 +3,7 @@ package com.wangxiaolu.promotion.common.redis.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.SetOperations;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Component;
......@@ -127,6 +125,9 @@ public class RedisCache {
redisTemplate.delete(keys);
}
public boolean hasKey(String key) {
return redisTemplate.hasKey(key);
}
private String valToJson(Object o) {
......
......@@ -35,5 +35,10 @@ public class DataException extends RuntimeException {
this.msg = RCode.API_ERROR.getMsg();
}
public DataException(StatusCode statusCode,Object... args) {
this.code = statusCode.getCode();
this.msg = String.format(statusCode.getMsg(),args);
}
}
......@@ -18,6 +18,7 @@ public enum RCode implements StatusCode {
PARAM_ERROR(1002, "参数错误"),
RESPONSE_PACK_ERROR(1003, "包装R失败"),
SELECT_PARAMS_ERROR(1004, "查询条件错误"),
REDIS_PUSH_DATA_NOT_EXIT(1005, "数据已过期或不存在,请重复上传;"),
/**
* 业务统一编码(不分模块)
......@@ -95,6 +96,9 @@ public enum RCode implements StatusCode {
*/
ACTIVITY_PLAN_MONTH_HAS(5000,"本月活动计划已上传,请删除后再次上传"),
ACTIVITY_PLAN_FILENAME_LONG(5001,"文件名过长,请少于20个字"),
ACTIVITY_PLAN_CELL_NOT_NULL(5002,"第%s行有空值,请改正后再次提交;"),
ACTIVITY_PLAN_TEM_ERROR(5003,"当前流程模板错误;"),
ACTIVITY_PLAN_REPETITION_ERROR(5004,"本次上传的活动或系统已存在的活动,有日期重复的计划;"),
/**
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论