🎉 2.3.3.RELEASE

This commit is contained in:
smallchill 2019-07-06 21:33:30 +08:00
parent 30bb595fce
commit 447c3d5515
68 changed files with 1124 additions and 630 deletions

View File

@ -1,7 +1,7 @@
<p align="center">
<img src="https://img.shields.io/badge/license-Apache%202-blue.svg" alt="Build Status">
<img src="https://img.shields.io/badge/Spring%20Cloud-Greenwich.SR1-blue.svg" alt="Coverage Status">
<img src="https://img.shields.io/badge/Spring%20Boot-2.1.5.RELEASE-blue.svg" alt="Downloads">
<img src="https://img.shields.io/badge/Spring%20Cloud-Greenwich.SR2-blue.svg" alt="Coverage Status">
<img src="https://img.shields.io/badge/Spring%20Boot-2.1.6.RELEASE-blue.svg" alt="Downloads">
</p>
## SpringBlade微服务开发平台

View File

@ -8,7 +8,7 @@
<parent>
<artifactId>SpringBlade</artifactId>
<groupId>org.springblade</groupId>
<version>2.3.2</version>
<version>2.3.3</version>
</parent>
<artifactId>blade-auth</artifactId>

View File

@ -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<AuthInfo> 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<AuthInfo> 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<UserInfo> res = client.userInfo(tenantCode, account, DigestUtil.encrypt(password));
User user = res.getData().getUser();
//验证用户
if (Func.isEmpty(user.getId())) {
return R.fail("用户名或密码不正确");
}
//设置jwt参数
Map<String, String> 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));
}
}

View File

@ -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<Param, ParamVO> {
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;
}

View File

@ -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);
}

View File

@ -0,0 +1,63 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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<UserInfo> 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;
}
}

View File

@ -0,0 +1,58 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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<UserInfo> result = userClient.userInfo(Func.toLong(claims.get(TokenConstant.USER_ID)));
userInfo = result.isSuccess() ? result.getData() : null;
}
}
return userInfo;
}
}

View File

@ -0,0 +1,59 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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<String, ITokenGranter> 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;
}
}
}

View File

@ -0,0 +1,31 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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();
}

View File

@ -0,0 +1,92 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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<String, String> 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<String, String> 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);
}
}

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>SpringBlade</artifactId>
<groupId>org.springblade</groupId>
<version>2.3.2</version>
<version>2.3.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -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";
}

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>SpringBlade</artifactId>
<groupId>org.springblade</groupId>
<version>2.3.2</version>
<version>2.3.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -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);
}

View File

@ -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;
/**
* <p>
* 全局拦截器作用所有的微服务
* <p>
* 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<Void>} to indicate when request processing is complete
*/
@Override
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
// 1. 清洗请求头中from 参数
ServerHttpRequest request = exchange.getRequest().mutate()
.headers(httpHeaders -> httpHeaders.remove("X"))
.build();
// 2. 重写StripPrefix
addOriginalRequestUrl(exchange, request.getURI());
String rawPath = request.getURI().getRawPath();
String newPath = "/" + Arrays.stream(StringUtils.tokenizeToStringArray(rawPath, "/"))
.skip(1L).collect(Collectors.joining("/"));
ServerHttpRequest newRequest = request.mutate()
.path(newPath)
.build();
exchange.getAttributes().put(GATEWAY_REQUEST_URL_ATTR, newRequest.getURI());
return chain.filter(exchange.mutate().request(newRequest.mutate().build()).build());
}
@Override
public int getOrder() {
return -1000;
}
}

View File

@ -1,43 +0,0 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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<ServerResponse> {
@Override
public Mono<ServerResponse> handle(ServerRequest serverRequest) {
log.error("网关执行请求:{}失败,hystrix服务降级处理", serverRequest.uri());
return ServerResponse.status(HttpStatus.INTERNAL_SERVER_ERROR.value())
.contentType(MediaType.TEXT_PLAIN).body(BodyInserters.fromObject("服务异常"));
}
}

View File

@ -1,59 +0,0 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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<ServerResponse> {
@Autowired(required = false)
private SecurityConfiguration securityConfiguration;
/**
* Handle the given request.
*
* @param request the request to handler
* @return the response
*/
@Override
public Mono<ServerResponse> handle(ServerRequest request) {
return ServerResponse.status(HttpStatus.OK)
.contentType(MediaType.APPLICATION_JSON_UTF8)
.body(BodyInserters.fromObject(
Optional.ofNullable(securityConfiguration)
.orElse(SecurityConfigurationBuilder.builder().build())));
}
}

