1 files modified
24 files renamed
637 files deleted
235 files added
| | |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>BladeX</artifactId> |
| | | <artifactId>skjcmanager</artifactId> |
| | | <version>3.0.1.RELEASE</version> |
| | | <packaging>pom</packaging> |
| | | |
| | |
| | | </properties> |
| | | |
| | | <modules> |
| | | <module>blade-auth</module> |
| | | <module>blade-common</module> |
| | | <module>blade-gateway</module> |
| | | <module>blade-ops</module> |
| | | <module>blade-ops-api</module> |
| | | <module>blade-plugin</module> |
| | | <module>blade-plugin-api</module> |
| | | <module>blade-service</module> |
| | | <module>blade-service-api</module> |
| | | <module>skjcmanager-auth</module> |
| | | <module>skjcmanager-common</module> |
| | | <module>skjcmanager-gateway</module> |
| | | <module>skjcmanager-ops</module> |
| | | <module>skjcmanager-ops-api</module> |
| | | <module>skjcmanager-plugin</module> |
| | | <module>skjcmanager-plugin-api</module> |
| | | <module>skjcmanager-service</module> |
| | | <module>skjcmanager-service-api</module> |
| | | </modules> |
| | | |
| | | <dependencyManagement> |
| | |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>blade-common</artifactId> |
| | | <artifactId>skjcmanager-common</artifactId> |
| | | <version>${bladex.project.version}</version> |
| | | </dependency> |
| | | <dependency> |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <project xmlns="http://maven.apache.org/POM/4.0.0" |
| | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| | | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| | | |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | | <parent> |
| | | <artifactId>skjcmanager</artifactId> |
| | | <groupId>org.springblade</groupId> |
| | | <version>3.0.1.RELEASE</version> |
| | | </parent> |
| | | |
| | | <artifactId>skjcmanager-auth</artifactId> |
| | | <name>${project.artifactId}</name> |
| | | <version>${bladex.project.version}</version> |
| | | <packaging>jar</packaging> |
| | | |
| | | <dependencies> |
| | | <!--Blade--> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>skjcmanager-common</artifactId> |
| | | <version>${bladex.project.version}</version> |
| | | <exclusions> |
| | | <exclusion> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>skjcmanager-scope-api</artifactId> |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>blade-core-db</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>blade-core-cloud</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>blade-starter-metrics</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>blade-starter-redis</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>blade-starter-swagger</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>blade-starter-social</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>skjcmanager-user-api</artifactId> |
| | | <version>${bladex.project.version}</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>skjcmanager-system-api</artifactId> |
| | | <version>${bladex.project.version}</version> |
| | | </dependency> |
| | | <!--安全模块--> |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-starter-security</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springframework.security.oauth</groupId> |
| | | <artifactId>spring-security-oauth2</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springframework.security</groupId> |
| | | <artifactId>spring-security-jwt</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springframework.data</groupId> |
| | | <artifactId>spring-data-redis</artifactId> |
| | | </dependency> |
| | | <!-- 验证码 --> |
| | | <dependency> |
| | | <groupId>com.github.whvcse</groupId> |
| | | <artifactId>easy-captcha</artifactId> |
| | | </dependency> |
| | | <!--freemarker--> |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-starter-freemarker</artifactId> |
| | | </dependency> |
| | | <!-- 链路追踪、服务监控 --> |
| | | <!--<dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>blade-starter-trace</artifactId> |
| | | </dependency>--> |
| | | <!-- 解决Java11无法运行的问题 --> |
| | | <!--<dependency> |
| | | <groupId>javax.xml.bind</groupId> |
| | | <artifactId>jaxb-api</artifactId> |
| | | <version>2.2.11</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.sun.xml.bind</groupId> |
| | | <artifactId>jaxb-core</artifactId> |
| | | <version>2.2.11</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.sun.xml.bind</groupId> |
| | | <artifactId>jaxb-impl</artifactId> |
| | | <version>2.2.11</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>javax.activation</groupId> |
| | | <artifactId>activation</artifactId> |
| | | <version>1.1.1</version> |
| | | </dependency>--> |
| | | </dependencies> |
| | | |
| | | <build> |
| | | <plugins> |
| | | <plugin> |
| | | <groupId>com.spotify</groupId> |
| | | <artifactId>dockerfile-maven-plugin</artifactId> |
| | | <configuration> |
| | | <username>${docker.username}</username> |
| | | <password>${docker.password}</password> |
| | | <repository>${docker.registry.url}/${docker.namespace}/${project.artifactId}</repository> |
| | | <tag>${project.version}</tag> |
| | | <useMavenSettingsForAuth>true</useMavenSettingsForAuth> |
| | | <buildArgs> |
| | | <JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE> |
| | | </buildArgs> |
| | | <skip>false</skip> |
| | | </configuration> |
| | | </plugin> |
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-antrun-plugin</artifactId> |
| | | </plugin> |
| | | </plugins> |
| | | </build> |
| | | |
| | | </project> |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.auth; |
| | | |
| | | |
| | | import cn.gistack.common.constant.AppsConstant; |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import org.springframework.cloud.openfeign.EnableFeignClients; |
| | | |
| | | /** |
| | | * 用户认证服务器 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @BladeCloudApplication |
| | | @EnableFeignClients(basePackages = "cn.gistack.system.user.feign") |
| | | public class AuthApplication { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppsConstant.APPLICATION_AUTH_NAME, AuthApplication.class, args); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.auth.config; |
| | | |
| | | import cn.gistack.auth.constant.AuthConstant; |
| | | import cn.gistack.auth.service.BladeClientDetailsServiceImpl; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.SneakyThrows; |
| | | import cn.gistack.auth.granter.BladeTokenGranter; |
| | | import org.springblade.core.redis.cache.BladeRedis; |
| | | import org.springblade.core.social.props.SocialProperties; |
| | | import cn.gistack.system.user.feign.IUserClient; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.core.annotation.Order; |
| | | import org.springframework.security.authentication.AuthenticationManager; |
| | | import org.springframework.security.core.userdetails.UserDetailsService; |
| | | import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer; |
| | | import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter; |
| | | import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer; |
| | | import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer; |
| | | import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerSecurityConfigurer; |
| | | import org.springframework.security.oauth2.provider.TokenGranter; |
| | | import org.springframework.security.oauth2.provider.token.TokenEnhancer; |
| | | import org.springframework.security.oauth2.provider.token.TokenEnhancerChain; |
| | | import org.springframework.security.oauth2.provider.token.TokenStore; |
| | | import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter; |
| | | |
| | | import javax.sql.DataSource; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 认证服务器配置 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Order |
| | | @Configuration(proxyBeanMethods = false) |
| | | @AllArgsConstructor |
| | | @EnableAuthorizationServer |
| | | public class BladeAuthorizationServerConfiguration extends AuthorizationServerConfigurerAdapter { |
| | | |
| | | private final DataSource dataSource; |
| | | |
| | | private final AuthenticationManager authenticationManager; |
| | | |
| | | private final UserDetailsService userDetailsService; |
| | | |
| | | private final TokenStore tokenStore; |
| | | |
| | | private final TokenEnhancer jwtTokenEnhancer; |
| | | |
| | | private final JwtAccessTokenConverter jwtAccessTokenConverter; |
| | | |
| | | private final BladeRedis bladeRedis; |
| | | |
| | | private final IUserClient userClient; |
| | | |
| | | private final SocialProperties socialProperties; |
| | | |
| | | @Override |
| | | public void configure(AuthorizationServerEndpointsConfigurer endpoints) { |
| | | //获取自定义tokenGranter |
| | | TokenGranter tokenGranter = BladeTokenGranter.getTokenGranter(authenticationManager, endpoints, bladeRedis, userClient, socialProperties); |
| | | |
| | | //配置端点 |
| | | endpoints.tokenStore(tokenStore) |
| | | .authenticationManager(authenticationManager) |
| | | .userDetailsService(userDetailsService) |
| | | .tokenGranter(tokenGranter); |
| | | |
| | | //扩展token返回结果 |
| | | if (jwtAccessTokenConverter != null && jwtTokenEnhancer != null) { |
| | | TokenEnhancerChain tokenEnhancerChain = new TokenEnhancerChain(); |
| | | List<TokenEnhancer> enhancerList = new ArrayList<>(); |
| | | enhancerList.add(jwtTokenEnhancer); |
| | | enhancerList.add(jwtAccessTokenConverter); |
| | | tokenEnhancerChain.setTokenEnhancers(enhancerList); |
| | | //jwt增强 |
| | | endpoints.tokenEnhancer(tokenEnhancerChain).accessTokenConverter(jwtAccessTokenConverter); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 配置客户端信息 |
| | | */ |
| | | @Override |
| | | @SneakyThrows |
| | | public void configure(ClientDetailsServiceConfigurer clients) { |
| | | BladeClientDetailsServiceImpl clientDetailsService = new BladeClientDetailsServiceImpl(dataSource); |
| | | clientDetailsService.setSelectClientDetailsSql(AuthConstant.DEFAULT_SELECT_STATEMENT); |
| | | clientDetailsService.setFindClientDetailsSql(AuthConstant.DEFAULT_FIND_STATEMENT); |
| | | clients.withClientDetails(clientDetailsService); |
| | | } |
| | | |
| | | @Override |
| | | public void configure(AuthorizationServerSecurityConfigurer oauthServer) { |
| | | oauthServer |
| | | .allowFormAuthenticationForClients() |
| | | .tokenKeyAccess("permitAll()") |
| | | .checkTokenAccess("isAuthenticated()"); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.auth.config; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.SneakyThrows; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.security.config.annotation.web.builders.HttpSecurity; |
| | | import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter; |
| | | |
| | | /** |
| | | * 自定义资源放行 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Configuration(proxyBeanMethods = false) |
| | | @AllArgsConstructor |
| | | public class BladeResourceServerConfiguration extends ResourceServerConfigurerAdapter { |
| | | |
| | | @Override |
| | | @SneakyThrows |
| | | public void configure(HttpSecurity http) { |
| | | http.authorizeRequests() |
| | | .antMatchers( |
| | | "/actuator/**", |
| | | "/oauth/captcha", |
| | | "/oauth/logout", |
| | | "/oauth/clear-cache", |
| | | "/oauth/render/**", |
| | | "/oauth/callback/**", |
| | | "/oauth/revoke/**", |
| | | "/oauth/refresh/**", |
| | | "/oauth/login", |
| | | "/oauth/form", |
| | | "/token/**", |
| | | "/mobile/**", |
| | | "/static/**", |
| | | "/v2/api-docs").permitAll() |
| | | .anyRequest().authenticated().and() |
| | | .csrf().disable(); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.auth.config; |
| | | |
| | | import cn.gistack.auth.support.BladeJwtTokenEnhancer; |
| | | import org.springblade.core.jwt.props.JwtProperties; |
| | | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; |
| | | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.security.jwt.crypto.sign.MacSigner; |
| | | import org.springframework.security.jwt.crypto.sign.SignatureVerifier; |
| | | import org.springframework.security.oauth2.provider.token.TokenEnhancer; |
| | | import org.springframework.security.oauth2.provider.token.TokenStore; |
| | | import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter; |
| | | import org.springframework.security.oauth2.provider.token.store.JwtTokenStore; |
| | | |
| | | /** |
| | | * JwtTokenStore |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Configuration(proxyBeanMethods = false) |
| | | @ConditionalOnProperty(prefix = "blade.security.oauth2", name = "storeType", havingValue = "jwt", matchIfMissing = true) |
| | | public class JwtTokenStoreConfiguration { |
| | | |
| | | /** |
| | | * 使用jwtTokenStore存储token |
| | | */ |
| | | @Bean |
| | | public TokenStore jwtTokenStore(JwtProperties jwtProperties) { |
| | | return new JwtTokenStore(getJwtAccessTokenConverter(jwtProperties)); |
| | | } |
| | | |
| | | /** |
| | | * 用于生成jwt |
| | | */ |
| | | @Bean |
| | | public JwtAccessTokenConverter jwtAccessTokenConverter(JwtProperties jwtProperties) { |
| | | return getJwtAccessTokenConverter(jwtProperties); |
| | | } |
| | | |
| | | /** |
| | | * 自定义 JwtAccessTokenConverter |
| | | */ |
| | | private JwtAccessTokenConverter getJwtAccessTokenConverter(JwtProperties jwtProperties) { |
| | | JwtAccessTokenConverter accessTokenConverter = new JwtAccessTokenConverter(); |
| | | accessTokenConverter.setSigningKey(jwtProperties.getSignKey()); |
| | | SignatureVerifier verifier = new MacSigner(jwtProperties.getSignKey()); |
| | | accessTokenConverter.setVerifier(verifier); |
| | | return accessTokenConverter; |
| | | } |
| | | |
| | | /** |
| | | * 用于扩展jwt |
| | | */ |
| | | @Bean |
| | | @ConditionalOnMissingBean(name = "jwtTokenEnhancer") |
| | | public TokenEnhancer jwtTokenEnhancer(JwtAccessTokenConverter jwtAccessTokenConverter, JwtProperties jwtProperties) { |
| | | return new BladeJwtTokenEnhancer(jwtAccessTokenConverter, jwtProperties); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.auth.config; |
| | | |
| | | import cn.gistack.auth.support.BladePasswordEncoderFactories; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.SneakyThrows; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.security.authentication.AuthenticationManager; |
| | | import org.springframework.security.config.annotation.web.builders.HttpSecurity; |
| | | import org.springframework.security.config.annotation.web.builders.WebSecurity; |
| | | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; |
| | | import org.springframework.security.crypto.password.PasswordEncoder; |
| | | |
| | | /** |
| | | * Security配置 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Configuration(proxyBeanMethods = false) |
| | | @AllArgsConstructor |
| | | public class SecurityConfiguration extends WebSecurityConfigurerAdapter { |
| | | |
| | | @Bean |
| | | @Override |
| | | @SneakyThrows |
| | | public AuthenticationManager authenticationManagerBean() { |
| | | return super.authenticationManagerBean(); |
| | | } |
| | | |
| | | @Bean |
| | | public PasswordEncoder passwordEncoder() { |
| | | return BladePasswordEncoderFactories.createDelegatingPasswordEncoder(); |
| | | } |
| | | |
| | | @Override |
| | | @SneakyThrows |
| | | protected void configure(HttpSecurity http) { |
| | | http.headers().frameOptions().disable(); |
| | | http.httpBasic().and().csrf().disable(); |
| | | http.formLogin().loginPage("/oauth/login").loginProcessingUrl("/oauth/form"); |
| | | } |
| | | |
| | | @Override |
| | | public void configure(WebSecurity web) { |
| | | web.ignoring().antMatchers("/js/*.js", "/css/*.css"); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.auth.constant; |
| | | |
| | | /** |
| | | * 授权校验常量 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface AuthConstant { |
| | | |
| | | /** |
| | | * 密码加密规则 |
| | | */ |
| | | String ENCRYPT = "{blade}"; |
| | | |
| | | /** |
| | | * blade_client表字段 |
| | | */ |
| | | String CLIENT_FIELDS = "client_id, CONCAT('{noop}',client_secret) as client_secret, resource_ids, scope, authorized_grant_types, " + |
| | | "web_server_redirect_uri, authorities, access_token_validity, " + |
| | | "refresh_token_validity, additional_information, autoapprove"; |
| | | |
| | | /** |
| | | * blade_client查询语句 |
| | | */ |
| | | String BASE_STATEMENT = "select " + CLIENT_FIELDS + " from blade_client"; |
| | | |
| | | /** |
| | | * blade_client查询排序 |
| | | */ |
| | | String DEFAULT_FIND_STATEMENT = BASE_STATEMENT + " order by client_id"; |
| | | |
| | | /** |
| | | * 查询client_id |
| | | */ |
| | | String DEFAULT_SELECT_STATEMENT = BASE_STATEMENT + " where client_id = ?"; |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.auth.endpoint; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import me.zhyd.oauth.model.AuthCallback; |
| | | import me.zhyd.oauth.model.AuthToken; |
| | | import me.zhyd.oauth.request.AuthRequest; |
| | | import me.zhyd.oauth.utils.AuthStateUtils; |
| | | import org.springblade.core.social.props.SocialProperties; |
| | | import org.springblade.core.social.utils.SocialUtil; |
| | | import org.springblade.core.tenant.annotation.NonDS; |
| | | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | |
| | | /** |
| | | * SocialEndpoint |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @NonDS |
| | | @Slf4j |
| | | @RestController |
| | | @AllArgsConstructor |
| | | @ConditionalOnProperty(value = "social.enabled", havingValue = "true") |
| | | public class BladeSocialEndpoint { |
| | | |
| | | private final SocialProperties socialProperties; |
| | | |
| | | /** |
| | | * 授权完毕跳转 |
| | | */ |
| | | @RequestMapping("/oauth/render/{source}") |
| | | public void renderAuth(@PathVariable("source") String source, HttpServletResponse response) throws IOException { |
| | | AuthRequest authRequest = SocialUtil.getAuthRequest(source, socialProperties); |
| | | String authorizeUrl = authRequest.authorize(AuthStateUtils.createState()); |
| | | response.sendRedirect(authorizeUrl); |
| | | } |
| | | |
| | | /** |
| | | * 获取认证信息 |
| | | */ |
| | | @RequestMapping("/oauth/callback/{source}") |
| | | public Object login(@PathVariable("source") String source, AuthCallback callback) { |
| | | AuthRequest authRequest = SocialUtil.getAuthRequest(source, socialProperties); |
| | | return authRequest.login(callback); |
| | | } |
| | | |
| | | /** |
| | | * 撤销授权 |
| | | */ |
| | | @RequestMapping("/oauth/revoke/{source}/{token}") |
| | | public Object revokeAuth(@PathVariable("source") String source, @PathVariable("token") String token) { |
| | | AuthRequest authRequest = SocialUtil.getAuthRequest(source, socialProperties); |
| | | return authRequest.revoke(AuthToken.builder().accessToken(token).build()); |
| | | } |
| | | |
| | | /** |
| | | * 续期令牌 |
| | | */ |
| | | @RequestMapping("/oauth/refresh/{source}") |
| | | public Object refreshAuth(@PathVariable("source") String source, String token) { |
| | | AuthRequest authRequest = SocialUtil.getAuthRequest(source, socialProperties); |
| | | return authRequest.refresh(AuthToken.builder().refreshToken(token).build()); |
| | | } |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.auth.endpoint; |
| | | |
| | | import com.wf.captcha.SpecCaptcha; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import cn.gistack.common.cache.CacheNames; |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.jwt.JwtUtil; |
| | | import org.springblade.core.jwt.props.JwtProperties; |
| | | import org.springblade.core.launch.constant.TokenConstant; |
| | | import org.springblade.core.redis.cache.BladeRedis; |
| | | import org.springblade.core.secure.BladeUser; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tenant.annotation.NonDS; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.support.Kv; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.springblade.core.tool.utils.WebUtil; |
| | | import org.springframework.security.core.Authentication; |
| | | import org.springframework.security.core.context.SecurityContextHolder; |
| | | import org.springframework.security.oauth2.common.OAuth2AccessToken; |
| | | import org.springframework.security.oauth2.common.OAuth2RefreshToken; |
| | | import org.springframework.security.oauth2.provider.AuthorizationRequest; |
| | | import org.springframework.security.oauth2.provider.ClientDetailsService; |
| | | import org.springframework.security.oauth2.provider.token.TokenStore; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | | |
| | | import javax.servlet.http.HttpSession; |
| | | import java.time.Duration; |
| | | |
| | | import static org.springblade.core.cache.constant.CacheConstant.*; |
| | | |
| | | /** |
| | | * BladeEndPoint |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @NonDS |
| | | @Slf4j |
| | | @RestController |
| | | @AllArgsConstructor |
| | | public class BladeTokenEndPoint { |
| | | |
| | | private final BladeRedis bladeRedis; |
| | | private final JwtProperties jwtProperties; |
| | | private final ClientDetailsService clientDetailsService; |
| | | private final TokenStore tokenStore; |
| | | |
| | | /** |
| | | * 登录页面 |
| | | */ |
| | | @GetMapping("/oauth/login") |
| | | public ModelAndView require(ModelAndView model) { |
| | | model.setViewName("login"); |
| | | return model; |
| | | } |
| | | |
| | | /** |
| | | * 授权页面 |
| | | */ |
| | | @GetMapping("/oauth/confirm_access") |
| | | public ModelAndView confirm(HttpSession session, ModelAndView model) { |
| | | Object auth = session.getAttribute("authorizationRequest"); |
| | | if (auth != null) { |
| | | AuthorizationRequest authorizationRequest = (AuthorizationRequest) auth; |
| | | model.addObject("client", clientDetailsService.loadClientByClientId(authorizationRequest.getClientId())); |
| | | model.addObject("principal", SecurityContextHolder.getContext().getAuthentication().getPrincipal()); |
| | | } |
| | | model.setViewName("confirm"); |
| | | return model; |
| | | } |
| | | |
| | | /** |
| | | * 用户信息 |
| | | */ |
| | | @GetMapping("/oauth/user-info") |
| | | public R<Authentication> currentUser(Authentication authentication) { |
| | | return R.data(authentication); |
| | | } |
| | | |
| | | /** |
| | | * 验证码 |
| | | */ |
| | | @GetMapping("/oauth/captcha") |
| | | public Kv captcha() { |
| | | SpecCaptcha specCaptcha = new SpecCaptcha(130, 48, 5); |
| | | String verCode = specCaptcha.text().toLowerCase(); |
| | | String key = StringUtil.randomUUID(); |
| | | // 存入redis并设置过期时间为30分钟 |
| | | bladeRedis.setEx(CacheNames.CAPTCHA_KEY + key, verCode, Duration.ofMinutes(30)); |
| | | // 将key和base64返回给前端 |
| | | return Kv.create().set("key", key).set("image", specCaptcha.toBase64()); |
| | | } |
| | | |
| | | /** |
| | | * 退出登录 |
| | | */ |
| | | @GetMapping("/oauth/logout") |
| | | public Kv logout() { |
| | | BladeUser user = AuthUtil.getUser(); |
| | | String token = JwtUtil.getToken(WebUtil.getRequest().getHeader(TokenConstant.HEADER)); |
| | | // 清空redis保存的token |
| | | if (user != null && jwtProperties.getState()) { |
| | | JwtUtil.removeAccessToken(user.getTenantId(), String.valueOf(user.getUserId()), token); |
| | | } |
| | | // 清空资源服务器保存的token |
| | | OAuth2AccessToken accessToken = tokenStore.readAccessToken(token); |
| | | OAuth2RefreshToken refreshToken = null; |
| | | if (accessToken != null && StringUtil.isNoneBlank(accessToken.getValue())) { |
| | | refreshToken = accessToken.getRefreshToken(); |
| | | tokenStore.removeAccessToken(accessToken); |
| | | } |
| | | if (refreshToken != null && StringUtil.isNoneBlank(refreshToken.getValue())) { |
| | | tokenStore.removeRefreshToken(refreshToken); |
| | | } |
| | | return Kv.create().set("success", "true").set("msg", "success"); |
| | | } |
| | | |
| | | /** |
| | | * 缓存清空 |
| | | */ |
| | | @GetMapping("/oauth/clear-cache") |
| | | public Kv clearCache() { |
| | | CacheUtil.clear(BIZ_CACHE); |
| | | CacheUtil.clear(USER_CACHE); |
| | | CacheUtil.clear(DICT_CACHE); |
| | | CacheUtil.clear(FLOW_CACHE); |
| | | CacheUtil.clear(SYS_CACHE); |
| | | CacheUtil.clear(PARAM_CACHE); |
| | | CacheUtil.clear(RESOURCE_CACHE); |
| | | CacheUtil.clear(MENU_CACHE); |
| | | CacheUtil.clear(DICT_CACHE, Boolean.FALSE); |
| | | CacheUtil.clear(MENU_CACHE, Boolean.FALSE); |
| | | CacheUtil.clear(SYS_CACHE, Boolean.FALSE); |
| | | CacheUtil.clear(PARAM_CACHE, Boolean.FALSE); |
| | | return Kv.create().set("success", "true").set("msg", "success"); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.auth.granter; |
| | | |
| | | import org.springblade.core.redis.cache.BladeRedis; |
| | | import org.springblade.core.social.props.SocialProperties; |
| | | import cn.gistack.system.user.feign.IUserClient; |
| | | import org.springframework.security.authentication.AuthenticationManager; |
| | | import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer; |
| | | import org.springframework.security.oauth2.provider.CompositeTokenGranter; |
| | | import org.springframework.security.oauth2.provider.TokenGranter; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 自定义拓展TokenGranter |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class BladeTokenGranter { |
| | | |
| | | /** |
| | | * 自定义tokenGranter |
| | | */ |
| | | public static TokenGranter getTokenGranter(final AuthenticationManager authenticationManager, final AuthorizationServerEndpointsConfigurer endpoints, BladeRedis bladeRedis, IUserClient userClient, SocialProperties socialProperties) { |
| | | // 默认tokenGranter集合 |
| | | List<TokenGranter> granters = new ArrayList<>(Collections.singletonList(endpoints.getTokenGranter())); |
| | | // 增加验证码模式 |
| | | granters.add(new CaptchaTokenGranter(authenticationManager, endpoints.getTokenServices(), endpoints.getClientDetailsService(), endpoints.getOAuth2RequestFactory(), bladeRedis)); |
| | | // 增加第三方登陆模式 |
| | | granters.add(new SocialTokenGranter(endpoints.getTokenServices(), endpoints.getClientDetailsService(), endpoints.getOAuth2RequestFactory(), userClient, socialProperties)); |
| | | // 组合tokenGranter集合 |
| | | return new CompositeTokenGranter(granters); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package cn.gistack.auth.granter; |
| | | |
| | | import cn.gistack.auth.utils.TokenUtil; |
| | | import cn.gistack.common.cache.CacheNames; |
| | | import org.springblade.core.redis.cache.BladeRedis; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.springblade.core.tool.utils.WebUtil; |
| | | import org.springframework.security.authentication.*; |
| | | import org.springframework.security.core.Authentication; |
| | | import org.springframework.security.oauth2.common.exceptions.InvalidGrantException; |
| | | import org.springframework.security.oauth2.common.exceptions.UserDeniedAuthorizationException; |
| | | import org.springframework.security.oauth2.provider.*; |
| | | import org.springframework.security.oauth2.provider.token.AbstractTokenGranter; |
| | | import org.springframework.security.oauth2.provider.token.AuthorizationServerTokenServices; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 验证码TokenGranter |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class CaptchaTokenGranter extends AbstractTokenGranter { |
| | | |
| | | private static final String GRANT_TYPE = "captcha"; |
| | | |
| | | private final AuthenticationManager authenticationManager; |
| | | |
| | | private BladeRedis bladeRedis; |
| | | |
| | | public CaptchaTokenGranter(AuthenticationManager authenticationManager, |
| | | AuthorizationServerTokenServices tokenServices, ClientDetailsService clientDetailsService, OAuth2RequestFactory requestFactory, BladeRedis bladeRedis) { |
| | | this(authenticationManager, tokenServices, clientDetailsService, requestFactory, GRANT_TYPE); |
| | | this.bladeRedis = bladeRedis; |
| | | } |
| | | |
| | | protected CaptchaTokenGranter(AuthenticationManager authenticationManager, AuthorizationServerTokenServices tokenServices, |
| | | ClientDetailsService clientDetailsService, OAuth2RequestFactory requestFactory, String grantType) { |
| | | super(tokenServices, clientDetailsService, requestFactory, grantType); |
| | | this.authenticationManager = authenticationManager; |
| | | } |
| | | |
| | | @Override |
| | | protected OAuth2Authentication getOAuth2Authentication(ClientDetails client, TokenRequest tokenRequest) { |
| | | HttpServletRequest request = WebUtil.getRequest(); |
| | | // 增加验证码判断 |
| | | String key = request.getHeader(TokenUtil.CAPTCHA_HEADER_KEY); |
| | | String code = request.getHeader(TokenUtil.CAPTCHA_HEADER_CODE); |
| | | // 获取验证码 |
| | | String redisCode = bladeRedis.get(CacheNames.CAPTCHA_KEY + key); |
| | | // 判断验证码 |
| | | if (code == null || !StringUtil.equalsIgnoreCase(redisCode, code)) { |
| | | throw new UserDeniedAuthorizationException(TokenUtil.CAPTCHA_NOT_CORRECT); |
| | | } |
| | | |
| | | Map<String, String> parameters = new LinkedHashMap<String, String>(tokenRequest.getRequestParameters()); |
| | | String username = parameters.get("username"); |
| | | String password = parameters.get("password"); |
| | | // Protect from downstream leaks of password |
| | | parameters.remove("password"); |
| | | |
| | | Authentication userAuth = new UsernamePasswordAuthenticationToken(username, password); |
| | | ((AbstractAuthenticationToken) userAuth).setDetails(parameters); |
| | | try { |
| | | userAuth = authenticationManager.authenticate(userAuth); |
| | | } |
| | | catch (AccountStatusException | BadCredentialsException ase) { |
| | | //covers expired, locked, disabled cases (mentioned in section 5.2, draft 31) |
| | | throw new InvalidGrantException(ase.getMessage()); |
| | | } |
| | | // If the username/password are wrong the spec says we should send 400/invalid grant |
| | | |
| | | if (userAuth == null || !userAuth.isAuthenticated()) { |
| | | throw new InvalidGrantException("Could not authenticate user: " + username); |
| | | } |
| | | |
| | | OAuth2Request storedOAuth2Request = getRequestFactory().createOAuth2Request(client, tokenRequest); |
| | | return new OAuth2Authentication(storedOAuth2Request, userAuth); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.auth.granter; |
| | | |
| | | import cn.gistack.auth.constant.AuthConstant; |
| | | import cn.gistack.auth.service.BladeUserDetails; |
| | | import me.zhyd.oauth.model.AuthCallback; |
| | | import me.zhyd.oauth.model.AuthResponse; |
| | | import me.zhyd.oauth.model.AuthUser; |
| | | import me.zhyd.oauth.request.AuthRequest; |
| | | import cn.gistack.auth.utils.TokenUtil; |
| | | import org.springblade.core.social.props.SocialProperties; |
| | | import org.springblade.core.social.utils.SocialUtil; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.support.Kv; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.core.tool.utils.WebUtil; |
| | | import cn.gistack.system.user.entity.User; |
| | | import cn.gistack.system.user.entity.UserInfo; |
| | | import cn.gistack.system.user.entity.UserOauth; |
| | | import cn.gistack.system.user.feign.IUserClient; |
| | | import org.springframework.security.authentication.AbstractAuthenticationToken; |
| | | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; |
| | | import org.springframework.security.core.Authentication; |
| | | import org.springframework.security.core.authority.AuthorityUtils; |
| | | import org.springframework.security.oauth2.common.exceptions.InvalidGrantException; |
| | | import org.springframework.security.oauth2.provider.*; |
| | | import org.springframework.security.oauth2.provider.token.AbstractTokenGranter; |
| | | import org.springframework.security.oauth2.provider.token.AuthorizationServerTokenServices; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 第三方登录认证类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class SocialTokenGranter extends AbstractTokenGranter { |
| | | private static final String GRANT_TYPE = "social"; |
| | | private static final Integer AUTH_SUCCESS_CODE = 2000; |
| | | |
| | | private final IUserClient userClient; |
| | | private final SocialProperties socialProperties; |
| | | |
| | | protected SocialTokenGranter(AuthorizationServerTokenServices tokenServices, ClientDetailsService clientDetailsService, OAuth2RequestFactory requestFactory, IUserClient userClient, SocialProperties socialProperties) { |
| | | super(tokenServices, clientDetailsService, requestFactory, GRANT_TYPE); |
| | | this.userClient = userClient; |
| | | this.socialProperties = socialProperties; |
| | | } |
| | | |
| | | @Override |
| | | protected OAuth2Authentication getOAuth2Authentication(ClientDetails client, TokenRequest tokenRequest) { |
| | | // 请求头租户信息 |
| | | HttpServletRequest request = WebUtil.getRequest(); |
| | | String tenantId = Func.toStr(request.getHeader(TokenUtil.TENANT_HEADER_KEY), TokenUtil.DEFAULT_TENANT_ID); |
| | | |
| | | Map<String, String> parameters = new LinkedHashMap<>(tokenRequest.getRequestParameters()); |
| | | // 开放平台来源 |
| | | String sourceParameter = parameters.get("source"); |
| | | // 匹配是否有别名定义 |
| | | String source = socialProperties.getAlias().getOrDefault(sourceParameter, sourceParameter); |
| | | // 开放平台授权码 |
| | | String code = parameters.get("code"); |
| | | // 开放平台状态吗 |
| | | String state = parameters.get("state"); |
| | | |
| | | // 获取开放平台授权数据 |
| | | AuthRequest authRequest = SocialUtil.getAuthRequest(source, socialProperties); |
| | | AuthCallback authCallback = new AuthCallback(); |
| | | authCallback.setCode(code); |
| | | authCallback.setState(state); |
| | | AuthResponse authResponse = authRequest.login(authCallback); |
| | | AuthUser authUser; |
| | | if (authResponse.getCode() == AUTH_SUCCESS_CODE) { |
| | | authUser = (AuthUser) authResponse.getData(); |
| | | } else { |
| | | throw new InvalidGrantException("social grant failure, auth response is not success"); |
| | | } |
| | | |
| | | // 组装数据 |
| | | UserOauth userOauth = Objects.requireNonNull(BeanUtil.copy(authUser, UserOauth.class)); |
| | | userOauth.setSource(authUser.getSource()); |
| | | userOauth.setTenantId(tenantId); |
| | | userOauth.setUuid(authUser.getUuid()); |
| | | |
| | | // 远程调用,获取认证信息 |
| | | R<UserInfo> result = userClient.userAuthInfo(userOauth); |
| | | BladeUserDetails bladeUserDetails; |
| | | if (result.isSuccess()) { |
| | | User user = result.getData().getUser(); |
| | | Kv detail = result.getData().getDetail(); |
| | | if (user == null || user.getId() == null) { |
| | | throw new InvalidGrantException("social grant failure, user is null"); |
| | | } |
| | | bladeUserDetails = new BladeUserDetails(user.getId(), |
| | | tenantId, result.getData().getOauthId(), user.getName(), user.getRealName(), user.getDeptId(), user.getPostId(), user.getRoleId(), Func.join(result.getData().getRoles()), Func.toStr(userOauth.getAvatar(), TokenUtil.DEFAULT_AVATAR), |
| | | userOauth.getUsername(), AuthConstant.ENCRYPT + user.getPassword(), detail, true, true, true, true, |
| | | AuthorityUtils.commaSeparatedStringToAuthorityList(Func.join(result.getData().getRoles()))); |
| | | } else { |
| | | throw new InvalidGrantException("social grant failure, feign client return error"); |
| | | } |
| | | |
| | | // 组装认证数据,关闭密码校验 |
| | | Authentication userAuth = new UsernamePasswordAuthenticationToken(bladeUserDetails, null, bladeUserDetails.getAuthorities()); |
| | | ((AbstractAuthenticationToken) userAuth).setDetails(parameters); |
| | | OAuth2Request storedOAuth2Request = getRequestFactory().createOAuth2Request(client, tokenRequest); |
| | | |
| | | // 返回 OAuth2Authentication |
| | | return new OAuth2Authentication(storedOAuth2Request, userAuth); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.auth.service; |
| | | |
| | | import org.springframework.security.oauth2.provider.ClientDetails; |
| | | import org.springframework.security.oauth2.provider.client.JdbcClientDetailsService; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.sql.DataSource; |
| | | |
| | | /** |
| | | * 客户端信息 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Component |
| | | public class BladeClientDetailsServiceImpl extends JdbcClientDetailsService { |
| | | |
| | | public BladeClientDetailsServiceImpl(DataSource dataSource) { |
| | | super(dataSource); |
| | | } |
| | | |
| | | /** |
| | | * 缓存客户端信息 |
| | | * |
| | | * @param clientId 客户端id |
| | | */ |
| | | @Override |
| | | public ClientDetails loadClientByClientId(String clientId) { |
| | | try { |
| | | return super.loadClientByClientId(clientId); |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | return null; |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.auth.service; |
| | | |
| | | import lombok.Getter; |
| | | import org.springblade.core.tool.support.Kv; |
| | | import org.springframework.security.core.GrantedAuthority; |
| | | import org.springframework.security.core.userdetails.User; |
| | | |
| | | import java.util.Collection; |
| | | |
| | | /** |
| | | * 用户信息拓展 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Getter |
| | | public class BladeUserDetails extends User { |
| | | |
| | | /** |
| | | * 用户id |
| | | */ |
| | | private final Long userId; |
| | | /** |
| | | * 租户ID |
| | | */ |
| | | private final String tenantId; |
| | | /** |
| | | * 第三方认证ID |
| | | */ |
| | | private final String oauthId; |
| | | /** |
| | | * 昵称 |
| | | */ |
| | | private final String name; |
| | | /** |
| | | * 真名 |
| | | */ |
| | | private final String realName; |
| | | /** |
| | | * 账号 |
| | | */ |
| | | private final String account; |
| | | /** |
| | | * 部门id |
| | | */ |
| | | private final String deptId; |
| | | /** |
| | | * 岗位id |
| | | */ |
| | | private final String postId; |
| | | /** |
| | | * 角色id |
| | | */ |
| | | private final String roleId; |
| | | /** |
| | | * 角色名 |
| | | */ |
| | | private final String roleName; |
| | | /** |
| | | * 头像 |
| | | */ |
| | | private final String avatar; |
| | | /** |
| | | * 用户详情 |
| | | */ |
| | | private final Kv detail; |
| | | |
| | | public BladeUserDetails(Long userId, String tenantId, String oauthId, String name, String realName, String deptId, String postId, String roleId, String roleName, String avatar, String username, String password, Kv detail, boolean enabled, boolean accountNonExpired, boolean credentialsNonExpired, boolean accountNonLocked, Collection<? extends GrantedAuthority> authorities) { |
| | | super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities); |
| | | this.userId = userId; |
| | | this.tenantId = tenantId; |
| | | this.oauthId = oauthId; |
| | | this.name = name; |
| | | this.realName = realName; |
| | | this.account = username; |
| | | this.deptId = deptId; |
| | | this.postId = postId; |
| | | this.roleId = roleId; |
| | | this.roleName = roleName; |
| | | this.avatar = avatar; |
| | | this.detail = detail; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.auth.service; |
| | | |
| | | import cn.gistack.auth.constant.AuthConstant; |
| | | import com.alibaba.nacos.common.utils.StringUtils; |
| | | import io.jsonwebtoken.Claims; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.SneakyThrows; |
| | | import cn.gistack.auth.utils.TokenUtil; |
| | | import cn.gistack.common.cache.CacheNames; |
| | | import org.springblade.core.jwt.JwtUtil; |
| | | import org.springblade.core.jwt.props.JwtProperties; |
| | | import org.springblade.core.redis.cache.BladeRedis; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.*; |
| | | import cn.gistack.system.cache.ParamCache; |
| | | import cn.gistack.system.entity.Tenant; |
| | | import cn.gistack.system.feign.ISysClient; |
| | | import cn.gistack.system.user.entity.User; |
| | | import cn.gistack.system.user.entity.UserInfo; |
| | | import cn.gistack.system.user.enums.UserEnum; |
| | | import cn.gistack.system.user.feign.IUserClient; |
| | | import org.springframework.security.core.authority.AuthorityUtils; |
| | | import org.springframework.security.core.userdetails.UserDetailsService; |
| | | import org.springframework.security.core.userdetails.UsernameNotFoundException; |
| | | import org.springframework.security.oauth2.common.exceptions.UserDeniedAuthorizationException; |
| | | import org.springframework.stereotype.Service; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.time.Duration; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 用户信息 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class BladeUserDetailsServiceImpl implements UserDetailsService { |
| | | |
| | | public static final Integer FAIL_COUNT = 5; |
| | | public static final String FAIL_COUNT_VALUE = "account.failCount"; |
| | | |
| | | private final IUserClient userClient; |
| | | private final ISysClient sysClient; |
| | | |
| | | private final BladeRedis bladeRedis; |
| | | private final JwtProperties jwtProperties; |
| | | |
| | | @Override |
| | | @SneakyThrows |
| | | public BladeUserDetails loadUserByUsername(String username) { |
| | | HttpServletRequest request = WebUtil.getRequest(); |
| | | // 获取用户绑定ID |
| | | String headerDept = request.getHeader(TokenUtil.DEPT_HEADER_KEY); |
| | | String headerRole = request.getHeader(TokenUtil.ROLE_HEADER_KEY); |
| | | // 获取租户ID |
| | | String headerTenant = request.getHeader(TokenUtil.TENANT_HEADER_KEY); |
| | | String paramTenant = request.getParameter(TokenUtil.TENANT_PARAM_KEY); |
| | | String password = request.getParameter(TokenUtil.PASSWORD_KEY); |
| | | String grantType = request.getParameter(TokenUtil.GRANT_TYPE_KEY); |
| | | // 判断租户请求头 |
| | | if (StringUtil.isAllBlank(headerTenant, paramTenant)) { |
| | | throw new UserDeniedAuthorizationException(TokenUtil.TENANT_NOT_FOUND); |
| | | } |
| | | // 判断令牌合法性 |
| | | if (!judgeRefreshToken(grantType, request)) { |
| | | throw new UserDeniedAuthorizationException(TokenUtil.TOKEN_NOT_PERMISSION); |
| | | } |
| | | |
| | | // 指定租户ID |
| | | String tenantId = StringUtils.isBlank(headerTenant) ? paramTenant : headerTenant; |
| | | // 判断登录是否锁定 |
| | | int count = getFailCount(tenantId, username); |
| | | int failCount = Func.toInt(ParamCache.getValue(FAIL_COUNT_VALUE), FAIL_COUNT); |
| | | if (count >= failCount) { |
| | | throw new UserDeniedAuthorizationException(TokenUtil.USER_HAS_TOO_MANY_FAILS); |
| | | } |
| | | |
| | | // 获取租户信息 |
| | | R<Tenant> tenant = sysClient.getTenant(tenantId); |
| | | if (tenant.isSuccess()) { |
| | | if (TokenUtil.judgeTenant(tenant.getData())) { |
| | | throw new UserDeniedAuthorizationException(TokenUtil.USER_HAS_NO_TENANT_PERMISSION); |
| | | } |
| | | } else { |
| | | throw new UserDeniedAuthorizationException(TokenUtil.USER_HAS_NO_TENANT); |
| | | } |
| | | |
| | | // 获取用户类型 |
| | | String userType = Func.toStr(request.getHeader(TokenUtil.USER_TYPE_HEADER_KEY), TokenUtil.DEFAULT_USER_TYPE); |
| | | |
| | | // 远程调用返回数据 |
| | | R<UserInfo> result; |
| | | // 根据不同用户类型调用对应的接口返回数据,用户可自行拓展 |
| | | if (userType.equals(UserEnum.WEB.getName())) { |
| | | result = userClient.userInfo(tenantId, username, UserEnum.WEB.getName()); |
| | | } else if (userType.equals(UserEnum.APP.getName())) { |
| | | result = userClient.userInfo(tenantId, username, UserEnum.APP.getName()); |
| | | } else { |
| | | result = userClient.userInfo(tenantId, username, UserEnum.OTHER.getName()); |
| | | } |
| | | |
| | | // 判断返回信息 |
| | | if (result.isSuccess()) { |
| | | UserInfo userInfo = result.getData(); |
| | | User user = userInfo.getUser(); |
| | | // 用户不存在,但提示用户名与密码错误并锁定账号 |
| | | if (user == null || user.getId() == null) { |
| | | setFailCount(tenantId, username, count); |
| | | throw new UsernameNotFoundException(TokenUtil.USER_NOT_FOUND); |
| | | } |
| | | // 用户存在但密码错误,超过次数则锁定账号 |
| | | if (grantType != null && !grantType.equals(TokenUtil.REFRESH_TOKEN_KEY) && !user.getPassword().equals(DigestUtil.hex(password))) { |
| | | setFailCount(tenantId, username, count); |
| | | throw new UsernameNotFoundException(TokenUtil.USER_NOT_FOUND); |
| | | } |
| | | // 用户角色不存在 |
| | | if (Func.isEmpty(userInfo.getRoles())) { |
| | | throw new UserDeniedAuthorizationException(TokenUtil.USER_HAS_NO_ROLE); |
| | | } |
| | | // 多部门情况下指定单部门 |
| | | if (Func.isNotEmpty(headerDept) && user.getDeptId().contains(headerDept)) { |
| | | user.setDeptId(headerDept); |
| | | } |
| | | // 多角色情况下指定单角色 |
| | | if (Func.isNotEmpty(headerRole) && user.getRoleId().contains(headerRole)) { |
| | | R<List<String>> roleResult = sysClient.getRoleAliases(headerRole); |
| | | if (roleResult.isSuccess()) { |
| | | userInfo.setRoles(roleResult.getData()); |
| | | } |
| | | user.setRoleId(headerRole); |
| | | } |
| | | // 成功则清除登录错误次数 |
| | | delFailCount(tenantId, username); |
| | | return new BladeUserDetails(user.getId(), |
| | | user.getTenantId(), StringPool.EMPTY, user.getName(), user.getRealName(), user.getDeptId(), user.getPostId(), user.getRoleId(), Func.join(userInfo.getRoles()), Func.toStr(user.getAvatar(), TokenUtil.DEFAULT_AVATAR), |
| | | username, AuthConstant.ENCRYPT + user.getPassword(), userInfo.getDetail(), true, true, true, true, |
| | | AuthorityUtils.commaSeparatedStringToAuthorityList(Func.join(result.getData().getRoles()))); |
| | | } else { |
| | | throw new UsernameNotFoundException(result.getMsg()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取账号错误次数 |
| | | * |
| | | * @param tenantId 租户id |
| | | * @param username 账号 |
| | | * @return int |
| | | */ |
| | | private int getFailCount(String tenantId, String username) { |
| | | return Func.toInt(bladeRedis.get(CacheNames.tenantKey(tenantId, CacheNames.USER_FAIL_KEY, username)), 0); |
| | | } |
| | | |
| | | /** |
| | | * 设置账号错误次数 |
| | | * |
| | | * @param tenantId 租户id |
| | | * @param username 账号 |
| | | * @param count 次数 |
| | | */ |
| | | private void setFailCount(String tenantId, String username, int count) { |
| | | bladeRedis.setEx(CacheNames.tenantKey(tenantId, CacheNames.USER_FAIL_KEY, username), count + 1, Duration.ofMinutes(30)); |
| | | } |
| | | |
| | | /** |
| | | * 清空账号错误次数 |
| | | * |
| | | * @param tenantId 租户id |
| | | * @param username 账号 |
| | | */ |
| | | private void delFailCount(String tenantId, String username) { |
| | | bladeRedis.del(CacheNames.tenantKey(tenantId, CacheNames.USER_FAIL_KEY, username)); |
| | | } |
| | | |
| | | /** |
| | | * 校验refreshToken合法性 |
| | | * |
| | | * @param grantType 认证类型 |
| | | * @param request 请求 |
| | | */ |
| | | private boolean judgeRefreshToken(String grantType, HttpServletRequest request) { |
| | | if (jwtProperties.getState() && jwtProperties.getSingle() && StringUtil.equals(grantType, TokenUtil.REFRESH_TOKEN_KEY)) { |
| | | String refreshToken = request.getParameter(TokenUtil.REFRESH_TOKEN_KEY); |
| | | Claims claims = JwtUtil.parseJWT(refreshToken); |
| | | String tenantId = String.valueOf(claims.get("tenant_id")); |
| | | String userId = String.valueOf(claims.get("user_id")); |
| | | String token = JwtUtil.getRefreshToken(tenantId, userId, refreshToken); |
| | | return StringUtil.equalsIgnoreCase(token, refreshToken); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.auth.support; |
| | | |
| | | import cn.gistack.auth.service.BladeUserDetails; |
| | | import lombok.AllArgsConstructor; |
| | | import cn.gistack.auth.utils.TokenUtil; |
| | | import org.springblade.core.jwt.JwtUtil; |
| | | import org.springblade.core.jwt.props.JwtProperties; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken; |
| | | import org.springframework.security.oauth2.common.OAuth2AccessToken; |
| | | import org.springframework.security.oauth2.common.OAuth2RefreshToken; |
| | | import org.springframework.security.oauth2.provider.OAuth2Authentication; |
| | | import org.springframework.security.oauth2.provider.token.TokenEnhancer; |
| | | import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * jwt返回参数增强 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @AllArgsConstructor |
| | | public class BladeJwtTokenEnhancer implements TokenEnhancer { |
| | | |
| | | private final JwtAccessTokenConverter jwtAccessTokenConverter; |
| | | private final JwtProperties jwtProperties; |
| | | |
| | | @Override |
| | | public OAuth2AccessToken enhance(OAuth2AccessToken accessToken, OAuth2Authentication authentication) { |
| | | BladeUserDetails principal = (BladeUserDetails) authentication.getUserAuthentication().getPrincipal(); |
| | | |
| | | //token参数增强 |
| | | Map<String, Object> info = new HashMap<>(16); |
| | | info.put(TokenUtil.CLIENT_ID, TokenUtil.getClientIdFromHeader()); |
| | | info.put(TokenUtil.USER_ID, Func.toStr(principal.getUserId())); |
| | | info.put(TokenUtil.DEPT_ID, Func.toStr(principal.getDeptId())); |
| | | info.put(TokenUtil.POST_ID, Func.toStr(principal.getPostId())); |
| | | info.put(TokenUtil.ROLE_ID, Func.toStr(principal.getRoleId())); |
| | | info.put(TokenUtil.TENANT_ID, principal.getTenantId()); |
| | | info.put(TokenUtil.OAUTH_ID, principal.getOauthId()); |
| | | info.put(TokenUtil.ACCOUNT, principal.getAccount()); |
| | | info.put(TokenUtil.USER_NAME, principal.getUsername()); |
| | | info.put(TokenUtil.NICK_NAME, principal.getName()); |
| | | info.put(TokenUtil.REAL_NAME, principal.getRealName()); |
| | | info.put(TokenUtil.ROLE_NAME, principal.getRoleName()); |
| | | info.put(TokenUtil.AVATAR, principal.getAvatar()); |
| | | info.put(TokenUtil.DETAIL, principal.getDetail()); |
| | | info.put(TokenUtil.LICENSE, TokenUtil.LICENSE_NAME); |
| | | ((DefaultOAuth2AccessToken) accessToken).setAdditionalInformation(info); |
| | | |
| | | //token状态设置 |
| | | if (jwtProperties.getState()) { |
| | | OAuth2AccessToken oAuth2AccessToken = jwtAccessTokenConverter.enhance(accessToken, authentication); |
| | | String accessTokenValue = oAuth2AccessToken.getValue(); |
| | | String tenantId = principal.getTenantId(); |
| | | String userId = Func.toStr(principal.getUserId()); |
| | | JwtUtil.addAccessToken(tenantId, userId, accessTokenValue, accessToken.getExpiresIn()); |
| | | |
| | | if (jwtProperties.getSingle()) { |
| | | OAuth2RefreshToken oAuth2RefreshToken = oAuth2AccessToken.getRefreshToken(); |
| | | String refreshTokenValue = oAuth2RefreshToken.getValue(); |
| | | JwtUtil.addRefreshToken(tenantId, userId, refreshTokenValue, accessToken.getExpiresIn() * 168); |
| | | } |
| | | } |
| | | |
| | | return accessToken; |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.auth.support; |
| | | |
| | | import org.springframework.security.crypto.password.PasswordEncoder; |
| | | |
| | | /** |
| | | * 无密码加密 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class BladeNoOpPasswordEncoder implements PasswordEncoder { |
| | | |
| | | @Override |
| | | public String encode(CharSequence rawPassword) { |
| | | return rawPassword.toString(); |
| | | } |
| | | |
| | | @Override |
| | | public boolean matches(CharSequence rawPassword, String encodedPassword) { |
| | | return rawPassword.toString().equals(encodedPassword); |
| | | } |
| | | |
| | | /** |
| | | * Get the singleton {@link BladeNoOpPasswordEncoder}. |
| | | */ |
| | | public static PasswordEncoder getInstance() { |
| | | return INSTANCE; |
| | | } |
| | | |
| | | private static final PasswordEncoder INSTANCE = new BladeNoOpPasswordEncoder(); |
| | | |
| | | private BladeNoOpPasswordEncoder() { |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.auth.support; |
| | | |
| | | import org.springblade.core.tool.utils.DigestUtil; |
| | | import org.springframework.security.crypto.password.PasswordEncoder; |
| | | |
| | | /** |
| | | * 自定义密码加密 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class BladePasswordEncoder implements PasswordEncoder { |
| | | |
| | | @Override |
| | | public String encode(CharSequence rawPassword) { |
| | | return DigestUtil.hex((String) rawPassword); |
| | | } |
| | | |
| | | @Override |
| | | public boolean matches(CharSequence rawPassword, String encodedPassword) { |
| | | return encodedPassword.equals(encode(rawPassword)); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2002-2017 the original author or authors. |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * https://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package cn.gistack.auth.support; |
| | | |
| | | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; |
| | | import org.springframework.security.crypto.password.DelegatingPasswordEncoder; |
| | | import org.springframework.security.crypto.password.PasswordEncoder; |
| | | import org.springframework.security.crypto.password.Pbkdf2PasswordEncoder; |
| | | import org.springframework.security.crypto.scrypt.SCryptPasswordEncoder; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 自定义密码工厂 |
| | | * |
| | | * @author Rob Winch, Chill |
| | | * @since 5.0 |
| | | */ |
| | | public class BladePasswordEncoderFactories { |
| | | |
| | | /** |
| | | * Creates a {@link DelegatingPasswordEncoder} with default mappings. Additional |
| | | * mappings may be added and the encoding will be updated to conform with best |
| | | * practices. However, due to the nature of {@link DelegatingPasswordEncoder} the |
| | | * updates should not impact users. The mappings current are: |
| | | * |
| | | * <ul> |
| | | * <li>blade - {@link BladePasswordEncoder} (sha1(md5("password")))</li> |
| | | * <li>bcrypt - {@link BCryptPasswordEncoder} (Also used for encoding)</li> |
| | | * <li>noop - {@link BladeNoOpPasswordEncoder}</li> |
| | | * <li>pbkdf2 - {@link Pbkdf2PasswordEncoder}</li> |
| | | * <li>scrypt - {@link SCryptPasswordEncoder}</li> |
| | | * </ul> |
| | | * |
| | | * @return the {@link PasswordEncoder} to use |
| | | */ |
| | | public static PasswordEncoder createDelegatingPasswordEncoder() { |
| | | String encodingId = "blade"; |
| | | Map<String, PasswordEncoder> encoders = new HashMap<>(16); |
| | | encoders.put(encodingId, new BladePasswordEncoder()); |
| | | encoders.put("bcrypt", new BCryptPasswordEncoder()); |
| | | encoders.put("noop", BladeNoOpPasswordEncoder.getInstance()); |
| | | encoders.put("pbkdf2", new Pbkdf2PasswordEncoder()); |
| | | encoders.put("scrypt", new SCryptPasswordEncoder()); |
| | | |
| | | return new DelegatingPasswordEncoder(encodingId, encoders); |
| | | } |
| | | |
| | | private BladePasswordEncoderFactories() { |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.auth.utils; |
| | | |
| | | import lombok.SneakyThrows; |
| | | import cn.gistack.common.constant.TenantConstant; |
| | | import org.springblade.core.launch.constant.TokenConstant; |
| | | import org.springblade.core.tenant.BladeTenantProperties; |
| | | import org.springblade.core.tool.constant.BladeConstant; |
| | | import org.springblade.core.tool.jackson.JsonUtil; |
| | | import org.springblade.core.tool.utils.*; |
| | | import cn.gistack.system.entity.Tenant; |
| | | import org.springframework.security.authentication.BadCredentialsException; |
| | | import org.springframework.security.oauth2.common.exceptions.UnapprovedClientAuthenticationException; |
| | | import org.springframework.security.oauth2.common.exceptions.UserDeniedAuthorizationException; |
| | | |
| | | import java.util.Base64; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 认证工具类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class TokenUtil { |
| | | |
| | | public final static String AVATAR = TokenConstant.AVATAR; |
| | | public final static String ACCOUNT = TokenConstant.ACCOUNT; |
| | | public final static String USER_NAME = TokenConstant.USER_NAME; |
| | | public final static String NICK_NAME = TokenConstant.NICK_NAME; |
| | | public final static String REAL_NAME = TokenConstant.REAL_NAME; |
| | | public final static String USER_ID = TokenConstant.USER_ID; |
| | | public final static String DEPT_ID = TokenConstant.DEPT_ID; |
| | | public final static String POST_ID = TokenConstant.POST_ID; |
| | | public final static String ROLE_ID = TokenConstant.ROLE_ID; |
| | | public final static String ROLE_NAME = TokenConstant.ROLE_NAME; |
| | | public final static String TENANT_ID = TokenConstant.TENANT_ID; |
| | | public final static String OAUTH_ID = TokenConstant.OAUTH_ID; |
| | | public final static String CLIENT_ID = TokenConstant.CLIENT_ID; |
| | | public final static String DETAIL = TokenConstant.DETAIL; |
| | | public final static String LICENSE = TokenConstant.LICENSE; |
| | | public final static String LICENSE_NAME = TokenConstant.LICENSE_NAME; |
| | | |
| | | public final static String DEPT_HEADER_KEY = "Dept-Id"; |
| | | public final static String ROLE_HEADER_KEY = "Role-Id"; |
| | | public final static String CAPTCHA_HEADER_KEY = "Captcha-Key"; |
| | | public final static String CAPTCHA_HEADER_CODE = "Captcha-Code"; |
| | | public final static String CAPTCHA_NOT_CORRECT = "验证码不正确"; |
| | | public final static String TENANT_HEADER_KEY = "Tenant-Id"; |
| | | public final static String TENANT_PARAM_KEY = "tenant_id"; |
| | | public final static String DEFAULT_TENANT_ID = "000000"; |
| | | public final static String TENANT_NOT_FOUND = "租户ID未找到"; |
| | | public final static String USER_TYPE_HEADER_KEY = "User-Type"; |
| | | public final static String DEFAULT_USER_TYPE = "web"; |
| | | public final static String TOKEN_NOT_PERMISSION = "令牌授权已过期"; |
| | | public final static String USER_NOT_FOUND = "用户名或密码错误"; |
| | | public final static String USER_HAS_NO_ROLE = "未获得用户的角色信息"; |
| | | public final static String USER_HAS_NO_TENANT = "未获得用户的租户信息"; |
| | | public final static String USER_HAS_NO_TENANT_PERMISSION = "租户授权已过期,请联系管理员"; |
| | | public final static String USER_HAS_TOO_MANY_FAILS = "登录错误次数过多,请稍后再试"; |
| | | public final static String HEADER_KEY = "Authorization"; |
| | | public final static String HEADER_PREFIX = "Basic "; |
| | | public final static String DEFAULT_AVATAR = ""; |
| | | public final static String PASSWORD_KEY = "password"; |
| | | public final static String GRANT_TYPE_KEY = "grant_type"; |
| | | public final static String REFRESH_TOKEN_KEY = "refresh_token"; |
| | | |
| | | private static BladeTenantProperties tenantProperties; |
| | | |
| | | /** |
| | | * 获取租户配置 |
| | | * |
| | | * @return tenantProperties |
| | | */ |
| | | private static BladeTenantProperties getTenantProperties() { |
| | | if (tenantProperties == null) { |
| | | tenantProperties = SpringUtil.getBean(BladeTenantProperties.class); |
| | | } |
| | | return tenantProperties; |
| | | } |
| | | |
| | | /** |
| | | * 解码 |
| | | */ |
| | | @SneakyThrows |
| | | public static String[] extractAndDecodeHeader() { |
| | | String header = WebUtil.getRequest().getHeader(TokenUtil.HEADER_KEY); |
| | | if (header == null || !header.startsWith(TokenUtil.HEADER_PREFIX)) { |
| | | throw new UnapprovedClientAuthenticationException("请求头中无client信息"); |
| | | } |
| | | |
| | | byte[] base64Token = header.substring(6).getBytes(Charsets.UTF_8_NAME); |
| | | |
| | | byte[] decoded; |
| | | try { |
| | | decoded = Base64.getDecoder().decode(base64Token); |
| | | } catch (IllegalArgumentException var7) { |
| | | throw new BadCredentialsException("Failed to decode basic authentication token"); |
| | | } |
| | | |
| | | String token = new String(decoded, Charsets.UTF_8_NAME); |
| | | int index = token.indexOf(StringPool.COLON); |
| | | if (index == -1) { |
| | | throw new BadCredentialsException("Invalid basic authentication token"); |
| | | } else { |
| | | return new String[]{token.substring(0, index), token.substring(index + 1)}; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取请求头中的客户端id |
| | | */ |
| | | public static String getClientIdFromHeader() { |
| | | String[] tokens = extractAndDecodeHeader(); |
| | | return tokens[0]; |
| | | } |
| | | |
| | | /** |
| | | * 获取token过期时间(次日凌晨3点) |
| | | * |
| | | * @return expire |
| | | */ |
| | | public static int getTokenValiditySecond() { |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.add(Calendar.DAY_OF_YEAR, 1); |
| | | cal.set(Calendar.HOUR_OF_DAY, 3); |
| | | cal.set(Calendar.SECOND, 0); |
| | | cal.set(Calendar.MINUTE, 0); |
| | | cal.set(Calendar.MILLISECOND, 0); |
| | | return (int) (cal.getTimeInMillis() - System.currentTimeMillis()) / 1000; |
| | | } |
| | | |
| | | /** |
| | | * 获取refreshToken过期时间 |
| | | * |
| | | * @return expire |
| | | */ |
| | | public static int getRefreshTokenValiditySeconds() { |
| | | return 60 * 60 * 24 * 15; |
| | | } |
| | | |
| | | /** |
| | | * 判断租户权限 |
| | | * |
| | | * @param tenant 租户信息 |
| | | * @return boolean |
| | | */ |
| | | public static boolean judgeTenant(Tenant tenant) { |
| | | if (tenant == null || tenant.getId() == null) { |
| | | throw new UserDeniedAuthorizationException(TokenUtil.USER_HAS_NO_TENANT); |
| | | } |
| | | if (StringUtil.equalsIgnoreCase(tenant.getTenantId(), BladeConstant.ADMIN_TENANT_ID)) { |
| | | return false; |
| | | } |
| | | Date expireTime = tenant.getExpireTime(); |
| | | if (getTenantProperties().getLicense()) { |
| | | String licenseKey = tenant.getLicenseKey(); |
| | | String decrypt = DesUtil.decryptFormHex(licenseKey, TenantConstant.DES_KEY); |
| | | expireTime = JsonUtil.parse(decrypt, Tenant.class).getExpireTime(); |
| | | } |
| | | if (expireTime != null && expireTime.before(DateUtil.now())) { |
| | | throw new UserDeniedAuthorizationException(TokenUtil.USER_HAS_NO_TENANT_PERMISSION); |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <project xmlns="http://maven.apache.org/POM/4.0.0" |
| | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| | | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| | | <parent> |
| | | <artifactId>skjcmanager</artifactId> |
| | | <groupId>org.springblade</groupId> |
| | | <version>3.0.1.RELEASE</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | | <artifactId>skjcmanager-common</artifactId> |
| | | <name>${project.artifactId}</name> |
| | | <version>${bladex.project.version}</version> |
| | | <packaging>jar</packaging> |
| | | |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>blade-core-launch</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>blade-starter-loadbalancer</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>blade-core-auto</artifactId> |
| | | <scope>provided</scope> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | <build> |
| | | <plugins> |
| | | <plugin> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-maven-plugin</artifactId> |
| | | <configuration> |
| | | <skip>true</skip> |
| | | <finalName>${project.name}</finalName> |
| | | </configuration> |
| | | </plugin> |
| | | </plugins> |
| | | </build> |
| | | |
| | | </project> |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.common.cache; |
| | | |
| | | /** |
| | | * 缓存名 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface CacheNames { |
| | | |
| | | /** |
| | | * 返回拼接后的key |
| | | * |
| | | * @param cacheKey 缓存key |
| | | * @param cacheKeyValue 缓存key值 |
| | | * @return tenantKey |
| | | */ |
| | | static String cacheKey(String cacheKey, String cacheKeyValue) { |
| | | return cacheKey.concat(cacheKeyValue); |
| | | } |
| | | |
| | | /** |
| | | * 返回租户格式的key |
| | | * |
| | | * @param tenantId 租户编号 |
| | | * @param cacheKey 缓存key |
| | | * @param cacheKeyValue 缓存key值 |
| | | * @return tenantKey |
| | | */ |
| | | static String tenantKey(String tenantId, String cacheKey, String cacheKeyValue) { |
| | | return tenantId.concat(":").concat(cacheKey).concat(cacheKeyValue); |
| | | } |
| | | |
| | | /** |
| | | * 验证码key |
| | | */ |
| | | String CAPTCHA_KEY = "blade:auth::blade:captcha:"; |
| | | |
| | | /** |
| | | * 登录失败key |
| | | */ |
| | | String USER_FAIL_KEY = "blade:user::blade:fail:"; |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.common.config; |
| | | |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | /** |
| | | * 公共封装包配置类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Configuration(proxyBeanMethods = false) |
| | | @AllArgsConstructor |
| | | public class BladeCommonConfiguration { |
| | | |
| | | } |
| New file |
| | |
| | | package cn.gistack.common.constant; |
| | | |
| | | public interface AppsConstant { |
| | | |
| | | String APPLICATION_VERSION = "3.0.1.RELEASE"; |
| | | String BASE_PACKAGES = "cn.skjcmanager"; |
| | | String APPLICATION_NAME_PREFIX = "skjcmanager-"; |
| | | String APPLICATION_GATEWAY_NAME = "skjcmanager-gateway"; |
| | | String APPLICATION_AUTH_NAME = "skjcmanager-auth"; |
| | | String APPLICATION_ADMIN_NAME = "skjcmanager-admin"; |
| | | String APPLICATION_REPORT_NAME = "skjcmanager-report"; |
| | | String APPLICATION_TURBINE_NAME = "skjcmanager-turbine"; |
| | | String APPLICATION_ZIPKIN_NAME = "skjcmanager-zipkin"; |
| | | String APPLICATION_WEBSOCKET_NAME = "skjcmanager-websocket"; |
| | | String APPLICATION_DESK_NAME = "skjcmanager-desk"; |
| | | String APPLICATION_SYSTEM_NAME = "skjcmanager-system"; |
| | | String APPLICATION_USER_NAME = "skjcmanager-user"; |
| | | String APPLICATION_LOG_NAME = "skjcmanager-log"; |
| | | String APPLICATION_DEVELOP_NAME = "skjcmanager-develop"; |
| | | String APPLICATION_FLOWDESIGN_NAME = "skjcmanager-flowdesign"; |
| | | String APPLICATION_FLOW_NAME = "skjcmanager-flow"; |
| | | String APPLICATION_RESOURCE_NAME = "skjcmanager-resource"; |
| | | String APPLICATION_SWAGGER_NAME = "skjcmanager-swagger"; |
| | | String APPLICATION_TEST_NAME = "skjcmanager-test"; |
| | | String APPLICATION_DEMO_NAME = "skjcmanager-demo"; |
| | | String DEV_CODE = "dev"; |
| | | String PROD_CODE = "prod"; |
| | | String TEST_CODE = "test"; |
| | | String OS_NAME_LINUX = "LINUX"; |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.common.constant; |
| | | |
| | | /** |
| | | * 通用常量 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface CommonConstant { |
| | | |
| | | /** |
| | | * sword 系统名 |
| | | */ |
| | | String SWORD_NAME = "sword"; |
| | | |
| | | /** |
| | | * saber 系统名 |
| | | */ |
| | | String SABER_NAME = "saber"; |
| | | |
| | | /** |
| | | * 顶级父节点id |
| | | */ |
| | | Long TOP_PARENT_ID = 0L; |
| | | |
| | | /** |
| | | * 顶级父节点名称 |
| | | */ |
| | | String TOP_PARENT_NAME = "顶级"; |
| | | |
| | | /** |
| | | * 未封存状态值 |
| | | */ |
| | | Integer NOT_SEALED_ID = 0; |
| | | |
| | | /** |
| | | * 默认密码 |
| | | */ |
| | | String DEFAULT_PASSWORD = "123456"; |
| | | |
| | | /** |
| | | * 默认密码参数值 |
| | | */ |
| | | String DEFAULT_PARAM_PASSWORD = "account.initPassword"; |
| | | |
| | | /** |
| | | * 默认排序字段 |
| | | */ |
| | | String SORT_FIELD = "sort"; |
| | | |
| | | /** |
| | | * 数据权限类型 |
| | | */ |
| | | Integer DATA_SCOPE_CATEGORY = 1; |
| | | |
| | | /** |
| | | * 接口权限类型 |
| | | */ |
| | | Integer API_SCOPE_CATEGORY = 2; |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.common.constant; |
| | | |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | |
| | | import static org.springblade.core.launch.constant.AppConstant.APPLICATION_NAME_PREFIX; |
| | | |
| | | /** |
| | | * 启动常量 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface LauncherConstant { |
| | | |
| | | /** |
| | | * xxljob |
| | | */ |
| | | String APPLICATION_XXLJOB_NAME = APPLICATION_NAME_PREFIX + "xxljob"; |
| | | |
| | | /** |
| | | * xxljob |
| | | */ |
| | | String APPLICATION_XXLJOB_ADMIN_NAME = APPLICATION_NAME_PREFIX + "xxljob-admin"; |
| | | |
| | | /** |
| | | * nacos dev 地址 |
| | | */ |
| | | String NACOS_DEV_ADDR = "172.16.13.144:8848"; |
| | | |
| | | /** |
| | | * nacos prod 地址 |
| | | */ |
| | | String NACOS_PROD_ADDR = "172.30.0.48:8848"; |
| | | |
| | | /** |
| | | * nacos test 地址 |
| | | */ |
| | | String NACOS_TEST_ADDR = "172.30.0.48:8848"; |
| | | |
| | | /** |
| | | * sentinel dev 地址 |
| | | */ |
| | | String SENTINEL_DEV_ADDR = "127.0.0.1:8858"; |
| | | |
| | | /** |
| | | * sentinel prod 地址 |
| | | */ |
| | | String SENTINEL_PROD_ADDR = "172.30.0.58:8858"; |
| | | |
| | | /** |
| | | * sentinel test 地址 |
| | | */ |
| | | String SENTINEL_TEST_ADDR = "172.30.0.58:8858"; |
| | | |
| | | /** |
| | | * seata dev 地址 |
| | | */ |
| | | String SEATA_DEV_ADDR = "127.0.0.1:8091"; |
| | | |
| | | /** |
| | | * seata prod 地址 |
| | | */ |
| | | String SEATA_PROD_ADDR = "172.30.0.68:8091"; |
| | | |
| | | /** |
| | | * seata test 地址 |
| | | */ |
| | | String SEATA_TEST_ADDR = "172.30.0.68:8091"; |
| | | |
| | | /** |
| | | * zipkin dev 地址 |
| | | */ |
| | | String ZIPKIN_DEV_ADDR = "http://127.0.0.1:9411"; |
| | | |
| | | /** |
| | | * zipkin prod 地址 |
| | | */ |
| | | String ZIPKIN_PROD_ADDR = "http://172.30.0.71:9411"; |
| | | |
| | | /** |
| | | * zipkin test 地址 |
| | | */ |
| | | String ZIPKIN_TEST_ADDR = "http://172.30.0.71:9411"; |
| | | |
| | | /** |
| | | * elk dev 地址 |
| | | */ |
| | | String ELK_DEV_ADDR = "127.0.0.1:9000"; |
| | | |
| | | /** |
| | | * elk prod 地址 |
| | | */ |
| | | String ELK_PROD_ADDR = "172.30.0.72:9000"; |
| | | |
| | | /** |
| | | * elk test 地址 |
| | | */ |
| | | String ELK_TEST_ADDR = "172.30.0.72:9000"; |
| | | |
| | | /** |
| | | * seata file模式 |
| | | */ |
| | | String FILE_MODE = "file"; |
| | | |
| | | /** |
| | | * seata nacos模式 |
| | | */ |
| | | String NACOS_MODE = "nacos"; |
| | | |
| | | /** |
| | | * seata default模式 |
| | | */ |
| | | String DEFAULT_MODE = "default"; |
| | | |
| | | /** |
| | | * seata group后缀 |
| | | */ |
| | | String GROUP_NAME = "-group"; |
| | | |
| | | /** |
| | | * seata 服务组格式 |
| | | * |
| | | * @param appName 服务名 |
| | | * @return group |
| | | */ |
| | | static String seataServiceGroup(String appName) { |
| | | return appName.concat(GROUP_NAME); |
| | | } |
| | | |
| | | /** |
| | | * 动态获取nacos地址 |
| | | * |
| | | * @param profile 环境变量 |
| | | * @return addr |
| | | */ |
| | | static String nacosAddr(String profile) { |
| | | switch (profile) { |
| | | case (AppConstant.PROD_CODE): |
| | | return NACOS_PROD_ADDR; |
| | | case (AppConstant.TEST_CODE): |
| | | return NACOS_TEST_ADDR; |
| | | default: |
| | | return NACOS_DEV_ADDR; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 动态获取sentinel地址 |
| | | * |
| | | * @param profile 环境变量 |
| | | * @return addr |
| | | */ |
| | | static String sentinelAddr(String profile) { |
| | | switch (profile) { |
| | | case (AppConstant.PROD_CODE): |
| | | return SENTINEL_PROD_ADDR; |
| | | case (AppConstant.TEST_CODE): |
| | | return SENTINEL_TEST_ADDR; |
| | | default: |
| | | return SENTINEL_DEV_ADDR; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 动态获取seata地址 |
| | | * |
| | | * @param profile 环境变量 |
| | | * @return addr |
| | | */ |
| | | static String seataAddr(String profile) { |
| | | switch (profile) { |
| | | case (AppConstant.PROD_CODE): |
| | | return SEATA_PROD_ADDR; |
| | | case (AppConstant.TEST_CODE): |
| | | return SEATA_TEST_ADDR; |
| | | default: |
| | | return SEATA_DEV_ADDR; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 动态获取zipkin地址 |
| | | * |
| | | * @param profile 环境变量 |
| | | * @return addr |
| | | */ |
| | | static String zipkinAddr(String profile) { |
| | | switch (profile) { |
| | | case (AppConstant.PROD_CODE): |
| | | return ZIPKIN_PROD_ADDR; |
| | | case (AppConstant.TEST_CODE): |
| | | return ZIPKIN_TEST_ADDR; |
| | | default: |
| | | return ZIPKIN_DEV_ADDR; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 动态获取elk地址 |
| | | * |
| | | * @param profile 环境变量 |
| | | * @return addr |
| | | */ |
| | | static String elkAddr(String profile) { |
| | | switch (profile) { |
| | | case (AppConstant.PROD_CODE): |
| | | return ELK_PROD_ADDR; |
| | | case (AppConstant.TEST_CODE): |
| | | return ELK_TEST_ADDR; |
| | | default: |
| | | return ELK_DEV_ADDR; |
| | | } |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.common.constant; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 租户常量 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface TenantConstant { |
| | | |
| | | /** |
| | | * 租户默认密码KEY |
| | | */ |
| | | String PASSWORD_KEY = "tenant.default.password"; |
| | | |
| | | /** |
| | | * 租户默认账号额度KEY |
| | | */ |
| | | String ACCOUNT_NUMBER_KEY = "tenant.default.accountNumber"; |
| | | |
| | | /** |
| | | * 租户默认菜单集合KEY |
| | | */ |
| | | String ACCOUNT_MENU_CODE_KEY = "tenant.default.menuCode"; |
| | | |
| | | /** |
| | | * 租户默认密码 |
| | | */ |
| | | String DEFAULT_PASSWORD = "123456"; |
| | | |
| | | /** |
| | | * 租户授权码默认16位密钥 |
| | | */ |
| | | String DES_KEY = "0000000000000000"; |
| | | |
| | | /** |
| | | * 租户默认账号额度 |
| | | */ |
| | | Integer DEFAULT_ACCOUNT_NUMBER = -1; |
| | | |
| | | /** |
| | | * 租户默认菜单集合 |
| | | */ |
| | | List<String> MENU_CODES = Arrays.asList( |
| | | "desk", "flow", "work", "monitor", "resource", "role", "user", "dept", "dictbiz", "topmenu" |
| | | ); |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.common.launch; |
| | | |
| | | import cn.gistack.common.constant.LauncherConstant; |
| | | import org.springblade.core.auto.service.AutoService; |
| | | import org.springblade.core.launch.service.LauncherService; |
| | | import org.springblade.core.launch.utils.PropsUtil; |
| | | import org.springframework.boot.builder.SpringApplicationBuilder; |
| | | |
| | | import java.util.Properties; |
| | | |
| | | /** |
| | | * 启动参数拓展 |
| | | * |
| | | * @author smallchil |
| | | */ |
| | | @AutoService(LauncherService.class) |
| | | public class LauncherServiceImpl implements LauncherService { |
| | | |
| | | @Override |
| | | public void launcher(SpringApplicationBuilder builder, String appName, String profile, boolean isLocalDev) { |
| | | Properties props = System.getProperties(); |
| | | // 通用注册 |
| | | PropsUtil.setProperty(props, "spring.cloud.nacos.discovery.server-addr", LauncherConstant.nacosAddr(profile)); |
| | | PropsUtil.setProperty(props, "spring.cloud.nacos.config.server-addr", LauncherConstant.nacosAddr(profile)); |
| | | PropsUtil.setProperty(props, "spring.cloud.sentinel.transport.dashboard", LauncherConstant.sentinelAddr(profile)); |
| | | PropsUtil.setProperty(props, "spring.zipkin.base-url", LauncherConstant.zipkinAddr(profile)); |
| | | PropsUtil.setProperty(props, "spring.datasource.dynamic.enabled", "false"); |
| | | |
| | | // 开启elk日志 |
| | | // PropsUtil.setProperty(props, "blade.log.elk.destination", LauncherConstant.elkAddr(profile)); |
| | | |
| | | // seata注册地址 |
| | | // PropsUtil.setProperty(props, "seata.service.grouplist.default", LauncherConstant.seataAddr(profile)); |
| | | // seata注册group格式 |
| | | // PropsUtil.setProperty(props, "seata.tx-service-group", LauncherConstant.seataServiceGroup(appName)); |
| | | // seata配置服务group |
| | | // PropsUtil.setProperty(props, "seata.service.vgroup-mapping.".concat(LauncherConstant.seataServiceGroup(appName)), LauncherConstant.DEFAULT_MODE); |
| | | // seata注册模式配置 |
| | | // PropsUtil.setProperty(props, "seata.registry.type", LauncherConstant.NACOS_MODE); |
| | | // PropsUtil.setProperty(props, "seata.registry.nacos.server-addr", LauncherConstant.nacosAddr(profile)); |
| | | // PropsUtil.setProperty(props, "seata.config.type", LauncherConstant.NACOS_MODE); |
| | | // PropsUtil.setProperty(props, "seata.config.nacos.server-addr", LauncherConstant.nacosAddr(profile)); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.common.utils; |
| | | |
| | | /** |
| | | * 通用工具类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class CommonUtil { |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <project xmlns="http://maven.apache.org/POM/4.0.0" |
| | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| | | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| | | <parent> |
| | | <artifactId>skjcmanager</artifactId> |
| | | <groupId>org.springblade</groupId> |
| | | <version>3.0.1.RELEASE</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | | <artifactId>skjcmanager-gateway</artifactId> |
| | | <name>${project.artifactId}</name> |
| | | <version>${bladex.project.version}</version> |
| | | <packaging>jar</packaging> |
| | | |
| | | <dependencies> |
| | | <!--Blade--> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>blade-core-launch</artifactId> |
| | | <exclusions> |
| | | <exclusion> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-starter-web</artifactId> |
| | | </exclusion> |
| | | <exclusion> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-starter-undertow</artifactId> |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>skjcmanager-common</artifactId> |
| | | <version>${bladex.project.version}</version> |
| | | <exclusions> |
| | | <exclusion> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>skjcmanager-core-launch</artifactId> |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>blade-starter-metrics</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>blade-starter-jwt</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.alibaba</groupId> |
| | | <artifactId>fastjson</artifactId> |
| | | </dependency> |
| | | <!--Spring--> |
| | | <dependency> |
| | | <groupId>org.springframework.cloud</groupId> |
| | | <artifactId>spring-cloud-starter-gateway</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springframework.cloud</groupId> |
| | | <artifactId>spring-cloud-starter-bootstrap</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.alibaba.cloud</groupId> |
| | | <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-starter-data-redis-reactive</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>de.codecentric</groupId> |
| | | <artifactId>spring-boot-admin-starter-client</artifactId> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | <build> |
| | | <plugins> |
| | | <plugin> |
| | | <groupId>com.spotify</groupId> |
| | | <artifactId>dockerfile-maven-plugin</artifactId> |
| | | <configuration> |
| | | <username>${docker.username}</username> |
| | | <password>${docker.password}</password> |
| | | <repository>${docker.registry.url}/${docker.namespace}/${project.artifactId}</repository> |
| | | <tag>${project.version}</tag> |
| | | <useMavenSettingsForAuth>true</useMavenSettingsForAuth> |
| | | <buildArgs> |
| | | <JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE> |
| | | </buildArgs> |
| | | <skip>false</skip> |
| | | </configuration> |
| | | </plugin> |
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-antrun-plugin</artifactId> |
| | | </plugin> |
| | | </plugins> |
| | | </build> |
| | | |
| | | </project> |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.gateway; |
| | | |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import org.springframework.boot.autoconfigure.SpringBootApplication; |
| | | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; |
| | | import org.springframework.scheduling.annotation.EnableScheduling; |
| | | |
| | | /** |
| | | * 项目启动 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @EnableScheduling |
| | | @EnableDiscoveryClient |
| | | @SpringBootApplication |
| | | public class GateWayApplication { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_GATEWAY_NAME, GateWayApplication.class, args); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.gateway.config; |
| | | |
| | | |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import cn.gistack.gateway.handler.ErrorExceptionHandler; |
| | | import org.springframework.boot.autoconfigure.AutoConfigureBefore; |
| | | import org.springframework.boot.autoconfigure.web.ServerProperties; |
| | | import org.springframework.boot.autoconfigure.web.reactive.error.ErrorWebFluxAutoConfiguration; |
| | | import org.springframework.boot.context.properties.EnableConfigurationProperties; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | /** |
| | | * 异常处理配置类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Configuration(proxyBeanMethods = false) |
| | | @AutoConfigureBefore(ErrorWebFluxAutoConfiguration.class) |
| | | @EnableConfigurationProperties({ServerProperties.class}) |
| | | public class ErrorHandlerConfiguration { |
| | | |
| | | @Bean |
| | | public ErrorExceptionHandler globalExceptionHandler(ObjectMapper objectMapper) { |
| | | return new ErrorExceptionHandler(objectMapper); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.gateway.config; |
| | | |
| | | import cn.gistack.gateway.props.AuthProperties; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.boot.context.properties.EnableConfigurationProperties; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.HttpMethod; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.http.server.reactive.ServerHttpRequest; |
| | | import org.springframework.http.server.reactive.ServerHttpResponse; |
| | | import org.springframework.web.cors.reactive.CorsUtils; |
| | | import org.springframework.web.server.ServerWebExchange; |
| | | import org.springframework.web.server.WebFilter; |
| | | import org.springframework.web.server.WebFilterChain; |
| | | import reactor.core.publisher.Mono; |
| | | |
| | | /** |
| | | * 路由配置信息 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Slf4j |
| | | @Configuration(proxyBeanMethods = false) |
| | | @AllArgsConstructor |
| | | @EnableConfigurationProperties({AuthProperties.class}) |
| | | public class RouterFunctionConfiguration { |
| | | |
| | | /** |
| | | * 这里为支持的请求头,如果有自定义的header字段请自己添加 |
| | | */ |
| | | private static final String ALLOWED_HEADERS = "X-Requested-With, Tenant-Id, Blade-Auth, Content-Type, Authorization, credential, X-XSRF-TOKEN, token, username, client, knfie4j-gateway-request, knife4j-gateway-code, request-origion"; |
| | | private static final String ALLOWED_METHODS = "GET,POST,PUT,DELETE,OPTIONS,HEAD"; |
| | | private static final String ALLOWED_ORIGIN = "*"; |
| | | private static final String ALLOWED_EXPOSE = "*"; |
| | | private static final String MAX_AGE = "18000L"; |
| | | |
| | | /** |
| | | * 跨域配置 |
| | | */ |
| | | @Bean |
| | | public WebFilter corsFilter() { |
| | | return (ServerWebExchange ctx, WebFilterChain chain) -> { |
| | | ServerHttpRequest request = ctx.getRequest(); |
| | | if (CorsUtils.isCorsRequest(request)) { |
| | | ServerHttpResponse response = ctx.getResponse(); |
| | | HttpHeaders headers = response.getHeaders(); |
| | | headers.add("Access-Control-Allow-Headers", ALLOWED_HEADERS); |
| | | headers.add("Access-Control-Allow-Methods", ALLOWED_METHODS); |
| | | headers.add("Access-Control-Allow-Origin", ALLOWED_ORIGIN); |
| | | headers.add("Access-Control-Expose-Headers", ALLOWED_EXPOSE); |
| | | headers.add("Access-Control-Max-Age", MAX_AGE); |
| | | headers.add("Access-Control-Allow-Credentials", "true"); |
| | | if (request.getMethod() == HttpMethod.OPTIONS) { |
| | | response.setStatusCode(HttpStatus.OK); |
| | | return Mono.empty(); |
| | | } |
| | | } |
| | | return chain.filter(ctx); |
| | | }; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.gateway.dynamic; |
| | | |
| | | import org.springframework.cloud.gateway.event.RefreshRoutesEvent; |
| | | import org.springframework.cloud.gateway.route.RouteDefinition; |
| | | import org.springframework.cloud.gateway.route.RouteDefinitionWriter; |
| | | import org.springframework.context.ApplicationEventPublisher; |
| | | import org.springframework.context.ApplicationEventPublisherAware; |
| | | import org.springframework.stereotype.Service; |
| | | import reactor.core.publisher.Mono; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 动态路由业务类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Service |
| | | public class DynamicRouteService implements ApplicationEventPublisherAware { |
| | | |
| | | private final RouteDefinitionWriter routeDefinitionWriter; |
| | | |
| | | private ApplicationEventPublisher publisher; |
| | | |
| | | public DynamicRouteService(RouteDefinitionWriter routeDefinitionWriter) { |
| | | this.routeDefinitionWriter = routeDefinitionWriter; |
| | | } |
| | | |
| | | @Override |
| | | public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) { |
| | | this.publisher = applicationEventPublisher; |
| | | } |
| | | |
| | | /** |
| | | * 增加路由 |
| | | */ |
| | | public String save(RouteDefinition definition) { |
| | | try { |
| | | routeDefinitionWriter.save(Mono.just(definition)).subscribe(); |
| | | this.publisher.publishEvent(new RefreshRoutesEvent(this)); |
| | | return "save success"; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return "save failure"; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 更新路由 |
| | | */ |
| | | public String update(RouteDefinition definition) { |
| | | try { |
| | | this.routeDefinitionWriter.delete(Mono.just(definition.getId())); |
| | | this.routeDefinitionWriter.save(Mono.just(definition)).subscribe(); |
| | | this.publisher.publishEvent(new RefreshRoutesEvent(this)); |
| | | return "update success"; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return "update failure"; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 更新路由 |
| | | */ |
| | | public String updateList(List<RouteDefinition> routeDefinitions) { |
| | | routeDefinitions.forEach(this::update); |
| | | return "update done"; |
| | | } |
| | | |
| | | /** |
| | | * 删除路由 |
| | | */ |
| | | public String delete(String id) { |
| | | try { |
| | | this.routeDefinitionWriter.delete(Mono.just(id)); |
| | | return "delete success"; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return "delete failure"; |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.gateway.dynamic; |
| | | |
| | | import com.alibaba.cloud.nacos.NacosConfigProperties; |
| | | import com.alibaba.cloud.nacos.NacosDiscoveryProperties; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.nacos.api.NacosFactory; |
| | | import com.alibaba.nacos.api.PropertyKeyConst; |
| | | import com.alibaba.nacos.api.config.ConfigService; |
| | | import com.alibaba.nacos.api.config.listener.Listener; |
| | | import com.alibaba.nacos.api.exception.NacosException; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springblade.core.launch.constant.NacosConstant; |
| | | import org.springblade.core.launch.props.BladeProperties; |
| | | import org.springframework.cloud.context.config.annotation.RefreshScope; |
| | | import org.springframework.cloud.gateway.route.RouteDefinition; |
| | | import org.springframework.core.annotation.Order; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.List; |
| | | import java.util.Properties; |
| | | import java.util.concurrent.Executor; |
| | | |
| | | /** |
| | | * 动态路由监听器 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Order |
| | | @Slf4j |
| | | @Component |
| | | @RefreshScope |
| | | public class DynamicRouteServiceListener { |
| | | |
| | | private final DynamicRouteService dynamicRouteService; |
| | | private final NacosDiscoveryProperties nacosDiscoveryProperties; |
| | | private final NacosConfigProperties nacosConfigProperties; |
| | | private final BladeProperties bladeProperties; |
| | | |
| | | public DynamicRouteServiceListener(DynamicRouteService dynamicRouteService, NacosDiscoveryProperties nacosDiscoveryProperties, NacosConfigProperties nacosConfigProperties, BladeProperties bladeProperties) { |
| | | this.dynamicRouteService = dynamicRouteService; |
| | | this.nacosDiscoveryProperties = nacosDiscoveryProperties; |
| | | this.nacosConfigProperties = nacosConfigProperties; |
| | | this.bladeProperties = bladeProperties; |
| | | dynamicRouteServiceListener(); |
| | | } |
| | | |
| | | /** |
| | | * 监听Nacos下发的动态路由配置 |
| | | */ |
| | | private void dynamicRouteServiceListener() { |
| | | try { |
| | | String dataId = NacosConstant.dataId(bladeProperties.getName(), bladeProperties.getEnv(), NacosConstant.NACOS_CONFIG_JSON_FORMAT); |
| | | String group = nacosConfigProperties.getGroup(); |
| | | Properties properties = new Properties(); |
| | | properties.setProperty(PropertyKeyConst.SERVER_ADDR, nacosDiscoveryProperties.getServerAddr()); |
| | | properties.setProperty(PropertyKeyConst.NAMESPACE, nacosDiscoveryProperties.getNamespace()); |
| | | ConfigService configService = NacosFactory.createConfigService(properties); |
| | | configService.addListener(dataId, group, new Listener() { |
| | | @Override |
| | | public void receiveConfigInfo(String configInfo) { |
| | | List<RouteDefinition> routeDefinitions = JSON.parseArray(configInfo, RouteDefinition.class); |
| | | dynamicRouteService.updateList(routeDefinitions); |
| | | } |
| | | |
| | | @Override |
| | | public Executor getExecutor() { |
| | | return null; |
| | | } |
| | | }); |
| | | String configInfo = configService.getConfig(dataId, group, 5000); |
| | | if (configInfo != null) { |
| | | List<RouteDefinition> routeDefinitions = JSON.parseArray(configInfo, RouteDefinition.class); |
| | | dynamicRouteService.updateList(routeDefinitions); |
| | | } |
| | | } catch (NacosException ignored) { |
| | | ignored.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.gateway.dynamic; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.LinkedHashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 过滤器定义模型 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | public class GatewayFilter { |
| | | |
| | | /** |
| | | * 过滤器对应的Name |
| | | */ |
| | | private String name; |
| | | |
| | | /** |
| | | * 对应的路由规则 |
| | | */ |
| | | private Map<String, String> args = new LinkedHashMap<>(); |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.gateway.dynamic; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.LinkedHashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 路由断言定义模型 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | public class GatewayPredicate { |
| | | |
| | | /** |
| | | * 断言对应的Name |
| | | */ |
| | | private String name; |
| | | |
| | | /** |
| | | * 配置的断言规则 |
| | | */ |
| | | private Map<String, String> args = new LinkedHashMap<>(); |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.gateway.dynamic; |
| | | |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Gateway的路由定义模型 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | public class GatewayRoute { |
| | | |
| | | /** |
| | | * 路由的id |
| | | */ |
| | | private String id; |
| | | |
| | | /** |
| | | * 路由断言集合配置 |
| | | */ |
| | | private List<GatewayPredicate> predicates = new ArrayList<>(); |
| | | |
| | | /** |
| | | * 路由过滤器集合配置 |
| | | */ |
| | | private List<GatewayFilter> filters = new ArrayList<>(); |
| | | |
| | | /** |
| | | * 路由规则转发的目标uri |
| | | */ |
| | | private String uri; |
| | | |
| | | /** |
| | | * 路由执行的顺序 |
| | | */ |
| | | private int order = 0; |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.gateway.filter; |
| | | |
| | | import cn.gistack.gateway.props.AuthProperties; |
| | | import cn.gistack.gateway.provider.AuthProvider; |
| | | import cn.gistack.gateway.provider.RequestProvider; |
| | | import cn.gistack.gateway.provider.ResponseProvider; |
| | | import com.alibaba.nacos.common.utils.StringUtils; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import io.jsonwebtoken.Claims; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springblade.core.jwt.JwtUtil; |
| | | import org.springblade.core.jwt.props.JwtProperties; |
| | | import org.springblade.core.launch.constant.TokenConstant; |
| | | import org.springframework.cloud.gateway.filter.GatewayFilterChain; |
| | | import org.springframework.cloud.gateway.filter.GlobalFilter; |
| | | import org.springframework.core.Ordered; |
| | | import org.springframework.core.io.buffer.DataBuffer; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.http.server.reactive.ServerHttpResponse; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.AntPathMatcher; |
| | | import org.springframework.web.server.ServerWebExchange; |
| | | import reactor.core.publisher.Flux; |
| | | import reactor.core.publisher.Mono; |
| | | |
| | | import java.nio.charset.StandardCharsets; |
| | | |
| | | /** |
| | | * 鉴权认证 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | @AllArgsConstructor |
| | | public class AuthFilter implements GlobalFilter, Ordered { |
| | | private final AuthProperties authProperties; |
| | | private final ObjectMapper objectMapper; |
| | | private final JwtProperties jwtProperties; |
| | | private final AntPathMatcher antPathMatcher = new AntPathMatcher(); |
| | | |
| | | @Override |
| | | public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) { |
| | | //校验 Token 放行 |
| | | String originalRequestUrl = RequestProvider.getOriginalRequestUrl(exchange); |
| | | String path = exchange.getRequest().getURI().getPath(); |
| | | if (isSkip(path) || isSkip(originalRequestUrl)) { |
| | | return chain.filter(exchange); |
| | | } |
| | | //校验 Token 合法性 |
| | | ServerHttpResponse resp = exchange.getResponse(); |
| | | String headerToken = exchange.getRequest().getHeaders().getFirst(AuthProvider.AUTH_KEY); |
| | | String paramToken = exchange.getRequest().getQueryParams().getFirst(AuthProvider.AUTH_KEY); |
| | | if (StringUtils.isBlank(headerToken) && StringUtils.isBlank(paramToken)) { |
| | | return unAuth(resp, "缺失令牌,鉴权失败"); |
| | | } |
| | | String auth = StringUtils.isBlank(headerToken) ? paramToken : headerToken; |
| | | String token = JwtUtil.getToken(auth); |
| | | Claims claims = JwtUtil.parseJWT(token); |
| | | if (token == null || claims == null) { |
| | | return unAuth(resp, "请求未授权"); |
| | | } |
| | | //判断 Token 状态 |
| | | if (jwtProperties.getState()) { |
| | | String tenantId = String.valueOf(claims.get(TokenConstant.TENANT_ID)); |
| | | String userId = String.valueOf(claims.get(TokenConstant.USER_ID)); |
| | | String accessToken = JwtUtil.getAccessToken(tenantId, userId, token); |
| | | if (!token.equalsIgnoreCase(accessToken)) { |
| | | return unAuth(resp, "令牌已失效"); |
| | | } |
| | | } |
| | | return chain.filter(exchange); |
| | | } |
| | | |
| | | private boolean isSkip(String path) { |
| | | return AuthProvider.getDefaultSkipUrl().stream().anyMatch(pattern -> antPathMatcher.match(pattern, path)) |
| | | || authProperties.getSkipUrl().stream().anyMatch(pattern -> antPathMatcher.match(pattern, path)) |
| | | || authProperties.getAuth().stream().anyMatch(auth -> antPathMatcher.match(auth.getPattern(), path)) |
| | | || authProperties.getBasic().stream().anyMatch(basic -> antPathMatcher.match(basic.getPattern(), path)) |
| | | || authProperties.getSign().stream().anyMatch(sign -> antPathMatcher.match(sign.getPattern(), path)); |
| | | } |
| | | |
| | | private Mono<Void> unAuth(ServerHttpResponse resp, String msg) { |
| | | resp.setStatusCode(HttpStatus.UNAUTHORIZED); |
| | | resp.getHeaders().add("Content-Type", "application/json;charset=UTF-8"); |
| | | String result = ""; |
| | | try { |
| | | result = objectMapper.writeValueAsString(ResponseProvider.unAuth(msg)); |
| | | } catch (JsonProcessingException e) { |
| | | log.error(e.getMessage(), e); |
| | | } |
| | | DataBuffer buffer = resp.bufferFactory().wrap(result.getBytes(StandardCharsets.UTF_8)); |
| | | return resp.writeWith(Flux.just(buffer)); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public int getOrder() { |
| | | return -100; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, DreamLu All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: DreamLu 卢春梦 (596392912@qq.com) |
| | | */ |
| | | package cn.gistack.gateway.filter; |
| | | |
| | | import cn.gistack.gateway.provider.AuthProvider; |
| | | import cn.gistack.gateway.provider.RequestProvider; |
| | | import com.alibaba.nacos.common.utils.StringUtils; |
| | | import io.jsonwebtoken.Claims; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springblade.core.jwt.JwtUtil; |
| | | import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties; |
| | | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
| | | import org.springframework.cloud.gateway.filter.GatewayFilterChain; |
| | | import org.springframework.cloud.gateway.filter.GlobalFilter; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.core.Ordered; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.server.reactive.ServerHttpRequest; |
| | | import org.springframework.web.server.ServerWebExchange; |
| | | import reactor.core.publisher.Mono; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * webflux 日志请求记录,方便开发调试。请求日志过滤器排序尽量低。 |
| | | * |
| | | * <p> |
| | | * 注意:暂时不支持结构体打印,想实现,请看下面的链接。 |
| | | * https://stackoverflow.com/questions/45240005/how-to-log-request-and-response-bodies-in-spring-webflux |
| | | * https://github.com/Silvmike/webflux-demo/blob/master/tests/src/test/java/ru/hardcoders/demo/webflux/web_handler/filters/logging |
| | | * </p> |
| | | * |
| | | * @author dream.lu |
| | | */ |
| | | @Slf4j |
| | | @Configuration(proxyBeanMethods = false) |
| | | @RequiredArgsConstructor |
| | | @ConditionalOnProperty(value = "blade.log.request.enabled", havingValue = "true", matchIfMissing = true) |
| | | public class GlobalRequestLogFilter implements GlobalFilter, Ordered { |
| | | private final WebEndpointProperties endpointProperties; |
| | | |
| | | @Override |
| | | public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) { |
| | | ServerHttpRequest request = exchange.getRequest(); |
| | | // 打印请求路径 |
| | | String path = request.getPath().pathWithinApplication().value(); |
| | | |
| | | // 忽略 endpoint 请求 |
| | | String endpointBasePath = endpointProperties.getBasePath(); |
| | | if (StringUtils.isNotBlank(endpointBasePath) && path.startsWith(endpointBasePath)) { |
| | | return chain.filter(exchange); |
| | | } |
| | | |
| | | String requestUrl = RequestProvider.getOriginalRequestUrl(exchange); |
| | | |
| | | // 构建成一条长 日志,避免并发下日志错乱 |
| | | StringBuilder beforeReqLog = new StringBuilder(300); |
| | | // 日志参数 |
| | | List<Object> beforeReqArgs = new ArrayList<>(); |
| | | beforeReqLog.append("\n\n================ Gateway Request Start ================\n"); |
| | | // 打印路由 |
| | | beforeReqLog.append("===> {}: {}\n"); |
| | | // 参数 |
| | | String requestMethod = request.getMethodValue(); |
| | | beforeReqArgs.add(requestMethod); |
| | | beforeReqArgs.add(requestUrl); |
| | | |
| | | // 打印请求头 |
| | | HttpHeaders headers = request.getHeaders(); |
| | | headers.forEach((headerName, headerValue) -> { |
| | | beforeReqLog.append("===Headers=== {}: {}\n"); |
| | | beforeReqArgs.add(headerName); |
| | | if (AuthProvider.AUTH_KEY.toLowerCase().equals(headerName)) { |
| | | String value = headerValue.get(0); |
| | | String token = JwtUtil.getToken(value); |
| | | Claims claims = JwtUtil.parseJWT(token); |
| | | beforeReqArgs.add((claims == null) ? "" : claims.toString()); |
| | | beforeReqLog.append("===Headers=== {}: {}\n"); |
| | | beforeReqArgs.add(headerName.concat("-original")); |
| | | beforeReqArgs.add(headerValue.toArray()); |
| | | } else { |
| | | beforeReqArgs.add(headerValue.toArray()); |
| | | } |
| | | }); |
| | | |
| | | beforeReqLog.append("================ Gateway Request End =================\n"); |
| | | // 打印执行时间 |
| | | log.info(beforeReqLog.toString(), beforeReqArgs.toArray()); |
| | | return chain.filter(exchange); |
| | | } |
| | | |
| | | @Override |
| | | public int getOrder() { |
| | | return Ordered.LOWEST_PRECEDENCE; |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, DreamLu All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: DreamLu 卢春梦 (596392912@qq.com) |
| | | */ |
| | | package cn.gistack.gateway.filter; |
| | | |
| | | import com.alibaba.nacos.common.utils.StringUtils; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties; |
| | | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
| | | import org.springframework.cloud.gateway.filter.GatewayFilterChain; |
| | | import org.springframework.cloud.gateway.filter.GlobalFilter; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.core.Ordered; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.server.reactive.ServerHttpRequest; |
| | | import org.springframework.http.server.reactive.ServerHttpResponse; |
| | | import org.springframework.util.MultiValueMap; |
| | | import org.springframework.web.server.ServerWebExchange; |
| | | import org.springframework.web.util.UriComponentsBuilder; |
| | | import reactor.core.publisher.Mono; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * webflux 相应日志,方便开发调试,注意排序要优先。 |
| | | * |
| | | * @author dream.lu |
| | | */ |
| | | @Slf4j |
| | | @Configuration(proxyBeanMethods = false) |
| | | @RequiredArgsConstructor |
| | | @ConditionalOnProperty(value = "blade.log.request.enabled", havingValue = "true", matchIfMissing = true) |
| | | public class GlobalResponseLogFilter implements GlobalFilter, Ordered { |
| | | private final WebEndpointProperties endpointProperties; |
| | | |
| | | @Override |
| | | public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) { |
| | | ServerHttpRequest request = exchange.getRequest(); |
| | | // 打印请求路径 |
| | | String path = request.getPath().pathWithinApplication().value(); |
| | | // 忽略 endpoint 请求 |
| | | String endpointBasePath = endpointProperties.getBasePath(); |
| | | if (StringUtils.isNotBlank(endpointBasePath) && path.startsWith(endpointBasePath)) { |
| | | return chain.filter(exchange); |
| | | } |
| | | return chain.filter(exchange).then( |
| | | Mono.fromRunnable(() -> { |
| | | MultiValueMap<String, String> queryParams = request.getQueryParams(); |
| | | String requestUrl = UriComponentsBuilder.fromPath(path).queryParams(queryParams).build().toUriString(); |
| | | |
| | | // 构建成一条长 日志,避免并发下日志错乱 |
| | | StringBuilder responseLog = new StringBuilder(300); |
| | | // 日志参数 |
| | | List<Object> responseArgs = new ArrayList<>(); |
| | | responseLog.append("\n\n================ Gateway Response Start ================\n"); |
| | | ServerHttpResponse response = exchange.getResponse(); |
| | | // 打印路由 200 get: /api/xxx/xxx |
| | | responseLog.append("<=== {} {}: {}\n"); |
| | | // 参数 |
| | | String requestMethod = request.getMethodValue(); |
| | | responseArgs.add(response.getStatusCode().value()); |
| | | responseArgs.add(requestMethod); |
| | | responseArgs.add(requestUrl); |
| | | |
| | | // 打印请求头 |
| | | HttpHeaders headers = response.getHeaders(); |
| | | headers.forEach((headerName, headerValue) -> { |
| | | responseLog.append("===Headers=== {}: {}\n"); |
| | | responseArgs.add(headerName); |
| | | responseArgs.add(headerValue.toArray()); |
| | | }); |
| | | |
| | | responseLog.append("================ Gateway Response End =================\n"); |
| | | // 打印执行时间 |
| | | log.info(responseLog.toString(), responseArgs.toArray()); |
| | | }) |
| | | ); |
| | | } |
| | | |
| | | @Override |
| | | public int getOrder() { |
| | | return Ordered.HIGHEST_PRECEDENCE; |
| | | } |
| | | } |
| New file |
| | |
| | | package cn.gistack.gateway.filter; |
| | | |
| | | import org.springframework.cloud.gateway.filter.GatewayFilterChain; |
| | | import org.springframework.cloud.gateway.filter.GlobalFilter; |
| | | import org.springframework.core.Ordered; |
| | | import org.springframework.http.server.reactive.ServerHttpRequest; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.server.ServerWebExchange; |
| | | import reactor.core.publisher.Mono; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR; |
| | | import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.addOriginalRequestUrl; |
| | | |
| | | /** |
| | | * <p> |
| | | * 全局拦截器,作用所有的微服务 |
| | | * <p> |
| | | * 1. 对请求头中参数进行处理 from 参数进行清洗 |
| | | * 2. 重写StripPrefix = 1,支持全局 |
| | | * |
| | | * @author lengleng |
| | | */ |
| | | @Component |
| | | public class RequestFilter implements GlobalFilter, Ordered { |
| | | |
| | | /** |
| | | * Process the Web request and (optionally) delegate to the next |
| | | * {@code WebFilter} through the given {@link GatewayFilterChain}. |
| | | * |
| | | * @param exchange the current server exchange |
| | | * @param chain provides a way to delegate to the next filter |
| | | * @return {@code Mono<Void>} to indicate when request processing is complete |
| | | */ |
| | | @Override |
| | | public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) { |
| | | // 1. 清洗请求头中from 参数 |
| | | ServerHttpRequest request = exchange.getRequest().mutate() |
| | | .headers(httpHeaders -> httpHeaders.remove("X")) |
| | | .build(); |
| | | |
| | | // 2. 重写StripPrefix |
| | | addOriginalRequestUrl(exchange, request.getURI()); |
| | | String rawPath = request.getURI().getRawPath(); |
| | | String newPath = "/" + Arrays.stream(StringUtils.tokenizeToStringArray(rawPath, "/")) |
| | | .skip(1L).collect(Collectors.joining("/")); |
| | | ServerHttpRequest newRequest = request.mutate() |
| | | .path(newPath) |
| | | .build(); |
| | | exchange.getAttributes().put(GATEWAY_REQUEST_URL_ATTR, newRequest.getURI()); |
| | | |
| | | return chain.filter(exchange.mutate().request(newRequest.mutate().build()).build()); |
| | | } |
| | | |
| | | @Override |
| | | public int getOrder() { |
| | | return -1000; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.gateway.handler; |
| | | |
| | | import cn.gistack.gateway.provider.ResponseProvider; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.boot.web.reactive.error.ErrorWebExceptionHandler; |
| | | import org.springframework.core.annotation.Order; |
| | | import org.springframework.core.io.buffer.DataBufferFactory; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.http.server.reactive.ServerHttpRequest; |
| | | import org.springframework.http.server.reactive.ServerHttpResponse; |
| | | import org.springframework.web.server.ResponseStatusException; |
| | | import org.springframework.web.server.ServerWebExchange; |
| | | import reactor.core.publisher.Mono; |
| | | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 异常处理 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Order(-1) |
| | | @RequiredArgsConstructor |
| | | public class ErrorExceptionHandler implements ErrorWebExceptionHandler { |
| | | |
| | | private final ObjectMapper objectMapper; |
| | | |
| | | @Override |
| | | public Mono<Void> handle(ServerWebExchange exchange, Throwable ex) { |
| | | ServerHttpRequest request = exchange.getRequest(); |
| | | ServerHttpResponse response = exchange.getResponse(); |
| | | |
| | | if (response.isCommitted()) { |
| | | return Mono.error(ex); |
| | | } |
| | | |
| | | response.getHeaders().setContentType(MediaType.APPLICATION_JSON); |
| | | if (ex instanceof ResponseStatusException) { |
| | | response.setStatusCode(((ResponseStatusException) ex).getStatus()); |
| | | } |
| | | |
| | | return response.writeWith(Mono.fromSupplier(() -> { |
| | | DataBufferFactory bufferFactory = response.bufferFactory(); |
| | | try { |
| | | int status = 500; |
| | | if (response.getStatusCode() != null) { |
| | | status = response.getStatusCode().value(); |
| | | } |
| | | Map<String, Object> result = ResponseProvider.response(status, this.buildMessage(request, ex)); |
| | | return bufferFactory.wrap(objectMapper.writeValueAsBytes(result)); |
| | | } catch (JsonProcessingException e) { |
| | | return bufferFactory.wrap(new byte[0]); |
| | | } |
| | | })); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 构建异常信息 |
| | | */ |
| | | private String buildMessage(ServerHttpRequest request, Throwable ex) { |
| | | String uri = request.getURI().toString(); |
| | | if (uri.endsWith("doc.html")) { |
| | | return "[Swagger聚合网关] 已迁移至 [blade-swagger] 服务,请开启 [blade-swagger] 服务并访问 [http://127.0.0.1:18000/doc.html]"; |
| | | } |
| | | StringBuilder message = new StringBuilder("Failed to handle request ["); |
| | | message.append(request.getMethodValue()); |
| | | message.append(" "); |
| | | message.append(request.getURI()); |
| | | message.append("]"); |
| | | if (ex != null) { |
| | | message.append(": "); |
| | | message.append(ex.getMessage()); |
| | | } |
| | | return message.toString(); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.gateway.props; |
| | | |
| | | import cn.gistack.gateway.provider.AuthSecure; |
| | | import cn.gistack.gateway.provider.BasicSecure; |
| | | import cn.gistack.gateway.provider.SignSecure; |
| | | import lombok.Data; |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| | | import org.springframework.cloud.context.config.annotation.RefreshScope; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 权限过滤 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @RefreshScope |
| | | @ConfigurationProperties("blade.secure") |
| | | public class AuthProperties { |
| | | |
| | | /** |
| | | * 放行API集合 |
| | | */ |
| | | private final List<String> skipUrl = new ArrayList<>(); |
| | | |
| | | /** |
| | | * 自定义授权配置 |
| | | */ |
| | | private final List<AuthSecure> auth = new ArrayList<>(); |
| | | |
| | | /** |
| | | * 基础认证配置 |
| | | */ |
| | | private final List<BasicSecure> basic = new ArrayList<>(); |
| | | |
| | | /** |
| | | * 签名认证配置 |
| | | */ |
| | | private final List<SignSecure> sign = new ArrayList<>(); |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.gateway.provider; |
| | | |
| | | import org.springblade.core.launch.constant.TokenConstant; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 鉴权配置 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class AuthProvider { |
| | | |
| | | public static final String AUTH_KEY = TokenConstant.HEADER; |
| | | private static final List<String> DEFAULT_SKIP_URL = new ArrayList<>(); |
| | | |
| | | static { |
| | | DEFAULT_SKIP_URL.add("/example"); |
| | | DEFAULT_SKIP_URL.add("/oauth/token/**"); |
| | | DEFAULT_SKIP_URL.add("/oauth/captcha/**"); |
| | | DEFAULT_SKIP_URL.add("/oauth/clear-cache/**"); |
| | | DEFAULT_SKIP_URL.add("/oauth/user-info"); |
| | | DEFAULT_SKIP_URL.add("/oauth/render/**"); |
| | | DEFAULT_SKIP_URL.add("/oauth/callback/**"); |
| | | DEFAULT_SKIP_URL.add("/oauth/revoke/**"); |
| | | DEFAULT_SKIP_URL.add("/oauth/refresh/**"); |
| | | DEFAULT_SKIP_URL.add("/token/**"); |
| | | DEFAULT_SKIP_URL.add("/actuator/**"); |
| | | DEFAULT_SKIP_URL.add("/v2/api-docs/**"); |
| | | DEFAULT_SKIP_URL.add("/auth/**"); |
| | | DEFAULT_SKIP_URL.add("/log/**"); |
| | | DEFAULT_SKIP_URL.add("/menu/routes"); |
| | | DEFAULT_SKIP_URL.add("/menu/auth-routes"); |
| | | DEFAULT_SKIP_URL.add("/menu/top-menu"); |
| | | DEFAULT_SKIP_URL.add("/tenant/info"); |
| | | DEFAULT_SKIP_URL.add("/process/resource-view"); |
| | | DEFAULT_SKIP_URL.add("/process/diagram-view"); |
| | | DEFAULT_SKIP_URL.add("/manager/check-upload"); |
| | | DEFAULT_SKIP_URL.add("/error/**"); |
| | | DEFAULT_SKIP_URL.add("/assets/**"); |
| | | } |
| | | |
| | | /** |
| | | * 默认无需鉴权的API |
| | | */ |
| | | public static List<String> getDefaultSkipUrl() { |
| | | return DEFAULT_SKIP_URL; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.gateway.provider; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | /** |
| | | * 自定义授权规则 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class AuthSecure { |
| | | /** |
| | | * 请求路径 |
| | | */ |
| | | private String pattern; |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.gateway.provider; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | /** |
| | | * 基础授权规则 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class BasicSecure { |
| | | /** |
| | | * 请求路径 |
| | | */ |
| | | private String pattern; |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.gateway.provider; |
| | | |
| | | import org.springframework.cloud.gateway.support.ServerWebExchangeUtils; |
| | | import org.springframework.http.server.reactive.ServerHttpRequest; |
| | | import org.springframework.util.MultiValueMap; |
| | | import org.springframework.web.server.ServerWebExchange; |
| | | import org.springframework.web.util.UriComponentsBuilder; |
| | | |
| | | import java.net.URI; |
| | | import java.util.LinkedHashSet; |
| | | |
| | | /** |
| | | * RequestProvider |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class RequestProvider { |
| | | |
| | | /** |
| | | * 获取原始url |
| | | * |
| | | * @param exchange |
| | | * @return |
| | | */ |
| | | public static String getOriginalRequestUrl(ServerWebExchange exchange) { |
| | | ServerHttpRequest request = exchange.getRequest(); |
| | | LinkedHashSet<URI> uris = exchange.getRequiredAttribute(ServerWebExchangeUtils.GATEWAY_ORIGINAL_REQUEST_URL_ATTR); |
| | | URI requestUri = uris.stream().findFirst().orElse(request.getURI()); |
| | | MultiValueMap<String, String> queryParams = request.getQueryParams(); |
| | | return UriComponentsBuilder.fromPath(requestUri.getRawPath()).queryParams(queryParams).build().toUriString(); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.gateway.provider; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 请求响应返回 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class ResponseProvider { |
| | | |
| | | /** |
| | | * 成功 |
| | | * |
| | | * @param message 信息 |
| | | * @return |
| | | */ |
| | | public static Map<String, Object> success(String message) { |
| | | return response(200, message); |
| | | } |
| | | |
| | | /** |
| | | * 失败 |
| | | * |
| | | * @param message 信息 |
| | | * @return |
| | | */ |
| | | public static Map<String, Object> fail(String message) { |
| | | return response(400, message); |
| | | } |
| | | |
| | | /** |
| | | * 未授权 |
| | | * |
| | | * @param message 信息 |
| | | * @return |
| | | */ |
| | | public static Map<String, Object> unAuth(String message) { |
| | | return response(401, message); |
| | | } |
| | | |
| | | /** |
| | | * 服务器异常 |
| | | * |
| | | * @param message 信息 |
| | | * @return |
| | | */ |
| | | public static Map<String, Object> error(String message) { |
| | | return response(500, message); |
| | | } |
| | | |
| | | /** |
| | | * 构建返回的JSON数据格式 |
| | | * |
| | | * @param status 状态码 |
| | | * @param message 信息 |
| | | * @return |
| | | */ |
| | | public static Map<String, Object> response(int status, String message) { |
| | | Map<String, Object> map = new HashMap<>(16); |
| | | map.put("code", status); |
| | | map.put("msg", message); |
| | | map.put("data", null); |
| | | return map; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.gateway.provider; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | /** |
| | | * 签名授权规则 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class SignSecure { |
| | | /** |
| | | * 请求路径 |
| | | */ |
| | | private String pattern; |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <project xmlns="http://maven.apache.org/POM/4.0.0" |
| | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| | | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| | | <parent> |
| | | <artifactId>skjcmanager</artifactId> |
| | | <groupId>org.springblade</groupId> |
| | | <version>3.0.1.RELEASE</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | | <artifactId>skjcmanager-ops-api</artifactId> |
| | | <name>${project.artifactId}</name> |
| | | <version>3.0.1.RELEASE</version> |
| | | <packaging>pom</packaging> |
| | | <description>BladeX 微服务API集合</description> |
| | | |
| | | <modules> |
| | | <module>skjcmanager-flow-api</module> |
| | | <module>skjcmanager-resource-api</module> |
| | | </modules> |
| | | |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>blade-starter-mybatis</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springframework.cloud</groupId> |
| | | <artifactId>spring-cloud-starter-openfeign</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>blade-core-auto</artifactId> |
| | | <scope>provided</scope> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | <build> |
| | | <plugins> |
| | | <plugin> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-maven-plugin</artifactId> |
| | | <configuration> |
| | | <skip>true</skip> |
| | | <finalName>${project.name}</finalName> |
| | | </configuration> |
| | | </plugin> |
| | | </plugins> |
| | | </build> |
| | | |
| | | </project> |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <project xmlns="http://maven.apache.org/POM/4.0.0" |
| | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| | | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| | | <parent> |
| | | <artifactId>skjcmanager-ops-api</artifactId> |
| | | <groupId>org.springblade</groupId> |
| | | <version>3.0.1.RELEASE</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | | <artifactId>skjcmanager-flow-api</artifactId> |
| | | <name>${project.artifactId}</name> |
| | | <version>${bladex.project.version}</version> |
| | | <packaging>jar</packaging> |
| | | |
| | | |
| | | |
| | | </project> |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.flow.core.constant; |
| | | |
| | | /** |
| | | * 流程常量. |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface ProcessConstant { |
| | | |
| | | /** |
| | | * 请假流程标识 |
| | | */ |
| | | String LEAVE_KEY = "Leave"; |
| | | |
| | | /** |
| | | * 报销流程标识 |
| | | */ |
| | | String EXPENSE_KEY = "Expense"; |
| | | |
| | | /** |
| | | * 同意标识 |
| | | */ |
| | | String PASS_KEY = "pass"; |
| | | |
| | | /** |
| | | * 同意代号 |
| | | */ |
| | | String PASS_ALIAS = "ok"; |
| | | |
| | | /** |
| | | * 同意默认批复 |
| | | */ |
| | | String PASS_COMMENT = "同意"; |
| | | |
| | | /** |
| | | * 驳回默认批复 |
| | | */ |
| | | String NOT_PASS_COMMENT = "驳回"; |
| | | |
| | | /** |
| | | * 创建人变量名 |
| | | */ |
| | | String TASK_VARIABLE_CREATE_USER = "createUser"; |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.flow.core.entity; |
| | | |
| | | import lombok.Data; |
| | | import cn.gistack.flow.core.constant.ProcessConstant; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 工作流通用实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | public class BladeFlow implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 任务编号 |
| | | */ |
| | | private String taskId; |
| | | /** |
| | | * 任务名称 |
| | | */ |
| | | private String taskName; |
| | | /** |
| | | * 任务定义Key |
| | | */ |
| | | private String taskDefinitionKey; |
| | | /** |
| | | * 任务执行人编号 |
| | | */ |
| | | private String assignee; |
| | | /** |
| | | * 任务执行人名称 |
| | | */ |
| | | private String assigneeName; |
| | | /** |
| | | * 流程分类 |
| | | */ |
| | | private String category; |
| | | /** |
| | | * 流程分类名 |
| | | */ |
| | | private String categoryName; |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | private Date createTime; |
| | | /** |
| | | * 结束时间 |
| | | */ |
| | | private Date endTime; |
| | | /** |
| | | * 签收时间 |
| | | */ |
| | | private Date claimTime; |
| | | /** |
| | | * 历史任务结束时间 |
| | | */ |
| | | private Date historyTaskEndTime; |
| | | /** |
| | | * 执行ID |
| | | */ |
| | | private String executionId; |
| | | /** |
| | | * 流程实例ID |
| | | */ |
| | | private String processInstanceId; |
| | | /** |
| | | * 流程ID |
| | | */ |
| | | private String processDefinitionId; |
| | | /** |
| | | * 流程标识 |
| | | */ |
| | | private String processDefinitionKey; |
| | | /** |
| | | * 流程名 |
| | | */ |
| | | private String processDefinitionName; |
| | | /** |
| | | * 流程版本 |
| | | */ |
| | | private int processDefinitionVersion; |
| | | /** |
| | | * 流程说明 |
| | | */ |
| | | private String processDefinitionDesc; |
| | | /** |
| | | * 流程简图名 |
| | | */ |
| | | private String processDefinitionDiagramResName; |
| | | /** |
| | | * 流程重命名 |
| | | */ |
| | | private String processDefinitionResName; |
| | | /** |
| | | * 历史任务流程实例ID 查看流程图会用到 |
| | | */ |
| | | private String historyProcessInstanceId; |
| | | /** |
| | | * 流程实例是否结束 |
| | | */ |
| | | private String processIsFinished; |
| | | /** |
| | | * 历史活动ID |
| | | */ |
| | | private String historyActivityId; |
| | | /** |
| | | * 历史活动流程 |
| | | */ |
| | | private String historyActivityName; |
| | | /** |
| | | * 历史活动耗时 |
| | | */ |
| | | private String historyActivityDurationTime; |
| | | /** |
| | | * 业务绑定Table |
| | | */ |
| | | private String businessTable; |
| | | /** |
| | | * 业务绑定ID |
| | | */ |
| | | private String businessId; |
| | | /** |
| | | * 任务状态 |
| | | */ |
| | | private String status; |
| | | /** |
| | | * 任务意见 |
| | | */ |
| | | private String comment; |
| | | /** |
| | | * 是否通过 |
| | | */ |
| | | private boolean isPass; |
| | | /** |
| | | * 是否通过代号 |
| | | */ |
| | | private String flag; |
| | | /** |
| | | * 开始查询日期 |
| | | */ |
| | | private Date beginDate; |
| | | /** |
| | | * 结束查询日期 |
| | | */ |
| | | private Date endDate; |
| | | /** |
| | | * 流程参数 |
| | | */ |
| | | private Map<String, Object> variables; |
| | | |
| | | /** |
| | | * 获取是否通过 |
| | | */ |
| | | public boolean isPass() { |
| | | return ProcessConstant.PASS_ALIAS.equals(flag) || ProcessConstant.PASS_COMMENT.equals(comment); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.flow.core.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.mp.base.BaseEntity; |
| | | |
| | | /** |
| | | * FlowEntity |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class FlowEntity extends BaseEntity { |
| | | |
| | | @TableField(exist = false) |
| | | private BladeFlow flow; |
| | | |
| | | public BladeFlow getFlow() { |
| | | if (flow == null) { |
| | | flow = new BladeFlow(); |
| | | } |
| | | return flow; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.flow.core.enums; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * 流程类型枚举 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum FlowModeEnum { |
| | | |
| | | /** |
| | | * 通用流程 |
| | | */ |
| | | COMMON("common", 1), |
| | | |
| | | /** |
| | | * 定制流程 |
| | | */ |
| | | CUSTOM("custom", 2), |
| | | ; |
| | | |
| | | final String name; |
| | | final int mode; |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.flow.core.feign; |
| | | |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import org.springblade.core.tool.api.R; |
| | | import cn.gistack.flow.core.entity.BladeFlow; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 工作流远程调用接口. |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @FeignClient( |
| | | value = AppConstant.APPLICATION_FLOW_NAME, |
| | | fallback = IFlowClientFallback.class |
| | | ) |
| | | public interface IFlowClient { |
| | | |
| | | String API_PREFIX = "/client"; |
| | | String START_PROCESS_INSTANCE_BY_ID = API_PREFIX + "/start-process-instance-by-id"; |
| | | String START_PROCESS_INSTANCE_BY_KEY = API_PREFIX + "/start-process-instance-by-key"; |
| | | String COMPLETE_TASK = API_PREFIX + "/complete-task"; |
| | | String TASK_VARIABLE = API_PREFIX + "/task-variable"; |
| | | String TASK_VARIABLES = API_PREFIX + "/task-variables"; |
| | | |
| | | /** |
| | | * 开启流程 |
| | | * |
| | | * @param processDefinitionId 流程id |
| | | * @param businessKey 业务key |
| | | * @param variables 参数 |
| | | * @return BladeFlow |
| | | */ |
| | | @PostMapping(START_PROCESS_INSTANCE_BY_ID) |
| | | R<BladeFlow> startProcessInstanceById(@RequestParam("processDefinitionId") String processDefinitionId, @RequestParam("businessKey") String businessKey, @RequestBody Map<String, Object> variables); |
| | | |
| | | /** |
| | | * 开启流程 |
| | | * |
| | | * @param processDefinitionKey 流程标识 |
| | | * @param businessKey 业务key |
| | | * @param variables 参数 |
| | | * @return BladeFlow |
| | | */ |
| | | @PostMapping(START_PROCESS_INSTANCE_BY_KEY) |
| | | R<BladeFlow> startProcessInstanceByKey(@RequestParam("processDefinitionKey") String processDefinitionKey, @RequestParam("businessKey") String businessKey, @RequestBody Map<String, Object> variables); |
| | | |
| | | /** |
| | | * 完成任务 |
| | | * |
| | | * @param taskId 任务id |
| | | * @param processInstanceId 流程实例id |
| | | * @param comment 评论 |
| | | * @param variables 参数 |
| | | * @return R |
| | | */ |
| | | @PostMapping(COMPLETE_TASK) |
| | | R completeTask(@RequestParam("taskId") String taskId, @RequestParam("processInstanceId") String processInstanceId, @RequestParam("comment") String comment, @RequestBody Map<String, Object> variables); |
| | | |
| | | /** |
| | | * 获取流程变量 |
| | | * |
| | | * @param taskId 任务id |
| | | * @param variableName 变量名 |
| | | * @return R |
| | | */ |
| | | @GetMapping(TASK_VARIABLE) |
| | | R<Object> taskVariable(@RequestParam("taskId") String taskId, @RequestParam("variableName") String variableName); |
| | | |
| | | /** |
| | | * 获取流程变量集合 |
| | | * |
| | | * @param taskId 任务id |
| | | * @return R |
| | | */ |
| | | @GetMapping(TASK_VARIABLES) |
| | | R<Map<String, Object>> taskVariables(@RequestParam("taskId") String taskId); |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.flow.core.feign; |
| | | |
| | | import org.springblade.core.tool.api.R; |
| | | import cn.gistack.flow.core.entity.BladeFlow; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 流程远程调用失败处理类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Component |
| | | public class IFlowClientFallback implements IFlowClient { |
| | | |
| | | @Override |
| | | public R<BladeFlow> startProcessInstanceById(String processDefinitionId, String businessKey, Map<String, Object> variables) { |
| | | return R.fail("远程调用失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R<BladeFlow> startProcessInstanceByKey(String processDefinitionKey, String businessKey, Map<String, Object> variables) { |
| | | return R.fail("远程调用失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R completeTask(String taskId, String processInstanceId, String comment, Map<String, Object> variables) { |
| | | return R.fail("远程调用失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R<Object> taskVariable(String taskId, String variableName) { |
| | | return R.fail("远程调用失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R<Map<String, Object>> taskVariables(String taskId) { |
| | | return R.fail("远程调用失败"); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.flow.core.utils; |
| | | |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import cn.gistack.flow.core.constant.ProcessConstant; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 工作流工具类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class FlowUtil { |
| | | |
| | | /** |
| | | * 定义流程key对应的表名 |
| | | */ |
| | | private final static Map<String, String> BUSINESS_TABLE = new HashMap<>(); |
| | | |
| | | static { |
| | | BUSINESS_TABLE.put(ProcessConstant.LEAVE_KEY, "blade_process_leave"); |
| | | } |
| | | |
| | | /** |
| | | * 通过流程key获取业务表名 |
| | | * |
| | | * @param key 流程key |
| | | */ |
| | | public static String getBusinessTable(String key) { |
| | | String businessTable = BUSINESS_TABLE.get(key); |
| | | if (Func.isEmpty(businessTable)) { |
| | | throw new RuntimeException("流程启动失败,未找到相关业务表"); |
| | | } |
| | | return businessTable; |
| | | } |
| | | |
| | | /** |
| | | * 获取业务标识 |
| | | * |
| | | * @param businessTable 业务表 |
| | | * @param businessId 业务表主键 |
| | | * @return businessKey |
| | | */ |
| | | public static String getBusinessKey(String businessTable, String businessId) { |
| | | return StringUtil.format("{}:{}", businessTable, businessId); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.flow.core.utils; |
| | | |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | |
| | | import static org.springblade.core.launch.constant.FlowConstant.TASK_USR_PREFIX; |
| | | |
| | | /** |
| | | * 工作流任务工具类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class TaskUtil { |
| | | |
| | | /** |
| | | * 获取任务用户格式 |
| | | * |
| | | * @return taskUser |
| | | */ |
| | | public static String getTaskUser() { |
| | | return StringUtil.format("{}{}", TASK_USR_PREFIX, AuthUtil.getUserId()); |
| | | } |
| | | |
| | | /** |
| | | * 获取任务用户格式 |
| | | * |
| | | * @param userId 用户id |
| | | * @return taskUser |
| | | */ |
| | | public static String getTaskUser(String userId) { |
| | | return StringUtil.format("{}{}", TASK_USR_PREFIX, userId); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取用户主键 |
| | | * |
| | | * @param taskUser 任务用户 |
| | | * @return userId |
| | | */ |
| | | public static Long getUserId(String taskUser) { |
| | | return Func.toLong(StringUtil.removePrefix(taskUser, TASK_USR_PREFIX)); |
| | | } |
| | | |
| | | /** |
| | | * 获取用户组格式 |
| | | * |
| | | * @return candidateGroup |
| | | */ |
| | | public static String getCandidateGroup() { |
| | | return AuthUtil.getUserRole(); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <project xmlns="http://maven.apache.org/POM/4.0.0" |
| | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| | | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| | | <parent> |
| | | <artifactId>skjcmanager-ops-api</artifactId> |
| | | <groupId>org.springblade</groupId> |
| | | <version>3.0.1.RELEASE</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | | <artifactId>skjcmanager-resource-api</artifactId> |
| | | <name>${project.artifactId}</name> |
| | | <version>${bladex.project.version}</version> |
| | | <packaging>jar</packaging> |
| | | |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>blade-starter-sms</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>blade-starter-tenant</artifactId> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | </project> |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.resource.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.tenant.mp.TenantEntity; |
| | | |
| | | /** |
| | | * 附件表实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @TableName("blade_attach") |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "Attach对象", description = "附件表") |
| | | public class Attach extends TenantEntity { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 附件地址 |
| | | */ |
| | | @ApiModelProperty(value = "附件地址") |
| | | private String link; |
| | | /** |
| | | * 附件域名 |
| | | */ |
| | | @ApiModelProperty(value = "附件域名") |
| | | private String domainUrl; |
| | | /** |
| | | * 附件名称 |
| | | */ |
| | | @ApiModelProperty(value = "附件名称") |
| | | private String name; |
| | | /** |
| | | * 附件原名 |
| | | */ |
| | | @ApiModelProperty(value = "附件原名") |
| | | private String originalName; |
| | | /** |
| | | * 附件拓展名 |
| | | */ |
| | | @ApiModelProperty(value = "附件拓展名") |
| | | private String extension; |
| | | /** |
| | | * 附件大小 |
| | | */ |
| | | @ApiModelProperty(value = "附件大小") |
| | | private Long attachSize; |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.resource.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.tenant.mp.TenantEntity; |
| | | |
| | | /** |
| | | * 实体类 |
| | | * |
| | | * @author BladeX |
| | | */ |
| | | @Data |
| | | @TableName("blade_oss") |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "Oss对象", description = "Oss对象") |
| | | public class Oss extends TenantEntity { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | /** |
| | | * 所属分类 |
| | | */ |
| | | @ApiModelProperty(value = "所属分类") |
| | | private Integer category; |
| | | |
| | | /** |
| | | * 资源编号 |
| | | */ |
| | | @ApiModelProperty(value = "资源编号") |
| | | private String ossCode; |
| | | |
| | | /** |
| | | * oss地址 |
| | | */ |
| | | @ApiModelProperty(value = "资源地址") |
| | | private String endpoint; |
| | | /** |
| | | * accessKey |
| | | */ |
| | | @ApiModelProperty(value = "accessKey") |
| | | private String accessKey; |
| | | /** |
| | | * secretKey |
| | | */ |
| | | @ApiModelProperty(value = "secretKey") |
| | | private String secretKey; |
| | | /** |
| | | * 空间名 |
| | | */ |
| | | @ApiModelProperty(value = "空间名") |
| | | private String bucketName; |
| | | /** |
| | | * 应用ID TencentCOS需要 |
| | | */ |
| | | @ApiModelProperty(value = "应用ID") |
| | | private String appId; |
| | | /** |
| | | * 地域简称 TencentCOS需要 |
| | | */ |
| | | @ApiModelProperty(value = "地域简称") |
| | | private String region; |
| | | /** |
| | | * 备注 |
| | | */ |
| | | @ApiModelProperty(value = "备注") |
| | | private String remark; |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.resource.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.tenant.mp.TenantEntity; |
| | | |
| | | /** |
| | | * 短信配置表实体类 |
| | | * |
| | | * @author BladeX |
| | | */ |
| | | @Data |
| | | @TableName("blade_sms") |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "Sms对象", description = "短信配置表") |
| | | public class Sms extends TenantEntity { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 资源编号 |
| | | */ |
| | | @ApiModelProperty(value = "资源编号") |
| | | private String smsCode; |
| | | |
| | | /** |
| | | * 模板ID |
| | | */ |
| | | @ApiModelProperty(value = "模板ID") |
| | | private String templateId; |
| | | /** |
| | | * 分类 |
| | | */ |
| | | @ApiModelProperty(value = "分类") |
| | | private Integer category; |
| | | /** |
| | | * accessKey |
| | | */ |
| | | @ApiModelProperty(value = "accessKey") |
| | | private String accessKey; |
| | | /** |
| | | * secretKey |
| | | */ |
| | | @ApiModelProperty(value = "secretKey") |
| | | private String secretKey; |
| | | /** |
| | | * regionId |
| | | */ |
| | | @ApiModelProperty(value = "regionId") |
| | | private String regionId; |
| | | /** |
| | | * 短信签名 |
| | | */ |
| | | @ApiModelProperty(value = "短信签名") |
| | | private String signName; |
| | | /** |
| | | * 备注 |
| | | */ |
| | | @ApiModelProperty(value = "备注") |
| | | private String remark; |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.resource.enums; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | import org.springblade.core.tool.utils.StringPool; |
| | | |
| | | /** |
| | | * Sms资源编码枚举类 |
| | | * |
| | | * @author Chill |
| | | * @apiNote 该枚举类对应短信配置模块的资源编码,可根据业务需求自行拓展 |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum SmsCodeEnum { |
| | | |
| | | /** |
| | | * 默认编号 |
| | | */ |
| | | DEFAULT(StringPool.EMPTY, 1), |
| | | |
| | | /** |
| | | * 验证码编号 |
| | | */ |
| | | VALIDATE("validate", 2), |
| | | |
| | | /** |
| | | * 通知公告编号 |
| | | */ |
| | | NOTICE("notice", 3), |
| | | |
| | | /** |
| | | * 下单通知编号 |
| | | */ |
| | | ORDER("order", 4), |
| | | |
| | | /** |
| | | * 会议通知编号 |
| | | */ |
| | | MEETING("meeting", 5), |
| | | ; |
| | | |
| | | final String name; |
| | | final int category; |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.resource.feign; |
| | | |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import org.springblade.core.sms.model.SmsResponse; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | /** |
| | | * ISmsClient |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @FeignClient( |
| | | value = AppConstant.APPLICATION_RESOURCE_NAME, |
| | | fallback = ISmsClientFallback.class |
| | | ) |
| | | public interface ISmsClient { |
| | | String API_PREFIX = "/client"; |
| | | String SEND_MESSAGE = API_PREFIX + "/send-message"; |
| | | String SEND_VALIDATE = API_PREFIX + "/send-validate"; |
| | | String VALIDATE_MESSAGE = API_PREFIX + "/validate-message"; |
| | | |
| | | /** |
| | | * 通用短信发送 |
| | | * |
| | | * @param code 资源编号 |
| | | * @param params 模板参数 |
| | | * @param phones 手机号集合 |
| | | * @return R |
| | | */ |
| | | @PostMapping(SEND_MESSAGE) |
| | | R<SmsResponse> sendMessage(@RequestParam("code") String code, @RequestParam("params") String params, @RequestParam("phones") String phones); |
| | | |
| | | /** |
| | | * 短信验证码发送 |
| | | * |
| | | * @param code 资源编号 |
| | | * @param phone 手机号 |
| | | * @return R |
| | | */ |
| | | @PostMapping(SEND_VALIDATE) |
| | | R sendValidate(@RequestParam("code") String code, @RequestParam("phone") String phone); |
| | | |
| | | /** |
| | | * 校验短信 |
| | | * |
| | | * @param code 资源编号 |
| | | * @param id 校验id |
| | | * @param value 校验值 |
| | | * @param phone 手机号 |
| | | * @return R |
| | | */ |
| | | @PostMapping(VALIDATE_MESSAGE) |
| | | R validateMessage(@RequestParam("code") String code, @RequestParam("id") String id, @RequestParam("value") String value, @RequestParam("phone") String phone); |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.resource.feign; |
| | | |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * 流程远程调用失败处理类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Component |
| | | public class ISmsClientFallback implements ISmsClient { |
| | | @Override |
| | | public R sendMessage(String code, String params, String phones) { |
| | | return R.fail("远程调用失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R sendValidate(String code, String phone) { |
| | | return R.fail("远程调用失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R validateMessage(String code, String id, String value, String phone) { |
| | | return R.fail("远程调用失败"); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.resource.utils; |
| | | |
| | | import cn.gistack.resource.feign.ISmsClient; |
| | | import org.springblade.core.sms.model.SmsCode; |
| | | import org.springblade.core.sms.model.SmsResponse; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.jackson.JsonUtil; |
| | | import org.springblade.core.tool.utils.RandomType; |
| | | import org.springblade.core.tool.utils.SpringUtil; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 短信服务工具类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class SmsUtil { |
| | | |
| | | public static final String PARAM_KEY = "code"; |
| | | public static final String SEND_SUCCESS = "短信发送成功"; |
| | | public static final String SEND_FAIL = "短信发送失败"; |
| | | public static final String VALIDATE_SUCCESS = "短信校验成功"; |
| | | public static final String VALIDATE_FAIL = "短信校验失败"; |
| | | |
| | | private static ISmsClient smsClient; |
| | | |
| | | /** |
| | | * 获取短信服务构建类 |
| | | * |
| | | * @return SmsBuilder |
| | | */ |
| | | public static ISmsClient getSmsClient() { |
| | | if (smsClient == null) { |
| | | smsClient = SpringUtil.getBean(ISmsClient.class); |
| | | } |
| | | return smsClient; |
| | | } |
| | | |
| | | /** |
| | | * 获取短信验证码参数 |
| | | * |
| | | * @return 验证码参数 |
| | | */ |
| | | public static Map<String, String> getValidateParams() { |
| | | Map<String, String> params = new HashMap<>(1); |
| | | params.put(PARAM_KEY, StringUtil.random(6, RandomType.INT)); |
| | | return params; |
| | | } |
| | | |
| | | /** |
| | | * 发送短信 |
| | | * |
| | | * @param code 资源编号 |
| | | * @param params 模板参数 |
| | | * @param phones 手机号集合 |
| | | * @return 发送结果 |
| | | */ |
| | | public static SmsResponse sendMessage(String code, Map<String, String> params, String phones) { |
| | | R<SmsResponse> result = getSmsClient().sendMessage(code, JsonUtil.toJson(params), phones); |
| | | return result.getData(); |
| | | } |
| | | |
| | | /** |
| | | * 发送验证码 |
| | | * |
| | | * @param code 资源编号 |
| | | * @param phone 手机号 |
| | | * @return 发送结果 |
| | | */ |
| | | public static SmsCode sendValidate(String code, String phone) { |
| | | SmsCode smsCode = new SmsCode(); |
| | | R result = getSmsClient().sendValidate(code, phone); |
| | | if (result.isSuccess()) { |
| | | smsCode = JsonUtil.parse(JsonUtil.toJson(result.getData()), SmsCode.class); |
| | | } else { |
| | | smsCode.setSuccess(Boolean.FALSE); |
| | | } |
| | | return smsCode; |
| | | } |
| | | |
| | | /** |
| | | * 校验短信 |
| | | * |
| | | * @param code 资源编号 |
| | | * @param id 校验id |
| | | * @param value 校验值 |
| | | * @return 发送结果 |
| | | */ |
| | | public static boolean validateMessage(String code, String id, String value, String phone) { |
| | | R result = getSmsClient().validateMessage(code, id, value, phone); |
| | | return result.isSuccess(); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.resource.vo; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import cn.gistack.resource.entity.Attach; |
| | | |
| | | /** |
| | | * 附件表视图实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "AttachVO对象", description = "附件表") |
| | | public class AttachVO extends Attach { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | } |
| New file |
| | |
| | | package cn.gistack.resource.vo; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import cn.gistack.resource.entity.Oss; |
| | | |
| | | /** |
| | | * OssVO |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "OssVO对象", description = "对象存储表") |
| | | public class OssVO extends Oss { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 分类名 |
| | | */ |
| | | private String categoryName; |
| | | |
| | | /** |
| | | * 是否启用 |
| | | */ |
| | | private String statusName; |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.resource.vo; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import cn.gistack.resource.entity.Sms; |
| | | |
| | | /** |
| | | * 短信配置表视图实体类 |
| | | * |
| | | * @author BladeX |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "SmsVO对象", description = "短信配置表") |
| | | public class SmsVO extends Sms { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 分类名 |
| | | */ |
| | | private String categoryName; |
| | | |
| | | /** |
| | | * 是否启用 |
| | | */ |
| | | private String statusName; |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <project xmlns="http://maven.apache.org/POM/4.0.0" |
| | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| | | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| | | <parent> |
| | | <artifactId>skjcmanager</artifactId> |
| | | <groupId>org.springblade</groupId> |
| | | <version>3.0.1.RELEASE</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | | <artifactId>skjcmanager-plugin-api</artifactId> |
| | | <name>${project.artifactId}</name> |
| | | <version>3.0.1.RELEASE</version> |
| | | <packaging>pom</packaging> |
| | | |
| | | <build> |
| | | <plugins> |
| | | <plugin> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-maven-plugin</artifactId> |
| | | <configuration> |
| | | <skip>true</skip> |
| | | <finalName>${project.name}</finalName> |
| | | </configuration> |
| | | </plugin> |
| | | </plugins> |
| | | </build> |
| | | |
| | | </project> |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <project xmlns="http://maven.apache.org/POM/4.0.0" |
| | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| | | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| | | <parent> |
| | | <artifactId>skjcmanager</artifactId> |
| | | <groupId>org.springblade</groupId> |
| | | <version>3.0.1.RELEASE</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | | <artifactId>skjcmanager-plugin</artifactId> |
| | | <name>${project.artifactId}</name> |
| | | <version>3.0.1.RELEASE</version> |
| | | <packaging>pom</packaging> |
| | | |
| | | </project> |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <project xmlns="http://maven.apache.org/POM/4.0.0" |
| | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| | | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| | | <parent> |
| | | <artifactId>skjcmanager</artifactId> |
| | | <groupId>org.springblade</groupId> |
| | | <version>3.0.1.RELEASE</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | | <artifactId>skjcmanager-service-api</artifactId> |
| | | <name>${project.artifactId}</name> |
| | | <version>3.0.1.RELEASE</version> |
| | | <packaging>pom</packaging> |
| | | <description>BladeX 微服务API集合</description> |
| | | |
| | | <modules> |
| | | <module>skjcmanager-desk-api</module> |
| | | <module>skjcmanager-dict-api</module> |
| | | <module>skjcmanager-scope-api</module> |
| | | <module>skjcmanager-system-api</module> |
| | | <module>skjcmanager-user-api</module> |
| | | </modules> |
| | | |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>blade-starter-mybatis</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>blade-starter-tenant</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springframework.cloud</groupId> |
| | | <artifactId>spring-cloud-starter-openfeign</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>io.springfox</groupId> |
| | | <artifactId>springfox-swagger2</artifactId> |
| | | <exclusions> |
| | | <exclusion> |
| | | <groupId>io.swagger</groupId> |
| | | <artifactId>swagger-models</artifactId> |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>io.swagger</groupId> |
| | | <artifactId>swagger-models</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>blade-core-auto</artifactId> |
| | | <scope>provided</scope> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | <build> |
| | | <plugins> |
| | | <plugin> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-maven-plugin</artifactId> |
| | | <configuration> |
| | | <skip>true</skip> |
| | | <finalName>${project.name}</finalName> |
| | | </configuration> |
| | | </plugin> |
| | | </plugins> |
| | | </build> |
| | | |
| | | </project> |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <project xmlns="http://maven.apache.org/POM/4.0.0" |
| | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| | | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| | | <parent> |
| | | <artifactId>skjcmanager-service-api</artifactId> |
| | | <groupId>org.springblade</groupId> |
| | | <version>3.0.1.RELEASE</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | | <artifactId>skjcmanager-desk-api</artifactId> |
| | | <name>${project.artifactId}</name> |
| | | <version>${bladex.project.version}</version> |
| | | <packaging>jar</packaging> |
| | | |
| | | </project> |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.desk.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.tenant.mp.TenantEntity; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @TableName("blade_notice") |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class Notice extends TenantEntity { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 标题 |
| | | */ |
| | | @ApiModelProperty(value = "标题") |
| | | private String title; |
| | | |
| | | /** |
| | | * 通知类型 |
| | | */ |
| | | @ApiModelProperty(value = "通知类型") |
| | | private Integer category; |
| | | |
| | | /** |
| | | * 发布日期 |
| | | */ |
| | | @ApiModelProperty(value = "发布日期") |
| | | private Date releaseTime; |
| | | |
| | | /** |
| | | * 内容 |
| | | */ |
| | | @ApiModelProperty(value = "内容") |
| | | private String content; |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.desk.feign; |
| | | |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import org.springblade.core.mp.support.BladePage; |
| | | import cn.gistack.desk.entity.Notice; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | /** |
| | | * Notice Feign接口类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @FeignClient( |
| | | value = AppConstant.APPLICATION_DESK_NAME |
| | | ) |
| | | public interface INoticeClient { |
| | | |
| | | String API_PREFIX = "/client"; |
| | | String TOP = API_PREFIX + "/top"; |
| | | |
| | | /** |
| | | * 获取notice列表 |
| | | * |
| | | * @param current |
| | | * @param size |
| | | * @return |
| | | */ |
| | | @GetMapping(TOP) |
| | | BladePage<Notice> top(@RequestParam("current") Integer current, @RequestParam("size") Integer size); |
| | | |
| | | } |
| New file |
| | |
| | | package cn.gistack.desk.vo; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import cn.gistack.desk.entity.Notice; |
| | | |
| | | /** |
| | | * 通知公告视图类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class NoticeVO extends Notice { |
| | | |
| | | @ApiModelProperty(value = "通知类型名") |
| | | private String categoryName; |
| | | |
| | | @ApiModelProperty(value = "租户编号") |
| | | private String tenantId; |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <project xmlns="http://maven.apache.org/POM/4.0.0" |
| | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| | | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| | | <parent> |
| | | <artifactId>skjcmanager-service-api</artifactId> |
| | | <groupId>org.springblade</groupId> |
| | | <version>3.0.1.RELEASE</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | | <artifactId>skjcmanager-dict-api</artifactId> |
| | | <name>${project.artifactId}</name> |
| | | <version>${bladex.project.version}</version> |
| | | <packaging>jar</packaging> |
| | | |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>blade-starter-cache</artifactId> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | </project> |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.cache; |
| | | |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.SpringUtil; |
| | | import org.springblade.core.tool.utils.StringPool; |
| | | import cn.gistack.system.entity.DictBiz; |
| | | import cn.gistack.system.enums.DictBizEnum; |
| | | import cn.gistack.system.feign.IDictBizClient; |
| | | |
| | | import java.util.List; |
| | | |
| | | import static org.springblade.core.cache.constant.CacheConstant.DICT_CACHE; |
| | | |
| | | /** |
| | | * 业务字典缓存工具类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class DictBizCache { |
| | | |
| | | private static final String DICT_ID = "dictBiz:id"; |
| | | private static final String DICT_VALUE = "dictBiz:value"; |
| | | private static final String DICT_LIST = "dictBiz:list"; |
| | | |
| | | private static IDictBizClient dictClient; |
| | | |
| | | private static IDictBizClient getDictClient() { |
| | | if (dictClient == null) { |
| | | dictClient = SpringUtil.getBean(IDictBizClient.class); |
| | | } |
| | | return dictClient; |
| | | } |
| | | |
| | | /** |
| | | * 获取字典实体 |
| | | * |
| | | * @param id 主键 |
| | | * @return DictBiz |
| | | */ |
| | | public static DictBiz getById(Long id) { |
| | | String keyPrefix = DICT_ID.concat(StringPool.DASH).concat(AuthUtil.getTenantId()).concat(StringPool.COLON); |
| | | return CacheUtil.get(DICT_CACHE, keyPrefix, id, () -> { |
| | | R<DictBiz> result = getDictClient().getById(id); |
| | | return result.getData(); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 获取字典值 |
| | | * |
| | | * @param code 字典编号枚举 |
| | | * @param dictKey Integer型字典键 |
| | | * @return String |
| | | */ |
| | | public static String getValue(DictBizEnum code, Integer dictKey) { |
| | | return getValue(code.getName(), dictKey); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取字典值 |
| | | * |
| | | * @param code 字典编号 |
| | | * @param dictKey Integer型字典键 |
| | | * @return String |
| | | */ |
| | | public static String getValue(String code, Integer dictKey) { |
| | | String keyPrefix = DICT_VALUE.concat(StringPool.DASH).concat(AuthUtil.getTenantId()).concat(StringPool.COLON); |
| | | return CacheUtil.get(DICT_CACHE, keyPrefix + code + StringPool.COLON, String.valueOf(dictKey), () -> { |
| | | R<String> result = getDictClient().getValue(code, String.valueOf(dictKey)); |
| | | return result.getData(); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 获取字典值 |
| | | * |
| | | * @param code 字典编号枚举 |
| | | * @param dictKey String型字典键 |
| | | * @return String |
| | | */ |
| | | public static String getValue(DictBizEnum code, String dictKey) { |
| | | return getValue(code.getName(), dictKey); |
| | | } |
| | | |
| | | /** |
| | | * 获取字典值 |
| | | * |
| | | * @param code 字典编号 |
| | | * @param dictKey String型字典键 |
| | | * @return String |
| | | */ |
| | | public static String getValue(String code, String dictKey) { |
| | | String keyPrefix = DICT_VALUE.concat(StringPool.DASH).concat(AuthUtil.getTenantId()).concat(StringPool.COLON); |
| | | return CacheUtil.get(DICT_CACHE, keyPrefix + code + StringPool.COLON, dictKey, () -> { |
| | | R<String> result = getDictClient().getValue(code, dictKey); |
| | | return result.getData(); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 获取字典集合 |
| | | * |
| | | * @param code 字典编号 |
| | | * @return List<DictBiz> |
| | | */ |
| | | public static List<DictBiz> getList(String code) { |
| | | String keyPrefix = DICT_LIST.concat(StringPool.DASH).concat(AuthUtil.getTenantId()).concat(StringPool.COLON); |
| | | return CacheUtil.get(DICT_CACHE, keyPrefix, code, () -> { |
| | | R<List<DictBiz>> result = getDictClient().getList(code); |
| | | return result.getData(); |
| | | }); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.cache; |
| | | |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.SpringUtil; |
| | | import org.springblade.core.tool.utils.StringPool; |
| | | import cn.gistack.system.entity.Dict; |
| | | import cn.gistack.system.enums.DictEnum; |
| | | import cn.gistack.system.feign.IDictClient; |
| | | |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | |
| | | import static org.springblade.core.cache.constant.CacheConstant.DICT_CACHE; |
| | | |
| | | /** |
| | | * 字典缓存工具类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class DictCache { |
| | | |
| | | private static final String DICT_ID = "dict:id:"; |
| | | private static final String DICT_KEY = "dict:key:"; |
| | | private static final String DICT_VALUE = "dict:value:"; |
| | | private static final String DICT_LIST = "dict:list:"; |
| | | |
| | | private static final Boolean TENANT_MODE = Boolean.FALSE; |
| | | |
| | | private static IDictClient dictClient; |
| | | |
| | | private static IDictClient getDictClient() { |
| | | if (dictClient == null) { |
| | | dictClient = SpringUtil.getBean(IDictClient.class); |
| | | } |
| | | return dictClient; |
| | | } |
| | | |
| | | /** |
| | | * 获取字典实体 |
| | | * |
| | | * @param id 主键 |
| | | * @return Dict |
| | | */ |
| | | public static Dict getById(Long id) { |
| | | return CacheUtil.get(DICT_CACHE, DICT_ID, id, () -> { |
| | | R<Dict> result = getDictClient().getById(id); |
| | | return result.getData(); |
| | | }, TENANT_MODE); |
| | | } |
| | | |
| | | /** |
| | | * 获取字典值 |
| | | * |
| | | * @param code 字典编号枚举 |
| | | * @param dictValue 字典值 |
| | | * @return String |
| | | */ |
| | | public static String getKey(DictEnum code, String dictValue) { |
| | | return getKey(code.getName(), dictValue); |
| | | } |
| | | |
| | | /** |
| | | * 获取字典键 |
| | | * |
| | | * @param code 字典编号 |
| | | * @param dictValue 字典值 |
| | | * @return String |
| | | */ |
| | | public static String getKey(String code, String dictValue) { |
| | | return CacheUtil.get(DICT_CACHE, DICT_KEY + code + StringPool.COLON, dictValue, () -> { |
| | | List<Dict> list = getList(code); |
| | | Optional<String> key = list.stream().filter( |
| | | dict -> dict.getDictValue().equalsIgnoreCase(dictValue) |
| | | ).map(Dict::getDictKey).findFirst(); |
| | | return key.orElse(StringPool.EMPTY); |
| | | }, TENANT_MODE); |
| | | } |
| | | |
| | | /** |
| | | * 获取字典值 |
| | | * |
| | | * @param code 字典编号枚举 |
| | | * @param dictKey Integer型字典键 |
| | | * @return String |
| | | */ |
| | | public static String getValue(DictEnum code, Integer dictKey) { |
| | | return getValue(code.getName(), dictKey); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取字典值 |
| | | * |
| | | * @param code 字典编号 |
| | | * @param dictKey Integer型字典键 |
| | | * @return String |
| | | */ |
| | | public static String getValue(String code, Integer dictKey) { |
| | | return CacheUtil.get(DICT_CACHE, DICT_VALUE + code + StringPool.COLON, String.valueOf(dictKey), () -> { |
| | | R<String> result = getDictClient().getValue(code, String.valueOf(dictKey)); |
| | | return result.getData(); |
| | | }, TENANT_MODE); |
| | | } |
| | | |
| | | /** |
| | | * 获取字典值 |
| | | * |
| | | * @param code 字典编号枚举 |
| | | * @param dictKey String型字典键 |
| | | * @return String |
| | | */ |
| | | public static String getValue(DictEnum code, String dictKey) { |
| | | return getValue(code.getName(), dictKey); |
| | | } |
| | | |
| | | /** |
| | | * 获取字典值 |
| | | * |
| | | * @param code 字典编号 |
| | | * @param dictKey String型字典键 |
| | | * @return String |
| | | */ |
| | | public static String getValue(String code, String dictKey) { |
| | | return CacheUtil.get(DICT_CACHE, DICT_VALUE + code + StringPool.COLON, dictKey, () -> { |
| | | R<String> result = getDictClient().getValue(code, dictKey); |
| | | return result.getData(); |
| | | }, TENANT_MODE); |
| | | } |
| | | |
| | | /** |
| | | * 获取字典集合 |
| | | * |
| | | * @param code 字典编号 |
| | | * @return List<Dict> |
| | | */ |
| | | public static List<Dict> getList(String code) { |
| | | return CacheUtil.get(DICT_CACHE, DICT_LIST, code, () -> { |
| | | R<List<Dict>> result = getDictClient().getList(code); |
| | | return result.getData(); |
| | | }, TENANT_MODE); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.constant; |
| | | |
| | | /** |
| | | * 字典常量. |
| | | * |
| | | * @author zhuangqian |
| | | */ |
| | | public interface DictConstant { |
| | | |
| | | String SEX_CODE = "sex"; |
| | | |
| | | String NOTICE_CODE = "notice"; |
| | | |
| | | String MENU_CATEGORY_CODE = "menu_category"; |
| | | |
| | | String BUTTON_FUNC_CODE = "button_func"; |
| | | |
| | | String YES_NO_CODE = "yes_no"; |
| | | |
| | | String FLOW_CATEGORY_CODE = "flow_category"; |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.dto; |
| | | |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import cn.gistack.system.entity.Dict; |
| | | |
| | | /** |
| | | * 数据传输对象实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class DictDTO extends Dict { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableLogic; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * 实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @TableName("blade_dict") |
| | | @ApiModel(value = "Dict对象", description = "Dict对象") |
| | | public class Dict implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "主键") |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 父主键 |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "父主键") |
| | | private Long parentId; |
| | | |
| | | /** |
| | | * 字典码 |
| | | */ |
| | | @ApiModelProperty(value = "字典码") |
| | | private String code; |
| | | |
| | | /** |
| | | * 字典值 |
| | | */ |
| | | @ApiModelProperty(value = "字典值") |
| | | private String dictKey; |
| | | |
| | | /** |
| | | * 字典名称 |
| | | */ |
| | | @ApiModelProperty(value = "字典名称") |
| | | private String dictValue; |
| | | |
| | | /** |
| | | * 排序 |
| | | */ |
| | | @ApiModelProperty(value = "排序") |
| | | private Integer sort; |
| | | |
| | | /** |
| | | * 字典备注 |
| | | */ |
| | | @ApiModelProperty(value = "字典备注") |
| | | private String remark; |
| | | |
| | | /** |
| | | * 是否已封存 |
| | | */ |
| | | @ApiModelProperty(value = "是否已封存") |
| | | private Integer isSealed; |
| | | |
| | | /** |
| | | * 是否已删除 |
| | | */ |
| | | @TableLogic |
| | | @ApiModelProperty(value = "是否已删除") |
| | | private Integer isDeleted; |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableLogic; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * 实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @TableName("blade_dict_biz") |
| | | @ApiModel(value = "DictBiz对象", description = "DictBiz对象") |
| | | public class DictBiz implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "主键") |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 租户ID |
| | | */ |
| | | @ApiModelProperty(value = "租户ID") |
| | | private String tenantId; |
| | | |
| | | /** |
| | | * 父主键 |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "父主键") |
| | | private Long parentId; |
| | | |
| | | /** |
| | | * 字典码 |
| | | */ |
| | | @ApiModelProperty(value = "字典码") |
| | | private String code; |
| | | |
| | | /** |
| | | * 字典值 |
| | | */ |
| | | @ApiModelProperty(value = "字典值") |
| | | private String dictKey; |
| | | |
| | | /** |
| | | * 字典名称 |
| | | */ |
| | | @ApiModelProperty(value = "字典名称") |
| | | private String dictValue; |
| | | |
| | | /** |
| | | * 排序 |
| | | */ |
| | | @ApiModelProperty(value = "排序") |
| | | private Integer sort; |
| | | |
| | | /** |
| | | * 字典备注 |
| | | */ |
| | | @ApiModelProperty(value = "字典备注") |
| | | private String remark; |
| | | |
| | | /** |
| | | * 是否已封存 |
| | | */ |
| | | @ApiModelProperty(value = "是否已封存") |
| | | private Integer isSealed; |
| | | |
| | | /** |
| | | * 是否已删除 |
| | | */ |
| | | @TableLogic |
| | | @ApiModelProperty(value = "是否已删除") |
| | | private Integer isDeleted; |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.enums; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * 业务字典枚举类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum DictBizEnum { |
| | | |
| | | /** |
| | | * 测试 |
| | | */ |
| | | TEST("test"), |
| | | ; |
| | | |
| | | final String name; |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.enums; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * 系统字典枚举类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum DictEnum { |
| | | |
| | | /** |
| | | * 性别 |
| | | */ |
| | | SEX("sex"), |
| | | /** |
| | | * 通知类型 |
| | | */ |
| | | NOTICE("notice"), |
| | | /** |
| | | * 菜单类型 |
| | | */ |
| | | MENU_CATEGORY("menu_category"), |
| | | /** |
| | | * 按钮功能 |
| | | */ |
| | | BUTTON_FUNC("button_func"), |
| | | /** |
| | | * 是否 |
| | | */ |
| | | YES_NO("yes_no"), |
| | | /** |
| | | * 流程类型 |
| | | */ |
| | | FLOW("flow"), |
| | | /** |
| | | * 机构类型 |
| | | */ |
| | | ORG_CATEGORY("org_category"), |
| | | /** |
| | | * 数据权限 |
| | | */ |
| | | DATA_SCOPE_TYPE("data_scope_type"), |
| | | /** |
| | | * 接口权限 |
| | | */ |
| | | API_SCOPE_TYPE("api_scope_type"), |
| | | /** |
| | | * 权限类型 |
| | | */ |
| | | SCOPE_CATEGORY("scope_category"), |
| | | /** |
| | | * 对象存储类型 |
| | | */ |
| | | OSS("oss"), |
| | | /** |
| | | * 短信服务类型 |
| | | */ |
| | | SMS("sms"), |
| | | /** |
| | | * 岗位类型 |
| | | */ |
| | | POST_CATEGORY("post_category"), |
| | | /** |
| | | * 行政区划 |
| | | */ |
| | | REGION("region"), |
| | | /** |
| | | * 用户平台 |
| | | */ |
| | | USER_TYPE("user_type"), |
| | | ; |
| | | |
| | | final String name; |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.feign; |
| | | |
| | | |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import org.springblade.core.tool.api.R; |
| | | import cn.gistack.system.entity.DictBiz; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Feign接口类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @FeignClient( |
| | | value = AppConstant.APPLICATION_SYSTEM_NAME, |
| | | fallback = IDictBizClientFallback.class |
| | | ) |
| | | public interface IDictBizClient { |
| | | |
| | | String API_PREFIX = "/client"; |
| | | String GET_BY_ID = API_PREFIX + "/dict-biz/get-by-id"; |
| | | String GET_VALUE = API_PREFIX + "/dict-biz/get-value"; |
| | | String GET_LIST = API_PREFIX + "/dict-biz/get-list"; |
| | | |
| | | /** |
| | | * 获取字典实体 |
| | | * |
| | | * @param id 主键 |
| | | * @return |
| | | */ |
| | | @GetMapping(GET_BY_ID) |
| | | R<DictBiz> getById(@RequestParam("id") Long id); |
| | | |
| | | /** |
| | | * 获取字典表对应值 |
| | | * |
| | | * @param code 字典编号 |
| | | * @param dictKey 字典序号 |
| | | * @return |
| | | */ |
| | | @GetMapping(GET_VALUE) |
| | | R<String> getValue(@RequestParam("code") String code, @RequestParam("dictKey") String dictKey); |
| | | |
| | | /** |
| | | * 获取字典表 |
| | | * |
| | | * @param code 字典编号 |
| | | * @return |
| | | */ |
| | | @GetMapping(GET_LIST) |
| | | R<List<DictBiz>> getList(@RequestParam("code") String code); |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.feign; |
| | | |
| | | import org.springblade.core.tool.api.R; |
| | | import cn.gistack.system.entity.DictBiz; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Feign失败配置 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Component |
| | | public class IDictBizClientFallback implements IDictBizClient { |
| | | @Override |
| | | public R<DictBiz> getById(Long id) { |
| | | return R.fail("获取数据失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R<String> getValue(String code, String dictKey) { |
| | | return R.fail("获取数据失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R<List<DictBiz>> getList(String code) { |
| | | return R.fail("获取数据失败"); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.feign; |
| | | |
| | | |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import org.springblade.core.tool.api.R; |
| | | import cn.gistack.system.entity.Dict; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Feign接口类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @FeignClient( |
| | | value = AppConstant.APPLICATION_SYSTEM_NAME, |
| | | fallback = IDictClientFallback.class |
| | | ) |
| | | public interface IDictClient { |
| | | |
| | | String API_PREFIX = "/client"; |
| | | String GET_BY_ID = API_PREFIX + "/dict/get-by-id"; |
| | | String GET_VALUE = API_PREFIX + "/dict/get-value"; |
| | | String GET_LIST = API_PREFIX + "/dict/get-list"; |
| | | |
| | | /** |
| | | * 获取字典实体 |
| | | * |
| | | * @param id 主键 |
| | | * @return |
| | | */ |
| | | @GetMapping(GET_BY_ID) |
| | | R<Dict> getById(@RequestParam("id") Long id); |
| | | |
| | | /** |
| | | * 获取字典表对应值 |
| | | * |
| | | * @param code 字典编号 |
| | | * @param dictKey 字典序号 |
| | | * @return |
| | | */ |
| | | @GetMapping(GET_VALUE) |
| | | R<String> getValue(@RequestParam("code") String code, @RequestParam("dictKey") String dictKey); |
| | | |
| | | /** |
| | | * 获取字典表 |
| | | * |
| | | * @param code 字典编号 |
| | | * @return |
| | | */ |
| | | @GetMapping(GET_LIST) |
| | | R<List<Dict>> getList(@RequestParam("code") String code); |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.feign; |
| | | |
| | | import org.springblade.core.tool.api.R; |
| | | import cn.gistack.system.entity.Dict; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Feign失败配置 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Component |
| | | public class IDictClientFallback implements IDictClient { |
| | | @Override |
| | | public R<Dict> getById(Long id) { |
| | | return R.fail("获取数据失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R<String> getValue(String code, String dictKey) { |
| | | return R.fail("获取数据失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R<List<Dict>> getList(String code) { |
| | | return R.fail("获取数据失败"); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.vo; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonInclude; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.tool.node.INode; |
| | | import cn.gistack.system.entity.DictBiz; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 视图实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "DictBizVO对象", description = "DictBizVO对象") |
| | | public class DictBizVO extends DictBiz implements INode<DictBizVO> { |
| | | private static final long serialVersionUID = 1L; |
| | | /** |
| | | * 主键ID |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 父节点ID |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long parentId; |
| | | |
| | | /** |
| | | * 子孙节点 |
| | | */ |
| | | @JsonInclude(JsonInclude.Include.NON_EMPTY) |
| | | private List<DictBizVO> children; |
| | | |
| | | @Override |
| | | public List<DictBizVO> getChildren() { |
| | | if (this.children == null) { |
| | | this.children = new ArrayList<>(); |
| | | } |
| | | return this.children; |
| | | } |
| | | |
| | | /** |
| | | * 上级字典 |
| | | */ |
| | | private String parentName; |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.vo; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonInclude; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.tool.node.INode; |
| | | import cn.gistack.system.entity.Dict; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 视图实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "DictVO对象", description = "DictVO对象") |
| | | public class DictVO extends Dict implements INode<DictVO> { |
| | | private static final long serialVersionUID = 1L; |
| | | /** |
| | | * 主键ID |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 父节点ID |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long parentId; |
| | | |
| | | /** |
| | | * 子孙节点 |
| | | */ |
| | | @JsonInclude(JsonInclude.Include.NON_EMPTY) |
| | | private List<DictVO> children; |
| | | |
| | | @Override |
| | | public List<DictVO> getChildren() { |
| | | if (this.children == null) { |
| | | this.children = new ArrayList<>(); |
| | | } |
| | | return this.children; |
| | | } |
| | | |
| | | /** |
| | | * 上级字典 |
| | | */ |
| | | private String parentName; |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <project xmlns="http://maven.apache.org/POM/4.0.0" |
| | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| | | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| | | <parent> |
| | | <artifactId>skjcmanager-service-api</artifactId> |
| | | <groupId>org.springblade</groupId> |
| | | <version>3.0.1.RELEASE</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | | <artifactId>skjcmanager-scope-api</artifactId> |
| | | <name>${project.artifactId}</name> |
| | | <version>${bladex.project.version}</version> |
| | | <packaging>jar</packaging> |
| | | |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>blade-core-secure</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>blade-starter-cache</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>blade-starter-datascope</artifactId> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | </project> |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.cache; |
| | | |
| | | import cn.gistack.system.feign.IApiScopeClient; |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.tool.utils.SpringUtil; |
| | | import org.springblade.core.tool.utils.StringPool; |
| | | |
| | | import java.util.List; |
| | | |
| | | import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE; |
| | | |
| | | /** |
| | | * 接口权限缓存 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class ApiScopeCache { |
| | | |
| | | private static final String SCOPE_CACHE_CODE = "apiScope:code:"; |
| | | |
| | | private static IApiScopeClient apiScopeClient; |
| | | |
| | | private static IApiScopeClient getApiScopeClient() { |
| | | if (apiScopeClient == null) { |
| | | apiScopeClient = SpringUtil.getBean(IApiScopeClient.class); |
| | | } |
| | | return apiScopeClient; |
| | | } |
| | | |
| | | /** |
| | | * 获取接口权限地址 |
| | | * |
| | | * @param roleId 角色id |
| | | * @return permissions |
| | | */ |
| | | public static List<String> permissionPath(String roleId) { |
| | | List<String> permissions = CacheUtil.get(SYS_CACHE, SCOPE_CACHE_CODE, roleId, List.class, Boolean.FALSE); |
| | | if (permissions == null) { |
| | | permissions = getApiScopeClient().permissionPath(roleId); |
| | | CacheUtil.put(SYS_CACHE, SCOPE_CACHE_CODE, roleId, permissions); |
| | | } |
| | | return permissions; |
| | | } |
| | | |
| | | /** |
| | | * 获取接口权限信息 |
| | | * |
| | | * @param permission 权限编号 |
| | | * @param roleId 角色id |
| | | * @return permissions |
| | | */ |
| | | public static List<String> permissionCode(String permission, String roleId) { |
| | | List<String> permissions = CacheUtil.get(SYS_CACHE, SCOPE_CACHE_CODE, permission + StringPool.COLON + roleId, List.class, Boolean.FALSE); |
| | | if (permissions == null) { |
| | | permissions = getApiScopeClient().permissionCode(permission, roleId); |
| | | CacheUtil.put(SYS_CACHE, SCOPE_CACHE_CODE, permission + StringPool.COLON + roleId, permissions); |
| | | } |
| | | return permissions; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.cache; |
| | | |
| | | import cn.gistack.system.feign.IDataScopeClient; |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.datascope.model.DataScopeModel; |
| | | import org.springblade.core.tool.utils.CollectionUtil; |
| | | import org.springblade.core.tool.utils.SpringUtil; |
| | | import org.springblade.core.tool.utils.StringPool; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | |
| | | import java.util.List; |
| | | |
| | | import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE; |
| | | |
| | | /** |
| | | * 数据权限缓存 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class DataScopeCache { |
| | | |
| | | private static final String SCOPE_CACHE_CODE = "dataScope:code:"; |
| | | private static final String SCOPE_CACHE_CLASS = "dataScope:class:"; |
| | | private static final String DEPT_CACHE_ANCESTORS = "dept:ancestors:"; |
| | | |
| | | private static IDataScopeClient dataScopeClient; |
| | | |
| | | private static IDataScopeClient getDataScopeClient() { |
| | | if (dataScopeClient == null) { |
| | | dataScopeClient = SpringUtil.getBean(IDataScopeClient.class); |
| | | } |
| | | return dataScopeClient; |
| | | } |
| | | |
| | | /** |
| | | * 获取数据权限 |
| | | * |
| | | * @param mapperId 数据权限mapperId |
| | | * @param roleId 用户角色集合 |
| | | * @return DataScopeModel |
| | | */ |
| | | public static DataScopeModel getDataScopeByMapper(String mapperId, String roleId) { |
| | | DataScopeModel dataScope = CacheUtil.get(SYS_CACHE, SCOPE_CACHE_CLASS, mapperId + StringPool.COLON + roleId, DataScopeModel.class, Boolean.FALSE); |
| | | if (dataScope == null || !dataScope.getSearched()) { |
| | | dataScope = getDataScopeClient().getDataScopeByMapper(mapperId, roleId); |
| | | CacheUtil.put(SYS_CACHE, SCOPE_CACHE_CLASS, mapperId + StringPool.COLON + roleId, dataScope); |
| | | } |
| | | return StringUtil.isNotBlank(dataScope.getResourceCode()) ? dataScope : null; |
| | | } |
| | | |
| | | /** |
| | | * 获取数据权限 |
| | | * |
| | | * @param code 数据权限资源编号 |
| | | * @return DataScopeModel |
| | | */ |
| | | public static DataScopeModel getDataScopeByCode(String code) { |
| | | DataScopeModel dataScope = CacheUtil.get(SYS_CACHE, SCOPE_CACHE_CODE, code, DataScopeModel.class, Boolean.FALSE); |
| | | if (dataScope == null || !dataScope.getSearched()) { |
| | | dataScope = getDataScopeClient().getDataScopeByCode(code); |
| | | CacheUtil.put(SYS_CACHE, SCOPE_CACHE_CODE, code, dataScope); |
| | | } |
| | | return StringUtil.isNotBlank(dataScope.getResourceCode()) ? dataScope : null; |
| | | } |
| | | |
| | | /** |
| | | * 获取部门子级 |
| | | * |
| | | * @param deptId 部门id |
| | | * @return deptIds |
| | | */ |
| | | public static List<Long> getDeptAncestors(Long deptId) { |
| | | List ancestors = CacheUtil.get(SYS_CACHE, DEPT_CACHE_ANCESTORS, deptId, List.class); |
| | | if (CollectionUtil.isEmpty(ancestors)) { |
| | | ancestors = getDataScopeClient().getDeptAncestors(deptId); |
| | | CacheUtil.put(SYS_CACHE, DEPT_CACHE_ANCESTORS, deptId, ancestors); |
| | | } |
| | | return ancestors; |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.config; |
| | | |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.core.datascope.handler.ScopeModelHandler; |
| | | import org.springblade.core.secure.config.RegistryConfiguration; |
| | | import org.springblade.core.secure.handler.IPermissionHandler; |
| | | import cn.gistack.system.handler.ApiScopePermissionHandler; |
| | | import cn.gistack.system.handler.DataScopeModelHandler; |
| | | import org.springframework.boot.autoconfigure.AutoConfigureBefore; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | /** |
| | | * 公共封装包配置类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Configuration(proxyBeanMethods = false) |
| | | @AllArgsConstructor |
| | | @AutoConfigureBefore(RegistryConfiguration.class) |
| | | public class ScopeConfiguration { |
| | | |
| | | @Bean |
| | | public ScopeModelHandler scopeModelHandler() { |
| | | return new DataScopeModelHandler(); |
| | | } |
| | | |
| | | @Bean |
| | | public IPermissionHandler permissionHandler() { |
| | | return new ApiScopePermissionHandler(); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.feign; |
| | | |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 接口权限Feign接口类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @FeignClient( |
| | | value = AppConstant.APPLICATION_SYSTEM_NAME, |
| | | fallback = IApiScopeClientFallback.class |
| | | ) |
| | | public interface IApiScopeClient { |
| | | |
| | | String API_PREFIX = "/client/api-scope"; |
| | | String PERMISSION_PATH = API_PREFIX + "/permission-path"; |
| | | String PERMISSION_CODE = API_PREFIX + "/permission-code"; |
| | | |
| | | /** |
| | | * 获取接口权限地址 |
| | | * |
| | | * @param roleId 角色id |
| | | * @return permissions |
| | | */ |
| | | @GetMapping(PERMISSION_PATH) |
| | | List<String> permissionPath(@RequestParam("roleId") String roleId); |
| | | |
| | | /** |
| | | * 获取接口权限信息 |
| | | * |
| | | * @param permission 权限编号 |
| | | * @param roleId 角色id |
| | | * @return permissions |
| | | */ |
| | | @GetMapping(PERMISSION_CODE) |
| | | List<String> permissionCode(@RequestParam("permission") String permission, @RequestParam("roleId") String roleId); |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.feign; |
| | | |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * IApiScopeClientFallback |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Component |
| | | public class IApiScopeClientFallback implements IApiScopeClient { |
| | | @Override |
| | | public List<String> permissionPath(String roleId) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public List<String> permissionCode(String permission, String roleId) { |
| | | return null; |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.feign; |
| | | |
| | | import org.springblade.core.datascope.model.DataScopeModel; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 数据权限Feign接口类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @FeignClient( |
| | | value = AppConstant.APPLICATION_SYSTEM_NAME, |
| | | fallback = IDataScopeClientFallback.class |
| | | ) |
| | | public interface IDataScopeClient { |
| | | |
| | | String API_PREFIX = "/client/data-scope"; |
| | | String GET_DATA_SCOPE_BY_MAPPER = API_PREFIX + "/by-mapper"; |
| | | String GET_DATA_SCOPE_BY_CODE = API_PREFIX + "/by-code"; |
| | | String GET_DEPT_ANCESTORS = API_PREFIX + "/dept-ancestors"; |
| | | |
| | | /** |
| | | * 获取数据权限 |
| | | * |
| | | * @param mapperId 数据权限mapperId |
| | | * @param roleId 用户角色集合 |
| | | * @return DataScopeModel |
| | | */ |
| | | @GetMapping(GET_DATA_SCOPE_BY_MAPPER) |
| | | DataScopeModel getDataScopeByMapper(@RequestParam("mapperId") String mapperId, @RequestParam("roleId") String roleId); |
| | | |
| | | /** |
| | | * 获取数据权限 |
| | | * |
| | | * @param code 数据权限资源编号 |
| | | * @return DataScopeModel |
| | | */ |
| | | @GetMapping(GET_DATA_SCOPE_BY_CODE) |
| | | DataScopeModel getDataScopeByCode(@RequestParam("code") String code); |
| | | |
| | | /** |
| | | * 获取部门子级 |
| | | * |
| | | * @param deptId 部门id |
| | | * @return deptIds |
| | | */ |
| | | @GetMapping(GET_DEPT_ANCESTORS) |
| | | List<Long> getDeptAncestors(@RequestParam("deptId") Long deptId); |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.feign; |
| | | |
| | | import org.springblade.core.datascope.model.DataScopeModel; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * IDataScopeClientFallback |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Component |
| | | public class IDataScopeClientFallback implements IDataScopeClient { |
| | | @Override |
| | | public DataScopeModel getDataScopeByMapper(String mapperId, String roleId) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public DataScopeModel getDataScopeByCode(String code) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public List<Long> getDeptAncestors(Long deptId) { |
| | | return null; |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.handler; |
| | | |
| | | import cn.gistack.system.cache.ApiScopeCache; |
| | | import org.springblade.core.secure.BladeUser; |
| | | import org.springblade.core.secure.handler.IPermissionHandler; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.utils.WebUtil; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 接口权限校验类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class ApiScopePermissionHandler implements IPermissionHandler { |
| | | |
| | | @Override |
| | | public boolean permissionAll() { |
| | | HttpServletRequest request = WebUtil.getRequest(); |
| | | BladeUser user = AuthUtil.getUser(); |
| | | if (request == null || user == null) { |
| | | return false; |
| | | } |
| | | String uri = request.getRequestURI(); |
| | | List<String> paths = ApiScopeCache.permissionPath(user.getRoleId()); |
| | | if (paths == null || paths.size() == 0) { |
| | | return false; |
| | | } |
| | | return paths.stream().anyMatch(uri::contains); |
| | | } |
| | | |
| | | @Override |
| | | public boolean hasPermission(String permission) { |
| | | HttpServletRequest request = WebUtil.getRequest(); |
| | | BladeUser user = AuthUtil.getUser(); |
| | | if (request == null || user == null) { |
| | | return false; |
| | | } |
| | | List<String> codes = ApiScopeCache.permissionCode(permission, user.getRoleId()); |
| | | return codes != null && codes.size() != 0; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.handler; |
| | | |
| | | import cn.gistack.system.cache.DataScopeCache; |
| | | import org.springblade.core.datascope.handler.ScopeModelHandler; |
| | | import org.springblade.core.datascope.model.DataScopeModel; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 通用数据权限规则 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class DataScopeModelHandler implements ScopeModelHandler { |
| | | |
| | | /** |
| | | * 获取数据权限 |
| | | * |
| | | * @param mapperId 数据权限mapperId |
| | | * @param roleId 用户角色集合 |
| | | * @return DataScopeModel |
| | | */ |
| | | @Override |
| | | public DataScopeModel getDataScopeByMapper(String mapperId, String roleId) { |
| | | return DataScopeCache.getDataScopeByMapper(mapperId, roleId); |
| | | } |
| | | |
| | | /** |
| | | * 获取数据权限 |
| | | * |
| | | * @param code 数据权限资源编号 |
| | | * @return DataScopeModel |
| | | */ |
| | | @Override |
| | | public DataScopeModel getDataScopeByCode(String code) { |
| | | return DataScopeCache.getDataScopeByCode(code); |
| | | } |
| | | |
| | | /** |
| | | * 获取部门子级 |
| | | * |
| | | * @param deptId 部门id |
| | | * @return deptIds |
| | | */ |
| | | @Override |
| | | public List<Long> getDeptAncestors(Long deptId) { |
| | | return DataScopeCache.getDeptAncestors(deptId); |
| | | } |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <project xmlns="http://maven.apache.org/POM/4.0.0" |
| | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| | | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| | | <parent> |
| | | <artifactId>skjcmanager-service-api</artifactId> |
| | | <groupId>org.springblade</groupId> |
| | | <version>3.0.1.RELEASE</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | | <artifactId>skjcmanager-system-api</artifactId> |
| | | <name>${project.artifactId}</name> |
| | | <version>${bladex.project.version}</version> |
| | | <packaging>jar</packaging> |
| | | |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>blade-starter-cache</artifactId> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | </project> |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.cache; |
| | | |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.SpringUtil; |
| | | import cn.gistack.system.entity.Param; |
| | | import cn.gistack.system.feign.ISysClient; |
| | | |
| | | import static org.springblade.core.cache.constant.CacheConstant.PARAM_CACHE; |
| | | |
| | | /** |
| | | * 参数缓存工具类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class ParamCache { |
| | | |
| | | private static final String PARAM_ID = "param:id:"; |
| | | private static final String PARAM_VALUE = "param:value:"; |
| | | |
| | | private static ISysClient sysClient; |
| | | |
| | | private static ISysClient getSysClient() { |
| | | if (sysClient == null) { |
| | | sysClient = SpringUtil.getBean(ISysClient.class); |
| | | } |
| | | return sysClient; |
| | | } |
| | | |
| | | /** |
| | | * 获取参数实体 |
| | | * |
| | | * @param id 主键 |
| | | * @return Param |
| | | */ |
| | | public static Param getById(Long id) { |
| | | return CacheUtil.get(PARAM_CACHE, PARAM_ID, id, () -> { |
| | | R<Param> result = getSysClient().getParam(id); |
| | | return result.getData(); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 获取参数配置 |
| | | * |
| | | * @param paramKey 参数值 |
| | | * @return String |
| | | */ |
| | | public static String getValue(String paramKey) { |
| | | return CacheUtil.get(PARAM_CACHE, PARAM_VALUE, paramKey, () -> { |
| | | R<String> result = getSysClient().getParamValue(paramKey); |
| | | return result.getData(); |
| | | }); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.cache; |
| | | |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.SpringUtil; |
| | | import cn.gistack.system.entity.Region; |
| | | import cn.gistack.system.feign.ISysClient; |
| | | |
| | | import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE; |
| | | |
| | | /** |
| | | * 行政区划缓存工具类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class RegionCache { |
| | | public static final int PROVINCE_LEVEL = 1; |
| | | public static final int CITY_LEVEL = 2; |
| | | public static final int DISTRICT_LEVEL = 3; |
| | | public static final int TOWN_LEVEL = 4; |
| | | public static final int VILLAGE_LEVEL = 5; |
| | | |
| | | private static final String REGION_CODE = "region:code:"; |
| | | |
| | | private static ISysClient sysClient; |
| | | |
| | | private static ISysClient getSysClient() { |
| | | if (sysClient == null) { |
| | | sysClient = SpringUtil.getBean(ISysClient.class); |
| | | } |
| | | return sysClient; |
| | | } |
| | | |
| | | /** |
| | | * 获取行政区划实体 |
| | | * |
| | | * @param code 区划编号 |
| | | * @return Param |
| | | */ |
| | | public static Region getByCode(String code) { |
| | | return CacheUtil.get(SYS_CACHE, REGION_CODE, code, () -> { |
| | | R<Region> result = getSysClient().getRegion(code); |
| | | return result.getData(); |
| | | }); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.cache; |
| | | |
| | | import cn.gistack.system.entity.*; |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.SpringUtil; |
| | | import org.springblade.core.tool.utils.StringPool; |
| | | import cn.gistack.system.feign.ISysClient; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE; |
| | | |
| | | /** |
| | | * 系统缓存 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class SysCache { |
| | | private static final String MENU_ID = "menu:id:"; |
| | | private static final String DEPT_ID = "dept:id:"; |
| | | private static final String DEPT_NAME = "dept:name:"; |
| | | private static final String DEPT_NAME_FUZZY = "dept:nameFuzzy:"; |
| | | private static final String DEPT_NAME_ID = "deptName:id:"; |
| | | private static final String DEPT_NAMES_ID = "deptNames:id:"; |
| | | private static final String DEPT_CHILD_ID = "deptChild:id:"; |
| | | private static final String DEPT_CHILDIDS_ID = "deptChildIds:id:"; |
| | | private static final String POST_ID = "post:id:"; |
| | | private static final String POST_NAME = "post:name:"; |
| | | private static final String POST_NAME_FUZZY = "post:nameFuzzy:"; |
| | | private static final String POST_NAME_ID = "postName:id:"; |
| | | private static final String POST_NAMES_ID = "postNames:id:"; |
| | | private static final String ROLE_ID = "role:id:"; |
| | | private static final String ROLE_NAME = "role:name:"; |
| | | private static final String ROLE_NAME_ID = "roleName:id:"; |
| | | private static final String ROLE_NAMES_ID = "roleNames:id:"; |
| | | private static final String ROLE_ALIAS_ID = "roleAlias:id:"; |
| | | private static final String ROLE_ALIASES_ID = "roleAliases:id:"; |
| | | public static final String TENANT_ID = "tenant:id:"; |
| | | public static final String TENANT_TENANT_ID = "tenant:tenantId:"; |
| | | public static final String TENANT_PACKAGE_ID = "tenant:packageId:"; |
| | | |
| | | private static ISysClient sysClient; |
| | | |
| | | private static ISysClient getSysClient() { |
| | | if (sysClient == null) { |
| | | sysClient = SpringUtil.getBean(ISysClient.class); |
| | | } |
| | | return sysClient; |
| | | } |
| | | |
| | | /** |
| | | * 获取菜单 |
| | | * |
| | | * @param id 主键 |
| | | * @return 菜单 |
| | | */ |
| | | public static Menu getMenu(Long id) { |
| | | return CacheUtil.get(SYS_CACHE, MENU_ID, id, () -> { |
| | | R<Menu> result = getSysClient().getMenu(id); |
| | | return result.getData(); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 获取部门 |
| | | * |
| | | * @param id 主键 |
| | | * @return 部门 |
| | | */ |
| | | public static Dept getDept(Long id) { |
| | | return CacheUtil.get(SYS_CACHE, DEPT_ID, id, () -> { |
| | | R<Dept> result = getSysClient().getDept(id); |
| | | return result.getData(); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 获取部门id |
| | | * |
| | | * @param tenantId 租户id |
| | | * @param deptNames 部门名 |
| | | * @return 部门id |
| | | */ |
| | | public static String getDeptIds(String tenantId, String deptNames) { |
| | | return CacheUtil.get(SYS_CACHE, DEPT_NAME, tenantId + StringPool.DASH + deptNames, () -> { |
| | | R<String> result = getSysClient().getDeptIds(tenantId, deptNames); |
| | | return result.getData(); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 获取部门id |
| | | * |
| | | * @param tenantId 租户id |
| | | * @param deptNames 部门名模糊查询 |
| | | * @return 部门id |
| | | */ |
| | | public static String getDeptIdsByFuzzy(String tenantId, String deptNames) { |
| | | return CacheUtil.get(SYS_CACHE, DEPT_NAME_FUZZY, tenantId + StringPool.DASH + deptNames, () -> { |
| | | R<String> result = getSysClient().getDeptIdsByFuzzy(tenantId, deptNames); |
| | | return result.getData(); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 获取部门名 |
| | | * |
| | | * @param id 主键 |
| | | * @return 部门名 |
| | | */ |
| | | public static String getDeptName(Long id) { |
| | | return CacheUtil.get(SYS_CACHE, DEPT_NAME_ID, id, () -> { |
| | | R<String> result = getSysClient().getDeptName(id); |
| | | return result.getData(); |
| | | }); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取部门名集合 |
| | | * |
| | | * @param deptIds 主键集合 |
| | | * @return 部门名 |
| | | */ |
| | | public static List<String> getDeptNames(String deptIds) { |
| | | return CacheUtil.get(SYS_CACHE, DEPT_NAMES_ID, deptIds, () -> { |
| | | R<List<String>> result = getSysClient().getDeptNames(deptIds); |
| | | return result.getData(); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 获取子部门集合 |
| | | * |
| | | * @param deptId 主键 |
| | | * @return 子部门 |
| | | */ |
| | | public static List<Dept> getDeptChild(Long deptId) { |
| | | return CacheUtil.get(SYS_CACHE, DEPT_CHILD_ID, deptId, () -> { |
| | | R<List<Dept>> result = getSysClient().getDeptChild(deptId); |
| | | return result.getData(); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 获取子部门ID集合 |
| | | * |
| | | * @param deptId 主键 |
| | | * @return 子部门ID |
| | | */ |
| | | public static List<Long> getDeptChildIds(Long deptId) { |
| | | if (deptId == null) { |
| | | return null; |
| | | } |
| | | List<Long> deptIdList = CacheUtil.get(SYS_CACHE, DEPT_CHILDIDS_ID, deptId, List.class); |
| | | if (deptIdList == null) { |
| | | deptIdList = new ArrayList<>(); |
| | | List<Dept> deptChild = getDeptChild(deptId); |
| | | if (deptChild != null) { |
| | | List<Long> collect = deptChild.stream().map(Dept::getId).collect(Collectors.toList()); |
| | | deptIdList.addAll(collect); |
| | | } |
| | | deptIdList.add(deptId); |
| | | CacheUtil.put(SYS_CACHE, DEPT_CHILDIDS_ID, deptId, deptIdList); |
| | | } |
| | | return deptIdList; |
| | | } |
| | | |
| | | /** |
| | | * 获取岗位 |
| | | * |
| | | * @param id 主键 |
| | | * @return |
| | | */ |
| | | public static Post getPost(Long id) { |
| | | return CacheUtil.get(SYS_CACHE, POST_ID, id, () -> { |
| | | R<Post> result = getSysClient().getPost(id); |
| | | return result.getData(); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 获取岗位id |
| | | * |
| | | * @param tenantId 租户id |
| | | * @param postNames 岗位名 |
| | | * @return |
| | | */ |
| | | public static String getPostIds(String tenantId, String postNames) { |
| | | return CacheUtil.get(SYS_CACHE, POST_NAME, tenantId + StringPool.DASH + postNames, () -> { |
| | | R<String> result = getSysClient().getPostIds(tenantId, postNames); |
| | | return result.getData(); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 获取岗位id |
| | | * |
| | | * @param tenantId 租户id |
| | | * @param postNames 岗位名模糊查询 |
| | | * @return |
| | | */ |
| | | public static String getPostIdsByFuzzy(String tenantId, String postNames) { |
| | | return CacheUtil.get(SYS_CACHE, POST_NAME_FUZZY, tenantId + StringPool.DASH + postNames, () -> { |
| | | R<String> result = getSysClient().getPostIdsByFuzzy(tenantId, postNames); |
| | | return result.getData(); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 获取岗位名 |
| | | * |
| | | * @param id 主键 |
| | | * @return 岗位名 |
| | | */ |
| | | public static String getPostName(Long id) { |
| | | return CacheUtil.get(SYS_CACHE, POST_NAME_ID, id, () -> { |
| | | R<String> result = getSysClient().getPostName(id); |
| | | return result.getData(); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 获取岗位名集合 |
| | | * |
| | | * @param postIds 主键集合 |
| | | * @return 岗位名 |
| | | */ |
| | | public static List<String> getPostNames(String postIds) { |
| | | return CacheUtil.get(SYS_CACHE, POST_NAMES_ID, postIds, () -> { |
| | | R<List<String>> result = getSysClient().getPostNames(postIds); |
| | | return result.getData(); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 获取角色 |
| | | * |
| | | * @param id 主键 |
| | | * @return Role |
| | | */ |
| | | public static Role getRole(Long id) { |
| | | return CacheUtil.get(SYS_CACHE, ROLE_ID, id, () -> { |
| | | R<Role> result = getSysClient().getRole(id); |
| | | return result.getData(); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 获取角色id |
| | | * |
| | | * @param tenantId 租户id |
| | | * @param roleNames 角色名 |
| | | * @return |
| | | */ |
| | | public static String getRoleIds(String tenantId, String roleNames) { |
| | | return CacheUtil.get(SYS_CACHE, ROLE_NAME, tenantId + StringPool.DASH + roleNames, () -> { |
| | | R<String> result = getSysClient().getRoleIds(tenantId, roleNames); |
| | | return result.getData(); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 获取角色名 |
| | | * |
| | | * @param id 主键 |
| | | * @return 角色名 |
| | | */ |
| | | public static String getRoleName(Long id) { |
| | | return CacheUtil.get(SYS_CACHE, ROLE_NAME_ID, id, () -> { |
| | | R<String> result = getSysClient().getRoleName(id); |
| | | return result.getData(); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 获取角色别名 |
| | | * |
| | | * @param id 主键 |
| | | * @return 角色别名 |
| | | */ |
| | | public static String getRoleAlias(Long id) { |
| | | return CacheUtil.get(SYS_CACHE, ROLE_ALIAS_ID, id, () -> { |
| | | R<String> result = getSysClient().getRoleAlias(id); |
| | | return result.getData(); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 获取角色名集合 |
| | | * |
| | | * @param roleIds 主键集合 |
| | | * @return 角色名 |
| | | */ |
| | | public static List<String> getRoleNames(String roleIds) { |
| | | return CacheUtil.get(SYS_CACHE, ROLE_NAMES_ID, roleIds, () -> { |
| | | R<List<String>> result = getSysClient().getRoleNames(roleIds); |
| | | return result.getData(); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 获取角色别名集合 |
| | | * |
| | | * @param roleIds 主键集合 |
| | | * @return 角色别名 |
| | | */ |
| | | public static List<String> getRoleAliases(String roleIds) { |
| | | return CacheUtil.get(SYS_CACHE, ROLE_ALIASES_ID, roleIds, () -> { |
| | | R<List<String>> result = getSysClient().getRoleAliases(roleIds); |
| | | return result.getData(); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 获取租户 |
| | | * |
| | | * @param id 主键 |
| | | * @return Tenant |
| | | */ |
| | | public static Tenant getTenant(Long id) { |
| | | return CacheUtil.get(SYS_CACHE, TENANT_ID, id, () -> { |
| | | R<Tenant> result = getSysClient().getTenant(id); |
| | | return result.getData(); |
| | | }, Boolean.FALSE); |
| | | } |
| | | |
| | | /** |
| | | * 获取租户 |
| | | * |
| | | * @param tenantId 租户id |
| | | * @return Tenant |
| | | */ |
| | | public static Tenant getTenant(String tenantId) { |
| | | return CacheUtil.get(SYS_CACHE, TENANT_TENANT_ID, tenantId, () -> { |
| | | R<Tenant> result = getSysClient().getTenant(tenantId); |
| | | return result.getData(); |
| | | }, Boolean.FALSE); |
| | | } |
| | | |
| | | /** |
| | | * 获取租户产品包 |
| | | * |
| | | * @param tenantId 租户id |
| | | * @return Tenant |
| | | */ |
| | | public static TenantPackage getTenantPackage(String tenantId) { |
| | | return CacheUtil.get(SYS_CACHE, TENANT_PACKAGE_ID, tenantId, () -> { |
| | | R<TenantPackage> result = getSysClient().getTenantPackage(tenantId); |
| | | return result.getData(); |
| | | }, Boolean.FALSE); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.dto; |
| | | |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import cn.gistack.system.entity.Dept; |
| | | |
| | | /** |
| | | * 数据传输对象实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class DeptDTO extends Dept { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * 数据传输对象实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | public class MenuDTO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | private String alias; |
| | | private String path; |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.dto; |
| | | |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import cn.gistack.system.entity.Param; |
| | | |
| | | /** |
| | | * 数据传输对象实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class ParamDTO extends Param { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.dto; |
| | | |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import cn.gistack.system.entity.Post; |
| | | |
| | | /** |
| | | * 岗位表数据传输对象实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class PostDTO extends Post { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.dto; |
| | | |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import cn.gistack.system.entity.Role; |
| | | |
| | | /** |
| | | * 数据传输对象实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class RoleDTO extends Role { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.dto; |
| | | |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import cn.gistack.system.entity.RoleMenu; |
| | | |
| | | /** |
| | | * 数据传输对象实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class RoleMenuDTO extends RoleMenu { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.mp.base.BaseEntity; |
| | | |
| | | /** |
| | | * 实体类 |
| | | * |
| | | * @author BladeX |
| | | */ |
| | | @Data |
| | | @TableName("blade_scope_api") |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "ApiScope对象", description = "ApiScope对象") |
| | | public class ApiScope extends BaseEntity { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 菜单主键 |
| | | */ |
| | | @ApiModelProperty(value = "菜单主键") |
| | | private Long menuId; |
| | | /** |
| | | * 资源编号 |
| | | */ |
| | | @ApiModelProperty(value = "资源编号") |
| | | private String resourceCode; |
| | | /** |
| | | * 接口权限名称 |
| | | */ |
| | | @ApiModelProperty(value = "接口权限名称") |
| | | private String scopeName; |
| | | /** |
| | | * 接口权限字段 |
| | | */ |
| | | @ApiModelProperty(value = "接口权限字段") |
| | | private String scopePath; |
| | | /** |
| | | * 接口权限类型 |
| | | */ |
| | | @ApiModelProperty(value = "接口权限类型") |
| | | private Integer scopeType; |
| | | /** |
| | | * 接口权限备注 |
| | | */ |
| | | @ApiModelProperty(value = "接口权限备注") |
| | | private String remark; |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonIgnore; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.mp.base.BaseEntity; |
| | | |
| | | /** |
| | | * 实体类 |
| | | * |
| | | * @author BladeX |
| | | */ |
| | | @Data |
| | | @TableName("blade_client") |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "Client对象", description = "Client对象") |
| | | public class AuthClient extends BaseEntity { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 客户端id |
| | | */ |
| | | @ApiModelProperty(value = "客户端id") |
| | | private String clientId; |
| | | /** |
| | | * 客户端密钥 |
| | | */ |
| | | @ApiModelProperty(value = "客户端密钥") |
| | | private String clientSecret; |
| | | /** |
| | | * 资源集合 |
| | | */ |
| | | @ApiModelProperty(value = "资源集合") |
| | | private String resourceIds; |
| | | /** |
| | | * 授权范围 |
| | | */ |
| | | @ApiModelProperty(value = "授权范围") |
| | | private String scope; |
| | | /** |
| | | * 授权类型 |
| | | */ |
| | | @ApiModelProperty(value = "授权类型") |
| | | private String authorizedGrantTypes; |
| | | /** |
| | | * 回调地址 |
| | | */ |
| | | @ApiModelProperty(value = "回调地址") |
| | | private String webServerRedirectUri; |
| | | /** |
| | | * 权限 |
| | | */ |
| | | @ApiModelProperty(value = "权限") |
| | | private String authorities; |
| | | /** |
| | | * 令牌过期秒数 |
| | | */ |
| | | @ApiModelProperty(value = "令牌过期秒数") |
| | | private Integer accessTokenValidity; |
| | | /** |
| | | * 刷新令牌过期秒数 |
| | | */ |
| | | @ApiModelProperty(value = "刷新令牌过期秒数") |
| | | private Integer refreshTokenValidity; |
| | | /** |
| | | * 附加说明 |
| | | */ |
| | | @JsonIgnore |
| | | @ApiModelProperty(value = "附加说明") |
| | | private String additionalInformation; |
| | | /** |
| | | * 自动授权 |
| | | */ |
| | | @ApiModelProperty(value = "自动授权") |
| | | private String autoapprove; |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.mp.base.BaseEntity; |
| | | |
| | | /** |
| | | * 实体类 |
| | | * |
| | | * @author BladeX |
| | | */ |
| | | @Data |
| | | @TableName("blade_scope_data") |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "DataScope对象", description = "DataScope对象") |
| | | public class DataScope extends BaseEntity { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 菜单主键 |
| | | */ |
| | | @ApiModelProperty(value = "菜单主键") |
| | | private Long menuId; |
| | | /** |
| | | * 资源编号 |
| | | */ |
| | | @ApiModelProperty(value = "资源编号") |
| | | private String resourceCode; |
| | | /** |
| | | * 数据权限名称 |
| | | */ |
| | | @ApiModelProperty(value = "数据权限名称") |
| | | private String scopeName; |
| | | /** |
| | | * 数据权限可见字段 |
| | | */ |
| | | @ApiModelProperty(value = "数据权限可见字段") |
| | | private String scopeField; |
| | | /** |
| | | * 数据权限类名 |
| | | */ |
| | | @ApiModelProperty(value = "数据权限类名") |
| | | private String scopeClass; |
| | | /** |
| | | * 数据权限字段 |
| | | */ |
| | | @ApiModelProperty(value = "数据权限字段") |
| | | private String scopeColumn; |
| | | /** |
| | | * 数据权限类型 |
| | | */ |
| | | @ApiModelProperty(value = "数据权限类型") |
| | | private Integer scopeType; |
| | | /** |
| | | * 数据权限值域 |
| | | */ |
| | | @ApiModelProperty(value = "数据权限值域") |
| | | private String scopeValue; |
| | | /** |
| | | * 数据权限备注 |
| | | */ |
| | | @ApiModelProperty(value = "数据权限备注") |
| | | private String remark; |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableLogic; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * 实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @TableName("blade_dept") |
| | | @ApiModel(value = "Dept对象", description = "Dept对象") |
| | | public class Dept implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "主键") |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 租户ID |
| | | */ |
| | | @ApiModelProperty(value = "租户ID") |
| | | private String tenantId; |
| | | |
| | | /** |
| | | * 父主键 |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "父主键") |
| | | private Long parentId; |
| | | |
| | | /** |
| | | * 机构名 |
| | | */ |
| | | @ApiModelProperty(value = "机构名") |
| | | private String deptName; |
| | | |
| | | /** |
| | | * 机构全称 |
| | | */ |
| | | @ApiModelProperty(value = "机构全称") |
| | | private String fullName; |
| | | |
| | | /** |
| | | * 祖级机构主键 |
| | | */ |
| | | @ApiModelProperty(value = "祖级机构主键") |
| | | private String ancestors; |
| | | |
| | | /** |
| | | * 机构类型 |
| | | */ |
| | | @ApiModelProperty(value = "机构类型") |
| | | private Integer deptCategory; |
| | | |
| | | /** |
| | | * 排序 |
| | | */ |
| | | @ApiModelProperty(value = "排序") |
| | | private Integer sort; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | @ApiModelProperty(value = "备注") |
| | | private String remark; |
| | | |
| | | /** |
| | | * 是否已删除 |
| | | */ |
| | | @TableLogic |
| | | @ApiModelProperty(value = "是否已删除") |
| | | private Integer isDeleted; |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableLogic; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import org.springblade.core.tool.utils.Func; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @TableName("blade_menu") |
| | | @ApiModel(value = "Menu对象", description = "Menu对象") |
| | | public class Menu implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "主键") |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 菜单父主键 |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "菜单父主键") |
| | | private Long parentId; |
| | | |
| | | /** |
| | | * 菜单编号 |
| | | */ |
| | | @ApiModelProperty(value = "菜单编号") |
| | | private String code; |
| | | |
| | | /** |
| | | * 菜单名称 |
| | | */ |
| | | @ApiModelProperty(value = "菜单名称") |
| | | private String name; |
| | | |
| | | /** |
| | | * 菜单别名 |
| | | */ |
| | | @ApiModelProperty(value = "菜单别名") |
| | | private String alias; |
| | | |
| | | /** |
| | | * 请求地址 |
| | | */ |
| | | @ApiModelProperty(value = "请求地址") |
| | | private String path; |
| | | |
| | | /** |
| | | * 菜单资源 |
| | | */ |
| | | @ApiModelProperty(value = "菜单资源") |
| | | private String source; |
| | | |
| | | /** |
| | | * 排序 |
| | | */ |
| | | @ApiModelProperty(value = "排序") |
| | | private Integer sort; |
| | | |
| | | /** |
| | | * 菜单类型 |
| | | */ |
| | | @ApiModelProperty(value = "菜单类型") |
| | | private Integer category; |
| | | |
| | | /** |
| | | * 操作按钮类型 |
| | | */ |
| | | @ApiModelProperty(value = "操作按钮类型") |
| | | private Integer action; |
| | | |
| | | /** |
| | | * 是否打开新页面 |
| | | */ |
| | | @ApiModelProperty(value = "是否打开新页面") |
| | | private Integer isOpen; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | @ApiModelProperty(value = "备注") |
| | | private String remark; |
| | | |
| | | /** |
| | | * 是否已删除 |
| | | */ |
| | | @TableLogic |
| | | @ApiModelProperty(value = "是否已删除") |
| | | private Integer isDeleted; |
| | | |
| | | |
| | | @Override |
| | | public boolean equals(Object obj) { |
| | | if (this == obj) { |
| | | return true; |
| | | } |
| | | if (obj == null) { |
| | | return false; |
| | | } |
| | | Menu other = (Menu) obj; |
| | | if (Func.equals(this.getId(), other.getId())) { |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public int hashCode() { |
| | | return Objects.hash(id, parentId, code); |
| | | } |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.mp.base.BaseEntity; |
| | | |
| | | /** |
| | | * 实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @TableName("blade_param") |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "Param对象", description = "Param对象") |
| | | public class Param extends BaseEntity { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 参数名 |
| | | */ |
| | | @ApiModelProperty(value = "参数名") |
| | | private String paramName; |
| | | |
| | | /** |
| | | * 参数键 |
| | | */ |
| | | @ApiModelProperty(value = "参数键") |
| | | private String paramKey; |
| | | |
| | | /** |
| | | * 参数值 |
| | | */ |
| | | @ApiModelProperty(value = "参数值") |
| | | private String paramValue; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | @ApiModelProperty(value = "备注") |
| | | private String remark; |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.tenant.mp.TenantEntity; |
| | | |
| | | /** |
| | | * 岗位表实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @TableName("blade_post") |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "Post对象", description = "岗位表") |
| | | public class Post extends TenantEntity { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 类型 |
| | | */ |
| | | @ApiModelProperty(value = "类型") |
| | | private Integer category; |
| | | /** |
| | | * 岗位编号 |
| | | */ |
| | | @ApiModelProperty(value = "岗位编号") |
| | | private String postCode; |
| | | /** |
| | | * 岗位名称 |
| | | */ |
| | | @ApiModelProperty(value = "岗位名称") |
| | | private String postName; |
| | | /** |
| | | * 岗位排序 |
| | | */ |
| | | @ApiModelProperty(value = "岗位排序") |
| | | private Integer sort; |
| | | /** |
| | | * 岗位描述 |
| | | */ |
| | | @ApiModelProperty(value = "岗位描述") |
| | | private String remark; |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * 行政区划表实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @TableName("blade_region") |
| | | @ApiModel(value = "Region对象", description = "行政区划表") |
| | | public class Region implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 区划编号 |
| | | */ |
| | | @TableId(value = "code", type = IdType.INPUT) |
| | | @ApiModelProperty(value = "区划编号") |
| | | private String code; |
| | | /** |
| | | * 父区划编号 |
| | | */ |
| | | @ApiModelProperty(value = "父区划编号") |
| | | private String parentCode; |
| | | /** |
| | | * 祖区划编号 |
| | | */ |
| | | @ApiModelProperty(value = "祖区划编号") |
| | | private String ancestors; |
| | | /** |
| | | * 区划名称 |
| | | */ |
| | | @ApiModelProperty(value = "区划名称") |
| | | private String name; |
| | | /** |
| | | * 省级区划编号 |
| | | */ |
| | | @ApiModelProperty(value = "省级区划编号") |
| | | private String provinceCode; |
| | | /** |
| | | * 省级名称 |
| | | */ |
| | | @ApiModelProperty(value = "省级名称") |
| | | private String provinceName; |
| | | /** |
| | | * 市级区划编号 |
| | | */ |
| | | @ApiModelProperty(value = "市级区划编号") |
| | | private String cityCode; |
| | | /** |
| | | * 市级名称 |
| | | */ |
| | | @ApiModelProperty(value = "市级名称") |
| | | private String cityName; |
| | | /** |
| | | * 区级区划编号 |
| | | */ |
| | | @ApiModelProperty(value = "区级区划编号") |
| | | private String districtCode; |
| | | /** |
| | | * 区级名称 |
| | | */ |
| | | @ApiModelProperty(value = "区级名称") |
| | | private String districtName; |
| | | /** |
| | | * 镇级区划编号 |
| | | */ |
| | | @ApiModelProperty(value = "镇级区划编号") |
| | | private String townCode; |
| | | /** |
| | | * 镇级名称 |
| | | */ |
| | | @ApiModelProperty(value = "镇级名称") |
| | | private String townName; |
| | | /** |
| | | * 村级区划编号 |
| | | */ |
| | | @ApiModelProperty(value = "村级区划编号") |
| | | private String villageCode; |
| | | /** |
| | | * 村级名称 |
| | | */ |
| | | @ApiModelProperty(value = "村级名称") |
| | | private String villageName; |
| | | /** |
| | | * 层级 |
| | | */ |
| | | @ApiModelProperty(value = "层级") |
| | | private Integer regionLevel; |
| | | /** |
| | | * 排序 |
| | | */ |
| | | @ApiModelProperty(value = "排序") |
| | | private Integer sort; |
| | | /** |
| | | * 备注 |
| | | */ |
| | | @ApiModelProperty(value = "备注") |
| | | private String remark; |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableLogic; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * 实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @TableName("blade_role") |
| | | @ApiModel(value = "Role对象", description = "Role对象") |
| | | public class Role implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "主键") |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 租户ID |
| | | */ |
| | | @ApiModelProperty(value = "租户ID") |
| | | private String tenantId; |
| | | |
| | | /** |
| | | * 父主键 |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "父主键") |
| | | private Long parentId; |
| | | |
| | | /** |
| | | * 角色名 |
| | | */ |
| | | @ApiModelProperty(value = "角色名") |
| | | private String roleName; |
| | | |
| | | /** |
| | | * 排序 |
| | | */ |
| | | @ApiModelProperty(value = "排序") |
| | | private Integer sort; |
| | | |
| | | /** |
| | | * 角色别名 |
| | | */ |
| | | @ApiModelProperty(value = "角色别名") |
| | | private String roleAlias; |
| | | |
| | | /** |
| | | * 是否已删除 |
| | | */ |
| | | @TableLogic |
| | | @ApiModelProperty(value = "是否已删除") |
| | | private Integer isDeleted; |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * 实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @TableName("blade_role_menu") |
| | | @ApiModel(value = "RoleMenu对象", description = "RoleMenu对象") |
| | | public class RoleMenu implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "主键") |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 菜单id |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "菜单id") |
| | | private Long menuId; |
| | | |
| | | /** |
| | | * 角色id |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "角色id") |
| | | private Long roleId; |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * 实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @TableName("blade_role_scope") |
| | | @ApiModel(value = "RoleScope对象", description = "RoleScope对象") |
| | | public class RoleScope implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "主键") |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 权限类型 |
| | | */ |
| | | @ApiModelProperty(value = "权限类型") |
| | | private Integer scopeCategory; |
| | | |
| | | /** |
| | | * 权限id |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "权限id") |
| | | private Long scopeId; |
| | | |
| | | /** |
| | | * 角色id |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "角色id") |
| | | private Long roleId; |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.NullSerializer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.mp.base.BaseEntity; |
| | | import org.springblade.core.tool.utils.DateUtil; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @TableName("blade_tenant") |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "Tenant对象", description = "Tenant对象") |
| | | public class Tenant extends BaseEntity { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 租户ID |
| | | */ |
| | | @ApiModelProperty(value = "租户ID") |
| | | private String tenantId; |
| | | /** |
| | | * 租户名称 |
| | | */ |
| | | @ApiModelProperty(value = "租户名称") |
| | | private String tenantName; |
| | | /** |
| | | * 域名地址 |
| | | */ |
| | | @ApiModelProperty(value = "域名地址") |
| | | private String domainUrl; |
| | | /** |
| | | * 系统背景 |
| | | */ |
| | | @ApiModelProperty(value = "系统背景") |
| | | private String backgroundUrl; |
| | | /** |
| | | * 联系人 |
| | | */ |
| | | @ApiModelProperty(value = "联系人") |
| | | private String linkman; |
| | | /** |
| | | * 联系电话 |
| | | */ |
| | | @ApiModelProperty(value = "联系电话") |
| | | private String contactNumber; |
| | | /** |
| | | * 联系地址 |
| | | */ |
| | | @ApiModelProperty(value = "联系地址") |
| | | private String address; |
| | | /** |
| | | * 账号额度 |
| | | */ |
| | | @ApiModelProperty(value = "账号额度") |
| | | private Integer accountNumber; |
| | | /** |
| | | * 过期时间 |
| | | */ |
| | | @DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME) |
| | | @JsonFormat(pattern = DateUtil.PATTERN_DATETIME) |
| | | @ApiModelProperty(value = "过期时间") |
| | | private Date expireTime; |
| | | /** |
| | | * 产品包ID |
| | | */ |
| | | @JsonSerialize(nullsUsing = NullSerializer.class) |
| | | @ApiModelProperty(value = "产品包ID") |
| | | private Long packageId; |
| | | /** |
| | | * 数据源ID |
| | | */ |
| | | @JsonSerialize(nullsUsing = NullSerializer.class) |
| | | @ApiModelProperty(value = "数据源ID") |
| | | private Long datasourceId; |
| | | /** |
| | | * 授权码 |
| | | */ |
| | | @ApiModelProperty(value = "授权码") |
| | | private String licenseKey; |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.mp.base.BaseEntity; |
| | | |
| | | /** |
| | | * 租户产品表实体类 |
| | | * |
| | | * @author BladeX |
| | | */ |
| | | @Data |
| | | @TableName("blade_tenant_package") |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "TenantPackage对象", description = "租户产品表") |
| | | public class TenantPackage extends BaseEntity { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 产品包名称 |
| | | */ |
| | | @ApiModelProperty(value = "产品包名称") |
| | | private String packageName; |
| | | /** |
| | | * 菜单ID |
| | | */ |
| | | @ApiModelProperty(value = "菜单ID") |
| | | private String menuId; |
| | | /** |
| | | * 备注 |
| | | */ |
| | | @ApiModelProperty(value = "备注") |
| | | private String remark; |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.tenant.mp.TenantEntity; |
| | | |
| | | /** |
| | | * 顶部菜单表实体类 |
| | | * |
| | | * @author BladeX |
| | | */ |
| | | @Data |
| | | @TableName("blade_top_menu") |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "TopMenu对象", description = "顶部菜单表") |
| | | public class TopMenu extends TenantEntity { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 顶部菜单编号 |
| | | */ |
| | | @ApiModelProperty(value = "顶部菜单编号") |
| | | private String code; |
| | | /** |
| | | * 顶部菜单名 |
| | | */ |
| | | @ApiModelProperty(value = "顶部菜单名") |
| | | private String name; |
| | | /** |
| | | * 顶部菜单资源 |
| | | */ |
| | | @ApiModelProperty(value = "顶部菜单资源") |
| | | private String source; |
| | | /** |
| | | * 顶部菜单排序 |
| | | */ |
| | | @ApiModelProperty(value = "顶部菜单排序") |
| | | private Integer sort; |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package cn.gistack.system.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * TopMenuSetting |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @TableName("blade_top_menu_setting") |
| | | public class TopMenuSetting { |
| | | |
| | | /** |
| | | * 主键id |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 顶部菜单id |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long topMenuId; |
| | | |
| | | /** |
| | | * 菜单id |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long menuId; |
| | | |
| | | } |
| New file |
| | |
| | | package cn.gistack.system.feign; |
| | | |
| | | import cn.gistack.system.entity.*; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Feign接口类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @FeignClient( |
| | | value = AppConstant.APPLICATION_SYSTEM_NAME, |
| | | fallback = ISysClientFallback.class |
| | | ) |
| | | public interface ISysClient { |
| | | |
| | | String API_PREFIX = "/client"; |
| | | String MENU = API_PREFIX + "/menu"; |
| | | String DEPT = API_PREFIX + "/dept"; |
| | | String DEPT_IDS = API_PREFIX + "/dept-ids"; |
| | | String DEPT_IDS_FUZZY = API_PREFIX + "/dept-ids-fuzzy"; |
| | | String DEPT_NAME = API_PREFIX + "/dept-name"; |
| | | String DEPT_NAMES = API_PREFIX + "/dept-names"; |
| | | String DEPT_CHILD = API_PREFIX + "/dept-child"; |
| | | String POST = API_PREFIX + "/post"; |
| | | String POST_IDS = API_PREFIX + "/post-ids"; |
| | | String POST_IDS_FUZZY = API_PREFIX + "/post-ids-fuzzy"; |
| | | String POST_NAME = API_PREFIX + "/post-name"; |
| | | String POST_NAMES = API_PREFIX + "/post-names"; |
| | | String ROLE = API_PREFIX + "/role"; |
| | | String ROLE_IDS = API_PREFIX + "/role-ids"; |
| | | String ROLE_NAME = API_PREFIX + "/role-name"; |
| | | String ROLE_NAMES = API_PREFIX + "/role-names"; |
| | | String ROLE_ALIAS = API_PREFIX + "/role-alias"; |
| | | String ROLE_ALIASES = API_PREFIX + "/role-aliases"; |
| | | String TENANT = API_PREFIX + "/tenant"; |
| | | String TENANT_ID = API_PREFIX + "/tenant-id"; |
| | | String TENANT_PACKAGE = API_PREFIX + "/tenant-package"; |
| | | String PARAM = API_PREFIX + "/param"; |
| | | String PARAM_VALUE = API_PREFIX + "/param-value"; |
| | | String REGION = API_PREFIX + "/region"; |
| | | |
| | | /** |
| | | * 获取菜单 |
| | | * |
| | | * @param id 主键 |
| | | * @return Menu |
| | | */ |
| | | @GetMapping(MENU) |
| | | R<Menu> getMenu(@RequestParam("id") Long id); |
| | | |
| | | /** |
| | | * 获取部门 |
| | | * |
| | | * @param id 主键 |
| | | * @return Dept |
| | | */ |
| | | @GetMapping(DEPT) |
| | | R<Dept> getDept(@RequestParam("id") Long id); |
| | | |
| | | /** |
| | | * 获取部门id |
| | | * |
| | | * @param tenantId 租户id |
| | | * @param deptNames 部门名 |
| | | * @return 部门id |
| | | */ |
| | | @GetMapping(DEPT_IDS) |
| | | R<String> getDeptIds(@RequestParam("tenantId") String tenantId, @RequestParam("deptNames") String deptNames); |
| | | |
| | | /** |
| | | * 获取部门id |
| | | * |
| | | * @param tenantId 租户id |
| | | * @param deptNames 部门名 |
| | | * @return 部门id |
| | | */ |
| | | @GetMapping(DEPT_IDS_FUZZY) |
| | | R<String> getDeptIdsByFuzzy(@RequestParam("tenantId") String tenantId, @RequestParam("deptNames") String deptNames); |
| | | |
| | | /** |
| | | * 获取部门名 |
| | | * |
| | | * @param id 主键 |
| | | * @return 部门名 |
| | | */ |
| | | @GetMapping(DEPT_NAME) |
| | | R<String> getDeptName(@RequestParam("id") Long id); |
| | | |
| | | /** |
| | | * 获取部门名 |
| | | * |
| | | * @param deptIds 主键 |
| | | * @return |
| | | */ |
| | | @GetMapping(DEPT_NAMES) |
| | | R<List<String>> getDeptNames(@RequestParam("deptIds") String deptIds); |
| | | |
| | | /** |
| | | * 获取子部门ID |
| | | * |
| | | * @param deptId |
| | | * @return |
| | | */ |
| | | @GetMapping(DEPT_CHILD) |
| | | R<List<Dept>> getDeptChild(@RequestParam("deptId") Long deptId); |
| | | |
| | | /** |
| | | * 获取岗位 |
| | | * |
| | | * @param id 主键 |
| | | * @return Post |
| | | */ |
| | | @GetMapping(POST) |
| | | R<Post> getPost(@RequestParam("id") Long id); |
| | | |
| | | /** |
| | | * 获取岗位id |
| | | * |
| | | * @param tenantId 租户id |
| | | * @param postNames 岗位名 |
| | | * @return 岗位id |
| | | */ |
| | | @GetMapping(POST_IDS) |
| | | R<String> getPostIds(@RequestParam("tenantId") String tenantId, @RequestParam("postNames") String postNames); |
| | | |
| | | /** |
| | | * 获取岗位id |
| | | * |
| | | * @param tenantId 租户id |
| | | * @param postNames 岗位名 |
| | | * @return 岗位id |
| | | */ |
| | | @GetMapping(POST_IDS_FUZZY) |
| | | R<String> getPostIdsByFuzzy(@RequestParam("tenantId") String tenantId, @RequestParam("postNames") String postNames); |
| | | |
| | | /** |
| | | * 获取岗位名 |
| | | * |
| | | * @param id 主键 |
| | | * @return 岗位名 |
| | | */ |
| | | @GetMapping(POST_NAME) |
| | | R<String> getPostName(@RequestParam("id") Long id); |
| | | |
| | | /** |
| | | * 获取岗位名 |
| | | * |
| | | * @param postIds 主键 |
| | | * @return |
| | | */ |
| | | @GetMapping(POST_NAMES) |
| | | R<List<String>> getPostNames(@RequestParam("postIds") String postIds); |
| | | |
| | | /** |
| | | * 获取角色 |
| | | * |
| | | * @param id 主键 |
| | | * @return Role |
| | | */ |
| | | @GetMapping(ROLE) |
| | | R<Role> getRole(@RequestParam("id") Long id); |
| | | |
| | | /** |
| | | * 获取角色id |
| | | * |
| | | * @param tenantId 租户id |
| | | * @param roleNames 角色名 |
| | | * @return 角色id |
| | | */ |
| | | @GetMapping(ROLE_IDS) |
| | | R<String> getRoleIds(@RequestParam("tenantId") String tenantId, @RequestParam("roleNames") String roleNames); |
| | | |
| | | /** |
| | | * 获取角色名 |
| | | * |
| | | * @param id 主键 |
| | | * @return 角色名 |
| | | */ |
| | | @GetMapping(ROLE_NAME) |
| | | R<String> getRoleName(@RequestParam("id") Long id); |
| | | |
| | | /** |
| | | * 获取角色别名 |
| | | * |
| | | * @param id 主键 |
| | | * @return 角色别名 |
| | | */ |
| | | @GetMapping(ROLE_ALIAS) |
| | | R<String> getRoleAlias(@RequestParam("id") Long id); |
| | | |
| | | /** |
| | | * 获取角色名 |
| | | * |
| | | * @param roleIds 主键 |
| | | * @return |
| | | */ |
| | | @GetMapping(ROLE_NAMES) |
| | | R<List<String>> getRoleNames(@RequestParam("roleIds") String roleIds); |
| | | |
| | | /** |
| | | * 获取角色别名 |
| | | * |
| | | * @param roleIds 主键 |
| | | * @return 角色别名 |
| | | */ |
| | | @GetMapping(ROLE_ALIASES) |
| | | R<List<String>> getRoleAliases(@RequestParam("roleIds") String roleIds); |
| | | |
| | | /** |
| | | * 获取租户 |
| | | * |
| | | * @param id 主键 |
| | | * @return Tenant |
| | | */ |
| | | @GetMapping(TENANT) |
| | | R<Tenant> getTenant(@RequestParam("id") Long id); |
| | | |
| | | /** |
| | | * 获取租户 |
| | | * |
| | | * @param tenantId 租户id |
| | | * @return Tenant |
| | | */ |
| | | @GetMapping(TENANT_ID) |
| | | R<Tenant> getTenant(@RequestParam("tenantId") String tenantId); |
| | | |
| | | /** |
| | | * 获取租户产品包 |
| | | * |
| | | * @param tenantId 租户id |
| | | * @return Tenant |
| | | */ |
| | | @GetMapping(TENANT_PACKAGE) |
| | | R<TenantPackage> getTenantPackage(@RequestParam("tenantId") String tenantId); |
| | | |
| | | /** |
| | | * 获取参数 |
| | | * |
| | | * @param id 主键 |
| | | * @return Param |
| | | */ |
| | | @GetMapping(PARAM) |
| | | R<Param> getParam(@RequestParam("id") Long id); |
| | | |
| | | /** |
| | | * 获取参数配置 |
| | | * |
| | | * @param paramKey 参数key |
| | | * @return String |
| | | */ |
| | | @GetMapping(PARAM_VALUE) |
| | | R<String> getParamValue(@RequestParam("paramKey") String paramKey); |
| | | |
| | | /** |
| | | * 获取行政区划 |
| | | * |
| | | * @param code 主键 |
| | | * @return Region |
| | | */ |
| | | @GetMapping(REGION) |
| | | R<Region> getRegion(@RequestParam("code") String code); |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.feign; |
| | | |
| | | import cn.gistack.system.entity.*; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Feign失败配置 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Component |
| | | public class ISysClientFallback implements ISysClient { |
| | | |
| | | @Override |
| | | public R<Menu> getMenu(Long id) { |
| | | return R.fail("获取数据失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R<Dept> getDept(Long id) { |
| | | return R.fail("获取数据失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R<String> getDeptIds(String tenantId, String deptNames) { |
| | | return R.fail("获取数据失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R<String> getDeptIdsByFuzzy(String tenantId, String deptNames) { |
| | | return R.fail("获取数据失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R<String> getDeptName(Long id) { |
| | | return R.fail("获取数据失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R<List<String>> getDeptNames(String deptIds) { |
| | | return R.fail("获取数据失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R<List<Dept>> getDeptChild(Long deptId) { |
| | | return R.fail("获取数据失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R<Post> getPost(Long id) { |
| | | return R.fail("获取数据失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R<String> getPostIds(String tenantId, String postNames) { |
| | | return R.fail("获取数据失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R<String> getPostIdsByFuzzy(String tenantId, String postNames) { |
| | | return R.fail("获取数据失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R<String> getPostName(Long id) { |
| | | return R.fail("获取数据失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R<List<String>> getPostNames(String postIds) { |
| | | return R.fail("获取数据失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R<Role> getRole(Long id) { |
| | | return R.fail("获取数据失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R<String> getRoleIds(String tenantId, String roleNames) { |
| | | return R.fail("获取数据失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R<String> getRoleName(Long id) { |
| | | return R.fail("获取数据失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R<String> getRoleAlias(Long id) { |
| | | return R.fail("获取数据失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R<List<String>> getRoleNames(String roleIds) { |
| | | return R.fail("获取数据失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R<List<String>> getRoleAliases(String roleIds) { |
| | | return R.fail("获取数据失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R<Tenant> getTenant(Long id) { |
| | | return R.fail("获取数据失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R<Tenant> getTenant(String tenantId) { |
| | | return R.fail("获取数据失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R<TenantPackage> getTenantPackage(String tenantId) { |
| | | return R.fail("获取数据失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R<Param> getParam(Long id) { |
| | | return R.fail("获取数据失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R<String> getParamValue(String paramKey) { |
| | | return R.fail("获取数据失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R<Region> getRegion(String code) { |
| | | return R.fail("获取数据失败"); |
| | | } |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.vo; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import cn.gistack.system.entity.ApiScope; |
| | | |
| | | /** |
| | | * 视图实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "ApiScopeVO对象", description = "ApiScopeVO对象") |
| | | public class ApiScopeVO extends ApiScope { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 规则类型名 |
| | | */ |
| | | private String scopeTypeName; |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * CheckedTreeVO |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | public class CheckedTreeVO { |
| | | |
| | | private List<String> menu; |
| | | |
| | | private List<String> dataScope; |
| | | |
| | | private List<String> apiScope; |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.vo; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import cn.gistack.system.entity.DataScope; |
| | | |
| | | /** |
| | | * 视图实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "DataScopeVO对象", description = "DataScopeVO对象") |
| | | public class DataScopeVO extends DataScope { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 规则类型名 |
| | | */ |
| | | private String scopeTypeName; |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.vo; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonInclude; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.tool.node.INode; |
| | | import cn.gistack.system.entity.Dept; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 视图实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "DeptVO对象", description = "DeptVO对象") |
| | | public class DeptVO extends Dept implements INode<DeptVO> { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键ID |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 父节点ID |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long parentId; |
| | | |
| | | /** |
| | | * 子孙节点 |
| | | */ |
| | | @JsonInclude(JsonInclude.Include.NON_EMPTY) |
| | | private List<DeptVO> children; |
| | | |
| | | /** |
| | | * 是否有子孙节点 |
| | | */ |
| | | @JsonInclude(JsonInclude.Include.NON_EMPTY) |
| | | private Boolean hasChildren; |
| | | |
| | | @Override |
| | | public List<DeptVO> getChildren() { |
| | | if (this.children == null) { |
| | | this.children = new ArrayList<>(); |
| | | } |
| | | return this.children; |
| | | } |
| | | |
| | | /** |
| | | * 上级机构 |
| | | */ |
| | | private String parentName; |
| | | |
| | | /** |
| | | * 机构类型名称 |
| | | */ |
| | | private String deptCategoryName; |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.vo; |
| | | |
| | | import lombok.Data; |
| | | import org.springblade.core.tool.node.TreeNode; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * GrantTreeVO |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | public class GrantTreeVO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | private List<TreeNode> menu; |
| | | |
| | | private List<TreeNode> dataScope; |
| | | |
| | | private List<TreeNode> apiScope; |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.vo; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * GrantVO |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | public class GrantVO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @ApiModelProperty(value = "roleIds集合") |
| | | private List<Long> roleIds; |
| | | |
| | | @ApiModelProperty(value = "menuIds集合") |
| | | private List<Long> menuIds; |
| | | |
| | | @ApiModelProperty(value = "topMenuIds集合") |
| | | private List<Long> topMenuIds; |
| | | |
| | | @ApiModelProperty(value = "dataScopeIds集合") |
| | | private List<Long> dataScopeIds; |
| | | |
| | | @ApiModelProperty(value = "apiScopeIds集合") |
| | | private List<Long> apiScopeIds; |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.vo; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonInclude; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.tool.node.INode; |
| | | import cn.gistack.system.entity.Menu; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 视图实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "MenuVO对象", description = "MenuVO对象") |
| | | public class MenuVO extends Menu implements INode<MenuVO> { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键ID |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 父节点ID |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long parentId; |
| | | |
| | | /** |
| | | * 子孙节点 |
| | | */ |
| | | @JsonInclude(JsonInclude.Include.NON_EMPTY) |
| | | private List<MenuVO> children; |
| | | |
| | | /** |
| | | * 是否有子孙节点 |
| | | */ |
| | | @JsonInclude(JsonInclude.Include.NON_EMPTY) |
| | | private Boolean hasChildren; |
| | | |
| | | @Override |
| | | public List<MenuVO> getChildren() { |
| | | if (this.children == null) { |
| | | this.children = new ArrayList<>(); |
| | | } |
| | | return this.children; |
| | | } |
| | | |
| | | /** |
| | | * 上级菜单 |
| | | */ |
| | | private String parentName; |
| | | |
| | | /** |
| | | * 菜单类型 |
| | | */ |
| | | private String categoryName; |
| | | |
| | | /** |
| | | * 按钮功能 |
| | | */ |
| | | private String actionName; |
| | | |
| | | /** |
| | | * 是否新窗口打开 |
| | | */ |
| | | private String isOpenName; |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.vo; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import cn.gistack.system.entity.Param; |
| | | |
| | | /** |
| | | * 视图实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "ParamVO对象", description = "ParamVO对象") |
| | | public class ParamVO extends Param { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.vo; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import cn.gistack.system.entity.Post; |
| | | |
| | | /** |
| | | * 岗位表视图实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "PostVO对象", description = "岗位表") |
| | | public class PostVO extends Post { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 岗位分类名 |
| | | */ |
| | | private String categoryName; |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.vo; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonInclude; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.tool.node.INode; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import cn.gistack.system.entity.Region; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 行政区划表视图实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "RegionVO对象", description = "行政区划表") |
| | | public class RegionVO extends Region implements INode<RegionVO> { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键ID |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 父节点ID |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long parentId; |
| | | |
| | | /** |
| | | * 父节点名称 |
| | | */ |
| | | private String parentName; |
| | | |
| | | /** |
| | | * 是否有子孙节点 |
| | | */ |
| | | @JsonInclude(JsonInclude.Include.NON_EMPTY) |
| | | private Boolean hasChildren; |
| | | |
| | | /** |
| | | * 子孙节点 |
| | | */ |
| | | @JsonInclude(JsonInclude.Include.NON_EMPTY) |
| | | private List<RegionVO> children; |
| | | |
| | | @Override |
| | | public Long getId() { |
| | | return Func.toLong(this.getCode()); |
| | | } |
| | | |
| | | @Override |
| | | public Long getParentId() { |
| | | return Func.toLong(this.getParentCode()); |
| | | } |
| | | |
| | | @Override |
| | | public List<RegionVO> getChildren() { |
| | | if (this.children == null) { |
| | | this.children = new ArrayList<>(); |
| | | } |
| | | return this.children; |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.vo; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import cn.gistack.system.entity.RoleMenu; |
| | | |
| | | /** |
| | | * 视图实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "RoleMenuVO对象", description = "RoleMenuVO对象") |
| | | public class RoleMenuVO extends RoleMenu { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.vo; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonInclude; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.tool.node.INode; |
| | | import cn.gistack.system.entity.Role; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 视图实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "RoleVO对象", description = "RoleVO对象") |
| | | public class RoleVO extends Role implements INode<RoleVO> { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键ID |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 父节点ID |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long parentId; |
| | | |
| | | /** |
| | | * 子孙节点 |
| | | */ |
| | | @JsonInclude(JsonInclude.Include.NON_EMPTY) |
| | | private List<RoleVO> children; |
| | | |
| | | @Override |
| | | public List<RoleVO> getChildren() { |
| | | if (this.children == null) { |
| | | this.children = new ArrayList<>(); |
| | | } |
| | | return this.children; |
| | | } |
| | | |
| | | /** |
| | | * 上级角色 |
| | | */ |
| | | private String parentName; |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <project xmlns="http://maven.apache.org/POM/4.0.0" |
| | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| | | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| | | <parent> |
| | | <artifactId>skjcmanager-service-api</artifactId> |
| | | <groupId>org.springblade</groupId> |
| | | <version>3.0.1.RELEASE</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | | <artifactId>skjcmanager-user-api</artifactId> |
| | | <name>${project.artifactId}</name> |
| | | <version>${bladex.project.version}</version> |
| | | <packaging>jar</packaging> |
| | | |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>blade-starter-cache</artifactId> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | </project> |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.user.cache; |
| | | |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.core.tool.utils.SpringUtil; |
| | | import org.springblade.core.tool.utils.StringPool; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import cn.gistack.system.user.entity.User; |
| | | import cn.gistack.system.user.feign.IUserClient; |
| | | |
| | | import static org.springblade.core.cache.constant.CacheConstant.USER_CACHE; |
| | | import static org.springblade.core.launch.constant.FlowConstant.TASK_USR_PREFIX; |
| | | |
| | | /** |
| | | * 系统缓存 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class UserCache { |
| | | private static final String USER_CACHE_ID = "user:id:"; |
| | | private static final String USER_CACHE_ACCOUNT = "user:account:"; |
| | | |
| | | private static IUserClient userClient; |
| | | |
| | | private static IUserClient getUserClient() { |
| | | if (userClient == null) { |
| | | userClient = SpringUtil.getBean(IUserClient.class); |
| | | } |
| | | return userClient; |
| | | } |
| | | |
| | | /** |
| | | * 根据任务用户id获取用户信息 |
| | | * |
| | | * @param taskUserId 任务用户id |
| | | * @return |
| | | */ |
| | | public static User getUserByTaskUser(String taskUserId) { |
| | | Long userId = Func.toLong(StringUtil.removePrefix(taskUserId, TASK_USR_PREFIX)); |
| | | return getUser(userId); |
| | | } |
| | | |
| | | /** |
| | | * 获取用户 |
| | | * |
| | | * @param userId 用户id |
| | | * @return |
| | | */ |
| | | public static User getUser(Long userId) { |
| | | return CacheUtil.get(USER_CACHE, USER_CACHE_ID, userId, () -> { |
| | | R<User> result = getUserClient().userInfoById(userId); |
| | | return result.getData(); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 获取用户 |
| | | * |
| | | * @param tenantId 租户id |
| | | * @param account 账号名 |
| | | * @return |
| | | */ |
| | | public static User getUser(String tenantId, String account) { |
| | | return CacheUtil.get(USER_CACHE, USER_CACHE_ACCOUNT, tenantId + StringPool.DASH + account, () -> { |
| | | R<User> result = getUserClient().userByAccount(tenantId, account); |
| | | return result.getData(); |
| | | }); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.user.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.tenant.mp.TenantEntity; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @TableName("blade_user") |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class User extends TenantEntity { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 用户编号 |
| | | */ |
| | | private String code; |
| | | /** |
| | | * 用户平台 |
| | | */ |
| | | private Integer userType; |
| | | /** |
| | | * 账号 |
| | | */ |
| | | private String account; |
| | | /** |
| | | * 密码 |
| | | */ |
| | | private String password; |
| | | /** |
| | | * 昵称 |
| | | */ |
| | | private String name; |
| | | /** |
| | | * 真名 |
| | | */ |
| | | private String realName; |
| | | /** |
| | | * 头像 |
| | | */ |
| | | private String avatar; |
| | | /** |
| | | * 邮箱 |
| | | */ |
| | | private String email; |
| | | /** |
| | | * 手机 |
| | | */ |
| | | private String phone; |
| | | /** |
| | | * 生日 |
| | | */ |
| | | private Date birthday; |
| | | /** |
| | | * 性别 |
| | | */ |
| | | private Integer sex; |
| | | /** |
| | | * 角色id |
| | | */ |
| | | private String roleId; |
| | | /** |
| | | * 部门id |
| | | */ |
| | | private String deptId; |
| | | /** |
| | | * 岗位id |
| | | */ |
| | | private String postId; |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.user.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.baomidou.mybatisplus.extension.activerecord.Model; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * 实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @TableName("blade_user_app") |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "UserApp对象", description = "UserApp对象") |
| | | public class UserApp extends Model<UserApp> { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "主键") |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 用户ID |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "用户ID") |
| | | private Long userId; |
| | | |
| | | /** |
| | | * 用户拓展信息 |
| | | */ |
| | | @ApiModelProperty(value = "用户拓展信息") |
| | | private String userExt; |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.user.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * 实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @TableName("blade_user_dept") |
| | | @ApiModel(value = "UserDept对象", description = "UserDept对象") |
| | | public class UserDept implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "主键") |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 用户ID |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "用户ID") |
| | | private Long userId; |
| | | |
| | | /** |
| | | * 部门ID |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "部门ID") |
| | | private Long deptId; |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.user.entity; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import org.springblade.core.tool.support.Kv; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 用户信息 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @ApiModel(description = "用户信息") |
| | | public class UserInfo implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 第三方授权id |
| | | */ |
| | | @ApiModelProperty(value = "第三方授权id") |
| | | private String oauthId; |
| | | |
| | | /** |
| | | * 用户基础信息 |
| | | */ |
| | | @ApiModelProperty(value = "用户") |
| | | private User user; |
| | | |
| | | /** |
| | | * 拓展信息 |
| | | */ |
| | | @ApiModelProperty(value = "拓展信息") |
| | | private Kv detail; |
| | | |
| | | /** |
| | | * 权限标识集合 |
| | | */ |
| | | @ApiModelProperty(value = "权限集合") |
| | | private List<String> permissions; |
| | | |
| | | /** |
| | | * 角色集合 |
| | | */ |
| | | @ApiModelProperty(value = "角色集合") |
| | | private List<String> roles; |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.user.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * 实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @TableName("blade_user_oauth") |
| | | public class UserOauth implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "主键") |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 租户ID |
| | | */ |
| | | private String tenantId; |
| | | |
| | | /** |
| | | * 第三方系统用户ID |
| | | */ |
| | | private String uuid; |
| | | |
| | | /** |
| | | * 用户ID |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "用户主键") |
| | | private Long userId; |
| | | |
| | | /** |
| | | * 用户名 |
| | | */ |
| | | private String username; |
| | | /** |
| | | * 用户昵称 |
| | | */ |
| | | private String nickname; |
| | | /** |
| | | * 用户头像 |
| | | */ |
| | | private String avatar; |
| | | /** |
| | | * 用户网址 |
| | | */ |
| | | private String blog; |
| | | /** |
| | | * 所在公司 |
| | | */ |
| | | private String company; |
| | | /** |
| | | * 位置 |
| | | */ |
| | | private String location; |
| | | /** |
| | | * 用户邮箱 |
| | | */ |
| | | private String email; |
| | | /** |
| | | * 用户备注(各平台中的用户个人介绍) |
| | | */ |
| | | private String remark; |
| | | /** |
| | | * 性别 |
| | | */ |
| | | private String gender; |
| | | /** |
| | | * 用户来源 |
| | | */ |
| | | private String source; |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.user.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.baomidou.mybatisplus.extension.activerecord.Model; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * 实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @TableName("blade_user_other") |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "UserOther对象", description = "UserOther对象") |
| | | public class UserOther extends Model<UserOther> { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "主键") |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 用户ID |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "用户ID") |
| | | private Long userId; |
| | | |
| | | /** |
| | | * 用户拓展信息 |
| | | */ |
| | | @ApiModelProperty(value = "用户拓展信息") |
| | | private String userExt; |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.user.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.baomidou.mybatisplus.extension.activerecord.Model; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * 实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @TableName("blade_user_web") |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "UserWeb对象", description = "UserWeb对象") |
| | | public class UserWeb extends Model<UserWeb> { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "主键") |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 用户ID |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "用户ID") |
| | | private Long userId; |
| | | |
| | | /** |
| | | * 用户拓展信息 |
| | | */ |
| | | @ApiModelProperty(value = "用户拓展信息") |
| | | private String userExt; |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.user.enums; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * 用户类型枚举 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum UserEnum { |
| | | |
| | | /** |
| | | * web |
| | | */ |
| | | WEB("web", 1), |
| | | |
| | | /** |
| | | * app |
| | | */ |
| | | APP("app", 2), |
| | | |
| | | /** |
| | | * other |
| | | */ |
| | | OTHER("other", 3), |
| | | ; |
| | | |
| | | final String name; |
| | | final int category; |
| | | |
| | | /** |
| | | * 匹配枚举值 |
| | | * |
| | | * @param name 名称 |
| | | * @return BladeUserEnum |
| | | */ |
| | | public static UserEnum of(String name) { |
| | | if (name == null) { |
| | | return null; |
| | | } |
| | | UserEnum[] values = UserEnum.values(); |
| | | for (UserEnum smsEnum : values) { |
| | | if (smsEnum.name.equals(name)) { |
| | | return smsEnum; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.user.feign; |
| | | |
| | | import org.springblade.core.tool.api.R; |
| | | import cn.gistack.system.user.entity.User; |
| | | import cn.gistack.system.user.entity.UserInfo; |
| | | import cn.gistack.system.user.entity.UserOauth; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | /** |
| | | * User Feign接口类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | //@FeignClient( |
| | | // value = AppConstant.APPLICATION_USER_NAME |
| | | //) |
| | | @FeignClient( |
| | | value = "skjcmanager-user" |
| | | ) |
| | | public interface IUserClient { |
| | | |
| | | String API_PREFIX = "/client"; |
| | | String USER_INFO = API_PREFIX + "/user-info"; |
| | | String USER_INFO_BY_TYPE = API_PREFIX + "/user-info-by-type"; |
| | | String USER_INFO_BY_ID = API_PREFIX + "/user-info-by-id"; |
| | | String USER_INFO_BY_ACCOUNT = API_PREFIX + "/user-info-by-account"; |
| | | String USER_AUTH_INFO = API_PREFIX + "/user-auth-info"; |
| | | String SAVE_USER = API_PREFIX + "/save-user"; |
| | | String REMOVE_USER = API_PREFIX + "/remove-user"; |
| | | |
| | | /** |
| | | * 获取用户信息 |
| | | * |
| | | * @param userId 用户id |
| | | * @return |
| | | */ |
| | | @GetMapping(USER_INFO_BY_ID) |
| | | R<User> userInfoById(@RequestParam("userId") Long userId); |
| | | |
| | | |
| | | /** |
| | | * 根据账号获取用户信息 |
| | | * |
| | | * @param tenantId 租户id |
| | | * @param account 账号 |
| | | * @return |
| | | */ |
| | | @GetMapping(USER_INFO_BY_ACCOUNT) |
| | | R<User> userByAccount(@RequestParam("tenantId") String tenantId, @RequestParam("account") String account); |
| | | |
| | | /** |
| | | * 获取用户信息 |
| | | * |
| | | * @param tenantId 租户ID |
| | | * @param account 账号 |
| | | * @return |
| | | */ |
| | | @GetMapping(USER_INFO) |
| | | R<UserInfo> userInfo(@RequestParam("tenantId") String tenantId, @RequestParam("account") String account); |
| | | |
| | | /** |
| | | * 获取用户信息 |
| | | * |
| | | * @param tenantId 租户ID |
| | | * @param account 账号 |
| | | * @param userType 用户平台 |
| | | * @return |
| | | */ |
| | | @GetMapping(USER_INFO_BY_TYPE) |
| | | R<UserInfo> userInfo(@RequestParam("tenantId") String tenantId, @RequestParam("account") String account, @RequestParam("userType") String userType); |
| | | |
| | | /** |
| | | * 获取第三方平台信息 |
| | | * |
| | | * @param userOauth 第三方授权用户信息 |
| | | * @return UserInfo |
| | | */ |
| | | @PostMapping(USER_AUTH_INFO) |
| | | R<UserInfo> userAuthInfo(@RequestBody UserOauth userOauth); |
| | | |
| | | /** |
| | | * 新建用户 |
| | | * |
| | | * @param user 用户实体 |
| | | * @return |
| | | */ |
| | | @PostMapping(SAVE_USER) |
| | | R<Boolean> saveUser(@RequestBody User user); |
| | | |
| | | /** |
| | | * 删除用户 |
| | | * |
| | | * @param tenantIds 租户id集合 |
| | | * @return |
| | | */ |
| | | @PostMapping(REMOVE_USER) |
| | | R<Boolean> removeUser(@RequestParam("tenantIds") String tenantIds); |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.user.feign; |
| | | |
| | | |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import org.springblade.core.tool.api.R; |
| | | import cn.gistack.system.user.entity.User; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * User Search Feign接口类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | //@FeignClient( |
| | | // value = AppConstant.APPLICATION_USER_NAME |
| | | //) |
| | | @FeignClient( |
| | | value = "skjcmanager-user" |
| | | ) |
| | | public interface IUserSearchClient { |
| | | |
| | | String API_PREFIX = "/client"; |
| | | String LIST_BY_USER = API_PREFIX + "/user/list-by-user"; |
| | | String LIST_BY_DEPT = API_PREFIX + "/user/list-by-dept"; |
| | | String LIST_BY_POST = API_PREFIX + "/user/list-by-post"; |
| | | String LIST_BY_ROLE = API_PREFIX + "/user/list-by-role"; |
| | | |
| | | /** |
| | | * 根据用户ID查询用户列表 |
| | | * |
| | | * @param userId 用户ID |
| | | * @return 用户列表 |
| | | */ |
| | | @GetMapping(LIST_BY_USER) |
| | | R<List<User>> listByUser(@RequestParam("userId") String userId); |
| | | |
| | | /** |
| | | * 根据部门ID查询用户列表 |
| | | * |
| | | * @param deptId 部门ID |
| | | * @return 用户列表 |
| | | */ |
| | | @GetMapping(LIST_BY_DEPT) |
| | | R<List<User>> listByDept(@RequestParam("deptId") String deptId); |
| | | |
| | | /** |
| | | * 根据岗位ID查询用户列表 |
| | | * |
| | | * @param postId 岗位ID |
| | | * @return 用户列表 |
| | | */ |
| | | @GetMapping(LIST_BY_POST) |
| | | R<List<User>> listByPost(@RequestParam("postId") String postId); |
| | | |
| | | /** |
| | | * 根据角色ID查询用户列表 |
| | | * |
| | | * @param roleId 角色ID |
| | | * @return 用户列表 |
| | | */ |
| | | @GetMapping(LIST_BY_ROLE) |
| | | R<List<User>> listByRole(@RequestParam("roleId") String roleId); |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.user.vo; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonIgnore; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import cn.gistack.system.user.entity.User; |
| | | |
| | | /** |
| | | * 视图实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "UserVO对象", description = "UserVO对象") |
| | | public class UserVO extends User { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键ID |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 密码 |
| | | */ |
| | | @JsonIgnore |
| | | private String password; |
| | | |
| | | /** |
| | | * 租户名 |
| | | */ |
| | | private String tenantName; |
| | | |
| | | /** |
| | | * 用户平台名 |
| | | */ |
| | | private String userTypeName; |
| | | |
| | | /** |
| | | * 角色名 |
| | | */ |
| | | private String roleName; |
| | | |
| | | /** |
| | | * 部门名 |
| | | */ |
| | | private String deptName; |
| | | |
| | | /** |
| | | * 岗位名 |
| | | */ |
| | | private String postName; |
| | | |
| | | /** |
| | | * 性别 |
| | | */ |
| | | private String sexName; |
| | | |
| | | /** |
| | | * 拓展信息 |
| | | */ |
| | | private String userExt; |
| | | } |
| New file |
| | |
| | | <?xml version="1.0"?> |
| | | <project xmlns="http://maven.apache.org/POM/4.0.0" |
| | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| | | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| | | |
| | | <parent> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>skjcmanager</artifactId> |
| | | <version>3.0.1.RELEASE</version> |
| | | </parent> |
| | | |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | | <artifactId>skjcmanager-service</artifactId> |
| | | <name>${project.artifactId}</name> |
| | | <version>3.0.1.RELEASE</version> |
| | | <packaging>pom</packaging> |
| | | <description>BladeX 微服务集合</description> |
| | | |
| | | <modules> |
| | | <module>skjcmanager-desk</module> |
| | | <module>skjcmanager-system</module> |
| | | <module>skjcmanager-user</module> |
| | | </modules> |
| | | |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>skjcmanager-common</artifactId> |
| | | <version>${bladex.project.version}</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>blade-starter-metrics</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>blade-starter-tenant</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>blade-starter-api-crypto</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>skjcmanager-dict-api</artifactId> |
| | | <version>${bladex.project.version}</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>skjcmanager-scope-api</artifactId> |
| | | <version>${bladex.project.version}</version> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | </project> |
| New file |
| | |
| | | <?xml version="1.0"?> |
| | | <project xmlns="http://maven.apache.org/POM/4.0.0" |
| | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| | | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| | | |
| | | <parent> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>skjcmanager-service</artifactId> |
| | | <version>3.0.1.RELEASE</version> |
| | | </parent> |
| | | |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | | <artifactId>skjcmanager-desk</artifactId> |
| | | <name>${project.artifactId}</name> |
| | | <version>${bladex.project.version}</version> |
| | | <packaging>jar</packaging> |
| | | |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>blade-core-boot</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>blade-starter-swagger</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>skjcmanager-desk-api</artifactId> |
| | | <version>${bladex.project.version}</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>skjcmanager-user-api</artifactId> |
| | | <version>${bladex.project.version}</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>skjcmanager-flow-api</artifactId> |
| | | <version>${bladex.project.version}</version> |
| | | </dependency> |
| | | <!--Oss--> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>blade-starter-oss</artifactId> |
| | | </dependency> |
| | | <!--MinIO--> |
| | | <dependency> |
| | | <groupId>io.minio</groupId> |
| | | <artifactId>minio</artifactId> |
| | | </dependency> |
| | | <!--QiNiu--> |
| | | <dependency> |
| | | <groupId>com.qiniu</groupId> |
| | | <artifactId>qiniu-java-sdk</artifactId> |
| | | </dependency> |
| | | <!--<dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>blade-starter-transaction</artifactId> |
| | | </dependency>--> |
| | | </dependencies> |
| | | |
| | | <build> |
| | | <plugins> |
| | | <plugin> |
| | | <groupId>com.spotify</groupId> |
| | | <artifactId>dockerfile-maven-plugin</artifactId> |
| | | <configuration> |
| | | <username>${docker.username}</username> |
| | | <password>${docker.password}</password> |
| | | <repository>${docker.registry.url}/${docker.namespace}/${project.artifactId}</repository> |
| | | <tag>${project.version}</tag> |
| | | <useMavenSettingsForAuth>true</useMavenSettingsForAuth> |
| | | <buildArgs> |
| | | <JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE> |
| | | </buildArgs> |
| | | <skip>false</skip> |
| | | </configuration> |
| | | </plugin> |
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-antrun-plugin</artifactId> |
| | | </plugin> |
| | | </plugins> |
| | | </build> |
| | | |
| | | </project> |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.desk; |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | |
| | | /** |
| | | * Desk启动器 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @BladeCloudApplication |
| | | public class DeskApplication { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_DESK_NAME, DeskApplication.class, args); |
| | | } |
| | | |
| | | } |
| | | |
| New file |
| | |
| | | package cn.gistack.desk.controller; |
| | | |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.core.tenant.annotation.NonDS; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.support.Kv; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 首页 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @NonDS |
| | | @RestController |
| | | @AllArgsConstructor |
| | | @Api(value = "首页", tags = "首页") |
| | | public class DashBoardController { |
| | | |
| | | /** |
| | | * 活跃用户 |
| | | */ |
| | | @GetMapping("/dashboard/activities") |
| | | @ApiOperationSupport(order = 1) |
| | | @ApiOperation(value = "活跃用户", notes = "活跃用户") |
| | | public R activities() { |
| | | List<Map<String, Object>> list = new ArrayList<>(); |
| | | |
| | | Map<String, Object> map1 = new HashMap<>(16); |
| | | map1.put("id", "trend-1"); |
| | | map1.put("updatedAt", "2019-01-01"); |
| | | map1.put("user", Kv.create().set("name", "曲丽丽").set("avatar", "https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png")); |
| | | map1.put("group", Kv.create().set("name", "高逼格设计天团").set("link", "http://github.com/")); |
| | | map1.put("project", Kv.create().set("name", "六月迭代").set("link", "http://github.com/")); |
| | | map1.put("template", "在 @{group} 新建项目 @{project}"); |
| | | list.add(map1); |
| | | |
| | | Map<String, Object> map2 = new HashMap<>(16); |
| | | map2.put("id", "trend-2"); |
| | | map2.put("updatedAt", "2019-01-01"); |
| | | map2.put("user", Kv.create().set("name", "付小小").set("avatar", "https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png")); |
| | | map2.put("group", Kv.create().set("name", "高逼格设计天团").set("link", "http://github.com/")); |
| | | map2.put("project", Kv.create().set("name", "七月月迭代").set("link", "http://github.com/")); |
| | | map2.put("template", "在 @{group} 新建项目 @{project}"); |
| | | list.add(map2); |
| | | |
| | | return R.data(list); |
| | | } |
| | | |
| | | /** |
| | | * 用户信息 |
| | | */ |
| | | @GetMapping("/dashboard/info") |
| | | @ApiOperationSupport(order = 2) |
| | | @ApiOperation(value = "用户信息", notes = "用户信息") |
| | | public R info() { |
| | | Map<String, Object> map = new HashMap<>(16); |
| | | map.put("id", "trend-1"); |
| | | map.put("updatedAt", "2019-01-01"); |
| | | map.put("user", Kv.create().set("name", "曲丽丽").set("avatar", "https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png")); |
| | | map.put("group", Kv.create().set("name", "高逼格设计天团").set("link", "http://github.com/")); |
| | | map.put("project", Kv.create().set("name", "六月迭代").set("link", "http://github.com/")); |
| | | map.put("template", "在 @{group} 新建项目 @{project}"); |
| | | return R.data(map); |
| | | } |
| | | |
| | | /** |
| | | * 签名信息 |
| | | */ |
| | | @PostMapping("/dashboard/sign") |
| | | @ApiOperationSupport(order = 3) |
| | | @ApiOperation(value = "签名信息", notes = "签名信息") |
| | | public R sign() { |
| | | Map<String, Object> map = new HashMap<>(16); |
| | | map.put("user", Kv.create().set("name", "曲丽丽").set("avatar", "https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png")); |
| | | return R.data(map); |
| | | } |
| | | |
| | | /** |
| | | * 获取消息 |
| | | */ |
| | | @GetMapping("/notice/notices") |
| | | @ApiOperationSupport(order = 4) |
| | | @ApiOperation(value = "消息", notes = "消息") |
| | | public R notices() { |
| | | List<Map<String, String>> list = new ArrayList<>(); |
| | | Map<String, String> map1 = new HashMap<>(16); |
| | | map1.put("logo", "https://spring.io/img/homepage/icon-spring-framework.svg"); |
| | | map1.put("title", "SpringBoot"); |
| | | map1.put("description", "现在的web项目几乎都会用到spring框架,而要使用spring难免需要配置大量的xml配置文件,而 springboot的出现解 决了这一问题,一个项目甚至不用部署到服务器上直接开跑,真像springboot所说:“just run”。"); |
| | | map1.put("member", "Chill"); |
| | | map1.put("href", "http://spring.io/projects/spring-boot"); |
| | | list.add(map1); |
| | | |
| | | Map<String, String> map2 = new HashMap<>(16); |
| | | map2.put("logo", "https://spring.io/img/homepage/icon-spring-cloud.svg"); |
| | | map2.put("title", "SpringCloud"); |
| | | map2.put("description", "SpringCloud是基于SpringBoot的一整套实现微服务的框架。他提供了微服务开发所需的配置管理、服务发现、断路器、智能路由、微代理、控制总线、全局锁、决策竞选、分布式会话和集群状态管理等组件。"); |
| | | map2.put("member", "Chill"); |
| | | map2.put("href", "http://spring.io/projects/spring-cloud"); |
| | | list.add(map2); |
| | | |
| | | Map<String, String> map3 = new HashMap<>(16); |
| | | map3.put("logo", "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1546359961068&di=05ff9406e6675ca9a58a525a7e7950b9&imgtype=jpg&src=http%3A%2F%2Fimg0.imgtn.bdimg.com%2Fit%2Fu%3D575314515%2C4268715674%26fm%3D214%26gp%3D0.jpg"); |
| | | map3.put("title", "Mybatis"); |
| | | map3.put("description", "MyBatis 是一款优秀的持久层框架,它支持定制化 SQL、存储过程以及高级映射。MyBatis 避免了几乎所有的 JDBC 代码和手动设置参数以及获取结果集。MyBatis 可以使用简单的 XML 或注解来配置和映射原生信息,将接口和 Java 的 POJOs(Plain Old Java Objects,普通的 Java对象)映射成数据库中的记录。"); |
| | | map3.put("member", "Chill"); |
| | | map3.put("href", "http://www.mybatis.org/mybatis-3/getting-started.html"); |
| | | list.add(map3); |
| | | |
| | | Map<String, String> map4 = new HashMap<>(16); |
| | | map4.put("logo", "https://gw.alipayobjects.com/zos/rmsportal/kZzEzemZyKLKFsojXItE.png"); |
| | | map4.put("title", "React"); |
| | | map4.put("description", "React 起源于 Facebook 的内部项目,因为该公司对市场上所有 JavaScript MVC 框架,都不满意,就决定自己写一套,用来架设Instagram 的网站。做出来以后,发现这套东西很好用,就在2013年5月开源了。"); |
| | | map4.put("member", "Chill"); |
| | | map4.put("href", "https://reactjs.org/"); |
| | | list.add(map4); |
| | | |
| | | Map<String, String> map5 = new HashMap<>(16); |
| | | map5.put("logo", "https://gw.alipayobjects.com/zos/rmsportal/dURIMkkrRFpPgTuzkwnB.png"); |
| | | map5.put("title", "Ant Design"); |
| | | map5.put("description", "蚂蚁金服体验技术部经过大量的项目实践和总结,沉淀出设计语言 Ant Design,这可不单纯只是设计原则、控件规范和视觉尺寸,还配套有前端代码实现方案。也就是说采用Ant Design后,UI设计和前端界面研发可同步完成,效率大大提升。"); |
| | | map5.put("member", "Chill"); |
| | | map5.put("href", "https://ant.design/docs/spec/introduce-cn"); |
| | | list.add(map5); |
| | | |
| | | Map<String, String> map6 = new HashMap<>(16); |
| | | map6.put("logo", "https://gw.alipayobjects.com/zos/rmsportal/sfjbOqnsXXJgNCjCzDBL.png"); |
| | | map6.put("title", "Ant Design Pro"); |
| | | map6.put("description", "Ant Design Pro 是一个企业级开箱即用的中后台前端/设计解决方案。符合阿里追求的'敏捷的前端+强大的中台'的思想。"); |
| | | map6.put("member", "Chill"); |
| | | map6.put("href", "https://pro.ant.design"); |
| | | list.add(map6); |
| | | |
| | | return R.data(list); |
| | | } |
| | | |
| | | /** |
| | | * 获取我的消息 |
| | | */ |
| | | @GetMapping("/notice/my-notices") |
| | | @ApiOperationSupport(order = 5) |
| | | @ApiOperation(value = "消息", notes = "消息") |
| | | public R myNotices() { |
| | | List<Map<String, String>> list = new ArrayList<>(); |
| | | Map<String, String> map1 = new HashMap<>(16); |
| | | map1.put("id", "000000001"); |
| | | map1.put("avatar", "https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png"); |
| | | map1.put("title", "你收到了 14 份新周报"); |
| | | map1.put("datetime", "2018-08-09"); |
| | | map1.put("type", "notification"); |
| | | list.add(map1); |
| | | |
| | | Map<String, String> map2 = new HashMap<>(16); |
| | | map2.put("id", "000000002"); |
| | | map2.put("avatar", "https://gw.alipayobjects.com/zos/rmsportal/OKJXDXrmkNshAMvwtvhu.png"); |
| | | map2.put("title", "你推荐的 曲妮妮 已通过第三轮面试"); |
| | | map2.put("datetime", "2018-08-08"); |
| | | map2.put("type", "notification"); |
| | | list.add(map2); |
| | | |
| | | |
| | | Map<String, String> map3 = new HashMap<>(16); |
| | | map3.put("id", "000000003"); |
| | | map3.put("avatar", "https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg"); |
| | | map3.put("title", "曲丽丽 评论了你"); |
| | | map3.put("description", "描述信息描述信息描述信息"); |
| | | map3.put("datetime", "2018-08-07"); |
| | | map3.put("type", "message"); |
| | | map3.put("clickClose", "true"); |
| | | list.add(map3); |
| | | |
| | | |
| | | Map<String, String> map4 = new HashMap<>(16); |
| | | map4.put("id", "000000004"); |
| | | map4.put("avatar", "https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg"); |
| | | map4.put("title", "朱偏右 回复了你"); |
| | | map4.put("description", "这种模板用于提醒谁与你发生了互动,左侧放『谁』的头像"); |
| | | map4.put("type", "message"); |
| | | map4.put("datetime", "2018-08-07"); |
| | | map4.put("clickClose", "true"); |
| | | list.add(map4); |
| | | |
| | | |
| | | Map<String, String> map5 = new HashMap<>(16); |
| | | map5.put("id", "000000005"); |
| | | map5.put("title", "任务名称"); |
| | | map5.put("description", "任务需要在 2018-01-12 20:00 前启动"); |
| | | map5.put("extra", "未开始"); |
| | | map5.put("status", "todo"); |
| | | map5.put("type", "event"); |
| | | list.add(map5); |
| | | |
| | | return R.data(list); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.desk.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import cn.gistack.flow.core.entity.FlowEntity; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 请假流程实体类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @TableName("blade_process_leave") |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class ProcessLeave extends FlowEntity { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 流程定义id |
| | | */ |
| | | private String processDefinitionId; |
| | | /** |
| | | * 流程实例id |
| | | */ |
| | | private String processInstanceId; |
| | | /** |
| | | * 请假开始时间 |
| | | */ |
| | | private Date startTime; |
| | | /** |
| | | * 请假结束时间 |
| | | */ |
| | | private Date endTime; |
| | | /** |
| | | * 请假理由 |
| | | */ |
| | | private String reason; |
| | | /** |
| | | * 审批人 |
| | | */ |
| | | private String taskUser; |
| | | /** |
| | | * 流程申请时间 |
| | | */ |
| | | private Date applyTime; |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.desk.feign; |
| | | |
| | | import cn.gistack.desk.entity.Notice; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.core.mp.support.BladePage; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.tenant.annotation.NonDS; |
| | | import cn.gistack.desk.service.INoticeService; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import springfox.documentation.annotations.ApiIgnore; |
| | | |
| | | /** |
| | | * Notice Feign |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @NonDS |
| | | @ApiIgnore() |
| | | @RestController |
| | | @AllArgsConstructor |
| | | public class NoticeClient implements INoticeClient { |
| | | |
| | | private final INoticeService service; |
| | | |
| | | @Override |
| | | @GetMapping(TOP) |
| | | public BladePage<Notice> top(Integer current, Integer size) { |
| | | Query query = new Query(); |
| | | query.setCurrent(current); |
| | | query.setSize(size); |
| | | IPage<Notice> page = service.page(Condition.getPage(query)); |
| | | return BladePage.of(page); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.desk.mapper; |
| | | |
| | | import cn.gistack.desk.entity.ProcessLeave; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | |
| | | /** |
| | | * Mapper 接口 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface LeaveMapper extends BaseMapper<ProcessLeave> { |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="cn.gistack.desk.mapper.NoticeMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="noticeResultMap" type="cn.gistack.desk.entity.Notice"> |
| | | <result column="id" property="id"/> |
| | | <result column="create_user" property="createUser"/> |
| | | <result column="create_time" property="createTime"/> |
| | | <result column="update_user" property="updateUser"/> |
| | | <result column="update_time" property="updateTime"/> |
| | | <result column="status" property="status"/> |
| | | <result column="is_deleted" property="isDeleted"/> |
| | | <result column="release_time" property="releaseTime"/> |
| | | <result column="title" property="title"/> |
| | | <result column="content" property="content"/> |
| | | </resultMap> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="noticeVOResultMap" type="cn.gistack.desk.vo.NoticeVO"> |
| | | <result column="id" property="id"/> |
| | | <result column="create_user" property="createUser"/> |
| | | <result column="create_time" property="createTime"/> |
| | | <result column="update_user" property="updateUser"/> |
| | | <result column="update_time" property="updateTime"/> |
| | | <result column="status" property="status"/> |
| | | <result column="is_deleted" property="isDeleted"/> |
| | | <result column="release_time" property="releaseTime"/> |
| | | <result column="title" property="title"/> |
| | | <result column="content" property="content"/> |
| | | </resultMap> |
| | | |
| | | <select id="topList" resultMap="noticeResultMap"> |
| | | select * from blade_notice limit #{number} |
| | | </select> |
| | | |
| | | <select id="selectNoticePage" resultMap="noticeVOResultMap"> |
| | | SELECT |
| | | n.*, |
| | | d.dict_value AS categoryName |
| | | FROM |
| | | blade_notice n |
| | | LEFT JOIN ( SELECT * FROM blade_dict WHERE CODE = 'notice' ) d ON n.category = d.dict_key |
| | | WHERE |
| | | n.is_deleted = 0 and n.tenant_id = #{notice.tenantId} |
| | | <if test="notice.title!=null"> |
| | | and n.title like concat(concat('%', #{notice.title}), '%') |
| | | </if> |
| | | <if test="notice.category!=null"> |
| | | and n.category = #{notice.category} |
| | | </if> |
| | | </select> |
| | | |
| | | </mapper> |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.desk.service; |
| | | |
| | | import cn.gistack.desk.entity.ProcessLeave; |
| | | import org.springblade.core.mp.base.BaseService; |
| | | |
| | | /** |
| | | * 服务类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface ILeaveService extends BaseService<ProcessLeave> { |
| | | |
| | | /** |
| | | * 开启流程 |
| | | * |
| | | * @param leave 请假实体 |
| | | * @return boolean |
| | | */ |
| | | boolean startProcess(ProcessLeave leave); |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system; |
| | | |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | |
| | | /** |
| | | * 系统模块启动器 |
| | | * @author Chill |
| | | */ |
| | | @BladeCloudApplication |
| | | public class SystemApplication { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppConstant.APPLICATION_SYSTEM_NAME, SystemApplication.class, args); |
| | | } |
| | | |
| | | } |
| | | |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.controller; |
| | | |
| | | import cn.gistack.system.wrapper.ApiScopeWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.core.boot.ctrl.BladeController; |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.tenant.annotation.NonDS; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import cn.gistack.system.entity.ApiScope; |
| | | import cn.gistack.system.service.IApiScopeService; |
| | | import cn.gistack.system.vo.ApiScopeVO; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.Valid; |
| | | |
| | | import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE; |
| | | |
| | | /** |
| | | * 接口权限控制器 |
| | | * |
| | | * @author BladeX |
| | | */ |
| | | @NonDS |
| | | @RestController |
| | | @AllArgsConstructor |
| | | @RequestMapping("api-scope") |
| | | @Api(value = "接口权限", tags = "接口权限") |
| | | public class ApiScopeController extends BladeController { |
| | | |
| | | private final IApiScopeService apiScopeService; |
| | | |
| | | /** |
| | | * 详情 |
| | | */ |
| | | @GetMapping("/detail") |
| | | @ApiOperationSupport(order = 1) |
| | | @ApiOperation(value = "详情", notes = "传入dataScope") |
| | | public R<ApiScope> detail(ApiScope dataScope) { |
| | | ApiScope detail = apiScopeService.getOne(Condition.getQueryWrapper(dataScope)); |
| | | return R.data(detail); |
| | | } |
| | | |
| | | /** |
| | | * 分页 |
| | | */ |
| | | @GetMapping("/list") |
| | | @ApiOperationSupport(order = 2) |
| | | @ApiOperation(value = "分页", notes = "传入dataScope") |
| | | public R<IPage<ApiScopeVO>> list(ApiScope dataScope, Query query) { |
| | | IPage<ApiScope> pages = apiScopeService.page(Condition.getPage(query), Condition.getQueryWrapper(dataScope)); |
| | | return R.data(ApiScopeWrapper.build().pageVO(pages)); |
| | | } |
| | | |
| | | /** |
| | | * 新增 |
| | | */ |
| | | @PostMapping("/save") |
| | | @ApiOperationSupport(order = 3) |
| | | @ApiOperation(value = "新增", notes = "传入dataScope") |
| | | public R save(@Valid @RequestBody ApiScope dataScope) { |
| | | CacheUtil.clear(SYS_CACHE, Boolean.FALSE); |
| | | return R.status(apiScopeService.save(dataScope)); |
| | | } |
| | | |
| | | /** |
| | | * 修改 |
| | | */ |
| | | @PostMapping("/update") |
| | | @ApiOperationSupport(order = 4) |
| | | @ApiOperation(value = "修改", notes = "传入dataScope") |
| | | public R update(@Valid @RequestBody ApiScope dataScope) { |
| | | CacheUtil.clear(SYS_CACHE, Boolean.FALSE); |
| | | return R.status(apiScopeService.updateById(dataScope)); |
| | | } |
| | | |
| | | /** |
| | | * 新增或修改 |
| | | */ |
| | | @PostMapping("/submit") |
| | | @ApiOperationSupport(order = 5) |
| | | @ApiOperation(value = "新增或修改", notes = "传入dataScope") |
| | | public R submit(@Valid @RequestBody ApiScope dataScope) { |
| | | CacheUtil.clear(SYS_CACHE, Boolean.FALSE); |
| | | return R.status(apiScopeService.saveOrUpdate(dataScope)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 删除 |
| | | */ |
| | | @PostMapping("/remove") |
| | | @ApiOperationSupport(order = 6) |
| | | @ApiOperation(value = "逻辑删除", notes = "传入ids") |
| | | public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
| | | CacheUtil.clear(SYS_CACHE, Boolean.FALSE); |
| | | return R.status(apiScopeService.deleteLogic(Func.toLongList(ids))); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.controller; |
| | | |
| | | import cn.gistack.system.vo.GrantTreeVO; |
| | | import cn.gistack.system.wrapper.MenuWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import io.swagger.annotations.*; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.core.boot.ctrl.BladeController; |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.secure.BladeUser; |
| | | import org.springblade.core.secure.annotation.PreAuth; |
| | | import org.springblade.core.tenant.annotation.NonDS; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.constant.RoleConstant; |
| | | import org.springblade.core.tool.node.TreeNode; |
| | | import org.springblade.core.tool.support.Kv; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import cn.gistack.system.entity.Menu; |
| | | import cn.gistack.system.entity.TopMenu; |
| | | import cn.gistack.system.service.IMenuService; |
| | | import cn.gistack.system.service.ITopMenuService; |
| | | import cn.gistack.system.vo.CheckedTreeVO; |
| | | import cn.gistack.system.vo.MenuVO; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import springfox.documentation.annotations.ApiIgnore; |
| | | |
| | | import javax.validation.Valid; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import static org.springblade.core.cache.constant.CacheConstant.MENU_CACHE; |
| | | |
| | | |
| | | /** |
| | | * 控制器 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @NonDS |
| | | @RestController |
| | | @AllArgsConstructor |
| | | @RequestMapping("/menu") |
| | | @Api(value = "菜单", tags = "菜单") |
| | | public class MenuController extends BladeController { |
| | | |
| | | private final IMenuService menuService; |
| | | private final ITopMenuService topMenuService; |
| | | |
| | | /** |
| | | * 详情 |
| | | */ |
| | | @GetMapping("/detail") |
| | | @PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR) |
| | | @ApiOperationSupport(order = 1) |
| | | @ApiOperation(value = "详情", notes = "传入menu") |
| | | public R<MenuVO> detail(Menu menu) { |
| | | Menu detail = menuService.getOne(Condition.getQueryWrapper(menu)); |
| | | return R.data(MenuWrapper.build().entityVO(detail)); |
| | | } |
| | | |
| | | /** |
| | | * 列表 |
| | | */ |
| | | @GetMapping("/list") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "code", value = "菜单编号", paramType = "query", dataType = "string"), |
| | | @ApiImplicitParam(name = "name", value = "菜单名称", paramType = "query", dataType = "string") |
| | | }) |
| | | @PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR) |
| | | @ApiOperationSupport(order = 2) |
| | | @ApiOperation(value = "列表", notes = "传入menu") |
| | | public R<List<MenuVO>> list(@ApiIgnore @RequestParam Map<String, Object> menu) { |
| | | List<Menu> list = menuService.list(Condition.getQueryWrapper(menu, Menu.class).lambda().orderByAsc(Menu::getSort)); |
| | | return R.data(MenuWrapper.build().listNodeVO(list)); |
| | | } |
| | | |
| | | /** |
| | | * 懒加载列表 |
| | | */ |
| | | @GetMapping("/lazy-list") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "code", value = "菜单编号", paramType = "query", dataType = "string"), |
| | | @ApiImplicitParam(name = "name", value = "菜单名称", paramType = "query", dataType = "string") |
| | | }) |
| | | @PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR) |
| | | @ApiOperationSupport(order = 3) |
| | | @ApiOperation(value = "懒加载列表", notes = "传入menu") |
| | | public R<List<MenuVO>> lazyList(Long parentId, @ApiIgnore @RequestParam Map<String, Object> menu) { |
| | | List<MenuVO> list = menuService.lazyList(parentId, menu); |
| | | return R.data(MenuWrapper.build().listNodeLazyVO(list)); |
| | | } |
| | | |
| | | /** |
| | | * 菜单列表 |
| | | */ |
| | | @GetMapping("/menu-list") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "code", value = "菜单编号", paramType = "query", dataType = "string"), |
| | | @ApiImplicitParam(name = "name", value = "菜单名称", paramType = "query", dataType = "string") |
| | | }) |
| | | @PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR) |
| | | @ApiOperationSupport(order = 4) |
| | | @ApiOperation(value = "菜单列表", notes = "传入menu") |
| | | public R<List<MenuVO>> menuList(@ApiIgnore @RequestParam Map<String, Object> menu) { |
| | | List<Menu> list = menuService.list(Condition.getQueryWrapper(menu, Menu.class).lambda().eq(Menu::getCategory, 1).orderByAsc(Menu::getSort)); |
| | | return R.data(MenuWrapper.build().listNodeVO(list)); |
| | | } |
| | | |
| | | /** |
| | | * 懒加载菜单列表 |
| | | */ |
| | | @GetMapping("/lazy-menu-list") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "code", value = "菜单编号", paramType = "query", dataType = "string"), |
| | | @ApiImplicitParam(name = "name", value = "菜单名称", paramType = "query", dataType = "string") |
| | | }) |
| | | @PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR) |
| | | @ApiOperationSupport(order = 5) |
| | | @ApiOperation(value = "懒加载菜单列表", notes = "传入menu") |
| | | public R<List<MenuVO>> lazyMenuList(Long parentId, @ApiIgnore @RequestParam Map<String, Object> menu) { |
| | | List<MenuVO> list = menuService.lazyMenuList(parentId, menu); |
| | | return R.data(MenuWrapper.build().listNodeLazyVO(list)); |
| | | } |
| | | |
| | | /** |
| | | * 新增或修改 |
| | | */ |
| | | @PostMapping("/submit") |
| | | @PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR) |
| | | @ApiOperationSupport(order = 6) |
| | | @ApiOperation(value = "新增或修改", notes = "传入menu") |
| | | public R submit(@Valid @RequestBody Menu menu) { |
| | | if (menuService.submit(menu)) { |
| | | CacheUtil.clear(MENU_CACHE); |
| | | CacheUtil.clear(MENU_CACHE, Boolean.FALSE); |
| | | // 返回懒加载树更新节点所需字段 |
| | | Kv kv = Kv.create().set("id", String.valueOf(menu.getId())); |
| | | return R.data(kv); |
| | | } |
| | | return R.fail("操作失败"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 删除 |
| | | */ |
| | | @PostMapping("/remove") |
| | | @PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR) |
| | | @ApiOperationSupport(order = 7) |
| | | @ApiOperation(value = "删除", notes = "传入ids") |
| | | public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
| | | CacheUtil.clear(MENU_CACHE); |
| | | CacheUtil.clear(MENU_CACHE, Boolean.FALSE); |
| | | return R.status(menuService.removeMenu(ids)); |
| | | } |
| | | |
| | | /** |
| | | * 前端菜单数据 |
| | | */ |
| | | @GetMapping("/routes") |
| | | @ApiOperationSupport(order = 8) |
| | | @ApiOperation(value = "前端菜单数据", notes = "前端菜单数据") |
| | | public R<List<MenuVO>> routes(BladeUser user, Long topMenuId) { |
| | | List<MenuVO> list = menuService.routes((user == null) ? null : user.getRoleId(), topMenuId); |
| | | return R.data(list); |
| | | } |
| | | |
| | | /** |
| | | * 前端按钮数据 |
| | | */ |
| | | @GetMapping("/buttons") |
| | | @ApiOperationSupport(order = 10) |
| | | @ApiOperation(value = "前端按钮数据", notes = "前端按钮数据") |
| | | public R<List<MenuVO>> buttons(BladeUser user) { |
| | | List<MenuVO> list = menuService.buttons(user.getRoleId()); |
| | | return R.data(list); |
| | | } |
| | | |
| | | /** |
| | | * 获取菜单树形结构 |
| | | */ |
| | | @GetMapping("/tree") |
| | | @ApiOperationSupport(order = 11) |
| | | @ApiOperation(value = "树形结构", notes = "树形结构") |
| | | public R<List<TreeNode>> tree() { |
| | | List<TreeNode> tree = menuService.tree(); |
| | | return R.data(tree); |
| | | } |
| | | |
| | | /** |
| | | * 获取权限分配树形结构 |
| | | */ |
| | | @GetMapping("/grant-tree") |
| | | @ApiOperationSupport(order = 12) |
| | | @ApiOperation(value = "权限分配树形结构", notes = "权限分配树形结构") |
| | | public R<GrantTreeVO> grantTree(BladeUser user) { |
| | | GrantTreeVO vo = new GrantTreeVO(); |
| | | vo.setMenu(menuService.grantTree(user)); |
| | | vo.setDataScope(menuService.grantDataScopeTree(user)); |
| | | vo.setApiScope(menuService.grantApiScopeTree(user)); |
| | | return R.data(vo); |
| | | } |
| | | |
| | | /** |
| | | * 获取权限分配树形结构 |
| | | */ |
| | | @GetMapping("/role-tree-keys") |
| | | @ApiOperationSupport(order = 13) |
| | | @ApiOperation(value = "角色所分配的树", notes = "角色所分配的树") |
| | | public R<CheckedTreeVO> roleTreeKeys(String roleIds) { |
| | | CheckedTreeVO vo = new CheckedTreeVO(); |
| | | vo.setMenu(menuService.roleTreeKeys(roleIds)); |
| | | vo.setDataScope(menuService.dataScopeTreeKeys(roleIds)); |
| | | vo.setApiScope(menuService.apiScopeTreeKeys(roleIds)); |
| | | return R.data(vo); |
| | | } |
| | | |
| | | /** |
| | | * 获取顶部菜单树形结构 |
| | | */ |
| | | @GetMapping("/grant-top-tree") |
| | | @ApiOperationSupport(order = 14) |
| | | @ApiOperation(value = "顶部菜单树形结构", notes = "顶部菜单树形结构") |
| | | public R<GrantTreeVO> grantTopTree(BladeUser user) { |
| | | GrantTreeVO vo = new GrantTreeVO(); |
| | | vo.setMenu(menuService.grantTopTree(user)); |
| | | return R.data(vo); |
| | | } |
| | | |
| | | /** |
| | | * 获取顶部菜单树形结构 |
| | | */ |
| | | @GetMapping("/top-tree-keys") |
| | | @ApiOperationSupport(order = 15) |
| | | @ApiOperation(value = "顶部菜单所分配的树", notes = "顶部菜单所分配的树") |
| | | public R<CheckedTreeVO> topTreeKeys(String topMenuIds) { |
| | | CheckedTreeVO vo = new CheckedTreeVO(); |
| | | vo.setMenu(menuService.topTreeKeys(topMenuIds)); |
| | | return R.data(vo); |
| | | } |
| | | |
| | | /** |
| | | * 顶部菜单数据 |
| | | */ |
| | | @GetMapping("/top-menu") |
| | | @ApiOperationSupport(order = 16) |
| | | @ApiOperation(value = "顶部菜单数据", notes = "顶部菜单数据") |
| | | public R<List<TopMenu>> topMenu(BladeUser user) { |
| | | if (Func.isEmpty(user)) { |
| | | return null; |
| | | } |
| | | List<TopMenu> list = topMenuService.list(Wrappers.<TopMenu>query().lambda().orderByAsc(TopMenu::getSort)); |
| | | return R.data(list); |
| | | } |
| | | |
| | | /** |
| | | * 获取配置的角色权限 |
| | | */ |
| | | @GetMapping("auth-routes") |
| | | @ApiOperationSupport(order = 17) |
| | | @ApiOperation(value = "菜单的角色权限") |
| | | public R<List<Kv>> authRoutes(BladeUser user) { |
| | | if (Func.isEmpty(user)) { |
| | | return null; |
| | | } |
| | | return R.data(menuService.authRoutes(user)); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import io.swagger.annotations.*; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.core.boot.ctrl.BladeController; |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.tenant.annotation.NonDS; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import cn.gistack.system.entity.Param; |
| | | import cn.gistack.system.service.IParamService; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import springfox.documentation.annotations.ApiIgnore; |
| | | |
| | | import javax.validation.Valid; |
| | | import java.util.Map; |
| | | |
| | | import static org.springblade.core.cache.constant.CacheConstant.PARAM_CACHE; |
| | | |
| | | /** |
| | | * 控制器 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @NonDS |
| | | @RestController |
| | | @AllArgsConstructor |
| | | @RequestMapping("/param") |
| | | @Api(value = "参数管理", tags = "接口") |
| | | public class ParamController extends BladeController { |
| | | |
| | | private final IParamService paramService; |
| | | |
| | | /** |
| | | * 详情 |
| | | */ |
| | | @GetMapping("/detail") |
| | | @ApiOperationSupport(order = 1) |
| | | @ApiOperation(value = "详情", notes = "传入param") |
| | | public R<Param> detail(Param param) { |
| | | Param detail = paramService.getOne(Condition.getQueryWrapper(param)); |
| | | return R.data(detail); |
| | | } |
| | | |
| | | /** |
| | | * 分页 |
| | | */ |
| | | @GetMapping("/list") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "paramName", value = "参数名称", paramType = "query", dataType = "string"), |
| | | @ApiImplicitParam(name = "paramKey", value = "参数键名", paramType = "query", dataType = "string"), |
| | | @ApiImplicitParam(name = "paramValue", value = "参数键值", paramType = "query", dataType = "string") |
| | | }) |
| | | @ApiOperationSupport(order = 2) |
| | | @ApiOperation(value = "分页", notes = "传入param") |
| | | public R<IPage<Param>> list(@ApiIgnore @RequestParam Map<String, Object> param, Query query) { |
| | | IPage<Param> pages = paramService.page(Condition.getPage(query), Condition.getQueryWrapper(param, Param.class)); |
| | | return R.data(pages); |
| | | } |
| | | |
| | | /** |
| | | * 新增或修改 |
| | | */ |
| | | @PostMapping("/submit") |
| | | @ApiOperationSupport(order = 3) |
| | | @ApiOperation(value = "新增或修改", notes = "传入param") |
| | | public R submit(@Valid @RequestBody Param param) { |
| | | CacheUtil.clear(PARAM_CACHE); |
| | | CacheUtil.clear(PARAM_CACHE, Boolean.FALSE); |
| | | return R.status(paramService.saveOrUpdate(param)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 删除 |
| | | */ |
| | | @PostMapping("/remove") |
| | | @ApiOperationSupport(order = 4) |
| | | @ApiOperation(value = "逻辑删除", notes = "传入ids") |
| | | public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
| | | CacheUtil.clear(PARAM_CACHE); |
| | | CacheUtil.clear(PARAM_CACHE, Boolean.FALSE); |
| | | return R.status(paramService.deleteLogic(Func.toLongList(ids))); |
| | | } |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.controller; |
| | | |
| | | import cn.gistack.system.vo.RegionVO; |
| | | import cn.gistack.system.wrapper.RegionWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import io.swagger.annotations.*; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.core.boot.ctrl.BladeController; |
| | | import org.springblade.core.excel.util.ExcelUtil; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.tenant.annotation.NonDS; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.DateUtil; |
| | | import cn.gistack.system.entity.Region; |
| | | import cn.gistack.system.excel.RegionExcel; |
| | | import cn.gistack.system.excel.RegionImporter; |
| | | import cn.gistack.system.service.IRegionService; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import springfox.documentation.annotations.ApiIgnore; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.Valid; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 行政区划表 控制器 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @NonDS |
| | | @RestController |
| | | @AllArgsConstructor |
| | | @RequestMapping("/region") |
| | | @Api(value = "行政区划", tags = "行政区划") |
| | | public class RegionController extends BladeController { |
| | | |
| | | private final IRegionService regionService; |
| | | |
| | | /** |
| | | * 详情 |
| | | */ |
| | | @GetMapping("/detail") |
| | | @ApiOperationSupport(order = 1) |
| | | @ApiOperation(value = "详情", notes = "传入region") |
| | | public R<RegionVO> detail(Region region) { |
| | | Region detail = regionService.getOne(Condition.getQueryWrapper(region)); |
| | | return R.data(RegionWrapper.build().entityVO(detail)); |
| | | } |
| | | |
| | | /** |
| | | * 分页 行政区划表 |
| | | */ |
| | | @GetMapping("/list") |
| | | @ApiOperationSupport(order = 2) |
| | | @ApiOperation(value = "分页", notes = "传入region") |
| | | public R<IPage<Region>> list(Region region, Query query) { |
| | | IPage<Region> pages = regionService.page(Condition.getPage(query), Condition.getQueryWrapper(region)); |
| | | return R.data(pages); |
| | | } |
| | | |
| | | /** |
| | | * 懒加载列表 |
| | | */ |
| | | @GetMapping("/lazy-list") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "code", value = "区划编号", paramType = "query", dataType = "string"), |
| | | @ApiImplicitParam(name = "name", value = "区划名称", paramType = "query", dataType = "string") |
| | | }) |
| | | @ApiOperationSupport(order = 3) |
| | | @ApiOperation(value = "懒加载列表", notes = "传入menu") |
| | | public R<List<RegionVO>> lazyList(String parentCode, @ApiIgnore @RequestParam Map<String, Object> menu) { |
| | | List<RegionVO> list = regionService.lazyList(parentCode, menu); |
| | | return R.data(RegionWrapper.build().listNodeLazyVO(list)); |
| | | } |
| | | |
| | | /** |
| | | * 懒加载列表 |
| | | */ |
| | | @GetMapping("/lazy-tree") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "code", value = "区划编号", paramType = "query", dataType = "string"), |
| | | @ApiImplicitParam(name = "name", value = "区划名称", paramType = "query", dataType = "string") |
| | | }) |
| | | @ApiOperationSupport(order = 4) |
| | | @ApiOperation(value = "懒加载列表", notes = "传入menu") |
| | | public R<List<RegionVO>> lazyTree(String parentCode, @ApiIgnore @RequestParam Map<String, Object> menu) { |
| | | List<RegionVO> list = regionService.lazyTree(parentCode, menu); |
| | | return R.data(RegionWrapper.build().listNodeLazyVO(list)); |
| | | } |
| | | |
| | | /** |
| | | * 新增 行政区划表 |
| | | */ |
| | | @PostMapping("/save") |
| | | @ApiOperationSupport(order = 5) |
| | | @ApiOperation(value = "新增", notes = "传入region") |
| | | public R save(@Valid @RequestBody Region region) { |
| | | return R.status(regionService.save(region)); |
| | | } |
| | | |
| | | /** |
| | | * 修改 行政区划表 |
| | | */ |
| | | @PostMapping("/update") |
| | | @ApiOperationSupport(order = 6) |
| | | @ApiOperation(value = "修改", notes = "传入region") |
| | | public R update(@Valid @RequestBody Region region) { |
| | | return R.status(regionService.updateById(region)); |
| | | } |
| | | |
| | | /** |
| | | * 新增或修改 行政区划表 |
| | | */ |
| | | @PostMapping("/submit") |
| | | @ApiOperationSupport(order = 7) |
| | | @ApiOperation(value = "新增或修改", notes = "传入region") |
| | | public R submit(@Valid @RequestBody Region region) { |
| | | return R.status(regionService.submit(region)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 删除 行政区划表 |
| | | */ |
| | | @PostMapping("/remove") |
| | | @ApiOperationSupport(order = 8) |
| | | @ApiOperation(value = "删除", notes = "传入主键") |
| | | public R remove(@ApiParam(value = "主键", required = true) @RequestParam String id) { |
| | | return R.status(regionService.removeRegion(id)); |
| | | } |
| | | |
| | | /** |
| | | * 行政区划下拉数据源 |
| | | */ |
| | | @GetMapping("/select") |
| | | @ApiOperationSupport(order = 9) |
| | | @ApiOperation(value = "下拉数据源", notes = "传入tenant") |
| | | public R<List<Region>> select(@RequestParam(required = false, defaultValue = "00") String code) { |
| | | List<Region> list = regionService.list(Wrappers.<Region>query().lambda().eq(Region::getParentCode, code)); |
| | | return R.data(list); |
| | | } |
| | | |
| | | /** |
| | | * 导入行政区划数据 |
| | | */ |
| | | @PostMapping("import-region") |
| | | @ApiOperationSupport(order = 10) |
| | | @ApiOperation(value = "导入行政区划", notes = "传入excel") |
| | | public R importRegion(MultipartFile file, Integer isCovered) { |
| | | RegionImporter regionImporter = new RegionImporter(regionService, isCovered == 1); |
| | | ExcelUtil.save(file, regionImporter, RegionExcel.class); |
| | | return R.success("操作成功"); |
| | | } |
| | | |
| | | /** |
| | | * 导出行政区划数据 |
| | | */ |
| | | @GetMapping("export-region") |
| | | @ApiOperationSupport(order = 11) |
| | | @ApiOperation(value = "导出行政区划", notes = "传入user") |
| | | public void exportRegion(@ApiIgnore @RequestParam Map<String, Object> region, HttpServletResponse response) { |
| | | QueryWrapper<Region> queryWrapper = Condition.getQueryWrapper(region, Region.class); |
| | | List<RegionExcel> list = regionService.exportRegion(queryWrapper); |
| | | ExcelUtil.export(response, "行政区划数据" + DateUtil.time(), "行政区划数据表", list, RegionExcel.class); |
| | | } |
| | | |
| | | /** |
| | | * 导出模板 |
| | | */ |
| | | @GetMapping("export-template") |
| | | @ApiOperationSupport(order = 12) |
| | | @ApiOperation(value = "导出模板") |
| | | public void exportUser(HttpServletResponse response) { |
| | | List<RegionExcel> list = new ArrayList<>(); |
| | | ExcelUtil.export(response, "行政区划模板", "行政区划表", list, RegionExcel.class); |
| | | } |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.controller; |
| | | |
| | | import cn.gistack.system.vo.GrantVO; |
| | | import cn.gistack.system.vo.RoleVO; |
| | | import cn.gistack.system.wrapper.RoleWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import io.swagger.annotations.*; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.core.boot.ctrl.BladeController; |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.secure.BladeUser; |
| | | import org.springblade.core.secure.annotation.PreAuth; |
| | | import org.springblade.core.secure.constant.AuthConstant; |
| | | import org.springblade.core.tenant.annotation.NonDS; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.constant.BladeConstant; |
| | | import org.springblade.core.tool.constant.RoleConstant; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import cn.gistack.system.cache.SysCache; |
| | | import cn.gistack.system.entity.Role; |
| | | import cn.gistack.system.service.IRoleService; |
| | | import cn.gistack.system.user.cache.UserCache; |
| | | import cn.gistack.system.user.entity.User; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import springfox.documentation.annotations.ApiIgnore; |
| | | |
| | | import javax.validation.Valid; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE; |
| | | |
| | | /** |
| | | * 控制器 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @NonDS |
| | | @RestController |
| | | @AllArgsConstructor |
| | | @RequestMapping("/role") |
| | | @Api(value = "角色", tags = "角色") |
| | | @PreAuth(RoleConstant.HAS_ROLE_ADMIN) |
| | | public class RoleController extends BladeController { |
| | | |
| | | private final IRoleService roleService; |
| | | |
| | | /** |
| | | * 详情 |
| | | */ |
| | | @GetMapping("/detail") |
| | | @ApiOperationSupport(order = 1) |
| | | @ApiOperation(value = "详情", notes = "传入role") |
| | | public R<RoleVO> detail(Role role) { |
| | | Role detail = roleService.getOne(Condition.getQueryWrapper(role)); |
| | | return R.data(RoleWrapper.build().entityVO(detail)); |
| | | } |
| | | |
| | | /** |
| | | * 列表 |
| | | */ |
| | | @GetMapping("/list") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "roleName", value = "参数名称", paramType = "query", dataType = "string"), |
| | | @ApiImplicitParam(name = "roleAlias", value = "角色别名", paramType = "query", dataType = "string") |
| | | }) |
| | | @ApiOperationSupport(order = 2) |
| | | @ApiOperation(value = "列表", notes = "传入role") |
| | | public R<List<RoleVO>> list(@ApiIgnore @RequestParam Map<String, Object> role, BladeUser bladeUser) { |
| | | QueryWrapper<Role> queryWrapper = Condition.getQueryWrapper(role, Role.class); |
| | | List<Role> list = roleService.list((!bladeUser.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID)) ? queryWrapper.lambda().eq(Role::getTenantId, bladeUser.getTenantId()) : queryWrapper); |
| | | return R.data(RoleWrapper.build().listNodeVO(list)); |
| | | } |
| | | |
| | | /** |
| | | * 获取角色树形结构 |
| | | */ |
| | | @GetMapping("/tree") |
| | | @ApiOperationSupport(order = 3) |
| | | @ApiOperation(value = "树形结构", notes = "树形结构") |
| | | public R<List<RoleVO>> tree(String tenantId, BladeUser bladeUser) { |
| | | List<RoleVO> tree = roleService.tree(Func.toStrWithEmpty(tenantId, bladeUser.getTenantId())); |
| | | return R.data(tree); |
| | | } |
| | | |
| | | /** |
| | | * 获取指定角色树形结构 |
| | | */ |
| | | @GetMapping("/tree-by-id") |
| | | @ApiOperationSupport(order = 4) |
| | | @ApiOperation(value = "树形结构", notes = "树形结构") |
| | | public R<List<RoleVO>> treeById(Long roleId, BladeUser bladeUser) { |
| | | Role role = SysCache.getRole(roleId); |
| | | List<RoleVO> tree = roleService.tree(Func.notNull(role) ? role.getTenantId() : bladeUser.getTenantId()); |
| | | return R.data(tree); |
| | | } |
| | | |
| | | /** |
| | | * 新增或修改 |
| | | */ |
| | | @PostMapping("/submit") |
| | | @ApiOperationSupport(order = 5) |
| | | @ApiOperation(value = "新增或修改", notes = "传入role") |
| | | public R submit(@Valid @RequestBody Role role) { |
| | | CacheUtil.clear(SYS_CACHE); |
| | | CacheUtil.clear(SYS_CACHE, Boolean.FALSE); |
| | | return R.status(roleService.submit(role)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 删除 |
| | | */ |
| | | @PostMapping("/remove") |
| | | @ApiOperationSupport(order = 6) |
| | | @ApiOperation(value = "删除", notes = "传入ids") |
| | | public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
| | | CacheUtil.clear(SYS_CACHE); |
| | | CacheUtil.clear(SYS_CACHE, Boolean.FALSE); |
| | | return R.status(roleService.removeRole(ids)); |
| | | } |
| | | |
| | | /** |
| | | * 设置角色权限 |
| | | */ |
| | | @PostMapping("/grant") |
| | | @ApiOperationSupport(order = 7) |
| | | @ApiOperation(value = "权限设置", notes = "传入roleId集合以及menuId集合") |
| | | public R grant(@RequestBody GrantVO grantVO) { |
| | | CacheUtil.clear(SYS_CACHE); |
| | | CacheUtil.clear(SYS_CACHE, Boolean.FALSE); |
| | | boolean temp = roleService.grant(grantVO.getRoleIds(), grantVO.getMenuIds(), grantVO.getDataScopeIds(), grantVO.getApiScopeIds()); |
| | | return R.status(temp); |
| | | } |
| | | |
| | | /** |
| | | * 下拉数据源 |
| | | */ |
| | | @PreAuth(AuthConstant.PERMIT_ALL) |
| | | @GetMapping("/select") |
| | | @ApiOperationSupport(order = 8) |
| | | @ApiOperation(value = "下拉数据源", notes = "传入id集合") |
| | | public R<List<Role>> select(Long userId, String roleId) { |
| | | if (Func.isNotEmpty(userId)) { |
| | | User user = UserCache.getUser(userId); |
| | | roleId = user.getRoleId(); |
| | | } |
| | | List<Role> list = roleService.list(Wrappers.<Role>lambdaQuery().in(Role::getId, Func.toLongList(roleId))); |
| | | return R.data(list); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.excel; |
| | | |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springblade.core.excel.support.ExcelImporter; |
| | | import cn.gistack.system.service.IRegionService; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 行政区划数据导入类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @RequiredArgsConstructor |
| | | public class RegionImporter implements ExcelImporter<RegionExcel> { |
| | | |
| | | private final IRegionService service; |
| | | private final Boolean isCovered; |
| | | |
| | | @Override |
| | | public void save(List<RegionExcel> data) { |
| | | service.importRegion(data, isCovered); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.mapper; |
| | | |
| | | import cn.gistack.system.entity.ApiScope; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | |
| | | /** |
| | | * Mapper 接口 |
| | | * |
| | | * @author BladeX |
| | | */ |
| | | public interface ApiScopeMapper extends BaseMapper<ApiScope> { |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.mapper; |
| | | |
| | | import cn.gistack.system.entity.AuthClient; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | |
| | | /** |
| | | * Mapper 接口 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface AuthClientMapper extends BaseMapper<AuthClient> { |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="cn.gistack.system.mapper.AuthClientMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="clientResultMap" type="cn.gistack.system.entity.AuthClient"> |
| | | <result column="id" property="id"/> |
| | | <result column="create_user" property="createUser"/> |
| | | <result column="create_time" property="createTime"/> |
| | | <result column="update_user" property="updateUser"/> |
| | | <result column="update_time" property="updateTime"/> |
| | | <result column="status" property="status"/> |
| | | <result column="is_deleted" property="isDeleted"/> |
| | | <result column="client_id" property="clientId"/> |
| | | <result column="client_secret" property="clientSecret"/> |
| | | <result column="resources_ids" property="resourceIds"/> |
| | | <result column="scope" property="scope"/> |
| | | <result column="authorized_grant_types" property="authorizedGrantTypes"/> |
| | | <result column="web_server_redirect_uri" property="webServerRedirectUri"/> |
| | | <result column="authorities" property="authorities"/> |
| | | <result column="access_token_validity" property="accessTokenValidity"/> |
| | | <result column="refresh_token_validity" property="refreshTokenValidity"/> |
| | | <result column="additional_information" property="additionalInformation"/> |
| | | <result column="autoapprove" property="autoapprove"/> |
| | | </resultMap> |
| | | |
| | | </mapper> |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.mapper; |
| | | |
| | | import cn.gistack.system.entity.DataScope; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | |
| | | /** |
| | | * Mapper 接口 |
| | | * |
| | | * @author BladeX |
| | | */ |
| | | public interface DataScopeMapper extends BaseMapper<DataScope> { |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.mapper; |
| | | |
| | | import cn.gistack.system.entity.Dept; |
| | | import cn.gistack.system.vo.DeptVO; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * DeptMapper 接口 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface DeptMapper extends BaseMapper<Dept> { |
| | | |
| | | /** |
| | | * 懒加载部门列表 |
| | | * |
| | | * @param tenantId |
| | | * @param parentId |
| | | * @param param |
| | | * @return |
| | | */ |
| | | List<DeptVO> lazyList(String tenantId, Long parentId, Map<String, Object> param); |
| | | |
| | | /** |
| | | * 获取树形节点 |
| | | * |
| | | * @param tenantId |
| | | * @return |
| | | */ |
| | | List<DeptVO> tree(String tenantId); |
| | | |
| | | /** |
| | | * 懒加载获取树形节点 |
| | | * |
| | | * @param tenantId |
| | | * @param parentId |
| | | * @return |
| | | */ |
| | | List<DeptVO> lazyTree(String tenantId, Long parentId); |
| | | |
| | | /** |
| | | * 获取部门名 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | List<String> getDeptNames(Long[] ids); |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="cn.gistack.system.mapper.DeptMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="deptResultMap" type="cn.gistack.system.entity.Dept"> |
| | | <id column="id" property="id"/> |
| | | <result column="parent_id" property="parentId"/> |
| | | <result column="dept_name" property="deptName"/> |
| | | <result column="full_name" property="fullName"/> |
| | | <result column="ancestors" property="ancestors"/> |
| | | <result column="dept_category" property="deptCategory"/> |
| | | <result column="sort" property="sort"/> |
| | | <result column="remark" property="remark"/> |
| | | <result column="is_deleted" property="isDeleted"/> |
| | | </resultMap> |
| | | |
| | | <resultMap id="deptVOResultMap" type="cn.gistack.system.vo.DeptVO"> |
| | | <id column="id" property="id"/> |
| | | <result column="parent_id" property="parentId"/> |
| | | <result column="dept_name" property="deptName"/> |
| | | <result column="full_name" property="fullName"/> |
| | | <result column="ancestors" property="ancestors"/> |
| | | <result column="dept_category" property="deptCategory"/> |
| | | <result column="sort" property="sort"/> |
| | | <result column="remark" property="remark"/> |
| | | <result column="is_deleted" property="isDeleted"/> |
| | | <result column="has_children" property="hasChildren"/> |
| | | </resultMap> |
| | | |
| | | <resultMap id="treeNodeResultMap" type="org.springblade.core.tool.node.TreeNode"> |
| | | <id column="id" property="id"/> |
| | | <result column="parent_id" property="parentId"/> |
| | | <result column="title" property="title"/> |
| | | <result column="value" property="value"/> |
| | | <result column="key" property="key"/> |
| | | <result column="has_children" property="hasChildren"/> |
| | | </resultMap> |
| | | |
| | | <select id="lazyList" resultMap="deptVOResultMap"> |
| | | SELECT |
| | | dept.* , |
| | | ( |
| | | SELECT |
| | | CASE WHEN count(1) > 0 THEN 1 ELSE 0 END |
| | | FROM |
| | | blade_dept |
| | | WHERE |
| | | parent_id = dept.id and is_deleted = 0 |
| | | ) AS "has_children" |
| | | FROM |
| | | blade_dept dept |
| | | WHERE dept.is_deleted = 0 |
| | | <if test="param1!=null and param1!=''"> |
| | | and dept.tenant_id = #{param1} |
| | | </if> |
| | | <if test="param2!=null"> |
| | | and dept.parent_id = #{param2} |
| | | </if> |
| | | <if test="param3.deptName!=null and param3.deptName!=''"> |
| | | and dept.dept_name like concat(concat('%', #{param3.deptName}),'%') |
| | | </if> |
| | | <if test="param3.fullName!=null and param3.fullName!=''"> |
| | | and dept.full_name like concat(concat('%', #{param3.fullName}),'%') |
| | | </if> |
| | | ORDER BY dept.sort |
| | | </select> |
| | | |
| | | <select id="tree" resultMap="treeNodeResultMap"> |
| | | select id, parent_id, dept_name as title, id as "value", id as "key" from blade_dept where is_deleted = 0 |
| | | <if test="_parameter!=null and _parameter!=''"> |
| | | and tenant_id = #{_parameter} |
| | | </if> |
| | | ORDER BY sort |
| | | </select> |
| | | |
| | | <select id="lazyTree" resultMap="treeNodeResultMap" > |
| | | SELECT |
| | | dept.id, |
| | | dept.parent_id, |
| | | dept.dept_name AS title, |
| | | dept.id AS "value", |
| | | dept.id AS "key", |
| | | ( |
| | | SELECT |
| | | CASE WHEN count(1) > 0 THEN 1 ELSE 0 END |
| | | FROM |
| | | blade_dept |
| | | WHERE |
| | | parent_id = dept.id and is_deleted = 0 |
| | | ) AS "has_children" |
| | | FROM |
| | | blade_dept dept |
| | | WHERE |
| | | dept.parent_id = #{param2} AND dept.is_deleted = 0 |
| | | <if test="param1!=null and param1!=''"> |
| | | and dept.tenant_id = #{param1} |
| | | </if> |
| | | ORDER BY dept.sort |
| | | </select> |
| | | |
| | | <select id="getDeptNames" resultType="java.lang.String"> |
| | | SELECT |
| | | dept_name |
| | | FROM |
| | | blade_dept |
| | | WHERE |
| | | id IN |
| | | <foreach collection="array" item="ids" index="index" open="(" close=")" separator=","> |
| | | #{ids} |
| | | </foreach> |
| | | and is_deleted = 0 |
| | | </select> |
| | | |
| | | </mapper> |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.mapper; |
| | | |
| | | import cn.gistack.system.entity.Dict; |
| | | import cn.gistack.system.vo.DictVO; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Mapper 接口 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface DictMapper extends BaseMapper<Dict> { |
| | | |
| | | /** |
| | | * 自定义分页 |
| | | * |
| | | * @param page |
| | | * @param dict |
| | | * @return |
| | | */ |
| | | List<DictVO> selectDictPage(IPage page, DictVO dict); |
| | | |
| | | /** |
| | | * 获取字典表对应中文 |
| | | * |
| | | * @param code 字典编号 |
| | | * @param dictKey 字典序号 |
| | | * @return |
| | | */ |
| | | String getValue(String code, String dictKey); |
| | | |
| | | /** |
| | | * 获取字典表 |
| | | * |
| | | * @param code 字典编号 |
| | | * @return |
| | | */ |
| | | List<Dict> getList(String code); |
| | | |
| | | /** |
| | | * 获取树形节点 |
| | | * |
| | | * @return |
| | | */ |
| | | List<DictVO> tree(); |
| | | |
| | | /** |
| | | * 获取树形节点 |
| | | * |
| | | * @return |
| | | */ |
| | | List<DictVO> parentTree(); |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.mapper; |
| | | |
| | | import cn.gistack.system.dto.MenuDTO; |
| | | import cn.gistack.system.entity.Menu; |
| | | import cn.gistack.system.vo.MenuVO; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.springblade.core.tool.node.TreeNode; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | |
| | | /** |
| | | * MenuMapper 接口 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface MenuMapper extends BaseMapper<Menu> { |
| | | |
| | | /** |
| | | * 懒加载列表 |
| | | * |
| | | * @param parentId |
| | | * @param param |
| | | * @return |
| | | */ |
| | | List<MenuVO> lazyList(Long parentId, Map<String, Object> param); |
| | | |
| | | /** |
| | | * 懒加载菜单列表 |
| | | * |
| | | * @param parentId |
| | | * @param param |
| | | * @return |
| | | */ |
| | | List<MenuVO> lazyMenuList(Long parentId, Map<String, Object> param); |
| | | |
| | | /** |
| | | * 树形结构 |
| | | * |
| | | * @return |
| | | */ |
| | | List<TreeNode> tree(); |
| | | |
| | | /** |
| | | * 授权树形结构 |
| | | * |
| | | * @return |
| | | */ |
| | | List<TreeNode> grantTree(); |
| | | |
| | | /** |
| | | * 授权树形结构 |
| | | * |
| | | * @param roleId |
| | | * @return |
| | | */ |
| | | List<TreeNode> grantTreeByRole(List<Long> roleId); |
| | | |
| | | /** |
| | | * 顶部菜单树形结构 |
| | | * |
| | | * @return |
| | | */ |
| | | List<TreeNode> grantTopTree(); |
| | | |
| | | /** |
| | | * 顶部菜单树形结构 |
| | | * |
| | | * @param roleId |
| | | * @return |
| | | */ |
| | | List<TreeNode> grantTopTreeByRole(List<Long> roleId); |
| | | |
| | | /** |
| | | * 数据权限授权树形结构 |
| | | * |
| | | * @return |
| | | */ |
| | | List<TreeNode> grantDataScopeTree(); |
| | | |
| | | /** |
| | | * 接口权限授权树形结构 |
| | | * |
| | | * @return |
| | | */ |
| | | List<TreeNode> grantApiScopeTree(); |
| | | |
| | | /** |
| | | * 数据权限授权树形结构 |
| | | * |
| | | * @param roleId |
| | | * @return |
| | | */ |
| | | List<TreeNode> grantDataScopeTreeByRole(List<Long> roleId); |
| | | |
| | | /** |
| | | * 接口权限授权树形结构 |
| | | * |
| | | * @param roleId |
| | | * @return |
| | | */ |
| | | List<TreeNode> grantApiScopeTreeByRole(List<Long> roleId); |
| | | |
| | | /** |
| | | * 所有菜单 |
| | | * |
| | | * @return |
| | | */ |
| | | List<Menu> allMenu(); |
| | | |
| | | /** |
| | | * 权限配置菜单 |
| | | * |
| | | * @param roleId |
| | | * @param topMenuId |
| | | * @return |
| | | */ |
| | | List<Menu> roleMenu(List<Long> roleId, Long topMenuId); |
| | | |
| | | /** |
| | | * 权限配置菜单 |
| | | * |
| | | * @param roleId |
| | | * @return |
| | | */ |
| | | List<Menu> roleMenuByRoleId(List<Long> roleId); |
| | | |
| | | /** |
| | | * 权限配置菜单 |
| | | * |
| | | * @param topMenuId |
| | | * @return |
| | | */ |
| | | List<Menu> roleMenuByTopMenuId(Long topMenuId); |
| | | |
| | | /** |
| | | * 菜单树形结构 |
| | | * |
| | | * @param roleId |
| | | * @return |
| | | */ |
| | | List<Menu> routes(List<Long> roleId); |
| | | |
| | | /** |
| | | * 按钮树形结构 |
| | | * |
| | | * @return |
| | | */ |
| | | List<Menu> allButtons(); |
| | | |
| | | /** |
| | | * 按钮树形结构 |
| | | * |
| | | * @param roleId |
| | | * @return |
| | | */ |
| | | List<Menu> buttons(List<Long> roleId); |
| | | |
| | | /** |
| | | * 获取配置的角色权限 |
| | | * |
| | | * @param roleIds |
| | | * @return |
| | | */ |
| | | List<MenuDTO> authRoutes(List<Long> roleIds); |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.mapper; |
| | | |
| | | import cn.gistack.system.entity.Post; |
| | | import cn.gistack.system.vo.PostVO; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 岗位表 Mapper 接口 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface PostMapper extends BaseMapper<Post> { |
| | | |
| | | /** |
| | | * 自定义分页 |
| | | * |
| | | * @param page |
| | | * @param post |
| | | * @return |
| | | */ |
| | | List<PostVO> selectPostPage(IPage page, PostVO post); |
| | | |
| | | /** |
| | | * 获取岗位名 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | List<String> getPostNames(Long[] ids); |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.mapper; |
| | | |
| | | import cn.gistack.system.entity.Region; |
| | | import cn.gistack.system.excel.RegionExcel; |
| | | import cn.gistack.system.vo.RegionVO; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 行政区划表 Mapper 接口 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface RegionMapper extends BaseMapper<Region> { |
| | | |
| | | /** |
| | | * 懒加载列表 |
| | | * |
| | | * @param parentCode |
| | | * @param param |
| | | * @return |
| | | */ |
| | | List<RegionVO> lazyList(String parentCode, Map<String, Object> param); |
| | | |
| | | /** |
| | | * 懒加载列表 |
| | | * |
| | | * @param parentCode |
| | | * @param param |
| | | * @return |
| | | */ |
| | | List<RegionVO> lazyTree(String parentCode, Map<String, Object> param); |
| | | |
| | | /** |
| | | * 导出区划数据 |
| | | * |
| | | * @param queryWrapper |
| | | * @return |
| | | */ |
| | | List<RegionExcel> exportRegion(@Param("ew") Wrapper<Region> queryWrapper); |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.mapper; |
| | | |
| | | import cn.gistack.system.entity.Role; |
| | | import cn.gistack.system.vo.RoleVO; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Mapper 接口 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface RoleMapper extends BaseMapper<Role> { |
| | | |
| | | /** |
| | | * 自定义分页 |
| | | * |
| | | * @param page |
| | | * @param role |
| | | * @return |
| | | */ |
| | | List<RoleVO> selectRolePage(IPage page, RoleVO role); |
| | | |
| | | /** |
| | | * 获取树形节点 |
| | | * |
| | | * @param tenantId |
| | | * @param excludeRole |
| | | * @return |
| | | */ |
| | | List<RoleVO> tree(String tenantId, String excludeRole); |
| | | |
| | | /** |
| | | * 获取角色名 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | List<String> getRoleNames(Long[] ids); |
| | | |
| | | /** |
| | | * 获取角色名 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | List<String> getRoleAliases(Long[] ids); |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="cn.gistack.system.mapper.RoleMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="roleResultMap" type="cn.gistack.system.entity.Role"> |
| | | <id column="id" property="id"/> |
| | | <result column="parent_id" property="parentId"/> |
| | | <result column="role_name" property="roleName"/> |
| | | <result column="sort" property="sort"/> |
| | | <result column="role_alias" property="roleAlias"/> |
| | | <result column="is_deleted" property="isDeleted"/> |
| | | </resultMap> |
| | | |
| | | <resultMap id="treeNodeResultMap" type="org.springblade.core.tool.node.TreeNode"> |
| | | <id column="id" property="id"/> |
| | | <result column="parent_id" property="parentId"/> |
| | | <result column="title" property="title"/> |
| | | <result column="value" property="value"/> |
| | | <result column="key" property="key"/> |
| | | </resultMap> |
| | | |
| | | <select id="selectRolePage" resultMap="roleResultMap"> |
| | | select * from blade_role where is_deleted = 0 |
| | | </select> |
| | | |
| | | <select id="tree" resultMap="treeNodeResultMap"> |
| | | select id, parent_id, role_name as title, id as "value", id as "key" from blade_role where is_deleted = 0 |
| | | <if test="param1!=null"> |
| | | and tenant_id = #{param1} |
| | | </if> |
| | | <if test="param2!=null"> |
| | | and role_alias <> #{param2} |
| | | </if> |
| | | </select> |
| | | |
| | | <select id="getRoleNames" resultType="java.lang.String"> |
| | | SELECT |
| | | role_name |
| | | FROM |
| | | blade_role |
| | | WHERE |
| | | id IN |
| | | <foreach collection="array" item="ids" index="index" open="(" close=")" separator=","> |
| | | #{ids} |
| | | </foreach> |
| | | and is_deleted = 0 |
| | | </select> |
| | | |
| | | <select id="getRoleAliases" resultType="java.lang.String"> |
| | | SELECT |
| | | role_alias |
| | | FROM |
| | | blade_role |
| | | WHERE |
| | | id IN |
| | | <foreach collection="array" item="ids" index="index" open="(" close=")" separator=","> |
| | | #{ids} |
| | | </foreach> |
| | | and is_deleted = 0 |
| | | </select> |
| | | |
| | | </mapper> |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="cn.gistack.system.mapper.RoleMenuMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="roleMenuResultMap" type="cn.gistack.system.entity.RoleMenu"> |
| | | <id column="id" property="id"/> |
| | | <result column="menu_id" property="menuId"/> |
| | | <result column="role_id" property="roleId"/> |
| | | </resultMap> |
| | | |
| | | <select id="selectRoleMenuPage" resultMap="roleMenuResultMap"> |
| | | select * from blade_role_menu where is_deleted = 0 |
| | | </select> |
| | | |
| | | </mapper> |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.mapper; |
| | | |
| | | import cn.gistack.system.entity.RoleScope; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | |
| | | /** |
| | | * Mapper 接口 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface RoleScopeMapper extends BaseMapper<RoleScope> { |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="cn.gistack.system.mapper.RoleScopeMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="roleMenuResultMap" type="cn.gistack.system.entity.RoleScope"> |
| | | <id column="id" property="id"/> |
| | | <result column="scope_id" property="scopeId"/> |
| | | <result column="role_id" property="roleId"/> |
| | | </resultMap> |
| | | |
| | | </mapper> |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="cn.gistack.system.mapper.TenantMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="tenantResultMap" type="cn.gistack.system.entity.Tenant"> |
| | | <result column="id" property="id"/> |
| | | <result column="create_user" property="createUser"/> |
| | | <result column="create_time" property="createTime"/> |
| | | <result column="update_user" property="updateUser"/> |
| | | <result column="update_time" property="updateTime"/> |
| | | <result column="status" property="status"/> |
| | | <result column="is_deleted" property="isDeleted"/> |
| | | <result column="tenant_id" property="tenantId"/> |
| | | <result column="tenant_name" property="tenantName"/> |
| | | <result column="domain_url" property="domainUrl"/> |
| | | <result column="background_url" property="backgroundUrl"/> |
| | | <result column="linkman" property="linkman"/> |
| | | <result column="contact_number" property="contactNumber"/> |
| | | <result column="address" property="address"/> |
| | | <result column="account_number" property="accountNumber"/> |
| | | <result column="expire_time" property="expireTime"/> |
| | | <result column="license_key" property="licenseKey"/> |
| | | </resultMap> |
| | | |
| | | |
| | | <select id="selectTenantPage" resultMap="tenantResultMap"> |
| | | select * from blade_tenant where is_deleted = 0 |
| | | </select> |
| | | |
| | | </mapper> |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.mapper; |
| | | |
| | | import cn.gistack.system.entity.TenantPackage; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | |
| | | /** |
| | | * 租户产品表 Mapper 接口 |
| | | * |
| | | * @author BladeX |
| | | */ |
| | | public interface TenantPackageMapper extends BaseMapper<TenantPackage> { |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="cn.gistack.system.mapper.TenantPackageMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="tenantPackageResultMap" type="cn.gistack.system.entity.TenantPackage"> |
| | | <result column="id" property="id"/> |
| | | <result column="create_user" property="createUser"/> |
| | | <result column="create_dept" property="createDept"/> |
| | | <result column="create_time" property="createTime"/> |
| | | <result column="update_user" property="updateUser"/> |
| | | <result column="update_time" property="updateTime"/> |
| | | <result column="status" property="status"/> |
| | | <result column="is_deleted" property="isDeleted"/> |
| | | <result column="package_name" property="packageName"/> |
| | | <result column="menu_id" property="menuId"/> |
| | | <result column="remark" property="remark"/> |
| | | </resultMap> |
| | | |
| | | </mapper> |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="cn.gistack.system.mapper.TopMenuMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="topMenuResultMap" type="cn.gistack.system.entity.TopMenu"> |
| | | <result column="id" property="id"/> |
| | | <result column="create_user" property="createUser"/> |
| | | <result column="create_dept" property="createDept"/> |
| | | <result column="create_time" property="createTime"/> |
| | | <result column="update_user" property="updateUser"/> |
| | | <result column="update_time" property="updateTime"/> |
| | | <result column="status" property="status"/> |
| | | <result column="is_deleted" property="isDeleted"/> |
| | | <result column="code" property="code"/> |
| | | <result column="name" property="name"/> |
| | | <result column="source" property="source"/> |
| | | <result column="sort" property="sort"/> |
| | | </resultMap> |
| | | |
| | | </mapper> |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.mapper; |
| | | |
| | | import cn.gistack.system.entity.TopMenuSetting; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | |
| | | /** |
| | | * Mapper 接口 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface TopMenuSettingMapper extends BaseMapper<TopMenuSetting> { |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="cn.gistack.system.mapper.TopMenuSettingMapper"> |
| | | |
| | | </mapper> |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.service; |
| | | |
| | | import cn.gistack.system.entity.AuthClient; |
| | | import org.springblade.core.mp.base.BaseService; |
| | | |
| | | /** |
| | | * 服务类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface IAuthClientService extends BaseService<AuthClient> { |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.service; |
| | | |
| | | |
| | | import cn.gistack.system.entity.DictBiz; |
| | | import cn.gistack.system.vo.DictBizVO; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.springblade.core.mp.support.Query; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 服务类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface IDictBizService extends IService<DictBiz> { |
| | | |
| | | /** |
| | | * 树形结构 |
| | | * |
| | | * @return |
| | | */ |
| | | List<DictBizVO> tree(); |
| | | |
| | | /** |
| | | * 树形结构 |
| | | * |
| | | * @return |
| | | */ |
| | | List<DictBizVO> parentTree(); |
| | | |
| | | /** |
| | | * 获取字典表对应中文 |
| | | * |
| | | * @param code 字典编号 |
| | | * @param dictKey 字典序号 |
| | | * @return |
| | | */ |
| | | String getValue(String code, String dictKey); |
| | | |
| | | /** |
| | | * 获取字典表 |
| | | * |
| | | * @param code 字典编号 |
| | | * @return |
| | | */ |
| | | List<DictBiz> getList(String code); |
| | | |
| | | /** |
| | | * 新增或修改 |
| | | * |
| | | * @param dict |
| | | * @return |
| | | */ |
| | | boolean submit(DictBiz dict); |
| | | |
| | | /** |
| | | * 删除字典 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | boolean removeDict(String ids); |
| | | |
| | | /** |
| | | * 顶级列表 |
| | | * |
| | | * @param dict |
| | | * @param query |
| | | * @return |
| | | */ |
| | | IPage<DictBizVO> parentList(Map<String, Object> dict, Query query); |
| | | |
| | | /** |
| | | * 子列表 |
| | | * |
| | | * @param dict |
| | | * @param parentId |
| | | * @return |
| | | */ |
| | | List<DictBizVO> childList(Map<String, Object> dict, Long parentId); |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.service; |
| | | |
| | | import cn.gistack.system.entity.Dict; |
| | | import cn.gistack.system.vo.DictVO; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.springblade.core.mp.support.Query; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 服务类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface IDictService extends IService<Dict> { |
| | | |
| | | /** |
| | | * 自定义分页 |
| | | * |
| | | * @param page |
| | | * @param dict |
| | | * @return |
| | | */ |
| | | IPage<DictVO> selectDictPage(IPage<DictVO> page, DictVO dict); |
| | | |
| | | /** |
| | | * 树形结构 |
| | | * |
| | | * @return |
| | | */ |
| | | List<DictVO> tree(); |
| | | |
| | | /** |
| | | * 树形结构 |
| | | * |
| | | * @return |
| | | */ |
| | | List<DictVO> parentTree(); |
| | | |
| | | /** |
| | | * 获取字典表对应中文 |
| | | * |
| | | * @param code 字典编号 |
| | | * @param dictKey 字典序号 |
| | | * @return |
| | | */ |
| | | String getValue(String code, String dictKey); |
| | | |
| | | /** |
| | | * 获取字典表 |
| | | * |
| | | * @param code 字典编号 |
| | | * @return |
| | | */ |
| | | List<Dict> getList(String code); |
| | | |
| | | /** |
| | | * 新增或修改 |
| | | * |
| | | * @param dict |
| | | * @return |
| | | */ |
| | | boolean submit(Dict dict); |
| | | |
| | | /** |
| | | * 删除字典 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | boolean removeDict(String ids); |
| | | |
| | | /** |
| | | * 顶级列表 |
| | | * |
| | | * @param dict |
| | | * @param query |
| | | * @return |
| | | */ |
| | | IPage<DictVO> parentList(Map<String, Object> dict, Query query); |
| | | |
| | | /** |
| | | * 子列表 |
| | | * |
| | | * @param dict |
| | | * @param parentId |
| | | * @return |
| | | */ |
| | | List<DictVO> childList(Map<String, Object> dict, Long parentId); |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.service; |
| | | |
| | | import cn.gistack.system.entity.Menu; |
| | | import cn.gistack.system.vo.MenuVO; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.springblade.core.secure.BladeUser; |
| | | import org.springblade.core.tool.node.TreeNode; |
| | | import org.springblade.core.tool.support.Kv; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 服务类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface IMenuService extends IService<Menu> { |
| | | |
| | | /** |
| | | * 懒加载列表 |
| | | * |
| | | * @param parentId |
| | | * @param param |
| | | * @return |
| | | */ |
| | | List<MenuVO> lazyList(Long parentId, Map<String, Object> param); |
| | | |
| | | /** |
| | | * 懒加载菜单列表 |
| | | * |
| | | * @param parentId |
| | | * @param param |
| | | * @return |
| | | */ |
| | | List<MenuVO> lazyMenuList(Long parentId, Map<String, Object> param); |
| | | |
| | | /** |
| | | * 菜单树形结构 |
| | | * |
| | | * @param roleId |
| | | * @param topMenuId |
| | | * @return |
| | | */ |
| | | List<MenuVO> routes(String roleId, Long topMenuId); |
| | | |
| | | /** |
| | | * 按钮树形结构 |
| | | * |
| | | * @param roleId |
| | | * @return |
| | | */ |
| | | List<MenuVO> buttons(String roleId); |
| | | |
| | | /** |
| | | * 树形结构 |
| | | * |
| | | * @return |
| | | */ |
| | | List<TreeNode> tree(); |
| | | |
| | | /** |
| | | * 授权树形结构 |
| | | * |
| | | * @param user |
| | | * @return |
| | | */ |
| | | List<TreeNode> grantTree(BladeUser user); |
| | | |
| | | /** |
| | | * 顶部菜单树形结构 |
| | | * |
| | | * @param user |
| | | * @return |
| | | */ |
| | | List<TreeNode> grantTopTree(BladeUser user); |
| | | |
| | | /** |
| | | * 数据权限授权树形结构 |
| | | * |
| | | * @param user |
| | | * @return |
| | | */ |
| | | List<TreeNode> grantDataScopeTree(BladeUser user); |
| | | |
| | | /** |
| | | * 接口权限授权树形结构 |
| | | * |
| | | * @param user |
| | | * @return |
| | | */ |
| | | List<TreeNode> grantApiScopeTree(BladeUser user); |
| | | |
| | | /** |
| | | * 默认选中节点 |
| | | * |
| | | * @param roleIds |
| | | * @return |
| | | */ |
| | | List<String> roleTreeKeys(String roleIds); |
| | | |
| | | /** |
| | | * 默认选中节点 |
| | | * |
| | | * @param topMenuIds |
| | | * @return |
| | | */ |
| | | List<String> topTreeKeys(String topMenuIds); |
| | | |
| | | /** |
| | | * 默认选中节点 |
| | | * |
| | | * @param roleIds |
| | | * @return |
| | | */ |
| | | List<String> dataScopeTreeKeys(String roleIds); |
| | | |
| | | /** |
| | | * 默认选中节点 |
| | | * |
| | | * @param roleIds |
| | | * @return |
| | | */ |
| | | List<String> apiScopeTreeKeys(String roleIds); |
| | | |
| | | /** |
| | | * 获取配置的角色权限 |
| | | * |
| | | * @param user |
| | | * @return |
| | | */ |
| | | List<Kv> authRoutes(BladeUser user); |
| | | |
| | | /** |
| | | * 删除菜单 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | boolean removeMenu(String ids); |
| | | |
| | | /** |
| | | * 提交 |
| | | * |
| | | * @param menu |
| | | * @return |
| | | */ |
| | | boolean submit(Menu menu); |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.service; |
| | | |
| | | import cn.gistack.system.entity.Post; |
| | | import cn.gistack.system.vo.PostVO; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.springblade.core.mp.base.BaseService; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 岗位表 服务类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface IPostService extends BaseService<Post> { |
| | | |
| | | /** |
| | | * 自定义分页 |
| | | * |
| | | * @param page |
| | | * @param post |
| | | * @return |
| | | */ |
| | | IPage<PostVO> selectPostPage(IPage<PostVO> page, PostVO post); |
| | | |
| | | /** |
| | | * 获取岗位ID |
| | | * |
| | | * @param tenantId |
| | | * @param postNames |
| | | * @return |
| | | */ |
| | | String getPostIds(String tenantId, String postNames); |
| | | |
| | | /** |
| | | * 获取岗位ID |
| | | * |
| | | * @param tenantId |
| | | * @param postNames |
| | | * @return |
| | | */ |
| | | String getPostIdsByFuzzy(String tenantId, String postNames); |
| | | |
| | | /** |
| | | * 获取岗位名 |
| | | * |
| | | * @param postIds |
| | | * @return |
| | | */ |
| | | List<String> getPostNames(String postIds); |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.service; |
| | | |
| | | import cn.gistack.system.entity.Region; |
| | | import cn.gistack.system.excel.RegionExcel; |
| | | import cn.gistack.system.vo.RegionVO; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 行政区划表 服务类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface IRegionService extends IService<Region> { |
| | | |
| | | /** |
| | | * 提交 |
| | | * |
| | | * @param region |
| | | * @return |
| | | */ |
| | | boolean submit(Region region); |
| | | |
| | | /** |
| | | * 删除 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | boolean removeRegion(String id); |
| | | |
| | | /** |
| | | * 懒加载列表 |
| | | * |
| | | * @param parentCode |
| | | * @param param |
| | | * @return |
| | | */ |
| | | List<RegionVO> lazyList(String parentCode, Map<String, Object> param); |
| | | |
| | | /** |
| | | * 懒加载列表 |
| | | * |
| | | * @param parentCode |
| | | * @param param |
| | | * @return |
| | | */ |
| | | List<RegionVO> lazyTree(String parentCode, Map<String, Object> param); |
| | | |
| | | /** |
| | | * 导入区划数据 |
| | | * |
| | | * @param data |
| | | * @param isCovered |
| | | * @return |
| | | */ |
| | | void importRegion(List<RegionExcel> data, Boolean isCovered); |
| | | |
| | | /** |
| | | * 导出区划数据 |
| | | * |
| | | * @param queryWrapper |
| | | * @return |
| | | */ |
| | | List<RegionExcel> exportRegion(Wrapper<Region> queryWrapper); |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.service; |
| | | |
| | | import cn.gistack.system.entity.RoleMenu; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | /** |
| | | * 服务类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface IRoleMenuService extends IService<RoleMenu> { |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.service; |
| | | |
| | | import cn.gistack.system.entity.Tenant; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.springblade.core.mp.base.BaseService; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 服务类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface ITenantService extends BaseService<Tenant> { |
| | | |
| | | /** |
| | | * 自定义分页 |
| | | * |
| | | * @param page |
| | | * @param tenant |
| | | * @return |
| | | */ |
| | | IPage<Tenant> selectTenantPage(IPage<Tenant> page, Tenant tenant); |
| | | |
| | | /** |
| | | * 根据租户编号获取实体 |
| | | * |
| | | * @param tenantId |
| | | * @return |
| | | */ |
| | | Tenant getByTenantId(String tenantId); |
| | | |
| | | /** |
| | | * 新增 |
| | | * |
| | | * @param tenant |
| | | * @return |
| | | */ |
| | | boolean submitTenant(Tenant tenant); |
| | | |
| | | /** |
| | | * 删除 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | boolean removeTenant(List<Long> ids); |
| | | |
| | | /** |
| | | * 配置租户授权 |
| | | * |
| | | * @param accountNumber |
| | | * @param expireTime |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | boolean setting(Integer accountNumber, Date expireTime, String ids); |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.service; |
| | | |
| | | import cn.gistack.system.entity.TopMenu; |
| | | import org.springblade.core.mp.base.BaseService; |
| | | |
| | | import javax.validation.constraints.NotEmpty; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 顶部菜单表 服务类 |
| | | * |
| | | * @author BladeX |
| | | */ |
| | | public interface ITopMenuService extends BaseService<TopMenu> { |
| | | |
| | | /** |
| | | * 顶部菜单配置 |
| | | * |
| | | * @param topMenuIds 顶部菜单id集合 |
| | | * @param menuIds 菜单id集合 |
| | | * @return 是否成功 |
| | | */ |
| | | boolean grant(@NotEmpty List<Long> topMenuIds, @NotEmpty List<Long> menuIds); |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.service; |
| | | |
| | | import cn.gistack.system.entity.TopMenuSetting; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | /** |
| | | * 服务类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface ITopMenuSettingService extends IService<TopMenuSetting> { |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.service.impl; |
| | | |
| | | import cn.gistack.system.entity.ApiScope; |
| | | import cn.gistack.system.mapper.ApiScopeMapper; |
| | | import cn.gistack.system.service.IApiScopeService; |
| | | import org.springblade.core.mp.base.BaseServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * 服务实现类 |
| | | * |
| | | * @author BladeX |
| | | */ |
| | | @Service |
| | | public class ApiScopeServiceImpl extends BaseServiceImpl<ApiScopeMapper, ApiScope> implements IApiScopeService { |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.service.impl; |
| | | |
| | | import cn.gistack.system.entity.AuthClient; |
| | | import cn.gistack.system.mapper.AuthClientMapper; |
| | | import cn.gistack.system.service.IAuthClientService; |
| | | import org.springblade.core.mp.base.BaseServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * 服务实现类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Service |
| | | public class AuthClientServiceImpl extends BaseServiceImpl<AuthClientMapper, AuthClient> implements IAuthClientService { |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.service.impl; |
| | | |
| | | import cn.gistack.system.entity.DataScope; |
| | | import cn.gistack.system.mapper.DataScopeMapper; |
| | | import cn.gistack.system.service.IDataScopeService; |
| | | import org.springblade.core.mp.base.BaseServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * 服务实现类 |
| | | * |
| | | * @author BladeX |
| | | */ |
| | | @Service |
| | | public class DataScopeServiceImpl extends BaseServiceImpl<DataScopeMapper, DataScope> implements IDataScopeService { |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.service.impl; |
| | | |
| | | import cn.gistack.system.cache.DictCache; |
| | | import cn.gistack.system.entity.Dict; |
| | | import cn.gistack.system.mapper.DictMapper; |
| | | import cn.gistack.system.service.IDictService; |
| | | import cn.gistack.system.vo.DictVO; |
| | | import cn.gistack.system.wrapper.DictWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import cn.gistack.common.constant.CommonConstant; |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.tool.constant.BladeConstant; |
| | | import org.springblade.core.tool.node.ForestNodeMerger; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.core.tool.utils.StringPool; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import static org.springblade.core.cache.constant.CacheConstant.DICT_CACHE; |
| | | |
| | | |
| | | /** |
| | | * 服务实现类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Service |
| | | public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements IDictService { |
| | | |
| | | @Override |
| | | public IPage<DictVO> selectDictPage(IPage<DictVO> page, DictVO dict) { |
| | | return page.setRecords(baseMapper.selectDictPage(page, dict)); |
| | | } |
| | | |
| | | @Override |
| | | public List<DictVO> tree() { |
| | | return ForestNodeMerger.merge(baseMapper.tree()); |
| | | } |
| | | |
| | | @Override |
| | | public List<DictVO> parentTree() { |
| | | return ForestNodeMerger.merge(baseMapper.parentTree()); |
| | | } |
| | | |
| | | @Override |
| | | public String getValue(String code, String dictKey) { |
| | | return Func.toStr(baseMapper.getValue(code, dictKey), StringPool.EMPTY); |
| | | } |
| | | |
| | | @Override |
| | | public List<Dict> getList(String code) { |
| | | return baseMapper.getList(code); |
| | | } |
| | | |
| | | @Override |
| | | public boolean submit(Dict dict) { |
| | | LambdaQueryWrapper<Dict> lqw = Wrappers.<Dict>query().lambda().eq(Dict::getCode, dict.getCode()).eq(Dict::getDictKey, dict.getDictKey()); |
| | | Long cnt = baseMapper.selectCount((Func.isEmpty(dict.getId())) ? lqw : lqw.notIn(Dict::getId, dict.getId())); |
| | | if (cnt > 0L) { |
| | | throw new ServiceException("当前字典键值已存在!"); |
| | | } |
| | | // 修改顶级字典后同步更新下属字典的编号 |
| | | if (Func.isNotEmpty(dict.getId()) && dict.getParentId().longValue() == BladeConstant.TOP_PARENT_ID) { |
| | | Dict parent = DictCache.getById(dict.getId()); |
| | | this.update(Wrappers.<Dict>update().lambda().set(Dict::getCode, dict.getCode()).eq(Dict::getCode, parent.getCode()).ne(Dict::getParentId, BladeConstant.TOP_PARENT_ID)); |
| | | } |
| | | if (Func.isEmpty(dict.getParentId())) { |
| | | dict.setParentId(BladeConstant.TOP_PARENT_ID); |
| | | } |
| | | dict.setIsDeleted(BladeConstant.DB_NOT_DELETED); |
| | | CacheUtil.clear(DICT_CACHE, Boolean.FALSE); |
| | | return saveOrUpdate(dict); |
| | | } |
| | | |
| | | @Override |
| | | public boolean removeDict(String ids) { |
| | | Long cnt = baseMapper.selectCount(Wrappers.<Dict>query().lambda().in(Dict::getParentId, Func.toLongList(ids))); |
| | | if (cnt > 0L) { |
| | | throw new ServiceException("请先删除子节点!"); |
| | | } |
| | | return removeByIds(Func.toLongList(ids)); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<DictVO> parentList(Map<String, Object> dict, Query query) { |
| | | IPage<Dict> page = this.page(Condition.getPage(query), Condition.getQueryWrapper(dict, Dict.class).lambda().eq(Dict::getParentId, CommonConstant.TOP_PARENT_ID).orderByAsc(Dict::getSort)); |
| | | return DictWrapper.build().pageVO(page); |
| | | } |
| | | |
| | | @Override |
| | | public List<DictVO> childList(Map<String, Object> dict, Long parentId) { |
| | | if (parentId < 0) { |
| | | return new ArrayList<>(); |
| | | } |
| | | dict.remove("parentId"); |
| | | Dict parentDict = DictCache.getById(parentId); |
| | | List<Dict> list = this.list(Condition.getQueryWrapper(dict, Dict.class).lambda().ne(Dict::getId, parentId).eq(Dict::getCode, parentDict.getCode()).orderByAsc(Dict::getSort)); |
| | | return DictWrapper.build().listNodeVO(list); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.service.impl; |
| | | |
| | | import cn.gistack.system.entity.Param; |
| | | import cn.gistack.system.mapper.ParamMapper; |
| | | import cn.gistack.system.service.IParamService; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import org.springblade.core.mp.base.BaseServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * 服务实现类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Service |
| | | public class ParamServiceImpl extends BaseServiceImpl<ParamMapper, Param> implements IParamService { |
| | | |
| | | @Override |
| | | public String getValue(String paramKey) { |
| | | Param param = this.getOne(Wrappers.<Param>query().lambda().eq(Param::getParamKey, paramKey)); |
| | | return param.getParamValue(); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import org.springblade.core.mp.base.BaseServiceImpl; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import cn.gistack.system.entity.Post; |
| | | import cn.gistack.system.mapper.PostMapper; |
| | | import cn.gistack.system.service.IPostService; |
| | | import cn.gistack.system.vo.PostVO; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 岗位表 服务实现类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Service |
| | | public class PostServiceImpl extends BaseServiceImpl<PostMapper, Post> implements IPostService { |
| | | |
| | | @Override |
| | | public IPage<PostVO> selectPostPage(IPage<PostVO> page, PostVO post) { |
| | | return page.setRecords(baseMapper.selectPostPage(page, post)); |
| | | } |
| | | |
| | | @Override |
| | | public String getPostIds(String tenantId, String postNames) { |
| | | List<Post> postList = baseMapper.selectList(Wrappers.<Post>query().lambda().eq(Post::getTenantId, tenantId).in(Post::getPostName, Func.toStrList(postNames))); |
| | | if (postList != null && postList.size() > 0) { |
| | | return postList.stream().map(post -> Func.toStr(post.getId())).distinct().collect(Collectors.joining(",")); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public String getPostIdsByFuzzy(String tenantId, String postNames) { |
| | | LambdaQueryWrapper<Post> queryWrapper = Wrappers.<Post>query().lambda().eq(Post::getTenantId, tenantId); |
| | | queryWrapper.and(wrapper -> { |
| | | List<String> names = Func.toStrList(postNames); |
| | | names.forEach(name -> wrapper.like(Post::getPostName, name).or()); |
| | | }); |
| | | List<Post> postList = baseMapper.selectList(queryWrapper); |
| | | if (postList != null && postList.size() > 0) { |
| | | return postList.stream().map(post -> Func.toStr(post.getId())).distinct().collect(Collectors.joining(",")); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public List<String> getPostNames(String postIds) { |
| | | return baseMapper.getPostNames(Func.toLongArray(postIds)); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.service.impl; |
| | | |
| | | import cn.gistack.system.entity.RoleMenu; |
| | | import cn.gistack.system.mapper.RoleMenuMapper; |
| | | import cn.gistack.system.service.IRoleMenuService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * 服务实现类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Service |
| | | public class RoleMenuServiceImpl extends ServiceImpl<RoleMenuMapper, RoleMenu> implements IRoleMenuService { |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import cn.gistack.system.entity.RoleScope; |
| | | import cn.gistack.system.mapper.RoleScopeMapper; |
| | | import cn.gistack.system.service.IRoleScopeService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * 服务实现类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Service |
| | | public class RoleScopeServiceImpl extends ServiceImpl<RoleScopeMapper, RoleScope> implements IRoleScopeService { |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.service.impl; |
| | | |
| | | import cn.gistack.system.entity.Role; |
| | | import cn.gistack.system.entity.RoleMenu; |
| | | import cn.gistack.system.entity.RoleScope; |
| | | import cn.gistack.system.mapper.RoleMapper; |
| | | import cn.gistack.system.service.IRoleMenuService; |
| | | import cn.gistack.system.service.IRoleScopeService; |
| | | import cn.gistack.system.service.IRoleService; |
| | | import cn.gistack.system.vo.RoleVO; |
| | | import cn.gistack.system.wrapper.RoleWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.constant.BladeConstant; |
| | | import org.springblade.core.tool.constant.RoleConstant; |
| | | import org.springblade.core.tool.node.ForestNodeMerger; |
| | | import org.springblade.core.tool.utils.CollectionUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.validation.annotation.Validated; |
| | | |
| | | import javax.validation.constraints.NotEmpty; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static cn.gistack.common.constant.CommonConstant.API_SCOPE_CATEGORY; |
| | | import static cn.gistack.common.constant.CommonConstant.DATA_SCOPE_CATEGORY; |
| | | |
| | | /** |
| | | * 服务实现类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Service |
| | | @Validated |
| | | @AllArgsConstructor |
| | | public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IRoleService { |
| | | |
| | | private final IRoleMenuService roleMenuService; |
| | | private final IRoleScopeService roleScopeService; |
| | | |
| | | @Override |
| | | public IPage<RoleVO> selectRolePage(IPage<RoleVO> page, RoleVO role) { |
| | | return page.setRecords(baseMapper.selectRolePage(page, role)); |
| | | } |
| | | |
| | | @Override |
| | | public List<RoleVO> tree(String tenantId) { |
| | | String userRole = AuthUtil.getUserRole(); |
| | | String excludeRole = null; |
| | | if (!CollectionUtil.contains(Func.toStrArray(userRole), RoleConstant.ADMIN) && !CollectionUtil.contains(Func.toStrArray(userRole), RoleConstant.ADMINISTRATOR)) { |
| | | excludeRole = RoleConstant.ADMINISTRATOR; |
| | | } |
| | | return ForestNodeMerger.merge(baseMapper.tree(tenantId, excludeRole)); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean grant(@NotEmpty List<Long> roleIds, List<Long> menuIds, List<Long> dataScopeIds, List<Long> apiScopeIds) { |
| | | return grantRoleMenu(roleIds, menuIds) && grantDataScope(roleIds, dataScopeIds) && grantApiScope(roleIds, apiScopeIds); |
| | | } |
| | | |
| | | private boolean grantRoleMenu(List<Long> roleIds, List<Long> menuIds) { |
| | | // 防止越权配置超管角色 |
| | | Long administratorCount = baseMapper.selectCount(Wrappers.<Role>query().lambda().eq(Role::getRoleAlias, RoleConstant.ADMINISTRATOR).in(Role::getId, roleIds)); |
| | | if (!AuthUtil.isAdministrator() && administratorCount > 0L) { |
| | | throw new ServiceException("无权配置超管角色!"); |
| | | } |
| | | // 防止越权配置管理员角色 |
| | | Long adminCount = baseMapper.selectCount(Wrappers.<Role>query().lambda().eq(Role::getRoleAlias, RoleConstant.ADMIN).in(Role::getId, roleIds)); |
| | | if (!AuthUtil.isAdmin() && adminCount > 0L) { |
| | | throw new ServiceException("无权配置管理员角色!"); |
| | | } |
| | | // 删除角色配置的菜单集合 |
| | | roleMenuService.remove(Wrappers.<RoleMenu>update().lambda().in(RoleMenu::getRoleId, roleIds)); |
| | | // 组装配置 |
| | | List<RoleMenu> roleMenus = new ArrayList<>(); |
| | | roleIds.forEach(roleId -> menuIds.forEach(menuId -> { |
| | | RoleMenu roleMenu = new RoleMenu(); |
| | | roleMenu.setRoleId(roleId); |
| | | roleMenu.setMenuId(menuId); |
| | | roleMenus.add(roleMenu); |
| | | })); |
| | | // 新增配置 |
| | | roleMenuService.saveBatch(roleMenus); |
| | | // 递归设置下属角色菜单集合 |
| | | recursionRoleMenu(roleIds, menuIds); |
| | | return true; |
| | | } |
| | | |
| | | private void recursionRoleMenu(List<Long> roleIds, List<Long> menuIds) { |
| | | roleIds.forEach(roleId -> baseMapper.selectList(Wrappers.<Role>query().lambda().eq(Role::getParentId, roleId)).forEach(role -> { |
| | | List<RoleMenu> roleMenuList = roleMenuService.list(Wrappers.<RoleMenu>query().lambda().eq(RoleMenu::getRoleId, role.getId())); |
| | | // 子节点过滤出父节点删除的菜单集合 |
| | | List<Long> collectRoleMenuIds = roleMenuList.stream().map(RoleMenu::getMenuId).filter(menuId -> !menuIds.contains(menuId)).collect(Collectors.toList()); |
| | | if (collectRoleMenuIds.size() > 0) { |
| | | // 删除子节点权限外的菜单集合 |
| | | roleMenuService.remove(Wrappers.<RoleMenu>update().lambda().eq(RoleMenu::getRoleId, role.getId()).in(RoleMenu::getMenuId, collectRoleMenuIds)); |
| | | // 递归设置下属角色菜单集合 |
| | | recursionRoleMenu(Collections.singletonList(role.getId()), menuIds); |
| | | } |
| | | })); |
| | | } |
| | | |
| | | private boolean grantDataScope(List<Long> roleIds, List<Long> dataScopeIds) { |
| | | // 删除角色配置的数据权限集合 |
| | | roleScopeService.remove(Wrappers.<RoleScope>update().lambda().eq(RoleScope::getScopeCategory, DATA_SCOPE_CATEGORY).in(RoleScope::getRoleId, roleIds)); |
| | | // 组装配置 |
| | | List<RoleScope> roleDataScopes = new ArrayList<>(); |
| | | roleIds.forEach(roleId -> dataScopeIds.forEach(scopeId -> { |
| | | RoleScope roleScope = new RoleScope(); |
| | | roleScope.setScopeCategory(DATA_SCOPE_CATEGORY); |
| | | roleScope.setRoleId(roleId); |
| | | roleScope.setScopeId(scopeId); |
| | | roleDataScopes.add(roleScope); |
| | | })); |
| | | // 新增配置 |
| | | roleScopeService.saveBatch(roleDataScopes); |
| | | return true; |
| | | } |
| | | |
| | | private boolean grantApiScope(List<Long> roleIds, List<Long> apiScopeIds) { |
| | | // 删除角色配置的接口权限集合 |
| | | roleScopeService.remove(Wrappers.<RoleScope>update().lambda().eq(RoleScope::getScopeCategory, API_SCOPE_CATEGORY).in(RoleScope::getRoleId, roleIds)); |
| | | // 组装配置 |
| | | List<RoleScope> roleApiScopes = new ArrayList<>(); |
| | | roleIds.forEach(roleId -> apiScopeIds.forEach(scopeId -> { |
| | | RoleScope roleScope = new RoleScope(); |
| | | roleScope.setScopeCategory(API_SCOPE_CATEGORY); |
| | | roleScope.setScopeId(scopeId); |
| | | roleScope.setRoleId(roleId); |
| | | roleApiScopes.add(roleScope); |
| | | })); |
| | | // 新增配置 |
| | | roleScopeService.saveBatch(roleApiScopes); |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public String getRoleIds(String tenantId, String roleNames) { |
| | | List<Role> roleList = baseMapper.selectList(Wrappers.<Role>query().lambda().eq(Role::getTenantId, tenantId).in(Role::getRoleName, Func.toStrList(roleNames))); |
| | | if (roleList != null && roleList.size() > 0) { |
| | | return roleList.stream().map(role -> Func.toStr(role.getId())).distinct().collect(Collectors.joining(",")); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public List<String> getRoleNames(String roleIds) { |
| | | return baseMapper.getRoleNames(Func.toLongArray(roleIds)); |
| | | } |
| | | |
| | | @Override |
| | | public List<String> getRoleAliases(String roleIds) { |
| | | return baseMapper.getRoleAliases(Func.toLongArray(roleIds)); |
| | | } |
| | | |
| | | @Override |
| | | public boolean submit(Role role) { |
| | | if (!AuthUtil.isAdministrator()) { |
| | | if (Func.toStr(role.getRoleAlias()).equals(RoleConstant.ADMINISTRATOR)) { |
| | | throw new ServiceException("无权限创建超管角色!"); |
| | | } |
| | | } |
| | | if (Func.isEmpty(role.getParentId())) { |
| | | role.setTenantId(AuthUtil.getTenantId()); |
| | | role.setParentId(BladeConstant.TOP_PARENT_ID); |
| | | } |
| | | if (role.getParentId() > 0) { |
| | | Role parent = getById(role.getParentId()); |
| | | if (Func.toLong(role.getParentId()) == Func.toLong(role.getId())) { |
| | | throw new ServiceException("父节点不可选择自身!"); |
| | | } |
| | | role.setTenantId(parent.getTenantId()); |
| | | } |
| | | role.setIsDeleted(BladeConstant.DB_NOT_DELETED); |
| | | return saveOrUpdate(role); |
| | | } |
| | | |
| | | @Override |
| | | public List<RoleVO> search(String roleName, Long parentId) { |
| | | String tenantId = AuthUtil.getTenantId(); |
| | | LambdaQueryWrapper<Role> queryWrapper = Wrappers.<Role>query().lambda(); |
| | | if (Func.isNotEmpty(roleName)) { |
| | | queryWrapper.like(Role::getRoleName, roleName); |
| | | } |
| | | if (Func.isNotEmpty(parentId) && parentId > 0L) { |
| | | queryWrapper.eq(Role::getParentId, parentId); |
| | | } |
| | | if (Func.isNotEmpty(tenantId)) { |
| | | queryWrapper.eq(Role::getTenantId, tenantId); |
| | | } |
| | | List<Role> roleList = baseMapper.selectList(queryWrapper); |
| | | return RoleWrapper.build().listNodeVO(roleList); |
| | | } |
| | | |
| | | @Override |
| | | public boolean removeRole(String ids) { |
| | | Long cnt = baseMapper.selectCount(Wrappers.<Role>query().lambda().in(Role::getParentId, Func.toLongList(ids))); |
| | | if (cnt > 0L) { |
| | | throw new ServiceException("请先删除子节点!"); |
| | | } |
| | | return removeByIds(Func.toLongList(ids)); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.service.impl; |
| | | |
| | | import cn.gistack.system.entity.TenantPackage; |
| | | import cn.gistack.system.mapper.TenantPackageMapper; |
| | | import cn.gistack.system.service.ITenantPackageService; |
| | | import org.springblade.core.mp.base.BaseServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * 租户产品表 服务实现类 |
| | | * |
| | | * @author BladeX |
| | | */ |
| | | @Service |
| | | public class TenantPackageServiceImpl extends BaseServiceImpl<TenantPackageMapper, TenantPackage> implements ITenantPackageService { |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.service.impl; |
| | | |
| | | import cn.gistack.system.cache.ParamCache; |
| | | import cn.gistack.system.entity.*; |
| | | import cn.gistack.system.mapper.TenantMapper; |
| | | import cn.gistack.system.service.*; |
| | | import cn.gistack.system.user.entity.User; |
| | | import cn.gistack.system.user.enums.UserEnum; |
| | | import cn.gistack.system.user.feign.IUserClient; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.IdWorker; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import lombok.AllArgsConstructor; |
| | | import org.gistack.system.entity.*; |
| | | import org.gistack.system.service.*; |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.mp.base.BaseServiceImpl; |
| | | import org.springblade.core.tenant.TenantId; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.constant.BladeConstant; |
| | | import org.springblade.core.tool.jackson.JsonUtil; |
| | | import org.springblade.core.tool.support.Kv; |
| | | import org.springblade.core.tool.utils.DesUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.springblade.system.entity.*; |
| | | import org.springblade.system.service.*; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE; |
| | | |
| | | /** |
| | | * 服务实现类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class TenantServiceImpl extends BaseServiceImpl<TenantMapper, Tenant> implements ITenantService { |
| | | |
| | | private final TenantId tenantId; |
| | | private final IRoleService roleService; |
| | | private final IMenuService menuService; |
| | | private final IDeptService deptService; |
| | | private final IPostService postService; |
| | | private final IRoleMenuService roleMenuService; |
| | | private final IDictBizService dictBizService; |
| | | private final IUserClient userClient; |
| | | |
| | | @Override |
| | | public IPage<Tenant> selectTenantPage(IPage<Tenant> page, Tenant tenant) { |
| | | return page.setRecords(baseMapper.selectTenantPage(page, tenant)); |
| | | } |
| | | |
| | | @Override |
| | | public Tenant getByTenantId(String tenantId) { |
| | | return getOne(Wrappers.<Tenant>query().lambda().eq(Tenant::getTenantId, tenantId)); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean submitTenant(Tenant tenant) { |
| | | if (Func.isEmpty(tenant.getId())) { |
| | | List<Tenant> tenants = baseMapper.selectList(Wrappers.<Tenant>query().lambda().eq(Tenant::getIsDeleted, BladeConstant.DB_NOT_DELETED)); |
| | | List<String> codes = tenants.stream().map(Tenant::getTenantId).collect(Collectors.toList()); |
| | | String tenantId = getTenantId(codes); |
| | | tenant.setTenantId(tenantId); |
| | | // 获取参数配置的账号额度 |
| | | int accountNumber = Func.toInt(ParamCache.getValue(ACCOUNT_NUMBER_KEY), DEFAULT_ACCOUNT_NUMBER); |
| | | tenant.setAccountNumber(accountNumber); |
| | | // 新建租户对应的默认角色 |
| | | Role role = new Role(); |
| | | role.setTenantId(tenantId); |
| | | role.setParentId(BladeConstant.TOP_PARENT_ID); |
| | | role.setRoleName("管理员"); |
| | | role.setRoleAlias("admin"); |
| | | role.setSort(2); |
| | | role.setIsDeleted(BladeConstant.DB_NOT_DELETED); |
| | | roleService.save(role); |
| | | // 新建租户对应的角色菜单权限 |
| | | LinkedList<Menu> userMenus = new LinkedList<>(); |
| | | // 获取参数配置的默认菜单集合,逗号隔开 |
| | | List<String> menuCodes = Func.toStrList(ParamCache.getValue(ACCOUNT_MENU_CODE_KEY)); |
| | | List<Menu> menus = getMenus((menuCodes.size() > 0 ? menuCodes : MENU_CODES), userMenus); |
| | | List<RoleMenu> roleMenus = new ArrayList<>(); |
| | | menus.forEach(menu -> { |
| | | RoleMenu roleMenu = new RoleMenu(); |
| | | roleMenu.setMenuId(menu.getId()); |
| | | roleMenu.setRoleId(role.getId()); |
| | | roleMenus.add(roleMenu); |
| | | }); |
| | | roleMenuService.saveBatch(roleMenus); |
| | | // 新建租户对应的默认部门 |
| | | Dept dept = new Dept(); |
| | | dept.setTenantId(tenantId); |
| | | dept.setParentId(BladeConstant.TOP_PARENT_ID); |
| | | dept.setAncestors(String.valueOf(BladeConstant.TOP_PARENT_ID)); |
| | | dept.setDeptName(tenant.getTenantName()); |
| | | dept.setFullName(tenant.getTenantName()); |
| | | dept.setDeptCategory(1); |
| | | dept.setSort(2); |
| | | dept.setIsDeleted(BladeConstant.DB_NOT_DELETED); |
| | | deptService.save(dept); |
| | | // 新建租户对应的默认岗位 |
| | | Post post = new Post(); |
| | | post.setTenantId(tenantId); |
| | | post.setCategory(1); |
| | | post.setPostCode("ceo"); |
| | | post.setPostName("首席执行官"); |
| | | post.setSort(1); |
| | | postService.save(post); |
| | | // 新建租户对应的默认业务字典 |
| | | LinkedList<DictBiz> dictBizs = new LinkedList<>(); |
| | | List<DictBiz> dictBizList = getDictBizs(tenantId, dictBizs); |
| | | dictBizService.saveBatch(dictBizList); |
| | | // 新建租户对应的默认管理用户 |
| | | User user = new User(); |
| | | user.setTenantId(tenantId); |
| | | user.setName("admin"); |
| | | user.setRealName("admin"); |
| | | user.setAccount("admin"); |
| | | // 获取参数配置的密码 |
| | | String password = Func.toStr(ParamCache.getValue(PASSWORD_KEY), DEFAULT_PASSWORD); |
| | | user.setPassword(password); |
| | | user.setRoleId(String.valueOf(role.getId())); |
| | | user.setDeptId(String.valueOf(dept.getId())); |
| | | user.setPostId(String.valueOf(post.getId())); |
| | | user.setBirthday(new Date()); |
| | | user.setSex(1); |
| | | user.setUserType(UserEnum.WEB.getCategory()); |
| | | user.setIsDeleted(BladeConstant.DB_NOT_DELETED); |
| | | boolean temp = super.saveOrUpdate(tenant); |
| | | R<Boolean> result = userClient.saveUser(user); |
| | | if (!result.isSuccess()) { |
| | | throw new ServiceException(result.getMsg()); |
| | | } |
| | | return temp; |
| | | } else { |
| | | CacheUtil.clear(SYS_CACHE, tenant.getTenantId()); |
| | | return super.saveOrUpdate(tenant); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean removeTenant(List<Long> ids) { |
| | | List<String> tenantIds = this.list(Wrappers.<Tenant>query().lambda().in(Tenant::getId, ids)) |
| | | .stream().map(tenant -> Func.toStr(tenant.getTenantId())).distinct().collect(Collectors.toList()); |
| | | CacheUtil.clear(SYS_CACHE, tenantIds); |
| | | if (tenantIds.contains(BladeConstant.ADMIN_TENANT_ID)) { |
| | | throw new ServiceException("不可删除管理租户!"); |
| | | } |
| | | boolean tenantTemp = this.deleteLogic(ids); |
| | | R<Boolean> result = userClient.removeUser(StringUtil.join(tenantIds)); |
| | | if (!result.isSuccess()) { |
| | | throw new ServiceException(result.getMsg()); |
| | | } |
| | | return tenantTemp; |
| | | } |
| | | |
| | | @Override |
| | | public boolean setting(Integer accountNumber, Date expireTime, String ids) { |
| | | List<String> tenantIds = this.list(Wrappers.<Tenant>query().lambda().in(Tenant::getId, ids)) |
| | | .stream().map(tenant -> Func.toStr(tenant.getTenantId())).distinct().collect(Collectors.toList()); |
| | | CacheUtil.clear(SYS_CACHE, tenantIds); |
| | | Func.toLongList(ids).forEach(id -> { |
| | | Kv kv = Kv.create().set("accountNumber", accountNumber).set("expireTime", expireTime).set("id", id); |
| | | String licenseKey = DesUtil.encryptToHex(JsonUtil.toJson(kv), DES_KEY); |
| | | update( |
| | | Wrappers.<Tenant>update().lambda() |
| | | .set(Tenant::getAccountNumber, accountNumber) |
| | | .set(Tenant::getExpireTime, expireTime) |
| | | .set(Tenant::getLicenseKey, licenseKey) |
| | | .eq(Tenant::getId, id) |
| | | ); |
| | | }); |
| | | return true; |
| | | } |
| | | |
| | | private String getTenantId(List<String> codes) { |
| | | String code = tenantId.generate(); |
| | | if (codes.contains(code)) { |
| | | return getTenantId(codes); |
| | | } |
| | | return code; |
| | | } |
| | | |
| | | private List<Menu> getMenus(List<String> codes, LinkedList<Menu> menus) { |
| | | codes.forEach(code -> { |
| | | Menu menu = menuService.getOne(Wrappers.<Menu>query().lambda().eq(Menu::getCode, code).eq(Menu::getIsDeleted, BladeConstant.DB_NOT_DELETED)); |
| | | if (menu != null) { |
| | | menus.add(menu); |
| | | recursionMenu(menu.getId(), menus); |
| | | } |
| | | }); |
| | | return menus; |
| | | } |
| | | |
| | | private void recursionMenu(Long parentId, LinkedList<Menu> menus) { |
| | | List<Menu> menuList = menuService.list(Wrappers.<Menu>query().lambda().eq(Menu::getParentId, parentId).eq(Menu::getIsDeleted, BladeConstant.DB_NOT_DELETED)); |
| | | menus.addAll(menuList); |
| | | menuList.forEach(menu -> recursionMenu(menu.getId(), menus)); |
| | | } |
| | | |
| | | private List<DictBiz> getDictBizs(String tenantId, LinkedList<DictBiz> dictBizs) { |
| | | List<DictBiz> dictBizList = dictBizService.list(Wrappers.<DictBiz>query().lambda().eq(DictBiz::getParentId, BladeConstant.TOP_PARENT_ID).eq(DictBiz::getIsDeleted, BladeConstant.DB_NOT_DELETED)); |
| | | dictBizList.forEach(dictBiz -> { |
| | | Long oldParentId = dictBiz.getId(); |
| | | Long newParentId = IdWorker.getId(); |
| | | dictBiz.setId(newParentId); |
| | | dictBiz.setTenantId(tenantId); |
| | | dictBizs.add(dictBiz); |
| | | recursionDictBiz(tenantId, oldParentId, newParentId, dictBizs); |
| | | }); |
| | | return dictBizs; |
| | | } |
| | | |
| | | private void recursionDictBiz(String tenantId, Long oldParentId, Long newParentId, LinkedList<DictBiz> dictBizs) { |
| | | List<DictBiz> dictBizList = dictBizService.list(Wrappers.<DictBiz>query().lambda().eq(DictBiz::getParentId, oldParentId).eq(DictBiz::getIsDeleted, BladeConstant.DB_NOT_DELETED)); |
| | | dictBizList.forEach(dictBiz -> { |
| | | Long oldSubParentId = dictBiz.getId(); |
| | | Long newSubParentId = IdWorker.getId(); |
| | | dictBiz.setId(newSubParentId); |
| | | dictBiz.setTenantId(tenantId); |
| | | dictBiz.setParentId(newParentId); |
| | | dictBizs.add(dictBiz); |
| | | recursionDictBiz(tenantId, oldSubParentId, newSubParentId, dictBizs); |
| | | }); |
| | | } |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.wrapper; |
| | | |
| | | import org.springblade.core.mp.support.BaseEntityWrapper; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import cn.gistack.system.cache.DictCache; |
| | | import cn.gistack.system.entity.ApiScope; |
| | | import cn.gistack.system.enums.DictEnum; |
| | | import cn.gistack.system.vo.ApiScopeVO; |
| | | |
| | | import java.util.Objects; |
| | | |
| | | |
| | | /** |
| | | * 包装类,返回视图层所需的字段 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class ApiScopeWrapper extends BaseEntityWrapper<ApiScope, ApiScopeVO> { |
| | | |
| | | public static ApiScopeWrapper build() { |
| | | return new ApiScopeWrapper(); |
| | | } |
| | | |
| | | @Override |
| | | public ApiScopeVO entityVO(ApiScope dataScope) { |
| | | ApiScopeVO apiScopeVO = Objects.requireNonNull(BeanUtil.copy(dataScope, ApiScopeVO.class)); |
| | | String scopeTypeName = DictCache.getValue(DictEnum.API_SCOPE_TYPE, dataScope.getScopeType()); |
| | | apiScopeVO.setScopeTypeName(scopeTypeName); |
| | | return apiScopeVO; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.wrapper; |
| | | |
| | | import org.springblade.core.mp.support.BaseEntityWrapper; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import cn.gistack.system.cache.DictCache; |
| | | import cn.gistack.system.entity.DataScope; |
| | | import cn.gistack.system.enums.DictEnum; |
| | | import cn.gistack.system.vo.DataScopeVO; |
| | | |
| | | import java.util.Objects; |
| | | |
| | | |
| | | /** |
| | | * 包装类,返回视图层所需的字段 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class DataScopeWrapper extends BaseEntityWrapper<DataScope, DataScopeVO> { |
| | | |
| | | public static DataScopeWrapper build() { |
| | | return new DataScopeWrapper(); |
| | | } |
| | | |
| | | @Override |
| | | public DataScopeVO entityVO(DataScope dataScope) { |
| | | DataScopeVO dataScopeVO = Objects.requireNonNull(BeanUtil.copy(dataScope, DataScopeVO.class)); |
| | | String scopeTypeName = DictCache.getValue(DictEnum.DATA_SCOPE_TYPE, dataScope.getScopeType()); |
| | | dataScopeVO.setScopeTypeName(scopeTypeName); |
| | | return dataScopeVO; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.wrapper; |
| | | |
| | | import org.springblade.core.mp.support.BaseEntityWrapper; |
| | | import org.springblade.core.tool.constant.BladeConstant; |
| | | import org.springblade.core.tool.node.ForestNodeMerger; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import cn.gistack.system.cache.DictBizCache; |
| | | import cn.gistack.system.entity.DictBiz; |
| | | import cn.gistack.system.vo.DictBizVO; |
| | | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | |
| | | /** |
| | | * 包装类,返回视图层所需的字段 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class DictBizWrapper extends BaseEntityWrapper<DictBiz, DictBizVO> { |
| | | |
| | | public static DictBizWrapper build() { |
| | | return new DictBizWrapper(); |
| | | } |
| | | |
| | | @Override |
| | | public DictBizVO entityVO(DictBiz dict) { |
| | | DictBizVO dictVO = Objects.requireNonNull(BeanUtil.copy(dict, DictBizVO.class)); |
| | | if (Func.equals(dict.getParentId(), BladeConstant.TOP_PARENT_ID)) { |
| | | dictVO.setParentName(BladeConstant.TOP_PARENT_NAME); |
| | | } else { |
| | | DictBiz parent = DictBizCache.getById(dict.getParentId()); |
| | | dictVO.setParentName(parent.getDictValue()); |
| | | } |
| | | return dictVO; |
| | | } |
| | | |
| | | public List<DictBizVO> listNodeVO(List<DictBiz> list) { |
| | | List<DictBizVO> collect = list.stream().map(dict -> BeanUtil.copy(dict, DictBizVO.class)).collect(Collectors.toList()); |
| | | return ForestNodeMerger.merge(collect); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.wrapper; |
| | | |
| | | import org.springblade.core.mp.support.BaseEntityWrapper; |
| | | import org.springblade.core.tool.constant.BladeConstant; |
| | | import org.springblade.core.tool.node.ForestNodeMerger; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import cn.gistack.system.cache.DictCache; |
| | | import cn.gistack.system.cache.SysCache; |
| | | import cn.gistack.system.entity.Menu; |
| | | import cn.gistack.system.enums.DictEnum; |
| | | import cn.gistack.system.vo.MenuVO; |
| | | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 包装类,返回视图层所需的字段 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class MenuWrapper extends BaseEntityWrapper<Menu, MenuVO> { |
| | | |
| | | public static MenuWrapper build() { |
| | | return new MenuWrapper(); |
| | | } |
| | | |
| | | @Override |
| | | public MenuVO entityVO(Menu menu) { |
| | | MenuVO menuVO = Objects.requireNonNull(BeanUtil.copy(menu, MenuVO.class)); |
| | | if (Func.equals(menu.getParentId(), BladeConstant.TOP_PARENT_ID)) { |
| | | menuVO.setParentName(BladeConstant.TOP_PARENT_NAME); |
| | | } else { |
| | | Menu parent = SysCache.getMenu(menu.getParentId()); |
| | | menuVO.setParentName(parent.getName()); |
| | | } |
| | | String category = DictCache.getValue(DictEnum.MENU_CATEGORY, Func.toInt(menuVO.getCategory())); |
| | | String action = DictCache.getValue(DictEnum.BUTTON_FUNC, Func.toInt(menuVO.getAction())); |
| | | String open = DictCache.getValue(DictEnum.YES_NO, Func.toInt(menuVO.getIsOpen())); |
| | | menuVO.setCategoryName(category); |
| | | menuVO.setActionName(action); |
| | | menuVO.setIsOpenName(open); |
| | | return menuVO; |
| | | } |
| | | |
| | | public List<MenuVO> listNodeVO(List<Menu> list) { |
| | | List<MenuVO> collect = list.stream().map(menu -> BeanUtil.copy(menu, MenuVO.class)).collect(Collectors.toList()); |
| | | return ForestNodeMerger.merge(collect); |
| | | } |
| | | |
| | | public List<MenuVO> listNodeLazyVO(List<MenuVO> list) { |
| | | return ForestNodeMerger.merge(list); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.wrapper; |
| | | |
| | | import org.springblade.core.mp.support.BaseEntityWrapper; |
| | | import org.springblade.core.tool.node.ForestNodeMerger; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import cn.gistack.system.cache.RegionCache; |
| | | import cn.gistack.system.entity.Region; |
| | | import cn.gistack.system.vo.RegionVO; |
| | | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 包装类,返回视图层所需的字段 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class RegionWrapper extends BaseEntityWrapper<Region, RegionVO> { |
| | | |
| | | public static RegionWrapper build() { |
| | | return new RegionWrapper(); |
| | | } |
| | | |
| | | @Override |
| | | public RegionVO entityVO(Region region) { |
| | | RegionVO regionVO = Objects.requireNonNull(BeanUtil.copy(region, RegionVO.class)); |
| | | Region parentRegion = RegionCache.getByCode(region.getParentCode()); |
| | | regionVO.setParentName(parentRegion.getName()); |
| | | return regionVO; |
| | | } |
| | | |
| | | public List<RegionVO> listNodeLazyVO(List<RegionVO> list) { |
| | | return ForestNodeMerger.merge(list); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <project xmlns="http://maven.apache.org/POM/4.0.0" |
| | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| | | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| | | <parent> |
| | | <artifactId>skjcmanager-service</artifactId> |
| | | <groupId>org.springblade</groupId> |
| | | <version>3.0.1.RELEASE</version> |
| | | </parent> |
| | | |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | | <artifactId>skjcmanager-user</artifactId> |
| | | <name>${project.artifactId}</name> |
| | | <version>${bladex.project.version}</version> |
| | | <packaging>jar</packaging> |
| | | |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>blade-core-boot</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>blade-starter-excel</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>blade-starter-swagger</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>skjcmanager-user-api</artifactId> |
| | | <version>${bladex.project.version}</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>skjcmanager-system-api</artifactId> |
| | | <version>${bladex.project.version}</version> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | <build> |
| | | <plugins> |
| | | <plugin> |
| | | <groupId>com.spotify</groupId> |
| | | <artifactId>dockerfile-maven-plugin</artifactId> |
| | | <configuration> |
| | | <username>${docker.username}</username> |
| | | <password>${docker.password}</password> |
| | | <repository>${docker.registry.url}/${docker.namespace}/${project.artifactId}</repository> |
| | | <tag>${project.version}</tag> |
| | | <useMavenSettingsForAuth>true</useMavenSettingsForAuth> |
| | | <buildArgs> |
| | | <JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE> |
| | | </buildArgs> |
| | | <skip>false</skip> |
| | | </configuration> |
| | | </plugin> |
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-antrun-plugin</artifactId> |
| | | </plugin> |
| | | </plugins> |
| | | </build> |
| | | |
| | | </project> |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.user; |
| | | |
| | | import cn.gistack.common.constant.AppsConstant; |
| | | import org.springblade.core.cloud.client.BladeCloudApplication; |
| | | import org.springblade.core.launch.BladeApplication; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | |
| | | /** |
| | | * 用户启动器 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @BladeCloudApplication |
| | | public class UserApplication { |
| | | |
| | | public static void main(String[] args) { |
| | | BladeApplication.run(AppsConstant.APPLICATION_USER_NAME, UserApplication.class, args); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.user.controller; |
| | | |
| | | |
| | | import cn.gistack.system.user.entity.User; |
| | | import cn.gistack.system.user.excel.UserExcel; |
| | | import cn.gistack.system.user.excel.UserImporter; |
| | | import cn.gistack.system.user.service.IUserService; |
| | | import cn.gistack.system.user.vo.UserVO; |
| | | import cn.gistack.system.user.wrapper.UserWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.AllArgsConstructor; |
| | | import cn.gistack.common.cache.CacheNames; |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.excel.util.ExcelUtil; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.redis.cache.BladeRedis; |
| | | import org.springblade.core.secure.BladeUser; |
| | | import org.springblade.core.secure.annotation.PreAuth; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tenant.annotation.NonDS; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.constant.BladeConstant; |
| | | import org.springblade.core.tool.constant.RoleConstant; |
| | | import org.springblade.core.tool.utils.DateUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.core.tool.utils.StringPool; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import springfox.documentation.annotations.ApiIgnore; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.Valid; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import static org.springblade.core.cache.constant.CacheConstant.USER_CACHE; |
| | | |
| | | /** |
| | | * 控制器 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @NonDS |
| | | @RestController |
| | | @RequestMapping |
| | | @AllArgsConstructor |
| | | public class UserController { |
| | | |
| | | private final IUserService userService; |
| | | private final BladeRedis bladeRedis; |
| | | |
| | | /** |
| | | * 查询单条 |
| | | */ |
| | | @ApiOperationSupport(order = 1) |
| | | @ApiOperation(value = "查看详情", notes = "传入id") |
| | | @GetMapping("/detail") |
| | | @PreAuth(RoleConstant.HAS_ROLE_ADMIN) |
| | | public R<UserVO> detail(User user) { |
| | | User detail = userService.getOne(Condition.getQueryWrapper(user)); |
| | | return R.data(UserWrapper.build().entityVO(detail)); |
| | | } |
| | | |
| | | /** |
| | | * 查询单条 |
| | | */ |
| | | @ApiOperationSupport(order = 2) |
| | | @ApiOperation(value = "查看详情", notes = "传入id") |
| | | @GetMapping("/info") |
| | | public R<UserVO> info(BladeUser user) { |
| | | User detail = userService.getById(user.getUserId()); |
| | | return R.data(UserWrapper.build().entityVO(detail)); |
| | | } |
| | | |
| | | /** |
| | | * 用户列表 |
| | | */ |
| | | @GetMapping("/list") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "account", value = "账号名", paramType = "query", dataType = "string"), |
| | | @ApiImplicitParam(name = "realName", value = "姓名", paramType = "query", dataType = "string") |
| | | }) |
| | | @ApiOperationSupport(order = 3) |
| | | @ApiOperation(value = "列表", notes = "传入account和realName") |
| | | @PreAuth(RoleConstant.HAS_ROLE_ADMIN) |
| | | public R<IPage<UserVO>> list(@ApiIgnore @RequestParam Map<String, Object> user, Query query, BladeUser bladeUser) { |
| | | QueryWrapper<User> queryWrapper = Condition.getQueryWrapper(user, User.class); |
| | | IPage<User> pages = userService.page(Condition.getPage(query), (!bladeUser.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID)) ? queryWrapper.lambda().eq(User::getTenantId, bladeUser.getTenantId()) : queryWrapper); |
| | | return R.data(UserWrapper.build().pageVO(pages)); |
| | | } |
| | | |
| | | /** |
| | | * 自定义用户列表 |
| | | */ |
| | | @GetMapping("/page") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "account", value = "账号名", paramType = "query", dataType = "string"), |
| | | @ApiImplicitParam(name = "realName", value = "姓名", paramType = "query", dataType = "string") |
| | | }) |
| | | @ApiOperationSupport(order = 3) |
| | | @ApiOperation(value = "列表", notes = "传入account和realName") |
| | | @PreAuth(RoleConstant.HAS_ROLE_ADMIN) |
| | | public R<IPage<UserVO>> page(@ApiIgnore User user, Query query, Long deptId, BladeUser bladeUser) { |
| | | IPage<User> pages = userService.selectUserPage(Condition.getPage(query), user, deptId, (bladeUser.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID) ? StringPool.EMPTY : bladeUser.getTenantId())); |
| | | return R.data(UserWrapper.build().pageVO(pages)); |
| | | } |
| | | |
| | | /** |
| | | * 新增或修改 |
| | | */ |
| | | @PostMapping("/submit") |
| | | @ApiOperationSupport(order = 4) |
| | | @ApiOperation(value = "新增或修改", notes = "传入User") |
| | | @PreAuth(RoleConstant.HAS_ROLE_ADMIN) |
| | | public R submit(@Valid @RequestBody User user) { |
| | | CacheUtil.clear(USER_CACHE); |
| | | return R.status(userService.submit(user)); |
| | | } |
| | | |
| | | /** |
| | | * 修改 |
| | | */ |
| | | @PostMapping("/update") |
| | | @ApiOperationSupport(order = 5) |
| | | @ApiOperation(value = "修改", notes = "传入User") |
| | | public R update(@Valid @RequestBody User user) { |
| | | CacheUtil.clear(USER_CACHE); |
| | | return R.status(userService.updateUser(user)); |
| | | } |
| | | |
| | | /** |
| | | * 删除 |
| | | */ |
| | | @PostMapping("/remove") |
| | | @ApiOperationSupport(order = 6) |
| | | @ApiOperation(value = "删除", notes = "传入id集合") |
| | | @PreAuth(RoleConstant.HAS_ROLE_ADMIN) |
| | | public R remove(@RequestParam String ids) { |
| | | CacheUtil.clear(USER_CACHE); |
| | | return R.status(userService.removeUser(ids)); |
| | | } |
| | | |
| | | /** |
| | | * 设置菜单权限 |
| | | */ |
| | | @PostMapping("/grant") |
| | | @ApiOperationSupport(order = 7) |
| | | @ApiOperation(value = "权限设置", notes = "传入roleId集合以及menuId集合") |
| | | @PreAuth(RoleConstant.HAS_ROLE_ADMIN) |
| | | public R grant(@ApiParam(value = "userId集合", required = true) @RequestParam String userIds, |
| | | @ApiParam(value = "roleId集合", required = true) @RequestParam String roleIds) { |
| | | boolean temp = userService.grant(userIds, roleIds); |
| | | return R.status(temp); |
| | | } |
| | | |
| | | /** |
| | | * 密码重制 |
| | | */ |
| | | @PostMapping("/reset-password") |
| | | @ApiOperationSupport(order = 8) |
| | | @ApiOperation(value = "初始化密码", notes = "传入userId集合") |
| | | @PreAuth(RoleConstant.HAS_ROLE_ADMIN) |
| | | public R resetPassword(@ApiParam(value = "userId集合", required = true) @RequestParam String userIds) { |
| | | boolean temp = userService.resetPassword(userIds); |
| | | return R.status(temp); |
| | | } |
| | | |
| | | /** |
| | | * 修改密码 |
| | | */ |
| | | @PostMapping("/update-password") |
| | | @ApiOperationSupport(order = 9) |
| | | @ApiOperation(value = "修改密码", notes = "传入密码") |
| | | public R updatePassword(BladeUser user, @ApiParam(value = "旧密码", required = true) @RequestParam String oldPassword, |
| | | @ApiParam(value = "新密码", required = true) @RequestParam String newPassword, |
| | | @ApiParam(value = "新密码", required = true) @RequestParam String newPassword1) { |
| | | boolean temp = userService.updatePassword(user.getUserId(), oldPassword, newPassword, newPassword1); |
| | | return R.status(temp); |
| | | } |
| | | |
| | | /** |
| | | * 修改基本信息 |
| | | */ |
| | | @PostMapping("/update-info") |
| | | @ApiOperationSupport(order = 10) |
| | | @ApiOperation(value = "修改基本信息", notes = "传入User") |
| | | public R updateInfo(@Valid @RequestBody User user) { |
| | | CacheUtil.clear(USER_CACHE); |
| | | return R.status(userService.updateUserInfo(user)); |
| | | } |
| | | |
| | | /** |
| | | * 用户列表 |
| | | */ |
| | | @GetMapping("/user-list") |
| | | @ApiOperationSupport(order = 11) |
| | | @ApiOperation(value = "用户列表", notes = "传入user") |
| | | public R<List<User>> userList(User user, BladeUser bladeUser) { |
| | | QueryWrapper<User> queryWrapper = Condition.getQueryWrapper(user); |
| | | List<User> list = userService.list((!AuthUtil.isAdministrator()) ? queryWrapper.lambda().eq(User::getTenantId, bladeUser.getTenantId()) : queryWrapper); |
| | | return R.data(list); |
| | | } |
| | | |
| | | /** |
| | | * 导入用户 |
| | | */ |
| | | @PostMapping("import-user") |
| | | @ApiOperationSupport(order = 12) |
| | | @ApiOperation(value = "导入用户", notes = "传入excel") |
| | | public R importUser(MultipartFile file, Integer isCovered) { |
| | | UserImporter userImporter = new UserImporter(userService, isCovered == 1); |
| | | ExcelUtil.save(file, userImporter, UserExcel.class); |
| | | return R.success("操作成功"); |
| | | } |
| | | |
| | | /** |
| | | * 导出用户 |
| | | */ |
| | | @GetMapping("export-user") |
| | | @ApiOperationSupport(order = 13) |
| | | @ApiOperation(value = "导出用户", notes = "传入user") |
| | | public void exportUser(@ApiIgnore @RequestParam Map<String, Object> user, BladeUser bladeUser, HttpServletResponse response) { |
| | | QueryWrapper<User> queryWrapper = Condition.getQueryWrapper(user, User.class); |
| | | if (!AuthUtil.isAdministrator()) { |
| | | queryWrapper.lambda().eq(User::getTenantId, bladeUser.getTenantId()); |
| | | } |
| | | queryWrapper.lambda().eq(User::getIsDeleted, BladeConstant.DB_NOT_DELETED); |
| | | List<UserExcel> list = userService.exportUser(queryWrapper); |
| | | ExcelUtil.export(response, "用户数据" + DateUtil.time(), "用户数据表", list, UserExcel.class); |
| | | } |
| | | |
| | | /** |
| | | * 导出模板 |
| | | */ |
| | | @GetMapping("export-template") |
| | | @ApiOperationSupport(order = 14) |
| | | @ApiOperation(value = "导出模板") |
| | | public void exportUser(HttpServletResponse response) { |
| | | List<UserExcel> list = new ArrayList<>(); |
| | | ExcelUtil.export(response, "用户数据模板", "用户数据表", list, UserExcel.class); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 第三方注册用户 |
| | | */ |
| | | @PostMapping("/register-guest") |
| | | @ApiOperationSupport(order = 15) |
| | | @ApiOperation(value = "第三方注册用户", notes = "传入user") |
| | | public R registerGuest(User user, Long oauthId) { |
| | | return R.status(userService.registerGuest(user, oauthId)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 配置用户平台信息 |
| | | */ |
| | | @PostMapping("/update-platform") |
| | | @ApiOperationSupport(order = 16) |
| | | @ApiOperation(value = "配置用户平台信息", notes = "传入user") |
| | | public R updatePlatform(Long userId, Integer userType, String userExt) { |
| | | return R.status(userService.updatePlatform(userId, userType, userExt)); |
| | | } |
| | | |
| | | /** |
| | | * 查看平台详情 |
| | | */ |
| | | @ApiOperationSupport(order = 17) |
| | | @ApiOperation(value = "查看平台详情", notes = "传入id") |
| | | @GetMapping("/platform-detail") |
| | | @PreAuth(RoleConstant.HAS_ROLE_ADMIN) |
| | | public R<UserVO> platformDetail(User user) { |
| | | return R.data(userService.platformDetail(user)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 用户列表查询 |
| | | */ |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "name", value = "人员姓名", paramType = "query", dataType = "string"), |
| | | @ApiImplicitParam(name = "deptName", value = "部门名称", paramType = "query", dataType = "string"), |
| | | @ApiImplicitParam(name = "postName", value = "职位名称", paramType = "query", dataType = "string"), |
| | | @ApiImplicitParam(name = "current", value = "当前页数", paramType = "query", dataType = "int"), |
| | | @ApiImplicitParam(name = "size", value = "每页数量", paramType = "query", dataType = "int") |
| | | }) |
| | | @ApiOperationSupport(order = 18) |
| | | @ApiOperation(value = "用户列表查询", notes = "用户列表查询") |
| | | @GetMapping("/search/user") |
| | | public R<IPage<UserVO>> userSearch(@ApiIgnore UserVO user, @ApiIgnore Query query) { |
| | | return R.data(userService.selectUserSearch(user, query)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 用户解锁 |
| | | */ |
| | | @PostMapping("/unlock") |
| | | @ApiOperationSupport(order = 19) |
| | | @ApiOperation(value = "账号解锁", notes = "传入id") |
| | | public R unlock(String userIds) { |
| | | if (StringUtil.isBlank(userIds)) { |
| | | return R.fail("请至少选择一个用户"); |
| | | } |
| | | List<User> userList = userService.list(Wrappers.<User>lambdaQuery().in(User::getId, Func.toLongList(userIds))); |
| | | userList.forEach(user -> bladeRedis.del(CacheNames.tenantKey(user.getTenantId(), CacheNames.USER_FAIL_KEY, user.getAccount()))); |
| | | return R.success("操作成功"); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.user.feign; |
| | | |
| | | import cn.gistack.system.user.entity.User; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.core.tenant.annotation.NonDS; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import cn.gistack.system.user.service.IUserSearchService; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 用户查询服务Feign实现类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @NonDS |
| | | @RestController |
| | | @AllArgsConstructor |
| | | public class UserSearchClient implements IUserSearchClient { |
| | | |
| | | private final IUserSearchService service; |
| | | |
| | | @Override |
| | | @GetMapping(LIST_BY_USER) |
| | | public R<List<User>> listByUser(String userId) { |
| | | return R.data(service.listByUser(Func.toLongList(userId))); |
| | | } |
| | | |
| | | @Override |
| | | @GetMapping(LIST_BY_DEPT) |
| | | public R<List<User>> listByDept(String deptId) { |
| | | return R.data(service.listByDept(Func.toLongList(deptId))); |
| | | } |
| | | |
| | | @Override |
| | | @GetMapping(LIST_BY_POST) |
| | | public R<List<User>> listByPost(String postId) { |
| | | return R.data(service.listByPost(Func.toLongList(postId))); |
| | | } |
| | | |
| | | @Override |
| | | @GetMapping(LIST_BY_ROLE) |
| | | public R<List<User>> listByRole(String roleId) { |
| | | return R.data(service.listByRole(Func.toLongList(roleId))); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.user.mapper; |
| | | |
| | | import cn.gistack.system.user.entity.UserApp; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | |
| | | /** |
| | | * Mapper 接口 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface UserAppMapper extends BaseMapper<UserApp> { |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="cn.gistack.system.user.mapper.UserAppMapper"> |
| | | |
| | | </mapper> |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.user.mapper; |
| | | |
| | | import cn.gistack.system.user.entity.UserDept; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | |
| | | /** |
| | | * Mapper 接口 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface UserDeptMapper extends BaseMapper<UserDept> { |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.user.mapper; |
| | | |
| | | import cn.gistack.system.user.entity.User; |
| | | import cn.gistack.system.user.excel.UserExcel; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Mapper 接口 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface UserMapper extends BaseMapper<User> { |
| | | |
| | | /** |
| | | * 自定义分页 |
| | | * |
| | | * @param page |
| | | * @param user |
| | | * @param deptIdList |
| | | * @param tenantId |
| | | * @return |
| | | */ |
| | | List<User> selectUserPage(IPage<User> page, @Param("user") User user, @Param("deptIdList") List<Long> deptIdList, @Param("tenantId") String tenantId); |
| | | |
| | | /** |
| | | * 获取用户 |
| | | * |
| | | * @param tenantId |
| | | * @param account |
| | | * @return |
| | | */ |
| | | User getUser(String tenantId, String account); |
| | | |
| | | /** |
| | | * 获取导出用户数据 |
| | | * |
| | | * @param queryWrapper |
| | | * @return |
| | | */ |
| | | List<UserExcel> exportUser(@Param("ew") Wrapper<User> queryWrapper); |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="cn.gistack.system.user.mapper.UserMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="userResultMap" type="cn.gistack.system.user.entity.User"> |
| | | <result column="id" property="id"/> |
| | | <result column="tenant_id" property="tenantId"/> |
| | | <result column="create_user" property="createUser"/> |
| | | <result column="create_time" property="createTime"/> |
| | | <result column="update_user" property="updateUser"/> |
| | | <result column="update_time" property="updateTime"/> |
| | | <result column="status" property="status"/> |
| | | <result column="is_deleted" property="isDeleted"/> |
| | | <result column="code" property="code"/> |
| | | <result column="user_type" property="userType"/> |
| | | <result column="account" property="account"/> |
| | | <result column="password" property="password"/> |
| | | <result column="name" property="name"/> |
| | | <result column="real_name" property="realName"/> |
| | | <result column="email" property="email"/> |
| | | <result column="phone" property="phone"/> |
| | | <result column="birthday" property="birthday"/> |
| | | <result column="sex" property="sex"/> |
| | | <result column="role_id" property="roleId"/> |
| | | <result column="dept_id" property="deptId"/> |
| | | <result column="post_id" property="postId"/> |
| | | </resultMap> |
| | | |
| | | <select id="selectUserPage" resultMap="userResultMap"> |
| | | select * from blade_user where is_deleted = 0 |
| | | <if test="tenantId!=null and tenantId != ''"> |
| | | and tenant_id = #{tenantId} |
| | | </if> |
| | | <if test="user.tenantId!=null and user.tenantId != ''"> |
| | | and tenant_id = #{user.tenantId} |
| | | </if> |
| | | <if test="user.account!=null and user.account != ''"> |
| | | and account = #{user.account} |
| | | </if> |
| | | <if test="user.realName!=null and user.realName != ''"> |
| | | and real_name = #{user.realName} |
| | | </if> |
| | | <if test="user.userType!=null and user.userType != ''"> |
| | | and user_type = #{user.userType} |
| | | </if> |
| | | <if test="deptIdList!=null and deptIdList.size>0"> |
| | | and id in ( |
| | | SELECT |
| | | user_id |
| | | FROM |
| | | blade_user_dept |
| | | WHERE |
| | | dept_id IN |
| | | <foreach collection="deptIdList" index="index" item="item" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> |
| | | ) |
| | | </if> |
| | | ORDER BY id |
| | | </select> |
| | | |
| | | <select id="getUser" resultMap="userResultMap"> |
| | | SELECT |
| | | * |
| | | FROM |
| | | blade_user |
| | | WHERE |
| | | tenant_id = #{param1} and account = #{param2} and is_deleted = 0 |
| | | </select> |
| | | |
| | | <select id="exportUser" resultType="cn.gistack.system.user.excel.UserExcel"> |
| | | SELECT id, tenant_id, user_type, account, name, real_name, email, phone, birthday, role_id, dept_id, post_id FROM blade_user ${ew.customSqlSegment} |
| | | </select> |
| | | |
| | | </mapper> |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="cn.gistack.system.user.mapper.UserOauthMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="userResultMap" type="cn.gistack.system.user.entity.UserOauth"> |
| | | <result column="id" property="id"/> |
| | | <result column="tenant_id" property="tenantId"/> |
| | | <result column="user_id" property="userId"/> |
| | | <result column="username" property="username"/> |
| | | <result column="nickname" property="nickname"/> |
| | | <result column="avatar" property="avatar"/> |
| | | <result column="blog" property="blog"/> |
| | | <result column="company" property="company"/> |
| | | <result column="location" property="location"/> |
| | | <result column="email" property="email"/> |
| | | <result column="remark" property="remark"/> |
| | | <result column="gender" property="gender"/> |
| | | <result column="source" property="source"/> |
| | | </resultMap> |
| | | |
| | | </mapper> |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="cn.gistack.system.user.mapper.UserOtherMapper"> |
| | | |
| | | </mapper> |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.user.service; |
| | | |
| | | |
| | | import cn.gistack.system.user.entity.User; |
| | | import cn.gistack.system.user.entity.UserInfo; |
| | | import cn.gistack.system.user.entity.UserOauth; |
| | | import cn.gistack.system.user.enums.UserEnum; |
| | | import cn.gistack.system.user.excel.UserExcel; |
| | | import cn.gistack.system.user.vo.UserVO; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.springblade.core.mp.base.BaseService; |
| | | import org.springblade.core.mp.support.Query; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 服务类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public interface IUserService extends BaseService<User> { |
| | | |
| | | /** |
| | | * 新增用户 |
| | | * |
| | | * @param user |
| | | * @return |
| | | */ |
| | | boolean submit(User user); |
| | | |
| | | /** |
| | | * 修改用户 |
| | | * |
| | | * @param user |
| | | * @return |
| | | */ |
| | | boolean updateUser(User user); |
| | | |
| | | /** |
| | | * 修改用户基本信息 |
| | | * |
| | | * @param user |
| | | * @return |
| | | */ |
| | | boolean updateUserInfo(User user); |
| | | |
| | | /** |
| | | * 自定义分页 |
| | | * |
| | | * @param page |
| | | * @param user |
| | | * @param deptId |
| | | * @param tenantId |
| | | * @return |
| | | */ |
| | | IPage<User> selectUserPage(IPage<User> page, User user, Long deptId, String tenantId); |
| | | |
| | | /** |
| | | * 自定义分页 |
| | | * |
| | | * @param user |
| | | * @param query |
| | | * @return |
| | | */ |
| | | IPage<UserVO> selectUserSearch(UserVO user, Query query); |
| | | |
| | | |
| | | /** |
| | | * 用户信息 |
| | | * |
| | | * @param userId |
| | | * @return |
| | | */ |
| | | UserInfo userInfo(Long userId); |
| | | |
| | | /** |
| | | * 用户信息 |
| | | * |
| | | * @param tenantId |
| | | * @param account |
| | | * @return |
| | | */ |
| | | UserInfo userInfo(String tenantId, String account); |
| | | |
| | | /** |
| | | * 用户信息 |
| | | * |
| | | * @param tenantId |
| | | * @param account |
| | | * @param userEnum |
| | | * @return |
| | | */ |
| | | UserInfo userInfo(String tenantId, String account, UserEnum userEnum); |
| | | |
| | | /** |
| | | * 用户信息 |
| | | * |
| | | * @param userOauth |
| | | * @return |
| | | */ |
| | | UserInfo userInfo(UserOauth userOauth); |
| | | |
| | | /** |
| | | * 根据账号获取用户 |
| | | * |
| | | * @param tenantId |
| | | * @param account |
| | | * @return |
| | | */ |
| | | User userByAccount(String tenantId, String account); |
| | | |
| | | /** |
| | | * 给用户设置角色 |
| | | * |
| | | * @param userIds |
| | | * @param roleIds |
| | | * @return |
| | | */ |
| | | boolean grant(String userIds, String roleIds); |
| | | |
| | | /** |
| | | * 初始化密码 |
| | | * |
| | | * @param userIds |
| | | * @return |
| | | */ |
| | | boolean resetPassword(String userIds); |
| | | |
| | | /** |
| | | * 修改密码 |
| | | * |
| | | * @param userId |
| | | * @param oldPassword |
| | | * @param newPassword |
| | | * @param newPassword1 |
| | | * @return |
| | | */ |
| | | boolean updatePassword(Long userId, String oldPassword, String newPassword, String newPassword1); |
| | | |
| | | /** |
| | | * 删除用户 |
| | | * |
| | | * @param userIds |
| | | * @return |
| | | */ |
| | | boolean removeUser(String userIds); |
| | | |
| | | /** |
| | | * 导入用户数据 |
| | | * |
| | | * @param data |
| | | * @param isCovered |
| | | * @return |
| | | */ |
| | | void importUser(List<UserExcel> data, Boolean isCovered); |
| | | |
| | | /** |
| | | * 导出用户数据 |
| | | * |
| | | * @param queryWrapper |
| | | * @return |
| | | */ |
| | | List<UserExcel> exportUser(Wrapper<User> queryWrapper); |
| | | |
| | | /** |
| | | * 注册用户 |
| | | * |
| | | * @param user |
| | | * @param oauthId |
| | | * @return |
| | | */ |
| | | boolean registerGuest(User user, Long oauthId); |
| | | |
| | | /** |
| | | * 配置用户平台 |
| | | * |
| | | * @param userId |
| | | * @param userType |
| | | * @param userExt |
| | | * @return |
| | | */ |
| | | boolean updatePlatform(Long userId, Integer userType, String userExt); |
| | | |
| | | /** |
| | | * 用户详细信息 |
| | | * |
| | | * @param user |
| | | * @return |
| | | */ |
| | | UserVO platformDetail(User user); |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.user.service.impl; |
| | | |
| | | |
| | | import cn.gistack.system.user.entity.UserDept; |
| | | import cn.gistack.system.user.mapper.UserDeptMapper; |
| | | import cn.gistack.system.user.service.IUserDeptService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * 服务实现类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Service |
| | | public class UserDeptServiceImpl extends ServiceImpl<UserDeptMapper, UserDept> implements IUserDeptService { |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.user.service.impl; |
| | | |
| | | |
| | | import cn.gistack.system.user.entity.UserOauth; |
| | | import cn.gistack.system.user.mapper.UserOauthMapper; |
| | | import cn.gistack.system.user.service.IUserOauthService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * 服务实现类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class UserOauthServiceImpl extends ServiceImpl<UserOauthMapper, UserOauth> implements IUserOauthService { |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.user.service.impl; |
| | | |
| | | |
| | | import cn.gistack.system.user.entity.User; |
| | | import cn.gistack.system.user.mapper.UserMapper; |
| | | import cn.gistack.system.user.service.IUserSearchService; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.core.mp.base.BaseServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 用户查询服务实现类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class UserSearchServiceImpl extends BaseServiceImpl<UserMapper, User> implements IUserSearchService { |
| | | |
| | | @Override |
| | | public List<User> listByUser(List<Long> userId) { |
| | | return this.list(Wrappers.<User>lambdaQuery().in(User::getId, userId)); |
| | | } |
| | | |
| | | @Override |
| | | public List<User> listByDept(List<Long> deptId) { |
| | | LambdaQueryWrapper<User> queryWrapper = Wrappers.lambdaQuery(); |
| | | deptId.forEach(id -> queryWrapper.like(User::getDeptId, id).or()); |
| | | return this.list(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<User> listByPost(List<Long> postId) { |
| | | LambdaQueryWrapper<User> queryWrapper = Wrappers.lambdaQuery(); |
| | | postId.forEach(id -> queryWrapper.like(User::getPostId, id).or()); |
| | | return this.list(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<User> listByRole(List<Long> roleId) { |
| | | LambdaQueryWrapper<User> queryWrapper = Wrappers.lambdaQuery(); |
| | | roleId.forEach(id -> queryWrapper.like(User::getRoleId, id).or()); |
| | | return this.list(queryWrapper); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.user.service.impl; |
| | | |
| | | |
| | | import cn.gistack.system.cache.DictCache; |
| | | import cn.gistack.system.cache.ParamCache; |
| | | import cn.gistack.system.cache.SysCache; |
| | | import cn.gistack.system.entity.Tenant; |
| | | import cn.gistack.system.enums.DictEnum; |
| | | import cn.gistack.system.feign.ISysClient; |
| | | import cn.gistack.system.user.cache.UserCache; |
| | | import cn.gistack.system.user.entity.*; |
| | | import cn.gistack.system.user.enums.UserEnum; |
| | | import cn.gistack.system.user.excel.UserExcel; |
| | | import cn.gistack.system.user.mapper.UserMapper; |
| | | import cn.gistack.system.user.service.IUserDeptService; |
| | | import cn.gistack.system.user.service.IUserOauthService; |
| | | import cn.gistack.system.user.service.IUserService; |
| | | import cn.gistack.system.user.vo.UserVO; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import lombok.AllArgsConstructor; |
| | | import cn.gistack.common.constant.CommonConstant; |
| | | import cn.gistack.common.constant.TenantConstant; |
| | | import org.gistack.system.user.entity.*; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.mp.base.BaseServiceImpl; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tenant.BladeTenantProperties; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.constant.BladeConstant; |
| | | import org.springblade.core.tool.jackson.JsonUtil; |
| | | import org.springblade.core.tool.support.Kv; |
| | | import org.springblade.core.tool.utils.*; |
| | | import org.springblade.system.user.entity.*; |
| | | import cn.gistack.system.user.wrapper.UserWrapper; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | import static cn.gistack.common.constant.CommonConstant.DEFAULT_PARAM_PASSWORD; |
| | | |
| | | /** |
| | | * 服务实现类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implements IUserService { |
| | | private static final String GUEST_NAME = "guest"; |
| | | |
| | | private final IUserDeptService userDeptService; |
| | | private final IUserOauthService userOauthService; |
| | | private final ISysClient sysClient; |
| | | private final BladeTenantProperties tenantProperties; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean submit(User user) { |
| | | if (StringUtil.isBlank(user.getTenantId())) { |
| | | user.setTenantId(BladeConstant.ADMIN_TENANT_ID); |
| | | } |
| | | String tenantId = user.getTenantId(); |
| | | Tenant tenant = SysCache.getTenant(tenantId); |
| | | if (Func.isNotEmpty(tenant)) { |
| | | Integer accountNumber = tenant.getAccountNumber(); |
| | | if (tenantProperties.getLicense()) { |
| | | String licenseKey = tenant.getLicenseKey(); |
| | | String decrypt = DesUtil.decryptFormHex(licenseKey, TenantConstant.DES_KEY); |
| | | accountNumber = JsonUtil.parse(decrypt, Tenant.class).getAccountNumber(); |
| | | } |
| | | Long tenantCount = baseMapper.selectCount(Wrappers.<User>query().lambda().eq(User::getTenantId, tenantId)); |
| | | if (accountNumber != null && accountNumber > 0 && accountNumber <= tenantCount) { |
| | | throw new ServiceException("当前租户已到最大账号额度!"); |
| | | } |
| | | } |
| | | if (Func.isNotEmpty(user.getPassword())) { |
| | | user.setPassword(DigestUtil.encrypt(user.getPassword())); |
| | | } |
| | | Long userCount = baseMapper.selectCount(Wrappers.<User>query().lambda().eq(User::getTenantId, tenantId).eq(User::getAccount, user.getAccount())); |
| | | if (userCount > 0L && Func.isEmpty(user.getId())) { |
| | | throw new ServiceException(StringUtil.format("当前用户 [{}] 已存在!", user.getAccount())); |
| | | } |
| | | return save(user) && submitUserDept(user); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean updateUser(User user) { |
| | | String tenantId = user.getTenantId(); |
| | | Long userCount = baseMapper.selectCount( |
| | | Wrappers.<User>query().lambda() |
| | | .eq(User::getTenantId, tenantId) |
| | | .eq(User::getAccount, user.getAccount()) |
| | | .notIn(User::getId, user.getId()) |
| | | ); |
| | | if (userCount > 0L) { |
| | | throw new ServiceException(StringUtil.format("当前用户 [{}] 已存在!", user.getAccount())); |
| | | } |
| | | return updateUserInfo(user) && submitUserDept(user); |
| | | } |
| | | |
| | | @Override |
| | | public boolean updateUserInfo(User user) { |
| | | user.setPassword(null); |
| | | return updateById(user); |
| | | } |
| | | |
| | | private boolean submitUserDept(User user) { |
| | | List<Long> deptIdList = Func.toLongList(user.getDeptId()); |
| | | List<UserDept> userDeptList = new ArrayList<>(); |
| | | deptIdList.forEach(deptId -> { |
| | | UserDept userDept = new UserDept(); |
| | | userDept.setUserId(user.getId()); |
| | | userDept.setDeptId(deptId); |
| | | userDeptList.add(userDept); |
| | | }); |
| | | userDeptService.remove(Wrappers.<UserDept>update().lambda().eq(UserDept::getUserId, user.getId())); |
| | | return userDeptService.saveBatch(userDeptList); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<User> selectUserPage(IPage<User> page, User user, Long deptId, String tenantId) { |
| | | List<Long> deptIdList = SysCache.getDeptChildIds(deptId); |
| | | return page.setRecords(baseMapper.selectUserPage(page, user, deptIdList, tenantId)); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<UserVO> selectUserSearch(UserVO user, Query query) { |
| | | LambdaQueryWrapper<User> queryWrapper = Wrappers.<User>query().lambda(); |
| | | String tenantId = AuthUtil.getTenantId(); |
| | | if (StringUtil.isNotBlank(tenantId)) { |
| | | queryWrapper.eq(User::getTenantId, tenantId); |
| | | } |
| | | if (StringUtil.isNotBlank(user.getName())) { |
| | | queryWrapper.like(User::getName, user.getName()); |
| | | } |
| | | if (StringUtil.isNotBlank(user.getDeptName())) { |
| | | String deptIds = SysCache.getDeptIdsByFuzzy(AuthUtil.getTenantId(), user.getDeptName()); |
| | | if (StringUtil.isNotBlank(deptIds)) { |
| | | queryWrapper.and(wrapper -> { |
| | | List<String> ids = Func.toStrList(deptIds); |
| | | ids.forEach(id -> wrapper.like(User::getDeptId, id).or()); |
| | | }); |
| | | } |
| | | } |
| | | if (StringUtil.isNotBlank(user.getPostName())) { |
| | | String postIds = SysCache.getPostIdsByFuzzy(AuthUtil.getTenantId(), user.getPostName()); |
| | | if (StringUtil.isNotBlank(postIds)) { |
| | | queryWrapper.and(wrapper -> { |
| | | List<String> ids = Func.toStrList(postIds); |
| | | ids.forEach(id -> wrapper.like(User::getPostId, id).or()); |
| | | }); |
| | | } |
| | | } |
| | | IPage<User> pages = this.page(Condition.getPage(query), queryWrapper); |
| | | return UserWrapper.build().pageVO(pages); |
| | | } |
| | | |
| | | @Override |
| | | public User userByAccount(String tenantId, String account) { |
| | | return baseMapper.selectOne(Wrappers.<User>query().lambda().eq(User::getTenantId, tenantId).eq(User::getAccount, account).eq(User::getIsDeleted, BladeConstant.DB_NOT_DELETED)); |
| | | } |
| | | |
| | | @Override |
| | | public UserInfo userInfo(Long userId) { |
| | | User user = baseMapper.selectById(userId); |
| | | return buildUserInfo(user); |
| | | } |
| | | |
| | | @Override |
| | | public UserInfo userInfo(String tenantId, String account) { |
| | | User user = baseMapper.getUser(tenantId, account); |
| | | return buildUserInfo(user); |
| | | } |
| | | |
| | | @Override |
| | | public UserInfo userInfo(String tenantId, String account, UserEnum userEnum) { |
| | | User user = baseMapper.getUser(tenantId, account); |
| | | return buildUserInfo(user, userEnum); |
| | | } |
| | | |
| | | private UserInfo buildUserInfo(User user) { |
| | | return buildUserInfo(user, UserEnum.WEB); |
| | | } |
| | | |
| | | private UserInfo buildUserInfo(User user, UserEnum userEnum) { |
| | | if (ObjectUtil.isEmpty(user)) { |
| | | return null; |
| | | } |
| | | UserInfo userInfo = new UserInfo(); |
| | | userInfo.setUser(user); |
| | | if (Func.isNotEmpty(user)) { |
| | | R<List<String>> result = sysClient.getRoleAliases(user.getRoleId()); |
| | | if (result.isSuccess()) { |
| | | List<String> roleAlias = result.getData(); |
| | | userInfo.setRoles(roleAlias); |
| | | } |
| | | } |
| | | // 根据每个用户平台,建立对应的detail表,通过查询将结果集写入到detail字段 |
| | | Kv detail = Kv.create().set("type", userEnum.getName()); |
| | | if (userEnum == UserEnum.WEB) { |
| | | UserWeb userWeb = new UserWeb(); |
| | | UserWeb query = userWeb.selectOne(Wrappers.<UserWeb>lambdaQuery().eq(UserWeb::getUserId, user.getId())); |
| | | if (ObjectUtil.isNotEmpty(query)) { |
| | | detail.set("ext", query.getUserExt()); |
| | | } |
| | | } else if (userEnum == UserEnum.APP) { |
| | | UserApp userApp = new UserApp(); |
| | | UserApp query = userApp.selectOne(Wrappers.<UserApp>lambdaQuery().eq(UserApp::getUserId, user.getId())); |
| | | if (ObjectUtil.isNotEmpty(query)) { |
| | | detail.set("ext", query.getUserExt()); |
| | | } |
| | | } else { |
| | | UserOther userOther = new UserOther(); |
| | | UserOther query = userOther.selectOne(Wrappers.<UserOther>lambdaQuery().eq(UserOther::getUserId, user.getId())); |
| | | if (ObjectUtil.isNotEmpty(query)) { |
| | | detail.set("ext", query.getUserExt()); |
| | | } |
| | | } |
| | | userInfo.setDetail(detail); |
| | | return userInfo; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public UserInfo userInfo(UserOauth userOauth) { |
| | | UserOauth uo = userOauthService.getOne(Wrappers.<UserOauth>query().lambda().eq(UserOauth::getUuid, userOauth.getUuid()).eq(UserOauth::getSource, userOauth.getSource())); |
| | | UserInfo userInfo; |
| | | if (Func.isNotEmpty(uo) && Func.isNotEmpty(uo.getUserId())) { |
| | | userInfo = this.userInfo(uo.getUserId()); |
| | | userInfo.setOauthId(Func.toStr(uo.getId())); |
| | | } else { |
| | | userInfo = new UserInfo(); |
| | | if (Func.isEmpty(uo)) { |
| | | userOauthService.save(userOauth); |
| | | userInfo.setOauthId(Func.toStr(userOauth.getId())); |
| | | } else { |
| | | userInfo.setOauthId(Func.toStr(uo.getId())); |
| | | } |
| | | User user = new User(); |
| | | user.setAccount(userOauth.getUsername()); |
| | | user.setTenantId(userOauth.getTenantId()); |
| | | userInfo.setUser(user); |
| | | userInfo.setRoles(Collections.singletonList(GUEST_NAME)); |
| | | } |
| | | return userInfo; |
| | | } |
| | | |
| | | @Override |
| | | public boolean grant(String userIds, String roleIds) { |
| | | User user = new User(); |
| | | user.setRoleId(roleIds); |
| | | return this.update(user, Wrappers.<User>update().lambda().in(User::getId, Func.toLongList(userIds))); |
| | | } |
| | | |
| | | @Override |
| | | public boolean resetPassword(String userIds) { |
| | | User user = new User(); |
| | | user.setPassword(DigestUtil.encrypt(CommonConstant.DEFAULT_PASSWORD)); |
| | | user.setUpdateTime(DateUtil.now()); |
| | | return this.update(user, Wrappers.<User>update().lambda().in(User::getId, Func.toLongList(userIds))); |
| | | } |
| | | |
| | | @Override |
| | | public boolean updatePassword(Long userId, String oldPassword, String newPassword, String newPassword1) { |
| | | User user = getById(userId); |
| | | if (!newPassword.equals(newPassword1)) { |
| | | throw new ServiceException("请输入正确的确认密码!"); |
| | | } |
| | | if (!user.getPassword().equals(DigestUtil.hex(oldPassword))) { |
| | | throw new ServiceException("原密码不正确!"); |
| | | } |
| | | return this.update(Wrappers.<User>update().lambda().set(User::getPassword, DigestUtil.hex(newPassword)).eq(User::getId, userId)); |
| | | } |
| | | |
| | | @Override |
| | | public boolean removeUser(String userIds) { |
| | | if (Func.contains(Func.toLongArray(userIds), AuthUtil.getUserId())) { |
| | | throw new ServiceException("不能删除本账号!"); |
| | | } |
| | | return deleteLogic(Func.toLongList(userIds)); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void importUser(List<UserExcel> data, Boolean isCovered) { |
| | | data.forEach(userExcel -> { |
| | | User user = Objects.requireNonNull(BeanUtil.copy(userExcel, User.class)); |
| | | // 设置用户平台 |
| | | user.setUserType(Func.toInt(DictCache.getKey(DictEnum.USER_TYPE, userExcel.getUserTypeName()), 1)); |
| | | // 设置部门ID |
| | | user.setDeptId(Func.toStrWithEmpty(SysCache.getDeptIds(userExcel.getTenantId(), userExcel.getDeptName()), StringPool.EMPTY)); |
| | | // 设置岗位ID |
| | | user.setPostId(Func.toStrWithEmpty(SysCache.getPostIds(userExcel.getTenantId(), userExcel.getPostName()), StringPool.EMPTY)); |
| | | // 设置角色ID |
| | | user.setRoleId(Func.toStrWithEmpty(SysCache.getRoleIds(userExcel.getTenantId(), userExcel.getRoleName()), StringPool.EMPTY)); |
| | | // 设置租户ID |
| | | if (!AuthUtil.isAdministrator() || StringUtil.isBlank(user.getTenantId())) { |
| | | user.setTenantId(AuthUtil.getTenantId()); |
| | | } |
| | | // 覆盖数据 |
| | | if (isCovered) { |
| | | // 查询用户是否存在 |
| | | User oldUser = UserCache.getUser(userExcel.getTenantId(), userExcel.getAccount()); |
| | | if (oldUser != null && oldUser.getId() != null) { |
| | | user.setId(oldUser.getId()); |
| | | this.updateUser(user); |
| | | return; |
| | | } |
| | | } |
| | | // 获取默认密码配置 |
| | | String initPassword = ParamCache.getValue(DEFAULT_PARAM_PASSWORD); |
| | | user.setPassword(initPassword); |
| | | this.submit(user); |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public List<UserExcel> exportUser(Wrapper<User> queryWrapper) { |
| | | List<UserExcel> userList = baseMapper.exportUser(queryWrapper); |
| | | userList.forEach(user -> { |
| | | user.setUserTypeName(DictCache.getValue(DictEnum.USER_TYPE, user.getUserType())); |
| | | user.setRoleName(StringUtil.join(SysCache.getRoleNames(user.getRoleId()))); |
| | | user.setDeptName(StringUtil.join(SysCache.getDeptNames(user.getDeptId()))); |
| | | user.setPostName(StringUtil.join(SysCache.getPostNames(user.getPostId()))); |
| | | }); |
| | | return userList; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean registerGuest(User user, Long oauthId) { |
| | | Tenant tenant = SysCache.getTenant(user.getTenantId()); |
| | | if (tenant == null || tenant.getId() == null) { |
| | | throw new ServiceException("租户信息错误!"); |
| | | } |
| | | UserOauth userOauth = userOauthService.getById(oauthId); |
| | | if (userOauth == null || userOauth.getId() == null) { |
| | | throw new ServiceException("第三方登陆信息错误!"); |
| | | } |
| | | user.setRealName(user.getName()); |
| | | user.setAvatar(userOauth.getAvatar()); |
| | | user.setRoleId(StringPool.MINUS_ONE); |
| | | user.setDeptId(StringPool.MINUS_ONE); |
| | | user.setPostId(StringPool.MINUS_ONE); |
| | | boolean userTemp = this.submit(user); |
| | | userOauth.setUserId(user.getId()); |
| | | userOauth.setTenantId(user.getTenantId()); |
| | | boolean oauthTemp = userOauthService.updateById(userOauth); |
| | | return (userTemp && oauthTemp); |
| | | } |
| | | @Override |
| | | public boolean updatePlatform(Long userId, Integer userType, String userExt) { |
| | | if (userType.equals(UserEnum.WEB.getCategory())) { |
| | | UserWeb userWeb = new UserWeb(); |
| | | UserWeb query = userWeb.selectOne(Wrappers.<UserWeb>lambdaQuery().eq(UserWeb::getUserId, userId)); |
| | | if (ObjectUtil.isNotEmpty(query)) { |
| | | userWeb.setId(query.getId()); |
| | | } |
| | | userWeb.setUserId(userId); |
| | | userWeb.setUserExt(userExt); |
| | | return userWeb.insertOrUpdate(); |
| | | } else if (userType.equals(UserEnum.APP.getCategory())) { |
| | | UserApp userApp = new UserApp(); |
| | | UserApp query = userApp.selectOne(Wrappers.<UserApp>lambdaQuery().eq(UserApp::getUserId, userId)); |
| | | if (ObjectUtil.isNotEmpty(query)) { |
| | | userApp.setId(query.getId()); |
| | | } |
| | | userApp.setUserId(userId); |
| | | userApp.setUserExt(userExt); |
| | | return userApp.insertOrUpdate(); |
| | | } else { |
| | | UserOther userOther = new UserOther(); |
| | | UserOther query = userOther.selectOne(Wrappers.<UserOther>lambdaQuery().eq(UserOther::getUserId, userId)); |
| | | if (ObjectUtil.isNotEmpty(query)) { |
| | | userOther.setId(query.getId()); |
| | | } |
| | | userOther.setUserId(userId); |
| | | userOther.setUserExt(userExt); |
| | | return userOther.insertOrUpdate(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public UserVO platformDetail(User user) { |
| | | User detail = baseMapper.selectOne(Condition.getQueryWrapper(user)); |
| | | UserVO userVO = UserWrapper.build().entityVO(detail); |
| | | if (userVO.getUserType().equals(UserEnum.WEB.getCategory())) { |
| | | UserWeb userWeb = new UserWeb(); |
| | | UserWeb query = userWeb.selectOne(Wrappers.<UserWeb>lambdaQuery().eq(UserWeb::getUserId, user.getId())); |
| | | if (ObjectUtil.isNotEmpty(query)) { |
| | | userVO.setUserExt(query.getUserExt()); |
| | | } |
| | | } else if (userVO.getUserType().equals(UserEnum.APP.getCategory())) { |
| | | UserApp userApp = new UserApp(); |
| | | UserApp query = userApp.selectOne(Wrappers.<UserApp>lambdaQuery().eq(UserApp::getUserId, user.getId())); |
| | | if (ObjectUtil.isNotEmpty(query)) { |
| | | userVO.setUserExt(query.getUserExt()); |
| | | } |
| | | } else { |
| | | UserOther userOther = new UserOther(); |
| | | UserOther query = userOther.selectOne(Wrappers.<UserOther>lambdaQuery().eq(UserOther::getUserId, user.getId())); |
| | | if (ObjectUtil.isNotEmpty(query)) { |
| | | userVO.setUserExt(query.getUserExt()); |
| | | } |
| | | } |
| | | return userVO; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.system.user.wrapper; |
| | | |
| | | import cn.gistack.system.cache.DictCache; |
| | | import cn.gistack.system.cache.SysCache; |
| | | import cn.gistack.system.entity.Tenant; |
| | | import cn.gistack.system.enums.DictEnum; |
| | | import cn.gistack.system.user.entity.User; |
| | | import cn.gistack.system.user.vo.UserVO; |
| | | import org.springblade.core.mp.support.BaseEntityWrapper; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 包装类,返回视图层所需的字段 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class UserWrapper extends BaseEntityWrapper<User, UserVO> { |
| | | |
| | | public static UserWrapper build() { |
| | | return new UserWrapper(); |
| | | } |
| | | |
| | | @Override |
| | | public UserVO entityVO(User user) { |
| | | UserVO userVO = Objects.requireNonNull(BeanUtil.copy(user, UserVO.class)); |
| | | Tenant tenant = SysCache.getTenant(user.getTenantId()); |
| | | List<String> roleName = SysCache.getRoleNames(user.getRoleId()); |
| | | List<String> deptName = SysCache.getDeptNames(user.getDeptId()); |
| | | List<String> postName = SysCache.getPostNames(user.getPostId()); |
| | | userVO.setTenantName(tenant.getTenantName()); |
| | | userVO.setRoleName(Func.join(roleName)); |
| | | userVO.setDeptName(Func.join(deptName)); |
| | | userVO.setPostName(Func.join(postName)); |
| | | userVO.setSexName(DictCache.getValue(DictEnum.SEX, user.getSex())); |
| | | userVO.setUserTypeName(DictCache.getValue(DictEnum.USER_TYPE, user.getUserType())); |
| | | return userVO; |
| | | } |
| | | |
| | | } |