|
|
|
@ -107,9 +107,12 @@ function lowerCase(str) { |
|
|
|
function rmPrefix(str) { |
|
|
|
if (str.indexOf("_") > -1) { |
|
|
|
var n = str.indexOf("_"); |
|
|
|
return str.slice(n + 1, str.length); |
|
|
|
return { |
|
|
|
prefix: str.slice(0, n + 1), |
|
|
|
suffix: str.slice(n + 1, str.length), |
|
|
|
}; |
|
|
|
} |
|
|
|
return str; |
|
|
|
return { prefix: "", suffix: str }; |
|
|
|
} |
|
|
|
|
|
|
|
function typeMap(str) { |
|
|
|
@ -225,7 +228,7 @@ export default { |
|
|
|
this.schemaKey = Date.now(); |
|
|
|
}, |
|
|
|
handleRouteOutput(v) { |
|
|
|
const title = rmPrefix(v.title); |
|
|
|
const title = rmPrefix(v.title).suffix; |
|
|
|
const tableName = toCamelCase(title); |
|
|
|
const lowTableName = title; |
|
|
|
const Output = ` |
|
|
|
@ -240,7 +243,7 @@ export default { |
|
|
|
return Output; |
|
|
|
}, |
|
|
|
handleJsApi(v) { |
|
|
|
const title = rmPrefix(v.title); |
|
|
|
const title = rmPrefix(v.title).suffix; |
|
|
|
const tableName = toCamelCase(title); |
|
|
|
const lowTableName = title; |
|
|
|
const Output = ` |
|
|
|
@ -289,7 +292,7 @@ export default { |
|
|
|
return Output; |
|
|
|
}, |
|
|
|
handleApiOutput(v) { |
|
|
|
const title = rmPrefix(v.title); |
|
|
|
const title = rmPrefix(v.title).suffix; |
|
|
|
const tableName = toCamelCase(title); |
|
|
|
const apiOutput = ` |
|
|
|
package api |
|
|
|
@ -378,7 +381,7 @@ export default { |
|
|
|
return apiOutput; |
|
|
|
}, |
|
|
|
handleServiceOutput(v) { |
|
|
|
const title = rmPrefix(v.title); |
|
|
|
const title = rmPrefix(v.title).suffix; |
|
|
|
const tableName = toCamelCase(title); |
|
|
|
const properties = v.properties; |
|
|
|
var primary = ``; |
|
|
|
@ -455,7 +458,7 @@ export default { |
|
|
|
`; |
|
|
|
return serviceOutput; |
|
|
|
}, |
|
|
|
getMyStruct() { |
|
|
|
getMyStruct(tablePrefix) { |
|
|
|
var oReq = new XMLHttpRequest(); |
|
|
|
oReq.open("POST", "/sql", false); // 同步请求 |
|
|
|
oReq.setRequestHeader("Content-type", "application/json"); |
|
|
|
@ -464,17 +467,19 @@ export default { |
|
|
|
JSON.stringify({ |
|
|
|
content: this.sqlinput, |
|
|
|
camel: !this.isUnderScoreCase, |
|
|
|
table_prefix: tablePrefix, |
|
|
|
}) |
|
|
|
); //发送数据需要自定义,这里发送的是JSON结构 |
|
|
|
var result = oReq.responseText; //响应结果 |
|
|
|
return result; |
|
|
|
}, |
|
|
|
handleModelOutput(v) { |
|
|
|
var struct = this.getMyStruct(); |
|
|
|
const tablePrefix = rmPrefix(v.title).prefix; |
|
|
|
var struct = this.getMyStruct(tablePrefix); |
|
|
|
console.log("struct", struct); |
|
|
|
const requires = v.required; |
|
|
|
const properties = v.properties; |
|
|
|
const title = rmPrefix(v.title); |
|
|
|
const title = rmPrefix(v.title).suffix; |
|
|
|
const tableName = toCamelCase(title); |
|
|
|
const tableNameLower = lowerCase(tableName); |
|
|
|
var primary = ``; |
|
|
|
|