.
This commit is contained in:
@@ -48,8 +48,8 @@ const meta = {
|
||||
callback(json)
|
||||
})
|
||||
},
|
||||
linkList() {
|
||||
return red.postX('/meta/link_list')
|
||||
tableLinkList() {
|
||||
return red.postX('/meta/table_link_list')
|
||||
},
|
||||
linkSave({link}) {
|
||||
return red.postX('/meta/link_save', {link: JSON.stringify(link)})
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
<style>
|
||||
.meta-link {
|
||||
padding-top: 5px;
|
||||
}
|
||||
.checkbox-inline:first-child{
|
||||
left: 10px;
|
||||
margin-right: 10px!important;
|
||||
}
|
||||
.checkbox input[type=checkbox], .checkbox-inline input[type=checkbox], .radio input[type=radio], .radio-inline input[type=radio] {
|
||||
margin-top: 12px;
|
||||
}
|
||||
.hv {
|
||||
color: #ea644a!important;
|
||||
}
|
||||
.hv:focus,.hv:hover {
|
||||
color: #8b8a15!important;
|
||||
}
|
||||
.active>.hv{
|
||||
color: #8b8a15!important;
|
||||
}
|
||||
.tlist{
|
||||
height:100%; overflow: auto;
|
||||
}
|
||||
.tlist>li.active>a,
|
||||
.tlist>li.active>a:focus,
|
||||
.tlist>li.active>a:hover,
|
||||
.tlist>li>a:hover {
|
||||
background-color: #92b0cb;
|
||||
}
|
||||
</style>
|
||||
<row class="meta-link">
|
||||
<div class="info">
|
||||
<a @click="showInfo()" href="javascript:;"><i class="icon icon-info"></i></a>
|
||||
@@ -22,31 +52,61 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="clearfix" style="padding-top: 5px"></div>
|
||||
<div class="col-xs-2 sheet-cell">
|
||||
<div style="padding-left: 10px;background-color: #ccc;width: 100%"> DB-Table</div>
|
||||
<ul class="nav nav-tabs nav-stacked tlist" style="height: 100%">
|
||||
<li class="clearfix" v-for="item in tables" >
|
||||
<a href="javascript:;" @click="tableAlias=item.alias" data-target="#tab3Content1" data-toggle="tab" v-text="tableItem(item)"></a>
|
||||
</li>
|
||||
</ul>
|
||||
<!--<p v-show="ckTable && ckTable.length">已选择 <code v-text="ckTable.length||0"></code> 个实体待导入</p>-->
|
||||
</div>
|
||||
|
||||
<div class="col-xs-8">
|
||||
{{ tableAlias }}
|
||||
</div>
|
||||
</row>
|
||||
|
||||
<script>
|
||||
let {tableLinkList, linkSave} = meta
|
||||
var vm = new Vue({
|
||||
el: ".meta-link",
|
||||
data: {
|
||||
tables: [],
|
||||
tableName: '',
|
||||
tableAlias: '',
|
||||
|
||||
},
|
||||
watch: {
|
||||
|
||||
},
|
||||
methods: {
|
||||
loadLinkList() {
|
||||
tableLinkList().then(res => {
|
||||
this.tables = res
|
||||
console.log(res)
|
||||
})
|
||||
},
|
||||
tableItem(table) {
|
||||
return `${table.name} [${table.comment}] (${table.linkCount})`
|
||||
},
|
||||
showInfo() {
|
||||
$('#f-info').modal({moveable: true})
|
||||
}
|
||||
},
|
||||
mounted: function () {
|
||||
this.loadLinkList()
|
||||
|
||||
/*
|
||||
|
||||
var m = {"a.field": "lxyer", "a.`age`": 11}
|
||||
|
||||
console.log(m["a.field"])
|
||||
|
||||
console.log("---------")
|
||||
for (var k in m) {
|
||||
console.log(k)
|
||||
}
|
||||
}*/
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -112,6 +112,14 @@ public class TplKit {
|
||||
return sqlPara.getSql().replaceAll("[\\s]+", " ");
|
||||
}
|
||||
|
||||
public String getTpl(String key, Map data, boolean delSpace) {
|
||||
if (!hadParse)
|
||||
parseTpl();
|
||||
SqlPara sqlPara = kit.getSqlPara(key, data);
|
||||
|
||||
return delSpace ? sqlPara.getSql().replaceAll("[\\s]+", " ") : sqlPara.getSql();
|
||||
}
|
||||
|
||||
public String getTpl(String key, Object m) {
|
||||
if (!hadParse)
|
||||
parseTpl();
|
||||
|
||||
@@ -200,6 +200,32 @@ public class MetadataService extends BaseService { //arango
|
||||
return JBean.by(0, "");
|
||||
}
|
||||
|
||||
@RestMapping(name = "table_link_list", comment = "实体表,包含link信息的列表")
|
||||
public JBean tableLinkList(@RestParam(name = "platToken") String token) {
|
||||
JBean jBean = new JBean();
|
||||
|
||||
List<Kv> list =
|
||||
MetaKit.getMetaTables().stream().filter(x ->
|
||||
(isEmpty.test(token) || x.getSysPlatId().equals(platId(token)))
|
||||
).map(x -> {
|
||||
Kv kv = Kv.of("name", x.getName())
|
||||
.set("comment", x.getComment())
|
||||
.set("alias", x.getAlias())
|
||||
.set("linkCount", 0);
|
||||
|
||||
//关联表数量
|
||||
long count = MetaKit.getMetaLinks().stream().filter(link -> {
|
||||
String[] tables = link.getTables();
|
||||
return x.getAlias().equals(tables[0]) || x.getAlias().equals(tables[1]);
|
||||
}).count();
|
||||
kv.set("linkCount", count);
|
||||
|
||||
return kv;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
return jBean.setBody(list);
|
||||
}
|
||||
|
||||
@RestMapping(name = "link_list", comment = "实体关系列表")
|
||||
public JBean linkList() {
|
||||
JBean jBean = new JBean();
|
||||
@@ -210,7 +236,7 @@ public class MetadataService extends BaseService { //arango
|
||||
return jBean;
|
||||
}
|
||||
|
||||
@RestMapping(name = "link_list", comment = "实体关系列表")
|
||||
@RestMapping(name = "link_save", comment = "实体关系列表")
|
||||
public JBean linkSave(MetaLink link, @RestParam(name = "platToken") String token) {
|
||||
if (link.getKey() != null) {
|
||||
link.update();
|
||||
|
||||
7
src/main/resources/tpl/_t.tpl
Normal file
7
src/main/resources/tpl/_t.tpl
Normal file
@@ -0,0 +1,7 @@
|
||||
#sql("service.method")
|
||||
@RestMapping(name = "#(url)", comment = "#(comment)")
|
||||
public JBean #(methodName)() {
|
||||
|
||||
return JBean.OK;
|
||||
}
|
||||
#end
|
||||
@@ -189,4 +189,36 @@ public class RunTest<T> {
|
||||
System.out.println(metaTables.size());
|
||||
}
|
||||
|
||||
TplKit tplKit = TplKit.use();
|
||||
|
||||
@Test
|
||||
public void buildMethod() {
|
||||
tplKit.addTpl("/tpl/_t.tpl");
|
||||
|
||||
buildMethod("table_link_list", "实体表,包含link信息的列表");
|
||||
}
|
||||
|
||||
private void buildMethod(String url, String comment) {
|
||||
|
||||
String[] arr = url.split("_");
|
||||
String methodName = "";
|
||||
|
||||
for (int i = 0; i < arr.length; i++) {
|
||||
if (i == 0) {
|
||||
methodName = arr[i].toLowerCase();
|
||||
} else {
|
||||
methodName += toUpperCaseFirst(arr[i].toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
Kv kv = Kv.of("url", url).set("comment", comment).set("methodName", methodName);
|
||||
String tpl = tplKit.getTpl("service.method", kv, false);
|
||||
System.out.println(tpl);
|
||||
}
|
||||
private String toUpperCaseFirst(String str){
|
||||
return str.substring(0, 1).toUpperCase() + str.substring(1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user