diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/ProxyServer.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/ProxyServer.java index 93ebd620..9bc2731c 100644 --- a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/ProxyServer.java +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/ProxyServer.java @@ -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("*")); + }); } } diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/base/rest/config/WebConfigurerAdapter.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/base/rest/config/WebConfigurerAdapter.java deleted file mode 100644 index 6b35c18c..00000000 --- a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/base/rest/config/WebConfigurerAdapter.java +++ /dev/null @@ -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()); - } -} diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/base/rest/interceptor/BaseAuthInterceptor.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/base/rest/interceptor/BaseAuthInterceptor.java index 1a09a6b3..299d4db8 100644 --- a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/base/rest/interceptor/BaseAuthInterceptor.java +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/base/rest/interceptor/BaseAuthInterceptor.java @@ -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); + } } diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/base/rest/interceptor/CorsInterceptor.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/base/rest/interceptor/CorsInterceptor.java deleted file mode 100644 index 50334dd3..00000000 --- a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/base/rest/interceptor/CorsInterceptor.java +++ /dev/null @@ -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"); - } - -} diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/base/rest/interceptor/GlobalAdviceHandler.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/base/rest/interceptor/GlobalAdviceHandler.java deleted file mode 100644 index 06ccd1e7..00000000 --- a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/base/rest/interceptor/GlobalAdviceHandler.java +++ /dev/null @@ -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); - } - -} diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/base/rest/interceptor/GlobalExceptionFilter.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/base/rest/interceptor/GlobalExceptionFilter.java new file mode 100644 index 00000000..1563e250 --- /dev/null +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/base/rest/interceptor/GlobalExceptionFilter.java @@ -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))); + } + } +} diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/base/rest/interceptor/GlobalExceptionHandler.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/base/rest/interceptor/GlobalExceptionHandler.java deleted file mode 100644 index cecd7725..00000000 --- a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/base/rest/interceptor/GlobalExceptionHandler.java +++ /dev/null @@ -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)); - } - -} diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/ClientConnectRecordController.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/ClientConnectRecordController.java index 8ade1dde..8bcd8c5e 100644 --- a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/ClientConnectRecordController.java +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/ClientConnectRecordController.java @@ -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 page(PageQuery pageQuery, ClientConnectRecordListReq req) { ParamCheckUtil.checkNotNull(pageQuery, "pageQuery"); return clientConnectRecordService.page(pageQuery, req); diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/IndexController.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/IndexController.java index 912b5c03..0e705b31 100644 --- a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/IndexController.java +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/IndexController.java @@ -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(); } diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/JobInfoController.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/JobInfoController.java index 1ed25b21..b225d265 100644 --- a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/JobInfoController.java +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/JobInfoController.java @@ -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 page(PageQuery pageQuery, JobInfoListReq req) { ParamCheckUtil.checkNotNull(pageQuery, "pageQuery"); return jobInfoService.page(pageQuery, req); } - @GetMapping("findList") + @Get + @Mapping("/findList") public List 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"); diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/JobLogController.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/JobLogController.java index 16f80d38..cb0db7f2 100644 --- a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/JobLogController.java +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/JobLogController.java @@ -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 page(PageQuery pageQuery, JobLogListReq req) { ParamCheckUtil.checkNotNull(pageQuery, "pageQuery"); return jobLogService.page(pageQuery, req); diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/LicenseController.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/LicenseController.java index 3d0230ff..4ab23792 100644 --- a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/LicenseController.java +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/LicenseController.java @@ -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 page(PageQuery pageQuery, LicenseListReq req) { ParamCheckUtil.checkNotNull(pageQuery, "pageQuery"); return licenseService.page(pageQuery, req); } - @GetMapping("list") + @Mapping("/list") public List 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"); diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/PortMappingController.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/PortMappingController.java index 6af60752..426d471b 100644 --- a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/PortMappingController.java +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/PortMappingController.java @@ -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 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"); diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/PortPoolController.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/PortPoolController.java index 25910fd9..fd5141b9 100644 --- a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/PortPoolController.java +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/PortPoolController.java @@ -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 page(PageQuery pageQuery, PortPoolListReq req) { ParamCheckUtil.checkNotNull(pageQuery, "pageQuery"); return portPoolService.page(pageQuery, req); } - @GetMapping("list") + @Get + @Mapping("/list") public List 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"); diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/ReportController.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/ReportController.java index 053d5744..f5727b59 100644 --- a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/ReportController.java +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/ReportController.java @@ -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 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 licenseFlowReportPage(PageQuery pageQuery, LicenseFlowReportReq req) { ParamCheckUtil.checkNotNull(pageQuery, "pageQuery"); diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/UserController.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/UserController.java index c61affdd..777d4ab0 100644 --- a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/UserController.java +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/UserController.java @@ -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 page(PageQuery pageQuery, UserListReq req) { ParamCheckUtil.checkNotNull(pageQuery, "pageQuery"); return userService.page(pageQuery, req); } - @GetMapping("list") + @Get + @Mapping("/list") public List 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"); diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/UserLoginRecordController.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/UserLoginRecordController.java index 4b7dcb5d..c317f107 100644 --- a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/UserLoginRecordController.java +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/UserLoginRecordController.java @@ -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 page(PageQuery pageQuery, UserLoginRecordListReq req) { ParamCheckUtil.checkNotNull(pageQuery, "pageQuery"); diff --git a/neutrino-proxy-server/src/main/resources/app.yml b/neutrino-proxy-server/src/main/resources/app.yml index 2f651215..4b0d7852 100644 --- a/neutrino-proxy-server/src/main/resources/app.yml +++ b/neutrino-proxy-server/src/main/resources/app.yml @@ -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印射(如果有需要?) #是否启用静态文件服务。(可不配,默认为启用) diff --git a/neutrino-proxy-server/src/main/resources/static/favicon.ico b/neutrino-proxy-server/src/main/resources/static/favicon.ico index 474afb8c..4b526ba9 100644 Binary files a/neutrino-proxy-server/src/main/resources/static/favicon.ico and b/neutrino-proxy-server/src/main/resources/static/favicon.ico differ