Pārlūkot izejas kodu

:recycle: 重构代码。@EnablePigxResoureServer 一个注解接入OAuth

冷冷 6 gadi atpakaļ
vecāks
revīzija
44ac88de6e
32 mainītis faili ar 329 papildinājumiem un 129 dzēšanām
  1. 8 3
      pigx-auth/pom.xml
  2. 1 1
      pigx-common/pigx-common-core/pom.xml
  3. 1 7
      pigx-common/pigx-common-job/pom.xml
  4. 10 6
      pigx-common/pigx-common-log/pom.xml
  5. 36 4
      pigx-common/pigx-common-log/src/main/java/com/pig4cloud/pigx/common/log/util/SysLogUtils.java
  6. 3 7
      pigx-common/pigx-common-security/pom.xml
  7. 8 0
      pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/annotation/EnablePigxResourceServer.java
  8. 40 0
      pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/PermitAllUrlProperties.java
  9. 8 0
      pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/PigxResourceServerAutoConfiguration.java
  10. 1 7
      pigx-common/pigx-common-swagger/pom.xml
  11. 2 2
      pigx-common/pigx-common-transaction/pom.xml
  12. 1 1
      pigx-common/pom.xml
  13. 1 1
      pigx-config/pom.xml
  14. 53 0
      pigx-config/src/main/resources/config/pigx-activiti-dev.yml
  15. 1 1
      pigx-eureka/pom.xml
  16. 4 2
      pigx-eureka/src/main/resources/bootstrap.yml
  17. 2 2
      pigx-gateway/pom.xml
  18. 2 2
      pigx-upms/pigx-upms-api/pom.xml
  19. 4 4
      pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/TreeUtil.java
  20. 7 6
      pigx-upms/pigx-upms-biz/pom.xml
  21. 15 15
      pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/DictController.java
  22. 21 0
      pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysDeptRelationService.java
  23. 53 0
      pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysDeptRelationServiceImpl.java
  24. 19 43
      pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysDeptServiceImpl.java
  25. 1 1
      pigx-upms/pom.xml
  26. 10 4
      pigx-visual/pigx-codegen/pom.xml
  27. 2 0
      pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/PigxCodeGenApplication.java
  28. 10 4
      pigx-visual/pigx-daemon/pom.xml
  29. 1 1
      pigx-visual/pigx-monitor/pom.xml
  30. 2 2
      pigx-visual/pigx-tx-manager/pom.xml
  31. 1 1
      pigx-visual/pom.xml
  32. 1 2
      pom.xml

+ 8 - 3
pigx-auth/pom.xml

@@ -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,18 @@
 		<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>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-jdbc</artifactId>
 		</dependency>
 		<!--缓存操作相关-->
 		<dependency>

+ 1 - 1
pigx-common/pigx-common-core/pom.xml

@@ -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
pigx-common/pigx-common-job/pom.xml

@@ -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
pigx-common/pigx-common-log/pom.xml

@@ -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>com.pig4cloud</groupId>
-			<artifactId>pigx-common-security</artifactId>
-			<version>${pigx.version}</version>
+			<groupId>org.springframework.security</groupId>
+			<artifactId>spring-security-core</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.security.oauth</groupId>
+			<artifactId>spring-security-oauth2</artifactId>
 		</dependency>
 	</dependencies>
 </project>

+ 36 - 4
pigx-common/pigx-common-log/src/main/java/com/pig4cloud/pigx/common/log/util/SysLogUtils.java

@@ -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 - 7
pigx-common/pigx-common-security/pom.xml

@@ -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,22 +38,18 @@
 		<dependency>
 			<groupId>com.pig4cloud</groupId>
 			<artifactId>pigx-common-core</artifactId>
-			<version>${pigx.version}</version>
+			<version>1.7.0</version>
 		</dependency>
 		<!--安全模块-->
 		<dependency>
 			<groupId>org.springframework.cloud</groupId>
 			<artifactId>spring-cloud-starter-security</artifactId>
 		</dependency>
