20201112
This commit is contained in:
@@ -7,6 +7,10 @@ use think\Db;
|
||||
use think\captcha;
|
||||
use think\Cache;
|
||||
|
||||
/**
|
||||
* @title 用户相关接口
|
||||
* @description 用户相关接口
|
||||
*/
|
||||
class User extends Controller {
|
||||
|
||||
protected $user_obj = '';
|
||||
@@ -19,6 +23,8 @@ class User extends Controller {
|
||||
protected $reviewer_to_journal_obj = '';
|
||||
protected $user_reviewer_info_obj = '';
|
||||
protected $user_msg_obj = '';
|
||||
protected $chief_to_journal_obj = '';
|
||||
protected $board_to_journal_obj = '';
|
||||
|
||||
public function __construct(\think\Request $request = null) {
|
||||
parent::__construct($request);
|
||||
@@ -32,11 +38,22 @@ class User extends Controller {
|
||||
$this->reviewer_to_journal_obj = Db::name('reviewer_to_journal');
|
||||
$this->user_reviewer_info_obj = Db::name('user_reviewer_info');
|
||||
$this->user_msg_obj = Db::name('user_msg');
|
||||
$this->chief_to_journal_obj = Db::name('chief_to_journal');
|
||||
$this->board_to_journal_obj = Db::name('board_to_journal');
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录功能
|
||||
* @return type
|
||||
* @title 登录功能
|
||||
* @description 登录功能
|
||||
* @author wangjinlei
|
||||
* @url /api/User/checkLogin
|
||||
* @method POST
|
||||
*
|
||||
* @param name:username type:string require:1 desc:用户名
|
||||
* @param name:password type:string require:1 desc:密码
|
||||
*
|
||||
* @return userinfo:用户信息#
|
||||
* @return roles:角色列表#
|
||||
*/
|
||||
public function checkLogin() {
|
||||
$data = $this->request->post();
|
||||
@@ -64,11 +81,126 @@ class User extends Controller {
|
||||
$up_data['last_login_time'] = time();
|
||||
$up_data['last_login_ip'] = $this->request->ip();
|
||||
$this->user_obj->where('user_id = ' . $user_info['user_id'])->update($up_data);
|
||||
return json(['code' => 0, 'userinfo' => $user_info]);
|
||||
$roles = $this->getUserRoles($user_info['account']);
|
||||
|
||||
$re['roles'] = $roles;
|
||||
$re['userinfo'] = $user_info;
|
||||
return jsonSuccess($re);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 审稿系统登录功能
|
||||
* @description 审稿系统登录功能
|
||||
* @author wangjinlei
|
||||
* @url /api/User/reviewer_login
|
||||
* @method POST
|
||||
*
|
||||
* @param name:username type:string require:1 desc:用户名
|
||||
* @param name:password type:string require:1 desc:密码
|
||||
*
|
||||
* @return userinfo:用户信息#
|
||||
*/
|
||||
// public function reviewer_login() {
|
||||
// $data = $this->request->post();
|
||||
// $user_info = $this->user_obj
|
||||
// ->where('account|email', $data['username'])
|
||||
// ->where('password', md5($data['password']))
|
||||
// ->find();
|
||||
// if ($user_info == null) {//登陆失败
|
||||
// return json(['code' => 1]);
|
||||
// } else {//登陆成功
|
||||
// $up_data['last_login_time'] = time();
|
||||
// $up_data['last_login_ip'] = $this->request->ip();
|
||||
// $this->user_obj->where('user_id = ' . $user_info['user_id'])->update($up_data);
|
||||
// return json(['code' => 0, 'userinfo' => $user_info]);
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* @title 获取用户身份列表
|
||||
* @description 获取用户身份列表
|
||||
* @author wangjinlei
|
||||
* @url /api/User/getUserRole
|
||||
* @method POST
|
||||
*
|
||||
* @param name:account type:string require:1 desc:用户名
|
||||
*
|
||||
* @return roles:角色列表#
|
||||
*
|
||||
*/
|
||||
public function getUserRole(){
|
||||
$data = $this->request->post();
|
||||
$roles = $this->getUserRoles($data['account']);
|
||||
$re['roles'] = $roles;
|
||||
return jsonSuccess($re);
|
||||
}
|
||||
|
||||
private function getUserRoles($account) {
|
||||
$user_info = $this->user_obj->where('account',$account)->find();
|
||||
if($user_info['type']==2){
|
||||
$ros[] = 'editor';
|
||||
return $ros;
|
||||
}
|
||||
$roles[] = 'author';
|
||||
$reviewer_res = $this->reviewer_to_journal_obj->where('reviewer_id',$user_info['user_id'])->where('state',0)->find();
|
||||
if($reviewer_res!=null){
|
||||
$roles[] = 'reviewer';
|
||||
}
|
||||
$yboard_res = $this->reviewer_to_journal_obj->where('reviewer_id',$user_info['user_id'])->where('is_yboard',1)->where('state',0)->find();
|
||||
if($yboard_res!=null){
|
||||
$roles[] = 'yboard';
|
||||
}
|
||||
$chief_res = $this->chief_to_journal_obj->where('user_id',$user_info['user_id'])->where('state',0)->find();
|
||||
if($chief_res != null){
|
||||
$roles[] = 'chief';
|
||||
}
|
||||
$board_res = $this->board_to_journal_obj->where('user_id',$user_info['user_id'])->where('state',0)->find();
|
||||
if($board_res != null){
|
||||
$roles[] = 'board';
|
||||
}
|
||||
return $roles;
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 升级审稿人至青年编委
|
||||
* @description 升级审稿人至青年编委
|
||||
* @author wangjinlei
|
||||
* @url /api/User/upReviewerToYboard
|
||||
* @method POST
|
||||
*
|
||||
* @param name:journal_id type:int require:1 desc:期刊id
|
||||
* @param name:user_id type:int require:1 desc:审稿人userid
|
||||
*
|
||||
* @return roles:角色列表#
|
||||
*
|
||||
*/
|
||||
public function upReviewerToYboard(){
|
||||
$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]);
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 降级青年编委至审稿人
|
||||
* @description 降级青年编委至审稿人
|
||||
* @author wangjinlei
|
||||
* @url /api/User/downReviewerToYboard
|
||||
* @method POST
|
||||
*
|
||||
* @param name:journal_id type:int require:1 desc:期刊id
|
||||
* @param name:user_id type:int require:1 desc:审稿人userid
|
||||
*
|
||||
* @return roles:角色列表#
|
||||
*
|
||||
*/
|
||||
public function downReviewerToYboard(){
|
||||
$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]);
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取orcid
|
||||
*/
|
||||
@@ -132,7 +264,6 @@ class User extends Controller {
|
||||
return json($inser_data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取验证码图片(用户注册)
|
||||
*/
|
||||
@@ -240,56 +371,88 @@ class User extends Controller {
|
||||
return $nowcode == $mbcode ? true : false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取审稿人列表
|
||||
* @title 获取审稿人列表
|
||||
* @description 获取审稿人列表
|
||||
* @author wangjinlei
|
||||
* @url /api/User/getreviewerList
|
||||
* @method POST
|
||||
*
|
||||
* @param name:username type:string require:1 desc:用户名
|
||||
* @param name:journalId type:int require:1 desc:期刊id当全选时为0
|
||||
* @param name:pageIndex type:int require:1 desc:开始页码
|
||||
* @param name:pageSize type:int require:1 desc:每页是数据条数
|
||||
*
|
||||
*/
|
||||
public function getreviewerList() {
|
||||
$data = $this->request->post();
|
||||
$editor_info = $this->user_obj->where('account',$data['username'])->where('state',0)->find();
|
||||
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
|
||||
$where['t_user.is_reviewer'] = 1;
|
||||
if ($data['journalId'] == 0) {
|
||||
$subQuery = $this->user_obj->field('user_id')->where('account', $data['username'])->buildSql();
|
||||
$journals = $this->journal_obj->where("editor_id in $subQuery")->column('journal_id');
|
||||
$uids = $this->reviewer_to_journal_obj->where('journal_id', 'in', $journals)->where('state',0)->column('reviewer_id');
|
||||
$where['t_user.user_id'] = ['in', $uids];
|
||||
} else {
|
||||
$uids = $this->reviewer_to_journal_obj->where('journal_id', $data['journalId'])->where('state',0)->column('reviewer_id');
|
||||
$where['t_user.user_id'] = ['in', $uids];
|
||||
$jous = [];
|
||||
if($data['journalId'] == 0){
|
||||
$jous = $this->journal_obj->where('editor_id',$editor_info['user_id'])->where('state',0)->column('journal_id');
|
||||
}else{
|
||||
$jous[] = $data['journalId'];
|
||||
}
|
||||
$res = $this->user_obj->field('t_user.*,t_user_reviewer_info.*')
|
||||
->join('t_user_reviewer_info', 't_user_reviewer_info.reviewer_id = t_user.user_id', 'LEFT')
|
||||
->where($where)
|
||||
->limit($limit_start, $data['pageSize'])
|
||||
$res = $this->reviewer_to_journal_obj
|
||||
->field('t_reviewer_to_journal.is_yboard,t_user.*,t_user_reviewer_info.*,t_journal.*')
|
||||
->join('t_journal','t_journal.journal_id = t_reviewer_to_journal.journal_id','left')
|
||||
->join('t_user','t_user.user_id = t_reviewer_to_journal.reviewer_id','left')
|
||||
->join('t_user_reviewer_info', 't_user_reviewer_info.reviewer_id = t_reviewer_to_journal.reviewer_id', 'LEFT')
|
||||
->where('t_reviewer_to_journal.journal_id','in',$jous)
|
||||
->where('t_reviewer_to_journal.state',0)
|
||||
->limit($limit_start,$data['pageSize'])
|
||||
->select();
|
||||
$total = $this->user_obj->where($where)->count();
|
||||
if ($res) {
|
||||
return json(['code' => 0, 'data' => $res, 'total' => $total]);
|
||||
} else {
|
||||
return json(['code' => 1]);
|
||||
}
|
||||
$count = $this->reviewer_to_journal_obj->where('t_reviewer_to_journal.journal_id','in',$jous)->where('t_reviewer_to_journal.state',0)->count();
|
||||
return json(['code' => 0, 'data' => $res, 'total' => $count]);
|
||||
|
||||
|
||||
|
||||
// $where['t_user.is_reviewer'] = 1;
|
||||
// if ($data['journalId'] == 0) {
|
||||
// $subQuery = $this->user_obj->field('user_id')->where('account', $data['username'])->buildSql();
|
||||
// $journals = $this->journal_obj->where("editor_id in $subQuery")->column('journal_id');
|
||||
// $uids = $this->reviewer_to_journal_obj->where('journal_id', 'in', $journals)->where('state', 0)->column('reviewer_id');
|
||||
// $where['t_user.user_id'] = ['in', $uids];
|
||||
// } else {
|
||||
// $uids = $this->reviewer_to_journal_obj->where('journal_id', $data['journalId'])->where('state', 0)->column('reviewer_id');
|
||||
// $where['t_user.user_id'] = ['in', $uids];
|
||||
// }
|
||||
// $res = $this->user_obj->field('t_user.*,t_user_reviewer_info.*')
|
||||
// ->join('t_user_reviewer_info', 't_user_reviewer_info.reviewer_id = t_user.user_id', 'LEFT')
|
||||
// ->where($where)
|
||||
// ->limit($limit_start, $data['pageSize'])
|
||||
// ->select();
|
||||
// $total = $this->user_obj->where($where)->count();
|
||||
// if ($res) {
|
||||
// return json(['code' => 0, 'data' => $res, 'total' => $total]);
|
||||
// } else {
|
||||
// return json(['code' => 1]);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function deleteArticleReviewer(){
|
||||
public function deleteArticleReviewer() {
|
||||
$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([]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function getReviewerForDel(){
|
||||
public function getReviewerForDel() {
|
||||
$data = $this->request->post();
|
||||
$user_info = $this->user_obj->where('user_id', $data['reviewer_id'])->find();
|
||||
$editor_info = $this->user_obj->where('account',$data['editor_account'])->find();
|
||||
$journals = $this->journal_obj->where("editor_id",$editor_info['user_id'])->column('journal_id');
|
||||
$rtjs = $this->reviewer_to_journal_obj->where('journal_id', 'in', $journals)->where('reviewer_id',$data['reviewer_id'])->where('state',0)->select();
|
||||
foreach($rtjs as $k => $v){
|
||||
$editor_info = $this->user_obj->where('account', $data['editor_account'])->find();
|
||||
$journals = $this->journal_obj->where("editor_id", $editor_info['user_id'])->column('journal_id');
|
||||
$rtjs = $this->reviewer_to_journal_obj->where('journal_id', 'in', $journals)->where('reviewer_id', $data['reviewer_id'])->where('state', 0)->select();
|
||||
foreach ($rtjs as $k => $v) {
|
||||
$rtjs[$k]['reviewer'] = $user_info;
|
||||
$rtjs[$k]['journal'] = $this->journal_obj->where('journal_id',$v['journal_id'])->find();
|
||||
$rtjs[$k]['journal'] = $this->journal_obj->where('journal_id', $v['journal_id'])->find();
|
||||
}
|
||||
return jsonSuccess($rtjs);
|
||||
}
|
||||
@@ -386,7 +549,7 @@ class User extends Controller {
|
||||
. "At present, you have passed our examination<br/>";
|
||||
$content .= '<a href="https://submission.tmrjournals.com">Submission System</a><br>';
|
||||
$content .= '<p>username:' . $apply_info['name'] . '</p>';
|
||||
$content .= '<p>Original Password: 123456qwe</p>';//$has_res ? '' : '<p>password:123456qwe</p>';
|
||||
$content .= '<p>Original Password: 123456qwe</p>'; //$has_res ? '' : '<p>password:123456qwe</p>';
|
||||
sendEmail($apply_info['email'], $journal_info['title'], $journal_info['title'], $content, $journal_info['email'], $journal_info['epassword']);
|
||||
$update_res = $this->user_reviewer_obj->where($where)->update(['state' => 1]);
|
||||
if ($res && $add_res && $addinfo_res && $update_res) {
|
||||
@@ -485,11 +648,11 @@ class User extends Controller {
|
||||
$re['orcid'] = $r->orcid;
|
||||
return jsonSuccess($re);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 登陆后绑定orcid账号
|
||||
*/
|
||||
public function OrcidBinding(){
|
||||
public function OrcidBinding() {
|
||||
$data = $this->request->post();
|
||||
$url = 'https://orcid.org/oauth/token';
|
||||
$param['client_id'] = "APP-PKF0BGRP6DWM6FUB";
|
||||
@@ -499,14 +662,13 @@ class User extends Controller {
|
||||
$param['redirect_uri'] = "https://submission.tmrjournals.com/orcidBind";
|
||||
$res = $this->myUrl($url, $param);
|
||||
$r = json_decode($res);
|
||||
|
||||
|
||||
|
||||
|
||||
$update['orcid'] = $r->orcid;
|
||||
$update['orcid_code'] = $res;
|
||||
|
||||
$this->user_obj->where('account',$data['account'])->update($update);
|
||||
|
||||
$this->user_obj->where('account', $data['account'])->update($update);
|
||||
return jsonSuccess([]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -557,11 +719,10 @@ class User extends Controller {
|
||||
return jsonSuccess($re);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 授权码转化成令牌,并存贮
|
||||
*/
|
||||
public function sq_to_lp(){
|
||||
public function sq_to_lp() {
|
||||
$url = 'https://orcid.org/oauth/token';
|
||||
$param['client_id'] = "APP-PKF0BGRP6DWM6FUB";
|
||||
$param['client_secret'] = "755a0e59-9282-44d0-afb4-ef9771942bab";
|
||||
@@ -572,7 +733,6 @@ class User extends Controller {
|
||||
$r = json_decode($res);
|
||||
echo $r->orcid;
|
||||
}
|
||||
|
||||
|
||||
private function myUrl($url, $param) {
|
||||
$header = array('Accept: application/json', 'Content-type:application/x-www-form-urlencoded');
|
||||
|
||||
Reference in New Issue
Block a user