diff --git a/application/api/controller/Supplementary.php b/application/api/controller/Supplementary.php index 2d41afd..2e02d4c 100644 --- a/application/api/controller/Supplementary.php +++ b/application/api/controller/Supplementary.php @@ -9,20 +9,20 @@ use think\Db; class Supplementary extends Controller { - public function __construct(\think\Request $request = null) { + public function __construct(\think\Request $request = null) { parent::__construct($request); } - /** - * @title 获取期刊介绍 - * @description 获取期刊编辑接口 - */ + /** + * @title 获取期刊介绍 + * @description 获取期刊编辑接口 + */ - public function getJournalPaperArt(){ + public function getJournalPaperArt(){ - //获取参数 + //获取参数 $aParam = $this->request->post(); //参数验证 @@ -37,7 +37,7 @@ class Supplementary extends Controller $aWhere = ['state' => 0,'issn' => ['in',$sIssn]]; $aJournal = Db::name('journal')->where($aWhere)->column('journal_id,issn'); if(empty($aJournal)){ - return json_encode(['status' => 3,'msg' => 'No journal information found']); + return json_encode(['status' => 3,'msg' => 'No journal information found']); } //查询期刊编辑信息 $aWhere = ['state' => 0,'journal_id' => ['in',array_keys($aJournal)],'title' => ['in',$sTitle]]; @@ -59,8 +59,8 @@ class Supplementary extends Controller continue; } } - return json_encode(['status' => 1,'msg' => 'success','data' => empty($aContent) ? [] : $aContent]); - } + return json_encode(['status' => 1,'msg' => 'success','data' => empty($aContent) ? [] : $aContent]); + } /** * @title 获取期刊信息 @@ -82,5 +82,121 @@ class Supplementary extends Controller $aJournal = Db::name('journal')->field($sField)->where($aWhere)->select(); return json_encode(['status' => 1,'msg' => 'success','data' => $aJournal]); } + /** + * @title 获取子期刊信息 + * @description 获取期刊编辑接口 + */ + public function getJournalStage(){ + //获取参数 + $aParam = $this->request->post(); + //参数验证 + $iJournalStageId = empty($aParam['journal_stage_id']) ? '' : $aParam['journal_stage_id']; + if(empty($iJournalStageId)){ + return json_encode(['status' => 2,'msg' => 'Please choose journal installment']); + } + + //根据期刊issn查询期刊ID + $aWhere = ['state' => 0,'journal_stage_id' => $iJournalStageId]; + $aJournal = Db::name('journal_stage')->where($aWhere)->find(); + return json_encode(['status' => 1,'msg' => 'success','data' => $aJournal]); + } + + /** + * @title 客座期刊(获取列表) + * @description 客座期刊(获取列表) + */ + public function getSpecialIssue(){ + + //获取参数 + $aParam = $this->request->post(); + + //期刊ID + $iJournalId = empty($aParam['journal_id']) ? 0 : $aParam['journal_id']; + if(empty($iJournalId)){ + return json(['status' => 2,'msg' => 'Please select an journal']); + } + + //获取期刊信息 + $aWhere = ['journal_id' => $iJournalId,'state' => 0]; + $aJournal = DB::name('journal')->field('journal_id')->where($aWhere)->find(); + if(empty($aJournal)){ + return json(['status' => 3,'msg' => 'No journal information found']); + } + + //查询专刊信息-进行中的 + $sNowDate = date('Y-m-d'); + $aWhere = ['journal_id' => $iJournalId,'state' => 2,'deadline' => ['>=',$sNowDate]]; + $aJournalSpecial = Db::name('journal_special')->where($aWhere)->select(); + if(empty($aJournalSpecial)){ + return json(['status' => 1,'msg' =>'The special issue data is empty']); + } + + //获取编辑信息 + $aJournalSpecialId = array_column($aJournalSpecial, 'journal_special_id'); + $aWhere = ['journal_id' => $iJournalId,'journal_special_id' => ['in',$aJournalSpecialId],'state' => 0]; + $aJournalSpecialToEditor = Db::name('journal_special_to_editor')->field('journal_special_editor_id,journal_special_id')->where($aWhere)->select(); + $aEditorList = []; + if(!empty($aJournalSpecialToEditor)){ + $aEditorId = array_unique(array_column($aJournalSpecialToEditor, 'journal_special_editor_id')); + $aWhere = ['journal_id' => $iJournalId,'journal_special_editor_id' => ['in',$aEditorId],'state' => 0]; + $aJournalSpecialEditor = Db::name('journal_special_editor')->field('journal_special_editor_id,first_name,last_name')->where($aWhere)->select(); + $aJournalSpecialEditor = empty($aJournalSpecialEditor) ? [] : array_column($aJournalSpecialEditor, null,'journal_special_editor_id'); + + foreach ($aJournalSpecialToEditor as $key => $value) { + $aEditorInfo = empty($aJournalSpecialEditor[$value['journal_special_editor_id']]) ? [] : $aJournalSpecialEditor[$value['journal_special_editor_id']]; + $sFirstName = empty($aEditorInfo['first_name']) ? '' : $aEditorInfo['first_name']; + $sLastName = empty($aEditorInfo['last_name']) ? '' : $aEditorInfo['last_name']; + $sName = $sFirstName.' '.$sLastName; + $sName = trim($sName);//str_replace([' ', ' '], '', trim($sName)); + if(!empty($sName)){ + $aEditorList[$value['journal_special_id']][] = $sName; + } + } + } + + //数据处理 + foreach ($aJournalSpecial as $key => $value) { + $aEditorInfo = empty($aEditorList[$value['journal_special_id']]) ? [] : $aEditorList[$value['journal_special_id']]; + $aJournalSpecial[$key]['editor'] = empty($aEditorInfo) ? '' : implode(',', array_unique($aEditorInfo)); + } + return json(['status' => 1,'msg' => 'success','data' => $aJournalSpecial]); + } + /** + * @title 获取期刊信息 + * @description 获取期刊编辑接口 + */ + public function getJournalDetail(){ + //获取参数 + $aParam = $this->request->post(); + + //期刊issn号 + $sIssn = empty($aParam['issn']) ? '' : $aParam['issn']; + //期刊Id + $iJournalId = empty($aParam['journal_id']) ? '' : $aParam['journal_id']; + //期刊缩写 + $sUsx = empty($aParam['usx']) ? '' : $aParam['usx']; + //期刊缩写 + $sSx = empty($aParam['sx']) ? '' : $aParam['sx']; + if(empty($sIssn) && empty($iJournalId) && empty($sUsx) && empty($sSx)){ + return json(['status' => 2,'msg' => 'Please select an journal']); + } + + $aWhere = ['state' => 0]; + if(!empty($sIssn)){ + $aWhere['issn'] = $sIssn; + } + if(!empty($iJournalId)){ + $aWhere['journal_id'] = $iJournalId; + } + if(!empty($sUsx)){ + $aWhere['usx'] = $sUsx; + } + if(!empty($sSx)){ + $aWhere['sx'] = $sSx; + } + //根据期刊信息 + $aJournal = Db::name('journal')->where($aWhere)->find(); + return json(['status' => 1,'msg' => 'success','data' => $aJournal]); + } } ?> \ No newline at end of file