diff --git a/app/Caches/IndexCarouselList.php b/app/Caches/IndexCarouselList.php index 94ccde8c..0a216296 100644 --- a/app/Caches/IndexCarouselList.php +++ b/app/Caches/IndexCarouselList.php @@ -18,7 +18,7 @@ class IndexCarouselList extends Cache public function getKey($id = null) { - return 'index_carousel_list'; + return 'index:carousel_list'; } public function getContent($id = null) diff --git a/app/Caches/IndexFreeCourseList.php b/app/Caches/IndexFreeCourseList.php index b6c69d67..5a8f380d 100644 --- a/app/Caches/IndexFreeCourseList.php +++ b/app/Caches/IndexFreeCourseList.php @@ -23,7 +23,7 @@ class IndexFreeCourseList extends Cache public function getKey($id = null) { - return 'index_free_course_list'; + return 'index:free_course_list'; } public function getContent($id = null) diff --git a/app/Caches/IndexLiveList.php b/app/Caches/IndexLiveList.php index 238c0d05..01719a4d 100644 --- a/app/Caches/IndexLiveList.php +++ b/app/Caches/IndexLiveList.php @@ -22,7 +22,7 @@ class IndexLiveList extends Cache public function getKey($id = null) { - return 'index_live_list'; + return 'index:live_list'; } public function getContent($id = null) diff --git a/app/Caches/IndexNewCourseList.php b/app/Caches/IndexNewCourseList.php index 7cb627cf..008c8651 100644 --- a/app/Caches/IndexNewCourseList.php +++ b/app/Caches/IndexNewCourseList.php @@ -23,7 +23,7 @@ class IndexNewCourseList extends Cache public function getKey($id = null) { - return 'index_new_course_list'; + return 'index:new_course_list'; } public function getContent($id = null) diff --git a/app/Caches/IndexVipCourseList.php b/app/Caches/IndexVipCourseList.php index ab869db0..20aeb6ee 100644 --- a/app/Caches/IndexVipCourseList.php +++ b/app/Caches/IndexVipCourseList.php @@ -23,7 +23,7 @@ class IndexVipCourseList extends Cache public function getKey($id = null) { - return 'index_vip_course_list'; + return 'index:vip_course_list'; } public function getContent($id = null) diff --git a/app/Caches/MaxCategoryId.php b/app/Caches/MaxCategoryId.php index dfc4fa4f..2a635c52 100644 --- a/app/Caches/MaxCategoryId.php +++ b/app/Caches/MaxCategoryId.php @@ -16,7 +16,7 @@ class MaxCategoryId extends Cache public function getKey($id = null) { - return 'max_category_id'; + return 'max_id:category'; } public function getContent($id = null) diff --git a/app/Caches/MaxChapterId.php b/app/Caches/MaxChapterId.php index e751dfe8..8b80793f 100644 --- a/app/Caches/MaxChapterId.php +++ b/app/Caches/MaxChapterId.php @@ -16,7 +16,7 @@ class MaxChapterId extends Cache public function getKey($id = null) { - return 'max_chapter_id'; + return 'max_id:chapter'; } public function getContent($id = null) diff --git a/app/Caches/MaxCourseId.php b/app/Caches/MaxCourseId.php index 6f8b350c..bfc0233d 100644 --- a/app/Caches/MaxCourseId.php +++ b/app/Caches/MaxCourseId.php @@ -16,7 +16,7 @@ class MaxCourseId extends Cache public function getKey($id = null) { - return 'max_course_id'; + return 'max_id:course'; } public function getContent($id = null) diff --git a/app/Caches/MaxHelpId.php b/app/Caches/MaxHelpId.php index ae43642d..af56d21c 100644 --- a/app/Caches/MaxHelpId.php +++ b/app/Caches/MaxHelpId.php @@ -16,7 +16,7 @@ class MaxHelpId extends Cache public function getKey($id = null) { - return 'max_help_id'; + return 'max_id:help'; } public function getContent($id = null) diff --git a/app/Caches/MaxImGroupId.php b/app/Caches/MaxImGroupId.php index 346206b4..ca2ab945 100644 --- a/app/Caches/MaxImGroupId.php +++ b/app/Caches/MaxImGroupId.php @@ -16,7 +16,7 @@ class MaxImGroupId extends Cache public function getKey($id = null) { - return 'max_im_group_id'; + return 'max_id:im_group'; } public function getContent($id = null) diff --git a/app/Caches/MaxPackageId.php b/app/Caches/MaxPackageId.php index b5252a4c..845cbfd4 100644 --- a/app/Caches/MaxPackageId.php +++ b/app/Caches/MaxPackageId.php @@ -16,7 +16,7 @@ class MaxPackageId extends Cache public function getKey($id = null) { - return 'max_package_id'; + return 'max_id:package'; } public function getContent($id = null) diff --git a/app/Caches/MaxPageId.php b/app/Caches/MaxPageId.php index cfed90f3..d3f1a466 100644 --- a/app/Caches/MaxPageId.php +++ b/app/Caches/MaxPageId.php @@ -16,7 +16,7 @@ class MaxPageId extends Cache public function getKey($id = null) { - return 'max_page_id'; + return 'max_id:page'; } public function getContent($id = null) diff --git a/app/Caches/MaxTopicId.php b/app/Caches/MaxTopicId.php index 3c739d7a..6a67fefa 100644 --- a/app/Caches/MaxTopicId.php +++ b/app/Caches/MaxTopicId.php @@ -16,7 +16,7 @@ class MaxTopicId extends Cache public function getKey($id = null) { - return 'max_topic_id'; + return 'max_id:topic'; } public function getContent($id = null) diff --git a/app/Caches/MaxUserId.php b/app/Caches/MaxUserId.php index 7109382b..4a48e522 100644 --- a/app/Caches/MaxUserId.php +++ b/app/Caches/MaxUserId.php @@ -16,7 +16,7 @@ class MaxUserId extends Cache public function getKey($id = null) { - return 'max_user_id'; + return 'max_id:user'; } public function getContent($id = null) diff --git a/app/Http/Admin/Controllers/ImGroupController.php b/app/Http/Admin/Controllers/ImGroupController.php index e2ef3b02..7be26303 100644 --- a/app/Http/Admin/Controllers/ImGroupController.php +++ b/app/Http/Admin/Controllers/ImGroupController.php @@ -11,7 +11,7 @@ class ImGroupController extends Controller { /** - * @Get("/list", name="admin.im_group.list") + * @Get("/list", name="admin.group.list") */ public function listAction() { @@ -19,27 +19,43 @@ class ImGroupController extends Controller $pager = $groupService->getGroups(); + $this->view->pick('im/group/list'); + $this->view->setVar('pager', $pager); } /** - * @Get("/search", name="admin.im_group.search") + * @Get("/search", name="admin.group.search") */ public function searchAction() { - + $this->view->pick('im/group/search'); } /** - * @Get("/add", name="admin.im_group.add") + * @Get("/add", name="admin.group.add") */ public function addAction() { - + $this->view->pick('im/group/add'); } /** - * @Post("/create", name="admin.im_group.create") + * @Get("/{id:[0-9]+}/edit", name="admin.group.edit") + */ + public function editAction($id) + { + $groupService = new ImGroupService(); + + $group = $groupService->getGroup($id); + + $this->view->pick('im/group/edit'); + + $this->view->setVar('group', $group); + } + + /** + * @Post("/create", name="admin.group.create") */ public function createAction() { @@ -48,7 +64,7 @@ class ImGroupController extends Controller $group = $groupService->createGroup(); $location = $this->url->get([ - 'for' => 'admin.im_group.edit', + 'for' => 'admin.group.edit', 'id' => $group->id, ]); @@ -61,19 +77,7 @@ class ImGroupController extends Controller } /** - * @Get("/{id:[0-9]+}/edit", name="admin.im_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.im_group.update") + * @Post("/{id:[0-9]+}/update", name="admin.group.update") */ public function updateAction($id) { @@ -81,7 +85,7 @@ class ImGroupController extends Controller $groupService->updateGroup($id); - $location = $this->url->get(['for' => 'admin.im_group.list']); + $location = $this->url->get(['for' => 'admin.group.list']); $content = [ 'location' => $location, @@ -92,7 +96,7 @@ class ImGroupController extends Controller } /** - * @Post("/{id:[0-9]+}/delete", name="admin.im_group.delete") + * @Post("/{id:[0-9]+}/delete", name="admin.group.delete") */ public function deleteAction($id) { @@ -111,7 +115,7 @@ class ImGroupController extends Controller } /** - * @Post("/{id:[0-9]+}/restore", name="admin.im_group.restore") + * @Post("/{id:[0-9]+}/restore", name="admin.group.restore") */ public function restoreAction($id) { diff --git a/app/Http/Admin/Controllers/SettingController.php b/app/Http/Admin/Controllers/SettingController.php index 7bb8a890..a465d086 100644 --- a/app/Http/Admin/Controllers/SettingController.php +++ b/app/Http/Admin/Controllers/SettingController.php @@ -278,4 +278,34 @@ class SettingController extends Controller } } + /** + * @Route("/im", name="admin.setting.im") + */ + public function imAction() + { + $section = 'im'; + + $settingService = new SettingService(); + + if ($this->request->isPost()) { + + $data = $this->request->getPost(); + + $settingService->updateSectionSettings($section, $data); + + $content = [ + 'location' => $this->request->getHTTPReferer(), + 'msg' => '更新配置成功', + ]; + + return $this->jsonSuccess($content); + + } else { + + $im = $settingService->getSectionSettings($section); + + $this->view->setVar('im', $im); + } + } + } diff --git a/app/Http/Admin/Services/AuthNode.php b/app/Http/Admin/Services/AuthNode.php index a901a612..c30d4d0f 100644 --- a/app/Http/Admin/Services/AuthNode.php +++ b/app/Http/Admin/Services/AuthNode.php @@ -348,31 +348,31 @@ class AuthNode extends Service 'id' => '2-4-1', 'title' => '群组列表', 'type' => 'menu', - 'route' => 'admin.im_group.list', + 'route' => 'admin.group.list', ], [ 'id' => '2-4-2', 'title' => '搜索群组', 'type' => 'menu', - 'route' => 'admin.im_group.search', + 'route' => 'admin.group.search', ], [ 'id' => '2-4-3', 'title' => '添加群组', 'type' => 'menu', - 'route' => 'admin.im_group.add', + 'route' => 'admin.group.add', ], [ 'id' => '2-4-4', 'title' => '编辑群组', 'type' => 'button', - 'route' => 'admin.im_group.edit', + 'route' => 'admin.group.edit', ], [ 'id' => '2-4-5', 'title' => '删除群组', 'type' => 'button', - 'route' => 'admin.im_group.delete', + 'route' => 'admin.group.delete', ], ], ], @@ -700,7 +700,13 @@ class AuthNode extends Service 'title' => '会员设置', 'type' => 'menu', 'route' => 'admin.setting.vip', - ] + ], + [ + 'id' => '5-1-11', + 'title' => '微聊设置', + 'type' => 'menu', + 'route' => 'admin.setting.im', + ], ], ], ], diff --git a/app/Http/Admin/Services/Course.php b/app/Http/Admin/Services/Course.php index 67996c63..31a3fb3b 100644 --- a/app/Http/Admin/Services/Course.php +++ b/app/Http/Admin/Services/Course.php @@ -190,8 +190,6 @@ class Course extends Service $course->update($data); - $this->updateCourseGroup($course); - return $course; } @@ -357,15 +355,6 @@ class Course extends Service return $validator->checkCourse($id); } - protected function updateCourseGroup(CourseModel $course) - { - $courseRepo = new CourseRepo(); - - $imGroup = $courseRepo->findImGroup($course->id); - - $imGroup->update(['name' => $course->title]); - } - protected function rebuildCourseCache(CourseModel $course) { $cache = new CourseCache(); diff --git a/app/Http/Admin/Views/im_group/add.volt b/app/Http/Admin/Views/im/group/add.volt similarity index 92% rename from app/Http/Admin/Views/im_group/add.volt rename to app/Http/Admin/Views/im/group/add.volt index 99ed9f81..fd2cac5a 100644 --- a/app/Http/Admin/Views/im_group/add.volt +++ b/app/Http/Admin/Views/im/group/add.volt @@ -2,7 +2,7 @@ {% block content %} -
+
添加群组
@@ -23,6 +23,7 @@
+
diff --git a/app/Http/Admin/Views/im_group/edit.volt b/app/Http/Admin/Views/im/group/edit.volt similarity index 97% rename from app/Http/Admin/Views/im_group/edit.volt rename to app/Http/Admin/Views/im/group/edit.volt index 9563ec19..10be069f 100644 --- a/app/Http/Admin/Views/im_group/edit.volt +++ b/app/Http/Admin/Views/im/group/edit.volt @@ -2,7 +2,7 @@ {% block content %} - +
编辑群组
diff --git a/app/Http/Admin/Views/im_group/list.volt b/app/Http/Admin/Views/im/group/list.volt similarity index 87% rename from app/Http/Admin/Views/im_group/list.volt rename to app/Http/Admin/Views/im/group/list.volt index 0a33fd6a..923c1478 100644 --- a/app/Http/Admin/Views/im_group/list.volt +++ b/app/Http/Admin/Views/im/group/list.volt @@ -47,10 +47,10 @@ {% for item in pager.items %} - {% set edit_url = url({'for':'admin.im_group.edit','id':item.id}) %} - {% set update_url = url({'for':'admin.im_group.update','id':item.id}) %} - {% set delete_url = url({'for':'admin.im_group.delete','id':item.id}) %} - {% set restore_url = url({'for':'admin.im_group.restore','id':item.id}) %} + {% set edit_url = url({'for':'admin.group.edit','id':item.id}) %} + {% set update_url = url({'for':'admin.group.update','id':item.id}) %} + {% set delete_url = url({'for':'admin.group.delete','id':item.id}) %} + {% set restore_url = url({'for':'admin.group.restore','id':item.id}) %} {{ item.id }} {{ item.name }} {{ type_info(item.type) }} diff --git a/app/Http/Admin/Views/im_group/search.volt b/app/Http/Admin/Views/im/group/search.volt similarity index 98% rename from app/Http/Admin/Views/im_group/search.volt rename to app/Http/Admin/Views/im/group/search.volt index dbb2cdc6..2769b899 100644 --- a/app/Http/Admin/Views/im_group/search.volt +++ b/app/Http/Admin/Views/im/group/search.volt @@ -2,7 +2,7 @@ {% block content %} - +
搜索群组
diff --git a/app/Http/Admin/Views/setting/im.volt b/app/Http/Admin/Views/setting/im.volt new file mode 100644 index 00000000..6f239d80 --- /dev/null +++ b/app/Http/Admin/Views/setting/im.volt @@ -0,0 +1,42 @@ +{% extends 'templates/main.volt' %} + +{% block content %} + + +
+ 微聊配置 +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + +
+
+ + +{% endblock %} \ No newline at end of file diff --git a/app/Http/Admin/Views/setting/site.volt b/app/Http/Admin/Views/setting/site.volt index c1c231e6..6d062530 100644 --- a/app/Http/Admin/Views/setting/site.volt +++ b/app/Http/Admin/Views/setting/site.volt @@ -2,7 +2,7 @@ {% block content %} - {% set closed_tips_display = site.status == 'normal' ? 'style="display:none;"' : '' %} + {% set closed_tips_display = site.enabled == 1 ? 'style="display:none;"' : '' %}
@@ -11,8 +11,8 @@
- - + +
@@ -110,7 +110,7 @@ form.on('radio(status)', function (data) { var block = $('#closed-tips-block'); - if (data.value === 'closed') { + if (data.value === '0') { block.show(); } else { block.hide(); diff --git a/app/Http/Web/Controllers/Controller.php b/app/Http/Web/Controllers/Controller.php index 917020de..62babec3 100644 --- a/app/Http/Web/Controllers/Controller.php +++ b/app/Http/Web/Controllers/Controller.php @@ -20,11 +20,6 @@ class Controller extends \Phalcon\Mvc\Controller */ protected $seo; - /** - * @var array - */ - protected $site; - /** * @var array */ @@ -35,6 +30,11 @@ class Controller extends \Phalcon\Mvc\Controller */ protected $appInfo; + /** + * @var array + */ + protected $siteInfo; + /** * @var UserModel */ @@ -45,7 +45,7 @@ class Controller extends \Phalcon\Mvc\Controller public function beforeExecuteRoute(Dispatcher $dispatcher) { - $this->site = $this->getSiteSettings(); + $this->siteInfo = $this->getSiteInfo(); $this->checkSiteStatus(); @@ -66,12 +66,12 @@ class Controller extends \Phalcon\Mvc\Controller $this->appInfo = $this->getAppInfo(); $this->authUser = $this->getAuthUser(); - $this->seo->setTitle($this->site['title']); + $this->seo->setTitle($this->siteInfo['title']); - $this->view->setVar('site', $this->site); $this->view->setVar('seo', $this->seo); $this->view->setVar('navs', $this->navs); $this->view->setVar('app_info', $this->appInfo); + $this->view->setVar('site_info', $this->siteInfo); $this->view->setVar('auth_user', $this->authUser); $this->view->setVar('socket_url', $this->getSocketUrl()); } @@ -98,7 +98,7 @@ class Controller extends \Phalcon\Mvc\Controller return $cache->get() ?: []; } - protected function getSiteSettings() + protected function getSiteInfo() { $cache = new SettingCache(); @@ -119,11 +119,11 @@ class Controller extends \Phalcon\Mvc\Controller protected function checkSiteStatus() { - if ($this->site['status'] == 'closed') { + if ($this->siteInfo['enabled'] == 0) { $this->dispatcher->forward([ 'controller' => 'error', 'action' => 'shutdown', - 'params' => ['message' => $this->site['closed_tips']], + 'params' => ['message' => $this->siteInfo['closed_tips']], ]); } } diff --git a/app/Http/Web/Controllers/ImController.php b/app/Http/Web/Controllers/ImController.php index 953d2287..5abe6a35 100644 --- a/app/Http/Web/Controllers/ImController.php +++ b/app/Http/Web/Controllers/ImController.php @@ -9,11 +9,39 @@ use Phalcon\Mvc\View; /** * @RoutePrefix("/im") */ -class ImController extends LayerController +class ImController extends Controller { use ResponseTrait; + /** + * @Get("/", name="web.im.index") + */ + public function indexAction() + { + + } + + /** + * @Get("/cs", name="web.im.cs") + */ + public function csAction() + { + /** + * @todo 在线客服 + */ + } + + /** + * @Get("/robot", name="web.im.robot") + */ + public function robotAction() + { + /** + * @todo 聊天机器人 + */ + } + /** * @Get("/init", name="web.im.init") */ @@ -68,7 +96,7 @@ class ImController extends LayerController /** * @Get("/friend/msg/unread", name="web.im.unread_friend_msg") */ - public function unreadFriendMsgAction() + public function unreadFriendMessageAction() { $service = new ImService(); @@ -78,9 +106,9 @@ class ImController extends LayerController } /** - * @Get("/sys/msg/unread", name="web.im.unread_sys_msg") + * @Get("/notice/unread", name="web.im.unread_notice") */ - public function unreadSysMsgAction() + public function unreadNoticeAction() { $service = new ImService(); @@ -90,24 +118,21 @@ class ImController extends LayerController } /** - * @Get("/sys/msg", name="web.im.sys_msg") + * @Get("/notice", name="web.im.notice") */ - public function sysMsgAction() + public function noticeAction() { $service = new ImService(); $pager = $service->getNotices(); - $pager->items = kg_array_object($pager->items); - - $this->view->pick('im/sys_msg'); $this->view->setVar('pager', $pager); } /** - * @Post("/sys/msg/read", name="web.im.read_sys_msg") + * @Post("/notice/read", name="web.im.read_notice") */ - public function readSysMsgAction() + public function readNoticeAction() { $service = new ImService(); @@ -140,51 +165,6 @@ class ImController extends LayerController return $this->jsonPaginate($pager); } - /** - * @Get("/find", name="web.im.find") - */ - public function findAction() - { - $service = new ImService(); - - $userPager = $service->getNewUsers(); - $groupPager = $service->getNewGroups(); - - $userPager->items = kg_array_object($userPager->items); - $groupPager->items = kg_array_object($groupPager->items); - - $this->view->setVar('user_pager', $userPager); - $this->view->setVar('group_pager', $groupPager); - } - - /** - * @Get("/search", name="web.im.search") - */ - public function searchAction() - { - $type = $this->request->getQuery('type'); - $query = $this->request->getQuery('query'); - $target = $this->request->getQuery('target'); - - $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); - - $service = new ImService(); - - if ($type == 'user') { - $this->view->pick('im/find_users'); - $target = $target ?: 'tab-users'; - $pager = $service->searchUsers($query); - } else { - $this->view->pick('im/find_groups'); - $target = $target ?: 'tab-groups'; - $pager = $service->searchGroups($query); - } - - $pager->target = $target; - - $this->view->setVar('pager', $pager); - } - /** * @Post("/user/bind", name="web.im.bind_user") */ diff --git a/app/Http/Web/Controllers/ImGroupController.php b/app/Http/Web/Controllers/ImGroupController.php index 00f8ca82..d123f706 100644 --- a/app/Http/Web/Controllers/ImGroupController.php +++ b/app/Http/Web/Controllers/ImGroupController.php @@ -12,15 +12,17 @@ class ImGroupController extends Controller { /** - * @Get("/list", name="web.im_group.list") + * @Get("/list", name="web.group.list") */ public function listAction() { $this->seo->prependTitle('群组'); + + $this->view->pick('im/group/list'); } /** - * @Get("/pager", name="web.im_group.pager") + * @Get("/pager", name="web.group.pager") */ public function pagerAction() { @@ -31,12 +33,12 @@ class ImGroupController extends Controller $pager->target = 'group-list'; $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); - $this->view->pick('im_group/pager'); + $this->view->pick('im/group/pager'); $this->view->setVar('pager', $pager); } /** - * @Get("/{id:[0-9]+}", name="web.im_group.show") + * @Get("/{id:[0-9]+}", name="web.group.show") */ public function showAction($id) { @@ -44,11 +46,12 @@ class ImGroupController extends Controller $group = $service->getGroup($id); + $this->view->pick('im/group/show'); $this->view->setVar('group', $group); } /** - * @Get("/{id:[0-9]+}/users", name="web.im_group.users") + * @Get("/{id:[0-9]+}/users", name="web.group.users") */ public function usersAction($id) { @@ -59,11 +62,12 @@ class ImGroupController extends Controller $pager->target = 'user-list'; $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); + $this->view->pick('im/group/users'); $this->view->setVar('pager', $pager); } /** - * @Get("/{id:[0-9]+}/users/active", name="web.im_group.active_users") + * @Get("/{id:[0-9]+}/users/active", name="web.group.active_users") */ public function activeUsersAction($id) { @@ -72,7 +76,7 @@ class ImGroupController extends Controller $users = $service->getActiveGroupUsers($id); $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); - $this->view->pick('im_group/active_users'); + $this->view->pick('im/group/active_users'); $this->view->setVar('users', $users); } diff --git a/app/Http/Web/Controllers/ImGroupManageController.php b/app/Http/Web/Controllers/ImGroupManageController.php index 12be7023..012c8393 100644 --- a/app/Http/Web/Controllers/ImGroupManageController.php +++ b/app/Http/Web/Controllers/ImGroupManageController.php @@ -21,8 +21,7 @@ class ImGroupManageController extends Controller $pager = $service->getGroupUsers($id); - $pager->items = kg_array_object($pager->items); - + $this->view->pick('im/group/manage/users'); $this->view->setVar('group', $group); $this->view->setVar('pager', $pager); } @@ -36,6 +35,7 @@ class ImGroupManageController extends Controller $group = $service->getGroup($id); + $this->view->pick('im/group/manage/edit'); $this->view->setVar('group', $group); } diff --git a/app/Http/Web/Controllers/ImSummaryController.php b/app/Http/Web/Controllers/ImSummaryController.php index a78ac073..56a96746 100644 --- a/app/Http/Web/Controllers/ImSummaryController.php +++ b/app/Http/Web/Controllers/ImSummaryController.php @@ -2,9 +2,6 @@ namespace App\Http\Web\Controllers; -use App\Http\Web\Services\ImGroup as ImGroupService; -use Phalcon\Mvc\View; - /** * @RoutePrefix("/im") */ @@ -35,20 +32,4 @@ class ImSummaryController extends Controller $this->seo->prependTitle('群组'); } - /** - * @Get("/pager", name="web.im_group.pager") - */ - public function pagerAction() - { - $service = new ImGroupService(); - - $pager = $service->getGroups(); - - $pager->target = 'group-list'; - - $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); - $this->view->pick('im_group/pager'); - $this->view->setVar('pager', $pager); - } - } diff --git a/app/Http/Web/Controllers/IndexController.php b/app/Http/Web/Controllers/IndexController.php index c24043ef..6c47c853 100644 --- a/app/Http/Web/Controllers/IndexController.php +++ b/app/Http/Web/Controllers/IndexController.php @@ -12,8 +12,8 @@ class IndexController extends Controller */ public function indexAction() { - $this->seo->setKeywords($this->site['keywords']); - $this->seo->setDescription($this->site['description']); + $this->seo->setKeywords($this->siteInfo['keywords']); + $this->seo->setDescription($this->siteInfo['description']); $indexService = new IndexService(); @@ -24,19 +24,4 @@ class IndexController extends Controller $this->view->setVar('vip_courses', $indexService->getVipCourses()); } - /** - * @Get("/im", name="web.im") - */ - public function imAction() - { - - } - - protected function getSocketUrl() - { - $config = $this->getDI()->get('config'); - - return $config->websocket->url; - } - } diff --git a/app/Http/Web/Controllers/MyController.php b/app/Http/Web/Controllers/MyController.php index 00aa31ff..3843194c 100644 --- a/app/Http/Web/Controllers/MyController.php +++ b/app/Http/Web/Controllers/MyController.php @@ -146,24 +146,22 @@ class MyController extends Controller } /** - * @Get("/im/friends", name="web.my.im_friends") + * @Get("/friends", name="web.my.friends") */ - public function imFriendsAction() + public function friendsAction() { $service = new MyFriendListService(); $pager = $service->handle(); - $pager->items = kg_array_object($pager->items); - - $this->view->pick('my/im_friends'); + $this->view->pick('my/friends'); $this->view->setVar('pager', $pager); } /** - * @Get("/im/groups", name="web.my.im_groups") + * @Get("/groups", name="web.my.groups") */ - public function imGroupsAction() + public function groupsAction() { $type = $this->request->getQuery('type', 'trim', 'joined'); @@ -171,9 +169,7 @@ class MyController extends Controller $pager = $service->handle($type); - $pager->items = kg_array_object($pager->items); - - $this->view->pick('my/im_groups'); + $this->view->pick('my/groups'); $this->view->setVar('type', $type); $this->view->setVar('pager', $pager); } diff --git a/app/Http/Web/Services/Im.php b/app/Http/Web/Services/Im.php index 25c11c2c..cb962bfd 100644 --- a/app/Http/Web/Services/Im.php +++ b/app/Http/Web/Services/Im.php @@ -3,8 +3,6 @@ namespace App\Http\Web\Services; use App\Builders\ImMessageList as ImMessageListBuilder; -use App\Caches\ImNewGroupList as ImNewGroupListCache; -use App\Caches\ImNewUserList as ImNewUserListCache; use App\Library\Paginator\Query as PagerQuery; use App\Models\ImMessage as ImMessageModel; use App\Models\ImUser as ImUserModel; @@ -13,7 +11,6 @@ use App\Repos\ImGroup as ImGroupRepo; use App\Repos\ImMessage as ImMessageRepo; use App\Repos\ImNotice as ImNoticeRepo; use App\Repos\ImUser as ImUserRepo; -use App\Repos\User as UserRepo; use App\Validators\ImFriendUser as ImFriendUserValidator; use App\Validators\ImGroup as ImGroupValidator; use App\Validators\ImGroupUser as ImGroupUserValidator; @@ -21,11 +18,6 @@ use App\Validators\ImMessage as ImMessageValidator; use App\Validators\ImUser as ImUserValidator; use GatewayClient\Gateway; -/** - * 警告: - * 对象有更新操作会导致afterFetch()中的设置失效, - * 有相关依赖的要重新调用一次afterFetch() - */ class Im extends Service { @@ -56,74 +48,6 @@ class Im extends Service ]; } - public function searchUsers($name) - { - $pagerQuery = new PagerQuery(); - - $params = $pagerQuery->getParams(); - - $params['name'] = $name; - - $sort = $pagerQuery->getSort(); - $page = $pagerQuery->getPage(); - $limit = $pagerQuery->getLimit(); - - $userRepo = new UserRepo(); - - $pager = $userRepo->paginate($params, $sort, $page, $limit); - - return $this->handleUserPager($pager); - } - - public function searchGroups($name) - { - $pagerQuery = new PagerQuery(); - - $params = $pagerQuery->getParams(); - - $params['name'] = $name; - - $sort = $pagerQuery->getSort(); - $page = $pagerQuery->getPage(); - $limit = $pagerQuery->getLimit(); - - $groupRepo = new ImGroupRepo(); - - $pager = $groupRepo->paginate($params, $sort, $page, $limit); - - return $this->handleGroupPager($pager); - } - - public function getNewUsers() - { - $cache = new ImNewUserListCache(); - - $items = $cache->get(); - - $pager = new \stdClass(); - - $pager->total_items = count($items); - $pager->total_pages = 1; - $pager->items = $items; - - return $pager; - } - - public function getNewGroups() - { - $cache = new ImNewGroupListCache(); - - $items = $cache->get(); - - $pager = new \stdClass(); - - $pager->total_items = count($items); - $pager->total_pages = 1; - $pager->items = $items; - - return $pager; - } - public function getGroupUsers() { $id = $this->request->getQuery('id'); @@ -648,62 +572,6 @@ class Im extends Service return $pager; } - protected function handleUserPager($pager) - { - if ($pager->total_items == 0) { - return $pager; - } - - $users = $pager->items->toArray(); - - $baseUrl = kg_ci_base_url(); - - $items = []; - - foreach ($users as $user) { - $user['avatar'] = $baseUrl . $user['avatar']; - $items[] = [ - 'id' => $user['id'], - 'name' => $user['name'], - 'avatar' => $user['avatar'], - 'about' => $user['about'], - 'vip' => $user['vip'], - ]; - } - - $pager->items = $items; - - return $pager; - } - - protected function handleGroupPager($pager) - { - if ($pager->total_items == 0) { - return $pager; - } - - $groups = $pager->items->toArray(); - - $baseUrl = kg_ci_base_url(); - - $items = []; - - foreach ($groups as $group) { - $group['avatar'] = $baseUrl . $group['avatar']; - $items[] = [ - 'id' => $group['id'], - 'type' => $group['type'], - 'name' => $group['name'], - 'avatar' => $group['avatar'], - 'about' => $group['about'], - ]; - } - - $pager->items = $items; - - return $pager; - } - protected function getImUser($id) { $repo = new ImUserRepo(); diff --git a/app/Http/Web/Views/im/find.volt b/app/Http/Web/Views/im/find.volt deleted file mode 100644 index 3a45ff50..00000000 --- a/app/Http/Web/Views/im/find.volt +++ /dev/null @@ -1,35 +0,0 @@ -{% extends 'templates/layer.volt' %} - -{% block content %} - -
- - - - -
-
-
    -
  • 成员
  • -
  • 群组
  • -
-
-
- {{ partial('im/find_users',{'pager':user_pager}) }} -
-
- {{ partial('im/find_groups',{'pager':group_pager}) }} -
-
-
-
-
- -{% endblock %} - -{% block include_js %} - - {{ js_include('web/js/im.find.js') }} - {{ js_include('web/js/im.apply.js') }} - -{% endblock %} \ No newline at end of file diff --git a/app/Http/Web/Views/im/find_groups.volt b/app/Http/Web/Views/im/find_groups.volt deleted file mode 100644 index 57915bca..00000000 --- a/app/Http/Web/Views/im/find_groups.volt +++ /dev/null @@ -1,27 +0,0 @@ -{% if pager.total_pages > 0 %} -
-
- {% for item in pager.items %} -
-
- {% if item.type == 'course' %} - - {% elseif item.type == 'chat' %} - - {% endif %} -
- - {{ item.name }} - -
-
{{ item.name }}
-
- 申请加入 -
-
-
- {% endfor %} -
-
- {{ partial('partials/pager_ajax') }} -{% endif %} \ No newline at end of file diff --git a/app/Http/Web/Views/im/find_users.volt b/app/Http/Web/Views/im/find_users.volt deleted file mode 100644 index cce64ea3..00000000 --- a/app/Http/Web/Views/im/find_users.volt +++ /dev/null @@ -1,23 +0,0 @@ -{% if pager.total_pages > 0 %} -
-
- {% for item in pager.items %} -
-
- {% if item.vip == 1 %} - VIP - {% endif %} -
- {{ item.name }} -
-
{{ item.name }}
-
- 申请好友 -
-
-
- {% endfor %} -
-
- {{ partial('partials/pager_ajax') }} -{% endif %} \ No newline at end of file diff --git a/app/Http/Web/Views/im_group/active_users.volt b/app/Http/Web/Views/im/group/active_users.volt similarity index 100% rename from app/Http/Web/Views/im_group/active_users.volt rename to app/Http/Web/Views/im/group/active_users.volt diff --git a/app/Http/Web/Views/im_group/list.volt b/app/Http/Web/Views/im/group/list.volt similarity index 69% rename from app/Http/Web/Views/im_group/list.volt rename to app/Http/Web/Views/im/group/list.volt index e10b53a5..80eeabc2 100644 --- a/app/Http/Web/Views/im_group/list.volt +++ b/app/Http/Web/Views/im/group/list.volt @@ -2,7 +2,7 @@ {% block content %} - {% set pager_url = url({'for':'web.im_group.pager'}) %} + {% set pager_url = url({'for':'web.group.pager'}) %}