1
This commit is contained in:
@@ -685,6 +685,117 @@ class Article extends Base
|
||||
}
|
||||
}
|
||||
|
||||
/**获取关联作者的信息
|
||||
* @return \think\response\Json|void
|
||||
*/
|
||||
public function getRelationAuthor(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
"user_id"=>"require"
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$user_info = $this->user_obj->where("user_id",$data['user_id'])->find();
|
||||
$authors = $this->article_obj->field("t_article_author.*")->join("t_article_author","t_article_author.article_id = t_article.article_id","left")
|
||||
->where("t_article.user_id",$data['user_id'])->where("t_article_author.state",0)
|
||||
->order("t_article_author.email,t_article_author.art_aut_id")->select();
|
||||
$cache_author = [];
|
||||
foreach ($authors as $k=>$v){
|
||||
if(!isset($v['email'])||$v['email']==""){
|
||||
continue;
|
||||
}
|
||||
$cache_author[$v['email']][] = $v;
|
||||
}
|
||||
$authors = [];
|
||||
foreach ($cache_author as $k => $v){
|
||||
$c = [];
|
||||
$c['email'] = $k;
|
||||
foreach ($v as $value){
|
||||
if($value['firstname']!=""){
|
||||
$c['firstname'] = $value['firstname'];
|
||||
}
|
||||
if($value['lastname']!=""){
|
||||
$c['lastname'] = $value['lastname'];
|
||||
}
|
||||
if($value['company']!=""){
|
||||
$c['company'] = $value['company'];
|
||||
}
|
||||
if($value['department']!=""){
|
||||
$c['department'] = $value['department'];
|
||||
}
|
||||
if($value['author_title']!=""){
|
||||
$c['author_title'] = $value['author_title'];
|
||||
}
|
||||
if($value['country']!=""){
|
||||
$c['country'] = $value['country'];
|
||||
}
|
||||
if($value['address']!=""){
|
||||
$c['address'] = $value['address'];
|
||||
}
|
||||
}
|
||||
$authors[] = $c;
|
||||
}
|
||||
$re['authors'] = $authors;
|
||||
return jsonSuccess($re);
|
||||
}
|
||||
|
||||
|
||||
/**通过邮件地址获取相关作者信息
|
||||
* @return void
|
||||
*/
|
||||
public function getRelationAuthorByEmail(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
"email"=>"require",
|
||||
"page"=>"require",
|
||||
"limit"=>"require"
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$es = explode("@",$data['email']);
|
||||
if($es==""){
|
||||
return jsonError("Email error");
|
||||
}
|
||||
$emails = $this->article_author_obj->field("email")->where("email","like","%".$data['email']."%")->where('state',0)->group("email")->page($data['page'],$data['limit'])->select();
|
||||
$count = $this->article_author_obj->field("email")->where("email","like","%".$data['email']."%")->where('state',0)->group("email")->count();
|
||||
$authors = [];
|
||||
foreach ($emails as $v){
|
||||
$c = [];
|
||||
$c['email'] = $v['email'];
|
||||
$cl = $this->article_author_obj->where("email",$v['email'])->where('state',0)->select();
|
||||
foreach ($cl as $value){
|
||||
if($value['firstname']!=""){
|
||||
$c['firstname'] = $value['firstname'];
|
||||
}
|
||||
if($value['lastname']!=""){
|
||||
$c['lastname'] = $value['lastname'];
|
||||
}
|
||||
if($value['company']!=""){
|
||||
$c['company'] = $value['company'];
|
||||
}
|
||||
if($value['department']!=""){
|
||||
$c['department'] = $value['department'];
|
||||
}
|
||||
if($value['author_title']!=""){
|
||||
$c['author_title'] = $value['author_title'];
|
||||
}
|
||||
if($value['country']!=""){
|
||||
$c['country'] = $value['country'];
|
||||
}
|
||||
if($value['address']!=""){
|
||||
$c['address'] = $value['address'];
|
||||
}
|
||||
}
|
||||
$authors[] = $c;
|
||||
}
|
||||
|
||||
$re['authors'] = $authors;
|
||||
$re['count'] = $count;
|
||||
return jsonSuccess($re);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全部作者反馈审稿人文件列表
|
||||
*/
|
||||
@@ -1973,6 +2084,151 @@ class Article extends Base
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**添加作者
|
||||
* @return void
|
||||
*/
|
||||
public function addAuthor(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
"article_id"=>"require",
|
||||
"firstname"=>"require",
|
||||
"lastname"=>"require",
|
||||
"email"=>"require",
|
||||
"country"=>"require",
|
||||
"isSuper"=>"require",
|
||||
"isReport"=>"require"
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$max = $this->article_author_obj->where("article_id",$data['article_id'])->where("state",0)->max("sort");
|
||||
$insert['article_id'] = $data['article_id'];
|
||||
$insert['sort'] = $max+1;
|
||||
$insert['firstname'] = trim($data['firstname']);
|
||||
$insert['lastname'] = trim($data['lastname']);
|
||||
$insert['email'] = trim($data['email']);
|
||||
$insert['country'] = trim($data['country']);
|
||||
$insert['is_super'] = $data['isSuper'] == 'true' ? 1 : 0;
|
||||
$insert['is_report'] = $data['isReport'] == 'true' ? 1 : 0;
|
||||
$insert['author_title'] = isset($data['title'])?trim($data["title"]):"";
|
||||
$insert['company'] = isset($data['company'])?trim($data['company']):"";
|
||||
$insert['department'] = isset($data['department'])?trim($data['department']):"";
|
||||
$insert['address'] = isset($data['address'])?trim($data['address']):"";
|
||||
$this->article_author_obj->insert($insert);
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
public function editAuthor(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
"art_aut_id"=>"require",
|
||||
"article_id"=>"require",
|
||||
"firstname"=>"require",
|
||||
"lastname"=>"require",
|
||||
"email"=>"require",
|
||||
"country"=>"require",
|
||||
"isSuper"=>"require",
|
||||
"isReport"=>"require",
|
||||
"title"=>"require"
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$insert['article_id'] = $data['article_id'];
|
||||
$insert['firstname'] = trim($data['firstname']);
|
||||
$insert['lastname'] = trim($data['lastname']);
|
||||
$insert['email'] = trim($data['email']);
|
||||
$insert['country'] = trim($data['country']);
|
||||
$insert['is_super'] = $data['isSuper'] == 'true' ? 1 : 0;
|
||||
$insert['is_report'] = $data['isReport'] == 'true' ? 1 : 0;
|
||||
$insert['author_title'] = trim($data["title"]);
|
||||
$insert['company'] = isset($data['company'])?trim($data['company']):"";
|
||||
$insert['department'] = isset($data['department'])?trim($data['department']):"";
|
||||
$insert['address'] = isset($data['address'])?trim($data['address']):"";
|
||||
$this->article_author_obj->where("art_aut_id",$data['art_aut_id'])->update($insert);
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getAuthors(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
"article_id"=>"require"
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$authors = $this->article_author_obj->where("article_id",$data["article_id"])->where("state",0)->order("sort")->select();
|
||||
$re['authors'] = $authors;
|
||||
return jsonSuccess($re);
|
||||
}
|
||||
|
||||
/**上调文章作者顺序
|
||||
* @return void
|
||||
*/
|
||||
public function upAuthors(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
"art_aut_id"=>"require"
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$info = $this->article_author_obj->where("art_aut_id",$data['art_aut_id'])->find();
|
||||
if($info['sort']<2){
|
||||
return jsonError("fail");
|
||||
}
|
||||
$info_1 = $this->article_author_obj->where("article_id",$info['article_id'])->where("state",0)->where("sort",$info['sort']-1)->find();
|
||||
$this->article_author_obj->where("art_aut_id",$info['art_aut_id'])->setDec("sort");
|
||||
$this->article_author_obj->where("art_aut_id",$info_1['art_aut_id'])->setInc("sort");
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
/**下调文章作者顺序
|
||||
* @return \think\response\Json|void
|
||||
*/
|
||||
public function downAuthors(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
"art_aut_id"=>"require"
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$info = $this->article_author_obj->where("art_aut_id",$data['art_aut_id'])->find();
|
||||
$info_1 = $this->article_author_obj->where("article_id",$info['article_id'])->where("state",0)->where("sort",$info['sort']+1)->find();
|
||||
if($info_1==null){
|
||||
return jsonError("fail");
|
||||
}
|
||||
$this->article_author_obj->where("art_aut_id",$info['art_aut_id'])->setInc("sort");
|
||||
$this->article_author_obj->where("art_aut_id",$info_1['art_aut_id'])->setDec("sort");
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function delAuthor(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
"art_aut_id"=>"require"
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$info = $this->article_author_obj->where("art_aut_id",$data['art_aut_id'])->find();
|
||||
//大于此条的sort都减一
|
||||
$this->article_author_obj->where("article_id",$info['article_id'])->where("sort",">",$info['sort'])->setDec("sort");
|
||||
$this->article_author_obj->where("art_aut_id",$data['art_aut_id'])->update(['state'=>1]);
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取已暂存的文章列表
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user