diff --git a/.gitignore b/.gitignore index 83e50754d82b0e8c701583f6cbb1642b253bc970..5850020e56eb945e4164a32fb627ede3b8817e72 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,7 @@ Thumbs.db *.war *.ear /target + +# Flattened pom +.flattened-pom.xml +/**/.flattened-pom.xml diff --git a/LICENSE b/LICENSE index ef4e4debf19abe5e0bb637f14115da5d1cd82de8..bee99db2858fa3f2e5cb9e9df04f41f2bcd15162 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 2023 BladeX (https://bladex.cn) 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..f64f14a0123842748503ef05555e125f09c6e721 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,45 @@ -## 简介 -* 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从流量控制、熔断降级、系统负载保护等多个维度保护服务的稳定性。 +
+ +## SpringBlade微服务开发平台 +* 采用前后端分离的模式,前端开源两个框架:[Sword](https://gitee.com/smallc/Sword) (基于 React、Ant Design)、[Saber](https://gitee.com/smallc/Saber) (基于 Vue、Element-UI) +* 后端采用SpringCloud全家桶,并同时对其基础组件做了高度的封装,单独开源出一个框架:[BladeTool](https://gitee.com/smallc/blade-tool) +* [BladeTool](https://github.com/chillzhuang/blade-tool)已推送至Maven中央库,直接引入即可,减少了工程的臃肿,也可更注重于业务开发 +* 集成Sentinel从流量控制、熔断降级、系统负载等多个维度保护服务的稳定性。 * 注册中心、配置中心选型Nacos,为工程瘦身的同时加强各模块之间的联动。 -* 使用Traefik进行反向代理,监听后台变化自动化应用新的配置文件。 -* 部署使用Docker或K8s + Jenkins -* 踩了踩Kong的坑,有个基本的使用方案,但不深入,因为涉及到OpenResty。 -* 封装了简单的Secure模块,采用JWT做Token认证,可拓展集成Redis等细颗粒度控制方案 -* 在2.0诞生之前,已经稳定生产了近一年,经历了从Camden -> Finchley的技术架构,也经历了从fat jar -> docker -> k8s + jenkins的部署架构 +* 极简封装了多租户底层,用更少的代码换来拓展性更强的SaaS多租户系统。 +* 借鉴OAuth2,自研多终端认证系统,可控制子系统的token权限互相隔离。 +* 借鉴Security,自研Secure模块,采用JWT做Token认证,可拓展集成Redis等细颗粒度控制方案。 +* 稳定生产了六年,经历了从 Camden -> Hoxton -> 2023 的技术架构,也经历了从fat jar -> docker -> k8s + jenkins的部署架构。 * 项目分包明确,规范微服务的开发模式,使包与包之间的分工清晰。 -## 会员计划及交流群 -* [会员计划及交流群](https://gitee.com/smallc/SpringBlade/wikis/SpringBlade会员计划) +## 架构图 +![]() |
+ ![]() |
+
![]() |
- ![]() |
-
![]() |
- ![]() |
-
![]() |
- ![]() |
-
![]() |
- ![]() |
-
![]() |
- ![]() |
-
![]() |
- ![]() |
-
![]() |
- ![]() |
-
![]() |
- ![]() |
-
![]() |
- ![]() |
-
![]() |
- ![]() |
-
![]() |
- ![]() |
-
* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,18 +16,16 @@ package org.springblade.auth; +import org.springblade.core.cloud.client.BladeCloudApplication; import org.springblade.core.launch.BladeApplication; import org.springblade.core.launch.constant.AppConstant; -import org.springframework.cloud.client.SpringCloudApplication; -import org.springframework.cloud.openfeign.EnableFeignClients; /** * 用户认证服务器 * * @author Chill */ -@SpringCloudApplication -@EnableFeignClients(AppConstant.BASE_PACKAGES) +@BladeCloudApplication public class AuthApplication { public static void main(String[] args) { diff --git a/blade-auth/src/main/java/org/springblade/auth/controller/AuthController.java b/blade-auth/src/main/java/org/springblade/auth/controller/AuthController.java index 21726e296c3ccc39f614b0f1d3a2f3d60c1eaae5..6c0a7aa6d4d42e038208fbf24bdacee69b4642c1 100644 --- a/blade-auth/src/main/java/org/springblade/auth/controller/AuthController.java +++ b/blade-auth/src/main/java/org/springblade/auth/controller/AuthController.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). + * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com). *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,25 +15,30 @@
*/
package org.springblade.auth.controller;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
+import com.wf.captcha.SpecCaptcha;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
-import org.springblade.core.log.annotation.ApiLog;
+import org.springblade.auth.granter.ITokenGranter;
+import org.springblade.auth.granter.TokenGranterBuilder;
+import org.springblade.auth.granter.TokenParameter;
+import org.springblade.auth.utils.TokenUtil;
+import org.springblade.common.cache.CacheNames;
+import org.springblade.core.redis.cache.BladeRedis;
import org.springblade.core.secure.AuthInfo;
-import org.springblade.core.secure.utils.SecureUtil;
import org.springblade.core.tool.api.R;
-import org.springblade.core.tool.utils.DigestUtil;
+import org.springblade.core.tool.support.Kv;
import org.springblade.core.tool.utils.Func;
-import org.springblade.system.user.entity.User;
+import org.springblade.core.tool.utils.WebUtil;
import org.springblade.system.user.entity.UserInfo;
-import org.springblade.system.user.feign.IUserClient;
+import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
/**
* 认证模块
@@ -42,52 +47,56 @@ import java.util.Map;
*/
@RestController
@AllArgsConstructor
-@Api(value = "用户授权认证", tags = "授权接口")
+@Tag(name = "用户授权认证", description = "授权接口")
public class AuthController {
- IUserClient client;
+ private BladeRedis bladeRedis;
- @ApiLog("登录用户验证")
@PostMapping("token")
- @ApiOperation(value = "获取认证token", notes = "传入账号:account,密码:password")
- public R
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springblade.auth.controller;
+
+import io.swagger.v3.oas.annotations.tags.Tag;
+import io.swagger.v3.oas.annotations.Operation;
+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 jakarta.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * 第三方登陆端点
+ *
+ * @author Chill
+ */
+@Slf4j
+@RestController
+@AllArgsConstructor
+@ConditionalOnProperty(value = "social.enabled", havingValue = "true")
+@Tag(name = "第三方登陆", description = "第三方登陆端点")
+public class SocialController {
+
+ private final SocialProperties socialProperties;
+
+ /**
+ * 授权完毕跳转
+ */
+ @Operation(summary = "授权完毕跳转")
+ @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);
+ }
+
+ /**
+ * 获取认证信息
+ */
+ @Operation(summary = "获取认证信息")
+ @RequestMapping("/oauth/callback/{source}")
+ public Object login(@PathVariable("source") String source, AuthCallback callback) {
+ AuthRequest authRequest = SocialUtil.getAuthRequest(source, socialProperties);
+ return authRequest.login(callback);
+ }
+
+ /**
+ * 撤销授权
+ */
+ @Operation(summary = "撤销授权")
+ @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
+ */
+ @Operation(summary = "续期令牌")
+ @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-service/blade-system/src/main/java/org/springblade/system/wrapper/ParamWrapper.java b/blade-auth/src/main/java/org/springblade/auth/enums/BladeUserEnum.java
similarity index 50%
rename from blade-service/blade-system/src/main/java/org/springblade/system/wrapper/ParamWrapper.java
rename to blade-auth/src/main/java/org/springblade/auth/enums/BladeUserEnum.java
index f8110392b4a2100022ef12a0f6bdaf472f2d86d0..2b218d54032918241c6f138aa5e203828d9ed2f6 100644
--- a/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/ParamWrapper.java
+++ b/blade-auth/src/main/java/org/springblade/auth/enums/BladeUserEnum.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,30 +13,32 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springblade.system.wrapper;
+package org.springblade.auth.enums;
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 lombok.Getter;
/**
- * 包装类,返回视图层所需的字段
+ * 用户类型枚举
*
* @author Chill
- * @since 2018-12-28
*/
+@Getter
@AllArgsConstructor
-public class ParamWrapper extends BaseEntityWrapper {
+public enum BladeUserEnum {
- private IDictClient dictClient;
+ /**
+ * web
+ */
+ WEB("web", 1),
- @Override
- public ParamVO entityVO(Param param) {
- ParamVO paramVO = BeanUtil.copy(param, ParamVO.class);
- return paramVO;
- }
+ /**
+ * 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..a078197090c9bbe0d37f68dee41a3de52221b9c1
--- /dev/null
+++ b/blade-auth/src/main/java/org/springblade/auth/granter/CaptchaTokenGranter.java
@@ -0,0 +1,107 @@
+/**
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springblade.auth.granter;
+
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+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.redis.cache.BladeRedis;
+import org.springblade.core.secure.props.BladeAuthProperties;
+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 jakarta.servlet.http.HttpServletRequest;
+
+import java.time.Duration;
+
+/**
+ * 验证码TokenGranter
+ *
+ * @author Chill
+ */
+@Slf4j
+@Component
+@AllArgsConstructor
+public class CaptchaTokenGranter implements ITokenGranter {
+
+ public static final String GRANT_TYPE = "captcha";
+ public static final Integer FAIL_COUNT = 5;
+
+ private IUserClient userClient;
+ private BladeRedis bladeRedis;
+
+ private BladeAuthProperties authProperties;
+
+ @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 = Func.toStr(bladeRedis.getAndDel(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");
+
+ // 判断登录是否锁定
+ int cnt = Func.toInt(bladeRedis.get(CacheNames.tenantKey(tenantId, CacheNames.USER_FAIL_KEY, account)), 0);
+ if (cnt >= FAIL_COUNT) {
+ log.error("用户登录失败次数过多, 账号:{}, IP:{}", account, WebUtil.getIP());
+ throw new ServiceException(TokenUtil.USER_HAS_TOO_MANY_FAILS);
+ }
+
+ UserInfo userInfo = null;
+ if (Func.isNoneBlank(account, password)) {
+ // 获取用户类型
+ String userType = tokenParameter.getArgs().getStr("userType");
+ // 解密密码
+ String decryptPassword = TokenUtil.decryptPassword(password, authProperties.getPublicKey(), authProperties.getPrivateKey());
+ // 定义返回结果
+ R
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package 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-auth/src/main/java/org/springblade/auth/granter/PasswordTokenGranter.java b/blade-auth/src/main/java/org/springblade/auth/granter/PasswordTokenGranter.java
new file mode 100644
index 0000000000000000000000000000000000000000..201d8094d25fb0463c66140ffd12d8992e4b3379
--- /dev/null
+++ b/blade-auth/src/main/java/org/springblade/auth/granter/PasswordTokenGranter.java
@@ -0,0 +1,96 @@
+/**
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springblade.auth.granter;
+
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+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.redis.cache.BladeRedis;
+import org.springblade.core.secure.props.BladeAuthProperties;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.DigestUtil;
+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.feign.IUserClient;
+import org.springframework.stereotype.Component;
+
+import java.time.Duration;
+
+/**
+ * PasswordTokenGranter
+ *
+ * @author Chill
+ */
+@Slf4j
+@Component
+@AllArgsConstructor
+public class PasswordTokenGranter implements ITokenGranter {
+
+ public static final String GRANT_TYPE = "password";
+ public static final Integer FAIL_COUNT = 5;
+
+ private IUserClient userClient;
+ private BladeRedis bladeRedis;
+
+ private BladeAuthProperties authProperties;
+
+ @Override
+ public UserInfo grant(TokenParameter tokenParameter) {
+ String tenantId = tokenParameter.getArgs().getStr("tenantId");
+ String account = tokenParameter.getArgs().getStr("account");
+ String password = tokenParameter.getArgs().getStr("password");
+
+ // 判断登录是否锁定
+ int cnt = Func.toInt(bladeRedis.get(CacheNames.tenantKey(tenantId, CacheNames.USER_FAIL_KEY, account)), 0);
+ if (cnt >= FAIL_COUNT) {
+ log.error("用户登录失败次数过多, 账号:{}, IP:{}", account, WebUtil.getIP());
+ throw new ServiceException(TokenUtil.USER_HAS_TOO_MANY_FAILS);
+ }
+
+ UserInfo userInfo = null;
+ if (Func.isNoneBlank(account, password)) {
+ // 获取用户类型
+ String userType = tokenParameter.getArgs().getStr("userType");
+ // 解密密码
+ String decryptPassword = TokenUtil.decryptPassword(password, authProperties.getPublicKey(), authProperties.getPrivateKey());
+ // 定义返回结果
+ R
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -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
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package 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 jakarta.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.copyProperties(authUser, UserOauth.class));
+ userOauth.setSource(authUser.getSource());
+ userOauth.setTenantId(tenantId);
+ userOauth.setUuid(authUser.getUuid());
+ // 远程调用,获取认证信息
+ R
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package 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
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package 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..daf679487ed044c43beb5f8ce38635b319e035ed
--- /dev/null
+++ b/blade-auth/src/main/java/org/springblade/auth/utils/TokenUtil.java
@@ -0,0 +1,132 @@
+/**
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springblade.auth.utils;
+
+import org.springblade.core.launch.constant.TokenConstant;
+import org.springblade.core.secure.AuthInfo;
+import org.springblade.core.secure.TokenInfo;
+import org.springblade.core.secure.utils.SecureUtil;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.core.tool.utils.SM2Util;
+import org.springblade.core.tool.utils.StringPool;
+import org.springblade.core.tool.utils.StringUtil;
+import org.springblade.system.user.entity.User;
+import org.springblade.system.user.entity.UserInfo;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 认证工具类
+ *
+ * @author Chill
+ */
+public class TokenUtil {
+
+ public final static String CAPTCHA_HEADER_KEY = "Captcha-Key";
+ public final static String CAPTCHA_HEADER_CODE = "Captcha-Code";
+ public final static String CAPTCHA_NOT_CORRECT = "验证码不正确";
+ public final static String TENANT_HEADER_KEY = "Tenant-Id";
+ public final static String DEFAULT_TENANT_ID = "000000";
+ public final static String USER_TYPE_HEADER_KEY = "User-Type";
+ public final static String DEFAULT_USER_TYPE = "web";
+ public final static String USER_NOT_FOUND = "用户名或密码错误";
+ public final static String HEADER_KEY = "Authorization";
+ public final static String HEADER_PREFIX = "Basic ";
+ public final static String ENCRYPT_PREFIX = "04";
+ public final static String USER_HAS_TOO_MANY_FAILS = "用户登录失败次数过多";
+ public final static String DEFAULT_AVATAR = "https://bladex.cn/images/logo.png";
+
+ /**
+ * 创建认证token
+ *
+ * @param userInfo 用户信息
+ * @return token
+ */
+ public static AuthInfo createAuthInfo(UserInfo userInfo) {
+ User user = userInfo.getUser();
+
+ //设置jwt参数
+ Map
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,9 +22,31 @@ package org.springblade.common.cache;
*/
public interface CacheNames {
- String NOTICE_ONE = "NOTICE_ONE";
+ String NOTICE_ONE = "notice:one";
- String DICT_VALUE = "DICT_VALUE";
- String DICT_LIST = "DICT_LIST";
+ String DICT_VALUE = "dict:value";
+ String DICT_LIST = "dict:list";
+
+ /**
+ * 验证码key
+ */
+ String CAPTCHA_KEY = "blade:auth::blade:captcha:";
+
+ /**
+ * 登录失败key
+ */
+ String USER_FAIL_KEY = "blade:user::blade:fail:";
+
+ /**
+ * 返回租户格式的key
+ *
+ * @param tenantId 租户编号
+ * @param cacheKey 缓存key
+ * @param cacheKeyValue 缓存key值
+ * @return tenantKey
+ */
+ static String tenantKey(String tenantId, String cacheKey, String cacheKeyValue) {
+ return tenantId.concat(":").concat(cacheKey).concat(cacheKeyValue);
+ }
}
diff --git a/blade-common/src/main/java/org/springblade/common/config/BladeCommonConfiguration.java b/blade-common/src/main/java/org/springblade/common/config/BladeCommonConfiguration.java
index e8bfb1ab2ff487281e8d4af283c0df7b79dd812a..ed34ca23a46a5d97a0e11c78bd098d09569af6c0 100644
--- a/blade-common/src/main/java/org/springblade/common/config/BladeCommonConfiguration.java
+++ b/blade-common/src/main/java/org/springblade/common/config/BladeCommonConfiguration.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,7 +24,7 @@ import org.springframework.context.annotation.Configuration;
*
* @author Chill
*/
-@Configuration
+@Configuration(proxyBeanMethods = false)
@AllArgsConstructor
public class BladeCommonConfiguration {
diff --git a/blade-common/src/main/java/org/springblade/common/constant/CommonConstant.java b/blade-common/src/main/java/org/springblade/common/constant/CommonConstant.java
index 76f5e89dbbdd6cf057bfd5ba0adb7d7623b38aa3..698604fa7471e396b4c1ba0d536199e42c114eed 100644
--- a/blade-common/src/main/java/org/springblade/common/constant/CommonConstant.java
+++ b/blade-common/src/main/java/org/springblade/common/constant/CommonConstant.java
@@ -8,29 +8,19 @@ package org.springblade.common.constant;
public interface CommonConstant {
/**
- * nacos dev 地址
+ * sword 系统名
*/
- String NACOS_DEV_ADDR = "127.0.0.1:8848";
+ String SWORD_NAME = "sword";
/**
- * nacos prod 地址
+ * saber 系统名
*/
- String NACOS_PROD_ADDR = "192.168.186.129:8848";
-
- /**
- * sentinel dev 地址
- */
- String SENTINEL_DEV_ADDR = "127.0.0.1:8858";
-
- /**
- * sentinel prod 地址
- */
- String SENTINEL_PROD_ADDR = "192.168.186.129:8858";
+ String SABER_NAME = "saber";
/**
* 顶级父节点id
*/
- Integer TOP_PARENT_ID = 0;
+ Long TOP_PARENT_ID = 0L;
/**
* 顶级父节点名称
diff --git a/blade-common/src/main/java/org/springblade/common/constant/LauncherConstant.java b/blade-common/src/main/java/org/springblade/common/constant/LauncherConstant.java
new file mode 100644
index 0000000000000000000000000000000000000000..4be5147398e8cb4108afe1eb93814efb7b8f076a
--- /dev/null
+++ b/blade-common/src/main/java/org/springblade/common/constant/LauncherConstant.java
@@ -0,0 +1,123 @@
+package org.springblade.common.constant;
+
+import org.springblade.core.launch.constant.AppConstant;
+
+/**
+ * 通用常量
+ *
+ * @author Chill
+ */
+public interface LauncherConstant {
+
+ /**
+ * nacos 用户名
+ */
+ String NACOS_USERNAME = "nacos";
+
+ /**
+ * nacos 密码
+ */
+ String NACOS_PASSWORD = "nacos";
+
+ /**
+ * nacos namespace id
+ */
+ String NACOS_NAMESPACE = "f447a694-519a-4255-95f9-bcbb5a5d636";
+
+ /**
+ * nacos dev 地址
+ */
+ String NACOS_DEV_ADDR = "127.0.0.1:8848";
+
+ /**
+ * nacos prod 地址
+ */
+ String NACOS_PROD_ADDR = "172.30.0.48:8848";
+
+ /**
+ * nacos test 地址
+ */
+ String NACOS_TEST_ADDR = "172.30.0.48:8848";
+
+ /**
+ * sentinel dev 地址
+ */
+ String SENTINEL_DEV_ADDR = "127.0.0.1:8858";
+
+ /**
+ * sentinel prod 地址
+ */
+ String SENTINEL_PROD_ADDR = "172.30.0.58:8858";
+
+ /**
+ * sentinel test 地址
+ */
+ String SENTINEL_TEST_ADDR = "172.30.0.58:8858";
+
+ /**
+ * zipkin dev 地址
+ */
+ String ZIPKIN_DEV_ADDR = "http://127.0.0.1:9411";
+
+ /**
+ * zipkin prod 地址
+ */
+ String ZIPKIN_PROD_ADDR = "http://172.30.0.58:9411";
+
+ /**
+ * zipkin test 地址
+ */
+ String ZIPKIN_TEST_ADDR = "http://172.30.0.58:9411";
+
+ /**
+ * 动态获取nacos地址
+ *
+ * @param profile 环境变量
+ * @return addr
+ */
+ static String nacosAddr(String profile) {
+ switch (profile) {
+ case (AppConstant.PROD_CODE):
+ return NACOS_PROD_ADDR;
+ case (AppConstant.TEST_CODE):
+ return NACOS_TEST_ADDR;
+ default:
+ return NACOS_DEV_ADDR;
+ }
+ }
+
+ /**
+ * 动态获取sentinel地址
+ *
+ * @param profile 环境变量
+ * @return addr
+ */
+ static String sentinelAddr(String profile) {
+ switch (profile) {
+ case (AppConstant.PROD_CODE):
+ return SENTINEL_PROD_ADDR;
+ case (AppConstant.TEST_CODE):
+ return SENTINEL_TEST_ADDR;
+ default:
+ return SENTINEL_DEV_ADDR;
+ }
+ }
+
+ /**
+ * 动态获取zipkin地址
+ *
+ * @param profile 环境变量
+ * @return addr
+ */
+ static String zipkinAddr(String profile) {
+ switch (profile) {
+ case (AppConstant.PROD_CODE):
+ return ZIPKIN_PROD_ADDR;
+ case (AppConstant.TEST_CODE):
+ return ZIPKIN_TEST_ADDR;
+ default:
+ return ZIPKIN_DEV_ADDR;
+ }
+ }
+
+}
diff --git a/blade-common/src/main/java/org/springblade/common/launch/LauncherServiceImpl.java b/blade-common/src/main/java/org/springblade/common/launch/LauncherServiceImpl.java
index 349570e971f3aebc7e10a9038db633929dd05f27..8a090e984a4884a3ddc99ba23393035079e75dea 100644
--- a/blade-common/src/main/java/org/springblade/common/launch/LauncherServiceImpl.java
+++ b/blade-common/src/main/java/org/springblade/common/launch/LauncherServiceImpl.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,9 @@
*/
package org.springblade.common.launch;
-import org.springblade.common.constant.CommonConstant;
-import org.springblade.core.launch.constant.AppConstant;
+import org.springblade.common.constant.LauncherConstant;
import org.springblade.core.launch.service.LauncherService;
+import org.springblade.core.launch.utils.PropsUtil;
import org.springframework.boot.builder.SpringApplicationBuilder;
import java.util.Properties;
@@ -32,9 +32,12 @@ public class LauncherServiceImpl implements LauncherService {
@Override
public void launcher(SpringApplicationBuilder builder, String appName, String profile) {
Properties props = System.getProperties();
- props.setProperty("spring.cloud.nacos.discovery.server-addr", profile.equals(AppConstant.DEV_CDOE) ? CommonConstant.NACOS_DEV_ADDR : CommonConstant.NACOS_PROD_ADDR);
- props.setProperty("spring.cloud.nacos.config.server-addr", profile.equals(AppConstant.DEV_CDOE) ? CommonConstant.NACOS_DEV_ADDR : CommonConstant.NACOS_PROD_ADDR);
- props.setProperty("spring.cloud.sentinel.transport.dashboard", profile.equals(AppConstant.DEV_CDOE) ? CommonConstant.SENTINEL_DEV_ADDR : CommonConstant.SENTINEL_PROD_ADDR);
+ PropsUtil.setProperty(props, "spring.cloud.nacos.username", LauncherConstant.NACOS_USERNAME);
+ PropsUtil.setProperty(props, "spring.cloud.nacos.password", LauncherConstant.NACOS_PASSWORD);
+ PropsUtil.setProperty(props, "spring.cloud.nacos.discovery.server-addr", LauncherConstant.nacosAddr(profile));
+ PropsUtil.setProperty(props, "spring.cloud.nacos.config.server-addr", LauncherConstant.nacosAddr(profile));
+ PropsUtil.setProperty(props, "spring.cloud.sentinel.transport.dashboard", LauncherConstant.sentinelAddr(profile));
+ PropsUtil.setProperty(props, "spring.zipkin.base-url", LauncherConstant.zipkinAddr(profile));
}
}
diff --git a/blade-common/src/main/java/org/springblade/common/tool/CommonUtil.java b/blade-common/src/main/java/org/springblade/common/tool/CommonUtil.java
index 4fd9d10e7c058b7bc143eb1ab0f094da77629e99..5785606ba541a554a35955a8676cc15ab7f055d8 100644
--- a/blade-common/src/main/java/org/springblade/common/tool/CommonUtil.java
+++ b/blade-common/src/main/java/org/springblade/common/tool/CommonUtil.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
*
* 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/blade-common/src/main/java/org/springblade/common/tool/PropsUtil.java b/blade-common/src/main/java/org/springblade/common/tool/PropsUtil.java
new file mode 100644
index 0000000000000000000000000000000000000000..0801fb2228b2aa8a35caf3f7bb370a9dc4dd7abb
--- /dev/null
+++ b/blade-common/src/main/java/org/springblade/common/tool/PropsUtil.java
@@ -0,0 +1,42 @@
+/**
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springblade.common.tool;
+
+import org.springframework.util.StringUtils;
+
+import java.util.Properties;
+
+/**
+ * 配置工具类
+ *
+ * @author Chill
+ */
+public class PropsUtil {
+
+ /**
+ * 设置配置值,已存在则跳过
+ *
+ * @param props property
+ * @param key key
+ * @param value value
+ */
+ public static void setProperty(Properties props, String key, String value) {
+ if (StringUtils.isEmpty(props.getProperty(key))) {
+ props.setProperty(key, value);
+ }
+ }
+
+}
diff --git a/blade-common/src/main/resources/banner.txt b/blade-common/src/main/resources/banner.txt
new file mode 100644
index 0000000000000000000000000000000000000000..cbd02807356154823ea75be33dc4d464c9b37201
--- /dev/null
+++ b/blade-common/src/main/resources/banner.txt
@@ -0,0 +1,10 @@
+${AnsiColor.BRIGHT_CYAN} _____ _ ${AnsiColor.BLUE} ______ _ _
+${AnsiColor.BRIGHT_CYAN}/ ___| (_) ${AnsiColor.BLUE} | ___ \| | | |
+${AnsiColor.BRIGHT_CYAN}\ `--. _ __ _ __ _ _ __ __ _ ${AnsiColor.BLUE} | |_/ /| | __ _ __| | ___
+${AnsiColor.BRIGHT_CYAN} `--. \| '_ \ | '__|| || '_ \ / _` | ${AnsiColor.BLUE} | ___ \| | / _` | / _` | / _ \
+${AnsiColor.BRIGHT_CYAN}/\__/ /| |_) || | | || | | || (_| | ${AnsiColor.BLUE} | |_/ /| || (_| || (_| || __/
+${AnsiColor.BRIGHT_CYAN}\____/ | .__/ |_| |_||_| |_| \__, | ${AnsiColor.BLUE} \____/ |_| \__,_| \__,_| \___|
+${AnsiColor.BRIGHT_CYAN} | | __/ |
+${AnsiColor.BRIGHT_CYAN} |_| |___/
+
+${AnsiColor.BLUE}:: SpringBlade :: ${spring.application.name}:${AnsiColor.RED}${blade.env}${AnsiColor.BLUE} :: Running SpringBoot ${spring-boot.version} :: ${AnsiColor.BRIGHT_BLACK}
diff --git a/blade-gateway/Dockerfile b/blade-gateway/Dockerfile
index e0ae9f9cce32985ae50429b4bf86732a8e9e07ba..8d53271a804595f3bbb6c22f110f702930ff5f88 100644
--- a/blade-gateway/Dockerfile
+++ b/blade-gateway/Dockerfile
@@ -1,6 +1,6 @@
-FROM anapsix/alpine-java:8_server-jre_unlimited
+FROM bladex/alpine-java:openjdk17_cn_slim
-MAINTAINER smallchill@163.com
+MAINTAINER bladejava@qq.com
RUN mkdir -p /blade/gateway
@@ -10,6 +10,6 @@ EXPOSE 80
ADD ./target/blade-gateway.jar ./app.jar
-ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "app.jar"]
+ENTRYPOINT ["java", "--add-opens", "java.base/java.lang=ALL-UNNAMED", "--add-opens", "java.base/java.lang.reflect=ALL-UNNAMED", "-Djava.security.egd=file:/dev/./urandom", "-jar", "app.jar"]
CMD ["--spring.profiles.active=test"]
diff --git a/blade-gateway/pom.xml b/blade-gateway/pom.xml
index 43c2d71a5401e1d34eea7798db25f323e06d6794..caccfdeb258ac452db50511970812f30bb6a8170 100644
--- a/blade-gateway/pom.xml
+++ b/blade-gateway/pom.xml
@@ -5,13 +5,12 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,20 +15,18 @@
*/
package org.springblade.gateway;
-import org.springblade.core.launch.constant.AppConstant;
import org.springblade.core.launch.BladeApplication;
-import org.springframework.cloud.client.SpringCloudApplication;
-import org.springframework.cloud.netflix.hystrix.EnableHystrix;
-import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springblade.core.launch.constant.AppConstant;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
/**
* 项目启动
*
* @author Chill
*/
-@EnableHystrix
-@EnableScheduling
-@SpringCloudApplication
+@EnableDiscoveryClient
+@SpringBootApplication
public class GateWayApplication {
public static void main(String[] args) {
diff --git a/blade-gateway/src/main/java/org/springblade/gateway/config/ErrorHandlerConfiguration.java b/blade-gateway/src/main/java/org/springblade/gateway/config/ErrorHandlerConfiguration.java
deleted file mode 100644
index 8caaccef9286f9969cc1d117f74c4ce456b63269..0000000000000000000000000000000000000000
--- a/blade-gateway/src/main/java/org/springblade/gateway/config/ErrorHandlerConfiguration.java
+++ /dev/null
@@ -1,82 +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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package 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
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springblade.gateway.config;
+
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springblade.gateway.props.JwtProperties;
+import org.springblade.gateway.utils.JwtUtil;
+import org.springframework.beans.factory.SmartInitializingSingleton;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * JWT配置信息
+ *
+ * @author Chill
+ */
+@Slf4j
+@Configuration(proxyBeanMethods = false)
+@AllArgsConstructor
+@EnableConfigurationProperties({JwtProperties.class})
+public class JwtConfiguration implements SmartInitializingSingleton {
+
+ private final JwtProperties properties;
+
+ @Override
+ public void afterSingletonsInstantiated() {
+ JwtUtil.setJwtProperties(properties);
+ }
+}
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..e2ef767c900eca9117ee7a34bff93df09b3eff10 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
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,24 +18,13 @@ package org.springblade.gateway.config;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
-import org.springblade.gateway.handler.*;
+import org.springblade.gateway.filter.GatewayFilter;
+import org.springblade.gateway.props.AuthProperties;
+import org.springblade.gateway.props.RequestProperties;
+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;
-import reactor.core.publisher.Mono;
/**
* 路由配置信息
@@ -43,72 +32,17 @@ import reactor.core.publisher.Mono;
* @author Chill
*/
@Slf4j
-@Configuration
+@Configuration(proxyBeanMethods = false)
@AllArgsConstructor
+@EnableConfigurationProperties({AuthProperties.class, RequestProperties.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_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) -> {
- ServerHttpRequest request = ctx.getRequest();
- if (CorsUtils.isCorsRequest(request)) {
- ServerHttpResponse response = ctx.getResponse();
- HttpHeaders headers = response.getHeaders();
- headers.add("Access-Control-Allow-Headers", ALLOWED_HEADERS);
- headers.add("Access-Control-Allow-Methods", ALLOWED_METHODS);
- headers.add("Access-Control-Allow-Origin", ALLOWED_ORIGIN);
- headers.add("Access-Control-Expose-Headers", ALLOWED_EXPOSE);
- headers.add("Access-Control-Max-Age", MAX_AGE);
- headers.add("Access-Control-Allow-Credentials", "true");
- if (request.getMethod() == HttpMethod.OPTIONS) {
- response.setStatusCode(HttpStatus.OK);
- return Mono.empty();
- }
- }
- return chain.filter(ctx);
- };
- }
-
- @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
* 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/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..cef89b252c69a824f0bae3a9acc3162dabca5b9a
--- /dev/null
+++ b/blade-gateway/src/main/java/org/springblade/gateway/filter/AuthFilter.java
@@ -0,0 +1,108 @@
+/**
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springblade.gateway.filter;
+
+import com.alibaba.nacos.common.utils.StringUtils;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.jsonwebtoken.Claims;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springblade.core.launch.props.BladeProperties;
+import org.springblade.gateway.props.AuthProperties;
+import org.springblade.gateway.provider.AuthProvider;
+import org.springblade.gateway.provider.ResponseProvider;
+import org.springblade.gateway.utils.JwtCrypto;
+import org.springblade.gateway.utils.JwtUtil;
+import org.springframework.cloud.gateway.filter.GatewayFilterChain;
+import org.springframework.cloud.gateway.filter.GlobalFilter;
+import org.springframework.core.Ordered;
+import org.springframework.core.io.buffer.DataBuffer;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.server.reactive.ServerHttpResponse;
+import org.springframework.stereotype.Component;
+import org.springframework.util.AntPathMatcher;
+import org.springframework.web.server.ServerWebExchange;
+import reactor.core.publisher.Flux;
+import reactor.core.publisher.Mono;
+
+import java.nio.charset.StandardCharsets;
+
+import static org.springblade.gateway.utils.JwtCrypto.BLADE_CRYPTO_AES_KEY;
+
+/**
+ * 鉴权认证
+ *
+ * @author Chill
+ */
+@Slf4j
+@Component
+@AllArgsConstructor
+public class AuthFilter implements GlobalFilter, Ordered {
+ private final AuthProperties authProperties;
+ private final ObjectMapper objectMapper;
+ private final BladeProperties bladeProperties;
+ private final AntPathMatcher antPathMatcher = new AntPathMatcher();
+
+ @Override
+ public Mono
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springblade.gateway.filter;
+
+import lombok.RequiredArgsConstructor;
+import org.springblade.gateway.props.RequestProperties;
+import org.springframework.core.Ordered;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.server.reactive.ServerHttpRequest;
+import org.springframework.http.server.reactive.ServerHttpResponse;
+import org.springframework.lang.NonNull;
+import org.springframework.util.AntPathMatcher;
+import org.springframework.util.PatternMatchUtils;
+import org.springframework.web.cors.reactive.CorsUtils;
+import org.springframework.web.server.ServerWebExchange;
+import org.springframework.web.server.WebFilter;
+import org.springframework.web.server.WebFilterChain;
+import reactor.core.publisher.Mono;
+
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * 全局拦截器
+ *
+ * @author Chill
+ */
+@RequiredArgsConstructor
+public class GatewayFilter implements WebFilter, Ordered {
+
+ /**
+ * 请求配置
+ */
+ private final RequestProperties requestProperties;
+ /**
+ * 路径匹配
+ */
+ private final AntPathMatcher antPathMatcher = new AntPathMatcher();
+
+ /**
+ * 默认拦截地址
+ */
+ private final List
- * 全局拦截器,作用所有的微服务
- *
- * 1. 对请求头中参数进行处理 from 参数进行清洗
- * 2. 重写StripPrefix = 1,支持全局
+ * request过滤器
*
* @author lengleng
*/
@Component
-public class RequestGlobalFilter implements GlobalFilter, Ordered {
+public class RequestFilter implements GlobalFilter, Ordered {
- /**
- * Process the Web request and (optionally) delegate to the next
- * {@code WebFilter} through the given {@link GatewayFilterChain}.
- *
- * @param exchange the current server exchange
- * @param chain provides a way to delegate to the next filter
- * @return {@code Mono
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,19 +13,24 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.springblade.gateway.handler;
-import org.springframework.boot.autoconfigure.web.ErrorProperties;
-import org.springframework.boot.autoconfigure.web.ResourceProperties;
-import org.springframework.boot.autoconfigure.web.reactive.error.DefaultErrorWebExceptionHandler;
-import org.springframework.boot.web.reactive.error.ErrorAttributes;
-import org.springframework.cloud.gateway.support.NotFoundException;
-import org.springframework.context.ApplicationContext;
-import org.springframework.http.HttpStatus;
-import org.springframework.web.reactive.function.server.*;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import lombok.RequiredArgsConstructor;
+import org.springblade.gateway.provider.ResponseProvider;
+import org.springframework.boot.web.reactive.error.ErrorWebExceptionHandler;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.annotation.Order;
+import org.springframework.core.io.buffer.DataBufferFactory;
+import org.springframework.http.MediaType;
+import org.springframework.http.server.reactive.ServerHttpRequest;
+import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.web.server.ResponseStatusException;
+import org.springframework.web.server.ServerWebExchange;
+import reactor.core.publisher.Mono;
-import java.util.HashMap;
import java.util.Map;
/**
@@ -33,62 +38,51 @@ import java.util.Map;
*
* @author Chill
*/
-public class ErrorExceptionHandler extends DefaultErrorWebExceptionHandler {
+@Order(-1)
+@Configuration(proxyBeanMethods = false)
+@RequiredArgsConstructor
+public class ErrorExceptionHandler implements ErrorWebExceptionHandler {
- public ErrorExceptionHandler(ErrorAttributes errorAttributes, ResourceProperties resourceProperties,
- ErrorProperties errorProperties, ApplicationContext applicationContext) {
- super(errorAttributes, resourceProperties, errorProperties, applicationContext);
- }
+ private final ObjectMapper objectMapper;
- /**
- * 获取异常属性
- */
@Override
- protected Map
- * 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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package 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
- * 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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package 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 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
- *
- * @author lengleng
- */
-@Slf4j
-@Component
-public class SwaggerSecurityHandler implements HandlerFunction
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package 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
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springblade.gateway.props;
+
+import io.jsonwebtoken.JwtException;
+import lombok.Data;
+import org.springblade.core.launch.constant.TokenConstant;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+/**
+ * JWT配置
+ *
+ * @author Chill
+ */
+@Data
+@ConfigurationProperties("blade.token")
+public class JwtProperties {
+
+ /**
+ * token是否有状态
+ */
+ private Boolean state = Boolean.FALSE;
+
+ /**
+ * 是否只可同时在线一人
+ */
+ private Boolean single = Boolean.FALSE;
+
+ /**
+ * token签名
+ */
+ private String signKey = "";
+
+ /**
+ * 获取签名规则
+ */
+ public String getSignKey() {
+ if (this.signKey.length() < TokenConstant.SIGN_KEY_LENGTH) {
+ throw new JwtException("请配置 blade.token.sign-key 的值, 长度32位以上");
+ }
+ return this.signKey;
+ }
+
+}
diff --git a/blade-gateway/src/main/java/org/springblade/gateway/props/RequestProperties.java b/blade-gateway/src/main/java/org/springblade/gateway/props/RequestProperties.java
new file mode 100644
index 0000000000000000000000000000000000000000..3250e0089806b8585a7ff69308fad19be12f22ba
--- /dev/null
+++ b/blade-gateway/src/main/java/org/springblade/gateway/props/RequestProperties.java
@@ -0,0 +1,58 @@
+/**
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springblade.gateway.props;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Request配置类
+ *
+ * @author Chill
+ */
+@Data
+@ConfigurationProperties("blade.request")
+public class RequestProperties {
+
+ /**
+ * 开启自定义request
+ */
+ private Boolean enabled = true;
+
+ /**
+ * 放行url
+ */
+ private List
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package 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
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springblade.gateway.provider;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 请求响应返回
+ *
+ * @author Chill
+ */
+public class ResponseProvider {
+
+ /**
+ * 成功
+ *
+ * @param message 信息
+ * @return
+ */
+ public static Map
- * 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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package 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
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springblade.gateway.utils;
+
+import lombok.SneakyThrows;
+import org.springframework.util.Assert;
+import org.springframework.util.StringUtils;
+import reactor.util.annotation.Nullable;
+
+import javax.crypto.Cipher;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
+
+/**
+ * JwtCrypto
+ *
+ * @author Chill
+ */
+public class JwtCrypto {
+
+ public static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;
+ public static final String BLADE_CRYPTO_AES_KEY = "blade.token.aes-key";
+
+
+ /**
+ * Base64加密
+ *
+ * @param content 文本内容
+ * @param aesTextKey 文本密钥
+ * @return {String}
+ */
+ public static String encryptToString(String content, String aesTextKey) {
+ return Base64.getEncoder().encodeToString(encrypt(content, aesTextKey));
+ }
+
+ /**
+ * Base64加密
+ *
+ * @param content 内容
+ * @param aesTextKey 文本密钥
+ * @return {String}
+ */
+ public static String encryptToString(byte[] content, String aesTextKey) {
+ return Base64.getEncoder().encodeToString(encrypt(content, aesTextKey));
+ }
+
+ /**
+ * 加密
+ *
+ * @param content 文本内容
+ * @param aesTextKey 文本密钥
+ * @return byte[]
+ */
+ public static byte[] encrypt(String content, String aesTextKey) {
+ return encrypt(content.getBytes(DEFAULT_CHARSET), aesTextKey);
+ }
+
+ /**
+ * 加密
+ *
+ * @param content 文本内容
+ * @param charset 编码
+ * @param aesTextKey 文本密钥
+ * @return byte[]
+ */
+ public static byte[] encrypt(String content, Charset charset, String aesTextKey) {
+ return encrypt(content.getBytes(charset), aesTextKey);
+ }
+
+ /**
+ * 加密
+ *
+ * @param content 内容
+ * @param aesTextKey 文本密钥
+ * @return byte[]
+ */
+ public static byte[] encrypt(byte[] content, String aesTextKey) {
+ return encrypt(content, Objects.requireNonNull(aesTextKey).getBytes(DEFAULT_CHARSET));
+ }
+
+ /**
+ * Base64解密
+ *
+ * @param content 文本内容
+ * @param aesTextKey 文本密钥
+ * @return {String}
+ */
+ @Nullable
+ public static String decryptToString(@Nullable String content, @Nullable String aesTextKey) {
+ if (!StringUtils.hasText(content) || !StringUtils.hasText(aesTextKey)) {
+ return null;
+ }
+ byte[] hexBytes = decrypt(Base64.getDecoder().decode(content.getBytes(DEFAULT_CHARSET)), aesTextKey);
+ return new String(hexBytes, DEFAULT_CHARSET);
+ }
+
+
+ /**
+ * 解密
+ *
+ * @param content 内容
+ * @param aesTextKey 文本密钥
+ * @return byte[]
+ */
+ public static byte[] decrypt(byte[] content, String aesTextKey) {
+ return decrypt(content, Objects.requireNonNull(aesTextKey).getBytes(DEFAULT_CHARSET));
+ }
+
+
+ /**
+ * 解密
+ *
+ * @param content 内容
+ * @param aesKey 密钥
+ * @return byte[]
+ */
+ public static byte[] encrypt(byte[] content, byte[] aesKey) {
+ return aes(Pkcs7Encoder.encode(content), aesKey, Cipher.ENCRYPT_MODE);
+ }
+
+ /**
+ * 加密
+ *
+ * @param encrypted 内容
+ * @param aesKey 密钥
+ * @return byte[]
+ */
+ public static byte[] decrypt(byte[] encrypted, byte[] aesKey) {
+ return Pkcs7Encoder.decode(aes(encrypted, aesKey, Cipher.DECRYPT_MODE));
+ }
+
+ /**
+ * ase加密
+ *
+ * @param encrypted 内容
+ * @param aesKey 密钥
+ * @param mode 模式
+ * @return byte[]
+ */
+ @SneakyThrows
+ private static byte[] aes(byte[] encrypted, byte[] aesKey, int mode) {
+ Assert.isTrue(aesKey.length == 32, "IllegalAesKey, aesKey's length must be 32");
+ Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
+ SecretKeySpec keySpec = new SecretKeySpec(aesKey, "AES");
+ IvParameterSpec iv = new IvParameterSpec(Arrays.copyOfRange(aesKey, 0, 16));
+ cipher.init(mode, keySpec, iv);
+ return cipher.doFinal(encrypted);
+ }
+
+ /**
+ * 提供基于PKCS7算法的加解密接口.
+ */
+ private static class Pkcs7Encoder {
+ private static final int BLOCK_SIZE = 32;
+
+ private static byte[] encode(byte[] src) {
+ int count = src.length;
+ // 计算需要填充的位数
+ int amountToPad = BLOCK_SIZE - (count % BLOCK_SIZE);
+ // 获得补位所用的字符
+ byte pad = (byte) (amountToPad & 0xFF);
+ byte[] pads = new byte[amountToPad];
+ for (int index = 0; index < amountToPad; index++) {
+ pads[index] = pad;
+ }
+ int length = count + amountToPad;
+ byte[] dest = new byte[length];
+ System.arraycopy(src, 0, dest, 0, count);
+ System.arraycopy(pads, 0, dest, count, amountToPad);
+ return dest;
+ }
+
+ private static byte[] decode(byte[] decrypted) {
+ int pad = decrypted[decrypted.length - 1];
+ if (pad < 1 || pad > BLOCK_SIZE) {
+ pad = 0;
+ }
+ if (pad > 0) {
+ return Arrays.copyOfRange(decrypted, 0, decrypted.length - pad);
+ }
+ return decrypted;
+ }
+ }
+}
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..5c374aabc0c5e322c299eac789e0c6d64ab548ce
--- /dev/null
+++ b/blade-gateway/src/main/java/org/springblade/gateway/utils/JwtUtil.java
@@ -0,0 +1,114 @@
+/**
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springblade.gateway.utils;
+
+import io.jsonwebtoken.Claims;
+import io.jsonwebtoken.Jwts;
+import lombok.Getter;
+import org.springblade.core.launch.constant.TokenConstant;
+import org.springblade.gateway.props.JwtProperties;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+
+/**
+ * JwtUtil
+ *
+ * @author Chill
+ */
+public class JwtUtil {
+
+ public static String BEARER = TokenConstant.BEARER;
+ public static String CRYPTO = TokenConstant.CRYPTO;
+ public static Integer AUTH_LENGTH = 7;
+
+ /**
+ * jwt配置
+ */
+ @Getter
+ private static JwtProperties jwtProperties;
+
+ public static void setJwtProperties(JwtProperties properties) {
+ if (JwtUtil.jwtProperties == null) {
+ JwtUtil.jwtProperties = properties;
+ }
+ }
+
+ /**
+ * 签名加密
+ */
+ public static String getBase64Security() {
+ return Base64.getEncoder().encodeToString(getJwtProperties().getSignKey().getBytes(StandardCharsets.UTF_8));
+ }
+
+ /**
+ * 获取请求传递的token串
+ *
+ * @param auth token
+ * @return String
+ */
+ public static String getToken(String auth) {
+ if (isBearer(auth) || isCrypto(auth)) {
+ return auth.substring(AUTH_LENGTH);
+ }
+ return null;
+ }
+
+ /**
+ * 判断token类型为bearer
+ *
+ * @param auth token
+ * @return String
+ */
+ public static Boolean isBearer(String auth) {
+ if ((auth != null) && (auth.length() > AUTH_LENGTH)) {
+ String headStr = auth.substring(0, 6).toLowerCase();
+ return headStr.compareTo(BEARER) == 0;
+ }
+ return false;
+ }
+
+ /**
+ * 判断token类型为crypto
+ *
+ * @param auth token
+ * @return String
+ */
+ public static Boolean isCrypto(String auth) {
+ if ((auth != null) && (auth.length() > AUTH_LENGTH)) {
+ String headStr = auth.substring(0, 6).toLowerCase();
+ return headStr.compareTo(CRYPTO) == 0;
+ }
+ return false;
+ }
+
+ /**
+ * 解析jsonWebToken
+ *
+ * @param jsonWebToken token串
+ * @return Claims
+ */
+ public static Claims parseJWT(String jsonWebToken) {
+ try {
+ return Jwts.parserBuilder()
+ .setSigningKey(Base64.getDecoder().decode(getBase64Security())).build()
+ .parseClaimsJws(jsonWebToken).getBody();
+ } catch (Exception ex) {
+ return null;
+ }
+ }
+
+}
diff --git a/blade-gateway/src/main/resources/application-dev.yml b/blade-gateway/src/main/resources/application-dev.yml
new file mode 100644
index 0000000000000000000000000000000000000000..b8eaf546c275a8cb4496551392ae4eb6da03fa03
--- /dev/null
+++ b/blade-gateway/src/main/resources/application-dev.yml
@@ -0,0 +1,11 @@
+blade:
+ #多团队协作服务配置
+ loadbalancer:
+ #开启配置
+ enabled: true
+ #灰度版本
+ #version: 3.0.0
+ #负载均衡优先调用的ip段
+ prior-ip-pattern:
+ - 192.168.0.*
+ - 127.0.0.1
diff --git a/blade-gateway/src/main/resources/application.yml b/blade-gateway/src/main/resources/application.yml
new file mode 100644
index 0000000000000000000000000000000000000000..d0c33710fd5491397e91935777eef01499296a88
--- /dev/null
+++ b/blade-gateway/src/main/resources/application.yml
@@ -0,0 +1,16 @@
+knife4j:
+ gateway:
+ enabled: true
+ tags-sorter: order
+ operations-sorter: order
+ # 指定服务发现的模式聚合微服务文档,并且是默认`default`分组
+ strategy: discover
+ discover:
+ enabled: true
+ # 指定版本号(Swagger2|OpenAPI3)
+ version : openapi3
+ # 需要排除的微服务(eg:网关服务)
+ excluded-services:
+ - blade-admin
+ - blade-gateway
+ - blade-log
diff --git a/blade-gateway/src/main/resources/bootstrap.yml b/blade-gateway/src/main/resources/bootstrap.yml
index c7f53a955e88132a8c2fc575759aba39a6019bc9..4172f5d6f2db13bdf00739da3d80fabaf8b783a0 100644
--- a/blade-gateway/src/main/resources/bootstrap.yml
+++ b/blade-gateway/src/main/resources/bootstrap.yml
@@ -1,42 +1,9 @@
server:
port: 80
-# 需要配置的服务名
-blade:
- service:
- blade-auth: blade-auth
- blade-desk: blade-desk
- blade-system: blade-system
-
spring:
cloud:
gateway:
- routes:
- # 认证中心
- - id: ${blade.service.blade-auth}
- uri: lb://${blade.service.blade-auth}
- predicates:
- - Path=/${blade.service.blade-auth}/**
- filters:
- - name: RequestRateLimiter
- args:
- # 使用SpEL按名称引用bean
- key-resolver: '#{@remoteAddrKeyResolver}'
- # 允许用户每秒处理多少个请求
- redis-rate-limiter.replenishRate: 10
- # 允许在一秒钟内完成的最大请求数
- redis-rate-limiter.burstCapacity: 20
- - StripPrefix=1
- # 首页模块
- - id: ${blade.service.blade-desk}
- uri: lb://${blade.service.blade-desk}
- predicates:
- - Path=/${blade.service.blade-desk}/**
- # 系统模块
- - id: ${blade.service.blade-system}
- uri: lb://${blade.service.blade-system}
- predicates:
- - Path=/${blade.service.blade-system}/**
discovery:
locator:
enabled: true
diff --git a/blade-ops/blade-admin/Dockerfile b/blade-ops/blade-admin/Dockerfile
index 67119b9b1013094942863e70d80bc8feb8726b5a..61e5f627dc8cbc7bc2d636d41f29fb7cd1c8619b 100644
--- a/blade-ops/blade-admin/Dockerfile
+++ b/blade-ops/blade-admin/Dockerfile
@@ -1,6 +1,6 @@
-FROM anapsix/alpine-java:8_server-jre_unlimited
+FROM bladex/alpine-java:openjdk17_cn_slim
-MAINTAINER smallchill@163.com
+MAINTAINER bladejava@qq.com
RUN mkdir -p /blade/admin
@@ -10,6 +10,6 @@ EXPOSE 7002
ADD ./target/blade-admin.jar ./app.jar
-ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "app.jar"]
+ENTRYPOINT ["java", "--add-opens", "java.base/java.lang=ALL-UNNAMED", "--add-opens", "java.base/java.lang.reflect=ALL-UNNAMED", "-Djava.security.egd=file:/dev/./urandom", "-jar", "app.jar"]
CMD ["--spring.profiles.active=test"]
diff --git a/blade-ops/blade-admin/pom.xml b/blade-ops/blade-admin/pom.xml
index 45ed799b9f9f442e06ab3a34e074bab2ebe9c007..9c150af218dfa61cd0f003a66a62db43579e2426 100644
--- a/blade-ops/blade-admin/pom.xml
+++ b/blade-ops/blade-admin/pom.xml
@@ -5,13 +5,12 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,9 +16,9 @@
package org.springblade.admin;
import de.codecentric.boot.admin.server.config.EnableAdminServer;
+import org.springblade.core.cloud.client.BladeCloudApplication;
import org.springblade.core.launch.BladeApplication;
import org.springblade.core.launch.constant.AppConstant;
-import org.springframework.cloud.client.SpringCloudApplication;
/**
* admin启动器
@@ -26,7 +26,7 @@ import org.springframework.cloud.client.SpringCloudApplication;
* @author Chill
*/
@EnableAdminServer
-@SpringCloudApplication
+@BladeCloudApplication
public class AdminApplication {
public static void main(String[] args) {
diff --git a/blade-ops/blade-admin/src/main/resources/bootstrap.yml b/blade-ops/blade-admin/src/main/resources/bootstrap.yml
index af767c951d41ed7aa15a0c5a3b8902584a07a020..7e296f7a8129c1f8b198461c861921cb6966d16c 100644
--- a/blade-ops/blade-admin/src/main/resources/bootstrap.yml
+++ b/blade-ops/blade-admin/src/main/resources/bootstrap.yml
@@ -14,4 +14,6 @@ spring:
boot:
admin:
discovery:
- ignored-services: consul
+ ignored-services:
+ - consul
+ - serverAddr
diff --git a/blade-ops/blade-develop/Dockerfile b/blade-ops/blade-develop/Dockerfile
new file mode 100644
index 0000000000000000000000000000000000000000..37c0333b75ba01bee7f14a85eba04f79f85a1950
--- /dev/null
+++ b/blade-ops/blade-develop/Dockerfile
@@ -0,0 +1,15 @@
+FROM bladex/alpine-java:openjdk17_cn_slim
+
+MAINTAINER bladejava@qq.com
+
+RUN mkdir -p /blade/develop
+
+WORKDIR /blade/develop
+
+EXPOSE 7007
+
+ADD ./target/blade-develop.jar ./app.jar
+
+ENTRYPOINT ["java", "--add-opens", "java.base/java.lang=ALL-UNNAMED", "--add-opens", "java.base/java.lang.reflect=ALL-UNNAMED", "-Djava.security.egd=file:/dev/./urandom", "-jar", "app.jar"]
+
+CMD ["--spring.profiles.active=test"]
diff --git a/blade-ops/blade-develop/pom.xml b/blade-ops/blade-develop/pom.xml
index 6019cb3309621d40588de8939cc43d0f16b9fb7d..f0fe0304111c29a74f57902ab5377b8436dc5b93 100644
--- a/blade-ops/blade-develop/pom.xml
+++ b/blade-ops/blade-develop/pom.xml
@@ -6,14 +6,13 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,18 +15,16 @@
*/
package org.springblade.develop;
+import org.springblade.core.cloud.client.BladeCloudApplication;
import org.springblade.core.launch.BladeApplication;
import org.springblade.core.launch.constant.AppConstant;
-import org.springframework.cloud.client.SpringCloudApplication;
-import org.springframework.cloud.openfeign.EnableFeignClients;
/**
* Develop启动器
*
* @author Chill
*/
-@SpringCloudApplication
-@EnableFeignClients(AppConstant.BASE_PACKAGES)
+@BladeCloudApplication
public class DevelopApplication {
public static void main(String[] args) {
diff --git a/blade-ops/blade-develop/src/main/java/org/springblade/develop/controller/CodeController.java b/blade-ops/blade-develop/src/main/java/org/springblade/develop/controller/CodeController.java
index c5eed5fd4679122d5352bd8dc40c908f09a1402a..867b7e19740edf2c077722f442506aa564e0493b 100644
--- a/blade-ops/blade-develop/src/main/java/org/springblade/develop/controller/CodeController.java
+++ b/blade-ops/blade-develop/src/main/java/org/springblade/develop/controller/CodeController.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,20 +16,30 @@
package org.springblade.develop.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
-import io.swagger.annotations.*;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import io.swagger.v3.oas.annotations.Hidden;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.Parameters;
+import io.swagger.v3.oas.annotations.enums.ParameterIn;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
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.secure.annotation.PreAuth;
import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.constant.RoleConstant;
import org.springblade.core.tool.utils.Func;
import org.springblade.develop.entity.Code;
+import org.springblade.develop.entity.Datasource;
import org.springblade.develop.service.ICodeService;
-import org.springblade.develop.support.BladeGenerator;
+import org.springblade.develop.service.IDatasourceService;
+import org.springblade.develop.support.BladeCodeGenerator;
import org.springframework.web.bind.annotation.*;
-import springfox.documentation.annotations.ApiIgnore;
-import javax.validation.Valid;
import java.util.Collection;
import java.util.Map;
@@ -37,21 +47,24 @@ import java.util.Map;
* 控制器
*
* @author Chill
- * @since 2018-12-24
*/
+@Hidden
@RestController
@AllArgsConstructor
@RequestMapping("/code")
-@Api(value = "代码生成", tags = "代码生成")
+@Tag(name = "代码生成", description = "代码生成")
+@PreAuth(RoleConstant.HAS_ROLE_ADMIN)
public class CodeController extends BladeController {
private ICodeService codeService;
+ private IDatasourceService datasourceService;
/**
* 详情
*/
@GetMapping("/detail")
- @ApiOperation(value = "详情", notes = "传入code", position = 1)
+ @ApiOperationSupport(order = 1)
+ @Operation(summary = "详情", description = "传入code")
public R
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springblade.develop.controller;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import lombok.AllArgsConstructor;
+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.springblade.develop.entity.Datasource;
+import org.springblade.develop.service.IDatasourceService;
+import org.springframework.web.bind.annotation.*;
+
+import jakarta.validation.Valid;
+import java.util.List;
+
+/**
+ * 数据源配置表 控制器
+ *
+ * @author Chill
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("/datasource")
+@Tag(name = "数据源配置表", description = "数据源配置表接口")
+public class DatasourceController extends BladeController {
+
+ private IDatasourceService datasourceService;
+
+ /**
+ * 详情
+ */
+ @GetMapping("/detail")
+ @ApiOperationSupport(order = 1)
+ @Operation(summary = "详情", description = "传入datasource")
+ public R
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,85 +19,107 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
+import java.io.Serial;
import java.io.Serializable;
/**
* 实体类
*
* @author Chill
- * @since 2018-12-24
*/
@Data
@TableName("blade_code")
-@ApiModel(value = "Code对象", description = "Code对象")
+@Schema(description = "Code对象")
public class Code implements Serializable {
+ @Serial
private static final long serialVersionUID = 1L;
/**
* 主键
*/
- @ApiModelProperty(value = "主键")
- @TableId(value = "id", type = IdType.AUTO)
- private Integer id;
+ @Schema(description = "主键")
+ @TableId(value = "id", type = IdType.ASSIGN_ID)
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long id;
+
+ /**
+ * 数据源主键
+ */
+ @Schema(description = "数据源主键")
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long datasourceId;
/**
* 模块名称
*/
- @ApiModelProperty(value = "服务名称")
+ @Schema(description = "服务名称")
private String serviceName;
/**
* 模块名称
*/
- @ApiModelProperty(value = "模块名称")
+ @Schema(description = "模块名称")
private String codeName;
/**
* 表名
*/
- @ApiModelProperty(value = "表名")
+ @Schema(description = "表名")
private String tableName;
/**
* 实体名
*/
- @ApiModelProperty(value = "表前缀")
+ @Schema(description = "表前缀")
private String tablePrefix;
/**
* 主键名
*/
- @ApiModelProperty(value = "主键名")
+ @Schema(description = "主键名")
private String pkName;
+ /**
+ * 基础业务模式
+ */
+ @Schema(description = "基础业务模式")
+ private Integer baseMode;
+
+ /**
+ * 包装器模式
+ */
+ @Schema(description = "包装器模式")
+ private Integer wrapMode;
+
/**
* 后端包名
*/
- @ApiModelProperty(value = "后端包名")
+ @Schema(description = "后端包名")
private String packageName;
/**
* 后端路径
*/
- @ApiModelProperty(value = "后端路径")
+ @Schema(description = "后端路径")
private String apiPath;
/**
* 前端路径
*/
- @ApiModelProperty(value = "前端路径")
+ @Schema(description = "前端路径")
private String webPath;
/**
* 是否已删除
*/
@TableLogic
- @ApiModelProperty(value = "是否已删除")
+ @Schema(description = "是否已删除")
private Integer isDeleted;
diff --git a/blade-ops/blade-develop/src/main/java/org/springblade/develop/entity/Datasource.java b/blade-ops/blade-develop/src/main/java/org/springblade/develop/entity/Datasource.java
new file mode 100644
index 0000000000000000000000000000000000000000..1ea5e15acc090a1d0ceb6d00d5bbb9a453fde549
--- /dev/null
+++ b/blade-ops/blade-develop/src/main/java/org/springblade/develop/entity/Datasource.java
@@ -0,0 +1,84 @@
+/**
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package 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.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.core.mp.base.BaseEntity;
+
+import java.io.Serial;
+
+/**
+ * 数据源配置表实体类
+ *
+ * @author Chill
+ */
+@Data
+@TableName("blade_datasource")
+@EqualsAndHashCode(callSuper = true)
+@Schema(description = "Datasource对象")
+public class Datasource extends BaseEntity {
+
+ @Serial
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 主键
+ */
+ @Schema(description = "主键")
+ @TableId(value = "id", type = IdType.ASSIGN_ID)
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long id;
+
+ /**
+ * 名称
+ */
+ @Schema(description = "名称")
+ private String name;
+ /**
+ * 驱动类
+ */
+ @Schema(description = "驱动类")
+ private String driverClass;
+ /**
+ * 连接地址
+ */
+ @Schema(description = "连接地址")
+ private String url;
+ /**
+ * 用户名
+ */
+ @Schema(description = "用户名")
+ private String username;
+ /**
+ * 密码
+ */
+ @Schema(description = "密码")
+ private String password;
+ /**
+ * 备注
+ */
+ @Schema(description = "备注")
+ 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..8ed5219194f6cb8846418bd30c48f55ef851a069 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
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,7 +22,6 @@ import org.springblade.develop.entity.Code;
* Mapper 接口
*
* @author Chill
- * @since 2018-12-24
*/
public interface CodeMapper extends BaseMapper
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package 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
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,8 +23,15 @@ import org.springblade.develop.entity.Code;
* 服务类
*
* @author Chill
- * @since 2018-12-24
*/
public interface ICodeService extends IService
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springblade.develop.service;
+
+import org.springblade.core.mp.base.BaseService;
+import org.springblade.develop.entity.Datasource;
+
+/**
+ * 数据源配置表 服务类
+ *
+ * @author Chill
+ */
+public interface IDatasourceService extends BaseService
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -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
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package 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
- * 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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.springblade.develop.support;
-
-import com.baomidou.mybatisplus.annotation.DbType;
-import com.baomidou.mybatisplus.core.toolkit.StringPool;
-import com.baomidou.mybatisplus.core.toolkit.StringUtils;
-import com.baomidou.mybatisplus.generator.AutoGenerator;
-import com.baomidou.mybatisplus.generator.InjectionConfig;
-import com.baomidou.mybatisplus.generator.config.*;
-import com.baomidou.mybatisplus.generator.config.converts.MySqlTypeConvert;
-import com.baomidou.mybatisplus.generator.config.converts.PostgreSqlTypeConvert;
-import com.baomidou.mybatisplus.generator.config.po.TableInfo;
-import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
-import lombok.Data;
-import lombok.extern.slf4j.Slf4j;
-import org.springblade.core.tool.utils.Func;
-import org.springblade.core.tool.utils.StringUtil;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.core.io.Resource;
-import org.springframework.core.io.support.PropertiesLoaderUtils;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.*;
-
-/**
- * 代码生成器配置类
- *
- * @author Chill
- */
-@Data
-@Slf4j
-public class BladeGenerator {
- /**
- * 代码所在服务名
- */
- private String serviceName = "blade-service";
- /**
- * 代码生成的包名
- */
- private String packageName = "org.springblade.test";
- /**
- * 代码后端生成的地址
- */
- private String packageDir;
- /**
- * 代码前端生成的地址
- */
- private String packageWebDir;
- /**
- * 需要去掉的表前缀
- */
- private String[] tablePrefix = {"blade_"};
- /**
- * 需要生成的表名(两者只能取其一)
- */
- private String[] includeTables = {"blade_test"};
- /**
- * 需要排除的表名(两者只能取其一)
- */
- private String[] excludeTables = {};
- /**
- * 是否包含基础业务字段
- */
- private Boolean hasSuperEntity = Boolean.FALSE;
- /**
- * 基础业务字段
- */
- private String[] superEntityColumns = {"id", "create_time", "create_user", "update_time", "update_user", "status", "is_deleted"};
- /**
- * 是否启用swagger
- */
- private Boolean isSwagger2 = Boolean.TRUE;
-
- public void run() {
- Properties props = getProperties();
- AutoGenerator mpg = new AutoGenerator();
- GlobalConfig gc = new GlobalConfig();
- String outputDir = getOutputDir();
- String author = props.getProperty("author");
- gc.setOutputDir(outputDir);
- gc.setAuthor(author);
- gc.setFileOverride(true);
- gc.setOpen(false);
- gc.setActiveRecord(false);
- gc.setEnableCache(false);
- gc.setBaseResultMap(true);
- gc.setBaseColumnList(true);
- gc.setMapperName("%sMapper");
- gc.setXmlName("%sMapper");
- gc.setServiceName("I%sService");
- gc.setServiceImplName("%sServiceImpl");
- gc.setControllerName("%sController");
- gc.setSwagger2(isSwagger2);
- mpg.setGlobalConfig(gc);
- DataSourceConfig dsc = new DataSourceConfig();
- String driverName = props.getProperty("spring.datasource.driver-class-name");
- if (StringUtil.containsAny(driverName, DbType.MYSQL.getDb())) {
- dsc.setDbType(DbType.MYSQL);
- dsc.setTypeConvert(new MySqlTypeConvert());
- } else {
- dsc.setDbType(DbType.POSTGRE_SQL);
- dsc.setTypeConvert(new PostgreSqlTypeConvert());
- }
- dsc.setUrl(props.getProperty("spring.datasource.url"));
- dsc.setDriverName(driverName);
- dsc.setUsername(props.getProperty("spring.datasource.username"));
- dsc.setPassword(props.getProperty("spring.datasource.password"));
- mpg.setDataSource(dsc);
- // 策略配置
- StrategyConfig strategy = new StrategyConfig();
- // strategy.setCapitalMode(true);// 全局大写命名
- // strategy.setDbColumnUnderline(true);//全局下划线命名
- strategy.setNaming(NamingStrategy.underline_to_camel);
- strategy.setColumnNaming(NamingStrategy.underline_to_camel);
- strategy.setTablePrefix(tablePrefix);
- if (includeTables.length > 0) {
- strategy.setInclude(includeTables);
- }
- if (excludeTables.length > 0) {
- strategy.setExclude(excludeTables);
- }
- if (hasSuperEntity) {
- strategy.setSuperEntityClass("org.springblade.core.mp.base.BaseEntity");
- strategy.setSuperEntityColumns(superEntityColumns);
- strategy.setSuperServiceClass("org.springblade.core.mp.base.BaseService");
- strategy.setSuperServiceImplClass("org.springblade.core.mp.base.BaseServiceImpl");
- } else {
- strategy.setSuperServiceClass("com.baomidou.mybatisplus.extension.service.IService");
- strategy.setSuperServiceImplClass("com.baomidou.mybatisplus.extension.service.impl.ServiceImpl");
- }
- // 自定义 controller 父类
- strategy.setSuperControllerClass("org.springblade.core.boot.ctrl.BladeController");
- strategy.setEntityBuilderModel(false);
- strategy.setEntityLombokModel(true);
- strategy.setControllerMappingHyphenStyle(true);
- mpg.setStrategy(strategy);
- // 包配置
- PackageConfig pc = new PackageConfig();
- // 控制台扫描
- pc.setModuleName(null);
- pc.setParent(packageName);
- pc.setController("controller");
- pc.setEntity("entity");
- pc.setXml("mapper");
- mpg.setPackageInfo(pc);
- mpg.setCfg(getInjectionConfig());
- mpg.execute();
- }
-
- private InjectionConfig getInjectionConfig() {
- String servicePackage = serviceName.split("-").length > 1 ? serviceName.split("-")[1] : serviceName;
- // 自定义配置
- InjectionConfig cfg = new InjectionConfig() {
- @Override
- public void initMap() {
- Map
- * 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
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.gnu.org/licenses/lgpl.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -15,15 +15,15 @@
*/
package $!{package.Controller};
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import lombok.AllArgsConstructor;
-import javax.validation.Valid;
+import jakarta.validation.Valid;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
-import org.springblade.system.feign.IDictClient;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;
@@ -35,14 +35,15 @@ import $!{package.Entity}.$!{entity};
#set($voPackage=$package.Entity.replace("entity","vo"))
import $!{voPackage}.$!{entity}VO;
#set($wrapperPackage=$package.Entity.replace("entity","wrapper"))
+#if($!{hasWrapper})
import $!{wrapperPackage}.$!{entity}Wrapper;
+#end
import $!{package.Service}.$!{table.serviceName};
#if($!{superControllerClassPackage})
import $!{superControllerClassPackage};
#end
#if(!$!{superEntityClass})
#end
-import java.util.List;
/**
* $!{table.comment} 控制器
@@ -52,8 +53,8 @@ import java.util.List;
*/
@RestController
@AllArgsConstructor
-@RequestMapping("#if($!{package.ModuleName})/$!{package.ModuleName}#end/$!{table.entityPath}")
-@Api(value = "$!{table.comment}", tags = "$!{table.comment}接口")
+@RequestMapping("#if($!{package.ModuleName})$!{package.ModuleName}#end/$!{entityKey}")
+@Tag(name = "$!{table.comment}", description = "$!{table.comment}接口")
#if($!{superControllerClass})
public class $!{table.controllerName} extends $!{superControllerClass} {
#else
@@ -62,63 +63,90 @@ public class $!{table.controllerName} {
private $!{table.serviceName} $!{table.entityPath}Service;
- private IDictClient dictClient;
-
+#if($!{hasWrapper})
/**
- * 详情
- */
+ * 详情
+ */
@GetMapping("/detail")
- @ApiOperation(value = "详情", notes = "传入$!{table.entityPath}", position = 1)
+ @ApiOperationSupport(order = 1)
+ @Operation(summary = "详情", description = "传入$!{table.entityPath}")
public R<$!{entity}VO> detail($!{entity} $!{table.entityPath}) {
$!{entity} detail = $!{table.entityPath}Service.getOne(Condition.getQueryWrapper($!{table.entityPath}));
- $!{entity}Wrapper $!{table.entityPath}Wrapper = new $!{entity}Wrapper(dictClient);
- return R.data($!{table.entityPath}Wrapper.entityVO(detail));
+ return R.data($!{entity}Wrapper.build().entityVO(detail));
}
/**
- * 分页 $!{table.comment}
- */
+ * 分页 $!{table.comment}
+ */
@GetMapping("/list")
- @ApiOperation(value = "分页", notes = "传入$!{table.entityPath}", position = 2)
+ @ApiOperationSupport(order = 2)
+ @Operation(summary = "分页", description = "传入$!{table.entityPath}")
public R
- * 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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package $!{package.Entity};
-
-#foreach($pkg in $!{table.importPackages})
-import $!{pkg};
-#end
-#if($!{entityLombokModel})
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-#end
-#if($!{swagger2})
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-#end
-
-/**
- * $!{table.comment}实体类
- *
- * @author $!{author}
- * @since $!{date}
- */
-#if($!{entityLombokModel})
-@Data
-#end
-#if($!{table.convert})
-@TableName("$!{table.name}")
-#end
-#if($!{superEntityClass})
-@EqualsAndHashCode(callSuper = true)
-#end
-#if($!{swagger2})
-@ApiModel(value = "$!{entity}对象", description = #if ("$!{table.comment}"=="")"$!{entity}对象"#else"$!{table.comment}"#end)
-#end
-#if($!{superEntityClass})
-public class $!{entity} extends $!{superEntityClass}#if($!{activeRecord})<$!{entity}>#end {
-#elseif($!{activeRecord})
-@Accessors(chain = true)
-public class $!{entity} extends Model<$!{entity}> {
-#else
-public class $!{entity} implements Serializable {
-#end
-
- private static final long serialVersionUID = 1L;
-
-## ---------- BEGIN 字段循环遍历 ----------
-#foreach($field in $!{table.fields})
-#if($!{field.keyFlag})
-#set($keyPropertyName=$!{field.propertyName})
-#end
-#if("$!field.comment" != "")
- /**
- * $!{field.comment}
- */
- #if($!{swagger2})
- @ApiModelProperty(value = "$!{field.comment}")
- #end
-#end
-#if($!{field.keyFlag})
-## 主键
-#if($!{field.keyIdentityFlag})
- @TableId(value = "$!{field.name}", type = IdType.AUTO)
-#elseif(!$null.isNull($!{idType}) && "$!idType" != "")
- @TableId(value = "$!{field.name}", type = IdType.$!{idType})
-#elseif($!{field.convert})
- @TableId("$!{field.name}")
-#end
-## 普通字段
-#elseif($!{field.fill})
-## ----- 存在字段填充设置 -----
-#if($!{field.convert})
- @TableField(value = "$!{field.name}", fill = FieldFill.$!{field.fill})
-#else
- @TableField(fill = FieldFill.$!{field.fill})
-#end
-#elseif($!{field.convert})
- @TableField("$!{field.name}")
-#end
-## 乐观锁注解
-#if($!{versionFieldName}==$!{field.name})
- @Version
-#end
-## 逻辑删除注解
-#if($!{logicDeleteFieldName}==$!{field.name})
- @TableLogic
-#end
- private $!{field.propertyType} $!{field.propertyName};
-
-#end
-## ---------- END 字段循环遍历 ----------
-
-#if(!$!{entityLombokModel})
-#foreach($field in $!{table.fields})
-#if($!{field.propertyType.equals("boolean")})
-#set($getprefix="is")
-#else
-#set($getprefix="get")
-#end
-
- public $!{field.propertyType} $!{getprefix}$!{field.capitalName}() {
- return $!{field.propertyName};
- }
-
-#if($!{entityBuilderModel})
- public $!{entity} set$!{field.capitalName}($!{field.propertyType} $!{field.propertyName}) {
-#else
- public void set$!{field.capitalName}($!{field.propertyType} $!{field.propertyName}) {
-#end
- this.$!{field.propertyName} = $!{field.propertyName};
-#if($!{entityBuilderModel})
- return this;
-#end
- }
-#end
-#end
-
-#if($!{entityColumnConstant})
-#foreach($field in $!{table.fields})
- public static final String $!{field.name.toUpperCase()} = "$!{field.name}";
-
-#end
-#end
-#if($!{activeRecord})
- @Override
- protected Serializable pkVal() {
-#if($!{keyPropertyName})
- return this.$!{keyPropertyName};
-#else
- return this.id;
-#end
- }
-
-#end
-#if(!$!{entityLombokModel})
- @Override
- public String toString() {
- return "$!{entity}{" +
-#foreach($field in $!{table.fields})
-#if($!{velocityCount}==1)
- "$!{field.propertyName}=" + $!{field.propertyName} +
-#else
- ", $!{field.propertyName}=" + $!{field.propertyName} +
-#end
-#end
- "}";
- }
-#end
-}
diff --git a/blade-ops/blade-develop/src/main/resources/templates/mapper.xml.vm b/blade-ops/blade-develop/src/main/resources/templates/mapper.xml.vm
deleted file mode 100644
index 77eb3dc682b25cafecc83e39b8d7985df21516b6..0000000000000000000000000000000000000000
--- a/blade-ops/blade-develop/src/main/resources/templates/mapper.xml.vm
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-
- * 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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package $!{package.ServiceImpl};
-
-import $!{package.Entity}.$!{entity};
-#set($voPackage=$package.Entity.replace("entity","vo"))
-import $!{voPackage}.$!{entity}VO;
-import $!{package.Mapper}.$!{table.mapperName};
-import $!{package.Service}.$!{table.serviceName};
-import $!{superServiceImplClassPackage};
-import org.springframework.stereotype.Service;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-
-/**
- * $!{table.comment} 服务实现类
- *
- * @author $!{author}
- * @since $!{date}
- */
-@Service
-#if($!{kotlin})
-open class $!{table.serviceImplName} : $!{superServiceImplClass}<$!{table.mapperName}, $!{entity}>(), $!{table.serviceName} {
-
-}
-#else
-public class $!{table.serviceImplName} extends $!{superServiceImplClass}<$!{table.mapperName}, $!{entity}> implements $!{table.serviceName} {
-
- @Override
- public IPage<$!{entity}VO> select$!{entity}Page(IPage<$!{entity}VO> page, $!{entity}VO $!{table.entityPath}) {
- return page.setRecords(baseMapper.select$!{entity}Page(page, $!{table.entityPath}));
- }
-
-}
-#end
diff --git a/blade-ops/blade-develop/src/main/resources/templates/sword/action.js.vm b/blade-ops/blade-develop/src/main/resources/templates/sword/action.js.vm
deleted file mode 100644
index e0eb4768565f83890f9877e7fafcaa1ff92a0b6c..0000000000000000000000000000000000000000
--- a/blade-ops/blade-develop/src/main/resources/templates/sword/action.js.vm
+++ /dev/null
@@ -1,37 +0,0 @@
-#set($upperEntityPath=$table.entityPath.toUpperCase())
-export const $!{upperEntityPath}_NAMESPACE = '$!{table.entityPath}';
-
-export function $!{upperEntityPath}_LIST(payload) {
- return {
- type: `${$!{upperEntityPath}_NAMESPACE}/fetchList`,
- payload,
- };
-}
-
-export function $!{upperEntityPath}_DETAIL(id) {
- return {
- type: `${$!{upperEntityPath}_NAMESPACE}/fetchDetail`,
- payload: { id },
- };
-}
-
-export function $!{upperEntityPath}_CLEAR_DETAIL() {
- return {
- type: `${$!{upperEntityPath}_NAMESPACE}/clearDetail`,
- payload: {},
- };
-}
-
-export function $!{upperEntityPath}_SUBMIT(payload) {
- return {
- type: `${$!{upperEntityPath}_NAMESPACE}/submit`,
- payload,
- };
-}
-
-export function $!{upperEntityPath}_REMOVE(payload) {
- return {
- type: `${$!{upperEntityPath}_NAMESPACE}/remove`,
- payload,
- };
-}
diff --git a/blade-ops/blade-develop/src/main/resources/templates/sword/add.js.vm b/blade-ops/blade-develop/src/main/resources/templates/sword/add.js.vm
deleted file mode 100644
index b1480a4245c5be831cd4a836204dd98bb5522082..0000000000000000000000000000000000000000
--- a/blade-ops/blade-develop/src/main/resources/templates/sword/add.js.vm
+++ /dev/null
@@ -1,73 +0,0 @@
-#set($upperEntityPath=$table.entityPath.toUpperCase())
-import React, { PureComponent } from 'react';
-import { Form, Input, Card, Button } from 'antd';
-import { connect } from 'dva';
-import Panel from '../../../components/Panel';
-import styles from '../../../layouts/Sword.less';
-import { $!{upperEntityPath}_SUBMIT } from '../../../actions/$!{table.entityPath}';
-
-const FormItem = Form.Item;
-
-@connect(({ loading }) => ({
- submitting: loading.effects['$!{table.entityPath}/submit'],
-}))
-@Form.create()
-class $!{entity}Add extends PureComponent {
- handleSubmit = e => {
- e.preventDefault();
- const { dispatch, form } = this.props;
- form.validateFieldsAndScroll((err, values) => {
- if (!err) {
- dispatch($!{upperEntityPath}_SUBMIT(values));
- }
- });
- };
-
- render() {
- const {
- form: { getFieldDecorator },
- submitting,
- } = this.props;
-
- const formItemLayout = {
- labelCol: {
- xs: { span: 24 },
- sm: { span: 7 },
- },
- wrapperCol: {
- xs: { span: 24 },
- sm: { span: 12 },
- md: { span: 10 },
- },
- };
-
- const action = (
-
- );
-
- return (
-
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +19,6 @@ package $!{wrapperPackage};
import lombok.AllArgsConstructor;
import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.utils.BeanUtil;
-import org.springblade.system.feign.IDictClient;
import $!{package.Entity}.$!{entity};
#set($voPackage=$package.Entity.replace("entity","vo"))
import $!{voPackage}.$!{entity}VO;
@@ -30,20 +29,15 @@ import $!{voPackage}.$!{entity}VO;
* @author $!{author}
* @since $!{date}
*/
-@AllArgsConstructor
public class $!{entity}Wrapper extends BaseEntityWrapper<$!{entity}, $!{entity}VO> {
- private IDictClient dictClient;
+ public static $!{entity}Wrapper build() {
+ return new $!{entity}Wrapper();
+ }
@Override
public $!{entity}VO entityVO($!{entity} $!{table.entityPath}) {
- $!{entity}VO $!{table.entityPath}VO = BeanUtil.copy($!{table.entityPath}, $!{entity}VO.class);
-
- /*R
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,9 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springblade.develop.support;
+package org.springblade.test;
+import org.springblade.develop.support.BladeCodeGenerator;
+
/**
* 代码生成器
*
@@ -23,14 +25,26 @@ package org.springblade.develop.support;
*/
public class CodeGenerator {
+ /**
+ * 代码生成的模块名
+ */
+ public static String CODE_NAME = "租户管理";
+ /**
+ * 代码所在服务名
+ */
+ public static String SERVICE_NAME = "blade-system";
/**
* 代码生成的包名
*/
- public static String PACKAGE_NAME = "org.springblade.demo";
+ public static String PACKAGE_NAME = "org.springblade.system";
+ /**
+ * 前端代码生成所属系统
+ */
+ public static String SYSTEM_NAME = "sword";
/**
- * 代码生成的地址
+ * 前端代码生成地址
*/
- public static String PACKAGE_DIR = "/blade-ops/blade-codegen/src/main/java";
+ public static String PACKAGE_WEB_DIR = "/Users/chill/Workspaces/product/Sword";
/**
* 需要去掉的表前缀
*/
@@ -38,7 +52,7 @@ public class CodeGenerator {
/**
* 需要生成的表名(两者只能取其一)
*/
- public static String[] INCLUDE_TABLES = {"blade_blog"};
+ public static String[] INCLUDE_TABLES = {"blade_tenant"};
/**
* 需要排除的表名(两者只能取其一)
*/
@@ -46,24 +60,28 @@ public class CodeGenerator {
/**
* 是否包含基础业务字段
*/
- public static Boolean HAS_SUPER_ENTITY = Boolean.FALSE;
+ public static Boolean HAS_SUPER_ENTITY = Boolean.TRUE;
/**
* 基础业务字段
*/
- public static String[] SUPER_ENTITY_COLUNMS = {"id", "create_time", "create_user", "update_time", "update_user", "status", "is_deleted"};
+ public static String[] SUPER_ENTITY_COLUMNS = {"create_time", "create_user", "update_time", "update_user", "status", "is_deleted"};
+
/**
* RUN THIS
*/
- public static void generate() {
- BladeGenerator generator = new BladeGenerator();
+ public static void main(String[] args) {
+ BladeCodeGenerator generator = new BladeCodeGenerator();
+ generator.setCodeName(CODE_NAME);
+ generator.setServiceName(SERVICE_NAME);
+ generator.setSystemName(SYSTEM_NAME);
generator.setPackageName(PACKAGE_NAME);
- generator.setPackageDir(PACKAGE_DIR);
+ generator.setPackageWebDir(PACKAGE_WEB_DIR);
generator.setTablePrefix(TABLE_PREFIX);
generator.setIncludeTables(INCLUDE_TABLES);
generator.setExcludeTables(EXCLUDE_TABLES);
generator.setHasSuperEntity(HAS_SUPER_ENTITY);
- generator.setSuperEntityColumns(SUPER_ENTITY_COLUNMS);
+ generator.setSuperEntityColumns(SUPER_ENTITY_COLUMNS);
generator.run();
}
diff --git a/blade-ops/blade-develop/src/test/resources/templates/code.properties b/blade-ops/blade-develop/src/test/resources/templates/code.properties
new file mode 100644
index 0000000000000000000000000000000000000000..229dc31a28525c7a18192c97104ef0eb8feb328b
--- /dev/null
+++ b/blade-ops/blade-develop/src/test/resources/templates/code.properties
@@ -0,0 +1,5 @@
+spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
+spring.datasource.url=jdbc:mysql://localhost:3306/blade?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&serverTimezone=GMT%2B8
+spring.datasource.username=root
+spring.datasource.password=root
+author=Blade
diff --git a/blade-ops/blade-develop/src/test/resources/templates/controller.java.vm b/blade-ops/blade-develop/src/test/resources/templates/controller.java.vm
new file mode 100644
index 0000000000000000000000000000000000000000..3862210a8b5742e2f2c16c1e3afd8d3b94f9d664
--- /dev/null
+++ b/blade-ops/blade-develop/src/test/resources/templates/controller.java.vm
@@ -0,0 +1,180 @@
+/**
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
+ *
+ * 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
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * 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 $!{package.Controller};
+
+import io.swagger.v3.oas.annotations.tags.Tag;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import lombok.AllArgsConstructor;
+import jakarta.validation.Valid;
+
+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.*;
+#if($!{superEntityClass})
+import org.springframework.web.bind.annotation.RequestParam;
+#end
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import $!{package.Entity}.$!{entity};
+#set($voPackage=$package.Entity.replace("entity","vo"))
+import $!{voPackage}.$!{entity}VO;
+#set($wrapperPackage=$package.Entity.replace("entity","wrapper"))
+#if($!{hasWrapper})
+import $!{wrapperPackage}.$!{entity}Wrapper;
+#end
+import $!{package.Service}.$!{table.serviceName};
+#if($!{superControllerClassPackage})
+import $!{superControllerClassPackage};
+#end
+#if(!$!{superEntityClass})
+#end
+
+/**
+ * $!{table.comment} 控制器
+ *
+ * @author $!{author}
+ * @since $!{date}
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("#if($!{package.ModuleName})$!{package.ModuleName}#end/$!{entityKey}")
+@Tag(name = "$!{table.comment}", description = "$!{table.comment}接口")
+#if($!{superControllerClass})
+public class $!{table.controllerName} extends $!{superControllerClass} {
+#else
+public class $!{table.controllerName} {
+#end
+
+ private $!{table.serviceName} $!{table.entityPath}Service;
+
+#if($!{hasWrapper})
+ /**
+ * 详情
+ */
+ @GetMapping("/detail")
+ @ApiOperationSupport(order = 1)
+ @Operation(summary = "详情", description = "传入$!{table.entityPath}")
+ public R<$!{entity}VO> detail($!{entity} $!{table.entityPath}) {
+ $!{entity} detail = $!{table.entityPath}Service.getOne(Condition.getQueryWrapper($!{table.entityPath}));
+ return R.data($!{entity}Wrapper.build().entityVO(detail));
+ }
+
+ /**
+ * 分页 $!{table.comment}
+ */
+ @GetMapping("/list")
+ @ApiOperationSupport(order = 2)
+ @Operation(summary = "分页", description = "传入$!{table.entityPath}")
+ public R
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,30 +13,33 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springblade.system.wrapper;
+#set($wrapperPackage=$package.Entity.replace("entity","wrapper"))
+package $!{wrapperPackage};
import lombok.AllArgsConstructor;
import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.utils.BeanUtil;
-import org.springblade.system.entity.RoleMenu;
-import org.springblade.system.feign.IDictClient;
-import org.springblade.system.vo.RoleMenuVO;
+import $!{package.Entity}.$!{entity};
+#set($voPackage=$package.Entity.replace("entity","vo"))
+import $!{voPackage}.$!{entity}VO;
/**
- * 包装类,返回视图层所需的字段
+ * $!{table.comment}包装类,返回视图层所需的字段
*
- * @author Chill
- * @since 2018-12-24
+ * @author $!{author}
+ * @since $!{date}
*/
-@AllArgsConstructor
-public class RoleMenuWrapper extends BaseEntityWrapper
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package 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 53%
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..10122bfe9d7999f0dcdb9c302e67f953be08155c 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
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -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-service/blade-user/src/main/resources/application-dev.yml b/blade-ops/blade-report/src/main/resources/application-dev.yml
similarity index 81%
rename from blade-service/blade-user/src/main/resources/application-dev.yml
rename to blade-ops/blade-report/src/main/resources/application-dev.yml
index 2d9323b6a826388d7bb2d6222d17baf102b5d352..97f23c86c9f442b3587491ed0c930c7748206129 100644
--- a/blade-service/blade-user/src/main/resources/application-dev.yml
+++ b/blade-ops/blade-report/src/main/resources/application-dev.yml
@@ -1,7 +1,3 @@
-#服务器端口
-server:
- port: 8102
-
#数据源配置
spring:
datasource:
diff --git a/blade-service/blade-user/src/main/resources/application-prod.yml b/blade-ops/blade-report/src/main/resources/application-prod.yml
similarity index 81%
rename from blade-service/blade-user/src/main/resources/application-prod.yml
rename to blade-ops/blade-report/src/main/resources/application-prod.yml
index c0d8c0562a0cadfa783ac1f4e242e8e8eff1441f..c238494f676e13bf479844bc2b4947c6d6b54f3e 100644
--- a/blade-service/blade-user/src/main/resources/application-prod.yml
+++ b/blade-ops/blade-report/src/main/resources/application-prod.yml
@@ -1,7 +1,3 @@
-#服务器端口
-server:
- port: 8102
-
#数据源配置
spring:
datasource:
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..ca95c3dcd9aa4e5daf65ebfb22359207a1d21b17
--- /dev/null
+++ b/blade-ops/blade-resource/Dockerfile
@@ -0,0 +1,15 @@
+FROM bladex/alpine-java:openjdk17_cn_slim
+
+MAINTAINER bladejava@qq.com
+
+RUN mkdir -p /blade/resource
+
+WORKDIR /blade/resource
+
+EXPOSE 8010
+
+ADD ./target/blade-resource.jar ./app.jar
+
+ENTRYPOINT ["java", "--add-opens", "java.base/java.lang=ALL-UNNAMED", "--add-opens", "java.base/java.lang.reflect=ALL-UNNAMED", "-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..7dc3b6021e95564fd64bdf8d303f1a1dec2794c7
--- /dev/null
+++ b/blade-ops/blade-resource/pom.xml
@@ -0,0 +1,74 @@
+
+
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package 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..952528fb5115150d8540a9192208df2f613329c4
--- /dev/null
+++ b/blade-ops/blade-resource/src/main/java/org/springblade/resource/endpoint/OssEndpoint.java
@@ -0,0 +1,173 @@
+/**
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springblade.resource.endpoint;
+
+import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.AllArgsConstructor;
+import lombok.SneakyThrows;
+import org.springblade.core.oss.QiniuTemplate;
+import org.springblade.core.oss.model.BladeFile;
+import org.springblade.core.oss.model.OssFile;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.Func;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * 对象存储端点
+ *
+ * @author Chill
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("/oss/endpoint")
+@Tag(name = "对象存储端点", description = "对象存储端点")
+public class OssEndpoint {
+
+ private QiniuTemplate qiniuTemplate;
+
+ /**
+ * 创建存储桶
+ *
+ * @param bucketName 存储桶名称
+ * @return Bucket
+ */
+ @SneakyThrows
+ @PostMapping("/make-bucket")
+ public R makeBucket(@RequestParam String bucketName) {
+ qiniuTemplate.makeBucket(bucketName);
+ return R.success("创建成功");
+ }
+
+ /**
+ * 创建存储桶
+ *
+ * @param bucketName 存储桶名称
+ * @return R
+ */
+ @SneakyThrows
+ @PostMapping("/remove-bucket")
+ public R removeBucket(@RequestParam String bucketName) {
+ qiniuTemplate.removeBucket(bucketName);
+ return R.success("删除成功");
+ }
+
+ /**
+ * 拷贝文件
+ *
+ * @param fileName 存储桶对象名称
+ * @param destBucketName 目标存储桶名称
+ * @param destFileName 目标存储桶对象名称
+ * @return R
+ */
+ @SneakyThrows
+ @PostMapping("/copy-file")
+ public R copyFile(@RequestParam String fileName, @RequestParam String destBucketName, String destFileName) {
+ qiniuTemplate.copyFile(fileName, destBucketName, destFileName);
+ return R.success("操作成功");
+ }
+
+ /**
+ * 获取文件信息
+ *
+ * @param fileName 存储桶对象名称
+ * @return InputStream
+ */
+ @SneakyThrows
+ @GetMapping("/stat-file")
+ public R
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,24 +13,25 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springblade.system.user;
+package org.springblade.seata.order;
import org.springblade.core.launch.BladeApplication;
import org.springblade.core.launch.constant.AppConstant;
-import org.springframework.cloud.client.SpringCloudApplication;
+import org.springblade.core.transaction.annotation.SeataCloudApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
/**
- * 用户启动器
+ * Order启动器
*
* @author Chill
*/
-@SpringCloudApplication
+@SeataCloudApplication
@EnableFeignClients(AppConstant.BASE_PACKAGES)
-public class UserApplication {
+public class SeataOrderApplication {
public static void main(String[] args) {
- BladeApplication.run(AppConstant.APPLICATION_USER_NAME, UserApplication.class, args);
+ BladeApplication.run("blade-seata-order", SeataOrderApplication.class, args);
}
}
+
diff --git a/blade-ops/blade-seata-order/src/main/java/org/springblade/seata/order/controller/OrderController.java b/blade-ops/blade-seata-order/src/main/java/org/springblade/seata/order/controller/OrderController.java
new file mode 100644
index 0000000000000000000000000000000000000000..93085687270ba5c040829fb331fd7738c7a65f01
--- /dev/null
+++ b/blade-ops/blade-seata-order/src/main/java/org/springblade/seata/order/controller/OrderController.java
@@ -0,0 +1,34 @@
+package org.springblade.seata.order.controller;
+
+import lombok.AllArgsConstructor;
+import org.springblade.core.tool.api.R;
+import org.springblade.seata.order.service.IOrderService;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * OrderController
+ *
+ * @author Chill
+ */
+@RestController
+@RequestMapping("order")
+@AllArgsConstructor
+public class OrderController {
+
+ private IOrderService orderService;
+
+ /**
+ * 创建订单
+ *
+ * @param userId 用户id
+ * @param commodityCode 商品代码
+ * @param count 数量
+ * @return boolean
+ */
+ @RequestMapping("/create")
+ public R createOrder(String userId, String commodityCode, Integer count) {
+ return R.status(orderService.createOrder(userId, commodityCode, count));
+ }
+
+}
diff --git a/blade-ops/blade-seata-order/src/main/java/org/springblade/seata/order/entity/Order.java b/blade-ops/blade-seata-order/src/main/java/org/springblade/seata/order/entity/Order.java
new file mode 100644
index 0000000000000000000000000000000000000000..48ac3976fe4cc356df16231571b24513fb75cedd
--- /dev/null
+++ b/blade-ops/blade-seata-order/src/main/java/org/springblade/seata/order/entity/Order.java
@@ -0,0 +1,33 @@
+package org.springblade.seata.order.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * Order
+ *
+ * @author Chill
+ */
+@Data
+@Accessors(chain = true)
+@TableName("tb_order")
+public class Order implements Serializable {
+
+ @Serial
+ private static final long serialVersionUID = 1L;
+
+ @TableId(value = "id", type = IdType.AUTO)
+ private Integer id;
+ private String userId;
+ private String commodityCode;
+ private Integer count;
+ private BigDecimal money;
+
+}
diff --git a/blade-ops/blade-seata-order/src/main/java/org/springblade/seata/order/feign/IStorageClient.java b/blade-ops/blade-seata-order/src/main/java/org/springblade/seata/order/feign/IStorageClient.java
new file mode 100644
index 0000000000000000000000000000000000000000..1605f1d356c309b88a03c0c7627795a2d73b9ebf
--- /dev/null
+++ b/blade-ops/blade-seata-order/src/main/java/org/springblade/seata/order/feign/IStorageClient.java
@@ -0,0 +1,25 @@
+package org.springblade.seata.order.feign;
+
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+/**
+ * StorageClient
+ *
+ * @author Chill
+ */
+@FeignClient(name = "blade-seata-storage", fallback = StorageClientFallback.class)
+public interface IStorageClient {
+
+ /**
+ * 减库存
+ *
+ * @param commodityCode 商品代码
+ * @param count 数量
+ * @return boolean
+ */
+ @GetMapping("/storage/deduct")
+ int deduct(@RequestParam("commodityCode") String commodityCode, @RequestParam("count") Integer count);
+
+}
diff --git a/blade-ops/blade-seata-order/src/main/java/org/springblade/seata/order/feign/StorageClientFallback.java b/blade-ops/blade-seata-order/src/main/java/org/springblade/seata/order/feign/StorageClientFallback.java
new file mode 100644
index 0000000000000000000000000000000000000000..6bfaeef7fe4e44ae45a6c0ea180f5dc16973c557
--- /dev/null
+++ b/blade-ops/blade-seata-order/src/main/java/org/springblade/seata/order/feign/StorageClientFallback.java
@@ -0,0 +1,18 @@
+package org.springblade.seata.order.feign;
+
+import org.springframework.stereotype.Component;
+
+/**
+ * StorageClientFallback
+ *
+ * @author Chill
+ */
+@Component
+public class StorageClientFallback implements IStorageClient {
+
+ @Override
+ public int deduct(String commodityCode, Integer count) {
+ return -1;
+ }
+
+}
diff --git a/blade-ops/blade-seata-order/src/main/java/org/springblade/seata/order/mapper/OrderMapper.java b/blade-ops/blade-seata-order/src/main/java/org/springblade/seata/order/mapper/OrderMapper.java
new file mode 100644
index 0000000000000000000000000000000000000000..078c9808ff167a4fc720ea075b08e53fda6b8dbd
--- /dev/null
+++ b/blade-ops/blade-seata-order/src/main/java/org/springblade/seata/order/mapper/OrderMapper.java
@@ -0,0 +1,12 @@
+package org.springblade.seata.order.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.springblade.seata.order.entity.Order;
+
+/**
+ * OrderMapper
+ *
+ * @author Chill
+ */
+public interface OrderMapper extends BaseMapper
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springblade.seata.storage;
+
+import org.springblade.core.launch.BladeApplication;
+import org.springblade.core.launch.constant.AppConstant;
+import org.springblade.core.transaction.annotation.SeataCloudApplication;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+
+/**
+ * Storage启动器
+ *
+ * @author Chill
+ */
+@SeataCloudApplication
+@EnableFeignClients(AppConstant.BASE_PACKAGES)
+public class SeataStorageApplication {
+
+ public static void main(String[] args) {
+ BladeApplication.run("blade-seata-storage", SeataStorageApplication.class, args);
+ }
+
+}
+
diff --git a/blade-ops/blade-seata-storage/src/main/java/org/springblade/seata/storage/controller/StorageController.java b/blade-ops/blade-seata-storage/src/main/java/org/springblade/seata/storage/controller/StorageController.java
new file mode 100644
index 0000000000000000000000000000000000000000..f44470975bf35e943d6c88cf0f8b142b218a6c3d
--- /dev/null
+++ b/blade-ops/blade-seata-storage/src/main/java/org/springblade/seata/storage/controller/StorageController.java
@@ -0,0 +1,31 @@
+package org.springblade.seata.storage.controller;
+
+import lombok.AllArgsConstructor;
+import org.springblade.seata.storage.service.IStorageService;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * StorageController
+ *
+ * @author Chill
+ */
+@RestController
+@RequestMapping("storage")
+@AllArgsConstructor
+public class StorageController {
+
+ private IStorageService storageService;
+
+ /**
+ * 减库存
+ *
+ * @param commodityCode 商品代码
+ * @param count 数量
+ */
+ @RequestMapping(path = "/deduct")
+ public int deduct(String commodityCode, Integer count) {
+ return storageService.deduct(commodityCode, count);
+ }
+
+}
diff --git a/blade-ops/blade-seata-storage/src/main/java/org/springblade/seata/storage/entity/Storage.java b/blade-ops/blade-seata-storage/src/main/java/org/springblade/seata/storage/entity/Storage.java
new file mode 100644
index 0000000000000000000000000000000000000000..b1e80ac658a0e4d177465eadb5dc82a3c418afd3
--- /dev/null
+++ b/blade-ops/blade-seata-storage/src/main/java/org/springblade/seata/storage/entity/Storage.java
@@ -0,0 +1,26 @@
+package org.springblade.seata.storage.entity;
+
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * storage
+ *
+ * @author Chill
+ */
+@Data
+@TableName("tb_storage")
+public class Storage implements Serializable {
+
+ @Serial
+ private static final long serialVersionUID = 1L;
+
+ private Long id;
+ private String commodityCode;
+ private Long count;
+
+}
diff --git a/blade-ops/blade-seata-storage/src/main/java/org/springblade/seata/storage/mapper/StorageMapper.java b/blade-ops/blade-seata-storage/src/main/java/org/springblade/seata/storage/mapper/StorageMapper.java
new file mode 100644
index 0000000000000000000000000000000000000000..800ac017266de305607bc2f26a0ca73264e14db1
--- /dev/null
+++ b/blade-ops/blade-seata-storage/src/main/java/org/springblade/seata/storage/mapper/StorageMapper.java
@@ -0,0 +1,12 @@
+package org.springblade.seata.storage.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.springblade.seata.storage.entity.Storage;
+
+/**
+ * StorageMapper
+ *
+ * @author Chill
+ */
+public interface StorageMapper extends BaseMapper
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package 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.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.core.mp.base.BaseEntity;
+
+import java.io.Serial;
+import java.util.Date;
+
+/**
+ * 实体类
+ *
+ * @author Chill
+ */
+@Data
+@TableName("blade_notice")
+@EqualsAndHashCode(callSuper = true)
+public class Notice extends BaseEntity {
+
+ @Serial
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 主键id
+ */
+ @Schema(description = "主键")
+ @TableId(value = "id", type = IdType.ASSIGN_ID)
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long id;
+
+ /**
+ * 标题
+ */
+ @Schema(description = "标题")
+ private String title;
+
+ /**
+ * 通知类型
+ */
+ @Schema(description = "通知类型")
+ private Integer category;
+
+ /**
+ * 发布日期
+ */
+ @Schema(description = "发布日期")
+ private Date releaseTime;
+
+ /**
+ * 内容
+ */
+ @Schema(description = "内容")
+ 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..19410c0f0fbd9c9af6a7abaad5a1a4a9cc4dc4a2
--- /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-2099, Chill Zhuang 庄骞 (bladejava@qq.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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.example.demo.feign;
+
+import org.springblade.core.launch.constant.AppConstant;
+import org.springblade.core.tool.api.R;
+import com.example.demo.entity.Notice;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import java.util.List;
+
+/**
+ * Notice Feign接口类
+ *
+ * @author Chill
+ */
+@FeignClient(
+ value = AppConstant.APPLICATION_DESK_NAME
+)
+public interface INoticeClient {
+
+ String API_PREFIX = "/client";
+ String TOP = API_PREFIX + "/top";
+
+ /**
+ * 获取notice列表
+ *
+ * @param number
+ * @return
+ */
+ @GetMapping(TOP)
+ R
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,17 @@
*/
package org.springblade.desk.entity;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
-import io.swagger.annotations.ApiModelProperty;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.BaseEntity;
+import java.io.Serial;
import java.util.Date;
/**
@@ -33,30 +38,39 @@ import java.util.Date;
@TableName("blade_notice")
public class Notice extends BaseEntity {
+ @Serial
private static final long serialVersionUID = 1L;
+ /**
+ * 主键id
+ */
+ @Schema(description = "主键")
+ @TableId(value = "id", type = IdType.ASSIGN_ID)
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long id;
+
/**
* 标题
*/
- @ApiModelProperty(value = "标题")
+ @Schema(description = "标题")
private String title;
/**
* 通知类型
*/
- @ApiModelProperty(value = "通知类型")
+ @Schema(description = "通知类型")
private Integer category;
/**
* 发布日期
*/
- @ApiModelProperty(value = "发布日期")
- private Date date;
+ @Schema(description = "发布日期")
+ private Date releaseTime;
/**
* 内容
*/
- @ApiModelProperty(value = "内容")
+ @Schema(description = "内容")
private String content;
diff --git a/blade-service-api/blade-desk-api/src/main/java/org/springblade/desk/feign/INoticeClient.java b/blade-service-api/blade-desk-api/src/main/java/org/springblade/desk/feign/INoticeClient.java
index 1c9640045c44d598b71224be28624eb5519570bb..3d174e859c8f156f1099861386aa1ee462ddbb3d 100644
--- a/blade-service-api/blade-desk-api/src/main/java/org/springblade/desk/feign/INoticeClient.java
+++ b/blade-service-api/blade-desk-api/src/main/java/org/springblade/desk/feign/INoticeClient.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
*
* 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/blade-service-api/blade-desk-api/src/main/java/org/springblade/desk/vo/NoticeVO.java b/blade-service-api/blade-desk-api/src/main/java/org/springblade/desk/vo/NoticeVO.java
index 49e237480a9e9245a21ae0ed10a603a8e8211c61..958ca6f5cdb79c0ef151162f806ce701b3aebbdb 100644
--- a/blade-service-api/blade-desk-api/src/main/java/org/springblade/desk/vo/NoticeVO.java
+++ b/blade-service-api/blade-desk-api/src/main/java/org/springblade/desk/vo/NoticeVO.java
@@ -1,6 +1,6 @@
package org.springblade.desk.vo;
-import io.swagger.annotations.ApiModelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.desk.entity.Notice;
@@ -14,7 +14,7 @@ import org.springblade.desk.entity.Notice;
@EqualsAndHashCode(callSuper = true)
public class NoticeVO extends Notice {
- @ApiModelProperty(value = "通知类型名")
+ @Schema(description = "通知类型名")
private String categoryName;
}
diff --git a/blade-service-api/blade-dict-api/pom.xml b/blade-service-api/blade-dict-api/pom.xml
index 3b8f6112a1e9fbe5dacb89bf6a14ee89f1df214f..31d0a38b6e5eb71deddbb2bfae5818041af8ba9c 100644
--- a/blade-service-api/blade-dict-api/pom.xml
+++ b/blade-service-api/blade-dict-api/pom.xml
@@ -5,13 +5,12 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,6 +19,8 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.system.entity.Dict;
+import java.io.Serial;
+
/**
* 数据传输对象实体类
*
@@ -28,6 +30,7 @@ import org.springblade.system.entity.Dict;
@Data
@EqualsAndHashCode(callSuper = true)
public class DictDTO extends Dict {
+ @Serial
private static final long serialVersionUID = 1L;
}
diff --git a/blade-service-api/blade-dict-api/src/main/java/org/springblade/system/entity/Dict.java b/blade-service-api/blade-dict-api/src/main/java/org/springblade/system/entity/Dict.java
index 9f6808ff6f29a661fafedfd656c867c18d8eebf3..1ca169c0ee0fe6522eb4cf77761ee61602dd9313 100644
--- a/blade-service-api/blade-dict-api/src/main/java/org/springblade/system/entity/Dict.java
+++ b/blade-service-api/blade-dict-api/src/main/java/org/springblade/system/entity/Dict.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,10 +19,12 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
+import java.io.Serial;
import java.io.Serializable;
/**
@@ -33,59 +35,62 @@ import java.io.Serializable;
*/
@Data
@TableName("blade_dict")
-@ApiModel(value = "Dict对象", description = "Dict对象")
+@Schema(description = "Dict对象")
public class Dict implements Serializable {
+ @Serial
private static final long serialVersionUID = 1L;
/**
* 主键
*/
- @ApiModelProperty(value = "主键")
- @TableId(value = "id", type = IdType.AUTO)
- private Integer id;
+ @Schema(description = "主键")
+ @TableId(value = "id", type = IdType.ASSIGN_ID)
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long id;
/**
* 父主键
*/
- @ApiModelProperty(value = "父主键")
- private Integer parentId;
+ @Schema(description = "父主键")
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long parentId;
/**
* 字典码
*/
- @ApiModelProperty(value = "字典码")
+ @Schema(description = "字典码")
private String code;
/**
* 字典值
*/
- @ApiModelProperty(value = "字典值")
+ @Schema(description = "字典值")
private Integer dictKey;
/**
* 字典名称
*/
- @ApiModelProperty(value = "字典名称")
+ @Schema(description = "字典名称")
private String dictValue;
/**
* 排序
*/
- @ApiModelProperty(value = "排序")
+ @Schema(description = "排序")
private Integer sort;
/**
* 字典备注
*/
- @ApiModelProperty(value = "字典备注")
+ @Schema(description = "字典备注")
private String remark;
/**
* 是否已删除
*/
@TableLogic
- @ApiModelProperty(value = "是否已删除")
+ @Schema(description = "是否已删除")
private Integer isDeleted;
diff --git a/blade-service-api/blade-dict-api/src/main/java/org/springblade/system/feign/IDictClient.java b/blade-service-api/blade-dict-api/src/main/java/org/springblade/system/feign/IDictClient.java
index 9aeabeeba77fba40647edaef91efe7a785fe2ec6..ade68aa48ff23a6943bd79c06e7ec89f6f00ea0b 100644
--- a/blade-service-api/blade-dict-api/src/main/java/org/springblade/system/feign/IDictClient.java
+++ b/blade-service-api/blade-dict-api/src/main/java/org/springblade/system/feign/IDictClient.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
*
* 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/blade-service-api/blade-dict-api/src/main/java/org/springblade/system/feign/IDictClientFallback.java b/blade-service-api/blade-dict-api/src/main/java/org/springblade/system/feign/IDictClientFallback.java
index 1933829463423e20c2fb0cca107f2935ca0dcf84..b54831234e0b29ebdce5a3530f10de4860017f39 100644
--- a/blade-service-api/blade-dict-api/src/main/java/org/springblade/system/feign/IDictClientFallback.java
+++ b/blade-service-api/blade-dict-api/src/main/java/org/springblade/system/feign/IDictClientFallback.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@ package org.springblade.system.feign;
import org.springblade.core.tool.api.R;
import org.springblade.system.entity.Dict;
+import org.springframework.stereotype.Component;
import java.util.List;
@@ -25,6 +26,7 @@ import java.util.List;
*
* @author Chill
*/
+@Component
public class IDictClientFallback implements IDictClient {
@Override
public R
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,12 +16,15 @@
package org.springblade.system.vo;
import com.fasterxml.jackson.annotation.JsonInclude;
-import io.swagger.annotations.ApiModel;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.tool.node.INode;
import org.springblade.system.entity.Dict;
+import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
@@ -33,27 +36,30 @@ import java.util.List;
*/
@Data
@EqualsAndHashCode(callSuper = true)
-@ApiModel(value = "DictVO对象", description = "DictVO对象")
-public class DictVO extends Dict implements INode {
+@Schema(description = "DictVO对象")
+public class DictVO extends Dict implements INode
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package 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
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -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..fef9addeb17da2583680948cbadff5a4a239f3a6
--- /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-2099, Chill Zhuang 庄骞 (bladejava@qq.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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package 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
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package 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
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springblade.system.handler;
+
+import org.springblade.core.datascope.handler.ScopeModelHandler;
+import org.springblade.core.datascope.model.DataScopeModel;
+import org.springblade.system.cache.DataScopeCache;
+
+import java.util.List;
+
+/**
+ * 通用数据权限规则
+ *
+ * @author Chill
+ */
+public class DataScopeModelHandler implements ScopeModelHandler {
+
+ /**
+ * 获取数据权限
+ *
+ * @param mapperId 数据权限mapperId
+ * @param roleId 用户角色集合
+ * @return DataScopeModel
+ */
+ @Override
+ public DataScopeModel getDataScopeByMapper(String mapperId, String roleId) {
+ return DataScopeCache.getDataScopeByMapper(mapperId, roleId);
+ }
+
+ /**
+ * 获取数据权限
+ *
+ * @param code 数据权限资源编号
+ * @return DataScopeModel
+ */
+ @Override
+ public DataScopeModel getDataScopeByCode(String code) {
+ return DataScopeCache.getDataScopeByCode(code);
+ }
+
+ /**
+ * 获取部门子级
+ *
+ * @param deptId 部门id
+ * @return deptIds
+ */
+ @Override
+ public List
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,15 +19,17 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.system.entity.Dept;
+import java.io.Serial;
+
/**
* 数据传输对象实体类
*
* @author Chill
- * @since 2018-12-24
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class DeptDTO extends Dept {
+ @Serial
private static final long serialVersionUID = 1L;
}
diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/dto/MenuDTO.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/dto/MenuDTO.java
index 8346ded61bad4a86e0ed30062c7c0d6e8f2ac329..899ca500552e0efdfe94ade7352716ca70d16677 100644
--- a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/dto/MenuDTO.java
+++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/dto/MenuDTO.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,16 +17,17 @@ package org.springblade.system.dto;
import lombok.Data;
+import java.io.Serial;
import java.io.Serializable;
/**
* 数据传输对象实体类
*
* @author Chill
- * @since 2018-12-24
*/
@Data
public class MenuDTO implements Serializable {
+ @Serial
private static final long serialVersionUID = 1L;
private String alias;
private String path;
diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/dto/ParamDTO.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/dto/ParamDTO.java
index cd22ebc3b7ca3b83370149f19804404063cba66a..893cd1929e765f463620e74fd7b5680ac9fb094b 100644
--- a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/dto/ParamDTO.java
+++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/dto/ParamDTO.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,15 +19,17 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.system.entity.Param;
+import java.io.Serial;
+
/**
* 数据传输对象实体类
*
* @author Chill
- * @since 2018-12-28
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class ParamDTO extends Param {
+ @Serial
private static final long serialVersionUID = 1L;
}
diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/dto/RoleDTO.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/dto/RoleDTO.java
index 76df81d7a4cad13921c9cd96f9e0c8e65a30bd8d..066d5aa1f3e1381d1e08d76ac740a84d40652530 100644
--- a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/dto/RoleDTO.java
+++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/dto/RoleDTO.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,15 +19,17 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.system.entity.Role;
+import java.io.Serial;
+
/**
* 数据传输对象实体类
*
* @author Chill
- * @since 2018-12-24
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class RoleDTO extends Role {
+ @Serial
private static final long serialVersionUID = 1L;
}
diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/dto/RoleMenuDTO.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/dto/RoleMenuDTO.java
index 137e8506e3e86efd737556545f05792896def942..c37aec17723a18a98be9ee0c20b04feb88029d9f 100644
--- a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/dto/RoleMenuDTO.java
+++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/dto/RoleMenuDTO.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,15 +19,17 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.system.entity.RoleMenu;
+import java.io.Serial;
+
/**
* 数据传输对象实体类
*
* @author Chill
- * @since 2018-12-24
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class RoleMenuDTO extends RoleMenu {
+ @Serial
private static final long serialVersionUID = 1L;
}
diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/AuthClient.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/AuthClient.java
new file mode 100644
index 0000000000000000000000000000000000000000..136d84ffa49fbcea6d895f397f5003de2d440653
--- /dev/null
+++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/AuthClient.java
@@ -0,0 +1,110 @@
+/**
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package 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.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.core.mp.base.BaseEntity;
+
+import java.io.Serial;
+
+/**
+ * 实体类
+ *
+ * @author BladeX
+ * @since 2019-03-24
+ */
+@Data
+@TableName("blade_client")
+@EqualsAndHashCode(callSuper = true)
+@Schema(description = "Client对象")
+public class AuthClient extends BaseEntity {
+
+ @Serial
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 主键id
+ */
+ @Schema(description = "主键")
+ @TableId(value = "id", type = IdType.ASSIGN_ID)
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long id;
+
+ /**
+ * 客户端id
+ */
+ @Schema(description = "客户端id")
+ private String clientId;
+ /**
+ * 客户端密钥
+ */
+ @Schema(description = "客户端密钥")
+ private String clientSecret;
+ /**
+ * 资源集合
+ */
+ @Schema(description = "资源集合")
+ private String resourceIds;
+ /**
+ * 授权范围
+ */
+ @Schema(description = "授权范围")
+ private String scope;
+ /**
+ * 授权类型
+ */
+ @Schema(description = "授权类型")
+ private String authorizedGrantTypes;
+ /**
+ * 回调地址
+ */
+ @Schema(description = "回调地址")
+ private String webServerRedirectUri;
+ /**
+ * 权限
+ */
+ @Schema(description = "权限")
+ private String authorities;
+ /**
+ * 令牌过期秒数
+ */
+ @Schema(description = "令牌过期秒数")
+ private Integer accessTokenValidity;
+ /**
+ * 刷新令牌过期秒数
+ */
+ @Schema(description = "刷新令牌过期秒数")
+ private Integer refreshTokenValidity;
+ /**
+ * 附加说明
+ */
+ @Schema(description = "附加说明")
+ private String additionalInformation;
+ /**
+ * 自动授权
+ */
+ @Schema(description = "自动授权")
+ private String autoapprove;
+
+
+}
diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/DataScope.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/DataScope.java
new file mode 100644
index 0000000000000000000000000000000000000000..b08d89305f41eb4c5913b97e3d9e07f4b23ba560
--- /dev/null
+++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/DataScope.java
@@ -0,0 +1,99 @@
+/**
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package 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.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.core.mp.base.BaseEntity;
+
+import java.io.Serial;
+
+/**
+ * 实体类
+ *
+ * @author BladeX
+ */
+@Data
+@TableName("blade_scope_data")
+@EqualsAndHashCode(callSuper = true)
+@Schema(description = "DataScope对象")
+public class DataScope extends BaseEntity {
+
+ @Serial
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 主键
+ */
+ @Schema(description = "主键")
+ @TableId(value = "id", type = IdType.ASSIGN_ID)
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long id;
+
+ /**
+ * 菜单主键
+ */
+ @Schema(description = "菜单主键")
+ private Long menuId;
+ /**
+ * 资源编号
+ */
+ @Schema(description = "资源编号")
+ private String resourceCode;
+ /**
+ * 数据权限名称
+ */
+ @Schema(description = "数据权限名称")
+ private String scopeName;
+ /**
+ * 数据权限可见字段
+ */
+ @Schema(description = "数据权限可见字段")
+ private String scopeField;
+ /**
+ * 数据权限类名
+ */
+ @Schema(description = "数据权限类名")
+ private String scopeClass;
+ /**
+ * 数据权限字段
+ */
+ @Schema(description = "数据权限字段")
+ private String scopeColumn;
+ /**
+ * 数据权限类型
+ */
+ @Schema(description = "数据权限类型")
+ private Integer scopeType;
+ /**
+ * 数据权限值域
+ */
+ @Schema(description = "数据权限值域")
+ private String scopeValue;
+ /**
+ * 数据权限备注
+ */
+ @Schema(description = "数据权限备注")
+ private String remark;
+
+
+}
diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/Dept.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/Dept.java
index b2c15619c5dfc22c52df1ee8ef1b2e5880266952..48c1040b1627fd0ce7f2b8e588b867e1e9fa554b 100644
--- a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/Dept.java
+++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/Dept.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,67 +19,83 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
+import java.io.Serial;
import java.io.Serializable;
/**
* 实体类
*
* @author Chill
- * @since 2018-12-24
*/
@Data
@TableName("blade_dept")
-@ApiModel(value = "Dept对象", description = "Dept对象")
+@Schema(description = "Dept对象")
public class Dept implements Serializable {
+ @Serial
private static final long serialVersionUID = 1L;
/**
* 主键
*/
- @ApiModelProperty(value = "主键")
- @TableId(value = "id", type = IdType.AUTO)
- private Integer id;
+ @Schema(description = "主键")
+ @TableId(value = "id", type = IdType.ASSIGN_ID)
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long id;
+
+ /**
+ * 租户ID
+ */
+ @Schema(description = "租户ID")
+ private String tenantId;
/**
* 父主键
*/
- @ApiModelProperty(value = "父主键")
- private Integer parentId;
+ @Schema(description = "父主键")
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long parentId;
+
+ /**
+ * 祖级机构主键
+ */
+ @Schema(description = "祖级机构主键")
+ private String ancestors;
/**
* 部门名
*/
- @ApiModelProperty(value = "部门名")
+ @Schema(description = "部门名")
private String deptName;
/**
- * 部门全程
+ * 部门全称
*/
- @ApiModelProperty(value = "部门全程")
+ @Schema(description = "部门全称")
private String fullName;
/**
* 排序
*/
- @ApiModelProperty(value = "排序")
+ @Schema(description = "排序")
private Integer sort;
/**
* 备注
*/
- @ApiModelProperty(value = "备注")
+ @Schema(description = "备注")
private String remark;
/**
* 是否已删除
*/
@TableLogic
- @ApiModelProperty(value = "是否已删除")
+ @Schema(description = "是否已删除")
private Integer isDeleted;
diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/Menu.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/Menu.java
index 1c364da43d92f1183970b88f922785282e9f7753..ec61d8895e2dd33850db3682a55e15f66b782fe7 100644
--- a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/Menu.java
+++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/Menu.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,104 +19,109 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springblade.core.tool.utils.Func;
+import java.io.Serial;
import java.io.Serializable;
+import java.util.Objects;
/**
* 实体类
*
* @author Chill
- * @since 2018-12-24
*/
@Data
@TableName("blade_menu")
-@ApiModel(value = "Menu对象", description = "Menu对象")
+@Schema(description = "Menu对象")
public class Menu implements Serializable {
+ @Serial
private static final long serialVersionUID = 1L;
/**
* 主键
*/
- @ApiModelProperty(value = "主键")
- @TableId(value = "id", type = IdType.AUTO)
- private Integer id;
+ @Schema(description = "主键")
+ @TableId(value = "id", type = IdType.ASSIGN_ID)
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long id;
/**
* 菜单父主键
*/
- @ApiModelProperty(value = "菜单父主键")
- private Integer parentId;
+ @Schema(description = "父主键")
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long parentId;
/**
* 菜单编号
*/
- @ApiModelProperty(value = "菜单编号")
+ @Schema(description = "菜单编号")
private String code;
/**
* 菜单名称
*/
- @ApiModelProperty(value = "菜单名称")
+ @Schema(description = "菜单名称")
private String name;
/**
* 菜单别名
*/
- @ApiModelProperty(value = "菜单别名")
+ @Schema(description = "菜单别名")
private String alias;
/**
* 请求地址
*/
- @ApiModelProperty(value = "请求地址")
+ @Schema(description = "请求地址")
private String path;
/**
* 菜单资源
*/
- @ApiModelProperty(value = "菜单资源")
+ @Schema(description = "菜单资源")
private String source;
/**
* 排序
*/
- @ApiModelProperty(value = "排序")
+ @Schema(description = "排序")
private Integer sort;
/**
* 菜单类型
*/
- @ApiModelProperty(value = "菜单类型")
+ @Schema(description = "菜单类型")
private Integer category;
/**
* 操作按钮类型
*/
- @ApiModelProperty(value = "操作按钮类型")
+ @Schema(description = "操作按钮类型")
private Integer action;
/**
* 是否打开新页面
*/
- @ApiModelProperty(value = "是否打开新页面")
+ @Schema(description = "是否打开新页面")
private Integer isOpen;
/**
* 备注
*/
- @ApiModelProperty(value = "备注")
+ @Schema(description = "备注")
private String remark;
/**
* 是否已删除
*/
@TableLogic
- @ApiModelProperty(value = "是否已删除")
+ @Schema(description = "是否已删除")
private Integer isDeleted;
@@ -129,10 +134,12 @@ public class Menu implements Serializable {
return false;
}
Menu other = (Menu) obj;
- if (Func.equals(this.getId(), other.getId())) {
- return true;
- }
- return false;
+ return Func.equals(this.getId(), other.getId());
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id, parentId, code);
}
}
diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/Param.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/Param.java
index 15976b21bf2f54f39d6fbb5534e10c1179acb00a..59df84f177220e8e1a3c0ddb5230dce271526a99 100644
--- a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/Param.java
+++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/Param.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,49 +15,62 @@
*/
package org.springblade.system.entity;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.BaseEntity;
+import java.io.Serial;
+
/**
* 实体类
*
* @author Chill
- * @since 2018-12-28
*/
@Data
@TableName("blade_param")
@EqualsAndHashCode(callSuper = true)
-@ApiModel(value = "Param对象", description = "Param对象")
+@Schema(description = "Param对象")
public class Param extends BaseEntity {
+ @Serial
private static final long serialVersionUID = 1L;
+ /**
+ * 主键id
+ */
+ @Schema(description = "主键")
+ @TableId(value = "id", type = IdType.ASSIGN_ID)
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long id;
+
/**
* 参数名
*/
- @ApiModelProperty(value = "参数名")
+ @Schema(description = "参数名")
private String paramName;
/**
* 参数键
*/
- @ApiModelProperty(value = "参数键")
+ @Schema(description = "参数键")
private String paramKey;
/**
* 参数值
*/
- @ApiModelProperty(value = "参数值")
+ @Schema(description = "参数值")
private String paramValue;
/**
* 备注
*/
- @ApiModelProperty(value = "备注")
+ @Schema(description = "备注")
private String remark;
diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/Post.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/Post.java
new file mode 100644
index 0000000000000000000000000000000000000000..66dc2548d31adac8fe070e7cfd89f0cba1a91a81
--- /dev/null
+++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/Post.java
@@ -0,0 +1,79 @@
+/**
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package 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.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.core.mp.base.TenantEntity;
+
+import java.io.Serial;
+
+/**
+ * 岗位表实体类
+ *
+ * @author Chill
+ */
+@Data
+@TableName("blade_post")
+@EqualsAndHashCode(callSuper = true)
+@Schema(description = "Post对象")
+public class Post extends TenantEntity {
+
+ @Serial
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 主键id
+ */
+ @Schema(description = "主键")
+ @TableId(value = "id", type = IdType.ASSIGN_ID)
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long id;
+
+ /**
+ * 类型
+ */
+ @Schema(description = "类型")
+ private Integer category;
+ /**
+ * 岗位编号
+ */
+ @Schema(description = "岗位编号")
+ private String postCode;
+ /**
+ * 岗位名称
+ */
+ @Schema(description = "岗位名称")
+ private String postName;
+ /**
+ * 岗位排序
+ */
+ @Schema(description = "岗位排序")
+ private Integer sort;
+ /**
+ * 岗位描述
+ */
+ @Schema(description = "岗位描述")
+ 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..7e1e49b69ac8ab7019348a7f24b23fa7d3842b44
--- /dev/null
+++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/Region.java
@@ -0,0 +1,128 @@
+/**
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springblade.system.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * 行政区划表实体类
+ *
+ * @author Chill
+ */
+@Data
+@TableName("blade_region")
+@Schema(description = "Region对象")
+public class Region implements Serializable {
+
+ @Serial
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 区划编号
+ */
+ @TableId(value = "code", type = IdType.INPUT)
+ @Schema(description = "区划编号")
+ private String code;
+ /**
+ * 父区划编号
+ */
+ @Schema(description = "父区划编号")
+ private String parentCode;
+ /**
+ * 祖区划编号
+ */
+ @Schema(description = "祖区划编号")
+ private String ancestors;
+ /**
+ * 区划名称
+ */
+ @Schema(description = "区划名称")
+ private String name;
+ /**
+ * 省级区划编号
+ */
+ @Schema(description = "省级区划编号")
+ private String provinceCode;
+ /**
+ * 省级名称
+ */
+ @Schema(description = "省级名称")
+ private String provinceName;
+ /**
+ * 市级区划编号
+ */
+ @Schema(description = "市级区划编号")
+ private String cityCode;
+ /**
+ * 市级名称
+ */
+ @Schema(description = "市级名称")
+ private String cityName;
+ /**
+ * 区级区划编号
+ */
+ @Schema(description = "区级区划编号")
+ private String districtCode;
+ /**
+ * 区级名称
+ */
+ @Schema(description = "区级名称")
+ private String districtName;
+ /**
+ * 镇级区划编号
+ */
+ @Schema(description = "镇级区划编号")
+ private String townCode;
+ /**
+ * 镇级名称
+ */
+ @Schema(description = "镇级名称")
+ private String townName;
+ /**
+ * 村级区划编号
+ */
+ @Schema(description = "村级区划编号")
+ private String villageCode;
+ /**
+ * 村级名称
+ */
+ @Schema(description = "村级名称")
+ private String villageName;
+ /**
+ * 层级
+ */
+ @Schema(description = "层级")
+ private Integer level;
+ /**
+ * 排序
+ */
+ @Schema(description = "排序")
+ private Integer sort;
+ /**
+ * 备注
+ */
+ @Schema(description = "备注")
+ private String remark;
+
+
+}
diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/Role.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/Role.java
index 69a331467cb40d57507223fdb7c4fe6f210b56e6..642e45aac35483be0b17333129aaf086b942882a 100644
--- a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/Role.java
+++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/Role.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,61 +19,71 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
+import java.io.Serial;
import java.io.Serializable;
/**
* 实体类
*
* @author Chill
- * @since 2018-12-24
*/
@Data
@TableName("blade_role")
-@ApiModel(value = "Role对象", description = "Role对象")
+@Schema(description = "Role对象")
public class Role implements Serializable {
+ @Serial
private static final long serialVersionUID = 1L;
/**
* 主键
*/
- @ApiModelProperty(value = "主键")
- @TableId(value = "id", type = IdType.AUTO)
- private Integer id;
+ @Schema(description = "主键")
+ @TableId(value = "id", type = IdType.ASSIGN_ID)
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long id;
+
+ /**
+ * 租户ID
+ */
+ @Schema(description = "租户ID")
+ private String tenantId;
/**
* 父主键
*/
- @ApiModelProperty(value = "父主键")
- private Integer parentId;
+ @Schema(description = "父主键")
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long parentId;
/**
* 角色名
*/
- @ApiModelProperty(value = "角色名")
+ @Schema(description = "角色名")
private String roleName;
/**
* 排序
*/
- @ApiModelProperty(value = "排序")
+ @Schema(description = "排序")
private Integer sort;
/**
* 角色别名
*/
- @ApiModelProperty(value = "角色别名")
+ @Schema(description = "角色别名")
private String roleAlias;
/**
* 是否已删除
*/
@TableLogic
- @ApiModelProperty(value = "是否已删除")
+ @Schema(description = "是否已删除")
private Integer isDeleted;
diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/RoleMenu.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/RoleMenu.java
index d2281efdfa3be8473edb61da59ac008fc3cc941e..e7470cc25c8cd2c92965fa0dcc9f17e4700aa597 100644
--- a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/RoleMenu.java
+++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/RoleMenu.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,43 +18,48 @@ package org.springblade.system.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
+import java.io.Serial;
import java.io.Serializable;
/**
* 实体类
*
* @author Chill
- * @since 2018-12-24
*/
@Data
@TableName("blade_role_menu")
-@ApiModel(value = "RoleMenu对象", description = "RoleMenu对象")
+@Schema(description = "RoleMenu对象")
public class RoleMenu implements Serializable {
+ @Serial
private static final long serialVersionUID = 1L;
/**
* 主键
*/
- @ApiModelProperty(value = "主键")
- @TableId(value = "id", type = IdType.AUTO)
- private Integer id;
+ @Schema(description = "主键")
+ @TableId(value = "id", type = IdType.ASSIGN_ID)
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long id;
/**
* 菜单id
*/
- @ApiModelProperty(value = "菜单id")
- private Integer menuId;
+ @Schema(description = "菜单id")
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long menuId;
/**
* 角色id
*/
- @ApiModelProperty(value = "角色id")
- private Integer roleId;
+ @Schema(description = "角色id")
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long roleId;
}
diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/RoleScope.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/RoleScope.java
new file mode 100644
index 0000000000000000000000000000000000000000..50af1a54881562c13c4c8f845e2b2d09f09085a7
--- /dev/null
+++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/RoleScope.java
@@ -0,0 +1,65 @@
+/**
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package 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.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * 实体类
+ *
+ * @author Chill
+ */
+@Data
+@TableName("blade_role_scope")
+@Schema(description = "RoleScope对象")
+public class RoleScope implements Serializable {
+
+ @Serial
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 主键
+ */
+ @JsonSerialize(using = ToStringSerializer.class)
+ @Schema(description = "主键")
+ @TableId(value = "id", type = IdType.ASSIGN_ID)
+ private Long id;
+
+ /**
+ * 权限id
+ */
+ @JsonSerialize(using = ToStringSerializer.class)
+ @Schema(description = "权限id")
+ private Long scopeId;
+
+ /**
+ * 角色id
+ */
+ @JsonSerialize(using = ToStringSerializer.class)
+ @Schema(description = "角色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..6272bb55d7e3e613ba02366839d2dee7b864b056
--- /dev/null
+++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/Tenant.java
@@ -0,0 +1,84 @@
+/**
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package 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.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.core.mp.base.BaseEntity;
+
+import java.io.Serial;
+
+/**
+ * 实体类
+ *
+ * @author Chill
+ */
+@Data
+@TableName("blade_tenant")
+@EqualsAndHashCode(callSuper = true)
+@Schema(description = "Tenant对象")
+public class Tenant extends BaseEntity {
+
+ @Serial
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 主键id
+ */
+ @Schema(description = "主键")
+ @TableId(value = "id", type = IdType.ASSIGN_ID)
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long id;
+
+ /**
+ * 租户ID
+ */
+ @Schema(description = "租户ID")
+ private String tenantId;
+ /**
+ * 租户名称
+ */
+ @Schema(description = "租户名称")
+ private String tenantName;
+ /**
+ * 域名地址
+ */
+ @Schema(description = "域名地址")
+ private String domain;
+ /**
+ * 联系人
+ */
+ @Schema(description = "联系人")
+ private String linkman;
+ /**
+ * 联系电话
+ */
+ @Schema(description = "联系电话")
+ private String contactNumber;
+ /**
+ * 联系地址
+ */
+ @Schema(description = "联系地址")
+ 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..1bd27dac0e0f8a6b0c715601b5d78532ec9e023c
--- /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-2099, Chill Zhuang 庄骞 (bladejava@qq.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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springblade.system.feign;
+
+import org.springblade.core.launch.constant.AppConstant;
+import org.springblade.core.tool.api.R;
+import org.springblade.system.entity.Dept;
+import org.springblade.system.entity.Role;
+import org.springblade.system.entity.Tenant;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import java.util.List;
+
+/**
+ * Feign接口类
+ *
+ * @author Chill
+ */
+@FeignClient(
+ value = AppConstant.APPLICATION_SYSTEM_NAME,
+ fallback = ISysClientFallback.class
+)
+public interface ISysClient {
+
+ String API_PREFIX = "/sys";
+
+
+ /**
+ * 获取部门
+ *
+ * @param id 主键
+ * @return Dept
+ */
+ @GetMapping(API_PREFIX + "/getDept")
+ Dept getDept(@RequestParam("id") Long id);
+
+ /**
+ * 获取部门名
+ *
+ * @param id 主键
+ * @return 部门名
+ */
+ @GetMapping(API_PREFIX + "/getDeptName")
+ String getDeptName(@RequestParam("id") Long id);
+
+ /**
+ * 获取部门id
+ *
+ * @param tenantId 租户id
+ * @param deptNames 部门名
+ * @return 部门id
+ */
+ @GetMapping(API_PREFIX + "/getDeptIds")
+ String getDeptIds(@RequestParam("tenantId") String tenantId, @RequestParam("deptNames") String deptNames);
+
+ /**
+ * 获取部门名
+ *
+ * @param deptIds 主键
+ * @return
+ */
+ @GetMapping(API_PREFIX + "/getDeptNames")
+ List
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,47 +13,86 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+package org.springblade.system.feign;
-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 org.springblade.core.tool.api.R;
+import org.springblade.system.entity.Dept;
+import org.springblade.system.entity.Role;
+import org.springblade.system.entity.Tenant;
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.UiConfiguration;
-import springfox.documentation.swagger.web.UiConfigurationBuilder;
-import java.util.Optional;
+import java.util.List;
/**
- * SwaggerUiHandler
+ * Feign失败配置
*
- * @author lengleng
+ * @author Chill
*/
-@Slf4j
@Component
-public class SwaggerUiHandler implements HandlerFunction
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springblade.system.vo;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * CheckedTreeVO
+ *
+ * @author Chill
+ */
+@Data
+public class CheckedTreeVO {
+
+ private List
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,32 +13,29 @@
* 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.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
-#end
-#if($!{swagger2})
-import io.swagger.annotations.ApiModel;
-#end
+import org.springblade.system.entity.DataScope;
+
+import java.io.Serial;
/**
- * $!{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} {
+@Schema(description = "DataScopeVO对象")
+public class DataScopeVO extends DataScope {
+ @Serial
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..511d1900dbb3f9a3ffd517f08e13a8d1cf1af2a6 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
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,12 +16,15 @@
package org.springblade.system.vo;
import com.fasterxml.jackson.annotation.JsonInclude;
-import io.swagger.annotations.ApiModel;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.tool.node.INode;
import org.springblade.system.entity.Dept;
+import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
@@ -29,32 +32,34 @@ import java.util.List;
* 视图实体类
*
* @author Chill
- * @since 2018-12-24
*/
@Data
@EqualsAndHashCode(callSuper = true)
-@ApiModel(value = "DeptVO对象", description = "DeptVO对象")
-public class DeptVO extends Dept implements INode {
+@Schema(description = "DeptVO对象")
+public class DeptVO extends Dept implements INode
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springblade.system.vo;
+
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * GrantTreeVO
+ *
+ * @author Chill
+ */
+@Data
+public class GrantTreeVO implements Serializable {
+ @Serial
+ private static final long serialVersionUID = 1L;
+
+ private List
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springblade.system.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * GrantVO
+ *
+ * @author Chill
+ */
+@Data
+public class GrantVO implements Serializable {
+ @Serial
+ private static final long serialVersionUID = 1L;
+
+ @Schema(description = "roleIds集合")
+ private List
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,12 +16,15 @@
package org.springblade.system.vo;
import com.fasterxml.jackson.annotation.JsonInclude;
-import io.swagger.annotations.ApiModel;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.tool.node.INode;
import org.springblade.system.entity.Menu;
+import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
@@ -29,32 +32,40 @@ import java.util.List;
* 视图实体类
*
* @author Chill
- * @since 2018-12-24
*/
@Data
@EqualsAndHashCode(callSuper = true)
-@ApiModel(value = "MenuVO对象", description = "MenuVO对象")
-public class MenuVO extends Menu implements INode {
+@Schema(description = "MenuVO对象")
+public class MenuVO extends Menu implements INode
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,21 +15,23 @@
*/
package org.springblade.system.vo;
-import io.swagger.annotations.ApiModel;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.system.entity.Param;
+import java.io.Serial;
+
/**
* 视图实体类
*
* @author Chill
- * @since 2018-12-28
*/
@Data
@EqualsAndHashCode(callSuper = true)
-@ApiModel(value = "ParamVO对象", description = "ParamVO对象")
+@Schema(description = "ParamVO对象")
public class ParamVO extends Param {
+ @Serial
private static final long serialVersionUID = 1L;
}
diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/PostVO.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/PostVO.java
new file mode 100644
index 0000000000000000000000000000000000000000..55bcff67883cf7be47aa2c261994c8bfee17b194
--- /dev/null
+++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/PostVO.java
@@ -0,0 +1,42 @@
+/**
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springblade.system.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.system.entity.Post;
+
+import java.io.Serial;
+
+/**
+ * 岗位表视图实体类
+ *
+ * @author Chill
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@Schema(description = "PostVO对象")
+public class PostVO extends Post {
+ @Serial
+ 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..4ebcdba3211cbab69fe5b155d2b268859b973b63
--- /dev/null
+++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/RegionVO.java
@@ -0,0 +1,90 @@
+/**
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package 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.v3.oas.annotations.media.Schema;
+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.io.Serial;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 行政区划表视图实体类
+ *
+ * @author Chill
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@Schema(description = "RegionVO对象")
+public class RegionVO extends Region implements INode
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,21 +15,23 @@
*/
package org.springblade.system.vo;
-import io.swagger.annotations.ApiModel;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.system.entity.RoleMenu;
+import java.io.Serial;
+
/**
* 视图实体类
*
* @author Chill
- * @since 2018-12-24
*/
@Data
@EqualsAndHashCode(callSuper = true)
-@ApiModel(value = "RoleMenuVO对象", description = "RoleMenuVO对象")
+@Schema(description = "RoleMenuVO对象")
public class RoleMenuVO extends RoleMenu {
+ @Serial
private static final long serialVersionUID = 1L;
}
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..e5e9a073bd4721b4b415a927e5193dad29a9894d 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
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,12 +16,15 @@
package org.springblade.system.vo;
import com.fasterxml.jackson.annotation.JsonInclude;
-import io.swagger.annotations.ApiModel;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.tool.node.INode;
import org.springblade.system.entity.Role;
+import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
@@ -29,32 +32,34 @@ import java.util.List;
* 视图实体类
*
* @author Chill
- * @since 2018-12-24
*/
@Data
@EqualsAndHashCode(callSuper = true)
-@ApiModel(value = "RoleVO对象", description = "RoleVO对象")
-public class RoleVO extends Role implements INode {
+@Schema(description = "RoleVO对象")
+public class RoleVO extends Role implements INode
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,18 @@
*/
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.v3.oas.annotations.media.Schema;
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.io.Serial;
+import java.util.Date;
/**
* 实体类
@@ -30,10 +36,24 @@ import java.time.LocalDateTime;
@Data
@TableName("blade_user")
@EqualsAndHashCode(callSuper = true)
-public class User extends BaseEntity {
+public class User extends TenantEntity {
+ @Serial
private static final long serialVersionUID = 1L;
+ /**
+ * 主键id
+ */
+ @Schema(description = "主键")
+ @TableId(value = "id", type = IdType.ASSIGN_ID)
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long id;
+
+
+ /**
+ * 编号
+ */
+ private String code;
/**
* 账号
*/
@@ -50,6 +70,10 @@ public class User extends BaseEntity {
* 真名
*/
private String realName;
+ /**
+ * 头像
+ */
+ private String avatar;
/**
* 邮箱
*/
@@ -61,7 +85,7 @@ public class User extends BaseEntity {
/**
* 生日
*/
- private LocalDateTime birthday;
+ private Date birthday;
/**
* 性别
*/
@@ -74,6 +98,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..5290b21af211571e285fa12d6fb3384b590a97ad 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
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,10 +15,10 @@
*/
package org.springblade.system.user.entity;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
+import java.io.Serial;
import java.io.Serializable;
import java.util.List;
@@ -28,27 +28,34 @@ import java.util.List;
* @author Chill
*/
@Data
-@ApiModel(description = "用户信息")
+@Schema(description = "用户信息")
public class UserInfo implements Serializable {
+ @Serial
private static final long serialVersionUID = 1L;
/**
* 用户基础信息
*/
- @ApiModelProperty(value = "用户")
+ @Schema(description = "用户")
private User user;
/**
* 权限标识集合
*/
- @ApiModelProperty(value = "权限集合")
+ @Schema(description = "权限集合")
private List
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package 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.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * 实体类
+ *
+ * @author Chill
+ */
+@Data
+@TableName("blade_user_oauth")
+public class UserOauth implements Serializable {
+
+ @Serial
+ private static final long serialVersionUID = 1L;
+
+
+ /**
+ * 主键
+ */
+ @JsonSerialize(using = ToStringSerializer.class)
+ @Schema(description = "主键")
+ @TableId(value = "id", type = IdType.ASSIGN_ID)
+ private Long id;
+
+ /**
+ * 租户ID
+ */
+ private String tenantId;
+
+ /**
+ * 第三方系统用户ID
+ */
+ private String uuid;
+
+ /**
+ * 用户ID
+ */
+ @JsonSerialize(using = ToStringSerializer.class)
+ @Schema(description = "用户主键")
+ private Long userId;
+
+ /**
+ * 用户名
+ */
+ private String username;
+ /**
+ * 用户昵称
+ */
+ private String nickname;
+ /**
+ * 用户头像
+ */
+ private String avatar;
+ /**
+ * 用户网址
+ */
+ private String blog;
+ /**
+ * 所在公司
+ */
+ private String company;
+ /**
+ * 位置
+ */
+ private String location;
+ /**
+ * 用户邮箱
+ */
+ private String email;
+ /**
+ * 用户备注(各平台中的用户个人介绍)
+ */
+ private String remark;
+ /**
+ * 性别
+ */
+ private String gender;
+ /**
+ * 用户来源
+ */
+ private String source;
+
+
+}
diff --git a/blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/feign/IUserClient.java b/blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/feign/IUserClient.java
index abf790876276047401babd15b912cc5353611a16..f85e1ed1861d6746f8e5e8859c3468bf82dd4a60 100644
--- a/blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/feign/IUserClient.java
+++ b/blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/feign/IUserClient.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,17 +18,23 @@ package org.springblade.system.user.feign;
import org.springblade.core.launch.constant.AppConstant;
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.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
/**
* User Feign接口类
+ *
* @author Chill
*/
@FeignClient(
- value = AppConstant.APPLICATION_USER_NAME
+ value = AppConstant.APPLICATION_SYSTEM_NAME,
+ fallback = IUserClientFallback.class
)
public interface IUserClient {
@@ -37,11 +43,39 @@ public interface IUserClient {
/**
* 获取用户信息
*
- * @param account 账号
- * @param password 密码
+ * @param userId 用户id
* @return
*/
- @GetMapping(API_PREFIX + "/userInfo")
- R
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package 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
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,51 +15,32 @@
*/
package org.springblade.system.user.vo;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import io.swagger.annotations.ApiModel;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.v3.oas.annotations.media.Schema;
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;
+import java.io.Serial;
/**
* 视图实体类
*
* @author Chill
- * @since 2018-12-24
*/
@Data
@EqualsAndHashCode(callSuper = true)
-@ApiModel(value = "UserVO对象", description = "UserVO对象")
-public class UserVO extends User implements INode {
+@Schema(description = "UserVO对象")
+public class UserVO extends User {
+ @Serial
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
- private Integer id;
-
- /**
- * 父节点ID
- */
- private Integer parentId;
-
- /**
- * 子孙节点
- */
- @JsonInclude(JsonInclude.Include.NON_EMPTY)
- private List
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,23 +13,22 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springblade.system.config;
+package com.example.demo;
-import org.springblade.system.feign.IDictClientFallback;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
+import org.springblade.core.cloud.client.BladeCloudApplication;
+import org.springblade.core.launch.BladeApplication;
/**
- * 字典feign失败配置
+ * Demo启动器
*
* @author Chill
*/
-@Configuration
-public class DictFeignConfiguration {
+@BladeCloudApplication
+public class DemoApplication {
- @Bean
- public IDictClientFallback dictClientFallback() {
- return new IDictClientFallback();
+ 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..d54045c123cd43dcedaf2e73195b4a9db79d8eb3
--- /dev/null
+++ b/blade-service/blade-demo/src/main/java/com/example/demo/config/DemoConfiguration.java
@@ -0,0 +1,36 @@
+/**
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package 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..4e0eeeb4814f4fce789edb646b7214e5efa7a63e
--- /dev/null
+++ b/blade-service/blade-demo/src/main/java/com/example/demo/controller/DemoController.java
@@ -0,0 +1,57 @@
+/**
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.example.demo.controller;
+
+import com.example.demo.props.DemoProperties;
+import io.swagger.v3.oas.annotations.tags.Tag;
+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")
+@Tag(name = "配置接口", description = "即时刷新配置")
+public class DemoController {
+
+ @Value("${demo.name:1}")
+ 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..8375cc19f84f474355f293118fea0de79b681c03
--- /dev/null
+++ b/blade-service/blade-demo/src/main/java/com/example/demo/controller/DynamicController.java
@@ -0,0 +1,66 @@
+/**
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package 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.v3.oas.annotations.tags.Tag;
+import io.swagger.v3.oas.annotations.Operation;
+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")
+@Tag(name = "多数据源接口", description = "多数据源")
+public class DynamicController {
+
+ private IDynamicService dynamicService;
+
+ /**
+ * master列表
+ */
+ @GetMapping("/master-list")
+ @ApiOperationSupport(order = 1)
+ @Operation(summary = "master列表", description = "master列表")
+ public R
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,28 +13,27 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springblade.system.user.controller;
-
+package com.example.demo.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
+import com.example.demo.entity.Notice;
+import com.example.demo.service.INoticeService;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.Parameters;
+import io.swagger.v3.oas.annotations.enums.ParameterIn;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.tags.Tag;
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.DigestUtil;
import org.springblade.core.tool.utils.Func;
-import org.springblade.system.feign.IDictClient;
-import org.springblade.system.user.entity.User;
-import org.springblade.system.user.service.IUserService;
-import org.springblade.system.user.wrapper.UserWrapper;
import org.springframework.web.bind.annotation.*;
-import springfox.documentation.annotations.ApiIgnore;
-import javax.validation.Valid;
import java.util.Map;
/**
@@ -43,80 +42,77 @@ import java.util.Map;
* @author Chill
*/
@RestController
-@RequestMapping
+@RequestMapping("notice")
@AllArgsConstructor
-public class UserController {
-
- private IUserService userService;
+@Tag(name = "用户博客", description = "博客接口")
+public class NoticeController extends BladeController implements CacheNames {
- private IDictClient dictClient;
+ private INoticeService noticeService;
/**
- * 查询单条
+ * 详情
*/
- @ApiOperation(value = "查看详情", notes = "传入id", position = 1)
@GetMapping("/detail")
- public R
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,30 +13,34 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springblade.system.user.feign;
+package com.example.demo.feign;
+import com.example.demo.entity.Notice;
+import com.example.demo.mapper.NoticeMapper;
import lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R;
-import org.springblade.system.user.entity.UserInfo;
-import org.springblade.system.user.service.IUserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
+import io.swagger.v3.oas.annotations.Hidden;
+
+import java.util.List;
/**
- * 用户服务Feign实现类
+ * Notice Feign
*
* @author Chill
*/
+@Hidden
@RestController
@AllArgsConstructor
-public class UserClient implements IUserClient {
+public class NoticeClient implements INoticeClient {
- IUserService service;
+ private NoticeMapper mapper;
@Override
- @GetMapping(API_PREFIX + "/userInfo")
- public R
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package 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.datasource.dynamic.enabled", "true");
+ // 自定义命名空间
+ // 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..3f45a87ccf997162b5b43c49e7020457ebf5cd0e
--- /dev/null
+++ b/blade-service/blade-demo/src/main/java/com/example/demo/mapper/NoticeMapper.java
@@ -0,0 +1,46 @@
+/**
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package 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
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package 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
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package 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
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.example.demo.service.impl;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.example.demo.mapper.NoticeMapper;
+import com.example.demo.service.INoticeService;
+import org.springblade.core.mp.base.BaseServiceImpl;
+import com.example.demo.entity.Notice;
+import org.springframework.stereotype.Service;
+
+/**
+ * 服务实现类
+ *
+ * @author Chill
+ */
+@Service
+public class NoticeServiceImpl extends BaseServiceImpl
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,18 +15,16 @@
*/
package org.springblade.desk;
+import org.springblade.core.cloud.client.BladeCloudApplication;
import org.springblade.core.launch.BladeApplication;
import org.springblade.core.launch.constant.AppConstant;
-import org.springframework.cloud.client.SpringCloudApplication;
-import org.springframework.cloud.openfeign.EnableFeignClients;
/**
* Desk启动器
*
* @author Chill
*/
-@SpringCloudApplication
-@EnableFeignClients(AppConstant.BASE_PACKAGES)
+@BladeCloudApplication
public class DeskApplication {
public static void main(String[] args) {
diff --git a/blade-service/blade-desk/src/main/java/org/springblade/desk/controller/DashBoardController.java b/blade-service/blade-desk/src/main/java/org/springblade/desk/controller/DashBoardController.java
index cac1455e58ce9fbc5db91da6e02a6fccb2eb2083..988d8e9d2957e44a1ae6b03c47f21fe7c7ddb2f9 100644
--- a/blade-service/blade-desk/src/main/java/org/springblade/desk/controller/DashBoardController.java
+++ b/blade-service/blade-desk/src/main/java/org/springblade/desk/controller/DashBoardController.java
@@ -1,7 +1,7 @@
package org.springblade.desk.controller;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import io.swagger.v3.oas.annotations.Operation;
import lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.support.Kv;
@@ -22,7 +22,7 @@ import java.util.Map;
@RestController
@RequestMapping("dashboard")
@AllArgsConstructor
-@Api(value = "首页", tags = "首页")
+@Tag(name = "首页", description = "首页")
public class DashBoardController {
/**
@@ -31,7 +31,7 @@ public class DashBoardController {
* @return
*/
@GetMapping("/activities")
- @ApiOperation(value = "活跃用户", notes = "活跃用户", position = 1)
+ @Operation(summary = "活跃用户", description = "活跃用户")
public R activities() {
List> 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/JwtConfiguration.java b/blade-gateway/src/main/java/org/springblade/gateway/config/JwtConfiguration.java
new file mode 100644
index 0000000000000000000000000000000000000000..45b3526277f707f50f4f805b793f3c46d847a4d3
--- /dev/null
+++ b/blade-gateway/src/main/java/org/springblade/gateway/config/JwtConfiguration.java
@@ -0,0 +1,44 @@
+/**
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
+ *
detail(Code code) {
Code detail = codeService.getOne(Condition.getQueryWrapper(code));
return R.data(detail);
@@ -61,13 +74,14 @@ public class CodeController extends BladeController {
* 分页
*/
@GetMapping("/list")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "codeName", value = "模块名", paramType = "query", dataType = "string"),
- @ApiImplicitParam(name = "tableName", value = "表名", paramType = "query", dataType = "string"),
- @ApiImplicitParam(name = "modelName", value = "实体名", paramType = "query", dataType = "string")
+ @Parameters({
+ @Parameter(name = "codeName", description = "模块名", in = ParameterIn.QUERY, schema = @Schema(type = "string")),
+ @Parameter(name = "tableName", description = "表名", in = ParameterIn.QUERY, schema = @Schema(type = "string")),
+ @Parameter(name = "modelName", description = "实体名", in = ParameterIn.QUERY, schema = @Schema(type = "string"))
})
- @ApiOperation(value = "分页", notes = "传入code", position = 2)
- public R
pages = codeService.page(Condition.getPage(query), Condition.getQueryWrapper(code, Code.class));
return R.data(pages);
}
@@ -76,9 +90,10 @@ public class CodeController extends BladeController {
* 新增或修改
*/
@PostMapping("/submit")
- @ApiOperation(value = "新增或修改", notes = "传入code", position = 6)
+ @ApiOperationSupport(order = 3)
+ @Operation(summary = "新增或修改", description = "传入code")
public R submit(@Valid @RequestBody Code code) {
- return R.status(codeService.saveOrUpdate(code));
+ return R.status(codeService.submit(code));
}
@@ -86,20 +101,43 @@ public class CodeController extends BladeController {
* 删除
*/
@PostMapping("/remove")
- @ApiOperation(value = "物理删除", notes = "传入ids", position = 7)
- public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
- return R.status(codeService.removeByIds(Func.toIntList(ids)));
+ @ApiOperationSupport(order = 4)
+ @Operation(summary = "删除", description = "传入ids")
+ public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
+ return R.status(codeService.removeByIds(Func.toLongList(ids)));
+ }
+
+ /**
+ * 复制
+ */
+ @PostMapping("/copy")
+ @ApiOperationSupport(order = 5)
+ @Operation(summary = "复制", description = "传入id")
+ public R copy(@Parameter(description = "主键", required = true) @RequestParam Long id) {
+ Code code = codeService.getById(id);
+ code.setId(null);
+ code.setCodeName(code.getCodeName() + "-copy");
+ return R.status(codeService.save(code));
}
/**
* 代码生成
*/
@PostMapping("/gen-code")
- @ApiOperation(value = "代码生成", notes = "传入ids", position = 8)
- public R genCode(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
- Collection
codes = codeService.listByIds(Func.toIntList(ids));
+ @ApiOperationSupport(order = 6)
+ @Operation(summary = "代码生成", description = "传入ids")
+ public R genCode(@Parameter(description = "主键集合", required = true) @RequestParam String ids, @RequestParam(defaultValue = "saber3") String system) {
+ Collection
codes = codeService.listByIds(Func.toLongList(ids));
codes.forEach(code -> {
- BladeGenerator generator = new BladeGenerator();
+ BladeCodeGenerator generator = new BladeCodeGenerator();
+ // 设置数据源
+ Datasource datasource = datasourceService.getById(code.getDatasourceId());
+ generator.setDriverName(datasource.getDriverClass());
+ generator.setUrl(datasource.getUrl());
+ generator.setUsername(datasource.getUsername());
+ generator.setPassword(datasource.getPassword());
+ // 设置基础配置
+ generator.setSystemName(system);
generator.setServiceName(code.getServiceName());
generator.setPackageName(code.getPackageName());
generator.setPackageDir(code.getApiPath());
@@ -107,7 +145,9 @@ public class CodeController extends BladeController {
generator.setTablePrefix(Func.toStrArray(code.getTablePrefix()));
generator.setIncludeTables(Func.toStrArray(code.getTableName()));
// 设置是否继承基础业务字段
- generator.setHasSuperEntity(false);
+ generator.setHasSuperEntity(code.getBaseMode() == 2);
+ // 设置是否开启包装器模式
+ generator.setHasWrapper(code.getWrapMode() == 2);
generator.run();
});
return R.success("代码生成成功");
diff --git a/blade-ops/blade-develop/src/main/java/org/springblade/develop/controller/DatasourceController.java b/blade-ops/blade-develop/src/main/java/org/springblade/develop/controller/DatasourceController.java
new file mode 100644
index 0000000000000000000000000000000000000000..4677ac66a70eff1caa00667a1550e3b77012ab82
--- /dev/null
+++ b/blade-ops/blade-develop/src/main/java/org/springblade/develop/controller/DatasourceController.java
@@ -0,0 +1,124 @@
+/**
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
+ *
> select() {
+ List
{
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 @@
{
+ /**
+ * 提交
+ *
+ * @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..0321b49d2ac9fc84928616ee97d36c865edaf52e
--- /dev/null
+++ b/blade-ops/blade-develop/src/main/java/org/springblade/develop/service/IDatasourceService.java
@@ -0,0 +1,28 @@
+/**
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
+ *
> top(@RequestParam("number") Integer number);
+
+}
diff --git a/blade-service-api/blade-demo-api/src/main/java/com/example/demo/vo/NoticeVO.java b/blade-service-api/blade-demo-api/src/main/java/com/example/demo/vo/NoticeVO.java
new file mode 100644
index 0000000000000000000000000000000000000000..f8a200e4d512b2da28f9ce56a71fff56c7ee7a2b
--- /dev/null
+++ b/blade-service-api/blade-demo-api/src/main/java/com/example/demo/vo/NoticeVO.java
@@ -0,0 +1,20 @@
+package com.example.demo.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import com.example.demo.entity.Notice;
+
+/**
+ * 通知公告视图类
+ *
+ * @author Chill
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class NoticeVO extends Notice {
+
+ @Schema(description = "通知类型名")
+ private String categoryName;
+
+}
diff --git a/blade-service-api/blade-desk-api/pom.xml b/blade-service-api/blade-desk-api/pom.xml
index 6c41bddcef0de9fa7c4e4238b60490b90d337752..f9e538e3710f889aa7f93abdc5213d23cabc5c8c 100644
--- a/blade-service-api/blade-desk-api/pom.xml
+++ b/blade-service-api/blade-desk-api/pom.xml
@@ -5,13 +5,12 @@
> masterList() {
+ List
> slaveList() {
+ List
> 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..8f2b0ea33d1af6bacb452c2db71ac7a16f1ab15c
--- /dev/null
+++ b/blade-service/blade-demo/src/main/java/com/example/demo/launcher/DemoLauncherServiceImpl.java
@@ -0,0 +1,49 @@
+/**
+ * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
+ *