From 69a3c374ca3afb770e3b9ffcbdda07ce362cbf58 Mon Sep 17 00:00:00 2001
From: 1 <1@123>
Date: 星期五, 09 一月 2026 19:59:29 +0800
Subject: [PATCH] #

---
 rsf-open-api/src/main/java/com/vincent/rsf/openApi/controller/example/AppAuthExampleController.java |   98 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 98 insertions(+), 0 deletions(-)

diff --git a/rsf-open-api/src/main/java/com/vincent/rsf/openApi/controller/example/AppAuthExampleController.java b/rsf-open-api/src/main/java/com/vincent/rsf/openApi/controller/example/AppAuthExampleController.java
new file mode 100644
index 0000000..37d71ef
--- /dev/null
+++ b/rsf-open-api/src/main/java/com/vincent/rsf/openApi/controller/example/AppAuthExampleController.java
@@ -0,0 +1,98 @@
+package com.vincent.rsf.openApi.controller.example;
+
+import com.vincent.rsf.openApi.entity.dto.CommonResponse;
+import com.vincent.rsf.openApi.security.utils.AuthUtils;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * App璁よ瘉浣跨敤绀轰緥鎺у埗鍣�
+ * 
+ * 婕旂ず濡備綍鍦ㄦ帶鍒跺櫒涓娇鐢ˋppId璁よ瘉
+ * 
+ * @author vincent
+ * @since 2026-01-05
+ */
+@RestController
+@RequestMapping("/example/auth")
+@Api(tags = "App璁よ瘉浣跨敤绀轰緥")
+public class AppAuthExampleController {
+
+    /**
+     * 闇�瑕丄pp璁よ瘉鐨勬帴鍙gず渚�
+     * 
+     * @param request HTTP璇锋眰
+     * @return 鍝嶅簲缁撴灉
+     */
+    @ApiOperation("闇�瑕丄pp璁よ瘉鐨勬帴鍙gず渚�")
+    @GetMapping("/protected")
+    public CommonResponse protectedEndpoint(HttpServletRequest request) {
+        // 鑾峰彇璁よ瘉鐨凙ppId
+        String appId = AuthUtils.getAppId(request);
+        
+        // 妫�鏌ユ槸鍚﹀凡璁よ瘉
+        if (appId == null) {
+            return CommonResponse.error("鏈�氳繃App璁よ瘉");
+        }
+        
+        return CommonResponse.ok()
+                .setMsg("璁块棶鎴愬姛")
+                .setData("璁よ瘉鐨凙ppId: " + appId);
+    }
+
+    /**
+     * 鑾峰彇褰撳墠璁よ瘉鐨凙pp淇℃伅
+     * 
+     * @param request HTTP璇锋眰
+     * @return App淇℃伅
+     */
+    @ApiOperation("鑾峰彇褰撳墠璁よ瘉鐨凙pp淇℃伅")
+    @GetMapping("/app-info")
+    public CommonResponse getAppInfo(HttpServletRequest request) {
+        String appId = AuthUtils.getAppId(request);
+        
+        if (appId == null) {
+            return CommonResponse.error("鏈�氳繃App璁よ瘉");
+        }
+        
+        return CommonResponse.ok()
+                .setMsg("鑾峰彇App淇℃伅鎴愬姛")
+                .setData("褰撳墠AppId: " + appId);
+    }
+
+    /**
+     * 鏃犻渶璁よ瘉鐨勫叕寮�鎺ュ彛
+     * 
+     * @return 鍝嶅簲缁撴灉
+     */
+    @ApiOperation("鏃犻渶璁よ瘉鐨勫叕寮�鎺ュ彛")
+    @GetMapping("/public")
+    public CommonResponse publicEndpoint() {
+        return CommonResponse.ok()
+                .setMsg("鍏紑鎺ュ彛璁块棶鎴愬姛")
+                .setData("浠讳綍浜洪兘鍙互璁块棶姝ゆ帴鍙�");
+    }
+
+    /**
+     * 妫�鏌ヨ璇佺姸鎬�
+     * 
+     * @param request HTTP璇锋眰
+     * @return 璁よ瘉鐘舵��
+     */
+    @ApiOperation("妫�鏌ヨ璇佺姸鎬�")
+    @PostMapping("/check-auth")
+    public CommonResponse checkAuth(HttpServletRequest request) {
+        boolean isAuthenticated = AuthUtils.isAuthenticated(request);
+        String appId = AuthUtils.getAppId(request);
+        
+        return CommonResponse.ok()
+                .setMsg("璁よ瘉妫�鏌ュ畬鎴�")
+                .setData("isAuthenticated: " + isAuthenticated + ", appId: " + appId);
+    }
+}

--
Gitblit v1.9.1