生成文件
This commit is contained in:
@@ -3227,4 +3227,60 @@ class Production extends Base
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成初稿
|
||||
* @param article_id 文章ID
|
||||
*/
|
||||
public function createArticlePdf($aParam = []){
|
||||
|
||||
//获取参数
|
||||
$aParam = empty($aParam) ? $this->request->post() : $aParam;
|
||||
|
||||
//必填值验证
|
||||
$iPArticleId = empty($aParam['p_article_id']) ? '' : $aParam['p_article_id'];
|
||||
if(empty($iPArticleId)){
|
||||
return json_encode(array('status' => 2,'msg' => 'Please select an article' ));
|
||||
}
|
||||
|
||||
//查询文章
|
||||
$aWhere = ['p_article_id' => $iPArticleId,'state' => 0];
|
||||
$aProductionArticle = Db::name('production_article')->where($aWhere)->find();
|
||||
if(empty($aProductionArticle)){
|
||||
return json_encode(array('status' => 3,'msg' => 'No articles found' ));
|
||||
}
|
||||
|
||||
//内容
|
||||
$oLatexContent = new \app\common\LatexContent;
|
||||
|
||||
//内容生成
|
||||
//获取第一页内容
|
||||
$aResult = $oLatexContent->buildFirst($aProductionArticle);
|
||||
$iStatus = empty($aResult['status']) ? 0 : $aResult['status'];
|
||||
$sMsg = empty($aResult['msg']) ? 'Content generation failed-First' : $aResult['msg'];
|
||||
$sFirstTemplateInfo = empty($aResult['data']) ? '' : $aResult['data'];
|
||||
|
||||
if($iStatus != 1){
|
||||
return json_encode(array('status' => 4,'msg' => $sMsg));
|
||||
}
|
||||
if(empty($sFirstTemplateInfo)){
|
||||
return json_encode(array('status' => 5,'msg' => 'Article content retrieval failed'));
|
||||
}
|
||||
|
||||
//生成主内容
|
||||
$aResult = $oLatexContent->buildMain($aProductionArticle);
|
||||
$iStatus = empty($aResult['status']) ? 0 : $aResult['status'];
|
||||
$sMsg = empty($aResult['msg']) ? 'Content generation failed-Main' : $aResult['msg'];
|
||||
$sMainTemplateInfo = empty($aResult['data']) ? '' : $aResult['data'];
|
||||
if($iStatus != 1){
|
||||
return json_encode(array('status' => 4,'msg' => $sMsg));
|
||||
}
|
||||
if(empty($sMainTemplateInfo)){
|
||||
return json_encode(array('status' => 5,'msg' => 'Article content retrieval failed'));
|
||||
}
|
||||
|
||||
//生成文件
|
||||
$sTemplateInfo = $sFirstTemplateInfo."\n".$sMainTemplateInfo;
|
||||
return json_encode(array('status' => 1,'msg' => 'PDF generated successfully'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user