Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE #8312]Update the mappers. #9190

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
/*
* Copyright 1999-2022 Alibaba Group Holding Ltd.
*
* 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.alibaba.nacos.plugin.datasource.impl.derby;

import com.alibaba.nacos.plugin.datasource.constants.TableConstant;
import com.alibaba.nacos.plugin.datasource.mapper.ConfigInfoAggrMapper;

import java.util.List;

/**
* The derby implementation of ConfigInfoAggrMapper.
*
* @author hyx
**/

public class ConfigInfoAggrMapperByDerby implements ConfigInfoAggrMapper {

@Override
public String select() {
return "SELECT content FROM config_info_aggr WHERE data_id = ? AND group_id = ? AND tenant_id = ? AND datum_id = ?";
}

@Override
public String insert() {
return "INSERT INTO config_info_aggr(data_id, group_id, tenant_id, datum_id, app_name, content, gmt_modified) VALUES(?,?,?,?,?,?,?)";
}

@Override
public String update() {
return "UPDATE config_info_aggr SET content = ? , gmt_modified = ? WHERE data_id = ? AND group_id = ? AND tenant_id = ? AND datum_id = ?";
}

@Override
public String removeAggrConfigInfo() {
return "DELETE FROM config_info_aggr WHERE data_id=? AND group_id=? AND tenant_id=?";
}

@Override
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.toString() + ")";
}

@Override
public String removeSingleAggrConfigInfo() {
return "DELETE FROM config_info_aggr WHERE data_id=? AND group_id=? AND tenant_id=? AND datum_id=?";
}

@Override
public String replaceAggr() {
return "INSERT INTO config_info_aggr(data_id, group_id, tenant_id, datum_id, app_name, "
+ "content, gmt_modified) VALUES(?,?,?,?,?,?,?) ";
}

@Override
public String aggrConfigInfoCount(List<String> datumIds, boolean isIn) {
return " SELECT count(*) FROM config_info_aggr WHERE data_id = ? AND group_id = ? AND tenant_id = ?";
}

@Override
public String findSingleConfigInfoAggr() {
return "SELECT id,data_id,group_id,tenant_id,datum_id,app_name,content FROM config_info_aggr WHERE data_id=? "
+ "AND group_id=? AND tenant_id=? AND datum_id=?";
}

@Override
public String findConfigInfoAggr() {
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 findConfigInfoAggrByPageCountRows() {
return "SELECT count(*) FROM config_info_aggr WHERE data_id = ? AND group_id = ? AND tenant_id = ?";
}

@Override
public String findConfigInfoAggrByPageFetchRows() {
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 ?,?";
}

@Override
public String findAllAggrGroup() {
return "SELECT DISTINCT data_id, group_id, tenant_id FROM config_info_aggr";
}

@Override
public String findDatumIdByContent() {
return "SELECT datum_id FROM config_info_aggr WHERE data_id = ? AND group_id = ? AND content = ? ";
}

@Override
public String getTableName() {
return TableConstant.CONFIG_INFO_AGGR;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* Copyright 1999-2022 Alibaba Group Holding Ltd.
*
* 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.alibaba.nacos.plugin.datasource.impl.derby;

import com.alibaba.nacos.plugin.datasource.constants.TableConstant;
import com.alibaba.nacos.plugin.datasource.mapper.ConfigInfoBetaMapper;

/**
* The derby implementation of ConfigInfoBetaMapper.
*
* @author hyx
**/

public class ConfigInfoBetaMapperByDerby implements ConfigInfoBetaMapper {

@Override
public String addConfigInfo4Beta() {
return "INSERT INTO config_info_beta(data_id,group_id,tenant_id,app_name,content,md5,beta_ips,src_ip,"
+ "src_user,gmt_create,gmt_modified,encrypted_data_key) VALUES(?,?,?,?,?,?,?,?,?,?,?,?)";
}

@Override
public String updateConfigInfo4Beta() {
return "UPDATE config_info_beta SET content=?,md5=?,beta_ips=?,src_ip=?,src_user=?,gmt_modified=?,app_name=?,encrypted_data_key=? "
+ "WHERE data_id=? AND group_id=? AND tenant_id=?";
}

@Override
public String updateConfigInfo4BetaCas() {
return "UPDATE config_info_beta SET content=?,md5=?,beta_ips=?,src_ip=?,src_user=?,gmt_modified=?,app_name=? "
+ "WHERE data_id=? AND group_id=? AND tenant_id=? AND (md5=? OR md5 IS NULL OR md5='')";
}

@Override
public String removeConfigInfo4Beta() {
return "DELETE FROM config_info_beta WHERE data_id=? AND group_id=? AND tenant_id=?";
}

@Override
public String findConfigInfo4Beta() {
return "SELECT id,data_id,group_id,tenant_id,app_name,content,beta_ips,encrypted_data_key FROM config_info_beta "
+ "WHERE data_id=? AND group_id=? AND tenant_id=?";
}

@Override
public String count() {
return "SELECT COUNT(*) FROM config_info_beta";
}

@Override
public String findAllConfigInfoBetaForDumpAllFetchRows() {
return " SELECT t.id,data_id,group_id,tenant_id,app_name,content,md5,gmt_modified,beta_ips "
+ " FROM ( SELECT id FROM config_info_beta ORDER BY id LIMIT ?,? )"
+ " g, config_info_beta t WHERE g.id = t.id ";
}

@Override
public String getTableName() {
return TableConstant.CONFIG_INFO_BETA;
}
}
Loading