Bladeren bron

增加authController范例

luoshi 4 jaren geleden
bovenliggende
commit
0382cf2264

+ 31 - 0
api-demo/src/main/java/com/qmth/demo/api/controller/AuthController.java

@@ -0,0 +1,31 @@
+package com.qmth.demo.api.controller;
+
+import com.qmth.boot.api.annotation.Aac;
+import com.qmth.boot.api.annotation.BOOL;
+import com.qmth.boot.api.config.ApiConfig;
+import com.qmth.boot.api.constant.ApiConstant;
+import com.qmth.boot.core.security.config.SecurityConfig;
+import com.qmth.demo.api.auth.DemoSession;
+import org.springframework.web.bind.annotation.RequestAttribute;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+
+@RestController
+@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/auth")
+@Aac(strict = BOOL.FALSE, auth = BOOL.TRUE)
+public class AuthController {
+
+    @Resource
+    private ApiConfig apiConfig;
+
+    @Resource
+    private SecurityConfig securityConfig;
+
+    @RequestMapping("/demo")
+    public Object security(@RequestAttribute DemoSession accessEntity) {
+        return accessEntity;
+    }
+
+}

+ 1 - 1
api-demo/src/main/resources/application.properties

@@ -10,6 +10,6 @@ server.port=8080
 #com.qmth.logging.root-level=info
 #com.qmth.logging.file-path=/Users/luoshi/Downloads/demo.log
 
-#com.qmth.cache.expire-after-write=30s
+com.qmth.cache.expire-after-write=30s
 
 com.qmth.redis.host=127.0.0.1