1
This commit is contained in:
@@ -17,6 +17,9 @@ class Ucenter extends Controller{
|
||||
protected $article_obj = '';
|
||||
protected $chief_to_journal_obj = '';
|
||||
protected $board_to_journal_obj = '';
|
||||
protected $major_obj = "";
|
||||
protected $major_to_journal_obj = '';
|
||||
protected $user_cv_obj = '';
|
||||
|
||||
public function __construct(\think\Request $request = null)
|
||||
{
|
||||
@@ -29,7 +32,9 @@ class Ucenter extends Controller{
|
||||
$this->article_obj = Db::name('article');
|
||||
$this->chief_to_journal_obj = Db::name('chief_to_journal');
|
||||
$this->board_to_journal_obj = Db::name('board_to_journal');
|
||||
|
||||
$this->major_obj = Db::name("major");
|
||||
$this->major_to_journal_obj = Db::name('major_to_journal');
|
||||
$this->user_cv_obj = Db::name('user_cv');
|
||||
}
|
||||
|
||||
|
||||
@@ -44,19 +49,33 @@ class Ucenter extends Controller{
|
||||
public function getUserInfo(){
|
||||
//接收参数
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
'user_id'=>'require'
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
|
||||
if(!isset($data['account'])){
|
||||
return json(['code' => 1,'msg'=>'account not null']);
|
||||
}
|
||||
//账号是否存在
|
||||
$isExist = $this->user_obj->where(['account' => $data['account']])->find();
|
||||
if(!$isExist){
|
||||
return json(['code' => 1,'msg'=>'account not exist']);
|
||||
}
|
||||
// 基本信息
|
||||
$baseInfo = $this->user_obj->where(['account' => $data['account']])->field('user_id,account,realname,email,ctime,orcid,icon,type')->find();
|
||||
$userInfo['baseInfo'] = $baseInfo;
|
||||
$baseInfo = $this->user_obj->where(['user_id' => $data['user_id']])->find();
|
||||
// $userInfo['baseInfo'] = $baseInfo;
|
||||
|
||||
//检查用户reviewer的info信息
|
||||
$reviewer_info = $this->user_reviewer_info_obj->where('reviewer_id',$data['user_id'])->find();
|
||||
if(!$reviewer_info){
|
||||
$insert_reviewer['reviewer_id'] = $data['user_id'];
|
||||
$this->user_reviewer_info_obj->insert($insert_reviewer);
|
||||
}
|
||||
|
||||
$userInfo['baseInfo']=$this->user_obj
|
||||
// ->field("t_user.*,")
|
||||
->join('t_user_reviewer_info','t_user.user_id = t_user_reviewer_info.reviewer_id','left')
|
||||
->where('t_user.user_id',$data['user_id'])
|
||||
->find();
|
||||
|
||||
//cv信息
|
||||
$cvs = $this->user_cv_obj->where('user_id',$data['user_id'])->where('state',0)->select();
|
||||
$userInfo['cvs'] = $cvs;
|
||||
// 默认为作者(若作者没有发表过文章则不返回)
|
||||
$isAuthor = $this->article_obj->where(['user_id'=>$baseInfo['user_id']])->find();
|
||||
if($isAuthor){
|
||||
@@ -67,32 +86,49 @@ class Ucenter extends Controller{
|
||||
if($isReviewer){
|
||||
$userInfo['asReviewer'] = self::getAsReviewer($baseInfo['user_id']);
|
||||
}
|
||||
|
||||
// 编辑
|
||||
if($baseInfo['type'] == 2){
|
||||
$editor = self::getAsEditor($baseInfo['user_id']);
|
||||
if(!empty($editor)){
|
||||
$userInfo['asEditor'] = $editor;
|
||||
}
|
||||
//编委信息
|
||||
$isBoard = $this->board_to_journal_obj->where('user_id',$baseInfo['user_id'])->where('state',0)->select();
|
||||
if($isBoard){
|
||||
$userInfo['asBoard'] = self::getAsBoard($baseInfo['user_id']);
|
||||
}
|
||||
// 主编
|
||||
$isChief = $this->chief_to_journal_obj->where(['user_id'=>$baseInfo['user_id'],'state'=>0])->find();
|
||||
if(!empty($isChief)){
|
||||
$userInfo['asChief'] = self::getAsChief($baseInfo['user_id']);
|
||||
}
|
||||
|
||||
// 编委
|
||||
// $isBoard = $this->board_to_journal_obj->where(['user_id'=>$baseInfo['user_id'],'state'=>0])->select();
|
||||
// if(!empty($isBoard)){
|
||||
// $userInfo['asBoard'] = self::getAsBoard($isBoard);
|
||||
// }
|
||||
// 客座编辑 asGuestEditor
|
||||
|
||||
// 青年编委 asYBoard
|
||||
|
||||
return jsonSuccess($userInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加用户cv
|
||||
*/
|
||||
public function addUserCv(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
'user_id'=>'require',
|
||||
'cv'=>'require'
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$insert['user_id'] = $data['user_id'];
|
||||
$insert['cv'] = $data['cv'];
|
||||
$insert['ctime'] = time();
|
||||
$this->user_cv_obj->insert($insert);
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户简历
|
||||
*/
|
||||
public function delUserCv(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
'user_cv_id'=>'require'
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$this->user_cv_obj->where('user_cv_id',$data['user_cv_id'])->update(['state'=>1]);
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 修改个人基本信息baseInfo
|
||||
* User: wangzhaocui
|
||||
@@ -102,23 +138,30 @@ class Ucenter extends Controller{
|
||||
*/
|
||||
public function updateUserInfo(){
|
||||
$data = $this->request->post();
|
||||
if(!isset($data['account']) || !isset($data['realname']) || !isset($data['email'])){
|
||||
return json(['code' => 1,'msg'=>'account not null']);
|
||||
$rule = new Validate([
|
||||
'user_id'=>'require',
|
||||
'realname'=>'require',
|
||||
'technical'=>'require',
|
||||
'country'=>'require',
|
||||
'major'=>'require|number',
|
||||
'field'=>'require'
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
//验证邮箱是否合规
|
||||
if(!preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/",$data['email'])){
|
||||
return json(['code'=>1,'msg'=>'Invalid email']);
|
||||
$update['realname'] = trim($data['realname']);
|
||||
if(isset($data['phone'])&&$data['phone']!=''){
|
||||
$update['phone'] = $data['phone'];
|
||||
}
|
||||
// 邮箱是否已经被绑定
|
||||
$res = $this->user_obj->where(['email'=>$data['email']])->find();
|
||||
if($res){
|
||||
return json(['code' => 1,'msg'=>'email is exist']);
|
||||
}
|
||||
$update=[
|
||||
'realname'=>$data['realname'],
|
||||
'email'=>$data['email']
|
||||
$this->user_obj->where(['user_id'=>$data['user_id']])->update($update);
|
||||
$updata1=[
|
||||
'technical'=>$data['technical'],
|
||||
'country'=>$data['country'],
|
||||
'major'=>$data['major'],
|
||||
'field'=>$data['field'],
|
||||
'introduction'=>$data['introduction'],
|
||||
];
|
||||
$this->user_obj->where(['account'=>$data['account']])->update($update);
|
||||
$this->user_reviewer_info_obj->where(['reviewer_id'=>$data['user_id']])->update($updata1);
|
||||
return jsonSuccess([]);
|
||||
|
||||
}
|
||||
@@ -130,30 +173,29 @@ class Ucenter extends Controller{
|
||||
* Time: 17:02
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function updateAsReviewerInfo(){
|
||||
$data = $this->request->post();
|
||||
// 验证规则
|
||||
$rule = new Validate([
|
||||
'user_id'=>'require|number',
|
||||
'technical'=>'require',
|
||||
'country'=>'require',
|
||||
'major'=>'require|number',
|
||||
'field'=>'require',
|
||||
// 'introduction'=>'require'
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return json(['code' => 1,'msg'=>$rule->getError()]);
|
||||
}
|
||||
$updata=[
|
||||
'technical'=>$data['technical'],
|
||||
'country'=>$data['country'],
|
||||
'major'=>$data['major'],
|
||||
'field'=>$data['field'],
|
||||
'introduction'=>$data['introduction'],
|
||||
];
|
||||
$this->user_reviewer_info_obj->where(['reviewer_id'=>$data['user_id']])->update($updata);
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
// public function updateAsReviewerInfo(){
|
||||
// $data = $this->request->post();
|
||||
// // 验证规则
|
||||
// $rule = new Validate([
|
||||
// 'user_id'=>'require|number',
|
||||
// 'technical'=>'require',
|
||||
// 'country'=>'require',
|
||||
// 'major'=>'require|number',
|
||||
// 'field'=>'require'
|
||||
// ]);
|
||||
// if(!$rule->check($data)){
|
||||
// return json(['code' => 1,'msg'=>$rule->getError()]);
|
||||
// }
|
||||
// $updata=[
|
||||
// 'technical'=>$data['technical'],
|
||||
// 'country'=>$data['country'],
|
||||
// 'major'=>$data['major'],
|
||||
// 'field'=>$data['field'],
|
||||
// 'introduction'=>$data['introduction'],
|
||||
// ];
|
||||
// $this->user_reviewer_info_obj->where(['reviewer_id'=>$data['user_id']])->update($updata);
|
||||
// return jsonSuccess([]);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Notes:修改 asEditor 信息
|
||||
@@ -195,31 +237,30 @@ class Ucenter extends Controller{
|
||||
*/
|
||||
public function updateIncon(){
|
||||
// 获取表单上传文件
|
||||
$file = request()->file('icon');
|
||||
$data = $this->request->post();
|
||||
if(!$file){
|
||||
return json(['code'=>1,'msg'=>'icon not null']);
|
||||
$rule = new Validate([
|
||||
'user_id'=>'require',
|
||||
'icon'=>'require'
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
if(!isset($data['account']) || empty($data['account'])){
|
||||
return json(['code'=>1,'msg'=>'account not null']);
|
||||
}
|
||||
// 移动到框架应用根目录/public/icon/ 目录下
|
||||
if($file){
|
||||
$info = $file->move(ROOT_PATH . 'public' . DS . 'icon');
|
||||
if($info){
|
||||
// 输出 icon/20160820/42a79759f284b767dfcb2a0197904287.jpg
|
||||
$icon = 'icon/'.str_replace("\\", "/", $info->getSaveName());
|
||||
// 更新数据库
|
||||
$this->user_obj->where(['account'=>$data['account']])->update(['icon'=>$icon]);
|
||||
return jsonSuccess(['account'=>$data['account'],'icon'=>$icon]);
|
||||
}else{
|
||||
// 上传失败获取错误信息
|
||||
return json(['code'=>1,'msg'=>$file->getError()]);
|
||||
$this->user_obj->where(['user_id'=>$data['user_id']])->update(['icon'=>$data['icon']]);
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
public function up_userIcon_file()
|
||||
{
|
||||
$file = request()->file('icon');
|
||||
if ($file) {
|
||||
$info = $file->move(ROOT_PATH . 'public' . DS . 'usericon');
|
||||
if ($info) {
|
||||
return json(['code' => 0, 'upurl' => str_replace("\\", "/", $info->getSaveName())]);
|
||||
} else {
|
||||
return json(['code' => 1, 'msg' => $file->getError()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 作者信息
|
||||
* User: wangzhaocui
|
||||
@@ -246,6 +287,19 @@ class Ucenter extends Controller{
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function getMajor(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
'major_id'=>'require'
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$major = $this->major_obj->where('major_id',$data['major_id'])->find();
|
||||
$major['children'] = $this->major_obj->where('pid',$major['major_id'])->select();
|
||||
$re['major'] = $major;
|
||||
return jsonSuccess($re);
|
||||
}
|
||||
/**
|
||||
* Notes:获取审稿人
|
||||
* User: admin
|
||||
@@ -255,7 +309,10 @@ class Ucenter extends Controller{
|
||||
*/
|
||||
private function getAsReviewer($userId){
|
||||
// 获取审稿人基本信息
|
||||
$res = $this->user_reviewer_info_obj->field('gender,technical,country,major,field,introduction')->where(['reviewer_id'=>$userId])->find();
|
||||
$res = $this->user_reviewer_info_obj->where(['reviewer_id'=>$userId])->find();
|
||||
|
||||
$res['majors'] = self::getMajorShu($res['major']);
|
||||
|
||||
|
||||
// 获取审稿人期刊
|
||||
$journal = $this->reviewer_to_journal_obj->field('t_journal.title,t_journal.abbr')
|
||||
@@ -263,16 +320,23 @@ class Ucenter extends Controller{
|
||||
->where(['t_reviewer_to_journal.reviewer_id'=>$userId,'t_reviewer_to_journal.state'=>0])
|
||||
->select();
|
||||
// 审稿人成功审稿次数
|
||||
$reviewerWhere=[
|
||||
'reviewer_id'=>$userId,
|
||||
'state'=>3
|
||||
];
|
||||
$successReview = $this->article_reviewer_obj->where($reviewerWhere)->count();
|
||||
$successReview = $this->article_reviewer_obj->where('reviewer_id',$userId)->where('state','in',[1,2,3])->count();
|
||||
|
||||
$res['successReview'] = $successReview;
|
||||
$res['journal'] = $journal;
|
||||
return $res;
|
||||
}
|
||||
|
||||
private function getMajorShu($major){
|
||||
$res = $this->major_obj->where('major_id',$major)->find();
|
||||
if($res['pid']==1){
|
||||
return $res['major_id'];
|
||||
}
|
||||
|
||||
$p = self::getMajorShu($res['pid']);
|
||||
return $p.','.$res['major_id'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 编辑的期刊资料
|
||||
* User: wangzhaocui
|
||||
@@ -319,41 +383,34 @@ class Ucenter extends Controller{
|
||||
* @param $data
|
||||
* @return array
|
||||
*/
|
||||
private function getAsBoard($data){
|
||||
private function getAsBoard($user_id){
|
||||
$data = $this->board_to_journal_obj->where('user_id',$user_id)->where('state',0)->select();
|
||||
foreach ($data as $k=>$v){
|
||||
// 查找期刊title
|
||||
$data[$k]= $this->journal_obj->where('journal_id',$v['journal_id'])->field('journal_id,title,issn,abbr')->find();
|
||||
// $data[$k]= $this->journal_obj->where('journal_id',$v['journal_id'])->field('journal_id,title,issn,abbr')->find();
|
||||
$data[$k]= $this->journal_obj->where('journal_id',$v['journal_id'])->find();
|
||||
// 其他编委名字
|
||||
$otherBoards = $this->board_to_journal_obj->field('t_user.realname')
|
||||
->join('t_user','t_user.user_id = t_board_to_journal.user_id')
|
||||
->where('t_board_to_journal.journal_id',$v['journal_id'])
|
||||
->select();
|
||||
$data[$k]['otherBoards'] = array_column($otherBoards, 'realname');
|
||||
// $otherBoards = $this->board_to_journal_obj->field('t_user.realname')
|
||||
// ->join('t_user','t_user.user_id = t_board_to_journal.user_id')
|
||||
// ->where('t_board_to_journal.journal_id',$v['journal_id'])
|
||||
// ->select();
|
||||
// $data[$k]['otherBoards'] = array_column($otherBoards, 'realname');
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 客座编辑资料(未完成)
|
||||
* User: wangzhaocui
|
||||
* Date: 2022/3/16
|
||||
* Time: 10:22
|
||||
* @param $userId
|
||||
*/
|
||||
private function getAsGuestEditor($userId){
|
||||
return ;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 青年编委
|
||||
* User: wangzhaocui
|
||||
* Date: 2022/3/17
|
||||
* Time: 16:01
|
||||
* @param $userId
|
||||
*/
|
||||
private function getAsYBoard($userId){
|
||||
return ;
|
||||
|
||||
public function up_cv_file()
|
||||
{
|
||||
$file = request()->file('reviewerCV');
|
||||
if ($file) {
|
||||
$info = $file->move(ROOT_PATH . 'public' . DS . 'reviewer');
|
||||
if ($info) {
|
||||
return json(['code' => 0, 'upurl' => str_replace("\\", "/", $info->getSaveName())]);
|
||||
} else {
|
||||
return json(['code' => 1, 'msg' => $file->getError()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user