Files
journal/application/api/controller/Supplementary.php
2026-02-10 11:38:08 +08:00

202 lines
8.0 KiB
PHP
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?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]);
}
/**
* @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]);
}
}
?>