mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-24 20:06:09 +08:00
恢复误删的AnswerList
This commit is contained in:
parent
e3e5d20a7c
commit
f094f10011
@ -55,7 +55,7 @@ Tips: 请用手机注册一个新账号,用户中心 -> 关注订阅,扫码
|
||||
### 项目组件
|
||||
|
||||
- 后台框架:[phalcon 3.4.5](https://phalcon.io)
|
||||
- 前端框架:[layui 2.7.6](https://layui.com)
|
||||
- 前端框架:[layui 2.8.2](https://layui.com)
|
||||
- 全文检索:[xunsearch 1.4.9](http://www.xunsearch.com)
|
||||
- 即时通讯:[workerman 3.5.22](https://workerman.net)
|
||||
- 基础依赖:[php7.3](https://php.net), [mysql5.7](https://mysql.com), [redis5.0](https://redis.io)
|
||||
|
@ -46,7 +46,7 @@ class Sitemap
|
||||
public function build($filename = null)
|
||||
{
|
||||
$xml = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
|
||||
$xml .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
|
||||
$xml .= '<urlset xmlns="https://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
|
||||
|
||||
foreach ($this->items as $item) {
|
||||
$item['loc'] = htmlentities($item['loc'], ENT_QUOTES);
|
||||
|
77
app/Services/Logic/Answer/AnswerList.php
Normal file
77
app/Services/Logic/Answer/AnswerList.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Services\Logic\Answer;
|
||||
|
||||
use App\Builders\AnswerList as AnswerListBuilder;
|
||||
use App\Library\Paginator\Query as PagerQuery;
|
||||
use App\Repos\Answer as AnswerRepo;
|
||||
use App\Services\Logic\Service as LogicService;
|
||||
|
||||
class AnswerList extends LogicService
|
||||
{
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$pagerQuery = new PagerQuery();
|
||||
|
||||
$params = $pagerQuery->getParams();
|
||||
|
||||
$params['deleted'] = 0;
|
||||
|
||||
$sort = $pagerQuery->getSort();
|
||||
$page = $pagerQuery->getPage();
|
||||
$limit = $pagerQuery->getLimit();
|
||||
|
||||
$answerRepo = new AnswerRepo();
|
||||
|
||||
$pager = $answerRepo->paginate($params, $sort, $page, $limit);
|
||||
|
||||
return $this->handleAnswers($pager);
|
||||
}
|
||||
|
||||
public function handleAnswers($pager)
|
||||
{
|
||||
if ($pager->total_items == 0) {
|
||||
return $pager;
|
||||
}
|
||||
|
||||
$builder = new AnswerListBuilder();
|
||||
|
||||
$answers = $pager->items->toArray();
|
||||
|
||||
$questions = $builder->getQuestions($answers);
|
||||
|
||||
$users = $builder->getUsers($answers);
|
||||
|
||||
$items = [];
|
||||
|
||||
foreach ($answers as $answer) {
|
||||
|
||||
$question = $questions[$answer['question_id']] ?? new \stdClass();
|
||||
$owner = $users[$answer['owner_id']] ?? new \stdClass();
|
||||
|
||||
$items[] = [
|
||||
'id' => $answer['id'],
|
||||
'summary' => $answer['summary'],
|
||||
'published' => $answer['published'],
|
||||
'accepted' => $answer['accepted'],
|
||||
'comment_count' => $answer['comment_count'],
|
||||
'like_count' => $answer['like_count'],
|
||||
'create_time' => $answer['create_time'],
|
||||
'update_time' => $answer['update_time'],
|
||||
'question' => $question,
|
||||
'owner' => $owner,
|
||||
];
|
||||
}
|
||||
|
||||
$pager->items = $items;
|
||||
|
||||
return $pager;
|
||||
}
|
||||
|
||||
}
|
@ -120,7 +120,6 @@ trait ArticleDataTrait
|
||||
$tagRepo = new TagRepo();
|
||||
$tags = $tagRepo->findByIds($newTagIds);
|
||||
if ($tags->count() > 0) {
|
||||
$articleTags = [];
|
||||
foreach ($tags as $tag) {
|
||||
$articleTags[] = ['id' => $tag->id, 'name' => $tag->name];
|
||||
$this->recountTagArticles($tag->id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user