This commit is contained in:
wangjinlei
2022-06-21 17:24:06 +08:00
parent 7016414402
commit d1e973388a
8 changed files with 633 additions and 283 deletions

View File

@@ -245,7 +245,7 @@ class User extends Controller
$check = $this->user_obj
->where('state', 0)
->where('account = "'.$data['account'].'" or email = "'.$data['email'].'"')
->where('account = "' . trim($data['account']) . '" or email = "' . trim($data['email']) . '"')
->find();
if ($check) {
return jsonError('用户已经存在');
@@ -263,11 +263,12 @@ class User extends Controller
/**
* 获取所有编辑
*/
public function getAllEditor(){
$editors = $this->user_obj->where('type',2)->where('state',0)->select();
public function getAllEditor()
{
$editors = $this->user_obj->where('type', 2)->where('state', 0)->select();
//获取编辑管理的期刊
foreach($editors as $k => $v){
$cache_journals = $this->journal_obj->where('editor_id',$v['user_id'])->where('state',0)->select();
foreach ($editors as $k => $v) {
$cache_journals = $this->journal_obj->where('editor_id', $v['user_id'])->where('state', 0)->select();
$editors[$k]['journals'] = $cache_journals;
}
$re['editors'] = $editors;
@@ -277,20 +278,21 @@ class User extends Controller
/**
* 修改编辑密码
*/
public function changeEditorPassword(){
public function changeEditorPassword()
{
$data = $this->request->post();
// 验证规则
$rule = new Validate([
'user_id'=>'require|number',
'password'=>'require'
'user_id' => 'require|number',
'password' => 'require'
]);
if(!$rule->check($data)){
return json(['code' => 1,'msg'=>$rule->getError()]);
if (!$rule->check($data)) {
return json(['code' => 1, 'msg' => $rule->getError()]);
}
$this->user_obj->where('user_id',$data['user_id'])->update(['password'=>md5($data['password'])]);
$this->user_obj->where('user_id', $data['user_id'])->update(['password' => md5($data['password'])]);
return jsonSuccess([]);
}
/**
* @title 消除黑名单
@@ -370,22 +372,23 @@ class User extends Controller
/**
* 获取用户详细信息
*/
public function getUserDetail(){
public function getUserDetail()
{
$data = $this->request->post();
$rule = new Validate([
'user_id' => 'require'
]);
if(!$rule->check($data)){
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$user_info = $this->user_obj->where("user_id",$data['user_id'])->where('state',0)->find();
$user_info = $this->user_obj->where("user_id", $data['user_id'])->where('state', 0)->find();
$user_info['roles'] = $this->getUserRoles($user_info['account']);
//获取用户的客座期刊的详细信息
$list = $this->user_to_special_obj->where('user_id',$user_info['user_id'])->where('uts_state',0)->select();
$list = $this->user_to_special_obj->where('user_id', $user_info['user_id'])->where('uts_state', 0)->select();
$specials = [];
foreach($list as $k => $v){
foreach ($list as $k => $v) {
$cache_info = $this->getSpecialDetailById($v['special_id']);
$cache_journal = $this->journal_obj->where('issn',$cache_info['journal_issn'])->find();
$cache_journal = $this->journal_obj->where('issn', $cache_info['journal_issn'])->find();
$cache_info['journal_id'] = $cache_journal['journal_id'];
$specials[] = $cache_info;
}
@@ -398,19 +401,20 @@ class User extends Controller
/**
* 获取用户所有客座专刊
*/
public function getUserAllSpecials(){
public function getUserAllSpecials()
{
$data = $this->request->post();
$rule = new Validate([
'user_id' => 'require'
]);
if(!$rule->check($data)){
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$list = $this->user_to_special_obj->where('user_id',$data['user_id'])->where('uts_state',0)->select();
$list = $this->user_to_special_obj->where('user_id', $data['user_id'])->where('uts_state', 0)->select();
$specials = [];
foreach($list as $k => $v){
foreach ($list as $k => $v) {
$cache_info = $this->getSpecialDetailById($v['special_id']);
$cache_journal = $this->journal_obj->where('issn',$cache_info['journal_issn'])->find();
$cache_journal = $this->journal_obj->where('issn', $cache_info['journal_issn'])->find();
$cache_info['journal_id'] = $cache_journal['journal_id'];
$specials[] = $cache_info;
}
@@ -419,10 +423,11 @@ class User extends Controller
}
public function getSpecialDetailById($special_id){
public function getSpecialDetailById($special_id)
{
$base_url = Env::get('journal.base_url');
$api_url = $base_url."/master/special/getSpecialDetailById";
$res = object_to_array(json_decode(myPost($api_url,['journal_special_id'=>$special_id])));
$api_url = $base_url . "/master/special/getSpecialDetailById";
$res = object_to_array(json_decode(myPost($api_url, ['journal_special_id' => $special_id])));
$special_info = $res['data']['special'];
unset($special_info['journal_id']);
return $special_info;
@@ -431,22 +436,23 @@ class User extends Controller
/**
* 添加用户身份
*/
public function addUserRole(){
public function addUserRole()
{
$data = $this->request->post();
$rule = new Validate([
'user_id' => 'require',
'role_type'=> 'require'
'role_type' => 'require'
]);
if(!$rule->check($data)){
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
if($data['role_type']=='special'){
if(!isset($data['special_id'])){
if ($data['role_type'] == 'special') {
if (!isset($data['special_id'])) {
return jsonError("添加客座编辑身份时客座id是必传项");
}
$check = $this->user_to_special_obj->where("user_id",$data['user_id'])->where('special_id',$data['special_id'])->where('uts_state',0)->find();
if($check){
$check = $this->user_to_special_obj->where("user_id", $data['user_id'])->where('special_id', $data['special_id'])->where('uts_state', 0)->find();
if ($check) {
return jsonError("不可重复添加");
}
$insert_uts['user_id'] = $data['user_id'];
@@ -455,7 +461,6 @@ class User extends Controller
$this->user_to_special_obj->insert($insert_uts);
return jsonSuccess([]);
}
}
@@ -531,8 +536,8 @@ class User extends Controller
if ($board_res != null) {
$roles[] = 'board';
}
$special_res = $this->user_to_special_obj->where('user_id',$user_info['user_id'])->where("uts_state",0)->find();
if($special_res != null){
$special_res = $this->user_to_special_obj->where('user_id', $user_info['user_id'])->where("uts_state", 0)->find();
if ($special_res != null) {
$roles[] = 'special';
}
return $roles;
@@ -736,7 +741,7 @@ class User extends Controller
$url = config('base_web_url') . 'retrieveact?actkey=' . $act_insert['act_key'];
$title = 'Your request to reset your password [TMR Publishing Group]';
$content = "$realname, we've received your request to reset your password.Please click the link below to change your password. <a href='$url' target='_blank'>$url</a>";
$res = sendEmail($email, $title, 'TMR', $content,Env::get('email.send_email'),Env::get("email.send_email_password"));
$res = sendEmail($email, $title, 'TMR', $content, Env::get('email.send_email'), Env::get("email.send_email_password"));
// if ($isUserPushed) {//成功
return json(['code' => 0, 'msg' => 'success']);
// } else {//失败
@@ -994,19 +999,23 @@ class User extends Controller
return jsonError("has reviewer");
}
$info_check = $this->user_reviewer_info_obj->where('reviewer_id', $user_info['user_id'])->find();
Db::startTrans();
$insert_info['reviewer_id'] = $user_info['user_id'];
$insert_info['gender'] = $data['gender'];
$insert_info['technical'] = $data['author_title'];
$insert_info['country'] = $data['country'];
$insert_info['introduction'] = $data['introduction'];
$insert_info['company'] = $data['company'];
$insert_info['major'] = $data['major'];
$insert_info['field'] = $data['field'];
$insert_info['qualifications'] = $data['qualifications'];
$res = $this->user_reviewer_info_obj->insertGetId($insert_info);
$res = true;
if ($info_check==null) {
$insert_info['reviewer_id'] = $user_info['user_id'];
$insert_info['gender'] = $data['gender'];
$insert_info['technical'] = $data['author_title'];
$insert_info['country'] = $data['country'];
$insert_info['introduction'] = $data['introduction'];
$insert_info['company'] = $data['company'];
$insert_info['major'] = $data['major'];
$insert_info['field'] = $data['field'];
$insert_info['qualifications'] = $data['qualifications'];
$res = $this->user_reviewer_info_obj->insertGetId($insert_info);
}
$insert_to['reviewer_id'] = $user_info['user_id'];
$insert_to['journal_id'] = $rfa_info['journal_id'];
$insert_to['account'] = $user_info['account'];