Просмотр исходного кода

:recycle: 重构代码。优化代码逻辑,方便扩展资源服务器

冷冷 7 лет назад
Родитель
Сommit
336f1b944e
25 измененных файлов с 208 добавлено и 99 удалено
  1. 6 0
      pigx-auth/pom.xml
  2. 1 1
      pigx-auth/src/main/java/com/pig4cloud/pigx/auth/config/WebSecurityConfigurer.java
  3. 9 1
      pigx-common/pigx-common-core/pom.xml
  4. 5 0
      pigx-common/pigx-common-log/pom.xml
  5. 1 1
      pigx-common/pigx-common-log/src/main/java/com/pig4cloud/pigx/common/log/util/SysLogUtils.java
  6. 4 7
      pigx-common/pigx-common-security/pom.xml
  7. 65 0
      pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/PigxResourceServerConfigurerAdapter.java
  8. 1 1
      pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/mobile/MobileAuthenticationProvider.java
  9. 1 1
      pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/mobile/MobileSecurityConfigurer.java
  10. 69 0
      pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/service/PigxUser.java
  11. 2 1
      pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/util/PigxUserDetailsService.java
  12. 14 17
      pigx-auth/src/main/java/com/pig4cloud/pigx/auth/service/PigxUserDetailsServiceImpl.java
  13. 6 5
      pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/util/SecurityUtils.java
  14. 1 0
      pigx-common/pigx-common-security/src/main/resources/META-INF/spring.factories
  15. 0 6
      pigx-common/pigx-common-swagger/pom.xml
  16. 1 1
      pigx-upms/pigx-upms-api/pom.xml
  17. 1 1
      pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/PigxAdminApplication.java
  18. 3 22
      pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/config/ResourceServerConfigurer.java
  19. 3 3
      pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/DeptController.java
  20. 2 2
      pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/UserController.java
  21. 4 5
      pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysDeptServiceImpl.java
  22. 1 3
      pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysSocialDetailsServiceImpl.java
  23. 4 10
      pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/config/ResourceServerConfigurer.java
  24. 4 7
      pigx-visual/pigx-daemon/src/main/java/com/pig4cloud/pigx/daemon/config/ResourceServerConfigurer.java
  25. 0 4
      pigx-visual/pigx-tx-manager/pom.xml

+ 6 - 0
pigx-auth/pom.xml

@@ -46,6 +46,12 @@
 			<artifactId>pigx-upms-api</artifactId>
 			<version>${pigx.version}</version>
 		</dependency>
+		<!--security-->
+		<dependency>
+			<groupId>com.pig4cloud</groupId>
+			<artifactId>pigx-common-security</artifactId>
+			<version>${pigx.version}</version>
+		</dependency>
 		<!--spring security 、oauth、jwt依赖-->
 		<dependency>
 			<groupId>org.springframework.cloud</groupId>

+ 1 - 1
pigx-auth/src/main/java/com/pig4cloud/pigx/auth/config/WebSecurityConfigurer.java

@@ -22,7 +22,7 @@ package com.pig4cloud.pigx.auth.config;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.pig4cloud.pigx.common.security.mobile.MobileLoginSuccessHandler;
 import com.pig4cloud.pigx.common.security.mobile.MobileSecurityConfigurer;
-import com.pig4cloud.pigx.common.security.util.PigxUserDetailsService;
+import com.pig4cloud.pigx.common.security.service.PigxUserDetailsService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;

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

@@ -50,7 +50,6 @@
 		<dependency>
 			<groupId>javax.servlet</groupId>
 			<artifactId>javax.servlet-api</artifactId>
-			<scope>provided</scope>
 		</dependency>
 		<!--jacksonJSR310规范-->
 		<dependency>
@@ -64,5 +63,14 @@
 			<version>${mbp.boot.version}</version>
 			<scope>compile</scope>
 		</dependency>
+		<!--feign 依赖-->
+		<dependency>
+			<groupId>io.github.openfeign</groupId>
+			<artifactId>feign-okhttp</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.cloud</groupId>
+			<artifactId>spring-cloud-starter-openfeign</artifactId>
+		</dependency>
 	</dependencies>
 </project>

+ 5 - 0
pigx-common/pigx-common-log/pom.xml

@@ -47,5 +47,10 @@
 			<artifactId>pigx-upms-api</artifactId>
 			<version>${pigx.version}</version>
 		</dependency>
