Skip to content

Commit

Permalink
Merge branch 'master' of git.guahao-inc.com:wuhanassist/confluence_mo…
Browse files Browse the repository at this point in the history
…del_gen
  • Loading branch information
jiangli committed Sep 22, 2017
2 parents 3f915cb + 60b4020 commit cc67d9c
Show file tree
Hide file tree
Showing 13 changed files with 320 additions and 16 deletions.
33 changes: 33 additions & 0 deletions 2.文件上传.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
author='Evan'
projectname='Homedoctor'
passkeys='code,flag,message'
fileuri='/Users/Evan/Desktop/index.html'
debug=true
verbose=false
modulename='taskFileUpload'
models=(
#文件上传
'modelFileUpload'
)

for model in ${models[@]}; do
types=${types}${model},
done
types=${types}

if [ "$debug" = true ] ; then
enableDebug='--debug'
fi

if [ "$verbose" = true ] ; then
enableVerbose='--verbose'
fi

./app.js ${enableVerbose} ${enableDebug} \
-C ${types} \
-P ${passkeys} \
-f ${fileuri} \
-a ${author} \
-m ${modulename} \
-j ${projectname}
30 changes: 20 additions & 10 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ $(".wiki-content>.table-wrap").each((i, table) => {
if(i%2 == 0) return parseRequestTable(table); // => 得到方法参数数组
parseResponseTable(table); // => 得到实体类数组
});
if(program.debug) await fs.writeJson('./output.json', responseModel).catch(console.log);
if(program.debug) await fs.writeJson('./output.json', entities).catch(console.log);
// 应用模板
await parseTemplate().catch(console.log);
// 完成
Expand All @@ -78,10 +78,10 @@ function parseResponseTable(table, classMeta) {
baseName = baseClasses[1];
isRoot = false;
}else{
modelName = respFactory.next().value;
modelName = respFactory.next().value;
}
let rowIsTable = false,
props = [],
let rowIsTable = false,
props = [],
complexProperty; // 如果当前行表示是个对象或数据, 把元数据保存, 用来生成子表格对应的类
$(table).children(".confluenceTable").children("tbody").children("tr")
.each((i,tr) => {
Expand Down Expand Up @@ -218,7 +218,7 @@ async function getFileContent(...components) {
return await fs.readFile(fullpath, 'utf8').catch(console.log);
}

async function genFileFromTemplate(filepath, tpl) {
async function renderFile(filepath, tpl) {
return await fs.writeFile(filepath, tpl, 'utf8').catch(console.log);
}

Expand Down Expand Up @@ -251,11 +251,21 @@ async function parseTemplate() {
exist_file.push(model);
}
let m_content = model.isRoot ? m_content2 : m_content1;
// 20180921添加: 遍历这个类, 如果有名为id的键, 打个标(给m文件处理), 并更名
let hasIdKey = false;
model.props.forEach(p=>{
if(p.name == 'id') {
hasIdKey = true;
p.name = 'recordId';
console.log("碰到一个 id 属性", p);
return;
}
});
// 输出路径
let h_file = getPath(out_model, model.className+'.h'),
m_file = getPath(out_model, model.className+'.m');
await genFileFromTemplate(h_file, eval(h_content)).catch(console.log);
await genFileFromTemplate(m_file, eval(m_content)).catch(console.log);
await renderFile(h_file, eval(h_content)).catch(console.log);
await renderFile(m_file, eval(m_content)).catch(console.log);
});
// ===================
// gen http request (task) file
Expand All @@ -278,8 +288,8 @@ async function parseTemplate() {
"args": methodArgs[i]
}
});
await genFileFromTemplate(h_file, eval(h_task)).catch(console.log);
await genFileFromTemplate(m_file, eval(m_task)).catch(console.log);
await renderFile(h_file, eval(h_task)).catch(console.log);
await renderFile(m_file, eval(m_task)).catch(console.log);

console.log(`all done. model path [${out_model}], task path [${out_task}]`)
console.log('=====END=====')
}
9 changes: 9 additions & 0 deletions my.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
./app.js \
-C modelVersionInfoResponse,modelVersionInfo,nouse \
-P code,flag,message \
-f /Users/Evan/Desktop/index.html \
-a Evan \
-j HomeDoctor \
-d true \
--verbose

35 changes: 35 additions & 0 deletions scripts/12.健康档案.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
author='walker'
projectname='Homedoctor'
passkeys='code,flag,message'
fileuri='/Users/walker/Desktop/index.html'
debug=true
verbose=false
modulename='taskHealthElement'
models=(
#基本健康档案模板
'modelHealthElementTemplate,modelHealthElementOptioModel'
#健康档案详情
'modelHealthElementInfo'
)

for model in ${models[@]}; do
types=${types}${model},
done
types=${types}

if [ "$debug" = true ] ; then
enableDebug='--debug'
fi

if [ "$verbose" = true ] ; then
enableVerbose='--verbose'
fi

./app.js ${enableVerbose} ${enableDebug} \
-C ${types} \
-P ${passkeys} \
-f ${fileuri} \
-a ${author} \
-m ${modulename} \
-j ${projectname}
34 changes: 34 additions & 0 deletions scripts/14.消息相关.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash
author='walker'
projectname='Homedoctor'
passkeys='code,flag,message'
fileuri='/Users/walker/Desktop/index.html'
debug=true
verbose=false
modulename='taskMessage'
models=(
#签约消息提醒列表
'modelMessageListItem'
#设置消息为已读
)

