674 lines
26 KiB
PHP
674 lines
26 KiB
PHP
<?php
|
|
namespace app\master\controller;
|
|
|
|
use think\Controller;
|
|
use think\Db;
|
|
|
|
/**
|
|
* @title 文章接口
|
|
* @description 文章相关操作
|
|
* @group 文章相关
|
|
*/
|
|
class Article extends Controller {
|
|
//put your code here
|
|
protected $admin_obj = '';
|
|
protected $journal_obj = '';
|
|
protected $article_obj = '';
|
|
protected $article_author_obj = '';
|
|
protected $article_organ_obj = '';
|
|
protected $author_to_organ_obj = '';
|
|
protected $article_to_topic_obj = '';
|
|
protected $journal_topic_obj = '';
|
|
protected $journal_stage_obj = '';
|
|
protected $country_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->article_organ_obj = Db::name('article_organ');
|
|
$this->author_to_organ_obj = Db::name('article_author_to_organ');
|
|
$this->article_to_topic_obj = Db::name('article_to_topic');
|
|
$this->journal_topic_obj = Db::name('journal_topic');
|
|
$this->journal_stage_obj = Db::name('journal_stage');
|
|
$this->country_obj = Db::name('country');
|
|
}
|
|
|
|
/**
|
|
* @title 获取期刊和分期
|
|
* @description 获取期刊和分期
|
|
* @author wangjinleichang
|
|
* @url /master/Article/getJournalAndStage
|
|
* @method POST
|
|
*
|
|
* @param name:editor_id type:int require:1 desc:编辑id
|
|
*
|
|
* @return joutaglist:array#
|
|
*
|
|
*/
|
|
public function getJournalAndStage(){
|
|
$data = $this->request->post();
|
|
$journal_list = $this->journal_obj->where('editor_id',$data['editor_id'])->where('state',0)->select();
|
|
$frag = [];
|
|
foreach ($journal_list as $v){
|
|
$v['journal_stage_id'] = $v['journal_id'];
|
|
$cache_list = $this->journal_stage_obj->where('journal_id',$v['journal_id'])->where('state',0)->select();
|
|
foreach($cache_list as $k => $vv){
|
|
$cache_list[$k]['title'] = $vv['stage_year'].' Vol.'.$vv['stage_vol'].' issue.'.$vv['stage_no'].$vv['stage_pagename'].$vv['stage_page'];
|
|
}
|
|
if(count($cache_list)>0){
|
|
$v['children'] = $cache_list;
|
|
}else{
|
|
$v['children'] = [];
|
|
}
|
|
$frag[] = $v;
|
|
}
|
|
return json(['code'=>0,'msg'=>'success','data'=>['joutaglist'=>$frag]]);
|
|
}
|
|
|
|
/**
|
|
* @title 添加文章基本信息
|
|
* @description 添加文章基本信息
|
|
* @author wangjinleichang
|
|
* @url /master/Article/addArticleBase
|
|
* @method POST
|
|
*
|
|
* @param name:journal_id type:int require:1 desc:期刊id
|
|
* @param name:journal_stage_id type:int require:1 desc:分期id
|
|
* @param name:sort type:int require:1 default:0 desc:权重
|
|
* @param name:title type:string require:1 desc:标题
|
|
*/
|
|
public function addArticleBase(){
|
|
$data = $this->request->post();
|
|
$insert_data['journal_id'] = $data['journal_id'];
|
|
$insert_data['journal_stage_id'] = $data['journal_stage_id'];
|
|
$insert_data['title'] = $data['title'];
|
|
$insert_data['sort'] = $data['sort'];
|
|
$insert_data['ctime'] = time();
|
|
$res = $this->article_obj->insert($insert_data);
|
|
if($res){
|
|
return json(['code'=>0,'msg'=>'success']);
|
|
}else{
|
|
return json(['code'=>1,'msg'=>'system error']);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @title 删除文章
|
|
* @description 删除文章
|
|
* @author wangjinleichang
|
|
* @url /master/Article/delArticle
|
|
* @method POST
|
|
*
|
|
* @param name:article_id type:int require:1 desc:文章id
|
|
*/
|
|
public function delArticle(){
|
|
$data = $this->request->post();
|
|
$res = $this->article_obj->where('article_id',$data['article_id'])->update(['state'=>1]);
|
|
return json(['code'=>0,'msg'=>'success']);
|
|
}
|
|
|
|
/**
|
|
* @title 添加文章作者
|
|
* @description 添加文章作者
|
|
* @author wangjinleichang
|
|
* @url /master/Article/addArticleAuthor
|
|
* @method POST
|
|
*
|
|
* @param name:article_id type:int require:1 desc:article_id
|
|
* @param name:author_name type:string require:1 desc:作者名字
|
|
* @param name:author_country type:string require:1 desc:国家
|
|
* @param name:is_first type:boolean require:1 default:0 desc:是否第一作者(1yes0no)
|
|
* @param name:is_report type:boolean require:1 default:0 desc:是否通讯作者(1yes0no)
|
|
* @param name:email type:string require:0 desc:邮箱
|
|
* @param name:organs type:string require:1 desc:array
|
|
*
|
|
*/
|
|
public function addArticleAuthor(){
|
|
$data = $this->request->post();
|
|
|
|
$insert_author['article_id'] = $data['article_id'];
|
|
$insert_author['author_name'] = $data['author_name'];
|
|
$insert_author['author_country'] = $data['author_country'];
|
|
$insert_author['is_first'] = $data['is_first'];
|
|
$insert_author['is_report'] = $data['is_report'];
|
|
$insert_author['email'] = intval($data['is_report'])==1?$data['email']:'';
|
|
Db::startTrans();
|
|
$insert_id = $this->article_author_obj->insertGetId($insert_author);
|
|
$or_res = true;
|
|
if(isset($data['organs'])&&is_array($data['organs'])){
|
|
foreach ($data['organs'] as $k => $v){
|
|
$cache_ins['article_id'] = $data['article_id'];
|
|
$cache_ins['article_author_id'] = $insert_id;
|
|
$cache_ins['article_organ_id'] = $v;
|
|
$or_res = $this->author_to_organ_obj->insert($cache_ins)?true:false;
|
|
}
|
|
}
|
|
if($insert_id&&$or_res){
|
|
Db::commit();
|
|
return json(['code'=>0,'msg'=>'success']);
|
|
}else{
|
|
Db::rollback();
|
|
return json(['code'=>1,'msg'=>'system error']);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @title 编辑文章作者
|
|
* @description 编辑文章作者
|
|
* @author wangjinleichang
|
|
* @url /master/Article/editArticleAuthor
|
|
* @method POST
|
|
*
|
|
* @param name:article_author_id type:int require:1 desc:article_id
|
|
* @param name:author_name type:string require:1 desc:作者名字
|
|
* @param name:author_country type:string require:1 desc:国家
|
|
* @param name:is_first type:boolean require:1 default:0 desc:是否第一作者(1yes0no)
|
|
* @param name:is_report type:boolean require:1 default:0 desc:是否通讯作者(1yes0no)
|
|
* @param name:email type:string require:0 desc:邮箱
|
|
* @param name:organs type:string require:1 desc:array
|
|
*
|
|
*/
|
|
public function editArticleAuthor(){
|
|
$data = $this->request->post();
|
|
|
|
// $data['article_author_id'] = 21;
|
|
// $data['article_id'] = 38;
|
|
// $data['author_name'] = '作者3';
|
|
// $data['author_country'] = 'Netherlands';
|
|
// $data['is_first'] = 1;
|
|
// $data['is_report'] = 1;
|
|
// $data['email'] = 'xl37@163.com';
|
|
// $data['organs'] = ['1','2','3'];
|
|
|
|
$old_article_author_info = $this->article_author_obj->where('article_author_id',$data['article_author_id'])->find();
|
|
$update_author['author_name'] = $data['author_name'];
|
|
$update_author['author_country'] = $data['author_country'];
|
|
$update_author['is_first'] = $data['is_first'];
|
|
$update_author['is_report'] = $data['is_report'];
|
|
$update_author['email'] = intval($data['is_report'])==1?$data['email']:'';
|
|
$this->article_author_obj->where('article_author_id',$data['article_author_id'])->update($update_author);
|
|
if(is_array($data['organs'])){
|
|
$has_ids = [];
|
|
foreach ($data['organs'] as $v){
|
|
$cache_one = $this->author_to_organ_obj->where('article_author_id',$data['article_author_id'])->where('article_organ_id',$v)->where('state',0)->find();
|
|
if($cache_one==null){
|
|
$insert['article_id'] = $old_article_author_info['article_id'];
|
|
$insert['article_author_id'] = $data['article_author_id'];
|
|
$insert['article_organ_id'] = $v;
|
|
$this->author_to_organ_obj->insert($insert);
|
|
}
|
|
$has_ids[] = intval($v);
|
|
}
|
|
$this->author_to_organ_obj->where('article_author_id',$data['article_author_id'])->where('state',0)->where('article_organ_id','not in',$has_ids)->update(['state'=>1]);
|
|
}else{
|
|
$this->author_to_organ_obj->where('article_author_id',$data['article_author_id'])->where('state',0)->update(['state'=>1]);
|
|
}
|
|
return json(['code'=>0,'msg'=>'success']);
|
|
}
|
|
|
|
/**
|
|
* @title 删除文章作者
|
|
* @description 删除文章作者
|
|
* @author wangjinleichang
|
|
* @url /master/Article/delArticleAuthor
|
|
* @method POST
|
|
*
|
|
* @param name:article_author_id type:int require:1 desc:article_id
|
|
*
|
|
*/
|
|
public function delArticleAuthor(){
|
|
$data = $this->request->post();
|
|
//删除作者和机构的关系
|
|
$this->author_to_organ_obj->where('article_author_id',$data['article_author_id'])->update(['state'=>1]);
|
|
$this->article_author_obj->where('article_author_id',$data['article_author_id'])->update(['state'=>1]);
|
|
return json(['code'=>0,'msg'=>'success']);
|
|
}
|
|
|
|
/**
|
|
* @title 获取文章作者和机构
|
|
* @description 获取文章作者和机构
|
|
* @author wangjinleichang
|
|
* @url /master/Article/getArticleAuthor
|
|
* @method POST
|
|
*
|
|
* @param name:article_id type:int require:1 desc:article_id
|
|
*
|
|
* @return authorList:array#
|
|
* @return organList:array#
|
|
*/
|
|
public function getArticleAuthor(){
|
|
$data = $this->request->post();
|
|
$author_list = $this->article_author_obj->where('article_id',$data['article_id'])->where('state',0)->select();
|
|
foreach ($author_list as $k => $v){
|
|
$cache_to = $this->author_to_organ_obj
|
|
->field('j_article_author_to_organ.*,j_article_organ.organ_name')
|
|
->join('j_article_organ','j_article_organ.article_organ_id = j_article_author_to_organ.article_organ_id')
|
|
->where('j_article_author_to_organ.article_author_id',$v['article_author_id'])
|
|
->where('j_article_author_to_organ.state',0)
|
|
->select();
|
|
$cache_frag = [];
|
|
foreach($cache_to as $vv){
|
|
$cache_frag[] = $vv;
|
|
}
|
|
$author_list[$k]['organs'] = $cache_frag;
|
|
}
|
|
$organ_list = $this->article_organ_obj->where('article_id',$data['article_id'])->where('state',0)->select();
|
|
return json(['code'=>0,'msg'=>'success','data'=>['authorList'=>$author_list,'organList'=>$organ_list]]);
|
|
}
|
|
|
|
/**
|
|
* @title 添加文章作者机构
|
|
* @description 添加文章作者机构
|
|
* @author wangjinleichang
|
|
* @url /master/Article/addArticleOrgan
|
|
* @method POST
|
|
*
|
|
* @param name:article_id type:int require:1 desc:article_id
|
|
* @param name:organ_name type:string require:1 desc:机构名字
|
|
*/
|
|
public function addArticleOrgan(){
|
|
$data = $this->request->post();
|
|
$insert_data['article_id'] = $data['article_id'];
|
|
$insert_data['organ_name'] = $data['organ_name'];
|
|
$res = $this->article_organ_obj->insert($insert_data);
|
|
if($res){
|
|
return json(['code'=>0,'msg'=>'success']);
|
|
}else{
|
|
return json(['code'=>1,'msg'=>'system error']);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @title 编辑文章作者机构
|
|
* @description 编辑文章作者机构
|
|
* @author wangjinleichang
|
|
* @url /master/Article/editArticleOrgan
|
|
* @method POST
|
|
*
|
|
* @param name:article_organ_id type:int require:1 desc:article_organ_id
|
|
* @param name:organ_name type:string require:1 desc:机构名字
|
|
*/
|
|
public function editArticleOrgan(){
|
|
$data = $this->request->post();
|
|
$this->article_organ_obj->where('article_organ_id',$data['article_organ_id'])->update(['organ_name'=>$data['organ_name']]);
|
|
return json(['code'=>0,'msg'=>'success']);
|
|
}
|
|
|
|
/**
|
|
* @title 删除文章作者机构
|
|
* @description 删除文章作者机构
|
|
* @author wangjinleichang
|
|
* @url /master/Article/delArticleOrgan
|
|
* @method POST
|
|
*
|
|
* @param name:article_organ_id type:int require:1 desc:article_organ_id
|
|
*/
|
|
public function delArticleOrgan(){
|
|
$data = $this->request->post();
|
|
//删除作者和机构的关系
|
|
$this->author_to_organ_obj->where('article_organ_id',$data['article_organ_id'])->update(['state'=>1]);
|
|
$this->article_organ_obj->where('article_organ_id',$data['article_organ_id'])->update(['state'=>1]);
|
|
return json(['code'=>0,'msg'=>'success']);
|
|
}
|
|
|
|
/**
|
|
* @title 获取文章基本信息
|
|
* @description 获取文章基本信息
|
|
* @author wangjinleichang
|
|
* @url /master/Article/getArticleBase
|
|
* @method POST
|
|
*
|
|
* @param name:article_id type:int require:1 desc:文章id
|
|
*
|
|
* @return articleInfo:文章详情@
|
|
* @articleInfo icon:图片
|
|
* @articleInfo tradition_tag:封皮标签
|
|
* @articleInfo tradition:封皮简介
|
|
* @articleInfo doi:doi
|
|
* @articleInfo abstract:简介
|
|
* @articleInfo keywords:关键字
|
|
* @articleInfo fund:fund
|
|
* @articleInfo file_html:html文件
|
|
* @articleInfo sort:权重
|
|
* @articleInfo pub_date:发表日期
|
|
*
|
|
*
|
|
* @return files:文件列表#
|
|
*
|
|
*/
|
|
public function getArticleBase(){
|
|
$data = $this->request->post();
|
|
$article_info = $this->article_obj->where('article_id',$data['article_id'])->find();
|
|
$journal_info = $this->journal_obj->where('journal_id',$article_info['journal_id'])->find();
|
|
$list = scandir(ROOT_PATH.'public/articleHTML/'.$journal_info['sx']);
|
|
$frag = [];
|
|
foreach ($list as $k => $v){
|
|
if($k>2){
|
|
$frag[] = $v;
|
|
}
|
|
}
|
|
|
|
$re['articleInfo'] = $article_info;
|
|
$re['files'] = $frag;
|
|
return jsonSuccess($re);
|
|
// return json(['code'=>0,'msg'=>'success','data'=>$article_info]);
|
|
}
|
|
|
|
/**
|
|
* @title 获取文章html文件列表
|
|
* @description 获取文章html文件列表
|
|
* @author wangjinleichang
|
|
* @url /master/Article/getHtmlFiles
|
|
* @method POST
|
|
*
|
|
* @param name:article_id type:int require:1 desc:文章id
|
|
*
|
|
* @return files:文件列表#
|
|
*
|
|
*/
|
|
public function getHtmlFiles(){
|
|
$data = $this->request->post();
|
|
$data['article_id'] = 1;
|
|
$article_info = $this->article_obj->where('article_id',$data['article_id'])->find();
|
|
$journal_info = $this->journal_obj->where('journal_id',$article_info['journal_id'])->find();
|
|
$list = scandir(ROOT_PATH.'public/articleHTML/'.$journal_info['sx']);
|
|
$frag = [];
|
|
foreach ($list as $k => $v){
|
|
if($k>2){
|
|
$frag[] = $v;
|
|
}
|
|
}
|
|
return jsonSuccess($data);
|
|
// $list = scandir(ROOT_PATH.'public/articleHTML/TMR');
|
|
// echo '<pre>';
|
|
// var_dump($list);
|
|
// echo '</pre>';
|
|
// die;
|
|
}
|
|
|
|
/**
|
|
* @title 编辑文章基本信息
|
|
* @description 编辑文章基本信息
|
|
* @author wangjinleichang
|
|
* @url /master/Article/editArticleBase
|
|
* @method POST
|
|
*
|
|
* @param name:article_id type:int require:1 desc:文章id
|
|
* @param name:title type:string require:1 desc:标题
|
|
* @param name:icon type:string require:1 desc:图片
|
|
* @param name:tradition_tag type:string require:1 desc:封皮标签
|
|
* @param name:tradition type:string require:1 desc:封皮简介
|
|
* @param name:journal_stage_id type:int require:1 desc:期刊分期id
|
|
* @param name:doi type:string require:1 desc:doi
|
|
* @param name:abstract type:string require:1 desc:简介
|
|
* @param name:keywords type:string require:1 desc:关键字
|
|
* @param name:abs_num type:int require:1 desc:简介数量
|
|
* @param name:pdf_num type:int require:1 desc:pdf数量
|
|
* @param name:html_num type:int require:1 desc:html数量
|
|
* @param name:npp type:strng require:1 desc:文章页码
|
|
* @param name:type type:string require:1 desc:类型
|
|
* @param name:cited type:int require:1 desc:引用数
|
|
* @param name:abbr type:string require:0 desc:作者简称
|
|
* @param name:sort type:int require:1 desc:权重
|
|
* @param name:file_html type:string require:0 desc:html文件
|
|
* @param name:fund type:string require:1 desc:fund
|
|
* @param name:pub_date type:string require:1 desc:发表日期
|
|
*
|
|
*/
|
|
public function editArticleBase(){
|
|
$data = $this->request->post();
|
|
$updata['icon'] = $data['icon'];
|
|
$updata['title'] = $data['title'];
|
|
$updata['journal_stage_id'] = $data['journal_stage_id'];
|
|
$updata['tradition_tag'] = $data['tradition_tag'];
|
|
$updata['tradition'] = $data['tradition'];
|
|
$updata['doi'] = $data['doi'];
|
|
$updata['abstract'] = $data['abstract'];
|
|
$updata['keywords'] = $data['keywords'];
|
|
$updata['abs_num'] = $data['abs_num'];
|
|
$updata['pdf_num'] = $data['pdf_num'];
|
|
$updata['html_num'] = $data['html_num'];
|
|
$updata['npp'] = $data['npp'];
|
|
$updata['type'] = $data['type'];
|
|
$updata['cited'] = $data['cited'];
|
|
$updata['abbr'] = $data['abbr'];
|
|
$updata['fund'] = $data['fund'];
|
|
$updata['file_html'] = $data['file_html'];
|
|
$updata['sort'] = $data['sort'];
|
|
$updata['pub_date'] = $data['pub_date'];
|
|
$res = $this->article_obj->where('article_id',$data['article_id'])->update($updata);
|
|
if($res){
|
|
return json(['code'=>0,'msg'=>'success']);
|
|
}else{
|
|
return json(['code'=>1,'msg'=>'system error']);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @title 编辑文章文件信息
|
|
* @description 编辑文章文件信息
|
|
* @author wangjinleichang
|
|
* @url /master/Article/editArticleFile
|
|
* @method POST
|
|
*
|
|
* @param name:article_id type:int require:1 desc:文章id
|
|
* @param name:filetype type:string require:1 desc:文件类型(PDF/HTML/SUB/SUB2/endNote/bibTex)
|
|
* @param name:fileURL type:string require:1 desc:文件地址
|
|
*
|
|
*/
|
|
public function editArticleFile(){
|
|
$data = $this->request->post();
|
|
if($data['filetype']=='PDF'){
|
|
$updata['file_pdf'] = $data['fileURL'];
|
|
}elseif($data['filetype']=='HTML'){
|
|
$updata['file_html'] = $data['fileURL'];
|
|
}elseif($data['filetype']=='SUB'){
|
|
$updata['file_sub'] = $data['fileURL'];
|
|
}elseif($data['filetype']=='SUB2'){
|
|
$updata['file_sub2'] = $data['fileURL'];
|
|
}elseif($data['filetype']=='endNote'){
|
|
$updata['endnote'] = $data['fileURL'];
|
|
}elseif($data['filetype']=='bibTex'){
|
|
$updata['bibtex'] = $data['fileURL'];
|
|
}
|
|
$this->article_obj->where('article_id',$data['article_id'])->update($updata);
|
|
return json(['code'=>0,'msg'=>'success']);
|
|
}
|
|
|
|
/**
|
|
* @title 获取文章列表
|
|
* @description 获取文章列表
|
|
* @author wangjinleichang
|
|
* @url /master/Article/getArticleList
|
|
* @method POST
|
|
*
|
|
* @param name:journal_id type:int default:0 require:1 desc:主键
|
|
* @param name:journal_stage_id type:int default:0 require:1 desc:主键
|
|
* @param name:editor_id type:int require:1 desc:编辑id
|
|
* @param name:seach type:string require:0 desc:关键词
|
|
* @param name:pageIndex type:int require:1 desc:当前页码数
|
|
* @param name:pageSize type:int require:1 desc:单页数据条数
|
|
*
|
|
* @return count:总数据数
|
|
* @return articleList:array#
|
|
*/
|
|
public function getArticleList(){
|
|
$data = $this->request->post();
|
|
// $data['editor_id'] = 6;
|
|
// $data['journal_id'] = 0;
|
|
// $data['journal_stage_id'] = 0;
|
|
// $data['seach'] = '';
|
|
// $data['pageIndex'] = 1;
|
|
// $data['pageSize'] = 80;
|
|
$where['j_article.state'] = 0;
|
|
if(intval($data['journal_id'])!==0){
|
|
$where['j_article.journal_id'] = $data['journal_id'];
|
|
}else{
|
|
$journals = $this->journal_obj->where('editor_id',$data['editor_id'])->column('journal_id');
|
|
$where['j_article.journal_id'] = ['in',$journals];
|
|
}
|
|
if(intval($data['journal_stage_id'])!==0){
|
|
$where['j_article.journal_stage_id'] = $data['journal_stage_id'];
|
|
}
|
|
if(isset($data['seach'])&&$data['seach']!=''){
|
|
$where['j_article.title'] = ['like','%'.$data['seach'].'%'];
|
|
}
|
|
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
|
|
$article_list = $this->article_obj->field('j_article.*,j_journal_stage.*,j_journal.title journal_title')->join(array(['j_journal_stage','j_article.journal_stage_id = j_journal_stage.journal_stage_id','LEFT'],['j_journal','j_journal.journal_id=j_article.journal_id','LEFT']))->where($where)->order(['j_article.sort desc','j_article.article_id'])->limit($limit_start,$data['pageSize'])->select();
|
|
$count = $this->article_obj->where($where)->count();
|
|
return json(['code'=>0,'msg'=>'success','data'=>['count'=>$count,'articleList'=>$article_list]]);
|
|
}
|
|
|
|
/**
|
|
* @title 获取文章对应期刊话题
|
|
* @description 获取文章对应期刊话题
|
|
* @author wangjinlei
|
|
* @url /master/Article/getTopicByArticle
|
|
* @method POST
|
|
*
|
|
* @param name:article_id type:int require:1 desc:期刊id
|
|
*
|
|
* @return topics:array#
|
|
* @return nowtopic:array#
|
|
*/
|
|
public function getTopicByArticle(){
|
|
$data = $this->request->post();
|
|
$article_info = $this->article_obj->where('article_id',$data['article_id'])->find();
|
|
$topic_res = $this->journal_topic_obj->where('journal_id',$article_info['journal_id'])->where('state',0)->select();
|
|
$frag = [];
|
|
foreach ($topic_res as $v){
|
|
if($v['is_final']==1){
|
|
$frag[] = $v;
|
|
}
|
|
}
|
|
foreach ($frag as $k => $val){
|
|
$frag[$k]['tname'] = $this->getTname($val, $topic_res);
|
|
}
|
|
//获取初始话题
|
|
$now_list = $this->article_to_topic_obj->where('article_id',$data['article_id'])->where('state',0)->select();
|
|
return json(['code'=>0,'msg'=>'success','data'=>['nowtopic'=>$now_list,'topics'=>$frag]]);
|
|
}
|
|
private function getTname($now,$arr){
|
|
if($now['parent_id']==0){
|
|
return $now['title'];
|
|
}else{
|
|
$frag = '>'.$now['title'];
|
|
foreach ($arr as $v){
|
|
if($v['journal_topic_id']==$now['parent_id']){
|
|
$frag = $this->getTname($v, $arr).$frag;
|
|
}
|
|
}
|
|
return $frag;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @title 增加文章话题
|
|
* @description 增加文章话题
|
|
* @author wangjinlei
|
|
* @url /master/Article/addTopicByArticle
|
|
* @method POST
|
|
*
|
|
* @param name:article_id type:int require:1 desc:期刊id
|
|
* @param name:topic_id type:int require:1 desc:话题id
|
|
*
|
|
*/
|
|
public function addTopicByArticle(){
|
|
$data = $this->request->post();
|
|
$insert['article_id'] = $data['article_id'];
|
|
$insert['topic_id'] = $data['topic_id'];
|
|
$res = $this->article_to_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/Article/delTopic
|
|
* @method POST
|
|
*
|
|
* @param name:article_to_topic_id type:int require:1 desc:主键id
|
|
*
|
|
*/
|
|
public function delTopic(){
|
|
$data = $this->request->post();
|
|
$res = $this->article_to_topic_obj->where('article_to_topic_id',$data['article_to_topic_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/Article/up_article_file
|
|
* @method POST
|
|
*
|
|
* @param name:name type:string require:1 default:articleicon desc:文件域名称
|
|
*
|
|
* @return upurl:图片地址
|
|
*/
|
|
public function up_article_file() {
|
|
$file = request()->file('articleicon');
|
|
if ($file) {
|
|
$info = $file->move(ROOT_PATH . 'public' . DS . 'articleicon');
|
|
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/Article/article_file
|
|
* @method GET
|
|
*
|
|
* @param name:name type:string require:1 desc:文件域名称(articlePDF/articleHTML/articleSUB/articleSUB2/bibTex/endNote)
|
|
* @param name:type type:string require:1 desc:pathinfo(articlePDF/articleHTML/articleSUB/articleSUB2/bibTex/endNote)
|
|
*
|
|
* @return upurl:图片地址
|
|
*/
|
|
public function article_file($type) {
|
|
$file = request()->file($type);
|
|
if ($file) {
|
|
$info = $file->move(ROOT_PATH . 'public' . DS . $type);
|
|
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/Article/getCountrys
|
|
* @method POST
|
|
*
|
|
* @return countrys:array#
|
|
*/
|
|
public function getCountrys() {
|
|
$res = $this->country_obj->order('en_name')->select();
|
|
return json(['code'=>0,'msg'=>'success','data'=>['countrys'=>$res]]);
|
|
}
|
|
|
|
|
|
}
|