This commit is contained in:
2024-03-21 18:39:49 +08:00
parent 59585e6369
commit 8cc55c2c4b
3 changed files with 308 additions and 0 deletions

View File

@@ -106,6 +106,7 @@
{url:"/metadata/metaLink.html", name:"实体关系", icon:"icon-branch"},
{url:"/metadata/metaService.html", name:"业务管理", icon: "icon-sliders"},
{url:"/metadata/dataList.html", name:"业务预览", icon:"icon-window-alt"},
/*{url: "/oth/ddlCompare.html", name: "DDL-Compare", icon: "icon-table"},*/
/*{url:"/metadata/dict.html", name:"字典管理", icon:"icon-usecase"},*/
/*{url:"/content/list.html", name:"游戏查询", icon:"icon-usecase"},
{url:"/content/funs.html", name:"平台功能", icon:"icon-usecase"},*/

198
root/oth/ddlCompare.html Normal file
View File

@@ -0,0 +1,198 @@
<row class="oth">
<!-- head -->
<!--<div class="col-md-2">
&lt;!&ndash;<h3 v-text="cfg.title"></h3>&ndash;&gt;
</div>-->
<div class="col-xs-2 sheet-cell">
数据源A
<select></select>
<select></select>
<br>
数据源B
<select></select>
<select></select>
<div style="padding-left: 10px;background-color: #ccc;width: 100%"> 实体表(Meta-Table)</div>
<!-- 创建一个空的树,需要包含 .tree CLASS -->
<ul class="tree tree-lines tree-angles" id="myTree" data-ride="tree"></ul>
</div>
<div class="col-md-10">
<div class="input-group pull-right" style="padding-top: 10px">
<a>HAO</a>
</div>
</div>
<div class="col-md-5">
<table class="table table-auto" style="width: 100%">
<tr>
<th>字段</th>
<th>备注</th>
<th>数据类型</th>
<th>默认值</th>
<th>可空</th>
</tr>
<tr>
<td>file_download_num</td>
<td>下载次数</td>
<td>int(11)</td>
<td>0</td>
<td>YES</td>
</tr>
<tr>
<td>xx</td>
<td>xx</td>
<td>xx</td>
<td>xx</td>
<td>xx</td>
</tr>
</table>
</div>
<div class="col-md-5">
<table class="table table-auto" style="width: 100%">
<tr>
<th>字段</th>
<th>备注</th>
<th>数据类型</th>
<th>默认值</th>
<th>可空</th>
</tr>
<tr>
<td>file_download_num</td>
<td>下载次数</td>
<td>int(11)</td>
<td>0</td>
<td>YES</td>
</tr>
<tr>
<td>xx</td>
<td>xx</td>
<td>xx</td>
<td>xx</td>
<td>xx</td>
</tr>
</table>
</div>
<!-- edit.modal -->
<div class="modal fade" id="myModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">关闭</span></button>
<h4 class="modal-title">金币发放 - [编辑]</h4>
</div>
<div class="modal-body">
<form class="form-horizontal">
<div class="form-group">
<label for="queryId" class="col-md-2 required">选择用户</label>
<div class="col-md-8">
<input v-model="row.name" class="form-control" id="queryId" placeholder="请输入 平台名称">
</div>
</div>
<div class="form-group">
<label for="token" class="col-md-2 required">平台 Token</label>
<div class="col-md-8 col-sm-10">
<input v-model="row.token" class="form-control" id="token" placeholder="请输入 Token">
</div>
</div>
<div class="form-group">
<label for="remark" class="col-md-2">备注</label>
<div class="col-md-8 col-sm-10">
<input v-model="row.remark" class="form-control" id="remark" placeholder="请输入 备注">
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
<button @click="save(row)" type="button" class="btn btn-primary">确定</button>
</div>
</div>
</div>
</div>
</row>
<script>
var myTreeData = [{"title":"ck","path":"","children":[{"title":"ck.go","path":"D:/wk/_own/go-demo/_hello/ck","children":null},{"title":"ck_test.go","path":"D:/wk/_own/go-demo/_hello/ck","children":null}]},{"title":"cmd","path":"","children":[{"title":"cmd_demo.go","path":"D:/wk/_own/go-demo/_hello/cmd","children":null},{"title":"pack.bat","path":"D:/wk/_own/go-demo/_hello/cmd","children":null},{"title":"pack_linux.bat","path":"D:/wk/_own/go-demo/_hello/cmd","children":null},{"title":"upx.exe","path":"D:/wk/_own/go-demo/_hello/cmd","children":null}]},{"title":"dev-kit","path":"","children":[{"title":"dev_kit.go","path":"D:/wk/_own/go-demo/_hello/dev-kit","children":null}]},{"title":"file-io","path":"","children":[{"title":"file_kit.go","path":"D:/wk/_own/go-demo/_hello/file-io","children":null},{"title":"file_kit_test.go","path":"D:/wk/_own/go-demo/_hello/file-io","children":null},{"title":"file_read_test.go","path":"D:/wk/_own/go-demo/_hello/file-io","children":null},{"title":"file_write_test.go","path":"D:/wk/_own/go-demo/_hello/file-io","children":null},{"title":"pub.txt","path":"D:/wk/_own/go-demo/_hello/file-io","children":null},{"title":"test.txt","path":"D:/wk/_own/go-demo/_hello/file-io","children":null},{"title":"test1.txt","path":"D:/wk/_own/go-demo/_hello/file-io","children":null},{"title":"test2.txt","path":"D:/wk/_own/go-demo/_hello/file-io","children":null}]},{"title":"goroutine","path":"","children":[{"title":"gotoutine_test.go","path":"D:/wk/_own/go-demo/_hello/goroutine","children":null},{"title":"pool_test.go","path":"D:/wk/_own/go-demo/_hello/goroutine","children":null}]},{"title":"interface","path":"","children":[{"title":"interface_test.go","path":"D:/wk/_own/go-demo/_hello/interface","children":null}]},{"title":"net","path":"","children":[{"title":"net-x","path":"","children":[{"title":"UserController.go","path":"D:/wk/_own/go-demo/_hello/net/net-x","children":null},{"title":"a.go","path":"D:/wk/_own/go-demo/_hello/net/net-x","children":null}]},{"title":"net-demo.go","path":"D:/wk/_own/go-demo/_hello/net","children":null},{"title":"net_x.go","path":"D:/wk/_own/go-demo/_hello/net","children":null}]},{"title":"pulsar","path":"","children":[{"title":"pulsar_test.go","path":"D:/wk/_own/go-demo/_hello/pulsar","children":null}]},{"title":"struct","path":"","children":[{"title":"struct-demo.go","path":"D:/wk/_own/go-demo/_hello/struct","children":null}]},{"title":"timer","path":"","children":[{"title":"timer_test.go","path":"D:/wk/_own/go-demo/_hello/timer","children":null}]},{"title":"hello_test.go","path":"D:/wk/_own/go-demo/_hello","children":null}]
let { platList, platSave } = plat
let { filetoken } = tmp
var vm = new Vue({
el: ".oth",
data: {
cfg: {
title: "业务平台 管理",
cols: [
{col: "name", label: "业务名称"},
{col: "token", label: "Token"},
{col: "remark", label: "说明"},
{col: "status", label: "状态", fmt: function (v) {
return {"0":"未启用", "1":"启用", "-1":"删除"}[v] || "";
}},
],
filters: []
},
list: {rows:[], total: 0},
row: {},
content:"",
token: "x"
},
watch: {
},
methods: {
findList () {
platList().then(res => {
vm.list = res
})
},
update: function (kv, row) {
red.post("/meta/save", {
_id: row._id,
doc: JSON.stringify(kv)
}, function (json) {
red.showMsg();
red.putAll(row, kv);
vm.findList();
});
},
edit: function (row) {
vm.row = row;
console.log(this.row);
$('#myModal').modal({moveable: true});
},
save: function (row) {
platSave({plat: row}).then(() => {
red.showMsg({msg: "操作成功"})
$('#myModal').modal('hide')
})
}
},
mounted: function () {
this.findList();
$('#myTree').tree({
data: myTreeData
,itemCreator: function($li, item) {
$li.append($('<a/>', {href: item.url, click: ()=>{
console.log(item.title)
vm.content = item.title
}}).text(item.title));
// return false; // 如果要忽略当前节点,可以通过返回 false 来实现
}
});
filetoken().then(res => {
this.token = res[0]
console.log(this.token)
})
}
});
</script>

