Files
journal/application/api/controller/Main.php
wangjinlei 8dc49aa900 20201112
2020-12-15 11:50:24 +08:00

103 lines
3.2 KiB
PHP

<?php
namespace app\api\controller;
use think\Controller;
use think\Db;
/**
* @title 前段web接口
* @description 前段web接口
* @group 前段web接口
*/
class Main extends Controller{
//put your code here
protected $admin_obj = '';
protected $journal_obj = '';
protected $article_obj = '';
protected $article_author_obj = '';
protected $journal_topic_obj = '';
protected $journal_stage_obj = '';
protected $journal_notices_obj = '';
protected $journal_abs_obj = '';
protected $article_to_topic_obj = '';
protected $sys_scient_obj = '';
protected $sys_book_obj = '';
public function __construct(\think\Request $request = null) {
parent::__construct($request);
$this->admin_obj = Db::name('admin');
$this->journal_obj = Db::name('journal');
$this->article_obj = Db::name('article');
$this->article_author_obj = Db::name('article_author');
$this->journal_topic_obj = Db::name('journal_topic');
$this->journal_stage_obj = Db::name('journal_stage');
$this->journal_notices_obj = Db::name('journal_notices');
$this->journal_abs_obj = Db::name('journal_abstracting');
$this->article_to_topic_obj = Db::name('article_to_topic');
$this->sys_scient_obj = Db::name('system_scient');
$this->sys_book_obj = Db::name('system_books');
}
/**
* @title 获取scients
* @description 获取scients
* @author wangjinlei
* @url /api/Main/getScients
* @method POST
*
*
* @return scients:array#
*
*/
public function getScients(){
$list = $this->sys_scient_obj->where('state',0)->select();
$re['scients'] = $list;
return jsonSuccess($re);
}
/**
* @title 获取books
* @description 获取books
* @author wangjinlei
* @url /api/Main/getBooks
* @method POST
*
*
* @return books:array#
*
*/
public function getBooks(){
$list = $this->sys_book_obj->where('state',0)->select();
$re['books'] = $list;
return jsonSuccess($re);
}
/**
* @title 获取首页Highlights
* @description 获取首页Highlights
* @author wangjinlei
* @url /api/Main/getMainhl
* @method POST
*
* @param name:journal_id type:int require:1 desc:期刊id
*
* @return Highlights:array#
*/
public function getMainhl(){
$data = $this->request->post();
$topic_info = $this->journal_topic_obj->where('journal_id',$data['journal_id'])->where('position','highlights')->where('state',0)->find();
if($topic_info){
$list = $this->article_to_topic_obj->field('j_article.*,j_journal_stage.*')
->join(array(['j_article','j_article.article_id = j_article_to_topic.article_id','LEFT'],['j_journal_stage','j_journal_stage.journal_stage_id = j_article.journal_stage_id','LEFT']))
->where('j_article_to_topic.topic_id',$topic_info['journal_topic_id'])
->where('j_article_to_topic.state',0)
->select();
return jsonSuccess(['topic_info'=>$topic_info,'articlelist'=>$list]);
}else{
return jsonError('no highlights');
}
}
}