diff --git a/README.md b/README.md index 6646378..8b1a0e8 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@

Build Status - Coverage Status - Downloads + Coverage Status + Downloads

## SpringBlade微服务开发平台 diff --git a/blade-auth/pom.xml b/blade-auth/pom.xml index 275ceb4..5852d2f 100644 --- a/blade-auth/pom.xml +++ b/blade-auth/pom.xml @@ -8,7 +8,7 @@ SpringBlade org.springblade - 2.3.2 + 2.3.3 blade-auth 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 511b825..0da7db3 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 @@ -19,22 +19,19 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import lombok.AllArgsConstructor; -import org.springblade.core.launch.constant.TokenConstant; +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.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.utils.Func; -import org.springblade.system.user.entity.User; +import org.springblade.core.tool.utils.WebUtil; import org.springblade.system.user.entity.UserInfo; -import org.springblade.system.user.feign.IUserClient; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import java.util.HashMap; -import java.util.Map; - /** * 认证模块 * @@ -45,50 +42,27 @@ import java.util.Map; @Api(value = "用户授权认证", tags = "授权接口") public class AuthController { - private IUserClient client; - @PostMapping("token") @ApiOperation(value = "获取认证token", notes = "传入租户编号:tenantCode,账号:account,密码:password") - public R token(@ApiParam(value = "租户编号", required = true) @RequestParam(defaultValue = "000000", required = false) String tenantCode, - @ApiParam(value = "账号", required = true) @RequestParam String account, - @ApiParam(value = "密码", required = true) @RequestParam String password) { + public R token(@ApiParam(value = "授权类型", required = true) @RequestParam(defaultValue = "password", required = false) String grantType, + @ApiParam(value = "刷新令牌") @RequestParam(required = false) String refreshToken, + @ApiParam(value = "租户编号", required = true) @RequestParam(defaultValue = "000000", required = false) String tenantCode, + @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); + + TokenParameter tokenParameter = new TokenParameter(); + tokenParameter.getArgs().set("tenantCode", tenantCode).set("account", account).set("password", password).set("grantType", grantType).set("refreshToken", refreshToken).set("userType", userType); + + ITokenGranter granter = TokenGranterBuilder.getGranter(grantType); + UserInfo userInfo = granter.grant(tokenParameter); + + if (userInfo == null || userInfo.getUser() == null) { + return R.fail(TokenUtil.USER_NOT_FOUND); } - R res = client.userInfo(tenantCode, account, DigestUtil.encrypt(password)); - - User user = res.getData().getUser(); - - //验证用户 - if (Func.isEmpty(user.getId())) { - return R.fail("用户名或密码不正确"); - } - - //设置jwt参数 - Map param = new HashMap<>(16); - param.put(TokenConstant.USER_ID, Func.toStr(user.getId())); - param.put(TokenConstant.ROLE_ID, user.getRoleId()); - param.put(TokenConstant.TENANT_CODE, user.getTenantCode()); - param.put(TokenConstant.ACCOUNT, user.getAccount()); - param.put(TokenConstant.USER_NAME, user.getRealName()); - param.put(TokenConstant.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(TokenConstant.BEARER); - //设置token过期时间 - authInfo.setExpiresIn(SecureUtil.getExpire()); - return R.data(authInfo); - + return R.data(TokenUtil.createAuthInfo(userInfo)); } } diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/ParamWrapper.java b/blade-auth/src/main/java/org/springblade/auth/enums/BladeUserEnum.java similarity index 56% rename from blade-service/blade-system/src/main/java/org/springblade/system/wrapper/ParamWrapper.java rename to blade-auth/src/main/java/org/springblade/auth/enums/BladeUserEnum.java index 26d7e41..4d0d538 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/ParamWrapper.java +++ b/blade-auth/src/main/java/org/springblade/auth/enums/BladeUserEnum.java @@ -13,29 +13,32 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springblade.system.wrapper; +package org.springblade.auth.enums; import lombok.AllArgsConstructor; -import org.springblade.core.mp.support.BaseEntityWrapper; -import org.springblade.core.tool.utils.BeanUtil; -import org.springblade.system.entity.Param; -import org.springblade.system.feign.IDictClient; -import org.springblade.system.vo.ParamVO; +import lombok.Getter; /** - * 包装类,返回视图层所需的字段 + * 用户类型枚举 * * @author Chill */ +@Getter @AllArgsConstructor -public class ParamWrapper extends BaseEntityWrapper { +public enum BladeUserEnum { - private IDictClient dictClient; + /** + * web + */ + WEB("web", 1), - @Override - public ParamVO entityVO(Param param) { - ParamVO paramVO = BeanUtil.copy(param, ParamVO.class); - return paramVO; - } + /** + * app + */ + APP("app", 2), + ; + + final String name; + final int category; } diff --git a/blade-gateway/src/main/java/org/springblade/gateway/config/RateLimiterConfiguration.java b/blade-auth/src/main/java/org/springblade/auth/granter/ITokenGranter.java similarity index 56% rename from blade-gateway/src/main/java/org/springblade/gateway/config/RateLimiterConfiguration.java rename to blade-auth/src/main/java/org/springblade/auth/granter/ITokenGranter.java index 420367f..b2ec731 100644 --- a/blade-gateway/src/main/java/org/springblade/gateway/config/RateLimiterConfiguration.java +++ b/blade-auth/src/main/java/org/springblade/auth/granter/ITokenGranter.java @@ -13,25 +13,24 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +package org.springblade.auth.granter; -package org.springblade.gateway.config; -import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import reactor.core.publisher.Mono; +import org.springblade.system.user.entity.UserInfo; /** - * 路由限流配置 + * 授权认证统一接口. * * @author Chill */ -@Configuration -public class RateLimiterConfiguration { +public interface ITokenGranter { - @Bean(value = "remoteAddrKeyResolver") - public KeyResolver remoteAddrKeyResolver() { - return exchange -> Mono.just(exchange.getRequest().getRemoteAddress().getAddress().getHostAddress()); - } + /** + * 获取用户信息 + * + * @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 0000000..4b398dd --- /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 + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springblade.auth.granter; + +import lombok.AllArgsConstructor; +import org.springblade.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 tenantCode = tokenParameter.getArgs().getStr("tenantCode"); + 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(tenantCode, account, DigestUtil.encrypt(password)); + } else if (userType.equals(BladeUserEnum.APP.getName())) { + result = userClient.userInfo(tenantCode, account, DigestUtil.encrypt(password)); + } else { + result = userClient.userInfo(tenantCode, 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 0000000..95fd95f --- /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 + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springblade.auth.granter; + +import 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 0000000..5f11660 --- /dev/null +++ b/blade-auth/src/main/java/org/springblade/auth/granter/TokenGranterBuilder.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 + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springblade.auth.granter; + +import lombok.AllArgsConstructor; +import org.springblade.core.secure.exception.SecureException; +import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.SpringUtil; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * TokenGranterBuilder + * + * @author Chill + */ +@AllArgsConstructor +public class TokenGranterBuilder { + + /** + * TokenGranter缓存池 + */ + private static Map granterPool = new ConcurrentHashMap<>(); + + static { + granterPool.put(PasswordTokenGranter.GRANT_TYPE, SpringUtil.getBean(PasswordTokenGranter.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 0000000..368c83e --- /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 + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springblade.auth.granter; + +import lombok.Data; +import org.springblade.core.tool.support.Kv; + +/** + * TokenParameter + * + * @author Chill + */ +@Data +public class TokenParameter { + + private Kv args = Kv.init(); + +} diff --git a/blade-auth/src/main/java/org/springblade/auth/utils/TokenUtil.java b/blade-auth/src/main/java/org/springblade/auth/utils/TokenUtil.java new file mode 100644 index 0000000..d2d6dc9 --- /dev/null +++ b/blade-auth/src/main/java/org/springblade/auth/utils/TokenUtil.java @@ -0,0 +1,92 @@ +/** + * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springblade.auth.utils; + +import org.springblade.core.launch.constant.TokenConstant; +import org.springblade.core.secure.AuthInfo; +import org.springblade.core.secure.TokenInfo; +import org.springblade.core.secure.utils.SecureUtil; +import org.springblade.core.tool.utils.Func; +import org.springblade.system.user.entity.User; +import org.springblade.system.user.entity.UserInfo; + +import java.util.HashMap; +import java.util.Map; + +/** + * 认证工具类 + * + * @author Chill + */ +public class TokenUtil { + + public final static String TENANT_HEADER_KEY = "Tenant-Code"; + public final static String DEFAULT_TENANT_ID = "000000"; + public final static String USER_TYPE_HEADER_KEY = "User-Type"; + public final static String DEFAULT_USER_TYPE = "web"; + public final static String USER_NOT_FOUND = "用户名或密码错误"; + public final static String HEADER_KEY = "Authorization"; + public final static String HEADER_PREFIX = "Basic "; + public final static String DEFAULT_AVATAR = "https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png"; + + /** + * 创建认证token + * + * @param userInfo 用户信息 + * @return token + */ + public static AuthInfo createAuthInfo(UserInfo userInfo) { + User user = userInfo.getUser(); + + //设置jwt参数 + Map param = new HashMap<>(16); + param.put(TokenConstant.TOKEN_TYPE, TokenConstant.ACCESS_TOKEN); + param.put(TokenConstant.TENANT_CODE, user.getTenantCode()); + param.put(TokenConstant.USER_ID, Func.toStr(user.getId())); + param.put(TokenConstant.ROLE_ID, user.getRoleId()); + param.put(TokenConstant.ACCOUNT, user.getAccount()); + param.put(TokenConstant.USER_NAME, user.getAccount()); + param.put(TokenConstant.ROLE_NAME, Func.join(userInfo.getRoles())); + + TokenInfo accessToken = SecureUtil.createJWT(param, "audience", "issuser", TokenConstant.ACCESS_TOKEN); + AuthInfo authInfo = new AuthInfo(); + authInfo.setAccount(user.getAccount()); + authInfo.setUserName(user.getRealName()); + authInfo.setAuthority(Func.join(userInfo.getRoles())); + authInfo.setAccessToken(accessToken.getToken()); + authInfo.setExpiresIn(accessToken.getExpire()); + authInfo.setRefreshToken(createRefreshToken(userInfo).getToken()); + authInfo.setTokenType(TokenConstant.BEARER); + authInfo.setLicense(TokenConstant.LICENSE_NAME); + + return authInfo; + } + + /** + * 创建refreshToken + * + * @param userInfo 用户信息 + * @return refreshToken + */ + private static TokenInfo createRefreshToken(UserInfo userInfo) { + User user = userInfo.getUser(); + Map param = new HashMap<>(16); + param.put(TokenConstant.TOKEN_TYPE, TokenConstant.REFRESH_TOKEN); + param.put(TokenConstant.USER_ID, Func.toStr(user.getId())); + return SecureUtil.createJWT(param, "audience", "issuser", TokenConstant.REFRESH_TOKEN); + } + +} diff --git a/blade-common/pom.xml b/blade-common/pom.xml index b04bddb..6db6af4 100644 --- a/blade-common/pom.xml +++ b/blade-common/pom.xml @@ -5,7 +5,7 @@ SpringBlade org.springblade - 2.3.2 + 2.3.3 4.0.0 diff --git a/blade-common/src/main/java/org/springblade/common/cache/CacheNames.java b/blade-common/src/main/java/org/springblade/common/cache/CacheNames.java index 53bd7cf..818c6ce 100644 --- a/blade-common/src/main/java/org/springblade/common/cache/CacheNames.java +++ b/blade-common/src/main/java/org/springblade/common/cache/CacheNames.java @@ -22,9 +22,9 @@ package org.springblade.common.cache; */ public interface CacheNames { - String NOTICE_ONE = "NOTICE_ONE"; + String NOTICE_ONE = "notice:one"; - String DICT_VALUE = "DICT_VALUE"; - String DICT_LIST = "DICT_LIST"; + String DICT_VALUE = "dict:value"; + String DICT_LIST = "dict:list"; } diff --git a/blade-gateway/pom.xml b/blade-gateway/pom.xml index 0463a8c..34aaf60 100644 --- a/blade-gateway/pom.xml +++ b/blade-gateway/pom.xml @@ -5,7 +5,7 @@ SpringBlade org.springblade - 2.3.2 + 2.3.3 4.0.0 diff --git a/blade-gateway/src/main/java/org/springblade/gateway/config/RouterFunctionConfiguration.java b/blade-gateway/src/main/java/org/springblade/gateway/config/RouterFunctionConfiguration.java index 86a9255..e365667 100644 --- a/blade-gateway/src/main/java/org/springblade/gateway/config/RouterFunctionConfiguration.java +++ b/blade-gateway/src/main/java/org/springblade/gateway/config/RouterFunctionConfiguration.java @@ -18,22 +18,17 @@ package org.springblade.gateway.config; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springblade.gateway.handler.*; +import org.springblade.gateway.handler.SwaggerResourceHandler; +import org.springblade.gateway.props.RouteProperties; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; -import org.springframework.http.server.reactive.ServerHttpRequest; -import org.springframework.http.server.reactive.ServerHttpResponse; -import org.springframework.web.cors.reactive.CorsUtils; import org.springframework.web.filter.reactive.HiddenHttpMethodFilter; import org.springframework.web.reactive.function.server.RequestPredicates; import org.springframework.web.reactive.function.server.RouterFunction; import org.springframework.web.reactive.function.server.RouterFunctions; import org.springframework.web.server.ServerWebExchange; -import org.springframework.web.server.WebFilter; import org.springframework.web.server.WebFilterChain; import reactor.core.publisher.Mono; @@ -45,55 +40,15 @@ import reactor.core.publisher.Mono; @Slf4j @Configuration @AllArgsConstructor +@EnableConfigurationProperties(RouteProperties.class) public class RouterFunctionConfiguration { - /** - * 这里为支持的请求头,如果有自定义的header字段请自己添加 - */ - private static final String ALLOWED_HEADERS = "x-requested-with, blade-auth, Content-Type, Authorization, credential, X-XSRF-TOKEN, token, username, client"; - private static final String ALLOWED_METHODS = "*"; - private static final String ALLOWED_ORIGIN = "*"; - private static final String ALLOWED_EXPOSE = "*"; - private static final String MAX_AGE = "18000L"; - - private final HystrixFallbackHandler hystrixFallbackHandler; private final SwaggerResourceHandler swaggerResourceHandler; - private final SwaggerSecurityHandler swaggerSecurityHandler; - private final SwaggerUiHandler swaggerUiHandler; - - @Bean - public WebFilter corsFilter() { - return (ServerWebExchange ctx, WebFilterChain chain) -> { - ServerHttpRequest request = ctx.getRequest(); - if (CorsUtils.isCorsRequest(request)) { - ServerHttpResponse response = ctx.getResponse(); - HttpHeaders headers = response.getHeaders(); - headers.add("Access-Control-Allow-Headers", ALLOWED_HEADERS); - headers.add("Access-Control-Allow-Methods", ALLOWED_METHODS); - headers.add("Access-Control-Allow-Origin", ALLOWED_ORIGIN); - headers.add("Access-Control-Expose-Headers", ALLOWED_EXPOSE); - headers.add("Access-Control-Max-Age", MAX_AGE); - headers.add("Access-Control-Allow-Credentials", "true"); - if (request.getMethod() == HttpMethod.OPTIONS) { - response.setStatusCode(HttpStatus.OK); - return Mono.empty(); - } - } - return chain.filter(ctx); - }; - } @Bean public RouterFunction routerFunction() { - return RouterFunctions.route( - RequestPredicates.path("/fallback") - .and(RequestPredicates.accept(MediaType.TEXT_PLAIN)), hystrixFallbackHandler) - .andRoute(RequestPredicates.GET("/swagger-resources") - .and(RequestPredicates.accept(MediaType.ALL)), swaggerResourceHandler) - .andRoute(RequestPredicates.GET("/swagger-resources/configuration/ui") - .and(RequestPredicates.accept(MediaType.ALL)), swaggerUiHandler) - .andRoute(RequestPredicates.GET("/swagger-resources/configuration/security") - .and(RequestPredicates.accept(MediaType.ALL)), swaggerSecurityHandler); + return RouterFunctions.route(RequestPredicates.GET("/swagger-resources") + .and(RequestPredicates.accept(MediaType.ALL)), swaggerResourceHandler); } diff --git a/blade-gateway/src/main/java/org/springblade/gateway/filter/RequestGlobalFilter.java b/blade-gateway/src/main/java/org/springblade/gateway/filter/RequestGlobalFilter.java deleted file mode 100644 index b3af9d9..0000000 --- a/blade-gateway/src/main/java/org/springblade/gateway/filter/RequestGlobalFilter.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.springblade.gateway.filter; - -import org.springframework.cloud.gateway.filter.GatewayFilterChain; -import org.springframework.cloud.gateway.filter.GlobalFilter; -import org.springframework.core.Ordered; -import org.springframework.http.server.reactive.ServerHttpRequest; -import org.springframework.stereotype.Component; -import org.springframework.util.StringUtils; -import org.springframework.web.server.ServerWebExchange; -import reactor.core.publisher.Mono; - -import java.util.Arrays; -import java.util.stream.Collectors; - -import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR; -import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.addOriginalRequestUrl; - -/** - *