View File

@ -1,59 +0,0 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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<ServerResponse> {
@Autowired(required = false)
private UiConfiguration uiConfiguration;
/**
* Handle the given request.
*
* @param request the request to handler
* @return the response
*/
@Override
public Mono<ServerResponse> handle(ServerRequest request) {
return ServerResponse.status(HttpStatus.OK)
.contentType(MediaType.APPLICATION_JSON_UTF8)
.body(BodyInserters.fromObject(
Optional.ofNullable(uiConfiguration)
.orElse(UiConfigurationBuilder.builder().build())));
}
}

View File

@ -0,0 +1,37 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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<RouteResource> resources = new ArrayList<>();
}

View File

@ -0,0 +1,44 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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;
}

View File

@ -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<String, String> 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<SwaggerResource> get() {
List<SwaggerResource> resources = new ArrayList<>();
List<String> 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<RouteResource> 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;
}

View File

@ -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

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-ops</artifactId>
<groupId>org.springblade</groupId>
<version>2.3.2</version>
<version>2.3.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>org.springblade</groupId>
<artifactId>blade-ops</artifactId>
<version>2.3.2</version>
<version>2.3.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -50,7 +50,7 @@ public class CodeController extends BladeController {
* 详情
*/
@GetMapping("/detail")
@ApiOperation(value = "详情", notes = "传入code", position = 1)
@ApiOperation(value = "详情", notes = "传入code")
public R<Code> 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<IPage<Code>> list(@ApiIgnore @RequestParam Map<String, Object> code, Query query) {
IPage<Code> 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<Code> codes = codeService.listByIds(Func.toIntList(ids));
codes.forEach(code -> {

View File

@ -0,0 +1,154 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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<IPage<$!{entity}VO>> 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<IPage<$!{entity}VO>> 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
}

View File

@ -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<RoleMenu, RoleMenuVO> {
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;
}
}

View File

@ -0,0 +1,154 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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<IPage<$!{entity}VO>> 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<IPage<$!{entity}VO>> 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
}

View File

@ -0,0 +1,45 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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;
}
}

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-ops</artifactId>
<groupId>org.springblade</groupId>
<version>2.3.2</version>
<version>2.3.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>SpringBlade</artifactId>
<groupId>org.springblade</groupId>
<version>2.3.2</version>
<version>2.3.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-service-api</artifactId>
<groupId>org.springblade</groupId>
<version>2.3.2</version>
<version>2.3.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-service-api</artifactId>
<groupId>org.springblade</groupId>
<version>2.3.2</version>
<version>2.3.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-service-api</artifactId>
<groupId>org.springblade</groupId>
<version>2.3.2</version>
<version>2.3.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-service-api</artifactId>
<groupId>org.springblade</groupId>
<version>2.3.2</version>
<version>2.3.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -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> userInfo(@RequestParam("userId") Long userId);
/**
* 获取用户信息
*
* @param tenantCode 租户编号
* @param account 账号
* @param password 密码
* @return
*/
@GetMapping(API_PREFIX + "/user-info")

View File

@ -5,13 +5,13 @@
<parent>
<artifactId>SpringBlade</artifactId>
<groupId>org.springblade</groupId>
<version>2.3.2</version>
<version>2.3.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>blade-service-api</artifactId>
<name>${project.artifactId}</name>
<version>2.3.2</version>
<version>2.3.3</version>
<packaging>pom</packaging>
<description>SpringBlade 微服务API集合</description>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>org.springblade</groupId>
<artifactId>blade-service</artifactId>
<version>2.3.2</version>
<version>2.3.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -31,7 +31,7 @@ public class DashBoardController {
* @return
*/
@GetMapping("/activities")
@ApiOperation(value = "活跃用户", notes = "活跃用户", position = 1)
@ApiOperation(value = "活跃用户", notes = "活跃用户")
public R activities() {
List<Map<String, Object>> list = new ArrayList<>();

View File

@ -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<NoticeVO> 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<IPage<NoticeVO>> list(@ApiIgnore @RequestParam Map<String, Object> notice, Query query) {
IPage<Notice> 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<Map<String, String>> list = new ArrayList<>();
Map<String, String> 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<Map<String, String>> list = new ArrayList<>();
Map<String, String> map1 = new HashMap<>(16);

View File

@ -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<Notice, NoticeVO> {
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) {

View File

@ -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).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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;

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-service</artifactId>
<groupId>org.springblade</groupId>
<version>2.3.2</version>
<version>2.3.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-service</artifactId>
<groupId>org.springblade</groupId>
<version>2.3.2</version>
<version>2.3.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -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<AuthClient> 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<IPage<AuthClient>> list(AuthClient authClient, Query query) {
IPage<AuthClient> 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)));
}

