所有服务追加400ms处理时间

master
Administrator 3 years ago
parent 2ea1632b32
commit 2ea03363d1

@ -13,7 +13,8 @@ public class ItemStockController {
private static int stock = 10; private static int stock = 10;
@GetMapping("/decr") @GetMapping("/decr")
public void decr(){ public void decr() throws InterruptedException {
Thread.sleep(400);
stock--; stock--;
if(stock < 0){ if(stock < 0){
throw new RuntimeException("商品库存不足!"); throw new RuntimeException("商品库存不足!");

@ -11,7 +11,8 @@ import org.springframework.web.bind.annotation.RestController;
public class OrderManageController { public class OrderManageController {
@GetMapping("create") @GetMapping("create")
public void create(){ public void create() throws InterruptedException {
Thread.sleep(400);
System.out.println("创建订单成功!"); System.out.println("创建订单成功!");
} }

@ -11,7 +11,8 @@ import org.springframework.web.bind.annotation.RestController;
public class CouponController { public class CouponController {
@GetMapping("/coupon") @GetMapping("/coupon")
public void coupon(){ public void coupon() throws InterruptedException {
Thread.sleep(400);
System.out.println("优惠券预扣除成功!"); System.out.println("优惠券预扣除成功!");
} }

@ -11,7 +11,8 @@ import org.springframework.web.bind.annotation.RestController;
public class UserPointsController { public class UserPointsController {
@GetMapping("/up") @GetMapping("/up")
public void up(){ public void up() throws InterruptedException {
Thread.sleep(400);
System.out.println("扣除用户积分成功!!"); System.out.println("扣除用户积分成功!!");
} }

@ -11,7 +11,8 @@ import org.springframework.web.bind.annotation.RestController;
public class BusinessController { public class BusinessController {
@GetMapping("/notify") @GetMapping("/notify")
public void notifyBusiness(){ public void notifyBusiness() throws InterruptedException {
Thread.sleep(400);
System.out.println("通知商家成功!!"); System.out.println("通知商家成功!!");
} }

Loading…
Cancel
Save