Skip to content

apijson动态数据源,从请求传入数据源信息,本项目为副本,请给原仓库点亮 ⭐️ Star

License

Notifications You must be signed in to change notification settings

APIJSON/apijson-dynamic-datasource

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

apijson-dynamic-datasource

项目中简单的实现了如下特性:

  1. 使用APIJSON如何在
  2. 在进行跨表批量增删改时如何保持事务一致性

APIJSON更多信息请查看

原理简述

在APIJSON的基础上,增加@ADDTransactional注解与AOP切面方法结合,找到跨表的批量操作并传递信号量,
根据信号量判断是否走源生commit事件,还是在AOP切面方法执行后统一commit
并增加对传入数据源信息参数的读取和使用
增加一个简单的连接池优化对数据库资源的使用

img.png

  • 黑色:原APIJSON代码
  • 红色:增加的代码

示例使用

DemoController.java中增加saveBatch方法批量处理增删改查操作,

请求url:
http://localhost:8080/saveBatch

请求示例:

[
  {
    "method": "post",
    "data": {
      "CZKTEST40": {
        "business_code": "f15afbd7-5f82-413d-85a6-d2054d60061a",
        "item_code": 1,
        "id": "010",
        "@dsUrl": "jdbc:mysql://10.133.92.80:3306/erp_dev_demo?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true",
        "@dsUserName": "root",
        "@dsPassword": "Mysql@2020"
      }
    }
  },
  {
    "method": "post",
    "data": {
      "CZKTEST40": {
        "business_code": "f15afbd7-5f82-413d-85a6-d2054d60061a",
        "item_code": 1,
        "id": "020",
        "@dsUrl": "jdbc:mysql://10.133.92.80:3306/erp_dev_demo?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true",
        "@dsUserName": "root",
        "@dsPassword": "Mysql@2020"
      }
    }
  }
]

响应示例

[
  {
    "msg": "success",
    "CZKTEST40": {
      "msg": "success",
      "code": 200,
      "@dsPassword": "Mysql@2020",
      "@dsUserName": "root",
      "count": 1,
      "id": "010",
      "ok": true,
      "@dsUrl": "jdbc:mysql://10.133.92.80:3306/erp_dev_demo?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true"
    },
    "code": 200,
    "ok": true
  },
  {
    "msg": "success",
    "CZKTEST40": {
      "msg": "success",
      "code": 200,
      "@dsPassword": "Mysql@2020",
      "@dsUserName": "root",
      "count": 1,
      "id": "020",
      "ok": true,
      "@dsUrl": "jdbc:mysql://10.133.92.80:3306/erp_dev_demo?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true"
    },
    "code": 200,
    "ok": true
  }
]

About

apijson动态数据源,从请求传入数据源信息,本项目为副本,请给原仓库点亮 ⭐️ Star

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%