根据P3C优化代码

This commit is contained in:
smallchill 2018-12-27 17:29:16 +08:00
parent 4b67b9a91f
commit a623b387a5
11 changed files with 26 additions and 26 deletions

View File

@ -16,7 +16,7 @@
package org.springblade.core.boot.file;
import org.springblade.core.tool.constant.SystemConstant;
import org.springblade.core.tool.date.DateUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;

View File

@ -16,7 +16,7 @@
package org.springblade.core.boot.file;
import org.springblade.core.tool.constant.SystemConstant;
import org.springblade.core.tool.date.DateUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.ImageUtil;
import org.springblade.core.tool.utils.StringPool;

View File

@ -23,7 +23,7 @@ import org.springblade.core.secure.exception.SecureException;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.api.ResultCode;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.URLUtil;
import org.springblade.core.tool.utils.UrlUtil;
import org.springblade.core.tool.utils.WebUtil;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
@ -155,7 +155,7 @@ public class BladeRestExceptionTranslator {
public R handleError(Throwable e) {
log.error("服务器异常", e);
//发送服务异常事件
ErrorLogPublisher.publishEvent(e, URLUtil.getPath(WebUtil.getRequest().getRequestURI()));
ErrorLogPublisher.publishEvent(e, UrlUtil.getPath(WebUtil.getRequest().getRequestURI()));
return R.failure(ResultCode.INTERNAL_SERVER_ERROR, (Func.isEmpty(e.getMessage()) ? ResultCode.INTERNAL_SERVER_ERROR.getMessage() : e.getMessage()));
}

View File

@ -22,7 +22,7 @@ import org.springblade.core.log.constant.EventConstant;
import org.springblade.core.launch.props.BladeProperties;
import org.springblade.core.secure.utils.SecureUtil;
import org.springblade.core.launch.server.ServerInfo;
import org.springblade.core.tool.utils.URLUtil;
import org.springblade.core.tool.utils.UrlUtil;
import org.springblade.core.tool.utils.WebUtil;
import org.springblade.core.log.feign.ILogClient;
import org.springblade.core.log.model.LogApi;
@ -64,7 +64,7 @@ public class ApiLogListener {
logApi.setEnv(bladeProperties.getEnv());
logApi.setRemoteIp(WebUtil.getIP(request));
logApi.setUserAgent(request.getHeader(WebUtil.USER_AGENT_HEADER));
logApi.setRequestUri(URLUtil.getPath(request.getRequestURI()));
logApi.setRequestUri(UrlUtil.getPath(request.getRequestURI()));
logApi.setMethod(request.getMethod());
logApi.setParams(WebUtil.getRequestParamString(request));
logApi.setCreateBy(SecureUtil.getUserAccount(request));

View File

@ -24,7 +24,7 @@ import org.springblade.core.log.constant.EventConstant;
import org.springblade.core.log.feign.ILogClient;
import org.springblade.core.log.model.LogBlade;
import org.springblade.core.secure.utils.SecureUtil;
import org.springblade.core.tool.utils.URLUtil;
import org.springblade.core.tool.utils.UrlUtil;
import org.springblade.core.tool.utils.WebUtil;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
@ -56,7 +56,7 @@ public class BladeLogListener {
Map<String, Object> source = (Map<String, Object>) event.getSource();
LogBlade logBlade = (LogBlade) source.get(EventConstant.EVENT_LOG);
HttpServletRequest request = (HttpServletRequest) source.get(EventConstant.EVENT_REQUEST);
logBlade.setRequestUri(URLUtil.getPath(request.getRequestURI()));
logBlade.setRequestUri(UrlUtil.getPath(request.getRequestURI()));
logBlade.setUserAgent(request.getHeader(WebUtil.USER_AGENT_HEADER));
logBlade.setMethod(request.getMethod());
logBlade.setParams(WebUtil.getRequestParamString(request));

View File

@ -21,7 +21,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springblade.core.tool.date.DatePattern;
import org.springblade.core.tool.utils.DateUtil;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
@ -113,8 +113,8 @@ public class LogApi implements Serializable {
/**
* 创建时间
*/
@DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
@JsonFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
@DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
@JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
private LocalDateTime createTime;

View File

@ -21,7 +21,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springblade.core.tool.date.DatePattern;
import org.springblade.core.tool.utils.DateUtil;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
@ -95,8 +95,8 @@ public class LogBlade implements Serializable {
/**
* 创建时间
*/
@DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
@JsonFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
@DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
@JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
private LocalDateTime createTime;

View File

@ -21,7 +21,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springblade.core.tool.date.DatePattern;
import org.springblade.core.tool.utils.DateUtil;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.lang.Nullable;
@ -114,7 +114,7 @@ public class LogError implements Serializable {
/**
* 创建时间
*/
@DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
@JsonFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
@DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
@JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
private LocalDateTime createTime;
}

View File

@ -21,7 +21,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springblade.core.tool.date.DatePattern;
import org.springblade.core.tool.utils.DateUtil;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
@ -50,8 +50,8 @@ public class BaseEntity implements Serializable {
/**
* 创建时间
*/
@DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
@JsonFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
@DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
@JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
@ApiModelProperty(value = "创建时间")
private LocalDateTime createTime;
@ -64,8 +64,8 @@ public class BaseEntity implements Serializable {
/**
* 更新时间
*/
@DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
@JsonFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
@DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
@JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
@ApiModelProperty(value = "更新时间")
private LocalDateTime updateTime;

View File

@ -19,8 +19,8 @@ import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import org.springblade.core.tool.date.DatePattern;
import org.springblade.core.tool.jackson.BladeJavaTimeModule;
import org.springblade.core.tool.utils.DateUtil;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
@ -47,7 +47,7 @@ public class JacksonConfiguration {
@Primary
@Bean
public ObjectMapper objectMapper(Jackson2ObjectMapperBuilder builder) {
builder.simpleDateFormat(DatePattern.NORM_DATETIME_PATTERN);
builder.simpleDateFormat(DateUtil.PATTERN_DATETIME);
//创建ObjectMapper
ObjectMapper objectMapper = builder.createXmlMapper(false).build();
//设置地点为中国
@ -57,7 +57,7 @@ public class JacksonConfiguration {
//设置为中国上海时区
objectMapper.setTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()));
//序列化时日期的统一格式
objectMapper.setDateFormat(new SimpleDateFormat(DatePattern.NORM_DATETIME_PATTERN, Locale.CHINA));
objectMapper.setDateFormat(new SimpleDateFormat(DateUtil.PATTERN_DATETIME, Locale.CHINA));
//序列化处理
objectMapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_CONTROL_CHARS, true);
objectMapper.configure(JsonParser.Feature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER, true);

View File

@ -54,7 +54,7 @@ public class PathUtil {
return null;
}
String protocol = url.getProtocol();
String file = URLUtil.decodeURL(url.getPath(), Charsets.UTF_8);
String file = UrlUtil.decodeURL(url.getPath(), Charsets.UTF_8);
if (FILE_PROTOCOL.equals(protocol)) {
return new File(file).getParentFile().getParentFile().getAbsolutePath();
} else if (JAR_PROTOCOL.equals(protocol) || ZIP_PROTOCOL.equals(protocol)) {