Compare commits
7
Commits
1.5.0
...
release/1.5.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4b78133398 | ||
|
|
f1ca3dfcaa | ||
|
|
94fe6f8aef | ||
|
|
08af2403ca | ||
|
|
5a928d1660 | ||
|
|
8baf7f3a37 | ||
|
|
1e2b3b3452 |
@@ -40,9 +40,11 @@ import fun.asgc.neutrino.core.web.router.HttpRouteParam;
|
||||
import fun.asgc.neutrino.core.web.router.HttpRouteResult;
|
||||
import fun.asgc.neutrino.core.web.router.HttpRouterType;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.http.*;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpHeaderNames;
|
||||
import io.netty.handler.codec.http.HttpHeaderValues;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
@@ -117,9 +119,10 @@ public class HttpRequestHandler {
|
||||
httpResponseWrapper.writeAndFlush();
|
||||
return;
|
||||
} else if(HttpRouterType.PAGE == httpRouteResult.getType()) {
|
||||
if (!preHandle(httpRouteResult.getPageRoute(), null)) {
|
||||
return;
|
||||
}
|
||||
// 静态页面无需前置拦截
|
||||
// if (!preHandle(httpRouteResult.getPageRoute(), null)) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// 前端页面
|
||||
String mimeType = MimeType.getMimeType(MimeType.parseSuffix(httpRouteResult.getPageLocation()));
|
||||
|
||||
-5
@@ -46,11 +46,6 @@ public class BaseAuthInterceptor implements HandlerInterceptor {
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpRequestWrapper requestParser, HttpResponseWrapper responseWrapper, String route, Method targetMethod) throws Exception {
|
||||
// TODO 临时解决静态页面被拦截的问题
|
||||
if (null == targetMethod) {
|
||||
return true;
|
||||
}
|
||||
|
||||
SystemContext systemContext = new SystemContext();
|
||||
SystemContextHolder.set(systemContext);
|
||||
systemContext.setIp(HttpUtil.getIP(HttpContextHolder.getChannelHandlerContext(), requestParser));
|
||||
|
||||
+1
-1
@@ -103,7 +103,7 @@ public class LicenseService {
|
||||
*/
|
||||
public LicenseCreateRes create(LicenseCreateReq req) {
|
||||
LicenseDO licenseDO = licenseMapper.checkRepeat(req.getUserId(), req.getName());
|
||||
ParamCheckUtil.checkNotNull(licenseDO, ExceptionConstant.LICENSE_NAME_CANNOT_REPEAT);
|
||||
ParamCheckUtil.checkExpression(null == licenseDO, ExceptionConstant.LICENSE_NAME_CANNOT_REPEAT);
|
||||
|
||||
String key = UUID.randomUUID().toString().replaceAll("-", "");
|
||||
Date now = new Date();
|
||||
|
||||
+29
-23
@@ -74,27 +74,34 @@ public class PortMappingService {
|
||||
public Page<PortMappingListRes> page(PageQuery pageQuery, PortMappingListReq req) {
|
||||
Page<PortMappingListRes> page = Page.create(pageQuery);
|
||||
portMappingMapper.page(page, req);
|
||||
if (!CollectionUtil.isEmpty(page.getRecords())) {
|
||||
Set<Integer> licenseIds = page.getRecords().stream().map(PortMappingListRes::getLicenseId).collect(Collectors.toSet());
|
||||
List<LicenseDO> licenseList = licenseMapper.findByIds(licenseIds);
|
||||
Set<Integer> userIds = licenseList.stream().map(LicenseDO::getUserId).collect(Collectors.toSet());
|
||||
List<UserDO> userList = userMapper.findByIds(userIds);
|
||||
Map<Integer, LicenseDO> licenseMap = licenseList.stream().collect(Collectors.toMap(LicenseDO::getId, Function.identity()));
|
||||
Map<Integer, UserDO> userMap = userList.stream().collect(Collectors.toMap(UserDO::getId, Function.identity()));
|
||||
page.getRecords().forEach(item -> {
|
||||
LicenseDO license = licenseMap.get(item.getLicenseId());
|
||||
if (null == license) {
|
||||
return;
|
||||
}
|
||||
item.setLicenseName(license.getName());
|
||||
item.setUserId(license.getUserId());
|
||||
UserDO user = userMap.get(license.getUserId());
|
||||
if (null == user) {
|
||||
return;
|
||||
}
|
||||
item.setUserName(user.getName());
|
||||
});
|
||||
if (CollectionUtil.isEmpty(page.getRecords())) {
|
||||
return page;
|
||||
}
|
||||
Set<Integer> licenseIds = page.getRecords().stream().map(PortMappingListRes::getLicenseId).collect(Collectors.toSet());
|
||||
if (CollectionUtil.isEmpty(licenseIds)) {
|
||||
return page;
|
||||
}
|
||||
List<LicenseDO> licenseList = licenseMapper.findByIds(licenseIds);
|
||||
if (CollectionUtil.isEmpty(licenseList)) {
|
||||
return page;
|
||||
}
|
||||
Set<Integer> userIds = licenseList.stream().map(LicenseDO::getUserId).collect(Collectors.toSet());
|
||||
List<UserDO> userList = userMapper.findByIds(userIds);
|
||||
Map<Integer, LicenseDO> licenseMap = licenseList.stream().collect(Collectors.toMap(LicenseDO::getId, Function.identity()));
|
||||
Map<Integer, UserDO> userMap = userList.stream().collect(Collectors.toMap(UserDO::getId, Function.identity()));
|
||||
page.getRecords().forEach(item -> {
|
||||
LicenseDO license = licenseMap.get(item.getLicenseId());
|
||||
if (null == license) {
|
||||
return;
|
||||
}
|
||||
item.setLicenseName(license.getName());
|
||||
item.setUserId(license.getUserId());
|
||||
UserDO user = userMap.get(license.getUserId());
|
||||
if (null == user) {
|
||||
return;
|
||||
}
|
||||
item.setUserName(user.getName());
|
||||
});
|
||||
return page;
|
||||
}
|
||||
|
||||
@@ -107,7 +114,7 @@ public class PortMappingService {
|
||||
}
|
||||
PortPoolDO portPoolDO = portPoolMapper.findByPort(req.getServerPort());
|
||||
ParamCheckUtil.checkNotNull(portPoolDO, ExceptionConstant.PORT_NOT_EXIST);
|
||||
ParamCheckUtil.checkNotNull(portMappingMapper.findByPort(req.getServerPort()), ExceptionConstant.PORT_CANNOT_REPEAT_MAPPING, req.getServerPort());
|
||||
ParamCheckUtil.checkExpression(null == portMappingMapper.findByPort(req.getServerPort()), ExceptionConstant.PORT_CANNOT_REPEAT_MAPPING, req.getServerPort());
|
||||
|
||||
|
||||
Date now = new Date();
|
||||
@@ -196,8 +203,7 @@ public class PortMappingService {
|
||||
ParamCheckUtil.checkNotNull(portMappingDO, ExceptionConstant.PORT_MAPPING_NOT_EXIST);
|
||||
|
||||
LicenseDO licenseDO = licenseMapper.findById(portMappingDO.getLicenseId());
|
||||
ParamCheckUtil.checkNotNull(licenseDO, ExceptionConstant.LICENSE_NOT_EXIST);
|
||||
if (!SystemContextHolder.isAdmin()) {
|
||||
if (null != licenseDO && !SystemContextHolder.isAdmin()) {
|
||||
// 临时处理,如果当前用户不是管理员,则操作userId不能为1
|
||||
ParamCheckUtil.checkExpression(!licenseDO.getUserId().equals(1), ExceptionConstant.NO_PERMISSION_VISIT);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user