|
@@ -7,6 +7,8 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
import space.anyi.seataAccountMicroService.service.AccountService;
|
|
import space.anyi.seataAccountMicroService.service.AccountService;
|
|
|
|
|
|
|
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* @ProjectName: distributedSystemLearn
|
|
* @ProjectName: distributedSystemLearn
|
|
|
* @FileName: AccountController
|
|
* @FileName: AccountController
|
|
@@ -20,6 +22,13 @@ public class AccountController {
|
|
|
private AccountService accountService;
|
|
private AccountService accountService;
|
|
|
@PostMapping("/account/reduce")
|
|
@PostMapping("/account/reduce")
|
|
|
public ResponseResult reduce(@RequestParam("userId")Long userId, @RequestParam("money")Integer money){
|
|
public ResponseResult reduce(@RequestParam("userId")Long userId, @RequestParam("money")Integer money){
|
|
|
|
|
+ //模拟耗时操作
|
|
|
|
|
+ try {
|
|
|
|
|
+ TimeUnit.SECONDS.sleep(12);
|
|
|
|
|
+ } catch (InterruptedException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ //扣减账户余额
|
|
|
accountService.reduce(userId,money);
|
|
accountService.reduce(userId,money);
|
|
|
return ResponseResult.okResult(200,"扣减账户余额OK");
|
|
return ResponseResult.okResult(200,"扣减账户余额OK");
|
|
|
}
|
|
}
|