-		<dependency>
-			<groupId>org.springframework.boot</groupId>
-			<artifactId>spring-boot-starter-jdbc</artifactId>
-		</dependency>
 		<!--UPMS API-->
 		<dependency>
 			<groupId>com.pig4cloud</groupId>
 			<artifactId>pigx-upms-api</artifactId>
-			<version>${pigx.version}</version>
+			<version>1.7.0</version>
 		</dependency>
 	</dependencies>
 </project>

+ 8 - 0
pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/annotation/EnablePigxResourceServer.java

@@ -0,0 +1,8 @@
+package com.pig4cloud.pigx.common.security;
+
+/**
+ * @author lengleng
+ * @date 2018/11/10
+ */
+public @interface EnablePigxResourceServer {
+}

+ 40 - 0
pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/PermitAllUrlProperties.java

@@ -0,0 +1,40 @@
+/*
+ *    Copyright (c) 2018-2025, lengleng All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the pig4cloud.com developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: lengleng (wangiegie@gmail.com)
+ */
+
+package com.pig4cloud.pigx.common.security.component;
+
+import lombok.Data;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author lengleng
+ * @date 2018/11/10
+ * <p>
+ * 资源服务器对外直接暴露URL
+ */
+@Data
+@Configuration
+@ConditionalOnExpression("!'${ignore}'.isEmpty()")
+@ConfigurationProperties(prefix = "ignore")
+public class PermitAllUrlProperties {
+	private List<String> urls = new ArrayList<>();
+}

+ 8 - 0
pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/PigxResourceServerAutoConfiguration.java

@@ -0,0 +1,8 @@
+package com.pig4cloud.pigx.common.security;
+
+/**
+ * @author lengleng
+ * @date 2018/11/10
+ */
+public class PigxResourceServerAutoConfiguration {
+}

+ 1 - 7
pigx-common/pigx-common-swagger/pom.xml

@@ -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
pigx-common/pigx-common-transaction/pom.xml

@@ -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
pigx-common/pom.xml

@@ -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
pigx-config/pom.xml

@@ -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>

+ 53 - 0
pigx-config/src/main/resources/config/pigx-activiti-dev.yml

@@ -0,0 +1,53 @@
+## spring security 配置
+security:
+  oauth2:
+    client:
+      client-id: ENC(tz2NM4GcmnE7sNJTYL8ZSg==)
+      client-secret: ENC(tz2NM4GcmnE7sNJTYL8ZSg==)
+      scope: server
+
+## 定时任务
+spring:
+  # 保存定时任务的数据源
+  datasource:
+    type: com.zaxxer.hikari.HikariDataSource
+    driver-class-name: com.mysql.jdbc.Driver
+    username: root
+    password:  root
+    url: jdbc:mysql://pigx-mysql:3306/pigxx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
+  elasticjob:
+    # 分布式任务协调依赖zookeeper
+    zookeeper:
+      server-lists: pigx-zookeeper:2181
+      namespace: pigx-daemon
+    # 普通任务
+    simples:
+      spring-simple-job:
+        job-class: com.pig4cloud.pigx.daemon.job.PigxSimpleJob
+        cron: 0 0 0/1 * * ?
+        sharding-total-count: 3
+        sharding-item-parameters: 0=service1,1=service2,2=service3
+        eventTraceRdbDataSource: 'dataSource'
+        listener:
+          listener-class: com.pig4cloud.pigx.daemon.listener.PigxElasticJobListener
+      spring-simple-job2:
+        job-class: com.pig4cloud.pigx.daemon.job.PigxSimpleJob2
+        cron: 0 0 0/1 * * ?
+        sharding-total-count: 3
+        sharding-item-parameters: 0=service1,1=service2,2=service3
+        eventTraceRdbDataSource: 'dataSource'
+        listener:
+          listener-class: com.pig4cloud.pigx.daemon.listener.PigxElasticJobListener
+    # 简单任务
+    dataflows:
+      spring-dataflow-job:
+        job-class: com.pig4cloud.pigx.daemon.job.PigxDataflowJob
+        cron: 0 0 0/1 * * ?
+        sharding-total-count: 3
+        sharding-item-parameters: 0=service1,1=service2,2=service3
+        streaming-process: true
+        eventTraceRdbDataSource: 'dataSource'
+        listener:
+          distributed-listener-class: com.pig4cloud.pigx.daemon.listener.PigxDistributeElasticJobListener
+          started-timeout-milliseconds: 5000
+          completed-timeout-milliseconds: 10000