+		<dependency>
+			<groupId>com.pig4cloud</groupId>
+			<artifactId>pigx-common-security</artifactId>
+			<version>${pigx.version}</version>
+		</dependency>
 	</dependencies>
 </project>

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

@@ -53,7 +53,7 @@ public class SysLogUtils {
 		});
 
 		SysLog sysLog = new SysLog();
-		sysLog.setCreateBy(SecurityUtils.getUser());
+		sysLog.setCreateBy(SecurityUtils.getUser().getUsername());
 		sysLog.setType(CommonConstant.STATUS_NORMAL);
 		sysLog.setRemoteAddr(HttpUtil.getClientIP(request));
 		sysLog.setRequestUri(URLUtil.getPath(request.getRequestURI()));

+ 4 - 7
pigx-common/pigx-common-security/pom.xml

@@ -46,14 +46,11 @@
 			<groupId>org.springframework.cloud</groupId>
 			<artifactId>spring-cloud-starter-security</artifactId>
 		</dependency>
-		<!--feign 依赖-->
+		<!--UPMS API-->
 		<dependency>
-			<groupId>io.github.openfeign</groupId>
-			<artifactId>feign-okhttp</artifactId>
-		</dependency>
-		<dependency>
-			<groupId>org.springframework.cloud</groupId>
-			<artifactId>spring-cloud-starter-openfeign</artifactId>
+			<groupId>com.pig4cloud</groupId>
+			<artifactId>pigx-upms-api</artifactId>
+			<version>${pigx.version}</version>
 		</dependency>
 	</dependencies>
 </project>

+ 65 - 0
pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/PigxResourceServerConfigurerAdapter.java

@@ -0,0 +1,65 @@
+/*
+ *    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 org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.core.userdetails.UserDetailsService;
+import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
+import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer;
+import org.springframework.security.oauth2.provider.token.DefaultAccessTokenConverter;
+import org.springframework.security.oauth2.provider.token.DefaultUserAuthenticationConverter;
+import org.springframework.security.oauth2.provider.token.RemoteTokenServices;
+
+/**
+ * @author lengleng
+ * @date 2018/6/22
+ */
+public abstract class PigxResourceServerConfigurerAdapter extends ResourceServerConfigurerAdapter {
+	@Autowired
+	protected ResourceAuthExceptionEntryPoint resourceAuthExceptionEntryPoint;
+	@Autowired
+	protected PigAccessDeniedHandler pigAccessDeniedHandler;
+	@Autowired
+	protected RemoteTokenServices remoteTokenServices;
+	@Autowired
+	protected UserDetailsService userDetailsService;
+
+	@Override
+	public abstract void configure(HttpSecurity http) throws Exception;
+
+	/**
+	 * why add  resourceId
+	 * https://stackoverflow.com/questions/28703847/how-do-you-set-a-resource-id-for-a-token
+	 *
+	 * @param resources
+	 */
+	@Override
+	public void configure(ResourceServerSecurityConfigurer resources) {
+		DefaultAccessTokenConverter accessTokenConverter = new DefaultAccessTokenConverter();
+		DefaultUserAuthenticationConverter userTokenConverter = new DefaultUserAuthenticationConverter();
+		userTokenConverter.setUserDetailsService(userDetailsService);
+		accessTokenConverter.setUserTokenConverter(userTokenConverter);
+		remoteTokenServices.setAccessTokenConverter(accessTokenConverter);
+		resources.authenticationEntryPoint(resourceAuthExceptionEntryPoint)
+			.accessDeniedHandler(pigAccessDeniedHandler)
+			.tokenServices(remoteTokenServices);
+	}
+
+
+}

+ 1 - 1
pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/mobile/MobileAuthenticationProvider.java

@@ -17,7 +17,7 @@
 
 package com.pig4cloud.pigx.common.security.mobile;
 
-import com.pig4cloud.pigx.common.security.util.PigxUserDetailsService;
+import com.pig4cloud.pigx.common.security.service.PigxUserDetailsService;
 import lombok.Getter;
 import lombok.Setter;
 import lombok.extern.slf4j.Slf4j;

+ 1 - 1
pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/mobile/MobileSecurityConfigurer.java

@@ -17,7 +17,7 @@
 
 package com.pig4cloud.pigx.common.security.mobile;
 
