mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-07-02 07:04:56 +08:00
去除了im里面的查找,后台增加im配置项,缓存归类
This commit is contained in:
parent
9f5b48c307
commit
e40e3d9faf
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
|
@ -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();
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
{% block content %}
|
||||
|
||||
<form class="layui-form kg-form" method="POST" action="{{ url({'for':'admin.im_group.create'}) }}">
|
||||
<form class="layui-form kg-form" method="POST" action="{{ url({'for':'admin.group.create'}) }}">
|
||||
<fieldset class="layui-elem-field layui-field-title">
|
||||
<legend>添加群组</legend>
|
||||
</fieldset>
|
||||
@ -23,6 +23,7 @@
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="type" value="course" title="课程" disabled="disabled">
|
||||
<input type="radio" name="type" value="chat" title="聊天" checked="checked">
|
||||
<input type="radio" name="type" value="staff" title="员工">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
@ -2,7 +2,7 @@
|
||||
|
||||
{% block content %}
|
||||
|
||||
<form class="layui-form kg-form" method="POST" action="{{ url({'for':'admin.im_group.update','id':group.id}) }}">
|
||||
<form class="layui-form kg-form" method="POST" action="{{ url({'for':'admin.group.update','id':group.id}) }}">
|
||||
<fieldset class="layui-elem-field layui-field-title">
|
||||
<legend>编辑群组</legend>
|
||||
</fieldset>
|
@ -47,10 +47,10 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
{% 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}) %}
|
||||
<tr>
|
||||
<td>{{ item.id }}</td>
|
||||
<td>{{ item.name }} {{ type_info(item.type) }}</td>
|
@ -2,7 +2,7 @@
|
||||
|
||||
{% block content %}
|
||||
|
||||
<form class="layui-form kg-form" method="GET" action="{{ url({'for':'admin.im_group.list'}) }}">
|
||||
<form class="layui-form kg-form" method="GET" action="{{ url({'for':'admin.group.list'}) }}">
|
||||
<fieldset class="layui-elem-field layui-field-title">
|
||||
<legend>搜索群组</legend>
|
||||
</fieldset>
|
42
app/Http/Admin/Views/setting/im.volt
Normal file
42
app/Http/Admin/Views/setting/im.volt
Normal file
@ -0,0 +1,42 @@
|
||||
{% extends 'templates/main.volt' %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<form class="layui-form kg-form" method="POST" action="{{ url({'for':'admin.setting.im'}) }}">
|
||||
<fieldset class="layui-elem-field layui-field-title">
|
||||
<legend>微聊配置</legend>
|
||||
</fieldset>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">应用名称</label>
|
||||
<div class="layui-input-block">
|
||||
<input class="layui-input" type="text" name="title" value="{{ im.title }}" layui-verify="required">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">客服1用户编号</label>
|
||||
<div class="layui-input-block">
|
||||
<input class="layui-input" type="text" name="cs_user1_id" value="{{ im.cs_user1_id }}" layui-verify="required">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">客服2用户编号</label>
|
||||
<div class="layui-input-block">
|
||||
<input class="layui-input" type="text" name="cs_user2_id" value="{{ im.cs_user2_id }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">客服3用户编号</label>
|
||||
<div class="layui-input-block">
|
||||
<input class="layui-input" type="text" name="cs_user3_id" value="{{ im.cs_user3_id }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"></label>
|
||||
<div class="layui-input-block">
|
||||
<button class="layui-btn" lay-submit="true" lay-filter="go">提交</button>
|
||||
<button type="button" class="kg-back layui-btn layui-btn-primary">返回</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
{% endblock %}
|
@ -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;"' : '' %}
|
||||
|
||||
<form class="layui-form kg-form" method="POST" action="{{ url({'for':'admin.setting.site'}) }}">
|
||||
<fieldset class="layui-elem-field layui-field-title">
|
||||
@ -11,8 +11,8 @@
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">站点状态</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="status" value="normal" title="正常" lay-filter="status" {% if site.status == "normal" %}checked{% endif %}>
|
||||
<input type="radio" name="status" value="closed" title="关闭" lay-filter="status" {% if site.status == "closed" %}checked{% endif %}>
|
||||
<input type="radio" name="enabled" value="1" title="正常" lay-filter="status" {% if site.enabled == 1 %}checked{% endif %}>
|
||||
<input type="radio" name="enabled" value="0" title="关闭" lay-filter="status" {% if site.enabled == 0 %}checked{% endif %}>
|
||||
</div>
|
||||
</div>
|
||||
<div id="closed-tips-block" {{ closed_tips_display }}>
|
||||
@ -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();
|
||||
|
@ -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']],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -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")
|
||||
*/
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -1,35 +0,0 @@
|
||||
{% extends 'templates/layer.volt' %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<div class="im-search-wrap">
|
||||
<form class="layui-form im-search-form" method="get" action="{{ url({'for':'web.im.search'}) }}">
|
||||
<input class="layui-input" type="text" name="query" placeholder="请输入关键字...">
|
||||
<button class="layui-hide" type="submit" lay-submit="true" lay-filter="im_search">搜索</button>
|
||||
</form>
|
||||
<div class="im-search-tab">
|
||||
<div class="layui-tab layui-tab-brief user-tab">
|
||||
<ul class="layui-tab-title">
|
||||
<li class="layui-this">成员</li>
|
||||
<li>群组</li>
|
||||
</ul>
|
||||
<div class="layui-tab-content">
|
||||
<div class="layui-tab-item layui-show" id="tab-users">
|
||||
{{ partial('im/find_users',{'pager':user_pager}) }}
|
||||
</div>
|
||||
<div class="layui-tab-item" id="tab-groups">
|
||||
{{ partial('im/find_groups',{'pager':group_pager}) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block include_js %}
|
||||
|
||||
{{ js_include('web/js/im.find.js') }}
|
||||
{{ js_include('web/js/im.apply.js') }}
|
||||
|
||||
{% endblock %}
|
@ -1,27 +0,0 @@
|
||||
{% if pager.total_pages > 0 %}
|
||||
<div class="im-user-list clearfix">
|
||||
<div class="layui-row layui-col-space20">
|
||||
{% for item in pager.items %}
|
||||
<div class="layui-col-md2">
|
||||
<div class="user-card">
|
||||
{% if item.type == 'course' %}
|
||||
<span class="layui-badge layui-bg-green type">课</span>
|
||||
{% elseif item.type == 'chat' %}
|
||||
<span class="layui-badge layui-bg-blue type">聊</span>
|
||||
{% endif %}
|
||||
<div class="avatar">
|
||||
<a href="javascript:">
|
||||
<img src="{{ item.avatar }}" alt="{{ item.name }}" title="{{ item.about }}">
|
||||
</a>
|
||||
</div>
|
||||
<div class="name layui-elip" title="{{ item.name }}">{{ item.name }}</div>
|
||||
<div class="action">
|
||||
<span class="layui-badge-rim apply-group" data-id="{{ item.id }}" data-name="{{ item.name }}" data-avatar="{{ item.avatar }}">申请加入</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{{ partial('partials/pager_ajax') }}
|
||||
{% endif %}
|
@ -1,23 +0,0 @@
|
||||
{% if pager.total_pages > 0 %}
|
||||
<div class="im-user-list clearfix">
|
||||
<div class="layui-row layui-col-space20">
|
||||
{% for item in pager.items %}
|
||||
<div class="layui-col-md2">
|
||||
<div class="user-card">
|
||||
{% if item.vip == 1 %}
|
||||
<span class="layui-badge layui-bg-orange vip">VIP</span>
|
||||
{% endif %}
|
||||
<div class="avatar">
|
||||
<a href="javascript:" title="{{ item.about|e }}"><img src="{{ item.avatar }}" alt="{{ item.name }}"></a>
|
||||
</div>
|
||||
<div class="name layui-elip" title="{{ item.name|e }}">{{ item.name }}</div>
|
||||
<div class="action">
|
||||
<span class="layui-badge-rim apply-friend" data-id="{{ item.id }}" data-name="{{ item.name }}" data-avatar="{{ item.avatar }}">申请好友</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{{ partial('partials/pager_ajax') }}
|
||||
{% endif %}
|
@ -2,7 +2,7 @@
|
||||
|
||||
{% block content %}
|
||||
|
||||
{% set pager_url = url({'for':'web.im_group.pager'}) %}
|
||||
{% set pager_url = url({'for':'web.group.pager'}) %}
|
||||
|
||||
<div class="layui-breadcrumb breadcrumb">
|
||||
<a href="/">首页</a>
|
||||
@ -15,6 +15,6 @@
|
||||
|
||||
{% block include_js %}
|
||||
|
||||
{{ js_include('web/js/im_group.list.js') }}
|
||||
{{ js_include('web/js/im.group.list.js') }}
|
||||
|
||||
{% endblock %}
|
@ -2,7 +2,7 @@
|
||||
|
||||
{% block content %}
|
||||
|
||||
{% set update_url = url({'for':'web.im_group.update','id':group.id}) %}
|
||||
{% set update_url = url({'for':'web.group.update','id':group.id}) %}
|
||||
{% set name_readonly = group.type == 'course' ? 'readonly="readonly"' : '' %}
|
||||
|
||||
<form class="layui-form" method="post" action="{{ update_url }}">
|
@ -6,7 +6,7 @@
|
||||
<div class="im-user-list clearfix">
|
||||
<div class="layui-row layui-col-space20">
|
||||
{% for item in pager.items %}
|
||||
{% set delete_url = url({'for':'web.im_group.delete_user','gid':group.id,'uid':item.id}) %}
|
||||
{% set delete_url = url({'for':'web.igm.delete_user','gid':group.id,'uid':item.id}) %}
|
||||
<div class="layui-col-md2">
|
||||
<div class="user-card">
|
||||
{% if item.vip == 1 %}
|
@ -1,8 +1,8 @@
|
||||
{% if pager.total_pages > 0 %}
|
||||
<div class="im-group-list clearfix">
|
||||
<div class="group-list clearfix">
|
||||
<div class="layui-row layui-col-space20">
|
||||
{% for item in pager.items %}
|
||||
{% set group_url = url({'for':'web.im_group.show','id':item.id}) %}
|
||||
{% set group_url = url({'for':'web.group.show','id':item.id}) %}
|
||||
{% set owner_url = url({'for':'web.user.show','id':item.owner.id}) %}
|
||||
{% set item.about = item.about ? item.about : '这家伙真懒,什么都没留下!' %}
|
||||
<div class="layui-col-md3">
|
@ -4,13 +4,13 @@
|
||||
|
||||
{% set group.about = group.about ? group.about : '这个家伙真懒,什么都没有留下~' %}
|
||||
{% set apply_group_url = '' %}
|
||||
{% set users_url = url({'for':'web.im_group.users','id':group.id}) %}
|
||||
{% set active_users_url = url({'for':'web.im_group.active_users','id':group.id}) %}
|
||||
{% set users_url = url({'for':'web.group.users','id':group.id}) %}
|
||||
{% set active_users_url = url({'for':'web.group.active_users','id':group.id}) %}
|
||||
|
||||
<div class="breadcrumb">
|
||||
<span class="layui-breadcrumb">
|
||||
<a href="/">首页</a>
|
||||
<a href="{{ url({'for':'web.im_group.list'}) }}">群组</a>
|
||||
<a href="{{ url({'for':'web.group.list'}) }}">群组</a>
|
||||
<a><cite>{{ group.name }}</cite></a>
|
||||
</span>
|
||||
</div>
|
||||
@ -31,7 +31,7 @@
|
||||
</div>
|
||||
<div class="layout-sidebar">
|
||||
<div class="sidebar">
|
||||
{{ partial('im_group/show_owner') }}
|
||||
{{ partial('im/group/show_owner') }}
|
||||
</div>
|
||||
<div class="sidebar wrap">
|
||||
<button class="layui-btn layui-btn-fluid apply-group" data-id="{{ group.id }}" data-name="{{ group.name }}" data-avatar="{{ group.avatar }}">加入群组</button>
|
||||
@ -44,7 +44,7 @@
|
||||
|
||||
{% block include_js %}
|
||||
|
||||
{{ js_include('web/js/im_group.show.js') }}
|
||||
{{ js_include('web/js/im.group.show.js') }}
|
||||
{{ js_include('web/js/im.apply.js') }}
|
||||
|
||||
{% endblock %}
|
@ -25,9 +25,9 @@
|
||||
</div>
|
||||
<div class="my-group-wrap wrap">
|
||||
{% if type == 'owned' %}
|
||||
{{ partial('my/im_groups_owned') }}
|
||||
{{ partial('my/groups_owned') }}
|
||||
{% else %}
|
||||
{{ partial('my/im_groups_joined') }}
|
||||
{{ partial('my/groups_joined') }}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
@ -40,8 +40,8 @@
|
||||
<div class="layui-card-header">聊天设置</div>
|
||||
<div class="layui-card-body">
|
||||
<ul class="my-menu">
|
||||
<li><a href="{{ url({'for':'web.my.im_friends'}) }}">我的好友</a></li>
|
||||
<li><a href="{{ url({'for':'web.my.im_groups'}) }}">我的群组</a></li>
|
||||
<li><a href="{{ url({'for':'web.my.friends'}) }}">我的好友</a></li>
|
||||
<li><a href="{{ url({'for':'web.my.groups'}) }}">我的群组</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -6,15 +6,15 @@
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="copyright">
|
||||
{% if site.copyright %}
|
||||
<span>© {{ site.copyright }}</span>
|
||||
{% if site_info.copyright %}
|
||||
<span>© {{ site_info.copyright }}</span>
|
||||
{% endif %}
|
||||
<a href="{{ app_info.link }}" title="{{ app_info.name }}">Powered by {{ app_info.alias }} {{ app_info.version }}</a>
|
||||
{% if site.icp_sn %}
|
||||
<a href="{{ site.icp_link }}">{{ site.icp_sn }}</a>
|
||||
{% if site_info.icp_sn %}
|
||||
<a href="{{ site_info.icp_link }}">{{ site_info.icp_sn }}</a>
|
||||
{% endif %}
|
||||
{% if site.police_sn %}
|
||||
<a href="{{ site.police_link }}">{{ site.police_sn }}</a>
|
||||
{% if site_info.police_sn %}
|
||||
<a href="{{ site_info.police_link }}">{{ site_info.police_sn }}</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -9,7 +9,11 @@
|
||||
vip: '{{ auth_user.vip }}'
|
||||
},
|
||||
im: {
|
||||
socket_url: '{{ im.socket_url }}'
|
||||
title: '',
|
||||
cs_user1_id: '',
|
||||
cs_user2_id: '',
|
||||
cs_user3_id: '',
|
||||
socket_url: ''
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<div class="search-group-list">
|
||||
{% for item in pager.items %}
|
||||
{% set group_url = url({'for':'web.im_group.show','id':item.id}) %}
|
||||
{% set owner_url = url({'for':'web.user.show','id':item.onwer.id}) %}
|
||||
{% set group_url = url({'for':'web.group.show','id':item.id}) %}
|
||||
{% set owner_url = url({'for':'web.user.show','id':item.owner.id}) %}
|
||||
{% set item.about = item.about ? item.about : '这个家伙真懒,什么也没有留下!' %}
|
||||
<div class="search-group-card clearfix">
|
||||
<div class="avatar">
|
||||
|
@ -29,15 +29,15 @@
|
||||
{{ js_include('lib/layui/layui.js') }}
|
||||
{{ js_include('web/js/common.js') }}
|
||||
|
||||
{% if router.getActionName() != 'im' %}
|
||||
{% if router.getControllerName() != 'im' %}
|
||||
{{ js_include('web/js/fixbar.js') }}
|
||||
{% endif %}
|
||||
|
||||
{% block include_js %}{% endblock %}
|
||||
{% block inline_js %}{% endblock %}
|
||||
|
||||
{% if site.analytics %}
|
||||
{{ site.analytics }}
|
||||
{% if site_info.analytics %}
|
||||
{{ site_info.analytics }}
|
||||
{% endif %}
|
||||
|
||||
</body>
|
||||
|
@ -2,7 +2,7 @@
|
||||
<div class="user-list clearfix">
|
||||
<div class="layui-row layui-col-space20">
|
||||
{% for item in pager.items %}
|
||||
{% set group_url = url({'for':'web.im_group.show','id':item.id}) %}
|
||||
{% set group_url = url({'for':'web.group.show','id':item.id}) %}
|
||||
{% set item.about = item.about ? item.about : '这家伙真懒,什么都没留下!' %}
|
||||
<div class="layui-col-md3">
|
||||
<div class="user-card">
|
||||
|
@ -244,6 +244,8 @@ class Course extends Model
|
||||
{
|
||||
parent::initialize();
|
||||
|
||||
$this->keepSnapshots(true);
|
||||
|
||||
$this->addBehavior(
|
||||
new SoftDelete([
|
||||
'field' => 'deleted',
|
||||
@ -290,10 +292,9 @@ class Course extends Model
|
||||
|
||||
public function beforeUpdate()
|
||||
{
|
||||
$this->update_time = time();
|
||||
|
||||
if ($this->deleted == 1) {
|
||||
$this->published = 0;
|
||||
if (time() - $this->update_time > 3 * 3600) {
|
||||
$syncer = new CourseIndexSyncer();
|
||||
$syncer->addItem($this->id);
|
||||
}
|
||||
|
||||
if (Text::startsWith($this->cover, 'http')) {
|
||||
@ -303,6 +304,12 @@ class Course extends Model
|
||||
if (is_array($this->attrs)) {
|
||||
$this->attrs = kg_json_encode($this->attrs);
|
||||
}
|
||||
|
||||
if ($this->deleted == 1) {
|
||||
$this->published = 0;
|
||||
}
|
||||
|
||||
$this->update_time = time();
|
||||
}
|
||||
|
||||
public function afterCreate()
|
||||
@ -314,9 +321,13 @@ class Course extends Model
|
||||
|
||||
public function afterUpdate()
|
||||
{
|
||||
$syncer = new CourseIndexSyncer();
|
||||
|
||||
$syncer->addItem($this->id);
|
||||
/**
|
||||
* 课程标题和群组名称保持一致
|
||||
*/
|
||||
if ($this->hasUpdated('title')) {
|
||||
$imGroup = ImGroup::findFirst(['course_id' => $this->id]);
|
||||
$imGroup->update(['name' => $this->title]);
|
||||
}
|
||||
}
|
||||
|
||||
public function afterFetch()
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Services\Syncer\GroupIndex as GroupIndexSyncer;
|
||||
use Phalcon\Mvc\Model\Behavior\SoftDelete;
|
||||
use Phalcon\Text;
|
||||
|
||||
@ -13,6 +14,7 @@ class ImGroup extends Model
|
||||
*/
|
||||
const TYPE_COURSE = 'course'; // 课程
|
||||
const TYPE_CHAT = 'chat'; // 聊天
|
||||
const TYPE_STAFF = 'staff'; // 员工
|
||||
|
||||
/**
|
||||
* 主键编号
|
||||
@ -135,15 +137,20 @@ class ImGroup extends Model
|
||||
|
||||
public function beforeUpdate()
|
||||
{
|
||||
$this->update_time = time();
|
||||
|
||||
if ($this->deleted == 1) {
|
||||
$this->published = 0;
|
||||
if (time() - $this->update_time > 3 * 3600) {
|
||||
$syncer = new GroupIndexSyncer();
|
||||
$syncer->addItem($this->id);
|
||||
}
|
||||
|
||||
if (Text::startsWith($this->avatar, 'http')) {
|
||||
$this->avatar = self::getAvatarPath($this->avatar);
|
||||
}
|
||||
|
||||
if ($this->deleted == 1) {
|
||||
$this->published = 0;
|
||||
}
|
||||
|
||||
$this->update_time = time();
|
||||
}
|
||||
|
||||
public function afterFetch()
|
||||
@ -167,6 +174,7 @@ class ImGroup extends Model
|
||||
return [
|
||||
self::TYPE_COURSE => '课程',
|
||||
self::TYPE_CHAT => '聊天',
|
||||
self::TYPE_STAFF => '员工',
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -158,10 +158,12 @@ class Order extends Model
|
||||
|
||||
public function beforeCreate()
|
||||
{
|
||||
$this->status = self::STATUS_PENDING;
|
||||
$this->sn = date('YmdHis') . rand(1000, 9999);
|
||||
$this->create_time = time();
|
||||
|
||||
$this->status = self::STATUS_PENDING;
|
||||
|
||||
$this->sn = date('YmdHis') . rand(1000, 9999);
|
||||
|
||||
if (is_array($this->item_info)) {
|
||||
$this->item_info = kg_json_encode($this->item_info);
|
||||
} else {
|
||||
@ -211,8 +213,8 @@ class Order extends Model
|
||||
public static function clientTypes()
|
||||
{
|
||||
return [
|
||||
self::CLIENT_DESKTOP => 'desktop',
|
||||
self::CLIENT_MOBILE => 'mobile',
|
||||
self::CLIENT_PC => 'pc',
|
||||
self::CLIENT_H5 => 'h5',
|
||||
self::CLIENT_APP => 'app',
|
||||
self::CLIENT_MINI => 'mini',
|
||||
];
|
||||
|
@ -126,9 +126,11 @@ class Trade extends Model
|
||||
|
||||
public function beforeCreate()
|
||||
{
|
||||
$this->status = self::STATUS_PENDING;
|
||||
$this->sn = date('YmdHis') . rand(1000, 9999);
|
||||
$this->create_time = time();
|
||||
|
||||
$this->status = self::STATUS_PENDING;
|
||||
|
||||
$this->sn = date('YmdHis') . rand(1000, 9999);
|
||||
}
|
||||
|
||||
public function beforeUpdate()
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Caches\MaxUserId as MaxUserIdCache;
|
||||
use App\Services\Syncer\UserIndex as UserIndexSyncer;
|
||||
use Phalcon\Mvc\Model\Behavior\SoftDelete;
|
||||
use Phalcon\Text;
|
||||
|
||||
@ -164,6 +165,8 @@ class User extends Model
|
||||
{
|
||||
parent::initialize();
|
||||
|
||||
$this->keepSnapshots(true);
|
||||
|
||||
$this->addBehavior(
|
||||
new SoftDelete([
|
||||
'field' => 'deleted',
|
||||
@ -185,11 +188,16 @@ class User extends Model
|
||||
|
||||
public function beforeUpdate()
|
||||
{
|
||||
$this->update_time = time();
|
||||
if (time() - $this->update_time > 3 * 3600) {
|
||||
$syncer = new UserIndexSyncer();
|
||||
$syncer->addItem($this->id);
|
||||
}
|
||||
|
||||
if (Text::startsWith($this->avatar, 'http')) {
|
||||
$this->avatar = self::getAvatarPath($this->avatar);
|
||||
}
|
||||
|
||||
$this->update_time = time();
|
||||
}
|
||||
|
||||
public function afterCreate()
|
||||
@ -201,12 +209,13 @@ class User extends Model
|
||||
|
||||
public function afterUpdate()
|
||||
{
|
||||
$imUser = ImUser::findFirst($this->id);
|
||||
|
||||
$imUser->update([
|
||||
'name' => $this->name,
|
||||
'avatar' => $this->avatar,
|
||||
]);
|
||||
if ($this->hasUpdated('name') || $this->hasUpdated('avatar')) {
|
||||
$imUser = ImUser::findFirst($this->id);
|
||||
$imUser->update([
|
||||
'name' => $this->name,
|
||||
'avatar' => $this->avatar,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function afterFetch()
|
||||
|
@ -120,12 +120,15 @@ class MyStorage extends Storage
|
||||
|
||||
if ($uploadFile == false) {
|
||||
|
||||
$name = $this->filter->sanitize($file->getName(), ['trim', 'string']);
|
||||
|
||||
$extension = $this->getFileExtension($file->getName());
|
||||
$keyName = $this->generateFileName($extension, $prefix);
|
||||
$path = $this->putFile($keyName, $file->getTempName());
|
||||
|
||||
$uploadFile = new UploadFileModel();
|
||||
|
||||
$uploadFile->name = $name;
|
||||
$uploadFile->mime = $file->getRealType();
|
||||
$uploadFile->size = $file->getSize();
|
||||
$uploadFile->path = $path;
|
||||
|
@ -41,7 +41,7 @@ class CourseIndex extends Service
|
||||
|
||||
public function getSyncKey()
|
||||
{
|
||||
return 'course_index_sync';
|
||||
return 'sync:course_index';
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ class GroupIndex extends Service
|
||||
|
||||
public function getSyncKey()
|
||||
{
|
||||
return 'group_index_sync';
|
||||
return 'sync:group_index';
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ class Learning extends Service
|
||||
|
||||
public function getSyncKey()
|
||||
{
|
||||
return 'learning_sync';
|
||||
return 'sync:learning';
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ class UserIndex extends Service
|
||||
|
||||
public function getSyncKey()
|
||||
{
|
||||
return 'user_index_sync';
|
||||
return 'sync:user_index';
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -73,7 +73,6 @@
|
||||
}
|
||||
|
||||
.pager {
|
||||
margin-top: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
@ -1371,7 +1370,11 @@ body {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.im-group-list .user-card {
|
||||
.group-list {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.group-list .user-card {
|
||||
height: 250px;
|
||||
}
|
||||
|
||||
@ -1602,24 +1605,6 @@ body {
|
||||
width: 10%;
|
||||
}
|
||||
|
||||
.im-manage-wrap {
|
||||
padding: 20px 20px 10px 20px;
|
||||
background-color: #f2f2f2;
|
||||
}
|
||||
|
||||
.im-search-wrap {
|
||||
padding: 20px;
|
||||
background-color: #f2f2f2;
|
||||
}
|
||||
|
||||
.im-search-form {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.im-search-tab .layui-tab-content {
|
||||
min-height: 300px;
|
||||
}
|
||||
|
||||
.im-user-list .user-card {
|
||||
height: 150px;
|
||||
font-size: 12px;
|
||||
@ -1650,20 +1635,6 @@ body {
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
.im-user-list .type {
|
||||
top: 10px;
|
||||
right: 10px;
|
||||
padding: 0 3px;
|
||||
}
|
||||
|
||||
.im-user-list .action .layui-badge-rim {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.im-user-list .layui-btn + .layui-btn {
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
.layim-msgbox {
|
||||
margin: 15px;
|
||||
}
|
||||
|
75
public/static/web/js/im.cs.js
Normal file
75
public/static/web/js/im.cs.js
Normal file
@ -0,0 +1,75 @@
|
||||
layui.use(['jquery', 'layim'], function () {
|
||||
|
||||
var $ = layui.jquery;
|
||||
var layim = layui.layim;
|
||||
var socket = new WebSocket(window.koogua.im.socket_url);
|
||||
|
||||
socket.onopen = function () {
|
||||
console.log('socket connect success');
|
||||
};
|
||||
|
||||
socket.onclose = function () {
|
||||
console.log('socket connect close');
|
||||
};
|
||||
|
||||
socket.onerror = function () {
|
||||
console.log('socket connect error');
|
||||
};
|
||||
|
||||
socket.onmessage = function (e) {
|
||||
var data = JSON.parse(e.data);
|
||||
console.log(data);
|
||||
if (data.type === 'ping') {
|
||||
socket.send('pong...');
|
||||
} else if (data.type === 'bind_user') {
|
||||
bindUser(data);
|
||||
} else if (data.type === 'show_chat_msg') {
|
||||
showChatMessage(data);
|
||||
}
|
||||
};
|
||||
|
||||
layim.config({
|
||||
brief: true,
|
||||
init: {
|
||||
mine: {
|
||||
id: "100000123",
|
||||
username: "访客",
|
||||
avatar: "//res.layui.com/images/fly/avatar/00.jpg",
|
||||
status: "online",
|
||||
}
|
||||
},
|
||||
maxLength: 1000,
|
||||
});
|
||||
|
||||
layim.chat({
|
||||
type: 'friend',
|
||||
id: 1111111,
|
||||
name: '在线客服一',
|
||||
avatar: '//tp1.sinaimg.cn/5619439268/180/40030060651/1',
|
||||
});
|
||||
|
||||
layim.on('sendMessage', function (res) {
|
||||
sendChatMessage(res);
|
||||
});
|
||||
|
||||
function bindUser(res) {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/im/user/bind',
|
||||
data: {client_id: res.client_id}
|
||||
});
|
||||
}
|
||||
|
||||
function sendChatMessage(res) {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/im/msg/send',
|
||||
data: {from: res.mine, to: res.to}
|
||||
});
|
||||
}
|
||||
|
||||
function showChatMessage(res) {
|
||||
layim.getMessage(res.message);
|
||||
}
|
||||
|
||||
});
|
@ -1,14 +0,0 @@
|
||||
layui.use(['form', 'helper'], function () {
|
||||
|
||||
var form = layui.form;
|
||||
var helper = layui.helper;
|
||||
|
||||
form.on('submit(im_search)', function (data) {
|
||||
var usersUrl = '/im/search?target=tab-users&type=user&query=' + data.field.query;
|
||||
var groupsUrl = '/im/search?target=tab-groups&type=group&query=' + data.field.query;
|
||||
helper.ajaxLoadHtml(usersUrl, 'tab-users');
|
||||
helper.ajaxLoadHtml(groupsUrl, 'tab-groups');
|
||||
return false;
|
||||
});
|
||||
|
||||
});
|
@ -2,7 +2,7 @@ layui.use(['jquery', 'layim'], function () {
|
||||
|
||||
var $ = layui.jquery;
|
||||
var layim = layui.layim;
|
||||
var socket = new WebSocket(window.koogua.socketUrl);
|
||||
var socket = new WebSocket(window.koogua.im.socket_url);
|
||||
|
||||
socket.onopen = function () {
|
||||
console.log('socket connect success');
|
||||
@ -23,7 +23,7 @@ layui.use(['jquery', 'layim'], function () {
|
||||
socket.send('pong...');
|
||||
} else if (data.type === 'bind_user') {
|
||||
bindUser(data);
|
||||
refreshMsgBox();
|
||||
refreshMessageBox();
|
||||
} else if (data.type === 'new_group_user') {
|
||||
showNewGroupUserMessage(data);
|
||||
} else if (data.type === 'show_online_tips') {
|
||||
@ -32,13 +32,13 @@ layui.use(['jquery', 'layim'], function () {
|
||||
setChatMessageCount(data);
|
||||
showChatMessage(data);
|
||||
} else if (data.type === 'refresh_msg_box') {
|
||||
refreshMsgBox();
|
||||
refreshMessageBox();
|
||||
} else if (data.type === 'friend_accepted') {
|
||||
friendAccepted(data);
|
||||
refreshMsgBox();
|
||||
refreshMessageBox();
|
||||
} else if (data.type === 'group_accepted') {
|
||||
groupAccepted(data);
|
||||
refreshMsgBox();
|
||||
refreshMessageBox();
|
||||
}
|
||||
};
|
||||
|
||||
@ -50,14 +50,7 @@ layui.use(['jquery', 'layim'], function () {
|
||||
members: {
|
||||
url: '/im/group/users'
|
||||
},
|
||||
uploadImage: {
|
||||
url: '/upload/im/image'
|
||||
},
|
||||
uploadFile: {
|
||||
url: '/upload/im/file'
|
||||
},
|
||||
maxLength: 1000,
|
||||
find: '/im/find',
|
||||
msgbox: '/im/msgbox',
|
||||
chatLog: '/im/chatlog'
|
||||
});
|
||||
@ -193,10 +186,10 @@ layui.use(['jquery', 'layim'], function () {
|
||||
});
|
||||
}
|
||||
|
||||
function refreshMsgBox() {
|
||||
function refreshMessageBox() {
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '/im/sys/msg/unread',
|
||||
url: '/im/notice/unread',
|
||||
success: function (res) {
|
||||
if (res.count > 0) {
|
||||
layim.msgbox(res.count);
|
||||
|
@ -36,13 +36,13 @@ layui.use(['jquery', 'layer', 'laypage'], function () {
|
||||
}
|
||||
|
||||
function loadPageHtml(target, page) {
|
||||
$.get('/im/sys/msg', {page: page}, function (html) {
|
||||
$.get('/im/notice', {page: page}, function (html) {
|
||||
target.html(html);
|
||||
});
|
||||
}
|
||||
|
||||
function readNotices() {
|
||||
$.post('/im/sys/msg/read');
|
||||
$.post('/im/notice/read');
|
||||
}
|
||||
|
||||
var action = {
|
||||
|
4
public/static/web/js/im.robot.js
Normal file
4
public/static/web/js/im.robot.js
Normal file
@ -0,0 +1,4 @@
|
||||
layui.use(['jquery', 'layim'], function () {
|
||||
|
||||
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user