134 lines
5.7 KiB
PHP
134 lines
5.7 KiB
PHP
<?php
|
|
namespace app\api\controller;
|
|
|
|
use app\api\controller\Base;
|
|
use think\Db;
|
|
/**
|
|
* @title 补充接口
|
|
* @description 文章接口
|
|
*/
|
|
class Supplementary extends Base
|
|
{
|
|
|
|
public function __construct(\think\Request $request = null) {
|
|
|
|
parent::__construct($request);
|
|
}
|
|
|
|
/**
|
|
* @title 获取期刊编辑
|
|
* @description 获取期刊编辑接口
|
|
*/
|
|
|
|
public function getJournalBoard(){
|
|
|
|
|
|
//获取参数
|
|
$aParam = $this->request->post();
|
|
|
|
//参数验证
|
|
$sIssn = empty($aParam['issn']) ? '' : $aParam['issn'];
|
|
if(empty($sIssn)){
|
|
return json_encode(['status' => 2,'msg' => 'Please select an journal']);
|
|
}
|
|
if(is_string($sIssn)){
|
|
$sIssn = explode(',', $sIssn);
|
|
}
|
|
//根据期刊issn查询期刊ID
|
|
$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']);
|
|
}
|
|
|
|
//查询期刊编辑信息
|
|
$aWhere = ['state' => 0,'journal_id' => ['in',array_keys($aJournal)]];
|
|
if(isset($aParam['type'])){//编辑类型
|
|
$aWhere['type'] = $aParam['type'];
|
|
}
|
|
$aJournalBoard = Db::name('board_to_journal')->field('journal_id,user_id')->where($aWhere)->select();
|
|
if(empty($aJournalBoard)){
|
|
return json_encode(['status' => 4,'msg' => 'No editorial information was found for the journal']);
|
|
}
|
|
|
|
//查询编辑详情
|
|
$aUserId = array_column($aJournalBoard, 'user_id');
|
|
$aWhere = ['state' => 0,'user_id' => ['in',$aUserId]];
|
|
$aUser = Db::name('user')->where($aWhere)->column('user_id,realname');
|
|
$aUserData = [];
|
|
foreach ($aJournalBoard as $key => $value) {
|
|
$sIssn = empty($aJournal[$value['journal_id']]) ? '' : $aJournal[$value['journal_id']];
|
|
if(empty($sIssn)){
|
|
continue;
|
|
}
|
|
$sRealName = empty($aUser[$value['user_id']]) ? '' : $aUser[$value['user_id']];
|
|
if(!empty($sRealName) && strlen($sRealName) >= 3 && substr($sRealName, 0, 3) === "\xEF\xBB\xBF") {
|
|
$sRealName = substr($sRealName, 3);
|
|
}
|
|
$aUserData[$sIssn][] = $sRealName;
|
|
}
|
|
return json_encode(['status' => 1,'msg' => 'success','data' => $aUserData]);
|
|
}
|
|
/**
|
|
* @title 获取文章底部信息
|
|
* @description 获取期刊编辑接口
|
|
*/
|
|
public function getProductiArticleFooter(){
|
|
|
|
$aParam = $this->request->post();
|
|
|
|
//官网文章ID
|
|
$iWarticleId = empty($aParam['w_article_id']) ? 0 : $aParam['w_article_id'];
|
|
if(empty($iWarticleId)){
|
|
return json_encode(['status' => 2,'msg' => 'Please select an article']);
|
|
}
|
|
|
|
//获取子刊信息
|
|
$aJournalStage = empty($aParam['journal_stage']) ? [] : $aParam['journal_stage'];
|
|
|
|
//查询文章生产信息
|
|
$aWhere = ['w_article_id' => $iWarticleId,'state' => ['in',[0,2]]];
|
|
$aProductionArticle = Db::name('production_article')->field('p_article_id,article_id,journal_stage_id,journal_id,title,type,acknowledgment,abbreviation,author_contribution,abbr,npp,doi,executive_editor')->where($aWhere)->find();
|
|
if(empty($aProductionArticle)){
|
|
return json_encode(['status' => 3,'msg' => 'No production article information found']);
|
|
}
|
|
|
|
//查询期刊信息
|
|
$iJournalId = empty($aProductionArticle['journal_id']) ? 0 : $aProductionArticle['journal_id'];
|
|
$aJournal = [];
|
|
if(!empty($iJournalId)){
|
|
$aWhere = ['journal_id' => $iJournalId,'state' => 0];
|
|
$aJournal = Db::name('journal')->field('jabbr,title')->where($aWhere)->find();
|
|
}
|
|
//获取文章时间/编委信息
|
|
$iArticleId = empty($aProductionArticle['article_id']) ? 0 : $aProductionArticle['article_id'];
|
|
if(empty($iArticleId)){
|
|
return json_encode(['status' => 3,'msg' => 'No article information found']);
|
|
}
|
|
$oLatexContent = new \app\common\LatexContent;
|
|
$aTime = $oLatexContent->getArticleTime(['article_id' => $iArticleId]);
|
|
$aProductionArticle = empty($aTime['data']) ? $aProductionArticle : array_merge($aTime['data'],$aProductionArticle);
|
|
|
|
//获取期刊引用信息
|
|
$sCite = $this->_cite($aProductionArticle,$aJournal,$aJournalStage);
|
|
$aProductionArticle['article_cite'] = empty($sCite) ? '' : $sCite;
|
|
$aProductionArticle['journal_title'] = empty($aJournal['title']) ? '' : $aJournal['title'];
|
|
return json_encode(['status' => 1,'data' => $aProductionArticle]);
|
|
}
|
|
//处理期刊引用信息
|
|
private function _cite($aArticle = [],$aJournal = [],$aJournalStage = []){
|
|
$no = empty($aJournalStage['stage_no']) ? ':' : '(' . $aJournalStage['stage_no'] . '):';
|
|
$jabbr = empty($aJournal['jabbr']) ? '' : $aJournal['jabbr'];
|
|
$stage_year = empty($aJournalStage['stage_year']) ? '' : $aJournalStage['stage_year'];
|
|
$stage_vol = empty($aJournalStage['stage_vol']) ? '' : $aJournalStage['stage_vol'];
|
|
|
|
$sCite = '';
|
|
if ($aArticle['journal_id'] == 22) {
|
|
$sCite = $aArticle['abbr'] . '. ' . $aArticle['title'] . '[J]. ' . choiseJabbr($aArticle['article_id'],$jabbr) . ',' . $stage_year . ',' . $stage_vol . $no . $aArticle['npp'] . '. doi:' . $aArticle['doi'];
|
|
} else {
|
|
$sCite = $aArticle['abbr'] . '. ' . $aArticle['title'] . '. <i>' . choiseJabbr($aArticle['article_id'], $jabbr) . '</i>. ' . $stage_year . ';' . $stage_vol . $no . $aArticle['npp'] . '. doi:' . $aArticle['doi'];
|
|
}
|
|
return $sCite;
|
|
}
|
|
}
|
|
?>
|