diff --git "a/2.\346\226\207\344\273\266\344\270\212\344\274\240.sh" "b/2.\346\226\207\344\273\266\344\270\212\344\274\240.sh" new file mode 100755 index 0000000..075595c --- /dev/null +++ "b/2.\346\226\207\344\273\266\344\270\212\344\274\240.sh" @@ -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} \ No newline at end of file diff --git a/app.js b/app.js index 2049ac7..1ccd183 100755 --- a/app.js +++ b/app.js @@ -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); // 完成 @@ -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) => { @@ -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); } @@ -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 @@ -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=====') } diff --git a/my.sh b/my.sh new file mode 100755 index 0000000..99dc470 --- /dev/null +++ b/my.sh @@ -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 + diff --git "a/scripts/12.\345\201\245\345\272\267\346\241\243\346\241\210.sh" "b/scripts/12.\345\201\245\345\272\267\346\241\243\346\241\210.sh" new file mode 100755 index 0000000..2b15685 --- /dev/null +++ "b/scripts/12.\345\201\245\345\272\267\346\241\243\346\241\210.sh" @@ -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} \ No newline at end of file diff --git "a/scripts/14.\346\266\210\346\201\257\347\233\270\345\205\263.sh" "b/scripts/14.\346\266\210\346\201\257\347\233\270\345\205\263.sh" new file mode 100755 index 0000000..1d84df3 --- /dev/null +++ "b/scripts/14.\346\266\210\346\201\257\347\233\270\345\205\263.sh" @@ -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} \ No newline at end of file diff --git "a/scripts/16.\346\224\257\344\273\230\347\233\270\345\205\263.sh" "b/scripts/16.\346\224\257\344\273\230\347\233\270\345\205\263.sh" index 79c083e..2b34a1b 100755 --- "a/scripts/16.\346\224\257\344\273\230\347\233\270\345\205\263.sh" +++ "b/scripts/16.\346\224\257\344\273\230\347\233\270\345\205\263.sh" @@ -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' diff --git "a/scripts/2.\346\226\207\344\273\266\344\270\212\344\274\240.sh" "b/scripts/2.\346\226\207\344\273\266\344\270\212\344\274\240.sh" new file mode 100755 index 0000000..075595c --- /dev/null +++ "b/scripts/2.\346\226\207\344\273\266\344\270\212\344\274\240.sh" @@ -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} \ No newline at end of file diff --git "a/scripts/24.\350\256\242\345\215\225\345\222\214\346\234\215\345\212\241\345\214\205\347\233\270\345\205\263.sh" "b/scripts/24.\350\256\242\345\215\225\345\222\214\346\234\215\345\212\241\345\214\205\347\233\270\345\205\263.sh" index 8be65fc..b525c74 100755 --- "a/scripts/24.\350\256\242\345\215\225\345\222\214\346\234\215\345\212\241\345\214\205\347\233\270\345\205\263.sh" +++ "b/scripts/24.\350\256\242\345\215\225\345\222\214\346\234\215\345\212\241\345\214\205\347\233\270\345\205\263.sh" @@ -20,9 +20,7 @@ models=( #获取配置项 'modelOrderConfigInfo,modelOrderConfigShowItem,modelOrderConfigRequireItem' #保存草稿 -'modelAgreementTagsInfo' #修改草稿 -'modelAgreementTagsInfo' #草稿详情 'modelAgreemntOrderDetailInfo,modelAgreementAttatch,modelAgreementTagsInfo' #订单校验 @@ -31,9 +29,9 @@ models=( #订单详情 'modelOrderDetailInfo,modelOrderDetailImgInfo,modelOrderDetailPkgItem' #服务包详情 -'modelServicePackageInfo,modelServicePackageDO' +'modelServicePackageInfo,modelServicePackageItemDO' #服务包列表(签约个人和签约团队的所有服务包) -'modelServicePackageInfo' +'modelServicePackageListItem' ) for model in ${models[@]}; do diff --git "a/scripts/6.\345\214\273\351\231\242\347\233\270\345\205\263.sh" "b/scripts/6.\345\214\273\351\231\242\347\233\270\345\205\263.sh" new file mode 100755 index 0000000..a3a407d --- /dev/null +++ "b/scripts/6.\345\214\273\351\231\242\347\233\270\345\205\263.sh" @@ -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} \ No newline at end of file diff --git "a/scripts/7.\345\214\273\347\224\237\347\233\270\345\205\263.sh" "b/scripts/7.\345\214\273\347\224\237\347\233\270\345\205\263.sh" new file mode 100755 index 0000000..a8de2ec --- /dev/null +++ "b/scripts/7.\345\214\273\347\224\237\347\233\270\345\205\263.sh" @@ -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} \ No newline at end of file diff --git "a/scripts/8.\350\201\212\345\244\251\347\233\270\345\205\263.sh" "b/scripts/8.\350\201\212\345\244\251\347\233\270\345\205\263.sh" new file mode 100755 index 0000000..1cc387c --- /dev/null +++ "b/scripts/8.\350\201\212\345\244\251\347\233\270\345\205\263.sh" @@ -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} \ No newline at end of file diff --git "a/scripts/9.\345\276\256\344\277\241\347\233\270\345\205\263.sh" "b/scripts/9.\345\276\256\344\277\241\347\233\270\345\205\263.sh" new file mode 100755 index 0000000..33e2a74 --- /dev/null +++ "b/scripts/9.\345\276\256\344\277\241\347\233\270\345\205\263.sh" @@ -0,0 +1,36 @@ +#!/bin/bash +author='walker' +projectname='Homedoctor' +passkeys='code,flag,message' +fileuri='/Users/walker/Desktop/index.html' +debug=true +verbose=false +modulename='taskWeChat' +models=( +#微信免登陆 +'modelSNSUserAuth' +#绑定微医用户 +'modelSNSUserAuth' +#获取openid +) + +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} \ No newline at end of file diff --git a/templates/model/template.m b/templates/model/template.m index aa7fac0..40aeb4d 100644 --- a/templates/model/template.m +++ b/templates/model/template.m @@ -11,7 +11,9 @@ @implementation ${model.className} + (NSDictionary *)JSONKeyPathsByPropertyKey { - return [NSDictionary mtl_identityPropertyMapWithModel:[self class]]; + ${hasIdKey ? `NSMutableDictionary *dict = [[NSDictionary mtl_identityPropertyMapWithModel:[self class]] mutableCopy]; + [dict setObject:@"id" forKey:@"recordId"]; + return dict;` : 'return [NSDictionary mtl_identityPropertyMapWithModel:[self class]];'}; } ${model.props.filter(m=>m.model).map(prop => {