diff --git a/dq-financial-crms/pom.xml b/dq-financial-crms/pom.xml index 8a846c97..f6f86562 100644 --- a/dq-financial-crms/pom.xml +++ b/dq-financial-crms/pom.xml @@ -21,12 +21,12 @@ - + com.daqing.financial dq-financial-api @@ -45,10 +45,6 @@ ooxml-schemas 1.0 - - org.springframework.cloud - spring-cloud-starter-openfeign - org.springframework.boot spring-boot-starter-test @@ -66,6 +62,12 @@ 2.3.28 compile + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + @@ -86,6 +88,18 @@ org.springframework.boot spring-boot-maven-plugin + + + + diff --git a/dq-financial-crms/src/main/java/com/daqing/financial/crms/DqFinancialCrmsApplication.java b/dq-financial-crms/src/main/java/com/daqing/financial/crms/DqFinancialCrmsApplication.java index 0ae25f33..73319226 100644 --- a/dq-financial-crms/src/main/java/com/daqing/financial/crms/DqFinancialCrmsApplication.java +++ b/dq-financial-crms/src/main/java/com/daqing/financial/crms/DqFinancialCrmsApplication.java @@ -1,15 +1,18 @@ package com.daqing.financial.crms; +import com.daqing.financial.hrauth.config.SecurityConfig; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Import; @EnableFeignClients(basePackages = "com.daqing.financial.crms.feign") @EnableDiscoveryClient @SpringBootApplication @ComponentScan(basePackages = "com.daqing") +@Import({SecurityConfig.class}) public class DqFinancialCrmsApplication { public static void main(String[] args) { diff --git a/dq-financial-crms/src/main/java/com/daqing/financial/crms/config/IPageConfig.java b/dq-financial-crms/src/main/java/com/daqing/financial/crms/config/IPageConfig.java index 6001a7e0..243e1e84 100644 --- a/dq-financial-crms/src/main/java/com/daqing/financial/crms/config/IPageConfig.java +++ b/dq-financial-crms/src/main/java/com/daqing/financial/crms/config/IPageConfig.java @@ -1,3 +1,4 @@ +/* package com.daqing.financial.crms.config; import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; @@ -11,3 +12,4 @@ public class IPageConfig { return new PaginationInterceptor(); } } +*/ diff --git a/dq-financial-crms/src/main/resources/bootstrap.properties b/dq-financial-crms/src/main/resources/bootstrap.properties index 9eae9596..ef1b4c95 100644 --- a/dq-financial-crms/src/main/resources/bootstrap.properties +++ b/dq-financial-crms/src/main/resources/bootstrap.properties @@ -28,6 +28,11 @@ spring.redis.jedis.pool.max-wait=-1 spring.redis.jedis.pool.max-idle=8 spring.redis.jedis.pool.min-idle=0 +#请求处理的超时时间 +ribbon.ReadTimeout: 120000 +#请求连接的超时时间 +ribbon.ConnectTimeout: 120000 + # 正式环境(prod) #服务名称 #spring.application.name=dq-financial-crms diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/config/SecurityConfig.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/config/SecurityConfig.java index c38fd051..a2e1797b 100644 --- a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/config/SecurityConfig.java +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/config/SecurityConfig.java @@ -112,9 +112,9 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { // 标识访问 `/home` 这个接口,需要具备`ADMIN`角色 // registry.antMatchers("/home").hasRole("ADMIN"); // 标识只能在 服务器本地ip[127.0.0.1或localhost] 访问 `/home` 这个接口,其他ip地址无法访问 - // registry.antMatchers("/hrms/auth/userlogin/getBackPwd").hasIpAddress("127.0.0.1"); + registry.antMatchers("/hrms/auth/permission/getUserRoles").hasIpAddress("127.0.0.1"); // 允许匿名的url - 可理解为放行接口 - 多个接口使用,分割 - registry.antMatchers("/**").permitAll(); + //registry.antMatchers("/**").permitAll(); // registry.antMatchers("/**").access("hasAuthority('admin')"); // OPTIONS(选项):查找适用于一个特定网址资源的通讯选择。 在不需执行具体的涉及数据传输的动作情况下, 允许客户端来确定与资源相关的选项以及 / 或者要求, 或是一个服务器的性能 //registry.antMatchers(HttpMethod.OPTIONS, "/**").denyAll(); @@ -139,7 +139,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { */ @Override public void configure(WebSecurity web) throws Exception { - web.ignoring().antMatchers("/**"); + //web.ignoring().antMatchers("/**"); + web.ignoring().antMatchers("/hrms/auth/permission/getUserRoles"); } } diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/controller/RolePermissionController.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/controller/RolePermissionController.java index dda29a6e..a17bfde7 100644 --- a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/controller/RolePermissionController.java +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/controller/RolePermissionController.java @@ -171,5 +171,13 @@ public class RolePermissionController { return new ResponseResult>().SUCCESS(roleList); } + @Transactional + @GetMapping("/queryPermissionList") + public ResponseResult queryPermissionList(@RequestParam("jiacan")String jiacan) { + List permissionList = permissionService.getList(jiacan); + + return new ResponseResult>().SUCCESS(permissionList); + } + } diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/dao/AuthPermissionDao.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/dao/AuthPermissionDao.java index b23cecec..30a4e1d5 100644 --- a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/dao/AuthPermissionDao.java +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/dao/AuthPermissionDao.java @@ -16,5 +16,5 @@ import java.util.List; */ @Mapper public interface AuthPermissionDao extends BaseMapper { - List selectRolePermiByPermiId(Long permissionId); + //List selectRolePermiByPermiId(Long permissionId); } diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/dao/RolePermissionMapper.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/dao/RolePermissionMapper.java index deab4157..4a99db22 100644 --- a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/dao/RolePermissionMapper.java +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/dao/RolePermissionMapper.java @@ -42,7 +42,7 @@ public interface RolePermissionMapper extends BaseMapper { EmployeeRoleEntity selectRoleByUserId(Long id); - List selectRolePermiByPermiId(Long permissionId); + //List selectRolePermiByPermiId(Long permissionId); List queryPermissionTree(); diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/feign/HrauthFeignService.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/feign/HrauthFeignService.java index e1fad3cc..1ef23424 100644 --- a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/feign/HrauthFeignService.java +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/feign/HrauthFeignService.java @@ -1,5 +1,6 @@ package com.daqing.financial.hrauth.feign; +import com.daqing.framework.domain.hrms.PermissionEntity; import com.daqing.framework.domain.hrms.RoleEntity; import com.daqing.framework.model.response.ResponseResult; import org.springframework.cloud.openfeign.FeignClient; @@ -17,4 +18,7 @@ public interface HrauthFeignService { @GetMapping("/hrms/auth/permission/getUserRoles") ResponseResult> getUserRoles(@RequestParam("userId")Integer userId); + + @GetMapping("/hrms/auth/permission/queryPermissionList") + ResponseResult> queryPermissionList(@RequestParam("jiacan")String jiacan); } diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/feign/HrmsFeignService.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/feign/HrmsFeignService.java index 6e2cbaa5..b96d5972 100644 --- a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/feign/HrmsFeignService.java +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/feign/HrmsFeignService.java @@ -1,7 +1,9 @@ package com.daqing.financial.hrauth.feign; import com.daqing.framework.domain.hrms.EmployeeEntity; +import com.daqing.framework.domain.hrms.PermissionEntity; import com.daqing.framework.domain.hrms.RoleEntity; +import com.daqing.framework.domain.hrms.RolePermissionEntity; import com.daqing.framework.model.response.ResponseResult; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; @@ -18,4 +20,10 @@ public interface HrmsFeignService { @GetMapping("/hrms/employee/getEmployeeByUserId") ResponseResult getEmployeeByUserId(@RequestParam("userId") Integer userId); + + @GetMapping("/hrms/permission/queryPermissionList") + ResponseResult> queryPermissionList(); + + @GetMapping("/hrms/permission/queryRolePermissionList") + ResponseResult> queryRolePermissionList(@RequestParam("id") Long id); } diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/handle/SecurityUser.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/handle/SecurityUser.java index e2be78f7..08c7dc91 100644 --- a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/handle/SecurityUser.java +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/handle/SecurityUser.java @@ -58,10 +58,14 @@ public class SecurityUser implements UserDetails { public Collection getAuthorities() { Collection authorities = new ArrayList<>(); if (!CollectionUtils.isEmpty(this.roleList)) { - for (Object role : this.roleList) { - SimpleGrantedAuthority authority = new SimpleGrantedAuthority("user_role"); + for (RoleEntity role : this.roleList) { + SimpleGrantedAuthority authority = new SimpleGrantedAuthority(role.getCode()); authorities.add(authority); } +// for (Object role : this.roleList) { +// SimpleGrantedAuthority authority = new SimpleGrantedAuthority("user_role"); +// authorities.add(authority); +// } } // SimpleGrantedAuthority authority = new SimpleGrantedAuthority("ADMIN"); diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/handle/UrlFilterInvocationSecurityMetadataSource.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/handle/UrlFilterInvocationSecurityMetadataSource.java index f581d105..023d4594 100644 --- a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/handle/UrlFilterInvocationSecurityMetadataSource.java +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/handle/UrlFilterInvocationSecurityMetadataSource.java @@ -5,9 +5,12 @@ import com.daqing.financial.hrauth.dao.AuthPermissionDao; import com.daqing.financial.hrauth.dao.AuthRoleDao; import com.daqing.financial.hrauth.dao.RolePermissionMapper; import com.daqing.financial.hrauth.enums.Constants; +import com.daqing.financial.hrauth.feign.HrauthFeignService; +import com.daqing.financial.hrauth.feign.HrmsFeignService; import com.daqing.framework.domain.hrms.PermissionEntity; import com.daqing.framework.domain.hrms.RoleEntity; import com.daqing.framework.domain.hrms.RolePermissionEntity; +import com.daqing.framework.model.response.ResponseResult; import lombok.extern.slf4j.Slf4j; import org.springframework.security.access.ConfigAttribute; import org.springframework.security.access.SecurityConfig; @@ -39,6 +42,9 @@ public class UrlFilterInvocationSecurityMetadataSource implements FilterInvocati @Resource AuthRoleDao roleMapper; + @Resource + HrmsFeignService hrmsFeignService; + /*** * 返回该url所需要的用户权限信息 @@ -65,11 +71,16 @@ public class UrlFilterInvocationSecurityMetadataSource implements FilterInvocati } // 数据库中所有url - List permissionList = permissionMapper.selectList(null); + //List permissionList = permissionMapper.selectList(null); + //String jiacan=null; + ResponseResult responseResult = hrmsFeignService.queryPermissionList(); + List permissionList = (List) responseResult.getData(); for (PermissionEntity permission : permissionList) { // 获取该url所对应的权限 if (requestUrl.equals(permission.getUrl())) { - List permissionEntityList = rolePermissionMapper.selectList(new QueryWrapper().eq("permission_id",permission.getId())); + //List permissionEntityList = rolePermissionMapper.selectList(new QueryWrapper().eq("permission_id",permission.getId())); + ResponseResult responseResult2 = hrmsFeignService.queryRolePermissionList(permission.getId()); + List permissionEntityList = (List) responseResult2.getData(); SecurityUser userRole = (SecurityUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();//获取spring security封装的当前用户信息对象 List list = userRole.getRoleList(); diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/RolePermissionService.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/RolePermissionService.java index 101abebc..c615ac31 100644 --- a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/RolePermissionService.java +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/RolePermissionService.java @@ -42,5 +42,7 @@ public interface RolePermissionService extends IService { List queryPermissionArrById(Long roleId); List getUserRoles(Integer userId); + + List getList(String jiacan); } diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/RolePermissionServiceImpl.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/RolePermissionServiceImpl.java index d025999f..a5b443b9 100644 --- a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/RolePermissionServiceImpl.java +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/RolePermissionServiceImpl.java @@ -4,10 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.daqing.financial.hrauth.dao.AuthEmployeeRoleDao; -import com.daqing.financial.hrauth.dao.AuthRoleDao; -import com.daqing.financial.hrauth.dao.RolePermissionMapper; -import com.daqing.financial.hrauth.dao.UserLoginDao; +import com.daqing.financial.hrauth.dao.*; import com.daqing.financial.hrauth.service.RolePermissionService; import com.daqing.framework.domain.hrms.EmployeeRoleEntity; import com.daqing.framework.domain.hrms.PermissionEntity; @@ -34,6 +31,9 @@ public class RolePermissionServiceImpl extends ServiceImpl listWithTree() { Listlist = this.getBaseMapper().queryPermissionTree(); @@ -132,4 +132,10 @@ public class RolePermissionServiceImpl extends ServiceImpl getList(String jiacan) { + List permissionList = permissionMapper.selectList(null); + return permissionList; + } + } \ No newline at end of file diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserDetailsServiceImpl.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserDetailsServiceImpl.java index 61dc4d7b..f08f38fb 100644 --- a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserDetailsServiceImpl.java +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserDetailsServiceImpl.java @@ -7,6 +7,7 @@ import com.daqing.financial.hrauth.dao.AuthRoleDao; import com.daqing.financial.hrauth.dao.UserLoginDao; import com.daqing.financial.hrauth.feign.HrauthFeignService; import com.daqing.financial.hrauth.handle.SecurityUser; +import com.daqing.financial.hrauth.service.RolePermissionService; import com.daqing.framework.domain.hrms.EmployeeRoleEntity; import com.daqing.framework.domain.hrms.RoleEntity; import com.daqing.framework.domain.hrms.UserEntity; @@ -49,6 +50,8 @@ public class UserDetailsServiceImpl implements UserDetailsService { private HrauthFeignService hrauthFeignService; @Autowired private UserLoginDao userLoginDao; + @Autowired + private RolePermissionService permissionService; /*** * 根据账号获取用户信息 @@ -116,6 +119,7 @@ public class UserDetailsServiceImpl implements UserDetailsService { log.info("来了调用远程接口~~~~~~~~~~~~~~~~~~~~~~~~~~"); ResponseResult responseResult = hrauthFeignService.getUserRoles(userId); List roleList = (List) responseResult.getData(); + //List roleList = permissionService.getUserRoles(userId); return roleList; } diff --git a/dq-financial-hrms-auth/src/main/resources/mapper/hrauth/AuthPermissionDao.xml b/dq-financial-hrms-auth/src/main/resources/mapper/hrauth/AuthPermissionDao.xml index f53e8f8b..c19bea46 100644 --- a/dq-financial-hrms-auth/src/main/resources/mapper/hrauth/AuthPermissionDao.xml +++ b/dq-financial-hrms-auth/src/main/resources/mapper/hrauth/AuthPermissionDao.xml @@ -19,9 +19,9 @@ - + --> \ No newline at end of file diff --git a/dq-financial-hrms-auth/src/main/resources/mapper/hrauth/RolePermissionMapper.xml b/dq-financial-hrms-auth/src/main/resources/mapper/hrauth/RolePermissionMapper.xml index 9c784c8f..7dfeafea 100644 --- a/dq-financial-hrms-auth/src/main/resources/mapper/hrauth/RolePermissionMapper.xml +++ b/dq-financial-hrms-auth/src/main/resources/mapper/hrauth/RolePermissionMapper.xml @@ -87,11 +87,11 @@ select role_id from hrms_employee_role where user_id=#{userId} - + -->