├── .gitignore ├── LICENSE ├── README.md ├── pom.xml ├── xll-auth ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xll │ │ └── upms │ │ └── auth │ │ ├── UPMSAuthServerApplication.java │ │ ├── component │ │ └── mobile │ │ │ ├── MobileAuthenticationFilter.java │ │ │ ├── MobileAuthenticationProvider.java │ │ │ ├── MobileAuthenticationToken.java │ │ │ ├── MobileLoginSuccessHandler.java │ │ │ └── MobileSecurityConfigurer.java │ │ ├── config │ │ ├── PigAuthorizationConfig.java │ │ ├── PigJwtAccessTokenConverter.java │ │ ├── PigRedisTokenStore.java │ │ ├── PigSecurityConfigurerAdapter.java │ │ └── SocialPropertiesConfig.java │ │ ├── controller │ │ └── AuthenticationController.java │ │ ├── feign │ │ ├── UserService.java │ │ └── fallback │ │ │ └── UserServiceFallbackImpl.java │ │ ├── service │ │ └── UserDetailServiceImpl.java │ │ └── util │ │ ├── MobileAuthenticationToken.java │ │ └── UserDetailsImpl.java │ └── resources │ ├── bootstrap.yml │ ├── org │ └── springframework │ │ └── security │ │ └── messages_zh_CN.properties │ ├── static │ └── css │ │ ├── bootstrap.min.css │ │ └── signin.css │ └── templates │ └── ftl │ └── login.ftl ├── xll-common ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xll │ │ └── upms │ │ └── common │ │ ├── bean │ │ ├── aop │ │ │ └── ControllerAop.java │ │ ├── config │ │ │ ├── FdfsPropertiesConfig.java │ │ │ ├── FilterIgnorePropertiesConfig.java │ │ │ ├── QiniuPropertiesConfig.java │ │ │ ├── RedisCacheConfig.java │ │ │ ├── SwaggerConfig.java │ │ │ └── WebMvcConfig.java │ │ ├── handler │ │ │ └── GlobalExceptionHandler.java │ │ ├── interceptor │ │ │ ├── DataScope.java │ │ │ └── DataScopeInterceptor.java │ │ ├── resolver │ │ │ └── TokenArgumentResolver.java │ │ └── xss │ │ │ ├── HtmlFilter.java │ │ │ ├── SqlFilter.java │ │ │ └── XssHttpServletRequestWrapper.java │ │ ├── constant │ │ ├── CommonConstant.java │ │ ├── MqQueueConstant.java │ │ ├── SecurityConstants.java │ │ ├── ServiceNameConstant.java │ │ └── enums │ │ │ ├── EnumSmsChannel.java │ │ │ └── EnumSmsChannelTemplate.java │ │ ├── entity │ │ ├── SysLog.java │ │ └── SysZuulRoute.java │ │ ├── util │ │ ├── Assert.java │ │ ├── AuthUtils.java │ │ ├── Query.java │ │ ├── R.java │ │ ├── UserUtils.java │ │ ├── exception │ │ │ ├── CheckedException.java │ │ │ ├── PigDeniedException.java │ │ │ ├── UnloginException.java │ │ │ └── ValidateCodeException.java │ │ └── template │ │ │ ├── DingTalkMsgTemplate.java │ │ │ └── MobileMsgTemplate.java │ │ ├── vo │ │ ├── ErrorPojo.java │ │ ├── ImageCode.java │ │ ├── LogVO.java │ │ ├── MenuVO.java │ │ ├── SysRole.java │ │ └── UserVO.java │ │ └── web │ │ └── BaseController.java │ └── resources │ └── logback-spring.xml ├── xll-config ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xll │ │ └── upms │ │ └── config │ │ └── UPMSConfigApplication.java │ └── resources │ ├── bootstrap.yml │ └── logback-spring.xml ├── xll-eureka ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xll │ │ └── upms │ │ └── eureka │ │ └── UPMSEurekaApplication.java │ └── resources │ ├── bootstrap.yml │ └── logback-spring.xml ├── xll-gateway ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── xll │ │ │ └── upms │ │ │ └── gateway │ │ │ ├── UPMSGatewayApplication.java │ │ │ ├── component │ │ │ ├── config │ │ │ │ ├── DynamicRouteConfiguration.java │ │ │ │ ├── DynamicRouteLocator.java │ │ │ │ ├── RegistrySwaggerResourcesProvider.java │ │ │ │ ├── ResourceServerConfiguration.java │ │ │ │ └── RibbonMetaFilterAutoConfiguration.java │ │ │ ├── fallback │ │ │ │ ├── AuthFallbackProvider.java │ │ │ │ └── UpmsFallbackProvider.java │ │ │ ├── filter │ │ │ │ ├── AccessFilter.java │ │ │ │ ├── DecodePasswordFilter.java │ │ │ │ ├── ErrorHandlerFilter.java │ │ │ │ ├── LoggerFilter.java │ │ │ │ ├── PreviewFilter.java │ │ │ │ ├── ValidateCodeFilter.java │ │ │ │ └── XssSecurityFilter.java │ │ │ ├── handler │ │ │ │ ├── MetadataCanaryRuleHandler.java │ │ │ │ ├── PigAccessDeniedHandler.java │ │ │ │ └── ZuulRateLimiterErrorHandler.java │ │ │ └── listener │ │ │ │ └── GroovyLoadInitListener.java │ │ │ ├── feign │ │ │ ├── MenuService.java │ │ │ └── fallback │ │ │ │ └── MenuServiceFallbackImpl.java │ │ │ ├── service │ │ │ ├── LogSendService.java │ │ │ ├── PermissionService.java │ │ │ └── impl │ │ │ │ ├── LogSendServiceImpl.java │ │ │ │ └── PermissionServiceImpl.java │ │ │ └── util │ │ │ └── RibbonVersionHolder.java │ └── resources │ │ └── bootstrap.yml │ └── test │ └── java │ └── com │ └── xll │ └── upms │ └── common │ └── util │ └── UserUtilsTest.java ├── xll-modules ├── pom.xml ├── xll-daemon-service │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── xll │ │ │ └── upms │ │ │ └── daemon │ │ │ ├── UPMSDaemonApplication.java │ │ │ └── job │ │ │ ├── DemoSimpleJob.java │ │ │ ├── UmpsDataflowJob.java │ │ │ └── UmpsSimpleJob.java │ │ └── resources │ │ └── bootstrap.yml ├── xll-mc-service │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── xll │ │ │ └── upms │ │ │ └── mc │ │ │ ├── UPMSMessageCenterApplication.java │ │ │ ├── config │ │ │ ├── DingTalkPropertiesConfig.java │ │ │ └── SmsAliyunPropertiesConfig.java │ │ │ ├── handler │ │ │ ├── AbstractMessageHandler.java │ │ │ ├── DingTalkMessageHandler.java │ │ │ ├── SmsAliyunMessageHandler.java │ │ │ └── SmsMessageHandler.java │ │ │ └── listener │ │ │ ├── DingTalkServiceChangeReceiveListener.java │ │ │ ├── MobileCodeReceiveListener.java │ │ │ └── MobileServiceChangeReceiveListener.java │ │ └── resources │ │ └── bootstrap.yml ├── xll-sso-client-demo │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── xll │ │ │ └── upms │ │ │ └── sso │ │ │ ├── UPMSSsoClientDemoApplication.java │ │ │ ├── config │ │ │ └── ResourceServerConfiguration.java │ │ │ └── controller │ │ │ └── DemoController.java │ │ └── resources │ │ ├── bootstrap.yml │ │ ├── logback-spring.xml │ │ └── static │ │ └── index.html └── xll-upms-service │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── xll │ │ │ └── upms │ │ │ └── admin │ │ │ ├── UPMSAdminApplication.java │ │ │ ├── common │ │ │ ├── config │ │ │ │ ├── KaptchaConfig.java │ │ │ │ ├── MybatisPlusConfig.java │ │ │ │ └── RabbitConfig.java │ │ │ ├── listener │ │ │ │ ├── LogReceiveListener.java │ │ │ │ └── RouteConfigInitListener.java │ │ │ └── util │ │ │ │ ├── PigResourcesGenerator.java │ │ │ │ └── TreeUtil.java │ │ │ ├── controller │ │ │ ├── DeptController.java │ │ │ ├── DictController.java │ │ │ ├── LogController.java │ │ │ ├── MenuController.java │ │ │ ├── OauthClientDetailsController.java │ │ │ ├── RoleController.java │ │ │ ├── UserController.java │ │ │ ├── ValidateCodeController.java │ │ │ └── ZuulRouteController.java │ │ │ ├── mapper │ │ │ ├── SysDeptMapper.java │ │ │ ├── SysDeptRelationMapper.java │ │ │ ├── SysDictMapper.java │ │ │ ├── SysLogMapper.java │ │ │ ├── SysMenuMapper.java │ │ │ ├── SysOauthClientDetailsMapper.java │ │ │ ├── SysRoleDeptMapper.java │ │ │ ├── SysRoleMapper.java │ │ │ ├── SysRoleMenuMapper.java │ │ │ ├── SysUserMapper.java │ │ │ ├── SysUserRoleMapper.java │ │ │ └── SysZuulRouteMapper.java │ │ │ ├── model │ │ │ ├── dto │ │ │ │ ├── DeptTree.java │ │ │ │ ├── MenuTree.java │ │ │ │ ├── RoleDTO.java │ │ │ │ ├── RouteConfig.java │ │ │ │ ├── TreeNode.java │ │ │ │ ├── UserDTO.java │ │ │ │ └── UserInfo.java │ │ │ └── entity │ │ │ │ ├── SysDept.java │ │ │ │ ├── SysDeptRelation.java │ │ │ │ ├── SysDict.java │ │ │ │ ├── SysMenu.java │ │ │ │ ├── SysOauthClientDetails.java │ │ │ │ ├── SysRole.java │ │ │ │ ├── SysRoleDept.java │ │ │ │ ├── SysRoleMenu.java │ │ │ │ ├── SysUser.java │ │ │ │ └── SysUserRole.java │ │ │ └── service │ │ │ ├── SysDeptRelationService.java │ │ │ ├── SysDeptService.java │ │ │ ├── SysDictService.java │ │ │ ├── SysLogService.java │ │ │ ├── SysMenuService.java │ │ │ ├── SysOauthClientDetailsService.java │ │ │ ├── SysRoleDeptService.java │ │ │ ├── SysRoleMenuService.java │ │ │ ├── SysRoleService.java │ │ │ ├── SysUserRoleService.java │ │ │ ├── SysUserService.java │ │ │ ├── SysZuulRouteService.java │ │ │ └── impl │ │ │ ├── SysDeptRelationServiceImpl.java │ │ │ ├── SysDeptServiceImpl.java │ │ │ ├── SysDictServiceImpl.java │ │ │ ├── SysLogServiceImpl.java │ │ │ ├── SysMenuServiceImpl.java │ │ │ ├── SysOauthClientDetailsServiceImpl.java │ │ │ ├── SysRoleDeptServiceImpl.java │ │ │ ├── SysRoleMenuServiceImpl.java │ │ │ ├── SysRoleServiceImpl.java │ │ │ ├── SysUserRoleServiceImpl.java │ │ │ ├── SysUserServiceImpl.java │ │ │ └── SysZuulRouteServiceImpl.java │ └── resources │ │ ├── bootstrap.yml │ │ ├── mapper │ │ ├── SysDeptMapper.xml │ │ ├── SysDeptRelationMapper.xml │ │ ├── SysDictMapper.xml │ │ ├── SysLogMapper.xml │ │ ├── SysMenuMapper.xml │ │ ├── SysOauthClientDetailsMapper.xml │ │ ├── SysRoleDeptMapper.xml │ │ ├── SysRoleMapper.xml │ │ ├── SysRoleMenuMapper.xml │ │ ├── SysUserMapper.xml │ │ ├── SysUserRoleMapper.xml │ │ └── SysZuulRouteMapper.xml │ │ └── templates │ │ ├── controller.java.vm │ │ ├── listvue.vue.vm │ │ └── menu.sql.vm │ └── test │ └── java │ └── com │ └── xll │ └── upms │ └── admin │ └── PigAdminApplicationTest.java └── xll-visual ├── pom.xml ├── xll-monitor ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xll │ │ └── upms │ │ └── monitor │ │ ├── UPMSMonitorApplication.java │ │ ├── config │ │ ├── MonitorDingTalkPropertiesConfig.java │ │ ├── MonitorMobilePropertiesConfig.java │ │ ├── MonitorPropertiesConfig.java │ │ └── PigNotifierConfiguration.java │ │ └── filter │ │ └── StatusChangeNotifier.java │ └── resources │ └── bootstrap.yml ├── xll-zipkin-db ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── xll │ │ └── upms │ │ └── zipkin │ │ └── UPMSZipkinDbApplication.java │ └── resources │ └── bootstrap.yml └── xll-zipkin-elk ├── pom.xml └── src └── main ├── java └── com │ └── xll │ └── upms │ └── zipkin │ └── UPMSZipkinElkApplication.java └── resources └── bootstrap.yml /.gitignore: -------------------------------------------------------------------------------- 1 | # maven ignore 2 | target/ 3 | *.war 4 | *.ear 5 | *.zip 6 | *.tar 7 | *.tar.gz 8 | 9 | # eclipse ignore 10 | .settings/ 11 | .project 12 | .classpath 13 | 14 | # idea ignore 15 | .idea/ 16 | *.ipr 17 | *.iml 18 | *.iws 19 | 20 | # logs # 21 | logs 22 | 23 | # temp ignore 24 | *.log 25 | *.cache 26 | *.diff 27 | *.patch 28 | *.tmp 29 | *.java~ 30 | *.properties~ 31 | *.xml~ 32 | 33 | # system ignore 34 | .DS_Store 35 | Thumbs.db 36 | Servers 37 | .metadata 38 | upload -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 lengleng 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # XLL Microservice Architecture 2 | --- 3 | **基于Spring Cloud、OAuth2.0、Vue的前后端分离的权限管理系统** 4 | 5 |

6 | 7 |

