757 lines
27 KiB
PHP
757 lines
27 KiB
PHP
<?php
|
|
|
|
namespace app\api\controller;
|
|
|
|
use app\api\controller\Base;
|
|
use think\Validate;
|
|
use think\Db;
|
|
/**
|
|
* @title 公共管理相关
|
|
* @description 公共管理相关
|
|
*/
|
|
class Publish extends Base
|
|
{
|
|
|
|
public function __construct(\think\Request $request = null)
|
|
{
|
|
parent::__construct($request);
|
|
}
|
|
|
|
/**
|
|
* 获取online文章列表
|
|
*/
|
|
public function getOnlineList(){
|
|
$data = $this->request->post();
|
|
$rule = new Validate([
|
|
'issn'=>'require'
|
|
]);
|
|
if(!$rule->check($data)){
|
|
return jsonError($rule->getError());
|
|
}
|
|
$t_journal_info = $this->journal_obj->where('issn',$data['issn'])->find();
|
|
|
|
$url = 'http://journalapi.tmrjournals.com/public/index.php/master/Article/getOnlineArticleForSubmit';
|
|
$pra = [];
|
|
$pra['issn'] = $t_journal_info['issn'];
|
|
$res = object_to_array(json_decode(myPost($url, $pra)));
|
|
|
|
$stages = $res['data']['stages'];
|
|
foreach ($stages as $k =>$v){
|
|
|
|
//获取微信公众号文章状态 chengxiaoling 20250522 start
|
|
if(empty($v['articles'])){
|
|
continue;
|
|
}
|
|
$aArticleId = array_column($v['articles'], 'article_id');
|
|
$aWechatArticle = $this->getWechatInfo($aArticleId);
|
|
$aAiArticle = empty($aWechatArticle['ai_article']) ? [] : $aWechatArticle['ai_article'];
|
|
$aAiWechatArticle = empty($aWechatArticle['ai_wechat_article']) ? [] : $aWechatArticle['ai_wechat_article'];
|
|
//获取微信公众号文章状态 chengxiaoling 20250522 end
|
|
|
|
foreach ($v['articles'] as $key =>$val){
|
|
$a = explode('/',$val['doi']);
|
|
if(!isset($a[1])){
|
|
continue;
|
|
}
|
|
$pro_info = $this->production_article_obj->where('doi',$a[1])->where('state',2)->find();
|
|
if (!$pro_info){
|
|
$stages[$k]['articles'][$key]['tg_article_id'] = 0 ;
|
|
continue;
|
|
}
|
|
$stages[$k]['articles'][$key]['tg_article_id'] = $pro_info['article_id'];
|
|
$stages[$k]['articles'][$key]['p_article_id'] = $pro_info['p_article_id'];
|
|
|
|
//获取微信公众号文章状态 chengxiaoling 20250522 start
|
|
$stages[$k]['articles'][$key]['ai_wechat_status'] = 2; //1 Ai内容已生成 2ai内容未生成
|
|
if(in_array($val['article_id'],$aAiArticle)){
|
|
$stages[$k]['articles'][$key]['ai_wechat_status'] = 1;
|
|
//是否推送到微信
|
|
$aDraft = empty($aAiWechatArticle[$val['article_id']]) ? [] : $aAiWechatArticle[$val['article_id']];
|
|
$stages[$k]['articles'][$key]['ai_wechat_status'] = empty($aDraft) ? 3 : 4; //3 未生成草稿 4 已生成草稿未发布 10 发布成功 11 发布中 >11发布失败
|
|
if(!empty($aDraft)){
|
|
foreach ($aDraft as $kk => $value) {
|
|
if($kk == '-1'){
|
|
$stages[$k]['articles'][$key]['ai_wechat_status'] = 4;
|
|
}else{
|
|
$stages[$k]['articles'][$key]['ai_wechat_status'] = '1'.$kk;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//获取微信公众号文章状态 chengxiaoling 20250522 end
|
|
}
|
|
}
|
|
|
|
$re['stages'] = $stages;
|
|
return jsonSuccess($re);
|
|
}
|
|
|
|
public function addPublicArticleCite(){
|
|
$data = $this->request->post();
|
|
$rule = new Validate([
|
|
"article_id" => "require",
|
|
"journal_id" => "require",
|
|
"doi" => "require",
|
|
"journal_name" => "require",
|
|
"article_name" => "require",
|
|
"author"=>"require",
|
|
"vol"=>"require"
|
|
]);
|
|
if(!$rule->check($data)){
|
|
return jsonError($rule->getError());
|
|
}
|
|
$url = 'http://journalapi.tmrjournals.com/public/index.php/master/Article/addArticleCiteNew';
|
|
$pra = [];
|
|
$pra['article_id'] = $data['article_id'];
|
|
$pra['journal_id'] = $data['journal_id'];
|
|
$pra['doi'] = $data['doi'];
|
|
$pra['journal_name'] = $data['journal_name'];
|
|
$pra['article_name'] = $data['article_name'];
|
|
$pra['author'] = $data['author'];
|
|
$pra['vol'] = $data['vol'];
|
|
$pra['factor'] = isset($data['factor'])?$data['factor']:0;
|
|
$pra['is_china'] = isset($data['is_china'])?$data['is_china']:0;
|
|
$pra['is_wos'] = isset($data['is_wos'])?$data['is_wos']:0;
|
|
object_to_array(json_decode(myPost($url, $pra)));
|
|
return jsonSuccess([]);
|
|
}
|
|
|
|
|
|
public function editArticleCite(){
|
|
$data = $this->request->post();
|
|
$rule = new Validate([
|
|
"article_cite_id" => "require",
|
|
"factor"=>"require",
|
|
"is_china"=>"require",
|
|
"is_wos"=>"require"
|
|
]);
|
|
if(!$rule->check($data)){
|
|
return jsonError($rule->getError());
|
|
}
|
|
$url = 'http://journalapi.tmrjournals.com/public/index.php/master/Article/editArticleCite';
|
|
$pra = [];
|
|
$pra['article_cite_id'] = $data['article_cite_id'];
|
|
$pra['factor'] = isset($data['factor'])?$data['factor']:0;
|
|
$pra['is_china'] = isset($data['is_china'])?$data['is_china']:0;
|
|
$pra['is_wos'] = isset($data['is_wos'])?$data['is_wos']:0;
|
|
$res = object_to_array(json_decode(myPost($url, $pra)));
|
|
return jsonSuccess($res);
|
|
}
|
|
|
|
|
|
public function getArticleCites(){
|
|
$data = $this->request->post();
|
|
$rule = new Validate([
|
|
"article_id" => "require"
|
|
]);
|
|
if(!$rule->check($data)){
|
|
return jsonError($rule->getError());
|
|
}
|
|
$url = "http://journalapi.tmrjournals.com/public/index.php/master/Article/getArticleCitesForSubmit";
|
|
$pra = [];
|
|
$pra['article_id'] = $data['article_id'];
|
|
$res = object_to_array(json_decode(myPost($url, $pra)));
|
|
$re['list'] = $res['data']["list"];
|
|
return jsonSuccess($re);
|
|
}
|
|
|
|
|
|
public function raboDataByDoi(){
|
|
$data = $this->request->post();
|
|
$rule = new Validate([
|
|
"doi"=>"require"
|
|
]);
|
|
if(!$rule->check($data)){
|
|
return jsonError($rule->getError());
|
|
}
|
|
$url = "https://doi.crossref.org/openurl/";
|
|
$pra['pid'] = "books@tmrjournals.com";
|
|
$pra['id'] = trim($data['doi']);
|
|
$pra['noredirect'] = true;
|
|
$r = xml_to_array(myGetParam($url,$pra));
|
|
|
|
|
|
if(isset($r["crossref_result"]["query_result"]["body"]['query']["article_title"])){
|
|
$flag = $r["crossref_result"]["query_result"]["body"]['query'];
|
|
$flag['author'] = formateAuthor(isset($r["crossref_result"]["query_result"]["body"]['query']['contributors']['contributor'])?$r["crossref_result"]["query_result"]["body"]['query']['contributors']['contributor']:null);
|
|
$flag['vol'] = formateVol($r["crossref_result"]["query_result"]["body"]['query']);
|
|
return jsonSuccess($flag);
|
|
}else{
|
|
return jsonError("not find");
|
|
}
|
|
}
|
|
|
|
|
|
public function delArticleCite(){
|
|
$data = $this->request->post();
|
|
$rule = new Validate([
|
|
"article_cite_id" => "require"
|
|
]);
|
|
if(!$rule->check($data)){
|
|
return jsonError($rule->getError());
|
|
}
|
|
|
|
$url = "http://journalapi.tmrjournals.com/public/index.php/master/Article/delArticleCiteForSubmission";
|
|
$pra['article_cite_id'] = $data['article_cite_id'];
|
|
$re = object_to_array(json_decode(myPost($url, $pra)));
|
|
|
|
|
|
return jsonSuccess($re);
|
|
}
|
|
|
|
public function getPublishArticleDetail(){
|
|
$data = $this->request->post();
|
|
$rule = new Validate([
|
|
"article_id"=>"require"
|
|
]);
|
|
if(!$rule->check($data)){
|
|
return jsonError($rule->getError());
|
|
}
|
|
$url = 'http://journalapi.tmrjournals.com/public/index.php/master/Article/getArticleDetail';
|
|
$pra = [];
|
|
$pra['article_id'] = $data['article_id'];
|
|
$res = object_to_array(json_decode(myPost($url, $pra)));
|
|
$detail = $res['data']["detail"];
|
|
|
|
if($detail['html_type']==2){
|
|
$product = $this->production_article_obj->where("w_article_id",$data['article_id'])->find();
|
|
$check = $this->article_main_obj->where("article_id",$product['article_id'])->find();
|
|
$detail['has_html'] = $check?1:0;
|
|
$detail['tg_article_id'] = $product['article_id'];
|
|
}
|
|
|
|
$re['detail'] = $detail;
|
|
return jsonSuccess($re);
|
|
}
|
|
|
|
public function createHtmlForType2(){
|
|
$data = $this->request->post();
|
|
$rule = new Validate([
|
|
"article_id"=>"require"
|
|
]);
|
|
if(!$rule->check($data)){
|
|
return jsonError($rule->getError());
|
|
}
|
|
$product = $this->production_article_obj->where("w_article_id",$data['article_id'])->find();
|
|
if(!$product){
|
|
return jsonError("system error,no product for article");
|
|
}
|
|
$check = $this->article_main_obj->where("article_id",$product['article_id'])->whereIn("state",[0,2])->find();
|
|
if(!$check){
|
|
$this->addArticleMainEx($product['article_id']);
|
|
}
|
|
$url = 'http://journalapi.tmrjournals.com/public/index.php/master/Article/changeArticleType2';
|
|
$pra = [];
|
|
$pra['article_id'] = $data['article_id'];
|
|
myPost($url, $pra);
|
|
$mains = getArticleMains($product['article_id']);
|
|
$re['list'] = $mains;
|
|
|
|
return jsonSuccess($re);
|
|
|
|
}
|
|
|
|
public function getHtmlForType2(){
|
|
$data = $this->request->post();
|
|
$rule = new Validate([
|
|
"article_id"=>"require"
|
|
]);
|
|
if(!$rule->check($data)){
|
|
return jsonError($rule->getError());
|
|
}
|
|
$product = $this->production_article_obj->where("w_article_id",$data['article_id'])->find();
|
|
if(!$product){
|
|
return jsonError("system error,no product for article");
|
|
}
|
|
$check = $this->article_main_obj->where("article_id",$product['article_id'])->whereIn("state",[0,2])->find();
|
|
if(!$check){
|
|
return jsonError("not find");
|
|
}
|
|
$mains = getArticleMains($product['article_id']);
|
|
$re['list'] = $mains;
|
|
|
|
return jsonSuccess($re);
|
|
}
|
|
|
|
/**
|
|
* 获取publish文章
|
|
*/
|
|
public function getPublicAiticles(){
|
|
$data = $this->request->post();
|
|
$rule = new Validate([
|
|
'issn'=>'require',
|
|
'pageIndex'=>'require',
|
|
'pageSize'=>'require'
|
|
]);
|
|
if(!$rule->check($data)){
|
|
return jsonError($rule->getError());
|
|
}
|
|
$url = 'http://journalapi.tmrjournals.com/public/index.php/master/Article/getArticleListForSubmit';
|
|
$pra = [];
|
|
$pra['issn'] = $data['issn'];
|
|
$pra['journal_stage_id'] = isset($data['journal_stage_id'])?$data['journal_stage_id']:0;
|
|
$pra['seach'] = isset($data['seach'])?trim($data['seach']):'';
|
|
$pra['pageIndex'] = $data['pageIndex'];
|
|
$pra['pageSize'] = $data['pageSize'];
|
|
$res = object_to_array(json_decode(myPost($url, $pra)));
|
|
|
|
$articles = $res['data']["articleList"];
|
|
//AI内容是否生成 chengxiaoling 20250522 start
|
|
if(!empty($articles)){
|
|
$aArticleId = array_column($articles, 'article_id');
|
|
$aWechatArticle = $this->getWechatInfo($aArticleId);
|
|
$aAiArticle = empty($aWechatArticle['ai_article']) ? [] : $aWechatArticle['ai_article'];
|
|
$aAiWechatArticle = empty($aWechatArticle['ai_wechat_article']) ? [] : $aWechatArticle['ai_wechat_article'];
|
|
}
|
|
//AI内容是否生成 chengxiaoling 20250522 end
|
|
foreach ($articles as $k => $v){
|
|
$a = explode('/',$v['doi']);
|
|
if(!isset($a[1])){
|
|
$articles[$k]['refers'] = [];
|
|
continue;
|
|
}
|
|
$pro_info = $this->production_article_obj->where('doi',$a[1])->where('state',2)->find();
|
|
if (!$pro_info){
|
|
$pid = $this->createEmptyProduction($v);
|
|
$articles[$k]['refers'] = [];
|
|
$articles[$k]['tg_article_id'] = 0 ;
|
|
$articles[$k]['p_article_id'] = $pid;
|
|
continue;
|
|
}
|
|
$articles[$k]['p_article_id'] = $pro_info['p_article_id'];
|
|
$articles[$k]['tg_article_id'] = $pro_info['article_id'];
|
|
$articles[$k]['refers'] = [];//$this->production_article_refer_obj->where("p_article_id",$pro_info['p_article_id'])->where('state',0)->order("index")->select();
|
|
|
|
//AI内容是否生成 chengxiaoling 20250522 start
|
|
$articles[$k]['ai_wechat_status'] = 2;
|
|
if(in_array($v['article_id'],$aAiArticle)){
|
|
$articles[$k]['ai_wechat_status'] = 1;
|
|
//是否推送到微信
|
|
$aDraft = empty($aAiWechatArticle[$v['article_id']]) ? [] : $aAiWechatArticle[$v['article_id']];
|
|
$articles[$k]['ai_wechat_status'] = empty($aDraft) ? 3 : 4; //3 未生成草稿 4 已生成草稿
|
|
if(!empty($aDraft)){
|
|
foreach ($aDraft as $kk=> $value) {
|
|
if($kk == '-1'){
|
|
$articles[$k]['ai_wechat_status'] = 4;
|
|
}else{
|
|
$articles[$k]['ai_wechat_status'] = '1'.$kk;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//AI内容是否生成 chengxiaoling 20250522 end
|
|
}
|
|
|
|
$re['count'] = $res['data']["count"];
|
|
$re['articleList'] = $articles;
|
|
return jsonSuccess($re);
|
|
}
|
|
|
|
|
|
|
|
public function refreshCite(){
|
|
$data = $this->request->post();
|
|
$rule = new Validate([
|
|
"article_id"=>"require"
|
|
]);
|
|
if(!$rule->check($data)){
|
|
return jsonError($rule->getError());
|
|
}
|
|
$url = 'http://journalapi.tmrjournals.com/public/index.php/master/Article/refreshCiteForSubmission';
|
|
$pra = [];
|
|
$pra['article_id'] = $data['article_id'];
|
|
$res = object_to_array(json_decode(myPost($url, $pra)));
|
|
return jsonSuccess($res);
|
|
}
|
|
|
|
public function getArticleMains(){
|
|
$data = $this->request->post();
|
|
$rule = new Validate([
|
|
"article_id"=>"require"
|
|
]);
|
|
if(!$rule->check($data)){
|
|
return jsonError($rule->getError());
|
|
}
|
|
$url = 'http://journalapi.tmrjournals.com/public/index.php/master/Article/getArticleMainsForSubmit';
|
|
$pra = [];
|
|
$pra['article_id'] = $data['article_id'];
|
|
$res = object_to_array(json_decode(myPost($url, $pra)));
|
|
|
|
$mains = $res['data']["mains"];
|
|
|
|
$re['mains'] = $mains;
|
|
return jsonSuccess($re);
|
|
}
|
|
|
|
public function getArticleReferences(){
|
|
$data = $this->request->post();
|
|
$rule = new Validate([
|
|
"article_id" => "require"
|
|
]);
|
|
if(!$rule->check($data)){
|
|
return jsonError($rule->getError());
|
|
}
|
|
$p_info = $this->production_article_obj->where("w_article_id",$data['article_id'])->find();
|
|
|
|
if(!$p_info){
|
|
return jsonSuccess([]);
|
|
}
|
|
$list = $this->production_article_refer_obj->where("p_article_id",$p_info['p_article_id'])->where('state',0)->order("index")->select();
|
|
$re["list"] = $list;
|
|
|
|
return jsonSuccess($re);
|
|
}
|
|
|
|
|
|
/**
|
|
* 提前出刊
|
|
*/
|
|
public function pushPublish(){
|
|
$data = $this->request->post();
|
|
$rule = new Validate([
|
|
'journal_stage_id'=>'require'
|
|
]);
|
|
if(!$rule->check($data)){
|
|
return jsonError($rule->getError());
|
|
}
|
|
|
|
$url = 'http://journalapi.tmrjournals.com/public/index.php/master/Journal/pushJournalPublishForSubmit';
|
|
$url1 = 'http://journalapi.tmrjournals.com/public/index.php/master/Datebase/dataPush';
|
|
$pra = [];
|
|
$pra['journal_stage_id'] = $data['journal_stage_id'];
|
|
$res = object_to_array(json_decode(myPost($url, $pra)));
|
|
$res1 = object_to_array(json_decode(myPost($url1, $pra)));
|
|
|
|
//同步分期下的文章PDF文件到ftp.portico.org chengxiaoling 20250925 start
|
|
if(!empty($data['journal_stage_id'])){
|
|
$sQueueId = \think\Queue::push('app\api\job\SyncArticleData@fire', ['journal_stage_id' => $data['journal_stage_id']], 'SyncArticleData');
|
|
}
|
|
//同步分期下的文章PDF文件到ftp.portico.org chengxiaoling 20250925 end
|
|
|
|
return jsonSuccess([]);
|
|
}
|
|
|
|
/**
|
|
* 获取期刊文章
|
|
*/
|
|
public function getJournalArticles(){
|
|
$data = $this->request->post();
|
|
$rule = new Validate([
|
|
'issn'=>'require'
|
|
]);
|
|
if(!$rule->check($data)){
|
|
return jsonError($rule->getError());
|
|
}
|
|
$url = 'http://journalapi.tmrjournals.com/public/index.php/master/Article/getArticleForSubmit';
|
|
$pra = [];
|
|
$pra['issn'] = $data['issn'];
|
|
$res = object_to_array(json_decode(myPost($url, $pra)));
|
|
$re['stages'] = $res['data']['stages'];
|
|
return jsonSuccess($re);
|
|
}
|
|
|
|
/**
|
|
* 获取所有分期
|
|
*/
|
|
public function getAllStages(){
|
|
$data = $this->request->post();
|
|
$rule = new Validate([
|
|
'issn'=>'require'
|
|
]);
|
|
if(!$rule->check($data)){
|
|
return jsonError($rule->getError());
|
|
}
|
|
$url = 'http://journalapi.tmrjournals.com/public/index.php/master/Article/getAllStagesForSubmit';
|
|
$pra = [];
|
|
$pra['issn'] = $data['issn'];
|
|
$res = object_to_array(json_decode(myPost($url, $pra)));
|
|
$re['stages'] = $res['data']['stages'];
|
|
return jsonSuccess($re);
|
|
}
|
|
|
|
/**
|
|
* 获取客座期刊列表
|
|
*/
|
|
public function getJournalSpecials(){
|
|
$data = $this->request->post();
|
|
$rule = new Validate([
|
|
'issn'=>'require'
|
|
]);
|
|
if(!$rule->check($data)){
|
|
return jsonError($rule->getError());
|
|
}
|
|
$url = 'http://journalapi.tmrjournals.com/public/index.php/master/Special/getSpecialByIssn';
|
|
$pra = [];
|
|
$pra['journal_issn'] = $data['issn'];
|
|
$res = object_to_array(json_decode(myPost($url, $pra)));
|
|
$re['stages'] = $res['data']['specials'];
|
|
return jsonSuccess($re);
|
|
}
|
|
|
|
/**添加refer通过拷贝word的形式
|
|
* @return void
|
|
*/
|
|
public function addRefersByWord(){
|
|
$data = $this->request->post();
|
|
$rule = new Validate([
|
|
"p_article_id"=>"require",
|
|
"contents"=>"require|array"
|
|
]);
|
|
if(!$rule->check($data)){
|
|
return jsonError($rule->getError());
|
|
}
|
|
foreach ($data['contents'] as $k => $v){
|
|
//处理content
|
|
if(strlen($v)<10){
|
|
continue;
|
|
}
|
|
$content = substr($v,stripos($v,".")+1);
|
|
$insert['p_article_id'] = $data['p_article_id'];
|
|
$insert['refer_frag'] = $content;
|
|
$insert['refer_type'] = "other";
|
|
$insert['cs'] = 0;
|
|
$this->production_article_refer_obj->insert($insert);
|
|
}
|
|
$this->refuseReferIndex($data['p_article_id']);
|
|
return jsonSuccess([]);
|
|
}
|
|
|
|
/**
|
|
* 编辑文章的客座期刊信息
|
|
*/
|
|
public function editArticleToSpecial(){
|
|
$data = $this->request->post();
|
|
$rule = new Validate([
|
|
'article_id'=>'require',
|
|
'journal_special_id'=>'require'
|
|
]);
|
|
if(!$rule->check($data)){
|
|
return jsonError($rule->getError());
|
|
}
|
|
$url = 'http://journalapi.tmrjournals.com/public/index.php/master/Article/changeArticleSpecialForSubmit';
|
|
$pra = [];
|
|
$pra['article_id'] = $data['article_id'];
|
|
$pra['journal_special_id'] = $data['journal_special_id'];
|
|
$res = object_to_array(json_decode(myPost($url, $pra)));
|
|
return jsonSuccess([]);
|
|
}
|
|
|
|
/**
|
|
* 编辑文章权重
|
|
*/
|
|
public function editArticle(){
|
|
$data = $this->request->post();
|
|
$rule = new Validate([
|
|
'article_id'=>'require',
|
|
'sort'=>'require'
|
|
]);
|
|
if(!$rule->check($data)){
|
|
return jsonError($rule->getError());
|
|
}
|
|
$url = 'http://journalapi.tmrjournals.com/public/index.php/master/Article/changeArticleForSubmit';
|
|
$pra = [];
|
|
$pra['article_id'] = $data['article_id'];
|
|
$pra['sort'] = $data['sort'];
|
|
$res = object_to_array(json_decode(myPost($url, $pra)));
|
|
return jsonSuccess([]);
|
|
}
|
|
|
|
/**
|
|
* 获取文章的基本信息
|
|
*/
|
|
public function getArticleDetail(){
|
|
$data = $this->request->post();
|
|
$rule = new Validate([
|
|
'article_id'=>'require'
|
|
]);
|
|
if(!$rule->check($data)){
|
|
return jsonError($rule->getError());
|
|
}
|
|
$url = 'http://journalapi.tmrjournals.com/public/index.php/master/Article/getArticleBase';
|
|
$pra = [];
|
|
$pra['article_id'] = $data['article_id'];
|
|
$res = object_to_array(json_decode(myPost($url, $pra)));
|
|
return jsonSuccess($res['data']);
|
|
}
|
|
|
|
// /**
|
|
// * 获取期刊话题
|
|
// */
|
|
// public function getJournalTopics(){
|
|
// $data = $this->request->post();
|
|
// $rule = new Validate([
|
|
// 'issn'=>'require'
|
|
// ]);
|
|
// if(!$rule->check($data)){
|
|
// return jsonError($rule->getError());
|
|
// }
|
|
// $url = 'http://journalapi.tmrjournals.com/public/index.php/master/Article/getTopicByArticle';
|
|
// $pra = [];
|
|
// $pra['article_id'] = $data['article_id'];
|
|
// $res = object_to_array(json_decode(myPost($url, $pra)));
|
|
// return jsonSuccess($res['data']);
|
|
// }
|
|
|
|
/**
|
|
* 获取文章的期刊话题列表
|
|
*/
|
|
public function getArticleTopics(){
|
|
$data = $this->request->post();
|
|
$rule = new Validate([
|
|
'article_id'=>'require'
|
|
]);
|
|
if(!$rule->check($data)){
|
|
return jsonError($rule->getError());
|
|
}
|
|
$url = 'http://journalapi.tmrjournals.com/public/index.php/master/Article/getTopicByArticle';
|
|
$pra = [];
|
|
$pra['article_id'] = $data['article_id'];
|
|
$res = object_to_array(json_decode(myPost($url, $pra)));
|
|
return jsonSuccess($res['data']);
|
|
}
|
|
|
|
/**
|
|
* 添加文章话题对应关系
|
|
*/
|
|
public function addArticleToTopic(){
|
|
$data = $this->request->post();
|
|
$rule = new Validate([
|
|
'article_id'=>'require',
|
|
'topic_id'=>'require'
|
|
]);
|
|
if(!$rule->check($data)){
|
|
return jsonError($rule->getError());
|
|
}
|
|
$url = 'http://journalapi.tmrjournals.com/public/index.php/master/Article/addTopicByArticle';
|
|
$pra = [];
|
|
$pra['article_id'] = $data['article_id'];
|
|
$pra['topic_id'] = $data['topic_id'];
|
|
$res = object_to_array(json_decode(myPost($url, $pra)));
|
|
return jsonSuccess([]);
|
|
}
|
|
|
|
/**
|
|
* 删除文章话题对应关系
|
|
*/
|
|
public function delArticleToTopic(){
|
|
$data = $this->request->post();
|
|
$rule = new Validate([
|
|
'article_to_topic_id'=>'require'
|
|
]);
|
|
if(!$rule->check($data)){
|
|
return jsonError($rule->getError());
|
|
}
|
|
$url = 'http://journalapi.tmrjournals.com/public/index.php/master/Article/delTopic';
|
|
$pra = [];
|
|
$pra['article_to_topic_id'] = $data['article_to_topic_id'];
|
|
$res = object_to_array(json_decode(myPost($url, $pra)));
|
|
return jsonSuccess([]);
|
|
}
|
|
|
|
/**
|
|
* 获取相关文章列表
|
|
*/
|
|
public function getArticleRelates(){
|
|
$data = $this->request->post();
|
|
$rule = new Validate([
|
|
'article_id'=>'require'
|
|
]);
|
|
if(!$rule->check($data)){
|
|
return jsonError($rule->getError());
|
|
}
|
|
$url = 'http://journalapi.tmrjournals.com/public/index.php/master/Article/getRelatedArticles';
|
|
$pra = [];
|
|
$pra['article_id'] = $data['article_id'];
|
|
$res = object_to_array(json_decode(myPost($url, $pra)));
|
|
return jsonSuccess($res['data']);
|
|
|
|
}
|
|
|
|
/**
|
|
* 获取关键词文章
|
|
*/
|
|
public function getKeywordArticleOrderJournal(){
|
|
$data = $this->request->post();
|
|
$rule = new Validate([
|
|
'keyword'=>'require'
|
|
]);
|
|
if(!$rule->check($data)){
|
|
return jsonError($rule->getError());
|
|
}
|
|
$url = 'http://journalapi.tmrjournals.com/public/index.php/master/Article/getKeywordArticleOrderJournalForSubmit';
|
|
$pra = [];
|
|
$pra['keyword'] = trim($data['keyword']);
|
|
$res = object_to_array(json_decode(myPost($url, $pra)));
|
|
return jsonSuccess($res['data']);
|
|
}
|
|
|
|
/**
|
|
* 添加相关文章
|
|
*/
|
|
public function addArticleRelate(){
|
|
$data = $this->request->post();
|
|
$rule = new Validate([
|
|
'article_id'=>'require',
|
|
'add_article_id'=>'require'
|
|
]);
|
|
if(!$rule->check($data)){
|
|
return jsonError($rule->getError());
|
|
}
|
|
$url = 'http://journalapi.tmrjournals.com/public/index.php/master/Article/addRelatedArticle';
|
|
$pra = [];
|
|
$pra['article_id'] = $data['article_id'];
|
|
$pra['add_article_id'] = $data['add_article_id'];
|
|
$res = object_to_array(json_decode(myPost($url, $pra)));
|
|
return jsonSuccess([]);
|
|
}
|
|
|
|
/**
|
|
* 删除相关文章
|
|
*/
|
|
public function delArticleRelate(){
|
|
$data = $this->request->post();
|
|
$rule = new Validate([
|
|
'article_id'=>'require',
|
|
'del_article_id'=>'require'
|
|
]);
|
|
if(!$rule->check($data)){
|
|
return jsonError($rule->getError());
|
|
}
|
|
$url = 'http://journalapi.tmrjournals.com/public/index.php/master/Article/delRelatedArticle';
|
|
$pra = [];
|
|
$pra['article_id'] = $data['article_id'];
|
|
$pra['del_article_id'] = $data['del_article_id'];
|
|
$res = object_to_array(json_decode(myPost($url, $pra)));
|
|
return jsonSuccess([]);
|
|
|
|
}
|
|
|
|
/**
|
|
* 获取微信公众号相关数量
|
|
*/
|
|
public function getWechatInfo($aArticleId){
|
|
|
|
if(empty($aArticleId)){
|
|
return [];
|
|
}
|
|
|
|
//获取文章生成记录
|
|
$aWhere = ['article_id' => ['in',$aArticleId],'is_delete' => 2];
|
|
$aAiArticle = Db::name('ai_article')->where($aWhere)->column('article_id');
|
|
if(!empty($aAiArticle)){
|
|
//获取推送到草稿箱否
|
|
$aWhere['article_id'] = ['in',$aAiArticle];
|
|
$ai_wechat_article = Db::name('ai_wechat_article')->field('article_id,template_id,wechat_id,is_publish,publish_status')->where($aWhere)->select();
|
|
if(!empty($ai_wechat_article)){
|
|
foreach ($ai_wechat_article as $key => $value) {
|
|
$aWechatArticle[$value['article_id']][$value['publish_status']][] = $value['template_id'];
|
|
}
|
|
}
|
|
}
|
|
unset($ai_wechat_article);
|
|
//返回数据
|
|
return ['ai_article' => $aAiArticle,'ai_wechat_article' => empty($aWechatArticle) ? [] : $aWechatArticle];
|
|
}
|
|
|
|
}
|