Skip to content

Commit

Permalink
[ISSUE #8312] Add more mapper. (#9119)
Browse files Browse the repository at this point in the history
* [ISSUE #8312] Create ConfigInfoTagMapper, HisConfigInfoMapper and TenantInfoMapper.

* [ISSUE #8312] Add more mapper.

* [ISSUE #8312]Let mappers extend Mapper.
  • Loading branch information
The-Gamer-01 authored Sep 12, 2022
1 parent 5585fd3 commit 4916493
Show file tree
Hide file tree
Showing 8 changed files with 530 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* @author hyx
**/

public interface ConfigInfoAggrMapper {
public interface ConfigInfoAggrMapper extends Mapper {

/**
* Query content from config_info_aggr by dataId, groupId, tenantId and datumId.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* @author hyx
**/

public interface ConfigInfoBetaMapper {
public interface ConfigInfoBetaMapper extends Mapper {

/**
* Add beta configuration information.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* @author hyx
**/

public interface ConfigInfoMapper {
public interface ConfigInfoMapper extends Mapper {

/**
* Update md5.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*
* 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.mapper;

/**
* The config tag info mapper.
*
* @author hyx
**/

public interface ConfigInfoTagMapper extends Mapper {

/**
* Add tag configuration information and publish data change events.
* The default sql:
* INSERT INTO config_info_tag(data_id,group_id,tenant_id,tag_id,app_name,content,md5,src_ip,src_user,
* gmt_create,gmt_modified) VALUES(?,?,?,?,?,?,?,?,?,?,?)
*
* @return The sql of add tag configuration.
*/
String addConfigInfo4Tag();

/**
* Update tag configuration information.
* The default sql:
* UPDATE config_info_tag SET content=?, md5 = ?, src_ip=?,src_user=?,gmt_modified=?,app_name=? WHERE
* data_id=? AND group_id=? AND tenant_id=? AND tag_id=?
*
* @return The sql of updating tag configuration information.
*/
String updateConfigInfo4Tag();

/**
* Update tag configuration information.
* The default sql:
* UPDATE config_info_tag SET content=?, md5 = ?, src_ip=?,src_user=?,gmt_modified=?,app_name=? WHERE
* data_id=? AND group_id=? AND tenant_id=? AND tag_id=? AND (md5=? or md5 is null or md5='')
*
* @return The sql of updating tag configuration information.
*/
String updateConfigInfo4TagCas();

/**
* Query tag configuration information based on dataId and group.
* The default sql:
* SELECT id,data_id,group_id,tenant_id,tag_id,app_name,content FROM config_info_tag WHERE data_id=? AND group_id=? AND tenant_id=? AND tag_id=?
*
* @return The sql of querying tag configuration information based on dataId and group.
*/
String findConfigInfo4Tag();

/**
* Returns the number of beta configuration items.
* The default sql:
* SELECT count(ID) FROM config_info_tag
*
* @return The sql of querying the number of beta configuration items.
*/
String configInfoTagCount();

/**
* The count of config_info table sql.
* The default sql:
* SELECT count(*) FROM config_info_tag
*
* @return The sql of the count of config_info table.
*/
String count();

/**
* Query all tag config info for dump task.
* The default sql:
* SELECT t.id,data_id,group_id,tenant_id,tag_id,app_name,content,md5,gmt_modified
* FROM ( SELECT id FROM config_info_tag ORDER BY id LIMIT ?,? ) g,
* config_info_tag t WHERE g.id = t.id
*
* @return The sql of querying all tag config info for dump task.
*/
String findAllConfigInfoTagForDumpAllFetch();

/**
* Delete configuration; database atomic operation, minimum SQL action, no business encapsulation.
* The default sql:
* DELETE FROM config_info_tag WHERE data_id=? AND group_id=? AND tenant_id=? AND tag_id=?
*
* @return The sql of deleting configuration; database atomic operation, minimum SQL action, no business encapsulation.
*/
String removeConfigInfoTag();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/*
* 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.mapper;

/**
* The group capacity mapper.
*
* @author hyx
**/

public interface GroupCapacityMapper extends Mapper {

/**
* Get the group capacity.
* The default sql:
* SELECT id, quota, `usage`, `max_size`, max_aggr_count, max_aggr_size, group_id FROM group_capacity
* WHERE group_id=?
*
* @return The sql of getting the group capacity.
*/
String getGroupCapacity();

/**
* Insert GroupCapacity into db.
* The default sql:
* INSERT INTO group_capacity (group_id, quota, `usage`, `max_size`, max_aggr_count, max_aggr_size,
* gmt_create, gmt_modified) SELECT ?, ?, count(*), ?, ?, ?, ?, ? FROM config_info;
*
* @return The sql of add group capacity.
*/
String insertGroupCapacity();

/**
* Increment UsageWithDefaultQuotaLimit.
* The default sql:
* UPDATE group_capacity SET `usage` = `usage` + 1, gmt_modified = ?
* WHERE group_id = ? AND `usage` < ? AND quota = 0
*
* @return The sql of incrementing UsageWithDefaultQuotaLimit.
*/
String incrementUsageWithDefaultQuotaLimit();

/**
* Increment UsageWithQuotaLimit.
* The default sql:
* UPDATE group_capacity SET `usage` = `usage` + 1, gmt_modified = ?
* WHERE group_id = ? AND `usage` < quota AND quota != 0
*
* @return The sql of incrementing UsageWithQuotaLimit.
*/
String incrementUsageWithQuotaLimit();

/**
* Increment Usage.
* The default sql:
* UPDATE group_capacity SET `usage` = `usage` + 1, gmt_modified = ? WHERE group_id = ?
*
* @return The sql of incrementing Usage.
*/
String incrementUsage();

/**
* Decrement Usage.
* The default sql:
* UPDATE group_capacity SET `usage` = `usage` - 1, gmt_modified = ? WHERE group_id = ? AND `usage` > 0
*
* @return The sql of decrementing usage.
*/
String decrementUsage();

/**
* Update GroupCapacity.
* The default sql:
* update group_capacity set ... gmt_modified = ? WHERE group_id = ?
*
* @return The sql of updating group capacity.
*/
String updateGroupCapacity();

/**
* Correct Usage.
* The default sql:
* UPDATE group_capacity SET `usage` = (SELECT count(*) FROM config_info), gmt_modified = ? WHERE
* group_id = ?
*
* @return The sql of correcting usage.
*/
String correctUsage();

/**
* Get group capacity list, noly has id and groupId value.
* The default sql:
* SELECT id, group_id FROM group_capacity WHERE id>? LIMIT ?
*
* @return The sql of getting group capacity list.
*/
String getCapacityList4CorrectUsage();

/**
* Delete GroupCapacity.
* The default sql:
* DELETE FROM group_capacity WHERE group_id = ?;
*
* @return The sql of deleting group capacity.
*/
String deleteGroupCapacity();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
* 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.mapper;

/**
* The history config info mapper.
*
* @author hyx
**/

public interface HistoryConfigInfoMapper extends Mapper {

/**
* Delete data before startTime.
* The default sql:
* DELETE FROM his_config_info WHERE gmt_modified < ? LIMIT ?
*
* @return The sql of deleting data before startTime.
*/
String removeConfigHistory();

/**
* Get the number of configurations before the specified time.
* The default sql:
* SELECT count(*) FROM his_config_info WHERE gmt_modified < ?
*
* @return The sql of getting the number of configurations before the specified time.
*/
String findConfigHistoryCountByTime();

/**
* Query deleted config.
* The default sql:
* SELECT DISTINCT data_id, group_id, tenant_id FROM his_config_info WHERE op_type = 'D' AND gmt_modified >=? AND gmt_modified <= ?
*
* @return The sql of querying deleted config.
*/
String findDeletedConfig();

/**
* Update change records; database atomic operations, minimal sql actions, no business encapsulation.
* The default sql:
* INSERT INTO his_config_info (id,data_id,group_id,tenant_id,app_name,content,md5,src_ip,src_user,gmt_modified,op_type,encrypted_data_key)
* VALUES(?,?,?,?,?,?,?,?,?,?,?,?)
*
* @return The sql of updating change records; database atomic operations, minimal sql actions, no business encapsulation.
*/
String insertConfigHistoryAtomic();

/**
* Query the numbers of history config information by data_id, group_id AND tenant_id.
* The default sql:
* SELECT count(*) FROM his_config_info WHERE data_id = ? AND group_id = ? AND tenant_id = ?
*
* @return The sql of querying the numbers of history config information by data_id, group_id AND tenant_id.
*/
String findConfigHistoryCountRows();

/**
* List configuration history change record.
* The default sql:
* SELECT nid,data_id,group_id,tenant_id,app_name,src_ip,src_user,op_type,gmt_create,gmt_modified FROM his_config_info
* WHERE data_id = ? AND group_id = ? AND tenant_id = ? ORDER BY nid DESC
*
* @return The sql of listing configuration history change record.
*/
String findConfigHistoryFetchRows();

/**
* Get history config detail.
* The default sql:
* SELECT nid,data_id,group_id,tenant_id,app_name,content,md5,src_user,src_ip,op_type,gmt_create,gmt_modified,encrypted_data_key
* FROM his_config_info WHERE nid = ?
*
* @return The sql of getting history config detail.
*/
String detailConfigHistory();

/**
* Get previous config detail.
* The default sql:
* SELECT nid,data_id,group_id,tenant_id,app_name,content,md5,src_user,src_ip,op_type,gmt_create,gmt_modified
* FROM his_config_info WHERE nid = (SELECT max(nid) FROM his_config_info WHERE id = ?)
*
* @return The sql of getting previous config detail.
*/
String detailPreviousConfigHistory();
}
Loading

0 comments on commit 4916493

Please sign in to comment.