This commit is contained in:
wangjinlei
2023-08-31 16:21:39 +08:00
parent d7edd953a4
commit adc0bd0e90
8 changed files with 232 additions and 50 deletions

View File

@@ -2,7 +2,7 @@
namespace app\api\controller;
use think\Controller;
use app\api\controller\Base;
use think\Db;
use think\Queue;
use think\Validate;
@@ -11,54 +11,23 @@ use think\Validate;
* @title 编委相关接口
* @description 编委相关接口
*/
class Board extends Controller {
class Board extends Base {
protected $article_obj = '';
protected $user_obj = '';
protected $user_act_obj = '';
protected $journal_obj = '';
protected $user_log_obj = '';
protected $reviewer_major_obj = '';
protected $reviewer_to_journal_obj = '';
protected $article_msg_obj = '';
protected $article_file_obj = '';
protected $article_reviewer_obj = '';
protected $article_author_obj = '';
protected $article_transfer_obj = '';
protected $staff_obj = '';
protected $staff_level_obj = '';
protected $staff_log_obj = '';
protected $staff_to_journal_obj = '';
protected $chief_to_journal_obj = '';
protected $board_to_journal_obj = '';
protected $chief_msg_obj = '';
protected $article_to_board_obj = '';
protected $login_auto_obj = '';
public function __construct(\think\Request $request = null) {
parent::__construct($request);
$this->user_obj = Db::name('user');
$this->user_act_obj = Db::name('user_act');
$this->article_obj = Db::name('article');
$this->journal_obj = Db::name('journal');
$this->user_log_obj = Db::name('user_log');
$this->reviewer_major_obj = Db::name('reviewer_major');
$this->reviewer_to_journal_obj = Db::name('reviewer_to_journal');
$this->article_msg_obj = Db::name('article_msg');
$this->article_file_obj = Db::name('article_file');
$this->article_reviewer_obj = Db::name('article_reviewer');
$this->article_author_obj = Db::name('article_author');
$this->article_transfer_obj = Db::name('article_transfer');
$this->staff_obj = Db::name('staff');
$this->staff_level_obj = Db::name('staff_level');
$this->staff_log_obj = Db::name('staff_log');
$this->staff_to_journal_obj = Db::name('staff_to_journal');
$this->chief_to_journal_obj = Db::name('chief_to_journal');
$this->board_to_journal_obj = Db::name('board_to_journal');
$this->chief_msg_obj = Db::name('chief_msg');
$this->article_to_board_obj = Db::name('article_to_board');
$this->chief_to_journal_obj = Db::name('chief_to_journal');
$this->login_auto_obj = Db::name('login_auto');
}
/**
@@ -290,10 +259,23 @@ class Board extends Controller {
}
public function getBoards(){
$data = $this->request->post();
$rule = new Validate([
"journal_id"=>"require"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$re['boards'] = $this->getBoardsForJournal($data['journal_id']);
return jsonSuccess($re);
}
/**
* 获取编委列表
*/
public function getBoards(){
public function getBoards1(){
$data = $this->request->post();
$rule = new Validate([
'journal_id'=>'require',
@@ -372,10 +354,22 @@ class Board extends Controller {
return jsonSuccess($re);
}
public function delBoard(){
$data = $this->request->post();
$rule = new Validate([
"btj_id"=>"require"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$this->board_to_journal_obj->where('btj_id',$data['btj_id'])->update(['state'=>1]);
return jsonSuccess([]);
}
/**
* 删除编委
*/
public function delBoard(){
public function delBoard1(){
$data = $this->request->post();
$rule = new Validate([
'board_id' => 'require'
@@ -393,10 +387,24 @@ class Board extends Controller {
return jsonSuccess([]);
}
/**
* 获取编委分组列表
*/
public function getBoardGroupList(){
$data = $this->request->post();
$rule = new Validate([
"journal_id"=>"require"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$groups = $this->board_group_obj->where('journal_id',$data['journal_id'])->where("state",0)->select();
$re['groups'] = $groups;
return jsonSuccess($re);
}
/**
* 获取编委分组列表(原版)
*/
public function getBoardGroupList1(){
$data = $this->request->post();
$rule = new Validate([
'journal_id'=>'require'
@@ -417,7 +425,7 @@ class Board extends Controller {
/**
* 添加编委分组
*/
public function addBoardGroup(){
public function addBoardGroup1(){
$data = $this->request->post();
$rule = new Validate([
'journal_id'=>'require|number',
@@ -435,10 +443,25 @@ class Board extends Controller {
return jsonSuccess([]);
}
public function addBoardGroup(){
$data = $this->request->post();
$rule = new Validate([
'journal_id'=>'require|number',
'group_name'=>'require'
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$insert['journal_id'] = $data['journal_id'];
$insert['group_name'] = trim($data['group_name']);
$this->board_group_obj->insert($insert);
return jsonSuccess([]);
}
/**
* 删除编委分组
*/
public function delBoardGroup(){
public function delBoardGroup1(){
$data = $this->request->post();
$rule = new Validate([
'board_group_id'=>'require'
@@ -457,10 +480,53 @@ class Board extends Controller {
}
}
public function delBoardGroup(){
$data = $this->request->post();
$rule = new Validate([
'board_group_id'=>'require'
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$check = $this->board_to_journal_obj->where('board_group_id',$data['board_group_id'])->where('state',0)->find();
if($check){
return jsonError("Please note that there are editorial committee members in the group, and you cannot delete this group.");
}
$this->board_group_obj->where('board_group_id',$data['board_group_id'])->update(['state'=>1]);
return jsonSuccess([]);
}
public function addBoard(){
$data = $this->request->post();
$rule = new Validate([
"user_id"=>"require",
"journal_id"=>"require",
"type"=>"require",
"board_group_id"=>"require",
"research_areas"=>"require"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$check = $this->board_to_journal_obj->where('user_id',$data['user_id'])->where('state',0)->find();
if($check){
return jsonError("According to TMR Publishing Group Policy, scientists are not allowed to serve on the editorial board of more than one journal at the same time.");
}
//添加对应关系
$insert['user_id'] = $data['user_id'];
$insert['journal_id'] = $data['journal_id'];
$insert['type'] = $data['type'];
$insert['board_group_id'] = $data['board_group_id'];
$insert['research_areas'] = trim($data['research_areas']);
$this->board_to_journal_obj->insert($insert);
return jsonSuccess([]);
}
/**
* 添加编委
*/
public function addBoard(){
public function addBoard1(){
$data = $this->request->post();
$rule = new Validate([
'user_id'=>'require',
@@ -515,10 +581,28 @@ class Board extends Controller {
return jsonSuccess([]);
}
public function editBoard(){
$data = $this->request->post();
$rule = new Validate([
"btj_id"=>"require",
"type"=>'require',
"board_group_id"=>"require",
"research_areas"=>"require"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$update['type'] = $data['type'];
$update['board_group_id'] = $data['type']==2?$data['board_group_id']:0;
$update['research_areas'] = trim($data['research_areas']);
$this->board_to_journal_obj->where('btj_id',$data['btj_id'])->update($update);
return jsonSuccess([]);
}
/**
* 编辑编委信息
*/
public function editBoard(){
public function editBoard1(){
$data = $this->request->post();
$rule = new Validate([
'board_id'=>'require',