View File

@ -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<DeptVO> 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<INode>> list(@ApiIgnore @RequestParam Map<String, Object> dept, BladeUser bladeUser) {
QueryWrapper<Dept> queryWrapper = Condition.getQueryWrapper(dept, Dept.class);
List<Dept> 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<List<DeptVO>> tree(String tenantCode, BladeUser bladeUser) {
List<DeptVO> 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)));
}

View File

@ -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<DictVO> 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<INode>> list(@ApiIgnore @RequestParam Map<String, Object> dict) {
@SuppressWarnings("unchecked")
List<Dict> 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<List<DictVO>> tree() {
List<DictVO> 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<List<Dict>> dictionary(String code) {
List<Dict> tree = dictService.getList(code);
return R.data(tree);

View File

@ -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<MenuVO> 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<MenuVO>> list(@ApiIgnore @RequestParam Map<String, Object> menu) {
@SuppressWarnings("unchecked")
List<Menu> 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<List<MenuVO>> routes(BladeUser user) {
List<MenuVO> 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<List<MenuVO>> buttons(BladeUser user) {
List<MenuVO> 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<List<MenuVO>> tree() {
List<MenuVO> 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<List<MenuVO>> 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<List<String>> 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<List<Kv>> authRoutes(BladeUser user) {
return R.data(menuService.authRoutes(user));
}

View File

@ -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<ParamVO> detail(Param param) {
@ApiOperationSupport(order = 1)
@ApiOperation(value = "详情", notes = "传入param")
public R<Param> 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<IPage<ParamVO>> list(@ApiIgnore @RequestParam Map<String, Object> param, Query query) {
@ApiOperationSupport(order = 2)
@ApiOperation(value = "分页", notes = "传入param")
public R<IPage<Param>> list(@ApiIgnore @RequestParam Map<String, Object> param, Query query) {
IPage<Param> pages = paramService.page(Condition.getPage(query), Condition.getQueryWrapper(param, Param.class));
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)));
}

View File

@ -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<RoleVO> 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<INode>> list(@ApiIgnore @RequestParam Map<String, Object> role, BladeUser bladeUser) {
QueryWrapper<Role> queryWrapper = Condition.getQueryWrapper(role, Role.class);
List<Role> 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<List<RoleVO>> tree(String tenantCode, BladeUser bladeUser) {
List<RoleVO> 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));

View File

@ -53,7 +53,7 @@ public class TenantController extends BladeController {
* 详情
*/
@GetMapping("/detail")
@ApiOperation(value = "详情", notes = "传入tenant", position = 1)
@ApiOperation(value = "详情", notes = "传入tenant")
public R<Tenant> 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<IPage<Tenant>> list(@ApiIgnore @RequestParam Map<String, Object> tenant, Query query, BladeUser bladeUser) {
QueryWrapper<Tenant> queryWrapper = Condition.getQueryWrapper(tenant, Tenant.class);
IPage<Tenant> 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<List<Tenant>> select(Tenant tenant, BladeUser bladeUser) {
QueryWrapper<Tenant> queryWrapper = Condition.getQueryWrapper(tenant);
List<Tenant> 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<IPage<Tenant>> page(Tenant tenant, Query query) {
IPage<Tenant> 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)));
}

View File

@ -67,7 +67,7 @@ public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements ID
}
@Override
@CacheEvict(cacheNames = {DICT_LIST, DICT_VALUE})
@CacheEvict(cacheNames = {DICT_LIST, DICT_VALUE}, allEntries = true)
public boolean submit(Dict dict) {
LambdaQueryWrapper<Dict> lqw = Wrappers.<Dict>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()));

View File

@ -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<Dept, DeptVO> {
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<Dept, DeptVO> {
return deptVO;
}
public List<INode> listNodeVO(List<Dept> list) {
List<INode> collect = list.stream().map(dept -> BeanUtil.copy(dept, DeptVO.class)).collect(Collectors.toList());
return ForestNodeMerger.merge(collect);

View File

@ -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<Dict, DictVO> {
private IDictService dictService;
private static IDictService dictService;
public DictWrapper() {
static {
dictService = SpringUtil.getBean(IDictService.class);
}
public static DictWrapper build() {
return new DictWrapper();
}
@Override

View File

@ -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<Menu, MenuVO> {
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

View File

@ -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<Role, RoleVO> {
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<Role, RoleVO> {
return roleVO;
}
public List<INode> listNodeVO(List<Role> list) {
List<INode> collect = list.stream().map(this::entityVO).collect(Collectors.toList());
return ForestNodeMerger.merge(collect);

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-service</artifactId>
<groupId>org.springblade</groupId>
<version>2.3.2</version>
<version>2.3.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -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<UserVO> 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<IPage<UserVO>> list(@ApiIgnore @RequestParam Map<String, Object> user, Query query, BladeUser bladeUser) {
QueryWrapper<User> queryWrapper = Condition.getQueryWrapper(user, User.class);
IPage<User> pages = userService.page(Condition.getPage(query), (!bladeUser.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);

View File

@ -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> userInfo(Long userId) {
return R.data(service.userInfo(userId));
}
@Override
@GetMapping(API_PREFIX + "/user-info")

View File

@ -32,6 +32,7 @@ public interface IUserService extends BaseService<User> {
/**
* 新增或修改用户
*
* @param user
* @return
*/
@ -46,6 +47,14 @@ public interface IUserService extends BaseService<User> {
*/
IPage<User> selectUserPage(IPage<User> page, User user);
/**
* 用户信息
*
* @param userId
* @return
*/
UserInfo userInfo(Long userId);
/**
* 用户信息
*

View File

@ -57,6 +57,18 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> 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<String> 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();

View File

@ -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<User, UserVO> {
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

View File

@ -7,12 +7,12 @@
<parent>
<groupId>org.springblade</groupId>
<artifactId>SpringBlade</artifactId>
<version>2.3.2</version>
<version>2.3.3</version>
</parent>
<artifactId>blade-service</artifactId>
<name>${project.artifactId}</name>
<version>2.3.2</version>
<version>2.3.3</version>
<packaging>pom</packaging>
<description>SpringBlade 微服务集合</description>

View File

@ -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

View File

@ -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

View File

@ -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`;

16
pom.xml
View File

@ -5,27 +5,27 @@
<groupId>org.springblade</groupId>
<artifactId>SpringBlade</artifactId>
<version>2.3.2</version>
<version>2.3.3</version>
<packaging>pom</packaging>
<properties>
<blade.tool.version>2.3.2</blade.tool.version>
<blade.project.version>2.3.2</blade.project.version>
<blade.tool.version>2.3.3</blade.tool.version>
<blade.project.version>2.3.3</blade.project.version>
<java.version>1.8</java.version>
<swagger.version>2.9.2</swagger.version>
<swagger.models.version>1.5.21</swagger.models.version>
<swagger.bootstrapui.version>1.9.4</swagger.bootstrapui.version>
<mybatis.plus.version>3.1.0</mybatis.plus.version>
<mybatis.plus.version>3.1.2</mybatis.plus.version>
<curator.framework.version>4.0.1</curator.framework.version>
<protostuff.version>1.6.0</protostuff.version>
<mica.auto.version>1.1.0</mica.auto.version>
<alibaba.cloud.version>0.9.0.RELEASE</alibaba.cloud.version>
<spring.boot.admin.version>2.1.4</spring.boot.admin.version>
<spring.boot.admin.version>2.1.5</spring.boot.admin.version>
<spring.boot.version>2.1.5.RELEASE</spring.boot.version>
<spring.cloud.version>Greenwich.SR1</spring.cloud.version>
<spring.platform.version>Cairo-SR7</spring.platform.version>
<spring.boot.version>2.1.6.RELEASE</spring.boot.version>
<spring.cloud.version>Greenwich.SR2</spring.cloud.version>
<spring.platform.version>Cairo-SR8</spring.platform.version>
<!-- 推荐使用Harbor -->
<docker.registry.url>10.211.55.5</docker.registry.url>

View File

@ -1,2 +1,2 @@
REGISTER=192.168.0.157/blade
TAG=2.3.2
TAG=2.3.3