+ 1 - 1
pigx-eureka/pom.xml

@@ -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
pigx-eureka/src/main/resources/bootstrap.yml

@@ -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
pigx-gateway/pom.xml

@@ -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>
@@ -63,7 +63,7 @@
 		<dependency>
 			<groupId>com.pig4cloud</groupId>
 			<artifactId>pigx-common-core</artifactId>
-			<version>${pigx.version}</version>
+			<version>1.7.0</version>
 		</dependency>
 		<!--缓存-->
 		<dependency>

+ 2 - 2
pigx-upms/pigx-upms-api/pom.xml

@@ -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>

+ 4 - 4
pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/TreeUtil.java

@@ -40,7 +40,7 @@ public class TreeUtil {
 	 */
 	public static <T extends TreeNode> List<T> bulid(List<T> treeNodes, Object root) {
 
-		List<T> trees = new ArrayList<T>();
+		List<T> trees = new ArrayList<>();
 
 		for (T treeNode : treeNodes) {
 
@@ -51,7 +51,7 @@ public class TreeUtil {
 			for (T it : treeNodes) {
 				if (it.getParentId() == treeNode.getId()) {
 					if (treeNode.getChildren() == null) {
-						treeNode.setChildren(new ArrayList<TreeNode>());
+						treeNode.setChildren(new ArrayList<>());
 					}
 					treeNode.add(it);
 				}
@@ -86,7 +86,7 @@ public class TreeUtil {
 		for (T it : treeNodes) {
 			if (treeNode.getId() == it.getParentId()) {
 				if (treeNode.getChildren() == null) {
-					treeNode.setChildren(new ArrayList<TreeNode>());
+					treeNode.setChildren(new ArrayList<>());
 				}
 				treeNode.add(findChildren(it, treeNodes));
 			}
@@ -102,7 +102,7 @@ public class TreeUtil {
 	 * @return
 	 */
 	public static List<MenuTree> bulidTree(List<SysMenu> menus, int root) {
-		List<MenuTree> trees = new ArrayList<MenuTree>();
+		List<MenuTree> trees = new ArrayList<>();
 		MenuTree node;
 		for (SysMenu menu : menus) {
 			node = new MenuTree();

+ 7 - 6
pigx-upms/pigx-upms-biz/pom.xml

@@ -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,13 +37,13 @@
 		<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>
 		<!--缓存依赖-->
 		<dependency>
@@ -55,7 +55,7 @@
 		<dependency>
 			<groupId>com.pig4cloud</groupId>
 			<artifactId>pigx-common-swagger</artifactId>
-			<version>${pigx.version}</version>
+			<version>1.7.0</version>
 		</dependency>
 		<!--eureka 客户端-->
 		<dependency>
@@ -69,8 +69,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>
 		<!--支持动态路由配置 -->
 		<dependency>

+ 15 - 15
pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/DictController.java

@@ -47,7 +47,7 @@ import java.util.Map;
  * @since 2017-11-19
  */
 @RestController
-@RequestMapping("/dict")
+@RequestMapping("/dict" )
 public class DictController {
 	@Autowired
 	private SysDictService sysDictService;
@@ -58,7 +58,7 @@ public class DictController {
 	 * @param id ID
 	 * @return 字典信息
 	 */
-	@GetMapping("/{id}")
+	@GetMapping("/{id}" )
 	public SysDict dict(@PathVariable Integer id) {
 		return sysDictService.selectById(id);
 	}
@@ -69,7 +69,7 @@ public class DictController {
 	 * @param params 分页对象
 	 * @return 分页对象
 	 */
-	@GetMapping("/dictPage")
+	@GetMapping("/dictPage" )
 	public Page dictPage(@RequestParam Map<String, Object> params) {
 		return sysDictService.selectPage(new Query<>(params), new EntityWrapper<>());
 	}
@@ -80,8 +80,8 @@ public class DictController {
 	 * @param type 类型
 	 * @return 同类型字典
 	 */
-	@GetMapping("/type/{type}")
-	@Cacheable(value = "dict_details", key = "#type")
+	@GetMapping("/type/{type}" )
+	@Cacheable(value = "dict_details", key = "#type" )
 	public List<SysDict> findDictByType(@PathVariable String type) {
 		SysDict condition = new SysDict();
 		condition.setDelFlag(CommonConstant.STATUS_NORMAL);
@@ -95,10 +95,10 @@ public class DictController {
 	 * @param sysDict 字典信息
 	 * @return success、false
 	 */
-	@SysLog("添加字典")
+	@SysLog("添加字典" )
 	@PostMapping
-	@CacheEvict(value = "dict_details", key = "#sysDict.type")
-	@PreAuthorize("@pms.hasPermission('sys_dict_add')")
+	@CacheEvict(value = "dict_details", key = "#sysDict.type" )
+	@PreAuthorize("@pms.hasPermission('sys_dict_add')" )
 	public R<Boolean> dict(@Valid @RequestBody SysDict sysDict) {
 		return new R<>(sysDictService.insert(sysDict));
 	}
@@ -110,10 +110,10 @@ public class DictController {
 	 * @param type 类型
 	 * @return R
 	 */
-	@SysLog("删除字典")
-	@DeleteMapping("/{id}/{type}")
-	@CacheEvict(value = "dict_details", key = "#type")
-	@PreAuthorize("@pms.hasPermission('sys_dict_del')")
+	@SysLog("删除字典" )
+	@DeleteMapping("/{id}/{type}" )
+	@CacheEvict(value = "dict_details", key = "#type" )
+	@PreAuthorize("@pms.hasPermission('sys_dict_del')" )
 	public R<Boolean> deleteDict(@PathVariable Integer id, @PathVariable String type) {
 		return new R<>(sysDictService.deleteById(id));
 	}
@@ -125,9 +125,9 @@ public class DictController {
 	 * @return success/false
 	 */
 	@PutMapping
-	@SysLog("修改字典")
-	@CacheEvict(value = "dict_details", key = "#sysDict.type")
-	@PreAuthorize("@pms.hasPermission('sys_dict_edit')")
+	@SysLog("修改字典" )
+	@CacheEvict(value = "dict_details", key = "#sysDict.type" )
+	@PreAuthorize("@pms.hasPermission('sys_dict_edit')" )
 	public R<Boolean> editDict(@Valid @RequestBody SysDict sysDict) {
 		return new R<>(sysDictService.updateById(sysDict));
 	}

+ 21 - 0
pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysDeptRelationService.java

@@ -20,6 +20,7 @@
 package com.pig4cloud.pigx.admin.service;
 
 import com.baomidou.mybatisplus.service.IService;
+import com.pig4cloud.pigx.admin.api.entity.SysDept;
 import com.pig4cloud.pigx.admin.api.entity.SysDeptRelation;
 
 /**
@@ -32,4 +33,24 @@ import com.pig4cloud.pigx.admin.api.entity.SysDeptRelation;
  */
 public interface SysDeptRelationService extends IService<SysDeptRelation> {
 
+	/**
+	 * 新建部门关系
+	 *
+	 * @param sysDept 部门
+	 */
+	void insertDeptRelation(SysDept sysDept);
+
+	/**
+	 * 通过ID删除部门关系
+	 *
+	 * @param id
+	 */
+	void deleteAllDeptRealtion(Integer id);
+
+	/**
+	 * 更新部门关系
+	 *
+	 * @param relation
+	 */
+	void updateDeptRealtion(SysDeptRelation relation);
 }

+ 53 - 0
pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysDeptRelationServiceImpl.java

@@ -19,12 +19,18 @@
 
 package com.pig4cloud.pigx.admin.service.impl;
 
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
+import com.pig4cloud.pigx.admin.api.entity.SysDept;
 import com.pig4cloud.pigx.admin.api.entity.SysDeptRelation;
 import com.pig4cloud.pigx.admin.mapper.SysDeptRelationMapper;
 import com.pig4cloud.pigx.admin.service.SysDeptRelationService;
+import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+import java.util.stream.Collectors;
+
 /**
  * <p>
  * 服务实现类
@@ -34,6 +40,53 @@ import org.springframework.stereotype.Service;
  * @since 2018-02-12
  */
 @Service
+@AllArgsConstructor
 public class SysDeptRelationServiceImpl extends ServiceImpl<SysDeptRelationMapper, SysDeptRelation> implements SysDeptRelationService {
+	private final SysDeptRelationMapper sysDeptRelationMapper;
+
+	/**
+	 * 维护部门关系
+	 *
+	 * @param sysDept 部门
+	 */
+	@Override
+	public void insertDeptRelation(SysDept sysDept) {
+		//增加部门关系表
+		SysDeptRelation condition = new SysDeptRelation();
+		condition.setDescendant(sysDept.getParentId());
+		List<SysDeptRelation> relationList = sysDeptRelationMapper
+			.selectList(new EntityWrapper<>(condition))
+			.stream().map(relation -> {
+				relation.setDescendant(sysDept.getDeptId());
+				return relation;
+			}).collect(Collectors.toList());
+		this.insertBatch(relationList);
+
+		//自己也要维护到关系表中
+		SysDeptRelation own = new SysDeptRelation();
+		own.setDescendant(sysDept.getDeptId());
+		own.setAncestor(sysDept.getDeptId());
+		sysDeptRelationMapper.insert(own);
+	}
+
+	/**
+	 * 通过ID删除部门关系
+	 *
+	 * @param id
+	 */
+	@Override
+	public void deleteAllDeptRealtion(Integer id) {
+		baseMapper.deleteAllDeptRealtion(id);
+	}
+
+	/**
+	 * 更新部门关系
+	 *
+	 * @param relation
+	 */
+	@Override
+	public void updateDeptRealtion(SysDeptRelation relation) {
+		baseMapper.updateDeptRealtion(relation);
+	}
 
 }

+ 19 - 43
pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysDeptServiceImpl.java

@@ -26,7 +26,7 @@ import com.pig4cloud.pigx.admin.api.entity.SysDept;
 import com.pig4cloud.pigx.admin.api.entity.SysDeptRelation;
 import com.pig4cloud.pigx.admin.api.vo.TreeUtil;
 import com.pig4cloud.pigx.admin.mapper.SysDeptMapper;
-import com.pig4cloud.pigx.admin.mapper.SysDeptRelationMapper;
+import com.pig4cloud.pigx.admin.service.SysDeptRelationService;
 import com.pig4cloud.pigx.admin.service.SysDeptService;
 import com.pig4cloud.pigx.common.core.constant.CommonConstant;
 import lombok.AllArgsConstructor;
@@ -34,8 +34,8 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 
 import java.time.LocalDateTime;
-import java.util.ArrayList;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -48,8 +48,7 @@ import java.util.List;
 @Service
 @AllArgsConstructor
 public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> implements SysDeptService {
-	private final SysDeptMapper sysDeptMapper;
-	private final SysDeptRelationMapper sysDeptRelationMapper;
+	private final SysDeptRelationService sysDeptRelationService;
 
 	/**
 	 * 添加信息部门
@@ -62,30 +61,10 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
 		SysDept sysDept = new SysDept();
 		BeanUtils.copyProperties(dept, sysDept);
 		this.insert(sysDept);
-		this.insertDeptRelation(sysDept);
+		sysDeptRelationService.insertDeptRelation(sysDept);
 		return Boolean.TRUE;
 	}
 
-	/**
-	 * 维护部门关系
-	 *
-	 * @param sysDept 部门
-	 */
-	private void insertDeptRelation(SysDept sysDept) {
-		//增加部门关系表
-		SysDeptRelation deptRelation = new SysDeptRelation();
-		deptRelation.setDescendant(sysDept.getParentId());
-		List<SysDeptRelation> deptRelationList = sysDeptRelationMapper.selectList(new EntityWrapper<>(deptRelation));
-		for (SysDeptRelation sysDeptRelation : deptRelationList) {
-			sysDeptRelation.setDescendant(sysDept.getDeptId());
-			sysDeptRelationMapper.insert(sysDeptRelation);
-		}
-		//自己也要维护到关系表中
-		SysDeptRelation own = new SysDeptRelation();
-		own.setDescendant(sysDept.getDeptId());
-		own.setAncestor(sysDept.getDeptId());
-		sysDeptRelationMapper.insert(own);
-	}
 
 	/**
 	 * 删除部门
@@ -100,7 +79,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
 		sysDept.setUpdateTime(LocalDateTime.now());
 		sysDept.setDelFlag(CommonConstant.STATUS_DEL);
 		this.deleteById(sysDept);
-		sysDeptRelationMapper.deleteAllDeptRealtion(id);
+		sysDeptRelationService.deleteAllDeptRealtion(id);
 		return Boolean.TRUE;
 	}
 
@@ -118,7 +97,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
 		SysDeptRelation relation = new SysDeptRelation();
 		relation.setAncestor(sysDept.getParentId());
 		relation.setDescendant(sysDept.getDeptId());
-		sysDeptRelationMapper.updateDeptRealtion(relation);
+		sysDeptRelationService.updateDeptRealtion(relation);
 		return Boolean.TRUE;
 	}
 
@@ -131,7 +110,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
 	@Override
 	public List<DeptTree> selectListTree(EntityWrapper<SysDept> sysDeptEntityWrapper) {
 		sysDeptEntityWrapper.orderBy("order_num", false);
-		return getDeptTree(this.selectList(sysDeptEntityWrapper), 0);
+		return getDeptTree(this.selectList(sysDeptEntityWrapper));
 	}
 
 
@@ -139,22 +118,19 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
 	 * 构建部门树
 	 *
 	 * @param depts 部门
-	 * @param root  根节点
 	 * @return
 	 */
-	private List<DeptTree> getDeptTree(List<SysDept> depts, int root) {
-		List<DeptTree> trees = new ArrayList<>();
-		DeptTree node;
-		for (SysDept dept : depts) {
-			if (dept.getParentId().equals(dept.getDeptId())) {
-				continue;
-			}
-			node = new DeptTree();
-			node.setId(dept.getDeptId());
-			node.setParentId(dept.getParentId());
-			node.setName(dept.getName());
-			trees.add(node);
-		}
-		return TreeUtil.bulid(trees, root);
+	private List<DeptTree> getDeptTree(List<SysDept> depts) {
+
+		List<DeptTree> treeList = depts.stream()
+			.filter(dept -> !dept.getDeptId().equals(dept.getParentId()))
+			.map(dept -> {
+				DeptTree node = new DeptTree();
+				node.setId(dept.getDeptId());
+				node.setParentId(dept.getParentId());
+				node.setName(dept.getName());
+				return node;
+			}).collect(Collectors.toList());
+		return TreeUtil.bulid(treeList, 0);
 	}
 }

+ 1 - 1
pigx-upms/pom.xml

@@ -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
pigx-visual/pigx-codegen/pom.xml

@@ -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>

+ 2 - 0
pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/PigxCodeGenApplication.java

@@ -17,6 +17,7 @@
 
 package com.pig4cloud.pigx.codegen;
 
+import com.pig4cloud.pigx.common.security.feign.EnablePigxFeignClients;
 import com.pig4cloud.pigx.common.swagger.annotation.EnablePigxSwagger2;
 import org.springframework.boot.SpringApplication;
 import org.springframework.cloud.client.SpringCloudApplication;
@@ -28,6 +29,7 @@ import org.springframework.cloud.client.SpringCloudApplication;
  */
 @EnablePigxSwagger2
 @SpringCloudApplication
+@EnablePigxFeignClients
 public class PigxCodeGenApplication {
 
 	public static void main(String[] args) {

+ 10 - 4
pigx-visual/pigx-daemon/pom.xml

@@ -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
pigx-visual/pigx-monitor/pom.xml

@@ -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
pigx-visual/pigx-tx-manager/pom.xml

@@ -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
pigx-visual/pom.xml

@@ -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
pom.xml

@@ -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>