diff --git a/.github/workflows/github-release.yml b/.github/workflows/github-release.yml new file mode 100644 index 0000000..a1b897f --- /dev/null +++ b/.github/workflows/github-release.yml @@ -0,0 +1,30 @@ +name: publish github release + +on: + workflow_dispatch: + inputs: + releaseversion: + description: 'Release version' + required: true + default: '0.0.1' + + +jobs: + publish-github-release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Create GitHub Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + with: + tag_name: ${{ github.event.inputs.releaseversion }} + release_name: ${{ github.event.inputs.releaseversion }} + body: | + ### Things that changed in this release + ${{ steps.changelog.outputs.changelog }} + draft: false + prerelease: ${{ contains(github.event.inputs.releaseversion, '-') }} diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml new file mode 100644 index 0000000..536efeb --- /dev/null +++ b/.github/workflows/maven.yml @@ -0,0 +1,27 @@ +# This workflow will build a Java project with Maven +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven + +name: nacos-datasource-plugin-pg + +on: + push: + branches: [ master,dev ] + pull_request: + branches: [ master,dev ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 8 + uses: actions/setup-java@v2 + with: + java-version: '8' + distribution: 'adopt' + + - name: mvn clean install + run: mvn clean install + + - name: mvn spring-javaformat:validate + run: mvn spring-javaformat:validate diff --git a/README.md b/README.md index 6be83b1..b688336 100644 --- a/README.md +++ b/README.md @@ -14,17 +14,18 @@ application.properties 配置文件中 spring.datasource.platform 配置项选 > 依赖已上传 maven 中央仓库,请勿使用阿里云代理 -| NACOS 版本 | 插件版本 | -|---------------|-------| -| 2.2.0 - 2.3.0 | 0.0.2 | -| 2.3.1 - 2.3.2 | 0.0.3 | +| NACOS 版本 | 插件版本 | +|---------------|----------| +| 2.2.0 - 2.3.0 | 0.0.2 | +| 2.3.1 - 2.3.2 | 0.0.4.PG | +| 2.4.0 - 2.4.1 | 0.0.5.PG | ```xml com.pig4cloud.plugin nacos-datasource-plugin-kingbase - 0.0.3 + 0.0.5.PG @@ -37,6 +38,8 @@ application.properties 配置文件中 spring.datasource.platform 配置项选 ### 2. 导入 nacos 人大金仓 数据库脚本 +- 请注意这里均使用 PG 协议测试,如有问题请自行修改脚本 + - 特殊设置: kingbase.conf , '' null 的转换 ```shell diff --git a/pom.xml b/pom.xml index c29658f..de16843 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ 4.0.0 com.pig4cloud.plugin nacos-datasource-plugin-kingbase - 0.0.4.PG + 0.0.5.PG nacos-datasource-plugin-kingbase nacos 人大金仓存储支持插件 https://pig4cloud.com @@ -25,7 +25,7 @@ - 2.3.2 + 2.4.1 0.0.32 3.8.1 1.8 diff --git a/src/main/java/com/pig4cloud/plugin/impl/kingbase/ConfigInfoAggrMapperByKingbase.java b/src/main/java/com/pig4cloud/plugin/impl/kingbase/ConfigInfoAggrMapperByKingbase.java index 4577ce1..7363adb 100644 --- a/src/main/java/com/pig4cloud/plugin/impl/kingbase/ConfigInfoAggrMapperByKingbase.java +++ b/src/main/java/com/pig4cloud/plugin/impl/kingbase/ConfigInfoAggrMapperByKingbase.java @@ -21,8 +21,7 @@ public MapperResult findConfigInfoAggrByPageFetchRows(MapperContext context) { String tenantId = (String) context.getWhereParameter(FieldConstant.TENANT_ID); String sql = "SELECT data_id,group_id,tenant_id,datum_id,app_name,content FROM config_info_aggr WHERE data_id= ? AND " - + "group_id= ? AND tenant_id= ? ORDER BY datum_id LIMIT " + pageSize + " offset " - + startRow; + + "group_id= ? AND tenant_id= ? ORDER BY datum_id LIMIT " + pageSize + " offset " + startRow; List paramList = CollectionUtils.list(dataId, groupId, tenantId); return new MapperResult(sql, paramList); } diff --git a/src/main/java/com/pig4cloud/plugin/impl/kingbase/ConfigInfoBetaMapperByKingbase.java b/src/main/java/com/pig4cloud/plugin/impl/kingbase/ConfigInfoBetaMapperByKingbase.java index d8e94e9..62d192b 100644 --- a/src/main/java/com/pig4cloud/plugin/impl/kingbase/ConfigInfoBetaMapperByKingbase.java +++ b/src/main/java/com/pig4cloud/plugin/impl/kingbase/ConfigInfoBetaMapperByKingbase.java @@ -16,8 +16,8 @@ public MapperResult findAllConfigInfoBetaForDumpAllFetchRows(MapperContext conte int startRow = context.getStartRow(); int pageSize = context.getPageSize(); String sql = " SELECT t.id,data_id,group_id,tenant_id,app_name,content,md5,gmt_modified,beta_ips,encrypted_data_key " - + " FROM ( SELECT id FROM config_info_beta ORDER BY id LIMIT " + pageSize + " offset " - + startRow + " )" + " g, config_info_beta t WHERE g.id = t.id "; + + " FROM ( SELECT id FROM config_info_beta ORDER BY id LIMIT " + pageSize + " offset " + startRow + + " )" + " g, config_info_beta t WHERE g.id = t.id "; List paramList = new ArrayList<>(); paramList.add(startRow); paramList.add(pageSize); diff --git a/src/main/java/com/pig4cloud/plugin/impl/kingbase/ConfigInfoMapperByKingbase.java b/src/main/java/com/pig4cloud/plugin/impl/kingbase/ConfigInfoMapperByKingbase.java index ade74f7..3ca735c 100644 --- a/src/main/java/com/pig4cloud/plugin/impl/kingbase/ConfigInfoMapperByKingbase.java +++ b/src/main/java/com/pig4cloud/plugin/impl/kingbase/ConfigInfoMapperByKingbase.java @@ -32,16 +32,14 @@ public MapperResult findConfigInfoByAppFetchRows(MapperContext context) { @Override public MapperResult getTenantIdList(MapperContext context) { String sql = "SELECT tenant_id FROM config_info WHERE tenant_id != '" + NamespaceUtil.getNamespaceDefaultId() - + "' GROUP BY tenant_id LIMIT " + context.getPageSize() + " offset " - + context.getStartRow(); + + "' GROUP BY tenant_id LIMIT " + context.getPageSize() + " offset " + context.getStartRow(); return new MapperResult(sql, Collections.emptyList()); } @Override public MapperResult getGroupIdList(MapperContext context) { String sql = "SELECT group_id FROM config_info WHERE tenant_id ='" + NamespaceUtil.getNamespaceDefaultId() - + "' GROUP BY group_id LIMIT " + context.getPageSize() + " offset " - + context.getStartRow(); + + "' GROUP BY group_id LIMIT " + context.getPageSize() + " offset " + context.getStartRow(); return new MapperResult(sql, Collections.emptyList()); } @@ -49,8 +47,7 @@ public MapperResult getGroupIdList(MapperContext context) { public MapperResult findAllConfigKey(MapperContext context) { String sql = " SELECT data_id,group_id,app_name FROM ( " + " SELECT id FROM config_info WHERE tenant_id LIKE ? ORDER BY id LIMIT " + context.getPageSize() - + " offset " + context.getStartRow() + " )" - + " g, config_info t WHERE g.id = t.id "; + + " offset " + context.getStartRow() + " )" + " g, config_info t WHERE g.id = t.id "; return new MapperResult(sql, CollectionUtils.list(context.getWhereParameter(FieldConstant.TENANT_ID))); } @@ -149,8 +146,9 @@ public MapperResult findConfigInfoBaseLikeFetchRows(MapperContext context) { where += " AND content LIKE ? "; paramList.add(content); } - return new MapperResult(sqlFetchRows + where + " LIMIT " + context.getPageSize() + " offset " - + context.getStartRow(), paramList); + return new MapperResult( + sqlFetchRows + where + " LIMIT " + context.getPageSize() + " offset " + context.getStartRow(), + paramList); } @Override @@ -183,8 +181,8 @@ public MapperResult findConfigInfo4PageFetchRows(MapperContext context) { where.append(" AND content LIKE ? "); paramList.add(content); } - return new MapperResult(sql + where + " LIMIT " + context.getPageSize() + " offset " - + context.getStartRow(), paramList); + return new MapperResult(sql + where + " LIMIT " + context.getPageSize() + " offset " + context.getStartRow(), + paramList); } @Override @@ -227,8 +225,9 @@ public MapperResult findConfigInfoLike4PageFetchRows(MapperContext context) { where.append(" AND content LIKE ? "); paramList.add(content); } - return new MapperResult(sqlFetchRows + where + " LIMIT " + context.getPageSize() + " offset " - + context.getStartRow(), paramList); + return new MapperResult( + sqlFetchRows + where + " LIMIT " + context.getPageSize() + " offset " + context.getStartRow(), + paramList); } @Override @@ -245,6 +244,4 @@ public String getDataSource() { return DataSourceConstant.KINGBASE; } - - } diff --git a/src/main/java/com/pig4cloud/plugin/impl/kingbase/KingbaseAbstractMapper.java b/src/main/java/com/pig4cloud/plugin/impl/kingbase/KingbaseAbstractMapper.java index 2ba2417..0d98537 100644 --- a/src/main/java/com/pig4cloud/plugin/impl/kingbase/KingbaseAbstractMapper.java +++ b/src/main/java/com/pig4cloud/plugin/impl/kingbase/KingbaseAbstractMapper.java @@ -152,4 +152,14 @@ public String count(List where) { return sql.toString(); } + /** + * Get function by functionName. + * @param functionName functionName + * @return function + */ + @Override + public String getFunction(String functionName) { + return "NOW()"; + } + }