From 84560eab857f3cc1c4ee6bd4bd8608830aceecdc Mon Sep 17 00:00:00 2001 From: songhuangfeng123 <shf18767906695@163.com> Date: 星期一, 04 七月 2022 13:57:47 +0800 Subject: [PATCH] Merge branches 'genchuang' and 'master' of https://sinanoaq.cn:8888/r/safePlatform-out into genchuang --- safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/accountController/LoginController.java | 8 ++-- safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/exception/GlobalExceptionHandler.java | 14 +++++++ safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/security/TokenAuthenticationFilter.java | 5 +- safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/security/WebSecurityConfig.java | 1 safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/accountController/UserController.java | 26 +++++++++++++ safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/accountController/MenuController.java | 8 ++-- emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/controller/Test.java | 5 +- 7 files changed, 54 insertions(+), 13 deletions(-) diff --git a/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/controller/Test.java b/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/controller/Test.java index d50e075..86be956 100644 --- a/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/controller/Test.java +++ b/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/controller/Test.java @@ -1,6 +1,7 @@ package com.gkhy.safePlatform.emergency.controller; -import com.gkhy.safePlatform.account.rpc.apimodel.UserAccountService; +import com.gkhy.safePlatform.account.rpc.apimodel.AccountAuthService; +import com.gkhy.safePlatform.account.rpc.apimodel.AccountAuthService; import org.apache.dubbo.config.annotation.DubboReference; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; @@ -12,7 +13,7 @@ public class Test { @DubboReference(check = false) - private UserAccountService userAccountService; + private AccountAuthService accountAuthService; // @Autowired // private DemoService demoService; diff --git a/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/accountController/LoginController.java b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/accountController/LoginController.java index 608b319..d139e52 100644 --- a/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/accountController/LoginController.java +++ b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/accountController/LoginController.java @@ -1,7 +1,7 @@ package com.gkhy.safePlatform.accountController; import com.alibaba.fastjson.JSONObject; -import com.gkhy.safePlatform.account.rpc.apimodel.UserAccountService; +import com.gkhy.safePlatform.account.rpc.apimodel.AccountAuthService; import com.gkhy.safePlatform.account.rpc.apimodel.model.resp.MenuRPCRespDTO; import com.gkhy.safePlatform.account.rpc.apimodel.model.resp.UserLoginRPCRespDTO; import com.gkhy.safePlatform.commons.vo.ResultVO; @@ -20,18 +20,18 @@ public class LoginController { @DubboReference(check = false) - private UserAccountService userAccountService; + private AccountAuthService accountAuthService; @RequestMapping("/login") public ResultVO<UserLoginRPCRespDTO> authLogin(@RequestBody JSONObject loginForm){ String username = loginForm.getString("username"); String password = loginForm.getString("password"); - return userAccountService.authLogin(username, password); + return accountAuthService.authLogin(username, password); } @RequestMapping("/menu") public ResultVO<List<MenuRPCRespDTO>> getMenu(Principal principal, Long projectId){ String userId = principal.getName(); - return userAccountService.getMenu(Long.valueOf(userId), projectId); + return accountAuthService.getMenu(Long.valueOf(userId), projectId); } } diff --git a/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/accountController/MenuController.java b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/accountController/MenuController.java index 6bd9dd2..07fc726 100644 --- a/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/accountController/MenuController.java +++ b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/accountController/MenuController.java @@ -1,6 +1,6 @@ package com.gkhy.safePlatform.accountController; -import com.gkhy.safePlatform.account.rpc.apimodel.UserAccountService; +import com.gkhy.safePlatform.account.rpc.apimodel.AccountMenuService; import com.gkhy.safePlatform.account.rpc.apimodel.model.req.MenuAddRPCReqDTO; import com.gkhy.safePlatform.account.rpc.apimodel.model.resp.MenuModRPCReqDTO; import com.gkhy.safePlatform.commons.enums.ResultCodes; @@ -18,7 +18,7 @@ public class MenuController { @DubboReference(check = false) - private UserAccountService userAccountService; + private AccountMenuService accountMenuService; /** @@ -27,7 +27,7 @@ @RequestMapping(value = "/add",method = RequestMethod.POST) public ResultVO<String> addMenu(Principal principal, @RequestBody MenuAddRPCReqDTO menuAddDto) { String userId = principal.getName(); - return userAccountService.addMenu(Long.valueOf(userId), menuAddDto); + return accountMenuService.addMenu(Long.valueOf(userId), menuAddDto); } @@ -37,7 +37,7 @@ @RequestMapping(value = "/mod",method = RequestMethod.POST) public ResultVO<String> addMenu(Principal principal, @RequestBody MenuModRPCReqDTO menuModDto) { String userId = principal.getName(); - return userAccountService.modMenu(Long.valueOf(userId), menuModDto); + return accountMenuService.modMenu(Long.valueOf(userId), menuModDto); } } diff --git a/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/accountController/UserController.java b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/accountController/UserController.java new file mode 100644 index 0000000..a7d00ff --- /dev/null +++ b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/accountController/UserController.java @@ -0,0 +1,26 @@ +package com.gkhy.safePlatform.accountController; + +import com.gkhy.safePlatform.account.rpc.apimodel.AccountMenuService; +import com.gkhy.safePlatform.account.rpc.apimodel.AccountUserService; +import com.gkhy.safePlatform.account.rpc.apimodel.model.req.query.AccountRPCQuery; +import com.gkhy.safePlatform.commons.query.PageQuery; +import org.apache.dubbo.config.annotation.DubboReference; +import org.apache.dubbo.config.annotation.DubboService; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.security.Principal; + +@RestController +@RequestMapping("/account") +public class UserController { + + @DubboReference(check = false) + private AccountUserService accountUserService; + + + @RequestMapping("/page/list") + public Object getUserPage(Principal principal, PageQuery<AccountRPCQuery> rpcQueryPageQuery) { + return accountUserService.getAccountPage(Long.valueOf(principal.getName()), rpcQueryPageQuery); + } +} diff --git a/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/exception/GlobalExceptionHandler.java b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/exception/GlobalExceptionHandler.java index 75b7c2f..7e23d1d 100644 --- a/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/exception/GlobalExceptionHandler.java +++ b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/exception/GlobalExceptionHandler.java @@ -9,6 +9,7 @@ import org.slf4j.LoggerFactory; import org.springframework.security.access.AccessDeniedException; import org.springframework.security.core.AuthenticationException; +import org.springframework.web.HttpRequestMethodNotSupportedException; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseBody; @@ -67,6 +68,19 @@ /** + * @Description: 请求方法 + */ + @ResponseBody + @ExceptionHandler(value = HttpRequestMethodNotSupportedException.class) + public ResultVO DHandler(HttpRequestMethodNotSupportedException e) { + ResultVO resultVO = new ResultVO(); + resultVO.setCode(ResultCodes.CLIENT_METHOD_NOT_MATCH.getCode()); + resultVO.setMsg(e.getMessage()); + return resultVO; + + } + + /** * 系统错误异常 */ @ResponseBody diff --git a/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/security/TokenAuthenticationFilter.java b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/security/TokenAuthenticationFilter.java index a6ba791..ae3b0f6 100644 --- a/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/security/TokenAuthenticationFilter.java +++ b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/security/TokenAuthenticationFilter.java @@ -2,7 +2,8 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; -import com.gkhy.safePlatform.account.rpc.apimodel.UserAccountService; +import com.gkhy.safePlatform.account.rpc.apimodel.AccountAuthService; +import com.gkhy.safePlatform.account.rpc.apimodel.AccountAuthService; import com.gkhy.safePlatform.commons.co.CacheAuthority; import com.gkhy.safePlatform.commons.co.CacheUser; import com.gkhy.safePlatform.commons.enums.RedisKeyEnum; @@ -37,7 +38,7 @@ @Autowired private TokenConfig tokenConfig; @DubboReference(check = false) - private UserAccountService userAccountService; + private AccountAuthService userAccountService; diff --git a/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/security/WebSecurityConfig.java b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/security/WebSecurityConfig.java index 7bd4a36..9d0e1fa 100644 --- a/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/security/WebSecurityConfig.java +++ b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/security/WebSecurityConfig.java @@ -1,6 +1,5 @@ package com.gkhy.safePlatform.config.security; -import com.gkhy.safePlatform.account.rpc.apimodel.UserAccountService; import com.gkhy.safePlatform.config.security.customzie.CustomizeAccessDeniedHandler; import com.gkhy.safePlatform.config.security.customzie.CustomizeAuthenticationEntryPoint; import org.apache.dubbo.config.annotation.DubboReference; -- Gitblit v1.9.2