Files
journal/application/master/controller/Special.php
2026-08-03 11:08:03 +08:00

623 lines
25 KiB
PHP

<?php
namespace app\master\controller;
use think\Controller;
use think\Db;
use think\Validate;
/**
* @title 客座期刊
* @description 客座期刊
* @group 客座期刊
*/
class Special extends Controller {
//put your code here
protected $admin_obj = '';
protected $journal_obj = '';
protected $article_obj = '';
protected $article_author_obj = '';
protected $journal_topic_obj = '';
protected $journal_stage_obj = '';
protected $journal_notices_obj = '';
protected $journal_abs_obj = '';
protected $journal_special_obj = '';
protected $journal_special_editor_obj = '';
protected $journal_special_to_editor_obj = '';
protected $journal_special_alert_obj = '';
protected $article_to_topic_obj = '';
protected $sys_scient_obj = '';
protected $sys_book_obj = '';
public function __construct(\think\Request $request = null) {
parent::__construct($request);
$this->admin_obj = Db::name('admin');
$this->journal_obj = Db::name('journal');
$this->article_obj = Db::name('article');
$this->article_author_obj = Db::name('article_author');
$this->journal_topic_obj = Db::name('journal_topic');
$this->journal_stage_obj = Db::name('journal_stage');
$this->journal_notices_obj = Db::name('journal_notices');
$this->journal_abs_obj = Db::name('journal_abstracting');
$this->journal_special_obj = Db::name('journal_special');
$this->journal_special_editor_obj = Db::name('journal_special_editor');
$this->journal_special_to_editor_obj = Db::name('journal_special_to_editor');
$this->journal_special_alert_obj = Db::name('journal_special_alert');
$this->article_to_topic_obj = Db::name('article_to_topic');
$this->sys_scient_obj = Db::name('system_scient');
$this->sys_book_obj = Db::name('system_books');
}
/**
* @title 客座期刊(获取列表)
* @description 客座期刊(获取列表)
* @author wangjinlei
* @url /master/Special/getSpecialList
* @method POST
*
* @param name:journal_id type:int require:1 desc:期刊id
* @param name:state type:int require:0 desc:状态
* @param name:pageIndex type:int require:1 desc:当前页码数
* @param name:pageSize type:int require:1 desc:单页数据条数
*
* @return journal:期刊信息
* @return count:总数
* @return specials:客座期刊列表array#
*/
public function getSpecialList(){
$data = $this->request->post();
$journal_info = $this->journal_obj->where('journal_id',$data['journal_id'])->find();
$where['journal_id'] = $data['journal_id'];
if(isset($data['state'])&&$data['state']!=-1){
$where['state'] = $data['state'];
}else{
$where['state'] = ['<>',1];
}
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
$list = $this->journal_special_obj
->where($where)
->order(['state','journal_special_id desc'])
->limit($limit_start,$data['pageSize'])
->select();
//获取作者
foreach ($list as $k => $v){
$frag = '';
$caches = $this->journal_special_to_editor_obj
->field('j_journal_special_editor.*')
->join('j_journal_special_editor','j_journal_special_editor.journal_special_editor_id = j_journal_special_to_editor.journal_special_editor_id','LEFT')
->where('j_journal_special_to_editor.journal_special_id',$v['journal_special_id'])
->where('j_journal_special_to_editor.state',0)
->select();
foreach ($caches as $val){
$frag = $frag == '' ? $val['first_name'].' '.$val['last_name'] : $frag.', '.$val['first_name'].' '.$val['last_name'];
}
$list[$k]['editor'] = $frag;
$sq = $this->journal_special_to_editor_obj->where('journal_special_id',$v['journal_special_id'])->where('state',2)->select();
if(count($sq)>0){
$list[$k]['has_sq'] = 1;
}else{
$list[$k]['has_sq'] = 0;
}
}
$count = $this->journal_special_obj->where($where)->count();
$re['journal'] = $journal_info;
$re['count'] = $count;
$re['specials'] = $list;
return jsonSuccess($re);
}
/**
* 获取期刊的专刊列表
*/
public function getSpecialByIssn(){
$data = $this->request->post();
$rule = new Validate([
'journal_issn' => 'require'
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$journal_info = $this->journal_obj->where('issn',$data['journal_issn'])->find();
$list = $this->journal_special_obj->where('journal_id',$journal_info['journal_id'])->where('state',2)->select();
$re['specials'] = $list;
return jsonSuccess($re);
}
/**
* @title 客座期刊(更改状态)
* @description 客座期刊(更改状态)
* @author wangjinlei
* @url /master/Special/changeSpecialState
* @method POST
*
* @param name:journal_special_id type:int require:1 desc:客座期刊id
* @param name:state type:int require:1 desc:状态(0:初始1:拒绝2:通过)
*/
public function changeSpecialState(){
$data = $this->request->post();
$this->journal_special_obj->where('journal_special_id',$data['journal_special_id'])->update(['state'=>$data['state']]);
return jsonSuccess([]);
}
/**
* @title 客座期刊(获取详情信息)
* @description 客座期刊(获取详情信息)
* @author wangjinlei
* @url /master/Special/getSpecialDetail
* @method POST
*
* @param name:journal_special_id type:int require:1 desc:客座期刊id
*
* @return special:客座期刊信息
* @return editors:作者array#
* @return applys:申请array#
*/
public function getSpecialDetail(){
$data = $this->request->post();
$special_info = $this->journal_special_obj->where('journal_special_id',$data['journal_special_id'])->find();
$editor_list = $this->journal_special_to_editor_obj->field('j_journal_special_editor.*,j_journal_special_editor.icon specialIcon')
->join('j_journal_special_editor','j_journal_special_editor.journal_special_editor_id = j_journal_special_to_editor.journal_special_editor_id','LEFT')
->where('j_journal_special_to_editor.journal_special_id',$data['journal_special_id'])
->where('j_journal_special_to_editor.state',0)
->select();
$applys = $this->journal_special_to_editor_obj->field('j_journal_special_to_editor.journal_special_to_editor_id,j_journal_special_editor.*')
->join('j_journal_special_editor','j_journal_special_editor.journal_special_editor_id = j_journal_special_to_editor.journal_special_editor_id','LEFT')
->where('j_journal_special_to_editor.journal_special_id',$data['journal_special_id'])
->where('j_journal_special_to_editor.state',2)
->select();
$re['special'] = $special_info;
$re['editors'] = $editor_list;
$re['applys'] = $applys;
return jsonSuccess($re);
}
/**
* 按期刊+邮箱查询客座编辑是否已存在
* @url /master/Special/getSpecialEditorByEmail
*/
public function getSpecialEditorByEmail(){
$data = $this->request->post();
$rule = new Validate([
'journal_id' => 'require|number',
'email' => 'require',
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$email = trim($data['email']);
$exist = $this->journal_special_editor_obj
->where('journal_id', intval($data['journal_id']))
->where('email', $email)
->find();
if (!$exist) {
return jsonSuccess([
'journal_special_editor_id' => 0,
'email' => $email,
]);
}
return jsonSuccess([
'journal_special_editor_id' => intval($exist['journal_special_editor_id']),
'email' => $email,
]);
}
/**
* @title 客座期刊(编辑客座期刊基础信息)
* @description 客座期刊(编辑客座期刊基础信息)
* @author wangjinlei
* @url /master/Special/editSpecialBasic
* @method POST
*
* @param name:journal_special_id type:int require:1 desc:客座期刊id
* @param name:title type:string require:1 desc:标题
* @param name:intro type:string require:1 desc:简介
* @param name:abstract type:string require:1 desc:描述
* @param name:keywords type:string require:1 desc:关键字
* @param name:deadline type:int require:1 desc:截止日期
*
* @return special:客座期刊信息
* @return editors:作者array#
*/
public function editSpecialBasic(){
$data = $this->request->post();
$update['title'] = $data['title'];
$update['intro'] = $data['intro'];
$update['icon'] = $data['icon'];
$update['abstract'] = $data['abstract'];
$update['keywords'] = $data['keywords'];
if (isset($data['deadline'])) {
$update['deadline'] = $data['deadline'];
}
if (isset($data['hasEditor'])) {
$update['hasEditor'] = (intval($data['hasEditor']) === 1) ? 1 : 0;
}
$this->journal_special_obj->where('journal_special_id',$data['journal_special_id'])->update($update);
return jsonSuccess([]);
}
/**
* @title 客座期刊编辑(添加编辑)
* @description 客座期刊编辑(添加编辑)
* @author wangjinlei
* @url /master/Special/addSpecialEditor
* @method POST
*
* @param name:journal_id type:int require:1 desc:期刊id
* @param name:email type:string require:1 desc:邮箱
* @param name:first_name type:string require:1 desc:名字
* @param name:last_name type:string require:1 desc:名字
* @param name:address type:string require:1 desc:地址
* @param name:interests type:string require:0 desc:兴趣
* @param name:website type:string require:0 desc:编辑主页
* @param name:orcid type:string require:0 desc:orcid
* @param name:specialIcon type:string require:1 desc:客座编辑头像
*/
public function addSpecialEditor(){
$data = $this->request->post();
// 验证规则
$rule = new Validate([
'journal_id'=>'require|number',
'email'=>'require',
'first_name'=>'require',
'last_name'=>'require',
'address'=>'require',
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$email = trim($data['email']);
$journalId = intval($data['journal_id']);
$exist = $this->journal_special_editor_obj
->where('journal_id', $journalId)
->where('email', $email)
->find();
if ($exist) {
$editorId = intval($exist['journal_special_editor_id']);
$update = [
'first_name' => trim($data['first_name']),
'last_name' => trim($data['last_name']),
'address' => trim($data['address']),
'interests' => isset($data['interests'])?trim($data['interests']):'',
'website' => isset($data['website'])?trim($data['website']):'',
'orcid' => isset($data['orcid'])?trim($data['orcid']):'',
];
if (isset($data['specialIcon']) && trim($data['specialIcon']) !== '') {
$update['icon'] = trim($data['specialIcon']);
}
$this->journal_special_editor_obj->where('journal_special_editor_id', $editorId)->update($update);
return jsonSuccess(['journal_special_editor_id' => $editorId]);
}
$insert['journal_id'] = $journalId;
$insert['email'] = $email;
$insert['first_name'] = trim($data['first_name']);
$insert['last_name'] = trim($data['last_name']);
$insert['address'] = trim($data['address']);
$insert['interests'] = isset($data['interests'])?trim($data['interests']):'';
$insert['website'] = isset($data['website'])?trim($data['website']):'';
$insert['orcid'] = isset($data['orcid'])?trim($data['orcid']):'';
$insert['icon'] = isset($data['specialIcon'])?trim($data['specialIcon']):'';
$editorId = $this->journal_special_editor_obj->insertGetId($insert);
if (!$editorId) {
return jsonError('add special editor failed');
}
return jsonSuccess(['journal_special_editor_id' => intval($editorId)]);
}
/**
* 获取客座期刊信息通过主键
*/
public function getSpecialDetailById(){
$data = $this->request->post();
$rule = new Validate([
'journal_special_id' => 'require'
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$special = $this->journal_special_obj
->field('j_journal_special.*,j_journal.title journal_title,j_journal.issn journal_issn')
->join("j_journal",'j_journal.journal_id = j_journal_special.journal_id','left')
->where('j_journal_special.journal_special_id',$data['journal_special_id'])
->find();
$re['special'] = $special;
return jsonSuccess($re);
}
/**
* @title 客座期刊编辑(更改编辑)
* @description 客座期刊编辑(更改编辑)
* @author wangjinlei
* @url /master/Special/editSpecialEditor
* @method POST
*
* @param name:journal_special_editor_id type:int require:1 desc:客座期刊编辑id
* @param name:email type:string require:1 desc:邮箱
* @param name:first_name type:string require:1 desc:名字
* @param name:last_name type:string require:1 desc:名字
* @param name:address type:string require:1 desc:地址
* @param name:interests type:string require:0 desc:兴趣
* @param name:website type:string require:0 desc:编辑主页
* @param name:orcid type:string require:0 desc:orcid
* @param name:specialIcon type:string require:1 desc:客座编辑头像
*/
public function editSpecialEditor(){
$data = $this->request->post();
$update['email'] = trim($data['email']);
$update['first_name'] = trim($data['first_name']);
$update['last_name'] = trim($data['last_name']);
$update['address'] = trim($data['address']);
$update['interests'] = trim($data['interests']);
$update['website'] = trim($data['website']);
$update['orcid'] = trim($data['orcid']);
$update['icon'] = trim($data['specialIcon']);
$this->journal_special_editor_obj->where('journal_special_editor_id',$data['journal_special_editor_id'])->update($update);
return jsonSuccess([]);
}
/**
* @title 客座期刊编辑(获取编辑列表,除去已经建立联系的)
* @description 客座期刊编辑(获取编辑列表,除去已经建立联系的)
* @author wangjinlei
* @url /master/Special/getSpecialEditors
* @method POST
*
* @param name:journal_id type:int require:1 desc:期刊id
* @param name:journal_special_id type:int require:1 desc:客座期刊编辑id
* @param name:pageIndex type:int require:1 desc:当前页码数
* @param name:pageSize type:int require:1 desc:单页数据条数
*
* @return count:总数
* @return editors:编辑列表array#
*/
public function getSpecialEditors(){
$data = $this->request->post();
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
$cids = $this->journal_special_to_editor_obj->where('journal_special_id',$data['journal_special_id'])->where('state','<>',1)->column('journal_special_editor_id');
$list = $this->journal_special_editor_obj->where('journal_special_editor_id','not in',$cids)->where('state',0)->limit($limit_start,$data['pageSize'])->select();
$count = $this->journal_special_editor_obj->where('journal_special_editor_id','not in',$cids)->where('state',0)->count();
foreach ($list as $k => $v){
$list[$k]['specialIcon'] = $v['icon'];
}
$re['count'] = $count;
$re['editors'] = $list;
return jsonSuccess($re);
}
/**
* @title 客座期刊编辑(添加客座期刊与作者的对应关系)
* @description 客座期刊编辑(添加客座期刊与作者的对应关系)
* @author wangjinlei
* @url /master/Special/addSpecialToEditor
* @method POST
*
* @param name:journal_id type:int require:1 desc:期刊id
* @param name:journal_special_id type:int require:1 desc:客座期刊id
* @param name:journal_special_editor_id type:int require:1 desc:客座期刊编辑id
*/
public function addSpecialToEditor(){
$data = $this->request->post();
$specialId = intval($data['journal_special_id']);
$editorId = intval($data['journal_special_editor_id']);
$journalId = intval($data['journal_id']);
$exist = $this->journal_special_to_editor_obj
->where('journal_special_id', $specialId)
->where('journal_special_editor_id', $editorId)
->find();
if ($exist) {
if (intval($exist['state']) !== 0) {
$this->journal_special_to_editor_obj
->where('journal_special_to_editor_id', $exist['journal_special_to_editor_id'])
->update(['state' => 0]);
}
return jsonSuccess([]);
}
$insert['journal_special_id'] = $specialId;
$insert['journal_special_editor_id'] = $editorId;
$insert['journal_id'] = $journalId;
$this->journal_special_to_editor_obj->insert($insert);
return jsonSuccess([]);
}
/**
* @title 客座期刊编辑(删除客座期刊与作者的对应关系)
* @description 客座期刊编辑(删除客座期刊与作者的对应关系)
* @author wangjinlei
* @url /master/Special/delSpecialToEditor
* @method POST
*
* @param name:journal_special_id type:int require:1 desc:客座期刊id
* @param name:journal_special_editor_id type:int require:1 desc:期刊编辑id
*/
public function delSpecialToEditor(){
$data = $this->request->post();
$this->journal_special_to_editor_obj
->where('journal_special_id',$data['journal_special_id'])
->where('journal_special_editor_id',$data['journal_special_editor_id'])
->update(['state'=>1]);
return jsonSuccess([]);
}
/**
* @title 客座期刊编辑(按邮箱解除客座期刊与作者的对应关系)
* @description 客座期刊编辑(按邮箱解除客座期刊与作者的对应关系)
* @author wangjinlei
* @url /master/Special/delSpecialToEditorByEmail
* @method POST
*
* @param name:journal_special_id type:int require:1 desc:客座期刊id
* @param name:email type:string require:1 desc:客座编辑邮箱
*/
public function delSpecialToEditorByEmail(){
$data = $this->request->post();
$rule = new Validate([
'journal_special_id' => 'require|number',
'email' => 'require',
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$specialId = intval($data['journal_special_id']);
$email = trim($data['email']);
$editorIds = $this->journal_special_editor_obj
->where('email', $email)
->where('state', 0)
->column('journal_special_editor_id');
if(empty($editorIds)){
return jsonError('editor not found');
}
$this->journal_special_to_editor_obj
->where('journal_special_id', $specialId)
->where('journal_special_editor_id', 'in', $editorIds)
->where('state', '<>', 1)
->update(['state' => 1]);
return jsonSuccess([]);
}
/**
* @title 客座期刊编辑(解除专刊下全部客座编辑绑定)
* @description 客座期刊编辑(解除专刊下全部客座编辑绑定)
* @author wangjinlei
* @url /master/Special/delAllSpecialToEditor
* @method POST
*
* @param name:journal_special_id type:int require:1 desc:客座期刊id
*/
public function delAllSpecialToEditor(){
$data = $this->request->post();
$rule = new Validate([
'journal_special_id' => 'require|number',
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$this->journal_special_to_editor_obj
->where('journal_special_id', $data['journal_special_id'])
->where('state', '<>', 1)
->update(['state' => 1]);
return jsonSuccess([]);
}
/**
* @title 客座期刊编辑(通过申请)
* @description 客座期刊编辑(通过申请)
* @author wangjinlei
* @url /master/Special/adoptEditor
* @method POST
*
* @param name:journal_special_to_editor_id type:int require:1 desc:期刊编辑链接id
*/
public function adoptEditor(){
$data = $this->request->post();
$this->journal_special_to_editor_obj->where('journal_special_to_editor_id',$data['journal_special_to_editor_id'])->update(['state'=>0]);
return jsonSuccess([]);
}
/**
* @title 客座期刊编辑(拒绝申请)
* @description 客座期刊编辑(拒绝申请)
* @author wangjinlei
* @url /master/Special/refuseEditor
* @method POST
*
* @param name:journal_special_to_editor_id type:int require:1 desc:期刊编辑链接id
*/
public function refuseEditor(){
$data = $this->request->post();
$this->journal_special_to_editor_obj->where('journal_special_to_editor_id',$data['journal_special_to_editor_id'])->update(['state'=>1]);
return jsonSuccess([]);
}
/**
* @title 客座期刊提示语(获取)
* @description 客座期刊提示语(获取)
* @author wangjinlei
* @url /master/Special/getSpecialAlert
* @method POST
*
* @param name:journal_id type:int require:1 desc:期刊id
*
* @return alertInfo:提示语信息#
*/
public function getSpecialAlert(){
$data = $this->request->post();
$info = $this->journal_special_alert_obj->where('journal_id',$data['journal_id'])->find();
if($info==null){
$insert['journal_id'] = $data['journal_id'];
$insert['agreement'] = '';
$insert['alert'] = '';
$insert['intro'] = '';
$this->journal_special_alert_obj->insert($insert);
}
$d = $this->journal_special_alert_obj->where('journal_id',$data['journal_id'])->find();
$re['alertInfo'] = $d;
return jsonSuccess($re);
}
/**
* @title 客座期刊提示语(编辑)
* @description 客座期刊提示语(编辑)
* @author wangjinlei
* @url /master/Special/editSpecialAlert
* @method POST
*
* @param name:special_alert_id type:int require:1 desc:客座提示语id
* @param name:agreement type:string require:1 desc:需知
* @param name:alert type:string require:1 desc:成功提示
* @param name:intro type:string require:1 desc:投稿简介
*/
public function editSpecialAlert(){
$data = $this->request->post();
$update['agreement'] = $data['agreement'];
$update['alert'] = $data['alert'];
$update['intro'] = $data['intro'];
$this->journal_special_alert_obj->where('special_alert_id',$data['special_alert_id'])->update($update);
return jsonSuccess([]);
}
/**
* @title 头像图片上传
* @description 头像图片上传
* @author wangjinlei
* @url /master/Special/up_icon_file
* @method POST
*
* @param name:name type:string require:1 default:specialIcon desc:文件域名称
*
* @return upurl:图片地址
*/
public function up_icon_file() {
$file = request()->file('specialIcon');
if ($file) {
$info = $file->move(ROOT_PATH . 'public' . DS . 'specialIcon');
if ($info) {
return json(['code' => 0, 'msg' => 'success', 'upurl' => str_replace("\\", "/", $info->getSaveName())]);
} else {
return json(['code' => 1, 'msg' => $file->getError()]);
}
}
}
}