♻️ 重构代码。 接受大众批评,常量替换,优化pom依赖

This commit is contained in:
冷冷 committed 2018-11-09 13:56:34 +08:00
1 parent 6baccc1370
commit f5ac00ec27
22 files changed
+101 -63

No files matched your search

+3 -3
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx</artifactId>
<version>${pigx.version}</version>
<version>1.7.0</version>
</parent>
<artifactId>pigx-auth</artifactId>
@@ -42,13 +42,13 @@
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-upms-api</artifactId>
<version>${pigx.version}</version>
<version>1.7.0</version>
</dependency>
<!--security-->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-security</artifactId>
<version>${pigx.version}</version>
<version>1.7.0</version>
</dependency>
<!--JDBC相关-->
<dependency>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common</artifactId>
<version>${pigx.version}</version>
<version>1.7.0</version>
</parent>
<artifactId>pigx-common-core</artifactId>
+1 -7
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common</artifactId>
<version>${pigx.version}</version>
<version>1.7.0</version>
</parent>
<artifactId>pigx-common-job</artifactId>
@@ -33,12 +33,6 @@
<description>pigx 定时任务</description>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<!-- import elastic-job lite core -->
<dependency>
<groupId>com.dangdang</groupId>
+10 -6
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common</artifactId>
<version>${pigx.version}</version>
<version>1.7.0</version>
</parent>
<artifactId>pigx-common-log</artifactId>
@@ -38,18 +38,22 @@
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-core</artifactId>
<version>${pigx.version}</version>
<version>1.7.0</version>
</dependency>
<!--UPMS接口模块-->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-upms-api</artifactId>
<version>${pigx.version}</version>
<version>1.7.0</version>
</dependency>
<!--安全依赖获取上下文信息-->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
</dependency>
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-security</artifactId>
<version>${pigx.version}</version>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
</dependency>
</dependencies>
</project>
@@ -23,11 +23,14 @@ import cn.hutool.core.util.URLUtil;
import cn.hutool.http.HttpUtil;
import com.pig4cloud.pigx.admin.api.entity.SysLog;
import com.pig4cloud.pigx.common.core.constant.CommonConstant;
import com.pig4cloud.pigx.common.security.util.SecurityUtils;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.util.Objects;
/**
* 系统日志工具类
@@ -36,16 +39,45 @@ import javax.servlet.http.HttpServletRequest;
*/
public class SysLogUtils {
public static SysLog getSysLog() {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
HttpServletRequest request = ((ServletRequestAttributes) Objects
.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
SysLog sysLog = new SysLog();
sysLog.setCreateBy(SecurityUtils.getUser().getUsername());
sysLog.setCreateBy(Objects.requireNonNull(getUsername()));
sysLog.setType(CommonConstant.STATUS_NORMAL);
sysLog.setRemoteAddr(HttpUtil.getClientIP(request));
sysLog.setRequestUri(URLUtil.getPath(request.getRequestURI()));
sysLog.setMethod(request.getMethod());
sysLog.setUserAgent(request.getHeader("user-agent"));
sysLog.setParams(HttpUtil.toParams(request.getParameterMap()));
sysLog.setServiceId(SecurityUtils.getClientId());
sysLog.setServiceId(getClientId());
return sysLog;
}
/**
* 获取客户端
*
* @return clientId
*/
private static String getClientId() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication instanceof OAuth2Authentication) {
OAuth2Authentication auth2Authentication = (OAuth2Authentication) authentication;
return auth2Authentication.getOAuth2Request().getClientId();
}
return null;
}
/**
* 获取用户名称
*
* @return username
*/
private static String getUsername() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication == null) {
return null;
}
return authentication.getName();
}
}
+3 -3
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common</artifactId>
<version>${pigx.version}</version>
<version>1.7.0</version>
</parent>
<artifactId>pigx-common-security</artifactId>
@@ -38,7 +38,7 @@
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-core</artifactId>
<version>${pigx.version}</version>
<version>1.7.0</version>
</dependency>
<!--安全模块-->
<dependency>
@@ -49,7 +49,7 @@
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-upms-api</artifactId>
<version>${pigx.version}</version>
<version>1.7.0</version>
</dependency>
</dependencies>
</project>
+1 -7
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common</artifactId>
<version>${pigx.version}</version>
<version>1.7.0</version>
</parent>
<artifactId>pigx-common-swagger</artifactId>
@@ -34,12 +34,6 @@
<dependencies>
<!--安全模块支持swagger security-->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-security</artifactId>
<version>${pigx.version}</version>
</dependency>
<!--swagger 依赖-->
<dependency>
<groupId>io.springfox</groupId>
+2 -2
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common</artifactId>
<version>${pigx.version}</version>
<version>1.7.0</version>
</parent>
<artifactId>pigx-common-transaction</artifactId>
@@ -17,7 +17,7 @@
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-core</artifactId>
<version>${pigx.version}</version>
<version>1.7.0</version>
</dependency>
<!--lcn 模块端控制依赖-->
<dependency>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx</artifactId>
<version>${pigx.version}</version>
<version>1.7.0</version>
</parent>
<artifactId>pigx-common</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx</artifactId>
<version>${pigx.version}</version>
<version>1.7.0</version>
</parent>
<artifactId>pigx-config</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx</artifactId>
<version>${pigx.version}</version>
<version>1.7.0</version>
</parent>
<artifactId>pigx-eureka</artifactId>
+4 -2
View File
@@ -7,8 +7,10 @@ spring:
name: pig
password: pig
application:
name: pigx-eureka
name: pig-eureka
cloud:
config:
enabled: false
# docker-compose部署时候 hostname 换成pigx-eureka
# 类似的 redis 使用pigx-redis ,gateway 换成 pigx-gateway
eureka:
+2 -2
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx</artifactId>
<version>${pigx.version}</version>
<version>1.7.0</version>
</parent>
<artifactId>pigx-gateway</artifactId>
@@ -57,7 +57,7 @@
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-core</artifactId>
<version>${pigx.version}</version>
<version>1.7.0</version>
</dependency>
<!--接口文档-->
<dependency>
+2 -2
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-upms</artifactId>
<version>${pigx.version}</version>
<version>1.7.0</version>
</parent>
<artifactId>pigx-upms-api</artifactId>
@@ -38,7 +38,7 @@
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-core</artifactId>
<version>${pigx.version}</version>
<version>1.7.0</version>
</dependency>
</dependencies>
</project>
+7 -6
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-upms</artifactId>
<version>${pigx.version}</version>
<version>1.7.0</version>
</parent>
<artifactId>pigx-upms-biz</artifactId>
@@ -37,19 +37,19 @@
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-upms-api</artifactId>
<version>${pigx.version}</version>
<version>1.7.0</version>
</dependency>
<!--日志处理-->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-log</artifactId>
<version>${pigx.version}</version>
<version>1.7.0</version>
</dependency>
<!--swagger-->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-swagger</artifactId>
<version>${pigx.version}</version>
<version>1.7.0</version>
</dependency>
<!--eureka 客户端-->
<dependency>
@@ -63,8 +63,9 @@
</dependency>
<!--spring security 、oauth、jwt依赖-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-security</artifactId>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-security</artifactId>
<version>1.7.0</version>
</dependency>
<!--mybatis-->
<dependency>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx</artifactId>
<version>${pigx.version}</version>
<version>1.7.0</version>
</parent>
<artifactId>pigx-upms</artifactId>
+10 -4
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-visual</artifactId>
<version>${pigx.version}</version>
<version>1.7.0</version>
</parent>
<artifactId>pigx-codegen</artifactId>
@@ -34,13 +34,19 @@
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-core</artifactId>
<version>${pigx.version}</version>
<version>1.7.0</version>
</dependency>
<!--swagger 内置安全模块-->
<!--swagger-->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-swagger</artifactId>
<version>${pigx.version}</version>
<version>1.7.0</version>
</dependency>
<!--安全模块-->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-security</artifactId>
<version>1.7.0</version>
</dependency>
<!--代码生成模板引擎-->
<dependency>
+10 -4
View File
@@ -23,7 +23,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-visual</artifactId>
<version>${pigx.version}</version>
<version>1.7.0</version>
</parent>
<artifactId>pigx-daemon</artifactId>
@@ -41,7 +41,7 @@
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-job</artifactId>
<version>${pigx.version}</version>
<version>1.7.0</version>
</dependency>
<!--mybatis-->
<dependency>
@@ -64,11 +64,17 @@
<artifactId>curator-recipes</artifactId>
<version>${curator.version}</version>
</dependency>
<!--swagger 内置安全模块-->
<!--swagger -->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-swagger</artifactId>
<version>${pigx.version}</version>
<version>1.7.0</version>
</dependency>
<!-- 安全模块-->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-security</artifactId>
<version>1.7.0</version>
</dependency>
<!--web 模块-->
<dependency>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-visual</artifactId>
<version>${pigx.version}</version>
<version>1.7.0</version>
</parent>
<artifactId>pigx-monitor</artifactId>
+2 -2
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-visual</artifactId>
<version>${pigx.version}</version>
<version>1.7.0</version>
</parent>
<artifactId>pigx-tx-manager</artifactId>
@@ -63,7 +63,7 @@
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-core</artifactId>
<version>${pigx.version}</version>
<version>1.7.0</version>
</dependency>
</dependencies>
<build>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx</artifactId>
<version>${pigx.version}</version>
<version>1.7.0</version>
</parent>
<artifactId>pigx-visual</artifactId>
+1 -2
View File
@@ -24,13 +24,12 @@
<groupId>com.pig4cloud</groupId>
<artifactId>pigx</artifactId>
<version>${pigx.version}</version>
<version>1.7.0</version>
<name>${project.artifactId}</name>
<packaging>pom</packaging>
<url>https://www.pig4cloud.com</url>
<properties>
<pigx.version>1.7.0</pigx.version>
<spring-boot.version>2.0.6.RELEASE</spring-boot.version>
<spring-cloud.version>Finchley.SR2</spring-cloud.version>
<spring-platform.version>Cairo-SR3</spring-platform.version>