-import com.pig4cloud.pigx.common.security.util.PigxUserDetailsService;
+import com.pig4cloud.pigx.common.security.service.PigxUserDetailsService;
 import lombok.AllArgsConstructor;
 import org.springframework.security.authentication.AuthenticationManager;
 import org.springframework.security.config.annotation.SecurityConfigurerAdapter;

+ 69 - 0
pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/service/PigxUser.java

@@ -0,0 +1,69 @@
+/*
+ *    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.service;
+
+import lombok.Getter;
+import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.core.userdetails.User;
+
+import java.util.Collection;
+
+/**
+ * @author lengleng
+ * @date 2018/8/20
+ * 扩展用户信息
+ */
+public class PigxUser extends User {
+	/**
+	 * 用户ID
+	 */
+	@Getter
+	private Integer id;
+	/**
+	 * 部门ID
+	 */
+	@Getter
+	private Integer deptId;
+
+	/**
+	 * Construct the <code>User</code> with the details required by
+	 * {@link DaoAuthenticationProvider}.
+	 *
+	 * @param id                    用户ID
+	 * @param deptId                部门ID
+	 * @param username              the username presented to the
+	 *                              <code>DaoAuthenticationProvider</code>
+	 * @param password              the password that should be presented to the
+	 *                              <code>DaoAuthenticationProvider</code>
+	 * @param enabled               set to <code>true</code> if the user is enabled
+	 * @param accountNonExpired     set to <code>true</code> if the account has not expired
+	 * @param credentialsNonExpired set to <code>true</code> if the credentials have not
+	 *                              expired
+	 * @param accountNonLocked      set to <code>true</code> if the account is not locked
+	 * @param authorities           the authorities that should be granted to the caller if they
+	 *                              presented the correct username and password and the user is enabled. Not null.
+	 * @throws IllegalArgumentException if a <code>null</code> value was passed either as
+	 *                                  a parameter or as an element in the <code>GrantedAuthority</code> collection
+	 */
+	public PigxUser(Integer id, Integer deptId, String username, String password, boolean enabled, boolean accountNonExpired, boolean credentialsNonExpired, boolean accountNonLocked, Collection<? extends GrantedAuthority> authorities) {
+		super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities);
+		this.id = id;
+		this.deptId = id;
+	}
+}

+ 2 - 1
pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/util/PigxUserDetailsService.java

@@ -13,7 +13,8 @@
  * 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.util;
+ */
+package com.pig4cloud.pigx.common.security.service;
 
 import org.springframework.security.core.userdetails.UserDetails;
 import org.springframework.security.core.userdetails.UserDetailsService;

+ 14 - 17
pigx-auth/src/main/java/com/pig4cloud/pigx/auth/service/PigxUserDetailsServiceImpl.java

@@ -1,23 +1,21 @@
 /*
+ *    Copyright (c) 2018-2025, lengleng All rights reserved.
  *
- *      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:
+ * 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)
- *
+ * 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.auth.service;
+package com.pig4cloud.pigx.common.security.service;
 
 import cn.hutool.core.util.ArrayUtil;
 import cn.hutool.core.util.StrUtil;
@@ -27,12 +25,10 @@ import com.pig4cloud.pigx.admin.api.feign.RemoteUserService;
 import com.pig4cloud.pigx.common.core.constant.CommonConstant;
 import com.pig4cloud.pigx.common.core.constant.SecurityConstants;
 import com.pig4cloud.pigx.common.core.util.R;
-import com.pig4cloud.pigx.common.security.util.PigxUserDetailsService;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.security.core.GrantedAuthority;
 import org.springframework.security.core.authority.AuthorityUtils;
-import org.springframework.security.core.userdetails.User;
 import org.springframework.security.core.userdetails.UserDetails;
 import org.springframework.security.core.userdetails.UsernameNotFoundException;
 import org.springframework.stereotype.Service;
@@ -104,7 +100,8 @@ public class PigxUserDetailsServiceImpl implements PigxUserDetailsService {
 		SysUser user = info.getSysUser();
 		boolean enabled = StrUtil.equals(user.getDelFlag(), CommonConstant.STATUS_NORMAL);
 		// 构造security用户
-		return new User(info.getSysUser().getUsername(), SecurityConstants.BCRYPT + user.getPassword(), enabled,
+
+		return new PigxUser(user.getUserId(), user.getDeptId(), user.getUsername(), SecurityConstants.BCRYPT + user.getPassword(), enabled,
 			true, true, true, authorities);
 	}
 }

+ 6 - 5
pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/util/SecurityUtils.java

@@ -22,6 +22,7 @@ package com.pig4cloud.pigx.common.security.util;
 
 import cn.hutool.core.util.StrUtil;
 import com.pig4cloud.pigx.common.core.constant.SecurityConstants;
+import com.pig4cloud.pigx.common.security.service.PigxUser;
 import org.springframework.security.core.Authentication;
 import org.springframework.security.core.GrantedAuthority;
 import org.springframework.security.core.context.SecurityContextHolder;
@@ -48,12 +49,12 @@ public class SecurityUtils {
 	/**
 	 * 获取用户
 	 */
