Pārlūkot izejas kodu

Merge branch 'master' of http://gogs.chelvc.com/wuyongqiang/admin

woody 1 gadu atpakaļ
vecāks
revīzija
6a8fb417f9

+ 1 - 0
src/main/java/com/chelvc/cloud/admin/controller/AuthorizeController.java

@@ -11,6 +11,7 @@ import com.chelvc.framework.oauth.annotation.Authorize;
 import com.chelvc.framework.sms.CaptchaSmsHandler;
 import com.chelvc.framework.sms.SmsSession;
 import lombok.RequiredArgsConstructor;
+import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;

+ 7 - 6
src/main/java/com/chelvc/cloud/admin/controller/CategoryController.java

@@ -4,6 +4,7 @@ import javax.validation.Valid;
 import javax.validation.constraints.Min;
 
 import com.chelvc.cloud.vehicle.api.dto.CategoryDTO;
+import com.chelvc.cloud.vehicle.api.param.CategoryListParam;
 import com.chelvc.cloud.vehicle.api.param.CategoryModifyParam;
 import com.chelvc.cloud.vehicle.api.param.CategoryPagingParam;
 import com.chelvc.cloud.vehicle.api.service.CategoryService;
@@ -84,9 +85,9 @@ public class CategoryController {
      *
      * @return 分类信息列表
      */
-    @GetMapping("/categories")
-    public List<CategoryDTO> listCategories() {
-        return this.categoryService.listActiveCategories();
+    @PostMapping("/categories")
+    public List<CategoryDTO> listCategories(@RequestBody @Valid CategoryListParam param) {
+        return this.categoryService.listActiveCategories(param);
     }
 
     /**
@@ -94,8 +95,8 @@ public class CategoryController {
      *
      * @return 分类信息列表
      */
-    @GetMapping("/getRootCategories")
-    public List<CategoryDTO> getRootCategories() {
-        return this.categoryService.getRootCategories();
+    @PostMapping("/getRootCategories")
+    public List<CategoryDTO> getRootCategories(@RequestBody @Valid CategoryListParam param) {
+        return this.categoryService.getRootCategories(param);
     }
 }

+ 40 - 0
src/main/java/com/chelvc/cloud/admin/controller/SemaphoreTest.java

@@ -0,0 +1,40 @@
+package com.chelvc.cloud.admin.controller;
+
+import java.util.concurrent.Semaphore;
+
+public class SemaphoreTest {
+
+    private static Semaphore semaphore = new Semaphore(1);
+
+    public Semaphore getSemaphore() {
+        return semaphore;
+    }
+    public static void main(String[] args) {
+        // 模拟15辆车同时停车
+        for (int i = 0; i < 15; i++) {
+            Thread thread = new Thread(new Runnable() {
+                @Override
+                public void run() {
+                    try {
+                        System.out.println("=====" + Thread.currentThread().getName() + "车辆来到停车场");
+                        if (semaphore.availablePermits() == 0) {
+                            // 没有车位了
+                            System.out.println("车位不足,请耐心等待," + Thread.currentThread().getName() + "车辆正在等待");
+                        }
+                        // 获取车位停车
+                        semaphore.acquire();
+                        System.out.println(Thread.currentThread().getName()+"成功进入停车场");
+                        //模拟车辆在停车场停留的时间
+                        Thread.sleep(3000);
+                        //驶出停车场
+                        semaphore.release();
+                        System.out.println(Thread.currentThread().getName()+"驶出停车场");
+                    } catch (InterruptedException e) {
+                        e.printStackTrace();
+                    }
+                }
+            });
+            thread.start();
+        }
+    }
+}