首页加载速度慢方法调整
This commit is contained in:
@@ -513,54 +513,114 @@ class Ucenter extends Base{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// private function getAsAuthorNew($userId){
|
||||||
|
// $user_info = $this->user_obj->where("user_id",$userId)->find();
|
||||||
|
// $flag = [];
|
||||||
|
// //推荐总数
|
||||||
|
// if($user_info['code']!=''){
|
||||||
|
// $tj_num = $this->article_obj->where("code",$user_info['code'])->count();
|
||||||
|
// }else{
|
||||||
|
// $tj_num = 0 ;
|
||||||
|
// }
|
||||||
|
// $flag['tj'] = $tj_num;
|
||||||
|
|
||||||
|
// //获取作为提交者的文章
|
||||||
|
// $ids1 = $this->article_obj->where("t_article.user_id",$userId)->column("article_id");
|
||||||
|
|
||||||
|
// //获取作为作者的文章
|
||||||
|
// $ids2 = $this->article_author_obj->where("email",$user_info['email'])->where("state",0)->column("article_id");
|
||||||
|
|
||||||
|
// $ids = array_unique(array_merge($ids1,$ids2));
|
||||||
|
// $articles = $this->article_obj
|
||||||
|
// ->field("t_article.*,t_journal.title as journal_title,t_journal.abbr")
|
||||||
|
// ->join("t_journal","t_journal.journal_id = t_article.journal_id","left")
|
||||||
|
// ->whereIn("t_article.article_id",$ids)
|
||||||
|
// ->select();
|
||||||
|
|
||||||
|
// foreach ($articles as $k => $v){
|
||||||
|
// $role = [];
|
||||||
|
// if($v['user_id'] == $user_info['user_id']){
|
||||||
|
// $role[] = "user";
|
||||||
|
// }
|
||||||
|
// $author_check = $this->article_author_obj->where("email",$user_info['email'])->where("article_id",$v['article_id'])->where("state",0)->find();
|
||||||
|
// if($author_check){
|
||||||
|
// $role[] = "author";
|
||||||
|
// }
|
||||||
|
// $articles[$k]['role'] = $role;
|
||||||
|
// if($v['state']==5){
|
||||||
|
// $check = $this->production_article_obj->where("article_id",$v['article_id'])->where("state",2)->find();
|
||||||
|
// if($check){
|
||||||
|
// $articles[$k]['link'] = "https://doi.org/10.53388/".$check['doi'];
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// $flag['articles'] = $articles;
|
||||||
|
|
||||||
|
// return $flag;
|
||||||
|
// }
|
||||||
private function getAsAuthorNew($userId){
|
private function getAsAuthorNew($userId){
|
||||||
$user_info = $this->user_obj->where("user_id",$userId)->find();
|
$user_info = $this->user_obj->where("user_id",$userId)->find();
|
||||||
$flag = [];
|
$flag = [];
|
||||||
//推荐总数
|
//推荐总数
|
||||||
|
$tj_num = 0 ;
|
||||||
if($user_info['code']!=''){
|
if($user_info['code']!=''){
|
||||||
$tj_num = $this->article_obj->where("code",$user_info['code'])->count();
|
$tj_num = $this->article_obj->where("code",$user_info['code'])->count();
|
||||||
}else{
|
|
||||||
$tj_num = 0 ;
|
|
||||||
}
|
}
|
||||||
$flag['tj'] = $tj_num;
|
$flag['tj'] = $tj_num;
|
||||||
|
|
||||||
//获取作为提交者的文章
|
//获取作为提交者的文章
|
||||||
$ids1 = $this->article_obj->where("t_article.user_id",$userId)->column("article_id");
|
$ids1 = $this->article_obj->where("t_article.user_id",$userId)->column("article_id");
|
||||||
|
|
||||||
//获取作为作者的文章
|
//获取作为作者的文章
|
||||||
$ids2 = $this->article_author_obj->where("email",$user_info['email'])->where("state",0)->column("article_id");
|
$ids2 = $this->article_author_obj->where("email",$user_info['email'])->where("state",0)->column("article_id");
|
||||||
|
//文章ID合并
|
||||||
$ids = array_unique(array_merge($ids1,$ids2));
|
$ids = array_unique(array_merge($ids1,$ids2));
|
||||||
$articles = $this->article_obj
|
|
||||||
|
$flag['articles'] = [];
|
||||||
|
|
||||||
|
if(empty($ids)){
|
||||||
|
return $flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
//查询文章信息
|
||||||
|
$aArticle = $aAuthor = $aProductionArticle = [];
|
||||||
|
$aChunksId = array_chunk($ids, 1000);
|
||||||
|
foreach ($aChunksId as $value) {
|
||||||
|
$articles = $this->article_obj
|
||||||
->field("t_article.*,t_journal.title as journal_title,t_journal.abbr")
|
->field("t_article.*,t_journal.title as journal_title,t_journal.abbr")
|
||||||
->join("t_journal","t_journal.journal_id = t_article.journal_id","left")
|
->join("t_journal","t_journal.journal_id = t_article.journal_id","left")
|
||||||
->whereIn("t_article.article_id",$ids)
|
->whereIn("article_id",$value)
|
||||||
->select();
|
->select();
|
||||||
|
if(!empty($articles)){
|
||||||
|
//查询生产文章主表
|
||||||
|
$aArticleId = array_column($articles, 'article_id');
|
||||||
|
$aProductionArticleInfo = $this->production_article_obj->field('article_id,doi')->whereIn("article_id",$aArticleId)->where("state",2)->column('doi','article_id');
|
||||||
|
if(!empty($aProductionArticleInfo)){
|
||||||
|
$aProductionArticle = array_merge($aProductionArticle,$aProductionArticleInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$aArticle = array_merge($aArticle,$articles);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
foreach ($articles as $k => $v){
|
//数据处理
|
||||||
|
foreach ($aArticle as $k => $v){
|
||||||
$role = [];
|
$role = [];
|
||||||
if($v['user_id'] == $user_info['user_id']){
|
if($v['user_id'] == $user_info['user_id']){
|
||||||
$role[] = "user";
|
$role[] = "user";
|
||||||
}
|
}
|
||||||
$author_check = $this->article_author_obj->where("email",$user_info['email'])->where("article_id",$v['article_id'])->where("state",0)->find();
|
if(!empty($ids2) && in_array($v['article_id'], $ids2)){
|
||||||
if($author_check){
|
|
||||||
$role[] = "author";
|
$role[] = "author";
|
||||||
}
|
}
|
||||||
$articles[$k]['role'] = $role;
|
$articles[$k]['role'] = $role;
|
||||||
if($v['state']==5){
|
if($v['state']==5 && !empty($aProductionArticle[$v['article_id']])){
|
||||||
$check = $this->production_article_obj->where("article_id",$v['article_id'])->where("state",2)->find();
|
$articles[$k]['link'] = empty($aProductionArticle[$v['article_id']]) ? '' : "https://doi.org/10.53388/".$aProductionArticle[$v['article_id']];
|
||||||
if($check){
|
|
||||||
$articles[$k]['link'] = "https://doi.org/10.53388/".$check['doi'];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$flag['articles'] = $articles;
|
$flag['articles'] = $articles;
|
||||||
|
|
||||||
return $flag;
|
return $flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function getMajor(){
|
public function getMajor(){
|
||||||
$data = $this->request->post();
|
$data = $this->request->post();
|
||||||
$rule = new Validate([
|
$rule = new Validate([
|
||||||
|
|||||||
Reference in New Issue
Block a user