增加sonar测试并修复sonar测试的问题
This commit is contained in:
-5
@@ -72,11 +72,6 @@ public interface CommonConstant {
|
||||
*/
|
||||
String DEL_FLAG = "is_del";
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
String UTF8 = "UTF-8";
|
||||
|
||||
/**
|
||||
* 超级管理员用户名
|
||||
*/
|
||||
|
||||
-4
@@ -15,8 +15,4 @@ public enum CodeEnum {
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-3
@@ -33,9 +33,7 @@ public class LoginAppUser extends SysUser implements SocialUserDetails {
|
||||
public Collection<? extends GrantedAuthority> getAuthorities() {
|
||||
Collection<GrantedAuthority> collection = new HashSet<>();
|
||||
if (!CollectionUtils.isEmpty(super.getRoles())) {
|
||||
super.getRoles().parallelStream().forEach(role -> {
|
||||
collection.add(new SimpleGrantedAuthority(role.getCode()));
|
||||
});
|
||||
super.getRoles().parallelStream().forEach(role -> collection.add(new SimpleGrantedAuthority(role.getCode())));
|
||||
}
|
||||
return collection;
|
||||
}
|
||||
|
||||
+2
-2
@@ -27,7 +27,7 @@ public class Result<T> implements Serializable {
|
||||
}
|
||||
|
||||
public static <T> Result<T> succeedWith(T datas, Integer code, String msg) {
|
||||
return new Result<T>(datas, code, msg);
|
||||
return new Result<>(datas, code, msg);
|
||||
}
|
||||
|
||||
public static <T> Result<T> failed(String msg) {
|
||||
@@ -39,7 +39,7 @@ public class Result<T> implements Serializable {
|
||||
}
|
||||
|
||||
public static <T> Result<T> failedWith(T datas, Integer code, String msg) {
|
||||
return new Result<T>(datas, code, msg);
|
||||
return new Result<>(datas, code, msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+4
@@ -9,6 +9,10 @@ import java.util.Date;
|
||||
* @author zlt
|
||||
*/
|
||||
public class DateUtils {
|
||||
private DateUtils() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
/** 时间格式(yyyy-MM-dd) */
|
||||
public final static String DATE_PATTERN = "yyyy-MM-dd";
|
||||
/** 时间格式(yyyy-MM-dd HH:mm:ss) */
|
||||
|
||||
+9
-6
@@ -13,6 +13,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -23,6 +24,10 @@ import java.util.Map;
|
||||
* @date 2019/1/6
|
||||
*/
|
||||
public class ExcelUtil {
|
||||
private ExcelUtil() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出
|
||||
*
|
||||
@@ -95,23 +100,21 @@ public class ExcelUtil {
|
||||
|
||||
public static <T> List<T> importExcel(String filePath, Integer titleRows, Integer headerRows, Class<T> pojoClass) {
|
||||
if (StringUtils.isBlank(filePath)) {
|
||||
return null;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
ImportParams params = new ImportParams();
|
||||
params.setTitleRows(titleRows);
|
||||
params.setHeadRows(headerRows);
|
||||
List<T> list = ExcelImportUtil.importExcel(new File(filePath), pojoClass, params);
|
||||
return list;
|
||||
return ExcelImportUtil.importExcel(new File(filePath), pojoClass, params);
|
||||
}
|
||||
|
||||
public static <T> List<T> importExcel(MultipartFile file, Integer titleRows, Integer headerRows, Class<T> pojoClass) throws Exception {
|
||||
if (file == null) {
|
||||
return null;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
ImportParams params = new ImportParams();
|
||||
params.setTitleRows(titleRows);
|
||||
params.setHeadRows(headerRows);
|
||||
List<T> list = ExcelImportUtil.importExcel(file.getInputStream(), pojoClass, params);
|
||||
return list;
|
||||
return ExcelImportUtil.importExcel(file.getInputStream(), pojoClass, params);
|
||||
}
|
||||
}
|
||||
|
||||
+4
@@ -8,6 +8,10 @@ import java.util.regex.Pattern;
|
||||
* 正则表达式手机号码校验类
|
||||
*/
|
||||
public class PhoneUtil {
|
||||
private PhoneUtil() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
private static String REGEX = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(17[013678])|(18[0,5-9]))\\d{8}$";
|
||||
private static Pattern P = Pattern.compile(REGEX);
|
||||
|
||||
|
||||
+3
@@ -14,6 +14,9 @@ import java.util.Map;
|
||||
* @date 2018/12/20
|
||||
*/
|
||||
public class ResponseUtil {
|
||||
private ResponseUtil() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
/**
|
||||
* 通过流写到前端
|
||||
*
|
||||
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
package com.central.common.utils;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.core.env.Environment;
|
||||
@@ -28,7 +27,7 @@ public class SpringUtil implements ApplicationContextAware {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
public void setApplicationContext(ApplicationContext applicationContext) {
|
||||
SpringUtil.applicationContext = applicationContext;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-8
@@ -1,25 +1,21 @@
|
||||
package com.central.common.utils;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.central.common.model.SysRole;
|
||||
import com.central.common.model.SysUser;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.oauth2.provider.OAuth2Authentication;
|
||||
import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken;
|
||||
|
||||
import com.central.common.model.LoginAppUser;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*
|
||||
* @author zlt
|
||||
*/
|
||||
public class SysUserUtil {
|
||||
private SysUserUtil() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
public static LoginAppUser getLoginAppUser(SysUser user) {
|
||||
LoginAppUser login = new LoginAppUser();
|
||||
BeanUtil.copyProperties(user, login);
|
||||
|
||||
+6
-3
@@ -14,6 +14,10 @@ import java.util.UUID;
|
||||
* @date 2017-3-28 下午1:11:31
|
||||
*/
|
||||
public class UUIDUtil {
|
||||
private UUIDUtil() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
private static String[] chars = new String[] { "a", "b", "c", "d", "e", "f",
|
||||
"g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s",
|
||||
"t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5",
|
||||
@@ -27,7 +31,7 @@ public class UUIDUtil {
|
||||
* @author wangfan
|
||||
*/
|
||||
public static String randomUUID8() {
|
||||
StringBuffer shortBuffer = new StringBuffer();
|
||||
StringBuilder shortBuffer = new StringBuilder();
|
||||
String uuid = UUID.randomUUID().toString().replace("-", "");
|
||||
for (int i = 0; i < 8; i++) {
|
||||
String str = uuid.substring(i * 4, i * 4 + 4);
|
||||
@@ -43,8 +47,7 @@ public class UUIDUtil {
|
||||
* @author wangfan
|
||||
*/
|
||||
public static String randomUUID32(){
|
||||
String uuid = UUID.randomUUID().toString().replace("-", "");
|
||||
return uuid;
|
||||
return UUID.randomUUID().toString().replace("-", "");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user