-	public static String getUser(Authentication authentication) {
+	public static PigxUser getUser(Authentication authentication) {
 		Object principal = authentication.getPrincipal();
-		if (principal == null) {
-			return null;
+		if (principal instanceof PigxUser) {
+			return (PigxUser) principal;
 		}
-		return (String) principal;
+		return null;
 	}
 
 	public static String getClientId() {
@@ -68,7 +69,7 @@ public class SecurityUtils {
 	/**
 	 * 获取用户
 	 */
-	public static String getUser() {
+	public static PigxUser getUser() {
 		Authentication authentication = getAuthentication();
 		if (authentication == null) {
 			return null;

+ 1 - 0
pigx-common/pigx-common-security/src/main/resources/META-INF/spring.factories

@@ -3,5 +3,6 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
   com.pig4cloud.pigx.common.security.component.PigAccessDeniedHandler,\
   com.pig4cloud.pigx.common.security.component.ResourceAuthExceptionEntryPoint,\
   com.pig4cloud.pigx.common.security.feign.PigxFeignClientConfiguration,\
+  com.pig4cloud.pigx.common.security.service.PigxUserDetailsServiceImpl,\
   com.pig4cloud.pigx.common.security.social.QqSocialConfig,\
   com.pig4cloud.pigx.common.security.social.WxSocialConfig

+ 0 - 6
pigx-common/pigx-common-swagger/pom.xml

@@ -41,12 +41,6 @@
 			<artifactId>pigx-common-security</artifactId>
 			<version>${pigx.version}</version>
 		</dependency>
-		<!--server-api-->
-		<dependency>
-			<groupId>javax.servlet</groupId>
-			<artifactId>javax.servlet-api</artifactId>
-			<scope>provided</scope>
-		</dependency>
 		<!--swagger 依赖-->
 		<dependency>
 			<groupId>io.springfox</groupId>

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

@@ -38,7 +38,7 @@
 		<!--core 工具类-->
 		<dependency>
 			<groupId>com.pig4cloud</groupId>
-			<artifactId>pigx-common-security</artifactId>
+			<artifactId>pigx-common-core</artifactId>
 			<version>${pigx.version}</version>
 		</dependency>
 	</dependencies>

+ 1 - 1
pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/PigxAdminApplication.java

@@ -31,8 +31,8 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
  * 用户统一管理系统
  */
 @EnablePigxSwagger2
-@EnableFeignClients
 @SpringCloudApplication
+@EnableFeignClients({"com.pig4cloud.pigx.admin.api.feign"})
 public class PigxAdminApplication {
 	public static void main(String[] args) {
 		SpringApplication.run(PigxAdminApplication.class, args);

+ 3 - 22
pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/config/ResourceServerConfigurer.java

@@ -19,15 +19,11 @@
 
 package com.pig4cloud.pigx.admin.config;
 
-import com.pig4cloud.pigx.common.security.component.PigAccessDeniedHandler;
-import com.pig4cloud.pigx.common.security.component.ResourceAuthExceptionEntryPoint;
-import lombok.AllArgsConstructor;
+import com.pig4cloud.pigx.common.security.component.PigxResourceServerConfigurerAdapter;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
 import org.springframework.security.config.annotation.web.builders.HttpSecurity;
 import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
-import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
-import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer;
 
 /**
  * @author lengleng
@@ -35,12 +31,8 @@ import org.springframework.security.oauth2.config.annotation.web.configurers.Res
  */
 @Configuration
 @EnableResourceServer
-@AllArgsConstructor
 @EnableGlobalMethodSecurity(prePostEnabled = true)
-public class ResourceServerConfigurer extends ResourceServerConfigurerAdapter {
-	private final PigAccessDeniedHandler pigAccessDeniedHandler;
-	private final ResourceAuthExceptionEntryPoint resourceAuthExceptionEntryPoint;
-
+public class ResourceServerConfigurer extends PigxResourceServerConfigurerAdapter {
 	@Override
 	public void configure(HttpSecurity http) throws Exception {
 		http.authorizeRequests()
@@ -53,16 +45,5 @@ public class ResourceServerConfigurer extends ResourceServerConfigurerAdapter {
 			.and().csrf().disable();
 	}
 
-	/**
-	 * why add  resourceId
-	 * https://stackoverflow.com/questions/28703847/how-do-you-set-a-resource-id-for-a-token
-	 *
-	 * @param resources
-	 * @throws Exception
-	 */
-	@Override
-	public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
-		resources.authenticationEntryPoint(resourceAuthExceptionEntryPoint)
-			.accessDeniedHandler(pigAccessDeniedHandler);
-	}
+
 }

+ 3 - 3
pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/DeptController.java

@@ -25,7 +25,7 @@ import com.pig4cloud.pigx.admin.api.entity.SysDept;
 import com.pig4cloud.pigx.admin.service.SysDeptService;
 import com.pig4cloud.pigx.common.core.constant.CommonConstant;
 import com.pig4cloud.pigx.common.core.util.R;
-import org.springframework.beans.factory.annotation.Autowired;
+import lombok.AllArgsConstructor;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
@@ -42,9 +42,9 @@ import java.util.List;
  */
 @RestController
 @RequestMapping("/dept")
+@AllArgsConstructor
 public class DeptController {
-	@Autowired
-	private SysDeptService sysDeptService;
+	private final SysDeptService sysDeptService;
 
 	/**
 	 * 通过ID查询

+ 2 - 2
pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/UserController.java

@@ -73,7 +73,7 @@ public class UserController {
 		}
 		//为空时查询当前用户
 		if (StrUtil.isBlank(username)) {
-			username = SecurityUtils.getUser();
+			username = SecurityUtils.getUser().getUsername();
 		}
 
 		return new R<>(userService.findUserInfo(EnumLoginType.PWD.getType(), username));
@@ -163,6 +163,6 @@ public class UserController {
 	 */
 	@PutMapping("/editInfo")
 	public R<Boolean> editInfo(@RequestBody UserDTO userDto) {
-		return userService.updateUserInfo(userDto, SecurityUtils.getUser());
+		return userService.updateUserInfo(userDto, SecurityUtils.getUser().getUsername());
 	}
 }

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

@@ -29,8 +29,8 @@ import com.pig4cloud.pigx.admin.mapper.SysDeptMapper;
 import com.pig4cloud.pigx.admin.mapper.SysDeptRelationMapper;
 import com.pig4cloud.pigx.admin.service.SysDeptService;
 import com.pig4cloud.pigx.common.core.constant.CommonConstant;
+import lombok.AllArgsConstructor;
 import org.springframework.beans.BeanUtils;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.time.LocalDateTime;
@@ -46,11 +46,10 @@ import java.util.List;
  * @since 2018-01-20
  */
 @Service
+@AllArgsConstructor
 public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> implements SysDeptService {
-	@Autowired
-	private SysDeptMapper sysDeptMapper;
-	@Autowired
-	private SysDeptRelationMapper sysDeptRelationMapper;
+	private final SysDeptMapper sysDeptMapper;
+	private final SysDeptRelationMapper sysDeptRelationMapper;
 
 	/**
 	 * 添加信息部门

+ 1 - 3
pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysSocialDetailsServiceImpl.java

@@ -71,9 +71,7 @@ public class SysSocialDetailsServiceImpl extends ServiceImpl<SysSocialDetailsMap
 	public Boolean bindSocial(String appId, String code) {
 		Map<String, String> result = getOpenId(appId, code);
 
-		SysUser condition = new SysUser();
-		condition.setUsername(SecurityUtils.getUser());
-		SysUser sysUser = sysUserMapper.selectOne(condition);
+		SysUser sysUser = sysUserMapper.selectById(SecurityUtils.getUser().getId());
 		sysUser.setWxOpenid(result.get("openId"));
 
 		sysUserMapper.updateAllColumnById(sysUser);

+ 4 - 10
pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/config/ResourceServerConfigurer.java

@@ -17,14 +17,12 @@
 
 package com.pig4cloud.pigx.codegen.config;
 
-import com.pig4cloud.pigx.common.security.component.PigAccessDeniedHandler;
-import com.pig4cloud.pigx.common.security.component.ResourceAuthExceptionEntryPoint;
+import com.pig4cloud.pigx.common.security.component.PigxResourceServerConfigurerAdapter;
 import lombok.AllArgsConstructor;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
 import org.springframework.security.config.annotation.web.builders.HttpSecurity;
 import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
-import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
 import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer;
 
 /**
@@ -35,9 +33,7 @@ import org.springframework.security.oauth2.config.annotation.web.configurers.Res
 @EnableResourceServer
 @AllArgsConstructor
 @EnableGlobalMethodSecurity(prePostEnabled = true)
-public class ResourceServerConfigurer extends ResourceServerConfigurerAdapter {
-	private final PigAccessDeniedHandler pigAccessDeniedHandler;
-	private final ResourceAuthExceptionEntryPoint resourceAuthExceptionEntryPoint;
+public class ResourceServerConfigurer extends PigxResourceServerConfigurerAdapter {
 
 	@Override
 	public void configure(HttpSecurity http) throws Exception {
@@ -48,14 +44,12 @@ public class ResourceServerConfigurer extends ResourceServerConfigurerAdapter {
 	}
 
 	/**
-	 * why add  resourceId
-	 * https://stackoverflow.com/questions/28703847/how-do-you-set-a-resource-id-for-a-token
+	 * 重写抽象类实现,不需要调用feign 获取 userdetils
 	 *
 	 * @param resources
-	 * @throws Exception
 	 */
 	@Override
-	public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
+	public void configure(ResourceServerSecurityConfigurer resources) {
 		resources.authenticationEntryPoint(resourceAuthExceptionEntryPoint)
 			.accessDeniedHandler(pigAccessDeniedHandler);
 	}

+ 4 - 7
pigx-visual/pigx-daemon/src/main/java/com/pig4cloud/pigx/daemon/config/ResourceServerConfigurer.java

@@ -18,6 +18,7 @@
 package com.pig4cloud.pigx.daemon.config;
 
 import com.pig4cloud.pigx.common.security.component.PigAccessDeniedHandler;
+import com.pig4cloud.pigx.common.security.component.PigxResourceServerConfigurerAdapter;
 import com.pig4cloud.pigx.common.security.component.ResourceAuthExceptionEntryPoint;
 import lombok.AllArgsConstructor;
 import org.springframework.context.annotation.Configuration;
@@ -35,9 +36,7 @@ import org.springframework.security.oauth2.config.annotation.web.configurers.Res
 @EnableResourceServer
 @AllArgsConstructor
 @EnableGlobalMethodSecurity(prePostEnabled = true)
-public class ResourceServerConfigurer extends ResourceServerConfigurerAdapter {
-	private final PigAccessDeniedHandler pigAccessDeniedHandler;
-	private final ResourceAuthExceptionEntryPoint resourceAuthExceptionEntryPoint;
+public class ResourceServerConfigurer extends PigxResourceServerConfigurerAdapter {
 
 	@Override
 	public void configure(HttpSecurity http) throws Exception {
@@ -48,14 +47,12 @@ public class ResourceServerConfigurer extends ResourceServerConfigurerAdapter {
 	}
 
 	/**
-	 * why add  resourceId
-	 * https://stackoverflow.com/questions/28703847/how-do-you-set-a-resource-id-for-a-token
+	 * 重写抽象类实现,不需要调用feign 获取 userdetils
 	 *
 	 * @param resources
-	 * @throws Exception
 	 */
 	@Override
-	public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
+	public void configure(ResourceServerSecurityConfigurer resources) {
 		resources.authenticationEntryPoint(resourceAuthExceptionEntryPoint)
 			.accessDeniedHandler(pigAccessDeniedHandler);
 	}

+ 0 - 4
pigx-visual/pigx-tx-manager/pom.xml

@@ -67,10 +67,6 @@
 			<artifactId>pigx-common-core</artifactId>
 			<version>${pigx.version}</version>
 		</dependency>
-		<dependency>
-			<groupId>javax.servlet</groupId>
-			<artifactId>javax.servlet-api</artifactId>
-		</dependency>
 	</dependencies>
 	<build>
 		<plugins>