From ef722e04b194161716e3856935cd64d4663436a5 Mon Sep 17 00:00:00 2001 From: hu177768073 <177768073@qq.com> Date: Fri, 8 Nov 2024 16:08:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E4=BB=98=E5=AE=9D=E6=8E=88=E6=9D=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hfkj/controller/UserAuthController.java | 35 ++++++++++++++++--- .../user/UserAuthorizePlatformEnum.java | 15 ++++++++ 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/cweb/src/main/java/com/hfkj/controller/UserAuthController.java b/cweb/src/main/java/com/hfkj/controller/UserAuthController.java index ed372d0..4d48862 100644 --- a/cweb/src/main/java/com/hfkj/controller/UserAuthController.java +++ b/cweb/src/main/java/com/hfkj/controller/UserAuthController.java @@ -26,10 +26,7 @@ import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -88,4 +85,34 @@ public class UserAuthController { } } + @RequestMapping(value="/getUserAuthDetail",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "支付宝授权详情") + public ResponseData getUserAuthDetail(@RequestParam(value = "platform" , required = true) Integer platform) { + try { + UserSessionObject session = userCenter.getSessionModel(UserSessionObject.class); + UserAuthorizePlatformEnum platformEnum = UserAuthorizePlatformEnum.getDataByType(platform); + if (platformEnum == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知平台"); + } + return ResponseMsgUtil.success( userPlatformAuthorizeService.getUserAuth(session.getUser().getId(), platformEnum)); + + } catch (Exception e) { + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/getUserAuthList",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "用户授权列表") + public ResponseData getUserAuthList() { + try { + UserSessionObject session = userCenter.getSessionModel(UserSessionObject.class); + return ResponseMsgUtil.success( userPlatformAuthorizeService.getUserAuth(session.getUser().getId())); + + } catch (Exception e) { + return ResponseMsgUtil.exception(e); + } + } + } diff --git a/service/src/main/java/com/hfkj/sysenum/user/UserAuthorizePlatformEnum.java b/service/src/main/java/com/hfkj/sysenum/user/UserAuthorizePlatformEnum.java index e1f1fca..6a6d623 100644 --- a/service/src/main/java/com/hfkj/sysenum/user/UserAuthorizePlatformEnum.java +++ b/service/src/main/java/com/hfkj/sysenum/user/UserAuthorizePlatformEnum.java @@ -2,6 +2,8 @@ package com.hfkj.sysenum.user; import lombok.Getter; +import java.util.Objects; + /** * 用户账户记录来源 * @author hurui @@ -26,4 +28,17 @@ public enum UserAuthorizePlatformEnum { this.name = name; } + + /** + * 查询数据 + * @param code + * @return + */ + public static UserAuthorizePlatformEnum getDataByType(Integer code) { + for (UserAuthorizePlatformEnum ele : values()) { + if (Objects.equals(code,ele.getType())) return ele; + } + return null; + } + }