Files
CJGIS_UAVPatrol/server/api/dm/template/function.js
❀ » Cato Sweeney. ❀ » Console@the.bb bb46cb3bcc *
2025-11-27 16:14:04 +08:00

59 lines
1.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// ==========================================================================
// 所属模块DevGenCode
// 生成日期2024-02-20 21:43:27 +0800 CST
// 生成路径: api/dm/template/function.js
// 生成人xScript_Engine
// 数据表dm_tables - DevGenTables
// dm_tables_column - DevGenTablesColumn
// ==========================================================================
function main() {
// 验证用户权限
'use api/user/acl/excerpt.js'
const tableId = payload.get().path.split('/').pop()
let tablesInfo = SQL.query('system_sql', 'SELECT * FROM dm_tables WHERE table_id =?', tableId)
if (!tablesInfo) {
return errMsg(404, '未找到数据')
}
tablesInfo = tablesInfo[0]
let tableInfo = Object.keys(tablesInfo).reduce((acc, key) => {
acc[underscoreToCamel(key.toLowerCase())] = tablesInfo[key];
return acc;
}, {});
let columns = SQL.query('system_sql', 'SELECT * FROM dm_table_columns WHERE table_id =?', tableId)
if (!columns) {
return errMsg(404, '未找到数据')
}
let result = []
columns.forEach(t => {
const newObj = Object.keys(t).reduce((acc, key) => {
acc[underscoreToCamel(key.toLowerCase())] = t[key];
return acc;
}, {});
result.push(newObj)
});
tableInfo.columns = result
// return okMsg(tableInfo)
let et = fs.read('api/dm/template/vue/edit-vue.template').toString()
let lt = fs.read('api/dm/template/vue/list-vue.template').toString()
let ef = ex.template(et, tableInfo).toString()
let lf = ex.template(lt, tableInfo).toString()
let res = {
edit: ef,
list: lf
}
return okMsg(res)
}