From f5da5f64a16d3b595ec0079f012a9ab108d71261 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E5=BF=97=E4=BC=9F?= Date: Sun, 22 May 2022 20:18:29 +0800 Subject: [PATCH 1/2] move samples to dbpack-samples --- samples/go/README.md | 67 ---- samples/go/aggregation_svc/main.go | 61 --- samples/go/aggregation_svc/svc/svc.go | 123 ------ samples/go/config1.yaml | 28 -- samples/go/config2.yaml | 43 --- samples/go/config3.yaml | 43 --- samples/go/go.mod | 32 -- samples/go/go.sum | 123 ------ samples/go/order_svc/dao/dao.go | 125 ------- samples/go/order_svc/main.go | 74 ---- samples/go/product_svc/dao/dao.go | 61 --- samples/go/product_svc/main.go | 78 ---- samples/java/README.md | 69 ---- samples/java/aggregation/.gitignore | 34 -- .../.mvn/wrapper/maven-wrapper.properties | 2 - samples/java/aggregation/mvnw | 310 --------------- samples/java/aggregation/mvnw.cmd | 182 --------- samples/java/aggregation/pom.xml | 71 ---- .../aggregation/AggregationApplication.java | 29 -- .../dbpack/aggregation/BaseController.java | 53 --- .../aggregation/SnowflakeIdGenerator.java | 106 ------ .../dbpack/aggregation/StandResponse.java | 76 ---- .../aggregation/StandResponseBuilder.java | 49 --- .../controller/OrderController.java | 46 --- .../dbpack/aggregation/entity/SoItem.java | 136 ------- .../dbpack/aggregation/entity/SoMaster.java | 342 ----------------- .../aggregation/req/AllocateInventoryReq.java | 39 -- .../aggregation/req/CreateOrderReq.java | 53 --- .../aggregation/service/OrderService.java | 102 ----- .../src/main/resources/application.properties | 1 - .../AggregationApplicationTests.java | 29 -- samples/java/config1.yaml | 28 -- samples/java/config2.yaml | 43 --- samples/java/config3.yaml | 43 --- samples/java/order/.gitignore | 34 -- .../.mvn/wrapper/maven-wrapper.properties | 2 - samples/java/order/mvnw | 310 --------------- samples/java/order/mvnw.cmd | 182 --------- samples/java/order/pom.xml | 69 ---- .../cectc/dbpack/order/BaseController.java | 53 --- .../cectc/dbpack/order/OrderApplication.java | 29 -- .../dbpack/order/SnowflakeIdGenerator.java | 107 ------ .../com/cectc/dbpack/order/StandResponse.java | 76 ---- .../dbpack/order/StandResponseBuilder.java | 49 --- .../dbpack/order/controller/SoController.java | 45 --- .../com/cectc/dbpack/order/entity/SoItem.java | 146 -------- .../cectc/dbpack/order/entity/SoMaster.java | 352 ------------------ .../dbpack/order/mapper/SoItemMapper.java | 30 -- .../dbpack/order/mapper/SoMasterMapper.java | 63 ---- .../cectc/dbpack/order/service/SoService.java | 65 ---- .../src/main/resources/application.properties | 6 - .../dbpack/order/OrderApplicationTests.java | 29 -- samples/java/product/.gitignore | 34 -- .../.mvn/wrapper/maven-wrapper.properties | 2 - samples/java/product/mvnw | 310 --------------- samples/java/product/mvnw.cmd | 182 --------- samples/java/product/pom.xml | 68 ---- .../cectc/dbpack/product/BaseController.java | 53 --- .../dbpack/product/ProductApplication.java | 29 -- .../cectc/dbpack/product/StandResponse.java | 76 ---- .../dbpack/product/StandResponseBuilder.java | 49 --- .../product/controller/ProductController.java | 45 --- .../dbpack/product/entity/Inventory.java | 108 ------ .../cectc/dbpack/product/entity/Product.java | 278 -------------- .../dbpack/product/mapper/ProductMapper.java | 27 -- .../product/req/AllocateInventoryReq.java | 39 -- .../product/service/ProductService.java | 38 -- .../src/main/resources/application.properties | 6 - .../product/ProductApplicationTests.java | 29 -- samples/php/README.md | 74 ---- samples/php/aggregation_svc/.htaccess | 4 - samples/php/aggregation_svc/index.php | 52 --- samples/php/aggregation_svc/svc/svc.php | 101 ----- samples/php/config1.yaml | 28 -- samples/php/config2.yaml | 43 --- samples/php/config3.yaml | 43 --- samples/php/order_svc/.htaccess | 4 - samples/php/order_svc/index.php | 43 --- samples/php/order_svc/svc/svc.php | 116 ------ samples/php/product_svc/.htaccess | 4 - samples/php/product_svc/index.php | 43 --- samples/php/product_svc/svc/svc.php | 73 ---- samples/python/README.md | 69 ---- samples/python/aggregation/__init__.py | 0 samples/python/aggregation/app.py | 66 ---- samples/python/config1.yaml | 28 -- samples/python/config2.yaml | 43 --- samples/python/config3.yaml | 43 --- samples/python/order/__init__.py | 0 samples/python/order/app.py | 69 ---- samples/python/product/__init__ .py | 0 samples/python/product/app.py | 35 -- samples/python/requirements.txt | 3 - samples/python/sqlacodegen.sh | 4 - samples/scripts/order.sql | 87 ----- samples/scripts/product.sql | 96 ----- 96 files changed, 6892 deletions(-) delete mode 100644 samples/go/README.md delete mode 100644 samples/go/aggregation_svc/main.go delete mode 100644 samples/go/aggregation_svc/svc/svc.go delete mode 100644 samples/go/config1.yaml delete mode 100644 samples/go/config2.yaml delete mode 100644 samples/go/config3.yaml delete mode 100644 samples/go/go.mod delete mode 100644 samples/go/go.sum delete mode 100644 samples/go/order_svc/dao/dao.go delete mode 100644 samples/go/order_svc/main.go delete mode 100644 samples/go/product_svc/dao/dao.go delete mode 100644 samples/go/product_svc/main.go delete mode 100644 samples/java/README.md delete mode 100644 samples/java/aggregation/.gitignore delete mode 100644 samples/java/aggregation/.mvn/wrapper/maven-wrapper.properties delete mode 100755 samples/java/aggregation/mvnw delete mode 100644 samples/java/aggregation/mvnw.cmd delete mode 100644 samples/java/aggregation/pom.xml delete mode 100644 samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/AggregationApplication.java delete mode 100644 samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/BaseController.java delete mode 100644 samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/SnowflakeIdGenerator.java delete mode 100644 samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/StandResponse.java delete mode 100644 samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/StandResponseBuilder.java delete mode 100644 samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/controller/OrderController.java delete mode 100644 samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/entity/SoItem.java delete mode 100644 samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/entity/SoMaster.java delete mode 100644 samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/req/AllocateInventoryReq.java delete mode 100644 samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/req/CreateOrderReq.java delete mode 100644 samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/service/OrderService.java delete mode 100644 samples/java/aggregation/src/main/resources/application.properties delete mode 100644 samples/java/aggregation/src/test/java/com/cectc/dbpack/aggregation/AggregationApplicationTests.java delete mode 100644 samples/java/config1.yaml delete mode 100644 samples/java/config2.yaml delete mode 100644 samples/java/config3.yaml delete mode 100644 samples/java/order/.gitignore delete mode 100644 samples/java/order/.mvn/wrapper/maven-wrapper.properties delete mode 100755 samples/java/order/mvnw delete mode 100644 samples/java/order/mvnw.cmd delete mode 100644 samples/java/order/pom.xml delete mode 100644 samples/java/order/src/main/java/com/cectc/dbpack/order/BaseController.java delete mode 100644 samples/java/order/src/main/java/com/cectc/dbpack/order/OrderApplication.java delete mode 100644 samples/java/order/src/main/java/com/cectc/dbpack/order/SnowflakeIdGenerator.java delete mode 100644 samples/java/order/src/main/java/com/cectc/dbpack/order/StandResponse.java delete mode 100644 samples/java/order/src/main/java/com/cectc/dbpack/order/StandResponseBuilder.java delete mode 100644 samples/java/order/src/main/java/com/cectc/dbpack/order/controller/SoController.java delete mode 100644 samples/java/order/src/main/java/com/cectc/dbpack/order/entity/SoItem.java delete mode 100644 samples/java/order/src/main/java/com/cectc/dbpack/order/entity/SoMaster.java delete mode 100644 samples/java/order/src/main/java/com/cectc/dbpack/order/mapper/SoItemMapper.java delete mode 100644 samples/java/order/src/main/java/com/cectc/dbpack/order/mapper/SoMasterMapper.java delete mode 100644 samples/java/order/src/main/java/com/cectc/dbpack/order/service/SoService.java delete mode 100644 samples/java/order/src/main/resources/application.properties delete mode 100644 samples/java/order/src/test/java/com/cectc/dbpack/order/OrderApplicationTests.java delete mode 100644 samples/java/product/.gitignore delete mode 100644 samples/java/product/.mvn/wrapper/maven-wrapper.properties delete mode 100755 samples/java/product/mvnw delete mode 100644 samples/java/product/mvnw.cmd delete mode 100644 samples/java/product/pom.xml delete mode 100644 samples/java/product/src/main/java/com/cectc/dbpack/product/BaseController.java delete mode 100644 samples/java/product/src/main/java/com/cectc/dbpack/product/ProductApplication.java delete mode 100644 samples/java/product/src/main/java/com/cectc/dbpack/product/StandResponse.java delete mode 100644 samples/java/product/src/main/java/com/cectc/dbpack/product/StandResponseBuilder.java delete mode 100644 samples/java/product/src/main/java/com/cectc/dbpack/product/controller/ProductController.java delete mode 100644 samples/java/product/src/main/java/com/cectc/dbpack/product/entity/Inventory.java delete mode 100644 samples/java/product/src/main/java/com/cectc/dbpack/product/entity/Product.java delete mode 100644 samples/java/product/src/main/java/com/cectc/dbpack/product/mapper/ProductMapper.java delete mode 100644 samples/java/product/src/main/java/com/cectc/dbpack/product/req/AllocateInventoryReq.java delete mode 100644 samples/java/product/src/main/java/com/cectc/dbpack/product/service/ProductService.java delete mode 100644 samples/java/product/src/main/resources/application.properties delete mode 100644 samples/java/product/src/test/java/com/cectc/dbpack/product/ProductApplicationTests.java delete mode 100644 samples/php/README.md delete mode 100644 samples/php/aggregation_svc/.htaccess delete mode 100644 samples/php/aggregation_svc/index.php delete mode 100644 samples/php/aggregation_svc/svc/svc.php delete mode 100644 samples/php/config1.yaml delete mode 100644 samples/php/config2.yaml delete mode 100644 samples/php/config3.yaml delete mode 100644 samples/php/order_svc/.htaccess delete mode 100644 samples/php/order_svc/index.php delete mode 100644 samples/php/order_svc/svc/svc.php delete mode 100644 samples/php/product_svc/.htaccess delete mode 100644 samples/php/product_svc/index.php delete mode 100644 samples/php/product_svc/svc/svc.php delete mode 100644 samples/python/README.md delete mode 100644 samples/python/aggregation/__init__.py delete mode 100644 samples/python/aggregation/app.py delete mode 100644 samples/python/config1.yaml delete mode 100644 samples/python/config2.yaml delete mode 100644 samples/python/config3.yaml delete mode 100644 samples/python/order/__init__.py delete mode 100644 samples/python/order/app.py delete mode 100644 samples/python/product/__init__ .py delete mode 100644 samples/python/product/app.py delete mode 100644 samples/python/requirements.txt delete mode 100644 samples/python/sqlacodegen.sh delete mode 100644 samples/scripts/order.sql delete mode 100644 samples/scripts/product.sql diff --git a/samples/go/README.md b/samples/go/README.md deleted file mode 100644 index 04c34b3..0000000 --- a/samples/go/README.md +++ /dev/null @@ -1,67 +0,0 @@ -# dbpack-samples - -### Step0: Clone dbpack -```shell -git clone git@github.com:cectc/dbpack.git -cd dbpack -``` - -### Step1: Setup etcd - -### Step2: Setup mysql, initialize the database with the following sql script -``` -./samples/scripts/order.sql -./samples/scripts/product.sql -``` - -### Step3: run dbpack -```bash -make build-local - -vim ./samples/go/config1.yaml -# update distributed_transaction.etcd_config.endpoints - -vim ./samples/go/config2.yaml -# update data_source_cluster.dsn -# update distributed_transaction.etcd_config.endpoints - -vim ./samples/go/config3.yaml -# update data_source_cluster.dsn -# update distributed_transaction.etcd_config.endpoints - -./dist/dbpack start --config ./samples/go/config1.yaml - -./dist/dbpack start --config ./samples/go/config2.yaml - -./dist/dbpack start --config ./samples/go/config3.yaml -``` - -### Step4: setup aggregation_svc client -```bash -cd samples/go/ - -go run aggregation_svc/main.go -``` - -### Step5: setup order_svc client -```bash -cd samples/go/ -vim ./order_svc/main.go -# update dsn - -go run order_svc/main.go -``` - -### Step6: setup product_svc client -```bash -cd samples/go/ -vim ./product_svc/main.go -# update dsn - -go run product_svc/main.go -``` - -### Step7: access and test -``` -curl -XPOST http://localhost:13000/v1/order/create -``` \ No newline at end of file diff --git a/samples/go/aggregation_svc/main.go b/samples/go/aggregation_svc/main.go deleted file mode 100644 index bc61e6f..0000000 --- a/samples/go/aggregation_svc/main.go +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2022 CECTC, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package main - -import ( - "github.com/gin-gonic/gin" - - "github.com/dbpack/samples/aggregation_svc/svc" -) - -func main() { - r := gin.Default() - - r.POST("/v1/order/create", func(c *gin.Context) { - xid := c.GetHeader("x_dbpack_xid") - err := svc.GetSvc().CreateSo(c, xid, false) - if err != nil { - c.JSON(400, gin.H{ - "success": false, - "message": "fail", - }) - } else { - c.JSON(200, gin.H{ - "success": true, - "message": "success", - }) - } - }) - - r.POST("/v1/order/create2", func(c *gin.Context) { - xid := c.GetHeader("x_dbpack_xid") - err := svc.GetSvc().CreateSo(c, xid, true) - if err != nil { - c.JSON(400, gin.H{ - "success": false, - "message": "fail", - }) - } else { - c.JSON(200, gin.H{ - "success": true, - "message": "success", - }) - } - }) - - r.Run(":3000") -} diff --git a/samples/go/aggregation_svc/svc/svc.go b/samples/go/aggregation_svc/svc/svc.go deleted file mode 100644 index 60e6a45..0000000 --- a/samples/go/aggregation_svc/svc/svc.go +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright 2022 CECTC, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package svc - -import ( - "bytes" - "context" - "encoding/json" - "errors" - "fmt" - "net/http" - - "github.com/dbpack/samples/order_svc/dao" - dao2 "github.com/dbpack/samples/product_svc/dao" -) - -type Svc struct { -} - -func GetSvc() *Svc { - return &Svc{} -} - -func (svc *Svc) CreateSo(ctx context.Context, xid string, rollback bool) error { - soMasters := []*dao.SoMaster{ - { - BuyerUserSysNo: 10001, - SellerCompanyCode: "SC001", - ReceiveDivisionSysNo: 110105, - ReceiveAddress: "beijing", - ReceiveZip: "000001", - ReceiveContact: "scott", - ReceiveContactPhone: "18728828296", - StockSysNo: 1, - PaymentType: 1, - SoAmt: 6999 * 2, - Status: 10, - AppID: "dk-order", - SoItems: []*dao.SoItem{ - { - ProductSysNo: 1, - ProductName: "apple iphone 13", - CostPrice: 6799, - OriginalPrice: 6799, - DealPrice: 6999, - Quantity: 2, - }, - }, - }, - } - - reqs := []*dao2.AllocateInventoryReq{{ - ProductSysNo: 1, - Qty: 2, - }} - - type rq1 struct { - Req []*dao.SoMaster - } - - type rq2 struct { - Req []*dao2.AllocateInventoryReq - } - - q1 := &rq1{Req: soMasters} - soReq, err := json.Marshal(q1) - req1, err := http.NewRequest("POST", "http://localhost:3001/createSo", bytes.NewBuffer(soReq)) - if err != nil { - panic(err) - } - req1.Header.Set("Content-Type", "application/json") - req1.Header.Set("xid", xid) - - client := &http.Client{} - result1, err1 := client.Do(req1) - if err1 != nil { - return err1 - } - - if result1.StatusCode == 400 { - return errors.New("err") - } - - q2 := &rq2{ - Req: reqs, - } - ivtReq, _ := json.Marshal(q2) - req2, err := http.NewRequest("POST", "http://localhost:3002/allocateInventory", bytes.NewBuffer(ivtReq)) - if err != nil { - panic(err) - } - req2.Header.Set("Content-Type", "application/json") - req2.Header.Set("xid", xid) - - result2, err2 := client.Do(req2) - if err2 != nil { - return err2 - } - - if result2.StatusCode == 400 { - return errors.New("err") - } - - if rollback { - fmt.Println("rollback") - return errors.New("there is a error") - } - return nil -} diff --git a/samples/go/config1.yaml b/samples/go/config1.yaml deleted file mode 100644 index 9099b85..0000000 --- a/samples/go/config1.yaml +++ /dev/null @@ -1,28 +0,0 @@ -listeners: - - protocol_type: http - socket_address: - address: 0.0.0.0 - port: 13000 - config: - backend_host: localhost:3000 - filters: - - httpDTFilter - -filters: - - name: httpDTFilter - kind: HttpDistributedTransaction - conf: - appid: aggregationSvc - transaction_infos: - - request_path: "/v1/order/create" - timeout: 60000 - - request_path: "/v1/order/create2" - timeout: 60000 - -distributed_transaction: - appid: aggregationSvc - retry_dead_threshold: 130000 - rollback_retry_timeout_unlock_enable: true - etcd_config: - endpoints: - - localhost:2379 \ No newline at end of file diff --git a/samples/go/config2.yaml b/samples/go/config2.yaml deleted file mode 100644 index c9348f9..0000000 --- a/samples/go/config2.yaml +++ /dev/null @@ -1,43 +0,0 @@ -listeners: - - protocol_type: mysql - socket_address: - address: 0.0.0.0 - port: 13307 - config: - users: - dksl: "123456" - server_version: "8.0.27" - executor: redirect - -executors: - - name: redirect - mode: sdb - config: - data_source_ref: product - -data_source_cluster: - - name: product - capacity: 30 - max_capacity: 100 - idle_timeout: 60s - dsn: root:123456@tcp(127.0.0.1:3306)/product?timeout=60s&readTimeout=60s&writeTimeout=60s&parseTime=true&loc=Local&charset=utf8mb4,utf8 - ping_interval: 20s - ping_times_for_change_status: 3 - filters: - - mysqlDTFilter - -filters: - - name: mysqlDTFilter - kind: MysqlDistributedTransaction - conf: - appid: productSvc - lock_retry_interval: 100ms - lock_retry_times: 15 - -distributed_transaction: - appid: productSvc - retry_dead_threshold: 130000 - rollback_retry_timeout_unlock_enable: true - etcd_config: - endpoints: - - localhost:2379 \ No newline at end of file diff --git a/samples/go/config3.yaml b/samples/go/config3.yaml deleted file mode 100644 index 4e0899a..0000000 --- a/samples/go/config3.yaml +++ /dev/null @@ -1,43 +0,0 @@ -listeners: - - protocol_type: mysql - socket_address: - address: 0.0.0.0 - port: 13308 - config: - users: - dksl: "123456" - server_version: "8.0.27" - executor: redirect - -executors: - - name: redirect - mode: sdb - config: - data_source_ref: order - -data_source_cluster: - - name: order - capacity: 30 - max_capacity: 100 - idle_timeout: 60s - dsn: root:123456@tcp(127.0.0.1:3306)/order?timeout=60s&readTimeout=60s&writeTimeout=60s&parseTime=true&loc=Local&charset=utf8mb4,utf8 - ping_interval: 20s - ping_times_for_change_status: 3 - filters: - - mysqlDTFilter - -filters: - - name: mysqlDTFilter - kind: MysqlDistributedTransaction - conf: - appid: orderSvc - lock_retry_interval: 100ms - lock_retry_times: 15 - -distributed_transaction: - appid: orderSvc - retry_dead_threshold: 130000 - rollback_retry_timeout_unlock_enable: true - etcd_config: - endpoints: - - localhost:2379 diff --git a/samples/go/go.mod b/samples/go/go.mod deleted file mode 100644 index 0975b55..0000000 --- a/samples/go/go.mod +++ /dev/null @@ -1,32 +0,0 @@ -module github.com/dbpack/samples - -go 1.18 - -require ( - github.com/cectc/dbpack v0.0.0-20220426064724-e9910501e32d - github.com/gin-gonic/gin v1.7.7 - github.com/go-sql-driver/mysql v1.6.0 - github.com/google/uuid v1.2.0 -) - -require ( - github.com/gin-contrib/sse v0.1.0 // indirect - github.com/go-playground/locales v0.13.0 // indirect - github.com/go-playground/universal-translator v0.17.0 // indirect - github.com/go-playground/validator/v10 v10.4.1 // indirect - github.com/golang/protobuf v1.5.2 // indirect - github.com/json-iterator/go v1.1.12 // indirect - github.com/leodido/go-urn v1.2.0 // indirect - github.com/mattn/go-isatty v0.0.12 // indirect - github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect - github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/natefinch/lumberjack v2.0.0+incompatible // indirect - github.com/ugorji/go/codec v1.1.7 // indirect - go.uber.org/atomic v1.9.0 // indirect - go.uber.org/multierr v1.7.0 // indirect - go.uber.org/zap v1.21.0 // indirect - golang.org/x/crypto v0.0.0-20220214200702-86341886e292 // indirect - golang.org/x/sys v0.0.0-20220412211240-33da011f77ad // indirect - google.golang.org/protobuf v1.27.1 // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect -) diff --git a/samples/go/go.sum b/samples/go/go.sum deleted file mode 100644 index a745e8e..0000000 --- a/samples/go/go.sum +++ /dev/null @@ -1,123 +0,0 @@ -github.com/BurntSushi/toml v1.1.0 h1:ksErzDEI1khOiGPgpwuI7x2ebx/uXQNw7xJpn9Eq1+I= -github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= -github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= -github.com/cectc/dbpack v0.0.0-20220426064724-e9910501e32d h1:EDToGjwwetBVt/eOt2f3Nl/+dX/b56t9ISjgXpLyXNc= -github.com/cectc/dbpack v0.0.0-20220426064724-e9910501e32d/go.mod h1:qdYG9EBxE0VWRg97qTyU3J2uw6X8GrIBgKr916jWNWU= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= -github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= -github.com/gin-gonic/gin v1.7.7 h1:3DoBmSbJbZAWqXJC3SLjAPfutPJJRN1U5pALB7EeTTs= -github.com/gin-gonic/gin v1.7.7/go.mod h1:axIBovoeJpVj8S3BwE0uPMTeReE4+AfFtqpqaZ1qq1U= -github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= -github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= -github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= -github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= -github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= -github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= -github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE= -github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4= -github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= -github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= -github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/uuid v1.2.0 h1:qJYtXnJRWmpe7m/3XlyhrsLrEURqHRM2kxzoxXqyUDs= -github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= -github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= -github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= -github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= -github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/natefinch/lumberjack v2.0.0+incompatible h1:4QJd3OLAMgj7ph+yZTuX13Ld4UpgHp07nNdFX7mqFfM= -github.com/natefinch/lumberjack v2.0.0+incompatible/go.mod h1:Wi9p2TTF5DG5oU+6YfsmYQpsTIOm0B1VNzQg9Mw6nPk= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= -github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs= -github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= -github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= -go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= -go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= -go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= -go.uber.org/multierr v1.7.0 h1:zaiO/rmgFjbmCXdSYJWQcdvOCsthmdaHfr3Gm2Kx4Ec= -go.uber.org/multierr v1.7.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= -go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8= -go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20220214200702-86341886e292 h1:f+lwQ+GtmgoY+A2YaQxlSOnDjXcQ7ZRLWOHbC6HtRqE= -golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220412211240-33da011f77ad h1:ntjMns5wyP/fN65tdBD4g8J5w8n015+iIIs9rtjXkY0= -golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= -google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/samples/go/order_svc/dao/dao.go b/samples/go/order_svc/dao/dao.go deleted file mode 100644 index d4a2238..0000000 --- a/samples/go/order_svc/dao/dao.go +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright 2022 CECTC, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package dao - -import ( - "context" - "database/sql" - "fmt" - "time" - - "github.com/cectc/dbpack/pkg/log" - "github.com/google/uuid" -) - -const ( - insertSoMaster = `INSERT /*+ XID('%s') */ INTO order.so_master (sysno, so_id, buyer_user_sysno, seller_company_code, - receive_division_sysno, receive_address, receive_zip, receive_contact, receive_contact_phone, stock_sysno, - payment_type, so_amt, status, order_date, appid, memo) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,now(),?,?)` - insertSoItem = `INSERT /*+ XID('%s') */ INTO order.so_item(sysno, so_sysno, product_sysno, product_name, cost_price, - original_price, deal_price, quantity) VALUES (?,?,?,?,?,?,?,?)` -) - -type Dao struct { - *sql.DB -} - -// SoMaster 现实中涉及金额可能使用长整形,这里使用 float64 仅作测试,不具有参考意义 -type SoMaster struct { - SysNo int64 `json:"sysNo"` - SoID string `json:"soID"` - BuyerUserSysNo int64 `json:"buyerUserSysNo"` - SellerCompanyCode string `json:"sellerCompanyCode"` - ReceiveDivisionSysNo int64 `json:"receiveDivisionSysNo"` - ReceiveAddress string `json:"receiveAddress"` - ReceiveZip string `json:"receiveZip"` - ReceiveContact string `json:"receiveContact"` - ReceiveContactPhone string `json:"receiveContactPhone"` - StockSysNo int64 `json:"stockSysNo"` - PaymentType int32 `json:"paymentType"` - SoAmt float64 `json:"soAmt"` - //10,创建成功,待支付;30;支付成功,待发货;50;发货成功,待收货;70,确认收货,已完成;90,下单失败;100已作废 - Status int32 `json:"status"` - OrderDate time.Time `json:"orderDate"` - PaymentDate time.Time `json:"paymentDate"` - DeliveryDate time.Time `json:"deliveryDate"` - ReceiveDate time.Time `json:"receiveDate"` - AppID string `json:"appID"` - Memo string `json:"memo"` - CreateUser string `json:"createUser"` - GmtCreate time.Time `json:"gmtCreate"` - ModifyUser string `json:"modifyUser"` - GmtModified time.Time `json:"gmtModified"` - - SoItems []*SoItem -} - -type SoItem struct { - SysNo int64 `json:"sysNo"` - SoSysNo int64 `json:"soSysNo"` - ProductSysNo int64 `json:"productSysNo"` - ProductName string `json:"productName"` - CostPrice float64 `json:"costPrice"` - OriginalPrice float64 `json:"originalPrice"` - DealPrice float64 `json:"dealPrice"` - Quantity int32 `json:"quantity"` -} - -func (dao *Dao) CreateSO(ctx context.Context, xid string, soMasters []*SoMaster) ([]uint64, error) { - result := make([]uint64, 0, len(soMasters)) - tx, err := dao.Begin() - if err != nil { - return nil, err - } - createSoMaster := fmt.Sprintf(insertSoMaster, xid) - createSoItem := fmt.Sprintf(insertSoItem, xid) - for _, soMaster := range soMasters { - soid := NextID() - _, err = tx.Exec(createSoMaster, soid, soid, soMaster.BuyerUserSysNo, soMaster.SellerCompanyCode, soMaster.ReceiveDivisionSysNo, - soMaster.ReceiveAddress, soMaster.ReceiveZip, soMaster.ReceiveContact, soMaster.ReceiveContactPhone, soMaster.StockSysNo, - soMaster.PaymentType, soMaster.SoAmt, soMaster.Status, soMaster.AppID, soMaster.Memo) - if err != nil { - if err != tx.Rollback() { - log.Error(err) - } - return nil, err - } - soItems := soMaster.SoItems - for _, soItem := range soItems { - soItemID := NextID() - _, err = tx.Exec(createSoItem, soItemID, soid, soItem.ProductSysNo, soItem.ProductName, soItem.CostPrice, soItem.OriginalPrice, - soItem.DealPrice, soItem.Quantity) - if err != nil { - if err != tx.Rollback() { - log.Error(err) - } - return nil, err - } - } - result = append(result, soid) - } - err = tx.Commit() - if err != nil { - return nil, err - } - return result, nil -} - -func NextID() uint64 { - id, _ := uuid.NewUUID() - return uint64(id.ID()) -} diff --git a/samples/go/order_svc/main.go b/samples/go/order_svc/main.go deleted file mode 100644 index c9d48a5..0000000 --- a/samples/go/order_svc/main.go +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2022 CECTC, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package main - -import ( - "database/sql" - "net/http" - "time" - - "github.com/gin-gonic/gin" - _ "github.com/go-sql-driver/mysql" // register mysql - - "github.com/dbpack/samples/order_svc/dao" -) - -var dsn = `dksl:123456@tcp(127.0.0.1:13308)/order?timeout=60s&readTimeout=60s&writeTimeout=60s&parseTime=true&loc=Local&charset=utf8mb4,utf8` - -func main() { - r := gin.Default() - - sqlDB, err := sql.Open("mysql", dsn) - if err != nil { - panic(err) - } - sqlDB.SetMaxOpenConns(100) - sqlDB.SetMaxIdleConns(20) - sqlDB.SetConnMaxLifetime(4 * time.Hour) - - d := &dao.Dao{ - DB: sqlDB, - } - - r.POST("/createSo", func(c *gin.Context) { - xid := c.GetHeader("xid") - - type req struct { - Req []*dao.SoMaster - } - var q req - if err := c.ShouldBindJSON(&q); err != nil { - c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) - return - } - - _, err := d.CreateSO(c, xid, q.Req) - - if err != nil { - c.JSON(400, gin.H{ - "success": false, - "message": "fail", - }) - } else { - c.JSON(200, gin.H{ - "success": true, - "message": "success", - }) - } - }) - r.Run(":3001") -} diff --git a/samples/go/product_svc/dao/dao.go b/samples/go/product_svc/dao/dao.go deleted file mode 100644 index b9010d0..0000000 --- a/samples/go/product_svc/dao/dao.go +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2022 CECTC, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package dao - -import ( - "context" - "database/sql" - "fmt" - - "github.com/cectc/dbpack/pkg/log" -) - -const ( - allocateInventorySql = `update /*+ XID('%s') */ product.inventory set available_qty = available_qty - ?, - allocated_qty = allocated_qty + ? where product_sysno = ? and available_qty >= ?` -) - -type Dao struct { - *sql.DB -} - -type AllocateInventoryReq struct { - ProductSysNo int64 - Qty int32 -} - -func (dao *Dao) AllocateInventory(ctx context.Context, xid string, reqs []*AllocateInventoryReq) error { - tx, err := dao.Begin() - if err != nil { - return err - } - updateInventory := fmt.Sprintf(allocateInventorySql, xid) - for _, req := range reqs { - _, err := tx.Exec(updateInventory, req.Qty, req.Qty, req.ProductSysNo, req.Qty) - if err != nil { - if err != tx.Rollback() { - log.Error(err) - } - return err - } - } - err = tx.Commit() - if err != nil { - return err - } - return nil -} diff --git a/samples/go/product_svc/main.go b/samples/go/product_svc/main.go deleted file mode 100644 index fff7ac9..0000000 --- a/samples/go/product_svc/main.go +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2022 CECTC, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package main - -import ( - "database/sql" - "net/http" - "time" - - "github.com/gin-gonic/gin" - _ "github.com/go-sql-driver/mysql" // register mysql - - "github.com/dbpack/samples/product_svc/dao" -) - -var dsn = `dksl:123456@tcp(127.0.0.1:13307)/product?timeout=60s&readTimeout=60s&writeTimeout=60s&parseTime=true&loc=Local&charset=utf8mb4,utf8` - -func main() { - r := gin.Default() - - sqlDB, err := sql.Open("mysql", dsn) - if err != nil { - panic(err) - } - sqlDB.SetMaxOpenConns(100) - sqlDB.SetMaxIdleConns(20) - sqlDB.SetConnMaxLifetime(4 * time.Hour) - - if err != nil { - panic(err) - } - d := &dao.Dao{ - DB: sqlDB, - } - - r.POST("/allocateInventory", func(c *gin.Context) { - xid := c.GetHeader("xid") - - type req struct { - Req []*dao.AllocateInventoryReq - } - var q req - if err := c.ShouldBindJSON(&q); err != nil { - c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) - return - } - - err := d.AllocateInventory(c, xid, q.Req) - - if err != nil { - c.JSON(400, gin.H{ - "success": false, - "message": "fail", - }) - } else { - c.JSON(200, gin.H{ - "success": true, - "message": "success", - }) - } - }) - - r.Run(":3002") -} diff --git a/samples/java/README.md b/samples/java/README.md deleted file mode 100644 index 6ac6add..0000000 --- a/samples/java/README.md +++ /dev/null @@ -1,69 +0,0 @@ -# dbpack-samples - -### Step0: Clone dbpack -```shell -git clone git@github.com:cectc/dbpack.git -cd dbpack -``` - -### Step1: Setup etcd - -### Step2: Setup mysql, initialize the database with the following sql script -``` -./samples/scripts/order.sql -./samples/scripts/product.sql -``` - -### Step3: run dbpack -```bash -make build-local - -vim ./samples/java/config1.yaml -# update distributed_transaction.etcd_config.endpoints - -vim ./samples/java/config2.yaml -# update data_source_cluster.dsn -# update distributed_transaction.etcd_config.endpoints - -vim ./samples/java/config3.yaml -# update data_source_cluster.dsn -# update distributed_transaction.etcd_config.endpoints - -./dist/dbpack start --config ./samples/java/config1.yaml - -./dist/dbpack start --config ./samples/java/config2.yaml - -./dist/dbpack start --config ./samples/java/config3.yaml -``` - -### Step4: setup aggregation_svc client -```bash -cd samples/java/aggregation -mvnw package -java -jar target/aggregation-0.0.1-SNAPSHOT.jar -``` - -### Step5: setup order_svc client -```bash -cd samples/java/order -vim ./src/main/resources/application.properties -# update spring.datasource.url - -mvnw package -java -jar target/order-0.0.1-SNAPSHOT.jar -``` - -### Step6: setup product_svc client -```bash -cd samples/java/product -vim ./src/main/resources/application.properties -# update spring.datasource.url - -mvnw package -java -jar target/product-0.0.1-SNAPSHOT.jar -``` - -### Step7: access and test -``` -curl -XPOST http://localhost:13000/v1/order/create -``` \ No newline at end of file diff --git a/samples/java/aggregation/.gitignore b/samples/java/aggregation/.gitignore deleted file mode 100644 index cf31856..0000000 --- a/samples/java/aggregation/.gitignore +++ /dev/null @@ -1,34 +0,0 @@ -HELP.md -target/ -.mvn/wrapper/maven-wrapper.jar -.mvn/wrapper/MavenWrapperDownloader.java -**/src/main/**/target/ -**/src/test/**/target/ - -### STS ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache - -### IntelliJ IDEA ### -.idea -*.iws -*.iml -*.ipr - -### NetBeans ### -/nbproject/private/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ -build/ -!**/src/main/**/build/ -!**/src/test/**/build/ - -### VS Code ### -.vscode/ diff --git a/samples/java/aggregation/.mvn/wrapper/maven-wrapper.properties b/samples/java/aggregation/.mvn/wrapper/maven-wrapper.properties deleted file mode 100644 index a9f1ef8..0000000 --- a/samples/java/aggregation/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1,2 +0,0 @@ -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.3/apache-maven-3.8.3-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar diff --git a/samples/java/aggregation/mvnw b/samples/java/aggregation/mvnw deleted file mode 100755 index a16b543..0000000 --- a/samples/java/aggregation/mvnw +++ /dev/null @@ -1,310 +0,0 @@ -#!/bin/sh -# ---------------------------------------------------------------------------- -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# ---------------------------------------------------------------------------- - -# ---------------------------------------------------------------------------- -# Maven Start Up Batch script -# -# Required ENV vars: -# ------------------ -# JAVA_HOME - location of a JDK home dir -# -# Optional ENV vars -# ----------------- -# M2_HOME - location of maven2's installed home dir -# MAVEN_OPTS - parameters passed to the Java VM when running Maven -# e.g. to debug Maven itself, use -# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -# MAVEN_SKIP_RC - flag to disable loading of mavenrc files -# ---------------------------------------------------------------------------- - -if [ -z "$MAVEN_SKIP_RC" ] ; then - - if [ -f /etc/mavenrc ] ; then - . /etc/mavenrc - fi - - if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" - fi - -fi - -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; -mingw=false -case "`uname`" in - CYGWIN*) cygwin=true ;; - MINGW*) mingw=true;; - Darwin*) darwin=true - # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home - # See https://developer.apple.com/library/mac/qa/qa1170/_index.html - if [ -z "$JAVA_HOME" ]; then - if [ -x "/usr/libexec/java_home" ]; then - export JAVA_HOME="`/usr/libexec/java_home`" - else - export JAVA_HOME="/Library/Java/Home" - fi - fi - ;; -esac - -if [ -z "$JAVA_HOME" ] ; then - if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=`java-config --jre-home` - fi -fi - -if [ -z "$M2_HOME" ] ; then - ## resolve links - $0 may be a link to maven's home - PRG="$0" - - # need this for relative symlinks - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname "$PRG"`/$link" - fi - done - - saveddir=`pwd` - - M2_HOME=`dirname "$PRG"`/.. - - # make it fully qualified - M2_HOME=`cd "$M2_HOME" && pwd` - - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi - -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --unix "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` -fi - -# For Mingw, ensure paths are in UNIX format before anything is touched -if $mingw ; then - [ -n "$M2_HOME" ] && - M2_HOME="`(cd "$M2_HOME"; pwd)`" - [ -n "$JAVA_HOME" ] && - JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" -fi - -if [ -z "$JAVA_HOME" ]; then - javaExecutable="`which javac`" - if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then - # readlink(1) is not available as standard on Solaris 10. - readLink=`which readlink` - if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then - if $darwin ; then - javaHome="`dirname \"$javaExecutable\"`" - javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" - else - javaExecutable="`readlink -f \"$javaExecutable\"`" - fi - javaHome="`dirname \"$javaExecutable\"`" - javaHome=`expr "$javaHome" : '\(.*\)/bin'` - JAVA_HOME="$javaHome" - export JAVA_HOME - fi - fi -fi - -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - else - JAVACMD="`which java`" - fi -fi - -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." >&2 - echo " We cannot execute $JAVACMD" >&2 - exit 1 -fi - -if [ -z "$JAVA_HOME" ] ; then - echo "Warning: JAVA_HOME environment variable is not set." -fi - -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher - -# traverses directory structure from process work directory to filesystem root -# first directory with .mvn subdirectory is considered project base directory -find_maven_basedir() { - - if [ -z "$1" ] - then - echo "Path not specified to find_maven_basedir" - return 1 - fi - - basedir="$1" - wdir="$1" - while [ "$wdir" != '/' ] ; do - if [ -d "$wdir"/.mvn ] ; then - basedir=$wdir - break - fi - # workaround for JBEAP-8937 (on Solaris 10/Sparc) - if [ -d "${wdir}" ]; then - wdir=`cd "$wdir/.."; pwd` - fi - # end of workaround - done - echo "${basedir}" -} - -# concatenates all lines of a file -concat_lines() { - if [ -f "$1" ]; then - echo "$(tr -s '\n' ' ' < "$1")" - fi -} - -BASE_DIR=`find_maven_basedir "$(pwd)"` -if [ -z "$BASE_DIR" ]; then - exit 1; -fi - -########################################################################################## -# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -# This allows using the maven wrapper in projects that prohibit checking in binary data. -########################################################################################## -if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found .mvn/wrapper/maven-wrapper.jar" - fi -else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." - fi - if [ -n "$MVNW_REPOURL" ]; then - jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - else - jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - fi - while IFS="=" read key value; do - case "$key" in (wrapperUrl) jarUrl="$value"; break ;; - esac - done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" - if [ "$MVNW_VERBOSE" = true ]; then - echo "Downloading from: $jarUrl" - fi - wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" - if $cygwin; then - wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` - fi - - if command -v wget > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found wget ... using wget" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - wget "$jarUrl" -O "$wrapperJarPath" - else - wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" - fi - elif command -v curl > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found curl ... using curl" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - curl -o "$wrapperJarPath" "$jarUrl" -f - else - curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f - fi - - else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Falling back to using Java to download" - fi - javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" - # For Cygwin, switch paths to Windows format before running javac - if $cygwin; then - javaClass=`cygpath --path --windows "$javaClass"` - fi - if [ -e "$javaClass" ]; then - if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Compiling MavenWrapperDownloader.java ..." - fi - # Compiling the Java class - ("$JAVA_HOME/bin/javac" "$javaClass") - fi - if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - # Running the downloader - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Running MavenWrapperDownloader.java ..." - fi - ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") - fi - fi - fi -fi -########################################################################################## -# End of extension -########################################################################################## - -export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} -if [ "$MVNW_VERBOSE" = true ]; then - echo $MAVEN_PROJECTBASEDIR -fi -MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" - -# For Cygwin, switch paths to Windows format before running java -if $cygwin; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --path --windows "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --windows "$CLASSPATH"` - [ -n "$MAVEN_PROJECTBASEDIR" ] && - MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` -fi - -# Provide a "standardized" way to retrieve the CLI args that will -# work with both Windows and non-Windows executions. -MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" -export MAVEN_CMD_LINE_ARGS - -WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -exec "$JAVACMD" \ - $MAVEN_OPTS \ - -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/samples/java/aggregation/mvnw.cmd b/samples/java/aggregation/mvnw.cmd deleted file mode 100644 index c8d4337..0000000 --- a/samples/java/aggregation/mvnw.cmd +++ /dev/null @@ -1,182 +0,0 @@ -@REM ---------------------------------------------------------------------------- -@REM Licensed to the Apache Software Foundation (ASF) under one -@REM or more contributor license agreements. See the NOTICE file -@REM distributed with this work for additional information -@REM regarding copyright ownership. The ASF licenses this file -@REM to you under the Apache License, Version 2.0 (the -@REM "License"); you may not use this file except in compliance -@REM with the License. You may obtain a copy of the License at -@REM -@REM https://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, -@REM software distributed under the License is distributed on an -@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -@REM KIND, either express or implied. See the License for the -@REM specific language governing permissions and limitations -@REM under the License. -@REM ---------------------------------------------------------------------------- - -@REM ---------------------------------------------------------------------------- -@REM Maven Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir -@REM -@REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files -@REM ---------------------------------------------------------------------------- - -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - -FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( - IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B -) - -@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -@REM This allows using the maven wrapper in projects that prohibit checking in binary data. -if exist %WRAPPER_JAR% ( - if "%MVNW_VERBOSE%" == "true" ( - echo Found %WRAPPER_JAR% - ) -) else ( - if not "%MVNW_REPOURL%" == "" ( - SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - ) - if "%MVNW_VERBOSE%" == "true" ( - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %DOWNLOAD_URL% - ) - - powershell -Command "&{"^ - "$webclient = new-object System.Net.WebClient;"^ - "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ - "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ - "}"^ - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ - "}" - if "%MVNW_VERBOSE%" == "true" ( - echo Finished downloading %WRAPPER_JAR% - ) -) -@REM End of extension - -@REM Provide a "standardized" way to retrieve the CLI args that will -@REM work with both Windows and non-Windows executions. -set MAVEN_CMD_LINE_ARGS=%* - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% diff --git a/samples/java/aggregation/pom.xml b/samples/java/aggregation/pom.xml deleted file mode 100644 index 3d6e53b..0000000 --- a/samples/java/aggregation/pom.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 2.6.7 - - - com.cectc.dbpack - aggregation - 0.0.1-SNAPSHOT - aggregation - Demo project for Spring Boot - - 1.8 - - - - org.springframework.boot - spring-boot-starter - - - - org.springframework.boot - spring-boot-starter-web - - - - org.springframework.boot - spring-boot-starter-test - test - - - org.apache.tomcat - annotations-api - 6.0.53 - provided - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - diff --git a/samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/AggregationApplication.java b/samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/AggregationApplication.java deleted file mode 100644 index d01b624..0000000 --- a/samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/AggregationApplication.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2022 CECTC, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.cectc.dbpack.aggregation; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class AggregationApplication { - - public static void main(String[] args) { - SpringApplication.run(AggregationApplication.class, args); - } - -} diff --git a/samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/BaseController.java b/samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/BaseController.java deleted file mode 100644 index 5a2434f..0000000 --- a/samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/BaseController.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2022 CECTC, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.cectc.dbpack.aggregation; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.InitializingBean; - -public class BaseController implements InitializingBean { - - final static Logger logger = LoggerFactory.getLogger(BaseController.class); - - public BaseController() { - } - - public StandResponse success() { - return StandResponseBuilder.ok(); - } - - - public StandResponse success(E data) { - return StandResponseBuilder.ok(data); - } - - - public StandResponse fail() { - return StandResponseBuilder.result(StandResponse.INTERNAL_SERVER_ERROR,"系统错误"); - } - - public StandResponse fail(Integer code, String message) { - return StandResponseBuilder.result(code,message); - } - - - @Override - public void afterPropertiesSet() throws Exception { - - } -} diff --git a/samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/SnowflakeIdGenerator.java b/samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/SnowflakeIdGenerator.java deleted file mode 100644 index f4141ca..0000000 --- a/samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/SnowflakeIdGenerator.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright 2022 CECTC, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.cectc.dbpack.aggregation; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import java.util.Random; - -public class SnowflakeIdGenerator { - - final static Logger logger = LoggerFactory.getLogger(SnowflakeIdGenerator.class); - - private long workerId; - private long dataCenterId; - private long sequence = 0L; - - private long twepoch = 1288834974657L; - - private long workerIdBits = 5L; - private long dataCenterIdBits = 5L; - private long maxWorkerId = ~(-1L << workerIdBits); - private long maxDataCenterId = ~(-1L << dataCenterIdBits); - private long sequenceBits = 12L; - - private long workerIdShift = sequenceBits; - private long datacenterIdShift = sequenceBits + workerIdBits; - private long timestampLeftShift = sequenceBits + workerIdBits + dataCenterIdBits; - private long sequenceMask = ~(-1L << sequenceBits); - - private long lastTimestamp = -1L; - - private static final SnowflakeIdGenerator generator; - - static { - Random random = new Random(); - long workerId = Long.getLong("id-worker", random.nextInt(31)); - long dataCenterId = Long.getLong("id-datacenter", random.nextInt(31)); - generator = new SnowflakeIdGenerator(workerId, dataCenterId); - } - - public static SnowflakeIdGenerator getInstance() { - return generator; - } - - public SnowflakeIdGenerator(long workerId, long dataCenterId) { - // sanity check for workerId - if (workerId > maxWorkerId || workerId < 0) { - throw new IllegalArgumentException(String.format("worker Id can't be greater than %d or less than 0", maxWorkerId)); - } - if (dataCenterId > maxDataCenterId || dataCenterId < 0) { - throw new IllegalArgumentException(String.format("datacenter Id can't be greater than %d or less than 0", maxDataCenterId)); - } - this.workerId = workerId; - this.dataCenterId = dataCenterId; - logger.info("worker starting. timestamp left shift {}, datacenter id bits {}, worker id bits {}, sequence bits {}, workerid {}", timestampLeftShift, dataCenterIdBits, workerIdBits, sequenceBits, workerId); - } - - public synchronized long nextId() { - long timestamp = timeGen(); - - if (timestamp < lastTimestamp) { - logger.error("clock is moving backwards. Rejecting requests until {}.", lastTimestamp); - throw new UnsupportedOperationException(String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp)); - } - - if (lastTimestamp == timestamp) { - sequence = (sequence + 1) & sequenceMask; - if (sequence == 0) { - timestamp = tilNextMillis(lastTimestamp); - } - } else { - sequence = 0L; - } - - lastTimestamp = timestamp; - - return ((timestamp - twepoch) << timestampLeftShift) | (dataCenterId << datacenterIdShift) | (workerId << workerIdShift) | sequence; - } - - protected long tilNextMillis(long lastTimestamp) { - long timestamp = timeGen(); - while (timestamp <= lastTimestamp) { - timestamp = timeGen(); - } - return timestamp; - } - - protected long timeGen() { - return System.currentTimeMillis(); - } - -} \ No newline at end of file diff --git a/samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/StandResponse.java b/samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/StandResponse.java deleted file mode 100644 index 5389666..0000000 --- a/samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/StandResponse.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2022 CECTC, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.cectc.dbpack.aggregation; - -import java.io.Serializable; - -public class StandResponse implements Serializable { - private static final long serialVersionUID = 1L; - - public final static int SUCCESS=200; - public final static int ACCESS_TOKEN_EXPIRED=401; - public final static int INTERNAL_SERVER_ERROR=500; - public final static int BUSINESS_EXCEPTION=600; - public final static int ARGUMENT_EXCEPTION=700; - public final static int ARGUMENT_MISSING=701; - public final static int ARGUMENT_TYPE_MISS_MATCH=702; - public final static int HEADER_MISSING=703; - public final static int COOKIE_MISSING=702; - - private Boolean success; - private Integer code; - private String msg; - private T data; - - public Boolean getSuccess() { - return success; - } - - public void setSuccess(Boolean success) { - this.success = success; - } - - public Integer getCode() { - return code; - } - - public void setCode(Integer code) { - this.code = code; - if(this.code==SUCCESS){ - this.success=true; - } - else{ - this.success=false; - } - } - - public String getMsg() { - return msg; - } - - public void setMsg(String msg) { - this.msg = msg; - } - - public T getData() { - return data; - } - - public void setData(T data) { - this.data = data; - } -} diff --git a/samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/StandResponseBuilder.java b/samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/StandResponseBuilder.java deleted file mode 100644 index b99c1de..0000000 --- a/samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/StandResponseBuilder.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2022 CECTC, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.cectc.dbpack.aggregation; - -public class StandResponseBuilder { - - public static StandResponse ok() { - return result(true,StandResponse.SUCCESS,"SUCCESS",null); -} - - public static StandResponse ok(E data) { - return result(true,StandResponse.SUCCESS,"SUCCESS", data); - } - - public static StandResponse result(int code, String msg) { - return result(code,msg, null); - } - - public static StandResponse result(Integer code, String msg, E data) { - StandResponse response = new StandResponse<>(); - response.setCode(code); - response.setMsg(msg); - response.setData(data); - return response; - } - - public static StandResponse result(Boolean success, Integer code, String msg, E data) { - StandResponse response = new StandResponse<>(); - response.setSuccess(success); - response.setCode(code); - response.setMsg(msg); - response.setData(data); - return response; - } -} \ No newline at end of file diff --git a/samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/controller/OrderController.java b/samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/controller/OrderController.java deleted file mode 100644 index 295f060..0000000 --- a/samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/controller/OrderController.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2022 CECTC, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.cectc.dbpack.aggregation.controller; - -import com.cectc.dbpack.aggregation.BaseController; -import com.cectc.dbpack.aggregation.StandResponse; -import com.cectc.dbpack.aggregation.service.OrderService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -@RestController -@RequestMapping("/v1/order") -public class OrderController extends BaseController { - @Autowired - OrderService orderService; - - @RequestMapping(value = "create", method = RequestMethod.POST) - public @ResponseBody - StandResponse> createSo(@RequestHeader("x_dbpack_xid") String xid) { - List soIds = orderService.CreateSo(xid); - return success(soIds); - } - - @RequestMapping(value = "create2", method = RequestMethod.POST) - public @ResponseBody - StandResponse> createSo2(@RequestHeader("x_dbpack_xid") String xid) { - orderService.CreateSo(xid); - throw new RuntimeException("exception"); - } -} diff --git a/samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/entity/SoItem.java b/samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/entity/SoItem.java deleted file mode 100644 index 4a8d399..0000000 --- a/samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/entity/SoItem.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright 2022 CECTC, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.cectc.dbpack.aggregation.entity; - -import java.io.Serializable; -import java.math.BigDecimal; - -/** - * 订单明细表 - * @author scott lewis 2019-05-27 - */ -public class SoItem implements Serializable { - private static final long serialVersionUID = 1L; - - /** - * sysno - */ - private Long sysNo; - - /** - * so_sysno - */ - private Long soSysNo; - - /** - * product_sysno - */ - private Long productSysNo; - - /** - * 商品名称 - */ - private String productName; - - /** - * 成本价 - */ - private BigDecimal costPrice; - - /** - * 原价 - */ - private BigDecimal originalPrice; - - /** - * 成交价 - */ - private BigDecimal dealPrice; - - /** - * 数量 - */ - private Integer quantity; - - - public SoItem() { - } - - public Long getSysNo() { - return sysNo; - } - - public void setSysNo(Long sysNo) { - this.sysNo = sysNo; - } - - public Long getSoSysNo() { - return soSysNo; - } - - public void setSoSysNo(Long soSysNo) { - this.soSysNo = soSysNo; - } - - public Long getProductSysNo() { - return productSysNo; - } - - public void setProductSysNo(Long productSysNo) { - this.productSysNo = productSysNo; - } - - public String getProductName() { - return productName; - } - - public void setProductName(String productName) { - this.productName = productName; - } - - public BigDecimal getCostPrice() { - return costPrice; - } - - public void setCostPrice(BigDecimal costPrice) { - this.costPrice = costPrice; - } - - public BigDecimal getOriginalPrice() { - return originalPrice; - } - - public void setOriginalPrice(BigDecimal originalPrice) { - this.originalPrice = originalPrice; - } - - public BigDecimal getDealPrice() { - return dealPrice; - } - - public void setDealPrice(BigDecimal dealPrice) { - this.dealPrice = dealPrice; - } - - public Integer getQuantity() { - return quantity; - } - - public void setQuantity(Integer quantity) { - this.quantity = quantity; - } -} \ No newline at end of file diff --git a/samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/entity/SoMaster.java b/samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/entity/SoMaster.java deleted file mode 100644 index e04e7ea..0000000 --- a/samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/entity/SoMaster.java +++ /dev/null @@ -1,342 +0,0 @@ -/* - * Copyright 2022 CECTC, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.cectc.dbpack.aggregation.entity; - -import java.io.Serializable; -import java.math.BigDecimal; -import java.util.Date; -import java.util.List; - -/** - * 订单表 - * @author scott lewis 2019-05-27 - */ -public class SoMaster implements Serializable { - private static final long serialVersionUID = 1L; - - /** - * sysno - */ - private Long sysNo; - - /** - * so_id - */ - private String soId; - - /** - * 下单用户号 - */ - private Long buyerUserSysNo; - - /** - * 卖家公司编号 - */ - private String sellerCompanyCode; - - /** - * receive_division_sysno - */ - private Long receiveDivisionSysNo; - - /** - * receive_address - */ - private String receiveAddress; - - /** - * receive_zip - */ - private String receiveZip; - - /** - * receive_contact - */ - private String receiveContact; - - /** - * receive_contact_phone - */ - private String receiveContactPhone; - - /** - * stock_sysno - */ - private Long stockSysNo; - - /** - * 支付方式:1,支付宝,2,微信 - */ - private Integer paymentType; - - /** - * 订单总额 - */ - private BigDecimal soAmt; - - /** - * 10,创建成功,待支付;30;支付成功,待发货;50;发货成功,待收货;70,确认收货,已完成;90,下单失败;100已作废 - */ - private Integer status; - - /** - * 下单时间 - */ - private Date orderDate; - - /** - * 支付时间 - */ - private Date paymemtDate; - - /** - * 发货时间 - */ - private Date deliveryDate; - - /** - * 发货时间 - */ - private Date receiveDate; - - /** - * 订单来源 - */ - private String appid; - - /** - * 备注 - */ - private String memo; - - /** - * create_user - */ - private String createUser; - - /** - * gmt_create - */ - private Date gmtCreate; - - /** - * modify_user - */ - private String modifyUser; - - /** - * gmt_modified - */ - private Date gmtModified; - - private List soItems; - - public SoMaster() { - } - - public Long getSysNo() { - return sysNo; - } - - public void setSysNo(Long sysNo) { - this.sysNo = sysNo; - } - - public String getSoId() { - return soId; - } - - public void setSoId(String soId) { - this.soId = soId; - } - - public Long getBuyerUserSysNo() { - return buyerUserSysNo; - } - - public void setBuyerUserSysNo(Long buyerUserSysNo) { - this.buyerUserSysNo = buyerUserSysNo; - } - - public String getSellerCompanyCode() { - return sellerCompanyCode; - } - - public void setSellerCompanyCode(String sellerCompanyCode) { - this.sellerCompanyCode = sellerCompanyCode; - } - - public Long getReceiveDivisionSysNo() { - return receiveDivisionSysNo; - } - - public void setReceiveDivisionSysNo(Long receiveDivisionSysNo) { - this.receiveDivisionSysNo = receiveDivisionSysNo; - } - - public String getReceiveAddress() { - return receiveAddress; - } - - public void setReceiveAddress(String receiveAddress) { - this.receiveAddress = receiveAddress; - } - - public String getReceiveZip() { - return receiveZip; - } - - public void setReceiveZip(String receiveZip) { - this.receiveZip = receiveZip; - } - - public String getReceiveContact() { - return receiveContact; - } - - public void setReceiveContact(String receiveContact) { - this.receiveContact = receiveContact; - } - - public String getReceiveContactPhone() { - return receiveContactPhone; - } - - public void setReceiveContactPhone(String receiveContactPhone) { - this.receiveContactPhone = receiveContactPhone; - } - - public Long getStockSysNo() { - return stockSysNo; - } - - public void setStockSysNo(Long stockSysNo) { - this.stockSysNo = stockSysNo; - } - - public Integer getPaymentType() { - return paymentType; - } - - public void setPaymentType(Integer paymentType) { - this.paymentType = paymentType; - } - - public BigDecimal getSoAmt() { - return soAmt; - } - - public void setSoAmt(BigDecimal soAmt) { - this.soAmt = soAmt; - } - - public Integer getStatus() { - return status; - } - - public void setStatus(Integer status) { - this.status = status; - } - - public Date getOrderDate() { - return orderDate; - } - - public void setOrderDate(Date orderDate) { - this.orderDate = orderDate; - } - - public Date getPaymemtDate() { - return paymemtDate; - } - - public void setPaymemtDate(Date paymemtDate) { - this.paymemtDate = paymemtDate; - } - - public Date getDeliveryDate() { - return deliveryDate; - } - - public void setDeliveryDate(Date deliveryDate) { - this.deliveryDate = deliveryDate; - } - - public Date getReceiveDate() { - return receiveDate; - } - - public void setReceiveDate(Date receiveDate) { - this.receiveDate = receiveDate; - } - - public String getAppid() { - return appid; - } - - public void setAppid(String appid) { - this.appid = appid; - } - - public String getMemo() { - return memo; - } - - public void setMemo(String memo) { - this.memo = memo; - } - - public String getCreateUser() { - return createUser; - } - - public void setCreateUser(String createUser) { - this.createUser = createUser; - } - - public Date getGmtCreate() { - return gmtCreate; - } - - public void setGmtCreate(Date gmtCreate) { - this.gmtCreate = gmtCreate; - } - - public String getModifyUser() { - return modifyUser; - } - - public void setModifyUser(String modifyUser) { - this.modifyUser = modifyUser; - } - - public Date getGmtModified() { - return gmtModified; - } - - public void setGmtModified(Date gmtModified) { - this.gmtModified = gmtModified; - } - - public List getSoItems() { - return soItems; - } - - public void setSoItems(List soItems) { - this.soItems = soItems; - } -} \ No newline at end of file diff --git a/samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/req/AllocateInventoryReq.java b/samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/req/AllocateInventoryReq.java deleted file mode 100644 index dd0c177..0000000 --- a/samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/req/AllocateInventoryReq.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2022 CECTC, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.cectc.dbpack.aggregation.req; - -public class AllocateInventoryReq { - private Long productSysNo; - - private Integer qty; - - public Long getProductSysNo() { - return productSysNo; - } - - public void setProductSysNo(Long productSysNo) { - this.productSysNo = productSysNo; - } - - public Integer getQty() { - return qty; - } - - public void setQty(Integer qty) { - this.qty = qty; - } -} diff --git a/samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/req/CreateOrderReq.java b/samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/req/CreateOrderReq.java deleted file mode 100644 index 6cbe647..0000000 --- a/samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/req/CreateOrderReq.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2022 CECTC, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.cectc.dbpack.aggregation.req; - -import java.util.List; - -public class CreateOrderReq { - public List shoppingProducts; - - public List getShoppingProducts() { - return shoppingProducts; - } - - public void setShoppingProducts(List shoppingProducts) { - this.shoppingProducts = shoppingProducts; - } - - public class ShoppingProduct { - private String productSysNo; - - private String quantity; - - public String getProductSysNo() { - return productSysNo; - } - - public void setProductSysNo(String productSysNo) { - this.productSysNo = productSysNo; - } - - public String getQuantity() { - return quantity; - } - - public void setQuantity(String quantity) { - this.quantity = quantity; - } - } -} diff --git a/samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/service/OrderService.java b/samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/service/OrderService.java deleted file mode 100644 index 3df0138..0000000 --- a/samples/java/aggregation/src/main/java/com/cectc/dbpack/aggregation/service/OrderService.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright 2022 CECTC, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.cectc.dbpack.aggregation.service; - -import com.cectc.dbpack.aggregation.StandResponse; -import com.cectc.dbpack.aggregation.BaseController; -import com.cectc.dbpack.aggregation.SnowflakeIdGenerator; -import com.cectc.dbpack.aggregation.entity.SoItem; -import com.cectc.dbpack.aggregation.entity.SoMaster; -import com.cectc.dbpack.aggregation.req.AllocateInventoryReq; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Service; -import org.springframework.web.client.RestTemplate; - -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.List; - -@Service -public class OrderService { - final static Logger logger = LoggerFactory.getLogger(BaseController.class); - private static final String createSoUrl = "http://localhost:3001/order/v1/so/insert"; - private static final String allocateInventoryUrl = "http://localhost:3002/product/v1/product/allocateInventory"; - - private final RestTemplate restTemplate = new RestTemplate(); - - public List CreateSo(String xid) { - return createSo(xid); - } - - private List createSo(String xid) { - List soSysNos = new ArrayList<>(); - List soMasters = new ArrayList<>(); - SoMaster soMaster = new SoMaster(); - Long id = SnowflakeIdGenerator.getInstance().nextId(); - soMaster.setSysNo(id); - soMaster.setAppid(id.toString()); - soMaster.setBuyerUserSysNo(1L); - soMaster.setSellerCompanyCode("SC001"); - soMaster.setReceiveDivisionSysNo(110105L); - soMaster.setReceiveAddress("beijing"); - soMaster.setReceiveZip("000001"); - soMaster.setReceiveContact("scott"); - soMaster.setReceiveContactPhone("18728828296"); - soMaster.setStockSysNo(1L); - soMaster.setPaymentType(1); - soMaster.setAppid("dk-order"); - - SoItem soItem = new SoItem(); - soItem.setSoSysNo(id); - soItem.setProductSysNo(1L); - soItem.setProductName("apple iphone 13"); - soItem.setCostPrice(new BigDecimal(6799)); - soItem.setOriginalPrice(new BigDecimal(6799)); - soItem.setDealPrice(new BigDecimal(6999)); - soItem.setQuantity(2); - - List soItems = new ArrayList<>(); - soItems.add(soItem); - - soMaster.setSoAmt(soItem.getDealPrice().multiply(new BigDecimal(soItem.getQuantity()))); - soMaster.setSoItems(soItems); - soMasters.add(soMaster); - soSysNos.add(id); - - - List reqs = new ArrayList<>(); - AllocateInventoryReq allocateInventoryReq = new AllocateInventoryReq(); - allocateInventoryReq.setProductSysNo(1L); - allocateInventoryReq.setQty(soItem.getQuantity()); - reqs.add(allocateInventoryReq); - - HttpHeaders headers = new HttpHeaders(); - headers.add("xid", xid); - HttpEntity> req1 = new HttpEntity<>(soMasters, headers); - HttpEntity> req2 = new HttpEntity<>(reqs, headers); - ResponseEntity response1 = restTemplate.postForEntity(createSoUrl, req1, StandResponse.class); - ResponseEntity response2 = restTemplate.postForEntity(allocateInventoryUrl, req2, StandResponse.class); - logger.debug("create so response {}", response1); - logger.debug("allocate inventory response {}", response2); - - return soSysNos; - } -} diff --git a/samples/java/aggregation/src/main/resources/application.properties b/samples/java/aggregation/src/main/resources/application.properties deleted file mode 100644 index b0f2669..0000000 --- a/samples/java/aggregation/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ -server.port=3000 diff --git a/samples/java/aggregation/src/test/java/com/cectc/dbpack/aggregation/AggregationApplicationTests.java b/samples/java/aggregation/src/test/java/com/cectc/dbpack/aggregation/AggregationApplicationTests.java deleted file mode 100644 index efa830a..0000000 --- a/samples/java/aggregation/src/test/java/com/cectc/dbpack/aggregation/AggregationApplicationTests.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2022 CECTC, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.cectc.dbpack.aggregation; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest -class AggregationApplicationTests { - - @Test - void contextLoads() { - } - -} diff --git a/samples/java/config1.yaml b/samples/java/config1.yaml deleted file mode 100644 index 9099b85..0000000 --- a/samples/java/config1.yaml +++ /dev/null @@ -1,28 +0,0 @@ -listeners: - - protocol_type: http - socket_address: - address: 0.0.0.0 - port: 13000 - config: - backend_host: localhost:3000 - filters: - - httpDTFilter - -filters: - - name: httpDTFilter - kind: HttpDistributedTransaction - conf: - appid: aggregationSvc - transaction_infos: - - request_path: "/v1/order/create" - timeout: 60000 - - request_path: "/v1/order/create2" - timeout: 60000 - -distributed_transaction: - appid: aggregationSvc - retry_dead_threshold: 130000 - rollback_retry_timeout_unlock_enable: true - etcd_config: - endpoints: - - localhost:2379 \ No newline at end of file diff --git a/samples/java/config2.yaml b/samples/java/config2.yaml deleted file mode 100644 index bae7ff8..0000000 --- a/samples/java/config2.yaml +++ /dev/null @@ -1,43 +0,0 @@ -listeners: - - protocol_type: mysql - socket_address: - address: 0.0.0.0 - port: 13307 - config: - users: - dksl: "123456" - server_version: "8.0.27" - executor: redirect - -executors: - - name: redirect - mode: sdb - config: - data_source_ref: product - -data_source_cluster: - - name: product - capacity: 30 - max_capacity: 100 - idle_timeout: 60s - dsn: root:123456@tcp(127.0.0.1:3306)/product?timeout=1s&readTimeout=1s&writeTimeout=1s&parseTime=true&loc=Local&charset=utf8mb4,utf8 - ping_interval: 20s - ping_times_for_change_status: 3 - filters: - - mysqlDTFilter - -filters: - - name: mysqlDTFilter - kind: MysqlDistributedTransaction - conf: - appid: productSvc - lock_retry_interval: 100ms - lock_retry_times: 15 - -distributed_transaction: - appid: productSvc - retry_dead_threshold: 130000 - rollback_retry_timeout_unlock_enable: true - etcd_config: - endpoints: - - localhost:2379 \ No newline at end of file diff --git a/samples/java/config3.yaml b/samples/java/config3.yaml deleted file mode 100644 index 81aa550..0000000 --- a/samples/java/config3.yaml +++ /dev/null @@ -1,43 +0,0 @@ -listeners: - - protocol_type: mysql - socket_address: - address: 0.0.0.0 - port: 13308 - config: - users: - dksl: "123456" - server_version: "8.0.27" - executor: redirect - -executors: - - name: redirect - mode: sdb - config: - data_source_ref: order - -data_source_cluster: - - name: order - capacity: 30 - max_capacity: 100 - idle_timeout: 60s - dsn: root:123456@tcp(127.0.0.1:3306)/order?timeout=1s&readTimeout=1s&writeTimeout=1s&parseTime=true&loc=Local&charset=utf8mb4,utf8 - ping_interval: 20s - ping_times_for_change_status: 3 - filters: - - mysqlDTFilter - -filters: - - name: mysqlDTFilter - kind: MysqlDistributedTransaction - conf: - appid: orderSvc - lock_retry_interval: 100ms - lock_retry_times: 15 - -distributed_transaction: - appid: orderSvc - retry_dead_threshold: 130000 - rollback_retry_timeout_unlock_enable: true - etcd_config: - endpoints: - - localhost:2379 diff --git a/samples/java/order/.gitignore b/samples/java/order/.gitignore deleted file mode 100644 index cf31856..0000000 --- a/samples/java/order/.gitignore +++ /dev/null @@ -1,34 +0,0 @@ -HELP.md -target/ -.mvn/wrapper/maven-wrapper.jar -.mvn/wrapper/MavenWrapperDownloader.java -**/src/main/**/target/ -**/src/test/**/target/ - -### STS ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache - -### IntelliJ IDEA ### -.idea -*.iws -*.iml -*.ipr - -### NetBeans ### -/nbproject/private/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ -build/ -!**/src/main/**/build/ -!**/src/test/**/build/ - -### VS Code ### -.vscode/ diff --git a/samples/java/order/.mvn/wrapper/maven-wrapper.properties b/samples/java/order/.mvn/wrapper/maven-wrapper.properties deleted file mode 100644 index a9f1ef8..0000000 --- a/samples/java/order/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1,2 +0,0 @@ -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.3/apache-maven-3.8.3-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar diff --git a/samples/java/order/mvnw b/samples/java/order/mvnw deleted file mode 100755 index a16b543..0000000 --- a/samples/java/order/mvnw +++ /dev/null @@ -1,310 +0,0 @@ -#!/bin/sh -# ---------------------------------------------------------------------------- -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# ---------------------------------------------------------------------------- - -# ---------------------------------------------------------------------------- -# Maven Start Up Batch script -# -# Required ENV vars: -# ------------------ -# JAVA_HOME - location of a JDK home dir -# -# Optional ENV vars -# ----------------- -# M2_HOME - location of maven2's installed home dir -# MAVEN_OPTS - parameters passed to the Java VM when running Maven -# e.g. to debug Maven itself, use -# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -# MAVEN_SKIP_RC - flag to disable loading of mavenrc files -# ---------------------------------------------------------------------------- - -if [ -z "$MAVEN_SKIP_RC" ] ; then - - if [ -f /etc/mavenrc ] ; then - . /etc/mavenrc - fi - - if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" - fi - -fi - -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; -mingw=false -case "`uname`" in - CYGWIN*) cygwin=true ;; - MINGW*) mingw=true;; - Darwin*) darwin=true - # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home - # See https://developer.apple.com/library/mac/qa/qa1170/_index.html - if [ -z "$JAVA_HOME" ]; then - if [ -x "/usr/libexec/java_home" ]; then - export JAVA_HOME="`/usr/libexec/java_home`" - else - export JAVA_HOME="/Library/Java/Home" - fi - fi - ;; -esac - -if [ -z "$JAVA_HOME" ] ; then - if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=`java-config --jre-home` - fi -fi - -if [ -z "$M2_HOME" ] ; then - ## resolve links - $0 may be a link to maven's home - PRG="$0" - - # need this for relative symlinks - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname "$PRG"`/$link" - fi - done - - saveddir=`pwd` - - M2_HOME=`dirname "$PRG"`/.. - - # make it fully qualified - M2_HOME=`cd "$M2_HOME" && pwd` - - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi - -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --unix "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` -fi - -# For Mingw, ensure paths are in UNIX format before anything is touched -if $mingw ; then - [ -n "$M2_HOME" ] && - M2_HOME="`(cd "$M2_HOME"; pwd)`" - [ -n "$JAVA_HOME" ] && - JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" -fi - -if [ -z "$JAVA_HOME" ]; then - javaExecutable="`which javac`" - if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then - # readlink(1) is not available as standard on Solaris 10. - readLink=`which readlink` - if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then - if $darwin ; then - javaHome="`dirname \"$javaExecutable\"`" - javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" - else - javaExecutable="`readlink -f \"$javaExecutable\"`" - fi - javaHome="`dirname \"$javaExecutable\"`" - javaHome=`expr "$javaHome" : '\(.*\)/bin'` - JAVA_HOME="$javaHome" - export JAVA_HOME - fi - fi -fi - -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - else - JAVACMD="`which java`" - fi -fi - -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." >&2 - echo " We cannot execute $JAVACMD" >&2 - exit 1 -fi - -if [ -z "$JAVA_HOME" ] ; then - echo "Warning: JAVA_HOME environment variable is not set." -fi - -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher - -# traverses directory structure from process work directory to filesystem root -# first directory with .mvn subdirectory is considered project base directory -find_maven_basedir() { - - if [ -z "$1" ] - then - echo "Path not specified to find_maven_basedir" - return 1 - fi - - basedir="$1" - wdir="$1" - while [ "$wdir" != '/' ] ; do - if [ -d "$wdir"/.mvn ] ; then - basedir=$wdir - break - fi - # workaround for JBEAP-8937 (on Solaris 10/Sparc) - if [ -d "${wdir}" ]; then - wdir=`cd "$wdir/.."; pwd` - fi - # end of workaround - done - echo "${basedir}" -} - -# concatenates all lines of a file -concat_lines() { - if [ -f "$1" ]; then - echo "$(tr -s '\n' ' ' < "$1")" - fi -} - -BASE_DIR=`find_maven_basedir "$(pwd)"` -if [ -z "$BASE_DIR" ]; then - exit 1; -fi - -########################################################################################## -# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -# This allows using the maven wrapper in projects that prohibit checking in binary data. -########################################################################################## -if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found .mvn/wrapper/maven-wrapper.jar" - fi -else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." - fi - if [ -n "$MVNW_REPOURL" ]; then - jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - else - jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - fi - while IFS="=" read key value; do - case "$key" in (wrapperUrl) jarUrl="$value"; break ;; - esac - done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" - if [ "$MVNW_VERBOSE" = true ]; then - echo "Downloading from: $jarUrl" - fi - wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" - if $cygwin; then - wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` - fi - - if command -v wget > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found wget ... using wget" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - wget "$jarUrl" -O "$wrapperJarPath" - else - wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" - fi - elif command -v curl > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found curl ... using curl" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - curl -o "$wrapperJarPath" "$jarUrl" -f - else - curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f - fi - - else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Falling back to using Java to download" - fi - javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" - # For Cygwin, switch paths to Windows format before running javac - if $cygwin; then - javaClass=`cygpath --path --windows "$javaClass"` - fi - if [ -e "$javaClass" ]; then - if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Compiling MavenWrapperDownloader.java ..." - fi - # Compiling the Java class - ("$JAVA_HOME/bin/javac" "$javaClass") - fi - if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - # Running the downloader - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Running MavenWrapperDownloader.java ..." - fi - ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") - fi - fi - fi -fi -########################################################################################## -# End of extension -########################################################################################## - -export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} -if [ "$MVNW_VERBOSE" = true ]; then - echo $MAVEN_PROJECTBASEDIR -fi -MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" - -# For Cygwin, switch paths to Windows format before running java -if $cygwin; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --path --windows "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --windows "$CLASSPATH"` - [ -n "$MAVEN_PROJECTBASEDIR" ] && - MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` -fi - -# Provide a "standardized" way to retrieve the CLI args that will -# work with both Windows and non-Windows executions. -MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" -export MAVEN_CMD_LINE_ARGS - -WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -exec "$JAVACMD" \ - $MAVEN_OPTS \ - -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/samples/java/order/mvnw.cmd b/samples/java/order/mvnw.cmd deleted file mode 100644 index c8d4337..0000000 --- a/samples/java/order/mvnw.cmd +++ /dev/null @@ -1,182 +0,0 @@ -@REM ---------------------------------------------------------------------------- -@REM Licensed to the Apache Software Foundation (ASF) under one -@REM or more contributor license agreements. See the NOTICE file -@REM distributed with this work for additional information -@REM regarding copyright ownership. The ASF licenses this file -@REM to you under the Apache License, Version 2.0 (the -@REM "License"); you may not use this file except in compliance -@REM with the License. You may obtain a copy of the License at -@REM -@REM https://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, -@REM software distributed under the License is distributed on an -@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -@REM KIND, either express or implied. See the License for the -@REM specific language governing permissions and limitations -@REM under the License. -@REM ---------------------------------------------------------------------------- - -@REM ---------------------------------------------------------------------------- -@REM Maven Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir -@REM -@REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files -@REM ---------------------------------------------------------------------------- - -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - -FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( - IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B -) - -@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -@REM This allows using the maven wrapper in projects that prohibit checking in binary data. -if exist %WRAPPER_JAR% ( - if "%MVNW_VERBOSE%" == "true" ( - echo Found %WRAPPER_JAR% - ) -) else ( - if not "%MVNW_REPOURL%" == "" ( - SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - ) - if "%MVNW_VERBOSE%" == "true" ( - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %DOWNLOAD_URL% - ) - - powershell -Command "&{"^ - "$webclient = new-object System.Net.WebClient;"^ - "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ - "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ - "}"^ - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ - "}" - if "%MVNW_VERBOSE%" == "true" ( - echo Finished downloading %WRAPPER_JAR% - ) -) -@REM End of extension - -@REM Provide a "standardized" way to retrieve the CLI args that will -@REM work with both Windows and non-Windows executions. -set MAVEN_CMD_LINE_ARGS=%* - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% diff --git a/samples/java/order/pom.xml b/samples/java/order/pom.xml deleted file mode 100644 index 7fbee91..0000000 --- a/samples/java/order/pom.xml +++ /dev/null @@ -1,69 +0,0 @@ - - - 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 2.6.7 - - - com.cectc.dbpack - order - 0.0.1-SNAPSHOT - order - Demo project for Spring Boot - - 1.8 - - - - mysql - mysql-connector-java - runtime - - - org.springframework.boot - spring-boot-starter-test - test - - - org.mybatis.spring.boot - mybatis-spring-boot-starter - 2.2.2 - - - org.springframework.boot - spring-boot-starter-web - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - - diff --git a/samples/java/order/src/main/java/com/cectc/dbpack/order/BaseController.java b/samples/java/order/src/main/java/com/cectc/dbpack/order/BaseController.java deleted file mode 100644 index eb7c81a..0000000 --- a/samples/java/order/src/main/java/com/cectc/dbpack/order/BaseController.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2022 CECTC, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.cectc.dbpack.order; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.InitializingBean; - -public class BaseController implements InitializingBean { - - final static Logger logger = LoggerFactory.getLogger(BaseController.class); - - public BaseController() { - } - - public StandResponse success() { - return StandResponseBuilder.ok(); - } - - - public StandResponse success(E data) { - return StandResponseBuilder.ok(data); - } - - - public StandResponse fail() { - return StandResponseBuilder.result(StandResponse.INTERNAL_SERVER_ERROR,"系统错误"); - } - - public StandResponse fail(Integer code, String message) { - return StandResponseBuilder.result(code,message); - } - - - @Override - public void afterPropertiesSet() throws Exception { - - } -} diff --git a/samples/java/order/src/main/java/com/cectc/dbpack/order/OrderApplication.java b/samples/java/order/src/main/java/com/cectc/dbpack/order/OrderApplication.java deleted file mode 100644 index 9d82ff8..0000000 --- a/samples/java/order/src/main/java/com/cectc/dbpack/order/OrderApplication.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2022 CECTC, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.cectc.dbpack.order; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class OrderApplication { - - public static void main(String[] args) { - SpringApplication.run(OrderApplication.class, args); - } - -} diff --git a/samples/java/order/src/main/java/com/cectc/dbpack/order/SnowflakeIdGenerator.java b/samples/java/order/src/main/java/com/cectc/dbpack/order/SnowflakeIdGenerator.java deleted file mode 100644 index e994b6e..0000000 --- a/samples/java/order/src/main/java/com/cectc/dbpack/order/SnowflakeIdGenerator.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright 2022 CECTC, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.cectc.dbpack.order; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Random; - -public class SnowflakeIdGenerator { - - final static Logger logger = LoggerFactory.getLogger(SnowflakeIdGenerator.class); - - private long workerId; - private long dataCenterId; - private long sequence = 0L; - - private long twepoch = 1288834974657L; - - private long workerIdBits = 5L; - private long dataCenterIdBits = 5L; - private long maxWorkerId = ~(-1L << workerIdBits); - private long maxDataCenterId = ~(-1L << dataCenterIdBits); - private long sequenceBits = 12L; - - private long workerIdShift = sequenceBits; - private long datacenterIdShift = sequenceBits + workerIdBits; - private long timestampLeftShift = sequenceBits + workerIdBits + dataCenterIdBits; - private long sequenceMask = ~(-1L << sequenceBits); - - private long lastTimestamp = -1L; - - private static final SnowflakeIdGenerator generator; - - static { - Random random = new Random(); - long workerId = Long.getLong("id-worker", random.nextInt(31)); - long dataCenterId = Long.getLong("id-datacenter", random.nextInt(31)); - generator = new SnowflakeIdGenerator(workerId, dataCenterId); - } - - public static SnowflakeIdGenerator getInstance() { - return generator; - } - - public SnowflakeIdGenerator(long workerId, long dataCenterId) { - // sanity check for workerId - if (workerId > maxWorkerId || workerId < 0) { - throw new IllegalArgumentException(String.format("worker Id can't be greater than %d or less than 0", maxWorkerId)); - } - if (dataCenterId > maxDataCenterId || dataCenterId < 0) { - throw new IllegalArgumentException(String.format("datacenter Id can't be greater than %d or less than 0", maxDataCenterId)); - } - this.workerId = workerId; - this.dataCenterId = dataCenterId; - logger.info("worker starting. timestamp left shift {}, datacenter id bits {}, worker id bits {}, sequence bits {}, workerid {}", timestampLeftShift, dataCenterIdBits, workerIdBits, sequenceBits, workerId); - } - - public synchronized long nextId() { - long timestamp = timeGen(); - - if (timestamp < lastTimestamp) { - logger.error("clock is moving backwards. Rejecting requests until {}.", lastTimestamp); - throw new UnsupportedOperationException(String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp)); - } - - if (lastTimestamp == timestamp) { - sequence = (sequence + 1) & sequenceMask; - if (sequence == 0) { - timestamp = tilNextMillis(lastTimestamp); - } - } else { - sequence = 0L; - } - - lastTimestamp = timestamp; - - return ((timestamp - twepoch) << timestampLeftShift) | (dataCenterId << datacenterIdShift) | (workerId << workerIdShift) | sequence; - } - - protected long tilNextMillis(long lastTimestamp) { - long timestamp = timeGen(); - while (timestamp <= lastTimestamp) { - timestamp = timeGen(); - } - return timestamp; - } - - protected long timeGen() { - return System.currentTimeMillis(); - } - -} \ No newline at end of file diff --git a/samples/java/order/src/main/java/com/cectc/dbpack/order/StandResponse.java b/samples/java/order/src/main/java/com/cectc/dbpack/order/StandResponse.java deleted file mode 100644 index 494fdeb..0000000 --- a/samples/java/order/src/main/java/com/cectc/dbpack/order/StandResponse.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2022 CECTC, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.cectc.dbpack.order; - -import java.io.Serializable; - -public class StandResponse implements Serializable { - private static final long serialVersionUID = 1L; - - public final static int SUCCESS=200; - public final static int ACCESS_TOKEN_EXPIRED=401; - public final static int INTERNAL_SERVER_ERROR=500; - public final static int BUSINESS_EXCEPTION=600; - public final static int ARGUMENT_EXCEPTION=700; - public final static int ARGUMENT_MISSING=701; - public final static int ARGUMENT_TYPE_MISS_MATCH=702; - public final static int HEADER_MISSING=703; - public final static int COOKIE_MISSING=702; - - private Boolean success; - private Integer code; - private String msg; - private T data; - - public Boolean getSuccess() { - return success; - } - - public void setSuccess(Boolean success) { - this.success = success; - } - - public Integer getCode() { - return code; - } - - public void setCode(Integer code) { - this.code = code; - if(this.code==SUCCESS){ - this.success=true; - } - else{ - this.success=false; - } - } - - public String getMsg() { - return msg; - } - - public void setMsg(String msg) { - this.msg = msg; - } - - public T getData() { - return data; - } - - public void setData(T data) { - this.data = data; - } -} diff --git a/samples/java/order/src/main/java/com/cectc/dbpack/order/StandResponseBuilder.java b/samples/java/order/src/main/java/com/cectc/dbpack/order/StandResponseBuilder.java deleted file mode 100644 index 6bf0601..0000000 --- a/samples/java/order/src/main/java/com/cectc/dbpack/order/StandResponseBuilder.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2022 CECTC, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.cectc.dbpack.order; - -public class StandResponseBuilder { - - public static StandResponse ok() { - return result(true,StandResponse.SUCCESS,"SUCCESS",null); -} - - public static StandResponse ok(E data) { - return result(true,StandResponse.SUCCESS,"SUCCESS", data); - } - - public static StandResponse result(int code, String msg) { - return result(code,msg, null); - } - - public static StandResponse result(Integer code, String msg, E data) { - StandResponse response = new StandResponse<>(); - response.setCode(code); - response.setMsg(msg); - response.setData(data); - return response; - } - - public static StandResponse result(Boolean success, Integer code, String msg, E data) { - StandResponse response = new StandResponse<>(); - response.setSuccess(success); - response.setCode(code); - response.setMsg(msg); - response.setData(data); - return response; - } -} \ No newline at end of file diff --git a/samples/java/order/src/main/java/com/cectc/dbpack/order/controller/SoController.java b/samples/java/order/src/main/java/com/cectc/dbpack/order/controller/SoController.java deleted file mode 100644 index 2e96a97..0000000 --- a/samples/java/order/src/main/java/com/cectc/dbpack/order/controller/SoController.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2022 CECTC, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.cectc.dbpack.order.controller; - -import com.cectc.dbpack.order.BaseController; -import com.cectc.dbpack.order.StandResponse; -import com.cectc.dbpack.order.entity.SoMaster; -import com.cectc.dbpack.order.service.SoService; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.util.List; - -/** - * 订单表 - * @author scott lewis - * @date 2019/05/27 - */ -@RestController -@RequestMapping(value = "/v1/so") -public class SoController extends BaseController { - - @Resource - private SoService soService; - - @RequestMapping(value = "/insert",method = RequestMethod.POST) - public StandResponse> insert(@RequestBody List soMasters, @RequestHeader("xid") String xid) { - List result = soService.createSo(soMasters, xid); - return success(result); - } -} \ No newline at end of file diff --git a/samples/java/order/src/main/java/com/cectc/dbpack/order/entity/SoItem.java b/samples/java/order/src/main/java/com/cectc/dbpack/order/entity/SoItem.java deleted file mode 100644 index dd9c398..0000000 --- a/samples/java/order/src/main/java/com/cectc/dbpack/order/entity/SoItem.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright 2022 CECTC, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.cectc.dbpack.order.entity; - -import java.io.Serializable; -import java.math.BigDecimal; - -/** - * 订单明细表 - * @author scott lewis 2019-05-27 - */ -public class SoItem implements Serializable { - private static final long serialVersionUID = 1L; - - private String xid; - - /** - * sysno - */ - private Long sysNo; - - /** - * so_sysno - */ - private Long soSysNo; - - /** - * product_sysno - */ - private Long productSysNo; - - /** - * 商品名称 - */ - private String productName; - - /** - * 成本价 - */ - private BigDecimal costPrice; - - /** - * 原价 - */ - private BigDecimal originalPrice; - - /** - * 成交价 - */ - private BigDecimal dealPrice; - - /** - * 数量 - */ - private Integer quantity; - - - public SoItem() { - } - - public String getXid() { - return xid; - } - - public void setXid(String xid) { - this.xid = xid; - } - - public Long getSysNo() { - return sysNo; - } - - public void setSysNo(Long sysNo) { - this.sysNo = sysNo; - } - - public Long getSoSysNo() { - return soSysNo; - } - - public void setSoSysNo(Long soSysNo) { - this.soSysNo = soSysNo; - } - - public Long getProductSysNo() { - return productSysNo; - } - - public void setProductSysNo(Long productSysNo) { - this.productSysNo = productSysNo; - } - - public String getProductName() { - return productName; - } - - public void setProductName(String productName) { - this.productName = productName; - } - - public BigDecimal getCostPrice() { - return costPrice; - } - - public void setCostPrice(BigDecimal costPrice) { - this.costPrice = costPrice; - } - - public BigDecimal getOriginalPrice() { - return originalPrice; - } - - public void setOriginalPrice(BigDecimal originalPrice) { - this.originalPrice = originalPrice; - } - - public BigDecimal getDealPrice() { - return dealPrice; - } - - public void setDealPrice(BigDecimal dealPrice) { - this.dealPrice = dealPrice; - } - - public Integer getQuantity() { - return quantity; - } - - public void setQuantity(Integer quantity) { - this.quantity = quantity; - } -} \ No newline at end of file diff --git a/samples/java/order/src/main/java/com/cectc/dbpack/order/entity/SoMaster.java b/samples/java/order/src/main/java/com/cectc/dbpack/order/entity/SoMaster.java deleted file mode 100644 index 3903aef..0000000 --- a/samples/java/order/src/main/java/com/cectc/dbpack/order/entity/SoMaster.java +++ /dev/null @@ -1,352 +0,0 @@ -/* - * Copyright 2022 CECTC, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.cectc.dbpack.order.entity; - -import java.io.Serializable; -import java.math.BigDecimal; -import java.util.Date; -import java.util.List; - -/** - * 订单表 - * @author scott lewis 2019-05-27 - */ -public class SoMaster implements Serializable { - private static final long serialVersionUID = 1L; - - private String xid; - - /** - * sysno - */ - private Long sysNo; - - /** - * so_id - */ - private String soId; - - /** - * 下单用户号 - */ - private Long buyerUserSysNo; - - /** - * 卖家公司编号 - */ - private String sellerCompanyCode; - - /** - * receive_division_sysno - */ - private Long receiveDivisionSysNo; - - /** - * receive_address - */ - private String receiveAddress; - - /** - * receive_zip - */ - private String receiveZip; - - /** - * receive_contact - */ - private String receiveContact; - - /** - * receive_contact_phone - */ - private String receiveContactPhone; - - /** - * stock_sysno - */ - private Long stockSysNo; - - /** - * 支付方式:1,支付宝,2,微信 - */ - private Integer paymentType; - - /** - * 订单总额 - */ - private BigDecimal soAmt; - - /** - * 10,创建成功,待支付;30;支付成功,待发货;50;发货成功,待收货;70,确认收货,已完成;90,下单失败;100已作废 - */ - private Integer status; - - /** - * 下单时间 - */ - private Date orderDate; - - /** - * 支付时间 - */ - private Date paymentDate; - - /** - * 发货时间 - */ - private Date deliveryDate; - - /** - * 发货时间 - */ - private Date receiveDate; - - /** - * 订单来源 - */ - private String appid; - - /** - * 备注 - */ - private String memo; - - /** - * create_user - */ - private String createUser; - - /** - * gmt_create - */ - private Date gmtCreate; - - /** - * modify_user - */ - private String modifyUser; - - /** - * gmt_modified - */ - private Date gmtModified; - - private List soItems; - - public SoMaster() { - } - - public String getXid() { - return xid; - } - - public void setXid(String xid) { - this.xid = xid; - } - - public Long getSysNo() { - return sysNo; - } - - public void setSysNo(Long sysNo) { - this.sysNo = sysNo; - } - - public String getSoId() { - return soId; - } - - public void setSoId(String soId) { - this.soId = soId; - } - - public Long getBuyerUserSysNo() { - return buyerUserSysNo; - } - - public void setBuyerUserSysNo(Long buyerUserSysNo) { - this.buyerUserSysNo = buyerUserSysNo; - } - - public String getSellerCompanyCode() { - return sellerCompanyCode; - } - - public void setSellerCompanyCode(String sellerCompanyCode) { - this.sellerCompanyCode = sellerCompanyCode; - } - - public Long getReceiveDivisionSysNo() { - return receiveDivisionSysNo; - } - - public void setReceiveDivisionSysNo(Long receiveDivisionSysNo) { - this.receiveDivisionSysNo = receiveDivisionSysNo; - } - - public String getReceiveAddress() { - return receiveAddress; - } - - public void setReceiveAddress(String receiveAddress) { - this.receiveAddress = receiveAddress; - } - - public String getReceiveZip() { - return receiveZip; - } - - public void setReceiveZip(String receiveZip) { - this.receiveZip = receiveZip; - } - - public String getReceiveContact() { - return receiveContact; - } - - public void setReceiveContact(String receiveContact) { - this.receiveContact = receiveContact; - } - - public String getReceiveContactPhone() { - return receiveContactPhone; - } - - public void setReceiveContactPhone(String receiveContactPhone) { - this.receiveContactPhone = receiveContactPhone; - } - - public Long getStockSysNo() { - return stockSysNo; - } - - public void setStockSysNo(Long stockSysNo) { - this.stockSysNo = stockSysNo; - } - - public Integer getPaymentType() { - return paymentType; - } - - public void setPaymentType(Integer paymentType) { - this.paymentType = paymentType; - } - - public BigDecimal getSoAmt() { - return soAmt; - } - - public void setSoAmt(BigDecimal soAmt) { - this.soAmt = soAmt; - } - - public Integer getStatus() { - return status; - } - - public void setStatus(Integer status) { - this.status = status; - } - - public Date getOrderDate() { - return orderDate; - } - - public void setOrderDate(Date orderDate) { - this.orderDate = orderDate; - } - - public Date getPaymentDate() { - return paymentDate; - } - - public void setPaymentDate(Date paymentDate) { - this.paymentDate = paymentDate; - } - - public Date getDeliveryDate() { - return deliveryDate; - } - - public void setDeliveryDate(Date deliveryDate) { - this.deliveryDate = deliveryDate; - } - - public Date getReceiveDate() { - return receiveDate; - } - - public void setReceiveDate(Date receiveDate) { - this.receiveDate = receiveDate; - } - - public String getAppid() { - return appid; - } - - public void setAppid(String appid) { - this.appid = appid; - } - - public String getMemo() { - return memo; - } - - public void setMemo(String memo) { - this.memo = memo; - } - - public String getCreateUser() { - return createUser; - } - - public void setCreateUser(String createUser) { - this.createUser = createUser; - } - - public Date getGmtCreate() { - return gmtCreate; - } - - public void setGmtCreate(Date gmtCreate) { - this.gmtCreate = gmtCreate; - } - - public String getModifyUser() { - return modifyUser; - } - - public void setModifyUser(String modifyUser) { - this.modifyUser = modifyUser; - } - - public Date getGmtModified() { - return gmtModified; - } - - public void setGmtModified(Date gmtModified) { - this.gmtModified = gmtModified; - } - - public List getSoItems() { - return soItems; - } - - public void setSoItems(List soItems) { - this.soItems = soItems; - } -} \ No newline at end of file diff --git a/samples/java/order/src/main/java/com/cectc/dbpack/order/mapper/SoItemMapper.java b/samples/java/order/src/main/java/com/cectc/dbpack/order/mapper/SoItemMapper.java deleted file mode 100644 index 6772738..0000000 --- a/samples/java/order/src/main/java/com/cectc/dbpack/order/mapper/SoItemMapper.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2022 CECTC, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.cectc.dbpack.order.mapper; - -import com.cectc.dbpack.order.entity.SoItem; -import org.apache.ibatis.annotations.Insert; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface SoItemMapper { - @Insert("INSERT /*+ XID('${xid}') */\n" + - "INTO `order`.`so_item` ( `so_sysno`, `product_sysno`, `product_name`, `cost_price`, `original_price`, `deal_price`, `quantity` )\n" + - "VALUES\n" + - "(#{soSysNo}, #{productSysNo}, #{productName}, #{costPrice}, #{originalPrice}, #{dealPrice}, #{quantity} );") - void createSoItem(SoItem soItem); -} diff --git a/samples/java/order/src/main/java/com/cectc/dbpack/order/mapper/SoMasterMapper.java b/samples/java/order/src/main/java/com/cectc/dbpack/order/mapper/SoMasterMapper.java deleted file mode 100644 index 511df5c..0000000 --- a/samples/java/order/src/main/java/com/cectc/dbpack/order/mapper/SoMasterMapper.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2022 CECTC, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.cectc.dbpack.order.mapper; - -import com.cectc.dbpack.order.entity.SoItem; -import com.cectc.dbpack.order.entity.SoMaster; -import org.apache.ibatis.annotations.Insert; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface SoMasterMapper { - @Insert("INSERT /*+ XID('${xid}') */\n" + - "INTO `order`.`so_master` (\n" + - "\t`sysno`,\n" + - "\t`so_id`,\n" + - "\t`buyer_user_sysno`,\n" + - "\t`seller_company_code`,\n" + - "\t`receive_division_sysno`,\n" + - "\t`receive_address`,\n" + - "\t`receive_zip`,\n" + - "\t`receive_contact`,\n" + - "\t`receive_contact_phone`,\n" + - "\t`stock_sysno`,\n" + - "\t`payment_type`,\n" + - "\t`so_amt`,\n" + - "\t`status`,\n" + - "\t`order_date`,\n" + - "\t`appid`\n" + - ")\n" + - "VALUES\n" + - "\t(\n" + - "\t\t#{sysNo},\n" + - "\t\t#{soId},\n" + - "\t\t#{buyerUserSysNo},\n" + - "\t\t#{sellerCompanyCode},\n" + - "\t\t#{receiveDivisionSysNo},\n" + - "\t\t#{receiveAddress},\n" + - "\t\t#{receiveZip},\n" + - "\t\t#{receiveContact},\n" + - "\t\t#{receiveContactPhone},\n" + - "\t\t#{stockSysNo},\n" + - "\t\t#{paymentType},\n" + - "\t\t#{soAmt},\n" + - "\t\t#{status},\n" + - "\t\t#{orderDate},\n" + - "\t\t#{appid}\n" + - "\t);") - void createSoMaster(SoMaster soMaster); -} diff --git a/samples/java/order/src/main/java/com/cectc/dbpack/order/service/SoService.java b/samples/java/order/src/main/java/com/cectc/dbpack/order/service/SoService.java deleted file mode 100644 index 98fed09..0000000 --- a/samples/java/order/src/main/java/com/cectc/dbpack/order/service/SoService.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2022 CECTC, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.cectc.dbpack.order.service; - -import com.cectc.dbpack.order.SnowflakeIdGenerator; -import com.cectc.dbpack.order.entity.SoItem; -import com.cectc.dbpack.order.entity.SoMaster; -import com.cectc.dbpack.order.mapper.SoItemMapper; -import com.cectc.dbpack.order.mapper.SoMasterMapper; -import org.springframework.jdbc.core.PreparedStatementCallback; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.StringUtils; - -import javax.annotation.Resource; -import java.sql.PreparedStatement; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; - -@Service -public class SoService { - @Resource - SoMasterMapper soMasterMapper; - @Resource - SoItemMapper soItemMapper; - - @Transactional(timeout = 10000) - public List createSo(List soMasters, String xid) { - List results = new ArrayList<>(); - if (soMasters.size()>0) { - for (SoMaster soMaster : soMasters) { - if (soMaster.getSoItems()!=null&&soMaster.getSoItems().size()>0) { - if (soMaster.getSysNo()==null) { - Long id = SnowflakeIdGenerator.getInstance().nextId(); - soMaster.setSysNo(id); - } - soMaster.setStatus(10); - soMaster.setXid(xid); - soMasterMapper.createSoMaster(soMaster); - for (SoItem soItem : soMaster.getSoItems()) { - soItem.setXid(xid); - soItemMapper.createSoItem(soItem); - } - results.add(soMaster.getSysNo()); - } - } - } - return results; - } -} diff --git a/samples/java/order/src/main/resources/application.properties b/samples/java/order/src/main/resources/application.properties deleted file mode 100644 index 67f49d4..0000000 --- a/samples/java/order/src/main/resources/application.properties +++ /dev/null @@ -1,6 +0,0 @@ -server.port=3001 -server.servlet.context-path=/order - -spring.datasource.url=jdbc:mysql://127.0.0.1:13308/order?useServerPrepStmts=true -spring.datasource.username=dksl -spring.datasource.password=123456 diff --git a/samples/java/order/src/test/java/com/cectc/dbpack/order/OrderApplicationTests.java b/samples/java/order/src/test/java/com/cectc/dbpack/order/OrderApplicationTests.java deleted file mode 100644 index fd18a22..0000000 --- a/samples/java/order/src/test/java/com/cectc/dbpack/order/OrderApplicationTests.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2022 CECTC, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.cectc.dbpack.order; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest -class OrderApplicationTests { - - @Test - void contextLoads() { - } - -} diff --git a/samples/java/product/.gitignore b/samples/java/product/.gitignore deleted file mode 100644 index cf31856..0000000 --- a/samples/java/product/.gitignore +++ /dev/null @@ -1,34 +0,0 @@ -HELP.md -target/ -.mvn/wrapper/maven-wrapper.jar -.mvn/wrapper/MavenWrapperDownloader.java -**/src/main/**/target/ -**/src/test/**/target/ - -### STS ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache - -### IntelliJ IDEA ### -.idea -*.iws -*.iml -*.ipr - -### NetBeans ### -/nbproject/private/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ -build/ -!**/src/main/**/build/ -!**/src/test/**/build/ - -### VS Code ### -.vscode/ diff --git a/samples/java/product/.mvn/wrapper/maven-wrapper.properties b/samples/java/product/.mvn/wrapper/maven-wrapper.properties deleted file mode 100644 index a9f1ef8..0000000 --- a/samples/java/product/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1,2 +0,0 @@ -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.3/apache-maven-3.8.3-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar diff --git a/samples/java/product/mvnw b/samples/java/product/mvnw deleted file mode 100755 index a16b543..0000000 --- a/samples/java/product/mvnw +++ /dev/null @@ -1,310 +0,0 @@ -#!/bin/sh -# ---------------------------------------------------------------------------- -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# ---------------------------------------------------------------------------- - -# ---------------------------------------------------------------------------- -# Maven Start Up Batch script -# -# Required ENV vars: -# ------------------ -# JAVA_HOME - location of a JDK home dir -# -# Optional ENV vars -# ----------------- -# M2_HOME - location of maven2's installed home dir -# MAVEN_OPTS - parameters passed to the Java VM when running Maven -# e.g. to debug Maven itself, use -# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -# MAVEN_SKIP_RC - flag to disable loading of mavenrc files -# ---------------------------------------------------------------------------- - -if [ -z "$MAVEN_SKIP_RC" ] ; then - - if [ -f /etc/mavenrc ] ; then - . /etc/mavenrc - fi - - if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" - fi - -fi - -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; -mingw=false -case "`uname`" in - CYGWIN*) cygwin=true ;; - MINGW*) mingw=true;; - Darwin*) darwin=true - # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home - # See https://developer.apple.com/library/mac/qa/qa1170/_index.html - if [ -z "$JAVA_HOME" ]; then - if [ -x "/usr/libexec/java_home" ]; then - export JAVA_HOME="`/usr/libexec/java_home`" - else - export JAVA_HOME="/Library/Java/Home" - fi - fi - ;; -esac - -if [ -z "$JAVA_HOME" ] ; then - if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=`java-config --jre-home` - fi -fi - -if [ -z "$M2_HOME" ] ; then - ## resolve links - $0 may be a link to maven's home - PRG="$0" - - # need this for relative symlinks - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname "$PRG"`/$link" - fi - done - - saveddir=`pwd` - - M2_HOME=`dirname "$PRG"`/.. - - # make it fully qualified - M2_HOME=`cd "$M2_HOME" && pwd` - - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi - -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --unix "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` -fi - -# For Mingw, ensure paths are in UNIX format before anything is touched -if $mingw ; then - [ -n "$M2_HOME" ] && - M2_HOME="`(cd "$M2_HOME"; pwd)`" - [ -n "$JAVA_HOME" ] && - JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" -fi - -if [ -z "$JAVA_HOME" ]; then - javaExecutable="`which javac`" - if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then - # readlink(1) is not available as standard on Solaris 10. - readLink=`which readlink` - if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then - if $darwin ; then - javaHome="`dirname \"$javaExecutable\"`" - javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" - else - javaExecutable="`readlink -f \"$javaExecutable\"`" - fi - javaHome="`dirname \"$javaExecutable\"`" - javaHome=`expr "$javaHome" : '\(.*\)/bin'` - JAVA_HOME="$javaHome" - export JAVA_HOME - fi - fi -fi - -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - else - JAVACMD="`which java`" - fi -fi - -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." >&2 - echo " We cannot execute $JAVACMD" >&2 - exit 1 -fi - -if [ -z "$JAVA_HOME" ] ; then - echo "Warning: JAVA_HOME environment variable is not set." -fi - -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher - -# traverses directory structure from process work directory to filesystem root -# first directory with .mvn subdirectory is considered project base directory -find_maven_basedir() { - - if [ -z "$1" ] - then - echo "Path not specified to find_maven_basedir" - return 1 - fi - - basedir="$1" - wdir="$1" - while [ "$wdir" != '/' ] ; do - if [ -d "$wdir"/.mvn ] ; then - basedir=$wdir - break - fi - # workaround for JBEAP-8937 (on Solaris 10/Sparc) - if [ -d "${wdir}" ]; then - wdir=`cd "$wdir/.."; pwd` - fi - # end of workaround - done - echo "${basedir}" -} - -# concatenates all lines of a file -concat_lines() { - if [ -f "$1" ]; then - echo "$(tr -s '\n' ' ' < "$1")" - fi -} - -BASE_DIR=`find_maven_basedir "$(pwd)"` -if [ -z "$BASE_DIR" ]; then - exit 1; -fi - -########################################################################################## -# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -# This allows using the maven wrapper in projects that prohibit checking in binary data. -########################################################################################## -if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found .mvn/wrapper/maven-wrapper.jar" - fi -else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." - fi - if [ -n "$MVNW_REPOURL" ]; then - jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - else - jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - fi - while IFS="=" read key value; do - case "$key" in (wrapperUrl) jarUrl="$value"; break ;; - esac - done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" - if [ "$MVNW_VERBOSE" = true ]; then - echo "Downloading from: $jarUrl" - fi - wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" - if $cygwin; then - wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` - fi - - if command -v wget > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found wget ... using wget" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - wget "$jarUrl" -O "$wrapperJarPath" - else - wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" - fi - elif command -v curl > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found curl ... using curl" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - curl -o "$wrapperJarPath" "$jarUrl" -f - else - curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f - fi - - else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Falling back to using Java to download" - fi - javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" - # For Cygwin, switch paths to Windows format before running javac - if $cygwin; then - javaClass=`cygpath --path --windows "$javaClass"` - fi - if [ -e "$javaClass" ]; then - if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Compiling MavenWrapperDownloader.java ..." - fi - # Compiling the Java class - ("$JAVA_HOME/bin/javac" "$javaClass") - fi - if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - # Running the downloader - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Running MavenWrapperDownloader.java ..." - fi - ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") - fi - fi - fi -fi -########################################################################################## -# End of extension -########################################################################################## - -export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} -if [ "$MVNW_VERBOSE" = true ]; then - echo $MAVEN_PROJECTBASEDIR -fi -MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" - -# For Cygwin, switch paths to Windows format before running java -if $cygwin; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --path --windows "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --windows "$CLASSPATH"` - [ -n "$MAVEN_PROJECTBASEDIR" ] && - MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` -fi - -# Provide a "standardized" way to retrieve the CLI args that will -# work with both Windows and non-Windows executions. -MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" -export MAVEN_CMD_LINE_ARGS - -WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -exec "$JAVACMD" \ - $MAVEN_OPTS \ - -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/samples/java/product/mvnw.cmd b/samples/java/product/mvnw.cmd deleted file mode 100644 index c8d4337..0000000 --- a/samples/java/product/mvnw.cmd +++ /dev/null @@ -1,182 +0,0 @@ -@REM ---------------------------------------------------------------------------- -@REM Licensed to the Apache Software Foundation (ASF) under one -@REM or more contributor license agreements. See the NOTICE file -@REM distributed with this work for additional information -@REM regarding copyright ownership. The ASF licenses this file -@REM to you under the Apache License, Version 2.0 (the -@REM "License"); you may not use this file except in compliance -@REM with the License. You may obtain a copy of the License at -@REM -@REM https://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, -@REM software distributed under the License is distributed on an -@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -@REM KIND, either express or implied. See the License for the -@REM specific language governing permissions and limitations -@REM under the License. -@REM ---------------------------------------------------------------------------- - -@REM ---------------------------------------------------------------------------- -@REM Maven Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir -@REM -@REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files -@REM ---------------------------------------------------------------------------- - -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - -FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( - IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B -) - -@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -@REM This allows using the maven wrapper in projects that prohibit checking in binary data. -if exist %WRAPPER_JAR% ( - if "%MVNW_VERBOSE%" == "true" ( - echo Found %WRAPPER_JAR% - ) -) else ( - if not "%MVNW_REPOURL%" == "" ( - SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - ) - if "%MVNW_VERBOSE%" == "true" ( - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %DOWNLOAD_URL% - ) - - powershell -Command "&{"^ - "$webclient = new-object System.Net.WebClient;"^ - "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ - "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ - "}"^ - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ - "}" - if "%MVNW_VERBOSE%" == "true" ( - echo Finished downloading %WRAPPER_JAR% - ) -) -@REM End of extension - -@REM Provide a "standardized" way to retrieve the CLI args that will -@REM work with both Windows and non-Windows executions. -set MAVEN_CMD_LINE_ARGS=%* - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% diff --git a/samples/java/product/pom.xml b/samples/java/product/pom.xml deleted file mode 100644 index 0c47531..0000000 --- a/samples/java/product/pom.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 2.6.7 - - - com.cectc.dbpack - product - 0.0.1-SNAPSHOT - product - Demo project for Spring Boot - - 1.8 - - - - mysql - mysql-connector-java - runtime - - - org.springframework.boot - spring-boot-starter-test - test - - - org.mybatis.spring.boot - mybatis-spring-boot-starter - 2.2.2 - - - org.springframework.boot - spring-boot-starter-web - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - diff --git a/samples/java/product/src/main/java/com/cectc/dbpack/product/BaseController.java b/samples/java/product/src/main/java/com/cectc/dbpack/product/BaseController.java deleted file mode 100644 index 82bc795..0000000 --- a/samples/java/product/src/main/java/com/cectc/dbpack/product/BaseController.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2022 CECTC, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.cectc.dbpack.product; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.InitializingBean; - -public class BaseController implements InitializingBean { - - final static Logger logger = LoggerFactory.getLogger(BaseController.class); - - public BaseController() { - } - - public StandResponse success() { - return StandResponseBuilder.ok(); - } - - - public StandResponse success(E data) { - return StandResponseBuilder.ok(data); - } - - - public StandResponse fail() { - return StandResponseBuilder.result(StandResponse.INTERNAL_SERVER_ERROR,"系统错误"); - } - - public StandResponse fail(Integer code, String message) { - return StandResponseBuilder.result(code,message); - } - - - @Override - public void afterPropertiesSet() throws Exception { - - } -} diff --git a/samples/java/product/src/main/java/com/cectc/dbpack/product/ProductApplication.java b/samples/java/product/src/main/java/com/cectc/dbpack/product/ProductApplication.java deleted file mode 100644 index 7ea52f7..0000000 --- a/samples/java/product/src/main/java/com/cectc/dbpack/product/ProductApplication.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2022 CECTC, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.cectc.dbpack.product; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class ProductApplication { - - public static void main(String[] args) { - SpringApplication.run(ProductApplication.class, args); - } - -} diff --git a/samples/java/product/src/main/java/com/cectc/dbpack/product/StandResponse.java b/samples/java/product/src/main/java/com/cectc/dbpack/product/StandResponse.java deleted file mode 100644 index 0a01a0b..0000000 --- a/samples/java/product/src/main/java/com/cectc/dbpack/product/StandResponse.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2022 CECTC, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.cectc.dbpack.product; - -import java.io.Serializable; - -public class StandResponse implements Serializable { - private static final long serialVersionUID = 1L; - - public final static int SUCCESS=200; - public final static int ACCESS_TOKEN_EXPIRED=401; - public final static int INTERNAL_SERVER_ERROR=500; - public final static int BUSINESS_EXCEPTION=600; - public final static int ARGUMENT_EXCEPTION=700; - public final static int ARGUMENT_MISSING=701; - public final static int ARGUMENT_TYPE_MISS_MATCH=702; - public final static int HEADER_MISSING=703; - public final static int COOKIE_MISSING=702; - - private Boolean success; - private Integer code; - private String msg; - private T data; - - public Boolean getSuccess() { - return success; - } - - public void setSuccess(Boolean success) { - this.success = success; - } - - public Integer getCode() { - return code; - } - - public void setCode(Integer code) { - this.code = code; - if(this.code==SUCCESS){ - this.success=true; - } - else{ - this.success=false; - } - } - - public String getMsg() { - return msg; - } - - public void setMsg(String msg) { - this.msg = msg; - } - - public T getData() { - return data; - } - - public void setData(T data) { - this.data = data; - } -} diff --git a/samples/java/product/src/main/java/com/cectc/dbpack/product/StandResponseBuilder.java b/samples/java/product/src/main/java/com/cectc/dbpack/product/StandResponseBuilder.java deleted file mode 100644 index aee570b..0000000 --- a/samples/java/product/src/main/java/com/cectc/dbpack/product/StandResponseBuilder.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2022 CECTC, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.cectc.dbpack.product; - -public class StandResponseBuilder { - - public static StandResponse ok() { - return result(true,StandResponse.SUCCESS,"SUCCESS",null); -} - - public static StandResponse ok(E data) { - return result(true,StandResponse.SUCCESS,"SUCCESS", data); - } - - public static StandResponse result(int code, String msg) { - return result(code,msg, null); - } - - public static StandResponse result(Integer code, String msg, E data) { - StandResponse response = new StandResponse<>(); - response.setCode(code); - response.setMsg(msg); - response.setData(data); - return response; - } - - public static StandResponse result(Boolean success, Integer code, String msg, E data) { - StandResponse response = new StandResponse<>(); - response.setSuccess(success); - response.setCode(code); - response.setMsg(msg); - response.setData(data); - return response; - } -} \ No newline at end of file diff --git a/samples/java/product/src/main/java/com/cectc/dbpack/product/controller/ProductController.java b/samples/java/product/src/main/java/com/cectc/dbpack/product/controller/ProductController.java deleted file mode 100644 index e28a413..0000000 --- a/samples/java/product/src/main/java/com/cectc/dbpack/product/controller/ProductController.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2022 CECTC, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.cectc.dbpack.product.controller; - -import com.cectc.dbpack.product.BaseController; -import com.cectc.dbpack.product.StandResponse; -import com.cectc.dbpack.product.req.AllocateInventoryReq; -import com.cectc.dbpack.product.service.ProductService; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.util.List; - -/** - * 商品sku - * @author scott lewis - * @date 2019/05/27 - */ -@RestController -@RequestMapping(value = "/v1/product") -public class ProductController extends BaseController { - - @Resource - private ProductService productService; - - @RequestMapping(value = "/allocateInventory",method = RequestMethod.POST) - public StandResponse allocateInventory(@RequestBody List reqs, @RequestHeader("xid") String xid) { - productService.allocateInventory(reqs, xid); - return success(); - } -} \ No newline at end of file diff --git a/samples/java/product/src/main/java/com/cectc/dbpack/product/entity/Inventory.java b/samples/java/product/src/main/java/com/cectc/dbpack/product/entity/Inventory.java deleted file mode 100644 index 6ca4b35..0000000 --- a/samples/java/product/src/main/java/com/cectc/dbpack/product/entity/Inventory.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright 2022 CECTC, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.cectc.dbpack.product.entity; - -import java.io.Serializable; - -/** - * 商品库存 - * @author scott lewis 2019-05-27 - */ -public class Inventory implements Serializable { - private static final long serialVersionUID = 1L; - - /** - * 主键 - */ - private Long sysno; - - /** - * product_sysno - */ - private Long productSysNo; - - /** - * 财务库存 - */ - private Integer accountQty; - - /** - * 可用库存 - */ - private Integer availableQty; - - /** - * 分配库存 - */ - private Integer allocatedQty; - - /** - * 调整锁定库存 - */ - private Integer adjustLockedQty; - - public Inventory() { - } - - public Long getSysno() { - return sysno; - } - - public void setSysno(Long sysno) { - this.sysno = sysno; - } - - public Long getProductSysNo() { - return productSysNo; - } - - public void setProductSysNo(Long productSysNo) { - this.productSysNo = productSysNo; - } - - public Integer getAccountQty() { - return accountQty; - } - - public void setAccountQty(Integer accountQty) { - this.accountQty = accountQty; - } - - public Integer getAvailableQty() { - return availableQty; - } - - public void setAvailableQty(Integer availableQty) { - this.availableQty = availableQty; - } - - public Integer getAllocatedQty() { - return allocatedQty; - } - - public void setAllocatedQty(Integer allocatedQty) { - this.allocatedQty = allocatedQty; - } - - public Integer getAdjustLockedQty() { - return adjustLockedQty; - } - - public void setAdjustLockedQty(Integer adjustLockedQty) { - this.adjustLockedQty = adjustLockedQty; - } -} diff --git a/samples/java/product/src/main/java/com/cectc/dbpack/product/entity/Product.java b/samples/java/product/src/main/java/com/cectc/dbpack/product/entity/Product.java deleted file mode 100644 index 28369f3..0000000 --- a/samples/java/product/src/main/java/com/cectc/dbpack/product/entity/Product.java +++ /dev/null @@ -1,278 +0,0 @@ -/* - * Copyright 2022 CECTC, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.cectc.dbpack.product.entity; - -import java.io.Serializable; -import java.util.Date; - -/** - * 商品sku - * @author scott lewis 2019-05-27 - */ -public class Product implements Serializable { - private static final long serialVersionUID = 1L; - - /** - * 主键 - */ - private Long sysNo; - - /** - * 品名 - */ - private String productName; - - /** - * product_title - */ - private String productTitle; - - /** - * 描述 - */ - private String productDesc; - - /** - * 描述 - */ - private String productDescLong; - - /** - * default_image_src - */ - private String defaultImageSrc; - - /** - * c3_sysno - */ - private Long c3SysNo; - - /** - * barcode - */ - private String barcode; - - /** - * length - */ - private Integer length; - - /** - * width - */ - private Integer width; - - /** - * height - */ - private Integer height; - - /** - * weight - */ - private Float weight; - - /** - * merchant_sysno - */ - private Long merchantSysNo; - - /** - * merchant_productid - */ - private String merchantProductId; - - /** - * 1,待上架;2,上架;3,下架;4,售罄下架;5,违规下架 - */ - private Integer status; - - /** - * 创建时间 - */ - private Date gmtCreate; - - /** - * 创建人 - */ - private String createUser; - - /** - * 修改人 - */ - private String modifyUser; - - /** - * 修改时间 - */ - private Date gmtModified; - - public Product() { - } - - public Long getSysNo() { - return sysNo; - } - - public void setSysNo(Long sysNo) { - this.sysNo = sysNo; - } - - public String getProductName() { - return productName; - } - - public void setProductName(String productName) { - this.productName = productName; - } - - public String getProductTitle() { - return productTitle; - } - - public void setProductTitle(String productTitle) { - this.productTitle = productTitle; - } - - public String getProductDesc() { - return productDesc; - } - - public void setProductDesc(String productDesc) { - this.productDesc = productDesc; - } - - public String getProductDescLong() { - return productDescLong; - } - - public void setProductDescLong(String productDescLong) { - this.productDescLong = productDescLong; - } - - public String getDefaultImageSrc() { - return defaultImageSrc; - } - - public void setDefaultImageSrc(String defaultImageSrc) { - this.defaultImageSrc = defaultImageSrc; - } - - public Long getC3SysNo() { - return c3SysNo; - } - - public void setC3SysNo(Long c3SysNo) { - this.c3SysNo = c3SysNo; - } - - public String getBarcode() { - return barcode; - } - - public void setBarcode(String barcode) { - this.barcode = barcode; - } - - public Integer getLength() { - return length; - } - - public void setLength(Integer length) { - this.length = length; - } - - public Integer getWidth() { - return width; - } - - public void setWidth(Integer width) { - this.width = width; - } - - public Integer getHeight() { - return height; - } - - public void setHeight(Integer height) { - this.height = height; - } - - public Float getWeight() { - return weight; - } - - public void setWeight(Float weight) { - this.weight = weight; - } - - public Long getMerchantSysNo() { - return merchantSysNo; - } - - public void setMerchantSysNo(Long merchantSysNo) { - this.merchantSysNo = merchantSysNo; - } - - public String getMerchantProductId() { - return merchantProductId; - } - - public void setMerchantProductId(String merchantProductId) { - this.merchantProductId = merchantProductId; - } - - public Integer getStatus() { - return status; - } - - public void setStatus(Integer status) { - this.status = status; - } - - public Date getGmtCreate() { - return gmtCreate; - } - - public void setGmtCreate(Date gmtCreate) { - this.gmtCreate = gmtCreate; - } - - public String getCreateUser() { - return createUser; - } - - public void setCreateUser(String createUser) { - this.createUser = createUser; - } - - public String getModifyUser() { - return modifyUser; - } - - public void setModifyUser(String modifyUser) { - this.modifyUser = modifyUser; - } - - public Date getGmtModified() { - return gmtModified; - } - - public void setGmtModified(Date gmtModified) { - this.gmtModified = gmtModified; - } -} diff --git a/samples/java/product/src/main/java/com/cectc/dbpack/product/mapper/ProductMapper.java b/samples/java/product/src/main/java/com/cectc/dbpack/product/mapper/ProductMapper.java deleted file mode 100644 index 71ab26b..0000000 --- a/samples/java/product/src/main/java/com/cectc/dbpack/product/mapper/ProductMapper.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2022 CECTC, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.cectc.dbpack.product.mapper; - -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; -import org.apache.ibatis.annotations.Update; - -@Mapper -public interface ProductMapper { - @Update("UPDATE /*+ XID('${xid}') */ `product`.`inventory` SET `available_qty` = `available_qty` - #{qty}, allocated_qty = allocated_qty + #{qty} WHERE product_sysno = #{productSysNo} AND available_qty >= #{qty}") - boolean allocateInventory(@Param("xid") String xid, @Param("productSysNo") long productSysNo, @Param("qty") int qty); -} diff --git a/samples/java/product/src/main/java/com/cectc/dbpack/product/req/AllocateInventoryReq.java b/samples/java/product/src/main/java/com/cectc/dbpack/product/req/AllocateInventoryReq.java deleted file mode 100644 index e9faf6a..0000000 --- a/samples/java/product/src/main/java/com/cectc/dbpack/product/req/AllocateInventoryReq.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2022 CECTC, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.cectc.dbpack.product.req; - -public class AllocateInventoryReq { - private Long productSysNo; - - private Integer qty; - - public Long getProductSysNo() { - return productSysNo; - } - - public void setProductSysNo(Long productSysNo) { - this.productSysNo = productSysNo; - } - - public Integer getQty() { - return qty; - } - - public void setQty(Integer qty) { - this.qty = qty; - } -} diff --git a/samples/java/product/src/main/java/com/cectc/dbpack/product/service/ProductService.java b/samples/java/product/src/main/java/com/cectc/dbpack/product/service/ProductService.java deleted file mode 100644 index 5ec4b89..0000000 --- a/samples/java/product/src/main/java/com/cectc/dbpack/product/service/ProductService.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2022 CECTC, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.cectc.dbpack.product.service; - -import com.cectc.dbpack.product.mapper.ProductMapper; -import com.cectc.dbpack.product.req.AllocateInventoryReq; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import javax.annotation.Resource; -import java.util.List; - -@Service -public class ProductService { - @Resource - ProductMapper productMapper; - - @Transactional - public void allocateInventory(List reqs, String xid) { - for (AllocateInventoryReq req : reqs) { - productMapper.allocateInventory(xid, req.getProductSysNo(), req.getQty()); - } - } -} \ No newline at end of file diff --git a/samples/java/product/src/main/resources/application.properties b/samples/java/product/src/main/resources/application.properties deleted file mode 100644 index 05dc77d..0000000 --- a/samples/java/product/src/main/resources/application.properties +++ /dev/null @@ -1,6 +0,0 @@ -server.port=3002 -server.servlet.context-path=/product - -spring.datasource.url=jdbc:mysql://127.0.0.1:13307/product?useServerPrepStmts=true -spring.datasource.username=dksl -spring.datasource.password=123456 diff --git a/samples/java/product/src/test/java/com/cectc/dbpack/product/ProductApplicationTests.java b/samples/java/product/src/test/java/com/cectc/dbpack/product/ProductApplicationTests.java deleted file mode 100644 index cd4be9f..0000000 --- a/samples/java/product/src/test/java/com/cectc/dbpack/product/ProductApplicationTests.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2022 CECTC, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.cectc.dbpack.product; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest -class ProductApplicationTests { - - @Test - void contextLoads() { - } - -} diff --git a/samples/php/README.md b/samples/php/README.md deleted file mode 100644 index c4641f9..0000000 --- a/samples/php/README.md +++ /dev/null @@ -1,74 +0,0 @@ -# dbpack-samples for php - -### Prerequisite -- php version >= php7 -- php pdo extension is installed -- when using pdo to connect to mysql server, should set `PDO::ATTR_EMULATE_PREPARES => false` to enable dpback distributed transaction - -### Step0: Clone dbpack -```shell -git clone git@github.com:cectc/dbpack.git -cd dbpack -``` - -### Step1: Setup etcd - -### Step2: Setup mysql, initialize the database with the following sql script -``` -./samples/scripts/order.sql -./samples/scripts/product.sql -``` - -### Step3: run dbpack -```bash -# local build -make build-local -# production build -make build - -vim ./samples/php/config1.yaml -# update distributed_transaction.etcd_config.endpoints - -vim ./samples/php/config2.yaml -# update data_source_cluster.dsn -# update distributed_transaction.etcd_config.endpoints - -vim ./samples/php/config3.yaml -# update data_source_cluster.dsn -# update distributed_transaction.etcd_config.endpoints - -./dist/dbpack start -config ../samples/php/config1.yaml - -./dist/dbpack start -config ../samples/php/config2.yaml - -./dist/dbpack start -config ../samples/php/config3.yaml -``` - -### Step4: setup aggregation_svc client -```bash -# config your apache/nginx to use php -# config your apache/nginx to /path/to/dbpack/samples/php/aggregation_svc -``` - -### Step5: setup order_svc client -```bash -# config your apache/nginx to use php -# config your apache/nginx to /path/to/dbpack/samples/php/order_svc -# update dsn in order_svc/svc/svc.php -``` - -### Step6: setup product_svc client -```bash -# config your apache/nginx to use php -# config your apache/nginx to /path/to/dbpack/samples/php/product_svc -# update dsn in product_svc/svc/svc.php -``` - -### Step7: access and test -``` -# commit test -curl -XPOST http://localhost:13000/v1/order/create - -# rollback test -curl -XPOST http://localhost:13000/v1/order/create2 -``` \ No newline at end of file diff --git a/samples/php/aggregation_svc/.htaccess b/samples/php/aggregation_svc/.htaccess deleted file mode 100644 index b3b3e58..0000000 --- a/samples/php/aggregation_svc/.htaccess +++ /dev/null @@ -1,4 +0,0 @@ -RewriteEngine on -RewriteCond %{REQUEST_FILENAME} !-f -RewriteCond %{REQUEST_FILENAME} !-d -RewriteRule ^(.*)$ /index.php?path=$1 [NC,L,QSA] \ No newline at end of file diff --git a/samples/php/aggregation_svc/index.php b/samples/php/aggregation_svc/index.php deleted file mode 100644 index cf35e6e..0000000 --- a/samples/php/aggregation_svc/index.php +++ /dev/null @@ -1,52 +0,0 @@ -CreateSo($xid, false)) { - responseOK(); - } else { - responseError(); - } - break; - case '/v1/order/create2': - if ($aggregationSvc->CreateSo($xid, true)) { - responseOK(); - } else { - responseError(); - } - break; - default: - die('api not found'); - } -} - -function responseOK() { - http_response_code(200); - echo json_encode([ - 'success' => true, - 'message' => 'success', - ]); -} - -function responseError() { - http_response_code(400); - echo json_encode([ - 'success' => false, - 'message' => 'fail', - ]); -} \ No newline at end of file diff --git a/samples/php/aggregation_svc/svc/svc.php b/samples/php/aggregation_svc/svc/svc.php deleted file mode 100644 index c64dd17..0000000 --- a/samples/php/aggregation_svc/svc/svc.php +++ /dev/null @@ -1,101 +0,0 @@ -createSoRequest($xid); - if (!$createSoSuccess) { - return false; - } - $allocateInventorySuccess = $this->allocateInventoryRequest($xid); - if (!$allocateInventorySuccess) { - return false; - } - if ($rollback) { - return false; - } - return true; - } - - protected function createSoRequest(string $xid): bool - { - $soMasters = [ - [ - 'buyerUserSysNo' => 10001, - 'sellerCompanyCode' => 'SC001', - 'receiveDivisionSysNo' => 110105, - 'receiveAddress' => 'beijing', - 'receiveZip' => '000001', - 'receiveContact' => 'scott', - 'receiveContactPhone' => '18728828296', - 'stockSysNo' => 1, - 'paymentType' => 1, - 'soAmt' => 6999 * 2, - 'status' => 10, - 'appID' => 'dk-order', - 'soItems' => [ - [ - 'productSysNo' => 1, - 'productName' => "apple iphone 13", - 'costPrice' => 6799, - 'originalPrice' => 6799, - 'dealPrice' => 6999, - 'quantity' => 2, - ], - ], - ], - ]; - $url = 'http://localhost:3001/createSo'; - $response = $this->sendRequest($url, $xid, $soMasters); - if (empty($response)) { - return false; - } - $responseData = json_decode($response, true); - return $responseData['success'] ?? false; - } - - protected function allocateInventoryRequest(string $xid): bool - { - $allocateInventoryReq = [ - [ - 'ProductSysNo' => 1, - 'Qty' => 2, - ], - ]; - $url = 'http://localhost:3002/allocateInventory'; - $response = $this->sendRequest($url, $xid, $allocateInventoryReq); - if (empty($response)) { - return false; - } - $responseData = json_decode($response, true); - return $responseData['success'] ?? false; - } - - private function sendRequest(string $url, string $xid, array $data): string - { - $ch = curl_init($url); - curl_setopt_array($ch, [ - CURLOPT_POST => true, - CURLOPT_RETURNTRANSFER => true, - CURLOPT_HTTPHEADER => array( - 'Content-Type: application/json', - 'xid: ' . $xid, - ), - CURLOPT_POSTFIELDS => json_encode($data) - ]); - - $response = curl_exec($ch); - if ($response === false) { - return ""; - } - $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); - if ($httpCode == 400) { - return ""; - } - curl_close($ch); - - return $response; - } -} \ No newline at end of file diff --git a/samples/php/config1.yaml b/samples/php/config1.yaml deleted file mode 100644 index 9099b85..0000000 --- a/samples/php/config1.yaml +++ /dev/null @@ -1,28 +0,0 @@ -listeners: - - protocol_type: http - socket_address: - address: 0.0.0.0 - port: 13000 - config: - backend_host: localhost:3000 - filters: - - httpDTFilter - -filters: - - name: httpDTFilter - kind: HttpDistributedTransaction - conf: - appid: aggregationSvc - transaction_infos: - - request_path: "/v1/order/create" - timeout: 60000 - - request_path: "/v1/order/create2" - timeout: 60000 - -distributed_transaction: - appid: aggregationSvc - retry_dead_threshold: 130000 - rollback_retry_timeout_unlock_enable: true - etcd_config: - endpoints: - - localhost:2379 \ No newline at end of file diff --git a/samples/php/config2.yaml b/samples/php/config2.yaml deleted file mode 100644 index 8c7cc81..0000000 --- a/samples/php/config2.yaml +++ /dev/null @@ -1,43 +0,0 @@ -listeners: - - protocol_type: mysql - socket_address: - address: 0.0.0.0 - port: 13307 - config: - users: - hehe: "hehe" - server_version: "8.0.27" - executor: redirect - -executors: - - name: redirect - mode: sdb - config: - data_source_ref: product - -data_source_cluster: - - name: product - capacity: 30 - max_capacity: 100 - idle_timeout: 60s - dsn: hehe:hehe@tcp(127.0.0.1:3306)/product?timeout=60s&readTimeout=60s&writeTimeout=60s&parseTime=true&loc=Local&charset=utf8mb4,utf8 - ping_interval: 20s - ping_times_for_change_status: 3 - filters: - - mysqlDTFilter - -filters: - - name: mysqlDTFilter - kind: MysqlDistributedTransaction - conf: - appid: productSvc - lock_retry_interval: 100ms - lock_retry_times: 15 - -distributed_transaction: - appid: productSvc - retry_dead_threshold: 130000 - rollback_retry_timeout_unlock_enable: true - etcd_config: - endpoints: - - localhost:2379 \ No newline at end of file diff --git a/samples/php/config3.yaml b/samples/php/config3.yaml deleted file mode 100644 index 045f4bc..0000000 --- a/samples/php/config3.yaml +++ /dev/null @@ -1,43 +0,0 @@ -listeners: - - protocol_type: mysql - socket_address: - address: 0.0.0.0 - port: 13308 - config: - users: - hehe: "hehe" - server_version: "8.0.27" - executor: redirect - -executors: - - name: redirect - mode: sdb - config: - data_source_ref: order - -data_source_cluster: - - name: order - capacity: 30 - max_capacity: 100 - idle_timeout: 60s - dsn: hehe:hehe@tcp(127.0.0.1:3306)/order?timeout=60s&readTimeout=60s&writeTimeout=60s&parseTime=true&loc=Local&charset=utf8mb4,utf8 - ping_interval: 20s - ping_times_for_change_status: 3 - filters: - - mysqlDTFilter - -filters: - - name: mysqlDTFilter - kind: MysqlDistributedTransaction - conf: - appid: orderSvc - lock_retry_interval: 100ms - lock_retry_times: 15 - -distributed_transaction: - appid: orderSvc - retry_dead_threshold: 130000 - rollback_retry_timeout_unlock_enable: true - etcd_config: - endpoints: - - localhost:2379 diff --git a/samples/php/order_svc/.htaccess b/samples/php/order_svc/.htaccess deleted file mode 100644 index b3b3e58..0000000 --- a/samples/php/order_svc/.htaccess +++ /dev/null @@ -1,4 +0,0 @@ -RewriteEngine on -RewriteCond %{REQUEST_FILENAME} !-f -RewriteCond %{REQUEST_FILENAME} !-d -RewriteRule ^(.*)$ /index.php?path=$1 [NC,L,QSA] \ No newline at end of file diff --git a/samples/php/order_svc/index.php b/samples/php/order_svc/index.php deleted file mode 100644 index 45d412f..0000000 --- a/samples/php/order_svc/index.php +++ /dev/null @@ -1,43 +0,0 @@ -createSo($xid, $soMasters); - - if ($result) { - responseOK(); - } else { - responseError(); - } - } -} - -function responseOK() { - http_response_code(200); - echo json_encode([ - 'success' => true, - 'message' => 'success', - ]); -} - -function responseError() { - http_response_code(400); - echo json_encode([ - 'success' => false, - 'message' => 'fail', - ]); -} \ No newline at end of file diff --git a/samples/php/order_svc/svc/svc.php b/samples/php/order_svc/svc/svc.php deleted file mode 100644 index 372a4dd..0000000 --- a/samples/php/order_svc/svc/svc.php +++ /dev/null @@ -1,116 +0,0 @@ -_connection = new PDO( - "mysql:host=$this->_host;port=$this->_port;dbname=$this->_database;charset=utf8", - $this->_username, - $this->_password, - [ - PDO::ATTR_PERSISTENT => true, - PDO::ATTR_EMULATE_PREPARES => false, // this option is required to use dbpack distributed transaction - ] - ); - } catch (PDOException $e) { - die($e->getMessage()); - } - } - - private function __clone() - { - } - - public function getConnection(): PDO - { - return $this->_connection; - } - - public function createSo(string $xid, array $soMasters): bool - { - $this->getConnection()->beginTransaction(); - - foreach ($soMasters as $master) { - if (!$this->insertSo($xid, $master)) { - $this->getConnection()->rollBack(); - } - } - return $this->getConnection()->commit(); - } - - private function insertSo(string $xid, array $soMaster): bool - { - $soId = hrtime(true); - $memo = ''; - $insertSoMasterSql = sprintf(self::insertSoMaster, $xid); - - $statement = $this->getConnection()->prepare($insertSoMasterSql); - $statement->bindValue(1, $soId); - $statement->bindValue(2, $soId); - $statement->bindValue(3, $soMaster['buyerUserSysNo']); - $statement->bindValue(4, $soMaster['sellerCompanyCode']); - $statement->bindValue(5, $soMaster['receiveDivisionSysNo']); - $statement->bindValue(6, $soMaster['receiveAddress']); - $statement->bindValue(7, $soMaster['receiveZip']); - $statement->bindValue(8, $soMaster['receiveContact']); - $statement->bindValue(9, $soMaster['receiveContactPhone']); - $statement->bindValue(10, $soMaster['stockSysNo']); - $statement->bindValue(11, $soMaster['paymentType']); - $statement->bindValue(12, $soMaster['soAmt']); - $statement->bindValue(13, $soMaster['status']); - $statement->bindValue(14, $soMaster['appID']); - $statement->bindValue(15, $memo); - - $result = $statement->execute(); - if (!$result) { - return false; - } - $insertSoItemSql = sprintf(self::insertSoItem, $xid); - foreach ($soMaster['soItems'] as $item) { - $soItemId = hrtime(true); - $statement = $this->getConnection()->prepare($insertSoItemSql); - $statement->bindValue(1, $soItemId); - $statement->bindValue(2, $soId); - $statement->bindValue(3, $item['productSysNo']); - $statement->bindValue(4, $item['productName']); - $statement->bindValue(5, $item['costPrice']); - $statement->bindValue(6, $item['originalPrice']); - $statement->bindValue(7, $item['dealPrice']); - $statement->bindValue(8, $item['quantity']); - - $result = $statement->execute(); - if (!$result) { - return false; - } - } - return true; - } -} - diff --git a/samples/php/product_svc/.htaccess b/samples/php/product_svc/.htaccess deleted file mode 100644 index b3b3e58..0000000 --- a/samples/php/product_svc/.htaccess +++ /dev/null @@ -1,4 +0,0 @@ -RewriteEngine on -RewriteCond %{REQUEST_FILENAME} !-f -RewriteCond %{REQUEST_FILENAME} !-d -RewriteRule ^(.*)$ /index.php?path=$1 [NC,L,QSA] \ No newline at end of file diff --git a/samples/php/product_svc/index.php b/samples/php/product_svc/index.php deleted file mode 100644 index 6a061d9..0000000 --- a/samples/php/product_svc/index.php +++ /dev/null @@ -1,43 +0,0 @@ -allocateInventory($xid, $inventories); - - if ($result) { - responseOK(); - } else { - responseError(); - } - } -} - -function responseOK() { - http_response_code(200); - echo json_encode([ - 'success' => true, - 'message' => 'success', - ]); -} - -function responseError() { - http_response_code(400); - echo json_encode([ - 'success' => false, - 'message' => 'fail', - ]); -} \ No newline at end of file diff --git a/samples/php/product_svc/svc/svc.php b/samples/php/product_svc/svc/svc.php deleted file mode 100644 index 9106491..0000000 --- a/samples/php/product_svc/svc/svc.php +++ /dev/null @@ -1,73 +0,0 @@ -= ?"; - - public static function getInstance(): ProductDB - { - if (empty(self::$_instance)) { - self::$_instance = new self(); - } - return self::$_instance; - } - - private function __construct() - { - try { - $this->_connection = new PDO( - "mysql:host=$this->_host;port=$this->_port;dbname=$this->_database;charset=utf8", - $this->_username, - $this->_password, - [ - PDO::ATTR_PERSISTENT => true, - PDO::ATTR_EMULATE_PREPARES => false, // this option is required to use dbpack distributed transaction - ] - ); - } catch (PDOException $e) { - die($e->getMessage()); - } - } - - private function __clone() - { - } - - public function getConnection(): PDO - { - return $this->_connection; - } - - public function allocateInventory(string $xid, array $inventories): bool - { - $this->getConnection()->beginTransaction(); - - foreach ($inventories as $inventory) { - $allocateInventorySql = sprintf(self::allocateInventorySql, $xid); - - $statement = $this->getConnection()->prepare($allocateInventorySql); - $statement->bindValue(1, $inventory['Qty']); - $statement->bindValue(2, $inventory['Qty']); - $statement->bindValue(3, $inventory['ProductSysNo']); - $statement->bindValue(4, $inventory['Qty']); - - $result = $statement->execute(); - if (!$result) { - $this->getConnection()->rollBack(); - } - } - return $this->getConnection()->commit(); - } -} - diff --git a/samples/python/README.md b/samples/python/README.md deleted file mode 100644 index 32dcd14..0000000 --- a/samples/python/README.md +++ /dev/null @@ -1,69 +0,0 @@ -# dbpack-samples - -### Step0: Clone dbpack -```shell -git clone git@github.com:cectc/dbpack.git -cd dbpack -``` - -### Step1: Setup etcd - -### Step2: Setup mysql, initialize the database with the following sql script -``` -./samples/scripts/order.sql -./samples/scripts/product.sql -``` - -### Step3: run dbpack -```bash -make build-local - -vim ./samples/python/config1.yaml -# update distributed_transaction.etcd_config.endpoints - -vim ./samples/python/config2.yaml -# update data_source_cluster.dsn -# update distributed_transaction.etcd_config.endpoints - -vim ./samples/python/config3.yaml -# update data_source_cluster.dsn -# update distributed_transaction.etcd_config.endpoints - -./dist/dbpack start --config samples/python/config1.yaml - -./dist/dbpack start --config samples/python/config2.yaml - -./dist/dbpack start --config samples/python/config3.yaml -``` - -### Step4: setup python requirements -```bash -cd samples/python -pip3 install -r requirements.txt -``` - -### Step5: setup aggregation client -```bash -cd samples/python/aggregation - -python3 app.py -``` - -### Step6: setup order client -```bash -cd samples/python/order - -python3 app.py -``` - -### Step7: setup product client -```bash -cd samples/python/product - -python3 app.py -``` - -### Step8: access and test -``` -curl -XPOST http://localhost:13000/v1/order/create -``` \ No newline at end of file diff --git a/samples/python/aggregation/__init__.py b/samples/python/aggregation/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/samples/python/aggregation/app.py b/samples/python/aggregation/app.py deleted file mode 100644 index ee1e933..0000000 --- a/samples/python/aggregation/app.py +++ /dev/null @@ -1,66 +0,0 @@ -from flask import Flask, request, jsonify -import requests - -app = Flask(__name__) - -@app.route('/v1/order/create', methods=['POST']) -def create_1(): - return create_so(rollback=False) - -@app.route('/v1/order/create2', methods=['POST']) -def create_2(): - return create_so(rollback=True) - -def create_so(rollback=True): - xid = request.headers.get("x_dbpack_xid") - - so_items = [dict( - product_sysno=1, - product_name="apple iphone 13", - original_price=6799, - cost_price=6799, - deal_price=6799, - quantity=2, - )] - - so_master = [dict( - buyer_user_sysno = 10001, - seller_company_code = "SC001", - receive_division_sysno = 110105, - receive_address = "beijing", - receive_zip = "000001", - receive_contact = "scott", - receive_contact_phone = "18728828296", - stock_sysno = 1, - payment_type = 1, - so_amt = 6999 * 2, - status = 10, - appid = "dk-order", - so_items = so_items, - )] - - success = (jsonify(dict(success=True, message="success")), 200) - failed = (jsonify(dict(success=False, message="failed")), 400) - headers = { - "Content-Type": "application/json", - "xid": xid - } - - so_req = dict(req=so_master) - resp1 = requests.post("http://localhost:3001/createSo", headers=headers, json=so_req, timeout=30) - if resp1.status_code == 400: - return failed - - ivt_req = dict(req=[dict(product_sysno= 1, qty=2)]) - resp2 = requests.post("http://localhost:3002/allocateInventory", headers=headers, json=ivt_req, timeout=30) - if resp2.status_code == 400: - return failed - - if rollback: - print("rollback") - return failed - - return success - -if __name__ == "__main__": - app.run(port=3000) diff --git a/samples/python/config1.yaml b/samples/python/config1.yaml deleted file mode 100644 index 9099b85..0000000 --- a/samples/python/config1.yaml +++ /dev/null @@ -1,28 +0,0 @@ -listeners: - - protocol_type: http - socket_address: - address: 0.0.0.0 - port: 13000 - config: - backend_host: localhost:3000 - filters: - - httpDTFilter - -filters: - - name: httpDTFilter - kind: HttpDistributedTransaction - conf: - appid: aggregationSvc - transaction_infos: - - request_path: "/v1/order/create" - timeout: 60000 - - request_path: "/v1/order/create2" - timeout: 60000 - -distributed_transaction: - appid: aggregationSvc - retry_dead_threshold: 130000 - rollback_retry_timeout_unlock_enable: true - etcd_config: - endpoints: - - localhost:2379 \ No newline at end of file diff --git a/samples/python/config2.yaml b/samples/python/config2.yaml deleted file mode 100644 index c9348f9..0000000 --- a/samples/python/config2.yaml +++ /dev/null @@ -1,43 +0,0 @@ -listeners: - - protocol_type: mysql - socket_address: - address: 0.0.0.0 - port: 13307 - config: - users: - dksl: "123456" - server_version: "8.0.27" - executor: redirect - -executors: - - name: redirect - mode: sdb - config: - data_source_ref: product - -data_source_cluster: - - name: product - capacity: 30 - max_capacity: 100 - idle_timeout: 60s - dsn: root:123456@tcp(127.0.0.1:3306)/product?timeout=60s&readTimeout=60s&writeTimeout=60s&parseTime=true&loc=Local&charset=utf8mb4,utf8 - ping_interval: 20s - ping_times_for_change_status: 3 - filters: - - mysqlDTFilter - -filters: - - name: mysqlDTFilter - kind: MysqlDistributedTransaction - conf: - appid: productSvc - lock_retry_interval: 100ms - lock_retry_times: 15 - -distributed_transaction: - appid: productSvc - retry_dead_threshold: 130000 - rollback_retry_timeout_unlock_enable: true - etcd_config: - endpoints: - - localhost:2379 \ No newline at end of file diff --git a/samples/python/config3.yaml b/samples/python/config3.yaml deleted file mode 100644 index 4e0899a..0000000 --- a/samples/python/config3.yaml +++ /dev/null @@ -1,43 +0,0 @@ -listeners: - - protocol_type: mysql - socket_address: - address: 0.0.0.0 - port: 13308 - config: - users: - dksl: "123456" - server_version: "8.0.27" - executor: redirect - -executors: - - name: redirect - mode: sdb - config: - data_source_ref: order - -data_source_cluster: - - name: order - capacity: 30 - max_capacity: 100 - idle_timeout: 60s - dsn: root:123456@tcp(127.0.0.1:3306)/order?timeout=60s&readTimeout=60s&writeTimeout=60s&parseTime=true&loc=Local&charset=utf8mb4,utf8 - ping_interval: 20s - ping_times_for_change_status: 3 - filters: - - mysqlDTFilter - -filters: - - name: mysqlDTFilter - kind: MysqlDistributedTransaction - conf: - appid: orderSvc - lock_retry_interval: 100ms - lock_retry_times: 15 - -distributed_transaction: - appid: orderSvc - retry_dead_threshold: 130000 - rollback_retry_timeout_unlock_enable: true - etcd_config: - endpoints: - - localhost:2379 diff --git a/samples/python/order/__init__.py b/samples/python/order/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/samples/python/order/app.py b/samples/python/order/app.py deleted file mode 100644 index 741e7f2..0000000 --- a/samples/python/order/app.py +++ /dev/null @@ -1,69 +0,0 @@ -from flask import Flask, jsonify, request -from datetime import datetime - -import random - -import mysql.connector - - -app = Flask(__name__) - -conn = mysql.connector.connect( - host="127.0.0.1", - port="13308", - user="dksl", - password="123456", - database="order", -) - -cursor = conn.cursor(prepared=True) - -insert_so_master = "INSERT /*+ XID('{xid}') */ INTO order.so_master({keys}) VALUES ({placeholders})" -insert_so_item = "INSERT /*+ XID('{xid}') */ INTO order.so_item({keys}) VALUES ({placeholders})" - -@app.route('/createSo', methods=['POST']) -def create_so(): - xid = request.headers.get('xid') - reqs = request.get_json() - if xid and "req" in reqs: - for res in reqs["req"]: - res["sysno"] = next_id() - res["so_id"] = res["sysno"] - res["order_date"] = datetime.now() - res_keys = [str(k) for k,v in res.items() if k != "so_items" and str(v) != ""] - so_master = insert_so_master.format( - xid=xid, - keys=", ".join(res_keys), - placeholders=", ".join(["%s"] * len(res_keys)), - ) - - try: - cursor.execute(so_master, tuple(res.get(k, "") for k in res_keys)) - except Exception as e: - print(e.args) - - so_items = res["so_items"] - for item in so_items: - item["sysno"] = next_id() - item["so_sysno"] = res["sysno"] - item_keys = [str(k) for k,v in item.items() if str(v) != "" ] - so_item = insert_so_item.format( - xid=xid, - keys=", ".join(item_keys), - placeholders=", ".join(["%s"] * len(item_keys)), - ) - try: - cursor.execute(so_item, tuple(item.get(k, "") for k in item_keys)) - except Exception as e: - print(e.args) - - return jsonify(dict(success=True, message="success")), 200 - - return jsonify(dict(success=False, message="failed")), 400 - -def next_id(): - return random.randrange(0, 9223372036854775807) - - -if __name__ == '__main__': - app.run(host="0.0.0.0", port=3001) diff --git a/samples/python/product/__init__ .py b/samples/python/product/__init__ .py deleted file mode 100644 index e69de29..0000000 diff --git a/samples/python/product/app.py b/samples/python/product/app.py deleted file mode 100644 index 599d791..0000000 --- a/samples/python/product/app.py +++ /dev/null @@ -1,35 +0,0 @@ -from flask import Flask, jsonify, request -import mysql.connector - - -app = Flask(__name__) - -conn = mysql.connector.connect( - host="127.0.0.1", - port="13307", - user="dksl", - password="123456", - database="product", -) - -cursor = conn.cursor(prepared=True) - -allocate_inventory_sql = "update /*+ XID(%s) */ product.inventory set available_qty = available_qty - %s, allocated_qty = allocated_qty + %s where product_sysno = %s and available_qty >= %s;" - -@app.route('/allocateInventory', methods=['POST']) -def create_so(): - xid = request.headers.get('xid') - reqs = request.get_json() - if xid and "req" in reqs: - for res in reqs["req"]: - try: - cursor.execute(allocate_inventory_sql, (xid, res["qty"], res["qty"], res["product_sysno"], res["qty"])) - except Exception as e: - print(e.args) - - return jsonify(dict(success=True, message="success")), 200 - - return jsonify(dict(success=False, message="failed")), 400 - -if __name__ == '__main__': - app.run(host="0.0.0.0", port=3002) \ No newline at end of file diff --git a/samples/python/requirements.txt b/samples/python/requirements.txt deleted file mode 100644 index 94499e8..0000000 --- a/samples/python/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -Flask==2.1.2 -mysql_connector_repackaged==0.3.1 -requests==2.22.0 diff --git a/samples/python/sqlacodegen.sh b/samples/python/sqlacodegen.sh deleted file mode 100644 index 4db25c7..0000000 --- a/samples/python/sqlacodegen.sh +++ /dev/null @@ -1,4 +0,0 @@ -# /bin/bash - -sqlacodegen "mysql+pymysql://root:123456@localhost:3306/order" -# sqlacodegen "mysql+pymysql://root:123456@localhost:3306/product" \ No newline at end of file diff --git a/samples/scripts/order.sql b/samples/scripts/order.sql deleted file mode 100644 index 723d3d9..0000000 --- a/samples/scripts/order.sql +++ /dev/null @@ -1,87 +0,0 @@ -/* - Navicat Premium Data Transfer - - Source Server : local - Source Server Type : MySQL - Source Server Version : 80013 - Source Host : localhost:3306 - Source Schema : order - - Target Server Type : MySQL - Target Server Version : 80013 - File Encoding : 65001 - - Date: 07/06/2020 23:07:56 -*/ -CREATE database if NOT EXISTS `order` default character set utf8mb4 collate utf8mb4_unicode_ci; -use `order`; - -SET NAMES utf8mb4; -SET FOREIGN_KEY_CHECKS = 0; - --- ---------------------------- --- Table structure for so_item --- ---------------------------- -DROP TABLE IF EXISTS `so_item`; -CREATE TABLE `so_item` ( - `sysno` bigint(20) NOT NULL AUTO_INCREMENT, - `so_sysno` bigint(20) DEFAULT NULL, - `product_sysno` bigint(20) DEFAULT NULL, - `product_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '商品名称', - `cost_price` decimal(16,6) DEFAULT NULL COMMENT '成本价', - `original_price` decimal(16,6) DEFAULT NULL COMMENT '原价', - `deal_price` decimal(16,6) DEFAULT NULL COMMENT '成交价', - `quantity` int(11) DEFAULT NULL COMMENT '数量', - PRIMARY KEY (`sysno`) -) ENGINE=InnoDB AUTO_INCREMENT=1269646673999564801 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='订单明细表'; - --- ---------------------------- --- Table structure for so_master --- ---------------------------- -DROP TABLE IF EXISTS `so_master`; -CREATE TABLE `so_master` ( - `sysno` bigint(20) NOT NULL, - `so_id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, - `buyer_user_sysno` bigint(20) DEFAULT NULL COMMENT '下单用户号', - `seller_company_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '卖家公司编号', - `receive_division_sysno` bigint(20) NOT NULL, - `receive_address` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL, - `receive_zip` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL, - `receive_contact` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL, - `receive_contact_phone` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, - `stock_sysno` bigint(20) DEFAULT NULL, - `payment_type` tinyint(4) DEFAULT NULL COMMENT '支付方式:1,支付宝,2,微信', - `so_amt` decimal(16,6) DEFAULT NULL COMMENT '订单总额', - `status` tinyint(4) DEFAULT NULL COMMENT '10,创建成功,待支付;30;支付成功,待发货;50;发货成功,待收货;70,确认收货,已完成;90,下单失败;100已作废', - `order_date` timestamp NULL DEFAULT NULL COMMENT '下单时间', - `payment_date` timestamp NULL DEFAULT NULL COMMENT '支付时间', - `delivery_date` timestamp NULL DEFAULT NULL COMMENT '发货时间', - `receive_date` timestamp NULL DEFAULT NULL COMMENT '发货时间', - `appid` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '订单来源', - `memo` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注', - `create_user` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, - `gmt_create` timestamp NULL DEFAULT NULL, - `modify_user` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, - `gmt_modified` timestamp NULL DEFAULT NULL, - PRIMARY KEY (`sysno`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='订单表'; - --- ---------------------------- --- Table structure for undo_log --- ---------------------------- -DROP TABLE IF EXISTS `undo_log`; -CREATE TABLE `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, - `ext` varchar(100) DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `idx_unionkey` (`xid`,`branch_id`) -) ENGINE=InnoDB AUTO_INCREMENT=27 DEFAULT CHARSET=utf8; - -SET FOREIGN_KEY_CHECKS = 1; diff --git a/samples/scripts/product.sql b/samples/scripts/product.sql deleted file mode 100644 index 678c206..0000000 --- a/samples/scripts/product.sql +++ /dev/null @@ -1,96 +0,0 @@ -/* - Navicat Premium Data Transfer - - Source Server : local - Source Server Type : MySQL - Source Server Version : 80013 - Source Host : localhost:3306 - Source Schema : product - - Target Server Type : MySQL - Target Server Version : 80013 - File Encoding : 65001 - - Date: 07/06/2020 23:08:54 -*/ - -CREATE database if NOT EXISTS `product` default character set utf8mb4 collate utf8mb4_unicode_ci; -use `product`; - -SET NAMES utf8mb4; -SET FOREIGN_KEY_CHECKS = 0; - --- ---------------------------- --- Table structure for inventory --- ---------------------------- -DROP TABLE IF EXISTS `inventory`; -CREATE TABLE `inventory` ( - `sysno` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', - `product_sysno` bigint(20) unsigned NOT NULL, - `account_qty` int(11) DEFAULT NULL COMMENT '财务库存', - `available_qty` int(11) DEFAULT NULL COMMENT '可用库存', - `allocated_qty` int(11) DEFAULT NULL COMMENT '分配库存', - `adjust_locked_qty` int(11) DEFAULT NULL COMMENT '调整锁定库存', - PRIMARY KEY (`sysno`) -) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='商品库存'; - --- ---------------------------- --- Records of inventory --- ---------------------------- -BEGIN; -INSERT INTO `inventory` VALUES (1, 1, 1000000, 1000000, 0, 0); -COMMIT; - --- ---------------------------- --- Table structure for product --- ---------------------------- -DROP TABLE IF EXISTS `product`; -CREATE TABLE `product` ( - `sysno` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', - `product_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '品名', - `product_title` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, - `product_desc` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '描述', - `product_desc_long` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '描述', - `default_image_src` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL, - `c3_sysno` bigint(20) DEFAULT NULL, - `barcode` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL, - `length` int(11) DEFAULT NULL, - `width` int(11) DEFAULT NULL, - `height` int(11) DEFAULT NULL, - `weight` float DEFAULT NULL, - `merchant_sysno` bigint(20) DEFAULT NULL, - `merchant_productid` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL, - `status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '1,待上架;2,上架;3,下架;4,售罄下架;5,违规下架', - `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `create_user` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '创建人', - `modify_user` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '修改人', - `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', - PRIMARY KEY (`sysno`) -) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='商品SKU'; - --- ---------------------------- --- Records of product --- ---------------------------- -BEGIN; -INSERT INTO `product` VALUES (1, 'apple iphone 13', 'apple iphone 13', 'apple iphone 13', '', 'https://img10.360buyimg.com/mobilecms/s500x500_jfs/t1/61921/34/1166/131384/5cf60a94E411eee07/1ee010f4142236c3.jpg', 0, '', 15, 5, 5, 5, 1, '', 1, '2019-05-28 03:36:17', '', '', '2019-06-06 01:37:36'); -COMMIT; - --- ---------------------------- --- Table structure for undo_log --- ---------------------------- -DROP TABLE IF EXISTS `undo_log`; -CREATE TABLE `undo_log` ( - `id` bigint(20) NOT NULL AUTO_INCREMENT, - `branch_id` bigint(20) NOT NULL, - `xid` varchar(100) NOT NULL, - `context` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, - `rollback_info` longblob NOT NULL, - `log_status` int(11) NOT NULL, - `log_created` datetime NOT NULL, - `log_modified` datetime NOT NULL, - `ext` varchar(100) DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `idx_unionkey` (`xid`,`branch_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -SET FOREIGN_KEY_CHECKS = 1; From 8ff4e5588ce400d487b53ee50aa59b11206e7979 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E5=BF=97=E4=BC=9F?= Date: Sun, 22 May 2022 20:34:18 +0800 Subject: [PATCH 2/2] add dbpack-samples link --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 93e56bc..43f3d12 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ ## Documentation [Official Website](https://cectc.github.io/dbpack-doc/) +[Samples](https://github.com/CECTC/dbpack-samples) ## Requirements