82 lines
2.6 KiB
PHP
82 lines
2.6 KiB
PHP
<?php
|
||
namespace app\api\controller;
|
||
|
||
use app\api\controller\Base;
|
||
use think\Db;
|
||
use think\Queue;
|
||
use think\Validate;
|
||
|
||
class Web extends Base
|
||
{
|
||
|
||
private $Base_url = "http://journalapi.tmrjournals.com/public/index.php/";
|
||
public function __construct(\think\Request $request = null)
|
||
{
|
||
parent::__construct($request);
|
||
}
|
||
|
||
public function getStages(){
|
||
$data = $this->request->post();
|
||
$rule = new Validate([
|
||
"journal_id" => 'require'
|
||
]);
|
||
if(!$rule->check($data)){
|
||
return jsonError($rule->getError());
|
||
}
|
||
$journal_info = $this->journal_obj->where('journal_id',$data['journal_id'])->find();
|
||
|
||
//发送请求到官网
|
||
$url = $this->Base_url."master/Submision/getJournalStages";
|
||
$program['issn'] = $journal_info['issn'];
|
||
$res = object_to_array(json_decode(myPost($url,$program)));
|
||
$list = $res['data']['stages'];
|
||
$re['stages'] = $list;
|
||
return jsonSuccess($re);
|
||
}
|
||
|
||
/**获取分期文章列表
|
||
* @return \think\response\Json|void
|
||
*/
|
||
public function getArticlesByStage(){
|
||
$data = $this->request->post();
|
||
$rule = new Validate([
|
||
"journal_stage_id"=>"require"
|
||
]);
|
||
if(!$rule->check($data)){
|
||
return jsonError($rule->getError());
|
||
}
|
||
$url = $this->Base_url."master/Submision/getArticlesByStage";
|
||
$program['journal_stage_id'] = $data['journal_stage_id'];
|
||
$res = object_to_array(json_decode(myPost($url,$program)));
|
||
$list = $res['data']['articles'];
|
||
$re['articles'] = $list;
|
||
return jsonSuccess($re);
|
||
}
|
||
|
||
public function getRefers(){
|
||
$data = $this->request->post();
|
||
$rule = new Validate([
|
||
"w_article_id"=>"require",
|
||
"doi"=>"require"
|
||
]);
|
||
if(!$rule->check($data)){
|
||
return jsonError($rule->getError());
|
||
}
|
||
$production_info = $this->production_article_obj->where('w_article_id',$data['w_article_id'])->find();
|
||
if (!$production_info){//一次验证,如果w_article_id获取失败
|
||
$production_info = $this->production_article_obj->where('doi',$data['doi'])->where('state',0)->find();
|
||
}
|
||
|
||
if(!$production_info){//如果两次获取都失败
|
||
$refers = [];
|
||
return jsonSuccess(['refer'=>$refers]);
|
||
}
|
||
|
||
$list = $this->production_article_refer_obj->where('p_article_id',$production_info['p_article_id'])->where('state',0)->order('index')->select();
|
||
$re['refers'] = $list;
|
||
return jsonSuccess($re);
|
||
}
|
||
|
||
|
||
}
|
||
?>
|