354 lines
12 KiB
PHP
354 lines
12 KiB
PHP
<?php
|
||
|
||
namespace app\master\controller;
|
||
|
||
use think\Controller;
|
||
use think\Db;
|
||
|
||
/**
|
||
* @title 期刊接口
|
||
* @description 期刊相关操作
|
||
* @group 期刊相关
|
||
*/
|
||
class Journal extends Controller {
|
||
//put your code here
|
||
protected $admin_obj = '';
|
||
protected $journal_obj = '';
|
||
protected $journal_topic_obj = '';
|
||
|
||
public function __construct(\think\Request $request = null) {
|
||
parent::__construct($request);
|
||
$this->admin_obj = Db::name('admin');
|
||
$this->journal_obj = Db::name('journal');
|
||
$this->journal_topic_obj = Db::name('journal_topic');
|
||
}
|
||
|
||
/**
|
||
* @title 获取期刊列表
|
||
* @description 获取期刊列表
|
||
* @author wangjinlei
|
||
* @url /master/Journal/getJournalList
|
||
* @method POST
|
||
*
|
||
*
|
||
* @return journalList:期刊列表@
|
||
* @journalList title:标题 issn:issn editorinchief:editorinchief acceptance:acceptance finaldecision:finaldecision apc:apc
|
||
*
|
||
*/
|
||
public function getJournalList(){
|
||
$res = $this->journal_obj->field('j_journal.*,j_admin.realname realname')->join('j_admin','j_admin.admin_id = j_journal.editor_id','LEFT')->where('j_journal.state',0)->order('j_journal.sort desc')->select();
|
||
return json(['code'=>0,'msg'=>'success','data'=>['journalList'=>$res]]);
|
||
}
|
||
|
||
|
||
/**
|
||
* @title 添加期刊
|
||
* @description 添加期刊
|
||
* @author wangjinlei
|
||
* @url /master/Journal/addJournal
|
||
* @method POST
|
||
*
|
||
* @param name:title type:string require:1 desc:标题
|
||
* @param name:issn type:string require:1
|
||
* @param name:editorinchief type:string require:1
|
||
* @param name:acceptance type:string require:1 desc:受理度
|
||
* @param name:finaldecision type:string require:1 desc:最终受理
|
||
* @param name:sort type:int require:1 detault:0 desc:权重值
|
||
* @param name:apc type:string require:1
|
||
* @param name:icon type:string require:1
|
||
* @param name:editor_id type:int require:1 desc:编辑id
|
||
* @param name:system_color type:string require:1
|
||
* @param name:submission_url type:string require:1
|
||
*
|
||
*/
|
||
public function addJournal(){
|
||
$data = $this->request->post();
|
||
$insert_data['title'] = $data['title'];
|
||
$insert_data['issn'] = $data['issn'];
|
||
$insert_data['editorinchief'] = $data['editorinchief'];
|
||
$insert_data['acceptance'] = $data['acceptance'];
|
||
$insert_data['finaldecision'] = $data['finaldecision'];
|
||
$insert_data['sort'] = $data['sort'];
|
||
$insert_data['apc'] = $data['apc'];
|
||
$insert_data['icon'] = $data['icon'];
|
||
$insert_data['editor_id'] = $data['editor_id'];
|
||
$insert_data['system_color'] = $data['system_color'];
|
||
$insert_data['submission_url'] = $data['submission_url'];
|
||
$res = $this->journal_obj->insert($insert_data);
|
||
if($res){
|
||
return json(['code'=>0,'msg'=>'success']);
|
||
}else{
|
||
return json(['code'=>1,'msg'=>'system error']);
|
||
}
|
||
}
|
||
|
||
|
||
/**
|
||
* @title 获取期刊详情
|
||
* @description 获取期刊详情
|
||
* @author wangjinlei
|
||
* @url /master/Journal/getJournalDetail
|
||
* @method POST
|
||
*
|
||
* @param name:journal_id require:1 desc:主键
|
||
*
|
||
* @return
|
||
*
|
||
*/
|
||
public function getJournalDetail(){
|
||
// $data = $this->request->post();
|
||
// $journal_info = $this->journal_obj->where('journal_id',$data['journal_id'])->find();
|
||
|
||
|
||
}
|
||
|
||
|
||
/**
|
||
* @title 删除期刊
|
||
* @description 删除期刊
|
||
* @author wangjinlei
|
||
* @url /master/Journal/delJournal
|
||
* @method POST
|
||
*
|
||
* @param name:journal_id require:1 desc:主键
|
||
*
|
||
*/
|
||
public function delJournal(){
|
||
$data = $this->request->post();
|
||
$res = $this->journal_obj->where('journal_id',$data['journal_id'])->update(['state'=>1]);
|
||
if($res){
|
||
return json(['code'=>0,'msg'=>'success']);
|
||
}else{
|
||
return json(['code'=>1,'msg'=>'system error']);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* @title 修改期刊详情
|
||
* @description 修改期刊详情
|
||
* @author wangjinlei
|
||
* @url /master/Journal/editJournalDetail
|
||
* @method POST
|
||
*
|
||
* @param name:journal_id require:1 desc:主键
|
||
* @param name:title type:string require:1 desc:标题
|
||
* @param name:issn type:string require:1
|
||
* @param name:editorinchief type:string require:1
|
||
* @param name:acceptance type:string require:1 desc:受理度
|
||
* @param name:finaldecision type:string require:1 desc:最终受理
|
||
* @param name:sort type:int require:1 detault:0 desc:权重值
|
||
* @param name:apc type:string require:1
|
||
* @param name:icon type:string require:1
|
||
* @param name:editor_id type:int require:1 desc:编辑id
|
||
* @param name:system_color type:string require:1
|
||
* @param name:submission_url type:string require:1
|
||
*
|
||
*/
|
||
public function editJournalDetail(){
|
||
$data = $this->request->post();
|
||
$insert_data['title'] = $data['title'];
|
||
$insert_data['issn'] = $data['issn'];
|
||
$insert_data['editorinchief'] = $data['editorinchief'];
|
||
$insert_data['acceptance'] = $data['acceptance'];
|
||
$insert_data['finaldecision'] = $data['finaldecision'];
|
||
$insert_data['sort'] = $data['sort'];
|
||
$insert_data['apc'] = $data['apc'];
|
||
$insert_data['icon'] = $data['icon'];
|
||
$insert_data['editor_id'] = $data['editor_id'];
|
||
$insert_data['system_color'] = $data['system_color'];
|
||
$insert_data['submission_url'] = $data['submission_url'];
|
||
$res = $this->journal_obj->where('journal_id',$data['journal_id'])->update($insert_data);
|
||
if($res){
|
||
return json(['code'=>0,'msg'=>'success']);
|
||
}else{
|
||
return json(['code'=>1,'msg'=>'Please confirm you have changed the journal information.']);
|
||
}
|
||
|
||
}
|
||
|
||
/**
|
||
* @title 获取编辑列表
|
||
* @description 获取编辑列表
|
||
* @author wangjinlei
|
||
* @url /master/Journal/getEditorList
|
||
* @method POST
|
||
*
|
||
*
|
||
* @return editorList:编辑列表@
|
||
* @editorList account:账号 realname:真实姓名 role:角色代号(0admin1editor)
|
||
*
|
||
*/
|
||
public function getEditorList(){
|
||
$editor_list = $this->admin_obj->where('role',1)->select();
|
||
return json(['code'=>0,'msg'=>'success','data'=>['editorList'=>$editor_list]]);
|
||
}
|
||
|
||
/**
|
||
* @title 图片上传
|
||
* @description 图片上传
|
||
* @author wangjinlei
|
||
* @url /master/Journal/up_file
|
||
* @method POST
|
||
*
|
||
* @param name:name type:string require:1 default:journalicon desc:文件域名称
|
||
*
|
||
*
|
||
* @return upurl:图片地址
|
||
*
|
||
*/
|
||
public function up_file() {
|
||
$file = request()->file('journalicon');
|
||
if ($file) {
|
||
$info = $file->move(ROOT_PATH . 'public' . DS . 'journalicon');
|
||
if ($info) {
|
||
return json(['code'=>0 , 'msg'=>'success', 'upurl' => str_replace("\\", "/", $info->getSaveName())]);
|
||
} else {
|
||
return json(['code' => 1, 'msg' => $file->getError()]);
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* @title 增加话题
|
||
* @description 增加话题
|
||
* @author wangjinlei
|
||
* @url /master/Journal/addTopic
|
||
* @method POST
|
||
*
|
||
* @param name:journal_id type:int require:1 desc:期刊id
|
||
* @param name:parent_id type:int require:1 default:0 desc:父id
|
||
* @param name:title type:string require:1 desc:标题
|
||
* @param name:icon type:string require:1 desc:缩略图
|
||
* @param name:is_final type:int require:1 desc:是否终结点(0no1yes)
|
||
* @param name:sort type:int require:1 default:0 desc:权重
|
||
*
|
||
*/
|
||
public function addTopic(){
|
||
$data = $this->request->post();
|
||
$level = 0;
|
||
if($data['parent_id']==0){
|
||
$level = 1;
|
||
}else{
|
||
$parent_info = $this->journal_topic_obj->where('journal_topic_id',$data['parent_id'])->find();
|
||
$level = intval($parent_info['level'])+1;
|
||
}
|
||
$insert['journal_id'] = $data['journal_id'];
|
||
$insert['parent_id'] = $data['parent_id'];
|
||
$insert['title'] = $data['title'];
|
||
$insert['icon'] = $data['icon'];
|
||
$insert['is_final'] = $data['is_final'];
|
||
$insert['sort'] = $data['sort'];
|
||
$insert['level'] = $level;
|
||
$res = $this->journal_topic_obj->insert($insert);
|
||
if($res){
|
||
return json(['code'=>0,'msg'=>'success']);
|
||
}else{
|
||
return json(['code'=>1,'msg'=>'system error']);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* @title 获取话题父级列表
|
||
* @description 获取话题父级列表
|
||
* @author wangjinlei
|
||
* @url /master/Journal/getParent
|
||
* @method POST
|
||
*
|
||
* @param name:journal_id type:int require:1 desc:
|
||
*
|
||
* @return parentList:array#
|
||
*/
|
||
public function getParent(){
|
||
$data = $this->request->post();
|
||
$res = $this->journal_topic_obj
|
||
->where('journal_id',$data['journal_id'])
|
||
->where('state',0)
|
||
->where('is_final',0)
|
||
->select();
|
||
//处理数组
|
||
$frag = [];
|
||
foreach ($res as $v){
|
||
if($v['parent_id'] == 0){
|
||
$frag[] = $v;
|
||
}
|
||
}
|
||
foreach ($frag as $kk => $vv){
|
||
$frag[$kk] = $this->getChieldarr($vv,$res);
|
||
}
|
||
return json(['code'=>0,'msg'=>'success','data'=>['parentList'=>$frag]]);
|
||
}
|
||
|
||
/**
|
||
* @title 获取话题列表
|
||
* @description 获取话题列表
|
||
* @author wangjinlei
|
||
* @url /master/Journal/getTopicList
|
||
* @method POST
|
||
*
|
||
* @param name:journal_id type:int require:1 desc:期刊id
|
||
*
|
||
* @return journal:array#
|
||
* @return topicList:话题数组@
|
||
* @topicList array:数据
|
||
*
|
||
*/
|
||
public function getTopicList(){
|
||
$data = $this->request->post();
|
||
$res = $this->journal_topic_obj
|
||
->where('journal_id',$data['journal_id'])
|
||
->where('state',0)
|
||
->select();
|
||
$journal_info = $this->journal_obj->where('journal_id',$data['journal_id'])->find();
|
||
//处理数组
|
||
$frag = [];
|
||
foreach ($res as $v){
|
||
if($v['parent_id'] == 0){
|
||
$frag[] = $v;
|
||
}
|
||
}
|
||
foreach ($frag as $kk => $vv){
|
||
$frag[$kk] = $this->getChieldarr($vv,$res);
|
||
}
|
||
return json(['code'=>0,'msg'=>'success','data'=>['journal'=>$journal_info,'topicList'=>$frag]]);
|
||
}
|
||
|
||
|
||
private function getChieldarr($vv,$res){
|
||
if($vv['is_final']==1){
|
||
return $vv;
|
||
}
|
||
foreach ($res as $v){
|
||
$vv['child'][] = $this->getChieldarr($v, $res);
|
||
}
|
||
return $vv;
|
||
}
|
||
|
||
|
||
/**
|
||
* @title topic图片上传
|
||
* @description topic图片上传
|
||
* @author wangjinlei
|
||
* @url /master/Journal/up_topic_file
|
||
* @method POST
|
||
*
|
||
* @param name:name type:string require:1 default:journaltopic desc:文件域名称
|
||
*
|
||
*
|
||
* @return upurl:图片地址
|
||
*
|
||
*/
|
||
public function up_topic_file() {
|
||
$file = request()->file('journaltopic');
|
||
if ($file) {
|
||
$info = $file->move(ROOT_PATH . 'public' . DS . 'journaltopic');
|
||
if ($info) {
|
||
return json(['code'=>0 , 'msg'=>'success', 'upurl' => str_replace("\\", "/", $info->getSaveName())]);
|
||
} else {
|
||
return json(['code' => 1, 'msg' => $file->getError()]);
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
}
|