user_obj = Db::name('user'); $this->user_act_obj = Db::name('user_act'); $this->article_obj = Db::name('article'); $this->journal_obj = Db::name('journal'); $this->user_log_obj = Db::name('user_log'); $this->user_reviewer_info_obj = Db::name("user_reviewer_info"); $this->reviewer_major_obj = Db::name('reviewer_major'); $this->reviewer_to_journal_obj = Db::name('reviewer_to_journal'); $this->article_reviewer_question_obj = Db::name('article_reviewer_question'); $this->article_msg_obj = Db::name('article_msg'); $this->article_file_obj = Db::name('article_file'); $this->article_reviewer_obj = Db::name('article_reviewer'); $this->article_author_obj = Db::name('article_author'); $this->article_transfer_obj = Db::name('article_transfer'); $this->chief_to_journal_obj = Db::name('chief_to_journal'); $this->login_auto_obj = Db::name('login_auto'); $this->major_obj = Db::name("major"); $this->major_to_journal_obj = Db::name('major_to_journal'); $this->reviewer_from_author_obj = Db::name("reviewer_from_author"); $this->article_dialog_obj = Db::name('article_dialog'); $this->article_proposal_obj = Db::name('article_proposal'); $this->user_black_obj = Db::name('user_black'); $this->user_reviewer_recommend_obj = Db::name('user_reviewer_recommend'); $this->ts_obj = Db::name('ts'); $this->ts_refer_obj = Db::name('ts_refer'); $this->ts_frag_obj = Db::name('ts_frag'); $this->online_obj = Db::name('online'); $this->production_article_obj = Db::name('production_article'); $this->production_article_author_obj = Db::name('production_article_author'); $this->production_article_organ_obj = Db::name('production_article_organ'); $this->production_article_refer_obj = Db::name('production_article_refer'); $this->production_article_author_to_organ_obj = Db::name('production_article_author_to_organ'); } /** * 添加生产实例 */ public function addProduction(){ $data = $this->request->post(); $rule = new Validate([ 'article_id'=>'require|number' ]); if(!$rule->check($data)){ return jsonError($rule->getError()); } $check = $this->production_article_obj->where('article_id',$data['article_id'])->where('state',0)->find(); if($check){ return jsonError($rule->getError()); } $article_info = $this->article_obj->where('article_id',$data['article_id'])->find(); $insert['article_id'] = $data['article_id']; $insert['journal_id'] = $article_info['journal_id']; $insert['ctime'] = time(); $this->production_article_obj->insert($insert); return jsonSuccess([]); } /** * 删除生产实例 */ public function delProduction(){ $data = $this->request->post(); $rule = new Validate([ 'p_article_id'=>'require|number' ]); if(!$rule->check($data)){ return jsonError($rule->getError()); } $this->production_article_obj->where('p_article_id',$data['p_article_id'])->update(['state'=>1]); return jsonSuccess([]); } /** * 编辑生产实例 */ public function editProduction(){ $data = $this->request->post(); $rule = new Validate([ 'p_article_id'=>'require|number', 'title'=>'require', 'subtitle'=>'require', 'type'=>'require', 'icon'=>'require', 'tradition_tag'=>'require', 'tradition'=>'require', 'doi'=>'require', 'abstract'=>'require', 'keywords'=>'require', 'fund'=>'require', 'abbr'=>'require', 'pub_date'=>'require', ]); if(!$rule->check($data)){ return jsonError($rule->getError()); } $update['title'] = trim($data['title']); $update['subtitle'] = trim($data['subtitle']); $update['type'] = trim($data['type']); $update['icon'] = trim($data['icon']); $update['tradition_tag'] = trim($data['tradition_tag']); $update['tradition'] = trim($data['tradition']); $update['mhoo'] = isset($data['mhoo'])?trim($data['mhoo']):''; $update['doi'] = trim($data['doi']); $update['abstract'] = trim($data['abstract']); $update['keywords'] = trim($data['keywords']); $update['fund'] = trim($data['fund']); $update['abbr'] = trim($data['abbr']); $update['pub_date'] = trim($data['pub_date']); $update['npp'] = $data['npp']; $this->production_article_obj->where('p_article_id',$data['p_article_id'])->update($update); return jsonSuccess([]); } /** * 获取生产实例列表 */ public function getProductionList(){ $data = $this->request->post(); $rule = new Validate([ 'editor_id'=>'require|number', 'journal_id'=>'require', 'pageIndex' => 'require', 'pageSize' => 'require' ]); if(!$rule->check($data)){ return jsonError($rule->getError()); } $journalids = []; if($data['journal_id']==0){ $journalids = $this->journal_obj->where('editor_id',$data['editor_id'])->column('journal_id'); } $limit_start = ($data['pageIndex'] - 1) * $data['pageSize']; $list = $this->production_article_obj->where('journal_id','in',$journalids)->where('state',0)->limit($limit_start,$data['pageSize'])->select(); $count = $this->production_article_obj->where('journal_id','in',$journalids)->where('state',0)->count(); $re['productions'] = $list; $re['count'] = $count; return jsonSuccess($re); } /** * 获取生产实例列表 */ public function getProductionDetail(){ $data = $this->request->post(); $rule = new Validate([ 'p_article_id'=>'require|number' ]); if(!$rule->check($data)){ return jsonError($rule->getError()); } $p_info = $this->production_article_obj->where('p_article_id',$data['p_article_id'])->find(); } /** * 添加作者机构 */ public function addAuthorOrgan(){ $data = $this->request->post(); $rule = new Validate([ 'p_article_id'=>'require|number', 'organ_name'=>'require' ]); if(!$rule->check($data)){ return jsonError($rule->getError()); } $p_info = $this->production_article_obj->where('p_article_id',$data['p_article_id'])->find(); $insert['p_article_id'] = $data['p_article_id']; $insert['article_id'] = $p_info['article_id']; $insert['organ_name'] = trim($data['organ_name']); $this->production_article_organ_obj->insert($insert); return jsonSuccess([]); } /** * 删除作者机构 */ public function delAuthorOrgan(){ $data = $this->request->post(); $rule = new Validate([ 'p_article_organ_id'=>'require|number' ]); if(!$rule->check($data)){ return jsonError($rule->getError()); } $this->production_article_organ_obj->where('p_article_organ_id',$data['p_article_organ_id'])->update(['state'=>1]); return jsonSuccess([]); } /** * 编辑作者机构信息 */ public function editAuthorOrgan(){ $data = $this->request->post(); $rule = new Validate([ 'p_article_organ_id'=>'require|number', 'organ_name'=>'require' ]); if(!$rule->check($data)){ return jsonError($rule->getError()); } $this->production_article_organ_obj->where('p_article_organ_id',$data['p_article_organ_id'])->update(['organ_name'=>$data['organ_name']]); return jsonSuccess([]); } /** * 获取机构列表 */ public function getOrganList(){ $data = $this->request->post(); $rule = new Validate([ 'p_article_id'=>'require|number' ]); if(!$rule->check($data)){ return jsonError($rule->getError()); } $list = $this->production_article_organ_obj->where('p_article_id',$data['p_article_id'])->where('state',0)->select(); $re['organs'] = $list; return jsonSuccess($re); } /** * 添加作者 */ public function addAuthor(){ $data = $this->request->post(); $rule = new Validate([ 'p_article_id'=>'require|number', 'first_name'=>'require', 'last_name'=>'require', 'author_country'=>'require', 'is_first'=>'require', 'is_report'=>'require' ]); if(!$rule->check($data)){ return jsonError($rule->getError()); } $p_info = $this->production_article_obj->where('p_article_id',$data['p_article_id'])->find(); $insert['p_article_id'] = $data['p_article_id']; $insert['article_id'] = $p_info['article_id']; $insert['author_name'] = $data['first_name'].' '.$data['last_name']; $insert['first_name'] = $data['first_name']; $insert['last_name'] = $data['las_name']; $insert['orcid'] = isset($data['orcid'])?$data['orcid']:''; $insert['author_country'] = $data['author_country']; $insert['is_first'] = $data['is_first']; $insert['is_report'] = $data['is_report']; $insert['email'] = isset($data['email'])?trim($data['email']):''; Db::startTrans(); $pa_id = $this->production_article_author_obj->insertGetId($insert); $or_res = true; if (isset($data['organs']) && is_array($data['organs'])) { foreach ($data['organs'] as $v) { $cache_ins['p_article_id'] = $data['p_article_id']; $cache_ins['p_article_author_id'] = $pa_id; $cache_ins['p_article_organ_id'] = $v; $or_res = $this->production_article_author_to_organ_obj->insert($cache_ins) ? true : false; } } if ($pa_id && $or_res) { Db::commit(); return jsonSuccess([]); } else { Db::rollback(); return jsonError("system error"); } } /** * 删除作者 */ public function delAuthor(){ $data = $this->request->post(); $rule = new Validate([ 'p_article_author_id'=>'require' ]); if(!$rule->check($data)){ return jsonError($rule->getError()); } $this->production_article_author_obj->where('p_article_author_id',$data['p_artice_author_id'])->update(['state'=>1]); return jsonSuccess([]); } /** * 获取作者列表 */ public function getAuthorlist(){ $data = $this->request->post(); $rule = new Validate([ 'p_article_id'=>'require' ]); if(!$rule->check($data)){ return jsonError($rule->getError()); } $list = $this->production_article_author_obj->where('p_article_id',$data['p_article_id'])->where('state',0)->select(); foreach($list as $k => $v){ $list[$k]['organs'] = $this->production_article_author_to_organ_obj ->field("t_production_article_organ.*") ->join("t_production_article_organ",'t_production_article_organ.p_article_organ_id = t_production_article_author_to_organ.p_article_organ_id','left') ->where('p_article_author_id',$v['p_article_author_id']) ->select(); } $re['authors'] = $list; return jsonSuccess($re); } /** * 上传文件 */ public function up_file(){ $file = request()->file('pdf'); if ($file) { $info = $file->move(ROOT_PATH . 'public' . DS . 'pdf'); if ($info) { return json(['code' => 0, 'upurl' => str_replace("\\", "/", $info->getSaveName())]); } else { return json(['code' => 1, 'msg' => $file->getError()]); } } } }