for model in ${models[@]}; do
types=${types}${model},
done
types=${types}

if [ "$debug" = true ] ; then
enableDebug='--debug'
fi

if [ "$verbose" = true ] ; then
enableVerbose='--verbose'
fi

./app.js ${enableVerbose} ${enableDebug} \
-C ${types} \
-P ${passkeys} \
-f ${fileuri} \
-a ${author} \
-m ${modulename} \
-j ${projectname}
2 changes: 1 addition & 1 deletion scripts/16.支付相关.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ passkeys='code,flag,message'
fileuri='/Users/walker/Desktop/index.html'
debug=true
verbose=false
modulename='taskHealthEducation'
modulename='taskPayment'
models=(
#获取支付参数(签约)
'modelAgrmtAppayPayParam,modelUnifiedPayDTO'
Expand Down
33 changes: 33 additions & 0 deletions scripts/2.文件上传.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
author='Evan'
projectname='Homedoctor'
passkeys='code,flag,message'
fileuri='/Users/Evan/Desktop/index.html'
debug=true
verbose=false
modulename='taskFileUpload'
models=(
#文件上传
'modelFileUpload'
)

for model in ${models[@]}; do
types=${types}${model},
done
types=${types}

if [ "$debug" = true ] ; then
enableDebug='--debug'
fi

if [ "$verbose" = true ] ; then
enableVerbose='--verbose'
fi

./app.js ${enableVerbose} ${enableDebug} \
-C ${types} \
-P ${passkeys} \
-f ${fileuri} \
-a ${author} \
-m ${modulename} \
-j ${projectname}
6 changes: 2 additions & 4 deletions scripts/24.订单和服务包相关.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ models=(
#获取配置项
'modelOrderConfigInfo,modelOrderConfigShowItem,modelOrderConfigRequireItem'
#保存草稿
'modelAgreementTagsInfo'
#修改草稿
'modelAgreementTagsInfo'
#草稿详情
'modelAgreemntOrderDetailInfo,modelAgreementAttatch,modelAgreementTagsInfo'
#订单校验
Expand All @@ -31,9 +29,9 @@ models=(
#订单详情
'modelOrderDetailInfo,modelOrderDetailImgInfo,modelOrderDetailPkgItem'
#服务包详情
'modelServicePackageInfo,modelServicePackageDO'
'modelServicePackageInfo,modelServicePackageItemDO'
#服务包列表(签约个人和签约团队的所有服务包)
'modelServicePackageInfo'
'modelServicePackageListItem'
)

for model in ${models[@]}; do
Expand Down
35 changes: 35 additions & 0 deletions scripts/6.医院相关.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
author='walker'
projectname='Homedoctor'
passkeys='code,flag,message'
fileuri='/Users/walker/Desktop/index.html'
debug=true
verbose=false
modulename='taskHospital'
models=(
#医院列表
'modelHospitalListItem'
#签约时间列表
'modelHosSignareaTimeInfo'
)

for model in ${models[@]}; do
types=${types}${model},
done
types=${types}

if [ "$debug" = true ] ; then
enableDebug='--debug'
fi

if [ "$verbose" = true ] ; then
enableVerbose='--verbose'
fi

./app.js ${enableVerbose} ${enableDebug} \
-C ${types} \
-P ${passkeys} \
-f ${fileuri} \
-a ${author} \
-m ${modulename} \
-j ${projectname}
39 changes: 39 additions & 0 deletions scripts/7.医生相关.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash
author='walker'
projectname='Homedoctor'
passkeys='code,flag,message'
fileuri='/Users/walker/Desktop/index.html'
debug=true
verbose=false
modulename='taskDoctor'
models=(
#医生列表
'modelDoctorListItem'
#附近家医列表
'modelNearDoctorListItem'
#医生详情
'modelDoctorDetailInfo'
#医生搜索
'modelDoctorSearchListItem'
)

for model in ${models[@]}; do
types=${types}${model},
done
types=${types}

if [ "$debug" = true ] ; then
enableDebug='--debug'
fi

if [ "$verbose" = true ] ; then
enableVerbose='--verbose'
fi

./app.js ${enableVerbose} ${enableDebug} \
-C ${types} \
-P ${passkeys} \
-f ${fileuri} \
-a ${author} \
-m ${modulename} \
-j ${projectname}
40 changes: 40 additions & 0 deletions scripts/8.聊天相关.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash
author='walker'
projectname='Homedoctor'
passkeys='code,flag,message'
fileuri='/Users/walker/Desktop/index.html'
debug=true
verbose=false
modulename='taskChat'
models=(
#聊天历史记录列表
'modelChatListItem'
#聊天服务器地址
'modelChatListServer'
#设置聊天已读
#轮询聊天历史记录列表
'modelChatListPollItem'
#轮询聊天添加记录
#电话问诊请求发起
)

for model in ${models[@]}; do
types=${types}${model},
done
types=${types}

if [ "$debug" = true ] ; then
enableDebug='--debug'
fi

if [ "$verbose" = true ] ; then
enableVerbose='--verbose'
fi

./app.js ${enableVerbose} ${enableDebug} \
-C ${types} \
-P ${passkeys} \
-f ${fileuri} \
-a ${author} \
-m ${modulename} \
-j ${projectname}
Loading

0 comments on commit cc67d9c

Please sign in to comment.