Files
journal/application/master/controller/Special.php
wangjinlei 0386c4b02f 20201112
2021-01-13 15:54:15 +08:00

298 lines
12 KiB
PHP

<?php
namespace app\master\controller;
use think\Controller;
use think\Db;
/**
* @title 客座期刊
* @description 客座期刊
* @group 客座期刊
*/
class Special 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 $journal_special_obj = '';
protected $journal_special_editor_obj = '';
protected $journal_special_to_editor_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->journal_special_obj = Db::name('journal_special');
$this->journal_special_editor_obj = Db::name('journal_special_editor');
$this->journal_special_to_editor_obj = Db::name('journal_special_to_editor');
$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 客座期刊(获取列表)
* @description 客座期刊(获取列表)
* @author wangjinlei
* @url /master/Special/getSpecialList
* @method POST
*
* @param name:journal_id type:int require:1 desc:期刊id
* @param name:state type:int require:0 desc:状态
* @param name:pageIndex type:int require:1 desc:当前页码数
* @param name:pageSize type:int require:1 desc:单页数据条数
*
* @return journal:期刊信息
* @return count:总数
* @return specials:客座期刊列表array#
*/
public function getSpecialList(){
$data = $this->request->post();
$journal_info = $this->journal_obj->where('journal_id',$data['journal_id'])->find();
$where['journal_id'] = $data['journal_id'];
if(isset($data['state'])&&$data['state']!=-1){
$where['state'] = $data['state'];
}else{
$where['state'] = ['<>',1];
}
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
$list = $this->journal_special_obj
->where($where)
->order(['state','journal_special_id desc'])
->limit($limit_start,$data['pageSize'])
->select();
//获取作者
foreach ($list as $k => $v){
$frag = '';
$caches = $this->journal_special_to_editor_obj
->field('j_journal_special_editor.*')
->join('j_journal_special_editor','j_journal_special_editor.journal_special_editor_id = j_journal_special_to_editor.journal_special_editor_id','LEFT')
->where('j_journal_special_to_editor.journal_special_id',$v['journal_special_id'])
->where('j_journal_special_to_editor.state',0)
->select();
foreach ($caches as $val){
$frag = $frag == ''?$val['first_name'].' '.$val['last_name']:','.$val['first_name'].' '.$val['last_name'];
}
$list[$k]['editor'] = $frag;
}
$count = $this->journal_special_obj->where($where)->count();
$re['journal'] = $journal_info;
$re['count'] = $count;
$re['specials'] = $list;
return jsonSuccess($re);
}
/**
* @title 客座期刊(更改状态)
* @description 客座期刊(更改状态)
* @author wangjinlei
* @url /master/Special/changeSpecialState
* @method POST
*
* @param name:journal_special_id type:int require:1 desc:客座期刊id
* @param name:state type:int require:1 desc:状态(0:初始1:拒绝2:通过)
*/
public function changeSpecialState(){
$data = $this->request->post();
$this->journal_special_obj->where('journal_special_id',$data['journal_special_id'])->update(['state'=>$data['state']]);
return jsonSuccess([]);
}
/**
* @title 客座期刊(获取详情信息)
* @description 客座期刊(获取详情信息)
* @author wangjinlei
* @url /master/Special/getSpecialDetail
* @method POST
*
* @param name:journal_special_id type:int require:1 desc:客座期刊id
*
* @return special:客座期刊信息
* @return editors:作者array#
*/
public function getSpecialDetail(){
$data = $this->request->post();
$special_info = $this->journal_special_obj->where('journal_special_id',$data['journal_special_id'])->find();
$editor_list = $this->journal_special_to_editor_obj->field('j_journal_special_editor.*')
->join('j_journal_special_editor','j_journal_special_editor.journal_special_editor_id = j_journal_special_to_editor.journal_special_editor_id','LEFT')
->where('j_journal_special_to_editor.journal_special_id',$data['journal_special_id'])
->where('j_journal_special_to_editor.state',0)
->select();
$re['special'] = $special_info;
$re['editors'] = $editor_list;
return jsonSuccess($re);
}
/**
* @title 客座期刊(编辑客座期刊基础信息)
* @description 客座期刊(编辑客座期刊基础信息)
* @author wangjinlei
* @url /master/Special/editSpecialBasic
* @method POST
*
* @param name:journal_special_id type:int require:1 desc:客座期刊id
* @param name:title type:string require:1 desc:标题
* @param name:intro type:string require:1 desc:简介
* @param name:abstract type:string require:1 desc:描述
* @param name:keywords type:string require:1 desc:关键字
* @param name:deadline type:int require:1 desc:截止日期
*
* @return special:客座期刊信息
* @return editors:作者array#
*/
public function editSpecialBasic(){
$data = $this->request->post();
$update['title'] = $data['title'];
$update['intro'] = $data['intro'];
$update['abstract'] = $data['abstract'];
$update['keywords'] = $data['keywords'];
$update['deadline'] = $data['deadline'];
$this->journal_special_obj->where('journal_special_id',$data['journal_special_id'])->update($update);
return jsonSuccess([]);
}
/**
* @title 客座期刊编辑(添加编辑)
* @description 客座期刊编辑(添加编辑)
* @author wangjinlei
* @url /master/Special/addSpecialEditor
* @method POST
*
* @param name:journal_id type:int require:1 desc:期刊id
* @param name:email type:string require:1 desc:邮箱
* @param name:first_name type:string require:1 desc:名字
* @param name:last_name type:string require:1 desc:名字
* @param name:address type:string require:1 desc:地址
* @param name:interests type:string require:0 desc:兴趣
* @param name:website type:string require:0 desc:编辑主页
* @param name:orcid type:string require:0 desc:orcid
*/
public function addSpecialEditor(){
$data = $this->request->post();
$insert['journal_id'] = $data['journal_id'];
$insert['email'] = $data['email'];
$insert['first_name'] = $data['first_name'];
$insert['last_name'] = $data['last_name'];
$insert['address'] = $data['address'];
$insert['interests'] = $data['interests'];
$insert['website'] = $data['website'];
$insert['orcid'] = $data['orcid'];
$this->journal_special_editor_obj->insert();
return jsonSuccess([]);
}
/**
* @title 客座期刊编辑(更改编辑)
* @description 客座期刊编辑(更改编辑)
* @author wangjinlei
* @url /master/Special/editSpecialEditor
* @method POST
*
* @param name:journal_special_editor_id type:int require:1 desc:客座期刊编辑id
* @param name:email type:string require:1 desc:邮箱
* @param name:first_name type:string require:1 desc:名字
* @param name:last_name type:string require:1 desc:名字
* @param name:address type:string require:1 desc:地址
* @param name:interests type:string require:0 desc:兴趣
* @param name:website type:string require:0 desc:编辑主页
* @param name:orcid type:string require:0 desc:orcid
*/
public function editSpecialEditor(){
$data = $this->request->post();
$update['email'] = $data['email'];
$update['first_name'] = $data['first_name'];
$update['last_name'] = $data['last_name'];
$update['address'] = $data['address'];
$update['interests'] = $data['interests'];
$update['website'] = $data['website'];
$update['orcid'] = $data['orcid'];
$this->journal_special_editor_obj->where('journal_special_editor_id',$data['journal_special_editor_id'])->update($update);
return jsonSuccess([]);
}
/**
* @title 客座期刊编辑(获取编辑列表,除去已经建立联系的)
* @description 客座期刊编辑(获取编辑列表,除去已经建立联系的)
* @author wangjinlei
* @url /master/Special/getSpecialEditors
* @method POST
*
* @param name:journal_id type:int require:1 desc:期刊id
* @param name:journal_special_id type:int require:1 desc:客座期刊编辑id
*
* @return editors:编辑列表array#
*/
public function getSpecialEditors(){
$data = $this->request->post();
$cids = $this->journal_special_to_editor_obj->where('journal_special_id',$data['journal_special_id'])->where('state',0)->column('journal_special_editor_id');
$list = $this->journal_special_editor_obj->where('journal_special_editor_id','not in',$cids)->where('state',0)->select();
$re['editors'] = $list;
return jsonSuccess($re);
}
/**
* @title 客座期刊编辑(添加客座期刊与作者的对应关系)
* @description 客座期刊编辑(添加客座期刊与作者的对应关系)
* @author wangjinlei
* @url /master/Special/addSpecialToEditor
* @method POST
*
* @param name:journal_id type:int require:1 desc:期刊id
* @param name:journal_special_id type:int require:1 desc:客座期刊id
* @param name:journal_special_editor_id type:int require:1 desc:客座期刊编辑id
*/
public function addSpecialToEditor(){
$data = $this->request->post();
$insert['journal_special_id'] = $data['journal_special_id'];
$insert['journal_special_editor_id'] = $data['journal_special_editor_id'];
$insert['journal_id'] = $data['journal_id'];
$this->journal_special_to_editor_obj->insert($insert);
return jsonSuccess([]);
}
/**
* @title 客座期刊编辑(删除客座期刊与作者的对应关系)
* @description 客座期刊编辑(删除客座期刊与作者的对应关系)
* @author wangjinlei
* @url /master/Special/delSpecialToEditor
* @method POST
*
* @param name:journal_special_id type:int require:1 desc:客座期刊id
* @param name:journal_special_editor_id type:int require:1 desc:期刊编辑id
*/
public function delSpecialToEditor(){
$data = $this->request->post();
$this->journal_special_to_editor_obj
->where('journal_special_id',$data['journal_special_id'])
->where('journal_special_editor_id',$data['journal_special_editor_id'])
->update(['state'=>1]);
return jsonSuccess([]);
}
}