This commit is contained in:
wangjinlei
2024-02-19 14:56:04 +08:00
parent 4fb600db4e
commit 122ff3852f
3 changed files with 149 additions and 40 deletions

View File

@@ -889,6 +889,38 @@ class Article extends Base
return jsonSuccess($re);
}
/**获取用户所投的文章
* @return \think\response\Json|void
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getArticlesByArticle(){
$data = $this->request->post();
$rule = new Validate([
"article_id" => "require"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$article_info = $this->article_obj->where('article_id',$data['article_id'])->find();
$list = $this->article_obj->field("t_article.*,t_journal.title journal_title")->join("t_journal","t_journal.journal_id = t_article.journal_id","left")->where("t_article.user_id",$article_info['user_id'])->select();
$re['user_articles'] = $list;
$authors = $this->article_author_obj->where('article_id',$data['article_id'])->where('state',0)->select();
foreach ($authors as $k => $v){
if($v['email']!=""&&$v['email']!="empty"){
$as = $this->article_obj->field("t_article.*,t_journal.title journal_title")->join("t_article_author","t_article.article_id = t_article_author.article_id","left")->join("t_journal","t_journal.journal_id = t_article.journal_id","left")->where("t_article.article_id","<>",$data['article_id'])->where("t_article_author.state",0)->where("t_article_author.email",$v['email'])->select();
}else{
$as = null;
}
$authors[$k]["articles"] = $as;
}
$re['author_articles'] = $authors;
return jsonSuccess($re);
}
/**
* 修改文章的作者(作者)
*/