代码ReView

v1.4.1
Parker 4 years ago
parent 014d97a7f8
commit 9e092bc790

@ -70,9 +70,9 @@ public enum ValidationMsg implements BaseMsg {
;
private static final String PREFIX = "参数验证错误: ";
private int code;
private final int code;
private final String message;
private String fieldName;
private String message;
ValidationMsg(int code, String message){
this.code = code;

@ -56,11 +56,10 @@ public final class ValidationUtil {
}
Field[] fields = ReflectUtil.getFields(obj.getClass());
for (int i = 0; i < fields.length; i++) {
Field field = fields[i];
for (Field field : fields) {
// 获得 统一验证 注解
ValidationArgs validationArgs = field.getAnnotation(ValidationArgs.class);
if(validationArgs != null){
if (validationArgs != null) {
ValiArgsType[] types = validationArgs.value();
Object fieldValue = ReflectUtil.getFieldValue(obj, field);
ValidationUtil.check(field, types, fieldValue);
@ -68,7 +67,7 @@ public final class ValidationUtil {
// 获得 最大长度 注解
ValidationArgsLenMax validationArgsMax = field.getAnnotation(ValidationArgsLenMax.class);
if(validationArgsMax != null){
if (validationArgsMax != null) {
int maxLength = validationArgsMax.value();
Object fieldValue = ReflectUtil.getFieldValue(obj, field);
ValidationUtil.checkMax(field, maxLength, fieldValue);
@ -76,7 +75,7 @@ public final class ValidationUtil {
// 获得 最小长度 注解
ValidationArgsLenMin validationArgsMin = field.getAnnotation(ValidationArgsLenMin.class);
if(validationArgsMin != null){
if (validationArgsMin != null) {
int minLength = validationArgsMin.value();
Object fieldValue = ReflectUtil.getFieldValue(obj, field);
ValidationUtil.checkMin(field, minLength, fieldValue);

@ -40,6 +40,6 @@ public class TokenThreadLocal {
public static void remove() {
try {
TOKEN_DATA.remove();
}catch (Exception e){}
}catch (Exception ignored){}
}
}

@ -14,7 +14,7 @@ public enum DictType {
;
private String code;
private final String code;
DictType(String code){
this.code = code;

@ -29,7 +29,7 @@ public enum SystemInfo {
/** 实例 */
INSTANCE;
private String systemID;
private final String systemID;
SystemInfo(){
// 生成系统ID

@ -34,8 +34,8 @@ public enum CommonMsg implements BaseMsg {
;
private int code;
private String message;
private final int code;
private final String message;
CommonMsg(int code, String message){
this.code = code;

@ -91,16 +91,14 @@ public class ZipUtils {
public static void main(String[] args) throws Exception {
List<Map<String, String>> list = new ArrayList<>();
OutputStream outputStream = new FileOutputStream(new File("/Users/system/Documents/脚本/opsli/test.zip"));
Map<String,String> m1 = new HashMap(){{put("path","/f1/f2/f3/");put("name","1.txt");put("data","abcdefg");}};
Map<String,String> m2 = new HashMap(){{put("path","/f1/f2/f3/f4/");put("name","2.txt");put("data","abcdefg");}};
Map<String,String> m3 = new HashMap(){{put("path","");put("name","3.txt");put("data","abcdefg");}};
Map<String,String> m1 = new HashMap<String,String>(){{put("path","/f1/f2/f3/");put("name","1.txt");put("data","abcdefg");}};
Map<String,String> m2 = new HashMap<String,String>(){{put("path","/f1/f2/f3/f4/");put("name","2.txt");put("data","abcdefg");}};
Map<String,String> m3 = new HashMap<String,String>(){{put("path","");put("name","3.txt");put("data","abcdefg");}};
list.add(m1);
list.add(m2);
list.add(m3);
toZip(list, outputStream);
if (outputStream != null) {
outputStream.close();
}
outputStream.close();
}
}

@ -66,7 +66,7 @@ public class ShiroConfig {
/**
* filer
* @param securityManager
* @param securityManager
* @return
*/
@Bean("shiroFilter")

@ -60,13 +60,13 @@ public class StartPrint {
// 睡一秒打印
ThreadUtil.sleep(1, TimeUnit.SECONDS);
String basePath = getBasePath();
StringBuilder printStr = new StringBuilder();
printStr.append("\n----------------------------------------------------------\n")
.append("OPSLI 快速开发平台 框架启动成功! 相关URLs:\n")
.append("项目地址: \t\thttp://" + basePath + "/\n")
.append("Doc文档: \t\thttp://" + basePath + "/doc.html\n")
.append("----------------------------------------------------------\n");
Console.log(printStr.toString());
String printStr =
"\n----------------------------------------------------------\n" +
"OPSLI 快速开发平台 框架启动成功! 相关URLs:\n" +
"项目地址: \t\thttp://" + basePath + "/\n" +
"Doc文档: \t\thttp://" + basePath + "/doc.html\n" +
"----------------------------------------------------------\n";
Console.log(printStr);
}
/**
@ -76,11 +76,11 @@ public class StartPrint {
public void errorPrint(){
// 睡一秒打印
ThreadUtil.sleep(1, TimeUnit.SECONDS);
StringBuilder printStr = new StringBuilder();
printStr.append("\n----------------------------------------------------------\n")
.append("OPSLI 快速开发平台 框架启动失败! 请检查相关配置!\n")
.append("----------------------------------------------------------\n");
Console.log(printStr.toString());
String printStr =
"\n----------------------------------------------------------\n" +
"OPSLI 快速开发平台 框架启动失败! 请检查相关配置!\n" +
"----------------------------------------------------------\n";
Console.log(printStr);
}

@ -15,8 +15,10 @@ import org.springframework.stereotype.Component;
@Component
@Slf4j
public class ApplicationFailedEventListener implements ApplicationListener<ApplicationFailedEvent> {
@Override
public void onApplicationEvent(ApplicationFailedEvent event) {
StartPrint.INSTANCE.errorPrint();
}
}

@ -14,10 +14,12 @@ import org.springframework.stereotype.Component;
*/
@Component
@Slf4j
public class ApplicationReadyEventListene implements ApplicationListener<ApplicationReadyEvent> {
public class ApplicationReadyEventListener implements ApplicationListener<ApplicationReadyEvent> {
@Override
public void onApplicationEvent(ApplicationReadyEvent event) {
event.getApplicationContext();
StartPrint.INSTANCE.successPrint();
}
}

@ -68,8 +68,8 @@ public enum CoreMsg implements BaseMsg {
;
private int code;
private String message;
private final int code;
private final String message;
CoreMsg(int code,String message){
this.code = code;

@ -34,8 +34,8 @@ public enum JwtMsg implements BaseMsg {
;
private int code;
private String message;
private final int code;
private final String message;
JwtMsg(int code, String message){
this.code = code;

@ -53,8 +53,8 @@ public enum TokenMsg implements BaseMsg {
EXCEPTION_NOT_AUTH(12202, "无权访问该方法"),
;
private int code;
private String message;
private final int code;
private final String message;
TokenMsg(int code, String message){
this.code = code;

@ -70,19 +70,6 @@ public class Page<T extends BaseEntity,E extends ApiWrapper> extends PageSeriali
this.queryWrapper = queryWrapper;
}
/**
*
* @param pageNo
* @param pageSize
*/
public Page(int pageNo, int pageSize, String orderBy) {
super();
this.pageNo = pageNo;
this.pageSize = pageSize;
}
/**
*
*/

@ -37,8 +37,7 @@ public class GenQueryBuilder<T extends BaseEntity> implements QueryBuilder<T> {
@Override
public QueryWrapper<T> build() {
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
return queryWrapper;
return new QueryWrapper<>();
}
}

@ -47,11 +47,11 @@ public class WebQueryBuilder<T extends BaseEntity> implements QueryBuilder<T>{
private static final String ORDER_DESC = "DESC";
/** 参数 */
private Map<String, String[]> parameterMap;
private final Map<String, String[]> parameterMap;
/** Entity Clazz */
private Class<? extends BaseEntity> entityClazz;
private final Class<? extends BaseEntity> entityClazz;
/** 默认排序字段 */
private String defaultOrderField;
private final String defaultOrderField;
/**
*
@ -152,27 +152,33 @@ public class WebQueryBuilder<T extends BaseEntity> implements QueryBuilder<T>{
}
// 转换驼峰 为 数据库下划线字段
key = HumpUtil.humpToUnderline(key);
if (EQ.equals(handle)) {
// 全值匹配
queryWrapper.eq(key,value);
} else if (LIKE.equals(handle)) {
// 模糊匹配
queryWrapper.like(key,value);
} else if (BEGIN.equals(handle)) {
// 大于等于
queryWrapper.ge(key,value);
} else if (END.equals(handle)) {
// 小于等于
queryWrapper.le(key,value);
} else if (ORDER.equals(handle)) {
// 排序
if(ORDER_ASC.equals(value)){
queryWrapper.orderByAsc(key);
} else if(ORDER_DESC.equals(value)){
queryWrapper.orderByDesc(key);
} else{
queryWrapper.orderByAsc(key);
}
switch (handle) {
case EQ:
// 全值匹配
queryWrapper.eq(key, value);
break;
case LIKE:
// 模糊匹配
queryWrapper.like(key, value);
break;
case BEGIN:
// 大于等于
queryWrapper.ge(key, value);
break;
case END:
// 小于等于
queryWrapper.le(key, value);
break;
case ORDER:
// 排序
if (ORDER_ASC.equals(value)) {
queryWrapper.orderByAsc(key);
} else if (ORDER_DESC.equals(value)) {
queryWrapper.orderByDesc(key);
} else {
queryWrapper.orderByAsc(key);
}
break;
}
}
@ -208,9 +214,8 @@ public class WebQueryBuilder<T extends BaseEntity> implements QueryBuilder<T>{
return true;
} else if (END.equals(handle)) {
return true;
} else if (ORDER.equals(handle)) {
return true;
} else {
return ORDER.equals(handle);
}
return false;
}
}

@ -1,8 +1,7 @@
package org.opsli.core.utils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.Validate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
@ -17,12 +16,11 @@ import org.springframework.stereotype.Component;
*/
@Component
@Lazy(false)
@Slf4j
public class SpringContextHolder implements ApplicationContextAware, DisposableBean {
private static ApplicationContext applicationContext = null;
private static Logger logger = LoggerFactory.getLogger(SpringContextHolder.class);
/**
* applicationContextBean, .
@ -45,8 +43,8 @@ public class SpringContextHolder implements ApplicationContextAware, DisposableB
* SpringContextHolderApplicationContextNull.
*/
public static void clearHolder() {
if (logger.isDebugEnabled()){
logger.debug("清除SpringContextHolder中的ApplicationContext:" + applicationContext);
if (log.isDebugEnabled()){
log.debug("清除SpringContextHolder中的ApplicationContext:" + applicationContext);
}
applicationContext = null;
}

@ -159,7 +159,7 @@ public class UserTokenUtil {
String userId = "";
try {
userId = JwtUtil.getClaim(token, SignConstants.USER_ID);
}catch (Exception e){}
}catch (Exception ignored){}
return userId;
}

@ -16,7 +16,6 @@
package org.opsli.core.waf.filter;
import org.opsli.common.exception.TokenException;
import org.opsli.core.waf.servlet.WafHttpServletRequestWrapper;
import javax.servlet.*;

@ -78,8 +78,8 @@ public enum SystemMsg implements BaseMsg {
;
private int code;
private String message;
private final int code;
private final String message;
SystemMsg(int code, String message){
this.code = code;

@ -37,8 +37,8 @@ public enum EhCacheMsg implements BaseMsg {
;
private int code;
private String message;
private final int code;
private final String message;
EhCacheMsg(int code, String message){
this.code = code;

@ -32,7 +32,7 @@ public class ExcelListener extends AnalysisEventListener {
private static final String SERIAL_VERSION_UID = "serialVersionUID";
private List<Object> dataList = new ArrayList<>();
private final List<Object> dataList = new ArrayList<>();
/**
* AnalysisContext sheet

@ -32,8 +32,8 @@ public enum ExcelMsg implements BaseMsg {
;
private int code;
private String message;
private final int code;
private final String message;
ExcelMsg(int code, String message){
this.code = code;

@ -31,8 +31,8 @@ public enum MailMsg implements BaseMsg {
;
private int code;
private String message;
private final int code;
private final String message;
MailMsg(int code,String message){
this.code = code;

Loading…
Cancel
Save