86 lines
2.8 KiB
PHP
86 lines
2.8 KiB
PHP
<?php
|
|
namespace app\api\controller;
|
|
use think\Controller;
|
|
use think\Db;
|
|
/**
|
|
* @title 补充接口
|
|
* @description 文章接口
|
|
*/
|
|
class Supplementary extends Controller
|
|
{
|
|
|
|
public function __construct(\think\Request $request = null) {
|
|
|
|
parent::__construct($request);
|
|
}
|
|
|
|
/**
|
|
* @title 获取期刊介绍
|
|
* @description 获取期刊编辑接口
|
|
*/
|
|
|
|
public function getJournalPaperArt(){
|
|
|
|
|
|
//获取参数
|
|
$aParam = $this->request->post();
|
|
|
|
//参数验证
|
|
$sIssn = empty($aParam['issn']) ? '' : $aParam['issn'];
|
|
if(empty($sIssn)){
|
|
return json_encode(['status' => 2,'msg' => 'Please select an journal']);
|
|
}
|
|
//期刊标题
|
|
$sTitle = empty($aParam['journal_title']) ? ['About Journal','About us','Journal Information','Aims and Scope'] : $aParam['journal_title'];
|
|
|
|
//根据期刊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)],'title' => ['in',$sTitle]];
|
|
$aJournalPaperArt = Db::name('journal_paper_art')->field('journal_id,content')->where($aWhere)->select();
|
|
if(empty($aJournalPaperArt)){
|
|
return json_encode(['status' => 1,'msg' => 'data is null']);
|
|
}
|
|
//数据处理
|
|
$keyword = 'Scope';
|
|
foreach ($aJournalPaperArt as $key => $value) {
|
|
|
|
$sContent = empty($value['content']) ? '' : $value['content'];
|
|
$sIssn = empty($aJournal[$value['journal_id']]) ? '' : $aJournal[$value['journal_id']];
|
|
if(empty($sContent) || empty($sIssn)){
|
|
continue;
|
|
}
|
|
if(stripos($sContent, $keyword) !== false){
|
|
$aContent[$sIssn] = $sContent;
|
|
continue;
|
|
}
|
|
}
|
|
return json_encode(['status' => 1,'msg' => 'success','data' => empty($aContent) ? [] : $aContent]);
|
|
}
|
|
|
|
/**
|
|
* @title 获取期刊信息
|
|
* @description 获取期刊编辑接口
|
|
*/
|
|
public function getJournal(){
|
|
//获取参数
|
|
$aParam = $this->request->post();
|
|
|
|
//参数验证
|
|
$sIssn = empty($aParam['issn']) ? '' : $aParam['issn'];
|
|
if(empty($sIssn)){
|
|
return json_encode(['status' => 2,'msg' => 'Please select an journal']);
|
|
}
|
|
|
|
//根据期刊issn查询期刊ID
|
|
$aWhere = ['state' => 0,'issn' => ['in',$sIssn]];
|
|
$sField = 'issn,icon';
|
|
$aJournal = Db::name('journal')->field($sField)->where($aWhere)->select();
|
|
return json_encode(['status' => 1,'msg' => 'success','data' => $aJournal]);
|
|
}
|
|
}
|
|
?>
|