|
|
@ -93,7 +93,6 @@ function toCamelCase(str) { |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function titleCase(str) { |
|
|
function titleCase(str) { |
|
|
const newStr = str.slice(0, 1).toUpperCase() + str.slice(1); |
|
|
const newStr = str.slice(0, 1).toUpperCase() + str.slice(1); |
|
|
return newStr; |
|
|
return newStr; |
|
|
@ -104,14 +103,13 @@ function lowerCase(str) { |
|
|
return newStr; |
|
|
return newStr; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 删除如t_user中的t_前缀 |
|
|
// 删除如t_user中的t_前缀 |
|
|
function rmPrefix(str) { |
|
|
function rmPrefix(str) { |
|
|
if (str.indexOf('_') > -1) { |
|
|
|
|
|
var n = str.indexOf('_') |
|
|
|
|
|
return str.slice(n+1, str.length) |
|
|
|
|
|
} |
|
|
|
|
|
return str |
|
|
|
|
|
|
|
|
if (str.indexOf("_") > -1) { |
|
|
|
|
|
var n = str.indexOf("_"); |
|
|
|
|
|
return str.slice(n + 1, str.length); |
|
|
|
|
|
} |
|
|
|
|
|
return str; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function typeMap(str) { |
|
|
function typeMap(str) { |
|
|
@ -227,9 +225,9 @@ export default { |
|
|
this.schemaKey = Date.now(); |
|
|
this.schemaKey = Date.now(); |
|
|
}, |
|
|
}, |
|
|
handleRouteOutput(v) { |
|
|
handleRouteOutput(v) { |
|
|
const title = rmPrefix(v.title); |
|
|
|
|
|
|
|
|
const title = rmPrefix(v.title); |
|
|
const tableName = toCamelCase(title); |
|
|
const tableName = toCamelCase(title); |
|
|
const lowTableName = title |
|
|
|
|
|
|
|
|
const lowTableName = title; |
|
|
const Output = ` |
|
|
const Output = ` |
|
|
{ |
|
|
{ |
|
|
${lowTableName} := admin.Group("${lowTableName}") |
|
|
${lowTableName} := admin.Group("${lowTableName}") |
|
|
@ -242,9 +240,9 @@ export default { |
|
|
return Output; |
|
|
return Output; |
|
|
}, |
|
|
}, |
|
|
handleJsApi(v) { |
|
|
handleJsApi(v) { |
|
|
const title = rmPrefix(v.title); |
|
|
|
|
|
|
|
|
const title = rmPrefix(v.title); |
|
|
const tableName = toCamelCase(title); |
|
|
const tableName = toCamelCase(title); |
|
|
const lowTableName = title |
|
|
|
|
|
|
|
|
const lowTableName = title; |
|
|
const Output = ` |
|
|
const Output = ` |
|
|
import request from '@/utils/request'; |
|
|
import request from '@/utils/request'; |
|
|
export function get${tableName}(data) { |
|
|
export function get${tableName}(data) { |
|
|
@ -291,7 +289,7 @@ export default { |
|
|
return Output; |
|
|
return Output; |
|
|
}, |
|
|
}, |
|
|
handleApiOutput(v) { |
|
|
handleApiOutput(v) { |
|
|
const title = rmPrefix(v.title); |
|
|
|
|
|
|
|
|
const title = rmPrefix(v.title); |
|
|
const tableName = toCamelCase(title); |
|
|
const tableName = toCamelCase(title); |
|
|
const apiOutput = ` |
|
|
const apiOutput = ` |
|
|
package api |
|
|
package api |
|
|
@ -380,7 +378,7 @@ export default { |
|
|
return apiOutput; |
|
|
return apiOutput; |
|
|
}, |
|
|
}, |
|
|
handleServiceOutput(v) { |
|
|
handleServiceOutput(v) { |
|
|
const title = rmPrefix(v.title); |
|
|
|
|
|
|
|
|
const title = rmPrefix(v.title); |
|
|
const tableName = toCamelCase(title); |
|
|
const tableName = toCamelCase(title); |
|
|
const properties = v.properties; |
|
|
const properties = v.properties; |
|
|
var primary = ``; |
|
|
var primary = ``; |
|
|
@ -462,7 +460,12 @@ export default { |
|
|
oReq.open("POST", "/sql", false); // 同步请求 |
|
|
oReq.open("POST", "/sql", false); // 同步请求 |
|
|
oReq.setRequestHeader("Content-type", "application/json"); |
|
|
oReq.setRequestHeader("Content-type", "application/json"); |
|
|
console.log(this.sqlinput); |
|
|
console.log(this.sqlinput); |
|
|
oReq.send(JSON.stringify({ content: this.sqlinput, camel: !this.isUnderScoreCase })); //发送数据需要自定义,这里发送的是JSON结构 |
|
|
|
|
|
|
|
|
oReq.send( |
|
|
|
|
|
JSON.stringify({ |
|
|
|
|
|
content: this.sqlinput, |
|
|
|
|
|
camel: !this.isUnderScoreCase, |
|
|
|
|
|
}) |
|
|
|
|
|
); //发送数据需要自定义,这里发送的是JSON结构 |
|
|
var result = oReq.responseText; //响应结果 |
|
|
var result = oReq.responseText; //响应结果 |
|
|
return result; |
|
|
return result; |
|
|
}, |
|
|
}, |
|
|
@ -471,7 +474,7 @@ export default { |
|
|
console.log("struct", struct); |
|
|
console.log("struct", struct); |
|
|
const requires = v.required; |
|
|
const requires = v.required; |
|
|
const properties = v.properties; |
|
|
const properties = v.properties; |
|
|
const title = rmPrefix(v.title); |
|
|
|
|
|
|
|
|
const title = rmPrefix(v.title); |
|
|
const tableName = toCamelCase(title); |
|
|
const tableName = toCamelCase(title); |
|
|
const tableNameLower = lowerCase(tableName); |
|
|
const tableNameLower = lowerCase(tableName); |
|
|
var primary = ``; |
|
|
var primary = ``; |
|
|
@ -757,4 +760,3 @@ export default { |
|
|
}, |
|
|
}, |
|
|
}; |
|
|
}; |
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|