diff --git a/app/Builders/ConsultList.php b/app/Builders/ConsultList.php
index a2feda41..c74407bd 100644
--- a/app/Builders/ConsultList.php
+++ b/app/Builders/ConsultList.php
@@ -25,7 +25,7 @@ class ConsultList extends Builder
$users = $this->getUsers($consults);
foreach ($consults as $key => $consult) {
- $consults[$key]['user'] = $users[$consult['user_id']] ?? new \stdClass();
+ $consults[$key]['owner'] = $users[$consult['owner_id']] ?? new \stdClass();
}
return $consults;
@@ -67,7 +67,7 @@ class ConsultList extends Builder
public function getUsers(array $consults)
{
- $ids = kg_array_column($consults, 'user_id');
+ $ids = kg_array_column($consults, 'owner_id');
$userRepo = new UserRepo();
diff --git a/app/Builders/ChapterTreeList.php b/app/Builders/CourseCatalog.php
similarity index 98%
rename from app/Builders/ChapterTreeList.php
rename to app/Builders/CourseCatalog.php
index 34da6b6a..5415dae2 100644
--- a/app/Builders/ChapterTreeList.php
+++ b/app/Builders/CourseCatalog.php
@@ -7,7 +7,7 @@ use App\Models\Course as CourseModel;
use Phalcon\Mvc\Model\Resultset;
use Phalcon\Mvc\Model\ResultsetInterface;
-class ChapterTreeList extends Builder
+class CourseCatalog extends Builder
{
/**
diff --git a/app/Builders/DanmuList.php b/app/Builders/DanmuList.php
index 270514b4..0886ed9c 100644
--- a/app/Builders/DanmuList.php
+++ b/app/Builders/DanmuList.php
@@ -36,7 +36,7 @@ class DanmuList extends Builder
$users = $this->getUsers($danmus);
foreach ($danmus as $key => $danmu) {
- $danmus[$key]['user'] = $users[$danmu['user_id']] ?? new \stdClass();
+ $danmus[$key]['owner'] = $users[$danmu['owner_id']] ?? new \stdClass();
}
return $danmus;
@@ -78,7 +78,7 @@ class DanmuList extends Builder
public function getUsers(array $danmus)
{
- $ids = kg_array_column($danmus, 'user_id');
+ $ids = kg_array_column($danmus, 'owner_id');
$userRepo = new UserRepo();
diff --git a/app/Builders/ImGroupList.php b/app/Builders/ImGroupList.php
new file mode 100644
index 00000000..7f779425
--- /dev/null
+++ b/app/Builders/ImGroupList.php
@@ -0,0 +1,70 @@
+getCourses($groups);
+
+ foreach ($groups as $key => $group) {
+ $groups[$key]['course'] = $courses[$group['course_id']] ?? new \stdClass();
+ }
+
+ return $groups;
+ }
+
+ public function handleUsers(array $groups)
+ {
+ $users = $this->getUsers($groups);
+
+ foreach ($groups as $key => $group) {
+ $groups[$key]['owner'] = $users[$group['owner_id']] ?? new \stdClass();
+ }
+
+ return $groups;
+ }
+
+ public function getCourses(array $groups)
+ {
+ $ids = kg_array_column($groups, 'course_id');
+
+ $courseRepo = new CourseRepo();
+
+ $courses = $courseRepo->findByIds($ids, ['id', 'title']);
+
+ $result = [];
+
+ foreach ($courses->toArray() as $course) {
+ $result[$course['id']] = $course;
+ }
+
+ return $result;
+ }
+
+ public function getUsers(array $groups)
+ {
+ $ids = kg_array_column($groups, 'owner_id');
+
+ $userRepo = new UserRepo();
+
+ $users = $userRepo->findByIds($ids, ['id', 'name', 'avatar']);
+
+ $baseUrl = kg_ci_base_url();
+
+ $result = [];
+
+ foreach ($users->toArray() as $user) {
+ $user['avatar'] = $baseUrl . $user['avatar'];
+ $result[$user['id']] = $user;
+ }
+
+ return $result;
+ }
+
+}
diff --git a/app/Builders/ReviewList.php b/app/Builders/ReviewList.php
index 322a69ac..a78a1f65 100644
--- a/app/Builders/ReviewList.php
+++ b/app/Builders/ReviewList.php
@@ -24,7 +24,7 @@ class ReviewList extends Builder
$users = $this->getUsers($reviews);
foreach ($reviews as $key => $review) {
- $reviews[$key]['user'] = $users[$review['user_id']] ?? new \stdClass();
+ $reviews[$key]['owner'] = $users[$review['owner_id']] ?? new \stdClass();
}
return $reviews;
@@ -49,7 +49,7 @@ class ReviewList extends Builder
public function getUsers(array $reviews)
{
- $ids = kg_array_column($reviews, 'user_id');
+ $ids = kg_array_column($reviews, 'owner_id');
$userRepo = new UserRepo();
diff --git a/app/Caches/CourseChapterList.php b/app/Caches/CourseCatalog.php
similarity index 63%
rename from app/Caches/CourseChapterList.php
rename to app/Caches/CourseCatalog.php
index 62b12f4c..687a50ab 100644
--- a/app/Caches/CourseChapterList.php
+++ b/app/Caches/CourseCatalog.php
@@ -2,9 +2,9 @@
namespace App\Caches;
-use App\Builders\ChapterTreeList as ChapterTreeListBuilder;
+use App\Builders\CourseCatalog as CourseCatalogBuilder;
-class CourseChapterList extends Cache
+class CourseCatalog extends Cache
{
protected $lifetime = 7 * 86400;
@@ -16,12 +16,12 @@ class CourseChapterList extends Cache
public function getKey($id = null)
{
- return "course_chapter_list:{$id}";
+ return "course_catalog:{$id}";
}
public function getContent($id = null)
{
- $builder = new ChapterTreeListBuilder();
+ $builder = new CourseCatalogBuilder();
$list = $builder->handle($id);
diff --git a/app/Caches/UserDailyCounter.php b/app/Caches/UserDailyCounter.php
index cbe76277..3382ace4 100644
--- a/app/Caches/UserDailyCounter.php
+++ b/app/Caches/UserDailyCounter.php
@@ -22,7 +22,6 @@ class UserDailyCounter extends Counter
public function getContent($id = null)
{
return [
- 'favorite_count' => 0,
'danmu_count' => 0,
'consult_count' => 0,
'order_count' => 0,
diff --git a/app/Http/Admin/Controllers/GroupController.php b/app/Http/Admin/Controllers/GroupController.php
new file mode 100644
index 00000000..4ce56787
--- /dev/null
+++ b/app/Http/Admin/Controllers/GroupController.php
@@ -0,0 +1,132 @@
+getGroups();
+
+ $this->view->setVar('pager', $pager);
+ }
+
+ /**
+ * @Get("/search", name="admin.group.search")
+ */
+ public function searchAction()
+ {
+
+ }
+
+ /**
+ * @Get("/add", name="admin.group.add")
+ */
+ public function addAction()
+ {
+
+ }
+
+ /**
+ * @Post("/create", name="admin.group.create")
+ */
+ public function createAction()
+ {
+ $groupService = new ImGroupService();
+
+ $group = $groupService->createGroup();
+
+ $location = $this->url->get([
+ 'for' => 'admin.group.edit',
+ 'id' => $group->id,
+ ]);
+
+ $content = [
+ 'location' => $location,
+ 'msg' => '创建群组成功',
+ ];
+
+ return $this->jsonSuccess($content);
+ }
+
+ /**
+ * @Get("/{id:[0-9]+}/edit", name="admin.group.edit")
+ */
+ public function editAction($id)
+ {
+ $groupService = new ImGroupService();
+
+ $group = $groupService->getGroup($id);
+
+ $this->view->setVar('group', $group);
+ }
+
+ /**
+ * @Post("/{id:[0-9]+}/update", name="admin.group.update")
+ */
+ public function updateAction($id)
+ {
+ $groupService = new ImGroupService();
+
+ $groupService->updateGroup($id);
+
+ $location = $this->url->get(['for' => 'admin.group.list']);
+
+ $content = [
+ 'location' => $location,
+ 'msg' => '更新群组成功',
+ ];
+
+ return $this->jsonSuccess($content);
+ }
+
+ /**
+ * @Post("/{id:[0-9]+}/delete", name="admin.group.delete")
+ */
+ public function deleteAction($id)
+ {
+ $groupService = new ImGroupService();
+
+ $groupService->deleteGroup($id);
+
+ $location = $this->request->getHTTPReferer();
+
+ $content = [
+ 'location' => $location,
+ 'msg' => '删除群组成功',
+ ];
+
+ return $this->jsonSuccess($content);
+ }
+
+ /**
+ * @Post("/{id:[0-9]+}/restore", name="admin.group.restore")
+ */
+ public function restoreAction($id)
+ {
+ $groupService = new ImGroupService();
+
+ $groupService->restoreGroup($id);
+
+ $location = $this->request->getHTTPReferer();
+
+ $content = [
+ 'location' => $location,
+ 'msg' => '还原群组成功',
+ ];
+
+ return $this->jsonSuccess($content);
+ }
+
+}
diff --git a/app/Http/Admin/Services/AuthNode.php b/app/Http/Admin/Services/AuthNode.php
index 077ef889..a4693f5e 100644
--- a/app/Http/Admin/Services/AuthNode.php
+++ b/app/Http/Admin/Services/AuthNode.php
@@ -325,6 +325,43 @@ class AuthNode extends Service
],
],
],
+ [
+ 'id' => '2-4',
+ 'title' => '群组管理',
+ 'type' => 'menu',
+ 'children' => [
+ [
+ 'id' => '2-4-1',
+ 'title' => '群组列表',
+ 'type' => 'menu',
+ 'route' => 'admin.group.list',
+ ],
+ [
+ 'id' => '2-4-2',
+ 'title' => '搜索群组',
+ 'type' => 'menu',
+ 'route' => 'admin.group.search',
+ ],
+ [
+ 'id' => '2-4-3',
+ 'title' => '添加群组',
+ 'type' => 'menu',
+ 'route' => 'admin.group.add',
+ ],
+ [
+ 'id' => '2-4-4',
+ 'title' => '编辑群组',
+ 'type' => 'button',
+ 'route' => 'admin.group.edit',
+ ],
+ [
+ 'id' => '2-4-5',
+ 'title' => '删除群组',
+ 'type' => 'button',
+ 'route' => 'admin.group.delete',
+ ],
+ ],
+ ],
[
'id' => '2-5',
'title' => '轮播管理',
diff --git a/app/Http/Admin/Services/Chapter.php b/app/Http/Admin/Services/Chapter.php
index a4b1e4ab..9a730d62 100644
--- a/app/Http/Admin/Services/Chapter.php
+++ b/app/Http/Admin/Services/Chapter.php
@@ -3,7 +3,7 @@
namespace App\Http\Admin\Services;
use App\Caches\Chapter as ChapterCache;
-use App\Caches\CourseChapterList as CourseChapterListCache;
+use App\Caches\CourseCatalog as CourseCatalogCache;
use App\Models\Chapter as ChapterModel;
use App\Models\ChapterLive as ChapterLiveModel;
use App\Models\ChapterRead as ChapterReadModel;
@@ -166,6 +166,8 @@ class Chapter extends Service
$this->updateCourseStats($chapter);
+ $this->rebuildCatalogCache($chapter);
+
return $chapter;
}
@@ -185,6 +187,8 @@ class Chapter extends Service
$this->updateCourseStats($chapter);
+ $this->rebuildCatalogCache($chapter);
+
return $chapter;
}
@@ -200,6 +204,8 @@ class Chapter extends Service
$this->updateCourseStats($chapter);
+ $this->rebuildCatalogCache($chapter);
+
return $chapter;
}
@@ -240,8 +246,11 @@ class Chapter extends Service
$cache = new ChapterCache();
$cache->rebuild($chapter->id);
+ }
- $cache = new CourseChapterListCache();
+ protected function rebuildCatalogCache(ChapterModel $chapter)
+ {
+ $cache = new CourseCatalogCache();
$cache->rebuild($chapter->course_id);
}
diff --git a/app/Http/Admin/Services/Consult.php b/app/Http/Admin/Services/Consult.php
index e668f61e..8625cf86 100644
--- a/app/Http/Admin/Services/Consult.php
+++ b/app/Http/Admin/Services/Consult.php
@@ -52,11 +52,11 @@ class Consult extends Service
$data = [];
- if (isset($post['question'])) {
+ if (!empty($post['question'])) {
$data['question'] = $validator->checkQuestion($post['question']);
}
- if (isset($post['answer'])) {
+ if (!empty($post['answer'])) {
$data['answer'] = $validator->checkAnswer($post['answer']);
}
diff --git a/app/Http/Admin/Services/Course.php b/app/Http/Admin/Services/Course.php
index 3f064898..04ea4b02 100644
--- a/app/Http/Admin/Services/Course.php
+++ b/app/Http/Admin/Services/Course.php
@@ -96,6 +96,7 @@ class Course extends Service
$imGroup->course_id = $course->id;
$imGroup->name = $course->title;
$imGroup->about = $course->summary;
+ $imGroup->published = 1;
if ($imGroup->create() === false) {
throw new \RuntimeException('Create ImGroup Failed');
diff --git a/app/Http/Admin/Services/ImGroup.php b/app/Http/Admin/Services/ImGroup.php
new file mode 100644
index 00000000..a24cd560
--- /dev/null
+++ b/app/Http/Admin/Services/ImGroup.php
@@ -0,0 +1,159 @@
+getParams();
+
+ $params['deleted'] = $params['deleted'] ?? 0;
+
+ $sort = $pagerQuery->getSort();
+ $page = $pagerQuery->getPage();
+ $limit = $pagerQuery->getLimit();
+
+ $groupRepo = new ImGroupRepo();
+
+ $pager = $groupRepo->paginate($params, $sort, $page, $limit);
+
+ return $this->handleGroups($pager);
+ }
+
+ public function getGroup($id)
+ {
+ return $this->findOrFail($id);
+ }
+
+ public function createGroup()
+ {
+ $post = $this->request->getPost();
+
+ $validator = new ImGroupValidator();
+
+ $data = [];
+
+ $data['name'] = $validator->checkName($post['name']);
+ $data['about'] = $validator->checkAbout($post['about']);
+ $data['type'] = $validator->checkType($post['type']);
+
+ $group = new ImGroupModel();
+
+ $group->create($data);
+
+ return $group;
+ }
+
+ public function updateGroup($id)
+ {
+ $group = $this->findOrFail($id);
+
+ $post = $this->request->getPost();
+
+ $validator = new ImGroupValidator();
+
+ $data = [];
+
+ if (isset($post['name'])) {
+ $data['name'] = $validator->checkName($post['name']);
+ }
+
+ if (isset($post['about'])) {
+ $data['about'] = $validator->checkAbout($post['about']);
+ }
+
+ if (isset($post['avatar'])) {
+ $data['avatar'] = $validator->checkAvatar($post['avatar']);
+ }
+
+ if (isset($post['published'])) {
+ $data['published'] = $validator->checkPublishStatus($post['published']);
+ }
+
+ if (isset($post['owner_id'])) {
+ $owner = $validator->checkGroupOwner($post['owner_id']);
+ $data['owner_id'] = $owner->id;
+ $this->handleGroupOwner($group, $owner);
+ }
+
+ $group->update($data);
+
+ return $group;
+ }
+
+ public function deleteGroup($id)
+ {
+ $group = $this->findOrFail($id);
+
+ $group->deleted = 1;
+
+ $group->update();
+
+ return $group;
+ }
+
+ public function restoreGroup($id)
+ {
+ $group = $this->findOrFail($id);
+
+ $group->deleted = 0;
+
+ $group->update();
+
+ return $group;
+ }
+
+ protected function handleGroupOwner(ImGroupModel $group, UserModel $user)
+ {
+ $repo = new ImGroupUserRepo();
+
+ $groupUser = $repo->findGroupUser($group->id, $user->id);
+
+ if ($groupUser) return;
+
+ $groupUser = new ImGroupUserModel();
+ $groupUser->group_id = $group->id;
+ $groupUser->user_id = $user->id;
+ $groupUser->create();
+
+ $group->user_count += 1;
+ $group->update();
+ }
+
+ protected function handleGroups($pager)
+ {
+ if ($pager->total_items > 0) {
+
+ $builder = new ImGroupListBuilder();
+
+ $pipeA = $pager->items->toArray();
+ $pipeB = $builder->handleUsers($pipeA);
+ $pipeC = $builder->objects($pipeB);
+
+ $pager->items = $pipeC;
+ }
+
+ return $pager;
+ }
+
+ protected function findOrFail($id)
+ {
+ $validator = new ImGroupValidator();
+
+ return $validator->checkGroup($id);
+ }
+
+}
diff --git a/app/Http/Admin/Views/category/list.volt b/app/Http/Admin/Views/category/list.volt
index 5a0f06c3..48f66a7b 100644
--- a/app/Http/Admin/Views/category/list.volt
+++ b/app/Http/Admin/Views/category/list.volt
@@ -52,7 +52,7 @@
{{ item.level }}
{{ item.child_count }}
{{ item.course_count }}
-
+
diff --git a/app/Http/Admin/Views/chapter/edit_lesson_basic.volt b/app/Http/Admin/Views/chapter/edit_lesson_basic.volt
index 8819d6e1..a8ccd8d3 100644
--- a/app/Http/Admin/Views/chapter/edit_lesson_basic.volt
+++ b/app/Http/Admin/Views/chapter/edit_lesson_basic.volt
@@ -24,8 +24,8 @@
diff --git a/app/Http/Admin/Views/chapter/edit_lesson_vod.volt b/app/Http/Admin/Views/chapter/edit_lesson_vod.volt
index cc5f07e7..3ffdbb1c 100644
--- a/app/Http/Admin/Views/chapter/edit_lesson_vod.volt
+++ b/app/Http/Admin/Views/chapter/edit_lesson_vod.volt
@@ -14,7 +14,7 @@
{% for item in play_urls %}
{{ item.format }}
- {{ item.duration|play_duration }}
+ {{ item.duration|duration }}
{{ item.width }} x {{ item.height }}
{{ item.rate }}kbps
{{ item.size }}M
diff --git a/app/Http/Admin/Views/chapter/lessons_live.volt b/app/Http/Admin/Views/chapter/lessons_live.volt
index 9db97dff..029ed8ed 100644
--- a/app/Http/Admin/Views/chapter/lessons_live.volt
+++ b/app/Http/Admin/Views/chapter/lessons_live.volt
@@ -37,7 +37,7 @@
课
{{ live_time_info(item.attrs) }}
-
+
diff --git a/app/Http/Admin/Views/chapter/lessons_read.volt b/app/Http/Admin/Views/chapter/lessons_read.volt
index 1ee05934..e6146fc9 100644
--- a/app/Http/Admin/Views/chapter/lessons_read.volt
+++ b/app/Http/Admin/Views/chapter/lessons_read.volt
@@ -28,7 +28,7 @@
课
{{ item.attrs['word_count'] }}
-
+
diff --git a/app/Http/Admin/Views/chapter/lessons_vod.volt b/app/Http/Admin/Views/chapter/lessons_vod.volt
index 16ef3794..de0421a8 100644
--- a/app/Http/Admin/Views/chapter/lessons_vod.volt
+++ b/app/Http/Admin/Views/chapter/lessons_vod.volt
@@ -44,8 +44,8 @@
课
{{ file_status(item.attrs['file_status']) }}
- {{ item.attrs['duration']|play_duration }}
-
+ {{ item.attrs['duration']|duration }}
+
diff --git a/app/Http/Admin/Views/consult/edit.volt b/app/Http/Admin/Views/consult/edit.volt
index 369d3adf..4b90ac0a 100644
--- a/app/Http/Admin/Views/consult/edit.volt
+++ b/app/Http/Admin/Views/consult/edit.volt
@@ -14,23 +14,23 @@
diff --git a/app/Http/Admin/Views/consult/list.volt b/app/Http/Admin/Views/consult/list.volt
index dfddee1a..98ad8c46 100644
--- a/app/Http/Admin/Views/consult/list.volt
+++ b/app/Http/Admin/Views/consult/list.volt
@@ -49,8 +49,8 @@
{% endif %}
- 昵称:{{ item.user.name }}
- 编号:{{ item.user.id }}
+ 昵称:{{ item.owner.name }}
+ 编号:{{ item.owner.id }}
{{ date('Y-m-d H:i:s',item.create_time) }}
diff --git a/app/Http/Admin/Views/consult/search.volt b/app/Http/Admin/Views/consult/search.volt
index 52cf3633..99fc3c32 100644
--- a/app/Http/Admin/Views/consult/search.volt
+++ b/app/Http/Admin/Views/consult/search.volt
@@ -21,7 +21,7 @@
diff --git a/app/Http/Admin/Views/course/chapters.volt b/app/Http/Admin/Views/course/chapters.volt
index c5e34ab6..461c26a4 100644
--- a/app/Http/Admin/Views/course/chapters.volt
+++ b/app/Http/Admin/Views/course/chapters.volt
@@ -42,7 +42,7 @@
{{ item.lesson_count }}
-
+
操作
diff --git a/app/Http/Admin/Views/course/edit_basic.volt b/app/Http/Admin/Views/course/edit_basic.volt
index 9bd5fa4f..eb434793 100644
--- a/app/Http/Admin/Views/course/edit_basic.volt
+++ b/app/Http/Admin/Views/course/edit_basic.volt
@@ -11,9 +11,9 @@
封面
diff --git a/app/Http/Admin/Views/group/add.volt b/app/Http/Admin/Views/group/add.volt
new file mode 100644
index 00000000..210d4a28
--- /dev/null
+++ b/app/Http/Admin/Views/group/add.volt
@@ -0,0 +1,37 @@
+
\ No newline at end of file
diff --git a/app/Http/Admin/Views/group/edit.volt b/app/Http/Admin/Views/group/edit.volt
new file mode 100644
index 00000000..e4d78ec9
--- /dev/null
+++ b/app/Http/Admin/Views/group/edit.volt
@@ -0,0 +1,61 @@
+
+
+
+ 编辑群组
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+{{ partial('partials/cover_uploader') }}
\ No newline at end of file
diff --git a/app/Http/Admin/Views/group/list.volt b/app/Http/Admin/Views/group/list.volt
new file mode 100644
index 00000000..0f4638f1
--- /dev/null
+++ b/app/Http/Admin/Views/group/list.volt
@@ -0,0 +1,63 @@
+{%- macro owner_info(owner) %}
+ {% if owner %}
+ {{ owner.name }}({{ owner.id }})
+ {% else %}
+ 未设置
+ {% endif %}
+{%- endmacro %}
+
+
+
+
+
+{{ partial('partials/pager') }}
\ No newline at end of file
diff --git a/app/Http/Admin/Views/group/search.volt b/app/Http/Admin/Views/group/search.volt
new file mode 100644
index 00000000..671cf511
--- /dev/null
+++ b/app/Http/Admin/Views/group/search.volt
@@ -0,0 +1,67 @@
+
+
+
+ 搜索群组
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/Http/Admin/Views/help/list.volt b/app/Http/Admin/Views/help/list.volt
index a8755fc9..e1d4aebe 100644
--- a/app/Http/Admin/Views/help/list.volt
+++ b/app/Http/Admin/Views/help/list.volt
@@ -39,7 +39,7 @@
{{ item.title }}
{{ date('Y-m-d H:i',item.create_time) }}
{{ date('Y-m-d H:i',item.update_time) }}
-
+
diff --git a/app/Http/Admin/Views/nav/list.volt b/app/Http/Admin/Views/nav/list.volt
index 6cb6506a..397ad959 100644
--- a/app/Http/Admin/Views/nav/list.volt
+++ b/app/Http/Admin/Views/nav/list.volt
@@ -71,7 +71,7 @@
{{ item.child_count }}
{{ position_info(item.position) }}
{{ target_info(item.target) }}
-
+
diff --git a/app/Http/Admin/Views/partials/cover_uploader.volt b/app/Http/Admin/Views/partials/cover_uploader.volt
index 2252665c..80ab226a 100644
--- a/app/Http/Admin/Views/partials/cover_uploader.volt
+++ b/app/Http/Admin/Views/partials/cover_uploader.volt
@@ -15,7 +15,7 @@
layer.load();
},
done: function (res, index, upload) {
- $('#cover-img').attr('src', res.data.src);
+ $('#img-cover').attr('src', res.data.src);
$('input[name=cover]').val(res.data.src);
layer.closeAll('loading');
},
diff --git a/app/Http/Admin/Views/partials/pager.volt b/app/Http/Admin/Views/partials/pager.volt
index 3f8b8892..c6945b16 100644
--- a/app/Http/Admin/Views/partials/pager.volt
+++ b/app/Http/Admin/Views/partials/pager.volt
@@ -1,8 +1,10 @@
{% if pager.total_pages > 1 %}
-
-
首页
-
上页
-
下页
-
尾页
+
{% endif %}
\ No newline at end of file
diff --git a/app/Http/Admin/Views/review/edit.volt b/app/Http/Admin/Views/review/edit.volt
index 944cc70a..9eb98405 100644
--- a/app/Http/Admin/Views/review/edit.volt
+++ b/app/Http/Admin/Views/review/edit.volt
@@ -22,8 +22,8 @@
diff --git a/app/Http/Admin/Views/review/list.volt b/app/Http/Admin/Views/review/list.volt
index aaa0619c..a05cfee1 100644
--- a/app/Http/Admin/Views/review/list.volt
+++ b/app/Http/Admin/Views/review/list.volt
@@ -41,8 +41,8 @@
评价:{{ substr(item.content,0,30) }}
- 昵称:{{ item.user.name }}
- 编号:{{ item.user.id }}
+ 昵称:{{ item.owner.name }}
+ 编号:{{ item.owner.id }}
{{ date('Y-m-d H:i:s',item.create_time) }}
diff --git a/app/Http/Admin/Views/review/search.volt b/app/Http/Admin/Views/review/search.volt
index fd47c8a8..8b4b714d 100644
--- a/app/Http/Admin/Views/review/search.volt
+++ b/app/Http/Admin/Views/review/search.volt
@@ -21,7 +21,7 @@
diff --git a/app/Http/Admin/Views/slide/edit.volt b/app/Http/Admin/Views/slide/edit.volt
index 2b865374..c72e5c56 100644
--- a/app/Http/Admin/Views/slide/edit.volt
+++ b/app/Http/Admin/Views/slide/edit.volt
@@ -18,9 +18,9 @@
封面
diff --git a/app/Http/Admin/Views/slide/list.volt b/app/Http/Admin/Views/slide/list.volt
index 53498c2d..1bf48de3 100644
--- a/app/Http/Admin/Views/slide/list.volt
+++ b/app/Http/Admin/Views/slide/list.volt
@@ -46,8 +46,8 @@
{{ item.id }}
{{ item.title }}
{{ target_info(item.target) }}
-
-
+
+
操作
diff --git a/app/Http/Web/Controllers/ChapterController.php b/app/Http/Web/Controllers/ChapterController.php
index 7837e2c6..02b664ca 100644
--- a/app/Http/Web/Controllers/ChapterController.php
+++ b/app/Http/Web/Controllers/ChapterController.php
@@ -4,10 +4,9 @@ namespace App\Http\Web\Controllers;
use App\Services\Frontend\Chapter\ChapterInfo as ChapterInfoService;
use App\Services\Frontend\Chapter\ChapterLike as ChapterLikeService;
-use App\Services\Frontend\Chapter\CommentList as ChapterCommentListService;
use App\Services\Frontend\Chapter\DanmuList as ChapterDanmuListService;
use App\Services\Frontend\Chapter\Learning as ChapterLearningService;
-use App\Services\Frontend\Course\ChapterList as CourseChapterListService;
+use App\Services\Frontend\Course\ChapterList as CourseCatalogService;
/**
* @RoutePrefix("/chapter")
@@ -33,7 +32,7 @@ class ChapterController extends Controller
]);
}
- $service = new CourseChapterListService();
+ $service = new CourseCatalogService();
$contents = $service->handle($chapter['course']['id']);
@@ -65,18 +64,6 @@ class ChapterController extends Controller
return $this->jsonSuccess(['items' => $items]);
}
- /**
- * @Get("/{id:[0-9]+}/comments", name="web.chapter.comments")
- */
- public function commentsAction($id)
- {
- $service = new ChapterCommentListService();
-
- $comments = $service->handle($id);
-
- return $this->jsonSuccess(['comments' => $comments]);
- }
-
/**
* @Post("/{id:[0-9]+}/like", name="web.chapter.like")
*/
@@ -84,9 +71,13 @@ class ChapterController extends Controller
{
$service = new ChapterLikeService();
- $service->handle($id);
+ $like = $service->handle($id);
- return $this->jsonSuccess();
+ $msg = $like->deleted == 0 ? '点赞成功' : '取消点赞成功';
+
+ $content = ['msg' => $msg];
+
+ return $this->jsonSuccess($content);
}
/**
diff --git a/app/Http/Web/Controllers/ConsultController.php b/app/Http/Web/Controllers/ConsultController.php
index f97ade49..6c46365c 100644
--- a/app/Http/Web/Controllers/ConsultController.php
+++ b/app/Http/Web/Controllers/ConsultController.php
@@ -6,6 +6,7 @@ use App\Services\Frontend\Consult\ConsultCreate as ConsultCreateService;
use App\Services\Frontend\Consult\ConsultDelete as ConsultDeleteService;
use App\Services\Frontend\Consult\ConsultInfo as ConsultInfoService;
use App\Services\Frontend\Consult\ConsultLike as ConsultLikeService;
+use App\Services\Frontend\Consult\ConsultRating as ConsultRatingService;
use App\Services\Frontend\Consult\ConsultUpdate as ConsultUpdateService;
use Phalcon\Mvc\View;
@@ -108,9 +109,27 @@ class ConsultController extends Controller
{
$service = new ConsultLikeService();
+ $like = $service->handle($id);
+
+ $msg = $like->deleted == 0 ? '点赞成功' : '取消点赞成功';
+
+ $content = ['msg' => $msg];
+
+ return $this->jsonSuccess($content);
+ }
+
+ /**
+ * @Post("/{id:[0-9]+}/rating", name="web.consult.rating")
+ */
+ public function ratingAction($id)
+ {
+ $service = new ConsultRatingService();
+
$service->handle($id);
- return $this->jsonSuccess();
+ $content = ['msg' => '评价成功'];
+
+ return $this->jsonSuccess($content);
}
}
diff --git a/app/Http/Web/Controllers/CourseController.php b/app/Http/Web/Controllers/CourseController.php
index dfce713d..ba96a028 100644
--- a/app/Http/Web/Controllers/CourseController.php
+++ b/app/Http/Web/Controllers/CourseController.php
@@ -3,7 +3,7 @@
namespace App\Http\Web\Controllers;
use App\Http\Web\Services\CourseQuery as CourseQueryService;
-use App\Services\Frontend\Course\ChapterList as CourseChapterListService;
+use App\Services\Frontend\Course\ChapterList as CourseCatalogService;
use App\Services\Frontend\Course\ConsultList as CourseConsultListService;
use App\Services\Frontend\Course\CourseInfo as CourseInfoService;
use App\Services\Frontend\Course\CourseList as CourseListService;
@@ -102,7 +102,7 @@ class CourseController extends Controller
*/
public function chaptersAction($id)
{
- $service = new CourseChapterListService();
+ $service = new CourseCatalogService();
$chapters = $service->handle($id);
@@ -206,9 +206,11 @@ class CourseController extends Controller
{
$service = new CourseFavoriteService();
- $service->handle($id);
+ $favorite = $service->handle($id);
- return $this->jsonSuccess(['msg' => '收藏课程成功']);
+ $msg = $favorite->deleted == 0 ? '收藏成功' : '取消收藏成功';
+
+ return $this->jsonSuccess(['msg' => $msg]);
}
}
diff --git a/app/Http/Web/Controllers/MyController.php b/app/Http/Web/Controllers/MyController.php
index 1d3d7e26..030538ee 100644
--- a/app/Http/Web/Controllers/MyController.php
+++ b/app/Http/Web/Controllers/MyController.php
@@ -5,6 +5,7 @@ namespace App\Http\Web\Controllers;
use App\Services\Frontend\My\AccountInfo as AccountInfoService;
use App\Services\Frontend\My\ConsultList as MyConsultListService;
use App\Services\Frontend\My\CourseList as MyCourseListService;
+use App\Services\Frontend\My\FavoriteList as MyFavoriteListService;
use App\Services\Frontend\My\ImFriendDelete as MyFriendDeleteService;
use App\Services\Frontend\My\ImGroupDelete as MyGroupDeleteService;
use App\Services\Frontend\My\OrderList as MyOrderListService;
@@ -84,10 +85,12 @@ class MyController extends Controller
*/
public function favoritesAction()
{
- $service = new MyConsultListService();
+ $service = new MyFavoriteListService();
$pager = $service->handle();
+ $pager->items = kg_array_object($pager->items);
+
$this->view->setVar('pager', $pager);
}
diff --git a/app/Http/Web/Controllers/ReviewController.php b/app/Http/Web/Controllers/ReviewController.php
index 5a5765ca..6135ae1b 100644
--- a/app/Http/Web/Controllers/ReviewController.php
+++ b/app/Http/Web/Controllers/ReviewController.php
@@ -111,9 +111,13 @@ class ReviewController extends Controller
{
$service = new ReviewLikeService();
- $service->handle($id);
+ $like = $service->handle($id);
- return $this->jsonSuccess();
+ $msg = $like->deleted == 0 ? '点赞成功' : '取消点赞成功';
+
+ $content = ['msg' => $msg];
+
+ return $this->jsonSuccess($content);
}
}
diff --git a/app/Http/Web/Services/ImFriendTrait.php b/app/Http/Web/Services/ImFriendTrait.php
index bdfd8808..529257eb 100644
--- a/app/Http/Web/Services/ImFriendTrait.php
+++ b/app/Http/Web/Services/ImFriendTrait.php
@@ -64,12 +64,16 @@ Trait ImFriendTrait
$friendUser = $friendUserRepo->findFriendUser($user->id, $sender->id);
if (!$friendUser) {
+
$friendUserModel = new ImFriendUserModel();
+
$friendUserModel->create([
'user_id' => $user->id,
'friend_id' => $sender->id,
'group_id' => $groupId,
]);
+
+ $this->incrUserFriendCount($user);
}
$friendUser = $friendUserRepo->findFriendUser($sender->id, $user->id);
@@ -77,12 +81,16 @@ Trait ImFriendTrait
$groupId = $message->item_info['group']['id'] ?: 0;
if (!$friendUser) {
+
$friendUserModel = new ImFriendUserModel();
+
$friendUserModel->create([
'user_id' => $sender->id,
'friend_id' => $user->id,
'group_id' => $groupId,
]);
+
+ $this->incrUserFriendCount($sender);
}
$itemInfo = $message->item_info;
@@ -245,4 +253,18 @@ Trait ImFriendTrait
}
}
+ protected function incrUserFriendCount(ImUserModel $user)
+ {
+ $user->friend_count += 1;
+ $user->update();
+ }
+
+ protected function decrUserFriendCount(ImUserModel $user)
+ {
+ if ($user->friend_count > 0) {
+ $user->friend_count -= 1;
+ $user->update();
+ }
+ }
+
}
diff --git a/app/Http/Web/Services/ImGroupTrait.php b/app/Http/Web/Services/ImGroupTrait.php
index a55a3b4d..bceccdd5 100644
--- a/app/Http/Web/Services/ImGroupTrait.php
+++ b/app/Http/Web/Services/ImGroupTrait.php
@@ -67,13 +67,17 @@ Trait ImGroupTrait
$groupUser = $groupUserRepo->findGroupUser($group->id, $applicant->id);
if (!$groupUser) {
+
$groupUserModel = new ImGroupUserModel();
+
$groupUserModel->create([
'group_id' => $group->id,
'user_id' => $applicant->id,
]);
- $group->user_count += 1;
- $group->update();
+
+ $this->incrGroupUserCount($group);
+
+ $this->incrUserGroupCount($applicant);
}
$itemInfo = $message->item_info;
@@ -264,4 +268,32 @@ Trait ImGroupTrait
}
}
+ protected function incrUserGroupCount(ImUserModel $user)
+ {
+ $user->group_count += 1;
+ $user->update();
+ }
+
+ protected function decrUserGroupCount(ImUserModel $user)
+ {
+ if ($user->group_count > 0) {
+ $user->group_count -= 1;
+ $user->update();
+ }
+ }
+
+ protected function incrGroupUserCount(ImGroupModel $group)
+ {
+ $group->user_count += 1;
+ $group->update();
+ }
+
+ protected function decrGroupUserCount(ImGroupModel $group)
+ {
+ if ($group->user_count > 0) {
+ $group->user_count -= 1;
+ $group->update();
+ }
+ }
+
}
diff --git a/app/Http/Web/Views/consult/add.volt b/app/Http/Web/Views/consult/add.volt
index 7e0665f3..9273044a 100644
--- a/app/Http/Web/Views/consult/add.volt
+++ b/app/Http/Web/Views/consult/add.volt
@@ -3,7 +3,7 @@
{% block content %}
+
{% endblock %}
\ No newline at end of file
diff --git a/app/Http/Web/Views/consult/show.volt b/app/Http/Web/Views/consult/show.volt
index 4dd72544..c28e1d4c 100644
--- a/app/Http/Web/Views/consult/show.volt
+++ b/app/Http/Web/Views/consult/show.volt
@@ -1,27 +1,60 @@
{% extends 'templates/layer.volt' %}
{% block content %}
-
-