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; + } + }