View File

@@ -100,4 +100,113 @@ public class _DbService extends BaseService {
return jBean;
}
// 比对表结构
/*@RestMapping(name = "table_compare", comment = "对比表结构")
public Kv tableCompare(String dbPlatA, String dbPlatB, String catalog) {
String sql = String.format("SELECT table_name 'tableName', column_name 'columnName', column_comment 'columnComment',column_type 'columnType',column_default 'columnDefault', is_nullable 'isNullable'" +
" FROM INFORMATION_SCHEMA.COLUMNS" +
" WHERE table_schema = '%s'", catalog);
List<Column> listA = MetaKit.getDbKit(dbPlatA, catalog).queryList(sql, Column.class);
List<Column> listB = MetaKit.getDbKit(dbPlatB, catalog).queryList(sql, Column.class);
Map<String, List<Column>> ddlA = Utils.group(listA, Column::getTableName);
Map<String, List<Column>> ddlB = Utils.group(listB, Column::getTableName);
Set<String> same = new HashSet<>(); // table_name;
List<Kv<String, Object>> differ = new ArrayList<>(); // 不相同的表,以及对应 A、B库的字段信息如[{"tableName": "", A: [{}], B: [{}], dif: [{}] }]
Kv<String, List<Table>> without = Kv.of(); // A,B不在对方库的表{A: [{}], B: [{}]}
ddlA.forEach((tableName, columns) -> {
// A 有B 无
if (!ddlB.containsKey(tableName)) {
List<Table> tables = without.getOrDefault("A", new ArrayList<>());
tables.add(new Table(tableName, columns));
without.set("A", tables);
}
// TODO 相同 、差异比较
List<Column> columns2 = ddlB.get(tableName);
if (columns2 == null) {
return;
}
List<Kv<String, Object>> dif = new ArrayList<>();
for (Column column : columns) {
Column column2 = columns2.stream().filter(c -> c.getColumnName().equals(column.getColumnName())).findFirst().orElse(null);
if (column2 == null) {
dif.add(Kv.of("column", column.getColumnName()).set("diff", "column not exist in B"));
} else {
if (!column.getColumnName().equals(column2.getColumnName())) {
dif.add(Kv.of("column", column.getColumnName()).set( "diff", "column name not same"));
}
if (!column.getColumnComment().equals(column2.getColumnComment())) {
dif.add(Kv.of("column", column.getColumnName()).set( "diff", "column comment not same"));
}
if (!column.getColumnType().equals(column2.getColumnType())) {
dif.add(Kv.of("column", column.getColumnName()).set( "diff", "column type not same"));
}
if (!column.getColumnDefault().equals(column2.getColumnDefault())) {
dif.add(Kv.of("column", column.getColumnName()).set( "diff", "column default not same"));
}
if (!column.getIsNullable().equals(column2.getIsNullable())) {
dif.add(Kv.of("column", column.getColumnName()).set( "diff", "column nullable not same"));
}
}
}
// columns2 中有 columns 中没有
for (Column column2 : columns2) {
if (!columns.stream().anyMatch(c -> c.getColumnName().equals(column2.getColumnName()))) {
dif.add(Kv.of("column", column2.getColumnName()).set( "diff", "column not exist in A"));
}
}
if (dif.size() > 0) {
differ.add(Kv.of("tableName", tableName).set( "A", columns).set( "B", columns2).set( "dif", dif));
}
});
// B 有A 无
ddlB.forEach((tableName, columns) -> {
if (ddlA.containsKey(tableName)) {
return;
}
List<Table> tables = without.getOrDefault("B", new ArrayList<>());
tables.add(new Table(tableName, columns));
without.set("B", tables);
});
Kv retKv = Kv.of(); // 返回结果
retKv.set("same", same);
retKv.set("differ", differ);
retKv.set("without", without);
return retKv;
}
@Getter
@Setter
static class Table {
String tableName;
List<Column> columns;
public Table(String tableName, List<Column> columns) {
this.tableName = tableName;
this.columns = columns;
}
}
@Getter
@Setter
static class Column {
@ConvertColumn(ignore = true)
private String tableName;
private String columnName;
private String columnComment;
private String columnType;
private String columnDefault;
private String isNullable;
}*/
}