luoshi 3 years ago
parent
commit
d80906b4ae

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

@@ -10,7 +10,7 @@ import org.springframework.web.bind.annotation.RestController;
 
 @RestController
 @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/auth")
-@Aac(strict = BOOL.FALSE, auth = BOOL.TRUE)
+@Aac(auth = BOOL.TRUE)
 public class AuthController {
 
     @RequestMapping("/demo")

+ 28 - 0
api-demo/src/main/java/com/qmth/demo/api/controller/ExceptionController.java

@@ -0,0 +1,28 @@
+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.constant.ApiConstant;
+import com.qmth.boot.core.exception.ReentrantException;
+import com.qmth.boot.core.exception.StatusException;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/exception")
+@Aac(strict = BOOL.FALSE, auth = BOOL.FALSE)
+public class ExceptionController {
+
+    @RequestMapping("/status")
+    public Object status(@RequestParam(required = false) Integer code, @RequestParam(required = false) String name,
+            @RequestParam String message) {
+        throw new StatusException(code, name, message, null);
+    }
+
+    @RequestMapping("/reentrant")
+    public Object reentrant(@RequestParam(required = false) String message) {
+        throw new ReentrantException(message);
+    }
+
+}

+ 1 - 1
api-demo/src/main/java/com/qmth/demo/api/controller/LockController.java

@@ -23,7 +23,7 @@ public class LockController {
 
     @RequestMapping("/lock")
     @Locks({ @Lockable(name = "test", key = "#key", type = LockType.READ),
-            @Lockable(name = "test", key = "#key", timeout = 0) })
+            @Lockable(name = "test2", key = "#key", timeout = 0) })
     public Object lock(@RequestParam String key) {
         return key;
     }

+ 2 - 0
api-demo/src/main/java/com/qmth/demo/api/db/UserQuery.java

@@ -6,12 +6,14 @@ import org.springframework.validation.annotation.Validated;
 
 import javax.validation.constraints.Max;
 import javax.validation.constraints.Min;
+import javax.validation.constraints.NotBlank;
 
 @Validated
 public class UserQuery extends BaseQuery<User> {
 
     private static final long serialVersionUID = 5160957717754609086L;
 
+    @NotBlank(message = "User.name不能为空")
     private String name;
 
     private Boolean enable;

+ 1 - 2
api-demo/src/main/java/com/qmth/demo/api/service/DemoTaskService.java

@@ -2,7 +2,6 @@ package com.qmth.demo.api.service;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 
 @Service
@@ -10,7 +9,7 @@ public class DemoTaskService {
 
     private Logger log = LoggerFactory.getLogger(DemoTaskService.class);
 
-    @Scheduled(fixedDelay = 5000, initialDelay = 5000)
+    //@Scheduled(fixedDelay = 5000, initialDelay = 5000)
     //@Lockable(name = "fixDelayTask", timeout = 0)
     public void fixDelayTask() {
         log.info("fix delay task running");

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

@@ -1,7 +1,7 @@
 server.port=8080
 
 #com.qmth.api.uri-prefix=/aaa
-#com.qmth.api.metrics-endpoint=/metrics
+com.qmth.api.metrics-endpoint=/metrics
 #com.qmth.api.global-auth=false
 #com.qmth.api.global-strict=false
 #com.qmth.api.global-rate-limit=1/5s