20201112
This commit is contained in:
@@ -4,6 +4,7 @@ namespace app\api\controller;
|
|||||||
|
|
||||||
use think\Controller;
|
use think\Controller;
|
||||||
use think\Db;
|
use think\Db;
|
||||||
|
use think\Queue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @title 期刊web接口
|
* @title 期刊web接口
|
||||||
@@ -28,6 +29,8 @@ class Journal extends Controller {
|
|||||||
protected $article_to_line_obj = '';
|
protected $article_to_line_obj = '';
|
||||||
protected $journal_paper_obj = '';
|
protected $journal_paper_obj = '';
|
||||||
protected $journal_paper_art_obj = '';
|
protected $journal_paper_art_obj = '';
|
||||||
|
protected $subscribe_journal_obj = '';
|
||||||
|
protected $subscribe_topic_obj = '';
|
||||||
|
|
||||||
public function __construct(\think\Request $request = null) {
|
public function __construct(\think\Request $request = null) {
|
||||||
parent::__construct($request);
|
parent::__construct($request);
|
||||||
@@ -46,6 +49,8 @@ class Journal extends Controller {
|
|||||||
$this->article_to_line_obj = Db::name('article_to_line');
|
$this->article_to_line_obj = Db::name('article_to_line');
|
||||||
$this->journal_paper_obj = Db::name('journal_paper');
|
$this->journal_paper_obj = Db::name('journal_paper');
|
||||||
$this->journal_paper_art_obj = Db::name('journal_paper_art');
|
$this->journal_paper_art_obj = Db::name('journal_paper_art');
|
||||||
|
$this->subscribe_journal_obj = Db::name('subscribe_journal');
|
||||||
|
$this->subscribe_topic_obj = Db::name('subscribe_topic');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -277,6 +282,7 @@ class Journal extends Controller {
|
|||||||
|
|
||||||
return json(['code' => 0, 'msg' => 'success', 'data' => ['stage' => $stage_info, 'articleList' => $list]]);
|
return json(['code' => 0, 'msg' => 'success', 'data' => ['stage' => $stage_info, 'articleList' => $list]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getAuthor($article) {
|
private function getAuthor($article) {
|
||||||
$where['article_id'] = $article['article_id'];
|
$where['article_id'] = $article['article_id'];
|
||||||
$where['state'] = 0;
|
$where['state'] = 0;
|
||||||
@@ -609,4 +615,88 @@ class Journal extends Controller {
|
|||||||
return jsonSuccess($re);
|
return jsonSuccess($re);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @title 获取期刊话题列表
|
||||||
|
* @description 获取期刊话题列表
|
||||||
|
* @author wangjinlei
|
||||||
|
* @url /api/Journal/getTopicForSubscribe
|
||||||
|
* @method POST
|
||||||
|
*
|
||||||
|
* @param name:journal_id type:int require:1 desc:期刊id
|
||||||
|
*
|
||||||
|
* @return topics:话题列表array#
|
||||||
|
*/
|
||||||
|
public function getTopicForSubscribe() {
|
||||||
|
$data = $this->request->post();
|
||||||
|
$list = $this->journal_topic_obj->where('journal_id', $data['journal_id'])->where('state', 0)->where('level', 2)->select();
|
||||||
|
|
||||||
|
$re['topics'] = $list;
|
||||||
|
return jsonSuccess($re);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @title 添加期刊订阅
|
||||||
|
* @description 添加期刊订阅
|
||||||
|
* @author wangjinlei
|
||||||
|
* @url /api/Journal/addSubscribeJournal
|
||||||
|
* @method POST
|
||||||
|
*
|
||||||
|
* @param name:journal_id type:int require:1 desc:期刊id
|
||||||
|
* @param name:email type:string require:1 desc:邮件地址
|
||||||
|
*/
|
||||||
|
public function addSubscribeJournal() {
|
||||||
|
$data = $this->request->post();
|
||||||
|
//去重
|
||||||
|
$repeat = $this->subscribe_journal_obj
|
||||||
|
->where('journal_id', $data['journal_id'])
|
||||||
|
->where('email', $data['email'])
|
||||||
|
->find();
|
||||||
|
if ($repeat) {
|
||||||
|
return jsonError('repeat subscribe!');
|
||||||
|
}
|
||||||
|
$insert['journal_id'] = $data['journal_id'];
|
||||||
|
$insert['email'] = $data['email'];
|
||||||
|
$this->subscribe_journal_obj->insert($insert);
|
||||||
|
return jsonSuccess([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @title 添加期刊话题订阅
|
||||||
|
* @description 添加期刊话题订阅
|
||||||
|
* @author wangjinlei
|
||||||
|
* @url /api/Journal/addSubscribeTopic
|
||||||
|
* @method POST
|
||||||
|
*
|
||||||
|
* @param name:topic_id type:int require:1 desc:期刊话题id
|
||||||
|
* @param name:email type:string require:1 desc:邮箱地址
|
||||||
|
*/
|
||||||
|
public function addSubscribeTopic() {
|
||||||
|
$data = $this->request->post();
|
||||||
|
//去重
|
||||||
|
$repeat = $this->subscribe_topic_obj
|
||||||
|
->where('topic_id', $data['topic_id'])
|
||||||
|
->where('email', $data['email'])
|
||||||
|
->find();
|
||||||
|
if ($repeat) {
|
||||||
|
return jsonError('repeat subscribe!');
|
||||||
|
}
|
||||||
|
$insert['topic_id'] = $data['topic_id'];
|
||||||
|
$insert['email'] = $data['email'];
|
||||||
|
$this->subscribe_topic_obj->insert($insert);
|
||||||
|
return jsonSuccess([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testEmail() {
|
||||||
|
// phpinfo();die;
|
||||||
|
|
||||||
|
|
||||||
|
$tt = 'mytestemail.';
|
||||||
|
$maidata['email'] = '751475802@qq.com';
|
||||||
|
$maidata['title'] = '测试邮件1';
|
||||||
|
$maidata['content'] = $tt;
|
||||||
|
$maidata['tmail'] = 'tmr@tmrjournals.com';
|
||||||
|
$maidata['tpassword'] = 'Wu999999tm';
|
||||||
|
Queue::push('app\api\job\mail@fire', $maidata, "mail");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
40
application/api/job/mail.php
Normal file
40
application/api/job/mail.php
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\job;
|
||||||
|
|
||||||
|
use think\queue\Job;
|
||||||
|
|
||||||
|
class mail {
|
||||||
|
|
||||||
|
//put your code here
|
||||||
|
|
||||||
|
public function fire(Job $job, $data) {
|
||||||
|
$res = $this->send($data);
|
||||||
|
if($res){
|
||||||
|
$job->delete();
|
||||||
|
}else{
|
||||||
|
if($job->attempts()>3){
|
||||||
|
// 第1种处理方式:重新发布任务,该任务延迟10秒后再执行
|
||||||
|
//$job->release(10);
|
||||||
|
// 第2种处理方式:原任务的基础上1分钟执行一次并增加尝试次数
|
||||||
|
//$job->failed();
|
||||||
|
// 第3种处理方式:删除任务
|
||||||
|
$job->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送邮件的逻辑
|
||||||
|
* @param type $data
|
||||||
|
*/
|
||||||
|
public function send($data){
|
||||||
|
$r = sendEmail($data['email'],$data['title'],$data['title'],$data['content'],$data['tmail'],$data['tpassword']);
|
||||||
|
if($r['status']==1){
|
||||||
|
return true;
|
||||||
|
}else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
return [
|
return [
|
||||||
// 'connector' => 'Sync'
|
// 'connector' => 'Sync'
|
||||||
'connector' => 'Redis', // Redis 驱动
|
'connector' => 'Redis', // Redis 驱动
|
||||||
'expire' => null, // 任务的过期时间,默认为60秒; 若要禁用,则设置为 null
|
'expire' => 60, // 任务的过期时间,默认为60秒; 若要禁用,则设置为 null
|
||||||
'default' => 'mail', // 默认的队列名称
|
'default' => 'mail', // 默认的队列名称
|
||||||
'host' => '127.0.0.1', // redis 主机ip
|
'host' => '127.0.0.1', // redis 主机ip
|
||||||
'port' => 6379, // redis 端口
|
'port' => 6379, // redis 端口
|
||||||
|
|||||||
@@ -165,16 +165,19 @@ class Datebase extends Controller{
|
|||||||
* @param name:pageIndex type:int require:1 desc:当前页码数
|
* @param name:pageIndex type:int require:1 desc:当前页码数
|
||||||
* @param name:pageSize type:int require:1 desc:单页数据条数
|
* @param name:pageSize type:int require:1 desc:单页数据条数
|
||||||
*
|
*
|
||||||
|
* @return dbinfo:数据库信息#
|
||||||
* @return count:总数据数
|
* @return count:总数据数
|
||||||
* @return dataList:array#
|
* @return dataList:array#
|
||||||
*/
|
*/
|
||||||
public function getDatas(){
|
public function getDatas(){
|
||||||
$data = $this->request->post();
|
$data = $this->request->post();
|
||||||
|
|
||||||
|
$db_info = $this->db_obj->where('db_id',$data['db_id'])->find();
|
||||||
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
|
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
|
||||||
$list = $this->db_data_obj->where('db_id',$data['db_id'])->where('state',0)->limit($limit_start,$data['pageSize'])->select();
|
$list = $this->db_data_obj->where('db_id',$data['db_id'])->where('state',0)->limit($limit_start,$data['pageSize'])->select();
|
||||||
$count = $this->db_data_obj->where('db_id',$data['db_id'])->count();
|
$count = $this->db_data_obj->where('db_id',$data['db_id'])->count();
|
||||||
|
|
||||||
|
$re['dbinfo'] = $db_info;
|
||||||
$re['dataList'] = $list;
|
$re['dataList'] = $list;
|
||||||
$re['count'] = $count;
|
$re['count'] = $count;
|
||||||
return jsonSuccess($re);
|
return jsonSuccess($re);
|
||||||
|
|||||||
@@ -107,6 +107,7 @@ class Journal extends Controller {
|
|||||||
* @param name:jabbr type:int require:0 desc:期刊简称
|
* @param name:jabbr type:int require:0 desc:期刊简称
|
||||||
* @param name:apc type:string require:1
|
* @param name:apc type:string require:1
|
||||||
* @param name:icon type:string require:1
|
* @param name:icon type:string require:1
|
||||||
|
* @param name:licon type:string require:1 desc:简易缩略图
|
||||||
* @param name:editor_id type:int require:1 desc:编辑id
|
* @param name:editor_id type:int require:1 desc:编辑id
|
||||||
* @param name:system_color type:string require:1
|
* @param name:system_color type:string require:1
|
||||||
* @param name:submission_url type:string require:1
|
* @param name:submission_url type:string require:1
|
||||||
@@ -124,6 +125,7 @@ class Journal extends Controller {
|
|||||||
$insert_data['jabbr'] = $data['jabbr'];
|
$insert_data['jabbr'] = $data['jabbr'];
|
||||||
$insert_data['apc'] = $data['apc'];
|
$insert_data['apc'] = $data['apc'];
|
||||||
$insert_data['icon'] = $data['icon'];
|
$insert_data['icon'] = $data['icon'];
|
||||||
|
$insert_data['licon'] = $data['licon'];
|
||||||
$insert_data['editor_id'] = $data['editor_id'];
|
$insert_data['editor_id'] = $data['editor_id'];
|
||||||
$insert_data['system_color'] = $data['system_color'];
|
$insert_data['system_color'] = $data['system_color'];
|
||||||
$insert_data['submission_url'] = $data['submission_url'];
|
$insert_data['submission_url'] = $data['submission_url'];
|
||||||
|
|||||||
Reference in New Issue
Block a user