1
This commit is contained in:
@@ -32,7 +32,7 @@ class Preaccept extends Base
|
||||
if($production_info==null){
|
||||
return jsonError("Object is null");
|
||||
}
|
||||
$list = $this->production_article_refer_obj->where("p_article_id",$production_info['p_article_id'])->where('state',0)->select();
|
||||
$list = $this->production_article_refer_obj->where("p_article_id",$production_info['p_article_id'])->where('state',0)->order("index")->select();
|
||||
|
||||
$re["refers"] = $list;
|
||||
return jsonSuccess($re);
|
||||
@@ -59,6 +59,116 @@ class Preaccept extends Base
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
/**添加refer
|
||||
* @return \think\response\Json
|
||||
* @throws \think\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function addRefer(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
"article_id"=>"require",
|
||||
"pre_p_refer_id"=>"require",
|
||||
"doi"=>"require"
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$p_info = $this->production_article_obj->where('article_id',$data['article_id'])->where('state',0)->find();
|
||||
$pre_refer = $this->production_article_refer_obj->where('p_refer_id',$data['pre_p_refer_id'])->find();
|
||||
$this->production_article_refer_obj->where('p_article_id',$p_info['p_article_id'])->where("index",">",$pre_refer['index'])->where('state',0)->setInc('index');
|
||||
$insert['p_article_id'] = $p_info['p_article_id'];
|
||||
$insert['refer_doi'] = $data['doi'];
|
||||
$insert['index'] = $pre_refer['index']+1;
|
||||
$insert['ctime'] = time();
|
||||
$adId = $this->production_article_refer_obj->insertGetId($insert);
|
||||
my_doiToFrag2($this->production_article_refer_obj->where('p_refer_id',$adId)->find());
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
/**删除refer
|
||||
* @return \think\response\Json
|
||||
* @throws \think\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public function delRefer(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
"p_refer_id"=>"require"
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$refer_info = $this->production_article_refer_obj->where('p_refer_id',$data['p_refer_id'])->find();
|
||||
$this->production_article_refer_obj->where('p_refer_id',$data['p_refer_id'])->where('index',">",$refer_info['index'])->setDec('index');
|
||||
$this->production_article_refer_obj->where('p_refer_id',$data['p_refer_id'])->update(['state'=>1]);
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
/**编辑refer
|
||||
* @return \think\response\Json
|
||||
* @throws \think\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public function editRefer(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
"p_refer_id"=>"require",
|
||||
"doi"=>"require"
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$this->production_article_refer_obj->where('p_refer_id',$data['p_refer_id'])->update(['refer_doi'=>$data['doi']]);
|
||||
my_doiToFrag2($this->production_article_refer_obj->where('p_refer_id',$data['p_refer_id'])->find());
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
/**调整refer排序
|
||||
* @return \think\response\Json
|
||||
* @throws \think\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function sortRefer(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
"p_refer_id"=>"require",
|
||||
"act"=>"require"
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$refer_info = $this->production_article_refer_obj->where('p_refer_id',$data['p_refer_id'])->find();
|
||||
if($data['act']=="up"){
|
||||
$up_info = $this->production_article_refer_obj->where('p_article_id',$refer_info['p_article_id'])->where('index',$refer_info['index']-1)->find();
|
||||
if(!$up_info){
|
||||
return jsonError("system error");
|
||||
}
|
||||
$this->production_article_refer_obj->where('p_refer_id',$up_info['p_refer_id'])->setInc("index");
|
||||
$this->production_article_refer_obj->where('p_refer_id',$refer_info['p_refer_id'])->setDec("index");
|
||||
}else{
|
||||
$down_info = $this->production_article_refer_obj->where('p_article_id',$refer_info['p_article_id'])->where('index',$refer_info['index']+1)->find();
|
||||
if(!$down_info){
|
||||
return jsonError("system error");
|
||||
}
|
||||
$this->production_article_refer_obj->where('p_refer_id',$refer_info['p_refer_id'])->setInc("index");
|
||||
$this->production_article_refer_obj->where('p_refer_id',$down_info['p_refer_id'])->setDec("index");
|
||||
}
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function addRefersByExcel(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
@@ -74,12 +184,14 @@ class Preaccept extends Base
|
||||
}
|
||||
$file = ROOT_PATH . 'public' . DS . "referFile".DS.$data['referFile'];
|
||||
$list = $this->readRefersExcel($file);
|
||||
foreach ($list as $v){
|
||||
foreach ($list as $k=> $v){
|
||||
$ca['p_article_id'] = $production_info['p_article_id'];
|
||||
$ca['refer_content'] = $v['content'];
|
||||
$ca['refer_doi'] = $v['doi'];
|
||||
$ca['index'] = $k;
|
||||
$ca['ctime'] = time();
|
||||
$this->production_article_refer_obj->insert($ca);
|
||||
$adId=$this->production_article_refer_obj->insertGetId($ca);
|
||||
my_doiToFrag2($this->production_article_refer_obj->where('p_refer_id',$adId)->find());
|
||||
}
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
@@ -117,7 +229,7 @@ class Preaccept extends Base
|
||||
|
||||
|
||||
|
||||
/**上传引用文献文件
|
||||
/**上传引用文献文件,并返回读取到的内容
|
||||
* @return \think\response\Json|void
|
||||
*/
|
||||
public function up_refer_file(){
|
||||
|
||||
Reference in New Issue
Block a user