- * 全局拦截器,作用所有的微服务 - *

- * 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/HystrixFallbackHandler.java b/blade-gateway/src/main/java/org/springblade/gateway/handler/HystrixFallbackHandler.java deleted file mode 100644 index 63d0398..0000000 --- a/blade-gateway/src/main/java/org/springblade/gateway/handler/HystrixFallbackHandler.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springblade.gateway.handler; - -import lombok.extern.slf4j.Slf4j; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.stereotype.Component; -import org.springframework.web.reactive.function.BodyInserters; -import org.springframework.web.reactive.function.server.HandlerFunction; -import org.springframework.web.reactive.function.server.ServerRequest; -import org.springframework.web.reactive.function.server.ServerResponse; -import reactor.core.publisher.Mono; - -/** - * Hystrix 降级处理 - * - * @author lengleng - */ -@Slf4j -@Component -public class HystrixFallbackHandler implements HandlerFunction { - @Override - public Mono handle(ServerRequest serverRequest) { - log.error("网关执行请求:{}失败,hystrix服务降级处理", serverRequest.uri()); - return ServerResponse.status(HttpStatus.INTERNAL_SERVER_ERROR.value()) - .contentType(MediaType.TEXT_PLAIN).body(BodyInserters.fromObject("服务异常")); - } -} diff --git a/blade-gateway/src/main/java/org/springblade/gateway/handler/SwaggerSecurityHandler.java b/blade-gateway/src/main/java/org/springblade/gateway/handler/SwaggerSecurityHandler.java deleted file mode 100644 index 59a3039..0000000 --- a/blade-gateway/src/main/java/org/springblade/gateway/handler/SwaggerSecurityHandler.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springblade.gateway.handler; - -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.stereotype.Component; -import org.springframework.web.reactive.function.BodyInserters; -import org.springframework.web.reactive.function.server.HandlerFunction; -import org.springframework.web.reactive.function.server.ServerRequest; -import org.springframework.web.reactive.function.server.ServerResponse; -import reactor.core.publisher.Mono; -import springfox.documentation.swagger.web.SecurityConfiguration; -import springfox.documentation.swagger.web.SecurityConfigurationBuilder; - -import java.util.Optional; - -/** - * SwaggerSecurityHandler - * - * @author lengleng - */ -@Slf4j -@Component -public class SwaggerSecurityHandler implements HandlerFunction { - @Autowired(required = false) - private SecurityConfiguration securityConfiguration; - - /** - * Handle the given request. - * - * @param request the request to handler - * @return the response - */ - @Override - public Mono handle(ServerRequest request) { - return ServerResponse.status(HttpStatus.OK) - .contentType(MediaType.APPLICATION_JSON_UTF8) - .body(BodyInserters.fromObject( - Optional.ofNullable(securityConfiguration) - .orElse(SecurityConfigurationBuilder.builder().build()))); - } -} 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 deleted file mode 100644 index 0923b3a..0000000 --- a/blade-gateway/src/main/java/org/springblade/gateway/handler/SwaggerUiHandler.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springblade.gateway.handler; - -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.stereotype.Component; -import org.springframework.web.reactive.function.BodyInserters; -import org.springframework.web.reactive.function.server.HandlerFunction; -import org.springframework.web.reactive.function.server.ServerRequest; -import org.springframework.web.reactive.function.server.ServerResponse; -import reactor.core.publisher.Mono; -import springfox.documentation.swagger.web.UiConfiguration; -import springfox.documentation.swagger.web.UiConfigurationBuilder; - -import java.util.Optional; - -/** - * SwaggerUiHandler - * - * @author lengleng - */ -@Slf4j -@Component -public class SwaggerUiHandler implements HandlerFunction { - @Autowired(required = false) - private UiConfiguration uiConfiguration; - - /** - * Handle the given request. - * - * @param request the request to handler - * @return the response - */ - @Override - public Mono handle(ServerRequest request) { - return ServerResponse.status(HttpStatus.OK) - .contentType(MediaType.APPLICATION_JSON_UTF8) - .body(BodyInserters.fromObject( - Optional.ofNullable(uiConfiguration) - .orElse(UiConfigurationBuilder.builder().build()))); - } -} 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 0000000..9b7aa5d --- /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 + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springblade.gateway.props; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.cloud.context.config.annotation.RefreshScope; + +import java.util.ArrayList; +import java.util.List; + +/** + * 路由配置类 + * + * @author Chill + */ +@Data +@RefreshScope +@ConfigurationProperties("blade.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 0000000..a279a40 --- /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 + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springblade.gateway.props; + +import lombok.Data; +import org.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/SwaggerProvider.java b/blade-gateway/src/main/java/org/springblade/gateway/provider/SwaggerProvider.java index 052b521..c316f36 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/resources/bootstrap.yml b/blade-gateway/src/main/resources/bootstrap.yml index c7f53a9..b3a18ab 100644 --- a/blade-gateway/src/main/resources/bootstrap.yml +++ b/blade-gateway/src/main/resources/bootstrap.yml @@ -1,42 +1,9 @@ server: port: 80 -# 需要配置的服务名 -blade: - service: - blade-auth: blade-auth - blade-desk: blade-desk - blade-system: blade-system - spring: cloud: gateway: - routes: - # 认证中心 - - id: ${blade.service.blade-auth} - uri: lb://${blade.service.blade-auth} - predicates: - - Path=/${blade.service.blade-auth}/** - filters: - - name: RequestRateLimiter - args: - # 使用SpEL按名称引用bean - key-resolver: '#{@remoteAddrKeyResolver}' - # 允许用户每秒处理多少个请求 - redis-rate-limiter.replenishRate: 10 - # 允许在一秒钟内完成的最大请求数 - redis-rate-limiter.burstCapacity: 20 - - StripPrefix=1 - # 首页模块 - - id: ${blade.service.blade-desk} - uri: lb://${blade.service.blade-desk} - predicates: - - Path=/${blade.service.blade-desk}/** - # 系统模块 - - id: ${blade.service.blade-system} - uri: lb://${blade.service.blade-system} - predicates: - - Path=/${blade.service.blade-system}/** discovery: locator: enabled: true @@ -44,4 +11,15 @@ spring: retry: enabled: true +# 聚合文档配置 +blade: + document: + resources: + - name: 授权模块 + location: /blade-auth + - name: 工作台模块 + location: /blade-desk + - name: 系统模块 + location: /blade-system + diff --git a/blade-ops/blade-admin/pom.xml b/blade-ops/blade-admin/pom.xml index 7a34fc7..c10ae09 100644 --- a/blade-ops/blade-admin/pom.xml +++ b/blade-ops/blade-admin/pom.xml @@ -5,7 +5,7 @@ blade-ops org.springblade - 2.3.2 + 2.3.3 4.0.0 diff --git a/blade-ops/blade-develop/pom.xml b/blade-ops/blade-develop/pom.xml index 663a3d0..4ed2068 100644 --- a/blade-ops/blade-develop/pom.xml +++ b/blade-ops/blade-develop/pom.xml @@ -6,7 +6,7 @@ org.springblade blade-ops - 2.3.2 + 2.3.3 4.0.0 diff --git a/blade-ops/blade-develop/src/main/java/org/springblade/develop/controller/CodeController.java b/blade-ops/blade-develop/src/main/java/org/springblade/develop/controller/CodeController.java index d9973ff..9eac77a 100644 --- a/blade-ops/blade-develop/src/main/java/org/springblade/develop/controller/CodeController.java +++ b/blade-ops/blade-develop/src/main/java/org/springblade/develop/controller/CodeController.java @@ -50,7 +50,7 @@ public class CodeController extends BladeController { * 详情 */ @GetMapping("/detail") - @ApiOperation(value = "详情", notes = "传入code", position = 1) + @ApiOperation(value = "详情", notes = "传入code") public R detail(Code code) { Code detail = codeService.getOne(Condition.getQueryWrapper(code)); return R.data(detail); @@ -65,7 +65,7 @@ public class CodeController extends BladeController { @ApiImplicitParam(name = "tableName", value = "表名", paramType = "query", dataType = "string"), @ApiImplicitParam(name = "modelName", value = "实体名", paramType = "query", dataType = "string") }) - @ApiOperation(value = "分页", notes = "传入code", position = 2) + @ApiOperation(value = "分页", notes = "传入code") public R> list(@ApiIgnore @RequestParam Map code, Query query) { IPage pages = codeService.page(Condition.getPage(query), Condition.getQueryWrapper(code, Code.class)); return R.data(pages); @@ -75,7 +75,7 @@ public class CodeController extends BladeController { * 新增或修改 */ @PostMapping("/submit") - @ApiOperation(value = "新增或修改", notes = "传入code", position = 6) + @ApiOperation(value = "新增或修改", notes = "传入code") public R submit(@Valid @RequestBody Code code) { return R.status(codeService.saveOrUpdate(code)); } @@ -85,7 +85,7 @@ public class CodeController extends BladeController { * 删除 */ @PostMapping("/remove") - @ApiOperation(value = "删除", notes = "传入ids", position = 7) + @ApiOperation(value = "删除", notes = "传入ids") public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { return R.status(codeService.removeByIds(Func.toIntList(ids))); } @@ -94,7 +94,7 @@ public class CodeController extends BladeController { * 代码生成 */ @PostMapping("/gen-code") - @ApiOperation(value = "代码生成", notes = "传入ids", position = 8) + @ApiOperation(value = "代码生成", notes = "传入ids") public R genCode(@ApiParam(value = "主键集合", required = true) @RequestParam String ids, @RequestParam(defaultValue = "sword") String system) { Collection codes = codeService.listByIds(Func.toIntList(ids)); codes.forEach(code -> { diff --git a/blade-ops/blade-develop/src/main/resources/templates/controller.java.vm b/blade-ops/blade-develop/src/main/resources/templates/controller.java.vm new file mode 100644 index 0000000..95ba868 --- /dev/null +++ b/blade-ops/blade-develop/src/main/resources/templates/controller.java.vm @@ -0,0 +1,154 @@ +/** + * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package $!{package.Controller}; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiOperationSupport; +import io.swagger.annotations.ApiParam; +import lombok.AllArgsConstructor; +import javax.validation.Valid; + +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; +import org.springframework.web.bind.annotation.*; +#if($!{superEntityClass}) +import org.springframework.web.bind.annotation.RequestParam; +#end +import com.baomidou.mybatisplus.core.metadata.IPage; +import $!{package.Entity}.$!{entity}; +#set($voPackage=$package.Entity.replace("entity","vo")) +import $!{voPackage}.$!{entity}VO; +#set($wrapperPackage=$package.Entity.replace("entity","wrapper")) +import $!{wrapperPackage}.$!{entity}Wrapper; +import $!{package.Service}.$!{table.serviceName}; +#if($!{superControllerClassPackage}) +import $!{superControllerClassPackage}; +#end +#if(!$!{superEntityClass}) +#end +import java.util.List; + +/** + * $!{table.comment} 控制器 + * + * @author $!{author} + * @since $!{date} + */ +@RestController +@AllArgsConstructor +@RequestMapping("#if($!{package.ModuleName})/$!{package.ModuleName}#end/$!{cfg.entityKey}") +@Api(value = "$!{table.comment}", tags = "$!{table.comment}接口") +#if($!{superControllerClass}) +public class $!{table.controllerName} extends $!{superControllerClass} { +#else +public class $!{table.controllerName} { +#end + + private $!{table.serviceName} $!{table.entityPath}Service; + + /** + * 详情 + */ + @GetMapping("/detail") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "详情", notes = "传入$!{table.entityPath}") + public R<$!{entity}VO> detail($!{entity} $!{table.entityPath}) { + $!{entity} detail = $!{table.entityPath}Service.getOne(Condition.getQueryWrapper($!{table.entityPath})); + return R.data($!{entity}Wrapper.build().entityVO(detail)); + } + + /** + * 分页 $!{table.comment} + */ + @GetMapping("/list") + @ApiOperationSupport(order = 2) + @ApiOperation(value = "分页", notes = "传入$!{table.entityPath}") + public R> list($!{entity} $!{table.entityPath}, Query query) { + IPage<$!{entity}> pages = $!{table.entityPath}Service.page(Condition.getPage(query), Condition.getQueryWrapper($!{table.entityPath})); + return R.data($!{entity}Wrapper.build().pageVO(pages)); + } + + /** + * 自定义分页 $!{table.comment} + */ + @GetMapping("/page") + @ApiOperationSupport(order = 3) + @ApiOperation(value = "分页", notes = "传入$!{table.entityPath}") + public R> page($!{entity}VO $!{table.entityPath}, Query query) { + IPage<$!{entity}VO> pages = $!{table.entityPath}Service.select$!{entity}Page(Condition.getPage(query), $!{table.entityPath}); + return R.data(pages); + } + + /** + * 新增 $!{table.comment} + */ + @PostMapping("/save") + @ApiOperationSupport(order = 4) + @ApiOperation(value = "新增", notes = "传入$!{table.entityPath}") + public R save(@Valid @RequestBody $!{entity} $!{table.entityPath}) { + return R.status($!{table.entityPath}Service.save($!{table.entityPath})); + } + + /** + * 修改 $!{table.comment} + */ + @PostMapping("/update") + @ApiOperationSupport(order = 5) + @ApiOperation(value = "修改", notes = "传入$!{table.entityPath}") + public R update(@Valid @RequestBody $!{entity} $!{table.entityPath}) { + return R.status($!{table.entityPath}Service.updateById($!{table.entityPath})); + } + + /** + * 新增或修改 $!{table.comment} + */ + @PostMapping("/submit") + @ApiOperationSupport(order = 6) + @ApiOperation(value = "新增或修改", notes = "传入$!{table.entityPath}") + public R submit(@Valid @RequestBody $!{entity} $!{table.entityPath}) { + return R.status($!{table.entityPath}Service.saveOrUpdate($!{table.entityPath})); + } + + #if($!{superEntityClass}) + + /** + * 删除 $!{table.comment} + */ + @PostMapping("/remove") + @ApiOperationSupport(order = 7) + @ApiOperation(value = "逻辑删除", notes = "传入ids") + public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { + return R.status($!{table.entityPath}Service.deleteLogic(Func.toIntList(ids))); + } + + #else + + /** + * 删除 $!{table.comment} + */ + @PostMapping("/remove") + @ApiOperationSupport(order = 7) + @ApiOperation(value = "删除", notes = "传入ids") + public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { + return R.status($!{table.entityPath}Service.removeByIds(Func.toIntList(ids))); + } + + #end + +} diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/RoleMenuWrapper.java b/blade-ops/blade-develop/src/main/resources/templates/wrapper.java.vm similarity index 53% rename from blade-service/blade-system/src/main/java/org/springblade/system/wrapper/RoleMenuWrapper.java rename to blade-ops/blade-develop/src/main/resources/templates/wrapper.java.vm index e87d78b..64a8b01 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/RoleMenuWrapper.java +++ b/blade-ops/blade-develop/src/main/resources/templates/wrapper.java.vm @@ -13,29 +13,33 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springblade.system.wrapper; +#set($wrapperPackage=$package.Entity.replace("entity","wrapper")) +package $!{wrapperPackage}; import lombok.AllArgsConstructor; import org.springblade.core.mp.support.BaseEntityWrapper; import org.springblade.core.tool.utils.BeanUtil; -import org.springblade.system.entity.RoleMenu; -import org.springblade.system.feign.IDictClient; -import org.springblade.system.vo.RoleMenuVO; +import $!{package.Entity}.$!{entity}; +#set($voPackage=$package.Entity.replace("entity","vo")) +import $!{voPackage}.$!{entity}VO; /** - * 包装类,返回视图层所需的字段 + * $!{table.comment}包装类,返回视图层所需的字段 * - * @author Chill + * @author $!{author} + * @since $!{date} */ -@AllArgsConstructor -public class RoleMenuWrapper extends BaseEntityWrapper { +public class $!{entity}Wrapper extends BaseEntityWrapper<$!{entity}, $!{entity}VO> { - private IDictClient dictClient; + public static $!{entity}Wrapper build() { + return new $!{entity}Wrapper(); + } @Override - public RoleMenuVO entityVO(RoleMenu roleMenu) { - RoleMenuVO roleMenuVO = BeanUtil.copy(roleMenu, RoleMenuVO.class); - return roleMenuVO; + public $!{entity}VO entityVO($!{entity} $!{table.entityPath}) { + $!{entity}VO $!{table.entityPath}VO = BeanUtil.copy($!{table.entityPath}, $!{entity}VO.class); + + return $!{table.entityPath}VO; } } diff --git a/blade-ops/blade-develop/src/test/resources/templates/controller.java.vm b/blade-ops/blade-develop/src/test/resources/templates/controller.java.vm new file mode 100644 index 0000000..95ba868 --- /dev/null +++ b/blade-ops/blade-develop/src/test/resources/templates/controller.java.vm @@ -0,0 +1,154 @@ +/** + * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package $!{package.Controller}; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiOperationSupport; +import io.swagger.annotations.ApiParam; +import lombok.AllArgsConstructor; +import javax.validation.Valid; + +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; +import org.springframework.web.bind.annotation.*; +#if($!{superEntityClass}) +import org.springframework.web.bind.annotation.RequestParam; +#end +import com.baomidou.mybatisplus.core.metadata.IPage; +import $!{package.Entity}.$!{entity}; +#set($voPackage=$package.Entity.replace("entity","vo")) +import $!{voPackage}.$!{entity}VO; +#set($wrapperPackage=$package.Entity.replace("entity","wrapper")) +import $!{wrapperPackage}.$!{entity}Wrapper; +import $!{package.Service}.$!{table.serviceName}; +#if($!{superControllerClassPackage}) +import $!{superControllerClassPackage}; +#end +#if(!$!{superEntityClass}) +#end +import java.util.List; + +/** + * $!{table.comment} 控制器 + * + * @author $!{author} + * @since $!{date} + */ +@RestController +@AllArgsConstructor +@RequestMapping("#if($!{package.ModuleName})/$!{package.ModuleName}#end/$!{cfg.entityKey}") +@Api(value = "$!{table.comment}", tags = "$!{table.comment}接口") +#if($!{superControllerClass}) +public class $!{table.controllerName} extends $!{superControllerClass} { +#else +public class $!{table.controllerName} { +#end + + private $!{table.serviceName} $!{table.entityPath}Service; + + /** + * 详情 + */ + @GetMapping("/detail") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "详情", notes = "传入$!{table.entityPath}") + public R<$!{entity}VO> detail($!{entity} $!{table.entityPath}) { + $!{entity} detail = $!{table.entityPath}Service.getOne(Condition.getQueryWrapper($!{table.entityPath})); + return R.data($!{entity}Wrapper.build().entityVO(detail)); + } + + /** + * 分页 $!{table.comment} + */ + @GetMapping("/list") + @ApiOperationSupport(order = 2) + @ApiOperation(value = "分页", notes = "传入$!{table.entityPath}") + public R> list($!{entity} $!{table.entityPath}, Query query) { + IPage<$!{entity}> pages = $!{table.entityPath}Service.page(Condition.getPage(query), Condition.getQueryWrapper($!{table.entityPath})); + return R.data($!{entity}Wrapper.build().pageVO(pages)); + } + + /** + * 自定义分页 $!{table.comment} + */ + @GetMapping("/page") + @ApiOperationSupport(order = 3) + @ApiOperation(value = "分页", notes = "传入$!{table.entityPath}") + public R> page($!{entity}VO $!{table.entityPath}, Query query) { + IPage<$!{entity}VO> pages = $!{table.entityPath}Service.select$!{entity}Page(Condition.getPage(query), $!{table.entityPath}); + return R.data(pages); + } + + /** + * 新增 $!{table.comment} + */ + @PostMapping("/save") + @ApiOperationSupport(order = 4) + @ApiOperation(value = "新增", notes = "传入$!{table.entityPath}") + public R save(@Valid @RequestBody $!{entity} $!{table.entityPath}) { + return R.status($!{table.entityPath}Service.save($!{table.entityPath})); + } + + /** + * 修改 $!{table.comment} + */ + @PostMapping("/update") + @ApiOperationSupport(order = 5) + @ApiOperation(value = "修改", notes = "传入$!{table.entityPath}") + public R update(@Valid @RequestBody $!{entity} $!{table.entityPath}) { + return R.status($!{table.entityPath}Service.updateById($!{table.entityPath})); + } + + /** + * 新增或修改 $!{table.comment} + */ + @PostMapping("/submit") + @ApiOperationSupport(order = 6) + @ApiOperation(value = "新增或修改", notes = "传入$!{table.entityPath}") + public R submit(@Valid @RequestBody $!{entity} $!{table.entityPath}) { + return R.status($!{table.entityPath}Service.saveOrUpdate($!{table.entityPath})); + } + + #if($!{superEntityClass}) + + /** + * 删除 $!{table.comment} + */ + @PostMapping("/remove") + @ApiOperationSupport(order = 7) + @ApiOperation(value = "逻辑删除", notes = "传入ids") + public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { + return R.status($!{table.entityPath}Service.deleteLogic(Func.toIntList(ids))); + } + + #else + + /** + * 删除 $!{table.comment} + */ + @PostMapping("/remove") + @ApiOperationSupport(order = 7) + @ApiOperation(value = "删除", notes = "传入ids") + public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { + return R.status($!{table.entityPath}Service.removeByIds(Func.toIntList(ids))); + } + + #end + +} diff --git a/blade-ops/blade-develop/src/test/resources/templates/wrapper.java.vm b/blade-ops/blade-develop/src/test/resources/templates/wrapper.java.vm new file mode 100644 index 0000000..64a8b01 --- /dev/null +++ b/blade-ops/blade-develop/src/test/resources/templates/wrapper.java.vm @@ -0,0 +1,45 @@ +/** + * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#set($wrapperPackage=$package.Entity.replace("entity","wrapper")) +package $!{wrapperPackage}; + +import lombok.AllArgsConstructor; +import org.springblade.core.mp.support.BaseEntityWrapper; +import org.springblade.core.tool.utils.BeanUtil; +import $!{package.Entity}.$!{entity}; +#set($voPackage=$package.Entity.replace("entity","vo")) +import $!{voPackage}.$!{entity}VO; + +/** + * $!{table.comment}包装类,返回视图层所需的字段 + * + * @author $!{author} + * @since $!{date} + */ +public class $!{entity}Wrapper extends BaseEntityWrapper<$!{entity}, $!{entity}VO> { + + public static $!{entity}Wrapper build() { + return new $!{entity}Wrapper(); + } + + @Override + public $!{entity}VO entityVO($!{entity} $!{table.entityPath}) { + $!{entity}VO $!{table.entityPath}VO = BeanUtil.copy($!{table.entityPath}, $!{entity}VO.class); + + return $!{table.entityPath}VO; + } + +} diff --git a/blade-ops/blade-resource/pom.xml b/blade-ops/blade-resource/pom.xml index 7589afe..134914b 100644 --- a/blade-ops/blade-resource/pom.xml +++ b/blade-ops/blade-resource/pom.xml @@ -5,7 +5,7 @@ blade-ops org.springblade - 2.3.2 + 2.3.3 4.0.0 diff --git a/blade-ops/pom.xml b/blade-ops/pom.xml index f04016f..53e805b 100644 --- a/blade-ops/pom.xml +++ b/blade-ops/pom.xml @@ -5,7 +5,7 @@ SpringBlade org.springblade - 2.3.2 + 2.3.3 4.0.0 diff --git a/blade-service-api/blade-desk-api/pom.xml b/blade-service-api/blade-desk-api/pom.xml index 4a67d25..63fa012 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-api org.springblade - 2.3.2 + 2.3.3 4.0.0 diff --git a/blade-service-api/blade-dict-api/pom.xml b/blade-service-api/blade-dict-api/pom.xml index de10b68..c3d7c67 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-api org.springblade - 2.3.2 + 2.3.3 4.0.0 diff --git a/blade-service-api/blade-system-api/pom.xml b/blade-service-api/blade-system-api/pom.xml index 74bbb5d..4fabf08 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-api org.springblade - 2.3.2 + 2.3.3 4.0.0 diff --git a/blade-service-api/blade-user-api/pom.xml b/blade-service-api/blade-user-api/pom.xml index 39666a6..62581ba 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-api org.springblade - 2.3.2 + 2.3.3 4.0.0 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 9214fc7..704c9b4 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 @@ -38,9 +38,18 @@ public interface IUserClient { /** * 获取用户信息 * - * @param tenantCode 租户编号 - * @param account 账号 - * @param password 密码 + * @param userId 用户id + * @return + */ + @GetMapping(API_PREFIX + "/user-info-by-id") + R userInfo(@RequestParam("userId") Long userId); + + /** + * 获取用户信息 + * + * @param tenantCode 租户编号 + * @param account 账号 + * @param password 密码 * @return */ @GetMapping(API_PREFIX + "/user-info") diff --git a/blade-service-api/pom.xml b/blade-service-api/pom.xml index a26bdaa..505cabe 100644 --- a/blade-service-api/pom.xml +++ b/blade-service-api/pom.xml @@ -5,13 +5,13 @@ SpringBlade org.springblade - 2.3.2 + 2.3.3 4.0.0 blade-service-api ${project.artifactId} - 2.3.2 + 2.3.3 pom SpringBlade 微服务API集合 diff --git a/blade-service/blade-desk/pom.xml b/blade-service/blade-desk/pom.xml index 76371f2..f5704ee 100644 --- a/blade-service/blade-desk/pom.xml +++ b/blade-service/blade-desk/pom.xml @@ -6,7 +6,7 @@ org.springblade blade-service - 2.3.2 + 2.3.3 4.0.0 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 cac1455..6f5b4e4 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> list = new ArrayList<>(); diff --git a/blade-service/blade-desk/src/main/java/org/springblade/desk/controller/NoticeController.java b/blade-service/blade-desk/src/main/java/org/springblade/desk/controller/NoticeController.java index 86d1cc5..a4c8d64 100644 --- a/blade-service/blade-desk/src/main/java/org/springblade/desk/controller/NoticeController.java +++ b/blade-service/blade-desk/src/main/java/org/springblade/desk/controller/NoticeController.java @@ -28,7 +28,6 @@ import org.springblade.desk.entity.Notice; import org.springblade.desk.service.INoticeService; import org.springblade.desk.vo.NoticeVO; import org.springblade.desk.wrapper.NoticeWrapper; -import org.springblade.system.feign.IDictClient; import org.springframework.web.bind.annotation.*; import springfox.documentation.annotations.ApiIgnore; @@ -51,17 +50,15 @@ public class NoticeController extends BladeController implements CacheNames { private INoticeService noticeService; - private IDictClient dictClient; - /** * 详情 */ @GetMapping("/detail") - @ApiOperation(value = "详情", notes = "传入notice", position = 2) + @ApiOperationSupport(order = 1) + @ApiOperation(value = "详情", notes = "传入notice") public R detail(Notice notice) { Notice detail = noticeService.getOne(Condition.getQueryWrapper(notice)); - NoticeWrapper noticeWrapper = new NoticeWrapper(dictClient); - return R.data(noticeWrapper.entityVO(detail)); + return R.data(NoticeWrapper.build().entityVO(detail)); } /** @@ -72,18 +69,19 @@ public class NoticeController extends BladeController implements CacheNames { @ApiImplicitParam(name = "category", value = "公告类型", paramType = "query", dataType = "integer"), @ApiImplicitParam(name = "title", value = "公告标题", paramType = "query", dataType = "string") }) - @ApiOperation(value = "分页", notes = "传入notice", position = 3) + @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)); - NoticeWrapper noticeWrapper = new NoticeWrapper(dictClient); - return R.data(noticeWrapper.pageVO(pages)); + return R.data(NoticeWrapper.build().pageVO(pages)); } /** * 新增 */ @PostMapping("/save") - @ApiOperation(value = "新增", notes = "传入notice", position = 4) + @ApiOperationSupport(order = 3) + @ApiOperation(value = "新增", notes = "传入notice") public R save(@RequestBody Notice notice) { return R.status(noticeService.save(notice)); } @@ -92,7 +90,8 @@ public class NoticeController extends BladeController implements CacheNames { * 修改 */ @PostMapping("/update") - @ApiOperation(value = "修改", notes = "传入notice", position = 5) + @ApiOperationSupport(order = 4) + @ApiOperation(value = "修改", notes = "传入notice") public R update(@RequestBody Notice notice) { return R.status(noticeService.updateById(notice)); } @@ -101,7 +100,8 @@ public class NoticeController extends BladeController implements CacheNames { * 新增或修改 */ @PostMapping("/submit") - @ApiOperation(value = "新增或修改", notes = "传入notice", position = 6) + @ApiOperationSupport(order = 5) + @ApiOperation(value = "新增或修改", notes = "传入notice") public R submit(@RequestBody Notice notice) { return R.status(noticeService.saveOrUpdate(notice)); } @@ -110,7 +110,8 @@ public class NoticeController extends BladeController implements CacheNames { * 删除 */ @PostMapping("/remove") - @ApiOperation(value = "逻辑删除", notes = "传入notice", position = 7) + @ApiOperationSupport(order = 6) + @ApiOperation(value = "逻辑删除", notes = "传入notice") public R remove(@ApiParam(value = "主键集合") @RequestParam String ids) { boolean temp = noticeService.deleteLogic(Func.toIntList(ids)); return R.status(temp); @@ -122,7 +123,8 @@ public class NoticeController extends BladeController implements CacheNames { * @return */ @GetMapping("/notices") - @ApiOperation(value = "消息", notes = "消息", position = 8) + @ApiOperationSupport(order = 7) + @ApiOperation(value = "消息", notes = "消息") public R notices() { List> list = new ArrayList<>(); Map map1 = new HashMap<>(16); @@ -182,7 +184,7 @@ public class NoticeController extends BladeController implements CacheNames { * @return */ @GetMapping("/my-notices") - @ApiOperation(value = "消息", notes = "消息", position = 9) + @ApiOperation(value = "消息", notes = "消息") public R myNotices() { List> list = new ArrayList<>(); Map map1 = new HashMap<>(16); diff --git a/blade-service/blade-desk/src/main/java/org/springblade/desk/wrapper/NoticeWrapper.java b/blade-service/blade-desk/src/main/java/org/springblade/desk/wrapper/NoticeWrapper.java index f3fb67e..70fe7f7 100644 --- a/blade-service/blade-desk/src/main/java/org/springblade/desk/wrapper/NoticeWrapper.java +++ b/blade-service/blade-desk/src/main/java/org/springblade/desk/wrapper/NoticeWrapper.java @@ -15,10 +15,10 @@ */ package org.springblade.desk.wrapper; -import lombok.AllArgsConstructor; import org.springblade.core.mp.support.BaseEntityWrapper; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.BeanUtil; +import org.springblade.core.tool.utils.SpringUtil; import org.springblade.desk.entity.Notice; import org.springblade.desk.vo.NoticeVO; import org.springblade.system.feign.IDictClient; @@ -28,10 +28,17 @@ import org.springblade.system.feign.IDictClient; * * @author Chill */ -@AllArgsConstructor public class NoticeWrapper extends BaseEntityWrapper { - private IDictClient dictClient; + private static IDictClient dictClient; + + static { + dictClient = SpringUtil.getBean(IDictClient.class); + } + + public static NoticeWrapper build() { + return new NoticeWrapper(); + } @Override public NoticeVO entityVO(Notice notice) { diff --git a/blade-service/blade-desk/src/test/java/org/springblade/desk/test/launcher/DemoTestLauncherServiceImpl.java b/blade-service/blade-desk/src/test/java/org/springblade/desk/test/launcher/DemoTestLauncherServiceImpl.java index 94b45c3..3ba4a5c 100644 --- a/blade-service/blade-desk/src/test/java/org/springblade/desk/test/launcher/DemoTestLauncherServiceImpl.java +++ b/blade-service/blade-desk/src/test/java/org/springblade/desk/test/launcher/DemoTestLauncherServiceImpl.java @@ -1,18 +1,17 @@ -/* - * 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) +/** + * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.springblade.desk.test.launcher; diff --git a/blade-service/blade-log/pom.xml b/blade-service/blade-log/pom.xml index 2e2613c..b9ed97e 100644 --- a/blade-service/blade-log/pom.xml +++ b/blade-service/blade-log/pom.xml @@ -5,7 +5,7 @@ blade-service org.springblade - 2.3.2 + 2.3.3 4.0.0 diff --git a/blade-service/blade-system/pom.xml b/blade-service/blade-system/pom.xml index 2ee4e87..5debe5c 100644 --- a/blade-service/blade-system/pom.xml +++ b/blade-service/blade-system/pom.xml @@ -5,7 +5,7 @@ blade-service org.springblade - 2.3.2 + 2.3.3 4.0.0 diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/controller/AuthClientController.java b/blade-service/blade-system/src/main/java/org/springblade/system/controller/AuthClientController.java index c1aa4e7..ec0fac5 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/controller/AuthClientController.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/controller/AuthClientController.java @@ -18,6 +18,7 @@ package org.springblade.system.controller; import com.baomidou.mybatisplus.core.metadata.IPage; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiOperationSupport; import io.swagger.annotations.ApiParam; import lombok.AllArgsConstructor; import org.springblade.core.boot.ctrl.BladeController; @@ -53,7 +54,8 @@ public class AuthClientController extends BladeController { * 详情 */ @GetMapping("/detail") - @ApiOperation(value = "详情", notes = "传入client", position = 1) + @ApiOperationSupport(order = 1) + @ApiOperation(value = "详情", notes = "传入client") public R detail(AuthClient authClient) { AuthClient detail = clientService.getOne(Condition.getQueryWrapper(authClient)); return R.data(detail); @@ -63,7 +65,8 @@ public class AuthClientController extends BladeController { * 分页 */ @GetMapping("/list") - @ApiOperation(value = "分页", notes = "传入client", position = 2) + @ApiOperationSupport(order = 2) + @ApiOperation(value = "分页", notes = "传入client") public R> list(AuthClient authClient, Query query) { IPage pages = clientService.page(Condition.getPage(query), Condition.getQueryWrapper(authClient)); return R.data(pages); @@ -73,7 +76,8 @@ public class AuthClientController extends BladeController { * 新增 */ @PostMapping("/save") - @ApiOperation(value = "新增", notes = "传入client", position = 4) + @ApiOperationSupport(order = 3) + @ApiOperation(value = "新增", notes = "传入client") public R save(@Valid @RequestBody AuthClient authClient) { return R.status(clientService.save(authClient)); } @@ -82,7 +86,8 @@ public class AuthClientController extends BladeController { * 修改 */ @PostMapping("/update") - @ApiOperation(value = "修改", notes = "传入client", position = 5) + @ApiOperationSupport(order = 4) + @ApiOperation(value = "修改", notes = "传入client") public R update(@Valid @RequestBody AuthClient authClient) { return R.status(clientService.updateById(authClient)); } @@ -91,7 +96,8 @@ public class AuthClientController extends BladeController { * 新增或修改 */ @PostMapping("/submit") - @ApiOperation(value = "新增或修改", notes = "传入client", position = 6) + @ApiOperationSupport(order = 5) + @ApiOperation(value = "新增或修改", notes = "传入client") public R submit(@Valid @RequestBody AuthClient authClient) { return R.status(clientService.saveOrUpdate(authClient)); } @@ -101,7 +107,8 @@ public class AuthClientController extends BladeController { * 删除 */ @PostMapping("/remove") - @ApiOperation(value = "逻辑删除", notes = "传入ids", position = 7) + @ApiOperationSupport(order = 6) + @ApiOperation(value = "逻辑删除", notes = "传入ids") public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { return R.status(clientService.deleteLogic(Func.toIntList(ids))); } diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/controller/DeptController.java b/blade-service/blade-system/src/main/java/org/springblade/system/controller/DeptController.java index 9de9759..6df8436 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/controller/DeptController.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/controller/DeptController.java @@ -53,11 +53,11 @@ public class DeptController extends BladeController { * 详情 */ @GetMapping("/detail") - @ApiOperation(value = "详情", notes = "传入dept", position = 1) + @ApiOperationSupport(order = 1) + @ApiOperation(value = "详情", notes = "传入dept") public R detail(Dept dept) { Dept detail = deptService.getOne(Condition.getQueryWrapper(dept)); - DeptWrapper deptWrapper = new DeptWrapper(deptService); - return R.data(deptWrapper.entityVO(detail)); + return R.data(DeptWrapper.build().entityVO(detail)); } /** @@ -68,12 +68,12 @@ public class DeptController extends BladeController { @ApiImplicitParam(name = "deptName", value = "部门名称", paramType = "query", dataType = "string"), @ApiImplicitParam(name = "fullName", value = "部门全称", paramType = "query", dataType = "string") }) - @ApiOperation(value = "列表", notes = "传入dept", position = 2) + @ApiOperationSupport(order = 2) + @ApiOperation(value = "列表", notes = "传入dept") public R> list(@ApiIgnore @RequestParam Map dept, BladeUser bladeUser) { QueryWrapper queryWrapper = Condition.getQueryWrapper(dept, Dept.class); List list = deptService.list((!bladeUser.getTenantCode().equals(BladeConstant.ADMIN_TENANT_CODE)) ? queryWrapper.lambda().eq(Dept::getTenantCode, bladeUser.getTenantCode()) : queryWrapper); - DeptWrapper deptWrapper = new DeptWrapper(); - return R.data(deptWrapper.listNodeVO(list)); + return R.data(DeptWrapper.build().listNodeVO(list)); } /** @@ -82,7 +82,8 @@ public class DeptController extends BladeController { * @return */ @GetMapping("/tree") - @ApiOperation(value = "树形结构", notes = "树形结构", position = 3) + @ApiOperationSupport(order = 3) + @ApiOperation(value = "树形结构", notes = "树形结构") public R> tree(String tenantCode, BladeUser bladeUser) { List tree = deptService.tree(Func.toStr(tenantCode, bladeUser.getTenantCode())); return R.data(tree); @@ -92,7 +93,8 @@ public class DeptController extends BladeController { * 新增或修改 */ @PostMapping("/submit") - @ApiOperation(value = "新增或修改", notes = "传入dept", position = 6) + @ApiOperationSupport(order = 4) + @ApiOperation(value = "新增或修改", notes = "传入dept") public R submit(@Valid @RequestBody Dept dept, BladeUser user) { if (Func.isEmpty(dept.getId())) { dept.setTenantCode(user.getTenantCode()); @@ -104,7 +106,8 @@ public class DeptController extends BladeController { * 删除 */ @PostMapping("/remove") - @ApiOperation(value = "删除", notes = "传入ids", position = 7) + @ApiOperationSupport(order = 5) + @ApiOperation(value = "删除", notes = "传入ids") public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { return R.status(deptService.removeByIds(Func.toIntList(ids))); } diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/controller/DictController.java b/blade-service/blade-system/src/main/java/org/springblade/system/controller/DictController.java index 2f89c39..88115d2 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/controller/DictController.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/controller/DictController.java @@ -54,11 +54,11 @@ public class DictController extends BladeController { * 详情 */ @GetMapping("/detail") - @ApiOperation(value = "详情", notes = "传入dict", position = 1) + @ApiOperationSupport(order = 1) + @ApiOperation(value = "详情", notes = "传入dict") public R detail(Dict dict) { Dict detail = dictService.getOne(Condition.getQueryWrapper(dict)); - DictWrapper dictWrapper = new DictWrapper(dictService); - return R.data(dictWrapper.entityVO(detail)); + return R.data(DictWrapper.build().entityVO(detail)); } /** @@ -69,12 +69,12 @@ public class DictController extends BladeController { @ApiImplicitParam(name = "code", value = "字典编号", paramType = "query", dataType = "string"), @ApiImplicitParam(name = "dictValue", value = "字典名称", paramType = "query", dataType = "string") }) - @ApiOperation(value = "列表", notes = "传入dict", position = 2) + @ApiOperationSupport(order = 2) + @ApiOperation(value = "列表", notes = "传入dict") public R> list(@ApiIgnore @RequestParam Map dict) { @SuppressWarnings("unchecked") List list = dictService.list(Condition.getQueryWrapper(dict, Dict.class).lambda().orderByAsc(Dict::getSort)); - DictWrapper dictWrapper = new DictWrapper(); - return R.data(dictWrapper.listNodeVO(list)); + return R.data(DictWrapper.build().listNodeVO(list)); } /** @@ -83,7 +83,8 @@ public class DictController extends BladeController { * @return */ @GetMapping("/tree") - @ApiOperation(value = "树形结构", notes = "树形结构", position = 3) + @ApiOperationSupport(order = 3) + @ApiOperation(value = "树形结构", notes = "树形结构") public R> tree() { List tree = dictService.tree(); return R.data(tree); @@ -93,7 +94,8 @@ public class DictController extends BladeController { * 新增或修改 */ @PostMapping("/submit") - @ApiOperation(value = "新增或修改", notes = "传入dict", position = 6) + @ApiOperationSupport(order = 4) + @ApiOperation(value = "新增或修改", notes = "传入dict") public R submit(@Valid @RequestBody Dict dict) { return R.status(dictService.submit(dict)); } @@ -103,8 +105,9 @@ public class DictController extends BladeController { * 删除 */ @PostMapping("/remove") - @CacheEvict(cacheNames = {DICT_LIST, DICT_VALUE}) - @ApiOperation(value = "删除", notes = "传入ids", position = 7) + @CacheEvict(cacheNames = {DICT_LIST, DICT_VALUE}, allEntries = true) + @ApiOperationSupport(order = 5) + @ApiOperation(value = "删除", notes = "传入ids") public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { return R.status(dictService.removeByIds(Func.toIntList(ids))); } @@ -115,7 +118,8 @@ public class DictController extends BladeController { * @return */ @GetMapping("/dictionary") - @ApiOperation(value = "获取字典", notes = "获取字典", position = 8) + @ApiOperationSupport(order = 6) + @ApiOperation(value = "获取字典", notes = "获取字典") public R> dictionary(String code) { List tree = dictService.getList(code); return R.data(tree); diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/controller/MenuController.java b/blade-service/blade-system/src/main/java/org/springblade/system/controller/MenuController.java index 334e7b4..7bd9b5b 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/controller/MenuController.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/controller/MenuController.java @@ -26,7 +26,6 @@ import org.springblade.core.tool.constant.RoleConstant; import org.springblade.core.tool.support.Kv; import org.springblade.core.tool.utils.Func; import org.springblade.system.entity.Menu; -import org.springblade.system.feign.IDictClient; import org.springblade.system.service.IMenuService; import org.springblade.system.vo.MenuVO; import org.springblade.system.wrapper.MenuWrapper; @@ -50,18 +49,16 @@ public class MenuController extends BladeController { private IMenuService menuService; - private IDictClient dictClient; - /** * 详情 */ @GetMapping("/detail") @PreAuth(RoleConstant.HAS_ROLE_ADMIN) - @ApiOperation(value = "详情", notes = "传入menu", position = 1) + @ApiOperationSupport(order = 1) + @ApiOperation(value = "详情", notes = "传入menu") public R detail(Menu menu) { Menu detail = menuService.getOne(Condition.getQueryWrapper(menu)); - MenuWrapper menuWrapper = new MenuWrapper(menuService, dictClient); - return R.data(menuWrapper.entityVO(detail)); + return R.data(MenuWrapper.build().entityVO(detail)); } /** @@ -73,12 +70,12 @@ public class MenuController extends BladeController { @ApiImplicitParam(name = "name", value = "菜单名称", paramType = "query", dataType = "string") }) @PreAuth(RoleConstant.HAS_ROLE_ADMIN) - @ApiOperation(value = "列表", notes = "传入menu", position = 2) + @ApiOperationSupport(order = 2) + @ApiOperation(value = "列表", notes = "传入menu") public R> list(@ApiIgnore @RequestParam Map menu) { @SuppressWarnings("unchecked") List

list = menuService.list(Condition.getQueryWrapper(menu, Menu.class).lambda().orderByAsc(Menu::getSort)); - MenuWrapper menuWrapper = new MenuWrapper(menuService, dictClient); - return R.data(menuWrapper.listNodeVO(list)); + return R.data(MenuWrapper.build().listNodeVO(list)); } /** @@ -86,7 +83,8 @@ public class MenuController extends BladeController { */ @PostMapping("/submit") @PreAuth(RoleConstant.HAS_ROLE_ADMIN) - @ApiOperation(value = "新增或修改", notes = "传入menu", position = 8) + @ApiOperationSupport(order = 3) + @ApiOperation(value = "新增或修改", notes = "传入menu") public R submit(@Valid @RequestBody Menu menu) { return R.status(menuService.saveOrUpdate(menu)); } @@ -97,7 +95,8 @@ public class MenuController extends BladeController { */ @PostMapping("/remove") @PreAuth(RoleConstant.HAS_ROLE_ADMIN) - @ApiOperation(value = "删除", notes = "传入ids", position = 9) + @ApiOperationSupport(order = 4) + @ApiOperation(value = "删除", notes = "传入ids") public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { return R.status(menuService.removeByIds(Func.toIntList(ids))); } @@ -106,7 +105,8 @@ public class MenuController extends BladeController { * 前端菜单数据 */ @GetMapping("/routes") - @ApiOperation(value = "前端菜单数据", notes = "前端菜单数据", position = 3) + @ApiOperationSupport(order = 5) + @ApiOperation(value = "前端菜单数据", notes = "前端菜单数据") public R> routes(BladeUser user) { List list = menuService.routes(user.getRoleId()); return R.data(list); @@ -116,7 +116,8 @@ public class MenuController extends BladeController { * 前端按钮数据 */ @GetMapping("/buttons") - @ApiOperation(value = "前端按钮数据", notes = "前端按钮数据", position = 4) + @ApiOperationSupport(order = 6) + @ApiOperation(value = "前端按钮数据", notes = "前端按钮数据") public R> buttons(BladeUser user) { List list = menuService.buttons(user.getRoleId()); return R.data(list); @@ -126,7 +127,8 @@ public class MenuController extends BladeController { * 获取菜单树形结构 */ @GetMapping("/tree") - @ApiOperation(value = "树形结构", notes = "树形结构", position = 5) + @ApiOperationSupport(order = 7) + @ApiOperation(value = "树形结构", notes = "树形结构") public R> tree() { List tree = menuService.tree(); return R.data(tree); @@ -136,7 +138,8 @@ public class MenuController extends BladeController { * 获取权限分配树形结构 */ @GetMapping("/grant-tree") - @ApiOperation(value = "权限分配树形结构", notes = "权限分配树形结构", position = 6) + @ApiOperationSupport(order = 8) + @ApiOperation(value = "权限分配树形结构", notes = "权限分配树形结构") public R> grantTree(BladeUser user) { return R.data(menuService.grantTree(user)); } @@ -145,7 +148,8 @@ public class MenuController extends BladeController { * 获取权限分配树形结构 */ @GetMapping("/role-tree-keys") - @ApiOperation(value = "角色所分配的树", notes = "角色所分配的树", position = 7) + @ApiOperationSupport(order = 9) + @ApiOperation(value = "角色所分配的树", notes = "角色所分配的树") public R> roleTreeKeys(String roleIds) { return R.data(menuService.roleTreeKeys(roleIds)); } @@ -154,7 +158,8 @@ public class MenuController extends BladeController { * 获取配置的角色权限 */ @GetMapping("auth-routes") - @ApiOperation(value = "菜单的角色权限", position = 8) + @ApiOperationSupport(order = 10) + @ApiOperation(value = "菜单的角色权限") public R> authRoutes(BladeUser user) { return R.data(menuService.authRoutes(user)); } diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/controller/ParamController.java b/blade-service/blade-system/src/main/java/org/springblade/system/controller/ParamController.java index cb5a0cc..88ab2c8 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/controller/ParamController.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/controller/ParamController.java @@ -24,10 +24,7 @@ import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; import org.springblade.system.entity.Param; -import org.springblade.system.feign.IDictClient; import org.springblade.system.service.IParamService; -import org.springblade.system.vo.ParamVO; -import org.springblade.system.wrapper.ParamWrapper; import org.springframework.web.bind.annotation.*; import springfox.documentation.annotations.ApiIgnore; @@ -47,17 +44,15 @@ public class ParamController extends BladeController { private IParamService paramService; - private IDictClient dictClient; - /** * 详情 */ @GetMapping("/detail") - @ApiOperation(value = "详情", notes = "传入param", position = 1) - public R detail(Param param) { + @ApiOperationSupport(order = 1) + @ApiOperation(value = "详情", notes = "传入param") + public R detail(Param param) { Param detail = paramService.getOne(Condition.getQueryWrapper(param)); - ParamWrapper paramWrapper = new ParamWrapper(dictClient); - return R.data(paramWrapper.entityVO(detail)); + return R.data(detail); } /** @@ -69,18 +64,19 @@ public class ParamController extends BladeController { @ApiImplicitParam(name = "paramKey", value = "参数键名", paramType = "query", dataType = "string"), @ApiImplicitParam(name = "paramValue", value = "参数键值", paramType = "query", dataType = "string") }) - @ApiOperation(value = "分页", notes = "传入param", position = 2) - public R> list(@ApiIgnore @RequestParam Map param, Query query) { + @ApiOperationSupport(order = 2) + @ApiOperation(value = "分页", notes = "传入param") + public R> list(@ApiIgnore @RequestParam Map param, Query query) { IPage pages = paramService.page(Condition.getPage(query), Condition.getQueryWrapper(param, Param.class)); - ParamWrapper paramWrapper = new ParamWrapper(dictClient); - return R.data(paramWrapper.pageVO(pages)); + return R.data(pages); } /** * 新增或修改 */ @PostMapping("/submit") - @ApiOperation(value = "新增或修改", notes = "传入param", position = 6) + @ApiOperationSupport(order = 3) + @ApiOperation(value = "新增或修改", notes = "传入param") public R submit(@Valid @RequestBody Param param) { return R.status(paramService.saveOrUpdate(param)); } @@ -90,7 +86,8 @@ public class ParamController extends BladeController { * 删除 */ @PostMapping("/remove") - @ApiOperation(value = "逻辑删除", notes = "传入ids", position = 7) + @ApiOperationSupport(order = 4) + @ApiOperation(value = "逻辑删除", notes = "传入ids") public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { return R.status(paramService.deleteLogic(Func.toIntList(ids))); } diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/controller/RoleController.java b/blade-service/blade-system/src/main/java/org/springblade/system/controller/RoleController.java index 33a1c0a..202d0f7 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/controller/RoleController.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/controller/RoleController.java @@ -53,11 +53,11 @@ public class RoleController extends BladeController { * 详情 */ @GetMapping("/detail") - @ApiOperation(value = "详情", notes = "传入role", position = 1) + @ApiOperationSupport(order = 1) + @ApiOperation(value = "详情", notes = "传入role") public R detail(Role role) { Role detail = roleService.getOne(Condition.getQueryWrapper(role)); - RoleWrapper roleWrapper = new RoleWrapper(roleService); - return R.data(roleWrapper.entityVO(detail)); + return R.data(RoleWrapper.build().entityVO(detail)); } /** @@ -68,19 +68,20 @@ public class RoleController extends BladeController { @ApiImplicitParam(name = "roleName", value = "参数名称", paramType = "query", dataType = "string"), @ApiImplicitParam(name = "roleAlias", value = "角色别名", paramType = "query", dataType = "string") }) - @ApiOperation(value = "列表", notes = "传入role", position = 2) + @ApiOperationSupport(order = 2) + @ApiOperation(value = "列表", notes = "传入role") public R> list(@ApiIgnore @RequestParam Map role, BladeUser bladeUser) { QueryWrapper queryWrapper = Condition.getQueryWrapper(role, Role.class); List list = roleService.list((!bladeUser.getTenantCode().equals(BladeConstant.ADMIN_TENANT_CODE)) ? queryWrapper.lambda().eq(Role::getTenantCode, bladeUser.getTenantCode()) : queryWrapper); - RoleWrapper roleWrapper = new RoleWrapper(roleService); - return R.data(roleWrapper.listNodeVO(list)); + return R.data(RoleWrapper.build().listNodeVO(list)); } /** * 获取角色树形结构 */ @GetMapping("/tree") - @ApiOperation(value = "树形结构", notes = "树形结构", position = 3) + @ApiOperationSupport(order = 3) + @ApiOperation(value = "树形结构", notes = "树形结构") public R> tree(String tenantCode, BladeUser bladeUser) { List tree = roleService.tree(Func.toStr(tenantCode, bladeUser.getTenantCode())); return R.data(tree); @@ -90,7 +91,8 @@ public class RoleController extends BladeController { * 新增或修改 */ @PostMapping("/submit") - @ApiOperation(value = "新增或修改", notes = "传入role", position = 6) + @ApiOperationSupport(order = 4) + @ApiOperation(value = "新增或修改", notes = "传入role") public R submit(@Valid @RequestBody Role role, BladeUser user) { if (Func.isEmpty(role.getId())) { role.setTenantCode(user.getTenantCode()); @@ -103,7 +105,8 @@ public class RoleController extends BladeController { * 删除 */ @PostMapping("/remove") - @ApiOperation(value = "删除", notes = "传入ids", position = 7) + @ApiOperationSupport(order = 5) + @ApiOperation(value = "删除", notes = "传入ids") public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { return R.status(roleService.removeByIds(Func.toIntList(ids))); } @@ -116,7 +119,8 @@ public class RoleController extends BladeController { * @return */ @PostMapping("/grant") - @ApiOperation(value = "权限设置", notes = "传入roleId集合以及menuId集合", position = 7) + @ApiOperationSupport(order = 6) + @ApiOperation(value = "权限设置", notes = "传入roleId集合以及menuId集合") public R grant(@ApiParam(value = "roleId集合", required = true) @RequestParam String roleIds, @ApiParam(value = "menuId集合", required = true) @RequestParam String menuIds) { boolean temp = roleService.grant(Func.toIntList(roleIds), Func.toIntList(menuIds)); diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/controller/TenantController.java b/blade-service/blade-system/src/main/java/org/springblade/system/controller/TenantController.java index 19a552a..8e6571f 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/controller/TenantController.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/controller/TenantController.java @@ -53,7 +53,7 @@ public class TenantController extends BladeController { * 详情 */ @GetMapping("/detail") - @ApiOperation(value = "详情", notes = "传入tenant", position = 1) + @ApiOperation(value = "详情", notes = "传入tenant") public R detail(Tenant tenant) { Tenant detail = tenantService.getOne(Condition.getQueryWrapper(tenant)); return R.data(detail); @@ -68,7 +68,7 @@ public class TenantController extends BladeController { @ApiImplicitParam(name = "tenantName", value = "角色别名", paramType = "query", dataType = "string"), @ApiImplicitParam(name = "contactNumber", value = "联系电话", paramType = "query", dataType = "string") }) - @ApiOperation(value = "分页", notes = "传入tenant", position = 2) + @ApiOperation(value = "分页", notes = "传入tenant") public R> list(@ApiIgnore @RequestParam Map tenant, Query query, BladeUser bladeUser) { QueryWrapper queryWrapper = Condition.getQueryWrapper(tenant, Tenant.class); IPage pages = tenantService.page(Condition.getPage(query), (!bladeUser.getTenantCode().equals(BladeConstant.ADMIN_TENANT_CODE)) ? queryWrapper.lambda().eq(Tenant::getTenantCode, bladeUser.getTenantCode()) : queryWrapper); @@ -79,7 +79,7 @@ public class TenantController extends BladeController { * 下拉数据源 */ @GetMapping("/select") - @ApiOperation(value = "下拉数据源", notes = "传入tenant", position = 3) + @ApiOperation(value = "下拉数据源", notes = "传入tenant") public R> select(Tenant tenant, BladeUser bladeUser) { QueryWrapper queryWrapper = Condition.getQueryWrapper(tenant); List list = tenantService.list((!bladeUser.getTenantCode().equals(BladeConstant.ADMIN_TENANT_CODE)) ? queryWrapper.lambda().eq(Tenant::getTenantCode, bladeUser.getTenantCode()) : queryWrapper); @@ -90,7 +90,7 @@ public class TenantController extends BladeController { * 自定义分页 */ @GetMapping("/page") - @ApiOperation(value = "分页", notes = "传入tenant", position = 4) + @ApiOperation(value = "分页", notes = "传入tenant") public R> page(Tenant tenant, Query query) { IPage pages = tenantService.selectTenantPage(Condition.getPage(query), tenant); return R.data(pages); @@ -100,7 +100,7 @@ public class TenantController extends BladeController { * 新增或修改 */ @PostMapping("/submit") - @ApiOperation(value = "新增或修改", notes = "传入tenant", position = 7) + @ApiOperation(value = "新增或修改", notes = "传入tenant") public R submit(@Valid @RequestBody Tenant tenant) { return R.status(tenantService.saveTenant(tenant)); } @@ -110,7 +110,7 @@ public class TenantController extends BladeController { * 删除 */ @PostMapping("/remove") - @ApiOperation(value = "逻辑删除", notes = "传入ids", position = 8) + @ApiOperation(value = "逻辑删除", notes = "传入ids") public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { return R.status(tenantService.deleteLogic(Func.toIntList(ids))); } diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DictServiceImpl.java b/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DictServiceImpl.java index d319c12..671b748 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DictServiceImpl.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DictServiceImpl.java @@ -67,7 +67,7 @@ public class DictServiceImpl extends ServiceImpl implements ID } @Override - @CacheEvict(cacheNames = {DICT_LIST, DICT_VALUE}) + @CacheEvict(cacheNames = {DICT_LIST, DICT_VALUE}, allEntries = true) public boolean submit(Dict dict) { LambdaQueryWrapper lqw = Wrappers.query().lambda().eq(Dict::getCode, dict.getCode()).eq(Dict::getDictKey, dict.getDictKey()); Integer cnt = baseMapper.selectCount((Func.isEmpty(dict.getId())) ? lqw : lqw.notIn(Dict::getId, dict.getId())); diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/DeptWrapper.java b/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/DeptWrapper.java index f386d3e..a393f43 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/DeptWrapper.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/DeptWrapper.java @@ -15,13 +15,13 @@ */ package org.springblade.system.wrapper; -import lombok.AllArgsConstructor; import org.springblade.common.constant.CommonConstant; import org.springblade.core.mp.support.BaseEntityWrapper; import org.springblade.core.tool.node.ForestNodeMerger; import org.springblade.core.tool.node.INode; import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.SpringUtil; import org.springblade.system.entity.Dept; import org.springblade.system.service.IDeptService; import org.springblade.system.vo.DeptVO; @@ -34,12 +34,16 @@ import java.util.stream.Collectors; * * @author Chill */ -@AllArgsConstructor public class DeptWrapper extends BaseEntityWrapper { - private IDeptService deptService; + private static IDeptService deptService; - public DeptWrapper() { + static { + deptService = SpringUtil.getBean(IDeptService.class); + } + + public static DeptWrapper build() { + return new DeptWrapper(); } @Override @@ -54,7 +58,6 @@ public class DeptWrapper extends BaseEntityWrapper { return deptVO; } - public List listNodeVO(List list) { List collect = list.stream().map(dept -> BeanUtil.copy(dept, DeptVO.class)).collect(Collectors.toList()); return ForestNodeMerger.merge(collect); diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/DictWrapper.java b/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/DictWrapper.java index 9db42e4..39a20c3 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/DictWrapper.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/DictWrapper.java @@ -15,13 +15,13 @@ */ package org.springblade.system.wrapper; -import lombok.AllArgsConstructor; import org.springblade.common.constant.CommonConstant; import org.springblade.core.mp.support.BaseEntityWrapper; import org.springblade.core.tool.node.ForestNodeMerger; import org.springblade.core.tool.node.INode; import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.SpringUtil; import org.springblade.system.entity.Dict; import org.springblade.system.service.IDictService; import org.springblade.system.vo.DictVO; @@ -34,12 +34,16 @@ import java.util.stream.Collectors; * * @author Chill */ -@AllArgsConstructor public class DictWrapper extends BaseEntityWrapper { - private IDictService dictService; + private static IDictService dictService; - public DictWrapper() { + static { + dictService = SpringUtil.getBean(IDictService.class); + } + + public static DictWrapper build() { + return new DictWrapper(); } @Override diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/MenuWrapper.java b/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/MenuWrapper.java index 75f4b21..1e4737c 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/MenuWrapper.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/MenuWrapper.java @@ -15,13 +15,13 @@ */ package org.springblade.system.wrapper; -import lombok.AllArgsConstructor; import org.springblade.common.constant.CommonConstant; import org.springblade.core.mp.support.BaseEntityWrapper; import org.springblade.core.tool.api.R; import org.springblade.core.tool.node.ForestNodeMerger; import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.SpringUtil; import org.springblade.system.entity.Menu; import org.springblade.system.feign.IDictClient; import org.springblade.system.service.IMenuService; @@ -35,14 +35,19 @@ import java.util.stream.Collectors; * * @author Chill */ -@AllArgsConstructor public class MenuWrapper extends BaseEntityWrapper { - private IMenuService menuService; + private static IMenuService menuService; - private IDictClient dictClient; + private static IDictClient dictClient; - public MenuWrapper() { + static { + menuService = SpringUtil.getBean(IMenuService.class); + dictClient = SpringUtil.getBean(IDictClient.class); + } + + public static MenuWrapper build() { + return new MenuWrapper(); } @Override diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/RoleWrapper.java b/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/RoleWrapper.java index c1ae009..b7bdeb9 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/RoleWrapper.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/RoleWrapper.java @@ -15,13 +15,13 @@ */ package org.springblade.system.wrapper; -import lombok.AllArgsConstructor; import org.springblade.common.constant.CommonConstant; import org.springblade.core.mp.support.BaseEntityWrapper; import org.springblade.core.tool.node.ForestNodeMerger; import org.springblade.core.tool.node.INode; import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.SpringUtil; import org.springblade.system.entity.Role; import org.springblade.system.service.IRoleService; import org.springblade.system.vo.RoleVO; @@ -34,12 +34,16 @@ import java.util.stream.Collectors; * * @author Chill */ -@AllArgsConstructor public class RoleWrapper extends BaseEntityWrapper { - private IRoleService roleService; + private static IRoleService roleService; - public RoleWrapper() { + static { + roleService = SpringUtil.getBean(IRoleService.class); + } + + public static RoleWrapper build() { + return new RoleWrapper(); } @Override @@ -54,7 +58,6 @@ public class RoleWrapper extends BaseEntityWrapper { return roleVO; } - public List listNodeVO(List list) { List collect = list.stream().map(this::entityVO).collect(Collectors.toList()); return ForestNodeMerger.merge(collect); diff --git a/blade-service/blade-user/pom.xml b/blade-service/blade-user/pom.xml index a8c58ca..b449182 100644 --- a/blade-service/blade-user/pom.xml +++ b/blade-service/blade-user/pom.xml @@ -5,7 +5,7 @@ blade-service org.springblade - 2.3.2 + 2.3.3 4.0.0 diff --git a/blade-service/blade-user/src/main/java/org/springblade/system/user/controller/UserController.java b/blade-service/blade-user/src/main/java/org/springblade/system/user/controller/UserController.java index fa01d56..c572194 100644 --- a/blade-service/blade-user/src/main/java/org/springblade/system/user/controller/UserController.java +++ b/blade-service/blade-user/src/main/java/org/springblade/system/user/controller/UserController.java @@ -18,10 +18,7 @@ package org.springblade.system.user.controller; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiImplicitParams; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; +import io.swagger.annotations.*; import lombok.AllArgsConstructor; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; @@ -29,7 +26,6 @@ import org.springblade.core.secure.BladeUser; import org.springblade.core.tool.api.R; import org.springblade.core.tool.constant.BladeConstant; import org.springblade.core.tool.utils.Func; -import org.springblade.system.feign.IDictClient; import org.springblade.system.user.entity.User; import org.springblade.system.user.service.IUserService; import org.springblade.system.user.vo.UserVO; @@ -52,17 +48,15 @@ public class UserController { private IUserService userService; - private IDictClient dictClient; - /** * 查询单条 */ - @ApiOperation(value = "查看详情", notes = "传入id", position = 1) + @ApiOperationSupport(order = 1) + @ApiOperation(value = "查看详情", notes = "传入id") @GetMapping("/detail") public R detail(User user) { User detail = userService.getOne(Condition.getQueryWrapper(user)); - UserWrapper userWrapper = new UserWrapper(userService, dictClient); - return R.data(userWrapper.entityVO(detail)); + return R.data(UserWrapper.build().entityVO(detail)); } /** @@ -73,19 +67,20 @@ public class UserController { @ApiImplicitParam(name = "account", value = "账号名", paramType = "query", dataType = "string"), @ApiImplicitParam(name = "realName", value = "姓名", paramType = "query", dataType = "string") }) - @ApiOperation(value = "列表", notes = "传入account和realName", position = 2) + @ApiOperationSupport(order = 2) + @ApiOperation(value = "列表", notes = "传入account和realName") public R> list(@ApiIgnore @RequestParam Map user, Query query, BladeUser bladeUser) { QueryWrapper queryWrapper = Condition.getQueryWrapper(user, User.class); IPage pages = userService.page(Condition.getPage(query), (!bladeUser.getTenantCode().equals(BladeConstant.ADMIN_TENANT_CODE)) ? queryWrapper.lambda().eq(User::getTenantCode, bladeUser.getTenantCode()) : queryWrapper); - UserWrapper userWrapper = new UserWrapper(userService, dictClient); - return R.data(userWrapper.pageVO(pages)); + return R.data(UserWrapper.build().pageVO(pages)); } /** * 新增或修改 */ @PostMapping("/submit") - @ApiOperation(value = "新增或修改", notes = "传入User", position = 3) + @ApiOperationSupport(order = 3) + @ApiOperation(value = "新增或修改", notes = "传入User") public R submit(@Valid @RequestBody User user) { return R.status(userService.submit(user)); } @@ -94,7 +89,8 @@ public class UserController { * 修改 */ @PostMapping("/update") - @ApiOperation(value = "修改", notes = "传入User", position = 3) + @ApiOperationSupport(order = 4) + @ApiOperation(value = "修改", notes = "传入User") public R update(@Valid @RequestBody User user) { return R.status(userService.updateById(user)); } @@ -103,7 +99,8 @@ public class UserController { * 删除 */ @PostMapping("/remove") - @ApiOperation(value = "删除", notes = "传入地基和", position = 4) + @ApiOperationSupport(order = 5) + @ApiOperation(value = "删除", notes = "传入地基和") public R remove(@RequestParam String ids) { return R.status(userService.deleteLogic(Func.toIntList(ids))); } @@ -117,7 +114,8 @@ public class UserController { * @return */ @PostMapping("/grant") - @ApiOperation(value = "权限设置", notes = "传入roleId集合以及menuId集合", position = 5) + @ApiOperationSupport(order = 6) + @ApiOperation(value = "权限设置", notes = "传入roleId集合以及menuId集合") public R grant(@ApiParam(value = "userId集合", required = true) @RequestParam String userIds, @ApiParam(value = "roleId集合", required = true) @RequestParam String roleIds) { boolean temp = userService.grant(userIds, roleIds); @@ -125,7 +123,8 @@ public class UserController { } @PostMapping("/reset-password") - @ApiOperation(value = "初始化密码", notes = "传入userId集合", position = 5) + @ApiOperationSupport(order = 7) + @ApiOperation(value = "初始化密码", notes = "传入userId集合") public R resetPassword(@ApiParam(value = "userId集合", required = true) @RequestParam String userIds) { boolean temp = userService.resetPassword(userIds); return R.status(temp); diff --git a/blade-service/blade-user/src/main/java/org/springblade/system/user/feign/UserClient.java b/blade-service/blade-user/src/main/java/org/springblade/system/user/feign/UserClient.java index 670adb7..1dc696f 100644 --- a/blade-service/blade-user/src/main/java/org/springblade/system/user/feign/UserClient.java +++ b/blade-service/blade-user/src/main/java/org/springblade/system/user/feign/UserClient.java @@ -17,6 +17,7 @@ package org.springblade.system.user.feign; import lombok.AllArgsConstructor; import org.springblade.core.tool.api.R; +import org.springblade.system.user.entity.User; import org.springblade.system.user.entity.UserInfo; import org.springblade.system.user.service.IUserService; import org.springframework.web.bind.annotation.GetMapping; @@ -31,7 +32,12 @@ import org.springframework.web.bind.annotation.RestController; @AllArgsConstructor public class UserClient implements IUserClient { - IUserService service; + private IUserService service; + + @Override + public R userInfo(Long userId) { + return R.data(service.userInfo(userId)); + } @Override @GetMapping(API_PREFIX + "/user-info") diff --git a/blade-service/blade-user/src/main/java/org/springblade/system/user/service/IUserService.java b/blade-service/blade-user/src/main/java/org/springblade/system/user/service/IUserService.java index 4e89455..6402ce4 100644 --- a/blade-service/blade-user/src/main/java/org/springblade/system/user/service/IUserService.java +++ b/blade-service/blade-user/src/main/java/org/springblade/system/user/service/IUserService.java @@ -32,6 +32,7 @@ public interface IUserService extends BaseService { /** * 新增或修改用户 + * * @param user * @return */ @@ -46,6 +47,14 @@ public interface IUserService extends BaseService { */ IPage selectUserPage(IPage page, User user); + /** + * 用户信息 + * + * @param userId + * @return + */ + UserInfo userInfo(Long userId); + /** * 用户信息 * diff --git a/blade-service/blade-user/src/main/java/org/springblade/system/user/service/impl/UserServiceImpl.java b/blade-service/blade-user/src/main/java/org/springblade/system/user/service/impl/UserServiceImpl.java index d795c86..15e64ee 100644 --- a/blade-service/blade-user/src/main/java/org/springblade/system/user/service/impl/UserServiceImpl.java +++ b/blade-service/blade-user/src/main/java/org/springblade/system/user/service/impl/UserServiceImpl.java @@ -57,6 +57,18 @@ public class UserServiceImpl extends BaseServiceImpl implement return page.setRecords(baseMapper.selectUserPage(page, user)); } + @Override + public UserInfo userInfo(Long userId) { + UserInfo userInfo = new UserInfo(); + User user = baseMapper.selectById(userId); + userInfo.setUser(user); + if (Func.isNotEmpty(user)) { + List roleAlias = baseMapper.getRoleAlias(Func.toStrArray(user.getRoleId())); + userInfo.setRoles(roleAlias); + } + return userInfo; + } + @Override public UserInfo userInfo(String tenantCode, String account, String password) { UserInfo userInfo = new UserInfo(); diff --git a/blade-service/blade-user/src/main/java/org/springblade/system/user/wrapper/UserWrapper.java b/blade-service/blade-user/src/main/java/org/springblade/system/user/wrapper/UserWrapper.java index 8049037..c1495e8 100644 --- a/blade-service/blade-user/src/main/java/org/springblade/system/user/wrapper/UserWrapper.java +++ b/blade-service/blade-user/src/main/java/org/springblade/system/user/wrapper/UserWrapper.java @@ -15,11 +15,11 @@ */ package org.springblade.system.user.wrapper; -import lombok.AllArgsConstructor; import org.springblade.core.mp.support.BaseEntityWrapper; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.SpringUtil; import org.springblade.system.feign.IDictClient; import org.springblade.system.user.entity.User; import org.springblade.system.user.service.IUserService; @@ -32,14 +32,19 @@ import java.util.List; * * @author Chill */ -@AllArgsConstructor public class UserWrapper extends BaseEntityWrapper { - private IUserService userService; + private static IUserService userService; - private IDictClient dictClient; + private static IDictClient dictClient; - public UserWrapper() { + static { + userService = SpringUtil.getBean(IUserService.class); + dictClient = SpringUtil.getBean(IDictClient.class); + } + + public static UserWrapper build() { + return new UserWrapper(); } @Override diff --git a/blade-service/pom.xml b/blade-service/pom.xml index aa03b95..60fa573 100644 --- a/blade-service/pom.xml +++ b/blade-service/pom.xml @@ -7,12 +7,12 @@ org.springblade SpringBlade - 2.3.2 + 2.3.3 blade-service ${project.artifactId} - 2.3.2 + 2.3.3 pom SpringBlade 微服务集合 diff --git a/doc/sql/blade-saber-mysql.sql b/doc/sql/blade-saber-mysql.sql index e7b7dd4..ce99318 100644 --- a/doc/sql/blade-saber-mysql.sql +++ b/doc/sql/blade-saber-mysql.sql @@ -5,13 +5,13 @@ Source Server Type : MySQL Source Server Version : 50723 Source Host : localhost:3306 - Source Schema : bladex + Source Schema : blade Target Server Type : MySQL Target Server Version : 50723 File Encoding : 65001 - Date: 25/03/2019 17:30:11 + Date: 05/07/2019 23:16:14 */ SET NAMES utf8mb4; @@ -165,10 +165,12 @@ CREATE TABLE `blade_log_error` ( `exception_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '异常名', `message` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '异常信息', `line_number` int(11) NULL DEFAULT NULL COMMENT '错误行数', + `remote_ip` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '操作IP地址', `method_class` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '方法类', `file_name` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '文件名', `method_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '方法名', `params` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '操作提交的数据', + `time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '执行时间', `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者', `create_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '创建时间', PRIMARY KEY (`id`) USING BTREE @@ -190,8 +192,12 @@ CREATE TABLE `blade_log_usual` ( `log_data` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '日志数据', `method` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '操作方式', `request_uri` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '请求URI', + `remote_ip` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '操作IP地址', + `method_class` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '方法类', + `method_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '方法名', `user_agent` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '用户代理', `params` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '操作提交的数据', + `time` datetime(0) NULL DEFAULT NULL COMMENT '执行时间', `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者', `create_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '创建时间', PRIMARY KEY (`id`) USING BTREE @@ -291,7 +297,7 @@ CREATE TABLE `blade_role` ( `role_alias` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '角色别名', `is_deleted` int(2) NULL DEFAULT 0 COMMENT '是否已删除', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci; +) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci; -- ---------------------------- -- Records of blade_role diff --git a/doc/sql/blade-sword-mysql.sql b/doc/sql/blade-sword-mysql.sql index 8093410..295e58c 100644 --- a/doc/sql/blade-sword-mysql.sql +++ b/doc/sql/blade-sword-mysql.sql @@ -5,13 +5,13 @@ Source Server Type : MySQL Source Server Version : 50723 Source Host : localhost:3306 - Source Schema : bladex + Source Schema : blade Target Server Type : MySQL Target Server Version : 50723 File Encoding : 65001 - Date: 24/03/2019 16:29:08 + Date: 05/07/2019 23:16:45 */ SET NAMES utf8mb4; @@ -165,10 +165,12 @@ CREATE TABLE `blade_log_error` ( `exception_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '异常名', `message` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '异常信息', `line_number` int(11) NULL DEFAULT NULL COMMENT '错误行数', + `remote_ip` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '操作IP地址', `method_class` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '方法类', `file_name` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '文件名', `method_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '方法名', `params` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '操作提交的数据', + `time` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '执行时间', `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者', `create_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '创建时间', PRIMARY KEY (`id`) USING BTREE @@ -190,8 +192,12 @@ CREATE TABLE `blade_log_usual` ( `log_data` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '日志数据', `method` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '操作方式', `request_uri` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '请求URI', + `remote_ip` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '操作IP地址', + `method_class` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '方法类', + `method_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '方法名', `user_agent` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '用户代理', `params` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '操作提交的数据', + `time` datetime(0) NULL DEFAULT NULL COMMENT '执行时间', `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者', `create_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '创建时间', PRIMARY KEY (`id`) USING BTREE @@ -291,7 +297,7 @@ CREATE TABLE `blade_role` ( `role_alias` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '角色别名', `is_deleted` int(2) NULL DEFAULT 0 COMMENT '是否已删除', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci; +) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci; -- ---------------------------- -- Records of blade_role diff --git a/doc/sql/blade-update-2.3.1.sql b/doc/sql/blade-update-2.3.1.sql deleted file mode 100644 index df744a1..0000000 --- a/doc/sql/blade-update-2.3.1.sql +++ /dev/null @@ -1,9 +0,0 @@ -ALTER TABLE `blade_log_error` - ADD COLUMN `remote_ip` varchar(255) NULL COMMENT '操作IP地址' AFTER `line_number`, - ADD COLUMN `time` varchar(64) NULL COMMENT '执行时间' AFTER `params`; - -ALTER TABLE `blade_log_usual` - ADD COLUMN `remote_ip` varchar(255) NULL COMMENT '操作IP地址' AFTER `request_uri`, - ADD COLUMN `method_class` varchar(255) NULL COMMENT '方法类' AFTER `remote_ip`, - ADD COLUMN `method_name` varchar(255) NULL COMMENT '方法名' AFTER `method_class`, - ADD COLUMN `time` datetime(0) NULL COMMENT '执行时间' AFTER `params`; diff --git a/pom.xml b/pom.xml index b2910d6..825de6f 100644 --- a/pom.xml +++ b/pom.xml @@ -5,27 +5,27 @@ org.springblade SpringBlade - 2.3.2 + 2.3.3 pom - 2.3.2 - 2.3.2 + 2.3.3 + 2.3.3 1.8 2.9.2 1.5.21 1.9.4 - 3.1.0 + 3.1.2 4.0.1 1.6.0 1.1.0 0.9.0.RELEASE - 2.1.4 + 2.1.5 - 2.1.5.RELEASE - Greenwich.SR1 - Cairo-SR7 + 2.1.6.RELEASE + Greenwich.SR2 + Cairo-SR8 10.211.55.5 diff --git a/script/docker/.env b/script/docker/.env index 883c556..7a0aa64 100644 --- a/script/docker/.env +++ b/script/docker/.env @@ -1,2 +1,2 @@ REGISTER=192.168.0.157/blade -TAG=2.3.2 +TAG=2.3.3