修复部分sonar问题
This commit is contained in:
@@ -179,10 +179,11 @@ public class UserEOController extends BaseController<UserEO> {
|
||||
return Result.error(e.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
is.close();
|
||||
if (is != null){
|
||||
is.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,17 +193,18 @@ public class UserEOController extends BaseController<UserEO> {
|
||||
@ApiOperation("下载模板")
|
||||
@GetMapping("/template")
|
||||
public ResponseMessage download(HttpServletResponse response) {
|
||||
|
||||
InputStream fis = null;
|
||||
OutputStream toClient = null;
|
||||
try {
|
||||
InputStream fis = Thread.currentThread().getContextClassLoader().getResourceAsStream("template/用户导入模板.xlsx");
|
||||
fis = Thread.currentThread().getContextClassLoader().getResourceAsStream("template/用户导入模板.xlsx");
|
||||
byte[] buffer = new byte[fis.available()];
|
||||
fis.read(buffer);
|
||||
fis.close();
|
||||
|
||||
response.reset();
|
||||
response.setContentType("application/vnd.ms-excel");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode("用户导入模板.xlsx","UTF-8"));
|
||||
OutputStream toClient = new BufferedOutputStream(response.getOutputStream());
|
||||
toClient = new BufferedOutputStream(response.getOutputStream());
|
||||
|
||||
toClient.write(buffer);
|
||||
|
||||
@@ -211,9 +213,23 @@ public class UserEOController extends BaseController<UserEO> {
|
||||
toClient.close();
|
||||
|
||||
} catch (IOException ex) {
|
||||
|
||||
ex.printStackTrace();
|
||||
} finally {
|
||||
if (fis != null){
|
||||
try {
|
||||
fis.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (toClient != null){
|
||||
try {
|
||||
toClient.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return Result.success();
|
||||
|
||||
|
||||
@@ -61,19 +61,25 @@ public class CompressUtil {
|
||||
}
|
||||
|
||||
} else { // 当前是文件
|
||||
|
||||
// 输入流
|
||||
FileInputStream inputStream = new FileInputStream(file);
|
||||
// 标记要打包的条目
|
||||
out.putNextEntry(new ZipEntry(file.getName()));
|
||||
// 进行写操作
|
||||
int len = 0;
|
||||
byte[] bytes = new byte[1024];
|
||||
while ((len = inputStream.read(bytes)) > 0) {
|
||||
out.write(bytes, 0, len);
|
||||
}
|
||||
// 关闭输入流
|
||||
inputStream.close();
|
||||
FileInputStream inputStream = null;
|
||||
try {
|
||||
// 输入流
|
||||
inputStream = new FileInputStream(file);
|
||||
// 标记要打包的条目
|
||||
out.putNextEntry(new ZipEntry(file.getName()));
|
||||
// 进行写操作
|
||||
int len = 0;
|
||||
byte[] bytes = new byte[1024];
|
||||
while ((len = inputStream.read(bytes)) > 0) {
|
||||
out.write(bytes, 0, len);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (inputStream != null){
|
||||
inputStream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.adc.da.sys.util;
|
||||
|
||||
import com.adc.da.util.exception.AdcDaBaseException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import sun.misc.BASE64Decoder;
|
||||
@@ -41,6 +42,11 @@ public class EncryptUtil {
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (encrypt == null){
|
||||
throw new AdcDaBaseException("秘钥生成错误");
|
||||
}
|
||||
|
||||
// 取MD5Hash码,并组合加密数组
|
||||
byte[] md5Hasn = null;
|
||||
try {
|
||||
@@ -48,6 +54,11 @@ public class EncryptUtil {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (md5Hasn == null){
|
||||
throw new AdcDaBaseException("MD5生成错误");
|
||||
}
|
||||
|
||||
// 组合消息体
|
||||
byte[] totalByte = EncryptUtil.addMD5(md5Hasn, encrypt);
|
||||
|
||||
@@ -112,6 +123,10 @@ public class EncryptUtil {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (temp == null){
|
||||
throw new AdcDaBaseException("秘钥生成错误");
|
||||
}
|
||||
|
||||
// 进行解密后的md5Hash校验
|
||||
byte[] md5Hash = null;
|
||||
try {
|
||||
@@ -120,6 +135,10 @@ public class EncryptUtil {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (md5Hash == null){
|
||||
throw new AdcDaBaseException("MD5生成错误");
|
||||
}
|
||||
|
||||
// 进行解密校检
|
||||
for (int i = 0; i < md5Hash.length; i++) {
|
||||
if (md5Hash[i] != temp[i]) {
|
||||
|
||||
Reference in New Issue
Block a user