diff --git a/LICENSE b/LICENSE
index ef4e4debf19abe5e0bb637f14115da5d1cd82de8..55336630441382e0aec517872f7ee356c33f6753 100644
--- a/LICENSE
+++ b/LICENSE
@@ -176,7 +176,7 @@ recommend that a file or class name and description of purpose be included on
the same "printed page" as the copyright notice for easier identification within
third-party archives.
- Copyright 2019 smallchill
+ Copyright 2020 BladeX (https://bladex.vip)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/README.md b/README.md
index b8a3edfb4f54ee6385dd86be8dccca6c7dee56d9..a7cacb34bfb85c91d46aae0f20ff9628bba5f4b0 100644
--- a/README.md
+++ b/README.md
@@ -1,31 +1,32 @@
-## 简介
-* SpringBlade 2.0 是如梦技术团队作品,是一个基于 Spring Boot 2 & Spring Cloud Finchley & Mybatis 等核心技术,用于快速构建中大型系统的基础框架。
-* SpringBlade 致力于创造新颖的开发模式,将开发中遇到的痛点、生产中所踩的坑整理归纳,并将解决方案都融合到框架中。
-
-## 官网
-官网地址:[https://bladex.vip](https://bladex.vip)
-
-## 在线演示
-演示地址:[https://sword.bladex.vip](https://sword.bladex.vip)
-
-## 主要特性&&变化
-* 采用前后端分离的模式,前端单独开源出一个框架:[Sword](https://gitee.com/smallc/Sword),主要选型技术为React、Ant Design、Umi、Dva
-* 后端采用SpringCloud全家桶,并同时对其基础组件做了高度的封装,单独开源出一个框架:[Blade-Tool](https://github.com/chillzhuang/blade-tool.git)
-* [Blade-Tool](https://github.com/chillzhuang/blade-tool.git)已推送至Maven中央库,直接引入即可,减少了工程的臃肿,也可更注重于业务开发
-* 集成Sentinel从流量控制、熔断降级、系统负载保护等多个维度保护服务的稳定性。
+
\ No newline at end of file
+
+
+## 关注我们
+
\ No newline at end of file
diff --git a/blade-auth/pom.xml b/blade-auth/pom.xml
index 1189c84bd691c14019051deecae94086a833d9bc..2bd3c4245f90e4594bf8a02e93ba0ca06ee11fcc 100644
--- a/blade-auth/pom.xml
+++ b/blade-auth/pom.xml
@@ -8,7 +8,7 @@
SpringBladeorg.springblade
- 2.0.0
+ 2.7.1blade-auth
@@ -48,6 +48,23 @@
blade-core-swagger${blade.tool.version}
+
+
+ com.github.whvcse
+ easy-captcha
+ ${captcha.version}
+
+
+
+ mysql
+ mysql-connector-java
+ runtime
+
+
+
@@ -72,6 +89,26 @@
true
+
+ org.apache.maven.plugins
+ maven-antrun-plugin
+
+
+ package
+
+ run
+
+
+
+
+
+
+
+
+
+
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..529264b37a0575bca4b3697d1be133d978b7baad 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
@@ -15,25 +15,30 @@
*/
package org.springblade.auth.controller;
+import com.wf.captcha.SpecCaptcha;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
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.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.RedisUtil;
+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;
/**
* 认证模块
@@ -45,49 +50,46 @@ import java.util.Map;
@Api(value = "用户授权认证", tags = "授权接口")
public class AuthController {
- IUserClient client;
+ private RedisUtil redisUtil;
- @ApiLog("登录用户验证")
@PostMapping("token")
- @ApiOperation(value = "获取认证token", notes = "传入账号:account,密码:password")
- public R token(@ApiParam(value = "账号", required = true) @RequestParam String account,
- @ApiParam(value = "密码", required = true) @RequestParam String password) {
+ @ApiOperation(value = "获取认证token", notes = "传入租户ID:tenantId,账号:account,密码:password")
+ public R token(@ApiParam(value = "授权类型", required = true) @RequestParam(defaultValue = "password", required = false) String grantType,
+ @ApiParam(value = "刷新令牌") @RequestParam(required = false) String refreshToken,
+ @ApiParam(value = "租户ID", required = true) @RequestParam(defaultValue = "000000", required = false) String tenantId,
+ @ApiParam(value = "账号") @RequestParam(required = false) String account,
+ @ApiParam(value = "密码") @RequestParam(required = false) String password) {
- if (Func.hasEmpty(account, password)) {
- return R.fail("接口调用不合法");
- }
+ String userType = Func.toStr(WebUtil.getRequest().getHeader(TokenUtil.USER_TYPE_HEADER_KEY), TokenUtil.DEFAULT_USER_TYPE);
- R res = client.userInfo(account, DigestUtil.encrypt(password));
+ TokenParameter tokenParameter = new TokenParameter();
+ tokenParameter.getArgs().set("tenantId", tenantId)
+ .set("account", account)
+ .set("password", password)
+ .set("grantType", grantType)
+ .set("refreshToken", refreshToken)
+ .set("userType", userType);
- User user = res.getData().getUser();
+ ITokenGranter granter = TokenGranterBuilder.getGranter(grantType);
+ UserInfo userInfo = granter.grant(tokenParameter);
- //验证用户
- if (user == null) {
- return R.fail("用户名或密码不正确");
+ if (userInfo == null || userInfo.getUser() == null || userInfo.getUser().getId() == null) {
+ return R.fail(TokenUtil.USER_NOT_FOUND);
}
- //设置jwt参数
- Map param = new HashMap<>(16);
- param.put(SecureUtil.USER_ID, Func.toStr(user.getId()));
- param.put(SecureUtil.ROLE_ID, user.getRoleId());
- param.put(SecureUtil.ACCOUNT, user.getAccount());
- param.put(SecureUtil.USER_NAME, user.getRealName());
- param.put(SecureUtil.ROLE_NAME, Func.join(res.getData().getRoles()));
-
- //拼装accessToken
- String accessToken = SecureUtil.createJWT(param, "audience", "issuser", true);
-
- //返回accessToken
- AuthInfo authInfo = new AuthInfo();
- authInfo.setAccount(user.getAccount());
- authInfo.setUserName(user.getRealName());
- authInfo.setAuthority(Func.join(res.getData().getRoles()));
- authInfo.setAccessToken(accessToken);
- authInfo.setTokenType(SecureUtil.BEARER);
- //设置token过期时间
- authInfo.setExpiresIn(SecureUtil.getExpire());
- return R.data(authInfo);
+ return R.data(TokenUtil.createAuthInfo(userInfo));
+ }
+ @GetMapping("/captcha")
+ @ApiOperation(value = "获取验证码")
+ public R captcha() {
+ SpecCaptcha specCaptcha = new SpecCaptcha(130, 48, 5);
+ String verCode = specCaptcha.text().toLowerCase();
+ String key = UUID.randomUUID().toString();
+ // 存入redis并设置过期时间为30分钟
+ redisUtil.set(CacheNames.CAPTCHA_KEY + key, verCode, 30L, TimeUnit.MINUTES);
+ // 将key和base64返回给前端
+ return R.data(Kv.init().set("key", key).set("image", specCaptcha.toBase64()));
}
}
diff --git a/blade-service-api/blade-dict-api/src/main/java/org/springblade/system/config/DictFeignConfiguration.java b/blade-auth/src/main/java/org/springblade/auth/enums/BladeUserEnum.java
similarity index 63%
rename from blade-service-api/blade-dict-api/src/main/java/org/springblade/system/config/DictFeignConfiguration.java
rename to blade-auth/src/main/java/org/springblade/auth/enums/BladeUserEnum.java
index 300c643167ca3c3375f717ec793ac2062ba01290..4d0d538a603b34875913f3dd9f92b1d0ea61e72f 100644
--- a/blade-service-api/blade-dict-api/src/main/java/org/springblade/system/config/DictFeignConfiguration.java
+++ b/blade-auth/src/main/java/org/springblade/auth/enums/BladeUserEnum.java
@@ -13,23 +13,32 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springblade.system.config;
+package org.springblade.auth.enums;
-import org.springblade.system.feign.IDictClientFallback;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
/**
- * 字典feign失败配置
+ * 用户类型枚举
*
* @author Chill
*/
-@Configuration
-public class DictFeignConfiguration {
+@Getter
+@AllArgsConstructor
+public enum BladeUserEnum {
- @Bean
- public IDictClientFallback dictClientFallback() {
- return new IDictClientFallback();
- }
+ /**
+ * web
+ */
+ WEB("web", 1),
+
+ /**
+ * app
+ */
+ APP("app", 2),
+ ;
+
+ final String name;
+ final int category;
}
diff --git a/blade-auth/src/main/java/org/springblade/auth/granter/CaptchaTokenGranter.java b/blade-auth/src/main/java/org/springblade/auth/granter/CaptchaTokenGranter.java
new file mode 100644
index 0000000000000000000000000000000000000000..e07591019a19b7781262442bf66e0b5dc8e3889e
--- /dev/null
+++ b/blade-auth/src/main/java/org/springblade/auth/granter/CaptchaTokenGranter.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the dreamlu.net developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.auth.granter;
+
+import lombok.AllArgsConstructor;
+import org.springblade.auth.enums.BladeUserEnum;
+import org.springblade.auth.utils.TokenUtil;
+import org.springblade.common.cache.CacheNames;
+import org.springblade.core.log.exception.ServiceException;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.*;
+import org.springblade.system.user.entity.UserInfo;
+import org.springblade.system.user.feign.IUserClient;
+import org.springframework.stereotype.Component;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * 验证码TokenGranter
+ *
+ * @author Chill
+ */
+@Component
+@AllArgsConstructor
+public class CaptchaTokenGranter implements ITokenGranter {
+
+ public static final String GRANT_TYPE = "captcha";
+
+ private IUserClient userClient;
+ private RedisUtil redisUtil;
+
+ @Override
+ public UserInfo grant(TokenParameter tokenParameter) {
+ HttpServletRequest request = WebUtil.getRequest();
+
+ String key = request.getHeader(TokenUtil.CAPTCHA_HEADER_KEY);
+ String code = request.getHeader(TokenUtil.CAPTCHA_HEADER_CODE);
+ // 获取验证码
+ String redisCode = String.valueOf(redisUtil.get(CacheNames.CAPTCHA_KEY + key));
+ // 判断验证码
+ if (code == null || !StringUtil.equalsIgnoreCase(redisCode, code)) {
+ throw new ServiceException(TokenUtil.CAPTCHA_NOT_CORRECT);
+ }
+
+ String tenantId = tokenParameter.getArgs().getStr("tenantId");
+ String account = tokenParameter.getArgs().getStr("account");
+ String password = tokenParameter.getArgs().getStr("password");
+ UserInfo userInfo = null;
+ if (Func.isNoneBlank(account, password)) {
+ // 获取用户类型
+ String userType = tokenParameter.getArgs().getStr("userType");
+ R result;
+ // 根据不同用户类型调用对应的接口返回数据,用户可自行拓展
+ if (userType.equals(BladeUserEnum.WEB.getName())) {
+ result = userClient.userInfo(tenantId, account, DigestUtil.encrypt(password));
+ } else if (userType.equals(BladeUserEnum.APP.getName())) {
+ result = userClient.userInfo(tenantId, account, DigestUtil.encrypt(password));
+ } else {
+ result = userClient.userInfo(tenantId, account, DigestUtil.encrypt(password));
+ }
+ userInfo = result.isSuccess() ? result.getData() : null;
+ }
+ return userInfo;
+ }
+
+}
diff --git a/blade-auth/src/main/java/org/springblade/auth/granter/ITokenGranter.java b/blade-auth/src/main/java/org/springblade/auth/granter/ITokenGranter.java
new file mode 100644
index 0000000000000000000000000000000000000000..b2ec7318087a646d52673b4ba58d2d51793722e9
--- /dev/null
+++ b/blade-auth/src/main/java/org/springblade/auth/granter/ITokenGranter.java
@@ -0,0 +1,36 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springblade.auth.granter;
+
+
+import org.springblade.system.user.entity.UserInfo;
+
+/**
+ * 授权认证统一接口.
+ *
+ * @author Chill
+ */
+public interface ITokenGranter {
+
+ /**
+ * 获取用户信息
+ *
+ * @param tokenParameter 授权参数
+ * @return UserInfo
+ */
+ UserInfo grant(TokenParameter tokenParameter);
+
+}
diff --git a/blade-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..9572a6a56512f0215c8fdeae5b9da0009979f16a
--- /dev/null
+++ b/blade-auth/src/main/java/org/springblade/auth/granter/PasswordTokenGranter.java
@@ -0,0 +1,63 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springblade.auth.granter;
+
+import lombok.AllArgsConstructor;
+import org.springblade.auth.enums.BladeUserEnum;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.DigestUtil;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.system.user.entity.UserInfo;
+import org.springblade.system.user.feign.IUserClient;
+import org.springframework.stereotype.Component;
+
+/**
+ * PasswordTokenGranter
+ *
+ * @author Chill
+ */
+@Component
+@AllArgsConstructor
+public class PasswordTokenGranter implements ITokenGranter {
+
+ public static final String GRANT_TYPE = "password";
+
+ private IUserClient userClient;
+
+ @Override
+ public UserInfo grant(TokenParameter tokenParameter) {
+ String tenantId = tokenParameter.getArgs().getStr("tenantId");
+ String account = tokenParameter.getArgs().getStr("account");
+ String password = tokenParameter.getArgs().getStr("password");
+ UserInfo userInfo = null;
+ if (Func.isNoneBlank(account, password)) {
+ // 获取用户类型
+ String userType = tokenParameter.getArgs().getStr("userType");
+ R result;
+ // 根据不同用户类型调用对应的接口返回数据,用户可自行拓展
+ if (userType.equals(BladeUserEnum.WEB.getName())) {
+ result = userClient.userInfo(tenantId, account, DigestUtil.encrypt(password));
+ } else if (userType.equals(BladeUserEnum.APP.getName())) {
+ result = userClient.userInfo(tenantId, account, DigestUtil.encrypt(password));
+ } else {
+ result = userClient.userInfo(tenantId, account, DigestUtil.encrypt(password));
+ }
+ userInfo = result.isSuccess() ? result.getData() : null;
+ }
+ return userInfo;
+ }
+
+}
diff --git a/blade-auth/src/main/java/org/springblade/auth/granter/RefreshTokenGranter.java b/blade-auth/src/main/java/org/springblade/auth/granter/RefreshTokenGranter.java
new file mode 100644
index 0000000000000000000000000000000000000000..95fd95fe17727341e3328be1dad4c477bd870b9c
--- /dev/null
+++ b/blade-auth/src/main/java/org/springblade/auth/granter/RefreshTokenGranter.java
@@ -0,0 +1,58 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springblade.auth.granter;
+
+import io.jsonwebtoken.Claims;
+import lombok.AllArgsConstructor;
+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 java.util.Objects;
+
+/**
+ * RefreshTokenGranter
+ *
+ * @author Chill
+ */
+@Component
+@AllArgsConstructor
+public class RefreshTokenGranter implements ITokenGranter {
+
+ public static final String GRANT_TYPE = "refresh_token";
+
+ private IUserClient userClient;
+
+ @Override
+ public UserInfo grant(TokenParameter tokenParameter) {
+ String grantType = tokenParameter.getArgs().getStr("grantType");
+ String refreshToken = tokenParameter.getArgs().getStr("refreshToken");
+ UserInfo userInfo = null;
+ if (Func.isNoneBlank(grantType, refreshToken) && grantType.equals(TokenConstant.REFRESH_TOKEN)) {
+ Claims claims = SecureUtil.parseJWT(refreshToken);
+ String tokenType = Func.toStr(Objects.requireNonNull(claims).get(TokenConstant.TOKEN_TYPE));
+ if (tokenType.equals(TokenConstant.REFRESH_TOKEN)) {
+ R result = userClient.userInfo(Func.toLong(claims.get(TokenConstant.USER_ID)));
+ userInfo = result.isSuccess() ? result.getData() : null;
+ }
+ }
+ return userInfo;
+ }
+}
diff --git a/blade-auth/src/main/java/org/springblade/auth/granter/TokenGranterBuilder.java b/blade-auth/src/main/java/org/springblade/auth/granter/TokenGranterBuilder.java
new file mode 100644
index 0000000000000000000000000000000000000000..1b035a145a1ca9e4cd10679f0c0ff15caf429d74
--- /dev/null
+++ b/blade-auth/src/main/java/org/springblade/auth/granter/TokenGranterBuilder.java
@@ -0,0 +1,60 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springblade.auth.granter;
+
+import lombok.AllArgsConstructor;
+import org.springblade.core.secure.exception.SecureException;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.core.tool.utils.SpringUtil;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * TokenGranterBuilder
+ *
+ * @author Chill
+ */
+@AllArgsConstructor
+public class TokenGranterBuilder {
+
+ /**
+ * TokenGranter缓存池
+ */
+ private static Map granterPool = new ConcurrentHashMap<>();
+
+ static {
+ granterPool.put(PasswordTokenGranter.GRANT_TYPE, SpringUtil.getBean(PasswordTokenGranter.class));
+ granterPool.put(CaptchaTokenGranter.GRANT_TYPE, SpringUtil.getBean(CaptchaTokenGranter.class));
+ granterPool.put(RefreshTokenGranter.GRANT_TYPE, SpringUtil.getBean(RefreshTokenGranter.class));
+ }
+
+ /**
+ * 获取TokenGranter
+ *
+ * @param grantType 授权类型
+ * @return ITokenGranter
+ */
+ public static ITokenGranter getGranter(String grantType) {
+ ITokenGranter tokenGranter = granterPool.get(Func.toStr(grantType, PasswordTokenGranter.GRANT_TYPE));
+ if (tokenGranter == null) {
+ throw new SecureException("no grantType was found");
+ } else {
+ return tokenGranter;
+ }
+ }
+
+}
diff --git a/blade-auth/src/main/java/org/springblade/auth/granter/TokenParameter.java b/blade-auth/src/main/java/org/springblade/auth/granter/TokenParameter.java
new file mode 100644
index 0000000000000000000000000000000000000000..368c83efbc1dcdd37e81ee94ff00f4fa5991f909
--- /dev/null
+++ b/blade-auth/src/main/java/org/springblade/auth/granter/TokenParameter.java
@@ -0,0 +1,31 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springblade.auth.granter;
+
+import lombok.Data;
+import org.springblade.core.tool.support.Kv;
+
+/**
+ * TokenParameter
+ *
+ * @author Chill
+ */
+@Data
+public class TokenParameter {
+
+ private Kv args = Kv.init();
+
+}
diff --git a/blade-auth/src/main/java/org/springblade/auth/utils/TokenUtil.java b/blade-auth/src/main/java/org/springblade/auth/utils/TokenUtil.java
new file mode 100644
index 0000000000000000000000000000000000000000..c3e1d641151f8f5b1c8462f8123dbc369796f87e
--- /dev/null
+++ b/blade-auth/src/main/java/org/springblade/auth/utils/TokenUtil.java
@@ -0,0 +1,95 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
- * 1. 对请求头中参数进行处理 from 参数进行清洗
- * 2. 重写StripPrefix = 1,支持全局
- *
- * @author lengleng
- */
-@Component
-public class RequestGlobalFilter 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} to indicate when request processing is complete
- */
- @Override
- public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) {
- // 1. 清洗请求头中from 参数
- ServerHttpRequest request = exchange.getRequest().mutate()
- .headers(httpHeaders -> httpHeaders.remove("X"))
- .build();
-
- // 2. 重写StripPrefix
- addOriginalRequestUrl(exchange, request.getURI());
- String rawPath = request.getURI().getRawPath();
- String newPath = "/" + Arrays.stream(StringUtils.tokenizeToStringArray(rawPath, "/"))
- .skip(1L).collect(Collectors.joining("/"));
- ServerHttpRequest newRequest = request.mutate()
- .path(newPath)
- .build();
- exchange.getAttributes().put(GATEWAY_REQUEST_URL_ATTR, newRequest.getURI());
-
- return chain.filter(exchange.mutate().request(newRequest.mutate().build()).build());
- }
-
- @Override
- public int getOrder() {
- return -1000;
- }
-
-}
diff --git a/blade-gateway/src/main/java/org/springblade/gateway/handler/ErrorExceptionHandler.java b/blade-gateway/src/main/java/org/springblade/gateway/handler/ErrorExceptionHandler.java
index 0d933283190b6b5f3000361bb22e933d203c1c53..29afa0e4e7e4c1413d34187d949443ef954b8997 100644
--- a/blade-gateway/src/main/java/org/springblade/gateway/handler/ErrorExceptionHandler.java
+++ b/blade-gateway/src/main/java/org/springblade/gateway/handler/ErrorExceptionHandler.java
@@ -15,17 +15,16 @@
*/
package org.springblade.gateway.handler;
+import org.springblade.gateway.provider.ResponseProvider;
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 org.springframework.web.server.ResponseStatusException;
-import java.util.HashMap;
import java.util.Map;
/**
@@ -53,7 +52,7 @@ public class ErrorExceptionHandler extends DefaultErrorWebExceptionHandler {
if (error instanceof ResponseStatusException) {
code = ((ResponseStatusException) error).getStatus().value();
}
- return response(code, this.buildMessage(request, error));
+ return ResponseProvider.response(code, this.buildMessage(request, error));
}
/**
@@ -70,11 +69,11 @@ public class ErrorExceptionHandler extends DefaultErrorWebExceptionHandler {
* 根据code获取对应的HttpStatus
*
* @param errorAttributes
+ * @return
*/
@Override
- protected HttpStatus getHttpStatus(Map errorAttributes) {
- int statusCode = (int) errorAttributes.get("code");
- return HttpStatus.valueOf(statusCode);
+ protected int getHttpStatus(Map errorAttributes) {
+ return (int) errorAttributes.get("code");
}
/**
@@ -97,19 +96,4 @@ public class ErrorExceptionHandler extends DefaultErrorWebExceptionHandler {
return message.toString();
}
- /**
- * 构建返回的JSON数据格式
- *
- * @param status 状态码
- * @param errorMessage 异常信息
- * @return
- */
- public static Map response(int status, String errorMessage) {
- Map map = new HashMap<>(16);
- map.put("code", status);
- map.put("message", errorMessage);
- map.put("data", null);
- return map;
- }
-
}
diff --git a/blade-gateway/src/main/java/org/springblade/gateway/handler/SwaggerResourceHandler.java b/blade-gateway/src/main/java/org/springblade/gateway/handler/SwaggerResourceHandler.java
index c1c5e29277b9a7e068395888db094df9a74032a6..2885b31fc2e604cbee4593f13f6c68eba7d5d1db 100644
--- a/blade-gateway/src/main/java/org/springblade/gateway/handler/SwaggerResourceHandler.java
+++ b/blade-gateway/src/main/java/org/springblade/gateway/handler/SwaggerResourceHandler.java
@@ -16,7 +16,7 @@
package org.springblade.gateway.handler;
-import lombok.AllArgsConstructor;
+import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
@@ -35,7 +35,7 @@ import springfox.documentation.swagger.web.SwaggerResourcesProvider;
*/
@Slf4j
@Component
-@AllArgsConstructor
+@RequiredArgsConstructor
public class SwaggerResourceHandler implements HandlerFunction {
private final SwaggerResourcesProvider swaggerResources;
@@ -48,7 +48,7 @@ public class SwaggerResourceHandler implements HandlerFunction {
@Override
public Mono handle(ServerRequest request) {
return ServerResponse.status(HttpStatus.OK)
- .contentType(MediaType.APPLICATION_JSON_UTF8)
- .body(BodyInserters.fromObject(swaggerResources.get()));
+ .contentType(MediaType.APPLICATION_JSON)
+ .body(BodyInserters.fromValue(swaggerResources.get()));
}
}
diff --git a/blade-gateway/src/main/java/org/springblade/gateway/handler/SwaggerSecurityHandler.java b/blade-gateway/src/main/java/org/springblade/gateway/handler/SwaggerSecurityHandler.java
index 59a3039f614166583cd486545c3f8bb57888f802..d30f477f680a51cf68bb8cc769d8db3c2db5e3b0 100644
--- a/blade-gateway/src/main/java/org/springblade/gateway/handler/SwaggerSecurityHandler.java
+++ b/blade-gateway/src/main/java/org/springblade/gateway/handler/SwaggerSecurityHandler.java
@@ -17,7 +17,6 @@
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;
@@ -26,11 +25,8 @@ 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
*
@@ -39,8 +35,6 @@ import java.util.Optional;
@Slf4j
@Component
public class SwaggerSecurityHandler implements HandlerFunction {
- @Autowired(required = false)
- private SecurityConfiguration securityConfiguration;
/**
* Handle the given request.
@@ -51,9 +45,7 @@ public class SwaggerSecurityHandler implements HandlerFunction {
@Override
public Mono handle(ServerRequest request) {
return ServerResponse.status(HttpStatus.OK)
- .contentType(MediaType.APPLICATION_JSON_UTF8)
- .body(BodyInserters.fromObject(
- Optional.ofNullable(securityConfiguration)
- .orElse(SecurityConfigurationBuilder.builder().build())));
+ .contentType(MediaType.APPLICATION_JSON)
+ .body(BodyInserters.fromValue(SecurityConfigurationBuilder.builder().build()));
}
}
diff --git a/blade-gateway/src/main/java/org/springblade/gateway/handler/SwaggerUiHandler.java b/blade-gateway/src/main/java/org/springblade/gateway/handler/SwaggerUiHandler.java
index 0923b3ac4e1aeeba49190f855ad1920021e431c4..8bb78af1f2885d1fb19ad0a795365a71792298f3 100644
--- a/blade-gateway/src/main/java/org/springblade/gateway/handler/SwaggerUiHandler.java
+++ b/blade-gateway/src/main/java/org/springblade/gateway/handler/SwaggerUiHandler.java
@@ -17,7 +17,6 @@
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;
@@ -26,11 +25,8 @@ 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;
-
/**
* SwaggerUiHandler
*
@@ -39,8 +35,6 @@ import java.util.Optional;
@Slf4j
@Component
public class SwaggerUiHandler implements HandlerFunction {
- @Autowired(required = false)
- private UiConfiguration uiConfiguration;
/**
* Handle the given request.
@@ -51,9 +45,7 @@ public class SwaggerUiHandler implements HandlerFunction {
@Override
public Mono handle(ServerRequest request) {
return ServerResponse.status(HttpStatus.OK)
- .contentType(MediaType.APPLICATION_JSON_UTF8)
- .body(BodyInserters.fromObject(
- Optional.ofNullable(uiConfiguration)
- .orElse(UiConfigurationBuilder.builder().build())));
+ .contentType(MediaType.APPLICATION_JSON)
+ .body(BodyInserters.fromValue(UiConfigurationBuilder.builder().build()));
}
}
diff --git a/blade-gateway/src/main/java/org/springblade/gateway/props/AuthProperties.java b/blade-gateway/src/main/java/org/springblade/gateway/props/AuthProperties.java
new file mode 100644
index 0000000000000000000000000000000000000000..efb8d54d4ac5876727710813d0d1edbd1b25bbfa
--- /dev/null
+++ b/blade-gateway/src/main/java/org/springblade/gateway/props/AuthProperties.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the dreamlu.net developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.gateway.props;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.cloud.context.config.annotation.RefreshScope;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 权限过滤
+ *
+ * @author Chill
+ */
+@Data
+@RefreshScope
+@ConfigurationProperties("blade.secure")
+public class AuthProperties {
+
+ /**
+ * 放行API集合
+ */
+ private final List skipUrl = new ArrayList<>();
+
+}
diff --git a/blade-gateway/src/main/java/org/springblade/gateway/props/RouteProperties.java b/blade-gateway/src/main/java/org/springblade/gateway/props/RouteProperties.java
new file mode 100644
index 0000000000000000000000000000000000000000..9b7aa5d63a2b1fcc9777b9f0d2594653e4c444c1
--- /dev/null
+++ b/blade-gateway/src/main/java/org/springblade/gateway/props/RouteProperties.java
@@ -0,0 +1,37 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package 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.document")
+public class RouteProperties {
+
+ private final List resources = new ArrayList<>();
+
+}
diff --git a/blade-gateway/src/main/java/org/springblade/gateway/props/RouteResource.java b/blade-gateway/src/main/java/org/springblade/gateway/props/RouteResource.java
new file mode 100644
index 0000000000000000000000000000000000000000..a279a4001ed2c474bc6210510608b8e3bd992910
--- /dev/null
+++ b/blade-gateway/src/main/java/org/springblade/gateway/props/RouteResource.java
@@ -0,0 +1,44 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springblade.gateway.props;
+
+import lombok.Data;
+import org.springblade.core.launch.constant.AppConstant;
+
+/**
+ * Swagger聚合文档属性
+ *
+ * @author Chill
+ */
+@Data
+public class RouteResource {
+
+ /**
+ * 文档名
+ */
+ private String name;
+
+ /**
+ * 文档所在服务地址
+ */
+ private String location;
+
+ /**
+ * 文档版本
+ */
+ private String version = AppConstant.APPLICATION_VERSION;
+
+}
diff --git a/blade-gateway/src/main/java/org/springblade/gateway/provider/AuthProvider.java b/blade-gateway/src/main/java/org/springblade/gateway/provider/AuthProvider.java
new file mode 100644
index 0000000000000000000000000000000000000000..4728ce670ac9f34d4511191666bd0221242a13be
--- /dev/null
+++ b/blade-gateway/src/main/java/org/springblade/gateway/provider/AuthProvider.java
@@ -0,0 +1,59 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springblade.gateway.provider;
+
+import org.springblade.core.launch.constant.TokenConstant;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 鉴权配置
+ *
+ * @author Chill
+ */
+public class AuthProvider {
+
+ public static String TARGET = "/**";
+ public static String REPLACEMENT = "";
+ public static String AUTH_KEY = TokenConstant.HEADER;
+ private static List defaultSkipUrl = new ArrayList<>();
+
+ static {
+ defaultSkipUrl.add("/example");
+ defaultSkipUrl.add("/token/**");
+ defaultSkipUrl.add("/captcha/**");
+ defaultSkipUrl.add("/actuator/health/**");
+ defaultSkipUrl.add("/v2/api-docs/**");
+ defaultSkipUrl.add("/v2/api-docs-ext/**");
+ defaultSkipUrl.add("/auth/**");
+ defaultSkipUrl.add("/log/**");
+ defaultSkipUrl.add("/menu/routes");
+ defaultSkipUrl.add("/menu/auth-routes");
+ defaultSkipUrl.add("/order/create/**");
+ defaultSkipUrl.add("/storage/deduct/**");
+ defaultSkipUrl.add("/error/**");
+ defaultSkipUrl.add("/assets/**");
+ }
+
+ /**
+ * 默认无需鉴权的API
+ */
+ public static List getDefaultSkipUrl() {
+ return defaultSkipUrl;
+ }
+
+}
diff --git a/blade-gateway/src/main/java/org/springblade/gateway/provider/ResponseProvider.java b/blade-gateway/src/main/java/org/springblade/gateway/provider/ResponseProvider.java
new file mode 100644
index 0000000000000000000000000000000000000000..cf4eb429c4a596e98fe5203b06419f857109f8ec
--- /dev/null
+++ b/blade-gateway/src/main/java/org/springblade/gateway/provider/ResponseProvider.java
@@ -0,0 +1,83 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springblade.gateway.provider;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 请求响应返回
+ *
+ * @author Chill
+ */
+public class ResponseProvider {
+
+ /**
+ * 成功
+ *
+ * @param message 信息
+ * @return
+ */
+ public static Map success(String message) {
+ return response(200, message);
+ }
+
+ /**
+ * 失败
+ *
+ * @param message 信息
+ * @return
+ */
+ public static Map fail(String message) {
+ return response(400, message);
+ }
+
+ /**
+ * 未授权
+ *
+ * @param message 信息
+ * @return
+ */
+ public static Map unAuth(String message) {
+ return response(401, message);
+ }
+
+ /**
+ * 服务器异常
+ *
+ * @param message 信息
+ * @return
+ */
+ public static Map error(String message) {
+ return response(500, message);
+ }
+
+ /**
+ * 构建返回的JSON数据格式
+ *
+ * @param status 状态码
+ * @param message 信息
+ * @return
+ */
+ public static Map response(int status, String message) {
+ Map map = new HashMap<>(16);
+ map.put("code", status);
+ map.put("message", message);
+ map.put("data", null);
+ return map;
+ }
+
+}
diff --git a/blade-gateway/src/main/java/org/springblade/gateway/provider/SwaggerProvider.java b/blade-gateway/src/main/java/org/springblade/gateway/provider/SwaggerProvider.java
index 052b5215eb62db98672e19523a3025b9942362e7..c316f3643bb527caaa062dc36343300e62082f1a 100644
--- a/blade-gateway/src/main/java/org/springblade/gateway/provider/SwaggerProvider.java
+++ b/blade-gateway/src/main/java/org/springblade/gateway/provider/SwaggerProvider.java
@@ -17,60 +17,42 @@
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.springblade.gateway.props.RouteProperties;
+import org.springblade.gateway.props.RouteResource;
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
+ * @author Chill
*/
@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 final String API_URI = "/v2/api-docs-ext";
- private static Map routeMap = new HashMap<>();
-
- static {
- routeMap.put(AppConstant.APPLICATION_AUTH_NAME, "授权模块");
- routeMap.put(AppConstant.APPLICATION_DESK_NAME, "工作台模块");
- routeMap.put(AppConstant.APPLICATION_SYSTEM_NAME, "系统模块");
- }
+ private RouteProperties routeProperties;
@Override
public List get() {
List resources = new ArrayList<>();
- List routes = new ArrayList<>();
- routeLocator.getRoutes().subscribe(route -> routes.add(route.getId()));
- gatewayProperties.getRoutes().stream().filter(routeDefinition -> routes.contains(routeDefinition.getId()))
- .forEach(routeDefinition -> routeDefinition.getPredicates().stream()
- .filter(predicateDefinition -> "Path".equalsIgnoreCase(predicateDefinition.getName()))
- .forEach(predicateDefinition -> resources.add(swaggerResource(routeDefinition.getId(),
- predicateDefinition.getArgs().get(NameUtils.GENERATED_NAME_PREFIX + "0")
- .replace("/**", API_URI)))));
+ List routeResources = routeProperties.getResources();
+ routeResources.forEach(routeResource -> resources.add(swaggerResource(routeResource)));
return resources;
}
- private SwaggerResource swaggerResource(String name, String location) {
+ private SwaggerResource swaggerResource(RouteResource routeResource) {
SwaggerResource swaggerResource = new SwaggerResource();
- swaggerResource.setName((routeMap.get(name) == null ? name : routeMap.get(name)));
- swaggerResource.setLocation(location);
- swaggerResource.setSwaggerVersion("2.0");
+ swaggerResource.setName(routeResource.getName());
+ swaggerResource.setLocation(routeResource.getLocation().concat(API_URI));
+ swaggerResource.setSwaggerVersion(routeResource.getVersion());
return swaggerResource;
}
diff --git a/blade-gateway/src/main/java/org/springblade/gateway/utils/JwtUtil.java b/blade-gateway/src/main/java/org/springblade/gateway/utils/JwtUtil.java
new file mode 100644
index 0000000000000000000000000000000000000000..79b3ad144d250123672ffbaff7cddd609ee476d5
--- /dev/null
+++ b/blade-gateway/src/main/java/org/springblade/gateway/utils/JwtUtil.java
@@ -0,0 +1,71 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springblade.develop.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.core.mp.base.BaseEntity;
+
+/**
+ * 数据源配置表实体类
+ *
+ * @author Chill
+ */
+@Data
+@TableName("blade_datasource")
+@EqualsAndHashCode(callSuper = true)
+@ApiModel(value = "Datasource对象", description = "数据源配置表")
+public class Datasource extends BaseEntity {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 主键
+ */
+ @ApiModelProperty(value = "主键")
+ @TableId(value = "id", type = IdType.ASSIGN_ID)
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long id;
+
+ /**
+ * 名称
+ */
+ @ApiModelProperty(value = "名称")
+ private String name;
+ /**
+ * 驱动类
+ */
+ @ApiModelProperty(value = "驱动类")
+ private String driverClass;
+ /**
+ * 连接地址
+ */
+ @ApiModelProperty(value = "连接地址")
+ private String url;
+ /**
+ * 用户名
+ */
+ @ApiModelProperty(value = "用户名")
+ private String username;
+ /**
+ * 密码
+ */
+ @ApiModelProperty(value = "密码")
+ private String password;
+ /**
+ * 备注
+ */
+ @ApiModelProperty(value = "备注")
+ private String remark;
+
+
+}
diff --git a/blade-ops/blade-develop/src/main/java/org/springblade/develop/mapper/CodeMapper.java b/blade-ops/blade-develop/src/main/java/org/springblade/develop/mapper/CodeMapper.java
index 4b187d5ed134d31e31d6e7df6b72aaf74890427f..ac38043b07aca145416c0de91dc46ab137a64224 100644
--- a/blade-ops/blade-develop/src/main/java/org/springblade/develop/mapper/CodeMapper.java
+++ b/blade-ops/blade-develop/src/main/java/org/springblade/develop/mapper/CodeMapper.java
@@ -22,7 +22,6 @@ import org.springblade.develop.entity.Code;
* Mapper 接口
*
* @author Chill
- * @since 2018-12-24
*/
public interface CodeMapper extends BaseMapper {
diff --git a/blade-ops/blade-develop/src/main/java/org/springblade/develop/mapper/CodeMapper.xml b/blade-ops/blade-develop/src/main/java/org/springblade/develop/mapper/CodeMapper.xml
index d282aafe11c9aed90da3a7fb930fd4dcc73aa1e7..46db5518b9d2ce3b19f9b0ee3f2f099270696e88 100644
--- a/blade-ops/blade-develop/src/main/java/org/springblade/develop/mapper/CodeMapper.xml
+++ b/blade-ops/blade-develop/src/main/java/org/springblade/develop/mapper/CodeMapper.xml
@@ -5,10 +5,13 @@
+
+
+
@@ -16,10 +19,4 @@
-
-
- select
- id, service_name, code_name, table_name, pk_name, model_name, package_name, api_path, web_path, is_deleted
-
-
diff --git a/blade-ops/blade-develop/src/main/java/org/springblade/develop/mapper/DatasourceMapper.java b/blade-ops/blade-develop/src/main/java/org/springblade/develop/mapper/DatasourceMapper.java
new file mode 100644
index 0000000000000000000000000000000000000000..3f3be53c68deb8961a1c4ee66eef88786d8425be
--- /dev/null
+++ b/blade-ops/blade-develop/src/main/java/org/springblade/develop/mapper/DatasourceMapper.java
@@ -0,0 +1,28 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springblade.develop.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.springblade.develop.entity.Datasource;
+
+/**
+ * 数据源配置表 Mapper 接口
+ *
+ * @author Chill
+ */
+public interface DatasourceMapper extends BaseMapper {
+
+}
diff --git a/blade-ops/blade-develop/src/main/java/org/springblade/develop/mapper/DatasourceMapper.xml b/blade-ops/blade-develop/src/main/java/org/springblade/develop/mapper/DatasourceMapper.xml
new file mode 100644
index 0000000000000000000000000000000000000000..c863cd42dab2194b57146a09ecfe137461ada93c
--- /dev/null
+++ b/blade-ops/blade-develop/src/main/java/org/springblade/develop/mapper/DatasourceMapper.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/blade-ops/blade-develop/src/main/java/org/springblade/develop/service/ICodeService.java b/blade-ops/blade-develop/src/main/java/org/springblade/develop/service/ICodeService.java
index 0b760d65be434d181088bdad795e59fdc2029560..38e25a77cad676c0adf40e6d184f7bd342d4f582 100644
--- a/blade-ops/blade-develop/src/main/java/org/springblade/develop/service/ICodeService.java
+++ b/blade-ops/blade-develop/src/main/java/org/springblade/develop/service/ICodeService.java
@@ -23,8 +23,15 @@ import org.springblade.develop.entity.Code;
* 服务类
*
* @author Chill
- * @since 2018-12-24
*/
public interface ICodeService extends IService {
+ /**
+ * 提交
+ *
+ * @param code
+ * @return
+ */
+ boolean submit(Code code);
+
}
diff --git a/blade-ops/blade-develop/src/main/java/org/springblade/develop/service/IDatasourceService.java b/blade-ops/blade-develop/src/main/java/org/springblade/develop/service/IDatasourceService.java
new file mode 100644
index 0000000000000000000000000000000000000000..d8109f3e51147b83b62b4e584f244c2eb453d8ee
--- /dev/null
+++ b/blade-ops/blade-develop/src/main/java/org/springblade/develop/service/IDatasourceService.java
@@ -0,0 +1,28 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springblade.develop.service;
+
+import org.springblade.core.mp.base.BaseService;
+import org.springblade.develop.entity.Datasource;
+
+/**
+ * 数据源配置表 服务类
+ *
+ * @author Chill
+ */
+public interface IDatasourceService extends BaseService {
+
+}
diff --git a/blade-ops/blade-develop/src/main/java/org/springblade/develop/service/impl/CodeServiceImpl.java b/blade-ops/blade-develop/src/main/java/org/springblade/develop/service/impl/CodeServiceImpl.java
index af4c5cc538fe8141546b2ae667b3c9ede0fb2412..83aaa96aa7dc0259c70dfaac197b57edfea1bf3e 100644
--- a/blade-ops/blade-develop/src/main/java/org/springblade/develop/service/impl/CodeServiceImpl.java
+++ b/blade-ops/blade-develop/src/main/java/org/springblade/develop/service/impl/CodeServiceImpl.java
@@ -16,6 +16,7 @@
package org.springblade.develop.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springblade.core.tool.constant.BladeConstant;
import org.springblade.develop.entity.Code;
import org.springblade.develop.mapper.CodeMapper;
import org.springblade.develop.service.ICodeService;
@@ -25,9 +26,14 @@ import org.springframework.stereotype.Service;
* 服务实现类
*
* @author Chill
- * @since 2018-12-24
*/
@Service
public class CodeServiceImpl extends ServiceImpl implements ICodeService {
+ @Override
+ public boolean submit(Code code) {
+ code.setIsDeleted(BladeConstant.DB_NOT_DELETED);
+ return saveOrUpdate(code);
+ }
+
}
diff --git a/blade-ops/blade-develop/src/main/java/org/springblade/develop/service/impl/DatasourceServiceImpl.java b/blade-ops/blade-develop/src/main/java/org/springblade/develop/service/impl/DatasourceServiceImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..c14222e8849a5dab7c16be14f124d04e20505c1e
--- /dev/null
+++ b/blade-ops/blade-develop/src/main/java/org/springblade/develop/service/impl/DatasourceServiceImpl.java
@@ -0,0 +1,32 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springblade.develop.service.impl;
+
+import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springblade.develop.entity.Datasource;
+import org.springblade.develop.mapper.DatasourceMapper;
+import org.springblade.develop.service.IDatasourceService;
+import org.springframework.stereotype.Service;
+
+/**
+ * 数据源配置表 服务实现类
+ *
+ * @author Chill
+ */
+@Service
+public class DatasourceServiceImpl extends BaseServiceImpl implements IDatasourceService {
+
+}
diff --git a/blade-ops/blade-develop/src/main/java/org/springblade/develop/support/BladeGenerator.java b/blade-ops/blade-develop/src/main/java/org/springblade/develop/support/BladeGenerator.java
deleted file mode 100644
index d39c2d105efe31dceb3ffdf38ff920215de6fcdf..0000000000000000000000000000000000000000
--- a/blade-ops/blade-develop/src/main/java/org/springblade/develop/support/BladeGenerator.java
+++ /dev/null
@@ -1,292 +0,0 @@
-/**
- * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springblade.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..73e4935e4c9cc025a0f19e71d9bfb814356d6ac7
--- /dev/null
+++ b/blade-ops/blade-seata-storage/src/main/java/org/springblade/seata/storage/entity/Storage.java
@@ -0,0 +1,24 @@
+package org.springblade.seata.storage.entity;
+
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * storage
+ *
+ * @author Chill
+ */
+@Data
+@TableName("tb_storage")
+public class Storage implements Serializable {
+
+ 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 {
+}
diff --git a/blade-ops/blade-seata-storage/src/main/java/org/springblade/seata/storage/mapper/StorageMapper.xml b/blade-ops/blade-seata-storage/src/main/java/org/springblade/seata/storage/mapper/StorageMapper.xml
new file mode 100644
index 0000000000000000000000000000000000000000..c2c8a9a33868a8c63974bdf807a403fa61e064e5
--- /dev/null
+++ b/blade-ops/blade-seata-storage/src/main/java/org/springblade/seata/storage/mapper/StorageMapper.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/blade-ops/blade-seata-storage/src/main/java/org/springblade/seata/storage/service/IStorageService.java b/blade-ops/blade-seata-storage/src/main/java/org/springblade/seata/storage/service/IStorageService.java
new file mode 100644
index 0000000000000000000000000000000000000000..1b2fe400a39b2e375c38a4b1989b4e98dc813e06
--- /dev/null
+++ b/blade-ops/blade-seata-storage/src/main/java/org/springblade/seata/storage/service/IStorageService.java
@@ -0,0 +1,22 @@
+package org.springblade.seata.storage.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.springblade.seata.storage.entity.Storage;
+
+/**
+ * IStorageService
+ *
+ * @author Chill
+ */
+public interface IStorageService extends IService {
+
+ /**
+ * 减库存
+ *
+ * @param commodityCode 商品代码
+ * @param count 数量
+ * @return boolean
+ */
+ int deduct(String commodityCode, int count);
+
+}
diff --git a/blade-ops/blade-seata-storage/src/main/java/org/springblade/seata/storage/service/impl/StorageServiceImpl.java b/blade-ops/blade-seata-storage/src/main/java/org/springblade/seata/storage/service/impl/StorageServiceImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..fc1eaccdcd05926c066e4bad266fe668f750484a
--- /dev/null
+++ b/blade-ops/blade-seata-storage/src/main/java/org/springblade/seata/storage/service/impl/StorageServiceImpl.java
@@ -0,0 +1,30 @@
+package org.springblade.seata.storage.service.impl;
+
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springblade.seata.storage.entity.Storage;
+import org.springblade.seata.storage.mapper.StorageMapper;
+import org.springblade.seata.storage.service.IStorageService;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * StorageServiceImpl
+ *
+ * @author Chill
+ */
+@Service
+public class StorageServiceImpl extends ServiceImpl implements IStorageService {
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public int deduct(String commodityCode, int count) {
+ Storage storage = baseMapper.selectOne(Wrappers.query().lambda().eq(Storage::getCommodityCode, commodityCode));
+ if (storage.getCount() < count) {
+ throw new RuntimeException("超过库存数,扣除失败!");
+ }
+ storage.setCount(storage.getCount() - count);
+ return baseMapper.updateById(storage);
+ }
+
+}
diff --git a/blade-ops/blade-seata-storage/src/main/resources/application-dev.yml b/blade-ops/blade-seata-storage/src/main/resources/application-dev.yml
new file mode 100644
index 0000000000000000000000000000000000000000..8e8a376c52ee15af1ba2915de3c9c8a0d31d8eaa
--- /dev/null
+++ b/blade-ops/blade-seata-storage/src/main/resources/application-dev.yml
@@ -0,0 +1,31 @@
+#服务器端口
+server:
+ port: 8502
+
+#数据源配置
+spring:
+ datasource:
+ url: jdbc:mysql://localhost:3306/seata_storage?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
+ username: root
+ password: root
+
+# seata配置
+seata:
+ #registry:
+ # type: nacos
+ # nacos:
+ # server-addr: localhost
+ #config:
+ # type: nacos
+ # nacos:
+ # server-addr: localhost
+ tx-service-group: blade-seata-storage-group
+ service:
+ grouplist:
+ default: 127.0.0.1:8091
+ vgroup-mapping:
+ blade-seata-storage-group: default
+ disable-global-transaction: false
+ client:
+ rm:
+ report-success-enable: false
diff --git a/blade-ops/pom.xml b/blade-ops/pom.xml
index 6e616cf80aa93cafe222883a352ccd06fd3f39e1..4929ddf6ebe46b176d2aa0cff4cf9822e2d1fc7a 100644
--- a/blade-ops/pom.xml
+++ b/blade-ops/pom.xml
@@ -5,7 +5,7 @@
SpringBladeorg.springblade
- 2.0.0
+ 2.7.14.0.0
@@ -14,6 +14,9 @@
blade-adminblade-develop
+ blade-resource
+ blade-seata-order
+ blade-seata-storage
diff --git a/blade-service-api/blade-demo-api/pom.xml b/blade-service-api/blade-demo-api/pom.xml
new file mode 100644
index 0000000000000000000000000000000000000000..4596007eea139a32659e98ee034a8df842222cc7
--- /dev/null
+++ b/blade-service-api/blade-demo-api/pom.xml
@@ -0,0 +1,18 @@
+
+
+
+ blade-service-api
+ org.springblade
+ 2.7.1
+
+ 4.0.0
+
+ blade-demo-api
+ ${project.artifactId}
+ ${blade.project.version}
+ jar
+
+
+
diff --git a/blade-service-api/blade-demo-api/src/main/java/com/example/demo/entity/Notice.java b/blade-service-api/blade-demo-api/src/main/java/com/example/demo/entity/Notice.java
new file mode 100644
index 0000000000000000000000000000000000000000..9f1727a2ea548e008aa3496f21ed8ee86340d5d8
--- /dev/null
+++ b/blade-service-api/blade-demo-api/src/main/java/com/example/demo/entity/Notice.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the dreamlu.net developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.example.demo.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.core.mp.base.BaseEntity;
+
+import java.util.Date;
+
+/**
+ * 实体类
+ *
+ * @author Chill
+ */
+@Data
+@TableName("blade_notice")
+@EqualsAndHashCode(callSuper = true)
+public class Notice extends BaseEntity {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 主键id
+ */
+ @ApiModelProperty(value = "主键")
+ @TableId(value = "id", type = IdType.ASSIGN_ID)
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long id;
+
+ /**
+ * 标题
+ */
+ @ApiModelProperty(value = "标题")
+ private String title;
+
+ /**
+ * 通知类型
+ */
+ @ApiModelProperty(value = "通知类型")
+ private Integer category;
+
+ /**
+ * 发布日期
+ */
+ @ApiModelProperty(value = "发布日期")
+ private Date releaseTime;
+
+ /**
+ * 内容
+ */
+ @ApiModelProperty(value = "内容")
+ private String content;
+
+
+}
diff --git a/blade-service-api/blade-demo-api/src/main/java/com/example/demo/feign/INoticeClient.java b/blade-service-api/blade-demo-api/src/main/java/com/example/demo/feign/INoticeClient.java
new file mode 100644
index 0000000000000000000000000000000000000000..740df4be1e6adb054fe7f6b6733904e945b9b3ca
--- /dev/null
+++ b/blade-service-api/blade-demo-api/src/main/java/com/example/demo/feign/INoticeClient.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the dreamlu.net developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: Chill 庄骞 (smallchill@163.com)
+ */
+package 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> 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..dfb0a6604e73796f32230ae4ff4cd3cccd9a728d
--- /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.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import com.example.demo.entity.Notice;
+
+/**
+ * 通知公告视图类
+ *
+ * @author Chill
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class NoticeVO extends Notice {
+
+ @ApiModelProperty(value = "通知类型名")
+ 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..fde0b32687ffcc1a8a57edf0340d39aa1500a6b7 100644
--- a/blade-service-api/blade-desk-api/pom.xml
+++ b/blade-service-api/blade-desk-api/pom.xml
@@ -5,7 +5,7 @@
blade-service-apiorg.springblade
- 2.0.0
+ 2.7.14.0.0
diff --git a/blade-service-api/blade-desk-api/src/main/java/org/springblade/desk/entity/Notice.java b/blade-service-api/blade-desk-api/src/main/java/org/springblade/desk/entity/Notice.java
index 7c7065c45d300e462ec506982f6f9a1692ac0b0d..ee07c3352a1d1c1acfde9c478ba1a6adfa4ee9a6 100644
--- a/blade-service-api/blade-desk-api/src/main/java/org/springblade/desk/entity/Notice.java
+++ b/blade-service-api/blade-desk-api/src/main/java/org/springblade/desk/entity/Notice.java
@@ -15,7 +15,11 @@
*/
package org.springblade.desk.entity;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -35,6 +39,14 @@ public class Notice extends BaseEntity {
private static final long serialVersionUID = 1L;
+ /**
+ * 主键id
+ */
+ @ApiModelProperty(value = "主键")
+ @TableId(value = "id", type = IdType.ASSIGN_ID)
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long id;
+
/**
* 标题
*/
@@ -51,7 +63,7 @@ public class Notice extends BaseEntity {
* 发布日期
*/
@ApiModelProperty(value = "发布日期")
- private Date date;
+ private Date releaseTime;
/**
* 内容
diff --git a/blade-service-api/blade-dict-api/pom.xml b/blade-service-api/blade-dict-api/pom.xml
index 3b8f6112a1e9fbe5dacb89bf6a14ee89f1df214f..f9a4d694eb5753761523dfcdfb1b766edcf58f7b 100644
--- a/blade-service-api/blade-dict-api/pom.xml
+++ b/blade-service-api/blade-dict-api/pom.xml
@@ -5,7 +5,7 @@
blade-service-apiorg.springblade
- 2.0.0
+ 2.7.14.0.0
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..ea05ce2725a1f47962ee3219f9899eb159060cce 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
@@ -19,6 +19,8 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@@ -42,14 +44,16 @@ public class Dict implements Serializable {
* 主键
*/
@ApiModelProperty(value = "主键")
- @TableId(value = "id", type = IdType.AUTO)
- private Integer id;
+ @TableId(value = "id", type = IdType.ASSIGN_ID)
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long id;
/**
* 父主键
*/
@ApiModelProperty(value = "父主键")
- private Integer parentId;
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long parentId;
/**
* 字典码
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..82f671dea49c6a57ac588d97ebb12dd0baa3a9a3 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
@@ -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 getValue(String code, Integer dictKey) {
diff --git a/blade-service-api/blade-dict-api/src/main/java/org/springblade/system/vo/DictVO.java b/blade-service-api/blade-dict-api/src/main/java/org/springblade/system/vo/DictVO.java
index d532627de49b4280d33b2a0082acc4a7c275418c..739d87e392c27da3af60ecfb692c911b13c4fb32 100644
--- a/blade-service-api/blade-dict-api/src/main/java/org/springblade/system/vo/DictVO.java
+++ b/blade-service-api/blade-dict-api/src/main/java/org/springblade/system/vo/DictVO.java
@@ -16,6 +16,8 @@
package org.springblade.system.vo;
import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -39,12 +41,14 @@ public class DictVO extends Dict implements INode {
/**
* 主键ID
*/
- private Integer id;
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long id;
/**
* 父节点ID
*/
- private Integer parentId;
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long parentId;
/**
* 子孙节点
diff --git a/blade-service-api/blade-system-api/pom.xml b/blade-service-api/blade-system-api/pom.xml
index 0847d6db1108d8a3ba3f749b45a896d25592bbc7..06298d51fb90af8b415d03942a8d0112da9048ac 100644
--- a/blade-service-api/blade-system-api/pom.xml
+++ b/blade-service-api/blade-system-api/pom.xml
@@ -5,7 +5,7 @@
blade-service-apiorg.springblade
- 2.0.0
+ 2.7.14.0.0
diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/dto/DeptDTO.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/dto/DeptDTO.java
index 38919250b3575a839c18c040f77c405a8140406b..70ca42858d2567a422baab6b232b4cf35491e069 100644
--- a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/dto/DeptDTO.java
+++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/dto/DeptDTO.java
@@ -23,7 +23,6 @@ import org.springblade.system.entity.Dept;
* 数据传输对象实体类
*
* @author Chill
- * @since 2018-12-24
*/
@Data
@EqualsAndHashCode(callSuper = true)
diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/dto/MenuDTO.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/dto/MenuDTO.java
index 8346ded61bad4a86e0ed30062c7c0d6e8f2ac329..80513cefdb10e9b2fb1c1466e868a662a1d7c87b 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
@@ -23,7 +23,6 @@ import java.io.Serializable;
* 数据传输对象实体类
*
* @author Chill
- * @since 2018-12-24
*/
@Data
public class MenuDTO implements Serializable {
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..c5b9631ebd9e4fae49b83885bc985f2b8409204e 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
@@ -23,7 +23,6 @@ import org.springblade.system.entity.Param;
* 数据传输对象实体类
*
* @author Chill
- * @since 2018-12-28
*/
@Data
@EqualsAndHashCode(callSuper = true)
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..c1c8dc14abd3badb054100ddbb16e161f2c98e6d 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
@@ -23,7 +23,6 @@ import org.springblade.system.entity.Role;
* 数据传输对象实体类
*
* @author Chill
- * @since 2018-12-24
*/
@Data
@EqualsAndHashCode(callSuper = true)
diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/dto/RoleMenuDTO.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/dto/RoleMenuDTO.java
index 137e8506e3e86efd737556545f05792896def942..2d7e8990dbc267b01f79a143fb837af1092146ab 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
@@ -23,7 +23,6 @@ import org.springblade.system.entity.RoleMenu;
* 数据传输对象实体类
*
* @author Chill
- * @since 2018-12-24
*/
@Data
@EqualsAndHashCode(callSuper = true)
diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/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..0d2cee1316e59e5ab23ef4622fe8f2b971f8aebd
--- /dev/null
+++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/AuthClient.java
@@ -0,0 +1,108 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springblade.system.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.core.mp.base.BaseEntity;
+
+/**
+ * 实体类
+ *
+ * @author Chill
+ */
+@Data
+@TableName("blade_tenant")
+@EqualsAndHashCode(callSuper = true)
+@ApiModel(value = "Tenant对象", description = "Tenant对象")
+public class Tenant extends BaseEntity {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 主键id
+ */
+ @ApiModelProperty(value = "主键")
+ @TableId(value = "id", type = IdType.ASSIGN_ID)
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long id;
+
+ /**
+ * 租户ID
+ */
+ @ApiModelProperty(value = "租户ID")
+ private String tenantId;
+ /**
+ * 租户名称
+ */
+ @ApiModelProperty(value = "租户名称")
+ private String tenantName;
+ /**
+ * 联系人
+ */
+ @ApiModelProperty(value = "联系人")
+ private String linkman;
+ /**
+ * 联系电话
+ */
+ @ApiModelProperty(value = "联系电话")
+ private String contactNumber;
+ /**
+ * 联系地址
+ */
+ @ApiModelProperty(value = "联系地址")
+ private String address;
+
+
+}
diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/feign/ISysClient.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/feign/ISysClient.java
new file mode 100644
index 0000000000000000000000000000000000000000..80754ba7497901abc16f70405867afbaa5e994d8
--- /dev/null
+++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/feign/ISysClient.java
@@ -0,0 +1,144 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springblade.system.vo;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.core.tool.node.INode;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.system.entity.Region;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 行政区划表视图实体类
+ *
+ * @author Chill
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ApiModel(value = "RegionVO对象", description = "行政区划表")
+public class RegionVO extends Region implements INode {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 主键ID
+ */
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long id;
+
+ /**
+ * 父节点ID
+ */
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long parentId;
+
+ /**
+ * 父节点名称
+ */
+ private String parentName;
+
+ /**
+ * 是否有子孙节点
+ */
+ @JsonInclude(JsonInclude.Include.NON_EMPTY)
+ private Boolean hasChildren;
+
+ /**
+ * 子孙节点
+ */
+ @JsonInclude(JsonInclude.Include.NON_EMPTY)
+ private List children;
+
+ @Override
+ public Long getId() {
+ return Func.toLong(this.getCode());
+ }
+
+ @Override
+ public Long getParentId() {
+ return Func.toLong(this.getParentCode());
+ }
+
+ @Override
+ public List getChildren() {
+ if (this.children == null) {
+ this.children = new ArrayList<>();
+ }
+ return this.children;
+ }
+}
diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/RoleMenuVO.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/RoleMenuVO.java
index 03b5643d7526b072615e809ec6a2697e2201ad52..d8099a1033f9e45557f41c7def0d5bba057e9483 100644
--- a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/RoleMenuVO.java
+++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/RoleMenuVO.java
@@ -24,7 +24,6 @@ import org.springblade.system.entity.RoleMenu;
* 视图实体类
*
* @author Chill
- * @since 2018-12-24
*/
@Data
@EqualsAndHashCode(callSuper = true)
diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/RoleVO.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/RoleVO.java
index 28792a0d13b006bbcde2f979183b0dc6517d0752..53f7bec4daddda3cd85d317abbec377f5a50b14a 100644
--- a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/RoleVO.java
+++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/RoleVO.java
@@ -16,6 +16,8 @@
package org.springblade.system.vo;
import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -29,7 +31,6 @@ import java.util.List;
* 视图实体类
*
* @author Chill
- * @since 2018-12-24
*/
@Data
@EqualsAndHashCode(callSuper = true)
@@ -40,12 +41,14 @@ public class RoleVO extends Role implements INode {
/**
* 主键ID
*/
- private Integer id;
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long id;
/**
* 父节点ID
*/
- private Integer parentId;
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long parentId;
/**
* 子孙节点
diff --git a/blade-service-api/blade-user-api/pom.xml b/blade-service-api/blade-user-api/pom.xml
index af115002e402179871502bae7b45a26e6a19519a..ca06e556bbd1e74059e78e8299b10e20ac69ca26 100644
--- a/blade-service-api/blade-user-api/pom.xml
+++ b/blade-service-api/blade-user-api/pom.xml
@@ -5,7 +5,7 @@
blade-service-apiorg.springblade
- 2.0.0
+ 2.7.14.0.0
diff --git a/blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/entity/User.java b/blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/entity/User.java
index c52747b71166d726def983812084c9e53e12c5ab..a38d1b24a5d808de3db6a00bdfc495ea6901047b 100644
--- a/blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/entity/User.java
+++ b/blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/entity/User.java
@@ -15,12 +15,17 @@
*/
package org.springblade.system.user.entity;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
-import org.springblade.core.mp.base.BaseEntity;
+import org.springblade.core.mp.base.TenantEntity;
-import java.time.LocalDateTime;
+import java.util.Date;
/**
* 实体类
@@ -30,10 +35,23 @@ import java.time.LocalDateTime;
@Data
@TableName("blade_user")
@EqualsAndHashCode(callSuper = true)
-public class User extends BaseEntity {
+public class User extends TenantEntity {
private static final long serialVersionUID = 1L;
+ /**
+ * 主键id
+ */
+ @ApiModelProperty(value = "主键")
+ @TableId(value = "id", type = IdType.ASSIGN_ID)
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long id;
+
+
+ /**
+ * 编号
+ */
+ private String code;
/**
* 账号
*/
@@ -50,6 +68,10 @@ public class User extends BaseEntity {
* 真名
*/
private String realName;
+ /**
+ * 头像
+ */
+ private String avatar;
/**
* 邮箱
*/
@@ -61,7 +83,7 @@ public class User extends BaseEntity {
/**
* 生日
*/
- private LocalDateTime birthday;
+ private Date birthday;
/**
* 性别
*/
@@ -74,6 +96,10 @@ public class User extends BaseEntity {
* 部门id
*/
private String deptId;
+ /**
+ * 部门id
+ */
+ private String postId;
}
diff --git a/blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/feign/IUserClient.java b/blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/feign/IUserClient.java
index abf790876276047401babd15b912cc5353611a16..f7585506a6b0314f21b4cd42e144705056199030 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
@@ -25,10 +25,12 @@ import org.springframework.web.bind.annotation.RequestParam;
/**
* User Feign接口类
+ *
* @author Chill
*/
@FeignClient(
- value = AppConstant.APPLICATION_USER_NAME
+ value = AppConstant.APPLICATION_USER_NAME,
+ fallback = IUserClientFallback.class
)
public interface IUserClient {
@@ -37,11 +39,21 @@ public interface IUserClient {
/**
* 获取用户信息
*
- * @param account 账号
- * @param password 密码
+ * @param userId 用户id
* @return
*/
- @GetMapping(API_PREFIX + "/userInfo")
- R userInfo(@RequestParam("account") String account, @RequestParam("password") String password);
+ @GetMapping(API_PREFIX + "/user-info-by-id")
+ R userInfo(@RequestParam("userId") Long userId);
+
+ /**
+ * 获取用户信息
+ *
+ * @param tenantId 租户ID
+ * @param account 账号
+ * @param password 密码
+ * @return
+ */
+ @GetMapping(API_PREFIX + "/user-info")
+ R userInfo(@RequestParam("tenantId") String tenantId, @RequestParam("account") String account, @RequestParam("password") String password);
}
diff --git a/blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/feign/IUserClientFallback.java b/blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/feign/IUserClientFallback.java
new file mode 100644
index 0000000000000000000000000000000000000000..02faf7b24122d9a85ad643da606fe38c2b0c8640
--- /dev/null
+++ b/blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/feign/IUserClientFallback.java
@@ -0,0 +1,39 @@
+/**
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springblade.system.user.feign;
+
+import org.springblade.core.tool.api.R;
+import org.springblade.system.user.entity.UserInfo;
+import org.springframework.stereotype.Component;
+
+/**
+ * Feign失败配置
+ *
+ * @author Chill
+ */
+@Component
+public class IUserClientFallback implements IUserClient {
+
+ @Override
+ public R userInfo(Long userId) {
+ return R.fail("未获取到账号信息");
+ }
+
+ @Override
+ public R userInfo(String tenantId, String account, String password) {
+ return R.fail("未获取到账号信息");
+ }
+}
diff --git a/blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/vo/UserVO.java b/blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/vo/UserVO.java
index b8392f603fca1ca718912009e9f5b142d0b6a1a5..0f4f76733a76279f6377f18c3eafcdc93fc4c39a 100644
--- a/blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/vo/UserVO.java
+++ b/blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/vo/UserVO.java
@@ -15,51 +15,29 @@
*/
package org.springblade.system.user.vo;
-import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
-import org.springblade.core.tool.node.INode;
import org.springblade.system.user.entity.User;
-import java.util.ArrayList;
-import java.util.List;
-
/**
* 视图实体类
*
* @author Chill
- * @since 2018-12-24
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "UserVO对象", description = "UserVO对象")
-public class UserVO extends User implements INode {
+public class UserVO extends User {
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
- private Integer id;
-
- /**
- * 父节点ID
- */
- private Integer parentId;
-
- /**
- * 子孙节点
- */
- @JsonInclude(JsonInclude.Include.NON_EMPTY)
- private List children;
-
- @Override
- public List getChildren() {
- if (this.children == null) {
- this.children = new ArrayList<>();
- }
- return this.children;
- }
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long id;
/**
* 角色名
@@ -71,6 +49,11 @@ public class UserVO extends User implements INode {
*/
private String deptName;
+ /**
+ * 岗位名
+ */
+ private String postName;
+
/**
* 性别
*/
diff --git a/blade-service-api/pom.xml b/blade-service-api/pom.xml
index df61f043db63d6fc8bc0406e0283c3d19341eb78..e4feba06a58da04354f57a063915e2446d95cf52 100644
--- a/blade-service-api/pom.xml
+++ b/blade-service-api/pom.xml
@@ -5,13 +5,13 @@
SpringBladeorg.springblade
- 2.0.0
+ 2.7.14.0.0blade-service-api${project.artifactId}
- 2.0.0
+ 2.7.1pomSpringBlade 微服务API集合
@@ -20,6 +20,7 @@
blade-dict-apiblade-system-apiblade-user-api
+ blade-demo-api
diff --git a/blade-service/blade-demo/pom.xml b/blade-service/blade-demo/pom.xml
new file mode 100644
index 0000000000000000000000000000000000000000..fb0e5b328fd875dc135aa20343833a586c4c46ac
--- /dev/null
+++ b/blade-service/blade-demo/pom.xml
@@ -0,0 +1,40 @@
+
+
+
+ blade-service
+ org.springblade
+ 2.7.1
+
+ 4.0.0
+
+ blade-demo
+ ${project.artifactId}
+ ${blade.project.version}
+ jar
+
+
+
+ org.springblade
+ blade-core-boot
+ ${blade.tool.version}
+
+
+ org.springblade
+ blade-core-swagger
+ ${blade.tool.version}
+
+
+ org.springblade
+ blade-demo-api
+ ${blade.project.version}
+
+
+ com.baomidou
+ dynamic-datasource-spring-boot-starter
+ 2.5.6
+
+
+
+
diff --git a/blade-service/blade-demo/src/main/java/com/example/demo/DemoApplication.java b/blade-service/blade-demo/src/main/java/com/example/demo/DemoApplication.java
new file mode 100644
index 0000000000000000000000000000000000000000..a06eaaa1318da2f1975841e987a3c8e367db2573
--- /dev/null
+++ b/blade-service/blade-demo/src/main/java/com/example/demo/DemoApplication.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the dreamlu.net developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.example.demo;
+
+import org.springblade.core.launch.BladeApplication;
+import org.springframework.cloud.client.SpringCloudApplication;
+
+/**
+ * Demo启动器
+ *
+ * @author Chill
+ */
+@SpringCloudApplication
+public class DemoApplication {
+
+ public static void main(String[] args) {
+ BladeApplication.run("blade-demo", DemoApplication.class, args);
+ }
+
+}
+
diff --git a/blade-service/blade-demo/src/main/java/com/example/demo/config/DemoConfiguration.java b/blade-service/blade-demo/src/main/java/com/example/demo/config/DemoConfiguration.java
new file mode 100644
index 0000000000000000000000000000000000000000..238549b7737bbf11e501db1293b57ad2426f7c2b
--- /dev/null
+++ b/blade-service/blade-demo/src/main/java/com/example/demo/config/DemoConfiguration.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the dreamlu.net developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: Chill 庄骞 (smallchill@163.com)
+ */
+package 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
+@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..0129a6a76b4c3c25477460c5615283183ba53803
--- /dev/null
+++ b/blade-service/blade-demo/src/main/java/com/example/demo/controller/DemoController.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the dreamlu.net developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.example.demo.controller;
+
+import com.example.demo.props.DemoProperties;
+import io.swagger.annotations.Api;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.cloud.context.config.annotation.RefreshScope;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * Demo控制器
+ *
+ * @author Chill
+ */
+@RefreshScope
+@RestController
+@RequestMapping("demo")
+@Api(value = "配置接口", tags = "即时刷新配置")
+public class DemoController {
+
+ @Value("${demo.name}")
+ private String name;
+
+ private final DemoProperties properties;
+
+ public DemoController(DemoProperties properties) {
+ this.properties = properties;
+ }
+
+
+ @GetMapping("name")
+ public String getName() {
+ return name;
+ }
+
+ @GetMapping("name-by-props")
+ public String getNameByProps() {
+ return properties.getName();
+ }
+
+}
diff --git a/blade-service/blade-demo/src/main/java/com/example/demo/controller/DynamicController.java b/blade-service/blade-demo/src/main/java/com/example/demo/controller/DynamicController.java
new file mode 100644
index 0000000000000000000000000000000000000000..212e836bc20f0559c9be8079e440fe5c6017e00b
--- /dev/null
+++ b/blade-service/blade-demo/src/main/java/com/example/demo/controller/DynamicController.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the dreamlu.net developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.example.demo.controller;
+
+import com.example.demo.entity.Notice;
+import com.example.demo.service.IDynamicService;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import org.springblade.core.tool.api.R;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * 多数据源
+ *
+ * @author Chill
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("dynamic")
+@Api(value = "多数据源接口", tags = "多数据源")
+public class DynamicController {
+
+ private IDynamicService dynamicService;
+
+ /**
+ * master列表
+ */
+ @GetMapping("/master-list")
+ @ApiOperationSupport(order = 1)
+ @ApiOperation(value = "master列表", notes = "master列表")
+ public R> masterList() {
+ List list = dynamicService.masterList();
+ return R.data(list);
+ }
+
+ /**
+ * slave列表
+ */
+ @GetMapping("/slave-list")
+ @ApiOperationSupport(order = 1)
+ @ApiOperation(value = "slave列表", notes = "slave列表")
+ public R> slaveList() {
+ List list = dynamicService.slaveList();
+ return R.data(list);
+ }
+
+}
diff --git a/blade-service/blade-demo/src/main/java/com/example/demo/controller/NoticeController.java b/blade-service/blade-demo/src/main/java/com/example/demo/controller/NoticeController.java
new file mode 100644
index 0000000000000000000000000000000000000000..88b8d21cb8e7be17020a86974eb13407ce6ff8ac
--- /dev/null
+++ b/blade-service/blade-demo/src/main/java/com/example/demo/controller/NoticeController.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the dreamlu.net developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.example.demo.controller;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.example.demo.entity.Notice;
+import com.example.demo.service.INoticeService;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import io.swagger.annotations.*;
+import lombok.AllArgsConstructor;
+import org.springblade.common.cache.CacheNames;
+import org.springblade.core.boot.ctrl.BladeController;
+import org.springblade.core.mp.support.Condition;
+import org.springblade.core.mp.support.Query;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.Func;
+import org.springframework.web.bind.annotation.*;
+import springfox.documentation.annotations.ApiIgnore;
+
+import java.util.Map;
+
+/**
+ * 控制器
+ *
+ * @author Chill
+ */
+@RestController
+@RequestMapping("notice")
+@AllArgsConstructor
+@Api(value = "用户博客", tags = "博客接口")
+public class NoticeController extends BladeController implements CacheNames {
+
+ private INoticeService noticeService;
+
+ /**
+ * 详情
+ */
+ @GetMapping("/detail")
+ @ApiOperationSupport(order = 1)
+ @ApiOperation(value = "详情", notes = "传入notice")
+ public R detail(Notice notice) {
+ Notice detail = noticeService.getOne(Condition.getQueryWrapper(notice));
+ return R.data(detail);
+ }
+
+ /**
+ * 分页
+ */
+ @GetMapping("/list")
+ @ApiImplicitParams({
+ @ApiImplicitParam(name = "category", value = "公告类型", paramType = "query", dataType = "integer"),
+ @ApiImplicitParam(name = "title", value = "公告标题", paramType = "query", dataType = "string")
+ })
+ @ApiOperationSupport(order = 2)
+ @ApiOperation(value = "分页", notes = "传入notice")
+ public R> list(@ApiIgnore @RequestParam Map notice, Query query) {
+ IPage pages = noticeService.page(Condition.getPage(query), Condition.getQueryWrapper(notice, Notice.class));
+ return R.data(pages);
+ }
+
+ /**
+ * 新增
+ */
+ @PostMapping("/save")
+ @ApiOperationSupport(order = 3)
+ @ApiOperation(value = "新增", notes = "传入notice")
+ public R save(@RequestBody Notice notice) {
+ return R.status(noticeService.save(notice));
+ }
+
+ /**
+ * 修改
+ */
+ @PostMapping("/update")
+ @ApiOperationSupport(order = 4)
+ @ApiOperation(value = "修改", notes = "传入notice")
+ public R update(@RequestBody Notice notice) {
+ return R.status(noticeService.updateById(notice));
+ }
+
+ /**
+ * 新增或修改
+ */
+ @PostMapping("/submit")
+ @ApiOperationSupport(order = 5)
+ @ApiOperation(value = "新增或修改", notes = "传入notice")
+ public R submit(@RequestBody Notice notice) {
+ return R.status(noticeService.saveOrUpdate(notice));
+ }
+
+ /**
+ * 删除
+ */
+ @PostMapping("/remove")
+ @ApiOperationSupport(order = 6)
+ @ApiOperation(value = "逻辑删除", notes = "传入notice")
+ public R remove(@ApiParam(value = "主键集合") @RequestParam String ids) {
+ boolean temp = noticeService.deleteLogic(Func.toLongList(ids));
+ return R.status(temp);
+ }
+
+}
diff --git a/blade-service/blade-demo/src/main/java/com/example/demo/feign/NoticeClient.java b/blade-service/blade-demo/src/main/java/com/example/demo/feign/NoticeClient.java
new file mode 100644
index 0000000000000000000000000000000000000000..81673880dfe630f84501267589b9ec92c975d757
--- /dev/null
+++ b/blade-service/blade-demo/src/main/java/com/example/demo/feign/NoticeClient.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the dreamlu.net developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: Chill 庄骞 (smallchill@163.com)
+ */
+package 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.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RestController;
+import springfox.documentation.annotations.ApiIgnore;
+
+import java.util.List;
+
+/**
+ * Notice Feign
+ *
+ * @author Chill
+ */
+@ApiIgnore()
+@RestController
+@AllArgsConstructor
+public class NoticeClient implements INoticeClient {
+
+ private NoticeMapper mapper;
+
+ @Override
+ @GetMapping(TOP)
+ public R> top(Integer number) {
+ return R.data(mapper.topList(number));
+ }
+
+}
diff --git a/blade-service/blade-demo/src/main/java/com/example/demo/launcher/DemoLauncherServiceImpl.java b/blade-service/blade-demo/src/main/java/com/example/demo/launcher/DemoLauncherServiceImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..b59916e651368294785df55e7b6f076e201a681b
--- /dev/null
+++ b/blade-service/blade-demo/src/main/java/com/example/demo/launcher/DemoLauncherServiceImpl.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the dreamlu.net developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.example.demo.launcher;
+
+import org.springblade.core.launch.constant.NacosConstant;
+import org.springblade.core.launch.service.LauncherService;
+import org.springblade.core.launch.utils.PropsUtil;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+
+import java.util.Properties;
+
+/**
+ * 启动参数拓展
+ *
+ * @author Chill
+ */
+public class DemoLauncherServiceImpl implements LauncherService {
+
+ @Override
+ public void launcher(SpringApplicationBuilder builder, String appName, String profile) {
+ Properties props = System.getProperties();
+ PropsUtil.setProperty(props, "spring.cloud.nacos.config.ext-config[0].data-id", NacosConstant.dataId("blade-demo", profile));
+ PropsUtil.setProperty(props, "spring.cloud.nacos.config.ext-config[0].group", NacosConstant.NACOS_CONFIG_GROUP);
+ PropsUtil.setProperty(props, "spring.cloud.nacos.config.ext-config[0].refresh", NacosConstant.NACOS_CONFIG_REFRESH);
+ // 自定义命名空间
+ // PropsUtil.setProperty(props, "spring.cloud.nacos.config.namespace", LauncherConstant.NACOS_NAMESPACE);
+ // PropsUtil.setProperty(props, "spring.cloud.nacos.discovery.namespace", LauncherConstant.NACOS_NAMESPACE);
+ }
+
+ @Override
+ public int getOrder() {
+ return 20;
+ }
+}
diff --git a/blade-service/blade-demo/src/main/java/com/example/demo/mapper/NoticeMapper.java b/blade-service/blade-demo/src/main/java/com/example/demo/mapper/NoticeMapper.java
new file mode 100644
index 0000000000000000000000000000000000000000..86102853e2e16d8049ef6d3159c98d96a0eba479
--- /dev/null
+++ b/blade-service/blade-demo/src/main/java/com/example/demo/mapper/NoticeMapper.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the dreamlu.net developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.example.demo.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.example.demo.entity.Notice;
+
+import java.util.List;
+
+/**
+ * Mapper 接口
+ *
+ * @author Chill
+ */
+public interface NoticeMapper extends BaseMapper {
+
+ /**
+ * 前N条数据
+ * @param number
+ * @return
+ */
+ List topList(Integer number);
+
+ /**
+ * 自定义分页
+ * @param page
+ * @param notice
+ * @return
+ */
+ List selectNoticePage(IPage page, Notice notice);
+
+}
diff --git a/blade-service/blade-demo/src/main/java/com/example/demo/mapper/NoticeMapper.xml b/blade-service/blade-demo/src/main/java/com/example/demo/mapper/NoticeMapper.xml
new file mode 100644
index 0000000000000000000000000000000000000000..046ca1354815d657ca7a6695d0197bc20d8825e6
--- /dev/null
+++ b/blade-service/blade-demo/src/main/java/com/example/demo/mapper/NoticeMapper.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ select id,
+ create_user AS createUser,
+ create_time AS createTime,
+ update_user AS updateUser,
+ update_time AS updateTime,
+ status,
+ is_deleted AS isDeleted,
+ title, content
+
+
+
+
+
+
+
diff --git a/blade-service/blade-demo/src/main/java/com/example/demo/props/DemoProperties.java b/blade-service/blade-demo/src/main/java/com/example/demo/props/DemoProperties.java
new file mode 100644
index 0000000000000000000000000000000000000000..7c3f700437aa2ce244fee1179eee6c8b11a0a145
--- /dev/null
+++ b/blade-service/blade-demo/src/main/java/com/example/demo/props/DemoProperties.java
@@ -0,0 +1,18 @@
+package com.example.demo.props;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+/**
+ * DemoProperties
+ *
+ * @author Chill
+ */
+@Data
+@ConfigurationProperties(prefix = "demo")
+public class DemoProperties {
+ /**
+ * 名称
+ */
+ private String name;
+}
diff --git a/blade-service/blade-demo/src/main/java/com/example/demo/service/IDynamicService.java b/blade-service/blade-demo/src/main/java/com/example/demo/service/IDynamicService.java
new file mode 100644
index 0000000000000000000000000000000000000000..dd09977c0ce8a3470ef56e7a1b439e61d5c28820
--- /dev/null
+++ b/blade-service/blade-demo/src/main/java/com/example/demo/service/IDynamicService.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the dreamlu.net developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.example.demo.service;
+
+import com.example.demo.entity.Notice;
+import org.springblade.core.mp.base.BaseService;
+
+import java.util.List;
+
+/**
+ * 服务类
+ *
+ * @author Chill
+ */
+public interface IDynamicService extends BaseService {
+
+ /**
+ * master数据源的列表
+ *
+ * @return
+ */
+ List masterList();
+
+ /**
+ * slave数据源的列表
+ *
+ * @return
+ */
+ List slaveList();
+
+}
diff --git a/blade-service/blade-demo/src/main/java/com/example/demo/service/INoticeService.java b/blade-service/blade-demo/src/main/java/com/example/demo/service/INoticeService.java
new file mode 100644
index 0000000000000000000000000000000000000000..015af8db6750a9699151f00778e8ea41a343b9ee
--- /dev/null
+++ b/blade-service/blade-demo/src/main/java/com/example/demo/service/INoticeService.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the dreamlu.net developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.example.demo.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.springblade.core.mp.base.BaseService;
+import com.example.demo.entity.Notice;
+
+/**
+ * 服务类
+ *
+ * @author Chill
+ */
+public interface INoticeService extends BaseService {
+
+ /**
+ * 自定义分页
+ * @param page
+ * @param notice
+ * @return
+ */
+ IPage selectNoticePage(IPage page, Notice notice);
+
+}
diff --git a/blade-service/blade-demo/src/main/java/com/example/demo/service/impl/DynamicServiceImpl.java b/blade-service/blade-demo/src/main/java/com/example/demo/service/impl/DynamicServiceImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..64dd1b627bd3fa6094444af21c66206ec0cdfb78
--- /dev/null
+++ b/blade-service/blade-demo/src/main/java/com/example/demo/service/impl/DynamicServiceImpl.java
@@ -0,0 +1,30 @@
+package com.example.demo.service.impl;
+
+import com.baomidou.dynamic.datasource.annotation.DS;
+import com.example.demo.entity.Notice;
+import com.example.demo.mapper.NoticeMapper;
+import com.example.demo.service.IDynamicService;
+import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * DynamicServiceImpl
+ *
+ * @author Chill
+ */
+@Service
+public class DynamicServiceImpl extends BaseServiceImpl implements IDynamicService {
+
+ @Override
+ public List masterList() {
+ return this.list();
+ }
+
+ @Override
+ @DS("slave")
+ public List slaveList() {
+ return this.list();
+ }
+}
diff --git a/blade-service/blade-demo/src/main/java/com/example/demo/service/impl/NoticeServiceImpl.java b/blade-service/blade-demo/src/main/java/com/example/demo/service/impl/NoticeServiceImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..60bb06a7252be0705f85ed5817755e23cf8b1694
--- /dev/null
+++ b/blade-service/blade-demo/src/main/java/com/example/demo/service/impl/NoticeServiceImpl.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the dreamlu.net developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: Chill 庄骞 (smallchill@163.com)
+ */
+package 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 implements INoticeService {
+
+ @Override
+ public IPage selectNoticePage(IPage page, Notice notice) {
+ return page.setRecords(baseMapper.selectNoticePage(page, notice));
+ }
+
+}
diff --git a/blade-service/blade-demo/src/main/resources/META-INF/services/org.springblade.core.launch.service.LauncherService b/blade-service/blade-demo/src/main/resources/META-INF/services/org.springblade.core.launch.service.LauncherService
new file mode 100644
index 0000000000000000000000000000000000000000..a8313049ea65b3f3afd442fdff63a6318f6a49cb
--- /dev/null
+++ b/blade-service/blade-demo/src/main/resources/META-INF/services/org.springblade.core.launch.service.LauncherService
@@ -0,0 +1 @@
+com.example.demo.launcher.DemoLauncherServiceImpl
diff --git a/blade-service/blade-demo/src/main/resources/application-dev.yml b/blade-service/blade-demo/src/main/resources/application-dev.yml
new file mode 100644
index 0000000000000000000000000000000000000000..38426fa1577ebeac4e73d00deb3a646bdd2a3c97
--- /dev/null
+++ b/blade-service/blade-demo/src/main/resources/application-dev.yml
@@ -0,0 +1,28 @@
+#服务器端口
+server:
+ port: 8200
+
+#数据源配置
+#spring:
+# datasource:
+# url: ${blade.datasource.dev.url}
+# username: ${blade.datasource.dev.username}
+# password: ${blade.datasource.dev.password}
+
+spring:
+ #排除DruidDataSourceAutoConfigure
+ autoconfigure:
+ exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
+ datasource:
+ dynamic:
+ #设置默认的数据源或者数据源组,默认值即为master
+ primary: master
+ datasource:
+ master:
+ url: ${blade.datasource.demo.master.url}
+ username: ${blade.datasource.demo.master.username}
+ password: ${blade.datasource.demo.master.password}
+ slave:
+ url: ${blade.datasource.demo.slave.url}
+ username: ${blade.datasource.demo.slave.username}
+ password: ${blade.datasource.demo.slave.password}
diff --git a/blade-service/blade-demo/src/main/resources/application-prod.yml b/blade-service/blade-demo/src/main/resources/application-prod.yml
new file mode 100644
index 0000000000000000000000000000000000000000..da892629d4abcc5781995a5d6bc61eb738a7dac8
--- /dev/null
+++ b/blade-service/blade-demo/src/main/resources/application-prod.yml
@@ -0,0 +1,28 @@
+#服务器端口
+server:
+ port: 8200
+
+#数据源配置
+#spring:
+# datasource:
+# url: ${blade.datasource.prod.url}
+# username: ${blade.datasource.prod.username}
+# password: ${blade.datasource.prod.password}
+
+spring:
+ #排除DruidDataSourceAutoConfigure
+ autoconfigure:
+ exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
+ datasource:
+ dynamic:
+ #设置默认的数据源或者数据源组,默认值即为master
+ primary: master
+ datasource:
+ master:
+ url: ${blade.datasource.demo.master.url}
+ username: ${blade.datasource.demo.master.username}
+ password: ${blade.datasource.demo.master.password}
+ slave:
+ url: ${blade.datasource.demo.slave.url}
+ username: ${blade.datasource.demo.slave.username}
+ password: ${blade.datasource.demo.slave.password}
diff --git a/blade-service/blade-demo/src/main/resources/application-test.yml b/blade-service/blade-demo/src/main/resources/application-test.yml
new file mode 100644
index 0000000000000000000000000000000000000000..4b4e157a317ef9744d4dd730ffa40b1d77ef3ad7
--- /dev/null
+++ b/blade-service/blade-demo/src/main/resources/application-test.yml
@@ -0,0 +1,28 @@
+#服务器端口
+server:
+ port: 8200
+
+#数据源配置
+#spring:
+# datasource:
+# url: ${blade.datasource.test.url}
+# username: ${blade.datasource.test.username}
+# password: ${blade.datasource.test.password}
+
+spring:
+ #排除DruidDataSourceAutoConfigure
+ autoconfigure:
+ exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
+ datasource:
+ dynamic:
+ #设置默认的数据源或者数据源组,默认值即为master
+ primary: master
+ datasource:
+ master:
+ url: ${blade.datasource.demo.master.url}
+ username: ${blade.datasource.demo.master.username}
+ password: ${blade.datasource.demo.master.password}
+ slave:
+ url: ${blade.datasource.demo.slave.url}
+ username: ${blade.datasource.demo.slave.username}
+ password: ${blade.datasource.demo.slave.password}
diff --git a/blade-service/blade-demo/src/main/resources/application.yml b/blade-service/blade-demo/src/main/resources/application.yml
new file mode 100644
index 0000000000000000000000000000000000000000..103a2570e06fe95f2a03a375d40e478ebaac3c23
--- /dev/null
+++ b/blade-service/blade-demo/src/main/resources/application.yml
@@ -0,0 +1,12 @@
+#mybatis-plus配置
+mybatis-plus:
+ mapper-locations: classpath:com/example/**/mapper/*Mapper.xml
+ #实体扫描,多个package用逗号或者分号分隔
+ typeAliasesPackage: com.example.**.entity
+
+#swagger扫描路径配置
+swagger:
+ base-packages:
+ - org.springbalde
+ - com.example
+
diff --git a/blade-service/blade-desk/pom.xml b/blade-service/blade-desk/pom.xml
index f76ece3b369d52c3e9559398377600eccb7ec65a..5fcaed70350a462003669a75c6d2d87b9add077f 100644
--- a/blade-service/blade-desk/pom.xml
+++ b/blade-service/blade-desk/pom.xml
@@ -6,7 +6,7 @@
org.springbladeblade-service
- 2.0.0
+ 2.7.14.0.0
@@ -37,6 +37,37 @@
blade-dict-api${blade.project.version}
+
+ org.springblade
+ blade-core-test
+ ${blade.tool.version}
+ test
+
+
+
+
+ org.apache.maven.plugins
+ maven-antrun-plugin
+
+
+ package
+
+ run
+
+
+
+
+
+
+
+
+
+
+
+
+
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..6f5b4e496b461db599c52ddf52f7d47b9ccf8d6f 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
@@ -31,7 +31,7 @@ public class DashBoardController {
* @return
*/
@GetMapping("/activities")
- @ApiOperation(value = "活跃用户", notes = "活跃用户", position = 1)
+ @ApiOperation(value = "活跃用户", notes = "活跃用户")
public R activities() {
List