|
@@ -9,13 +9,14 @@ const TemplateDocxPath = path.join(__dirname,"template/模板-推荐申报表.do
|
|
|
* @example
|
|
|
* Cloud Code test
|
|
|
curl -X POST -H "Content-Type: application/json" -H 'X-Parse-Application-Id: edu-textbook' -d '{ "processId": "Wz34loxdbO" }' http://127.0.0.1:61337/parse/functions/tbookExportReport
|
|
|
+ curl -X POST -H "Content-Type: application/json" -H 'X-Parse-Application-Id: edu-textbook' -d '{ "processId": "Wz34loxdbO" }' http://8.140.98.43/parse/functions/tbookExportReport
|
|
|
*/
|
|
|
export function defineTbookExportReport(){
|
|
|
Parse.Cloud.define("tbookExportReport", async (request) => {
|
|
|
let processId = request.params.processId;
|
|
|
if(processId) {
|
|
|
try{
|
|
|
- let result = await exportProcessReportDocs()
|
|
|
+ let result = await exportProcessReportDocs(processId)
|
|
|
if(result?.docsList?.length==0){
|
|
|
throw new Parse.Error(404,"合集内无申报教材")
|
|
|
}
|
|
@@ -44,6 +45,7 @@ const TemplateDocxPath = path.join(__dirname,"template/模板-推荐申报表.do
|
|
|
* zipUrl
|
|
|
*/
|
|
|
async function exportProcessReportDocs(processId) {
|
|
|
+ if(!processId) return {}
|
|
|
let query = new Parse.Query("EduTextbook")
|
|
|
query.equalTo("eduProcess",processId);
|
|
|
let textbookList = await query.find();
|
|
@@ -53,8 +55,6 @@ async function exportProcessReportDocs(processId) {
|
|
|
let result = await renderReportDocsByTextbook(textbook);
|
|
|
docsList.push(result)
|
|
|
}
|
|
|
- console.log(textbookList);
|
|
|
- console.log(docsList)
|
|
|
let zipPath,zipUrl
|
|
|
if(docsList?.length){
|
|
|
zipPath = await createZip(docsList?.map(item=>item?.filePath),`流程合集-${processId}.zip`)
|
|
@@ -64,6 +64,9 @@ async function exportProcessReportDocs(processId) {
|
|
|
docsList = docsList.map(item=>{return {code:item.code,title:item.title,url:item?.url}})
|
|
|
}
|
|
|
|
|
|
+ console.log(textbookList);
|
|
|
+ console.log(docsList)
|
|
|
+ console.log(processId)
|
|
|
let result = {
|
|
|
docsList,
|
|
|
zipUrl
|