20201112
This commit is contained in:
@@ -14,16 +14,24 @@ class Article extends Controller {
|
||||
protected $admin_obj = '';
|
||||
protected $journal_obj = '';
|
||||
protected $article_obj = '';
|
||||
protected $article_author_obj = '';
|
||||
protected $article_organ_obj = '';
|
||||
protected $author_to_organ_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->journal_topic_obj = Db::name('journal_topic');
|
||||
$this->journal_stage_obj = Db::name('journal_stage');
|
||||
$this->country_obj = Db::name('country');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,11 +48,18 @@ class Article extends Controller {
|
||||
*/
|
||||
public function getJournalAndStage(){
|
||||
$data = $this->request->post();
|
||||
$data['editor_id'] = 6;
|
||||
$journal_list = $this->journal_obj->where('editor_id',$data['editor_id'])->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'])->select();
|
||||
$v['children'] = $cache_list;
|
||||
foreach($cache_list as $k => $vv){
|
||||
$cache_list[$k]['title'] = $vv['stage_year'].' Vol.'.$vv['stage_vol'].' No.'.$vv['stage_no'].' pp. '.$vv['stage_page'];
|
||||
}
|
||||
if(count($cache_list)>0){
|
||||
$v['children'] = $cache_list;
|
||||
}
|
||||
$frag[] = $v;
|
||||
}
|
||||
return json(['code'=>0,'msg'=>'success','data'=>['joutaglist'=>$frag]]);
|
||||
@@ -67,7 +82,7 @@ class Article extends Controller {
|
||||
$insert_data['journal_id'] = $data['journal_id'];
|
||||
$insert_data['journal_stage_id'] = $data['journal_stage_id'];
|
||||
$insert_data['title'] = $data['title'];
|
||||
$insert_data['sort'] =
|
||||
$insert_data['sort'] = $data['sort'];
|
||||
$insert_data['ctime'] = time();
|
||||
$res = $this->article_obj->insert($insert_data);
|
||||
if($res){
|
||||
@@ -77,6 +92,210 @@ class Article extends Controller {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @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();
|
||||
$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/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/getArticleBase
|
||||
* @method POST
|
||||
*
|
||||
* @param name:article_id type:int require:1 desc:文章id
|
||||
*
|
||||
* @return icon:图片
|
||||
* @return tradition_tag:封皮标签
|
||||
* @return tradition:封皮简介
|
||||
* @return doi:doi
|
||||
* @return abstract:简介
|
||||
* @return keywords:关键字
|
||||
* @return fund:fund
|
||||
* @return sort:权重
|
||||
* @return pub_date:发表日期
|
||||
*/
|
||||
public function getArticleBase(){
|
||||
$data = $this->request->post();
|
||||
$article = $this->article_obj->where('article_id',$data['article_id'])->find();
|
||||
return json(['code'=>0,'msg'=>'success','data'=>$article]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 编辑文章基本信息
|
||||
* @description 编辑文章基本信息
|
||||
* @author wangjinleichang
|
||||
* @url /master/Article/editArticleBase
|
||||
* @method POST
|
||||
*
|
||||
* @param name:article_id type:int require:1 desc:文章id
|
||||
* @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: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: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['tradition_tag'] = $data['tradition_tag'];
|
||||
$updata['tradition'] = $data['tradition'];
|
||||
$updata['doi'] = $data['doi'];
|
||||
$updata['abstract'] = $data['abstract'];
|
||||
$updata['keywords'] = $data['keywords'];
|
||||
$updata['fund'] = $data['fund'];
|
||||
$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 获取文章列表
|
||||
@@ -86,6 +305,7 @@ class Article extends Controller {
|
||||
*
|
||||
* @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:单页数据条数
|
||||
@@ -95,11 +315,20 @@ class Article extends Controller {
|
||||
*/
|
||||
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['state'] = 0;
|
||||
if($data['journal_id']!==0){
|
||||
if(intval($data['journal_id'])!==0){
|
||||
$where['journal_id'] = $data['journal_id'];
|
||||
}else{
|
||||
$journals = $this->journal_obj->where('editor_id',$data['editor_id'])->column('journal_id');
|
||||
$where['journal_id'] = ['in',$journals];
|
||||
}
|
||||
if($data['journal_stage_id']!==0){
|
||||
if(intval($data['journal_stage_id'])!==0){
|
||||
$where['journal_stage_id'] = $data['journal_stage_id'];
|
||||
}
|
||||
if(isset($data['seach'])&&$data['seach']!=''){
|
||||
@@ -111,5 +340,42 @@ class Article extends Controller {
|
||||
return json(['code'=>0,'msg'=>'success','data'=>['count'=>$count,'articleList'=>$article_list]]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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/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]]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user