mirror of
				https://github.com/continew-org/continew-admin.git
				synced 2025-11-04 10:57:10 +08:00 
			
		
		
		
	style: 优化社交身份认证注释为三方账号认证
This commit is contained in:
		@@ -69,7 +69,7 @@ public class CacheConsts {
 | 
			
		||||
    public static final String DASHBOARD_KEY_PREFIX = "DASHBOARD";
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 社交身份认证状态键前缀
 | 
			
		||||
     * 三方账号认证状态键前缀
 | 
			
		||||
     */
 | 
			
		||||
    public static final String SOCIAL_AUTH_STATE_KEY_PREFIX = "SOCIAL_AUTH_STATE";
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -42,10 +42,10 @@ public interface LoginService {
 | 
			
		||||
    String login(String username, String password);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 社交身份登录
 | 
			
		||||
     * 三方账号登录
 | 
			
		||||
     *
 | 
			
		||||
     * @param authUser
 | 
			
		||||
     *            社交身份信息
 | 
			
		||||
     *            三方账号信息
 | 
			
		||||
     * @return 令牌
 | 
			
		||||
     */
 | 
			
		||||
    String socialLogin(AuthUser authUser);
 | 
			
		||||
 
 | 
			
		||||
@@ -62,7 +62,7 @@ public interface UserSocialService {
 | 
			
		||||
     * 绑定
 | 
			
		||||
     * 
 | 
			
		||||
     * @param authUser
 | 
			
		||||
     *            社交身份信息
 | 
			
		||||
     *            三方账号信息
 | 
			
		||||
     * @param userId
 | 
			
		||||
     *            用户 ID
 | 
			
		||||
     */
 | 
			
		||||
 
 | 
			
		||||
@@ -53,7 +53,7 @@ const useUserStore = defineStore('user', {
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    // 社交身份登录
 | 
			
		||||
    // 三方账号身份登录
 | 
			
		||||
    async socialLogin(source: string, req: any) {
 | 
			
		||||
      try {
 | 
			
		||||
        const res = await userSocialLogin(source, req);
 | 
			
		||||
 
 | 
			
		||||
@@ -44,13 +44,13 @@ import me.zhyd.oauth.request.AuthRequest;
 | 
			
		||||
import me.zhyd.oauth.utils.AuthStateUtils;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 社交身份认证 API
 | 
			
		||||
 * 三方账号认证 API
 | 
			
		||||
 *
 | 
			
		||||
 * @author Charles7c
 | 
			
		||||
 * @since 2023/10/8 22:52
 | 
			
		||||
 */
 | 
			
		||||
@Log(module = "登录")
 | 
			
		||||
@Tag(name = "社交身份认证 API")
 | 
			
		||||
@Tag(name = "三方账号认证 API")
 | 
			
		||||
@SaIgnore
 | 
			
		||||
@RestController
 | 
			
		||||
@RequiredArgsConstructor
 | 
			
		||||
@@ -60,7 +60,7 @@ public class SocialAuthController {
 | 
			
		||||
    private final LoginService loginService;
 | 
			
		||||
    private final AuthRequestFactory authRequestFactory;
 | 
			
		||||
 | 
			
		||||
    @Operation(summary = "社交身份登录授权", description = "社交身份登录授权")
 | 
			
		||||
    @Operation(summary = "三方账号登录授权", description = "三方账号登录授权")
 | 
			
		||||
    @Parameter(name = "source", description = "来源", example = "gitee", in = ParameterIn.PATH)
 | 
			
		||||
    @GetMapping("/{source}")
 | 
			
		||||
    public R authorize(@PathVariable String source) {
 | 
			
		||||
@@ -68,7 +68,7 @@ public class SocialAuthController {
 | 
			
		||||
        return R.ok("操作成功", authRequest.authorize(AuthStateUtils.createState()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Operation(summary = "社交身份登录", description = "社交身份登录")
 | 
			
		||||
    @Operation(summary = "三方账号登录", description = "三方账号登录")
 | 
			
		||||
    @Parameter(name = "source", description = "来源", example = "gitee", in = ParameterIn.PATH)
 | 
			
		||||
    @PostMapping("/{source}")
 | 
			
		||||
    public LoginVO login(@PathVariable String source, @RequestBody AuthCallback callback) {
 | 
			
		||||
@@ -87,7 +87,7 @@ public class SocialAuthController {
 | 
			
		||||
        try {
 | 
			
		||||
            return authRequestFactory.get(source);
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            throw new BadRequestException(String.format("暂不支持 [%s] 登录", source));
 | 
			
		||||
            throw new BadRequestException(String.format("暂不支持 [%s] 平台账号登录", source));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -121,9 +121,9 @@ public class UserCenterController {
 | 
			
		||||
        return R.ok("修改成功");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Operation(summary = "查询绑定的第三方账号", description = "查询绑定的第三方账号")
 | 
			
		||||
    @Operation(summary = "查询绑定的三方账号", description = "查询绑定的三方账号")
 | 
			
		||||
    @GetMapping("/social")
 | 
			
		||||
    public List<UserSocialBindVO> listSocial() {
 | 
			
		||||
    public List<UserSocialBindVO> listSocialBind() {
 | 
			
		||||
        List<UserSocialDO> userSocialList = userSocialService.listByUserId(LoginHelper.getUserId());
 | 
			
		||||
        return userSocialList.stream().map(userSocial -> {
 | 
			
		||||
            String source = userSocial.getSource();
 | 
			
		||||
@@ -134,7 +134,7 @@ public class UserCenterController {
 | 
			
		||||
        }).collect(Collectors.toList());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Operation(summary = "绑定第三方账号", description = "绑定第三方账号")
 | 
			
		||||
    @Operation(summary = "绑定三方账号", description = "绑定三方账号")
 | 
			
		||||
    @Parameter(name = "source", description = "来源", example = "gitee", in = ParameterIn.PATH)
 | 
			
		||||
    @PostMapping("/social/{source}")
 | 
			
		||||
    public R bindSocial(@PathVariable String source, @RequestBody AuthCallback callback) {
 | 
			
		||||
@@ -146,7 +146,7 @@ public class UserCenterController {
 | 
			
		||||
        return R.ok("绑定成功");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Operation(summary = "解绑第三方账号", description = "解绑第三方账号")
 | 
			
		||||
    @Operation(summary = "解绑三方账号", description = "解绑三方账号")
 | 
			
		||||
    @Parameter(name = "source", description = "来源", example = "gitee", in = ParameterIn.PATH)
 | 
			
		||||
    @DeleteMapping("/social/{source}")
 | 
			
		||||
    public R unbindSocial(@PathVariable String source) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user