代理服务端solon化改造,rest接口、静态资源服务调通

This commit is contained in:
aoshiguchen
2023-03-09 23:37:20 +08:00
parent e940edeee9
commit 5269fb9149
19 changed files with 258 additions and 399 deletions
@@ -2,6 +2,7 @@ package fun.asgc.neutrino.proxy.server;
import org.noear.solon.Solon;
import org.noear.solon.annotation.Controller;
import org.noear.solon.web.cors.CrossFilter;
/**
*
@@ -12,6 +13,9 @@ import org.noear.solon.annotation.Controller;
public class ProxyServer {
public static void main(String[] args) {
Solon.start(ProxyServer.class, args);
Solon.start(ProxyServer.class, args, app -> {
// 跨域支持。加-1 优先级更高
app.filter(-1, new CrossFilter().allowedOrigins("*"));
});
}
}
@@ -1,56 +0,0 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package fun.asgc.neutrino.proxy.server.base.rest.config;
import fun.asgc.neutrino.core.annotation.Configuration;
import fun.asgc.neutrino.core.web.config.WebMvcConfigurer;
import fun.asgc.neutrino.core.web.interceptor.ExceptionHandlerRegistry;
import fun.asgc.neutrino.core.web.interceptor.InterceptorRegistry;
import fun.asgc.neutrino.core.web.interceptor.RestControllerAdviceHandler;
import fun.asgc.neutrino.proxy.server.base.rest.interceptor.*;
/**
* web配置
* @author: aoshiguchen
* @date: 2022/7/30
*/
@Configuration
public class WebConfigurerAdapter implements WebMvcConfigurer {
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new BaseAuthInterceptor())
.addPathPatterns("/**").excludePathPatterns("/**/*.html", "/**/*.js", "/**/*.ico");
registry.addInterceptor(new CorsInterceptor());
registry.addInterceptor(new VisitLogInterceptor());
}
@Override
public RestControllerAdviceHandler adviceHandler() {
return new GlobalAdviceHandler();
}
@Override
public void addExceptionHandler(ExceptionHandlerRegistry registry) {
registry.addExceptionHandler(new GlobalExceptionHandler());
}
}
@@ -1,87 +1,75 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package fun.asgc.neutrino.proxy.server.base.rest.interceptor;
import fun.asgc.neutrino.core.util.HttpUtil;
import fun.asgc.neutrino.core.util.StringUtil;
import fun.asgc.neutrino.core.web.context.HttpContextHolder;
import fun.asgc.neutrino.core.web.context.HttpRequestWrapper;
import fun.asgc.neutrino.core.web.context.HttpResponseWrapper;
import fun.asgc.neutrino.core.web.interceptor.HandlerInterceptor;
import fun.asgc.neutrino.proxy.server.base.rest.Authorization;
import fun.asgc.neutrino.proxy.server.base.rest.ServiceException;
import fun.asgc.neutrino.proxy.server.base.rest.SystemContext;
import fun.asgc.neutrino.proxy.server.base.rest.SystemContextHolder;
import fun.asgc.neutrino.proxy.server.base.rest.*;
import fun.asgc.neutrino.proxy.server.base.rest.annotation.OnlyAdmin;
import fun.asgc.neutrino.proxy.server.constant.EnableStatusEnum;
import fun.asgc.neutrino.proxy.server.constant.ExceptionConstant;
import fun.asgc.neutrino.proxy.server.dal.entity.UserDO;
import fun.asgc.neutrino.proxy.server.service.UserService;
import org.noear.solon.Solon;
import org.noear.solon.annotation.Component;
import org.noear.solon.core.handle.Action;
import org.noear.solon.core.handle.Context;
import org.noear.solon.core.handle.Handler;
import org.noear.solon.core.route.RouterInterceptor;
import org.noear.solon.core.route.RouterInterceptorChain;
import java.lang.reflect.Method;
/**
* 鉴权拦截器
* @author: aoshiguchen
* @date: 2022/7/30
* @date: 2023/3/9
*/
public class BaseAuthInterceptor implements HandlerInterceptor {
@Component
public class BaseAuthInterceptor implements RouterInterceptor {
@Override
public boolean preHandle(HttpRequestWrapper requestParser, HttpResponseWrapper responseWrapper, String route, Method targetMethod) throws Exception {
SystemContext systemContext = new SystemContext();
SystemContextHolder.set(systemContext);
systemContext.setIp(HttpUtil.getIP(HttpContextHolder.getChannelHandlerContext(), requestParser));
@Override
public void doIntercept(Context ctx, Handler mainHandler, RouterInterceptorChain chain) throws Throwable {
if (!(mainHandler instanceof Action)) {
return;
}
Action action = (Action) mainHandler;
Method targetMethod = action.method().getMethod();
Authorization authorization = targetMethod.getAnnotation(Authorization.class);
if (null == authorization || authorization.login()) {
String authorize = requestParser.getHeaderValue("Authorize");
if (StringUtil.isEmpty(authorize)) {
throw ServiceException.create(ExceptionConstant.USER_NOT_LOGIN);
}
UserDO userDO = Solon.context().getBean(UserService.class).findByToken(authorize);
if (null == userDO) {
throw ServiceException.create(ExceptionConstant.USER_NOT_LOGIN);
}
if (EnableStatusEnum.DISABLE.getStatus().equals(userDO.getEnable())) {
throw ServiceException.create(ExceptionConstant.USER_DISABLE);
}
if (targetMethod.isAnnotationPresent(OnlyAdmin.class) && !userDO.getLoginName().equals("admin")) {
throw ServiceException.create(ExceptionConstant.NO_PERMISSION_VISIT);
}
SystemContext systemContext = new SystemContext();
SystemContextHolder.set(systemContext);
systemContext.setIp(ctx.ip());
systemContext.setToken(authorize);
systemContext.setUser(userDO);
Authorization authorization = targetMethod.getAnnotation(Authorization.class);
if (null == authorization || authorization.login()) {
String authorize = ctx.header("Authorize");
if (StringUtil.isEmpty(authorize)) {
throw ServiceException.create(ExceptionConstant.USER_NOT_LOGIN);
}
UserDO userDO = Solon.context().getBean(UserService.class).findByToken(authorize);
if (null == userDO) {
throw ServiceException.create(ExceptionConstant.USER_NOT_LOGIN);
}
if (EnableStatusEnum.DISABLE.getStatus().equals(userDO.getEnable())) {
throw ServiceException.create(ExceptionConstant.USER_DISABLE);
}
if (targetMethod.isAnnotationPresent(OnlyAdmin.class) && !userDO.getLoginName().equals("admin")) {
throw ServiceException.create(ExceptionConstant.NO_PERMISSION_VISIT);
}
// token续期
Solon.context().getBean(UserService.class).updateTokenExpirationTime(authorize);
}
systemContext.setToken(authorize);
systemContext.setUser(userDO);
return true;
}
// token续期
Solon.context().getBean(UserService.class).updateTokenExpirationTime(authorize);
}
chain.doIntercept(ctx, mainHandler);
}
@Override
public void afterCompletion(HttpRequestWrapper requestParser, HttpResponseWrapper responseWrapper, String route, Method targetMethod) {
SystemContextHolder.remove();
}
@Override
public Object postResult(Context ctx, Object result) throws Throwable {
SystemContextHolder.remove();
if (result instanceof ResponseBody) {
return result;
}
return new ResponseBody<>()
.setCode(0)
.setData(result);
}
}
@@ -1,49 +0,0 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package fun.asgc.neutrino.proxy.server.base.rest.interceptor;
import fun.asgc.neutrino.core.web.context.HttpRequestWrapper;
import fun.asgc.neutrino.core.web.context.HttpResponseWrapper;
import fun.asgc.neutrino.core.web.interceptor.HandlerInterceptor;
import java.lang.reflect.Method;
/**
* 处理跨域问题
* @author: aoshiguchen
* @date: 2022/7/30
*/
public class CorsInterceptor implements HandlerInterceptor {
@Override
public void postHandle(HttpRequestWrapper requestParser, HttpResponseWrapper responseWrapper, String route, Method targetMethod, Object result) throws Exception {
responseWrapper.headers().add("Access-Control-Allow-Origin", "*");
responseWrapper.headers().add("Access-Control-Allow-Methods", "POST, GET, OPTIONS");
responseWrapper.headers().add("Access-Control-Max-Age", "86400");
responseWrapper.headers().add("Access-Control-Allow-Headers", "*");
responseWrapper.headers().add("Access-Control-Allow-Credentials", "true");
responseWrapper.headers().add("XDomainRequestAllowed", "1");
responseWrapper.headers().add("Access-Control-Allow-Headers","Authorize, Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers, Content-Type");
responseWrapper.headers().add("Access-Control-Allow-Credentials", "true");
}
}
@@ -1,48 +0,0 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package fun.asgc.neutrino.proxy.server.base.rest.interceptor;
import fun.asgc.neutrino.core.web.context.HttpRequestWrapper;
import fun.asgc.neutrino.core.web.context.HttpResponseWrapper;
import fun.asgc.neutrino.core.web.interceptor.RestControllerAdviceHandler;
import fun.asgc.neutrino.proxy.server.base.rest.ResponseBody;
import java.lang.reflect.Method;
/**
* 全局返回处理
* @author: aoshiguchen
* @date: 2022/7/31
*/
public class GlobalAdviceHandler implements RestControllerAdviceHandler {
@Override
public Object advice(HttpRequestWrapper requestParser, HttpResponseWrapper responseWrapper, String route, Method targetMethod, Object res) {
if (res instanceof ResponseBody) {
return res;
}
return new ResponseBody<>()
.setCode(0)
.setData(res);
}
}
@@ -0,0 +1,37 @@
package fun.asgc.neutrino.proxy.server.base.rest.interceptor;
import fun.asgc.neutrino.proxy.server.base.rest.ResponseBody;
import fun.asgc.neutrino.proxy.server.base.rest.ServiceException;
import fun.asgc.neutrino.proxy.server.constant.ExceptionConstant;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.noear.solon.annotation.Component;
import org.noear.solon.core.handle.Context;
import org.noear.solon.core.handle.Filter;
import org.noear.solon.core.handle.FilterChain;
/**
* @author: aoshiguchen
* @date: 2023/3/9
*/
@Component
public class GlobalExceptionFilter implements Filter {
@Override
public void doFilter(Context ctx, FilterChain chain) throws Throwable {
try {
chain.doFilter(ctx);
} catch (Throwable e) {
if (e instanceof ServiceException) {
ServiceException serviceException = (ServiceException)e;
ctx.render(new ResponseBody<>()
.setCode(serviceException.getCode())
.setMsg(serviceException.getMsg()));
return;
}
ctx.render(new ResponseBody<>()
.setCode(ExceptionConstant.SYSTEM_ERROR.getCode())
.setMsg(ExceptionConstant.SYSTEM_ERROR.getMsg())
.setStack(ExceptionUtils.getStackTrace(e)));
}
}
}
@@ -1,53 +0,0 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package fun.asgc.neutrino.proxy.server.base.rest.interceptor;
import fun.asgc.neutrino.core.web.context.HttpRequestWrapper;
import fun.asgc.neutrino.core.web.context.HttpResponseWrapper;
import fun.asgc.neutrino.core.web.interceptor.RestControllerExceptionHandler;
import fun.asgc.neutrino.proxy.server.constant.ExceptionConstant;
import fun.asgc.neutrino.proxy.server.base.rest.ResponseBody;
import fun.asgc.neutrino.proxy.server.base.rest.ServiceException;
import org.apache.commons.lang3.exception.ExceptionUtils;
/**
* 全局异常处理
* @author: aoshiguchen
* @date: 2022/7/31
*/
public class GlobalExceptionHandler implements RestControllerExceptionHandler {
@Override
public Object handle(HttpRequestWrapper requestParser, HttpResponseWrapper responseWrapper, Throwable e) {
if (e instanceof ServiceException) {
ServiceException serviceException = (ServiceException)e;
return new ResponseBody<>()
.setCode(serviceException.getCode())
.setMsg(serviceException.getMsg());
}
return new ResponseBody<>()
.setCode(ExceptionConstant.SYSTEM_ERROR.getCode())
.setMsg(ExceptionConstant.SYSTEM_ERROR.getMsg())
.setStack(ExceptionUtils.getStackTrace(e));
}
}
@@ -21,32 +21,31 @@
*/
package fun.asgc.neutrino.proxy.server.controller;
import fun.asgc.neutrino.core.annotation.Autowired;
import fun.asgc.neutrino.core.annotation.NonIntercept;
import fun.asgc.neutrino.core.db.page.Page;
import fun.asgc.neutrino.core.db.page.PageQuery;
import fun.asgc.neutrino.core.web.annotation.GetMapping;
import fun.asgc.neutrino.core.web.annotation.RequestMapping;
import fun.asgc.neutrino.core.web.annotation.RestController;
import fun.asgc.neutrino.proxy.server.controller.req.ClientConnectRecordListReq;
import fun.asgc.neutrino.proxy.server.controller.res.ClientConnectRecordListRes;
import fun.asgc.neutrino.proxy.server.service.ClientConnectRecordService;
import fun.asgc.neutrino.proxy.server.util.ParamCheckUtil;
import lombok.extern.slf4j.Slf4j;
import org.noear.solon.annotation.Controller;
import org.noear.solon.annotation.Get;
import org.noear.solon.annotation.Inject;
import org.noear.solon.annotation.Mapping;
/**
* @author: aoshiguchen
* @date: 2022/11/26
*/
@Slf4j
@NonIntercept
@RequestMapping("client-connect-record")
@RestController
@Mapping("/client-connect-record")
@Controller
public class ClientConnectRecordController {
@Autowired
@Inject
private ClientConnectRecordService clientConnectRecordService;
@GetMapping("page")
@Get
@Mapping("/page")
public Page<ClientConnectRecordListRes> page(PageQuery pageQuery, ClientConnectRecordListReq req) {
ParamCheckUtil.checkNotNull(pageQuery, "pageQuery");
return clientConnectRecordService.page(pageQuery, req);
@@ -21,32 +21,35 @@
*/
package fun.asgc.neutrino.proxy.server.controller;
import fun.asgc.neutrino.core.annotation.NonIntercept;
import fun.asgc.neutrino.core.web.annotation.RequestBody;
import fun.asgc.neutrino.proxy.server.base.rest.Authorization;
import fun.asgc.neutrino.proxy.server.controller.req.LoginReq;
import fun.asgc.neutrino.proxy.server.controller.res.LoginRes;
import fun.asgc.neutrino.proxy.server.service.UserService;
import fun.asgc.neutrino.proxy.server.util.ParamCheckUtil;
import org.noear.solon.annotation.Controller;
import org.noear.solon.annotation.Inject;
import org.noear.solon.annotation.Mapping;
import org.noear.solon.annotation.Post;
import org.noear.solon.annotation.*;
import org.noear.solon.core.handle.Context;
/**
*
* @author: aoshiguchen
* @date: 2022/7/31
*/
@NonIntercept
@Controller
public class IndexController {
@Inject
private UserService userService;
@Authorization(login = false)
@Get
@Mapping("/")
public void home(Context ctx) {
ctx.forward("/index.html");
}
@Authorization(login = false)
@Post
@Mapping("login")
@Mapping("/login")
public LoginRes login(@RequestBody LoginReq req) {
ParamCheckUtil.checkNotEmpty(req.getLoginName(), "loginName");
ParamCheckUtil.checkNotEmpty(req.getLoginPassword(), "loginPassword");
@@ -55,7 +58,7 @@ public class IndexController {
}
@Post
@Mapping("logout")
@Mapping("/logout")
public void logout() {
userService.logout();
}
@@ -21,18 +21,23 @@
*/
package fun.asgc.neutrino.proxy.server.controller;
import fun.asgc.neutrino.core.annotation.Autowired;
import fun.asgc.neutrino.core.annotation.NonIntercept;
import fun.asgc.neutrino.core.db.page.Page;
import fun.asgc.neutrino.core.db.page.PageQuery;
import fun.asgc.neutrino.core.web.annotation.*;
import fun.asgc.neutrino.core.web.annotation.RequestBody;
import fun.asgc.neutrino.proxy.server.base.rest.annotation.OnlyAdmin;
import fun.asgc.neutrino.proxy.server.controller.req.*;
import fun.asgc.neutrino.proxy.server.controller.res.*;
import fun.asgc.neutrino.proxy.server.controller.req.JobInfoExecuteReq;
import fun.asgc.neutrino.proxy.server.controller.req.JobInfoListReq;
import fun.asgc.neutrino.proxy.server.controller.req.JobInfoUpdateEnableStatusReq;
import fun.asgc.neutrino.proxy.server.controller.req.JobInfoUpdateReq;
import fun.asgc.neutrino.proxy.server.controller.res.JobInfoExecuteRes;
import fun.asgc.neutrino.proxy.server.controller.res.JobInfoListRes;
import fun.asgc.neutrino.proxy.server.controller.res.JobInfoUpdateEnableStatusRes;
import fun.asgc.neutrino.proxy.server.controller.res.JobInfoUpdateRes;
import fun.asgc.neutrino.proxy.server.dal.entity.JobInfoDO;
import fun.asgc.neutrino.proxy.server.service.JobInfoService;
import fun.asgc.neutrino.proxy.server.util.ParamCheckUtil;
import lombok.extern.slf4j.Slf4j;
import org.noear.solon.annotation.*;
import java.util.List;
@@ -42,26 +47,28 @@ import java.util.List;
* @date: 2022/9/5
*/
@Slf4j
@NonIntercept
@RequestMapping("job-info")
@RestController
@Mapping("/job-info")
@Controller
public class JobInfoController {
@Autowired
@Inject
private JobInfoService jobInfoService;
@GetMapping("page")
@Get
@Mapping("/page")
public Page<JobInfoListRes> page(PageQuery pageQuery, JobInfoListReq req) {
ParamCheckUtil.checkNotNull(pageQuery, "pageQuery");
return jobInfoService.page(pageQuery, req);
}
@GetMapping("findList")
@Get
@Mapping("/findList")
public List<JobInfoDO> findList() {
return jobInfoService.findList();
}
@OnlyAdmin
@PostMapping("update/enable-status")
@Post
@Mapping("/update/enable-status")
public JobInfoUpdateEnableStatusRes updateEnableStatus(@RequestBody JobInfoUpdateEnableStatusReq req) {
ParamCheckUtil.checkNotNull(req, "req");
ParamCheckUtil.checkNotNull(req.getId(), "id");
@@ -70,7 +77,8 @@ public class JobInfoController {
}
@OnlyAdmin
@PostMapping("execute")
@Post
@Mapping("execute")
public JobInfoExecuteRes execute(@RequestBody JobInfoExecuteReq req) {
ParamCheckUtil.checkNotNull(req, "req");
ParamCheckUtil.checkNotNull(req.getId(), "id");
@@ -78,7 +86,8 @@ public class JobInfoController {
return jobInfoService.execute(req);
}
@PostMapping("update")
@Post
@Mapping("update")
public JobInfoUpdateRes update(@RequestBody JobInfoUpdateReq req) {
ParamCheckUtil.checkNotNull(req, "req");
@@ -21,16 +21,17 @@
*/
package fun.asgc.neutrino.proxy.server.controller;
import fun.asgc.neutrino.core.annotation.Autowired;
import fun.asgc.neutrino.core.annotation.NonIntercept;
import fun.asgc.neutrino.core.db.page.Page;
import fun.asgc.neutrino.core.db.page.PageQuery;
import fun.asgc.neutrino.core.web.annotation.*;
import fun.asgc.neutrino.proxy.server.controller.req.*;
import fun.asgc.neutrino.proxy.server.controller.res.*;
import fun.asgc.neutrino.proxy.server.controller.req.JobLogListReq;
import fun.asgc.neutrino.proxy.server.controller.res.JobLogListRes;
import fun.asgc.neutrino.proxy.server.service.JobLogService;
import fun.asgc.neutrino.proxy.server.util.ParamCheckUtil;
import lombok.extern.slf4j.Slf4j;
import org.noear.solon.annotation.Controller;
import org.noear.solon.annotation.Get;
import org.noear.solon.annotation.Inject;
import org.noear.solon.annotation.Mapping;
/**
*
@@ -38,14 +39,14 @@ import lombok.extern.slf4j.Slf4j;
* @date: 2022/9/25
*/
@Slf4j
@NonIntercept
@RequestMapping("job-log")
@RestController
@Mapping("/job-log")
@Controller
public class JobLogController {
@Autowired
@Inject
private JobLogService jobLogService;
@GetMapping("page")
@Get
@Mapping("/page")
public Page<JobLogListRes> page(PageQuery pageQuery, JobLogListReq req) {
ParamCheckUtil.checkNotNull(pageQuery, "pageQuery");
return jobLogService.page(pageQuery, req);
@@ -21,11 +21,10 @@
*/
package fun.asgc.neutrino.proxy.server.controller;
import fun.asgc.neutrino.core.annotation.Autowired;
import fun.asgc.neutrino.core.annotation.NonIntercept;
import fun.asgc.neutrino.core.db.page.Page;
import fun.asgc.neutrino.core.db.page.PageQuery;
import fun.asgc.neutrino.core.web.annotation.*;
import fun.asgc.neutrino.core.web.annotation.RequestBody;
import fun.asgc.neutrino.core.web.annotation.RequestParam;
import fun.asgc.neutrino.proxy.server.base.rest.annotation.OnlyAdmin;
import fun.asgc.neutrino.proxy.server.controller.req.LicenseCreateReq;
import fun.asgc.neutrino.proxy.server.controller.req.LicenseListReq;
@@ -34,6 +33,7 @@ import fun.asgc.neutrino.proxy.server.controller.req.LicenseUpdateReq;
import fun.asgc.neutrino.proxy.server.controller.res.*;
import fun.asgc.neutrino.proxy.server.service.LicenseService;
import fun.asgc.neutrino.proxy.server.util.ParamCheckUtil;
import org.noear.solon.annotation.*;
import java.util.List;
@@ -42,28 +42,28 @@ import java.util.List;
* @author: aoshiguchen
* @date: 2022/8/6
*/
@NonIntercept
@RequestMapping("license")
@RestController
@Mapping("/license")
@Controller
public class LicenseController {
@Autowired
@Inject
private LicenseService licenseService;
@GetMapping("page")
@Get
@Mapping("/page")
public Page<LicenseListRes> page(PageQuery pageQuery, LicenseListReq req) {
ParamCheckUtil.checkNotNull(pageQuery, "pageQuery");
return licenseService.page(pageQuery, req);
}
@GetMapping("list")
@Mapping("/list")
public List<LicenseListRes> list(LicenseListReq req) {
return licenseService.list(req);
}
@OnlyAdmin
@PostMapping("create")
@Post
@Mapping("/create")
public LicenseCreateRes create(@RequestBody LicenseCreateReq req) {
ParamCheckUtil.checkNotNull(req, "req");
ParamCheckUtil.checkNotEmpty(req.getName(), "name");
@@ -73,7 +73,8 @@ public class LicenseController {
}
@OnlyAdmin
@PostMapping("update")
@Post
@Mapping("/update")
public LicenseUpdateRes update(@RequestBody LicenseUpdateReq req) {
ParamCheckUtil.checkNotNull(req, "req");
ParamCheckUtil.checkNotNull(req.getId(), "id");
@@ -82,7 +83,8 @@ public class LicenseController {
return licenseService.update(req);
}
@GetMapping("detail")
@Post
@Mapping("/detail")
public LicenseDetailRes detail(@RequestParam("id") Integer id) {
ParamCheckUtil.checkNotNull(id, "id");
@@ -90,7 +92,8 @@ public class LicenseController {
}
@OnlyAdmin
@PostMapping("update/enable-status")
@Post
@Mapping("/update/enable-status")
public LicenseUpdateEnableStatusRes updateEnableStatus(@RequestBody LicenseUpdateEnableStatusReq req) {
ParamCheckUtil.checkNotNull(req, "req");
ParamCheckUtil.checkNotNull(req.getId(), "id");
@@ -100,7 +103,8 @@ public class LicenseController {
}
@OnlyAdmin
@PostMapping("delete")
@Post
@Mapping("/delete")
public void delete(@RequestParam("id") Integer id) {
ParamCheckUtil.checkNotNull(id, "id");
@@ -108,7 +112,8 @@ public class LicenseController {
}
@OnlyAdmin
@PostMapping("reset")
@Post
@Mapping("/reset")
public void reset(@RequestParam("id") Integer id) {
ParamCheckUtil.checkNotNull(id, "id");
@@ -21,11 +21,11 @@
*/
package fun.asgc.neutrino.proxy.server.controller;
import fun.asgc.neutrino.core.annotation.Autowired;
import fun.asgc.neutrino.core.annotation.NonIntercept;
import fun.asgc.neutrino.core.db.page.Page;
import fun.asgc.neutrino.core.db.page.PageQuery;
import fun.asgc.neutrino.core.web.annotation.*;
import fun.asgc.neutrino.core.web.annotation.RequestBody;
import fun.asgc.neutrino.core.web.annotation.RequestParam;
import fun.asgc.neutrino.proxy.server.controller.req.PortMappingCreateReq;
import fun.asgc.neutrino.proxy.server.controller.req.PortMappingListReq;
import fun.asgc.neutrino.proxy.server.controller.req.PortMappingUpdateEnableStatusReq;
@@ -33,6 +33,7 @@ import fun.asgc.neutrino.proxy.server.controller.req.PortMappingUpdateReq;
import fun.asgc.neutrino.proxy.server.controller.res.*;
import fun.asgc.neutrino.proxy.server.service.PortMappingService;
import fun.asgc.neutrino.proxy.server.util.ParamCheckUtil;
import org.noear.solon.annotation.*;
/**
* 端口映射
@@ -40,20 +41,22 @@ import fun.asgc.neutrino.proxy.server.util.ParamCheckUtil;
* @date: 2022/8/8
*/
@NonIntercept
@RequestMapping("port-mapping")
@RestController
@Mapping("/port-mapping")
@Controller
public class PortMappingController {
@Autowired
@Inject
private PortMappingService portMappingService;
@GetMapping("page")
@Get
@Mapping("/page")
public Page<PortMappingListRes> page(PageQuery pageQuery, PortMappingListReq req) {
ParamCheckUtil.checkNotNull(pageQuery, "pageQuery");
return portMappingService.page(pageQuery, req);
}
@PostMapping("create")
@Post
@Mapping("/create")
public PortMappingCreateRes create(@RequestBody PortMappingCreateReq req) {
ParamCheckUtil.checkNotNull(req, "req");
ParamCheckUtil.checkNotNull(req.getLicenseId(), "licenseId");
@@ -64,21 +67,24 @@ public class PortMappingController {
return portMappingService.create(req);
}
@PostMapping("update")
@Post
@Mapping("/update")
public PortMappingUpdateRes update(@RequestBody PortMappingUpdateReq req) {
ParamCheckUtil.checkNotNull(req, "req");
return portMappingService.update(req);
}
@GetMapping("detail")
@Get
@Mapping("/detail")
public PortMappingDetailRes detail(@RequestParam("id") Integer id) {
ParamCheckUtil.checkNotNull(id, "id");
return portMappingService.detail(id);
}
@PostMapping("update/enable-status")
@Post
@Mapping("/update/enable-status")
public PortMappingUpdateEnableStatusRes updateEnableStatus(@RequestBody PortMappingUpdateEnableStatusReq req) {
ParamCheckUtil.checkNotNull(req, "req");
ParamCheckUtil.checkNotNull(req.getId(), "id");
@@ -87,7 +93,8 @@ public class PortMappingController {
return portMappingService.updateEnableStatus(req);
}
@PostMapping("delete")
@Post
@Mapping("/delete")
public void delete(@RequestParam("id") Integer id) {
ParamCheckUtil.checkNotNull(id, "id");
@@ -21,11 +21,10 @@
*/
package fun.asgc.neutrino.proxy.server.controller;
import fun.asgc.neutrino.core.annotation.Autowired;
import fun.asgc.neutrino.core.annotation.NonIntercept;
import fun.asgc.neutrino.core.db.page.Page;
import fun.asgc.neutrino.core.db.page.PageQuery;
import fun.asgc.neutrino.core.web.annotation.*;
import fun.asgc.neutrino.core.web.annotation.RequestBody;
import fun.asgc.neutrino.core.web.annotation.RequestParam;
import fun.asgc.neutrino.proxy.server.base.rest.annotation.OnlyAdmin;
import fun.asgc.neutrino.proxy.server.controller.req.PortPoolCreateReq;
import fun.asgc.neutrino.proxy.server.controller.req.PortPoolListReq;
@@ -35,6 +34,7 @@ import fun.asgc.neutrino.proxy.server.controller.res.PortPoolListRes;
import fun.asgc.neutrino.proxy.server.controller.res.PortPoolUpdateEnableStatusRes;
import fun.asgc.neutrino.proxy.server.service.PortPoolService;
import fun.asgc.neutrino.proxy.server.util.ParamCheckUtil;
import org.noear.solon.annotation.*;
import java.util.List;
@@ -43,27 +43,29 @@ import java.util.List;
* @author: aoshiguchen
* @date: 2022/8/7
*/
@NonIntercept
@RequestMapping("port-pool")
@RestController
@Mapping("/port-pool")
@Controller
public class PortPoolController {
@Autowired
@Inject
private PortPoolService portPoolService;
@GetMapping("page")
@Get
@Mapping("/page")
public Page<PortPoolListRes> page(PageQuery pageQuery, PortPoolListReq req) {
ParamCheckUtil.checkNotNull(pageQuery, "pageQuery");
return portPoolService.page(pageQuery, req);
}
@GetMapping("list")
@Get
@Mapping("/list")
public List<PortPoolListRes> list(PortPoolListReq req) {
return portPoolService.list(req);
}
@OnlyAdmin
@PostMapping("create")
@Post
@Mapping("/create")
public PortPoolCreateRes create(@RequestBody PortPoolCreateReq req) {
ParamCheckUtil.checkNotNull(req, "req");
ParamCheckUtil.checkNotNull(req.getPort(), "port");
@@ -72,7 +74,8 @@ public class PortPoolController {
}
@OnlyAdmin
@PostMapping("update/enable-status")
@Post
@Mapping("/update/enable-status")
public PortPoolUpdateEnableStatusRes updateEnableStatus(@RequestBody PortPoolUpdateEnableStatusReq req) {
ParamCheckUtil.checkNotNull(req, "req");
ParamCheckUtil.checkNotNull(req.getId(), "id");
@@ -82,7 +85,8 @@ public class PortPoolController {
}
@OnlyAdmin
@PostMapping("delete")
@Post
@Mapping("/delete")
public void delete(@RequestParam("id") Integer id) {
ParamCheckUtil.checkNotNull(id, "id");
@@ -21,13 +21,8 @@
*/
package fun.asgc.neutrino.proxy.server.controller;
import fun.asgc.neutrino.core.annotation.Autowired;
import fun.asgc.neutrino.core.annotation.NonIntercept;
import fun.asgc.neutrino.core.db.page.Page;
import fun.asgc.neutrino.core.db.page.PageQuery;
import fun.asgc.neutrino.core.web.annotation.GetMapping;
import fun.asgc.neutrino.core.web.annotation.RequestMapping;
import fun.asgc.neutrino.core.web.annotation.RestController;
import fun.asgc.neutrino.proxy.server.controller.req.LicenseFlowReportReq;
import fun.asgc.neutrino.proxy.server.controller.req.UserFlowReportReq;
import fun.asgc.neutrino.proxy.server.controller.res.LicenseFlowReportRes;
@@ -35,18 +30,21 @@ import fun.asgc.neutrino.proxy.server.controller.res.ReportDataViewRes;
import fun.asgc.neutrino.proxy.server.controller.res.UserFlowReportRes;
import fun.asgc.neutrino.proxy.server.service.ReportService;
import fun.asgc.neutrino.proxy.server.util.ParamCheckUtil;
import org.noear.solon.annotation.Controller;
import org.noear.solon.annotation.Get;
import org.noear.solon.annotation.Inject;
import org.noear.solon.annotation.Mapping;
/**
* 报表管理
* @author: aoshiguchen
* @date: 2022/9/12
*/
@NonIntercept
@RequestMapping("report")
@RestController
@Mapping("/report")
@Controller
public class ReportController {
@Autowired
@Inject
private ReportService reportService;
/**
@@ -62,7 +60,8 @@ public class ReportController {
* 4、点击历史流量:下方展示历史流量折线图。筛选项:日/月 日期选择:日(展示最近30天,最多跨30日),月(展示最近12个月,最多跨12个月)
* @return
*/
@GetMapping("data-view")
@Get
@Mapping("/data-view")
public ReportDataViewRes dataView() {
return new ReportDataViewRes()
.setUserOnlineNumber(2).setEnableUserNumber(3).setUserNumber(5)
@@ -78,7 +77,8 @@ public class ReportController {
* @param req
* @return
*/
@GetMapping("user/flow-report/page")
@Get
@Mapping("/user/flow-report/page")
public Page<UserFlowReportRes> userFlowReportPage(PageQuery pageQuery, UserFlowReportReq req) {
ParamCheckUtil.checkNotNull(pageQuery, "pageQuery");
@@ -91,7 +91,8 @@ public class ReportController {
* @param req
* @return
*/
@GetMapping("license/flow-report/page")
@Get
@Mapping("/license/flow-report/page")
public Page<LicenseFlowReportRes> licenseFlowReportPage(PageQuery pageQuery, LicenseFlowReportReq req) {
ParamCheckUtil.checkNotNull(pageQuery, "pageQuery");
@@ -21,11 +21,10 @@
*/
package fun.asgc.neutrino.proxy.server.controller;
import fun.asgc.neutrino.core.annotation.Autowired;
import fun.asgc.neutrino.core.annotation.NonIntercept;
import fun.asgc.neutrino.core.db.page.Page;
import fun.asgc.neutrino.core.db.page.PageQuery;
import fun.asgc.neutrino.core.web.annotation.*;
import fun.asgc.neutrino.core.web.annotation.RequestBody;
import fun.asgc.neutrino.core.web.annotation.RequestParam;
import fun.asgc.neutrino.proxy.server.base.rest.SystemContextHolder;
import fun.asgc.neutrino.proxy.server.base.rest.annotation.OnlyAdmin;
import fun.asgc.neutrino.proxy.server.constant.ExceptionConstant;
@@ -36,6 +35,7 @@ import fun.asgc.neutrino.proxy.server.dal.entity.UserDO;
import fun.asgc.neutrino.proxy.server.service.UserService;
import fun.asgc.neutrino.proxy.server.util.Md5Util;
import fun.asgc.neutrino.proxy.server.util.ParamCheckUtil;
import org.noear.solon.annotation.*;
import java.util.List;
@@ -44,35 +44,38 @@ import java.util.List;
* @author: aoshiguchen
* @date: 2022/7/31
*/
@NonIntercept
@RequestMapping("user")
@RestController
@Mapping("/user")
@Controller
public class UserController {
@Autowired
@Inject
private UserService userService;
@Autowired
@Inject
private UserMapper userMapper;
@GetMapping("page")
@Get
@Mapping("/page")
public Page<UserListRes> page(PageQuery pageQuery, UserListReq req) {
ParamCheckUtil.checkNotNull(pageQuery, "pageQuery");
return userService.page(pageQuery, req);
}
@GetMapping("list")
@Get
@Mapping("/list")
public List<UserListRes> list(UserListReq req) {
return userService.list(req);
}
@GetMapping("info")
@Get
@Mapping("/info")
public UserInfoRes info(UserInfoReq req) {
return userService.info(req);
}
@OnlyAdmin
@PostMapping("update/enable-status")
@Post
@Mapping("/update/enable-status")
public UserUpdateEnableStatusRes updateEnableStatus(@RequestBody UserUpdateEnableStatusReq req) {
ParamCheckUtil.checkNotNull(req, "req");
ParamCheckUtil.checkNotNull(req.getId(), "id");
@@ -82,7 +85,8 @@ public class UserController {
}
@OnlyAdmin
@PostMapping("create")
@Post
@Mapping("/create")
public UserCreateRes create(@RequestBody UserCreateReq req) {
ParamCheckUtil.checkNotNull(req, "req");
ParamCheckUtil.checkNotEmpty(req.getName(), "name");
@@ -92,7 +96,8 @@ public class UserController {
}
@OnlyAdmin
@PostMapping("update")
@Post
@Mapping("/update")
public UserUpdateRes update(@RequestBody UserUpdateReq req) {
ParamCheckUtil.checkNotNull(req, "req");
ParamCheckUtil.checkNotNull(req.getId(), "id");
@@ -103,7 +108,8 @@ public class UserController {
}
@OnlyAdmin
@PostMapping("update/password")
@Post
@Mapping("/update/password")
public UserUpdatePasswordRes updatePassword(@RequestBody UserUpdatePasswordReq req) {
ParamCheckUtil.checkNotNull(req, "req");
ParamCheckUtil.checkNotNull(req.getId(), "id");
@@ -113,7 +119,8 @@ public class UserController {
return userService.updatePassword(req);
}
@PostMapping("current-user/update/password")
@Post
@Mapping("/current-user/update/password")
public UserUpdatePasswordRes currentUserUpdatePassword(@RequestBody UserUpdatePasswordReq req) {
ParamCheckUtil.checkNotNull(req, "req");
ParamCheckUtil.checkNotEmpty(req.getOldLoginPassword(), "oldLoginPassword");
@@ -129,7 +136,8 @@ public class UserController {
}
@OnlyAdmin
@PostMapping("delete")
@Post
@Mapping("/delete")
public void delete(@RequestParam("id") Integer id) {
ParamCheckUtil.checkNotNull(id, "id");
@@ -21,30 +21,29 @@
*/
package fun.asgc.neutrino.proxy.server.controller;
import fun.asgc.neutrino.core.annotation.Autowired;
import fun.asgc.neutrino.core.annotation.NonIntercept;
import fun.asgc.neutrino.core.db.page.Page;
import fun.asgc.neutrino.core.db.page.PageQuery;
import fun.asgc.neutrino.core.web.annotation.GetMapping;
import fun.asgc.neutrino.core.web.annotation.RequestMapping;
import fun.asgc.neutrino.core.web.annotation.RestController;
import fun.asgc.neutrino.proxy.server.controller.req.UserLoginRecordListReq;
import fun.asgc.neutrino.proxy.server.controller.res.UserLoginRecordListRes;
import fun.asgc.neutrino.proxy.server.service.UserLoginRecordService;
import fun.asgc.neutrino.proxy.server.util.ParamCheckUtil;
import org.noear.solon.annotation.Controller;
import org.noear.solon.annotation.Get;
import org.noear.solon.annotation.Inject;
import org.noear.solon.annotation.Mapping;
/**
* @author: aoshiguchen
* @date: 2022/10/20
*/
@NonIntercept
@RequestMapping("user-login-record")
@RestController
@Mapping("/user-login-record")
@Controller
public class UserLoginRecordController {
@Autowired
@Inject
private UserLoginRecordService userLoginRecordService;
@GetMapping("page")
@Get
@Mapping("/page")
public Page<UserLoginRecordListRes> page(PageQuery pageQuery, UserLoginRecordListReq req) {
ParamCheckUtil.checkNotNull(pageQuery, "pageQuery");
@@ -18,13 +18,13 @@ neutrino:
key-store-password: 123456
key-manager-password: 123456
jks-path: classpath:/test.jks
data:
db:
type: sqlite
url: jdbc:sqlite:data.db
driver-class: org.sqlite.JDBC
username:
password:
# data:
# db:
# type: sqlite
# url: jdbc:sqlite:data.db
# driver-class: org.sqlite.JDBC
# username:
# password:
#添加MIME印射(如果有需要?)
#是否启用静态文件服务。(可不配,默认为启用)
Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 12 KiB