1
This commit is contained in:
@@ -7,6 +7,7 @@ use think\Db;
|
||||
use think\captcha;
|
||||
use think\Cache;
|
||||
use think\Env;
|
||||
use think\Loader;
|
||||
use think\Queue;
|
||||
use think\Validate;
|
||||
|
||||
@@ -156,6 +157,7 @@ class User extends Controller
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
'user_id'=>'require',
|
||||
'realname'=>'require',
|
||||
'wos_index'=>'require',
|
||||
'google_index'=>'require'
|
||||
]);
|
||||
@@ -172,6 +174,8 @@ class User extends Controller
|
||||
$updata['google_index'] = $data['google_index'];
|
||||
$updata['google_time'] = time();
|
||||
}
|
||||
$updata['realname'] = trim($data['realname']);
|
||||
$updata['localname'] = trim($data['localname']);
|
||||
if(count($updata)>0){
|
||||
$this->user_obj->where('user_id',$data['user_id'])->update($updata);
|
||||
}
|
||||
@@ -188,6 +192,7 @@ class User extends Controller
|
||||
* @param name:pageIndex type:int require:1 desc:当前页码数
|
||||
* @param name:pageSize type:int require:1 desc:单页数据条数
|
||||
* @param name:username type:string require:1 desc:用户名或邮箱
|
||||
* @param name:role type:string require:1 desc:0:全部1:editor2:reviewer3:board
|
||||
*
|
||||
* @return users:用户列表#
|
||||
* @return count:总数
|
||||
@@ -195,17 +200,45 @@ class User extends Controller
|
||||
public function getAllUser()
|
||||
{
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
'pageIndex'=>'require',
|
||||
'pageSize'=>'require',
|
||||
'role'=>'require'
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
|
||||
$black_list = $this->user_black_obj->where('black_state', 0)->column("user_id");
|
||||
$frag = [];
|
||||
$count = 0;
|
||||
if ($data['username'] == "") {
|
||||
$frag = $this->user_obj->where('state', 0)->where("user_id", "not in", $black_list)->limit($limit_start, $data['pageSize'])->select();
|
||||
$count = $this->user_obj->where('state', 0)->where("user_id", "not in", $black_list)->count();
|
||||
} else {
|
||||
$frag = $this->user_obj->where('state', 0)->where("user_id", "not in", $black_list)->where("account|email", 'like', '%' . trim($data['username'] . '%'))->limit($limit_start, $data['pageSize'])->select();
|
||||
$count = $this->user_obj->where('state', 0)->where("user_id", "not in", $black_list)->where("account|email", 'like', '%' . trim($data['username'] . '%'))->count();
|
||||
$where = [];
|
||||
$where['state'] = 0;
|
||||
// $where['user_id'] = ['not in',$black_list];
|
||||
if ($data['username'] != "") {
|
||||
$where["account|email"] = ['like','%' . trim($data['username'] . '%')];
|
||||
}
|
||||
if($data['role']==1){
|
||||
$where['type'] = 2;
|
||||
}elseif($data['role']==2){
|
||||
$c = $this->reviewer_to_journal_obj->where('state',0)->column('reviewer_id');
|
||||
$where['user_id'] = ['in',$c];
|
||||
}elseif($data['role']==3){
|
||||
$cc = $this->board_to_journal_obj->where('state',0)->column('user_id');
|
||||
$where['user_id'] = ['in',$cc];
|
||||
}
|
||||
|
||||
|
||||
if(isset($where['user_id'])){
|
||||
$where['user_id'] = [['not in',$black_list],$where['user_id']];
|
||||
}else{
|
||||
$where['user_id'] = ['not in',$black_list];
|
||||
}
|
||||
|
||||
$frag = $this->user_obj->where($where)->limit($limit_start, $data['pageSize'])->select();
|
||||
$count = $this->user_obj->where($where)->count();
|
||||
|
||||
|
||||
foreach ($frag as $k => $v) {
|
||||
$frag[$k]['roles'] = $this->getUserRoles($v['account']);
|
||||
}
|
||||
@@ -444,6 +477,11 @@ class User extends Controller
|
||||
$specials[] = $cache_info;
|
||||
}
|
||||
|
||||
//如果是审稿人的,获取期审稿人的附加信息
|
||||
$reviewer_info = $this->user_reviewer_info_obj->where('reviewer_id',$data['user_id'])->where('state',0)->find();
|
||||
if($reviewer_info){
|
||||
$user_info['company'] = $reviewer_info['company'];
|
||||
}
|
||||
$user_info['specials'] = $specials;
|
||||
$re['user'] = $user_info;
|
||||
return jsonSuccess($re);
|
||||
@@ -514,6 +552,155 @@ class User extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 谷歌测试
|
||||
*/
|
||||
public function googleTest(){
|
||||
Loader::import("google.google-search-results");
|
||||
Loader::import("google.restclient");
|
||||
// require 'path/to/google-search-results.php';
|
||||
// require 'path/to/restclient.php';
|
||||
|
||||
// $query = [
|
||||
// "engine" => "google_scholar",
|
||||
// "q" => "biology",
|
||||
// ];
|
||||
// $query = [
|
||||
// "engine" => "google_scholar_author",
|
||||
// "author_id" => "YrGbzsEAAAAJ",
|
||||
// ];
|
||||
|
||||
$query = [
|
||||
"engine" => "google_scholar_profiles",
|
||||
"mauthors" => "biol",
|
||||
];
|
||||
|
||||
$search = new \GoogleSearch('7651ca6caf949b0ac6ce28a95f3d2e9d8ee51b024ba7fad86f0298fb84290765');
|
||||
$result = $search->get_json($query);
|
||||
// $organic_results = $result->organic_results;
|
||||
$organic_results = $result;
|
||||
dump($organic_results);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取google学术人物列表
|
||||
*/
|
||||
public function googleGetAuthor(){
|
||||
$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();
|
||||
if($user_info['g_author']!=''||$user_info['realname']==''){
|
||||
return jsonError('Google account is tied/Please tied your realname first before proceeding to the next step');
|
||||
}
|
||||
Loader::import("google.google-search-results");
|
||||
Loader::import("google.restclient");
|
||||
|
||||
$query = [
|
||||
"engine" => "google_scholar_profiles",
|
||||
"mauthors" => $user_info['realname'],
|
||||
];
|
||||
|
||||
$search = new \GoogleSearch('7651ca6caf949b0ac6ce28a95f3d2e9d8ee51b024ba7fad86f0298fb84290765');
|
||||
$result = $search->get_json($query);
|
||||
$organic_results = object_to_array($result);
|
||||
|
||||
if(isset($organic_results['profiles'])){
|
||||
$re['authors'] = $organic_results['profiles'];
|
||||
return jsonSuccess($re);
|
||||
}else{
|
||||
return jsonError('no date');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定谷歌用户id
|
||||
*/
|
||||
public function googleBindAuthor(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
'user_id'=>'require',
|
||||
'g_author'=>'require',
|
||||
// 'website'=>'require'
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
// $this->user_obj->where('user_id',$data['user_id'])->update(['g_author'=>trim($data['g_author']),'g_website'=>trim($data['website'])]);
|
||||
$this->user_obj->where('user_id',$data['user_id'])->update(['g_author'=>trim($data['g_author'])]);
|
||||
//绑定完成后自动获取指数
|
||||
Loader::import("google.google-search-results");
|
||||
Loader::import("google.restclient");
|
||||
|
||||
$query = [
|
||||
"engine" => "google_scholar_author",
|
||||
"author_id" => $data['g_author']
|
||||
];
|
||||
|
||||
$search = new \GoogleSearch('7651ca6caf949b0ac6ce28a95f3d2e9d8ee51b024ba7fad86f0298fb84290765');
|
||||
$result = $search->get_json($query);
|
||||
$organic_results = object_to_array($result);
|
||||
$h_index= 0;
|
||||
// if(isset($organic_results['cited_by']['table']['h_index'])){
|
||||
$h_index = $organic_results['cited_by']['table'][1]['h_index']['all'];
|
||||
// }else{
|
||||
// $h_index = $organic_results['cited_by']['table']['indice_h']['all'];
|
||||
// }
|
||||
|
||||
$updata['google_index'] = $h_index;
|
||||
$updata['google_time'] = time();
|
||||
$this->user_obj->where('user_id',$data['user_id'])->update($updata);
|
||||
|
||||
|
||||
return jsonSuccess($organic_results);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取H指数
|
||||
*/
|
||||
public function googleGetIndex(){
|
||||
$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();
|
||||
if($user_info['google_time']>strtotime('-1 year')){
|
||||
return jsonError('The time interval obtained is one year');
|
||||
}
|
||||
if($user_info['g_author']==''){
|
||||
return jsonError('google_id is null , please bind google_id before the request.');
|
||||
}
|
||||
Loader::import("google.google-search-results");
|
||||
Loader::import("google.restclient");
|
||||
|
||||
$query = [
|
||||
"engine" => "google_scholar_author",
|
||||
"author_id" => $user_info['g_author']
|
||||
];
|
||||
|
||||
$search = new \GoogleSearch('7651ca6caf949b0ac6ce28a95f3d2e9d8ee51b024ba7fad86f0298fb84290765');
|
||||
$result = $search->get_json($query);
|
||||
$organic_results = object_to_array($result);
|
||||
|
||||
$h_index= 0;
|
||||
// if(isset($organic_results['cited_by']['table']['h_index'])){
|
||||
$h_index = $organic_results['cited_by']['table'][1]['h_index']['all'];
|
||||
// }else{
|
||||
// $h_index = $organic_results['cited_by']['table']['indice_h']['all'];
|
||||
// }
|
||||
|
||||
$updata['google_index'] = $h_index;
|
||||
$updata['google_time'] = time();
|
||||
$this->user_obj->where('user_id',$data['user_id'])->update($updata);
|
||||
return jsonSuccess($organic_results);
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 审稿系统登录功能
|
||||
|
||||
Reference in New Issue
Block a user