Skip to content

Commit

Permalink
Change the "configType" field to "publishType"(alibaba#12217
Browse files Browse the repository at this point in the history
  • Loading branch information
KiteSoar committed Aug 13, 2024
1 parent a90a732 commit d485756
Show file tree
Hide file tree
Showing 16 changed files with 51 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class ConfigHistoryInfo implements Serializable {
*/
private String opType;

private String configType;
private String publishType;

private String extraInfo;

Expand Down Expand Up @@ -140,12 +140,12 @@ public void setOpType(String opType) {
this.opType = opType;
}

public String getConfigType() {
return configType;
public String getPublishType() {
return publishType;
}

public void setConfigType(String configType) {
this.configType = configType;
public void setPublishType(String publishType) {
this.publishType = publishType;
}

public String getExtraInfo() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ public ConfigHistoryInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
configHistoryInfo.setSrcIp(rs.getString("src_ip"));
configHistoryInfo.setSrcUser(rs.getString("src_user"));
configHistoryInfo.setOpType(rs.getString("op_type"));
configHistoryInfo.setConfigType(rs.getString("config_type"));
configHistoryInfo.setPublishType(rs.getString("publish_type"));
configHistoryInfo.setExtraInfo(rs.getString("ext_info"));
configHistoryInfo.setCreatedTime(rs.getTimestamp("gmt_create"));
configHistoryInfo.setLastModifiedTime(rs.getTimestamp("gmt_modified"));
Expand All @@ -587,7 +587,7 @@ public ConfigHistoryInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
configHistoryInfo.setSrcUser(rs.getString("src_user"));
configHistoryInfo.setSrcIp(rs.getString("src_ip"));
configHistoryInfo.setOpType(rs.getString("op_type"));
configHistoryInfo.setConfigType(rs.getString("config_type"));
configHistoryInfo.setPublishType(rs.getString("publish_type"));
configHistoryInfo.setExtraInfo(rs.getString("ext_info"));
configHistoryInfo.setCreatedTime(rs.getTimestamp("gmt_create"));
configHistoryInfo.setLastModifiedTime(rs.getTimestamp("gmt_modified"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ public interface HistoryConfigInfoPersistService {
* @param srcUser user
* @param time time
* @param ops ops type
* @param configType config type
* @param publishType publish type
* @param extraInfo extra config info
*/
void insertConfigHistoryAtomic(long id, ConfigInfo configInfo, String srcIp, String srcUser, final Timestamp time,
String ops, String configType, String extraInfo);
String ops, String publishType, String extraInfo);
//------------------------------------------delete---------------------------------------------//

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,20 @@ public <E> PaginationHelper<E> createPaginationHelper() {

@Override
public void insertConfigHistoryAtomic(long configHistoryId, ConfigInfo configInfo, String srcIp, String srcUser,
final Timestamp time, String ops, String configType, String extraInfo) {
final Timestamp time, String ops, String publishType, String extraInfo) {
String appNameTmp = StringUtils.defaultEmptyIfBlank(configInfo.getAppName());
String tenantTmp = StringUtils.defaultEmptyIfBlank(configInfo.getTenant());
final String md5Tmp = MD5Utils.md5Hex(configInfo.getContent(), Constants.ENCODE);
String configTypeTmp = StringUtils.defaultEmptyIfBlank(configType);
String publishTypeTmp = StringUtils.defaultEmptyIfBlank(publishType);
String encryptedDataKey = StringUtils.defaultEmptyIfBlank(configInfo.getEncryptedDataKey());

HistoryConfigInfoMapper historyConfigInfoMapper = mapperManager.findMapper(
dataSourceService.getDataSourceType(), TableConstant.HIS_CONFIG_INFO);
final String sql = historyConfigInfoMapper.insert(
Arrays.asList("id", "data_id", "group_id", "tenant_id", "app_name", "content", "md5", "src_ip",
"src_user", "gmt_modified", "op_type", "config_type", "ext_info", "encrypted_data_key"));
"src_user", "gmt_modified", "op_type", "publish_type", "ext_info", "encrypted_data_key"));
final Object[] args = new Object[] {configHistoryId, configInfo.getDataId(), configInfo.getGroup(), tenantTmp,
appNameTmp, configInfo.getContent(), md5Tmp, srcIp, srcUser, time, ops, configTypeTmp, extraInfo, encryptedDataKey};
appNameTmp, configInfo.getContent(), md5Tmp, srcIp, srcUser, time, ops, publishTypeTmp, extraInfo, encryptedDataKey};

EmbeddedStorageContextHolder.addSqlContext(sql, args);
}
Expand Down Expand Up @@ -162,7 +162,7 @@ public ConfigHistoryInfo detailConfigHistory(Long nid) {
dataSourceService.getDataSourceType(), TableConstant.HIS_CONFIG_INFO);
String sqlFetchRows = historyConfigInfoMapper.select(
Arrays.asList("nid", "data_id", "group_id", "tenant_id", "app_name", "content", "md5", "src_user",
"src_ip", "op_type", "config_type", "ext_info", "gmt_create", "gmt_modified", "encrypted_data_key"),
"src_ip", "op_type", "publish_type", "ext_info", "gmt_create", "gmt_modified", "encrypted_data_key"),
Collections.singletonList("nid"));
return databaseOperate.queryOne(sqlFetchRows, new Object[] {nid}, HISTORY_DETAIL_ROW_MAPPER);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,21 @@ public <E> PaginationHelper<E> createPaginationHelper() {

@Override
public void insertConfigHistoryAtomic(long id, ConfigInfo configInfo, String srcIp, String srcUser,
final Timestamp time, String ops, String configType, String extraInfo) {
final Timestamp time, String ops, String publishType, String extraInfo) {
String appNameTmp = StringUtils.defaultEmptyIfBlank(configInfo.getAppName());
String tenantTmp = StringUtils.defaultEmptyIfBlank(configInfo.getTenant());
final String md5Tmp = MD5Utils.md5Hex(configInfo.getContent(), Constants.ENCODE);
String encryptedDataKey = StringUtils.defaultEmptyIfBlank(configInfo.getEncryptedDataKey());
String configTypeTmp = StringUtils.defaultEmptyIfBlank(configType);
String publishTypeTmp = StringUtils.defaultEmptyIfBlank(publishType);

try {
HistoryConfigInfoMapper historyConfigInfoMapper = mapperManager.findMapper(
dataSourceService.getDataSourceType(), TableConstant.HIS_CONFIG_INFO);
jt.update(historyConfigInfoMapper.insert(
Arrays.asList("id", "data_id", "group_id", "tenant_id", "app_name", "content", "md5", "src_ip",
"src_user", "gmt_modified", "op_type", "config_type", "ext_info", "encrypted_data_key")),
"src_user", "gmt_modified", "op_type", "publish_type", "ext_info", "encrypted_data_key")),
id, configInfo.getDataId(), configInfo.getGroup(), tenantTmp, appNameTmp, configInfo.getContent(),
md5Tmp, srcIp, srcUser, time, ops, configTypeTmp, extraInfo, encryptedDataKey);
md5Tmp, srcIp, srcUser, time, ops, publishTypeTmp, extraInfo, encryptedDataKey);
} catch (DataAccessException e) {
LogUtil.FATAL_LOG.error("[db-error] " + e, e);
throw e;
Expand Down Expand Up @@ -175,7 +175,7 @@ public ConfigHistoryInfo detailConfigHistory(Long nid) {
dataSourceService.getDataSourceType(), TableConstant.HIS_CONFIG_INFO);
String sqlFetchRows = historyConfigInfoMapper.select(
Arrays.asList("nid", "data_id", "group_id", "tenant_id", "app_name", "content", "md5", "src_user",
"src_ip", "op_type", "gmt_create", "gmt_modified", "config_type", "ext_info", "encrypted_data_key"),
"src_ip", "op_type", "gmt_create", "gmt_modified", "publish_type", "ext_info", "encrypted_data_key"),
Collections.singletonList("nid"));
try {
ConfigHistoryInfo historyInfo = jt.queryForObject(sqlFetchRows, new Object[] {nid},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,20 @@ void testInsertConfigHistoryAtomic() {
String srcUser = "user12345";
String srcIp = "ip1234";
String ops = "D";
String configType = "formal";
String publishType = "formal";
String extraInfo = "{\"type\":\"properties\"}";
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
ConfigInfo configInfo = new ConfigInfo(dataId, group, tenant, appName, content);
configInfo.setEncryptedDataKey("key23456");
//expect insert success,verify insert invoked
embeddedHistoryConfigInfoPersistService.insertConfigHistoryAtomic(id, configInfo, srcIp, srcUser, timestamp, ops, configType, extraInfo);
embeddedHistoryConfigInfoPersistService.insertConfigHistoryAtomic(id, configInfo, srcIp, srcUser, timestamp, ops,
publishType, extraInfo);

//verify insert to be invoked
embeddedStorageContextHolderMockedStatic.verify(
() -> EmbeddedStorageContextHolder.addSqlContext(anyString(), eq(id), eq(dataId), eq(group), eq(tenant), eq(appName),
eq(content), eq(configInfo.getMd5()), eq(srcIp), eq(srcUser), eq(timestamp), eq(ops), eq(configType), eq(extraInfo),
eq(content), eq(configInfo.getMd5()), eq(srcIp), eq(srcUser), eq(timestamp), eq(ops), eq(
publishType), eq(extraInfo),
eq(configInfo.getEncryptedDataKey())), times(1));
}

Expand Down
2 changes: 1 addition & 1 deletion console-ui/src/locales/en-US.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ const I18N_CONF = {
lastUpdateTime: 'Last Modified At',
operator: 'Operator',
operation: 'Operation',
configType: 'Config Type',
publishType: 'Publish Type',
formal: 'Formal Version',
gray: 'Gray Version',
compare: 'Compare',
Expand Down
2 changes: 1 addition & 1 deletion console-ui/src/locales/zh-CN.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ const I18N_CONF = {
articleMeetRequirements: '条满足要求的配置。',
lastUpdateTime: '最后更新时间',
operator: '操作人',
configType: '配置类型',
publishType: '发布类型',
formal: '正式版本',
gray: '灰度版本',
operation: '操作',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class HistoryRollback extends React.Component {

renderCol(value, index, record) {
const { locale = {} } = this.props;
const isBeta = record.configType === 'gray';
const isBeta = record.publishType === 'gray';
return (
<div>
<a onClick={this.goDetail.bind(this, record)} style={{ marginRight: 5 }}>
Expand Down Expand Up @@ -440,8 +440,8 @@ class HistoryRollback extends React.Component {
<Table.Column title="Data ID" dataIndex="dataId" />
<Table.Column title="Group" dataIndex="group" />
<Table.Column
title={locale.configType}
dataIndex="configType"
title={locale.publishType}
dataIndex="publishType"
cell={(value, index, record) => {
if (value === 'formal') {
return locale.formal;
Expand Down
16 changes: 8 additions & 8 deletions console/src/main/resources/static/console-ui/public/js/main.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions console/src/main/resources/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<link rel="stylesheet" type="text/css" href="console-ui/public/css/icon.css">
<link rel="stylesheet" type="text/css" href="console-ui/public/css/font-awesome.css">
<!-- 第三方css结束 -->
<link href="./css/main.css?dc1cbb269b5d98a893e2" rel="stylesheet"></head>
<link href="./css/main.css?83d40c9f1114d4587b10" rel="stylesheet"></head>

<body>
<div id="root" style="overflow:hidden"></div>
Expand All @@ -56,6 +56,6 @@
<script src="console-ui/public/js/merge.js"></script>
<script src="console-ui/public/js/loader.js"></script>
<!-- 第三方js结束 -->
<script type="text/javascript" src="./js/main.js?dc1cbb269b5d98a893e2"></script></body>
<script type="text/javascript" src="./js/main.js?83d40c9f1114d4587b10"></script></body>

</html>
16 changes: 8 additions & 8 deletions console/src/main/resources/static/js/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion distribution/conf/derby-schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ CREATE TABLE his_config_info (
src_user varchar(128),
src_ip varchar(50) DEFAULT NULL,
op_type char(10) DEFAULT NULL,
config_type varchar(128) DEFAULT 'formal',
publish_type varchar(128) DEFAULT 'formal',
ext_info LONG VARCHAR DEFAULT NULL,
encrypted_data_key LONG VARCHAR DEFAULT NULL,
constraint hisconfiginfo_nid_key PRIMARY KEY (nid));
Expand Down
2 changes: 1 addition & 1 deletion distribution/conf/mysql-schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ CREATE TABLE `his_config_info` (
`src_ip` varchar(50) DEFAULT NULL COMMENT 'source ip',
`op_type` char(10) DEFAULT NULL COMMENT 'operation type',
`tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
`config_type` varchar(128) NOT NULL DEFAULT 'formal' COMMENT '配置类型',
`publish_type` varchar(128) NOT NULL DEFAULT 'formal' COMMENT '发布类型',
`ext_info` text DEFAULT NULL COMMENT '额外信息',
`encrypted_data_key` varchar(1024) NOT NULL DEFAULT '' COMMENT '密钥',
PRIMARY KEY (`nid`),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public MapperResult removeConfigHistory(MapperContext context) {
@Override
public MapperResult pageFindConfigHistoryFetchRows(MapperContext context) {
String sql =
"SELECT nid,data_id,group_id,tenant_id,app_name,src_ip,src_user,op_type,ext_info,config_type,gmt_create,gmt_modified "
"SELECT nid,data_id,group_id,tenant_id,app_name,src_ip,src_user,op_type,ext_info,publish_type,gmt_create,gmt_modified "
+ "FROM his_config_info "
+ "WHERE data_id = ? AND group_id = ? AND tenant_id = ? ORDER BY nid DESC OFFSET "
+ context.getStartRow() + " ROWS FETCH NEXT " + context.getPageSize() + " ROWS ONLY";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public MapperResult removeConfigHistory(MapperContext context) {
@Override
public MapperResult pageFindConfigHistoryFetchRows(MapperContext context) {
String sql =
"SELECT nid,data_id,group_id,tenant_id,app_name,src_ip,src_user,op_type,ext_info,config_type,gmt_create,gmt_modified "
"SELECT nid,data_id,group_id,tenant_id,app_name,src_ip,src_user,op_type,ext_info,publish_type,gmt_create,gmt_modified "
+ "FROM his_config_info " + "WHERE data_id = ? AND group_id = ? AND tenant_id = ? ORDER BY nid DESC LIMIT "
+ context.getStartRow() + "," + context.getPageSize();
return new MapperResult(sql, CollectionUtils.list(context.getWhereParameter(FieldConstant.DATA_ID),
Expand Down

0 comments on commit d485756

Please sign in to comment.