8 | 9 | ### 功能列表 10 | - 完善登录:账号密码模式、短信验证码模式、社交账号模式均整合Spring security oAuth 11 | - 单点登录:基于Srping security oAuth 提供单点登录接口,方便其他系统对接 12 | - 用户管理:用户是系统操作者,该功能主要完成系统用户配置。 13 | - 机构管理:配置系统组织机构,树结构展现,可随意调整上下级。 14 | - 菜单管理:配置系统菜单,操作权限,按钮权限标识等。 15 | - 角色管理:角色菜单权限分配、设置角色按机构进行数据范围权限划分。 16 | - 动态路由:基于zuul实现动态路由,后端可配置化。 17 | - 灰度发布:自定义ribbon路由规则匹配多版本请求。 18 | - 终端管理:动态配置oauth终端,后端可配置化。 19 | - 字典管理:对系统中经常使用的一些较为固定的数据进行维护,如:是否等。 20 | - 操作日志:系统正常操作日志记录和查询;系统异常信息日志记录和查询。 21 | - 服务限流:多种维度的流量控制(服务、IP、用户等) 22 | - 消息总线:配置动态实时刷新 23 | - 分库分表:shardingdbc分库分表策略 24 | - 数据权限: 使用mybatis对原查询做增强,业务代码不用控制,即可实现。 25 | - 文件系统: 支持FastDFS、七牛云,扩展API几行代码实现上传下载 26 | - 消息中心:短信、邮件模板发送,几行代码实现发送 27 | - 聚合文档:基于zuul实现 swagger各个模块的实现 28 | - 代码生成:前后端代码的生成,支持Vue 29 | - 缓存管理:基于Cache Cloud 保证Redis 的高可用 30 | - 服务监控: Spring Boot Admin 31 | - 分布式任务调度: 基于elastic-job的分布式任务,zookeeper做调度中心 32 | - zipkin链路追踪: 数据保存ELK,图形化展示 33 | - pinpoint链路追踪: 数据保存hbase,图形化展示 34 | -------------------------------------------------------------------------------- /xll-auth/src/main/java/com/xll/upms/auth/UPMSAuthServerApplication.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.auth; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import org.springframework.cloud.netflix.feign.EnableFeignClients; 7 | import org.springframework.context.annotation.ComponentScan; 8 | 9 | /** 10 | * @Author 徐亮亮 11 | * @Description: 获取用户信息也是通过这个应用实现 12 | * 这里既是认证服务器,也是资源服务器 13 | * @Date 2019/1/18 20:08 14 | */ 15 | @SpringBootApplication 16 | @EnableDiscoveryClient 17 | @EnableFeignClients 18 | @ComponentScan(basePackages = {"com.xll.upms.auth", "com.xll.upms.common.bean"}) 19 | public class UPMSAuthServerApplication { 20 | 21 | public static void main(String[] args) { 22 | SpringApplication.run(UPMSAuthServerApplication.class, args); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /xll-auth/src/main/java/com/xll/upms/auth/component/mobile/MobileAuthenticationProvider.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.auth.component.mobile; 2 | 3 | import com.xll.upms.auth.feign.UserService; 4 | import com.xll.upms.auth.util.UserDetailsImpl; 5 | import com.xll.upms.common.vo.UserVO; 6 | import org.springframework.security.authentication.AuthenticationProvider; 7 | import org.springframework.security.core.Authentication; 8 | import org.springframework.security.core.AuthenticationException; 9 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 10 | 11 | /** 12 | * @Author 徐亮亮 13 | * @Description: 手机号登录校验逻辑 14 | * @Date 2019/1/18 20:29 15 | */ 16 | public class MobileAuthenticationProvider implements AuthenticationProvider { 17 | private UserService userService; 18 | 19 | @Override 20 | public Authentication authenticate(Authentication authentication) throws AuthenticationException { 21 | MobileAuthenticationToken mobileAuthenticationToken = (MobileAuthenticationToken) authentication; 22 | UserVO userVo = userService.findUserByMobile((String) mobileAuthenticationToken.getPrincipal()); 23 | 24 | if (userVo == null) { 25 | throw new UsernameNotFoundException("手机号不存在:" + mobileAuthenticationToken.getPrincipal()); 26 | } 27 | 28 | UserDetailsImpl userDetails = buildUserDeatils(userVo); 29 | 30 | MobileAuthenticationToken authenticationToken = new MobileAuthenticationToken(userDetails, userDetails.getAuthorities()); 31 | authenticationToken.setDetails(mobileAuthenticationToken.getDetails()); 32 | return authenticationToken; 33 | } 34 | 35 | private UserDetailsImpl buildUserDeatils(UserVO userVo) { 36 | return new UserDetailsImpl(userVo); 37 | } 38 | 39 | @Override 40 | public boolean supports(Class authentication) { 41 | return MobileAuthenticationToken.class.isAssignableFrom(authentication); 42 | } 43 | 44 | public UserService getUserService() { 45 | return userService; 46 | } 47 | 48 | public void setUserService(UserService userService) { 49 | this.userService = userService; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /xll-auth/src/main/java/com/xll/upms/auth/component/mobile/MobileAuthenticationToken.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.auth.component.mobile; 2 | 3 | import org.springframework.security.authentication.AbstractAuthenticationToken; 4 | import org.springframework.security.core.GrantedAuthority; 5 | import org.springframework.security.core.SpringSecurityCoreVersion; 6 | 7 | import java.util.Collection; 8 | 9 | /** 10 | * @Author 徐亮亮 11 | * @Description:手机号登录令牌 12 | * @Date 2019/1/18 20:29 13 | */ 14 | public class MobileAuthenticationToken extends AbstractAuthenticationToken { 15 | 16 | private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID; 17 | 18 | private final Object principal; 19 | 20 | public MobileAuthenticationToken(String mobile) { 21 | super(null); 22 | this.principal = mobile; 23 | setAuthenticated(false); 24 | } 25 | 26 | public MobileAuthenticationToken(Object principal, 27 | Collection authorities) { 28 | super(authorities); 29 | this.principal = principal; 30 | super.setAuthenticated(true); 31 | } 32 | 33 | @Override 34 | public Object getPrincipal() { 35 | return this.principal; 36 | } 37 | 38 | @Override 39 | public Object getCredentials() { 40 | return null; 41 | } 42 | 43 | @Override 44 | public void setAuthenticated(boolean isAuthenticated) throws IllegalArgumentException { 45 | if (isAuthenticated) { 46 | throw new IllegalArgumentException( 47 | "Cannot set this token to trusted - use constructor which takes a GrantedAuthority list instead"); 48 | } 49 | 50 | super.setAuthenticated(false); 51 | } 52 | 53 | @Override 54 | public void eraseCredentials() { 55 | super.eraseCredentials(); 56 | } 57 | } 58 | 59 | -------------------------------------------------------------------------------- /xll-auth/src/main/java/com/xll/upms/auth/component/mobile/MobileSecurityConfigurer.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.auth.component.mobile; 2 | 3 | import com.xll.upms.auth.feign.UserService; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.security.authentication.AuthenticationManager; 6 | import org.springframework.security.config.annotation.SecurityConfigurerAdapter; 7 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 8 | import org.springframework.security.web.DefaultSecurityFilterChain; 9 | import org.springframework.security.web.authentication.AuthenticationSuccessHandler; 10 | import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; 11 | import org.springframework.stereotype.Component; 12 | 13 | /** 14 | * @Author 徐亮亮 15 | * @Description: 手机号登录配置入口 16 | * @Date 2019/1/18 20:31 17 | */ 18 | @Component 19 | public class MobileSecurityConfigurer extends SecurityConfigurerAdapter { 20 | @Autowired 21 | private AuthenticationSuccessHandler mobileLoginSuccessHandler; 22 | @Autowired 23 | private UserService userService; 24 | 25 | @Override 26 | public void configure(HttpSecurity http) throws Exception { 27 | MobileAuthenticationFilter mobileAuthenticationFilter = new MobileAuthenticationFilter(); 28 | mobileAuthenticationFilter.setAuthenticationManager(http.getSharedObject(AuthenticationManager.class)); 29 | mobileAuthenticationFilter.setAuthenticationSuccessHandler(mobileLoginSuccessHandler); 30 | 31 | MobileAuthenticationProvider mobileAuthenticationProvider = new MobileAuthenticationProvider(); 32 | mobileAuthenticationProvider.setUserService(userService); 33 | http.authenticationProvider(mobileAuthenticationProvider) 34 | .addFilterAfter(mobileAuthenticationFilter, UsernamePasswordAuthenticationFilter.class); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /xll-auth/src/main/java/com/xll/upms/auth/config/PigJwtAccessTokenConverter.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.auth.config; 2 | 3 | import com.xll.upms.common.constant.SecurityConstants; 4 | import org.springframework.security.oauth2.common.OAuth2AccessToken; 5 | import org.springframework.security.oauth2.provider.OAuth2Authentication; 6 | import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter; 7 | 8 | import java.util.Map; 9 | 10 | /** 11 | * @Author 徐亮亮 12 | * @Description: token 声明版权 13 | * @Date 2019/1/18 20:24 14 | */ 15 | public class PigJwtAccessTokenConverter extends JwtAccessTokenConverter { 16 | @Override 17 | public Map convertAccessToken(OAuth2AccessToken token, OAuth2Authentication authentication) { 18 | Map representation = (Map) super.convertAccessToken(token, authentication); 19 | representation.put("license", SecurityConstants.PIG_LICENSE); 20 | return representation; 21 | } 22 | 23 | @Override 24 | public OAuth2AccessToken extractAccessToken(String value, Map map) { 25 | return super.extractAccessToken(value, map); 26 | } 27 | 28 | @Override 29 | public OAuth2Authentication extractAuthentication(Map map) { 30 | return super.extractAuthentication(map); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /xll-auth/src/main/java/com/xll/upms/auth/config/PigSecurityConfigurerAdapter.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.auth.config; 2 | 3 | import com.xll.upms.auth.component.mobile.MobileSecurityConfigurer; 4 | import com.xll.upms.common.bean.config.FilterIgnorePropertiesConfig; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.autoconfigure.security.SecurityProperties; 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.core.annotation.Order; 9 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 10 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 11 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 12 | import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; 13 | /** 14 | * @Author 徐亮亮 15 | * @Description: 安全配置适配器 16 | * @Date 2019/1/18 20:26 17 | */ 18 | @Order(SecurityProperties.ACCESS_OVERRIDE_ORDER - 1) 19 | @Configuration 20 | @EnableWebSecurity 21 | public class PigSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter { 22 | @Autowired 23 | private FilterIgnorePropertiesConfig filterIgnorePropertiesConfig; 24 | @Autowired 25 | private MobileSecurityConfigurer mobileSecurityConfigurer; 26 | 27 | @Override 28 | public void configure(HttpSecurity http) throws Exception { 29 | ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry registry = 30 | http.formLogin().loginPage("/authentication/require") 31 | .loginProcessingUrl("/authentication/form") 32 | .and() 33 | .authorizeRequests(); 34 | filterIgnorePropertiesConfig.getUrls().forEach(url -> registry.antMatchers(url).permitAll()); 35 | registry.anyRequest().authenticated() 36 | .and() 37 | .csrf().disable(); 38 | http.apply(mobileSecurityConfigurer); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /xll-auth/src/main/java/com/xll/upms/auth/config/SocialPropertiesConfig.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.auth.config; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * @Author 徐亮亮 7 | * @Description: 登录基础配置 8 | * @Date 2019/1/18 20:27 9 | */ 10 | @Data 11 | public class SocialPropertiesConfig { 12 | /** 13 | * 提供商 14 | */ 15 | private String providerId; 16 | /** 17 | * 应用ID 18 | */ 19 | private String clientId; 20 | /** 21 | * 应用密钥 22 | */ 23 | private String clientSecret; 24 | 25 | } 26 | -------------------------------------------------------------------------------- /xll-auth/src/main/java/com/xll/upms/auth/controller/AuthenticationController.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.auth.controller; 2 | 3 | import com.xll.upms.common.constant.SecurityConstants; 4 | import com.xll.upms.common.util.R; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.beans.factory.annotation.Qualifier; 7 | import org.springframework.cache.annotation.CacheEvict; 8 | import org.springframework.security.core.Authentication; 9 | import org.springframework.security.oauth2.provider.token.ConsumerTokenServices; 10 | import org.springframework.web.bind.annotation.GetMapping; 11 | import org.springframework.web.bind.annotation.PostMapping; 12 | import org.springframework.web.bind.annotation.RequestMapping; 13 | import org.springframework.web.bind.annotation.RestController; 14 | import org.springframework.web.servlet.ModelAndView; 15 | 16 | /** 17 | * @Author 徐亮亮 18 | * @Description: 授权认证控制器 19 | * @Date 2019/1/18 20:22 20 | */ 21 | @RestController 22 | @RequestMapping("/authentication") 23 | public class AuthenticationController { 24 | @Autowired 25 | @Qualifier("consumerTokenServices") 26 | private ConsumerTokenServices consumerTokenServices; 27 | 28 | /** 29 | * 认证页面 30 | * @return ModelAndView 31 | */ 32 | @GetMapping("/require") 33 | public ModelAndView require() { 34 | return new ModelAndView("ftl/login"); 35 | } 36 | 37 | /** 38 | * 用户信息校验 39 | * @param authentication 信息 40 | * @return 用户信息 41 | */ 42 | @RequestMapping("/user") 43 | public Object user(Authentication authentication) { 44 | return authentication.getPrincipal(); 45 | } 46 | 47 | /** 48 | * 清除Redis中 accesstoken refreshtoken 49 | * 50 | * @param accesstoken accesstoken 51 | * @return true/false 52 | */ 53 | @PostMapping("/removeToken") 54 | @CacheEvict(value = SecurityConstants.TOKEN_USER_DETAIL, key = "#accesstoken") 55 | public R removeToken(String accesstoken) { 56 | return new R<>( consumerTokenServices.revokeToken(accesstoken)); 57 | } 58 | } -------------------------------------------------------------------------------- /xll-auth/src/main/java/com/xll/upms/auth/feign/UserService.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.auth.feign; 2 | 3 | import com.xll.upms.auth.feign.fallback.UserServiceFallbackImpl; 4 | import com.xll.upms.common.vo.UserVO; 5 | import org.springframework.cloud.netflix.feign.FeignClient; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.PathVariable; 8 | 9 | /** 10 | * @Author 徐亮亮 11 | * @Description: 调用umps服务接口 12 | * @Date 2019/1/18 20:12 13 | */ 14 | @FeignClient(name = "pig-upms-service", fallback = UserServiceFallbackImpl.class) 15 | public interface UserService { 16 | /** 17 | * 通过用户名查询用户、角色信息 18 | * 19 | * @param username 用户名 20 | * @return UserVo 21 | */ 22 | @GetMapping("/user/findUserByUsername/{username}") 23 | UserVO findUserByUsername(@PathVariable("username") String username); 24 | 25 | /** 26 | * 通过手机号查询用户、角色信息 27 | * 28 | * @param mobile 手机号 29 | * @return UserVo 30 | */ 31 | @GetMapping("/user/findUserByMobile/{mobile}") 32 | UserVO findUserByMobile(@PathVariable("mobile") String mobile); 33 | 34 | /** 35 | * 根据OpenId查询用户信息 36 | * @param openId openId 37 | * @return UserVo 38 | */ 39 | @GetMapping("/user/findUserByOpenId/{openId}") 40 | UserVO findUserByOpenId(@PathVariable("openId") String openId); 41 | } 42 | -------------------------------------------------------------------------------- /xll-auth/src/main/java/com/xll/upms/auth/feign/fallback/UserServiceFallbackImpl.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.auth.feign.fallback; 2 | 3 | import com.xll.upms.auth.feign.UserService; 4 | import com.xll.upms.common.vo.UserVO; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | * @author lengleng 11 | * @date 2017/10/31 12 | * 用户服务的fallback 13 | */ 14 | /** 15 | * @Author 徐亮亮 16 | * @Description: 用户服务的回调(如果请求异常快速返回信息给用户) 17 | * @Date 2019/1/18 20:20 18 | */ 19 | @Service 20 | public class UserServiceFallbackImpl implements UserService { 21 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 22 | 23 | @Override 24 | public UserVO findUserByUsername(String username) { 25 | logger.error("调用{}异常:{}", "findUserByUsername", username); 26 | return null; 27 | } 28 | 29 | /** 30 | * 通过手机号查询用户、角色信息 31 | * 32 | * @param mobile 手机号 33 | * @return UserVo 34 | */ 35 | @Override 36 | public UserVO findUserByMobile(String mobile) { 37 | logger.error("调用{}异常:{}", "通过手机号查询用户", mobile); 38 | return null; 39 | } 40 | 41 | /** 42 | * 根据OpenId查询用户信息 43 | * 44 | * @param openId openId 45 | * @return UserVo 46 | */ 47 | @Override 48 | public UserVO findUserByOpenId(String openId) { 49 | logger.error("调用{}异常:{}", "通过OpenId查询用户", openId); 50 | return null; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /xll-auth/src/main/java/com/xll/upms/auth/service/UserDetailServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.auth.service; 2 | 3 | import com.xll.upms.auth.feign.UserService; 4 | import com.xll.upms.auth.util.UserDetailsImpl; 5 | import com.xll.upms.common.vo.UserVO; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.security.core.userdetails.UserDetailsService; 8 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 9 | import org.springframework.stereotype.Service; 10 | 11 | /** 12 | * @Author 徐亮亮 13 | * @Description: 用户详情业务逻辑 14 | * @Date 2019/1/18 20:10 15 | */ 16 | @Service("userDetailService") 17 | public class UserDetailServiceImpl implements UserDetailsService { 18 | @Autowired 19 | private UserService userService; 20 | 21 | @Override 22 | public UserDetailsImpl loadUserByUsername(String username) throws UsernameNotFoundException { 23 | UserVO userVo = userService.findUserByUsername(username); 24 | if (userVo == null) { 25 | throw new UsernameNotFoundException("用户名不存在或者密码错误"); 26 | } 27 | return new UserDetailsImpl(userVo); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /xll-auth/src/main/java/com/xll/upms/auth/util/MobileAuthenticationToken.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.auth.util; 2 | 3 | import org.springframework.security.authentication.AbstractAuthenticationToken; 4 | import org.springframework.security.core.GrantedAuthority; 5 | import org.springframework.security.core.SpringSecurityCoreVersion; 6 | 7 | import java.util.Collection; 8 | 9 | /** 10 | * @Author 徐亮亮 11 | * @Description:手机号登录令牌 12 | * @Date 2019/1/18 19:55 13 | */ 14 | public class MobileAuthenticationToken extends AbstractAuthenticationToken { 15 | 16 | private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID; 17 | 18 | private final Object principal; 19 | 20 | public MobileAuthenticationToken(String mobile) { 21 | super(null); 22 | this.principal = mobile; 23 | setAuthenticated(false); 24 | } 25 | 26 | public MobileAuthenticationToken(Object principal, 27 | Collection authorities) { 28 | super(authorities); 29 | this.principal = principal; 30 | super.setAuthenticated(true); 31 | } 32 | 33 | @Override 34 | public Object getPrincipal() { 35 | return this.principal; 36 | } 37 | 38 | @Override 39 | public Object getCredentials() { 40 | return null; 41 | } 42 | 43 | @Override 44 | public void setAuthenticated(boolean isAuthenticated) throws IllegalArgumentException { 45 | if (isAuthenticated) { 46 | throw new IllegalArgumentException( 47 | "Cannot set this token to trusted - use constructor which takes a GrantedAuthority list instead"); 48 | } 49 | 50 | super.setAuthenticated(false); 51 | } 52 | 53 | @Override 54 | public void eraseCredentials() { 55 | super.eraseCredentials(); 56 | } 57 | } 58 | 59 | -------------------------------------------------------------------------------- /xll-auth/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: pig-auth 4 | profiles: 5 | active: dev 6 | cloud: 7 | config: 8 | fail-fast: true 9 | discovery: 10 | service-id: pig-config-server 11 | enabled: true 12 | profile: ${spring.profiles.active} 13 | label: master 14 | --- 15 | spring: 16 | profiles: dev 17 | 18 | eureka: 19 | instance: 20 | prefer-ip-address: true 21 | lease-renewal-interval-in-seconds: 5 22 | lease-expiration-duration-in-seconds: 20 23 | 24 | client: 25 | serviceUrl: 26 | defaultZone: http://xll:gip6666@localhost:1025/eureka 27 | registry-fetch-interval-seconds: 10 28 | 29 | --- 30 | spring: 31 | profiles: prd 32 | eureka: 33 | instance: 34 | prefer-ip-address: true 35 | client: 36 | serviceUrl: 37 | defaultZone: http://xll:gip6666@eureka:1025/eureka 38 | -------------------------------------------------------------------------------- /xll-auth/src/main/resources/static/css/signin.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018-2025, lengleng All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * Neither the name of the pig4cloud.com developer nor the names of its 13 | * contributors may be used to endorse or promote products derived from 14 | * this software without specific prior written permission. 15 | * Author: lengleng (wangiegie@gmail.com) 16 | */ 17 | 18 | body { 19 | padding-top: 40px; 20 | padding-bottom: 40px; 21 | background-color: #eee; 22 | } 23 | 24 | .form-signin { 25 | max-width: 330px; 26 | padding: 15px; 27 | margin: 0 auto; 28 | } 29 | .form-margin-top { 30 | margin-top: 50px; 31 | } 32 | .form-signin .form-signin-heading, 33 | .form-signin .checkbox { 34 | margin-bottom: 10px; 35 | } 36 | .form-signin .checkbox { 37 | font-weight: normal; 38 | } 39 | .form-signin .form-control { 40 | position: relative; 41 | height: auto; 42 | -webkit-box-sizing: border-box; 43 | -moz-box-sizing: border-box; 44 | box-sizing: border-box; 45 | padding: 10px; 46 | font-size: 16px; 47 | } 48 | .form-signin .form-control:focus { 49 | z-index: 2; 50 | } 51 | .form-signin input[type="email"] { 52 | margin-bottom: -1px; 53 | border-bottom-right-radius: 0; 54 | border-bottom-left-radius: 0; 55 | } 56 | .form-signin input[type="password"] { 57 | margin-bottom: 10px; 58 | border-top-left-radius: 0; 59 | border-top-right-radius: 0; 60 | } 61 | footer{ 62 | text-align: center; 63 | position:absolute; 64 | bottom:0; 65 | width:100%; 66 | height:100px; 67 | } 68 | -------------------------------------------------------------------------------- /xll-auth/src/main/resources/templates/ftl/login.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Pig微服务统一认证 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 25 |
26 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /xll-common/src/main/java/com/xll/upms/common/bean/config/FdfsPropertiesConfig.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.common.bean.config; 2 | 3 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 4 | import org.springframework.boot.context.properties.ConfigurationProperties; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | /** 8 | * @Author 徐亮亮 9 | * @Description:FastDFs参数 10 | * @Date 2019/1/18 20:33 11 | */ 12 | @Configuration 13 | @ConditionalOnProperty(prefix = "fdfs", name = "file-host") 14 | @ConfigurationProperties(prefix = "fdfs") 15 | public class FdfsPropertiesConfig { 16 | private String fileHost; 17 | 18 | public String getFileHost() { 19 | return fileHost; 20 | } 21 | 22 | public void setFileHost(String fileHost) { 23 | this.fileHost = fileHost; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /xll-common/src/main/java/com/xll/upms/common/bean/config/FilterIgnorePropertiesConfig.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.common.bean.config; 2 | 3 | import lombok.Data; 4 | import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; 5 | import org.springframework.boot.context.properties.ConfigurationProperties; 6 | import org.springframework.cloud.context.config.annotation.RefreshScope; 7 | import org.springframework.context.annotation.Configuration; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | /** 13 | * @Author 徐亮亮 14 | * @Description:过滤忽略属性配置类 15 | * @Date 2019/1/18 20:34 16 | */ 17 | @Data 18 | @Configuration 19 | @RefreshScope 20 | @ConditionalOnExpression("!'${ignore}'.isEmpty()") 21 | @ConfigurationProperties(prefix = "ignore") 22 | public class FilterIgnorePropertiesConfig { 23 | private List urls = new ArrayList<>(); 24 | 25 | private List clients = new ArrayList<>(); 26 | } 27 | -------------------------------------------------------------------------------- /xll-common/src/main/java/com/xll/upms/common/bean/config/QiniuPropertiesConfig.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.common.bean.config; 2 | 3 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 4 | import org.springframework.boot.context.properties.ConfigurationProperties; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | /** 8 | * @Author 徐亮亮 9 | * @Description:七牛参数配置类 10 | * @Date 2019/1/18 20:35 11 | */ 12 | @Configuration 13 | @ConditionalOnProperty(prefix = "qiniu", name = "accessKey") 14 | @ConfigurationProperties(prefix = "qiniu") 15 | public class QiniuPropertiesConfig { 16 | private String accessKey; 17 | private String secretKey; 18 | private String bucket; 19 | private String qiniuHost; 20 | 21 | public String getAccessKey() { 22 | return accessKey; 23 | } 24 | 25 | public void setAccessKey(String accessKey) { 26 | this.accessKey = accessKey; 27 | } 28 | 29 | public String getSecretKey() { 30 | return secretKey; 31 | } 32 | 33 | public void setSecretKey(String secretKey) { 34 | this.secretKey = secretKey; 35 | } 36 | 37 | public String getBucket() { 38 | return bucket; 39 | } 40 | 41 | public void setBucket(String bucket) { 42 | this.bucket = bucket; 43 | } 44 | 45 | public String getQiniuHost() { 46 | return qiniuHost; 47 | } 48 | 49 | public void setQiniuHost(String qiniuHost) { 50 | this.qiniuHost = qiniuHost; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /xll-common/src/main/java/com/xll/upms/common/bean/config/RedisCacheConfig.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.common.bean.config; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.cache.CacheManager; 5 | import org.springframework.cache.annotation.CachingConfigurerSupport; 6 | import org.springframework.cache.annotation.EnableCaching; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | import org.springframework.data.redis.cache.RedisCacheManager; 10 | import org.springframework.data.redis.connection.RedisConnectionFactory; 11 | import org.springframework.data.redis.core.RedisTemplate; 12 | import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer; 13 | import org.springframework.data.redis.serializer.StringRedisSerializer; 14 | 15 | /** 16 | * @Author 徐亮亮 17 | * @Description: Redis缓存配置类 18 | * @Date 2019/1/18 20:35 19 | */ 20 | @Configuration 21 | @EnableCaching 22 | public class RedisCacheConfig extends CachingConfigurerSupport { 23 | @Value("${redis.cache.expiration:3600}") 24 | private Long expiration; 25 | 26 | @Bean 27 | public CacheManager cacheManager(RedisTemplate redisTemplate) { 28 | RedisCacheManager rcm = new RedisCacheManager(redisTemplate); 29 | rcm.setDefaultExpiration(expiration); 30 | return rcm; 31 | } 32 | 33 | @Bean 34 | public RedisTemplate redisTemplate(RedisConnectionFactory factory) { 35 | RedisTemplate template = new RedisTemplate<>(); 36 | template.setConnectionFactory(factory); 37 | template.setKeySerializer(new StringRedisSerializer()); 38 | template.setValueSerializer(new JdkSerializationRedisSerializer()); 39 | return template; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /xll-common/src/main/java/com/xll/upms/common/bean/config/SwaggerConfig.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.common.bean.config; 2 | 3 | import io.swagger.annotations.ApiOperation; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import springfox.documentation.builders.ApiInfoBuilder; 7 | import springfox.documentation.builders.ParameterBuilder; 8 | import springfox.documentation.builders.PathSelectors; 9 | import springfox.documentation.builders.RequestHandlerSelectors; 10 | import springfox.documentation.schema.ModelRef; 11 | import springfox.documentation.service.ApiInfo; 12 | import springfox.documentation.service.Contact; 13 | import springfox.documentation.service.Parameter; 14 | import springfox.documentation.spi.DocumentationType; 15 | import springfox.documentation.spring.web.plugins.Docket; 16 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | /** 22 | * @Author 徐亮亮 23 | * @Description:Swagger配置类 24 | * @Date 2019/1/18 20:36 25 | */ 26 | @Configuration 27 | @EnableSwagger2 28 | public class SwaggerConfig { 29 | 30 | @Bean 31 | public Docket createRestApi() { 32 | ParameterBuilder tokenBuilder = new ParameterBuilder(); 33 | List parameterList = new ArrayList<>(); 34 | tokenBuilder.name("Authorization") 35 | .defaultValue("去其他请求中获取heard中token参数") 36 | .description("令牌") 37 | .modelRef(new ModelRef("string")) 38 | .parameterType("header") 39 | .required(true).build(); 40 | parameterList.add(tokenBuilder.build()); 41 | return new Docket(DocumentationType.SWAGGER_2) 42 | .apiInfo(apiInfo()) 43 | .select() 44 | .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) 45 | .paths(PathSelectors.any()) 46 | .build() 47 | .globalOperationParameters(parameterList); 48 | } 49 | 50 | private ApiInfo apiInfo() { 51 | return new ApiInfoBuilder() 52 | .title("Pig Swagger API ") 53 | .description("https://gitee.com/log4j/pig/wikis") 54 | .termsOfServiceUrl("https://gitee.com/log4j/pig") 55 | .contact(new Contact("冷冷","https://gitee.com/log4j/pig","wangiegie@gmail.com")) 56 | .version("1.0") 57 | .build(); 58 | } 59 | 60 | } -------------------------------------------------------------------------------- /xll-common/src/main/java/com/xll/upms/common/bean/config/WebMvcConfig.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.common.bean.config; 2 | 3 | import com.xll.upms.common.bean.resolver.TokenArgumentResolver; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.method.support.HandlerMethodArgumentResolver; 6 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @Author 徐亮亮 12 | * @Description: MVC配置类 13 | * @Date 2019/1/18 20:37 14 | */ 15 | @Configuration 16 | public class WebMvcConfig extends WebMvcConfigurerAdapter { 17 | @Override 18 | public void addArgumentResolvers(List argumentResolvers) { 19 | argumentResolvers.add(new TokenArgumentResolver()); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /xll-common/src/main/java/com/xll/upms/common/bean/handler/GlobalExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.common.bean.handler; 2 | 3 | /** 4 | * @author lengleng 5 | * @date 2018/5/24 6 | */ 7 | 8 | import com.xll.upms.common.util.R; 9 | import lombok.extern.slf4j.Slf4j; 10 | import org.springframework.http.HttpStatus; 11 | import org.springframework.web.bind.annotation.ExceptionHandler; 12 | import org.springframework.web.bind.annotation.ResponseBody; 13 | import org.springframework.web.bind.annotation.ResponseStatus; 14 | import org.springframework.web.bind.annotation.RestControllerAdvice; 15 | 16 | /** 17 | * @Author 徐亮亮 18 | * @Description: 全局的的异常拦截器 19 | * @Date 2019/1/18 20:37 20 | */ 21 | @Slf4j 22 | @RestControllerAdvice 23 | public class GlobalExceptionHandler { 24 | /** 25 | * 全局异常. 26 | * 27 | * @param e the e 28 | * @return R 29 | */ 30 | @ExceptionHandler(Exception.class) 31 | @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) 32 | @ResponseBody 33 | public R exception(Exception e) { 34 | log.info("保存全局异常信息 ex={}", e.getMessage(), e); 35 | return new R<>(e); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /xll-common/src/main/java/com/xll/upms/common/bean/interceptor/DataScope.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.common.bean.interceptor; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.HashMap; 6 | import java.util.List; 7 | 8 | /** 9 | * @Author 徐亮亮 10 | * @Description: 数据权限、参考guns实现,增强查询参数 11 | * @Date 2019/1/18 20:38 12 | */ 13 | @Data 14 | public class DataScope extends HashMap { 15 | /** 16 | * 限制范围的字段名称 17 | */ 18 | private String scopeName = "dept_id"; 19 | 20 | /** 21 | * 具体的数据范围 22 | */ 23 | private List deptIds; 24 | 25 | /** 26 | * 是否只查询本部门 27 | */ 28 | private Boolean isOnly = false; 29 | } 30 | -------------------------------------------------------------------------------- /xll-common/src/main/java/com/xll/upms/common/bean/xss/SqlFilter.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.common.bean.xss; 2 | 3 | import com.xll.upms.common.util.exception.CheckedException; 4 | import org.apache.commons.lang3.StringUtils; 5 | 6 | /** 7 | * @Author 徐亮亮 8 | * @Description:SQL过滤 9 | * @Date 2019/1/18 20:42 10 | */ 11 | public class SqlFilter { 12 | 13 | /** 14 | * SQL注入过滤 15 | * @param str 待验证的字符串 16 | */ 17 | public static String sqlInject(String str){ 18 | if(StringUtils.isBlank(str)){ 19 | return null; 20 | } 21 | //去掉'|"|;|\字符 22 | str = StringUtils.replace(str, "'", ""); 23 | str = StringUtils.replace(str, "\"", ""); 24 | str = StringUtils.replace(str, ";", ""); 25 | str = StringUtils.replace(str, "\\", ""); 26 | 27 | //转换成小写 28 | str = str.toLowerCase(); 29 | 30 | //非法字符 31 | String[] keywords = {"master", "truncate", "insert", "select", "delete", "update", "declare", "alert", "drop"}; 32 | 33 | //判断是否包含非法字符 34 | for(String keyword : keywords){ 35 | if(str.indexOf(keyword) != -1){ 36 | throw new CheckedException("包含非法字符"); 37 | } 38 | } 39 | 40 | return str; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /xll-common/src/main/java/com/xll/upms/common/constant/CommonConstant.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.common.constant; 2 | 3 | /** 4 | * @Author 徐亮亮 5 | * @Description: 基础常量 6 | * @Date 2019/1/18 20:48 7 | */ 8 | public interface CommonConstant { 9 | /** 10 | * token请求头名称 11 | */ 12 | String REQ_HEADER = "Authorization"; 13 | 14 | /** 15 | * token分割符 16 | */ 17 | String TOKEN_SPLIT = "Bearer "; 18 | 19 | /** 20 | * jwt签名 21 | */ 22 | String SIGN_KEY = "PIG"; 23 | /** 24 | * 删除 25 | */ 26 | String STATUS_DEL = "1"; 27 | /** 28 | * 正常 29 | */ 30 | String STATUS_NORMAL = "0"; 31 | 32 | /** 33 | * 锁定 34 | */ 35 | String STATUS_LOCK = "9"; 36 | 37 | /** 38 | * 菜单 39 | */ 40 | String MENU = "0"; 41 | 42 | /** 43 | * 按钮 44 | */ 45 | String BUTTON = "1"; 46 | 47 | /** 48 | * 删除标记 49 | */ 50 | String DEL_FLAG = "del_flag"; 51 | 52 | /** 53 | * 编码 54 | */ 55 | String UTF8 = "UTF-8"; 56 | 57 | /** 58 | * JSON 资源 59 | */ 60 | String CONTENT_TYPE = "application/json; charset=utf-8"; 61 | 62 | /** 63 | * 阿里大鱼 64 | */ 65 | String ALIYUN_SMS = "aliyun_sms"; 66 | 67 | /** 68 | * 路由信息Redis保存的key 69 | */ 70 | String ROUTE_KEY = "_ROUTE_KEY"; 71 | } 72 | -------------------------------------------------------------------------------- /xll-common/src/main/java/com/xll/upms/common/constant/MqQueueConstant.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.common.constant; 2 | 3 | /** 4 | * @Author 徐亮亮 5 | * @Description: MQ 消息队列常量 6 | * @Date 2019/1/18 20:49 7 | */ 8 | public interface MqQueueConstant { 9 | /** 10 | * log rabbit队列名称 11 | */ 12 | String LOG_QUEUE = "log"; 13 | 14 | /** 15 | * 发送短信验证码队列 16 | */ 17 | String MOBILE_CODE_QUEUE = "mobile_code_queue"; 18 | 19 | /** 20 | * 短信服务状态队列 21 | */ 22 | String MOBILE_SERVICE_STATUS_CHANGE = "mobile_service_status_change"; 23 | 24 | /** 25 | * 钉钉服务状态队列 26 | */ 27 | String DINGTALK_SERVICE_STATUS_CHANGE = "dingtalk_service_status_change"; 28 | 29 | /** 30 | * zipkin 队列 31 | */ 32 | String ZIPKIN_NAME_QUEUE = "zipkin"; 33 | 34 | /** 35 | * 路由配置状态队列 36 | */ 37 | String ROUTE_CONFIG_CHANGE = "route_config_change"; 38 | } 39 | -------------------------------------------------------------------------------- /xll-common/src/main/java/com/xll/upms/common/constant/ServiceNameConstant.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.common.constant; 2 | 3 | /** 4 | * @Author 徐亮亮 5 | * @Description: 服务名称常量 6 | * @Date 2019/1/18 20:50 7 | */ 8 | public interface ServiceNameConstant { 9 | /** 10 | * 认证服务的SERVICEID(zuul 配置的对应) 11 | */ 12 | String AUTH_SERVICE = "pig-auth"; 13 | 14 | /** 15 | * UMPS模块 16 | */ 17 | String UMPS_SERVICE = "pig-upms-service"; 18 | } 19 | -------------------------------------------------------------------------------- /xll-common/src/main/java/com/xll/upms/common/constant/enums/EnumSmsChannel.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.common.constant.enums; 2 | 3 | /** 4 | * @Author 徐亮亮 5 | * @Description: 短信通道枚举 6 | * @Date 2019/1/18 20:47 7 | */ 8 | public enum EnumSmsChannel { 9 | /** 10 | * 阿里大鱼短信通道 11 | */ 12 | ALIYUN("ALIYUN_SMS", "阿里大鱼"); 13 | /** 14 | * 通道名称 15 | */ 16 | private String name; 17 | /** 18 | * 通道描述 19 | */ 20 | private String description; 21 | 22 | EnumSmsChannel(String name, String description) { 23 | this.name = name; 24 | this.description = description; 25 | } 26 | 27 | public String getName() { 28 | return name; 29 | } 30 | 31 | public void setName(String name) { 32 | this.name = name; 33 | } 34 | 35 | public String getDescription() { 36 | return description; 37 | } 38 | 39 | public void setDescription(String description) { 40 | this.description = description; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /xll-common/src/main/java/com/xll/upms/common/constant/enums/EnumSmsChannelTemplate.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.common.constant.enums; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | /** 7 | * @Author 徐亮亮 8 | * @Description: 短信通道枚举模板 9 | * @Date 2019/1/18 20:47 10 | */ 11 | public enum EnumSmsChannelTemplate { 12 | /** 13 | * 登录验证 14 | */ 15 | LOGIN_NAME_LOGIN("loginCodeChannel", "登录验证"), 16 | /** 17 | * 服务异常提醒 18 | */ 19 | SERVICE_STATUS_CHANGE("serviceStatusChange", "Pig4Cloud"); 20 | 21 | 22 | /** 23 | * 模板名称 24 | */ 25 | @Getter 26 | @Setter 27 | private String template; 28 | /** 29 | * 模板签名 30 | */ 31 | @Getter 32 | @Setter 33 | private String signName; 34 | 35 | EnumSmsChannelTemplate(String template, String signName) { 36 | this.template = template; 37 | this.signName = signName; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /xll-common/src/main/java/com/xll/upms/common/entity/SysZuulRoute.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.common.entity; 2 | 3 | import com.baomidou.mybatisplus.activerecord.Model; 4 | import com.baomidou.mybatisplus.annotations.TableField; 5 | import com.baomidou.mybatisplus.annotations.TableId; 6 | import com.baomidou.mybatisplus.annotations.TableName; 7 | import com.baomidou.mybatisplus.enums.IdType; 8 | import lombok.Data; 9 | 10 | import java.io.Serializable; 11 | import java.util.Date; 12 | 13 | /** 14 | * @Author 徐亮亮 15 | * @Description:动态路由配置表实体类 16 | * @Date 2019/1/18 20:51 17 | */ 18 | @Data 19 | @TableName("sys_zuul_route") 20 | public class SysZuulRoute extends Model { 21 | 22 | private static final long serialVersionUID = 1L; 23 | 24 | /** 25 | * router Id 26 | */ 27 | @TableId(value = "id", type = IdType.AUTO) 28 | private Integer id; 29 | /** 30 | * 路由路径 31 | */ 32 | private String path; 33 | /** 34 | * 服务名称 35 | */ 36 | @TableField("service_id") 37 | private String serviceId; 38 | /** 39 | * url代理 40 | */ 41 | private String url; 42 | /** 43 | * 转发去掉前缀 44 | */ 45 | @TableField("strip_prefix") 46 | private String stripPrefix; 47 | /** 48 | * 是否重试 49 | */ 50 | private String retryable; 51 | /** 52 | * 是否启用 53 | */ 54 | private String enabled; 55 | /** 56 | * 敏感请求头 57 | */ 58 | @TableField("sensitiveHeaders_list") 59 | private String sensitiveheadersList; 60 | /** 61 | * 创建时间 62 | */ 63 | @TableField("create_time") 64 | private Date createTime; 65 | /** 66 | * 更新时间 67 | */ 68 | @TableField("update_time") 69 | private Date updateTime; 70 | /** 71 | * 删除标识(0-正常,1-删除) 72 | */ 73 | @TableField("del_flag") 74 | private String delFlag; 75 | 76 | @Override 77 | protected Serializable pkVal() { 78 | return this.id; 79 | } 80 | 81 | 82 | } 83 | -------------------------------------------------------------------------------- /xll-common/src/main/java/com/xll/upms/common/util/Assert.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.common.util; 2 | 3 | import com.xll.upms.common.util.exception.CheckedException; 4 | import org.apache.commons.lang.StringUtils; 5 | 6 | import javax.validation.ConstraintViolation; 7 | import javax.validation.Validation; 8 | import javax.validation.Validator; 9 | import java.util.Set; 10 | 11 | /** 12 | * @Author 徐亮亮 13 | * @Description: 数据校验 14 | * @Date 2019/1/18 20:56 15 | */ 16 | public class Assert { 17 | private static Validator validator; 18 | 19 | static { 20 | validator = Validation.buildDefaultValidatorFactory().getValidator(); 21 | } 22 | 23 | /** 24 | * 校验对象 25 | * @param object 待校验对象 26 | * @param groups 待校验的组 27 | * @throws CheckedException 校验不通过,则报RRException异常 28 | */ 29 | public static void validateEntity(Object object, Class... groups) 30 | throws CheckedException { 31 | Set> constraintViolations = validator.validate(object, groups); 32 | if (!constraintViolations.isEmpty()) { 33 | StringBuilder msg = new StringBuilder(); 34 | for(ConstraintViolation constraint: constraintViolations){ 35 | msg.append(constraint.getMessage()).append("
"); 36 | } 37 | throw new CheckedException(msg.toString()); 38 | } 39 | } 40 | 41 | public static void isBlank(String str, String message) { 42 | if (StringUtils.isBlank(str)) { 43 | throw new CheckedException(message); 44 | } 45 | } 46 | 47 | public static void isNull(Object object, String message) { 48 | if (object == null) { 49 | throw new CheckedException(message); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /xll-common/src/main/java/com/xll/upms/common/util/AuthUtils.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.common.util; 2 | 3 | import com.xll.upms.common.constant.CommonConstant; 4 | import com.xll.upms.common.util.exception.CheckedException; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.security.crypto.codec.Base64; 7 | 8 | import javax.servlet.http.HttpServletRequest; 9 | import java.io.IOException; 10 | 11 | /** 12 | * @Author 徐亮亮 13 | * @Description: 认证授权相关工具类 14 | * @Date 2019/1/18 20:57 15 | */ 16 | @Slf4j 17 | public class AuthUtils { 18 | private static final String BASIC_ = "Basic "; 19 | 20 | /** 21 | * 从header 请求中的clientId/clientsecect 22 | * 23 | * @param header header中的参数 24 | * @throws CheckedException if the Basic header is not present or is not valid 25 | * Base64 26 | */ 27 | public static String[] extractAndDecodeHeader(String header) 28 | throws IOException { 29 | 30 | byte[] base64Token = header.substring(6).getBytes("UTF-8"); 31 | byte[] decoded; 32 | try { 33 | decoded = Base64.decode(base64Token); 34 | } catch (IllegalArgumentException e) { 35 | throw new CheckedException( 36 | "Failed to decode basic authentication token"); 37 | } 38 | 39 | String token = new String(decoded, CommonConstant.UTF8); 40 | 41 | int delim = token.indexOf(":"); 42 | 43 | if (delim == -1) { 44 | throw new CheckedException("Invalid basic authentication token"); 45 | } 46 | return new String[]{token.substring(0, delim), token.substring(delim + 1)}; 47 | } 48 | 49 | /** 50 | * *从header 请求中的clientId/clientsecect 51 | * 52 | * @param request 53 | * @return 54 | * @throws IOException 55 | */ 56 | public static String[] extractAndDecodeHeader(HttpServletRequest request) 57 | throws IOException { 58 | String header = request.getHeader("Authorization"); 59 | 60 | if (header == null || !header.startsWith(BASIC_)) { 61 | throw new CheckedException("请求头中client信息为空"); 62 | } 63 | 64 | return extractAndDecodeHeader(header); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /xll-common/src/main/java/com/xll/upms/common/util/Query.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.common.util; 2 | 3 | import com.baomidou.mybatisplus.plugins.Page; 4 | import org.apache.commons.lang.StringUtils; 5 | 6 | import java.util.Map; 7 | 8 | /** 9 | * @Author 徐亮亮 10 | * @Description: 查询工具类 11 | * @Date 2019/1/18 20:57 12 | */ 13 | public class Query extends Page { 14 | private static final String PAGE = "page"; 15 | private static final String LIMIT = "limit"; 16 | private static final String ORDER_BY_FIELD = "orderByField"; 17 | private static final String IS_ASC = "isAsc"; 18 | 19 | public Query(Map params) { 20 | super(Integer.parseInt(params.getOrDefault(PAGE, 1).toString()) 21 | , Integer.parseInt(params.getOrDefault(LIMIT, 10).toString())); 22 | 23 | String orderByField = params.getOrDefault(ORDER_BY_FIELD, "").toString(); 24 | if (StringUtils.isNotEmpty(orderByField)) { 25 | this.setOrderByField(orderByField); 26 | } 27 | 28 | Boolean isAsc = Boolean.parseBoolean(params.getOrDefault(IS_ASC, Boolean.TRUE).toString()); 29 | this.setAsc(isAsc); 30 | 31 | params.remove(PAGE); 32 | params.remove(LIMIT); 33 | params.remove(ORDER_BY_FIELD); 34 | params.remove(IS_ASC); 35 | this.setCondition(params); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /xll-common/src/main/java/com/xll/upms/common/util/R.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.common.util; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * @Author 徐亮亮 7 | * @Description: 响应信息主体 8 | * @Date 2019/1/18 20:58 9 | */ 10 | public class R implements Serializable { 11 | 12 | private static final long serialVersionUID = 1L; 13 | 14 | public static final int NO_LOGIN = -1; 15 | 16 | public static final int SUCCESS = 0; 17 | 18 | public static final int FAIL = 1; 19 | 20 | public static final int NO_PERMISSION = 2; 21 | 22 | private String msg = "success"; 23 | 24 | private int code = SUCCESS; 25 | 26 | private T data; 27 | 28 | public R() { 29 | super(); 30 | } 31 | 32 | public R(T data) { 33 | super(); 34 | this.data = data; 35 | } 36 | 37 | public R(T data, String msg) { 38 | super(); 39 | this.data = data; 40 | this.msg = msg; 41 | } 42 | 43 | public R(Throwable e) { 44 | super(); 45 | this.msg = e.getMessage(); 46 | this.code = FAIL; 47 | } 48 | 49 | public String getMsg() { 50 | return msg; 51 | } 52 | 53 | public void setMsg(String msg) { 54 | this.msg = msg; 55 | } 56 | 57 | public int getCode() { 58 | return code; 59 | } 60 | 61 | public void setCode(int code) { 62 | this.code = code; 63 | } 64 | 65 | public T getData() { 66 | return data; 67 | } 68 | 69 | public void setData(T data) { 70 | this.data = data; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /xll-common/src/main/java/com/xll/upms/common/util/exception/CheckedException.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.common.util.exception; 2 | 3 | /** 4 | * @Author 徐亮亮 5 | * @Description: 检查异常 6 | * @Date 2019/1/18 20:52 7 | */ 8 | public class CheckedException extends RuntimeException { 9 | 10 | private static final long serialVersionUID = 1L; 11 | 12 | public CheckedException() { 13 | } 14 | 15 | public CheckedException(String message) { 16 | super(message); 17 | } 18 | 19 | public CheckedException(Throwable cause) { 20 | super(cause); 21 | } 22 | 23 | public CheckedException(String message, Throwable cause) { 24 | super(message, cause); 25 | } 26 | 27 | public CheckedException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { 28 | super(message, cause, enableSuppression, writableStackTrace); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /xll-common/src/main/java/com/xll/upms/common/util/exception/PigDeniedException.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.common.util.exception; 2 | 3 | /** 4 | * @Author 徐亮亮 5 | * @Description: 403 授权拒绝 6 | * @Date 2019/1/18 20:53 7 | */ 8 | public class PigDeniedException extends RuntimeException { 9 | 10 | private static final long serialVersionUID = 1L; 11 | 12 | public PigDeniedException() { 13 | } 14 | 15 | public PigDeniedException(String message) { 16 | super(message); 17 | } 18 | 19 | public PigDeniedException(Throwable cause) { 20 | super(cause); 21 | } 22 | 23 | public PigDeniedException(String message, Throwable cause) { 24 | super(message, cause); 25 | } 26 | 27 | public PigDeniedException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { 28 | super(message, cause, enableSuppression, writableStackTrace); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /xll-common/src/main/java/com/xll/upms/common/util/exception/UnloginException.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.common.util.exception; 2 | 3 | /** 4 | * @Author 徐亮亮 5 | * @Description: 登录失败异常 6 | * @Date 2019/1/18 20:53 7 | */ 8 | public class UnloginException extends RuntimeException { 9 | 10 | private static final long serialVersionUID = 1L; 11 | 12 | public UnloginException() { 13 | } 14 | 15 | public UnloginException(String message) { 16 | super(message); 17 | } 18 | 19 | public UnloginException(Throwable cause) { 20 | super(cause); 21 | } 22 | 23 | public UnloginException(String message, Throwable cause) { 24 | super(message, cause); 25 | } 26 | 27 | public UnloginException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { 28 | super(message, cause, enableSuppression, writableStackTrace); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /xll-common/src/main/java/com/xll/upms/common/util/exception/ValidateCodeException.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.common.util.exception; 2 | 3 | /** 4 | * @Author 徐亮亮 5 | * @Description:验证码异常 6 | * @Date 2019/1/18 20:54 7 | */ 8 | public class ValidateCodeException extends Exception { 9 | 10 | /** 11 | * 12 | */ 13 | private static final long serialVersionUID = -7285211528095468156L; 14 | 15 | public ValidateCodeException(String msg) { 16 | super(msg); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /xll-common/src/main/java/com/xll/upms/common/util/template/DingTalkMsgTemplate.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.common.util.template; 2 | 3 | import lombok.Data; 4 | import lombok.ToString; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * @Author 徐亮亮 10 | * @Description: 钉钉消息模板 11 | * msgtype : text 12 | * text : {"content":"服务: pig-upms-service 状态:UP"} 13 | * @Date 2019/1/18 20:55 14 | */ 15 | @Data 16 | @ToString 17 | public class DingTalkMsgTemplate implements Serializable { 18 | private String msgtype; 19 | private TextBean text; 20 | 21 | public String getMsgtype() { 22 | return msgtype; 23 | } 24 | 25 | public void setMsgtype(String msgtype) { 26 | this.msgtype = msgtype; 27 | } 28 | 29 | public TextBean getText() { 30 | return text; 31 | } 32 | 33 | public void setText(TextBean text) { 34 | this.text = text; 35 | } 36 | 37 | public static class TextBean { 38 | /** 39 | * content : 服务: pig-upms-service 状态:UP 40 | */ 41 | 42 | private String content; 43 | 44 | public String getContent() { 45 | return content; 46 | } 47 | 48 | public void setContent(String content) { 49 | this.content = content; 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /xll-common/src/main/java/com/xll/upms/common/util/template/MobileMsgTemplate.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.common.util.template; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * @Author 徐亮亮 9 | * @Description:短信消息模板 10 | * @Date 2019/1/18 20:55 11 | */ 12 | @Data 13 | public class MobileMsgTemplate implements Serializable { 14 | /** 15 | * 手机号 16 | */ 17 | private String mobile; 18 | /** 19 | * 组装后的模板内容JSON字符串 20 | */ 21 | private String context; 22 | /** 23 | * 短信通道 24 | */ 25 | private String channel; 26 | /** 27 | * 短信类型(验证码或者通知短信) 28 | * 暂时不用,留着后面存数据库备用吧 29 | */ 30 | private String type; 31 | /** 32 | * 短信签名 33 | */ 34 | private String signName; 35 | /** 36 | * 短信模板 37 | */ 38 | private String template; 39 | 40 | public MobileMsgTemplate(String mobile, String context, String channel, String signName, String template){ 41 | this.mobile = mobile; 42 | this.context = context; 43 | this.channel = channel; 44 | this.signName = signName; 45 | this.template = template; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /xll-common/src/main/java/com/xll/upms/common/vo/ErrorPojo.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.common.vo; 2 | 3 | import com.alibaba.fastjson.annotation.JSONField; 4 | import lombok.Data; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * @Author 徐亮亮 10 | * @Description:spring boot 的异常对象视图实体类 11 | * @Date 2019/1/18 20:59 12 | */ 13 | @Data 14 | public class ErrorPojo implements Serializable { 15 | 16 | @JSONField(name = "timestamp") 17 | private long timestamp; 18 | @JSONField(name = "status") 19 | private int status; 20 | @JSONField(name = "error") 21 | private String error; 22 | @JSONField(name = "exception") 23 | private String exception; 24 | @JSONField(name = "message") 25 | private String message; 26 | @JSONField(name = "path") 27 | private String path; 28 | } 29 | -------------------------------------------------------------------------------- /xll-common/src/main/java/com/xll/upms/common/vo/ImageCode.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.common.vo; 2 | 3 | import lombok.Data; 4 | 5 | import java.awt.image.BufferedImage; 6 | import java.io.Serializable; 7 | import java.time.LocalDateTime; 8 | 9 | 10 | /** 11 | * @Author 徐亮亮 12 | * @Description: 图片码视图实体类 13 | * @Date 2019/1/18 21:00 14 | */ 15 | @Data 16 | public class ImageCode implements Serializable { 17 | private String code; 18 | 19 | private LocalDateTime expireTime; 20 | 21 | private BufferedImage image; 22 | 23 | public ImageCode(BufferedImage image, String sRand, int defaultImageExpire) { 24 | this.image = image; 25 | this.code = sRand; 26 | this.expireTime = LocalDateTime.now().plusSeconds(defaultImageExpire); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /xll-common/src/main/java/com/xll/upms/common/vo/LogVO.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.common.vo; 2 | 3 | import com.xll.upms.common.entity.SysLog; 4 | import lombok.Data; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * @Author 徐亮亮 10 | * @Description: 日志视图实体类 11 | * @Date 2019/1/18 21:01 12 | */ 13 | @Data 14 | public class LogVO implements Serializable { 15 | private static final long serialVersionUID = 1L; 16 | 17 | private SysLog sysLog; 18 | private String username; 19 | } 20 | -------------------------------------------------------------------------------- /xll-common/src/main/java/com/xll/upms/common/vo/MenuVO.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.common.vo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.util.Date; 7 | 8 | /** 9 | * @Author 徐亮亮 10 | * @Description:菜单权限表视图实体类 11 | * @Date 2019/1/18 21:01 12 | */ 13 | @Data 14 | public class MenuVO implements Serializable { 15 | 16 | private static final long serialVersionUID = 1L; 17 | 18 | /** 19 | * 菜单ID 20 | */ 21 | private Integer menuId; 22 | /** 23 | * 菜单名称 24 | */ 25 | private String name; 26 | /** 27 | * 菜单权限标识 28 | */ 29 | private String permission; 30 | /** 31 | * 请求链接 32 | */ 33 | private String url; 34 | /** 35 | * 请求方法 36 | */ 37 | private String method; 38 | /** 39 | * 父菜单ID 40 | */ 41 | private Integer parentId; 42 | /** 43 | * 图标 44 | */ 45 | private String icon; 46 | /** 47 | * 一个路径 48 | */ 49 | private String path; 50 | /** 51 | * VUE页面 52 | */ 53 | private String component; 54 | /** 55 | * 排序值 56 | */ 57 | private Integer sort; 58 | /** 59 | * 菜单类型 (0菜单 1按钮) 60 | */ 61 | private String type; 62 | /** 63 | * 创建时间 64 | */ 65 | private Date createTime; 66 | /** 67 | * 更新时间 68 | */ 69 | private Date updateTime; 70 | /** 71 | * 0--正常 1--删除 72 | */ 73 | private String delFlag; 74 | 75 | 76 | @Override 77 | public int hashCode() { 78 | return menuId.hashCode(); 79 | } 80 | 81 | /** 82 | * menuId 相同则相同 83 | * 84 | * @param obj 85 | * @return 86 | */ 87 | @Override 88 | public boolean equals(Object obj) { 89 | if (obj instanceof MenuVO) { 90 | Integer targetMenuId = ((MenuVO) obj).getMenuId(); 91 | return menuId.equals(targetMenuId); 92 | } 93 | return super.equals(obj); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /xll-common/src/main/java/com/xll/upms/common/vo/SysRole.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.common.vo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.util.Date; 7 | 8 | /** 9 | * @Author 徐亮亮 10 | * @Description: 系统权限视图实体类 11 | * @Date 2019/1/18 21:02 12 | */ 13 | @Data 14 | public class SysRole implements Serializable { 15 | private static final long serialVersionUID = 1L; 16 | 17 | private Integer roleId; 18 | private String roleName; 19 | private String roleCode; 20 | private String roleDesc; 21 | private Date createTime; 22 | private Date updateTime; 23 | private String delFlag; 24 | 25 | @Override 26 | public String toString() { 27 | return "SysRole{" + 28 | ", roleId=" + roleId + 29 | ", roleName=" + roleName + 30 | ", roleCode=" + roleCode + 31 | ", roleDesc=" + roleDesc + 32 | ", createTime=" + createTime + 33 | ", updateTime=" + updateTime + 34 | ", delFlag=" + delFlag + 35 | "}"; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /xll-common/src/main/java/com/xll/upms/common/vo/UserVO.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.common.vo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.util.Date; 7 | import java.util.List; 8 | 9 | /** 10 | * @Author 徐亮亮 11 | * @Description: 用户视图实体类 12 | * @Date 2019/1/18 21:03 13 | */ 14 | @Data 15 | public class UserVO implements Serializable { 16 | private static final long serialVersionUID = 1L; 17 | 18 | /** 19 | * 主键ID 20 | */ 21 | private Integer userId; 22 | /** 23 | * 用户名 24 | */ 25 | private String username; 26 | /** 27 | * 密码 28 | */ 29 | private String password; 30 | /** 31 | * 随机盐 32 | */ 33 | private String salt; 34 | /** 35 | * 创建时间 36 | */ 37 | private Date createTime; 38 | /** 39 | * 修改时间 40 | */ 41 | private Date updateTime; 42 | /** 43 | * 0-正常,1-删除 44 | */ 45 | private String delFlag; 46 | /** 47 | * 简介 48 | */ 49 | private String phone; 50 | /** 51 | * 头像 52 | */ 53 | private String avatar; 54 | 55 | /** 56 | * 部门ID 57 | */ 58 | private Integer deptId; 59 | /** 60 | * 部门名称 61 | */ 62 | private String deptName; 63 | 64 | /** 65 | * 角色列表 66 | */ 67 | private List roleList; 68 | } 69 | -------------------------------------------------------------------------------- /xll-common/src/main/java/com/xll/upms/common/web/BaseController.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.common.web; 2 | 3 | import com.xll.upms.common.util.UserUtils; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | 6 | import javax.servlet.http.HttpServletRequest; 7 | import java.util.List; 8 | 9 | /** 10 | * @Author 徐亮亮 11 | * @Description:基础控制器 12 | * @Date 2019/1/18 21:03 13 | */ 14 | public class BaseController { 15 | @Autowired 16 | private HttpServletRequest request; 17 | protected org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(this.getClass()); 18 | 19 | /** 20 | * 根据请求heard中的token获取用户角色 21 | * 22 | * @return 角色名 23 | */ 24 | public List getRole() { 25 | return UserUtils.getRole(request); 26 | } 27 | 28 | /** 29 | * 根据请求heard中的token获取用户ID 30 | * 31 | * @return 用户ID 32 | */ 33 | public Integer getUserId() { 34 | return UserUtils.getUserId(request); 35 | } 36 | 37 | 38 | } 39 | -------------------------------------------------------------------------------- /xll-config/src/main/java/com/xll/upms/config/UPMSConfigApplication.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.config; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import org.springframework.cloud.config.server.EnableConfigServer; 7 | 8 | /** 9 | * @Author 徐亮亮 10 | * @Description: 配置服务器中心 11 | * @Date 2019/1/18 21:03 12 | */ 13 | @EnableDiscoveryClient 14 | @EnableConfigServer 15 | @SpringBootApplication 16 | public class UPMSConfigApplication { 17 | 18 | public static void main(String[] args) { 19 | SpringApplication.run(UPMSConfigApplication.class, args); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /xll-config/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 4001 3 | 4 | spring: 5 | application: 6 | name: pig-config-server 7 | profiles: 8 | active: dev 9 | cloud: 10 | config: 11 | server: 12 | git: 13 | uri: https://gitee.com/goodsX/pig-config.git 14 | default-label: master #解决监控down 15 | 16 | # 关闭安全管理 17 | management: 18 | security: 19 | enabled: false 20 | endpoints: 21 | health: 22 | sensitive: false 23 | --- 24 | spring: 25 | profiles: dev 26 | rabbitmq: 27 | host: 192.168.10.153 28 | port: 5672 29 | username: guest 30 | password: guest 31 | eureka: 32 | instance: 33 | prefer-ip-address: true 34 | lease-renewal-interval-in-seconds: 5 35 | lease-expiration-duration-in-seconds: 20 36 | client: 37 | serviceUrl: 38 | defaultZone: http://xll:gip6666@localhost:1025/eureka 39 | registry-fetch-interval-seconds: 10 40 | --- 41 | spring: 42 | profiles: prd 43 | rabbitmq: 44 | host: 192.168.10.153 45 | port: 5672 46 | username: guest 47 | password: guest 48 | cloud: 49 | config: 50 | retry: 51 | initial-interval: 3000 52 | multiplier: 1.5 53 | max-interval: 20000 54 | max-attempts: 6 55 | eureka: 56 | instance: 57 | prefer-ip-address: true 58 | client: 59 | serviceUrl: 60 | defaultZone: http://xll:gip6666@eureka:1025/eureka 61 | -------------------------------------------------------------------------------- /xll-eureka/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 21 | 4.0.0 22 | 23 | com.xll.upms 24 | xll-eureka 25 | 1.3.1 26 | jar 27 | 28 | xll-eureka 29 | eureka server 30 | 31 | 32 | com.xll 33 | xll-upms 34 | 1.3.1 35 | 36 | 37 | 38 | 39 | org.springframework.cloud 40 | spring-cloud-starter-eureka-server 41 | 42 | 43 | org.springframework.cloud 44 | spring-cloud-starter-security 45 | 46 | 47 | 48 | 49 | 50 | 51 | org.springframework.boot 52 | spring-boot-maven-plugin 53 | 54 | ${project.name} 55 | 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /xll-eureka/src/main/java/com/xll/upms/eureka/UPMSEurekaApplication.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.eureka; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; 6 | 7 | /** 8 | * @Author 徐亮亮 9 | * @Description:服务注册与服务发现 10 | * @Date 2019/1/18 21:04 11 | */ 12 | @EnableEurekaServer 13 | @SpringBootApplication 14 | public class UPMSEurekaApplication { 15 | 16 | public static void main(String[] args) { 17 | SpringApplication.run(UPMSEurekaApplication.class, args); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /xll-eureka/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 1025 3 | 4 | spring: 5 | application: 6 | name: pig-eureka-server 7 | cloud: 8 | config: 9 | enabled: false 10 | 11 | security: 12 | basic: 13 | enabled: true # 启用身份认证 14 | user: 15 | name: xll # 定义用户名 16 | password: gip6666 # 定义密码 17 | 18 | eureka: 19 | client: 20 | fetch-registry: false 21 | register-with-eureka: false 22 | serviceUrl: 23 | defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/ 24 | instance: 25 | hostname: localhost 26 | server: #配置属性,但由于 Eureka 自我保护模式以及心跳周期长的原因,经常会遇到 Eureka Server 不剔除已关停的节点的问题 27 | enable-self-preservation: false 28 | eviction-interval-timer-in-ms: 5000 29 | -------------------------------------------------------------------------------- /xll-gateway/src/main/java/com/xll/upms/gateway/component/config/DynamicRouteConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.gateway.component.config; 2 | 3 | import org.springframework.boot.autoconfigure.web.ServerProperties; 4 | import org.springframework.cloud.client.discovery.DiscoveryClient; 5 | import org.springframework.cloud.client.serviceregistry.Registration; 6 | import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | import org.springframework.data.redis.core.RedisTemplate; 10 | 11 | /** 12 | * @Author 徐亮亮 13 | * @Description:动态路由配置类 14 | * @Date 2019/1/18 21:05 15 | */ 16 | @Configuration 17 | public class DynamicRouteConfiguration { 18 | private Registration registration; 19 | private DiscoveryClient discovery; 20 | private ZuulProperties zuulProperties; 21 | private ServerProperties server; 22 | private RedisTemplate redisTemplate; 23 | 24 | public DynamicRouteConfiguration(Registration registration, DiscoveryClient discovery, 25 | ZuulProperties zuulProperties, ServerProperties server, RedisTemplate redisTemplate) { 26 | this.registration = registration; 27 | this.discovery = discovery; 28 | this.zuulProperties = zuulProperties; 29 | this.server = server; 30 | this.redisTemplate = redisTemplate; 31 | } 32 | 33 | @Bean 34 | public DynamicRouteLocator dynamicRouteLocator() { 35 | return new DynamicRouteLocator(server.getServletPrefix() 36 | , discovery 37 | , zuulProperties 38 | , registration 39 | , redisTemplate); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /xll-gateway/src/main/java/com/xll/upms/gateway/component/config/RegistrySwaggerResourcesProvider.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.gateway.component.config; 2 | 3 | import com.xll.upms.common.constant.ServiceNameConstant; 4 | import org.apache.commons.lang.StringUtils; 5 | import org.springframework.cloud.netflix.zuul.filters.Route; 6 | import org.springframework.cloud.netflix.zuul.filters.RouteLocator; 7 | import org.springframework.context.annotation.Primary; 8 | import org.springframework.stereotype.Component; 9 | import springfox.documentation.swagger.web.SwaggerResource; 10 | import springfox.documentation.swagger.web.SwaggerResourcesProvider; 11 | 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | 15 | /** 16 | * @Author 徐亮亮 17 | * @Description: routeLocator 聚合swagger 18 | * @Date 2019/1/18 21:05 19 | */ 20 | @Component 21 | @Primary 22 | public class RegistrySwaggerResourcesProvider implements SwaggerResourcesProvider { 23 | private final RouteLocator routeLocator; 24 | 25 | public RegistrySwaggerResourcesProvider(RouteLocator routeLocator) { 26 | this.routeLocator = routeLocator; 27 | } 28 | 29 | @Override 30 | public List get() { 31 | List resources = new ArrayList<>(); 32 | 33 | List routes = routeLocator.getRoutes(); 34 | routes.forEach(route -> { 35 | //授权不维护到swagger 36 | if (!StringUtils.contains(route.getId(), ServiceNameConstant.AUTH_SERVICE)){ 37 | resources.add(swaggerResource(route.getId(), route.getFullPath().replace("**", "v2/api-docs"))); 38 | } 39 | }); 40 | 41 | return resources; 42 | } 43 | 44 | private SwaggerResource swaggerResource(String name, String location) { 45 | SwaggerResource swaggerResource = new SwaggerResource(); 46 | swaggerResource.setName(name); 47 | swaggerResource.setLocation(location); 48 | swaggerResource.setSwaggerVersion("2.0"); 49 | return swaggerResource; 50 | } 51 | } -------------------------------------------------------------------------------- /xll-gateway/src/main/java/com/xll/upms/gateway/component/config/RibbonMetaFilterAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.gateway.component.config; 2 | 3 | import com.xll.upms.gateway.component.handler.MetadataCanaryRuleHandler; 4 | import com.netflix.loadbalancer.ZoneAvoidanceRule; 5 | import com.netflix.niws.loadbalancer.DiscoveryEnabledNIWSServerList; 6 | import org.springframework.beans.factory.config.ConfigurableBeanFactory; 7 | import org.springframework.boot.autoconfigure.AutoConfigureBefore; 8 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 9 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; 10 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 11 | import org.springframework.cloud.netflix.ribbon.RibbonClientConfiguration; 12 | import org.springframework.context.annotation.Bean; 13 | import org.springframework.context.annotation.Configuration; 14 | import org.springframework.context.annotation.Scope; 15 | 16 | /** 17 | * @Author 徐亮亮 18 | * @Description:灰度路由初始化类 19 | * @Date 2019/1/18 21:06 20 | */ 21 | @Configuration 22 | @ConditionalOnClass(DiscoveryEnabledNIWSServerList.class) 23 | @AutoConfigureBefore(RibbonClientConfiguration.class) 24 | @ConditionalOnProperty(value = "zuul.ribbon.metadata.enabled") 25 | public class RibbonMetaFilterAutoConfiguration { 26 | 27 | @Bean 28 | @ConditionalOnMissingBean 29 | @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) 30 | public ZoneAvoidanceRule metadataAwareRule() { 31 | return new MetadataCanaryRuleHandler(); 32 | } 33 | } 34 | 35 | -------------------------------------------------------------------------------- /xll-gateway/src/main/java/com/xll/upms/gateway/component/filter/AccessFilter.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.gateway.component.filter; 2 | 3 | import com.xll.upms.common.constant.SecurityConstants; 4 | import com.xll.upms.gateway.util.RibbonVersionHolder; 5 | import com.netflix.zuul.ZuulFilter; 6 | import com.netflix.zuul.context.RequestContext; 7 | import com.xiaoleilu.hutool.collection.CollectionUtil; 8 | import com.xiaoleilu.hutool.util.StrUtil; 9 | import org.springframework.beans.factory.annotation.Value; 10 | import org.springframework.cloud.netflix.zuul.filters.support.FilterConstants; 11 | import org.springframework.security.core.Authentication; 12 | import org.springframework.security.core.context.SecurityContextHolder; 13 | import org.springframework.stereotype.Component; 14 | 15 | import static org.springframework.cloud.netflix.zuul.filters.support.FilterConstants.FORM_BODY_WRAPPER_FILTER_ORDER; 16 | 17 | /** 18 | * @Author 徐亮亮 19 | * @Description: 在RateLimitPreFilter 之前执行,不然又空指针问题 20 | * @Date 2019/1/18 21:08 21 | */ 22 | @Component 23 | public class AccessFilter extends ZuulFilter { 24 | @Value("${zuul.ribbon.metadata.enabled:false}") 25 | private boolean canary; 26 | 27 | @Override 28 | public String filterType() { 29 | return FilterConstants.PRE_TYPE; 30 | } 31 | 32 | @Override 33 | public int filterOrder() { 34 | return FORM_BODY_WRAPPER_FILTER_ORDER - 1; 35 | } 36 | 37 | @Override 38 | public boolean shouldFilter() { 39 | return true; 40 | } 41 | 42 | @Override 43 | public Object run() { 44 | RequestContext requestContext = RequestContext.getCurrentContext(); 45 | String version = requestContext.getRequest().getHeader(SecurityConstants.VERSION); 46 | if (canary && StrUtil.isNotBlank(version)) { 47 | RibbonVersionHolder.setContext(version); 48 | } 49 | 50 | requestContext.set("startTime", System.currentTimeMillis()); 51 | Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); 52 | if (authentication != null) { 53 | requestContext.addZuulRequestHeader(SecurityConstants.USER_HEADER, authentication.getName()); 54 | requestContext.addZuulRequestHeader(SecurityConstants.ROLE_HEADER, CollectionUtil.join(authentication.getAuthorities(), ",")); 55 | } 56 | return null; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /xll-gateway/src/main/java/com/xll/upms/gateway/component/filter/ErrorHandlerFilter.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.gateway.component.filter; 2 | 3 | import com.xll.upms.gateway.service.LogSendService; 4 | import com.netflix.zuul.ZuulFilter; 5 | import com.netflix.zuul.context.RequestContext; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Component; 8 | 9 | import static org.springframework.cloud.netflix.zuul.filters.support.FilterConstants.ERROR_TYPE; 10 | import static org.springframework.cloud.netflix.zuul.filters.support.FilterConstants.SEND_RESPONSE_FILTER_ORDER; 11 | 12 | /** 13 | * @Author 徐亮亮 14 | * @Description: 网关统一异常处理 15 | * @Date 2019/1/18 21:09 16 | */ 17 | @Component 18 | public class ErrorHandlerFilter extends ZuulFilter { 19 | @Autowired 20 | private LogSendService logSendService; 21 | 22 | @Override 23 | public String filterType() { 24 | return ERROR_TYPE; 25 | } 26 | 27 | @Override 28 | public int filterOrder() { 29 | return SEND_RESPONSE_FILTER_ORDER + 1; 30 | } 31 | 32 | @Override 33 | public boolean shouldFilter() { 34 | RequestContext requestContext = RequestContext.getCurrentContext(); 35 | return requestContext.getThrowable() != null; 36 | } 37 | 38 | @Override 39 | public Object run() { 40 | RequestContext requestContext = RequestContext.getCurrentContext(); 41 | logSendService.send(requestContext); 42 | return null; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /xll-gateway/src/main/java/com/xll/upms/gateway/component/filter/LoggerFilter.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.gateway.component.filter; 2 | 3 | import com.xll.upms.gateway.service.LogSendService; 4 | import com.netflix.zuul.ZuulFilter; 5 | import com.netflix.zuul.context.RequestContext; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Component; 8 | 9 | import static org.springframework.cloud.netflix.zuul.filters.support.FilterConstants.POST_TYPE; 10 | import static org.springframework.cloud.netflix.zuul.filters.support.FilterConstants.SEND_RESPONSE_FILTER_ORDER; 11 | 12 | /** 13 | * @Author 徐亮亮 14 | * @Description: 网关日志拦截器 15 | * @Date 2019/1/18 21:10 16 | */ 17 | @Component 18 | public class LoggerFilter extends ZuulFilter { 19 | 20 | @Autowired 21 | private LogSendService logSendService; 22 | 23 | @Override 24 | public String filterType() { 25 | return POST_TYPE; 26 | } 27 | 28 | @Override 29 | public int filterOrder() { 30 | return SEND_RESPONSE_FILTER_ORDER - 1; 31 | } 32 | 33 | @Override 34 | public boolean shouldFilter() { 35 | return true; 36 | } 37 | 38 | @Override 39 | public Object run() { 40 | logSendService.send(RequestContext.getCurrentContext()); 41 | return null; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /xll-gateway/src/main/java/com/xll/upms/gateway/component/filter/PreviewFilter.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.gateway.component.filter; 2 | 3 | import com.alibaba.fastjson.JSONObject; 4 | import com.xll.upms.common.util.R; 5 | import com.netflix.zuul.ZuulFilter; 6 | import com.netflix.zuul.context.RequestContext; 7 | import com.xiaoleilu.hutool.util.StrUtil; 8 | import lombok.extern.slf4j.Slf4j; 9 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 10 | import org.springframework.cloud.context.config.annotation.RefreshScope; 11 | import org.springframework.cloud.netflix.zuul.filters.support.FilterConstants; 12 | import org.springframework.context.annotation.Configuration; 13 | import org.springframework.http.HttpMethod; 14 | 15 | import javax.servlet.http.HttpServletRequest; 16 | 17 | /** 18 | * @Author 徐亮亮 19 | * @Description: 演示环境控制 20 | * @Date 2019/1/18 21:10 21 | */ 22 | @Slf4j 23 | @RefreshScope 24 | @Configuration 25 | @ConditionalOnProperty(value = "security.validate.preview", havingValue = "true") 26 | public class PreviewFilter extends ZuulFilter { 27 | private static final String TOKEN = "token"; 28 | 29 | @Override 30 | public String filterType() { 31 | return FilterConstants.PRE_TYPE; 32 | } 33 | 34 | @Override 35 | public int filterOrder() { 36 | return Integer.MIN_VALUE; 37 | } 38 | 39 | @Override 40 | public boolean shouldFilter() { 41 | HttpServletRequest request = RequestContext.getCurrentContext().getRequest(); 42 | if (StrUtil.equalsIgnoreCase(request.getMethod(), HttpMethod.GET.name()) || 43 | StrUtil.containsIgnoreCase(request.getRequestURI(), TOKEN)){ 44 | return false; 45 | } 46 | return true; 47 | } 48 | 49 | @Override 50 | public Object run() { 51 | RequestContext ctx = RequestContext.getCurrentContext(); 52 | R result = new R<>(); 53 | result.setCode(479); 54 | result.setMsg("演示环境,没有权限操作"); 55 | 56 | ctx.setResponseStatusCode(479); 57 | ctx.setSendZuulResponse(false); 58 | ctx.getResponse().setContentType("application/json;charset=UTF-8"); 59 | ctx.setResponseBody(JSONObject.toJSONString(result)); 60 | return null; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /xll-gateway/src/main/java/com/xll/upms/gateway/component/filter/XssSecurityFilter.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.gateway.component.filter; 2 | 3 | import com.xll.upms.common.bean.xss.XssHttpServletRequestWrapper; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.stereotype.Component; 6 | import org.springframework.web.filter.OncePerRequestFilter; 7 | 8 | import javax.servlet.FilterChain; 9 | import javax.servlet.ServletException; 10 | import javax.servlet.http.HttpServletRequest; 11 | import javax.servlet.http.HttpServletResponse; 12 | import java.io.IOException; 13 | 14 | /** 15 | * @Author 徐亮亮 16 | * @Description: XSS 过滤 17 | * @Date 2019/1/18 21:12 18 | */ 19 | @Slf4j 20 | @Component 21 | public class XssSecurityFilter extends OncePerRequestFilter { 22 | 23 | /** 24 | * Same contract as for {@code doFilter}, but guaranteed to be 25 | * just invoked once per request within a single request thread. 26 | * See {@link #shouldNotFilterAsyncDispatch()} for details. 27 | *

Provides HttpServletRequest and HttpServletResponse arguments instead of the 28 | * default ServletRequest and ServletResponse ones. 29 | * 30 | * @param request 31 | * @param response 32 | * @param filterChain 33 | */ 34 | @Override 35 | protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { 36 | XssHttpServletRequestWrapper xssRequest = new XssHttpServletRequestWrapper(request); 37 | filterChain.doFilter(xssRequest, response); 38 | } 39 | } -------------------------------------------------------------------------------- /xll-gateway/src/main/java/com/xll/upms/gateway/component/handler/MetadataCanaryRuleHandler.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.gateway.component.handler; 2 | 3 | /** 4 | * @author lengleng 5 | * @date 2018/10/19 6 | */ 7 | 8 | import com.xll.upms.common.constant.SecurityConstants; 9 | import com.xll.upms.gateway.util.RibbonVersionHolder; 10 | import com.netflix.loadbalancer.AbstractServerPredicate; 11 | import com.netflix.loadbalancer.PredicateKey; 12 | import com.netflix.loadbalancer.ZoneAvoidanceRule; 13 | import com.netflix.niws.loadbalancer.DiscoveryEnabledServer; 14 | import com.xiaoleilu.hutool.util.StrUtil; 15 | import lombok.extern.slf4j.Slf4j; 16 | 17 | import java.util.Map; 18 | 19 | /** 20 | * @author lengleng 21 | * @date 2018/10/16 22 | *

23 | * 24 | *

25 | * 26 | */ 27 | /** 28 | * @Author 徐亮亮 29 | * @Description: 路由微服务断言 30 | * 1. eureka metadata 存在版本定义时候进行判断 31 | * 2. 不存在 metadata 直接返回true 32 | * @Date 2019/1/18 21:12 33 | */ 34 | @Slf4j 35 | public class MetadataCanaryRuleHandler extends ZoneAvoidanceRule { 36 | 37 | @Override 38 | public AbstractServerPredicate getPredicate() { 39 | return new AbstractServerPredicate() { 40 | @Override 41 | public boolean apply(PredicateKey predicateKey) { 42 | String targetVersion = RibbonVersionHolder.getContext(); 43 | RibbonVersionHolder.clearContext(); 44 | if (StrUtil.isBlank(targetVersion)) { 45 | log.debug("客户端未配置目标版本直接路由"); 46 | return true; 47 | } 48 | 49 | DiscoveryEnabledServer server = (DiscoveryEnabledServer) predicateKey.getServer(); 50 | final Map metadata = server.getInstanceInfo().getMetadata(); 51 | if (StrUtil.isBlank(metadata.get(SecurityConstants.VERSION))) { 52 | log.debug("当前微服务{} 未配置版本直接路由"); 53 | return true; 54 | } 55 | 56 | if (metadata.get(SecurityConstants.VERSION).equals(targetVersion)) { 57 | return true; 58 | } else { 59 | log.debug("当前微服务{} 版本为{},目标版本{} 匹配失败", server.getInstanceInfo().getAppName() 60 | , metadata.get(SecurityConstants.VERSION), targetVersion); 61 | return false; 62 | } 63 | } 64 | }; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /xll-gateway/src/main/java/com/xll/upms/gateway/component/handler/PigAccessDeniedHandler.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.gateway.component.handler; 2 | 3 | import com.fasterxml.jackson.databind.ObjectMapper; 4 | import com.xll.upms.common.constant.CommonConstant; 5 | import com.xll.upms.common.util.R; 6 | import com.xll.upms.common.util.exception.PigDeniedException; 7 | import lombok.extern.slf4j.Slf4j; 8 | import org.apache.http.HttpStatus; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.security.access.AccessDeniedException; 11 | import org.springframework.security.oauth2.provider.error.OAuth2AccessDeniedHandler; 12 | import org.springframework.stereotype.Component; 13 | 14 | import javax.servlet.ServletException; 15 | import javax.servlet.http.HttpServletRequest; 16 | import javax.servlet.http.HttpServletResponse; 17 | import java.io.IOException; 18 | import java.io.PrintWriter; 19 | 20 | /** 21 | * @Author 徐亮亮 22 | * @Description: 授权拒绝处理器,覆盖默认的OAuth2AccessDeniedHandler 23 | * 包装失败信息到PigDeniedException 24 | * @Date 2019/1/18 21:13 25 | */ 26 | @Slf4j 27 | @Component 28 | public class PigAccessDeniedHandler extends OAuth2AccessDeniedHandler { 29 | @Autowired 30 | private ObjectMapper objectMapper; 31 | 32 | /** 33 | * 授权拒绝处理,使用R包装 34 | * 35 | * @param request request 36 | * @param response response 37 | * @param authException authException 38 | * @throws IOException IOException 39 | * @throws ServletException ServletException 40 | */ 41 | @Override 42 | public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException authException) throws IOException, ServletException { 43 | log.info("授权失败,禁止访问 {}", request.getRequestURI()); 44 | response.setCharacterEncoding(CommonConstant.UTF8); 45 | response.setContentType(CommonConstant.CONTENT_TYPE); 46 | R result = new R<>(new PigDeniedException("授权失败,禁止访问")); 47 | response.setStatus(HttpStatus.SC_FORBIDDEN); 48 | PrintWriter printWriter = response.getWriter(); 49 | printWriter.append(objectMapper.writeValueAsString(result)); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /xll-gateway/src/main/java/com/xll/upms/gateway/component/handler/ZuulRateLimiterErrorHandler.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.gateway.component.handler; 2 | 3 | import com.marcosbarbero.cloud.autoconfigure.zuul.ratelimit.config.repository.DefaultRateLimiterErrorHandler; 4 | import com.marcosbarbero.cloud.autoconfigure.zuul.ratelimit.config.repository.RateLimiterErrorHandler; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | 9 | /** 10 | * @Author 徐亮亮 11 | * @Description:限流降级处理 12 | * @Date 2019/1/18 21:13 13 | */ 14 | @Slf4j 15 | @Configuration 16 | public class ZuulRateLimiterErrorHandler { 17 | 18 | @Bean 19 | public RateLimiterErrorHandler rateLimitErrorHandler() { 20 | return new DefaultRateLimiterErrorHandler() { 21 | @Override 22 | public void handleSaveError(String key, Exception e) { 23 | log.error("保存key:[{}]异常", key, e); 24 | } 25 | 26 | @Override 27 | public void handleFetchError(String key, Exception e) { 28 | log.error("路由失败:[{}]异常", key); 29 | } 30 | 31 | @Override 32 | public void handleError(String msg, Exception e) { 33 | log.error("限流异常:[{}]", msg, e); 34 | } 35 | }; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /xll-gateway/src/main/java/com/xll/upms/gateway/component/listener/GroovyLoadInitListener.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.gateway.component.listener; 2 | 3 | import com.netflix.zuul.FilterFileManager; 4 | import com.netflix.zuul.FilterLoader; 5 | import com.netflix.zuul.groovy.GroovyCompiler; 6 | import com.netflix.zuul.groovy.GroovyFileFilter; 7 | import com.netflix.zuul.monitoring.MonitoringHelper; 8 | import lombok.extern.slf4j.Slf4j; 9 | import org.springframework.beans.factory.annotation.Value; 10 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 11 | import org.springframework.boot.context.embedded.EmbeddedServletContainerInitializedEvent; 12 | import org.springframework.context.event.EventListener; 13 | import org.springframework.stereotype.Component; 14 | 15 | /** 16 | * @Author 徐亮亮 17 | * @Description: 动态filter 初始化配置 18 | * @Date 2019/1/18 21:13 19 | */ 20 | @Slf4j 21 | @Component 22 | @ConditionalOnProperty("zuul.groovy.path") 23 | public class GroovyLoadInitListener { 24 | @Value("${zuul.groovy.path}") 25 | private String groovyPath; 26 | 27 | @EventListener(value = {EmbeddedServletContainerInitializedEvent.class}) 28 | public void init() { 29 | MonitoringHelper.initMocks(); 30 | FilterLoader.getInstance().setCompiler(new GroovyCompiler()); 31 | FilterFileManager.setFilenameFilter(new GroovyFileFilter()); 32 | try { 33 | FilterFileManager.init(10, groovyPath); 34 | } catch (Exception e) { 35 | log.error("初始化网关Groovy 文件失败 {}", e); 36 | } 37 | log.warn("初始化网关Groovy 文件成功"); 38 | } 39 | } -------------------------------------------------------------------------------- /xll-gateway/src/main/java/com/xll/upms/gateway/feign/MenuService.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.gateway.feign; 2 | 3 | import com.xll.upms.common.vo.MenuVO; 4 | import com.xll.upms.gateway.feign.fallback.MenuServiceFallbackImpl; 5 | import org.springframework.cloud.netflix.feign.FeignClient; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.PathVariable; 8 | 9 | import java.util.Set; 10 | 11 | /** 12 | * @Author 徐亮亮 13 | * @Description: 调度服务upms接口 14 | * @Date 2019/1/18 21:15 15 | */ 16 | @FeignClient(name = "xll-upms-service", fallback = MenuServiceFallbackImpl.class) 17 | public interface MenuService { 18 | /** 19 | * 通过角色名查询菜单 20 | * 21 | * @param role 角色名称 22 | * @return 菜单列表 23 | */ 24 | @GetMapping(value = "/menu/findMenuByRole/{role}") 25 | Set findMenuByRole(@PathVariable("role") String role); 26 | } 27 | -------------------------------------------------------------------------------- /xll-gateway/src/main/java/com/xll/upms/gateway/feign/fallback/MenuServiceFallbackImpl.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.gateway.feign.fallback; 2 | 3 | import com.xll.upms.common.vo.MenuVO; 4 | import com.xll.upms.gateway.feign.MenuService; 5 | import com.xiaoleilu.hutool.collection.CollUtil; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.Set; 10 | 11 | /** 12 | * @Author 徐亮亮 13 | * @Description: 按钮业务逻辑回调类 14 | * @Date 2019/1/18 21:14 15 | */ 16 | @Slf4j 17 | @Service 18 | public class MenuServiceFallbackImpl implements MenuService { 19 | @Override 20 | public Set findMenuByRole(String role) { 21 | log.error("调用{}异常{}","findMenuByRole",role); 22 | return CollUtil.newHashSet(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /xll-gateway/src/main/java/com/xll/upms/gateway/service/LogSendService.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.gateway.service; 2 | 3 | import com.netflix.zuul.context.RequestContext; 4 | 5 | /** 6 | * @Author 徐亮亮 7 | * @Description: 日志发送业务逻辑 8 | * @Date 2019/1/18 21:17 9 | */ 10 | public interface LogSendService { 11 | /** 12 | * 往消息通道发消息 13 | * 14 | * @param requestContext requestContext 15 | */ 16 | void send(RequestContext requestContext); 17 | } 18 | -------------------------------------------------------------------------------- /xll-gateway/src/main/java/com/xll/upms/gateway/service/PermissionService.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.gateway.service; 2 | 3 | import org.springframework.security.core.Authentication; 4 | 5 | import javax.servlet.http.HttpServletRequest; 6 | 7 | /** 8 | * @Author 徐亮亮 9 | * @Description: 10 | * @Date 2019/1/18 21:18 11 | */ 12 | public interface PermissionService { 13 | /** 14 | * 判断请求是否有权限 15 | * 16 | * @param request HttpServletRequest 17 | * @param authentication 认证信息 18 | * @return 是否有权限 19 | */ 20 | boolean hasPermission(HttpServletRequest request, Authentication authentication); 21 | } 22 | -------------------------------------------------------------------------------- /xll-gateway/src/main/java/com/xll/upms/gateway/util/RibbonVersionHolder.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.gateway.util; 2 | 3 | import com.alibaba.ttl.TransmittableThreadLocal; 4 | 5 | /** 6 | * @Author 徐亮亮 7 | * @Description: 负载均衡处理器 8 | * @Date 2019/1/18 21:19 9 | */ 10 | public class RibbonVersionHolder { 11 | private static final ThreadLocal context = new TransmittableThreadLocal<>(); 12 | 13 | 14 | public static String getContext() { 15 | return context.get(); 16 | } 17 | 18 | public static void setContext(String value) { 19 | context.set(value); 20 | } 21 | 22 | public static void clearContext() { 23 | context.remove(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /xll-gateway/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: pig-gateway 4 | profiles: 5 | active: dev 6 | cloud: 7 | config: 8 | fail-fast: true 9 | discovery: 10 | service-id: pig-config-server 11 | enabled: true 12 | profile: ${spring.profiles.active} 13 | label: master 14 | 15 | logging: 16 | level: error 17 | 18 | --- 19 | spring: 20 | profiles: dev 21 | eureka: 22 | instance: 23 | prefer-ip-address: true 24 | lease-renewal-interval-in-seconds: 5 25 | lease-expiration-duration-in-seconds: 20 26 | client: 27 | serviceUrl: 28 | defaultZone: http://xll:gip6666@localhost:1025/eureka 29 | registry-fetch-interval-seconds: 10 30 | #认证服务器地址 31 | security: 32 | auth: 33 | server: http://localhost:3000 34 | --- 35 | spring: 36 | profiles: prd 37 | eureka: 38 | instance: 39 | prefer-ip-address: true 40 | client: 41 | serviceUrl: 42 | defaultZone: http://xll:gip6666@eureka:1025/eureka 43 | 44 | #建议使用ng负载均衡 45 | security: 46 | auth: 47 | server: http://localhost:3000 48 | -------------------------------------------------------------------------------- /xll-gateway/src/test/java/com/xll/upms/common/util/UserUtilsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018-2025, lengleng All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * Neither the name of the pig4cloud.com developer nor the names of its 13 | * contributors may be used to endorse or promote products derived from 14 | * this software without specific prior written permission. 15 | * Author: lengleng (wangiegie@gmail.com) 16 | */ 17 | 18 | package com.xll.upms.common.util; 19 | 20 | import com.xll.upms.common.constant.CommonConstant; 21 | import org.apache.commons.lang.StringUtils; 22 | import org.junit.Test; 23 | 24 | import java.util.Optional; 25 | 26 | /** 27 | * @author lengleng 28 | * @date 2017/12/22 29 | */ 30 | public class UserUtilsTest { 31 | @Test 32 | public void getToken() throws Exception { 33 | String authorization = null; 34 | System.out.println(StringUtils.substringAfter(authorization, CommonConstant.TOKEN_SPLIT)); 35 | } 36 | 37 | @Test 38 | public void optionalTest() { 39 | Optional optional = Optional.ofNullable(""); 40 | System.out.println(optional.isPresent()); 41 | } 42 | 43 | } -------------------------------------------------------------------------------- /xll-modules/pom.xml: -------------------------------------------------------------------------------- 1 | 17 | 18 | 20 | 21 | xll-upms 22 | com.xll 23 | 1.3.1 24 | 25 | 4.0.0 26 | 27 | com.xll.upms 28 | xll-modules 29 | 1.3.1 30 | pom 31 | 32 | xll-modules 33 | http://maven.apache.org 34 | 35 | 36 | UTF-8 37 | 38 | 39 | 40 | xll-daemon-service 41 | xll-mc-service 42 | xll-sso-client-demo 43 | xll-upms-service 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /xll-modules/xll-daemon-service/src/main/java/com/xll/upms/daemon/UPMSDaemonApplication.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.daemon; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | 7 | /** 8 | * @Author 徐亮亮 9 | * @Description: 分布式任务调度模块 10 | * @Date 2019/1/18 21:22 11 | */ 12 | @EnableDiscoveryClient 13 | @SpringBootApplication 14 | public class UPMSDaemonApplication { 15 | 16 | public static void main(String[] args) { 17 | SpringApplication.run(UPMSDaemonApplication.class, args); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /xll-modules/xll-daemon-service/src/main/java/com/xll/upms/daemon/job/DemoSimpleJob.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.daemon.job; 2 | 3 | import com.dangdang.ddframe.job.api.ShardingContext; 4 | import com.dangdang.ddframe.job.api.simple.SimpleJob; 5 | import com.zen.elasticjob.spring.boot.annotation.ElasticJobConfig; 6 | import lombok.extern.slf4j.Slf4j; 7 | 8 | /** 9 | * @Author 徐亮亮 10 | * @Description: 测试Job 11 | * @Date 2019/1/18 21:20 12 | */ 13 | @Slf4j 14 | @ElasticJobConfig(cron = "0 0 0/1 * * ?", shardingTotalCount = 3, 15 | shardingItemParameters = "0=pig1,1=pig2,2=pig3", 16 | startedTimeoutMilliseconds = 5000L, 17 | completedTimeoutMilliseconds = 10000L, 18 | eventTraceRdbDataSource = "dataSource") 19 | public class DemoSimpleJob implements SimpleJob { 20 | /** 21 | * 业务执行逻辑 22 | * 23 | * @param shardingContext 分片信息 24 | */ 25 | @Override 26 | public void execute(ShardingContext shardingContext) { 27 | log.info("--------------"); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /xll-modules/xll-daemon-service/src/main/java/com/xll/upms/daemon/job/UmpsDataflowJob.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.daemon.job; 2 | 3 | import com.dangdang.ddframe.job.api.ShardingContext; 4 | import com.dangdang.ddframe.job.api.dataflow.DataflowJob; 5 | import com.zen.elasticjob.spring.boot.annotation.ElasticJobConfig; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @Author 徐亮亮 11 | * @Description:数据流任务Job 12 | * @Date 2019/1/18 21:21 13 | */ 14 | @ElasticJobConfig(cron = "0 0 0/1 * * ? ", shardingTotalCount = 3, shardingItemParameters = "0=Beijing,1=Shanghai,2=Guangzhou") 15 | public class UmpsDataflowJob implements DataflowJob { 16 | 17 | 18 | @Override 19 | public List fetchData(ShardingContext shardingContext) { 20 | return null; 21 | } 22 | 23 | @Override 24 | public void processData(ShardingContext shardingContext, List list) { 25 | 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /xll-modules/xll-daemon-service/src/main/java/com/xll/upms/daemon/job/UmpsSimpleJob.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.daemon.job; 2 | 3 | import com.dangdang.ddframe.job.api.ShardingContext; 4 | import com.dangdang.ddframe.job.api.simple.SimpleJob; 5 | import com.zen.elasticjob.spring.boot.annotation.ElasticJobConfig; 6 | import lombok.extern.slf4j.Slf4j; 7 | 8 | /** 9 | * @Author 徐亮亮 10 | * @Description: 简单任务调度 11 | * @Date 2019/1/18 21:21 12 | */ 13 | @Slf4j 14 | @ElasticJobConfig(cron = "0 0 0/1 * * ?", shardingTotalCount = 3, 15 | shardingItemParameters = "0=pig1,1=pig2,2=pig3", 16 | startedTimeoutMilliseconds = 5000L, 17 | completedTimeoutMilliseconds = 10000L, 18 | eventTraceRdbDataSource = "dataSource") 19 | public class UmpsSimpleJob implements SimpleJob { 20 | /** 21 | * 业务执行逻辑 22 | * 23 | * @param shardingContext 分片信息 24 | */ 25 | @Override 26 | public void execute(ShardingContext shardingContext) { 27 | log.info("shardingContext:{}", shardingContext); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /xll-modules/xll-daemon-service/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: pig-daemon-service 4 | profiles: 5 | active: dev 6 | cloud: 7 | config: 8 | fail-fast: true 9 | discovery: 10 | service-id: pig-config-server 11 | enabled: true 12 | profile: ${spring.profiles.active} 13 | label: master 14 | --- 15 | spring: 16 | profiles: dev 17 | eureka: 18 | instance: 19 | prefer-ip-address: true 20 | lease-renewal-interval-in-seconds: 5 21 | lease-expiration-duration-in-seconds: 20 22 | client: 23 | serviceUrl: 24 | defaultZone: http://xll:gip6666@localhost:1025/eureka 25 | registry-fetch-interval-seconds: 10 26 | 27 | --- 28 | spring: 29 | profiles: prd 30 | eureka: 31 | instance: 32 | prefer-ip-address: true 33 | client: 34 | serviceUrl: 35 | defaultZone: http://xll:gip6666@eureka:1025/eureka -------------------------------------------------------------------------------- /xll-modules/xll-mc-service/src/main/java/com/xll/upms/mc/UPMSMessageCenterApplication.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.mc; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | 7 | /** 8 | * @Author 徐亮亮 9 | * @Description: 消息中心 10 | * @Date 2019/1/18 21:25 11 | */ 12 | @EnableDiscoveryClient 13 | @SpringBootApplication 14 | public class UPMSMessageCenterApplication { 15 | 16 | public static void main(String[] args) { 17 | SpringApplication.run(UPMSMessageCenterApplication.class, args); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /xll-modules/xll-mc-service/src/main/java/com/xll/upms/mc/config/DingTalkPropertiesConfig.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.mc.config; 2 | 3 | import lombok.Data; 4 | import org.springframework.boot.context.properties.ConfigurationProperties; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | /** 8 | * @Author 徐亮亮 9 | * @Description: 钉钉服务配置 10 | * @Date 2019/1/18 21:22 11 | */ 12 | @Data 13 | @Configuration 14 | @ConfigurationProperties(prefix = "sms.dingtalk") 15 | public class DingTalkPropertiesConfig { 16 | /** 17 | * webhook 18 | */ 19 | private String webhook; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /xll-modules/xll-mc-service/src/main/java/com/xll/upms/mc/config/SmsAliyunPropertiesConfig.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.mc.config; 2 | 3 | import lombok.Data; 4 | import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; 5 | import org.springframework.boot.context.properties.ConfigurationProperties; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | import java.util.Map; 9 | 10 | /** 11 | * @Author 徐亮亮 12 | * @Description: 阿里大鱼短息服务配置 13 | * @Date 2019/1/18 21:23 14 | */ 15 | @Data 16 | @Configuration 17 | @ConditionalOnExpression("!'${sms.aliyun}'.isEmpty()") 18 | @ConfigurationProperties(prefix = "sms.aliyun") 19 | public class SmsAliyunPropertiesConfig { 20 | /** 21 | * 应用ID 22 | */ 23 | private String accessKey; 24 | 25 | /** 26 | * 应用秘钥 27 | */ 28 | private String secretKey; 29 | 30 | /** 31 | * 短信模板配置 32 | */ 33 | private Map channels; 34 | } 35 | -------------------------------------------------------------------------------- /xll-modules/xll-mc-service/src/main/java/com/xll/upms/mc/handler/AbstractMessageHandler.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.mc.handler; 2 | 3 | import com.xll.upms.common.util.template.MobileMsgTemplate; 4 | 5 | /** 6 | * @Author 徐亮亮 7 | * @Description: 抽象消息处理器 8 | * @Date 2019/1/18 21:23 9 | */ 10 | public abstract class AbstractMessageHandler implements SmsMessageHandler { 11 | 12 | /** 13 | * 执行入口 14 | * 15 | * @param mobileMsgTemplate 信息 16 | */ 17 | @Override 18 | public void execute(MobileMsgTemplate mobileMsgTemplate) { 19 | check(mobileMsgTemplate); 20 | if (!process(mobileMsgTemplate)) { 21 | fail(mobileMsgTemplate); 22 | } 23 | } 24 | 25 | /** 26 | * 数据校验 27 | * 28 | * @param mobileMsgTemplate 信息 29 | */ 30 | @Override 31 | public abstract void check(MobileMsgTemplate mobileMsgTemplate); 32 | 33 | /** 34 | * 业务处理 35 | * 36 | * @param mobileMsgTemplate 信息 37 | * @return boolean 38 | */ 39 | @Override 40 | public abstract boolean process(MobileMsgTemplate mobileMsgTemplate); 41 | 42 | /** 43 | * 失败处理 44 | * 45 | * @param mobileMsgTemplate 信息 46 | */ 47 | @Override 48 | public abstract void fail(MobileMsgTemplate mobileMsgTemplate); 49 | } 50 | -------------------------------------------------------------------------------- /xll-modules/xll-mc-service/src/main/java/com/xll/upms/mc/handler/DingTalkMessageHandler.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.mc.handler; 2 | 3 | import com.alibaba.fastjson.JSONObject; 4 | import com.xll.upms.common.util.template.DingTalkMsgTemplate; 5 | import com.xll.upms.mc.config.DingTalkPropertiesConfig; 6 | import com.xiaoleilu.hutool.http.HttpUtil; 7 | import com.xiaoleilu.hutool.util.StrUtil; 8 | import lombok.extern.slf4j.Slf4j; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Component; 11 | 12 | /** 13 | * @Author 徐亮亮 14 | * @Description: 发送钉钉消息逻辑 15 | * @Date 2019/1/18 21:24 16 | */ 17 | @Slf4j 18 | @Component 19 | public class DingTalkMessageHandler { 20 | @Autowired 21 | private DingTalkPropertiesConfig dingTalkPropertiesConfig; 22 | 23 | /** 24 | * 业务处理 25 | * 26 | * @param text 消息 27 | */ 28 | public boolean process(String text) { 29 | String webhook = dingTalkPropertiesConfig.getWebhook(); 30 | if (StrUtil.isBlank(webhook)) { 31 | log.error("钉钉配置错误,webhook为空"); 32 | return false; 33 | } 34 | 35 | DingTalkMsgTemplate dingTalkMsgTemplate = new DingTalkMsgTemplate(); 36 | dingTalkMsgTemplate.setMsgtype("text"); 37 | DingTalkMsgTemplate.TextBean textBean = new DingTalkMsgTemplate.TextBean(); 38 | textBean.setContent(text); 39 | dingTalkMsgTemplate.setText(textBean); 40 | String result = HttpUtil.post(webhook, JSONObject.toJSONString(dingTalkMsgTemplate)); 41 | log.info("钉钉提醒成功,报文响应:{}", result); 42 | return true; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /xll-modules/xll-mc-service/src/main/java/com/xll/upms/mc/handler/SmsMessageHandler.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.mc.handler; 2 | 3 | import com.xll.upms.common.util.template.MobileMsgTemplate; 4 | 5 | /** 6 | * @Author 徐亮亮 7 | * @Description: 消息处理器 8 | * @Date 2019/1/18 21:24 9 | */ 10 | public interface SmsMessageHandler { 11 | /** 12 | * 执行入口 13 | * 14 | * @param mobileMsgTemplate 信息 15 | */ 16 | void execute(MobileMsgTemplate mobileMsgTemplate); 17 | 18 | /** 19 | * 数据校验 20 | * 21 | * @param mobileMsgTemplate 信息 22 | */ 23 | void check(MobileMsgTemplate mobileMsgTemplate); 24 | 25 | /** 26 | * 业务处理 27 | * 28 | * @param mobileMsgTemplate 信息 29 | * @return boolean 30 | */ 31 | boolean process(MobileMsgTemplate mobileMsgTemplate); 32 | 33 | /** 34 | * 失败处理 35 | * 36 | * @param mobileMsgTemplate 信息 37 | */ 38 | void fail(MobileMsgTemplate mobileMsgTemplate); 39 | } 40 | -------------------------------------------------------------------------------- /xll-modules/xll-mc-service/src/main/java/com/xll/upms/mc/listener/DingTalkServiceChangeReceiveListener.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.mc.listener; 2 | 3 | import com.xll.upms.common.constant.MqQueueConstant; 4 | import com.xll.upms.mc.handler.DingTalkMessageHandler; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.amqp.rabbit.annotation.RabbitHandler; 7 | import org.springframework.amqp.rabbit.annotation.RabbitListener; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Component; 10 | 11 | /** 12 | * @Author 徐亮亮 13 | * @Description: 监听服务状态改变发送请求 14 | * @Date 2019/1/18 21:25 15 | */ 16 | @Slf4j 17 | @Component 18 | @RabbitListener(queues = MqQueueConstant.DINGTALK_SERVICE_STATUS_CHANGE) 19 | public class DingTalkServiceChangeReceiveListener { 20 | @Autowired 21 | private DingTalkMessageHandler dingTalkMessageHandler; 22 | 23 | @RabbitHandler 24 | public void receive(String text) { 25 | long startTime = System.currentTimeMillis(); 26 | log.info("消息中心接收到钉钉发送请求-> 内容:{} ", text); 27 | dingTalkMessageHandler.process(text); 28 | long useTime = System.currentTimeMillis() - startTime; 29 | log.info("调用 钉钉网关处理完毕,耗时 {}毫秒", useTime); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /xll-modules/xll-mc-service/src/main/java/com/xll/upms/mc/listener/MobileCodeReceiveListener.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.mc.listener; 2 | 3 | import com.xll.upms.common.constant.MqQueueConstant; 4 | import com.xll.upms.common.util.template.MobileMsgTemplate; 5 | import com.xll.upms.mc.handler.SmsMessageHandler; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.springframework.amqp.rabbit.annotation.RabbitHandler; 8 | import org.springframework.amqp.rabbit.annotation.RabbitListener; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Component; 11 | 12 | import java.util.Map; 13 | 14 | /** 15 | * @Author 徐亮亮 16 | * @Description: 监听短信发送请求 17 | * @Date 2019/1/18 21:25 18 | */ 19 | @Slf4j 20 | @Component 21 | @RabbitListener(queues = MqQueueConstant.MOBILE_CODE_QUEUE) 22 | public class MobileCodeReceiveListener { 23 | @Autowired 24 | private Map messageHandlerMap; 25 | 26 | @RabbitHandler 27 | public void receive(MobileMsgTemplate mobileMsgTemplate) { 28 | long startTime = System.currentTimeMillis(); 29 | log.info("消息中心接收到短信发送请求-> 手机号:{} -> 验证码: {} ", mobileMsgTemplate.getMobile(), mobileMsgTemplate.getContext()); 30 | String channel = mobileMsgTemplate.getChannel(); 31 | SmsMessageHandler messageHandler = messageHandlerMap.get(channel); 32 | if (messageHandler == null) { 33 | log.error("没有找到指定的路由通道,不进行发送处理完毕!"); 34 | return; 35 | } 36 | 37 | messageHandler.execute(mobileMsgTemplate); 38 | long useTime = System.currentTimeMillis() - startTime; 39 | log.info("调用 {} 短信网关处理完毕,耗时 {}毫秒", channel, useTime); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /xll-modules/xll-mc-service/src/main/java/com/xll/upms/mc/listener/MobileServiceChangeReceiveListener.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.mc.listener; 2 | 3 | import com.xll.upms.common.constant.MqQueueConstant; 4 | import com.xll.upms.common.util.template.MobileMsgTemplate; 5 | import com.xll.upms.mc.handler.SmsMessageHandler; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.springframework.amqp.rabbit.annotation.RabbitHandler; 8 | import org.springframework.amqp.rabbit.annotation.RabbitListener; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Component; 11 | 12 | import java.util.Map; 13 | 14 | /** 15 | * @Author 徐亮亮 16 | * @Description: 监听服务状态改变发送请求 17 | * @Date 2019/1/18 21:25 18 | */ 19 | @Slf4j 20 | @Component 21 | @RabbitListener(queues = MqQueueConstant.MOBILE_SERVICE_STATUS_CHANGE) 22 | public class MobileServiceChangeReceiveListener { 23 | @Autowired 24 | private Map messageHandlerMap; 25 | 26 | 27 | @RabbitHandler 28 | public void receive(MobileMsgTemplate mobileMsgTemplate) { 29 | long startTime = System.currentTimeMillis(); 30 | log.info("消息中心接收到短信发送请求-> 手机号:{} -> 信息体:{} ", mobileMsgTemplate.getMobile(), mobileMsgTemplate.getContext()); 31 | String channel = mobileMsgTemplate.getChannel(); 32 | SmsMessageHandler messageHandler = messageHandlerMap.get(channel); 33 | if (messageHandler == null) { 34 | log.error("没有找到指定的路由通道,不进行发送处理完毕!"); 35 | return; 36 | } 37 | 38 | messageHandler.execute(mobileMsgTemplate); 39 | long useTime = System.currentTimeMillis() - startTime; 40 | log.info("调用 {} 短信网关处理完毕,耗时 {}毫秒", mobileMsgTemplate.getType(), useTime); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /xll-modules/xll-mc-service/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: pig-mc-service 4 | profiles: 5 | active: dev 6 | cloud: 7 | config: 8 | fail-fast: true 9 | discovery: 10 | service-id: pig-config-server 11 | enabled: true 12 | profile: ${spring.profiles.active} 13 | label: master 14 | --- 15 | spring: 16 | profiles: dev 17 | eureka: 18 | instance: 19 | prefer-ip-address: true 20 | lease-renewal-interval-in-seconds: 5 21 | lease-expiration-duration-in-seconds: 20 22 | client: 23 | serviceUrl: 24 | defaultZone: http://xll:gip6666@localhost:1025/eureka 25 | registry-fetch-interval-seconds: 10 26 | 27 | --- 28 | spring: 29 | profiles: prd 30 | eureka: 31 | instance: 32 | prefer-ip-address: true 33 | client: 34 | serviceUrl: 35 | defaultZone: http://xll:gip6666@eureka:1025/eureka -------------------------------------------------------------------------------- /xll-modules/xll-sso-client-demo/src/main/java/com/xll/upms/sso/UPMSSsoClientDemoApplication.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.sso; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.autoconfigure.security.oauth2.client.EnableOAuth2Sso; 6 | 7 | /** 8 | * @Author 徐亮亮 9 | * @Description: 单点登录客户端 10 | * @Date 2019/1/18 21:27 11 | */ 12 | @EnableOAuth2Sso 13 | @SpringBootApplication 14 | public class UPMSSsoClientDemoApplication { 15 | 16 | public static void main(String[] args) { 17 | SpringApplication.run(UPMSSsoClientDemoApplication.class, args); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /xll-modules/xll-sso-client-demo/src/main/java/com/xll/upms/sso/config/ResourceServerConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.sso.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 5 | import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer; 6 | import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter; 7 | 8 | /** 9 | * @Author 徐亮亮 10 | * @Description: 当前配置 暴露监控信息 11 | * @Date 2019/1/18 21:26 12 | */ 13 | @Configuration 14 | @EnableResourceServer 15 | public class ResourceServerConfiguration extends ResourceServerConfigurerAdapter { 16 | 17 | @Override 18 | public void configure(HttpSecurity http) throws Exception { 19 | http 20 | .authorizeRequests() 21 | .anyRequest().authenticated() 22 | .and() 23 | .csrf().disable(); 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /xll-modules/xll-sso-client-demo/src/main/java/com/xll/upms/sso/controller/DemoController.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.sso.controller; 2 | 3 | import org.springframework.security.core.Authentication; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | /** 8 | * @Author 徐亮亮 9 | * @Description: 测试 10 | * @Date 2019/1/18 21:26 11 | */ 12 | @RestController 13 | public class DemoController { 14 | @GetMapping("/") 15 | public Authentication user(Authentication authentication) { 16 | return authentication; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /xll-modules/xll-sso-client-demo/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 4040 3 | context-path: /sso1 4 | 5 | #监控短点配置 6 | management: 7 | security: 8 | enabled: false 9 | endpoints: 10 | actuator: 11 | enabled: true 12 | shutdown: 13 | enabled: false 14 | 15 | security: 16 | oauth2: 17 | client: 18 | client-id: pig 19 | client-secret: pig 20 | user-authorization-uri: http://localhost:3000/oauth/authorize 21 | access-token-uri: http://localhost:3000/oauth/token 22 | scope: server 23 | resource: 24 | jwt: 25 | key-uri: http://localhost:3000/oauth/token_key 26 | 27 | spring: 28 | application: 29 | name: pig-sso-client-demo 30 | profiles: 31 | active: dev 32 | --- 33 | spring: 34 | profiles: dev 35 | eureka: 36 | instance: 37 | prefer-ip-address: true 38 | lease-renewal-interval-in-seconds: 5 39 | lease-expiration-duration-in-seconds: 20 40 | client: 41 | serviceUrl: 42 | defaultZone: http://xll:gip6666@localhost:1025/eureka 43 | 44 | --- 45 | spring: 46 | profiles: prd 47 | eureka: 48 | instance: 49 | prefer-ip-address: true 50 | client: 51 | serviceUrl: 52 | defaultZone: http://xll:gip6666@eureka:1025/eureka 53 | -------------------------------------------------------------------------------- /xll-modules/xll-sso-client-demo/src/main/resources/static/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Title 6 | 7 | 8 | 获取登录信息 9 | 10 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/UPMSAdminApplication.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import org.springframework.context.annotation.ComponentScan; 7 | import org.springframework.scheduling.annotation.EnableAsync; 8 | 9 | /** 10 | * @Author 徐亮亮 11 | * @Description: UPMS用户授权管理系统服务 12 | * @Date 2019/1/18 21:59 13 | */ 14 | 15 | @EnableAsync 16 | @SpringBootApplication 17 | @EnableDiscoveryClient 18 | @ComponentScan(basePackages = {"com.xll.upms.admin", "com.xll.upms.common.bean"}) 19 | //@ComponentScan(basePackages = {"com.xll.upms"}) 20 | public class UPMSAdminApplication { 21 | public static void main(String[] args) { 22 | SpringApplication.run(UPMSAdminApplication.class, args); 23 | } 24 | } -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/common/config/KaptchaConfig.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.common.config; 2 | 3 | import com.xll.upms.common.constant.SecurityConstants; 4 | import com.google.code.kaptcha.impl.DefaultKaptcha; 5 | import com.google.code.kaptcha.util.Config; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | 9 | import java.util.Properties; 10 | 11 | @Configuration 12 | public class KaptchaConfig { 13 | 14 | private static final String KAPTCHA_BORDER = "kaptcha.border"; 15 | private static final String KAPTCHA_TEXTPRODUCER_FONT_COLOR = "kaptcha.textproducer.font.color"; 16 | private static final String KAPTCHA_TEXTPRODUCER_CHAR_SPACE = "kaptcha.textproducer.char.space"; 17 | private static final String KAPTCHA_IMAGE_WIDTH = "kaptcha.image.width"; 18 | private static final String KAPTCHA_IMAGE_HEIGHT = "kaptcha.image.height"; 19 | private static final String KAPTCHA_TEXTPRODUCER_CHAR_LENGTH = "kaptcha.textproducer.char.length"; 20 | private static final Object KAPTCHA_IMAGE_FONT_SIZE = "kaptcha.textproducer.font.size"; 21 | 22 | @Bean 23 | public DefaultKaptcha producer() { 24 | Properties properties = new Properties(); 25 | properties.put(KAPTCHA_BORDER, SecurityConstants.DEFAULT_IMAGE_BORDER); 26 | properties.put(KAPTCHA_TEXTPRODUCER_FONT_COLOR, SecurityConstants.DEFAULT_COLOR_FONT); 27 | properties.put(KAPTCHA_TEXTPRODUCER_CHAR_SPACE, SecurityConstants.DEFAULT_CHAR_SPACE); 28 | properties.put(KAPTCHA_IMAGE_WIDTH, SecurityConstants.DEFAULT_IMAGE_WIDTH); 29 | properties.put(KAPTCHA_IMAGE_HEIGHT, SecurityConstants.DEFAULT_IMAGE_HEIGHT); 30 | properties.put(KAPTCHA_IMAGE_FONT_SIZE, SecurityConstants.DEFAULT_IMAGE_FONT_SIZE); 31 | properties.put(KAPTCHA_TEXTPRODUCER_CHAR_LENGTH, SecurityConstants.DEFAULT_IMAGE_LENGTH); 32 | Config config = new Config(properties); 33 | DefaultKaptcha defaultKaptcha = new DefaultKaptcha(); 34 | defaultKaptcha.setConfig(config); 35 | return defaultKaptcha; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/common/config/MybatisPlusConfig.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.common.config; 2 | 3 | import com.baomidou.mybatisplus.plugins.PaginationInterceptor; 4 | import com.xll.upms.common.bean.interceptor.DataScopeInterceptor; 5 | import org.mybatis.spring.annotation.MapperScan; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | 9 | /** 10 | * @Author 徐亮亮 11 | * @Description:Mapper映射文件配置类 12 | * @Date 2019/1/18 21:30 13 | */ 14 | @Configuration 15 | @MapperScan("com.xll.upms.admin.mapper") 16 | public class MybatisPlusConfig { 17 | /** 18 | * 分页插件 19 | * 20 | * @return PaginationInterceptor 21 | */ 22 | @Bean 23 | public PaginationInterceptor paginationInterceptor() { 24 | return new PaginationInterceptor(); 25 | } 26 | 27 | /** 28 | * 数据权限插件 29 | * 30 | * @return DataScopeInterceptor 31 | */ 32 | @Bean 33 | public DataScopeInterceptor dataScopeInterceptor() { 34 | return new DataScopeInterceptor(); 35 | } 36 | } -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/common/config/RabbitConfig.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.common.config; 2 | 3 | import com.xll.upms.common.constant.MqQueueConstant; 4 | import org.springframework.amqp.core.Queue; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | /** 9 | * @Author 徐亮亮 10 | * @Description: rabbit初始化配置 11 | * @Date 2019/1/18 21:30 12 | */ 13 | @Configuration 14 | public class RabbitConfig { 15 | /** 16 | * 初始化 log队列 17 | * 18 | * @return 19 | */ 20 | @Bean 21 | public Queue initLogQueue() { 22 | return new Queue(MqQueueConstant.LOG_QUEUE); 23 | } 24 | 25 | /** 26 | * 初始化 手机验证码通道 27 | * 28 | * @return 29 | */ 30 | @Bean 31 | public Queue initMobileCodeQueue() { 32 | return new Queue(MqQueueConstant.MOBILE_CODE_QUEUE); 33 | } 34 | 35 | /** 36 | * 初始化服务状态改变队列 37 | * 38 | * @return 39 | */ 40 | @Bean 41 | public Queue initMobileServiceStatusChangeQueue() { 42 | return new Queue(MqQueueConstant.MOBILE_SERVICE_STATUS_CHANGE); 43 | } 44 | 45 | /** 46 | * 初始化钉钉状态改变队列 47 | * 48 | * @return 49 | */ 50 | @Bean 51 | public Queue initDingTalkServiceStatusChangeQueue() { 52 | return new Queue(MqQueueConstant.DINGTALK_SERVICE_STATUS_CHANGE); 53 | } 54 | 55 | /** 56 | * 初始化zipkin队列 57 | * 58 | * @return 59 | */ 60 | @Bean 61 | public Queue initZipkinQueue() { 62 | return new Queue(MqQueueConstant.ZIPKIN_NAME_QUEUE); 63 | } 64 | 65 | /** 66 | * 初始化路由配置状态队列 67 | * 68 | * @return 69 | */ 70 | @Bean 71 | public Queue initRouteConfigChangeQueue() { 72 | return new Queue(MqQueueConstant.ROUTE_CONFIG_CHANGE); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/common/listener/LogReceiveListener.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.common.listener; 2 | 3 | import com.xll.upms.admin.service.SysLogService; 4 | import com.xll.upms.common.constant.MqQueueConstant; 5 | import com.xll.upms.common.entity.SysLog; 6 | import com.xll.upms.common.vo.LogVO; 7 | import org.slf4j.MDC; 8 | import org.springframework.amqp.rabbit.annotation.RabbitHandler; 9 | import org.springframework.amqp.rabbit.annotation.RabbitListener; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.beans.factory.annotation.Qualifier; 12 | import org.springframework.stereotype.Component; 13 | import org.springframework.stereotype.Service; 14 | 15 | /** 16 | * @Author 徐亮亮 17 | * @Description: 日志接收监听器 18 | * @Date 2019/1/18 21:31 19 | */ 20 | @Component 21 | //@Service 22 | @RabbitListener(queues = MqQueueConstant.LOG_QUEUE) 23 | public class LogReceiveListener { 24 | private static final String KEY_USER = "user"; 25 | 26 | @Autowired 27 | private SysLogService sysLogService; 28 | 29 | @RabbitHandler 30 | public void receive(LogVO logVo) { 31 | SysLog sysLog = logVo.getSysLog(); 32 | MDC.put(KEY_USER, logVo.getUsername()); 33 | sysLog.setCreateBy(logVo.getUsername()); 34 | sysLogService.insert(sysLog); 35 | MDC.remove(KEY_USER); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/controller/DeptController.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.controller; 2 | 3 | import com.baomidou.mybatisplus.mapper.EntityWrapper; 4 | import com.xll.upms.admin.model.dto.DeptTree; 5 | import com.xll.upms.admin.model.entity.SysDept; 6 | import com.xll.upms.admin.service.SysDeptService; 7 | import com.xll.upms.common.constant.CommonConstant; 8 | import com.xll.upms.common.web.BaseController; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.web.bind.annotation.*; 11 | 12 | import java.util.Date; 13 | import java.util.List; 14 | 15 | /** 16 | * @Author 徐亮亮 17 | * @Description: 部门管理 前端控制器 18 | * @Date 2019/1/18 21:34 19 | */ 20 | @RestController 21 | @RequestMapping("/dept") 22 | public class DeptController extends BaseController { 23 | @Autowired 24 | private SysDeptService sysDeptService; 25 | 26 | /** 27 | * 通过ID查询 28 | * 29 | * @param id ID 30 | * @return SysDept 31 | */ 32 | @GetMapping("/{id}") 33 | public SysDept get(@PathVariable Integer id) { 34 | return sysDeptService.selectById(id); 35 | } 36 | 37 | 38 | /** 39 | * 返回树形菜单集合 40 | * 41 | * @return 树形菜单 42 | */ 43 | @GetMapping(value = "/tree") 44 | public List getTree() { 45 | SysDept condition = new SysDept(); 46 | condition.setDelFlag(CommonConstant.STATUS_NORMAL); 47 | return sysDeptService.selectListTree(new EntityWrapper<>(condition)); 48 | } 49 | 50 | /** 51 | * 添加 52 | * 53 | * @param sysDept 实体 54 | * @return success/false 55 | */ 56 | @PostMapping 57 | public Boolean add(@RequestBody SysDept sysDept) { 58 | return sysDeptService.insertDept(sysDept); 59 | } 60 | 61 | /** 62 | * 删除 63 | * 64 | * @param id ID 65 | * @return success/false 66 | */ 67 | @DeleteMapping("/{id}") 68 | public Boolean delete(@PathVariable Integer id) { 69 | return sysDeptService.deleteDeptById(id); 70 | } 71 | 72 | /** 73 | * 编辑 74 | * 75 | * @param sysDept 实体 76 | * @return success/false 77 | */ 78 | @PutMapping 79 | public Boolean edit(@RequestBody SysDept sysDept) { 80 | sysDept.setUpdateTime(new Date()); 81 | return sysDeptService.updateDeptById(sysDept); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/controller/LogController.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.controller; 2 | 3 | 4 | import com.baomidou.mybatisplus.mapper.EntityWrapper; 5 | import com.baomidou.mybatisplus.plugins.Page; 6 | import com.xll.upms.admin.service.SysLogService; 7 | import com.xll.upms.common.constant.CommonConstant; 8 | import com.xll.upms.common.util.Query; 9 | import com.xll.upms.common.util.R; 10 | import com.xll.upms.common.web.BaseController; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.web.bind.annotation.*; 13 | 14 | import java.util.Map; 15 | 16 | /** 17 | * @Author 徐亮亮 18 | * @Description: 日志表 前端控制器 19 | * @Date 2019/1/18 21:35 20 | */ 21 | @RestController 22 | @RequestMapping("/log") 23 | public class LogController extends BaseController { 24 | @Autowired 25 | private SysLogService sysLogService; 26 | 27 | /** 28 | * 分页查询日志信息 29 | * 30 | * @param params 分页对象 31 | * @return 分页对象 32 | */ 33 | @RequestMapping("/logPage") 34 | public Page logPage(@RequestParam Map params) { 35 | params.put(CommonConstant.DEL_FLAG, CommonConstant.STATUS_NORMAL); 36 | return sysLogService.selectPage(new Query<>(params), new EntityWrapper<>()); 37 | } 38 | 39 | /** 40 | * 根据ID 41 | * 42 | * @param id ID 43 | * @return success/false 44 | */ 45 | @DeleteMapping("/{id}") 46 | public R delete(@PathVariable Long id) { 47 | return new R<>(sysLogService.updateByLogId(id)); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/mapper/SysDeptMapper.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.mapper; 2 | 3 | import com.baomidou.mybatisplus.mapper.BaseMapper; 4 | import com.xll.upms.admin.model.entity.SysDept; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @Author 徐亮亮 11 | * @Description: 部门管理 Mapper 接口 12 | * @Date 2019/1/18 21:38 13 | */ 14 | @Mapper 15 | public interface SysDeptMapper extends BaseMapper { 16 | 17 | /** 18 | * 关联dept——relation 19 | * 20 | * @param delFlag 删除标记 21 | * @return 数据列表 22 | */ 23 | List selectDeptDtoList(String delFlag); 24 | } -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/mapper/SysDeptRelationMapper.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.mapper; 2 | 3 | import com.baomidou.mybatisplus.mapper.BaseMapper; 4 | import com.xll.upms.admin.model.entity.SysDeptRelation; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * @Author 徐亮亮 9 | * @Description: 部门关系 Mapper 10 | * @Date 2019/1/18 21:39 11 | */ 12 | @Mapper 13 | public interface SysDeptRelationMapper extends BaseMapper { 14 | /** 15 | * 删除部门关系表数据 16 | * 17 | * @param id 部门ID 18 | */ 19 | void deleteAllDeptRealtion(Integer id); 20 | 21 | /** 22 | * 更改部分关系表数据 23 | * 24 | * @param deptRelation 25 | */ 26 | void updateDeptRealtion(SysDeptRelation deptRelation); 27 | } -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/mapper/SysDictMapper.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.mapper; 2 | 3 | import com.baomidou.mybatisplus.mapper.BaseMapper; 4 | import com.xll.upms.admin.model.entity.SysDict; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * @Author 徐亮亮 9 | * @Description: 字典表 Mapper 接口 10 | * @Date 2019/1/18 21:40 11 | */ 12 | @Mapper 13 | public interface SysDictMapper extends BaseMapper { 14 | 15 | } -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/mapper/SysLogMapper.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.mapper; 2 | 3 | import com.baomidou.mybatisplus.mapper.BaseMapper; 4 | import com.xll.upms.common.entity.SysLog; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * @Author 徐亮亮 9 | * @Description: 日志表 Mapper 接口 10 | * @Date 2019/1/18 21:40 11 | */ 12 | @Mapper 13 | public interface SysLogMapper extends BaseMapper { 14 | 15 | } -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/mapper/SysMenuMapper.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.mapper; 2 | 3 | import com.baomidou.mybatisplus.mapper.BaseMapper; 4 | import com.xll.upms.admin.model.entity.SysMenu; 5 | import com.xll.upms.common.vo.MenuVO; 6 | import org.apache.ibatis.annotations.Mapper; 7 | import org.apache.ibatis.annotations.Param; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @Author 徐亮亮 13 | * @Description: 菜单权限表 Mapper 接口 14 | * @Date 2019/1/18 21:40 15 | */ 16 | @Mapper 17 | public interface SysMenuMapper extends BaseMapper { 18 | 19 | /** 20 | * 通过角色名查询菜单 21 | * 22 | * @param role 角色名称 23 | * @return 菜单列表 24 | */ 25 | List findMenuByRoleName(@Param("role") String role); 26 | } -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/mapper/SysOauthClientDetailsMapper.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.mapper; 2 | 3 | 4 | import com.baomidou.mybatisplus.mapper.BaseMapper; 5 | import com.xll.upms.admin.model.entity.SysOauthClientDetails; 6 | import org.apache.ibatis.annotations.Mapper; 7 | 8 | /** 9 | * @Author 徐亮亮 10 | * @Description: 客户认证详情信息Mapper 11 | * @Date 2019/1/18 21:40 12 | */ 13 | @Mapper 14 | public interface SysOauthClientDetailsMapper extends BaseMapper { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/mapper/SysRoleDeptMapper.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.mapper; 2 | 3 | import com.baomidou.mybatisplus.mapper.BaseMapper; 4 | import com.xll.upms.admin.model.entity.SysRoleDept; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * @Author 徐亮亮 9 | * @Description: 角色与部门对应关系 Mapper 接口 10 | * @Date 2019/1/18 21:42 11 | */ 12 | @Mapper 13 | public interface SysRoleDeptMapper extends BaseMapper { 14 | 15 | } -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/mapper/SysRoleMapper.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.mapper; 2 | 3 | import com.baomidou.mybatisplus.mapper.BaseMapper; 4 | import com.xll.upms.admin.model.entity.SysRole; 5 | import com.xll.upms.common.util.Query; 6 | import org.apache.ibatis.annotations.Mapper; 7 | 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | /** 12 | * @Author 徐亮亮 13 | * @Description: 角色Mapper 14 | * @Date 2019/1/18 21:42 15 | */ 16 | @Mapper 17 | public interface SysRoleMapper extends BaseMapper { 18 | 19 | /** 20 | * 查询角色列表含有部门信息 21 | * @param query 查询对象 22 | * @param condition 条件 23 | * @return List 24 | */ 25 | List selectRolePage(Query query, Map condition); 26 | 27 | /** 28 | * 通过部门ID查询角色列表 29 | * 30 | * @param deptId 部门ID 31 | * @return 角色列表 32 | */ 33 | List selectListByDeptId(Integer deptId); 34 | } -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/mapper/SysRoleMenuMapper.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.mapper; 2 | 3 | 4 | import com.baomidou.mybatisplus.mapper.BaseMapper; 5 | import com.xll.upms.admin.model.entity.SysRoleMenu; 6 | import org.apache.ibatis.annotations.Mapper; 7 | 8 | /** 9 | * @Author 徐亮亮 10 | * @Description: 角色菜单表 Mapper 接口 11 | * @Date 2019/1/18 21:43 12 | */ 13 | @Mapper 14 | public interface SysRoleMenuMapper extends BaseMapper { 15 | 16 | } -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/mapper/SysUserMapper.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.mapper; 2 | 3 | import com.baomidou.mybatisplus.mapper.BaseMapper; 4 | import com.xll.upms.admin.model.entity.SysUser; 5 | import com.xll.upms.common.bean.interceptor.DataScope; 6 | import com.xll.upms.common.util.Query; 7 | import com.xll.upms.common.vo.UserVO; 8 | import org.apache.ibatis.annotations.Mapper; 9 | import org.apache.ibatis.annotations.Param; 10 | 11 | import java.util.List; 12 | 13 | /** 14 | * @Author 徐亮亮 15 | * @Description: 用户表 Mapper 接口 16 | * @Date 2019/1/18 21:43 17 | */ 18 | @Mapper 19 | public interface SysUserMapper extends BaseMapper { 20 | /** 21 | * 通过用户名查询用户信息(含有角色信息) 22 | * 23 | * @param username 用户名 24 | * @return userVo 25 | */ 26 | UserVO selectUserVoByUsername(String username); 27 | 28 | /** 29 | * 分页查询用户信息(含角色) 30 | * 31 | * @param query 查询条件 32 | * @param username 用户名 33 | * @param dataScope 数据权限 34 | * @return list 35 | */ 36 | List selectUserVoPageDataScope(Query query, @Param("username") Object username, DataScope dataScope); 37 | 38 | /** 39 | * 通过手机号查询用户信息(含有角色信息) 40 | * 41 | * @param mobile 用户名 42 | * @return userVo 43 | */ 44 | UserVO selectUserVoByMobile(String mobile); 45 | 46 | /** 47 | * 通过openId查询用户信息 48 | * 49 | * @param openId openid 50 | * @return userVo 51 | */ 52 | UserVO selectUserVoByOpenId(String openId); 53 | 54 | /** 55 | * 通过ID查询用户信息 56 | * 57 | * @param id 用户ID 58 | * @return userVo 59 | */ 60 | UserVO selectUserVoById(Integer id); 61 | } -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/mapper/SysUserRoleMapper.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.mapper; 2 | 3 | import com.baomidou.mybatisplus.mapper.BaseMapper; 4 | import com.xll.upms.admin.model.entity.SysUserRole; 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | /** 9 | * @Author 徐亮亮 10 | * @Description: 用户角色表 Mapper 接口 11 | * @Date 2019/1/18 21:43 12 | */ 13 | @Mapper 14 | public interface SysUserRoleMapper extends BaseMapper { 15 | /** 16 | * @Author 徐亮亮 17 | * @Description: 根据用户Id删除该用户的角色关系 18 | * @Date 2019/1/18 21:44 19 | */ 20 | Boolean deleteByUserId(@Param("userId") Integer userId); 21 | } -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/mapper/SysZuulRouteMapper.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.mapper; 2 | 3 | import com.baomidou.mybatisplus.mapper.BaseMapper; 4 | import com.xll.upms.common.entity.SysZuulRoute; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * @Author 徐亮亮 9 | * @Description: 动态路由配置表 Mapper 接口 10 | * @Date 2019/1/18 21:44 11 | */ 12 | @Mapper 13 | public interface SysZuulRouteMapper extends BaseMapper { 14 | 15 | } 16 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/model/dto/DeptTree.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.model.dto; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * @Author 徐亮亮 7 | * @Description: 部门树 8 | * @Date 2019/1/18 21:45 9 | */ 10 | @Data 11 | public class DeptTree extends TreeNode { 12 | private String name; 13 | } 14 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/model/dto/MenuTree.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.model.dto; 2 | 3 | import com.xll.upms.common.vo.MenuVO; 4 | import lombok.Data; 5 | 6 | /** 7 | * @Author 徐亮亮 8 | * @Description: 菜单树 9 | * @Date 2019/1/18 21:45 10 | */ 11 | @Data 12 | public class MenuTree extends TreeNode { 13 | private String icon; 14 | private String name; 15 | private String url; 16 | private boolean spread = false; 17 | private String path; 18 | private String component; 19 | private String authority; 20 | private String redirect; 21 | private String code; 22 | private String type; 23 | private String label; 24 | private Integer sort; 25 | 26 | public MenuTree() { 27 | } 28 | 29 | public MenuTree(int id, String name, int parentId) { 30 | this.id = id; 31 | this.parentId = parentId; 32 | this.name = name; 33 | this.label = name; 34 | } 35 | 36 | public MenuTree(int id, String name, MenuTree parent) { 37 | this.id = id; 38 | this.parentId = parent.getId(); 39 | this.name = name; 40 | this.label = name; 41 | } 42 | 43 | public MenuTree(MenuVO menuVo) { 44 | this.id = menuVo.getMenuId(); 45 | this.parentId = menuVo.getParentId(); 46 | this.icon = menuVo.getIcon(); 47 | this.name = menuVo.getName(); 48 | this.url = menuVo.getUrl(); 49 | this.path = menuVo.getPath(); 50 | this.component = menuVo.getComponent(); 51 | this.type = menuVo.getType(); 52 | this.label = menuVo.getName(); 53 | this.sort = menuVo.getSort(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/model/dto/RoleDTO.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.model.dto; 2 | 3 | import com.xll.upms.admin.model.entity.SysRole; 4 | import lombok.Data; 5 | 6 | /** 7 | * @Author 徐亮亮 8 | * @Description: 角色DTO 9 | * @Date 2019/1/18 21:46 10 | */ 11 | @Data 12 | public class RoleDTO extends SysRole { 13 | /** 14 | * 角色部门Id 15 | */ 16 | private Integer roleDeptId; 17 | 18 | /** 19 | * 部门名称 20 | */ 21 | private String deptName; 22 | } 23 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/model/dto/RouteConfig.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.model.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.util.Map; 7 | 8 | /** 9 | * @Author 徐亮亮 10 | * @Description: 路由配置 11 | * @Date 2019/1/18 21:46 12 | */ 13 | @Data 14 | public class RouteConfig implements Serializable{ 15 | 16 | @com.alibaba.fastjson.annotation.JSONField(name = "path") 17 | private String path; 18 | @com.alibaba.fastjson.annotation.JSONField(name = "component") 19 | private String component; 20 | @com.alibaba.fastjson.annotation.JSONField(name = "name") 21 | private String name; 22 | @com.alibaba.fastjson.annotation.JSONField(name = "components") 23 | private String components; 24 | @com.alibaba.fastjson.annotation.JSONField(name = "redirect") 25 | private String redirect; 26 | @com.alibaba.fastjson.annotation.JSONField(name = "props") 27 | private String props; 28 | @com.alibaba.fastjson.annotation.JSONField(name = "alias") 29 | private String alias; 30 | @com.alibaba.fastjson.annotation.JSONField(name = "children") 31 | private String children; 32 | @com.alibaba.fastjson.annotation.JSONField(name = "beforeEnter") 33 | private String beforeEnter; 34 | @com.alibaba.fastjson.annotation.JSONField(name = "meta") 35 | private Map meta; 36 | @com.alibaba.fastjson.annotation.JSONField(name = "caseSensitive") 37 | private Boolean caseSensitive; 38 | @com.alibaba.fastjson.annotation.JSONField(name = "pathToRegexpOptions") 39 | private String pathToRegexpOptions; 40 | } 41 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/model/dto/TreeNode.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.model.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | /** 9 | * @Author 徐亮亮 10 | * @Description: 树节点 11 | * @Date 2019/1/18 21:47 12 | */ 13 | @Data 14 | public class TreeNode { 15 | protected int id; 16 | protected int parentId; 17 | protected List children = new ArrayList(); 18 | 19 | public void add(TreeNode node) { 20 | children.add(node); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/model/dto/UserDTO.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.model.dto; 2 | 3 | import com.xll.upms.admin.model.entity.SysUser; 4 | import lombok.Data; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @Author 徐亮亮 10 | * @Description: 用户DTO 11 | * @Date 2019/1/18 21:47 12 | */ 13 | @Data 14 | public class UserDTO extends SysUser { 15 | /** 16 | * 角色ID 17 | */ 18 | private List role; 19 | 20 | private Integer deptId; 21 | 22 | /** 23 | * 新密码 24 | */ 25 | private String newpassword1; 26 | } 27 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/model/dto/UserInfo.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.model.dto; 2 | 3 | import com.xll.upms.admin.model.entity.SysUser; 4 | import lombok.Data; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * @Author 徐亮亮 10 | * @Description: 用户基础信息 11 | * @Date 2019/1/18 21:47 12 | */ 13 | @Data 14 | public class UserInfo implements Serializable { 15 | /** 16 | * 用户基本信息 17 | */ 18 | private SysUser sysUser; 19 | /** 20 | * 权限标识集合 21 | */ 22 | private String[] permissions; 23 | 24 | /** 25 | * 角色集合 26 | */ 27 | private String[] roles; 28 | } 29 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/model/entity/SysDept.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.model.entity; 2 | 3 | import com.baomidou.mybatisplus.activerecord.Model; 4 | import com.baomidou.mybatisplus.annotations.TableField; 5 | import com.baomidou.mybatisplus.annotations.TableId; 6 | import com.baomidou.mybatisplus.annotations.TableName; 7 | import com.baomidou.mybatisplus.enums.IdType; 8 | import lombok.Data; 9 | 10 | import java.io.Serializable; 11 | import java.util.Date; 12 | 13 | /** 14 | * @Author 徐亮亮 15 | * @Description: 部门管理 16 | * @Date 2019/1/18 21:48 17 | */ 18 | @Data 19 | @TableName("sys_dept") 20 | public class SysDept extends Model { 21 | 22 | private static final long serialVersionUID = 1L; 23 | 24 | @TableId(value = "dept_id", type = IdType.AUTO) 25 | private Integer deptId; 26 | /** 27 | * 部门名称 28 | */ 29 | private String name; 30 | /** 31 | * 排序 32 | */ 33 | @TableField("order_num") 34 | private Integer orderNum; 35 | /** 36 | * 创建时间 37 | */ 38 | @TableField("create_time") 39 | private Date createTime; 40 | /** 41 | * 修改时间 42 | */ 43 | @TableField("update_time") 44 | private Date updateTime; 45 | /** 46 | * 是否删除 -1:已删除 0:正常 47 | */ 48 | @TableField("del_flag") 49 | private String delFlag; 50 | 51 | @TableField("parent_id") 52 | private Integer parentId; 53 | 54 | 55 | @Override 56 | protected Serializable pkVal() { 57 | return this.deptId; 58 | } 59 | 60 | @Override 61 | public String toString() { 62 | return "SysDept{" + 63 | ", deptId=" + deptId + 64 | ", name=" + name + 65 | ", orderNum=" + orderNum + 66 | ", createTime=" + createTime + 67 | ", updateTime=" + updateTime + 68 | ", delFlag=" + delFlag + 69 | "}"; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/model/entity/SysDeptRelation.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.model.entity; 2 | 3 | import com.baomidou.mybatisplus.activerecord.Model; 4 | import com.baomidou.mybatisplus.annotations.TableName; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | 9 | /** 10 | * @Author 徐亮亮 11 | * @Description: 部门关系实体类 12 | * @Date 2019/1/18 21:48 13 | */ 14 | @Data 15 | @TableName("sys_dept_relation") 16 | public class SysDeptRelation extends Model { 17 | 18 | private static final long serialVersionUID = 1L; 19 | 20 | /** 21 | * 祖先节点 22 | */ 23 | private Integer ancestor; 24 | /** 25 | * 后代节点 26 | */ 27 | private Integer descendant; 28 | 29 | 30 | @Override 31 | protected Serializable pkVal() { 32 | return this.ancestor; 33 | } 34 | 35 | @Override 36 | public String toString() { 37 | return "SysDeptRelation{" + 38 | ", ancestor=" + ancestor + 39 | ", descendant=" + descendant + 40 | "}"; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/model/entity/SysDict.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.model.entity; 2 | 3 | import com.baomidou.mybatisplus.activerecord.Model; 4 | import com.baomidou.mybatisplus.annotations.TableField; 5 | import com.baomidou.mybatisplus.annotations.TableId; 6 | import com.baomidou.mybatisplus.annotations.TableName; 7 | import com.baomidou.mybatisplus.enums.IdType; 8 | import lombok.Data; 9 | 10 | import java.io.Serializable; 11 | import java.math.BigDecimal; 12 | import java.util.Date; 13 | 14 | /** 15 | * @Author 徐亮亮 16 | * @Description: 字典表 17 | * @Date 2019/1/18 21:48 18 | */ 19 | @Data 20 | @TableName("sys_dict") 21 | public class SysDict extends Model { 22 | 23 | private static final long serialVersionUID = 1L; 24 | 25 | /** 26 | * 编号 27 | */ 28 | @TableId(value="id", type= IdType.AUTO) 29 | private Integer id; 30 | /** 31 | * 数据值 32 | */ 33 | private String value; 34 | /** 35 | * 标签名 36 | */ 37 | private String label; 38 | /** 39 | * 类型 40 | */ 41 | private String type; 42 | /** 43 | * 描述 44 | */ 45 | private String description; 46 | /** 47 | * 排序(升序) 48 | */ 49 | private BigDecimal sort; 50 | /** 51 | * 创建时间 52 | */ 53 | @TableField("create_time") 54 | private Date createTime; 55 | /** 56 | * 更新时间 57 | */ 58 | @TableField("update_time") 59 | private Date updateTime; 60 | /** 61 | * 备注信息 62 | */ 63 | private String remarks; 64 | /** 65 | * 删除标记 66 | */ 67 | @TableField("del_flag") 68 | private String delFlag; 69 | 70 | 71 | @Override 72 | protected Serializable pkVal() { 73 | return this.id; 74 | } 75 | 76 | @Override 77 | public String toString() { 78 | return "SysDict{" + 79 | ", id=" + id + 80 | ", value=" + value + 81 | ", label=" + label + 82 | ", type=" + type + 83 | ", description=" + description + 84 | ", sort=" + sort + 85 | ", createTime=" + createTime + 86 | ", updateTime=" + updateTime + 87 | ", remarks=" + remarks + 88 | ", delFlag=" + delFlag + 89 | "}"; 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/model/entity/SysRole.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.model.entity; 2 | 3 | import com.baomidou.mybatisplus.activerecord.Model; 4 | import com.baomidou.mybatisplus.annotations.TableField; 5 | import com.baomidou.mybatisplus.annotations.TableId; 6 | import com.baomidou.mybatisplus.annotations.TableName; 7 | import com.baomidou.mybatisplus.enums.IdType; 8 | import lombok.Data; 9 | 10 | import java.io.Serializable; 11 | import java.util.Date; 12 | 13 | /** 14 | * @Author 徐亮亮 15 | * @Description:角色实体类 16 | * @Date 2019/1/18 21:49 17 | */ 18 | @Data 19 | @TableName("sys_role") 20 | public class SysRole extends Model { 21 | 22 | private static final long serialVersionUID = 1L; 23 | 24 | @TableId(value = "role_id", type = IdType.AUTO) 25 | private Integer roleId; 26 | @TableField("role_name") 27 | private String roleName; 28 | @TableField("role_code") 29 | private String roleCode; 30 | @TableField("role_desc") 31 | private String roleDesc; 32 | @TableField("create_time") 33 | private Date createTime; 34 | @TableField("update_time") 35 | private Date updateTime; 36 | /** 37 | * 删除标识(0-正常,1-删除) 38 | */ 39 | @TableField("del_flag") 40 | private String delFlag; 41 | 42 | @Override 43 | protected Serializable pkVal() { 44 | return this.roleId; 45 | } 46 | 47 | @Override 48 | public String toString() { 49 | return "SysRole{" + 50 | ", roleId=" + roleId + 51 | ", roleName=" + roleName + 52 | ", roleCode=" + roleCode + 53 | ", roleDesc=" + roleDesc + 54 | ", createTime=" + createTime + 55 | ", updateTime=" + updateTime + 56 | ", delFlag=" + delFlag + 57 | "}"; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/model/entity/SysRoleDept.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.model.entity; 2 | 3 | import com.baomidou.mybatisplus.activerecord.Model; 4 | import com.baomidou.mybatisplus.annotations.TableField; 5 | import com.baomidou.mybatisplus.annotations.TableId; 6 | import com.baomidou.mybatisplus.annotations.TableName; 7 | import com.baomidou.mybatisplus.enums.IdType; 8 | import lombok.Data; 9 | 10 | import java.io.Serializable; 11 | 12 | /** 13 | * @Author 徐亮亮 14 | * @Description: 角色与部门对应关系 15 | * @Date 2019/1/18 21:50 16 | */ 17 | @Data 18 | @TableName("sys_role_dept") 19 | public class SysRoleDept extends Model { 20 | 21 | private static final long serialVersionUID = 1L; 22 | 23 | @TableId(value="id", type= IdType.AUTO) 24 | private Integer id; 25 | /** 26 | * 角色ID 27 | */ 28 | @TableField("role_id") 29 | private Integer roleId; 30 | /** 31 | * 部门ID 32 | */ 33 | @TableField("dept_id") 34 | private Integer deptId; 35 | 36 | 37 | @Override 38 | protected Serializable pkVal() { 39 | return this.id; 40 | } 41 | 42 | @Override 43 | public String toString() { 44 | return "SysRoleDept{" + 45 | ", id=" + id + 46 | ", roleId=" + roleId + 47 | ", deptId=" + deptId + 48 | "}"; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/model/entity/SysRoleMenu.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.model.entity; 2 | 3 | import com.baomidou.mybatisplus.activerecord.Model; 4 | import com.baomidou.mybatisplus.annotations.TableId; 5 | import com.baomidou.mybatisplus.annotations.TableName; 6 | import com.baomidou.mybatisplus.enums.IdType; 7 | import lombok.Data; 8 | 9 | import java.io.Serializable; 10 | 11 | /** 12 | * @Author 徐亮亮 13 | * @Description: 角色菜单表 14 | * @Date 2019/1/18 21:50 15 | */ 16 | @Data 17 | @TableName("sys_role_menu") 18 | public class SysRoleMenu extends Model { 19 | 20 | private static final long serialVersionUID = 1L; 21 | 22 | /** 23 | * 角色ID 24 | */ 25 | @TableId(type = IdType.INPUT) 26 | private Integer roleId; 27 | /** 28 | * 菜单ID 29 | */ 30 | @TableId(type = IdType.INPUT) 31 | private Integer menuId; 32 | 33 | @Override 34 | protected Serializable pkVal() { 35 | return this.roleId; 36 | } 37 | 38 | @Override 39 | public String toString() { 40 | return "SysRoleMenu{" + 41 | ", roleId=" + roleId + 42 | ", menuId=" + menuId + 43 | "}"; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/model/entity/SysUser.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.model.entity; 2 | 3 | import com.baomidou.mybatisplus.activerecord.Model; 4 | import com.baomidou.mybatisplus.annotations.TableField; 5 | import com.baomidou.mybatisplus.annotations.TableId; 6 | import com.baomidou.mybatisplus.annotations.TableName; 7 | import com.baomidou.mybatisplus.enums.IdType; 8 | import com.fasterxml.jackson.annotation.JsonIgnore; 9 | import lombok.Data; 10 | 11 | import java.io.Serializable; 12 | import java.util.Date; 13 | 14 | /** 15 | * @Author 徐亮亮 16 | * @Description: 用户表 17 | * @Date 2019/1/18 21:51 18 | */ 19 | @Data 20 | @TableName("sys_user") 21 | public class SysUser extends Model { 22 | 23 | private static final long serialVersionUID = 1L; 24 | 25 | /** 26 | * 主键ID 27 | */ 28 | @TableId(value = "user_id", type = IdType.AUTO) 29 | private Integer userId; 30 | /** 31 | * 用户名 32 | */ 33 | private String username; 34 | 35 | private String password; 36 | /** 37 | * 随机盐 38 | */ 39 | @JsonIgnore 40 | private String salt; 41 | /** 42 | * 创建时间 43 | */ 44 | @TableField("create_time") 45 | private Date createTime; 46 | /** 47 | * 修改时间 48 | */ 49 | @TableField("update_time") 50 | private Date updateTime; 51 | /** 52 | * 0-正常,1-删除 53 | */ 54 | @TableField("del_flag") 55 | private String delFlag; 56 | 57 | /** 58 | * 简介 59 | */ 60 | private String phone; 61 | /** 62 | * 头像 63 | */ 64 | private String avatar; 65 | 66 | /** 67 | * 部门ID 68 | */ 69 | @TableField("dept_id") 70 | private Integer deptId; 71 | 72 | 73 | @Override 74 | protected Serializable pkVal() { 75 | return this.userId; 76 | } 77 | 78 | @Override 79 | public String toString() { 80 | return "SysUser{" + 81 | "userId=" + userId + 82 | ", username='" + username + '\'' + 83 | ", password='" + password + '\'' + 84 | ", salt='" + salt + '\'' + 85 | ", createTime=" + createTime + 86 | ", updateTime=" + updateTime + 87 | ", delFlag='" + delFlag + '\'' + 88 | ", phone='" + phone + '\'' + 89 | ", avatar='" + avatar + '\'' + 90 | ", deptId=" + deptId + 91 | '}'; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/model/entity/SysUserRole.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018-2025, lengleng All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * Neither the name of the pig4cloud.com developer nor the names of its 13 | * contributors may be used to endorse or promote products derived from 14 | * this software without specific prior written permission. 15 | * Author: lengleng (wangiegie@gmail.com) 16 | */ 17 | 18 | package com.xll.upms.admin.model.entity; 19 | 20 | import com.baomidou.mybatisplus.activerecord.Model; 21 | import com.baomidou.mybatisplus.annotations.TableId; 22 | import com.baomidou.mybatisplus.annotations.TableName; 23 | import com.baomidou.mybatisplus.enums.IdType; 24 | import lombok.Data; 25 | 26 | import java.io.Serializable; 27 | 28 | /** 29 | * @Author 徐亮亮 30 | * @Description: 用户角色表 31 | * @Date 2019/1/18 21:51 32 | */ 33 | @Data 34 | @TableName("sys_user_role") 35 | public class SysUserRole extends Model { 36 | 37 | private static final long serialVersionUID = 1L; 38 | 39 | /** 40 | * 用户ID 41 | */ 42 | @TableId(type = IdType.INPUT) 43 | private Integer userId; 44 | /** 45 | * 角色ID 46 | */ 47 | @TableId(type = IdType.INPUT) 48 | private Integer roleId; 49 | 50 | 51 | @Override 52 | protected Serializable pkVal() { 53 | return this.userId; 54 | } 55 | 56 | @Override 57 | public String toString() { 58 | return "SysUserRole{" + 59 | ", userId=" + userId + 60 | ", roleId=" + roleId + 61 | "}"; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/service/SysDeptRelationService.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.service; 2 | 3 | import com.baomidou.mybatisplus.service.IService; 4 | import com.xll.upms.admin.model.entity.SysDeptRelation; 5 | 6 | /** 7 | * @Author 徐亮亮 8 | * @Description: 部门服务类 9 | * @Date 2019/1/18 21:55 10 | */ 11 | public interface SysDeptRelationService extends IService { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/service/SysDeptService.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.service; 2 | 3 | import com.baomidou.mybatisplus.mapper.EntityWrapper; 4 | import com.baomidou.mybatisplus.service.IService; 5 | import com.xll.upms.admin.model.dto.DeptTree; 6 | import com.xll.upms.admin.model.entity.SysDept; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @Author 徐亮亮 12 | * @Description: 部门管理 服务类 13 | * @Date 2019/1/18 21:56 14 | */ 15 | public interface SysDeptService extends IService { 16 | 17 | /** 18 | * 查询部门树菜单 19 | * @param sysDeptEntityWrapper 20 | * @return 树 21 | */ 22 | List selectListTree(EntityWrapper sysDeptEntityWrapper); 23 | 24 | /** 25 | * 添加信息部门 26 | * @param sysDept 27 | * @return 28 | */ 29 | Boolean insertDept(SysDept sysDept); 30 | 31 | /** 32 | * 删除部门 33 | * @param id 部门 ID 34 | * @return 成功、失败 35 | */ 36 | Boolean deleteDeptById(Integer id); 37 | 38 | /** 39 | * 更新部门 40 | * @param sysDept 部门信息 41 | * @return 成功、失败 42 | */ 43 | Boolean updateDeptById(SysDept sysDept); 44 | } 45 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/service/SysDictService.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.service; 2 | 3 | import com.baomidou.mybatisplus.service.IService; 4 | import com.xll.upms.admin.model.entity.SysDict; 5 | 6 | /** 7 | * @Author 徐亮亮 8 | * @Description: 字典表 服务类 9 | * @Date 2019/1/18 21:56 10 | */ 11 | public interface SysDictService extends IService { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/service/SysLogService.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.service; 2 | 3 | import com.baomidou.mybatisplus.service.IService; 4 | import com.xll.upms.common.entity.SysLog; 5 | 6 | /** 7 | * @Author 徐亮亮 8 | * @Description: 日志表 服务类 9 | * @Date 2019/1/18 21:56 10 | */ 11 | public interface SysLogService extends IService { 12 | 13 | /** 14 | * 通过ID删除日志(逻辑删除) 15 | * 16 | * @param id 日志ID 17 | * @return true/false 18 | */ 19 | Boolean updateByLogId(Long id); 20 | } 21 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/service/SysMenuService.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.service; 2 | 3 | 4 | import com.baomidou.mybatisplus.service.IService; 5 | import com.xll.upms.admin.model.entity.SysMenu; 6 | import com.xll.upms.common.vo.MenuVO; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @Author 徐亮亮 12 | * @Description: 菜单权限表 服务类 13 | * @Date 2019/1/18 21:57 14 | */ 15 | public interface SysMenuService extends IService { 16 | /** 17 | * 通过角色名称查询URL 权限 18 | * 19 | * @param role 角色名称 20 | * @return 菜单列表 21 | */ 22 | List findMenuByRoleName(String role); 23 | 24 | /** 25 | * 级联删除菜单 26 | * 27 | * @param id 菜单ID 28 | * @return 成功、失败 29 | */ 30 | Boolean deleteMenu(Integer id); 31 | 32 | /** 33 | * 更新菜单信息 34 | * 35 | * @param sysMenu 菜单信息 36 | * @return 成功、失败 37 | */ 38 | Boolean updateMenuById(SysMenu sysMenu); 39 | } 40 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/service/SysOauthClientDetailsService.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.service; 2 | 3 | import com.baomidou.mybatisplus.service.IService; 4 | import com.xll.upms.admin.model.entity.SysOauthClientDetails; 5 | 6 | /** 7 | * @Author 徐亮亮 8 | * @Description: 服务类 9 | * @Date 2019/1/18 21:57 10 | */ 11 | public interface SysOauthClientDetailsService extends IService { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/service/SysRoleDeptService.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.service; 2 | 3 | import com.baomidou.mybatisplus.service.IService; 4 | import com.xll.upms.admin.model.entity.SysRoleDept; 5 | 6 | /** 7 | * @Author 徐亮亮 8 | * @Description: 角色与部门对应关系 服务类 9 | * @Date 2019/1/18 21:57 10 | */ 11 | public interface SysRoleDeptService extends IService { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/service/SysRoleMenuService.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.service; 2 | 3 | 4 | import com.baomidou.mybatisplus.service.IService; 5 | import com.xll.upms.admin.model.entity.SysRoleMenu; 6 | 7 | /** 8 | * @Author 徐亮亮 9 | * @Description: 角色菜单表 服务类 10 | * @Date 2019/1/18 21:57 11 | */ 12 | public interface SysRoleMenuService extends IService { 13 | 14 | /** 15 | * 更新角色菜单 16 | * 17 | * 18 | * @param role 19 | * @param roleId 角色 20 | * @param menuIds 菜单列表 21 | * @return 22 | */ 23 | Boolean insertRoleMenus(String role, Integer roleId, String menuIds); 24 | } 25 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/service/SysRoleService.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.service; 2 | 3 | import com.baomidou.mybatisplus.mapper.EntityWrapper; 4 | import com.baomidou.mybatisplus.plugins.Page; 5 | import com.baomidou.mybatisplus.service.IService; 6 | import com.xll.upms.admin.model.dto.RoleDTO; 7 | import com.xll.upms.admin.model.entity.SysRole; 8 | import com.xll.upms.common.util.Query; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * @Author 徐亮亮 14 | * @Description: 角色 服务类 15 | * @Date 2019/1/18 21:58 16 | */ 17 | public interface SysRoleService extends IService { 18 | 19 | /** 20 | * 添加角色 21 | * 22 | * @param roleDto 角色信息 23 | * @return 成功、失败 24 | */ 25 | Boolean insertRole(RoleDTO roleDto); 26 | 27 | /** 28 | * 分页查角色列表 29 | * 30 | * @param objectQuery 查询条件 31 | * @param objectEntityWrapper wapper 32 | * @return page 33 | */ 34 | Page selectwithDeptPage(Query objectQuery, EntityWrapper objectEntityWrapper); 35 | 36 | /** 37 | * 更新角色 38 | * @param roleDto 含有部门信息 39 | * @return 成功、失败 40 | */ 41 | Boolean updateRoleById(RoleDTO roleDto); 42 | 43 | /** 44 | * 通过部门ID查询角色列表 45 | * @param deptId 部门ID 46 | * @return 角色列表 47 | */ 48 | List selectListByDeptId(Integer deptId); 49 | } 50 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/service/SysUserRoleService.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.service; 2 | 3 | 4 | import com.baomidou.mybatisplus.service.IService; 5 | import com.xll.upms.admin.model.entity.SysUserRole; 6 | 7 | /** 8 | * @Author 徐亮亮 9 | * @Description: 用户角色表 服务类 10 | * @Date 2019/1/18 21:58 11 | */ 12 | public interface SysUserRoleService extends IService { 13 | 14 | /** 15 | * 根据用户Id删除该用户的角色关系 16 | * 17 | * @author 寻欢·李 18 | * @date 2017年12月7日 16:31:38 19 | * @param userId 用户ID 20 | * @return boolean 21 | */ 22 | Boolean deleteByUserId(Integer userId); 23 | } 24 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/service/SysUserService.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.service; 2 | 3 | import com.baomidou.mybatisplus.plugins.Page; 4 | import com.baomidou.mybatisplus.service.IService; 5 | import com.xll.upms.admin.model.dto.UserDTO; 6 | import com.xll.upms.admin.model.dto.UserInfo; 7 | import com.xll.upms.admin.model.entity.SysUser; 8 | import com.xll.upms.common.util.Query; 9 | import com.xll.upms.common.util.R; 10 | import com.xll.upms.common.vo.UserVO; 11 | 12 | /** 13 | * @Author 徐亮亮 14 | * @Description: 用户 服务器 15 | * @Date 2019/1/18 21:58 16 | */ 17 | public interface SysUserService extends IService { 18 | /** 19 | * 根据用户名查询用户角色信息 20 | * 21 | * @param username 用户名 22 | * @return userVo 23 | */ 24 | UserVO findUserByUsername(String username); 25 | 26 | /** 27 | * 分页查询用户信息(含有角色信息) 28 | * 29 | * @param query 查询条件 30 | * @param userVO 31 | * @return 32 | */ 33 | Page selectWithRolePage(Query query, UserVO userVO); 34 | 35 | /** 36 | * 查询用户信息 37 | * 38 | * @param userVo 角色名 39 | * @return userInfo 40 | */ 41 | UserInfo findUserInfo(UserVO userVo); 42 | 43 | /** 44 | * 保存验证码 45 | * @param randomStr 随机串 46 | * @param imageCode 验证码*/ 47 | void saveImageCode(String randomStr, String imageCode); 48 | 49 | /** 50 | * 删除用户 51 | * @param sysUser 用户 52 | * @return boolean 53 | */ 54 | Boolean deleteUserById(SysUser sysUser); 55 | 56 | /** 57 | * 更新当前用户基本信息 58 | * @param userDto 用户信息 59 | * @param username 用户名 60 | * @return Boolean 61 | */ 62 | R updateUserInfo(UserDTO userDto, String username); 63 | 64 | /** 65 | * 更新指定用户信息 66 | * @param userDto 用户信息 67 | * @return 68 | */ 69 | Boolean updateUser(UserDTO userDto); 70 | 71 | /** 72 | * 通过手机号查询用户信息 73 | * @param mobile 手机号 74 | * @return 用户信息 75 | */ 76 | UserVO findUserByMobile(String mobile); 77 | 78 | /** 79 | * 发送验证码 80 | * @param mobile 手机号 81 | * @return R 82 | */ 83 | R sendSmsCode(String mobile); 84 | 85 | /** 86 | * 通过openId查询用户 87 | * @param openId openId 88 | * @return 用户信息 89 | */ 90 | UserVO findUserByOpenId(String openId); 91 | 92 | /** 93 | * 通过ID查询用户信息 94 | * @param id 用户ID 95 | * @return 用户信息 96 | */ 97 | UserVO selectUserVoById(Integer id); 98 | } 99 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/service/SysZuulRouteService.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.service; 2 | 3 | import com.baomidou.mybatisplus.service.IService; 4 | import com.xll.upms.common.entity.SysZuulRoute; 5 | 6 | /** 7 | * @Author 徐亮亮 8 | * @Description: 动态路由配置表 服务类 9 | * @Date 2019/1/18 21:59 10 | */ 11 | public interface SysZuulRouteService extends IService { 12 | 13 | /** 14 | * 立即生效配置 15 | * @return 16 | */ 17 | Boolean applyZuulRoute(); 18 | } 19 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/service/impl/SysDeptRelationServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.service.impl; 2 | 3 | import com.baomidou.mybatisplus.service.impl.ServiceImpl; 4 | import com.xll.upms.admin.mapper.SysDeptRelationMapper; 5 | import com.xll.upms.admin.model.entity.SysDeptRelation; 6 | import com.xll.upms.admin.service.SysDeptRelationService; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | * @Author 徐亮亮 11 | * @Description: 服务实现类 12 | * @Date 2019/1/18 21:51 13 | */ 14 | @Service 15 | public class SysDeptRelationServiceImpl extends ServiceImpl implements SysDeptRelationService { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/service/impl/SysDictServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.service.impl; 2 | 3 | import com.baomidou.mybatisplus.service.impl.ServiceImpl; 4 | import com.xll.upms.admin.mapper.SysDictMapper; 5 | import com.xll.upms.admin.model.entity.SysDict; 6 | import com.xll.upms.admin.service.SysDictService; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | * @Author 徐亮亮 11 | * @Description: 字典表 服务实现类 12 | * @Date 2019/1/18 21:52 13 | */ 14 | @Service 15 | public class SysDictServiceImpl extends ServiceImpl implements SysDictService { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/service/impl/SysLogServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.service.impl; 2 | 3 | import com.baomidou.mybatisplus.service.impl.ServiceImpl; 4 | import com.xll.upms.admin.mapper.SysLogMapper; 5 | import com.xll.upms.admin.service.SysLogService; 6 | import com.xll.upms.common.constant.CommonConstant; 7 | import com.xll.upms.common.entity.SysLog; 8 | import com.xll.upms.common.util.Assert; 9 | import org.springframework.stereotype.Service; 10 | import org.springframework.transaction.annotation.Transactional; 11 | 12 | import java.util.Date; 13 | 14 | /** 15 | * @Author 徐亮亮 16 | * @Description: 日志表 服务实现类 17 | * @Date 2019/1/18 21:52 18 | */ 19 | @Service 20 | @Transactional 21 | public class SysLogServiceImpl extends ServiceImpl implements SysLogService { 22 | 23 | @Override 24 | public Boolean updateByLogId(Long id) { 25 | Assert.isNull(id, "日志ID为空"); 26 | 27 | SysLog sysLog = new SysLog(); 28 | sysLog.setId(id); 29 | sysLog.setDelFlag(CommonConstant.STATUS_DEL); 30 | sysLog.setUpdateTime(new Date()); 31 | return updateById(sysLog); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/service/impl/SysMenuServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.service.impl; 2 | 3 | import com.baomidou.mybatisplus.mapper.EntityWrapper; 4 | import com.baomidou.mybatisplus.service.impl.ServiceImpl; 5 | import com.xll.upms.admin.mapper.SysMenuMapper; 6 | import com.xll.upms.admin.model.entity.SysMenu; 7 | import com.xll.upms.admin.service.SysMenuService; 8 | import com.xll.upms.common.constant.CommonConstant; 9 | import com.xll.upms.common.util.Assert; 10 | import com.xll.upms.common.vo.MenuVO; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.cache.annotation.CacheEvict; 13 | import org.springframework.cache.annotation.Cacheable; 14 | import org.springframework.stereotype.Service; 15 | 16 | import java.util.List; 17 | 18 | /** 19 | * @Author 徐亮亮 20 | * @Description: 菜单权限表 服务实现类 21 | * @Date 2019/1/18 21:53 22 | */ 23 | @Service 24 | public class SysMenuServiceImpl extends ServiceImpl implements SysMenuService { 25 | @Autowired 26 | private SysMenuMapper sysMenuMapper; 27 | 28 | @Override 29 | @Cacheable(value = "menu_details", key = "#role + '_menu'") 30 | public List findMenuByRoleName(String role) { 31 | return sysMenuMapper.findMenuByRoleName(role); 32 | } 33 | 34 | @Override 35 | @CacheEvict(value = "menu_details", allEntries = true) 36 | public Boolean deleteMenu(Integer id) { 37 | Assert.isNull(id, "菜单ID不能为空"); 38 | // 删除当前节点 39 | SysMenu condition1 = new SysMenu(); 40 | condition1.setMenuId(id); 41 | condition1.setDelFlag(CommonConstant.STATUS_DEL); 42 | this.updateById(condition1); 43 | 44 | // 删除父节点为当前节点的节点 45 | SysMenu conditon2 = new SysMenu(); 46 | conditon2.setParentId(id); 47 | SysMenu sysMenu = new SysMenu(); 48 | sysMenu.setDelFlag(CommonConstant.STATUS_DEL); 49 | return this.update(sysMenu, new EntityWrapper<>(conditon2)); 50 | } 51 | 52 | @Override 53 | @CacheEvict(value = "menu_details", allEntries = true) 54 | public Boolean updateMenuById(SysMenu sysMenu) { 55 | return this.updateById(sysMenu); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/service/impl/SysOauthClientDetailsServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.service.impl; 2 | 3 | import com.baomidou.mybatisplus.service.impl.ServiceImpl; 4 | import com.xll.upms.admin.mapper.SysOauthClientDetailsMapper; 5 | import com.xll.upms.admin.model.entity.SysOauthClientDetails; 6 | import com.xll.upms.admin.service.SysOauthClientDetailsService; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | * @Author 徐亮亮 11 | * @Description: 服务实现类 12 | * @Date 2019/1/18 21:53 13 | */ 14 | @Service 15 | public class SysOauthClientDetailsServiceImpl extends ServiceImpl implements SysOauthClientDetailsService { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/service/impl/SysRoleDeptServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.service.impl; 2 | 3 | import com.baomidou.mybatisplus.service.impl.ServiceImpl; 4 | import com.xll.upms.admin.mapper.SysRoleDeptMapper; 5 | import com.xll.upms.admin.model.entity.SysRoleDept; 6 | import com.xll.upms.admin.service.SysRoleDeptService; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | * @Author 徐亮亮 11 | * @Description: 角色与部门对应关系 服务实现类 12 | * @Date 2019/1/18 21:53 13 | */ 14 | @Service 15 | public class SysRoleDeptServiceImpl extends ServiceImpl implements SysRoleDeptService { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/service/impl/SysRoleMenuServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.service.impl; 2 | 3 | import com.baomidou.mybatisplus.mapper.EntityWrapper; 4 | import com.baomidou.mybatisplus.service.impl.ServiceImpl; 5 | import com.xll.upms.admin.mapper.SysRoleMenuMapper; 6 | import com.xll.upms.admin.model.entity.SysRoleMenu; 7 | import com.xll.upms.admin.service.SysRoleMenuService; 8 | import com.xiaoleilu.hutool.util.StrUtil; 9 | import org.springframework.cache.annotation.CacheEvict; 10 | import org.springframework.stereotype.Service; 11 | 12 | import java.util.ArrayList; 13 | import java.util.Arrays; 14 | import java.util.List; 15 | 16 | /** 17 | * @Author 徐亮亮 18 | * @Description: 角色菜单表 服务实现类 19 | * @Date 2019/1/18 21:53 20 | */ 21 | @Service 22 | public class SysRoleMenuServiceImpl extends ServiceImpl implements SysRoleMenuService { 23 | @Override 24 | @CacheEvict(value = "menu_details", key = "#role + '_menu'") 25 | public Boolean insertRoleMenus(String role, Integer roleId,String menuIds) { 26 | SysRoleMenu condition = new SysRoleMenu(); 27 | condition.setRoleId(roleId); 28 | this.delete(new EntityWrapper<>(condition)); 29 | 30 | if (StrUtil.isBlank(menuIds)){ 31 | return Boolean.TRUE; 32 | } 33 | 34 | if (StrUtil.isBlank(menuIds)) { 35 | return Boolean.TRUE; 36 | } 37 | 38 | List roleMenuList = new ArrayList<>(); 39 | List menuIdList = Arrays.asList(menuIds.split(",")); 40 | 41 | for (String menuId : menuIdList) { 42 | SysRoleMenu roleMenu = new SysRoleMenu(); 43 | roleMenu.setRoleId(roleId); 44 | roleMenu.setMenuId(Integer.valueOf(menuId)); 45 | roleMenuList.add(roleMenu); 46 | } 47 | return this.insertBatch(roleMenuList); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/service/impl/SysUserRoleServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.service.impl; 2 | 3 | import com.baomidou.mybatisplus.service.impl.ServiceImpl; 4 | import com.xll.upms.admin.mapper.SysUserRoleMapper; 5 | import com.xll.upms.admin.model.entity.SysUserRole; 6 | import com.xll.upms.admin.service.SysUserRoleService; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | * @Author 徐亮亮 11 | * @Description: 用户角色表 服务实现类 12 | * @Date 2019/1/18 21:54 13 | */ 14 | @Service 15 | public class SysUserRoleServiceImpl extends ServiceImpl implements SysUserRoleService { 16 | 17 | /** 18 | * 根据用户Id删除该用户的角色关系 19 | * 20 | * @param userId 用户ID 21 | * @return boolean 22 | * @author 寻欢·李 23 | * @date 2017年12月7日 16:31:38 24 | */ 25 | @Override 26 | public Boolean deleteByUserId(Integer userId) { 27 | return baseMapper.deleteByUserId(userId); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/java/com/xll/upms/admin/service/impl/SysZuulRouteServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.admin.service.impl; 2 | 3 | import com.baomidou.mybatisplus.mapper.EntityWrapper; 4 | import com.baomidou.mybatisplus.service.impl.ServiceImpl; 5 | import com.xll.upms.admin.mapper.SysZuulRouteMapper; 6 | import com.xll.upms.admin.service.SysZuulRouteService; 7 | import com.xll.upms.common.constant.CommonConstant; 8 | import com.xll.upms.common.constant.MqQueueConstant; 9 | import com.xll.upms.common.entity.SysZuulRoute; 10 | import org.springframework.amqp.rabbit.core.RabbitTemplate; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.data.redis.core.RedisTemplate; 13 | import org.springframework.stereotype.Service; 14 | 15 | import java.util.List; 16 | 17 | /** 18 | * @Author 徐亮亮 19 | * @Description: 动态路由配置表 服务实现类 20 | * @Date 2019/1/18 21:55 21 | */ 22 | @Service 23 | public class SysZuulRouteServiceImpl extends ServiceImpl implements SysZuulRouteService { 24 | @Autowired 25 | private RedisTemplate redisTemplate; 26 | @Autowired 27 | private RabbitTemplate rabbitTemplate; 28 | 29 | /** 30 | * 立即生效配置 31 | * 32 | * @return 33 | */ 34 | @Override 35 | public Boolean applyZuulRoute() { 36 | EntityWrapper wrapper = new EntityWrapper(); 37 | wrapper.eq(CommonConstant.DEL_FLAG, CommonConstant.STATUS_NORMAL); 38 | List routeList = selectList(wrapper); 39 | redisTemplate.opsForValue().set(CommonConstant.ROUTE_KEY, routeList); 40 | rabbitTemplate.convertAndSend(MqQueueConstant.ROUTE_CONFIG_CHANGE, 1); 41 | return Boolean.TRUE; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: pig-upms-service 4 | profiles: 5 | active: dev 6 | cloud: 7 | config: 8 | fail-fast: true 9 | discovery: 10 | service-id: pig-config-server 11 | enabled: true 12 | profile: ${spring.profiles.active} 13 | label: master 14 | 15 | --- 16 | spring: 17 | profiles: dev 18 | eureka: 19 | instance: 20 | prefer-ip-address: true 21 | lease-renewal-interval-in-seconds: 5 22 | lease-expiration-duration-in-seconds: 20 23 | client: 24 | serviceUrl: 25 | defaultZone: http://xll:gip6666@localhost:1025/eureka 26 | registry-fetch-interval-seconds: 10 27 | 28 | --- 29 | spring: 30 | profiles: prd 31 | eureka: 32 | instance: 33 | prefer-ip-address: true 34 | client: 35 | serviceUrl: 36 | defaultZone: http://xll:gip6666@eureka:1025/eureka 37 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/resources/mapper/SysDeptMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | dept_id AS deptId, parent_id AS parentId, name, order_num AS orderNum, create_time AS createTime, update_time AS updateTime, del_flag AS delFlag 18 | 19 | 20 | 21 | 29 | 30 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/resources/mapper/SysDeptRelationMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | ancestor, descendant 14 | 15 | 16 | 17 | 18 | DELETE FROM sys_dept_relation 19 | WHERE 20 | descendant IN ( SELECT temp.descendant FROM 21 | ( SELECT descendant FROM sys_dept_relation WHERE ancestor = #{descendant} ) temp ) 22 | AND ancestor IN ( SELECT temp.ancestor FROM ( SELECT ancestor FROM 23 | sys_dept_relation WHERE descendant = #{descendant} AND ancestor != descendant ) temp ); 24 | 25 | INSERT INTO sys_dept_relation (ancestor, descendant) 26 | SELECT a.ancestor, b.descendant 27 | FROM sys_dept_relation a 28 | CROSS JOIN sys_dept_relation b 29 | WHERE a.descendant = #{ancestor} 30 | AND b.ancestor = #{descendant}; 31 | 32 | 33 | 34 | 35 | DELETE 36 | FROM 37 | sys_dept_relation 38 | WHERE 39 | descendant IN ( 40 | SELECT 41 | temp.descendant 42 | FROM 43 | ( 44 | SELECT 45 | descendant 46 | FROM 47 | sys_dept_relation 48 | WHERE 49 | ancestor = #{id} 50 | ) temp 51 | ) 52 | 53 | 54 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/resources/mapper/SysDictMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | id, value, label, type, description, sort, create_time AS createTime, update_time AS updateTime, remarks, del_flag AS delFlag 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/resources/mapper/SysLogMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | id, type, title, create_by AS createBy, create_time AS createTime, update_time AS updateTime, remote_addr AS remoteAddr, user_agent AS userAgent, request_uri AS requestUri, method, params, `time`, del_flag AS delFlag 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/resources/mapper/SysOauthClientDetailsMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | client_id AS clientId, resource_ids AS resourceIds, client_secret AS clientSecret, scope, authorized_grant_types AS authorizedGrantTypes, web_server_redirect_uri AS webServerRedirectUri, authorities, access_token_validity AS accessTokenValidity, refresh_token_validity AS refreshTokenValidity, additional_information AS additionalInformation, autoapprove 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/resources/mapper/SysRoleDeptMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | id, role_id AS roleId, dept_id AS deptId 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/resources/mapper/SysRoleMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 39 | 51 | 52 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/resources/mapper/SysRoleMenuMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/resources/mapper/SysUserRoleMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | DELETE FROM sys_user_role WHERE user_id = #{userId} 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/resources/mapper/SysZuulRouteMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | id, path, service_id AS serviceId, url, strip_prefix AS stripPrefix, retryable, enabled, sensitiveHeaders_list AS sensitiveheadersList, create_time AS createTime, update_time AS updateTime, del_flag AS delFlag 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/main/resources/templates/menu.sql.vm: -------------------------------------------------------------------------------- 1 | -- 菜单SQL 2 | INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) 3 | VALUES ('1', '$!{comments}', 'modules/generator/$!{pathName}.html', NULL, '1', 'fa fa-file-code-o', '6'); 4 | 5 | -- 按钮父菜单ID 6 | set @parentId = @@identity; 7 | 8 | -- 菜单对应按钮SQL 9 | INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) 10 | SELECT @parentId, '查看', null, '$!{pathName}:list,$!{pathName}:info', '2', null, '6'; 11 | INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) 12 | SELECT @parentId, '新增', null, '$!{pathName}:save', '2', null, '6'; 13 | INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) 14 | SELECT @parentId, '修改', null, '$!{pathName}:update', '2', null, '6'; 15 | INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) 16 | SELECT @parentId, '删除', null, '$!{pathName}:delete', '2', null, '6'; 17 | -------------------------------------------------------------------------------- /xll-modules/xll-upms-service/src/test/java/com/xll/upms/admin/PigAdminApplicationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018-2025, lengleng All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * Neither the name of the pig4cloud.com developer nor the names of its 13 | * contributors may be used to endorse or promote products derived from 14 | * this software without specific prior written permission. 15 | * Author: lengleng (wangiegie@gmail.com) 16 | */ 17 | 18 | package com.xll.upms.admin; 19 | 20 | import com.ulisesbocchio.jasyptspringboot.encryptor.DefaultLazyEncryptor; 21 | import org.jasypt.encryption.StringEncryptor; 22 | import org.junit.Test; 23 | import org.springframework.core.env.StandardEnvironment; 24 | 25 | /** 26 | * 配置文件加解密工具类 27 | * 28 | * @author lengleng 29 | */ 30 | public class PigAdminApplicationTest { 31 | private static final String JASYPT_ENCRYPTOR_PASSWORD = "jasypt.encryptor.password"; 32 | 33 | /** 34 | * jasypt.encryptor.password 对应 配置中心 application-dev.yml 中的密码 35 | */ 36 | @Test 37 | public void testEnvironmentProperties() { 38 | System.setProperty(JASYPT_ENCRYPTOR_PASSWORD, "xll"); 39 | StringEncryptor stringEncryptor = new DefaultLazyEncryptor(new StandardEnvironment()); 40 | 41 | //加密方法 42 | System.out.println(stringEncryptor.encrypt("admin")); 43 | //解密方法 44 | System.out.println(stringEncryptor.decrypt("n7bwIvqtfJW7LGgaK8zvaA==")); 45 | } 46 | } -------------------------------------------------------------------------------- /xll-visual/pom.xml: -------------------------------------------------------------------------------- 1 | 17 | 18 | 20 | 4.0.0 21 | 22 | com.xll.upms 23 | xll-visual 24 | 1.3.1 25 | pom 26 | 27 | xll-visual 28 | 图形化管理模块 29 | 30 | 31 | xll-upms 32 | com.xll 33 | 1.3.1 34 | 35 | 36 | 37 | xll-monitor 38 | xll-zipkin-elk 39 | xll-zipkin-db 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /xll-visual/xll-monitor/src/main/java/com/xll/upms/monitor/UPMSMonitorApplication.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.monitor; 2 | 3 | import de.codecentric.boot.admin.config.EnableAdminServer; 4 | import de.codecentric.boot.admin.notify.LoggingNotifier; 5 | import de.codecentric.boot.admin.notify.Notifier; 6 | import de.codecentric.boot.admin.notify.RemindingNotifier; 7 | import de.codecentric.boot.admin.notify.filter.FilteringNotifier; 8 | import org.springframework.boot.SpringApplication; 9 | import org.springframework.cloud.client.SpringCloudApplication; 10 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 11 | import org.springframework.cloud.netflix.turbine.EnableTurbine; 12 | import org.springframework.context.annotation.Bean; 13 | import org.springframework.context.annotation.Configuration; 14 | import org.springframework.context.annotation.Primary; 15 | import org.springframework.scheduling.annotation.Scheduled; 16 | 17 | import java.util.concurrent.TimeUnit; 18 | 19 | /** 20 | * @Author 徐亮亮 21 | * @Description: 监控模块 22 | * @Date 2019/1/18 22:05 23 | */ 24 | @EnableAdminServer 25 | @EnableTurbine 26 | @EnableDiscoveryClient 27 | @SpringCloudApplication 28 | public class UPMSMonitorApplication { 29 | 30 | public static void main(String[] args) { 31 | SpringApplication.run(UPMSMonitorApplication.class, args); 32 | } 33 | 34 | @Configuration 35 | public static class NotifierConfig { 36 | @Bean 37 | @Primary 38 | public RemindingNotifier remindingNotifier() { 39 | RemindingNotifier notifier = new RemindingNotifier(filteringNotifier(loggerNotifier())); 40 | notifier.setReminderPeriod(TimeUnit.SECONDS.toMillis(10)); 41 | return notifier; 42 | } 43 | 44 | @Scheduled(fixedRate = 1_000L) 45 | public void remind() { 46 | remindingNotifier().sendReminders(); 47 | } 48 | 49 | @Bean 50 | public FilteringNotifier filteringNotifier(Notifier delegate) { 51 | return new FilteringNotifier(delegate); 52 | } 53 | 54 | @Bean 55 | public LoggingNotifier loggerNotifier() { 56 | return new LoggingNotifier(); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /xll-visual/xll-monitor/src/main/java/com/xll/upms/monitor/config/MonitorDingTalkPropertiesConfig.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.monitor.config; 2 | 3 | import lombok.Data; 4 | import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; 5 | 6 | /** 7 | * @Author 徐亮亮 8 | * @Description: 监控钉钉属性配置类 9 | * @Date 2019/1/18 22:03 10 | */ 11 | @Data 12 | @ConditionalOnExpression("!'${webhook}'.isEmpty()") 13 | public class MonitorDingTalkPropertiesConfig { 14 | /** 15 | * 是否开启钉钉通知 16 | */ 17 | private Boolean enabled; 18 | } 19 | -------------------------------------------------------------------------------- /xll-visual/xll-monitor/src/main/java/com/xll/upms/monitor/config/MonitorMobilePropertiesConfig.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.monitor.config; 2 | 3 | import lombok.Data; 4 | import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | /** 10 | * @Author 徐亮亮 11 | * @Description: 监控手机属性配置类 12 | * @Date 2019/1/18 22:04 13 | */ 14 | @Data 15 | @ConditionalOnExpression("!'${mobiles}'.isEmpty()") 16 | public class MonitorMobilePropertiesConfig { 17 | private Boolean enabled; 18 | private List mobiles = new ArrayList<>(); 19 | } 20 | -------------------------------------------------------------------------------- /xll-visual/xll-monitor/src/main/java/com/xll/upms/monitor/config/MonitorPropertiesConfig.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.monitor.config; 2 | 3 | import lombok.Data; 4 | import org.springframework.boot.context.properties.ConfigurationProperties; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | /** 8 | * @Author 徐亮亮 9 | * @Description: 监控属性配置类 10 | * @Date 2019/1/18 22:04 11 | */ 12 | @Data 13 | @Configuration 14 | @ConfigurationProperties(prefix = "notifier") 15 | public class MonitorPropertiesConfig { 16 | 17 | private MonitorMobilePropertiesConfig mobile; 18 | 19 | private MonitorDingTalkPropertiesConfig dingTalk; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /xll-visual/xll-monitor/src/main/java/com/xll/upms/monitor/config/PigNotifierConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.monitor.config; 2 | 3 | import com.xll.upms.monitor.filter.StatusChangeNotifier; 4 | import de.codecentric.boot.admin.notify.RemindingNotifier; 5 | import org.springframework.amqp.rabbit.core.RabbitTemplate; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | import org.springframework.context.annotation.Primary; 10 | import org.springframework.scheduling.annotation.EnableScheduling; 11 | import org.springframework.scheduling.annotation.Scheduled; 12 | 13 | import java.util.concurrent.TimeUnit; 14 | 15 | /** 16 | * @Author 徐亮亮 17 | * @Description: 监控提醒配置 18 | * @Date 2019/1/18 22:05 19 | */ 20 | @Configuration 21 | @EnableScheduling 22 | public class PigNotifierConfiguration { 23 | @Autowired 24 | private RabbitTemplate rabbitTemplate; 25 | @Autowired 26 | private MonitorPropertiesConfig monitorPropertiesConfig; 27 | @Bean 28 | @Primary 29 | public RemindingNotifier remindingNotifier() { 30 | RemindingNotifier remindingNotifier = new RemindingNotifier(mobileNotifier()); 31 | remindingNotifier.setReminderPeriod(TimeUnit.MINUTES.toMillis(1)); 32 | return remindingNotifier; 33 | } 34 | 35 | @Bean 36 | public StatusChangeNotifier mobileNotifier(){ 37 | return new StatusChangeNotifier(monitorPropertiesConfig,rabbitTemplate); 38 | } 39 | 40 | @Scheduled(fixedRate = 60_000L) 41 | public void remind() { 42 | remindingNotifier().sendReminders(); 43 | } 44 | } -------------------------------------------------------------------------------- /xll-visual/xll-monitor/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: pig-monitor 4 | profiles: 5 | active: dev 6 | cloud: 7 | config: 8 | fail-fast: true 9 | discovery: 10 | service-id: pig-config-server 11 | enabled: true 12 | profile: ${spring.profiles.active} 13 | label: master 14 | --- 15 | spring: 16 | profiles: dev 17 | eureka: 18 | instance: 19 | prefer-ip-address: true 20 | lease-renewal-interval-in-seconds: 5 21 | lease-expiration-duration-in-seconds: 20 22 | client: 23 | serviceUrl: 24 | defaultZone: http://xll:gip6666@localhost:1025/eureka 25 | registry-fetch-interval-seconds: 10 26 | 27 | --- 28 | spring: 29 | profiles: prd 30 | eureka: 31 | instance: 32 | prefer-ip-address: true 33 | client: 34 | serviceUrl: 35 | defaultZone: http://xll:gip6666@eureka:1025/eureka -------------------------------------------------------------------------------- /xll-visual/xll-zipkin-db/src/main/java/com/xll/upms/zipkin/UPMSZipkinDbApplication.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.zipkin; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import zipkin.server.EnableZipkinServer; 7 | 8 | /** 9 | * @Author 徐亮亮 10 | * @Description: zipkin mysql 存储实现 11 | * @Date 2019/1/18 22:06 12 | */ 13 | @EnableDiscoveryClient 14 | @SpringBootApplication 15 | @EnableZipkinServer 16 | public class UPMSZipkinDbApplication { 17 | public static void main(String[] args) { 18 | SpringApplication.run(UPMSZipkinDbApplication.class, args); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /xll-visual/xll-zipkin-db/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: pig-zipkin-db 4 | profiles: 5 | active: dev 6 | cloud: 7 | config: 8 | fail-fast: true 9 | discovery: 10 | service-id: pig-config-server 11 | enabled: true 12 | profile: ${spring.profiles.active} 13 | label: master 14 | 15 | --- 16 | spring: 17 | profiles: dev 18 | eureka: 19 | instance: 20 | prefer-ip-address: true 21 | lease-renewal-interval-in-seconds: 5 22 | lease-expiration-duration-in-seconds: 20 23 | client: 24 | serviceUrl: 25 | defaultZone: http://xll:gip6666@localhost:1025/eureka 26 | registry-fetch-interval-seconds: 10 27 | 28 | --- 29 | spring: 30 | profiles: prd 31 | eureka: 32 | instance: 33 | prefer-ip-address: true 34 | client: 35 | serviceUrl: 36 | defaultZone: http://xll:gip6666@eureka:1025/eureka -------------------------------------------------------------------------------- /xll-visual/xll-zipkin-elk/src/main/java/com/xll/upms/zipkin/UPMSZipkinElkApplication.java: -------------------------------------------------------------------------------- 1 | package com.xll.upms.zipkin; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import zipkin.server.EnableZipkinServer; 7 | 8 | /** 9 | * @Author 徐亮亮 10 | * @Description: 链路追踪 11 | * @Date 2019/1/19 16:35 12 | */ 13 | @EnableDiscoveryClient 14 | @SpringBootApplication 15 | @EnableZipkinServer 16 | public class UPMSZipkinElkApplication { 17 | 18 | public static void main(String[] args) { 19 | SpringApplication.run(UPMSZipkinElkApplication.class, args); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /xll-visual/xll-zipkin-elk/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: pig-zipkin-elk 4 | profiles: 5 | active: dev 6 | cloud: 7 | config: 8 | fail-fast: true 9 | discovery: 10 | service-id: pig-config-server 11 | enabled: true 12 | profile: ${spring.profiles.active} 13 | label: master 14 | 15 | --- 16 | spring: 17 | profiles: dev 18 | eureka: 19 | instance: 20 | prefer-ip-address: true 21 | lease-renewal-interval-in-seconds: 5 22 | lease-expiration-duration-in-seconds: 20 23 | client: 24 | serviceUrl: 25 | defaultZone: http://xll:gip6666@localhost:1025/eureka 26 | registry-fetch-interval-seconds: 10 27 | 28 | --- 29 | spring: 30 | profiles: prd 31 | eureka: 32 | instance: 33 | prefer-ip-address: true 34 | client: 35 | serviceUrl: 36 | defaultZone: http://xll:gip6666@eureka:1025/eureka --------------------------------------------------------------------------------