forked from yudaocode/SpringBoot-Labs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
YunaiV
committed
Apr 2, 2020
1 parent
d2d18b8
commit 8b1a03a
Showing
35 changed files
with
1,002 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...b52/seatademo/service/StorageService.java → ...b52/seatademo/service/ProductService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
lab-52/lab-52-multiple-datasource/src/main/resources/data.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# Order | ||
DROP DATABASE IF EXISTS seata_order; | ||
CREATE DATABASE seata_order; | ||
|
||
CREATE TABLE seata_order.orders | ||
( | ||
id INT(11) NOT NULL AUTO_INCREMENT, | ||
user_id INT(11) DEFAULT NULL, | ||
product_id INT(11) DEFAULT NULL, | ||
pay_amount DECIMAL(10, 0) DEFAULT NULL, | ||
add_time DATETIME DEFAULT CURRENT_TIMESTAMP, | ||
last_update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | ||
PRIMARY KEY (id) | ||
) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8; | ||
|
||
CREATE TABLE seata_order.undo_log | ||
( | ||
id BIGINT(20) NOT NULL AUTO_INCREMENT, | ||
branch_id BIGINT(20) NOT NULL, | ||
xid VARCHAR(100) NOT NULL, | ||
context VARCHAR(128) NOT NULL, | ||
rollback_info LONGBLOB NOT NULL, | ||
log_status INT(11) NOT NULL, | ||
log_created DATETIME NOT NULL, | ||
log_modified DATETIME NOT NULL, | ||
PRIMARY KEY (id), | ||
UNIQUE KEY ux_undo_log (xid, branch_id) | ||
) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8; | ||
|
||
# Product | ||
DROP DATABASE IF EXISTS seata_product; | ||
CREATE DATABASE seata_product; | ||
|
||
CREATE TABLE seata_product.product | ||
( | ||
id INT(11) NOT NULL AUTO_INCREMENT, | ||
stock INT(11) DEFAULT NULL, | ||
last_update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | ||
PRIMARY KEY (id) | ||
) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8; | ||
INSERT INTO seata_product.product (id, stock) VALUES (1, 10); # 插入一条产品的库存 | ||
|
||
CREATE TABLE seata_product.undo_log | ||
( | ||
id BIGINT(20) NOT NULL AUTO_INCREMENT, | ||
branch_id BIGINT(20) NOT NULL, | ||
xid VARCHAR(100) NOT NULL, | ||
context VARCHAR(128) NOT NULL, | ||
rollback_info LONGBLOB NOT NULL, | ||
log_status INT(11) NOT NULL, | ||
log_created DATETIME NOT NULL, | ||
log_modified DATETIME NOT NULL, | ||
PRIMARY KEY (id), | ||
UNIQUE KEY ux_undo_log (xid, branch_id) | ||
) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8; | ||
|
||
# Account | ||
DROP DATABASE IF EXISTS seata_account; | ||
CREATE DATABASE seata_account; | ||
|
||
CREATE TABLE seata_account.account | ||
( | ||
id INT(11) NOT NULL AUTO_INCREMENT, | ||
balance DOUBLE DEFAULT NULL, | ||
last_update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | ||
PRIMARY KEY (id) | ||
) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8; | ||
|
||
CREATE TABLE seata_account.undo_log | ||
( | ||
id BIGINT(20) NOT NULL AUTO_INCREMENT, | ||
branch_id BIGINT(20) NOT NULL, | ||
xid VARCHAR(100) NOT NULL, | ||
context VARCHAR(128) NOT NULL, | ||
rollback_info LONGBLOB NOT NULL, | ||
log_status INT(11) NOT NULL, | ||
log_created DATETIME NOT NULL, | ||
log_modified DATETIME NOT NULL, | ||
PRIMARY KEY (id), | ||
UNIQUE KEY ux_undo_log (xid, branch_id) | ||
) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8; | ||
INSERT INTO seata_account.account (id, balance) VALUES (1, 10); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# Order | ||
DROP DATABASE IF EXISTS seata_order; | ||
CREATE DATABASE seata_order; | ||
|
||
CREATE TABLE seata_order.orders | ||
( | ||
id INT(11) NOT NULL AUTO_INCREMENT, | ||
user_id INT(11) DEFAULT NULL, | ||
product_id INT(11) DEFAULT NULL, | ||
pay_amount DECIMAL(10, 0) DEFAULT NULL, | ||
add_time DATETIME DEFAULT CURRENT_TIMESTAMP, | ||
last_update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | ||
PRIMARY KEY (id) | ||
) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8; | ||
|
||
CREATE TABLE seata_order.undo_log | ||
( | ||
id BIGINT(20) NOT NULL AUTO_INCREMENT, | ||
branch_id BIGINT(20) NOT NULL, | ||
xid VARCHAR(100) NOT NULL, | ||
context VARCHAR(128) NOT NULL, | ||
rollback_info LONGBLOB NOT NULL, | ||
log_status INT(11) NOT NULL, | ||
log_created DATETIME NOT NULL, | ||
log_modified DATETIME NOT NULL, | ||
PRIMARY KEY (id), | ||
UNIQUE KEY ux_undo_log (xid, branch_id) | ||
) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8; | ||
|
||
# Product | ||
DROP DATABASE IF EXISTS seata_product; | ||
CREATE DATABASE seata_product; | ||
|
||
CREATE TABLE seata_product.product | ||
( | ||
id INT(11) NOT NULL AUTO_INCREMENT, | ||
stock INT(11) DEFAULT NULL, | ||
last_update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | ||
PRIMARY KEY (id) | ||
) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8; | ||
INSERT INTO seata_product.product (id, stock) VALUES (1, 10); # 插入一条产品的库存 | ||
|
||
CREATE TABLE seata_product.undo_log | ||
( | ||
id BIGINT(20) NOT NULL AUTO_INCREMENT, | ||
branch_id BIGINT(20) NOT NULL, | ||
xid VARCHAR(100) NOT NULL, | ||
context VARCHAR(128) NOT NULL, | ||
rollback_info LONGBLOB NOT NULL, | ||
log_status INT(11) NOT NULL, | ||
log_created DATETIME NOT NULL, | ||
log_modified DATETIME NOT NULL, | ||
PRIMARY KEY (id), | ||
UNIQUE KEY ux_undo_log (xid, branch_id) | ||
) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8; | ||
|
||
# Account | ||
DROP DATABASE IF EXISTS seata_account; | ||
CREATE DATABASE seata_account; | ||
|
||
CREATE TABLE seata_account.account | ||
( | ||
id INT(11) NOT NULL AUTO_INCREMENT, | ||
balance DOUBLE DEFAULT NULL, | ||
last_update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | ||
PRIMARY KEY (id) | ||
) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8; | ||
|
||
CREATE TABLE seata_account.undo_log | ||
( | ||
id BIGINT(20) NOT NULL AUTO_INCREMENT, | ||
branch_id BIGINT(20) NOT NULL, | ||
xid VARCHAR(100) NOT NULL, | ||
context VARCHAR(128) NOT NULL, | ||
rollback_info LONGBLOB NOT NULL, | ||
log_status INT(11) NOT NULL, | ||
log_created DATETIME NOT NULL, | ||
log_modified DATETIME NOT NULL, | ||
PRIMARY KEY (id), | ||
UNIQUE KEY ux_undo_log (xid, branch_id) | ||
) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8; | ||
INSERT INTO seata_account.account (id, balance) VALUES (1, 10); |
14 changes: 14 additions & 0 deletions
14
lab-53/lab-53-seata-at-dubbo-demo/lab-53-seata-at-dubbo-demo-account-service-api/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>lab-53-seata-at-dubbo-demo</artifactId> | ||
<groupId>cn.iocoder.springboot.labs</groupId> | ||
<version>1.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>lab-53-seata-at-dubbo-demo-account-service-api</artifactId> | ||
|
||
</project> |
17 changes: 17 additions & 0 deletions
17
...vice-api/src/main/java/cn/iocoder/springboot/lab53/accountservice/api/AccountService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package cn.iocoder.springboot.lab53.accountservice.api; | ||
|
||
/** | ||
* 账户 Service | ||
*/ | ||
public interface AccountService { | ||
|
||
/** | ||
* 扣除余额 | ||
* | ||
* @param userId 用户编号 | ||
* @param price 扣减金额 | ||
* @throws Exception 失败时抛出异常 | ||
*/ | ||
void reduceBalance(Long userId, Integer price) throws Exception; | ||
|
||
} |
Oops, something went wrong.