This commit is contained in:
wangjinlei
2022-04-13 17:39:01 +08:00
parent 3571a47fb2
commit c57559a4a8
3 changed files with 291 additions and 184 deletions

4
.env
View File

@@ -5,3 +5,7 @@ send_email_password = Wu999999tmrwe
;审核建议邮箱 ;审核建议邮箱
editor_email = publisher@tmrjournals.com editor_email = publisher@tmrjournals.com
[journal]
;官网服务器地址
base_url = http://journalapi.tmrjournals.com/public/index.php

View File

@@ -6,6 +6,7 @@ use think\Controller;
use think\Db; use think\Db;
use think\Env; use think\Env;
use think\Queue; use think\Queue;
use think\Validate;
class Special extends Controller { class Special extends Controller {
@@ -142,6 +143,27 @@ class Special extends Controller {
return json(['code' => 0, 'data' => ['articles' => $re]]); return json(['code' => 0, 'data' => ['articles' => $re]]);
} }
/**
* 获取期刊的专刊列表
*/
public function getSpecialByIssn(){
$data = $this->request->post();
$rule = new Validate([
'journal_issn' => 'require'
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$base_url = Env::get('journal.base_url');
$res = object_to_array(json_decode(myPost($base_url."/master/Special/getSpecialByIssn",['journal_issn'=>$data['journal_issn']])));
$specials = $res['data']['specials'];
foreach($specials as $k => $v){
unset($specials[$k]['journal_id']);
}
$re['specials'] = $specials;
return jsonSuccess($re);
}
/** /**
* 添加文章(作者) * 添加文章(作者)
*/ */

View File

@@ -8,12 +8,14 @@ use think\captcha;
use think\Cache; use think\Cache;
use think\Env; use think\Env;
use think\Queue; use think\Queue;
use think\Validate;
/** /**
* @title 用户相关接口 * @title 用户相关接口
* @description 用户相关接口 * @description 用户相关接口
*/ */
class User extends Controller { class User extends Controller
{
protected $user_obj = ''; protected $user_obj = '';
protected $captcha_obj = ''; protected $captcha_obj = '';
@@ -31,7 +33,8 @@ class User extends Controller {
protected $article_author_obj = ''; protected $article_author_obj = '';
protected $user_black_obj = ''; protected $user_black_obj = '';
public function __construct(\think\Request $request = null) { public function __construct(\think\Request $request = null)
{
parent::__construct($request); parent::__construct($request);
$this->user_obj = Db::name('user'); $this->user_obj = Db::name('user');
$this->captcha_obj = Db::name('captcha'); $this->captcha_obj = Db::name('captcha');
@@ -63,7 +66,8 @@ class User extends Controller {
* @return userinfo:用户信息# * @return userinfo:用户信息#
* @return roles:角色列表# * @return roles:角色列表#
*/ */
public function checkLogin() { public function checkLogin()
{
$data = $this->request->post(); $data = $this->request->post();
// if ($data['username'] == 'fariba' || $data['username'] == 'zc' || $data['username'] == 'Mohammad Hossein' || $data['username'] == 'xiaoyueyue' || $data['username'] == 'sethlee000' || $data['username'] == 'yuanying9908') { // if ($data['username'] == 'fariba' || $data['username'] == 'zc' || $data['username'] == 'Mohammad Hossein' || $data['username'] == 'xiaoyueyue' || $data['username'] == 'sethlee000' || $data['username'] == 'yuanying9908') {
// return json(['code' => 1, 'msg' => 'Your account has been blocked. Please contact the publisher for details: publisher@tmrjournals.com.']); // return json(['code' => 1, 'msg' => 'Your account has been blocked. Please contact the publisher for details: publisher@tmrjournals.com.']);
@@ -108,7 +112,8 @@ class User extends Controller {
/** /**
* 为所有用户发送邮件 * 为所有用户发送邮件
*/ */
public function pushEmail() { public function pushEmail()
{
die; die;
$list = $this->user_obj->where('state', 0)->select(); $list = $this->user_obj->where('state', 0)->select();
//发送邮件通知审稿人 //发送邮件通知审稿人
@@ -145,7 +150,8 @@ class User extends Controller {
* @return users:用户列表# * @return users:用户列表#
* @return count:总数 * @return count:总数
*/ */
public function getAllUser() { public function getAllUser()
{
$data = $this->request->post(); $data = $this->request->post();
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize']; $limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
$black_list = $this->user_black_obj->where('black_state', 0)->column("user_id"); $black_list = $this->user_black_obj->where('black_state', 0)->column("user_id");
@@ -177,7 +183,8 @@ class User extends Controller {
* @param name:reason type:string require:1 desc:拉黑原因 * @param name:reason type:string require:1 desc:拉黑原因
* *
*/ */
public function pushUserToBlack() { public function pushUserToBlack()
{
$data = $this->request->post(); $data = $this->request->post();
$check_black = $this->user_black_obj->where('user_id', $data['user_id'])->where('black_state', 0)->find(); $check_black = $this->user_black_obj->where('user_id', $data['user_id'])->where('black_state', 0)->find();
if ($check_black) { if ($check_black) {
@@ -203,7 +210,8 @@ class User extends Controller {
* @return blacks:黑名单列表# * @return blacks:黑名单列表#
* @return count:总数 * @return count:总数
*/ */
public function getUserBlackList() { public function getUserBlackList()
{
$data = $this->request->post(); $data = $this->request->post();
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize']; $limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
$list = $this->user_black_obj $list = $this->user_black_obj
@@ -217,6 +225,39 @@ class User extends Controller {
return jsonSuccess($re); return jsonSuccess($re);
} }
/**
* 添加用户
*/
public function addUser()
{
$data = $this->request->post();
$rules = new Validate([
'account' => 'require|alphaNum|min:5',
'email' => 'require|email',
'password' => 'require',
]);
if (!$rules->check($data)) {
return jsonError($rules->getError());
}
$check = $this->user_obj
->where('state', 0)
->where('account = "'.$data['account'].'" or email = "'.$data['email'].'"')
->find();
if ($check) {
return jsonError('用户已经存在');
}
$inser_data['account'] = $data['account'];
$inser_data['password'] = md5($data['password']);
$inser_data['email'] = $data['email'];
$inser_data['phone'] = isset($data['phone']) ? $data['phone'] : '';
$inser_data['realname'] = isset($data['realname']) ? $data['realname'] : '';
$inser_data['ctime'] = time();
$this->user_obj->insertGetId($inser_data);
return jsonSuccess([]);
}
/** /**
* @title 消除黑名单 * @title 消除黑名单
* @description 消除黑名单 * @description 消除黑名单
@@ -227,7 +268,8 @@ class User extends Controller {
* @param name:black_id type:int require:1 desc:黑名单id * @param name:black_id type:int require:1 desc:黑名单id
* *
*/ */
public function clearBlack() { public function clearBlack()
{
$data = $this->request->post(); $data = $this->request->post();
$this->user_black_obj->where("black_id", $data['black_id'])->update(['black_state' => 1]); $this->user_black_obj->where("black_id", $data['black_id'])->update(['black_state' => 1]);
return jsonSuccess([]); return jsonSuccess([]);
@@ -244,7 +286,8 @@ class User extends Controller {
* @param name:journal_id type:int require:1 desc:期刊id * @param name:journal_id type:int require:1 desc:期刊id
* *
*/ */
public function applyReviewerForReviewer() { public function applyReviewerForReviewer()
{
$data = $this->request->post(); $data = $this->request->post();
$user_info = $this->user_obj->where('account', trim($data['username']))->find(); $user_info = $this->user_obj->where('account', trim($data['username']))->find();
$journal_info = $this->journal_obj->where('journal_id', $data['journal_id'])->find(); $journal_info = $this->journal_obj->where('journal_id', $data['journal_id'])->find();
@@ -330,14 +373,16 @@ class User extends Controller {
* @return roles:角色列表# * @return roles:角色列表#
* *
*/ */
public function getUserRole() { public function getUserRole()
{
$data = $this->request->post(); $data = $this->request->post();
$roles = $this->getUserRoles($data['account']); $roles = $this->getUserRoles($data['account']);
$re['roles'] = $roles; $re['roles'] = $roles;
return jsonSuccess($re); return jsonSuccess($re);
} }
private function getUserRoles($account) { private function getUserRoles($account)
{
$user_info = $this->user_obj->where('account', $account)->find(); $user_info = $this->user_obj->where('account', $account)->find();
if ($user_info['type'] == 2) { if ($user_info['type'] == 2) {
$ros[] = 'editor'; $ros[] = 'editor';
@@ -376,7 +421,8 @@ class User extends Controller {
* @return roles:角色列表# * @return roles:角色列表#
* *
*/ */
public function upReviewerToYboard() { public function upReviewerToYboard()
{
$data = $this->request->post(); $data = $this->request->post();
$this->reviewer_to_journal_obj->where('journal_id', $data['journal_id'])->where('reviewer_id', $data['user_id'])->where('state', 0)->update(['is_yboard' => 1]); $this->reviewer_to_journal_obj->where('journal_id', $data['journal_id'])->where('reviewer_id', $data['user_id'])->where('state', 0)->update(['is_yboard' => 1]);
return jsonSuccess([]); return jsonSuccess([]);
@@ -395,7 +441,8 @@ class User extends Controller {
* @return roles:角色列表# * @return roles:角色列表#
* *
*/ */
public function downReviewerToYboard() { public function downReviewerToYboard()
{
$data = $this->request->post(); $data = $this->request->post();
$this->reviewer_to_journal_obj->where('journal_id', $data['journal_id'])->where('reviewer_id', $data['user_id'])->where('state', 0)->update(['is_yboard' => 0]); $this->reviewer_to_journal_obj->where('journal_id', $data['journal_id'])->where('reviewer_id', $data['user_id'])->where('state', 0)->update(['is_yboard' => 0]);
return jsonSuccess([]); return jsonSuccess([]);
@@ -404,7 +451,8 @@ class User extends Controller {
/** /**
* 获取orcid * 获取orcid
*/ */
public function checkOrcid() { public function checkOrcid()
{
$data = $this->request->post(); $data = $this->request->post();
$account = $data['account']; $account = $data['account'];
$user = $this->user_obj->where('account', $account)->find(); $user = $this->user_obj->where('account', $account)->find();
@@ -414,7 +462,8 @@ class User extends Controller {
/** /**
* 根据account获取用户信息 * 根据account获取用户信息
*/ */
public function getUserdata() { public function getUserdata()
{
$account = $this->request->post('account'); $account = $this->request->post('account');
$where['account'] = $account; $where['account'] = $account;
if ($account == 'superadmin') { if ($account == 'superadmin') {
@@ -432,7 +481,8 @@ class User extends Controller {
/** /**
* 注册功能 * 注册功能
*/ */
public function register() { public function register()
{
$data = $this->request->post(); $data = $this->request->post();
//检测是否用户名和邮箱已经占用 //检测是否用户名和邮箱已经占用
$account = $data['username']; $account = $data['username'];
@@ -478,7 +528,8 @@ class User extends Controller {
/** /**
* 获取验证码图片(用户注册) * 获取验证码图片(用户注册)
*/ */
public function testCaptcha() { public function testCaptcha()
{
$data = $this->request->get(); $data = $this->request->get();
$config = config('captcha'); $config = config('captcha');
$capt = new captcha\Captcha($config); $capt = new captcha\Captcha($config);
@@ -488,7 +539,8 @@ class User extends Controller {
/** /**
* 修改密码 * 修改密码
*/ */
public function retrieve() { public function retrieve()
{
$data = $this->request->post(); $data = $this->request->post();
//获取act信息 //获取act信息
$act_where['act_key'] = $data['actkey']; $act_where['act_key'] = $data['actkey'];
@@ -507,7 +559,8 @@ class User extends Controller {
/** /**
* 获取验证码图片(密码找回) * 获取验证码图片(密码找回)
*/ */
public function retrieveCaptcha() { public function retrieveCaptcha()
{
$data = $this->request->get(); $data = $this->request->get();
$config = config('captcha_retrieve'); $config = config('captcha_retrieve');
$capt = new captcha\Captcha($config); $capt = new captcha\Captcha($config);
@@ -517,7 +570,8 @@ class User extends Controller {
/** /**
* 找回密码第一步,获取邮箱 * 找回密码第一步,获取邮箱
*/ */
public function retrieveGetEmail() { public function retrieveGetEmail()
{
$data = $this->request->post(); $data = $this->request->post();
//验证验证码 //验证验证码
if (!$this->my_checkcaptcha($data['code'], $data['random_num'])) { if (!$this->my_checkcaptcha($data['code'], $data['random_num'])) {
@@ -536,7 +590,8 @@ class User extends Controller {
/** /**
* 找回密码第二部,发送邮件 * 找回密码第二部,发送邮件
*/ */
public function retrievePushEmail() { public function retrievePushEmail()
{
$email = $this->request->post('email'); $email = $this->request->post('email');
$where['email'] = $email; $where['email'] = $email;
$user = $this->user_obj->where($where)->field('realname,user_id')->find(); $user = $this->user_obj->where($where)->field('realname,user_id')->find();
@@ -573,7 +628,8 @@ class User extends Controller {
/** /**
* 验证修改密码页面的合法性 * 验证修改密码页面的合法性
*/ */
public function checkActkey() { public function checkActkey()
{
$actkey = $this->request->post('actkey'); $actkey = $this->request->post('actkey');
$where['act_key'] = $actkey; $where['act_key'] = $actkey;
$where['state'] = 0; $where['state'] = 0;
@@ -588,7 +644,8 @@ class User extends Controller {
/** /**
* 自定义验证验证码 * 自定义验证验证码
*/ */
public function my_checkcaptcha($code, $id) { public function my_checkcaptcha($code, $id)
{
$nowcode = Cache::get(md5($id)); $nowcode = Cache::get(md5($id));
$mbcode = authcode($code); $mbcode = authcode($code);
return $nowcode == $mbcode ? true : false; return $nowcode == $mbcode ? true : false;
@@ -607,7 +664,8 @@ class User extends Controller {
* @param name:pageSize type:int require:1 desc:每页是数据条数 * @param name:pageSize type:int require:1 desc:每页是数据条数
* *
*/ */
public function getreviewerList() { public function getreviewerList()
{
$data = $this->request->post(); $data = $this->request->post();
$editor_info = $this->user_obj->where('account', $data['username'])->where('state', 0)->find(); $editor_info = $this->user_obj->where('account', $data['username'])->where('state', 0)->find();
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize']; $limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
@@ -657,7 +715,8 @@ class User extends Controller {
/** /**
* *
*/ */
public function deleteArticleReviewer() { public function deleteArticleReviewer()
{
$data = $this->request->post(); $data = $this->request->post();
$this->reviewer_to_journal_obj->where('reviewer_id', $data['reviewer_id'])->where('journal_id', $data['journal_id'])->update(['state' => 1]); $this->reviewer_to_journal_obj->where('reviewer_id', $data['reviewer_id'])->where('journal_id', $data['journal_id'])->update(['state' => 1]);
return jsonSuccess([]); return jsonSuccess([]);
@@ -666,7 +725,8 @@ class User extends Controller {
/** /**
* *
*/ */
public function getReviewerForDel() { public function getReviewerForDel()
{
$data = $this->request->post(); $data = $this->request->post();
$user_info = $this->user_obj->where('user_id', $data['reviewer_id'])->find(); $user_info = $this->user_obj->where('user_id', $data['reviewer_id'])->find();
$editor_info = $this->user_obj->where('account', $data['editor_account'])->find(); $editor_info = $this->user_obj->where('account', $data['editor_account'])->find();
@@ -682,7 +742,8 @@ class User extends Controller {
/** /**
* 获取审核员申请列表 * 获取审核员申请列表
*/ */
public function getReviewerApplyList() { public function getReviewerApplyList()
{
$data = $this->request->post(); $data = $this->request->post();
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize']; $limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
$where['state'] = 0; $where['state'] = 0;
@@ -701,7 +762,8 @@ class User extends Controller {
/** /**
* 获取申请详情 * 获取申请详情
*/ */
public function getApplyDetail() { public function getApplyDetail()
{
$reviewerId = $this->request->post('reviewerApplyId'); $reviewerId = $this->request->post('reviewerApplyId');
$where['t_user_reviewer_apply.reviewer_apply_id'] = $reviewerId; $where['t_user_reviewer_apply.reviewer_apply_id'] = $reviewerId;
$res = $this->user_reviewer_obj $res = $this->user_reviewer_obj
@@ -729,7 +791,8 @@ class User extends Controller {
* *
* @return reviewerTrans:列表# * @return reviewerTrans:列表#
*/ */
public function getAuthorToReviewerList() { public function getAuthorToReviewerList()
{
$data = $this->request->post(); $data = $this->request->post();
$user_info = $this->user_obj->where('account', $data['username'])->find(); $user_info = $this->user_obj->where('account', $data['username'])->find();
$journals = $this->journal_obj->where("editor_id", $user_info['user_id'])->where('state', 0)->column("journal_id"); $journals = $this->journal_obj->where("editor_id", $user_info['user_id'])->where('state', 0)->column("journal_id");
@@ -761,7 +824,8 @@ class User extends Controller {
* *
* @return reviewerTrans:列表# * @return reviewerTrans:列表#
*/ */
public function getAuthorToReviewerDetail() { public function getAuthorToReviewerDetail()
{
$data = $this->request->post(); $data = $this->request->post();
$detail = $this->reviewer_from_author_obj $detail = $this->reviewer_from_author_obj
->field("t_reviewer_from_author.rfa_id,t_article_author.*,t_journal.title journal_title") ->field("t_reviewer_from_author.rfa_id,t_article_author.*,t_journal.title journal_title")
@@ -794,7 +858,8 @@ class User extends Controller {
* *
* *
*/ */
public function ReviewerFromAuthorAdopt() { public function ReviewerFromAuthorAdopt()
{
$data = $this->request->post(); $data = $this->request->post();
$rfa_info = $this->reviewer_from_author_obj->where('rfa_id', $data['rfa_id'])->find(); $rfa_info = $this->reviewer_from_author_obj->where('rfa_id', $data['rfa_id'])->find();
$journal_info = $this->journal_obj->where('journal_id', $rfa_info['journal_id'])->find(); $journal_info = $this->journal_obj->where('journal_id', $rfa_info['journal_id'])->find();
@@ -852,7 +917,8 @@ class User extends Controller {
* *
* *
*/ */
public function ReviewerFromAuthorReject() { public function ReviewerFromAuthorReject()
{
$data = $this->request->post(); $data = $this->request->post();
$this->reviewer_from_author_obj->where('rfa_id', $data['rfa_id'])->update(['rfa_state' => 2]); $this->reviewer_from_author_obj->where('rfa_id', $data['rfa_id'])->update(['rfa_state' => 2]);
return jsonSuccess([]); return jsonSuccess([]);
@@ -861,7 +927,8 @@ class User extends Controller {
/** /**
* 通过审稿人 * 通过审稿人
*/ */
public function reviewerAdopt() { public function reviewerAdopt()
{
$reviewerId = $this->request->post('reviewerApplyId'); $reviewerId = $this->request->post('reviewerApplyId');
$where['reviewer_apply_id'] = $reviewerId; $where['reviewer_apply_id'] = $reviewerId;
$apply_info = $this->user_reviewer_obj->where($where)->find(); $apply_info = $this->user_reviewer_obj->where($where)->find();
@@ -951,7 +1018,8 @@ class User extends Controller {
/** /**
* 获取用户消息 * 获取用户消息
*/ */
public function getUserMsg() { public function getUserMsg()
{
//接收参数 //接收参数
$data = $this->request->post(); $data = $this->request->post();
$user_info = $this->user_obj->where('account', $data['account'])->find(); $user_info = $this->user_obj->where('account', $data['account'])->find();
@@ -969,7 +1037,8 @@ class User extends Controller {
/** /**
* 更改用户消息状态 * 更改用户消息状态
*/ */
public function changeMsgState() { public function changeMsgState()
{
//接收参数 //接收参数
$id = $this->request->post('id'); $id = $this->request->post('id');
$this->user_msg_obj $this->user_msg_obj
@@ -981,7 +1050,8 @@ class User extends Controller {
/** /**
* 审核人审查去重 * 审核人审查去重
*/ */
public function checkReviewer() { public function checkReviewer()
{
$username = $this->request->post('username'); $username = $this->request->post('username');
$userres = $this->user_obj->where('account', $username)->find(); $userres = $this->user_obj->where('account', $username)->find();
$applyres = $this->user_reviewer_obj->where("name = '$username' and state <> 2")->find(); $applyres = $this->user_reviewer_obj->where("name = '$username' and state <> 2")->find();
@@ -1004,7 +1074,8 @@ class User extends Controller {
* @return is:0否1是 * @return is:0否1是
* *
*/ */
public function checkUserIsReviewer() { public function checkUserIsReviewer()
{
$data = $this->request->post(); $data = $this->request->post();
$user_info = $this->user_obj->where('account', $data['username'])->find(); $user_info = $this->user_obj->where('account', $data['username'])->find();
$check = $this->reviewer_to_journal_obj->where('reviewer_id', $user_info['user_id'])->where('state', 0)->find(); $check = $this->reviewer_to_journal_obj->where('reviewer_id', $user_info['user_id'])->where('state', 0)->find();
@@ -1025,7 +1096,8 @@ class User extends Controller {
* @return has:0无1有 * @return has:0无1有
* *
*/ */
public function checkUserByAccountOrEmail() { public function checkUserByAccountOrEmail()
{
$data = $this->request->post(); $data = $this->request->post();
$check_info = $this->user_obj->where("account|email", $data['username'])->where("state", 0)->find(); $check_info = $this->user_obj->where("account|email", $data['username'])->where("state", 0)->find();
@@ -1037,31 +1109,32 @@ class User extends Controller {
/** /**
* 审查用户通过邮箱 * 审查用户通过邮箱
*/ */
public function checkUserByEmail(){ public function checkUserByEmail()
{
$data = $this->request->post(); $data = $this->request->post();
$check_info = $this->user_obj->where("email", $data['email'])->where("state", 0)->find(); $check_info = $this->user_obj->where("email", $data['email'])->where("state", 0)->find();
$re['has'] = $check_info == null ? 0 : 1; $re['has'] = $check_info == null ? 0 : 1;
return jsonSuccess($re); return jsonSuccess($re);
} }
/** /**
* 审查用户通过账号 * 审查用户通过账号
*/ */
public function checkUserByAccount(){ public function checkUserByAccount()
{
$data = $this->request->post(); $data = $this->request->post();
$check_info = $this->user_obj->where("account", $data['account'])->where("state", 0)->find(); $check_info = $this->user_obj->where("account", $data['account'])->where("state", 0)->find();
$re['has'] = $check_info == null ? 0 : 1; $re['has'] = $check_info == null ? 0 : 1;
return jsonSuccess($re); return jsonSuccess($re);
} }
/** /**
* 拒绝审核人 * 拒绝审核人
*/ */
public function reviewerRejec() { public function reviewerRejec()
{
$reviewerId = $this->request->post('reviewerApplyId'); $reviewerId = $this->request->post('reviewerApplyId');
$where['reviewer_apply_id'] = $reviewerId; $where['reviewer_apply_id'] = $reviewerId;
$this->user_reviewer_obj->where($where)->update(['state' => 2]); $this->user_reviewer_obj->where($where)->update(['state' => 2]);
@@ -1081,7 +1154,8 @@ class User extends Controller {
* *
* @return data:领域列表# * @return data:领域列表#
*/ */
public function getMajorList() { public function getMajorList()
{
$res = $this->reviewer_major_obj->select(); $res = $this->reviewer_major_obj->select();
return json(['code' => 0, 'data' => $res]); return json(['code' => 0, 'data' => $res]);
} }
@@ -1089,7 +1163,8 @@ class User extends Controller {
/** /**
* orcid登陆 * orcid登陆
*/ */
public function OrcidLogin() { public function OrcidLogin()
{
$data = $this->request->post(); $data = $this->request->post();
$url = 'https://orcid.org/oauth/token'; $url = 'https://orcid.org/oauth/token';
$param['client_id'] = "APP-PKF0BGRP6DWM6FUB"; $param['client_id'] = "APP-PKF0BGRP6DWM6FUB";
@@ -1120,7 +1195,8 @@ class User extends Controller {
/** /**
* 登陆后绑定orcid账号 * 登陆后绑定orcid账号
*/ */
public function OrcidBinding() { public function OrcidBinding()
{
$data = $this->request->post(); $data = $this->request->post();
$url = 'https://orcid.org/oauth/token'; $url = 'https://orcid.org/oauth/token';
$param['client_id'] = "APP-PKF0BGRP6DWM6FUB"; $param['client_id'] = "APP-PKF0BGRP6DWM6FUB";
@@ -1142,7 +1218,8 @@ class User extends Controller {
/** /**
* 绑定orcid到系统内的用户 * 绑定orcid到系统内的用户
*/ */
public function orcidBind() { public function orcidBind()
{
$data = $this->request->post(); $data = $this->request->post();
//确定系统内部有此账户 //确定系统内部有此账户
$serch['account'] = trim($data['username']); $serch['account'] = trim($data['username']);
@@ -1168,7 +1245,8 @@ class User extends Controller {
/** /**
* 注册绑定orcid至我们的账户 * 注册绑定orcid至我们的账户
*/ */
public function orcidRegister() { public function orcidRegister()
{
$data = $this->request->post(); $data = $this->request->post();
$cache = Cache::get($data['orcid']); $cache = Cache::get($data['orcid']);
$res = $this->object2array(json_decode($cache)); $res = $this->object2array(json_decode($cache));
@@ -1197,7 +1275,8 @@ class User extends Controller {
/** /**
* 授权码转化成令牌,并存贮 * 授权码转化成令牌,并存贮
*/ */
public function sq_to_lp() { public function sq_to_lp()
{
$url = 'https://orcid.org/oauth/token'; $url = 'https://orcid.org/oauth/token';
$param['client_id'] = "APP-PKF0BGRP6DWM6FUB"; $param['client_id'] = "APP-PKF0BGRP6DWM6FUB";
$param['client_secret'] = "755a0e59-9282-44d0-afb4-ef9771942bab"; $param['client_secret'] = "755a0e59-9282-44d0-afb4-ef9771942bab";
@@ -1209,7 +1288,8 @@ class User extends Controller {
echo $r->orcid; echo $r->orcid;
} }
private function myUrl($url, $param) { private function myUrl($url, $param)
{
$header = array('Accept: application/json', 'Content-type:application/x-www-form-urlencoded'); $header = array('Accept: application/json', 'Content-type:application/x-www-form-urlencoded');
$pp = http_build_query($param); $pp = http_build_query($param);
$httph = curl_init($url); $httph = curl_init($url);
@@ -1230,7 +1310,8 @@ class User extends Controller {
/** /**
* 项目转数组 * 项目转数组
*/ */
private function object2array($object) { private function object2array($object)
{
if (is_object($object)) { if (is_object($object)) {
foreach ($object as $key => $value) { foreach ($object as $key => $value) {
$array[$key] = $value; $array[$key] = $value;
@@ -1244,7 +1325,8 @@ class User extends Controller {
/** /**
* curl -i -H "Accept: application/vnd.orcid+xml" -H 'Authorization: Bearer dd91868d-d29a-475e-9acb-bd3fdf2f43f4' 'https://api.sandbox.orcid.org/v2.1/0000-0002-9227-8514/education/22423' * curl -i -H "Accept: application/vnd.orcid+xml" -H 'Authorization: Bearer dd91868d-d29a-475e-9acb-bd3fdf2f43f4' 'https://api.sandbox.orcid.org/v2.1/0000-0002-9227-8514/education/22423'
*/ */
public function geturl() { public function geturl()
{
// $url = "https://api.orcid.org/v3.0/0000-0003-3278-0964/record"; // $url = "https://api.orcid.org/v3.0/0000-0003-3278-0964/record";
$url = "https://pub.orcid.org/v3.0/expanded-search/?q=0000-0003-3440-7901"; $url = "https://pub.orcid.org/v3.0/expanded-search/?q=0000-0003-3440-7901";
$headerArray = array("Content-type: application/vnd.orcid+json", "Authorization: Bearer 28924261-b2a9-4ed0-952c-e2647843d1ba"); $headerArray = array("Content-type: application/vnd.orcid+json", "Authorization: Bearer 28924261-b2a9-4ed0-952c-e2647843d1ba");
@@ -1268,5 +1350,4 @@ class User extends Controller {
die; die;
// return $output; // return $output;
} }
} }