mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-07-15 04:46:06 +08:00
Merge branch 'koogua/v1.7.5'
This commit is contained in:
commit
f273e874e7
@ -1,3 +1,11 @@
|
||||
### [v1.7.5](https://gitee.com/koogua/course-tencent-cloud/releases/v1.7.5)(2024-01-10)
|
||||
|
||||
- 去除一些过度的设计
|
||||
- 优化bootstrap
|
||||
- 优化logger
|
||||
- 优化contact
|
||||
- 精简空判断
|
||||
|
||||
### [v1.7.4](https://gitee.com/koogua/course-tencent-cloud/releases/v1.7.4)(2024-12-10)
|
||||
|
||||
- 更新layui-v2.9.20
|
||||
|
@ -8,7 +8,6 @@
|
||||
namespace App\Builders;
|
||||
|
||||
use App\Repos\Question as QuestionRepo;
|
||||
use App\Repos\User as UserRepo;
|
||||
|
||||
class AnswerList extends Builder
|
||||
{
|
||||
@ -18,7 +17,7 @@ class AnswerList extends Builder
|
||||
$questions = $this->getQuestions($answers);
|
||||
|
||||
foreach ($answers as $key => $answer) {
|
||||
$answers[$key]['question'] = $questions[$answer['question_id']] ?? new \stdClass();
|
||||
$answers[$key]['question'] = $questions[$answer['question_id']] ?? null;
|
||||
}
|
||||
|
||||
return $answers;
|
||||
@ -29,7 +28,7 @@ class AnswerList extends Builder
|
||||
$users = $this->getUsers($answers);
|
||||
|
||||
foreach ($answers as $key => $answer) {
|
||||
$answers[$key]['owner'] = $users[$answer['owner_id']] ?? new \stdClass();
|
||||
$answers[$key]['owner'] = $users[$answer['owner_id']] ?? null;
|
||||
}
|
||||
|
||||
return $answers;
|
||||
@ -56,20 +55,7 @@ class AnswerList extends Builder
|
||||
{
|
||||
$ids = kg_array_column($answers, 'owner_id');
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findShallowUserByIds($ids);
|
||||
|
||||
$baseUrl = kg_cos_url();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$user['avatar'] = $baseUrl . $user['avatar'];
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $this->getShallowUserByIds($ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,7 +8,6 @@
|
||||
namespace App\Builders;
|
||||
|
||||
use App\Repos\Article as ArticleRepo;
|
||||
use App\Repos\User as UserRepo;
|
||||
use Phalcon\Text;
|
||||
|
||||
class ArticleFavoriteList extends Builder
|
||||
@ -19,7 +18,7 @@ class ArticleFavoriteList extends Builder
|
||||
$articles = $this->getArticles($relations);
|
||||
|
||||
foreach ($relations as $key => $value) {
|
||||
$relations[$key]['article'] = $articles[$value['article_id']] ?? new \stdClass();
|
||||
$relations[$key]['article'] = $articles[$value['article_id']] ?? null;
|
||||
}
|
||||
|
||||
return $relations;
|
||||
@ -30,7 +29,7 @@ class ArticleFavoriteList extends Builder
|
||||
$users = $this->getUsers($relations);
|
||||
|
||||
foreach ($relations as $key => $value) {
|
||||
$relations[$key]['user'] = $users[$value['user_id']] ?? new \stdClass();
|
||||
$relations[$key]['user'] = $users[$value['user_id']] ?? null;
|
||||
}
|
||||
|
||||
return $relations;
|
||||
@ -70,20 +69,7 @@ class ArticleFavoriteList extends Builder
|
||||
{
|
||||
$ids = kg_array_column($relations, 'user_id');
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findByIds($ids, ['id', 'name', 'avatar']);
|
||||
|
||||
$baseUrl = kg_cos_url();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$user['avatar'] = $baseUrl . $user['avatar'];
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $this->getShallowUserByIds($ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ namespace App\Builders;
|
||||
|
||||
use App\Caches\CategoryAllList as CategoryAllListCache;
|
||||
use App\Models\Category as CategoryModel;
|
||||
use App\Repos\User as UserRepo;
|
||||
|
||||
class ArticleList extends Builder
|
||||
{
|
||||
@ -28,7 +27,7 @@ class ArticleList extends Builder
|
||||
$categories = $this->getCategories();
|
||||
|
||||
foreach ($articles as $key => $article) {
|
||||
$articles[$key]['category'] = $categories[$article['category_id']] ?? new \stdClass();
|
||||
$articles[$key]['category'] = $categories[$article['category_id']] ?? null;
|
||||
}
|
||||
|
||||
return $articles;
|
||||
@ -39,7 +38,7 @@ class ArticleList extends Builder
|
||||
$users = $this->getUsers($articles);
|
||||
|
||||
foreach ($articles as $key => $article) {
|
||||
$articles[$key]['owner'] = $users[$article['owner_id']] ?? new \stdClass();
|
||||
$articles[$key]['owner'] = $users[$article['owner_id']] ?? null;
|
||||
}
|
||||
|
||||
return $articles;
|
||||
@ -69,20 +68,7 @@ class ArticleList extends Builder
|
||||
{
|
||||
$ids = kg_array_column($articles, 'owner_id');
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findShallowUserByIds($ids);
|
||||
|
||||
$baseUrl = kg_cos_url();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$user['avatar'] = $baseUrl . $user['avatar'];
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $this->getShallowUserByIds($ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
namespace App\Builders;
|
||||
|
||||
use App\Repos\User as UserRepo;
|
||||
use Phalcon\Di\Injectable;
|
||||
|
||||
class Builder extends Injectable
|
||||
@ -17,4 +18,22 @@ class Builder extends Injectable
|
||||
return kg_array_object($items);
|
||||
}
|
||||
|
||||
protected function getShallowUserByIds(array $ids)
|
||||
{
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findShallowUserByIds($ids);
|
||||
|
||||
$baseUrl = kg_cos_url();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$user['avatar'] = $baseUrl . $user['avatar'];
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,8 +7,6 @@
|
||||
|
||||
namespace App\Builders;
|
||||
|
||||
use App\Repos\User as UserRepo;
|
||||
|
||||
class CommentList extends Builder
|
||||
{
|
||||
|
||||
@ -17,8 +15,8 @@ class CommentList extends Builder
|
||||
$users = $this->getUsers($comments);
|
||||
|
||||
foreach ($comments as $key => $comment) {
|
||||
$comments[$key]['owner'] = $users[$comment['owner_id']] ?? new \stdClass();
|
||||
$comments[$key]['to_user'] = $users[$comment['to_user_id']] ?? new \stdClass();
|
||||
$comments[$key]['owner'] = $users[$comment['owner_id']] ?? null;
|
||||
$comments[$key]['to_user'] = $users[$comment['to_user_id']] ?? null;
|
||||
}
|
||||
|
||||
return $comments;
|
||||
@ -30,20 +28,7 @@ class CommentList extends Builder
|
||||
$toUserIds = kg_array_column($comments, 'to_user_id');
|
||||
$ids = array_merge($ownerIds, $toUserIds);
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findShallowUserByIds($ids);
|
||||
|
||||
$baseUrl = kg_cos_url();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$user['avatar'] = $baseUrl . $user['avatar'];
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $this->getShallowUserByIds($ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,7 +8,6 @@
|
||||
namespace App\Builders;
|
||||
|
||||
use App\Repos\Course as CourseRepo;
|
||||
use App\Repos\User as UserRepo;
|
||||
|
||||
class ConsultList extends Builder
|
||||
{
|
||||
@ -18,7 +17,7 @@ class ConsultList extends Builder
|
||||
$courses = $this->getCourses($consults);
|
||||
|
||||
foreach ($consults as $key => $consult) {
|
||||
$consults[$key]['course'] = $courses[$consult['course_id']] ?? new \stdClass();
|
||||
$consults[$key]['course'] = $courses[$consult['course_id']] ?? null;
|
||||
}
|
||||
|
||||
return $consults;
|
||||
@ -29,8 +28,8 @@ class ConsultList extends Builder
|
||||
$users = $this->getUsers($consults);
|
||||
|
||||
foreach ($consults as $key => $consult) {
|
||||
$consults[$key]['owner'] = $users[$consult['owner_id']] ?? new \stdClass();
|
||||
$consults[$key]['replier'] = $users[$consult['replier_id']] ?? new \stdClass();
|
||||
$consults[$key]['owner'] = $users[$consult['owner_id']] ?? null;
|
||||
$consults[$key]['replier'] = $users[$consult['replier_id']] ?? null;
|
||||
}
|
||||
|
||||
return $consults;
|
||||
@ -59,20 +58,7 @@ class ConsultList extends Builder
|
||||
$replierIds = kg_array_column($consults, 'replier_id');
|
||||
$ids = array_merge($ownerIds, $replierIds);
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findShallowUserByIds($ids);
|
||||
|
||||
$baseUrl = kg_cos_url();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$user['avatar'] = $baseUrl . $user['avatar'];
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $this->getShallowUserByIds($ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,7 +8,6 @@
|
||||
namespace App\Builders;
|
||||
|
||||
use App\Repos\Course as CourseRepo;
|
||||
use App\Repos\User as UserRepo;
|
||||
|
||||
class CourseFavoriteList extends Builder
|
||||
{
|
||||
@ -18,7 +17,7 @@ class CourseFavoriteList extends Builder
|
||||
$courses = $this->getCourses($relations);
|
||||
|
||||
foreach ($relations as $key => $value) {
|
||||
$relations[$key]['course'] = $courses[$value['course_id']] ?? new \stdClass();
|
||||
$relations[$key]['course'] = $courses[$value['course_id']] ?? null;
|
||||
}
|
||||
|
||||
return $relations;
|
||||
@ -29,7 +28,7 @@ class CourseFavoriteList extends Builder
|
||||
$users = $this->getUsers($relations);
|
||||
|
||||
foreach ($relations as $key => $value) {
|
||||
$relations[$key]['user'] = $users[$value['user_id']] ?? new \stdClass();
|
||||
$relations[$key]['user'] = $users[$value['user_id']] ?? null;
|
||||
}
|
||||
|
||||
return $relations;
|
||||
@ -70,20 +69,7 @@ class CourseFavoriteList extends Builder
|
||||
{
|
||||
$ids = kg_array_column($relations, 'user_id');
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findByIds($ids, ['id', 'name', 'avatar']);
|
||||
|
||||
$baseUrl = kg_cos_url();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$user['avatar'] = $baseUrl . $user['avatar'];
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $this->getShallowUserByIds($ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ namespace App\Builders;
|
||||
|
||||
use App\Caches\CategoryAllList as CategoryAllListCache;
|
||||
use App\Models\Category as CategoryModel;
|
||||
use App\Repos\User as UserRepo;
|
||||
|
||||
class CourseList extends Builder
|
||||
{
|
||||
@ -19,7 +18,7 @@ class CourseList extends Builder
|
||||
$categories = $this->getCategories();
|
||||
|
||||
foreach ($courses as $key => $course) {
|
||||
$courses[$key]['category'] = $categories[$course['category_id']] ?? new \stdClass();
|
||||
$courses[$key]['category'] = $categories[$course['category_id']] ?? null;
|
||||
}
|
||||
|
||||
return $courses;
|
||||
@ -30,7 +29,7 @@ class CourseList extends Builder
|
||||
$teachers = $this->getTeachers($courses);
|
||||
|
||||
foreach ($courses as $key => $course) {
|
||||
$courses[$key]['teacher'] = $teachers[$course['teacher_id']] ?? new \stdClass();
|
||||
$courses[$key]['teacher'] = $teachers[$course['teacher_id']] ?? null;
|
||||
}
|
||||
|
||||
return $courses;
|
||||
@ -60,20 +59,7 @@ class CourseList extends Builder
|
||||
{
|
||||
$ids = kg_array_column($courses, 'teacher_id');
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findShallowUserByIds($ids);
|
||||
|
||||
$baseUrl = kg_cos_url();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$user['avatar'] = $baseUrl . $user['avatar'];
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $this->getShallowUserByIds($ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ class CourseTopicList extends Builder
|
||||
$courses = $this->getCourses($relations);
|
||||
|
||||
foreach ($relations as $key => $value) {
|
||||
$relations[$key]['course'] = $courses[$value['course_id']] ?? new \stdClass();
|
||||
$relations[$key]['course'] = $courses[$value['course_id']] ?? null;
|
||||
}
|
||||
|
||||
return $relations;
|
||||
@ -29,7 +29,7 @@ class CourseTopicList extends Builder
|
||||
$topics = $this->getTopics($relations);
|
||||
|
||||
foreach ($relations as $key => $value) {
|
||||
$relations[$key]['topic'] = $topics[$value['topic_id']] ?? new \stdClass();
|
||||
$relations[$key]['topic'] = $topics[$value['topic_id']] ?? null;
|
||||
}
|
||||
|
||||
return $relations;
|
||||
|
@ -8,7 +8,6 @@
|
||||
namespace App\Builders;
|
||||
|
||||
use App\Repos\Course as CourseRepo;
|
||||
use App\Repos\User as UserRepo;
|
||||
|
||||
class CourseUserList extends Builder
|
||||
{
|
||||
@ -18,7 +17,7 @@ class CourseUserList extends Builder
|
||||
$courses = $this->getCourses($relations);
|
||||
|
||||
foreach ($relations as $key => $value) {
|
||||
$relations[$key]['course'] = $courses[$value['course_id']] ?? new \stdClass();
|
||||
$relations[$key]['course'] = $courses[$value['course_id']] ?? null;
|
||||
}
|
||||
|
||||
return $relations;
|
||||
@ -29,7 +28,7 @@ class CourseUserList extends Builder
|
||||
$users = $this->getUsers($relations);
|
||||
|
||||
foreach ($relations as $key => $value) {
|
||||
$relations[$key]['user'] = $users[$value['user_id']] ?? new \stdClass();
|
||||
$relations[$key]['user'] = $users[$value['user_id']] ?? null;
|
||||
}
|
||||
|
||||
return $relations;
|
||||
@ -74,20 +73,7 @@ class CourseUserList extends Builder
|
||||
{
|
||||
$ids = kg_array_column($relations, 'user_id');
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findByIds($ids, ['id', 'name', 'avatar']);
|
||||
|
||||
$baseUrl = kg_cos_url();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$user['avatar'] = $baseUrl . $user['avatar'];
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $this->getShallowUserByIds($ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ class HelpList extends Builder
|
||||
$categories = $this->getCategories();
|
||||
|
||||
foreach ($helps as $key => $help) {
|
||||
$helps[$key]['category'] = $categories[$help['category_id']] ?? new \stdClass();
|
||||
$helps[$key]['category'] = $categories[$help['category_id']] ?? null;
|
||||
}
|
||||
|
||||
return $helps;
|
||||
|
@ -9,7 +9,6 @@ namespace App\Builders;
|
||||
|
||||
use App\Repos\Chapter as ChapterRepo;
|
||||
use App\Repos\Course as CourseRepo;
|
||||
use App\Repos\User as UserRepo;
|
||||
|
||||
class LearningList extends Builder
|
||||
{
|
||||
@ -19,7 +18,7 @@ class LearningList extends Builder
|
||||
$courses = $this->getCourses($relations);
|
||||
|
||||
foreach ($relations as $key => $value) {
|
||||
$relations[$key]['course'] = $courses[$value['course_id']] ?? new \stdClass();
|
||||
$relations[$key]['course'] = $courses[$value['course_id']] ?? null;
|
||||
}
|
||||
|
||||
return $relations;
|
||||
@ -30,7 +29,7 @@ class LearningList extends Builder
|
||||
$chapters = $this->getChapters($relations);
|
||||
|
||||
foreach ($relations as $key => $value) {
|
||||
$relations[$key]['chapter'] = $chapters[$value['chapter_id']] ?? new \stdClass();
|
||||
$relations[$key]['chapter'] = $chapters[$value['chapter_id']] ?? null;
|
||||
}
|
||||
|
||||
return $relations;
|
||||
@ -41,7 +40,7 @@ class LearningList extends Builder
|
||||
$users = $this->getUsers($relations);
|
||||
|
||||
foreach ($relations as $key => $value) {
|
||||
$relations[$key]['user'] = $users[$value['user_id']] ?? new \stdClass();
|
||||
$relations[$key]['user'] = $users[$value['user_id']] ?? null;
|
||||
}
|
||||
|
||||
return $relations;
|
||||
@ -85,17 +84,7 @@ class LearningList extends Builder
|
||||
{
|
||||
$ids = kg_array_column($relations, 'user_id');
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findByIds($ids, ['id', 'name']);
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $this->getShallowUserByIds($ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ class LiveList extends Builder
|
||||
$courses = $this->getCourses($lives);
|
||||
|
||||
foreach ($lives as $key => $live) {
|
||||
$lives[$key]['course'] = $courses[$live['course_id']] ?? new \stdClass();
|
||||
$lives[$key]['course'] = $courses[$live['course_id']] ?? null;
|
||||
}
|
||||
|
||||
return $lives;
|
||||
@ -30,7 +30,7 @@ class LiveList extends Builder
|
||||
$chapters = $this->getChapters($lives);
|
||||
|
||||
foreach ($lives as $key => $live) {
|
||||
$lives[$key]['chapter'] = $chapters[$live['chapter_id']] ?? new \stdClass();
|
||||
$lives[$key]['chapter'] = $chapters[$live['chapter_id']] ?? null;
|
||||
}
|
||||
|
||||
return $lives;
|
||||
@ -63,7 +63,7 @@ class LiveList extends Builder
|
||||
|
||||
foreach ($courses->toArray() as $course) {
|
||||
$course['cover'] = $baseUrl . $course['cover'];
|
||||
$course['teacher'] = $teachers[$course['teacher_id']] ?? new \stdClass();
|
||||
$course['teacher'] = $teachers[$course['teacher_id']] ?? null;
|
||||
$result[$course['id']] = [
|
||||
'id' => $course['id'],
|
||||
'title' => $course['title'],
|
||||
|
@ -7,8 +7,6 @@
|
||||
|
||||
namespace App\Builders;
|
||||
|
||||
use App\Repos\User as UserRepo;
|
||||
|
||||
class NotificationList extends Builder
|
||||
{
|
||||
|
||||
@ -17,8 +15,8 @@ class NotificationList extends Builder
|
||||
$users = $this->getUsers($notifications);
|
||||
|
||||
foreach ($notifications as $key => $notification) {
|
||||
$notifications[$key]['sender'] = $users[$notification['sender_id']] ?? new \stdClass();
|
||||
$notifications[$key]['receiver'] = $users[$notification['receiver_id']] ?? new \stdClass();
|
||||
$notifications[$key]['sender'] = $users[$notification['sender_id']] ?? null;
|
||||
$notifications[$key]['receiver'] = $users[$notification['receiver_id']] ?? null;
|
||||
}
|
||||
|
||||
return $notifications;
|
||||
@ -30,20 +28,7 @@ class NotificationList extends Builder
|
||||
$receiverIds = kg_array_column($notifications, 'receiver_id');
|
||||
$ids = array_merge($senderIds, $receiverIds);
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findShallowUserByIds($ids);
|
||||
|
||||
$baseUrl = kg_cos_url();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$user['avatar'] = $baseUrl . $user['avatar'];
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $this->getShallowUserByIds($ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ namespace App\Builders;
|
||||
|
||||
use App\Models\Course as CourseModel;
|
||||
use App\Models\Order as OrderModel;
|
||||
use App\Repos\User as UserRepo;
|
||||
|
||||
class OrderList extends Builder
|
||||
{
|
||||
@ -30,7 +29,7 @@ class OrderList extends Builder
|
||||
$users = $this->getUsers($orders);
|
||||
|
||||
foreach ($orders as $key => $order) {
|
||||
$orders[$key]['owner'] = $users[$order['owner_id']] ?? new \stdClass();
|
||||
$orders[$key]['owner'] = $users[$order['owner_id']] ?? null;
|
||||
}
|
||||
|
||||
return $orders;
|
||||
@ -175,17 +174,7 @@ class OrderList extends Builder
|
||||
{
|
||||
$ids = kg_array_column($orders, 'owner_id');
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findShallowUserByIds($ids);
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $this->getShallowUserByIds($ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,7 +8,6 @@
|
||||
namespace App\Builders;
|
||||
|
||||
use App\Repos\Question as QuestionRepo;
|
||||
use App\Repos\User as UserRepo;
|
||||
use Phalcon\Text;
|
||||
|
||||
class QuestionFavoriteList extends Builder
|
||||
@ -19,7 +18,7 @@ class QuestionFavoriteList extends Builder
|
||||
$questions = $this->getQuestions($relations);
|
||||
|
||||
foreach ($relations as $key => $value) {
|
||||
$relations[$key]['question'] = $questions[$value['question_id']] ?? new \stdClass();
|
||||
$relations[$key]['question'] = $questions[$value['question_id']] ?? null;
|
||||
}
|
||||
|
||||
return $relations;
|
||||
@ -30,7 +29,7 @@ class QuestionFavoriteList extends Builder
|
||||
$users = $this->getUsers($relations);
|
||||
|
||||
foreach ($relations as $key => $value) {
|
||||
$relations[$key]['user'] = $users[$value['user_id']] ?? new \stdClass();
|
||||
$relations[$key]['user'] = $users[$value['user_id']] ?? null;
|
||||
}
|
||||
|
||||
return $relations;
|
||||
@ -70,20 +69,7 @@ class QuestionFavoriteList extends Builder
|
||||
{
|
||||
$ids = kg_array_column($relations, 'user_id');
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findShallowUserByIds($ids);
|
||||
|
||||
$baseUrl = kg_cos_url();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$user['avatar'] = $baseUrl . $user['avatar'];
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $this->getShallowUserByIds($ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ namespace App\Builders;
|
||||
|
||||
use App\Caches\CategoryAllList as CategoryAllListCache;
|
||||
use App\Models\Category as CategoryModel;
|
||||
use App\Repos\User as UserRepo;
|
||||
|
||||
class QuestionList extends Builder
|
||||
{
|
||||
@ -28,7 +27,7 @@ class QuestionList extends Builder
|
||||
$categories = $this->getCategories();
|
||||
|
||||
foreach ($questions as $key => $question) {
|
||||
$questions[$key]['category'] = $categories[$question['category_id']] ?? new \stdClass();
|
||||
$questions[$key]['category'] = $categories[$question['category_id']] ?? null;
|
||||
}
|
||||
|
||||
return $questions;
|
||||
@ -39,8 +38,8 @@ class QuestionList extends Builder
|
||||
$users = $this->getUsers($questions);
|
||||
|
||||
foreach ($questions as $key => $question) {
|
||||
$questions[$key]['owner'] = $users[$question['owner_id']] ?? new \stdClass();
|
||||
$questions[$key]['last_replier'] = $users[$question['last_replier_id']] ?? new \stdClass();
|
||||
$questions[$key]['owner'] = $users[$question['owner_id']] ?? null;
|
||||
$questions[$key]['last_replier'] = $users[$question['last_replier_id']] ?? null;
|
||||
}
|
||||
|
||||
return $questions;
|
||||
@ -72,20 +71,7 @@ class QuestionList extends Builder
|
||||
$lastReplierIds = kg_array_column($questions, 'last_replier_id');
|
||||
$ids = array_merge($ownerIds, $lastReplierIds);
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findShallowUserByIds($ids);
|
||||
|
||||
$baseUrl = kg_cos_url();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$user['avatar'] = $baseUrl . $user['avatar'];
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $this->getShallowUserByIds($ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ namespace App\Builders;
|
||||
|
||||
use App\Models\Refund as RefundModel;
|
||||
use App\Repos\Order as OrderRepo;
|
||||
use App\Repos\User as UserRepo;
|
||||
|
||||
class RefundList extends Builder
|
||||
{
|
||||
@ -19,7 +18,7 @@ class RefundList extends Builder
|
||||
$orders = $this->getOrders($trades);
|
||||
|
||||
foreach ($trades as $key => $trade) {
|
||||
$trades[$key]['order'] = $orders[$trade['order_id']] ?? new \stdClass();
|
||||
$trades[$key]['order'] = $orders[$trade['order_id']] ?? null;
|
||||
}
|
||||
|
||||
return $trades;
|
||||
@ -30,7 +29,7 @@ class RefundList extends Builder
|
||||
$users = $this->getUsers($refunds);
|
||||
|
||||
foreach ($refunds as $key => $refund) {
|
||||
$refunds[$key]['owner'] = $users[$refund['owner_id']] ?? new \stdClass();
|
||||
$refunds[$key]['owner'] = $users[$refund['owner_id']] ?? null;
|
||||
}
|
||||
|
||||
return $refunds;
|
||||
@ -75,20 +74,7 @@ class RefundList extends Builder
|
||||
{
|
||||
$ids = kg_array_column($refunds, 'owner_id');
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findShallowUserByIds($ids);
|
||||
|
||||
$baseUrl = kg_cos_url();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$user['avatar'] = $baseUrl . $user['avatar'];
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $this->getShallowUserByIds($ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,8 +7,6 @@
|
||||
|
||||
namespace App\Builders;
|
||||
|
||||
use App\Repos\User as UserRepo;
|
||||
|
||||
class ReportList extends Builder
|
||||
{
|
||||
|
||||
@ -17,7 +15,7 @@ class ReportList extends Builder
|
||||
$users = $this->getUsers($reports);
|
||||
|
||||
foreach ($reports as $key => $report) {
|
||||
$reports[$key]['owner'] = $users[$report['owner_id']] ?? new \stdClass();
|
||||
$reports[$key]['owner'] = $users[$report['owner_id']] ?? null;
|
||||
}
|
||||
|
||||
return $reports;
|
||||
@ -27,20 +25,7 @@ class ReportList extends Builder
|
||||
{
|
||||
$ids = kg_array_column($reports, 'owner_id');
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findShallowUserByIds($ids);
|
||||
|
||||
$baseUrl = kg_cos_url();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$user['avatar'] = $baseUrl . $user['avatar'];
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $this->getShallowUserByIds($ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ class ResourceList extends Builder
|
||||
$uploads = $this->getUploads($relations);
|
||||
|
||||
foreach ($relations as $key => $value) {
|
||||
$relations[$key]['upload'] = $uploads[$value['upload_id']] ?? new \stdClass();
|
||||
$relations[$key]['upload'] = $uploads[$value['upload_id']] ?? null;
|
||||
}
|
||||
|
||||
return $relations;
|
||||
|
@ -8,7 +8,6 @@
|
||||
namespace App\Builders;
|
||||
|
||||
use App\Repos\Course as CourseRepo;
|
||||
use App\Repos\User as UserRepo;
|
||||
|
||||
class ReviewList extends Builder
|
||||
{
|
||||
@ -18,7 +17,7 @@ class ReviewList extends Builder
|
||||
$courses = $this->getCourses($reviews);
|
||||
|
||||
foreach ($reviews as $key => $review) {
|
||||
$reviews[$key]['course'] = $courses[$review['course_id']] ?? new \stdClass();
|
||||
$reviews[$key]['course'] = $courses[$review['course_id']] ?? null;
|
||||
}
|
||||
|
||||
return $reviews;
|
||||
@ -29,7 +28,7 @@ class ReviewList extends Builder
|
||||
$users = $this->getUsers($reviews);
|
||||
|
||||
foreach ($reviews as $key => $review) {
|
||||
$reviews[$key]['owner'] = $users[$review['owner_id']] ?? new \stdClass();
|
||||
$reviews[$key]['owner'] = $users[$review['owner_id']] ?? null;
|
||||
}
|
||||
|
||||
return $reviews;
|
||||
@ -56,20 +55,7 @@ class ReviewList extends Builder
|
||||
{
|
||||
$ids = kg_array_column($reviews, 'owner_id');
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findShallowUserByIds($ids);
|
||||
|
||||
$baseUrl = kg_cos_url();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$user['avatar'] = $baseUrl . $user['avatar'];
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $this->getShallowUserByIds($ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,7 +8,6 @@
|
||||
namespace App\Builders;
|
||||
|
||||
use App\Repos\Tag as TagRepo;
|
||||
use App\Repos\User as UserRepo;
|
||||
|
||||
class TagFollowList extends Builder
|
||||
{
|
||||
@ -18,7 +17,7 @@ class TagFollowList extends Builder
|
||||
$tags = $this->getTags($relations);
|
||||
|
||||
foreach ($relations as $key => $value) {
|
||||
$relations[$key]['tag'] = $tags[$value['tag_id']] ?? new \stdClass();
|
||||
$relations[$key]['tag'] = $tags[$value['tag_id']] ?? null;
|
||||
}
|
||||
|
||||
return $relations;
|
||||
@ -29,7 +28,7 @@ class TagFollowList extends Builder
|
||||
$users = $this->getUsers($relations);
|
||||
|
||||
foreach ($relations as $key => $value) {
|
||||
$relations[$key]['user'] = $users[$value['user_id']] ?? new \stdClass();
|
||||
$relations[$key]['user'] = $users[$value['user_id']] ?? null;
|
||||
}
|
||||
|
||||
return $relations;
|
||||
@ -61,20 +60,7 @@ class TagFollowList extends Builder
|
||||
{
|
||||
$ids = kg_array_column($relations, 'user_id');
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findByIds($ids, ['id', 'name', 'avatar']);
|
||||
|
||||
$baseUrl = kg_cos_url();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$user['avatar'] = $baseUrl . $user['avatar'];
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $this->getShallowUserByIds($ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,7 +8,6 @@
|
||||
namespace App\Builders;
|
||||
|
||||
use App\Repos\Order as OrderRepo;
|
||||
use App\Repos\User as UserRepo;
|
||||
|
||||
class TradeList extends Builder
|
||||
{
|
||||
@ -18,7 +17,7 @@ class TradeList extends Builder
|
||||
$orders = $this->getOrders($trades);
|
||||
|
||||
foreach ($trades as $key => $trade) {
|
||||
$trades[$key]['order'] = $orders[$trade['order_id']] ?? new \stdClass();
|
||||
$trades[$key]['order'] = $orders[$trade['order_id']] ?? null;
|
||||
}
|
||||
|
||||
return $trades;
|
||||
@ -29,7 +28,7 @@ class TradeList extends Builder
|
||||
$users = $this->getUsers($trades);
|
||||
|
||||
foreach ($trades as $key => $trade) {
|
||||
$trades[$key]['owner'] = $users[$trade['owner_id']] ?? new \stdClass();
|
||||
$trades[$key]['owner'] = $users[$trade['owner_id']] ?? null;
|
||||
}
|
||||
|
||||
return $trades;
|
||||
@ -56,20 +55,7 @@ class TradeList extends Builder
|
||||
{
|
||||
$ids = kg_array_column($trades, 'owner_id');
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$users = $userRepo->findShallowUserByIds($ids);
|
||||
|
||||
$baseUrl = kg_cos_url();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($users->toArray() as $user) {
|
||||
$user['avatar'] = $baseUrl . $user['avatar'];
|
||||
$result[$user['id']] = $user;
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $this->getShallowUserByIds($ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ class UserList extends Builder
|
||||
$accounts = $this->getAccounts($users);
|
||||
|
||||
foreach ($users as $key => $user) {
|
||||
$users[$key]['account'] = $accounts[$user['id']] ?? new \stdClass();
|
||||
$users[$key]['account'] = $accounts[$user['id']] ?? null;
|
||||
}
|
||||
|
||||
return $users;
|
||||
|
@ -1,36 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Repos\Help as HelpRepo;
|
||||
|
||||
class Help extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 7 * 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return "help:{$id}";
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
$helpRepo = new HelpRepo();
|
||||
|
||||
$help = $helpRepo->findById($id);
|
||||
|
||||
return $help ?: null;
|
||||
}
|
||||
|
||||
}
|
@ -1,97 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Models\Category as CategoryModel;
|
||||
use App\Models\Help as HelpModel;
|
||||
use Phalcon\Mvc\Model\Resultset;
|
||||
use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
|
||||
class HelpList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 7 * 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return 'help_list';
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
|
||||
$categories = $this->findCategories();
|
||||
|
||||
if ($categories->count() == 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($categories as $category) {
|
||||
|
||||
$item = [];
|
||||
|
||||
$item['category'] = [
|
||||
'id' => $category->id,
|
||||
'name' => $category->name,
|
||||
];
|
||||
|
||||
$item['helps'] = [];
|
||||
|
||||
$helps = $this->findHelps($category->id);
|
||||
|
||||
if ($helps->count() > 0) {
|
||||
foreach ($helps as $help) {
|
||||
$item['helps'][] = [
|
||||
'id' => $help->id,
|
||||
'title' => $help->title,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$result[] = $item;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ResultsetInterface|Resultset|CategoryModel[]
|
||||
*/
|
||||
protected function findCategories()
|
||||
{
|
||||
return CategoryModel::query()
|
||||
->where('type = :type:', ['type' => CategoryModel::TYPE_HELP])
|
||||
->andWhere('level = 1')
|
||||
->andWhere('published = 1')
|
||||
->andWhere('deleted = 0')
|
||||
->orderBy('priority ASC')
|
||||
->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $categoryId
|
||||
* @return ResultsetInterface|Resultset|CategoryModel[]
|
||||
*/
|
||||
protected function findHelps($categoryId)
|
||||
{
|
||||
return HelpModel::query()
|
||||
->where('category_id = :category_id:', ['category_id' => $categoryId])
|
||||
->andWhere('published = 1')
|
||||
->andWhere('deleted = 0')
|
||||
->orderBy('priority ASC')
|
||||
->execute();
|
||||
}
|
||||
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Models\Answer as AnswerModel;
|
||||
|
||||
class MaxAnswerId extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 365 * 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return 'max_answer_id';
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
$answer = AnswerModel::findFirst(['order' => 'id DESC']);
|
||||
|
||||
return $answer->id ?? 0;
|
||||
}
|
||||
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Models\Comment as CommentModel;
|
||||
|
||||
class MaxCommentId extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 365 * 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return 'max_comment_id';
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
$comment = CommentModel::findFirst(['order' => 'id DESC']);
|
||||
|
||||
return $comment->id ?? 0;
|
||||
}
|
||||
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Models\Help as HelpModel;
|
||||
|
||||
class MaxHelpId extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 365 * 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return 'max_help_id';
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
$help = HelpModel::findFirst(['order' => 'id DESC']);
|
||||
|
||||
return $help->id ?? 0;
|
||||
}
|
||||
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Models\Page as PageModel;
|
||||
|
||||
class MaxPageId extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 365 * 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return 'max_page_id';
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
$page = PageModel::findFirst(['order' => 'id DESC']);
|
||||
|
||||
return $page->id ?? 0;
|
||||
}
|
||||
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Models\PointGift as PointGiftModel;
|
||||
|
||||
class MaxPointGiftId extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 365 * 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return 'max_point_gift_id';
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
$gift = PointGiftModel::findFirst(['order' => 'id DESC']);
|
||||
|
||||
return $gift->id ?? 0;
|
||||
}
|
||||
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Models\Upload as UploadModel;
|
||||
|
||||
class MaxUploadId extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 365 * 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return 'max_upload_id';
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
$upload = UploadModel::findFirst(['order' => 'id DESC']);
|
||||
|
||||
return $upload->id ?? 0;
|
||||
}
|
||||
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Repos\Page as PageRepo;
|
||||
|
||||
class Page extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 7 * 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return "page:{$id}";
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
$pageRepo = new PageRepo();
|
||||
|
||||
$page = $pageRepo->findById($id);
|
||||
|
||||
return $page ?: null;
|
||||
}
|
||||
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Repos\PointGift as PointGiftRepo;
|
||||
|
||||
class PointGift extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return "point_gift:{$id}";
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
$giftRepo = new PointGiftRepo();
|
||||
|
||||
$gift = $giftRepo->findById($id);
|
||||
|
||||
return $gift ?: null;
|
||||
}
|
||||
|
||||
}
|
@ -177,13 +177,13 @@ class ServerMonitorTask extends Task
|
||||
|
||||
$searcher = new CourseSearcher();
|
||||
|
||||
$user = $searcher->search('id:1');
|
||||
$course = $searcher->search('id:1');
|
||||
|
||||
$benchmark->stop();
|
||||
|
||||
$elapsedTime = $benchmark->getElapsedTime();
|
||||
|
||||
if (empty($user)) {
|
||||
if (empty($course)) {
|
||||
return "xunsearch搜索失败";
|
||||
}
|
||||
|
||||
@ -242,4 +242,4 @@ class ServerMonitorTask extends Task
|
||||
return $coreCount * $processorCount;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -168,14 +168,12 @@ class Course extends Service
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($post['category_id']) && !empty($post['category_id'])) {
|
||||
$category = $validator->checkCategory($post['category_id']);
|
||||
$data['category_id'] = $category->id;
|
||||
if (isset($post['category_id'])) {
|
||||
$data['category_id'] = $validator->checkCategoryId($post['category_id']);
|
||||
}
|
||||
|
||||
if (isset($post['teacher_id']) && !empty($post['teacher_id'])) {
|
||||
$teacher = $validator->checkTeacher($post['teacher_id']);
|
||||
$data['teacher_id'] = $teacher->id;
|
||||
if (isset($post['teacher_id'])) {
|
||||
$data['teacher_id'] = $validator->checkTeacherId($post['teacher_id']);
|
||||
}
|
||||
|
||||
if (isset($post['xm_tag_ids'])) {
|
||||
|
@ -8,8 +8,6 @@
|
||||
namespace App\Http\Admin\Services;
|
||||
|
||||
use App\Builders\HelpList as HelpListBuilder;
|
||||
use App\Caches\Help as HelpCache;
|
||||
use App\Caches\HelpList as HelpListCache;
|
||||
use App\Models\Category as CategoryModel;
|
||||
use App\Models\Help as HelpModel;
|
||||
use App\Repos\Category as CategoryRepo;
|
||||
@ -76,9 +74,6 @@ class Help extends Service
|
||||
|
||||
$help->create($data);
|
||||
|
||||
$this->rebuildHelpCache($help);
|
||||
$this->rebuildHelpListCache();
|
||||
|
||||
return $help;
|
||||
}
|
||||
|
||||
@ -119,9 +114,6 @@ class Help extends Service
|
||||
|
||||
$help->update($data);
|
||||
|
||||
$this->rebuildHelpCache($help);
|
||||
$this->rebuildHelpListCache();
|
||||
|
||||
return $help;
|
||||
}
|
||||
|
||||
@ -133,9 +125,6 @@ class Help extends Service
|
||||
|
||||
$help->update();
|
||||
|
||||
$this->rebuildHelpCache($help);
|
||||
$this->rebuildHelpListCache();
|
||||
|
||||
return $help;
|
||||
}
|
||||
|
||||
@ -147,9 +136,6 @@ class Help extends Service
|
||||
|
||||
$help->update();
|
||||
|
||||
$this->rebuildHelpCache($help);
|
||||
$this->rebuildHelpListCache();
|
||||
|
||||
return $help;
|
||||
}
|
||||
|
||||
@ -160,20 +146,6 @@ class Help extends Service
|
||||
return $validator->checkHelp($id);
|
||||
}
|
||||
|
||||
protected function rebuildHelpCache(HelpModel $help)
|
||||
{
|
||||
$cache = new HelpCache();
|
||||
|
||||
$cache->rebuild($help->id);
|
||||
}
|
||||
|
||||
protected function rebuildHelpListCache()
|
||||
{
|
||||
$cache = new HelpListCache();
|
||||
|
||||
$cache->rebuild();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Resultset $helps
|
||||
* @return array|object
|
||||
|
@ -59,9 +59,8 @@ class Package extends Service
|
||||
$result = [];
|
||||
|
||||
foreach ($items as $item) {
|
||||
$price = $item->market_price > 0 ? sprintf("¥%0.2f", $item->market_price) : '免费';
|
||||
$result[] = [
|
||||
'name' => sprintf('%s - %s(¥%0.2f)', $item->id, $item->title, $price),
|
||||
'name' => sprintf('%s - %s(¥%0.2f)', $item->id, $item->title, $item->market_price),
|
||||
'value' => $item->id,
|
||||
'selected' => in_array($item->id, $courseIds),
|
||||
];
|
||||
@ -152,7 +151,7 @@ class Package extends Service
|
||||
$package->update($data);
|
||||
|
||||
$this->handlePackagedCourses($package->id);
|
||||
$this->updatePackageCourseCount($package->id);
|
||||
$this->recountPackageCourses($package->id);
|
||||
$this->rebuildPackageCache($package->id);
|
||||
|
||||
return $package;
|
||||
@ -217,7 +216,7 @@ class Package extends Service
|
||||
'course_id' => $courseId,
|
||||
'package_id' => $package->id,
|
||||
]);
|
||||
$this->updateCoursePackageCount($courseId);
|
||||
$this->recountCoursePackages($courseId);
|
||||
$this->rebuildCoursePackageCache($courseId);
|
||||
}
|
||||
}
|
||||
@ -229,7 +228,7 @@ class Package extends Service
|
||||
foreach ($deletedCourseIds as $courseId) {
|
||||
$coursePackage = $coursePackageRepo->findCoursePackage($courseId, $package->id);
|
||||
$coursePackage->delete();
|
||||
$this->updateCoursePackageCount($courseId);
|
||||
$this->recountCoursePackages($courseId);
|
||||
$this->rebuildCoursePackageCache($courseId);
|
||||
}
|
||||
}
|
||||
@ -249,7 +248,7 @@ class Package extends Service
|
||||
}
|
||||
}
|
||||
|
||||
protected function updatePackageCourseCount($packageId)
|
||||
protected function recountPackageCourses($packageId)
|
||||
{
|
||||
$packageRepo = new PackageRepo();
|
||||
|
||||
@ -262,7 +261,7 @@ class Package extends Service
|
||||
$package->update();
|
||||
}
|
||||
|
||||
protected function updateCoursePackageCount($courseId)
|
||||
protected function recountCoursePackages($courseId)
|
||||
{
|
||||
$courseRepo = new CourseRepo();
|
||||
|
||||
@ -293,15 +292,4 @@ class Package extends Service
|
||||
$cache->rebuild($courseId);
|
||||
}
|
||||
|
||||
protected function recountCoursePackages($courseId)
|
||||
{
|
||||
$courseRepo = new CourseRepo();
|
||||
|
||||
$course = $courseRepo->findById($courseId);
|
||||
|
||||
$course->package_count = $courseRepo->countPackages($courseId);
|
||||
|
||||
$course->update();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
namespace App\Http\Admin\Services;
|
||||
|
||||
use App\Caches\Page as PageCache;
|
||||
use App\Library\Paginator\Query as PagerQuery;
|
||||
use App\Models\Page as PageModel;
|
||||
use App\Repos\Page as PageRepo;
|
||||
@ -53,8 +52,6 @@ class Page extends Service
|
||||
|
||||
$page->create($data);
|
||||
|
||||
$this->rebuildPageCache($page);
|
||||
|
||||
return $page;
|
||||
}
|
||||
|
||||
@ -96,8 +93,6 @@ class Page extends Service
|
||||
|
||||
$page->update($data);
|
||||
|
||||
$this->rebuildPageCache($page);
|
||||
|
||||
return $page;
|
||||
}
|
||||
|
||||
@ -109,8 +104,6 @@ class Page extends Service
|
||||
|
||||
$page->update();
|
||||
|
||||
$this->rebuildPageCache($page);
|
||||
|
||||
return $page;
|
||||
}
|
||||
|
||||
@ -122,8 +115,6 @@ class Page extends Service
|
||||
|
||||
$page->update();
|
||||
|
||||
$this->rebuildPageCache($page);
|
||||
|
||||
return $page;
|
||||
}
|
||||
|
||||
@ -134,11 +125,4 @@ class Page extends Service
|
||||
return $validator->checkPage($id);
|
||||
}
|
||||
|
||||
protected function rebuildPageCache(PageModel $page)
|
||||
{
|
||||
$cache = new PageCache();
|
||||
|
||||
$cache->rebuild($page->id);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
namespace App\Http\Admin\Services;
|
||||
|
||||
use App\Caches\PointGift as PointGiftCache;
|
||||
use App\Library\Paginator\Query as PagerQuery;
|
||||
use App\Models\PointGift as PointGiftModel;
|
||||
use App\Repos\Course as CourseRepo;
|
||||
@ -116,8 +115,6 @@ class PointGift extends Service
|
||||
break;
|
||||
}
|
||||
|
||||
$this->rebuildPointGiftCache($gift);
|
||||
|
||||
return $gift;
|
||||
}
|
||||
|
||||
@ -165,8 +162,6 @@ class PointGift extends Service
|
||||
|
||||
$gift->update($data);
|
||||
|
||||
$this->rebuildPointGiftCache($gift);
|
||||
|
||||
return $gift;
|
||||
}
|
||||
|
||||
@ -178,8 +173,6 @@ class PointGift extends Service
|
||||
|
||||
$gift->update();
|
||||
|
||||
$this->rebuildPointGiftCache($gift);
|
||||
|
||||
return $gift;
|
||||
}
|
||||
|
||||
@ -191,8 +184,6 @@ class PointGift extends Service
|
||||
|
||||
$gift->update();
|
||||
|
||||
$this->rebuildPointGiftCache($gift);
|
||||
|
||||
return $gift;
|
||||
}
|
||||
|
||||
@ -203,13 +194,6 @@ class PointGift extends Service
|
||||
return $validator->checkPointGift($id);
|
||||
}
|
||||
|
||||
protected function rebuildPointGiftCache(PointGiftModel $gift)
|
||||
{
|
||||
$cache = new PointGiftCache();
|
||||
|
||||
$cache->rebuild($gift->id);
|
||||
}
|
||||
|
||||
protected function createCoursePointGift($post)
|
||||
{
|
||||
$validator = new PointGiftValidator();
|
||||
|
@ -49,7 +49,7 @@
|
||||
name: 'xm_tag_ids',
|
||||
max: 5,
|
||||
filterable: true,
|
||||
filterMethod: function (val, item, index, prop) {
|
||||
filterMethod: function (val, item) {
|
||||
return item.name.toLowerCase().indexOf(val.toLowerCase()) !== -1;
|
||||
},
|
||||
data: {{ xm_tags|json_encode }}
|
||||
@ -71,4 +71,4 @@
|
||||
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
@ -84,7 +84,7 @@
|
||||
name: 'course_id',
|
||||
filterable: true,
|
||||
radio: true,
|
||||
filterMethod: function (val, item, index, prop) {
|
||||
filterMethod: function (val, item) {
|
||||
return item.name.toLowerCase().indexOf(val.toLowerCase()) !== -1;
|
||||
},
|
||||
data: {{ xm_courses|json_encode }}
|
||||
@ -102,4 +102,4 @@
|
||||
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
@ -65,7 +65,7 @@
|
||||
name: 'xm_tag_ids',
|
||||
max: 5,
|
||||
filterable: true,
|
||||
filterMethod: function (val, item, index, prop) {
|
||||
filterMethod: function (val, item) {
|
||||
return item.name.toLowerCase().indexOf(val.toLowerCase()) !== -1;
|
||||
},
|
||||
data: {{ xm_tags|json_encode }}
|
||||
@ -77,7 +77,7 @@
|
||||
max: 10,
|
||||
autoRow: true,
|
||||
filterable: true,
|
||||
filterMethod: function (val, item, index, prop) {
|
||||
filterMethod: function (val, item) {
|
||||
return item.name.toLowerCase().indexOf(val.toLowerCase()) !== -1;
|
||||
},
|
||||
data: {{ xm_courses|json_encode }}
|
||||
@ -107,4 +107,4 @@
|
||||
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
@ -1,31 +0,0 @@
|
||||
{%- macro item_type_info(value) %}
|
||||
{% if value == 1 %}
|
||||
课程
|
||||
{% elseif value == 2 %}
|
||||
套餐
|
||||
{% elseif value == 3 %}
|
||||
会员
|
||||
{% endif %}
|
||||
{%- endmacro %}
|
||||
|
||||
{%- macro item_full_info(item_type,item_info) %}
|
||||
{% if item_type == 1 %}
|
||||
{% set course = item_info.course %}
|
||||
<p>名称:{{ course.title }}({{ course.id }})</p>
|
||||
<p>类型:{{ item_type_info(item_type) }} 价格:{{ '¥%0.2f'|format(course.market_price) }}</p>
|
||||
{% elseif item_type == 2 %}
|
||||
{% set package = item_info.package %}
|
||||
<p>名称:{{ package.title }}({{ package.id }})</p>
|
||||
<p>类型:{{ item_type_info(item_type) }} 价格:{{ '¥%0.2f'|format(package.market_price) }}</p>
|
||||
{% elseif item_type == 3 %}
|
||||
{% set vip = item_info.vip %}
|
||||
<p>期限:{{ '%d个月'|format(vip.expiry) }}({{ vip.id }})</p>
|
||||
<p>类型:{{ item_type_info(item_type) }} 价格:{{ '¥%0.2f'|format(vip.price) }}</p>
|
||||
{% endif %}
|
||||
{%- endmacro %}
|
||||
|
||||
{%- macro schedules_info(schedules) %}
|
||||
{% for value in schedules %}
|
||||
<span class="layui-badge layui-bg-gray">{{ value }}点</span>
|
||||
{% endfor %}
|
||||
{%- endmacro %}
|
@ -82,7 +82,7 @@
|
||||
max: 15,
|
||||
autoRow: true,
|
||||
filterable: true,
|
||||
filterMethod: function (val, item, index, prop) {
|
||||
filterMethod: function (val, item) {
|
||||
return item.name.toLowerCase().indexOf(val.toLowerCase()) !== -1;
|
||||
},
|
||||
data: {{ xm_courses|json_encode }}
|
||||
@ -92,4 +92,4 @@
|
||||
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
@ -69,7 +69,7 @@
|
||||
name: 'xm_course_id',
|
||||
radio: true,
|
||||
filterable: true,
|
||||
filterMethod: function (val, item, index, prop) {
|
||||
filterMethod: function (val, item) {
|
||||
return item.name.toLowerCase().indexOf(val.toLowerCase()) !== -1;
|
||||
},
|
||||
data: {{ xm_courses|json_encode }}
|
||||
@ -91,4 +91,4 @@
|
||||
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
@ -48,7 +48,7 @@
|
||||
name: 'xm_tag_ids',
|
||||
max: 5,
|
||||
filterable: true,
|
||||
filterMethod: function (val, item, index, prop) {
|
||||
filterMethod: function (val, item) {
|
||||
return item.name.toLowerCase().indexOf(val.toLowerCase()) !== -1;
|
||||
},
|
||||
data: {{ xm_tags|json_encode }}
|
||||
@ -58,4 +58,4 @@
|
||||
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
@ -84,7 +84,7 @@
|
||||
name: 'course_id',
|
||||
filterable: true,
|
||||
radio: true,
|
||||
filterMethod: function (val, item, index, prop) {
|
||||
filterMethod: function (val, item) {
|
||||
return item.name.toLowerCase().indexOf(val.toLowerCase()) !== -1;
|
||||
},
|
||||
data: {{ xm_courses|json_encode }}
|
||||
@ -102,4 +102,4 @@
|
||||
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
@ -75,7 +75,7 @@
|
||||
name: 'xm_course_id',
|
||||
radio: true,
|
||||
filterable: true,
|
||||
filterMethod: function (val, item, index, prop) {
|
||||
filterMethod: function (val, item) {
|
||||
return item.name.toLowerCase().indexOf(val.toLowerCase()) !== -1;
|
||||
},
|
||||
data: {{ xm_courses|json_encode }}
|
||||
@ -86,7 +86,7 @@
|
||||
name: 'xm_page_id',
|
||||
radio: true,
|
||||
filterable: true,
|
||||
filterMethod: function (val, item, index, prop) {
|
||||
filterMethod: function (val, item) {
|
||||
return item.name.toLowerCase().indexOf(val.toLowerCase()) !== -1;
|
||||
},
|
||||
data: {{ xm_pages|json_encode }}
|
||||
@ -101,4 +101,4 @@
|
||||
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
@ -44,7 +44,7 @@
|
||||
max: 15,
|
||||
autoRow: true,
|
||||
filterable: true,
|
||||
filterMethod: function (val, item, index, prop) {
|
||||
filterMethod: function (val, item) {
|
||||
return item.name.toLowerCase().indexOf(val.toLowerCase()) !== -1;
|
||||
},
|
||||
data: {{ xm_courses|json_encode }}
|
||||
@ -55,4 +55,3 @@
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
@ -87,7 +87,7 @@ class PointGiftController extends Controller
|
||||
$hotGifts = $this->getHotGifts();
|
||||
$userBalance = $this->getUserBalance();
|
||||
|
||||
$this->seo->prependTitle(['积分兑换', $gift['name']]);
|
||||
$this->seo->prependTitle(['积分商城', $gift['name']]);
|
||||
|
||||
$this->view->pick('point/gift/show');
|
||||
$this->view->setVar('gift', $gift);
|
||||
|
@ -38,11 +38,11 @@
|
||||
{% endif %}
|
||||
{% if contact_info.weibo %}
|
||||
{% set link_url = 'https://weibo.com/u/%s'|format(contact_info.weibo) %}
|
||||
<a class="weibo" href="{{ link_url }}" title="微博主页"><span class="iconfont icon-weibo"></span></a>
|
||||
<a class="weibo" href="{{ link_url }}" title="微博主页" target="_blank"><span class="iconfont icon-weibo"></span></a>
|
||||
{% endif %}
|
||||
{% if contact_info.zhihu %}
|
||||
{% set link_url = 'https://www.zhihu.com/people/%s'|format(contact_info.zhihu) %}
|
||||
<a class="zhihu" href="{{ link_url }}" title="知乎主页"><span class="iconfont icon-zhihu"></span></a>
|
||||
<a class="zhihu" href="{{ link_url }}" title="知乎主页" target="_blank"><span class="iconfont icon-zhihu"></span></a>
|
||||
{% endif %}
|
||||
{% if contact_info.email %}
|
||||
{% set link_url = 'mailto:%s'|format(contact_info.email) %}
|
||||
@ -53,8 +53,8 @@
|
||||
{% endif %}
|
||||
{% if contact_info.address %}
|
||||
{% set link_url = 'https://map.baidu.com/search/%s?querytype=s&wd=%s'|format(contact_info.address,contact_info.address) %}
|
||||
<a class="location" href="{{ link_url }}" title="联系地址:{{ contact_info.address }}"><span class="iconfont icon-location"></span></a>
|
||||
<a class="location" href="{{ link_url }}" title="联系地址:{{ contact_info.address }}" target="_blank"><span class="iconfont icon-location"></span></a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
<div class="layui-breadcrumb breadcrumb">
|
||||
<a href="/">首页</a>
|
||||
<a><cite>积分兑换</cite></a>
|
||||
<a><cite>积分商城</cite></a>
|
||||
</div>
|
||||
|
||||
<div id="gift-list" data-url="{{ pager_url }}"></div>
|
||||
@ -17,4 +17,4 @@
|
||||
|
||||
{{ js_include('home/js/point.gift.list.js') }}
|
||||
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
@ -10,7 +10,7 @@
|
||||
<div class="breadcrumb">
|
||||
<span class="layui-breadcrumb">
|
||||
<a href="/">首页</a>
|
||||
<a href="{{ gift_list_url }}">积分兑换</a>
|
||||
<a href="{{ gift_list_url }}">积分商城</a>
|
||||
<a><cite>{{ gift.name }}</cite></a>
|
||||
</span>
|
||||
</div>
|
||||
@ -55,7 +55,23 @@
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">物品详情</div>
|
||||
<div class="layui-card-body">
|
||||
<div class="gift-details ke-content kg-zoom">{{ gift.details }}</div>
|
||||
<div class="gift-details ke-content kg-zoom">
|
||||
{% if gift.type == 1 %}
|
||||
{% set course_url = url({'for':'home.course.show','id':gift.attrs.id}) %}
|
||||
<p class="item">
|
||||
<a href="{{ course_url }}">{{ gift.name }}</a>
|
||||
<span class="layui-badge">查看</span>
|
||||
</p>
|
||||
{% elseif gift.type == 3 %}
|
||||
{% set vip_url = url({'for':'home.vip.index'}) %}
|
||||
<p class="item">
|
||||
<a href="{{ vip_url }}">{{ gift.name }}</a>
|
||||
<span class="layui-badge">查看</span>
|
||||
</p>
|
||||
{% else %}
|
||||
{{ gift.details }}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -124,4 +140,4 @@
|
||||
|
||||
{{ js_include('home/js/point.gift.show.js') }}
|
||||
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
@ -16,7 +16,7 @@ class AppInfo
|
||||
|
||||
protected $link = 'https://www.koogua.com';
|
||||
|
||||
protected $version = '1.7.4';
|
||||
protected $version = '1.7.5';
|
||||
|
||||
public function __get($name)
|
||||
{
|
||||
@ -32,4 +32,4 @@ class AppInfo
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -70,9 +70,9 @@ class CsrfToken
|
||||
*/
|
||||
$config = Di::getDefault()->getShared('config');
|
||||
|
||||
$lifetime = $config->path('csrf_token.lifetime') ?: $this->lifetime;
|
||||
$lifetime = $config->path('csrf_token.lifetime', $this->lifetime);
|
||||
|
||||
return $lifetime + time();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -19,15 +19,13 @@ class Logger
|
||||
* @param string $channel
|
||||
* @return FileLogger
|
||||
*/
|
||||
public function getInstance($channel = null)
|
||||
public function getInstance($channel = 'common')
|
||||
{
|
||||
/**
|
||||
* @var Config $config
|
||||
*/
|
||||
$config = Di::getDefault()->getShared('config');
|
||||
|
||||
$channel = $channel ? $channel : 'common';
|
||||
|
||||
$filename = sprintf('%s-%s.log', $channel, date('Y-m-d'));
|
||||
|
||||
$path = log_path($filename);
|
||||
|
@ -42,4 +42,4 @@ class View extends PhView
|
||||
return $var;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Caches\MaxAnswerId as MaxAnswerIdCache;
|
||||
use Phalcon\Mvc\Model\Behavior\SoftDelete;
|
||||
|
||||
class Answer extends Model
|
||||
@ -166,13 +165,6 @@ class Answer extends Model
|
||||
$this->update_time = time();
|
||||
}
|
||||
|
||||
public function afterCreate()
|
||||
{
|
||||
$cache = new MaxAnswerIdCache();
|
||||
|
||||
$cache->rebuild();
|
||||
}
|
||||
|
||||
public static function publishTypes()
|
||||
{
|
||||
return [
|
||||
|
@ -253,7 +253,7 @@ class Article extends Model
|
||||
$this->cover = self::getCoverPath($this->cover);
|
||||
}
|
||||
|
||||
if (is_array($this->tags) || is_object($this->tags)) {
|
||||
if (is_array($this->tags)) {
|
||||
$this->tags = kg_json_encode($this->tags);
|
||||
}
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ class Chapter extends Model
|
||||
}
|
||||
}
|
||||
|
||||
if (is_array($this->attrs) || is_object($this->attrs)) {
|
||||
if (is_array($this->attrs)) {
|
||||
$this->attrs = kg_json_encode($this->attrs);
|
||||
}
|
||||
|
||||
@ -241,7 +241,7 @@ class Chapter extends Model
|
||||
|
||||
public function beforeUpdate()
|
||||
{
|
||||
if (is_array($this->attrs) || is_object($this->attrs)) {
|
||||
if (is_array($this->attrs)) {
|
||||
$this->attrs = kg_json_encode($this->attrs);
|
||||
}
|
||||
|
||||
|
@ -75,11 +75,11 @@ class ChapterVod extends Model
|
||||
|
||||
public function beforeCreate()
|
||||
{
|
||||
if (is_array($this->file_transcode) || is_object($this->file_transcode)) {
|
||||
if (is_array($this->file_transcode)) {
|
||||
$this->file_transcode = kg_json_encode($this->file_transcode);
|
||||
}
|
||||
|
||||
if (is_array($this->file_remote) || is_object($this->file_remote)) {
|
||||
if (is_array($this->file_remote)) {
|
||||
$this->file_remote = kg_json_encode($this->file_remote);
|
||||
}
|
||||
|
||||
@ -88,11 +88,11 @@ class ChapterVod extends Model
|
||||
|
||||
public function beforeUpdate()
|
||||
{
|
||||
if (is_array($this->file_transcode) || is_object($this->file_transcode)) {
|
||||
if (is_array($this->file_transcode)) {
|
||||
$this->file_transcode = kg_json_encode($this->file_transcode);
|
||||
}
|
||||
|
||||
if (is_array($this->file_remote) || is_object($this->file_remote)) {
|
||||
if (is_array($this->file_remote)) {
|
||||
$this->file_remote = kg_json_encode($this->file_remote);
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Caches\MaxCommentId as MaxCommentIdCache;
|
||||
use Phalcon\Mvc\Model\Behavior\SoftDelete;
|
||||
|
||||
class Comment extends Model
|
||||
@ -167,18 +166,12 @@ class Comment extends Model
|
||||
$this->update_time = time();
|
||||
}
|
||||
|
||||
public function afterCreate()
|
||||
{
|
||||
$cache = new MaxCommentIdCache();
|
||||
|
||||
$cache->rebuild();
|
||||
}
|
||||
|
||||
public static function itemTypes()
|
||||
{
|
||||
return [
|
||||
self::ITEM_CHAPTER => '章节',
|
||||
self::ITEM_ARTICLE => '文章',
|
||||
self::ITEM_QUESTION => '问题',
|
||||
self::ITEM_ANSWER => '回答',
|
||||
];
|
||||
}
|
||||
|
@ -321,7 +321,7 @@ class Course extends Model
|
||||
}
|
||||
}
|
||||
|
||||
if (is_array($this->attrs) || is_object($this->attrs)) {
|
||||
if (is_array($this->attrs)) {
|
||||
$this->attrs = kg_json_encode($this->attrs);
|
||||
}
|
||||
|
||||
@ -338,7 +338,7 @@ class Course extends Model
|
||||
$sync->addItem($this->id);
|
||||
}
|
||||
|
||||
if (is_array($this->attrs) || is_object($this->attrs)) {
|
||||
if (is_array($this->attrs)) {
|
||||
$this->attrs = kg_json_encode($this->attrs);
|
||||
}
|
||||
|
||||
@ -355,17 +355,13 @@ class Course extends Model
|
||||
$this->cover = self::getCoverPath($this->cover);
|
||||
}
|
||||
|
||||
if (is_array($this->tags) || is_object($this->tags)) {
|
||||
if (is_array($this->tags)) {
|
||||
$this->tags = kg_json_encode($this->tags);
|
||||
}
|
||||
|
||||
if (empty($this->summary)) {
|
||||
$this->summary = kg_parse_summary($this->details);
|
||||
}
|
||||
|
||||
if (empty($this->origin_price)) {
|
||||
$this->origin_price = 1.5 * $this->market_price;
|
||||
}
|
||||
}
|
||||
|
||||
public function afterCreate()
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Caches\MaxHelpId as MaxHelpIdCache;
|
||||
use Phalcon\Mvc\Model\Behavior\SoftDelete;
|
||||
|
||||
class Help extends Model
|
||||
@ -117,11 +116,4 @@ class Help extends Model
|
||||
$this->update_time = time();
|
||||
}
|
||||
|
||||
public function afterCreate()
|
||||
{
|
||||
$cache = new MaxHelpIdCache();
|
||||
|
||||
$cache->rebuild();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ class Notification extends Model
|
||||
|
||||
public function beforeSave()
|
||||
{
|
||||
if (is_array($this->event_info) || is_object($this->event_info)) {
|
||||
if (is_array($this->event_info)) {
|
||||
$this->event_info = kg_json_encode($this->event_info);
|
||||
}
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ class Order extends Model
|
||||
|
||||
public function beforeSave()
|
||||
{
|
||||
if (is_array($this->item_info) || is_object($this->item_info)) {
|
||||
if (is_array($this->item_info)) {
|
||||
$this->item_info = kg_json_encode($this->item_info);
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Caches\MaxPageId as MaxPageIdCache;
|
||||
use Phalcon\Mvc\Model\Behavior\SoftDelete;
|
||||
|
||||
class Page extends Model
|
||||
@ -110,11 +109,4 @@ class Page extends Model
|
||||
$this->update_time = time();
|
||||
}
|
||||
|
||||
public function afterCreate()
|
||||
{
|
||||
$cache = new MaxPageIdCache();
|
||||
|
||||
$cache->rebuild();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Caches\MaxPointGiftId as MaxPointGiftIdCache;
|
||||
use Phalcon\Mvc\Model\Behavior\SoftDelete;
|
||||
use Phalcon\Text;
|
||||
|
||||
@ -181,7 +180,7 @@ class PointGift extends Model
|
||||
}
|
||||
}
|
||||
|
||||
if (is_array($this->attrs) || is_object($this->attrs)) {
|
||||
if (is_array($this->attrs)) {
|
||||
$this->attrs = kg_json_encode($this->attrs);
|
||||
}
|
||||
|
||||
@ -190,7 +189,7 @@ class PointGift extends Model
|
||||
|
||||
public function beforeUpdate()
|
||||
{
|
||||
if (is_array($this->attrs) || is_object($this->attrs)) {
|
||||
if (is_array($this->attrs)) {
|
||||
$this->attrs = kg_json_encode($this->attrs);
|
||||
}
|
||||
|
||||
@ -206,13 +205,6 @@ class PointGift extends Model
|
||||
}
|
||||
}
|
||||
|
||||
public function afterCreate()
|
||||
{
|
||||
$cache = new MaxPointGiftIdCache();
|
||||
|
||||
$cache->rebuild();
|
||||
}
|
||||
|
||||
public function afterFetch()
|
||||
{
|
||||
if (!Text::startsWith($this->cover, 'http')) {
|
||||
|
@ -110,7 +110,7 @@ class PointHistory extends Model
|
||||
|
||||
public function beforeSave()
|
||||
{
|
||||
if (is_array($this->event_info) || is_object($this->event_info)) {
|
||||
if (is_array($this->event_info)) {
|
||||
$this->event_info = kg_json_encode($this->event_info);
|
||||
}
|
||||
}
|
||||
|
@ -281,7 +281,7 @@ class Question extends Model
|
||||
$this->cover = self::getCoverPath($this->cover);
|
||||
}
|
||||
|
||||
if (is_array($this->tags) || is_object($this->tags)) {
|
||||
if (is_array($this->tags)) {
|
||||
$this->tags = kg_json_encode($this->tags);
|
||||
}
|
||||
}
|
||||
@ -295,6 +295,9 @@ class Question extends Model
|
||||
|
||||
public function afterFetch()
|
||||
{
|
||||
/**
|
||||
* 问题封面非必要,有则处理,无则略过
|
||||
*/
|
||||
if (!empty($this->cover) && !Text::startsWith($this->cover, 'http')) {
|
||||
$this->cover = kg_cos_article_cover_url($this->cover);
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ class Role extends Model
|
||||
|
||||
public function beforeSave()
|
||||
{
|
||||
if (is_array($this->routes) || is_object($this->routes)) {
|
||||
if (is_array($this->routes)) {
|
||||
$this->routes = kg_json_encode($this->routes);
|
||||
}
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ class Slide extends Model
|
||||
$this->cover = self::getCoverPath($this->cover);
|
||||
}
|
||||
|
||||
if (is_array($this->target_attrs) || is_object($this->target_attrs)) {
|
||||
if (is_array($this->target_attrs)) {
|
||||
$this->target_attrs = kg_json_encode($this->target_attrs);
|
||||
}
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ class Tag extends Model
|
||||
$this->icon = self::getIconPath($this->icon);
|
||||
}
|
||||
|
||||
if (is_array($this->scopes) || is_object($this->scopes)) {
|
||||
if (is_array($this->scopes)) {
|
||||
$this->scopes = kg_json_encode($this->scopes);
|
||||
}
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ class Task extends Model
|
||||
|
||||
public function beforeSave()
|
||||
{
|
||||
if (is_array($this->item_info) || is_object($this->item_info)) {
|
||||
if (is_array($this->item_info)) {
|
||||
$this->item_info = kg_json_encode($this->item_info);
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Caches\MaxUploadId as MaxUploadIdCache;
|
||||
use Phalcon\Mvc\Model\Behavior\SoftDelete;
|
||||
|
||||
class Upload extends Model
|
||||
@ -122,11 +121,4 @@ class Upload extends Model
|
||||
$this->update_time = time();
|
||||
}
|
||||
|
||||
public function afterCreate()
|
||||
{
|
||||
$cache = new MaxUploadIdCache();
|
||||
|
||||
$cache->rebuild();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -95,22 +95,21 @@ class Vip extends Model
|
||||
|
||||
public function beforeCreate()
|
||||
{
|
||||
if (empty($this->cover)) {
|
||||
$this->cover = kg_default_vip_cover_path();
|
||||
} elseif (Text::startsWith($this->cover, 'http')) {
|
||||
$this->cover = self::getCoverPath($this->cover);
|
||||
}
|
||||
|
||||
$this->create_time = time();
|
||||
}
|
||||
|
||||
public function beforeUpdate()
|
||||
{
|
||||
if (Text::startsWith($this->cover, 'http')) {
|
||||
$this->update_time = time();
|
||||
}
|
||||
|
||||
public function beforeSave()
|
||||
{
|
||||
if (empty($this->cover)) {
|
||||
$this->cover = kg_default_vip_cover_path();
|
||||
} elseif (Text::startsWith($this->cover, 'http')) {
|
||||
$this->cover = self::getCoverPath($this->cover);
|
||||
}
|
||||
|
||||
$this->update_time = time();
|
||||
}
|
||||
|
||||
public function afterFetch()
|
||||
|
@ -7,12 +7,11 @@
|
||||
|
||||
namespace App\Services\Logic\Article;
|
||||
|
||||
use App\Caches\Category as CategoryCache;
|
||||
use App\Models\Article as ArticleModel;
|
||||
use App\Models\Category as CategoryModel;
|
||||
use App\Models\User as UserModel;
|
||||
use App\Repos\ArticleFavorite as ArticleFavoriteRepo;
|
||||
use App\Repos\ArticleLike as ArticleLikeRepo;
|
||||
use App\Services\Category as CategoryService;
|
||||
use App\Services\Logic\ArticleTrait;
|
||||
use App\Services\Logic\Service as LogicService;
|
||||
use App\Services\Logic\User\ShallowUserInfo;
|
||||
@ -39,7 +38,7 @@ class ArticleInfo extends LogicService
|
||||
|
||||
protected function handleArticle(ArticleModel $article, UserModel $user)
|
||||
{
|
||||
$category = $this->handleCategoryInfo($article->category_id);
|
||||
$categoryPaths = $this->handleCategoryPaths($article->category_id);
|
||||
$owner = $this->handleOwnerInfo($article->owner_id);
|
||||
$me = $this->handleMeInfo($article, $user);
|
||||
|
||||
@ -63,27 +62,19 @@ class ArticleInfo extends LogicService
|
||||
'favorite_count' => $article->favorite_count,
|
||||
'create_time' => $article->create_time,
|
||||
'update_time' => $article->update_time,
|
||||
'category' => $category,
|
||||
'category_paths' => $categoryPaths,
|
||||
'owner' => $owner,
|
||||
'me' => $me,
|
||||
];
|
||||
}
|
||||
|
||||
protected function handleCategoryInfo($categoryId)
|
||||
protected function handleCategoryPaths($categoryId)
|
||||
{
|
||||
$cache = new CategoryCache();
|
||||
if ($categoryId == 0) return null;
|
||||
|
||||
/**
|
||||
* @var CategoryModel $category
|
||||
*/
|
||||
$category = $cache->get($categoryId);
|
||||
$service = new CategoryService();
|
||||
|
||||
if (!$category) return new \stdClass();
|
||||
|
||||
return [
|
||||
'id' => $category->id,
|
||||
'name' => $category->name,
|
||||
];
|
||||
return $service->getCategoryPaths($categoryId);
|
||||
}
|
||||
|
||||
protected function handleOwnerInfo($userId)
|
||||
|
@ -31,8 +31,9 @@ class ChapterInfo extends LogicService
|
||||
protected $user;
|
||||
|
||||
use CourseTrait;
|
||||
use CourseUserTrait;
|
||||
use ChapterTrait;
|
||||
use CourseUserTrait;
|
||||
use ChapterUserTrait;
|
||||
|
||||
public function handle($id)
|
||||
{
|
||||
|
57
app/Services/Logic/Chapter/ChapterUserTrait.php
Normal file
57
app/Services/Logic/Chapter/ChapterUserTrait.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Services\Logic\Chapter;
|
||||
|
||||
use App\Models\Chapter as ChapterModel;
|
||||
use App\Models\ChapterUser as ChapterUserModel;
|
||||
use App\Models\User as UserModel;
|
||||
use App\Repos\ChapterUser as ChapterUserRepo;
|
||||
|
||||
trait ChapterUserTrait
|
||||
{
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $ownedChapter = false;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $joinedChapter = false;
|
||||
|
||||
/**
|
||||
* @var ChapterUserModel|null
|
||||
*/
|
||||
protected $chapterUser;
|
||||
|
||||
public function setChapterUser(ChapterModel $chapter, UserModel $user)
|
||||
{
|
||||
if ($user->id == 0) return;
|
||||
|
||||
$chapterUser = null;
|
||||
|
||||
$courseUser = $this->courseUser;
|
||||
|
||||
if ($courseUser) {
|
||||
$chapterUserRepo = new ChapterUserRepo();
|
||||
$chapterUser = $chapterUserRepo->findChapterUser($chapter->id, $user->id);
|
||||
}
|
||||
|
||||
$this->chapterUser = $chapterUser;
|
||||
|
||||
if ($chapterUser) {
|
||||
$this->joinedChapter = true;
|
||||
}
|
||||
|
||||
if ($this->ownedCourse || $chapter->free) {
|
||||
$this->ownedChapter = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -7,31 +7,11 @@
|
||||
|
||||
namespace App\Services\Logic;
|
||||
|
||||
use App\Models\Chapter as ChapterModel;
|
||||
use App\Models\ChapterUser as ChapterUserModel;
|
||||
use App\Models\CourseUser as CourseUserModel;
|
||||
use App\Models\User as UserModel;
|
||||
use App\Repos\ChapterUser as ChapterUserRepo;
|
||||
use App\Validators\Chapter as ChapterValidator;
|
||||
|
||||
trait ChapterTrait
|
||||
{
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $ownedChapter = false;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $joinedChapter = false;
|
||||
|
||||
/**
|
||||
* @var ChapterUserModel|null
|
||||
*/
|
||||
protected $chapterUser;
|
||||
|
||||
public function checkChapterVod($id)
|
||||
{
|
||||
$validator = new ChapterValidator();
|
||||
@ -67,31 +47,4 @@ trait ChapterTrait
|
||||
return $validator->checkChapterCache($id);
|
||||
}
|
||||
|
||||
public function setChapterUser(ChapterModel $chapter, UserModel $user)
|
||||
{
|
||||
if ($user->id == 0) return;
|
||||
|
||||
$chapterUser = null;
|
||||
|
||||
/**
|
||||
* @var CourseUserModel $courseUser
|
||||
*/
|
||||
$courseUser = $this->courseUser;
|
||||
|
||||
if ($courseUser) {
|
||||
$chapterUserRepo = new ChapterUserRepo();
|
||||
$chapterUser = $chapterUserRepo->findChapterUser($chapter->id, $user->id);
|
||||
}
|
||||
|
||||
$this->chapterUser = $chapterUser;
|
||||
|
||||
if ($chapterUser) {
|
||||
$this->joinedChapter = true;
|
||||
}
|
||||
|
||||
if ($this->ownedCourse || $chapter->free) {
|
||||
$this->ownedChapter = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ class CommentInfo extends LogicService
|
||||
|
||||
protected function handleToUserInfo($userId)
|
||||
{
|
||||
if ($userId == 0) return new \stdClass();
|
||||
if ($userId == 0) return null;
|
||||
|
||||
$service = new ShallowUserInfo();
|
||||
|
||||
|
@ -23,6 +23,7 @@ class ConsultCreate extends LogicService
|
||||
|
||||
use ClientTrait;
|
||||
use CourseTrait;
|
||||
use ConsultDataTrait;
|
||||
|
||||
public function handle()
|
||||
{
|
||||
@ -34,10 +35,6 @@ class ConsultCreate extends LogicService
|
||||
|
||||
$validator->checkDailyConsultLimit($user);
|
||||
|
||||
$validator = new UserLimitValidator();
|
||||
|
||||
$validator->checkDailyConsultLimit($user);
|
||||
|
||||
$course = $this->checkCourse($courseId);
|
||||
|
||||
return $this->handleCourseConsult($course, $user);
|
||||
@ -47,32 +44,20 @@ class ConsultCreate extends LogicService
|
||||
{
|
||||
$post = $this->request->getPost();
|
||||
|
||||
$data = $this->handlePostData($post);
|
||||
|
||||
$validator = new ConsultValidator();
|
||||
|
||||
$question = $validator->checkQuestion($post['question']);
|
||||
|
||||
$private = 0;
|
||||
|
||||
if (isset($post['private'])) {
|
||||
$private = $validator->checkPrivateStatus($post['private']);
|
||||
}
|
||||
|
||||
$validator->checkIfDuplicated($course->id, $user->id, $question);
|
||||
|
||||
$priority = $this->getPriority($course, $user);
|
||||
$validator->checkIfDuplicated($course->id, $user->id, $data['question']);
|
||||
|
||||
$consult = new ConsultModel();
|
||||
|
||||
$consult->question = $question;
|
||||
$consult->private = $private;
|
||||
$consult->priority = $priority;
|
||||
$consult->course_id = $course->id;
|
||||
$consult->owner_id = $user->id;
|
||||
$consult->client_type = $this->getClientType();
|
||||
$consult->client_ip = $this->getClientIp();
|
||||
$consult->published = ConsultModel::PUBLISH_PENDING;
|
||||
$data['priority'] = $this->getPriority($course, $user);
|
||||
$data['published'] = ConsultModel::PUBLISH_PENDING;
|
||||
$data['course_id'] = $course->id;
|
||||
$data['owner_id'] = $user->id;
|
||||
|
||||
$consult->create();
|
||||
$consult->create($data);
|
||||
|
||||
$this->recountCourseConsults($course);
|
||||
$this->incrUserDailyConsultCount($user);
|
||||
|
38
app/Services/Logic/Consult/ConsultDataTrait.php
Normal file
38
app/Services/Logic/Consult/ConsultDataTrait.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Services\Logic\Consult;
|
||||
|
||||
use App\Traits\Client as ClientTrait;
|
||||
use App\Validators\Consult as ConsultValidator;
|
||||
|
||||
trait ConsultDataTrait
|
||||
{
|
||||
|
||||
use ClientTrait;
|
||||
|
||||
protected function handlePostData($post)
|
||||
{
|
||||
$data = [];
|
||||
|
||||
$data['client_type'] = $this->getClientType();
|
||||
$data['client_ip'] = $this->getClientIp();
|
||||
|
||||
$validator = new ConsultValidator();
|
||||
|
||||
if (isset($post['question'])) {
|
||||
$data['question'] = $validator->checkQuestion($post['question']);
|
||||
}
|
||||
|
||||
if (isset($post['private'])) {
|
||||
$data['private'] = $validator->checkPrivateStatus($post['private']);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
@ -76,7 +76,7 @@ class ConsultInfo extends LogicService
|
||||
|
||||
protected function handleReplierInfo($userId)
|
||||
{
|
||||
if ($userId == 0) return new \stdClass();
|
||||
if ($userId == 0) return null;
|
||||
|
||||
$service = new ShallowUserInfo();
|
||||
|
||||
|
@ -15,6 +15,7 @@ class ConsultUpdate extends LogicService
|
||||
{
|
||||
|
||||
use ConsultTrait;
|
||||
use ConsultDataTrait;
|
||||
|
||||
public function handle($id)
|
||||
{
|
||||
@ -28,15 +29,7 @@ class ConsultUpdate extends LogicService
|
||||
|
||||
$validator->checkEditPriv($consult, $user);
|
||||
|
||||
$data = [];
|
||||
|
||||
if (isset($post['question'])) {
|
||||
$data['question'] = $validator->checkQuestion($post['question']);
|
||||
}
|
||||
|
||||
if (isset($post['private'])) {
|
||||
$data['private'] = $validator->checkPrivateStatus($post['private']);
|
||||
}
|
||||
$data = $this->handlePostData($post);
|
||||
|
||||
$consult->update($data);
|
||||
|
||||
|
29
app/Services/Logic/ContentTrait.php
Normal file
29
app/Services/Logic/ContentTrait.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Services\Logic;
|
||||
|
||||
trait ContentTrait
|
||||
{
|
||||
|
||||
public function handleContent($content)
|
||||
{
|
||||
return $this->handleCosImageStyle($content);
|
||||
}
|
||||
|
||||
protected function handleCosImageStyle($content)
|
||||
{
|
||||
$style = '!content_800';
|
||||
|
||||
$pattern = '/src="(.*?)\/img\/content\/(.*?)"/';
|
||||
|
||||
$replacement = 'src="$1/img/content/$2' . $style . '"';
|
||||
|
||||
return preg_replace($pattern, $replacement, $content);
|
||||
}
|
||||
|
||||
}
|
@ -79,7 +79,7 @@ class BasicInfo extends LogicService
|
||||
|
||||
protected function handleCategoryPaths($categoryId)
|
||||
{
|
||||
if ($categoryId == 0) return new \stdClass();
|
||||
if ($categoryId == 0) return null;
|
||||
|
||||
$service = new CategoryService();
|
||||
|
||||
@ -88,7 +88,7 @@ class BasicInfo extends LogicService
|
||||
|
||||
protected function handleTeacherInfo($userId)
|
||||
{
|
||||
if ($userId == 0) return new \stdClass();
|
||||
if ($userId == 0) return null;
|
||||
|
||||
$service = new ShallowUserInfoService();
|
||||
|
||||
|
@ -50,14 +50,14 @@ class ChapterList extends LogicService
|
||||
|
||||
protected function handleLoginUserChapters(array $chapters, CourseModel $course, UserModel $user)
|
||||
{
|
||||
$mapping = $this->getLearningMapping($course->id, $user->id, $this->courseUser->plan_id);
|
||||
$mappings = $this->getLearningMappings($course->id, $user->id, $this->courseUser->plan_id);
|
||||
|
||||
foreach ($chapters as &$chapter) {
|
||||
foreach ($chapter['children'] as &$lesson) {
|
||||
$owned = ($this->ownedCourse || $lesson['free'] == 1) && $lesson['published'] == 1;
|
||||
$lesson['me'] = [
|
||||
'progress' => $mapping[$lesson['id']]['progress'] ?? 0,
|
||||
'duration' => $mapping[$lesson['id']]['duration'] ?? 0,
|
||||
'progress' => $mappings[$lesson['id']]['progress'] ?? 0,
|
||||
'duration' => $mappings[$lesson['id']]['duration'] ?? 0,
|
||||
'owned' => $owned ? 1 : 0,
|
||||
'logged' => 1,
|
||||
];
|
||||
@ -84,7 +84,7 @@ class ChapterList extends LogicService
|
||||
return $chapters;
|
||||
}
|
||||
|
||||
protected function getLearningMapping($courseId, $userId, $planId)
|
||||
protected function getLearningMappings($courseId, $userId, $planId)
|
||||
{
|
||||
$courseRepo = new CourseRepo();
|
||||
|
||||
@ -92,17 +92,17 @@ class ChapterList extends LogicService
|
||||
|
||||
if ($userLearnings->count() == 0) return [];
|
||||
|
||||
$mapping = [];
|
||||
$mappings = [];
|
||||
|
||||
foreach ($userLearnings as $learning) {
|
||||
$mapping[$learning->chapter_id] = [
|
||||
$mappings[$learning->chapter_id] = [
|
||||
'progress' => $learning->progress,
|
||||
'duration' => $learning->duration,
|
||||
'consumed' => $learning->consumed,
|
||||
];
|
||||
}
|
||||
|
||||
return $mapping;
|
||||
return $mappings;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,7 +7,9 @@
|
||||
|
||||
namespace App\Services\Logic\Help;
|
||||
|
||||
use App\Caches\HelpList as HelpListCache;
|
||||
use App\Caches\CategoryList as CategoryListCache;
|
||||
use App\Models\Category as CategoryModel;
|
||||
use App\Repos\Help as HelpRepo;
|
||||
use App\Services\Logic\Service as LogicService;
|
||||
|
||||
class HelpList extends LogicService
|
||||
@ -15,9 +17,43 @@ class HelpList extends LogicService
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$cache = new HelpListCache();
|
||||
$cache = new CategoryListCache();
|
||||
|
||||
return $cache->get();
|
||||
$categories = $cache->get(CategoryModel::TYPE_HELP);
|
||||
|
||||
$helpRepo = new HelpRepo();
|
||||
|
||||
$helps = $helpRepo->findAll([
|
||||
'published' => 1,
|
||||
'deleted' => 0,
|
||||
]);
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($categories as $category) {
|
||||
|
||||
$item = [];
|
||||
|
||||
$item['category'] = [
|
||||
'id' => $category['id'],
|
||||
'name' => $category['name'],
|
||||
];
|
||||
|
||||
$item['helps'] = [];
|
||||
|
||||
if ($helps->count() > 0) {
|
||||
foreach ($helps as $help) {
|
||||
$item['helps'][] = [
|
||||
'id' => $help->id,
|
||||
'title' => $help->title,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$result[] = $item;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,11 +19,4 @@ trait HelpTrait
|
||||
return $validator->checkHelp($id);
|
||||
}
|
||||
|
||||
public function checkHelpCache($id)
|
||||
{
|
||||
$validator = new HelpValidator();
|
||||
|
||||
return $validator->checkHelpCache($id);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -82,12 +82,7 @@ class ConsultReply extends LogicService
|
||||
|
||||
$task = new TaskModel();
|
||||
|
||||
$itemInfo = [
|
||||
'consult' => ['id' => $consult->id],
|
||||
];
|
||||
|
||||
$task->item_id = $consult->id;
|
||||
$task->item_info = $itemInfo;
|
||||
$task->item_type = TaskModel::TYPE_NOTICE_CONSULT_REPLY;
|
||||
$task->priority = TaskModel::PRIORITY_LOW;
|
||||
$task->status = TaskModel::STATUS_PENDING;
|
||||
|
@ -58,12 +58,7 @@ class ConsultCreate extends DingTalkNotice
|
||||
|
||||
$task = new TaskModel();
|
||||
|
||||
$itemInfo = [
|
||||
'consult' => ['id' => $consult->id],
|
||||
];
|
||||
|
||||
$task->item_id = $consult->id;
|
||||
$task->item_info = $itemInfo;
|
||||
$task->item_type = TaskModel::TYPE_STAFF_NOTICE_CONSULT_CREATE;
|
||||
$task->priority = TaskModel::PRIORITY_LOW;
|
||||
$task->status = TaskModel::STATUS_PENDING;
|
||||
@ -71,4 +66,4 @@ class ConsultCreate extends DingTalkNotice
|
||||
$task->create();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -40,12 +40,7 @@ class PointGiftRedeem extends DingTalkNotice
|
||||
|
||||
$task = new TaskModel();
|
||||
|
||||
$itemInfo = [
|
||||
'point_gift_redeem' => ['id' => $redeem->id],
|
||||
];
|
||||
|
||||
$task->item_id = $redeem->id;
|
||||
$task->item_info = $itemInfo;
|
||||
$task->item_type = TaskModel::TYPE_STAFF_NOTICE_POINT_GIFT_REDEEM;
|
||||
$task->priority = TaskModel::PRIORITY_MIDDLE;
|
||||
$task->status = TaskModel::STATUS_PENDING;
|
||||
@ -53,4 +48,4 @@ class PointGiftRedeem extends DingTalkNotice
|
||||
$task->create();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -42,12 +42,7 @@ class TeacherLive extends DingTalkNotice
|
||||
|
||||
$task = new TaskModel();
|
||||
|
||||
$itemInfo = [
|
||||
'live' => ['id' => $live->id],
|
||||
];
|
||||
|
||||
$task->item_id = $live->id;
|
||||
$task->item_info = $itemInfo;
|
||||
$task->item_type = TaskModel::TYPE_STAFF_NOTICE_TEACHER_LIVE;
|
||||
$task->priority = TaskModel::PRIORITY_LOW;
|
||||
$task->status = TaskModel::STATUS_PENDING;
|
||||
@ -55,4 +50,4 @@ class TeacherLive extends DingTalkNotice
|
||||
$task->create();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ class LiveBegin extends LogicService
|
||||
$smsNoticeEnabled = $this->smsNoticeEnabled();
|
||||
|
||||
$courseUser = $task->item_info['course_user'];
|
||||
$chapterId = $task->item_info['chapter']['id'];
|
||||
$chapterId = $task->item_id;
|
||||
|
||||
$courseRepo = new CourseRepo();
|
||||
|
||||
@ -84,9 +84,6 @@ class LiveBegin extends LogicService
|
||||
'course_id' => $courseUser->course_id,
|
||||
'user_id' => $courseUser->user_id,
|
||||
],
|
||||
'chapter' => [
|
||||
'id' => $chapter->id,
|
||||
],
|
||||
];
|
||||
|
||||
$task->item_id = $chapter->id;
|
||||
|
@ -67,12 +67,7 @@ class OrderFinish extends LogicService
|
||||
|
||||
$task = new TaskModel();
|
||||
|
||||
$itemInfo = [
|
||||
'order' => ['id' => $order->id],
|
||||
];
|
||||
|
||||
$task->item_id = $order->id;
|
||||
$task->item_info = $itemInfo;
|
||||
$task->item_type = TaskModel::TYPE_NOTICE_ORDER_FINISH;
|
||||
$task->priority = TaskModel::PRIORITY_HIGH;
|
||||
$task->status = TaskModel::STATUS_PENDING;
|
||||
|
@ -63,12 +63,7 @@ class PointGoodsDeliver extends LogicService
|
||||
|
||||
$task = new TaskModel();
|
||||
|
||||
$itemInfo = [
|
||||
'redeem' => ['id' => $redeem->id],
|
||||
];
|
||||
|
||||
$task->item_id = $redeem->id;
|
||||
$task->item_info = $itemInfo;
|
||||
$task->item_type = TaskModel::TYPE_NOTICE_POINT_GOODS_DELIVER;
|
||||
$task->priority = TaskModel::PRIORITY_MIDDLE;
|
||||
$task->status = TaskModel::STATUS_PENDING;
|
||||
|
@ -67,12 +67,7 @@ class RefundFinish extends LogicService
|
||||
|
||||
$task = new TaskModel();
|
||||
|
||||
$itemInfo = [
|
||||
'refund' => ['id' => $refund->id],
|
||||
];
|
||||
|
||||
$task->item_id = $refund->id;
|
||||
$task->item_info = $itemInfo;
|
||||
$task->item_type = TaskModel::TYPE_NOTICE_REFUND_FINISH;
|
||||
$task->priority = TaskModel::PRIORITY_MIDDLE;
|
||||
$task->status = TaskModel::STATUS_PENDING;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user