diff --git a/LICENSE b/LICENSE
index ef4e4debf19abe5e0bb637f14115da5d1cd82de8..55336630441382e0aec517872f7ee356c33f6753 100644
--- a/LICENSE
+++ b/LICENSE
@@ -176,7 +176,7 @@ recommend that a file or class name and description of purpose be included on
the same "printed page" as the copyright notice for easier identification within
third-party archives.
- Copyright 2019 smallchill
+ Copyright 2020 BladeX (https://bladex.vip)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/README.md b/README.md
index b8a3edfb4f54ee6385dd86be8dccca6c7dee56d9..4311957cde096ca6528ddcae117c0434aaaa1106 100644
--- a/README.md
+++ b/README.md
@@ -1,31 +1,32 @@
-## 简介
-* SpringBlade 2.0 是如梦技术团队作品,是一个基于 Spring Boot 2 & Spring Cloud Finchley & Mybatis 等核心技术,用于快速构建中大型系统的基础框架。
-* SpringBlade 致力于创造新颖的开发模式,将开发中遇到的痛点、生产中所踩的坑整理归纳,并将解决方案都融合到框架中。
-
-## 官网
-官网地址:[https://bladex.vip](https://bladex.vip)
-
-## 在线演示
-演示地址:[https://sword.bladex.vip](https://sword.bladex.vip)
-
-## 主要特性&&变化
-* 采用前后端分离的模式,前端单独开源出一个框架:[Sword](https://gitee.com/smallc/Sword),主要选型技术为React、Ant Design、Umi、Dva
-* 后端采用SpringCloud全家桶,并同时对其基础组件做了高度的封装,单独开源出一个框架:[Blade-Tool](https://github.com/chillzhuang/blade-tool.git)
-* [Blade-Tool](https://github.com/chillzhuang/blade-tool.git)已推送至Maven中央库,直接引入即可,减少了工程的臃肿,也可更注重于业务开发
-* 集成Sentinel从流量控制、熔断降级、系统负载保护等多个维度保护服务的稳定性。
+
+ * 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
+ *
+ * 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 org.springblade.auth.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+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.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;
+
+/**
+ * 第三方登陆端点
+ *
+ * @author Chill
+ */
+@Slf4j
+@RestController
+@AllArgsConstructor
+@ConditionalOnProperty(value = "social.enabled", havingValue = "true")
+@Api(value = "第三方登陆", tags = "第三方登陆端点")
+public class SocialController {
+
+ private final SocialProperties socialProperties;
+
+ /**
+ * 授权完毕跳转
+ */
+ @ApiOperation(value = "授权完毕跳转")
+ @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);
+ }
+
+ /**
+ * 获取认证信息
+ */
+ @ApiOperation(value = "获取认证信息")
+ @RequestMapping("/oauth/callback/{source}")
+ public Object login(@PathVariable("source") String source, AuthCallback callback) {
+ AuthRequest authRequest = SocialUtil.getAuthRequest(source, socialProperties);
+ return authRequest.login(callback);
+ }
+
+ /**
+ * 撤销授权
+ */
+ @ApiOperation(value = "撤销授权")
+ @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());
+ }
+
+ /**
+ * 续期accessToken
+ */
+ @ApiOperation(value = "续期令牌")
+ @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());
+ }
+
+
+}
diff --git a/blade-auth/src/main/java/org/springblade/auth/enums/BladeUserEnum.java b/blade-auth/src/main/java/org/springblade/auth/enums/BladeUserEnum.java
new file mode 100644
index 0000000000000000000000000000000000000000..4d0d538a603b34875913f3dd9f92b1d0ea61e72f
--- /dev/null
+++ b/blade-auth/src/main/java/org/springblade/auth/enums/BladeUserEnum.java
@@ -0,0 +1,44 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * 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
+ *
+ * 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 org.springblade.auth.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * 用户类型枚举
+ *
+ * @author Chill
+ */
+@Getter
+@AllArgsConstructor
+public enum BladeUserEnum {
+
+ /**
+ * web
+ */
+ WEB("web", 1),
+
+ /**
+ * app
+ */
+ APP("app", 2),
+ ;
+
+ final String name;
+ final int category;
+
+}
diff --git a/blade-auth/src/main/java/org/springblade/auth/granter/CaptchaTokenGranter.java b/blade-auth/src/main/java/org/springblade/auth/granter/CaptchaTokenGranter.java
new file mode 100644
index 0000000000000000000000000000000000000000..a3d9e7ca54af7f1e0af836babf430bdb50efbd13
--- /dev/null
+++ b/blade-auth/src/main/java/org/springblade/auth/granter/CaptchaTokenGranter.java
@@ -0,0 +1,79 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * 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
+ *
+ * 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 org.springblade.auth.granter;
+
+import lombok.AllArgsConstructor;
+import org.springblade.auth.enums.BladeUserEnum;
+import org.springblade.auth.utils.TokenUtil;
+import org.springblade.common.cache.CacheNames;
+import org.springblade.core.log.exception.ServiceException;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.*;
+import org.springblade.system.user.entity.UserInfo;
+import org.springblade.system.user.feign.IUserClient;
+import org.springframework.stereotype.Component;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * 验证码TokenGranter
+ *
+ * @author Chill
+ */
+@Component
+@AllArgsConstructor
+public class CaptchaTokenGranter implements ITokenGranter {
+
+ public static final String GRANT_TYPE = "captcha";
+
+ private IUserClient userClient;
+ private RedisUtil redisUtil;
+
+ @Override
+ public UserInfo grant(TokenParameter tokenParameter) {
+ HttpServletRequest request = WebUtil.getRequest();
+
+ String key = request.getHeader(TokenUtil.CAPTCHA_HEADER_KEY);
+ String code = request.getHeader(TokenUtil.CAPTCHA_HEADER_CODE);
+ // 获取验证码
+ String redisCode = String.valueOf(redisUtil.get(CacheNames.CAPTCHA_KEY + key));
+ // 判断验证码
+ if (code == null || !StringUtil.equalsIgnoreCase(redisCode, code)) {
+ throw new ServiceException(TokenUtil.CAPTCHA_NOT_CORRECT);
+ }
+
+ String tenantId = tokenParameter.getArgs().getStr("tenantId");
+ String account = tokenParameter.getArgs().getStr("account");
+ String password = tokenParameter.getArgs().getStr("password");
+ UserInfo userInfo = null;
+ if (Func.isNoneBlank(account, password)) {
+ // 获取用户类型
+ String userType = tokenParameter.getArgs().getStr("userType");
+ R result;
+ // 根据不同用户类型调用对应的接口返回数据,用户可自行拓展
+ if (userType.equals(BladeUserEnum.WEB.getName())) {
+ result = userClient.userInfo(tenantId, account, DigestUtil.encrypt(password));
+ } else if (userType.equals(BladeUserEnum.APP.getName())) {
+ result = userClient.userInfo(tenantId, account, DigestUtil.encrypt(password));
+ } else {
+ result = userClient.userInfo(tenantId, account, DigestUtil.encrypt(password));
+ }
+ userInfo = result.isSuccess() ? result.getData() : null;
+ }
+ return userInfo;
+ }
+
+}
diff --git a/blade-auth/src/main/java/org/springblade/auth/granter/ITokenGranter.java b/blade-auth/src/main/java/org/springblade/auth/granter/ITokenGranter.java
new file mode 100644
index 0000000000000000000000000000000000000000..b2ec7318087a646d52673b4ba58d2d51793722e9
--- /dev/null
+++ b/blade-auth/src/main/java/org/springblade/auth/granter/ITokenGranter.java
@@ -0,0 +1,36 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * 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
+ *
+ * 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 org.springblade.auth.granter;
+
+
+import org.springblade.system.user.entity.UserInfo;
+
+/**
+ * 授权认证统一接口.
+ *
+ * @author Chill
+ */
+public interface ITokenGranter {
+
+ /**
+ * 获取用户信息
+ *
+ * @param tokenParameter 授权参数
+ * @return UserInfo
+ */
+ UserInfo grant(TokenParameter tokenParameter);
+
+}
diff --git a/blade-gateway/src/main/java/org/springblade/gateway/handler/SwaggerSecurityHandler.java b/blade-auth/src/main/java/org/springblade/auth/granter/PasswordTokenGranter.java
similarity index 32%
rename from blade-gateway/src/main/java/org/springblade/gateway/handler/SwaggerSecurityHandler.java
rename to blade-auth/src/main/java/org/springblade/auth/granter/PasswordTokenGranter.java
index 59a3039f614166583cd486545c3f8bb57888f802..9572a6a56512f0215c8fdeae5b9da0009979f16a 100644
--- a/blade-gateway/src/main/java/org/springblade/gateway/handler/SwaggerSecurityHandler.java
+++ b/blade-auth/src/main/java/org/springblade/auth/granter/PasswordTokenGranter.java
@@ -13,47 +13,51 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+package org.springblade.auth.granter;
-package org.springblade.gateway.handler;
-
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.MediaType;
+import lombok.AllArgsConstructor;
+import org.springblade.auth.enums.BladeUserEnum;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.DigestUtil;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.system.user.entity.UserInfo;
+import org.springblade.system.user.feign.IUserClient;
import org.springframework.stereotype.Component;
-import org.springframework.web.reactive.function.BodyInserters;
-import org.springframework.web.reactive.function.server.HandlerFunction;
-import org.springframework.web.reactive.function.server.ServerRequest;
-import org.springframework.web.reactive.function.server.ServerResponse;
-import reactor.core.publisher.Mono;
-import springfox.documentation.swagger.web.SecurityConfiguration;
-import springfox.documentation.swagger.web.SecurityConfigurationBuilder;
-
-import java.util.Optional;
/**
- * SwaggerSecurityHandler
+ * PasswordTokenGranter
*
- * @author lengleng
+ * @author Chill
*/
-@Slf4j
@Component
-public class SwaggerSecurityHandler implements HandlerFunction {
- @Autowired(required = false)
- private SecurityConfiguration securityConfiguration;
+@AllArgsConstructor
+public class PasswordTokenGranter implements ITokenGranter {
+
+ public static final String GRANT_TYPE = "password";
+
+ private IUserClient userClient;
- /**
- * Handle the given request.
- *
- * @param request the request to handler
- * @return the response
- */
@Override
- public Mono handle(ServerRequest request) {
- return ServerResponse.status(HttpStatus.OK)
- .contentType(MediaType.APPLICATION_JSON_UTF8)
- .body(BodyInserters.fromObject(
- Optional.ofNullable(securityConfiguration)
- .orElse(SecurityConfigurationBuilder.builder().build())));
+ public UserInfo grant(TokenParameter tokenParameter) {
+ String tenantId = tokenParameter.getArgs().getStr("tenantId");
+ String account = tokenParameter.getArgs().getStr("account");
+ String password = tokenParameter.getArgs().getStr("password");
+ UserInfo userInfo = null;
+ if (Func.isNoneBlank(account, password)) {
+ // 获取用户类型
+ String userType = tokenParameter.getArgs().getStr("userType");
+ R result;
+ // 根据不同用户类型调用对应的接口返回数据,用户可自行拓展
+ if (userType.equals(BladeUserEnum.WEB.getName())) {
+ result = userClient.userInfo(tenantId, account, DigestUtil.encrypt(password));
+ } else if (userType.equals(BladeUserEnum.APP.getName())) {
+ result = userClient.userInfo(tenantId, account, DigestUtil.encrypt(password));
+ } else {
+ result = userClient.userInfo(tenantId, account, DigestUtil.encrypt(password));
+ }
+ userInfo = result.isSuccess() ? result.getData() : null;
+ }
+ return userInfo;
}
+
}
diff --git a/blade-gateway/src/main/java/org/springblade/gateway/handler/SwaggerResourceHandler.java b/blade-auth/src/main/java/org/springblade/auth/granter/RefreshTokenGranter.java
similarity index 37%
rename from blade-gateway/src/main/java/org/springblade/gateway/handler/SwaggerResourceHandler.java
rename to blade-auth/src/main/java/org/springblade/auth/granter/RefreshTokenGranter.java
index c1c5e29277b9a7e068395888db094df9a74032a6..95fd95fe17727341e3328be1dad4c477bd870b9c 100644
--- a/blade-gateway/src/main/java/org/springblade/gateway/handler/SwaggerResourceHandler.java
+++ b/blade-auth/src/main/java/org/springblade/auth/granter/RefreshTokenGranter.java
@@ -13,42 +13,46 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+package org.springblade.auth.granter;
-package org.springblade.gateway.handler;
-
+import io.jsonwebtoken.Claims;
import lombok.AllArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.MediaType;
+import org.springblade.core.launch.constant.TokenConstant;
+import org.springblade.core.secure.utils.SecureUtil;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.system.user.entity.UserInfo;
+import org.springblade.system.user.feign.IUserClient;
import org.springframework.stereotype.Component;
-import org.springframework.web.reactive.function.BodyInserters;
-import org.springframework.web.reactive.function.server.HandlerFunction;
-import org.springframework.web.reactive.function.server.ServerRequest;
-import org.springframework.web.reactive.function.server.ServerResponse;
-import reactor.core.publisher.Mono;
-import springfox.documentation.swagger.web.SwaggerResourcesProvider;
+
+import java.util.Objects;
/**
- * SwaggerResourceHandler
+ * RefreshTokenGranter
*
- * @author lengleng
+ * @author Chill
*/
-@Slf4j
@Component
@AllArgsConstructor
-public class SwaggerResourceHandler implements HandlerFunction {
- private final SwaggerResourcesProvider swaggerResources;
+public class RefreshTokenGranter implements ITokenGranter {
+
+ public static final String GRANT_TYPE = "refresh_token";
+
+ private IUserClient userClient;
- /**
- * Handle the given request.
- *
- * @param request the request to handler
- * @return the response
- */
@Override
- public Mono handle(ServerRequest request) {
- return ServerResponse.status(HttpStatus.OK)
- .contentType(MediaType.APPLICATION_JSON_UTF8)
- .body(BodyInserters.fromObject(swaggerResources.get()));
+ public UserInfo grant(TokenParameter tokenParameter) {
+ String grantType = tokenParameter.getArgs().getStr("grantType");
+ String refreshToken = tokenParameter.getArgs().getStr("refreshToken");
+ UserInfo userInfo = null;
+ if (Func.isNoneBlank(grantType, refreshToken) && grantType.equals(TokenConstant.REFRESH_TOKEN)) {
+ Claims claims = SecureUtil.parseJWT(refreshToken);
+ String tokenType = Func.toStr(Objects.requireNonNull(claims).get(TokenConstant.TOKEN_TYPE));
+ if (tokenType.equals(TokenConstant.REFRESH_TOKEN)) {
+ R result = userClient.userInfo(Func.toLong(claims.get(TokenConstant.USER_ID)));
+ userInfo = result.isSuccess() ? result.getData() : null;
+ }
+ }
+ return userInfo;
}
}
diff --git a/blade-auth/src/main/java/org/springblade/auth/granter/SocialTokenGranter.java b/blade-auth/src/main/java/org/springblade/auth/granter/SocialTokenGranter.java
new file mode 100644
index 0000000000000000000000000000000000000000..905312d6040eed1373d680a599907781095e47f4
--- /dev/null
+++ b/blade-auth/src/main/java/org/springblade/auth/granter/SocialTokenGranter.java
@@ -0,0 +1,91 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * 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
+ *
+ * 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 org.springblade.auth.granter;
+
+import lombok.AllArgsConstructor;
+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 org.springblade.auth.utils.TokenUtil;
+import org.springblade.core.log.exception.ServiceException;
+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.utils.BeanUtil;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.core.tool.utils.WebUtil;
+import org.springblade.system.user.entity.UserInfo;
+import org.springblade.system.user.entity.UserOauth;
+import org.springblade.system.user.feign.IUserClient;
+import org.springframework.stereotype.Component;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Objects;
+
+/**
+ * SocialTokenGranter
+ *
+ * @author Chill
+ */
+@Component
+@AllArgsConstructor
+public class SocialTokenGranter implements ITokenGranter {
+
+ public static final String GRANT_TYPE = "social";
+
+ private static final Integer AUTH_SUCCESS_CODE = 2000;
+
+ private final IUserClient userClient;
+ private final SocialProperties socialProperties;
+
+ @Override
+ public UserInfo grant(TokenParameter tokenParameter) {
+ HttpServletRequest request = WebUtil.getRequest();
+ String tenantId = Func.toStr(request.getHeader(TokenUtil.TENANT_HEADER_KEY), TokenUtil.DEFAULT_TENANT_ID);
+ // 开放平台来源
+ String sourceParameter = request.getParameter("source");
+ // 匹配是否有别名定义
+ String source = socialProperties.getAlias().getOrDefault(sourceParameter, sourceParameter);
+ // 开放平台授权码
+ String code = request.getParameter("code");
+ // 开放平台状态吗
+ String state = request.getParameter("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 ServiceException("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 result = userClient.userAuthInfo(userOauth);
+ return result.getData();
+ }
+
+}
diff --git a/blade-auth/src/main/java/org/springblade/auth/granter/TokenGranterBuilder.java b/blade-auth/src/main/java/org/springblade/auth/granter/TokenGranterBuilder.java
new file mode 100644
index 0000000000000000000000000000000000000000..e8700f7d1d41964804c45dcd9a04b0ef1e4cf87b
--- /dev/null
+++ b/blade-auth/src/main/java/org/springblade/auth/granter/TokenGranterBuilder.java
@@ -0,0 +1,61 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * 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
+ *
+ * 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 org.springblade.auth.granter;
+
+import lombok.AllArgsConstructor;
+import org.springblade.core.secure.exception.SecureException;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.core.tool.utils.SpringUtil;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * TokenGranterBuilder
+ *
+ * @author Chill
+ */
+@AllArgsConstructor
+public class TokenGranterBuilder {
+
+ /**
+ * TokenGranter缓存池
+ */
+ private static final Map GRANTER_POOL = new ConcurrentHashMap<>();
+
+ static {
+ GRANTER_POOL.put(PasswordTokenGranter.GRANT_TYPE, SpringUtil.getBean(PasswordTokenGranter.class));
+ GRANTER_POOL.put(CaptchaTokenGranter.GRANT_TYPE, SpringUtil.getBean(CaptchaTokenGranter.class));
+ GRANTER_POOL.put(RefreshTokenGranter.GRANT_TYPE, SpringUtil.getBean(RefreshTokenGranter.class));
+ GRANTER_POOL.put(SocialTokenGranter.GRANT_TYPE, SpringUtil.getBean(SocialTokenGranter.class));
+ }
+
+ /**
+ * 获取TokenGranter
+ *
+ * @param grantType 授权类型
+ * @return ITokenGranter
+ */
+ public static ITokenGranter getGranter(String grantType) {
+ ITokenGranter tokenGranter = GRANTER_POOL.get(Func.toStr(grantType, PasswordTokenGranter.GRANT_TYPE));
+ if (tokenGranter == null) {
+ throw new SecureException("no grantType was found");
+ } else {
+ return tokenGranter;
+ }
+ }
+
+}
diff --git a/blade-auth/src/main/java/org/springblade/auth/granter/TokenParameter.java b/blade-auth/src/main/java/org/springblade/auth/granter/TokenParameter.java
new file mode 100644
index 0000000000000000000000000000000000000000..368c83efbc1dcdd37e81ee94ff00f4fa5991f909
--- /dev/null
+++ b/blade-auth/src/main/java/org/springblade/auth/granter/TokenParameter.java
@@ -0,0 +1,31 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * 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
+ *
+ * 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 org.springblade.auth.granter;
+
+import lombok.Data;
+import org.springblade.core.tool.support.Kv;
+
+/**
+ * TokenParameter
+ *
+ * @author Chill
+ */
+@Data
+public class TokenParameter {
+
+ private Kv args = Kv.init();
+
+}
diff --git a/blade-auth/src/main/java/org/springblade/auth/utils/TokenUtil.java b/blade-auth/src/main/java/org/springblade/auth/utils/TokenUtil.java
new file mode 100644
index 0000000000000000000000000000000000000000..5de8370b2105f450ebe97c4828063c254fe57a6a
--- /dev/null
+++ b/blade-auth/src/main/java/org/springblade/auth/utils/TokenUtil.java
@@ -0,0 +1,100 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * 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
+ *
+ * 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
+ *
- * 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
- *
- * 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 org.springblade.gateway.config;
-
-
-import org.springblade.gateway.handler.ErrorExceptionHandler;
-import org.springframework.beans.factory.ObjectProvider;
-import org.springframework.boot.autoconfigure.web.ResourceProperties;
-import org.springframework.boot.autoconfigure.web.ServerProperties;
-import org.springframework.boot.context.properties.EnableConfigurationProperties;
-import org.springframework.boot.web.reactive.error.ErrorAttributes;
-import org.springframework.boot.web.reactive.error.ErrorWebExceptionHandler;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.core.Ordered;
-import org.springframework.core.annotation.Order;
-import org.springframework.http.codec.ServerCodecConfigurer;
-import org.springframework.web.reactive.result.view.ViewResolver;
-
-import java.util.Collections;
-import java.util.List;
-
-/**
- * 异常处理配置类
- *
- * @author Chill
- */
-@Configuration
-@EnableConfigurationProperties({ServerProperties.class, ResourceProperties.class})
-public class ErrorHandlerConfiguration {
-
- private final ServerProperties serverProperties;
-
- private final ApplicationContext applicationContext;
-
- private final ResourceProperties resourceProperties;
-
- private final List viewResolvers;
-
- private final ServerCodecConfigurer serverCodecConfigurer;
-
- public ErrorHandlerConfiguration(ServerProperties serverProperties,
- ResourceProperties resourceProperties,
- ObjectProvider> viewResolversProvider,
- ServerCodecConfigurer serverCodecConfigurer,
- ApplicationContext applicationContext) {
- this.serverProperties = serverProperties;
- this.applicationContext = applicationContext;
- this.resourceProperties = resourceProperties;
- this.viewResolvers = viewResolversProvider.getIfAvailable(Collections::emptyList);
- this.serverCodecConfigurer = serverCodecConfigurer;
- }
-
- @Bean
- @Order(Ordered.HIGHEST_PRECEDENCE)
- public ErrorWebExceptionHandler errorWebExceptionHandler(ErrorAttributes errorAttributes) {
- ErrorExceptionHandler exceptionHandler = new ErrorExceptionHandler(
- errorAttributes,
- this.resourceProperties,
- this.serverProperties.getError(),
- this.applicationContext);
- exceptionHandler.setViewResolvers(this.viewResolvers);
- exceptionHandler.setMessageWriters(this.serverCodecConfigurer.getWriters());
- exceptionHandler.setMessageReaders(this.serverCodecConfigurer.getReaders());
- return exceptionHandler;
- }
-
-}
diff --git a/blade-gateway/src/main/java/org/springblade/gateway/config/RouterFunctionConfiguration.java b/blade-gateway/src/main/java/org/springblade/gateway/config/RouterFunctionConfiguration.java
index 86a92552ead1b124c9efda34ac91be3c033a9587..784e4901cc8b666f981a15ce80067d941a34ed05 100644
--- a/blade-gateway/src/main/java/org/springblade/gateway/config/RouterFunctionConfiguration.java
+++ b/blade-gateway/src/main/java/org/springblade/gateway/config/RouterFunctionConfiguration.java
@@ -18,20 +18,16 @@ package org.springblade.gateway.config;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
-import org.springblade.gateway.handler.*;
+import org.springblade.gateway.props.AuthProperties;
+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.MediaType;
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.filter.reactive.HiddenHttpMethodFilter;
-import org.springframework.web.reactive.function.server.RequestPredicates;
-import org.springframework.web.reactive.function.server.RouterFunction;
-import org.springframework.web.reactive.function.server.RouterFunctions;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.WebFilter;
import org.springframework.web.server.WebFilterChain;
@@ -43,24 +39,23 @@ import reactor.core.publisher.Mono;
* @author Chill
*/
@Slf4j
-@Configuration
+@Configuration(proxyBeanMethods = false)
@AllArgsConstructor
+@EnableConfigurationProperties({AuthProperties.class})
public class RouterFunctionConfiguration {
/**
* 这里为支持的请求头,如果有自定义的header字段请自己添加
*/
- private static final String ALLOWED_HEADERS = "x-requested-with, blade-auth, Content-Type, Authorization, credential, X-XSRF-TOKEN, token, username, client";
- private static final String ALLOWED_METHODS = "*";
+ 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, 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";
- private final HystrixFallbackHandler hystrixFallbackHandler;
- private final SwaggerResourceHandler swaggerResourceHandler;
- private final SwaggerSecurityHandler swaggerSecurityHandler;
- private final SwaggerUiHandler swaggerUiHandler;
-
+ /**
+ * 跨域配置
+ */
@Bean
public WebFilter corsFilter() {
return (ServerWebExchange ctx, WebFilterChain chain) -> {
@@ -83,32 +78,4 @@ public class RouterFunctionConfiguration {
};
}
- @Bean
- public RouterFunction routerFunction() {
- return RouterFunctions.route(
- RequestPredicates.path("/fallback")
- .and(RequestPredicates.accept(MediaType.TEXT_PLAIN)), hystrixFallbackHandler)
- .andRoute(RequestPredicates.GET("/swagger-resources")
- .and(RequestPredicates.accept(MediaType.ALL)), swaggerResourceHandler)
- .andRoute(RequestPredicates.GET("/swagger-resources/configuration/ui")
- .and(RequestPredicates.accept(MediaType.ALL)), swaggerUiHandler)
- .andRoute(RequestPredicates.GET("/swagger-resources/configuration/security")
- .and(RequestPredicates.accept(MediaType.ALL)), swaggerSecurityHandler);
-
- }
-
- /**
- * 解决springboot2.0.5版本出现的 Only one connection receive subscriber allowed.
- * 参考:https://github.com/spring-cloud/spring-cloud-gateway/issues/541
- */
- @Bean
- public HiddenHttpMethodFilter hiddenHttpMethodFilter() {
- return new HiddenHttpMethodFilter() {
- @Override
- public Mono filter(ServerWebExchange exchange, WebFilterChain chain) {
- return chain.filter(exchange);
- }
- };
- }
-
}
diff --git a/blade-gateway/src/main/java/org/springblade/gateway/filter/AuthFilter.java b/blade-gateway/src/main/java/org/springblade/gateway/filter/AuthFilter.java
new file mode 100644
index 0000000000000000000000000000000000000000..0e5a7f08670dfcb9c92b3c04e0a7ba2e083d27fd
--- /dev/null
+++ b/blade-gateway/src/main/java/org/springblade/gateway/filter/AuthFilter.java
@@ -0,0 +1,99 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * 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
+ *
- * 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
- *
- * 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 org.springblade.gateway.handler;
-
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.MediaType;
-import org.springframework.stereotype.Component;
-import org.springframework.web.reactive.function.BodyInserters;
-import org.springframework.web.reactive.function.server.HandlerFunction;
-import org.springframework.web.reactive.function.server.ServerRequest;
-import org.springframework.web.reactive.function.server.ServerResponse;
-import reactor.core.publisher.Mono;
-
-/**
- * Hystrix 降级处理
- *
- * @author lengleng
- */
-@Slf4j
-@Component
-public class HystrixFallbackHandler implements HandlerFunction {
- @Override
- public Mono handle(ServerRequest serverRequest) {
- log.error("网关执行请求:{}失败,hystrix服务降级处理", serverRequest.uri());
- return ServerResponse.status(HttpStatus.INTERNAL_SERVER_ERROR.value())
- .contentType(MediaType.TEXT_PLAIN).body(BodyInserters.fromObject("服务异常"));
- }
-}
diff --git a/blade-gateway/src/main/java/org/springblade/gateway/props/AuthProperties.java b/blade-gateway/src/main/java/org/springblade/gateway/props/AuthProperties.java
new file mode 100644
index 0000000000000000000000000000000000000000..38a924db06d5ba1c8fac8a7adc077dc2b95d7dcd
--- /dev/null
+++ b/blade-gateway/src/main/java/org/springblade/gateway/props/AuthProperties.java
@@ -0,0 +1,40 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * 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
+ *
+ * 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 org.springblade.gateway.props;
+
+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 skipUrl = new ArrayList<>();
+
+}
diff --git a/blade-gateway/src/main/java/org/springblade/gateway/provider/AuthProvider.java b/blade-gateway/src/main/java/org/springblade/gateway/provider/AuthProvider.java
new file mode 100644
index 0000000000000000000000000000000000000000..1dc122086bc1fb0bde7f305e2fc45ea2da30c3f4
--- /dev/null
+++ b/blade-gateway/src/main/java/org/springblade/gateway/provider/AuthProvider.java
@@ -0,0 +1,58 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * 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
+ *
+ * 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 org.springblade.gateway.provider;
+
+import org.springblade.core.launch.constant.TokenConstant;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 鉴权配置
+ *
+ * @author Chill
+ */
+public class AuthProvider {
+
+ public static String AUTH_KEY = TokenConstant.HEADER;
+ private static final List DEFAULT_SKIP_URL = new ArrayList<>();
+
+ static {
+ DEFAULT_SKIP_URL.add("/example");
+ DEFAULT_SKIP_URL.add("/token/**");
+ DEFAULT_SKIP_URL.add("/captcha/**");
+ DEFAULT_SKIP_URL.add("/actuator/health/**");
+ DEFAULT_SKIP_URL.add("/v2/api-docs/**");
+ DEFAULT_SKIP_URL.add("/auth/**");
+ DEFAULT_SKIP_URL.add("/oauth/**");
+ DEFAULT_SKIP_URL.add("/log/**");
+ DEFAULT_SKIP_URL.add("/menu/routes");
+ DEFAULT_SKIP_URL.add("/menu/auth-routes");
+ DEFAULT_SKIP_URL.add("/tenant/info");
+ DEFAULT_SKIP_URL.add("/order/create/**");
+ DEFAULT_SKIP_URL.add("/storage/deduct/**");
+ DEFAULT_SKIP_URL.add("/error/**");
+ DEFAULT_SKIP_URL.add("/assets/**");
+ }
+
+ /**
+ * 默认无需鉴权的API
+ */
+ public static List getDefaultSkipUrl() {
+ return DEFAULT_SKIP_URL;
+ }
+
+}
diff --git a/blade-gateway/src/main/java/org/springblade/gateway/provider/ResponseProvider.java b/blade-gateway/src/main/java/org/springblade/gateway/provider/ResponseProvider.java
new file mode 100644
index 0000000000000000000000000000000000000000..ddcd65d9fb9cc93a4a8a10a251b2dd3103df5b7d
--- /dev/null
+++ b/blade-gateway/src/main/java/org/springblade/gateway/provider/ResponseProvider.java
@@ -0,0 +1,83 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * 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
+ *
+ * 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 org.springblade.gateway.provider;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 请求响应返回
+ *
+ * @author Chill
+ */
+public class ResponseProvider {
+
+ /**
+ * 成功
+ *
+ * @param message 信息
+ * @return
+ */
+ public static Map success(String message) {
+ return response(200, message);
+ }
+
+ /**
+ * 失败
+ *
+ * @param message 信息
+ * @return
+ */
+ public static Map fail(String message) {
+ return response(400, message);
+ }
+
+ /**
+ * 未授权
+ *
+ * @param message 信息
+ * @return
+ */
+ public static Map unAuth(String message) {
+ return response(401, message);
+ }
+
+ /**
+ * 服务器异常
+ *
+ * @param message 信息
+ * @return
+ */
+ public static Map error(String message) {
+ return response(500, message);
+ }
+
+ /**
+ * 构建返回的JSON数据格式
+ *
+ * @param status 状态码
+ * @param message 信息
+ * @return
+ */
+ public static Map response(int status, String message) {
+ Map map = new HashMap<>(16);
+ map.put("code", status);
+ map.put("msg", message);
+ map.put("data", null);
+ return map;
+ }
+
+}
diff --git a/blade-gateway/src/main/java/org/springblade/gateway/provider/SwaggerProvider.java b/blade-gateway/src/main/java/org/springblade/gateway/provider/SwaggerProvider.java
deleted file mode 100644
index 052b5215eb62db98672e19523a3025b9942362e7..0000000000000000000000000000000000000000
--- a/blade-gateway/src/main/java/org/springblade/gateway/provider/SwaggerProvider.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/**
- * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
- *
- * 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
- *
- * 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 org.springblade.gateway.provider;
-
-import lombok.AllArgsConstructor;
-import org.springblade.core.launch.constant.AppConstant;
-import org.springframework.cloud.gateway.config.GatewayProperties;
-import org.springframework.cloud.gateway.route.RouteLocator;
-import org.springframework.cloud.gateway.support.NameUtils;
-import org.springframework.context.annotation.Primary;
-import org.springframework.stereotype.Component;
-import springfox.documentation.swagger.web.SwaggerResource;
-import springfox.documentation.swagger.web.SwaggerResourcesProvider;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * 聚合接口文档注册
- *
- * @author Sywd
- */
-@Primary
-@Component
-@AllArgsConstructor
-public class SwaggerProvider implements SwaggerResourcesProvider {
- public static final String API_URI = "/v2/api-docs-ext";
- private final RouteLocator routeLocator;
- private final GatewayProperties gatewayProperties;
-
- private static Map routeMap = new HashMap<>();
-
- static {
- routeMap.put(AppConstant.APPLICATION_AUTH_NAME, "授权模块");
- routeMap.put(AppConstant.APPLICATION_DESK_NAME, "工作台模块");
- routeMap.put(AppConstant.APPLICATION_SYSTEM_NAME, "系统模块");
- }
-
- @Override
- public List get() {
- List resources = new ArrayList<>();
- List routes = new ArrayList<>();
- routeLocator.getRoutes().subscribe(route -> routes.add(route.getId()));
- gatewayProperties.getRoutes().stream().filter(routeDefinition -> routes.contains(routeDefinition.getId()))
- .forEach(routeDefinition -> routeDefinition.getPredicates().stream()
- .filter(predicateDefinition -> "Path".equalsIgnoreCase(predicateDefinition.getName()))
- .forEach(predicateDefinition -> resources.add(swaggerResource(routeDefinition.getId(),
- predicateDefinition.getArgs().get(NameUtils.GENERATED_NAME_PREFIX + "0")
- .replace("/**", API_URI)))));
- return resources;
- }
-
- private SwaggerResource swaggerResource(String name, String location) {
- SwaggerResource swaggerResource = new SwaggerResource();
- swaggerResource.setName((routeMap.get(name) == null ? name : routeMap.get(name)));
- swaggerResource.setLocation(location);
- swaggerResource.setSwaggerVersion("2.0");
- return swaggerResource;
- }
-
-}
diff --git a/blade-gateway/src/main/java/org/springblade/gateway/utils/JwtUtil.java b/blade-gateway/src/main/java/org/springblade/gateway/utils/JwtUtil.java
new file mode 100644
index 0000000000000000000000000000000000000000..2d05163d9c80bc6e7d7698eba5d5ad07700da384
--- /dev/null
+++ b/blade-gateway/src/main/java/org/springblade/gateway/utils/JwtUtil.java
@@ -0,0 +1,71 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * 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
+ *
+ * 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
+ *
+ * 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
+ *
+ * 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 org.springblade.develop.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 lombok.EqualsAndHashCode;
+import org.springblade.core.mp.base.BaseEntity;
+
+/**
+ * 数据源配置表实体类
+ *
+ * @author Chill
+ */
+@Data
+@TableName("blade_datasource")
+@EqualsAndHashCode(callSuper = true)
+@ApiModel(value = "Datasource对象", description = "数据源配置表")
+public class Datasource extends BaseEntity {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 主键
+ */
+ @ApiModelProperty(value = "主键")
+ @TableId(value = "id", type = IdType.ASSIGN_ID)
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long id;
+
+ /**
+ * 名称
+ */
+ @ApiModelProperty(value = "名称")
+ private String name;
+ /**
+ * 驱动类
+ */
+ @ApiModelProperty(value = "驱动类")
+ private String driverClass;
+ /**
+ * 连接地址
+ */
+ @ApiModelProperty(value = "连接地址")
+ private String url;
+ /**
+ * 用户名
+ */
+ @ApiModelProperty(value = "用户名")
+ private String username;
+ /**
+ * 密码
+ */
+ @ApiModelProperty(value = "密码")
+ private String password;
+ /**
+ * 备注
+ */
+ @ApiModelProperty(value = "备注")
+ private String remark;
+
+
+}
diff --git a/blade-ops/blade-develop/src/main/java/org/springblade/develop/mapper/CodeMapper.java b/blade-ops/blade-develop/src/main/java/org/springblade/develop/mapper/CodeMapper.java
index 4b187d5ed134d31e31d6e7df6b72aaf74890427f..ac38043b07aca145416c0de91dc46ab137a64224 100644
--- a/blade-ops/blade-develop/src/main/java/org/springblade/develop/mapper/CodeMapper.java
+++ b/blade-ops/blade-develop/src/main/java/org/springblade/develop/mapper/CodeMapper.java
@@ -22,7 +22,6 @@ import org.springblade.develop.entity.Code;
* Mapper 接口
*
* @author Chill
- * @since 2018-12-24
*/
public interface CodeMapper extends BaseMapper {
diff --git a/blade-ops/blade-develop/src/main/java/org/springblade/develop/mapper/CodeMapper.xml b/blade-ops/blade-develop/src/main/java/org/springblade/develop/mapper/CodeMapper.xml
index d282aafe11c9aed90da3a7fb930fd4dcc73aa1e7..46db5518b9d2ce3b19f9b0ee3f2f099270696e88 100644
--- a/blade-ops/blade-develop/src/main/java/org/springblade/develop/mapper/CodeMapper.xml
+++ b/blade-ops/blade-develop/src/main/java/org/springblade/develop/mapper/CodeMapper.xml
@@ -5,10 +5,13 @@
+
+
+
@@ -16,10 +19,4 @@
-
-
- select
- id, service_name, code_name, table_name, pk_name, model_name, package_name, api_path, web_path, is_deleted
-
-
diff --git a/blade-ops/blade-develop/src/main/java/org/springblade/develop/mapper/DatasourceMapper.java b/blade-ops/blade-develop/src/main/java/org/springblade/develop/mapper/DatasourceMapper.java
new file mode 100644
index 0000000000000000000000000000000000000000..3f3be53c68deb8961a1c4ee66eef88786d8425be
--- /dev/null
+++ b/blade-ops/blade-develop/src/main/java/org/springblade/develop/mapper/DatasourceMapper.java
@@ -0,0 +1,28 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * 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
+ *
+ * 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 org.springblade.develop.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.springblade.develop.entity.Datasource;
+
+/**
+ * 数据源配置表 Mapper 接口
+ *
+ * @author Chill
+ */
+public interface DatasourceMapper extends BaseMapper {
+
+}
diff --git a/blade-ops/blade-develop/src/main/java/org/springblade/develop/mapper/DatasourceMapper.xml b/blade-ops/blade-develop/src/main/java/org/springblade/develop/mapper/DatasourceMapper.xml
new file mode 100644
index 0000000000000000000000000000000000000000..c863cd42dab2194b57146a09ecfe137461ada93c
--- /dev/null
+++ b/blade-ops/blade-develop/src/main/java/org/springblade/develop/mapper/DatasourceMapper.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/blade-ops/blade-develop/src/main/java/org/springblade/develop/service/ICodeService.java b/blade-ops/blade-develop/src/main/java/org/springblade/develop/service/ICodeService.java
index 0b760d65be434d181088bdad795e59fdc2029560..38e25a77cad676c0adf40e6d184f7bd342d4f582 100644
--- a/blade-ops/blade-develop/src/main/java/org/springblade/develop/service/ICodeService.java
+++ b/blade-ops/blade-develop/src/main/java/org/springblade/develop/service/ICodeService.java
@@ -23,8 +23,15 @@ import org.springblade.develop.entity.Code;
* 服务类
*
* @author Chill
- * @since 2018-12-24
*/
public interface ICodeService extends IService {
+ /**
+ * 提交
+ *
+ * @param code
+ * @return
+ */
+ boolean submit(Code code);
+
}
diff --git a/blade-ops/blade-develop/src/main/java/org/springblade/develop/service/IDatasourceService.java b/blade-ops/blade-develop/src/main/java/org/springblade/develop/service/IDatasourceService.java
new file mode 100644
index 0000000000000000000000000000000000000000..d8109f3e51147b83b62b4e584f244c2eb453d8ee
--- /dev/null
+++ b/blade-ops/blade-develop/src/main/java/org/springblade/develop/service/IDatasourceService.java
@@ -0,0 +1,28 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * 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
+ *
+ * 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 org.springblade.develop.service;
+
+import org.springblade.core.mp.base.BaseService;
+import org.springblade.develop.entity.Datasource;
+
+/**
+ * 数据源配置表 服务类
+ *
+ * @author Chill
+ */
+public interface IDatasourceService extends BaseService {
+
+}
diff --git a/blade-ops/blade-develop/src/main/java/org/springblade/develop/service/impl/CodeServiceImpl.java b/blade-ops/blade-develop/src/main/java/org/springblade/develop/service/impl/CodeServiceImpl.java
index af4c5cc538fe8141546b2ae667b3c9ede0fb2412..83aaa96aa7dc0259c70dfaac197b57edfea1bf3e 100644
--- a/blade-ops/blade-develop/src/main/java/org/springblade/develop/service/impl/CodeServiceImpl.java
+++ b/blade-ops/blade-develop/src/main/java/org/springblade/develop/service/impl/CodeServiceImpl.java
@@ -16,6 +16,7 @@
package org.springblade.develop.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springblade.core.tool.constant.BladeConstant;
import org.springblade.develop.entity.Code;
import org.springblade.develop.mapper.CodeMapper;
import org.springblade.develop.service.ICodeService;
@@ -25,9 +26,14 @@ import org.springframework.stereotype.Service;
* 服务实现类
*
* @author Chill
- * @since 2018-12-24
*/
@Service
public class CodeServiceImpl extends ServiceImpl implements ICodeService {
+ @Override
+ public boolean submit(Code code) {
+ code.setIsDeleted(BladeConstant.DB_NOT_DELETED);
+ return saveOrUpdate(code);
+ }
+
}
diff --git a/blade-ops/blade-develop/src/main/java/org/springblade/develop/service/impl/DatasourceServiceImpl.java b/blade-ops/blade-develop/src/main/java/org/springblade/develop/service/impl/DatasourceServiceImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..c14222e8849a5dab7c16be14f124d04e20505c1e
--- /dev/null
+++ b/blade-ops/blade-develop/src/main/java/org/springblade/develop/service/impl/DatasourceServiceImpl.java
@@ -0,0 +1,32 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * 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
+ *
+ * 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 org.springblade.develop.service.impl;
+
+import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springblade.develop.entity.Datasource;
+import org.springblade.develop.mapper.DatasourceMapper;
+import org.springblade.develop.service.IDatasourceService;
+import org.springframework.stereotype.Service;
+
+/**
+ * 数据源配置表 服务实现类
+ *
+ * @author Chill
+ */
+@Service
+public class DatasourceServiceImpl extends BaseServiceImpl implements IDatasourceService {
+
+}
diff --git a/blade-ops/blade-develop/src/main/java/org/springblade/develop/support/BladeGenerator.java b/blade-ops/blade-develop/src/main/java/org/springblade/develop/support/BladeGenerator.java
deleted file mode 100644
index d39c2d105efe31dceb3ffdf38ff920215de6fcdf..0000000000000000000000000000000000000000
--- a/blade-ops/blade-develop/src/main/java/org/springblade/develop/support/BladeGenerator.java
+++ /dev/null
@@ -1,292 +0,0 @@
-/**
- * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
- *
- * 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
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * 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
- *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * 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
+ *
+ * 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 org.springblade.report;
+
+import org.springblade.core.cloud.client.BladeCloudApplication;
+import org.springblade.core.launch.BladeApplication;
+import org.springblade.core.launch.constant.AppConstant;
+
+/**
+ * UReport启动器
+ *
+ * @author Chill
+ */
+@BladeCloudApplication
+public class ReportApplication {
+
+ public static void main(String[] args) {
+ BladeApplication.run(AppConstant.APPLICATION_REPORT_NAME, ReportApplication.class, args);
+ }
+
+}
diff --git a/blade-auth/src/main/java/org/springblade/auth/config/RegistryConfiguration.java b/blade-ops/blade-report/src/main/java/org/springblade/report/config/BladeReportConfiguration.java
similarity index 58%
rename from blade-auth/src/main/java/org/springblade/auth/config/RegistryConfiguration.java
rename to blade-ops/blade-report/src/main/java/org/springblade/report/config/BladeReportConfiguration.java
index 98f8ee54942763a9f69e187515c58d47a05e5129..443efa042213f764368e111c7e7d94c123e39b57 100644
--- a/blade-auth/src/main/java/org/springblade/auth/config/RegistryConfiguration.java
+++ b/blade-ops/blade-report/src/main/java/org/springblade/report/config/BladeReportConfiguration.java
@@ -13,27 +13,30 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springblade.auth.config;
+package org.springblade.report.config;
-
-import org.springblade.core.secure.registry.SecureRegistry;
+import org.springblade.core.report.datasource.ReportDataSource;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+import javax.sql.DataSource;
/**
- * secure模块api放行配置
+ * 报表配置类
*
* @author Chill
*/
-@Configuration
-public class RegistryConfiguration implements WebMvcConfigurer {
+@Configuration(proxyBeanMethods = false)
+@ConditionalOnProperty(value = "report.enabled", havingValue = "true", matchIfMissing = true)
+public class BladeReportConfiguration {
+ /**
+ * 自定义报表可选数据源
+ */
@Bean
- public SecureRegistry secureRegistry() {
- SecureRegistry secureRegistry = new SecureRegistry();
- secureRegistry.excludePathPatterns("/token/**");
- return secureRegistry;
+ public ReportDataSource reportDataSource(DataSource dataSource) {
+ return new ReportDataSource(dataSource);
}
}
diff --git a/blade-ops/blade-report/src/main/resources/application-dev.yml b/blade-ops/blade-report/src/main/resources/application-dev.yml
new file mode 100644
index 0000000000000000000000000000000000000000..97f23c86c9f442b3587491ed0c930c7748206129
--- /dev/null
+++ b/blade-ops/blade-report/src/main/resources/application-dev.yml
@@ -0,0 +1,6 @@
+#数据源配置
+spring:
+ datasource:
+ url: ${blade.datasource.dev.url}
+ username: ${blade.datasource.dev.username}
+ password: ${blade.datasource.dev.password}
diff --git a/blade-ops/blade-report/src/main/resources/application-prod.yml b/blade-ops/blade-report/src/main/resources/application-prod.yml
new file mode 100644
index 0000000000000000000000000000000000000000..c238494f676e13bf479844bc2b4947c6d6b54f3e
--- /dev/null
+++ b/blade-ops/blade-report/src/main/resources/application-prod.yml
@@ -0,0 +1,6 @@
+#数据源配置
+spring:
+ datasource:
+ url: ${blade.datasource.prod.url}
+ username: ${blade.datasource.prod.username}
+ password: ${blade.datasource.prod.password}
diff --git a/blade-ops/blade-report/src/main/resources/application-test.yml b/blade-ops/blade-report/src/main/resources/application-test.yml
new file mode 100644
index 0000000000000000000000000000000000000000..5738832a5ae076418c556fc57614f0132f8ab775
--- /dev/null
+++ b/blade-ops/blade-report/src/main/resources/application-test.yml
@@ -0,0 +1,6 @@
+#数据源配置
+spring:
+ datasource:
+ url: ${blade.datasource.test.url}
+ username: ${blade.datasource.test.username}
+ password: ${blade.datasource.test.password}
diff --git a/blade-ops/blade-report/src/main/resources/application.yml b/blade-ops/blade-report/src/main/resources/application.yml
new file mode 100644
index 0000000000000000000000000000000000000000..027a146fc652feb8cd2a0e900780d220b8f08511
--- /dev/null
+++ b/blade-ops/blade-report/src/main/resources/application.yml
@@ -0,0 +1,10 @@
+#服务器端口
+server:
+ port: 8108
+
+#报表配置
+report:
+ enabled: true
+ database:
+ provider:
+ prefix: blade-
diff --git a/blade-ops/blade-resource/Dockerfile b/blade-ops/blade-resource/Dockerfile
new file mode 100644
index 0000000000000000000000000000000000000000..72ee5432b9eb70939ba96d923073565610657fcc
--- /dev/null
+++ b/blade-ops/blade-resource/Dockerfile
@@ -0,0 +1,15 @@
+FROM anapsix/alpine-java:8_server-jre_unlimited
+
+MAINTAINER smallchill@163.com
+
+RUN mkdir -p /blade/resource
+
+WORKDIR /blade/resource
+
+EXPOSE 8010
+
+ADD ./target/blade-resource.jar ./app.jar
+
+ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "app.jar"]
+
+CMD ["--spring.profiles.active=test"]
diff --git a/blade-ops/blade-resource/pom.xml b/blade-ops/blade-resource/pom.xml
new file mode 100644
index 0000000000000000000000000000000000000000..f65af4ff95e4896431bf62bd5072cfadde7f37cc
--- /dev/null
+++ b/blade-ops/blade-resource/pom.xml
@@ -0,0 +1,91 @@
+
+
+
+ blade-ops
+ org.springblade
+ 3.4.1
+
+ 4.0.0
+
+ blade-resource
+ ${project.artifactId}
+ ${blade.project.version}
+ jar
+
+
+
+ org.springblade
+ blade-common
+ ${blade.project.version}
+
+
+ org.springblade
+ blade-core-tool
+ ${blade.tool.version}
+
+
+ org.springblade
+ blade-core-cloud
+ ${blade.tool.version}
+
+
+ org.springblade
+ blade-core-secure
+
+
+
+
+ org.springblade
+ blade-core-oss
+ ${blade.tool.version}
+
+
+
+
+
+
+ com.spotify
+ docker-maven-plugin
+ ${docker.plugin.version}
+
+ ${docker.registry.url}/blade/${project.artifactId}:${project.version}
+ ${project.basedir}
+ ${docker.registry.host}
+
+
+ /
+ ${project.build.directory}
+ ${project.build.finalName}.jar
+
+
+ ${docker.registry.url}
+ ${docker.registry.url}
+ true
+
+
+
+ org.apache.maven.plugins
+ maven-antrun-plugin
+
+
+ package
+
+ run
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/blade-ops/blade-resource/src/main/java/org/springblade/resource/ResourceApplication.java b/blade-ops/blade-resource/src/main/java/org/springblade/resource/ResourceApplication.java
new file mode 100644
index 0000000000000000000000000000000000000000..4e294f3146b3304163375fb08b29d209b9d219b4
--- /dev/null
+++ b/blade-ops/blade-resource/src/main/java/org/springblade/resource/ResourceApplication.java
@@ -0,0 +1,35 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * 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
+ *
+ * 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 org.springblade.resource;
+
+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 ResourceApplication {
+
+ public static void main(String[] args) {
+ BladeApplication.run(AppConstant.APPLICATION_RESOURCE_NAME, ResourceApplication.class, args);
+ }
+
+}
+
diff --git a/blade-ops/blade-resource/src/main/java/org/springblade/resource/endpoint/OssEndpoint.java b/blade-ops/blade-resource/src/main/java/org/springblade/resource/endpoint/OssEndpoint.java
new file mode 100644
index 0000000000000000000000000000000000000000..7cddd8f8a7d4961e149c968ebb3654741642866d
--- /dev/null
+++ b/blade-ops/blade-resource/src/main/java/org/springblade/resource/endpoint/OssEndpoint.java
@@ -0,0 +1,173 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * 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
+ *
+ * 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
+ *
+ * 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
+ *
+ * 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
+ *
+ * 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 com.example.demo.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 lombok.EqualsAndHashCode;
+import org.springblade.core.mp.base.BaseEntity;
+
+import java.util.Date;
+
+/**
+ * 实体类
+ *
+ * @author Chill
+ */
+@Data
+@TableName("blade_notice")
+@EqualsAndHashCode(callSuper = true)
+public class Notice extends BaseEntity {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 主键id
+ */
+ @ApiModelProperty(value = "主键")
+ @TableId(value = "id", type = IdType.ASSIGN_ID)
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long id;
+
+ /**
+ * 标题
+ */
+ @ApiModelProperty(value = "标题")
+ private String title;
+
+ /**
+ * 通知类型
+ */
+ @ApiModelProperty(value = "通知类型")
+ private Integer category;
+
+ /**
+ * 发布日期
+ */
+ @ApiModelProperty(value = "发布日期")
+ private Date releaseTime;
+
+ /**
+ * 内容
+ */
+ @ApiModelProperty(value = "内容")
+ private String content;
+
+
+}
diff --git a/blade-service-api/blade-demo-api/src/main/java/com/example/demo/feign/INoticeClient.java b/blade-service-api/blade-demo-api/src/main/java/com/example/demo/feign/INoticeClient.java
new file mode 100644
index 0000000000000000000000000000000000000000..911be4d7047bdb7402e2f05b94606ddcb3a9bdca
--- /dev/null
+++ b/blade-service-api/blade-demo-api/src/main/java/com/example/demo/feign/INoticeClient.java
@@ -0,0 +1,49 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * 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
+ *
+ * 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
+ *
+ * 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 org.springblade.system.cache;
+
+import org.springblade.core.datascope.model.DataScopeModel;
+import org.springblade.core.tool.utils.*;
+import org.springblade.system.feign.IDataScopeClient;
+
+import java.util.List;
+
+import static org.springblade.core.tool.utils.CacheUtil.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);
+ 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);
+ 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 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;
+ }
+}
diff --git a/blade-gateway/src/main/java/org/springblade/gateway/config/RateLimiterConfiguration.java b/blade-service-api/blade-scope-api/src/main/java/org/springblade/system/config/ScopeConfiguration.java
similarity index 57%
rename from blade-gateway/src/main/java/org/springblade/gateway/config/RateLimiterConfiguration.java
rename to blade-service-api/blade-scope-api/src/main/java/org/springblade/system/config/ScopeConfiguration.java
index 420367f72ea50671e306e046a0f99838c22438ed..e38ec61b8a3cf45c0518ca049cc8803b83447de2 100644
--- a/blade-gateway/src/main/java/org/springblade/gateway/config/RateLimiterConfiguration.java
+++ b/blade-service-api/blade-scope-api/src/main/java/org/springblade/system/config/ScopeConfiguration.java
@@ -13,25 +13,30 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+package org.springblade.system.config;
-package org.springblade.gateway.config;
-import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver;
+import lombok.AllArgsConstructor;
+import org.springblade.core.datascope.handler.ScopeModelHandler;
+import org.springblade.core.secure.config.RegistryConfiguration;
+import org.springblade.system.handler.DataScopeModelHandler;
+import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-import reactor.core.publisher.Mono;
/**
- * 路由限流配置
+ * 公共封装包配置类
*
* @author Chill
*/
-@Configuration
-public class RateLimiterConfiguration {
+@Configuration(proxyBeanMethods = false)
+@AllArgsConstructor
+@AutoConfigureBefore(RegistryConfiguration.class)
+public class ScopeConfiguration {
- @Bean(value = "remoteAddrKeyResolver")
- public KeyResolver remoteAddrKeyResolver() {
- return exchange -> Mono.just(exchange.getRequest().getRemoteAddress().getAddress().getHostAddress());
+ @Bean
+ public ScopeModelHandler scopeModelHandler() {
+ return new DataScopeModelHandler();
}
}
diff --git a/blade-service-api/blade-scope-api/src/main/java/org/springblade/system/feign/IDataScopeClient.java b/blade-service-api/blade-scope-api/src/main/java/org/springblade/system/feign/IDataScopeClient.java
new file mode 100644
index 0000000000000000000000000000000000000000..6dc5b1615427c137cec04506b7ea35dfd0407f70
--- /dev/null
+++ b/blade-service-api/blade-scope-api/src/main/java/org/springblade/system/feign/IDataScopeClient.java
@@ -0,0 +1,71 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * 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
+ *
+ * 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 org.springblade.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 getDeptAncestors(@RequestParam("deptId") Long deptId);
+
+
+}
diff --git a/blade-service-api/blade-scope-api/src/main/java/org/springblade/system/feign/IDataScopeClientFallback.java b/blade-service-api/blade-scope-api/src/main/java/org/springblade/system/feign/IDataScopeClientFallback.java
new file mode 100644
index 0000000000000000000000000000000000000000..abcd35a38a083d7da82e9a2467c71dea3058ee6e
--- /dev/null
+++ b/blade-service-api/blade-scope-api/src/main/java/org/springblade/system/feign/IDataScopeClientFallback.java
@@ -0,0 +1,44 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * 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
+ *
+ * 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 org.springblade.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 getDeptAncestors(Long deptId) {
+ return null;
+ }
+}
diff --git a/blade-service-api/blade-scope-api/src/main/java/org/springblade/system/handler/DataScopeModelHandler.java b/blade-service-api/blade-scope-api/src/main/java/org/springblade/system/handler/DataScopeModelHandler.java
new file mode 100644
index 0000000000000000000000000000000000000000..2e7cb67cdfe2025900ab0c49de4775c8b67cb8ed
--- /dev/null
+++ b/blade-service-api/blade-scope-api/src/main/java/org/springblade/system/handler/DataScopeModelHandler.java
@@ -0,0 +1,64 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * 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
+ *
+ * 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
+ *
+ * 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
+ *
+ * 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
+ *
+ * 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 org.springblade.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 lombok.EqualsAndHashCode;
+import org.springblade.core.mp.base.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;
+
+ /**
+ * 主键id
+ */
+ @ApiModelProperty(value = "主键")
+ @TableId(value = "id", type = IdType.ASSIGN_ID)
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long id;
+
+ /**
+ * 类型
+ */
+ @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;
+
+
+}
diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/Region.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/Region.java
new file mode 100644
index 0000000000000000000000000000000000000000..2447890e0407207e26d3ea9a002cafa24bc1e3e8
--- /dev/null
+++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/Region.java
@@ -0,0 +1,127 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * 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
+ *
+ * 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
+ *
+ * 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 org.springblade.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;
+
+ /**
+ * 权限id
+ */
+ @JsonSerialize(using = ToStringSerializer.class)
+ @ApiModelProperty(value = "权限id")
+ private Long scopeId;
+
+ /**
+ * 角色id
+ */
+ @JsonSerialize(using = ToStringSerializer.class)
+ @ApiModelProperty(value = "角色id")
+ private Long roleId;
+
+
+}
diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/Tenant.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/Tenant.java
new file mode 100644
index 0000000000000000000000000000000000000000..a9b6915b758114598c4251a3978adbaeac8bb9ed
--- /dev/null
+++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/Tenant.java
@@ -0,0 +1,82 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * 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
+ *
+ * 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 org.springblade.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 lombok.EqualsAndHashCode;
+import org.springblade.core.mp.base.BaseEntity;
+
+/**
+ * 实体类
+ *
+ * @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 = "主键")
+ @TableId(value = "id", type = IdType.ASSIGN_ID)
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long id;
+
+ /**
+ * 租户ID
+ */
+ @ApiModelProperty(value = "租户ID")
+ private String tenantId;
+ /**
+ * 租户名称
+ */
+ @ApiModelProperty(value = "租户名称")
+ private String tenantName;
+ /**
+ * 域名地址
+ */
+ @ApiModelProperty(value = "域名地址")
+ private String domain;
+ /**
+ * 联系人
+ */
+ @ApiModelProperty(value = "联系人")
+ private String linkman;
+ /**
+ * 联系电话
+ */
+ @ApiModelProperty(value = "联系电话")
+ private String contactNumber;
+ /**
+ * 联系地址
+ */
+ @ApiModelProperty(value = "联系地址")
+ private String address;
+
+
+}
diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/feign/ISysClient.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/feign/ISysClient.java
new file mode 100644
index 0000000000000000000000000000000000000000..302b5f25096709bb9edccd14d55ea547ee849eb2
--- /dev/null
+++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/feign/ISysClient.java
@@ -0,0 +1,164 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * 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
+ *
+ * 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
+ *
+ * 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 org.springblade.system.vo;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * CheckedTreeVO
+ *
+ * @author Chill
+ */
+@Data
+public class CheckedTreeVO {
+
+ private List menu;
+
+ private List dataScope;
+
+}
diff --git a/blade-ops/blade-develop/src/main/resources/templates/entityVO.java.vm b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/DataScopeVO.java
similarity index 63%
rename from blade-ops/blade-develop/src/main/resources/templates/entityVO.java.vm
rename to blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/DataScopeVO.java
index cc88136e268db9d94263d4abe3270faf41ea43e4..59c8d40fc716f48ac3fc47964df6e96c117903d6 100644
--- a/blade-ops/blade-develop/src/main/resources/templates/entityVO.java.vm
+++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/DataScopeVO.java
@@ -13,32 +13,26 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#set($voPackage=$package.Entity.replace("entity","vo"))
-package $!{voPackage};
+package org.springblade.system.vo;
-import $!{package.Entity}.$!{entity};
-#if($!{entityLombokModel})
+import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
-#end
-#if($!{swagger2})
-import io.swagger.annotations.ApiModel;
-#end
+import org.springblade.system.entity.DataScope;
/**
- * $!{table.comment}视图实体类
+ * 视图实体类
*
- * @author $!{author}
- * @since $!{date}
+ * @author Chill
*/
-#if($!{entityLombokModel})
@Data
@EqualsAndHashCode(callSuper = true)
-#end
-#if($!{swagger2})
-@ApiModel(value = "$!{entity}VO对象", description = #if ("$!{table.comment}"=="")"$!{entity}VO对象"#else"$!{table.comment}"#end)
-#end
-public class $!{entity}VO extends $!{entity} {
+@ApiModel(value = "DataScopeVO对象", description = "DataScopeVO对象")
+public class DataScopeVO extends DataScope {
private static final long serialVersionUID = 1L;
+ /**
+ * 规则类型名
+ */
+ private String scopeTypeName;
}
diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/DeptVO.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/DeptVO.java
index 7ad5e5c2f70bd5d01385aa30bb09155e60ecd9a3..80bcb39bb81b409fc69e71a893c7a07a14a25335 100644
--- a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/DeptVO.java
+++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/DeptVO.java
@@ -16,6 +16,8 @@
package org.springblade.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;
@@ -29,7 +31,6 @@ import java.util.List;
* 视图实体类
*
* @author Chill
- * @since 2018-12-24
*/
@Data
@EqualsAndHashCode(callSuper = true)
@@ -40,12 +41,14 @@ public class DeptVO extends Dept implements INode {
/**
* 主键ID
*/
- private Integer id;
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long id;
/**
* 父节点ID
*/
- private Integer parentId;
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long parentId;
/**
* 子孙节点
diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/GrantTreeVO.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/GrantTreeVO.java
new file mode 100644
index 0000000000000000000000000000000000000000..4d9c14428a0e4522c0e7b4b41c96908d50ccbb4d
--- /dev/null
+++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/GrantTreeVO.java
@@ -0,0 +1,36 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * 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
+ *
+ * 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 org.springblade.system.vo;
+
+import lombok.Data;
+
+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 menu;
+
+ private List dataScope;
+
+}
diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/GrantVO.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/GrantVO.java
new file mode 100644
index 0000000000000000000000000000000000000000..31cbc808d01c5338de5d7800659671110684a6b8
--- /dev/null
+++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/GrantVO.java
@@ -0,0 +1,42 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * 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
+ *
+ * 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 org.springblade.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 roleIds;
+
+ @ApiModelProperty(value = "menuIds集合")
+ private List menuIds;
+
+ @ApiModelProperty(value = "dataScopeIds集合")
+ private List dataScopeIds;
+
+}
diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/MenuVO.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/MenuVO.java
index 3cd06e9bba211c1f48b2595da5dfb82b5b27bcf7..60a76ae3abcecf82a1b64f75ddfe67a055f25819 100644
--- a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/MenuVO.java
+++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/MenuVO.java
@@ -16,6 +16,8 @@
package org.springblade.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;
@@ -29,7 +31,6 @@ import java.util.List;
* 视图实体类
*
* @author Chill
- * @since 2018-12-24
*/
@Data
@EqualsAndHashCode(callSuper = true)
@@ -40,12 +41,14 @@ public class MenuVO extends Menu implements INode {
/**
* 主键ID
*/
- private Integer id;
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long id;
/**
* 父节点ID
*/
- private Integer parentId;
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long parentId;
/**
* 子孙节点
@@ -53,6 +56,12 @@ public class MenuVO extends Menu implements INode {
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private List children;
+ /**
+ * 是否有子孙节点
+ */
+ @JsonInclude(JsonInclude.Include.NON_EMPTY)
+ private Boolean hasChildren;
+
@Override
public List getChildren() {
if (this.children == null) {
diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/ParamVO.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/ParamVO.java
index 50b7b571446cca86150f88a53c17bbea1f4f768c..b8c063e56b5c2d0de008998d80d65bc41e1517e0 100644
--- a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/ParamVO.java
+++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/ParamVO.java
@@ -24,7 +24,6 @@ import org.springblade.system.entity.Param;
* 视图实体类
*
* @author Chill
- * @since 2018-12-28
*/
@Data
@EqualsAndHashCode(callSuper = true)
diff --git a/blade-ops/blade-develop/src/main/resources/templates/entityDTO.java.vm b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/PostVO.java
similarity index 71%
rename from blade-ops/blade-develop/src/main/resources/templates/entityDTO.java.vm
rename to blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/PostVO.java
index a7f0512552f17ff01317ec0e72e32ab74b1a053f..dff4c498b6180deadbf3209f95935356f4afcfcd 100644
--- a/blade-ops/blade-develop/src/main/resources/templates/entityDTO.java.vm
+++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/PostVO.java
@@ -13,26 +13,27 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#set($dtoPackage=$package.Entity.replace("entity","dto"))
-package $!{dtoPackage};
+package org.springblade.system.vo;
-import $!{package.Entity}.$!{entity};
-#if($!{entityLombokModel})
+import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
-#end
+import org.springblade.system.entity.Post;
/**
- * $!{table.comment}数据传输对象实体类
+ * 岗位表视图实体类
*
- * @author $!{author}
- * @since $!{date}
+ * @author Chill
*/
-#if($!{entityLombokModel})
@Data
@EqualsAndHashCode(callSuper = true)
-#end
-public class $!{entity}DTO extends $!{entity} {
+@ApiModel(value = "PostVO对象", description = "岗位表")
+public class PostVO extends Post {
private static final long serialVersionUID = 1L;
+ /**
+ * 岗位分类名
+ */
+ private String categoryName;
+
}
diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/RegionVO.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/RegionVO.java
new file mode 100644
index 0000000000000000000000000000000000000000..9ff9259b404f55faf776405687333501abe791f2
--- /dev/null
+++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/RegionVO.java
@@ -0,0 +1,88 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * 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
+ *
+ * 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 org.springblade.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 org.springblade.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 {
+ 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 children;
+
+ @Override
+ public Long getId() {
+ return Func.toLong(this.getCode());
+ }
+
+ @Override
+ public Long getParentId() {
+ return Func.toLong(this.getParentCode());
+ }
+
+ @Override
+ public List getChildren() {
+ if (this.children == null) {
+ this.children = new ArrayList<>();
+ }
+ return this.children;
+ }
+}
diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/RoleMenuVO.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/RoleMenuVO.java
index 03b5643d7526b072615e809ec6a2697e2201ad52..d8099a1033f9e45557f41c7def0d5bba057e9483 100644
--- a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/RoleMenuVO.java
+++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/RoleMenuVO.java
@@ -24,7 +24,6 @@ import org.springblade.system.entity.RoleMenu;
* 视图实体类
*
* @author Chill
- * @since 2018-12-24
*/
@Data
@EqualsAndHashCode(callSuper = true)
diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/RoleVO.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/RoleVO.java
index 28792a0d13b006bbcde2f979183b0dc6517d0752..53f7bec4daddda3cd85d317abbec377f5a50b14a 100644
--- a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/RoleVO.java
+++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/RoleVO.java
@@ -16,6 +16,8 @@
package org.springblade.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;
@@ -29,7 +31,6 @@ import java.util.List;
* 视图实体类
*
* @author Chill
- * @since 2018-12-24
*/
@Data
@EqualsAndHashCode(callSuper = true)
@@ -40,12 +41,14 @@ public class RoleVO extends Role implements INode {
/**
* 主键ID
*/
- private Integer id;
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long id;
/**
* 父节点ID
*/
- private Integer parentId;
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long parentId;
/**
* 子孙节点
diff --git a/blade-service-api/blade-user-api/pom.xml b/blade-service-api/blade-user-api/pom.xml
index af115002e402179871502bae7b45a26e6a19519a..322fa35f127805e9799e6d1238ba619ff3cfc8cb 100644
--- a/blade-service-api/blade-user-api/pom.xml
+++ b/blade-service-api/blade-user-api/pom.xml
@@ -5,7 +5,7 @@
blade-service-apiorg.springblade
- 2.0.0
+ 3.4.14.0.0
diff --git a/blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/entity/User.java b/blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/entity/User.java
index c52747b71166d726def983812084c9e53e12c5ab..a38d1b24a5d808de3db6a00bdfc495ea6901047b 100644
--- a/blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/entity/User.java
+++ b/blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/entity/User.java
@@ -15,12 +15,17 @@
*/
package org.springblade.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 lombok.EqualsAndHashCode;
-import org.springblade.core.mp.base.BaseEntity;
+import org.springblade.core.mp.base.TenantEntity;
-import java.time.LocalDateTime;
+import java.util.Date;
/**
* 实体类
@@ -30,10 +35,23 @@ import java.time.LocalDateTime;
@Data
@TableName("blade_user")
@EqualsAndHashCode(callSuper = true)
-public class User extends BaseEntity {
+public class User extends TenantEntity {
private static final long serialVersionUID = 1L;
+ /**
+ * 主键id
+ */
+ @ApiModelProperty(value = "主键")
+ @TableId(value = "id", type = IdType.ASSIGN_ID)
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long id;
+
+
+ /**
+ * 编号
+ */
+ private String code;
/**
* 账号
*/
@@ -50,6 +68,10 @@ public class User extends BaseEntity {
* 真名
*/
private String realName;
+ /**
+ * 头像
+ */
+ private String avatar;
/**
* 邮箱
*/
@@ -61,7 +83,7 @@ public class User extends BaseEntity {
/**
* 生日
*/
- private LocalDateTime birthday;
+ private Date birthday;
/**
* 性别
*/
@@ -74,6 +96,10 @@ public class User extends BaseEntity {
* 部门id
*/
private String deptId;
+ /**
+ * 部门id
+ */
+ private String postId;
}
diff --git a/blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/entity/UserInfo.java b/blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/entity/UserInfo.java
index d5e85e6005114cabd4cf4187f4ee1419869daf65..bb171c6e28c834f62affacbec5af5a53365c797b 100644
--- a/blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/entity/UserInfo.java
+++ b/blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/entity/UserInfo.java
@@ -51,4 +51,10 @@ public class UserInfo implements Serializable {
@ApiModelProperty(value = "角色集合")
private List roles;
+ /**
+ * 第三方授权id
+ */
+ @ApiModelProperty(value = "第三方授权id")
+ private String oauthId;
+
}
diff --git a/blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/entity/UserOauth.java b/blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/entity/UserOauth.java
new file mode 100644
index 0000000000000000000000000000000000000000..e6c45fd034a5ea02d4c727e71b418e165ed540c1
--- /dev/null
+++ b/blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/entity/UserOauth.java
@@ -0,0 +1,107 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * 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
+ *
+ * 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
+ *
+ * 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 org.springblade.system.user.feign;
+
+import org.springblade.core.tool.api.R;
+import org.springblade.system.user.entity.User;
+import org.springblade.system.user.entity.UserInfo;
+import org.springblade.system.user.entity.UserOauth;
+import org.springframework.stereotype.Component;
+
+/**
+ * Feign失败配置
+ *
+ * @author Chill
+ */
+@Component
+public class IUserClientFallback implements IUserClient {
+
+ @Override
+ public R userInfo(Long userId) {
+ return R.fail("未获取到账号信息");
+ }
+
+ @Override
+ public R userInfo(String tenantId, String account, String password) {
+ return R.fail("未获取到账号信息");
+ }
+
+ @Override
+ public R userAuthInfo(UserOauth userOauth) {
+ return R.fail("未获取到账号信息");
+ }
+
+ @Override
+ public R saveUser(User user) {
+ return R.fail("创建用户失败");
+ }
+}
diff --git a/blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/vo/UserVO.java b/blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/vo/UserVO.java
index b8392f603fca1ca718912009e9f5b142d0b6a1a5..0f4f76733a76279f6377f18c3eafcdc93fc4c39a 100644
--- a/blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/vo/UserVO.java
+++ b/blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/vo/UserVO.java
@@ -15,51 +15,29 @@
*/
package org.springblade.system.user.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.system.user.entity.User;
-import java.util.ArrayList;
-import java.util.List;
-
/**
* 视图实体类
*
* @author Chill
- * @since 2018-12-24
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "UserVO对象", description = "UserVO对象")
-public class UserVO extends User implements INode {
+public class UserVO extends User {
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
- private Integer id;
-
- /**
- * 父节点ID
- */
- private Integer parentId;
-
- /**
- * 子孙节点
- */
- @JsonInclude(JsonInclude.Include.NON_EMPTY)
- private List children;
-
- @Override
- public List getChildren() {
- if (this.children == null) {
- this.children = new ArrayList<>();
- }
- return this.children;
- }
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long id;
/**
* 角色名
@@ -71,6 +49,11 @@ public class UserVO extends User implements INode {
*/
private String deptName;
+ /**
+ * 岗位名
+ */
+ private String postName;
+
/**
* 性别
*/
diff --git a/blade-service-api/pom.xml b/blade-service-api/pom.xml
index df61f043db63d6fc8bc0406e0283c3d19341eb78..585503a104cbb14ebdffa0a24a609375fe865687 100644
--- a/blade-service-api/pom.xml
+++ b/blade-service-api/pom.xml
@@ -5,13 +5,13 @@
SpringBladeorg.springblade
- 2.0.0
+ 3.4.14.0.0blade-service-api${project.artifactId}
- 2.0.0
+ 3.4.1pomSpringBlade 微服务API集合
@@ -20,6 +20,8 @@
blade-dict-apiblade-system-apiblade-user-api
+ blade-scope-api
+ blade-demo-api
diff --git a/blade-service/blade-demo/pom.xml b/blade-service/blade-demo/pom.xml
new file mode 100644
index 0000000000000000000000000000000000000000..772be98e2bd485415c2d48b8f318a100b03c5484
--- /dev/null
+++ b/blade-service/blade-demo/pom.xml
@@ -0,0 +1,40 @@
+
+
+
+ blade-service
+ org.springblade
+ 3.4.1
+
+ 4.0.0
+
+ blade-demo
+ ${project.artifactId}
+ ${blade.project.version}
+ jar
+
+
+
+ org.springblade
+ blade-core-boot
+ ${blade.tool.version}
+
+
+ org.springblade
+ blade-core-swagger
+ ${blade.tool.version}
+
+
+ org.springblade
+ blade-demo-api
+ ${blade.project.version}
+
+
+ com.baomidou
+ dynamic-datasource-spring-boot-starter
+ 2.5.6
+
+
+
+
diff --git a/blade-service/blade-demo/src/main/java/com/example/demo/DemoApplication.java b/blade-service/blade-demo/src/main/java/com/example/demo/DemoApplication.java
new file mode 100644
index 0000000000000000000000000000000000000000..5193c78c8af5ba8084595f258d52a7cd93578a00
--- /dev/null
+++ b/blade-service/blade-demo/src/main/java/com/example/demo/DemoApplication.java
@@ -0,0 +1,34 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * 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
+ *
+ * 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 com.example.demo;
+
+import org.springblade.core.cloud.client.BladeCloudApplication;
+import org.springblade.core.launch.BladeApplication;
+
+/**
+ * Demo启动器
+ *
+ * @author Chill
+ */
+@BladeCloudApplication
+public class DemoApplication {
+
+ public static void main(String[] args) {
+ BladeApplication.run("blade-demo", DemoApplication.class, args);
+ }
+
+}
+
diff --git a/blade-service/blade-demo/src/main/java/com/example/demo/config/DemoConfiguration.java b/blade-service/blade-demo/src/main/java/com/example/demo/config/DemoConfiguration.java
new file mode 100644
index 0000000000000000000000000000000000000000..88c992749439830ea83eac2246a0339ecf2c351e
--- /dev/null
+++ b/blade-service/blade-demo/src/main/java/com/example/demo/config/DemoConfiguration.java
@@ -0,0 +1,36 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * 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
+ *
+ * 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 com.example.demo.config;
+
+
+import com.example.demo.props.DemoProperties;
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * 配置feign、mybatis包名、properties
+ *
+ * @author Chill
+ */
+@Configuration(proxyBeanMethods = false)
+@EnableFeignClients({"org.springblade", "com.example"})
+@MapperScan({"org.springblade.**.mapper.**", "com.example.**.mapper.**"})
+@EnableConfigurationProperties(DemoProperties.class)
+public class DemoConfiguration {
+
+}
diff --git a/blade-service/blade-demo/src/main/java/com/example/demo/controller/DemoController.java b/blade-service/blade-demo/src/main/java/com/example/demo/controller/DemoController.java
new file mode 100644
index 0000000000000000000000000000000000000000..62106fe718894f14b37c1fed950d1796fab15e5c
--- /dev/null
+++ b/blade-service/blade-demo/src/main/java/com/example/demo/controller/DemoController.java
@@ -0,0 +1,57 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * 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
+ *
+ * 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 com.example.demo.controller;
+
+import com.example.demo.props.DemoProperties;
+import io.swagger.annotations.Api;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.cloud.context.config.annotation.RefreshScope;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * Demo控制器
+ *
+ * @author Chill
+ */
+@RefreshScope
+@RestController
+@RequestMapping("demo")
+@Api(value = "配置接口", tags = "即时刷新配置")
+public class DemoController {
+
+ @Value("${demo.name}")
+ private String name;
+
+ private final DemoProperties properties;
+
+ public DemoController(DemoProperties properties) {
+ this.properties = properties;
+ }
+
+
+ @GetMapping("name")
+ public String getName() {
+ return name;
+ }
+
+ @GetMapping("name-by-props")
+ public String getNameByProps() {
+ return properties.getName();
+ }
+
+}
diff --git a/blade-service/blade-demo/src/main/java/com/example/demo/controller/DynamicController.java b/blade-service/blade-demo/src/main/java/com/example/demo/controller/DynamicController.java
new file mode 100644
index 0000000000000000000000000000000000000000..6ba52cdd4a4e84ebb74bcc66161a72f7bd0adc1c
--- /dev/null
+++ b/blade-service/blade-demo/src/main/java/com/example/demo/controller/DynamicController.java
@@ -0,0 +1,66 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * 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
+ *
+ * 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 com.example.demo.controller;
+
+import com.example.demo.entity.Notice;
+import com.example.demo.service.IDynamicService;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import org.springblade.core.tool.api.R;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * 多数据源
+ *
+ * @author Chill
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("dynamic")
+@Api(value = "多数据源接口", tags = "多数据源")
+public class DynamicController {
+
+ private IDynamicService dynamicService;
+
+ /**
+ * master列表
+ */
+ @GetMapping("/master-list")
+ @ApiOperationSupport(order = 1)
+ @ApiOperation(value = "master列表", notes = "master列表")
+ public R> masterList() {
+ List list = dynamicService.masterList();
+ return R.data(list);
+ }
+
+ /**
+ * slave列表
+ */
+ @GetMapping("/slave-list")
+ @ApiOperationSupport(order = 1)
+ @ApiOperation(value = "slave列表", notes = "slave列表")
+ public R> slaveList() {
+ List list = dynamicService.slaveList();
+ return R.data(list);
+ }
+
+}
diff --git a/blade-service/blade-demo/src/main/java/com/example/demo/controller/NoticeController.java b/blade-service/blade-demo/src/main/java/com/example/demo/controller/NoticeController.java
new file mode 100644
index 0000000000000000000000000000000000000000..3736d7b4e7e4ac2ff5ae019b3ddebbb94b051d29
--- /dev/null
+++ b/blade-service/blade-demo/src/main/java/com/example/demo/controller/NoticeController.java
@@ -0,0 +1,115 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * 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
+ *
+ * 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 com.example.demo.controller;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.example.demo.entity.Notice;
+import com.example.demo.service.INoticeService;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import io.swagger.annotations.*;
+import lombok.AllArgsConstructor;
+import org.springblade.common.cache.CacheNames;
+import org.springblade.core.boot.ctrl.BladeController;
+import org.springblade.core.mp.support.Condition;
+import org.springblade.core.mp.support.Query;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.Func;
+import org.springframework.web.bind.annotation.*;
+import springfox.documentation.annotations.ApiIgnore;
+
+import java.util.Map;
+
+/**
+ * 控制器
+ *
+ * @author Chill
+ */
+@RestController
+@RequestMapping("notice")
+@AllArgsConstructor
+@Api(value = "用户博客", tags = "博客接口")
+public class NoticeController extends BladeController implements CacheNames {
+
+ private INoticeService noticeService;
+
+ /**
+ * 详情
+ */
+ @GetMapping("/detail")
+ @ApiOperationSupport(order = 1)
+ @ApiOperation(value = "详情", notes = "传入notice")
+ public R detail(Notice notice) {
+ Notice detail = noticeService.getOne(Condition.getQueryWrapper(notice));
+ return R.data(detail);
+ }
+
+ /**
+ * 分页
+ */
+ @GetMapping("/list")
+ @ApiImplicitParams({
+ @ApiImplicitParam(name = "category", value = "公告类型", paramType = "query", dataType = "integer"),
+ @ApiImplicitParam(name = "title", value = "公告标题", paramType = "query", dataType = "string")
+ })
+ @ApiOperationSupport(order = 2)
+ @ApiOperation(value = "分页", notes = "传入notice")
+ public R> list(@ApiIgnore @RequestParam Map notice, Query query) {
+ IPage pages = noticeService.page(Condition.getPage(query), Condition.getQueryWrapper(notice, Notice.class));
+ return R.data(pages);
+ }
+
+ /**
+ * 新增
+ */
+ @PostMapping("/save")
+ @ApiOperationSupport(order = 3)
+ @ApiOperation(value = "新增", notes = "传入notice")
+ public R save(@RequestBody Notice notice) {
+ return R.status(noticeService.save(notice));
+ }
+
+ /**
+ * 修改
+ */
+ @PostMapping("/update")
+ @ApiOperationSupport(order = 4)
+ @ApiOperation(value = "修改", notes = "传入notice")
+ public R update(@RequestBody Notice notice) {
+ return R.status(noticeService.updateById(notice));
+ }
+
+ /**
+ * 新增或修改
+ */
+ @PostMapping("/submit")
+ @ApiOperationSupport(order = 5)
+ @ApiOperation(value = "新增或修改", notes = "传入notice")
+ public R submit(@RequestBody Notice notice) {
+ return R.status(noticeService.saveOrUpdate(notice));
+ }
+
+ /**
+ * 删除
+ */
+ @PostMapping("/remove")
+ @ApiOperationSupport(order = 6)
+ @ApiOperation(value = "逻辑删除", notes = "传入notice")
+ public R remove(@ApiParam(value = "主键集合") @RequestParam String ids) {
+ boolean temp = noticeService.deleteLogic(Func.toLongList(ids));
+ return R.status(temp);
+ }
+
+}
diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/ParamWrapper.java b/blade-service/blade-demo/src/main/java/com/example/demo/feign/NoticeClient.java
similarity index 55%
rename from blade-service/blade-system/src/main/java/org/springblade/system/wrapper/ParamWrapper.java
rename to blade-service/blade-demo/src/main/java/com/example/demo/feign/NoticeClient.java
index f8110392b4a2100022ef12a0f6bdaf472f2d86d0..b87b54fd6900682325580c0950d5ced78d327c60 100644
--- a/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/ParamWrapper.java
+++ b/blade-service/blade-demo/src/main/java/com/example/demo/feign/NoticeClient.java
@@ -13,30 +13,34 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springblade.system.wrapper;
+package com.example.demo.feign;
+import com.example.demo.entity.Notice;
+import com.example.demo.mapper.NoticeMapper;
import lombok.AllArgsConstructor;
-import org.springblade.core.mp.support.BaseEntityWrapper;
-import org.springblade.core.tool.utils.BeanUtil;
-import org.springblade.system.entity.Param;
-import org.springblade.system.feign.IDictClient;
-import org.springblade.system.vo.ParamVO;
+import org.springblade.core.tool.api.R;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RestController;
+import springfox.documentation.annotations.ApiIgnore;
+
+import java.util.List;
/**
- * 包装类,返回视图层所需的字段
+ * Notice Feign
*
* @author Chill
- * @since 2018-12-28
*/
+@ApiIgnore()
+@RestController
@AllArgsConstructor
-public class ParamWrapper extends BaseEntityWrapper {
+public class NoticeClient implements INoticeClient {
- private IDictClient dictClient;
+ private NoticeMapper mapper;
@Override
- public ParamVO entityVO(Param param) {
- ParamVO paramVO = BeanUtil.copy(param, ParamVO.class);
- return paramVO;
+ @GetMapping(TOP)
+ public R> top(Integer number) {
+ return R.data(mapper.topList(number));
}
}
diff --git a/blade-service/blade-demo/src/main/java/com/example/demo/launcher/DemoLauncherServiceImpl.java b/blade-service/blade-demo/src/main/java/com/example/demo/launcher/DemoLauncherServiceImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..c1f967d4f7e49d79f19e7340de5ffeeead1ebf65
--- /dev/null
+++ b/blade-service/blade-demo/src/main/java/com/example/demo/launcher/DemoLauncherServiceImpl.java
@@ -0,0 +1,47 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * 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
+ *
+ * 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 com.example.demo.launcher;
+
+import org.springblade.core.launch.constant.NacosConstant;
+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 Chill
+ */
+public class DemoLauncherServiceImpl implements LauncherService {
+
+ @Override
+ public void launcher(SpringApplicationBuilder builder, String appName, String profile) {
+ Properties props = System.getProperties();
+ PropsUtil.setProperty(props, "spring.cloud.nacos.config.ext-config[0].data-id", NacosConstant.dataId("blade-demo", profile));
+ PropsUtil.setProperty(props, "spring.cloud.nacos.config.ext-config[0].group", NacosConstant.NACOS_CONFIG_GROUP);
+ PropsUtil.setProperty(props, "spring.cloud.nacos.config.ext-config[0].refresh", NacosConstant.NACOS_CONFIG_REFRESH);
+ // 自定义命名空间
+ // PropsUtil.setProperty(props, "spring.cloud.nacos.config.namespace", LauncherConstant.NACOS_NAMESPACE);
+ // PropsUtil.setProperty(props, "spring.cloud.nacos.discovery.namespace", LauncherConstant.NACOS_NAMESPACE);
+ }
+
+ @Override
+ public int getOrder() {
+ return 20;
+ }
+}
diff --git a/blade-service/blade-demo/src/main/java/com/example/demo/mapper/NoticeMapper.java b/blade-service/blade-demo/src/main/java/com/example/demo/mapper/NoticeMapper.java
new file mode 100644
index 0000000000000000000000000000000000000000..a69dbd8d4ca3c48559b27020204e3296eb45142c
--- /dev/null
+++ b/blade-service/blade-demo/src/main/java/com/example/demo/mapper/NoticeMapper.java
@@ -0,0 +1,46 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * 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
+ *
+ * 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 com.example.demo.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.example.demo.entity.Notice;
+
+import java.util.List;
+
+/**
+ * Mapper 接口
+ *
+ * @author Chill
+ */
+public interface NoticeMapper extends BaseMapper {
+
+ /**
+ * 前N条数据
+ * @param number
+ * @return
+ */
+ List topList(Integer number);
+
+ /**
+ * 自定义分页
+ * @param page
+ * @param notice
+ * @return
+ */
+ List selectNoticePage(IPage page, Notice notice);
+
+}
diff --git a/blade-service/blade-demo/src/main/java/com/example/demo/mapper/NoticeMapper.xml b/blade-service/blade-demo/src/main/java/com/example/demo/mapper/NoticeMapper.xml
new file mode 100644
index 0000000000000000000000000000000000000000..046ca1354815d657ca7a6695d0197bc20d8825e6
--- /dev/null
+++ b/blade-service/blade-demo/src/main/java/com/example/demo/mapper/NoticeMapper.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ select id,
+ create_user AS createUser,
+ create_time AS createTime,
+ update_user AS updateUser,
+ update_time AS updateTime,
+ status,
+ is_deleted AS isDeleted,
+ title, content
+
+
+
+
+
+
+
diff --git a/blade-service/blade-demo/src/main/java/com/example/demo/props/DemoProperties.java b/blade-service/blade-demo/src/main/java/com/example/demo/props/DemoProperties.java
new file mode 100644
index 0000000000000000000000000000000000000000..7c3f700437aa2ce244fee1179eee6c8b11a0a145
--- /dev/null
+++ b/blade-service/blade-demo/src/main/java/com/example/demo/props/DemoProperties.java
@@ -0,0 +1,18 @@
+package com.example.demo.props;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+/**
+ * DemoProperties
+ *
+ * @author Chill
+ */
+@Data
+@ConfigurationProperties(prefix = "demo")
+public class DemoProperties {
+ /**
+ * 名称
+ */
+ private String name;
+}
diff --git a/blade-service/blade-demo/src/main/java/com/example/demo/service/IDynamicService.java b/blade-service/blade-demo/src/main/java/com/example/demo/service/IDynamicService.java
new file mode 100644
index 0000000000000000000000000000000000000000..5eb5a14196da7240d9cc29ff9c39b47f6021c075
--- /dev/null
+++ b/blade-service/blade-demo/src/main/java/com/example/demo/service/IDynamicService.java
@@ -0,0 +1,44 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * 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
+ *
+ * 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 com.example.demo.service;
+
+import com.example.demo.entity.Notice;
+import org.springblade.core.mp.base.BaseService;
+
+import java.util.List;
+
+/**
+ * 服务类
+ *
+ * @author Chill
+ */
+public interface IDynamicService extends BaseService {
+
+ /**
+ * master数据源的列表
+ *
+ * @return
+ */
+ List masterList();
+
+ /**
+ * slave数据源的列表
+ *
+ * @return
+ */
+ List slaveList();
+
+}
diff --git a/blade-service/blade-demo/src/main/java/com/example/demo/service/INoticeService.java b/blade-service/blade-demo/src/main/java/com/example/demo/service/INoticeService.java
new file mode 100644
index 0000000000000000000000000000000000000000..1bf17fd5bb997cc45ebed6118b7470fe6918bed6
--- /dev/null
+++ b/blade-service/blade-demo/src/main/java/com/example/demo/service/INoticeService.java
@@ -0,0 +1,37 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * 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
+ *
+ * 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 com.example.demo.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.springblade.core.mp.base.BaseService;
+import com.example.demo.entity.Notice;
+
+/**
+ * 服务类
+ *
+ * @author Chill
+ */
+public interface INoticeService extends BaseService {
+
+ /**
+ * 自定义分页
+ * @param page
+ * @param notice
+ * @return
+ */
+ IPage selectNoticePage(IPage page, Notice notice);
+
+}
diff --git a/blade-service/blade-demo/src/main/java/com/example/demo/service/impl/DynamicServiceImpl.java b/blade-service/blade-demo/src/main/java/com/example/demo/service/impl/DynamicServiceImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..64dd1b627bd3fa6094444af21c66206ec0cdfb78
--- /dev/null
+++ b/blade-service/blade-demo/src/main/java/com/example/demo/service/impl/DynamicServiceImpl.java
@@ -0,0 +1,30 @@
+package com.example.demo.service.impl;
+
+import com.baomidou.dynamic.datasource.annotation.DS;
+import com.example.demo.entity.Notice;
+import com.example.demo.mapper.NoticeMapper;
+import com.example.demo.service.IDynamicService;
+import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * DynamicServiceImpl
+ *
+ * @author Chill
+ */
+@Service
+public class DynamicServiceImpl extends BaseServiceImpl implements IDynamicService {
+
+ @Override
+ public List masterList() {
+ return this.list();
+ }
+
+ @Override
+ @DS("slave")
+ public List slaveList() {
+ return this.list();
+ }
+}
diff --git a/blade-service/blade-demo/src/main/java/com/example/demo/service/impl/NoticeServiceImpl.java b/blade-service/blade-demo/src/main/java/com/example/demo/service/impl/NoticeServiceImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..d31519c192c108367a96319530db2a5e4d2697b7
--- /dev/null
+++ b/blade-service/blade-demo/src/main/java/com/example/demo/service/impl/NoticeServiceImpl.java
@@ -0,0 +1,38 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * 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
+ *