From e2a8e343243dc10db83fbafaa336b8360b544b71 Mon Sep 17 00:00:00 2001 From: zxc <954985706@qq.com> Date: Fri, 10 Jul 2020 09:22:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E7=AC=AC=E4=B8=89=E6=96=B9?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/AuthRedirectController.java | 37 +++++++++++++++++++ .../controller/WeChatNotifyController.java | 31 ---------------- .../com/epmet/dao/AuthorizationInfoDao.java | 8 ++++ .../epmet/dao/ComponentAccessTokenDao.java | 2 + .../main/java/com/epmet/dao/FuncInfoDao.java | 12 ++++++ .../java/com/epmet/dao/PreAuthTokenDao.java | 7 ++++ .../dao/RefreshAuthorizerAccessTokenDao.java | 12 ++++++ .../service/ComponentVerifyTicketService.java | 6 --- .../ComponentVerifyTicketServiceImpl.java | 12 ++++++ .../resources/mapper/AuthorizationInfoDao.xml | 5 +++ .../mapper/ComponentAccessTokenDao.xml | 4 ++ .../src/main/resources/mapper/FuncInfoDao.xml | 6 +++ .../main/resources/mapper/PreAuthTokenDao.xml | 6 +++ .../RefreshAuthorizerAccessTokenDao.xml | 5 +++ 14 files changed, 116 insertions(+), 37 deletions(-) create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/AuthRedirectController.java diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/AuthRedirectController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/AuthRedirectController.java new file mode 100644 index 0000000000..cb38cf1014 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/AuthRedirectController.java @@ -0,0 +1,37 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.Result; +import com.epmet.service.ComponentVerifyTicketService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * @Author zxc + * @CreateTime 2020/7/10 9:04 + */ +@RestController +@RequestMapping("mpweb") +public class AuthRedirectController { + + @Autowired + private ComponentVerifyTicketService componentVerifyTicketService; + + /** + * @Description 授权回调URL + * @param + * @author zxc + */ + public Result redirectUri(HttpServletRequest request, HttpServletResponse response, @LoginUser TokenDto tokenDto, @RequestParam("authAppId")String authAppId){ + componentVerifyTicketService.redirectUri(request,response,tokenDto,authAppId); + return new Result(); + } + +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/WeChatNotifyController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/WeChatNotifyController.java index f9e98d5114..a63583e38c 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/WeChatNotifyController.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/WeChatNotifyController.java @@ -1,15 +1,10 @@ package com.epmet.controller; -import com.epmet.commons.tools.annotation.LoginUser; -import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.service.ComponentVerifyTicketService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - /** * @Author zxc * @CreateTime 2020/7/8 15:06 @@ -44,16 +39,6 @@ public class WeChatNotifyController { return new Result(); } - /** - * @Description 使用授权码获取授权信息 - * @author zxc - */ - /*@PostMapping(value = "/authinfobyauthcode") - public Result authInfoByAuthCode() { - componentVerifyTicketService.authInfoByAuthCode(); - return new Result(); - }*/ - /** * @Description 获取/刷新接口调用令牌 * @author zxc @@ -64,20 +49,4 @@ public class WeChatNotifyController { return new Result(); } - /** - * @Description 授权回调URL - * @param - * @author zxc - */ - @PostMapping("redirecturi") - public Result redirectUri(HttpServletRequest request, HttpServletResponse response, @LoginUser TokenDto tokenDto, @PathVariable String authAppId){ - componentVerifyTicketService.redirectUri(request,response,tokenDto,authAppId); - return new Result(); - } - - @PostMapping("merge") - public Result merge(){ - - return new Result(); - } } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthorizationInfoDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthorizationInfoDao.java index 908d924afb..02539669af 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthorizationInfoDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthorizationInfoDao.java @@ -21,6 +21,7 @@ import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.form.AuthorizationInfoFormDTO; import com.epmet.entity.AuthorizationInfoEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; /** * 授权信息表 @@ -37,5 +38,12 @@ public interface AuthorizationInfoDao extends BaseDao { * @author zxc */ void insertAuthorizationInfo(AuthorizationInfoFormDTO formDTO); + + /** + * @Description 逻辑删除授权信息 + * @param customerId + * @author zxc + */ + void updateOldAuthorizationInfo(@Param("customerId")String customerId); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ComponentAccessTokenDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ComponentAccessTokenDao.java index 12666b9f01..4615c22728 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ComponentAccessTokenDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ComponentAccessTokenDao.java @@ -37,5 +37,7 @@ public interface ComponentAccessTokenDao extends BaseDao { + /** + * @Description 插入授权列表信息 + * @param funcInfoList + * @author zxc + */ void insertFuncInfo(@Param("funcInfoList") List funcInfoList); + + /** + * @Description 逻辑删除 权限列表 + * @param customerId + * @author zxc + */ + void updateOldFuncInfo(@Param("customerId")String customerId); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PreAuthTokenDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PreAuthTokenDao.java index 36e0dce88b..defe7f5bb0 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PreAuthTokenDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PreAuthTokenDao.java @@ -37,5 +37,12 @@ public interface PreAuthTokenDao extends BaseDao { * @author zxc */ void insertPreAuthToken(PreAuthTokenFormDTO formDTO); + + /** + * @Description 逻辑删 pre_auth_code + * @param + * @author zxc + */ + void updateOldPreAuthCode(); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/RefreshAuthorizerAccessTokenDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/RefreshAuthorizerAccessTokenDao.java index c6293fbd37..ecd62336d5 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/RefreshAuthorizerAccessTokenDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/RefreshAuthorizerAccessTokenDao.java @@ -22,6 +22,7 @@ import com.epmet.dto.form.AuthorizerAccessTokenFormDTO; import com.epmet.dto.result.WillOverDueResultDTO; import com.epmet.entity.RefreshAuthorizerAccessTokenEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -41,7 +42,18 @@ public interface RefreshAuthorizerAccessTokenDao extends BaseDao checkWillOverDue(); + /** + * @Description 插入 authorizer_access_token + * @param refreshAccessToken + * @author zxc + */ void insertAuthorizerAccessToken(AuthorizerAccessTokenFormDTO refreshAccessToken); + /** + * @Description 逻辑删除 授权方的authorizer_access_token + * @param customerId + * @author zxc + */ + void updateOldAuthorizerAccessToken(@Param("customerId")String customerId); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/ComponentVerifyTicketService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/ComponentVerifyTicketService.java index d12d7cce9a..a20ff2d1f4 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/ComponentVerifyTicketService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/ComponentVerifyTicketService.java @@ -31,12 +31,6 @@ public interface ComponentVerifyTicketService { */ void preAuthCode(); - /** - * @Description 使用授权码获取授权信息 - * @author zxc - */ -// void authInfoByAuthCode(); - /** * @Description 获取/刷新接口调用令牌 * @param diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java index c223823929..f66db43c0e 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java @@ -156,6 +156,8 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe ComponentAccessTokenFormDTO formDTO = new ComponentAccessTokenFormDTO(); formDTO.setComponentAccessToken(componentAccessToken); formDTO.setExpiresIn(Integer.valueOf(expiresIn)); + //先逻辑删,在插入 + componentAccessTokenDao.updateOldComponentAccessToken(); componentAccessTokenDao.insertComponentAccessToken(formDTO); //存缓存 redisThird.setComponentAccessToken(componentAccessToken); @@ -192,6 +194,8 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe PreAuthTokenFormDTO formDTO = new PreAuthTokenFormDTO(); formDTO.setPreAuthToken(preAuthCode); formDTO.setExpiresIn(ex); + //先逻辑删除,在插入DB + preAuthTokenDao.updateOldPreAuthCode(); preAuthTokenDao.insertPreAuthToken(formDTO); //预授权码 放入缓存 redisThird.setPreAuthCode(preAuthCode,ex); @@ -229,6 +233,8 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe authInfoDTO.setAuthorizerRefreshToken(authorizationInfoResultDTO.getAuthorizer_refresh_token()); authInfoDTO.setExpiresIn(Integer.valueOf(authorizationInfoResultDTO.getExpires_in())); authInfoDTO.setCustomerId(customerId); + //先逻辑删除,在插入 + authorizationInfoDao.updateOldAuthorizationInfo(customerId); authorizationInfoDao.insertAuthorizationInfo(authInfoDTO); // 获取/刷新接口调用令牌记录表 插入 AuthorizerAccessTokenFormDTO refreshAccessToken = new AuthorizerAccessTokenFormDTO(); @@ -237,6 +243,8 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe refreshAccessToken.setAuthorizerAccessToken(authorizationInfoResultDTO.getAuthorizer_access_token()); refreshAccessToken.setAuthorizerRefreshToken(authorizationInfoResultDTO.getAuthorizer_refresh_token()); refreshAccessToken.setExpiresIn(Integer.valueOf(authorizationInfoResultDTO.getExpires_in())); + //先逻辑删除,再插入 + refreshAuthorizerAccessTokenDao.updateOldAuthorizerAccessToken(customerId); refreshAuthorizerAccessTokenDao.insertAuthorizerAccessToken(refreshAccessToken); // 2. 权限列表 List funcInfos = new ArrayList<>(); @@ -253,6 +261,8 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe fu.setCustomerId(customerId); funcInfos.add(fu); } + //先逻辑删除,在插入 + funcInfoDao.updateOldFuncInfo(customerId); funcInfoDao.insertFuncInfo(funcInfos); // 授权信息放入缓存 redisThird.setAuthInfo(authorizationInfoResultDTO); @@ -291,6 +301,8 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe formDTO.setExpiresIn(Integer.valueOf(expiresIn)); formDTO.setCustomerId(willOverDueDTO.getCustomerId()); formDTO.setAuthAppid(willOverDueDTO.getAuthAppId()); + //先逻辑删除,在插入 + refreshAuthorizerAccessTokenDao.updateOldAuthorizerAccessToken(willOverDueDTO.getCustomerId()); refreshAuthorizerAccessTokenDao.insertAuthorizerAccessToken(formDTO); //缓存 refreshAuthorizerAccessToken diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthorizationInfoDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthorizationInfoDao.xml index 88c9cb5b5a..97929fa2d6 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthorizationInfoDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthorizationInfoDao.xml @@ -36,4 +36,9 @@ ) + + + update authorization_info set del_flag = 0 where customer_id = #{customerId} + + \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ComponentAccessTokenDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ComponentAccessTokenDao.xml index bf76c092c8..7e294a150a 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ComponentAccessTokenDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ComponentAccessTokenDao.xml @@ -30,4 +30,8 @@ ) + + update component_access_token set del_flag = 1 + + \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/FuncInfoDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/FuncInfoDao.xml index 332b2e672f..0982fcefd6 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/FuncInfoDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/FuncInfoDao.xml @@ -16,6 +16,7 @@ + INSERT INTO func_info ( ID, FUNCSCOPE_CATEGORY, FUNCSCOPE_ID, CUSTOMER_ID, AUTHORIZATION_INFO_APPID, DEL_FLAG, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME ) @@ -35,4 +36,9 @@ + + + update func_info set del_flag = 0 where customer_id = #{customerId} + + \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PreAuthTokenDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PreAuthTokenDao.xml index e0eeb08e23..bac47ff2f3 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PreAuthTokenDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PreAuthTokenDao.xml @@ -14,6 +14,7 @@ + INSERT INTO pre_auth_token ( ID, PRE_AUTH_TOKEN, EXPIRES_IN, DEL_FLAG, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME ) VALUES @@ -29,4 +30,9 @@ ) + + + update pre_auth_token set del_flag = 0 + + \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/RefreshAuthorizerAccessTokenDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/RefreshAuthorizerAccessTokenDao.xml index 9670ff2e90..fbc94fa431 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/RefreshAuthorizerAccessTokenDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/RefreshAuthorizerAccessTokenDao.xml @@ -49,4 +49,9 @@ ) + + + update refresh_authorizer_access_token set del_flag = 0 where customer_id = #{customerId} + + \ No newline at end of file