-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
upgrade(version): 0.0.3 适配 nacos 2.3.2
注意更新SQL , users 表字段不兼容
- Loading branch information
Showing
13 changed files
with
431 additions
and
618 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,30 +5,31 @@ | |
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>2.7.15</version> | ||
<version>2.7.18</version> | ||
<relativePath/> <!-- lookup parent from repository --> | ||
</parent> | ||
<groupId>com.pig4cloud.plugin</groupId> | ||
<artifactId>nacos-datasource-plugin-pg</artifactId> | ||
<version>0.0.2</version> | ||
<version>0.0.3</version> | ||
<name>nacos-datasource-plugin-pg</name> | ||
<description>nacos-datasource-plugin-pg</description> | ||
<url>https://pig4cloud.com</url> | ||
|
||
<licenses> | ||
<license> | ||
<name>The ApacheSoftware License, Version 2.0</name> | ||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> | ||
<distribution>repo</distribution> | ||
</license> | ||
</licenses> | ||
|
||
<properties> | ||
<nacos.version>2.3.2</nacos.version> | ||
<spring.checkstyle.plugin>0.0.32</spring.checkstyle.plugin> | ||
<maven.compiler.version>3.8.1</maven.compiler.version> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
<spring.checkstyle.plugin>0.0.32</spring.checkstyle.plugin> | ||
<git.commit.plugin>2.2.5</git.commit.plugin> | ||
<commons-compress>1.21</commons-compress> | ||
<maven.compiler.version>3.8.1</maven.compiler.version> | ||
</properties> | ||
|
||
<developers> | ||
|
@@ -37,6 +38,7 @@ | |
<email>[email protected]</email> | ||
</developer> | ||
</developers> | ||
|
||
<scm> | ||
<tag>master</tag> | ||
<connection>https://gitee.wang/lengleng/pig</connection> | ||
|
@@ -45,42 +47,34 @@ | |
</scm> | ||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<optional>true</optional> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.alibaba.nacos</groupId> | ||
<artifactId>nacos-datasource-plugin</artifactId> | ||
<version>2.2.4</version> | ||
<version>${nacos.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.alibaba.nacos</groupId> | ||
<artifactId>nacos-common</artifactId> | ||
<version>2.2.4</version> | ||
<version>${nacos.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<!--打包jar 与git commit 关联插件--> | ||
<plugin> | ||
<groupId>pl.project13.maven</groupId> | ||
<artifactId>git-commit-id-plugin</artifactId> | ||
<version>${git.commit.plugin}</version> | ||
</plugin> | ||
<!--代码格式插件,默认使用spring 规则--> | ||
<plugin> | ||
<groupId>io.spring.javaformat</groupId> | ||
|
@@ -272,4 +266,5 @@ | |
</distributionManagement> | ||
</profile> | ||
</profiles> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 18 additions & 58 deletions
76
src/main/java/com/pig4cloud/plugin/impl/postgresql/ConfigInfoAggrMapperByPostgresql.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,35 @@ | ||
package com.pig4cloud.plugin.impl.postgresql; | ||
|
||
import com.alibaba.nacos.plugin.datasource.constants.TableConstant; | ||
import com.alibaba.nacos.plugin.datasource.mapper.AbstractMapper; | ||
import com.alibaba.nacos.common.utils.CollectionUtils; | ||
import com.alibaba.nacos.plugin.datasource.constants.FieldConstant; | ||
import com.alibaba.nacos.plugin.datasource.mapper.ConfigInfoAggrMapper; | ||
import com.alibaba.nacos.plugin.datasource.model.MapperContext; | ||
import com.alibaba.nacos.plugin.datasource.model.MapperResult; | ||
import com.pig4cloud.plugin.constants.DataSourceConstant; | ||
|
||
import java.util.List; | ||
|
||
public class ConfigInfoAggrMapperByPostgresql extends AbstractMapper implements ConfigInfoAggrMapper { | ||
|
||
/** | ||
* 批量删除 | ||
* @param datumList | ||
* @return | ||
*/ | ||
public String batchRemoveAggr(List<String> datumList) { | ||
final StringBuilder datumString = new StringBuilder(); | ||
for (String datum : datumList) { | ||
datumString.append('\'').append(datum).append("',"); | ||
} | ||
datumString.deleteCharAt(datumString.length() - 1); | ||
return "DELETE FROM config_info_aggr WHERE data_id = ? AND group_id = ? AND tenant_id = ? AND datum_id IN (" | ||
+ datumString + ")"; | ||
} | ||
|
||
@Override | ||
public String aggrConfigInfoCount(int size, boolean isIn) { | ||
StringBuilder sql = new StringBuilder( | ||
"SELECT count(*) FROM config_info_aggr WHERE data_id = ? AND group_id = ? AND tenant_id = ? AND datum_id"); | ||
if (isIn) { | ||
sql.append(" IN ("); | ||
} | ||
else { | ||
sql.append(" NOT IN ("); | ||
} | ||
for (int i = 0; i < size; i++) { | ||
if (i > 0) { | ||
sql.append(", "); | ||
} | ||
sql.append('?'); | ||
} | ||
sql.append(')'); | ||
|
||
return sql.toString(); | ||
} | ||
|
||
@Override | ||
public String findConfigInfoAggrIsOrdered() { | ||
return "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"; | ||
} | ||
|
||
@Override | ||
public String findConfigInfoAggrByPageFetchRows(int startRow, int pageSize) { | ||
return "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; | ||
} | ||
public class ConfigInfoAggrMapperByPostgresql extends PostgresqlAbstractMapper implements ConfigInfoAggrMapper { | ||
|
||
@Override | ||
public String findAllAggrGroupByDistinct() { | ||
return "SELECT DISTINCT data_id, group_id, tenant_id FROM config_info_aggr"; | ||
} | ||
|
||
@Override | ||
public String getTableName() { | ||
return TableConstant.CONFIG_INFO_AGGR; | ||
public MapperResult findConfigInfoAggrByPageFetchRows(MapperContext context) { | ||
int startRow = context.getStartRow(); | ||
int pageSize = context.getPageSize(); | ||
String dataId = (String) context.getWhereParameter(FieldConstant.DATA_ID); | ||
String groupId = (String) context.getWhereParameter(FieldConstant.GROUP_ID); | ||
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; | ||
List<Object> paramList = CollectionUtils.list(dataId, groupId, tenantId); | ||
return new MapperResult(sql, paramList); | ||
} | ||
|
||
@Override | ||
public String getDataSource() { | ||
return DataSourceConstant.POSTGRESQL; | ||
} | ||
|
||
|
||
} |
31 changes: 15 additions & 16 deletions
31
src/main/java/com/pig4cloud/plugin/impl/postgresql/ConfigInfoBetaMapperByPostgresql.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.