| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- <?php
- namespace App\Http\Controllers\Api\v1;
- use App\Http\Controllers\Api\webApp;
- use App\Services\Api\GroupService;
- use App\Services\Api\ImChatService;
- use App\Services\Api\MemberSettingService;
- use App\Services\Api\MessageService;
- /**
- * 群聊管理
- * @package App\Http\Controllers\Api
- */
- class GroupController extends webApp
- {
- /**
- * 我的群聊
- * @return array
- */
- public function index()
- {
- $params = request()->post();
- $pageSize = request()->post('pageSize', 12);
- $datas = GroupService::make()->getDataList($this->userId,$params,$pageSize);
- return showJson(1010, true, $datas);
- }
- /**
- * 聊天主页
- * @return array
- */
- public function create()
- {
- $params = request()->all();
- if(!$result = GroupService::make()->create($this->userId, $params)){
- return showJson(GroupService::make()->getError(), false);
- }else{
- return showJson(GroupService::make()->getError(), true, $result);
- }
- }
- /**
- * 群聊信息
- * @return array
- */
- public function info()
- {
- $id = request()->post('id',0);
- $info = GroupService::make()->getInfo($this->userId, $id);
- return showJson(1010, true, $info);
- }
- /**
- * 消息列表
- * @return array|mixed
- */
- public function history()
- {
- $params = request()->post();
- $pageSize = request()->post('pageSize', 20);
- $datas = MessageService::make()->getDataList($this->userId, $params, $pageSize);
- return showJson(1010, true, $datas);
- }
- /**
- * 修改消息设置参数
- * @return array
- */
- public function setting()
- {
- $params = request()->post();
- if(!$result = GroupService::make()->saveData($this->userId, $params)){
- return showJson(1020, false);
- }else{
- return showJson(1019, true);
- }
- }
- /**
- * 退出群聊
- * @return array
- */
- public function exitGroup()
- {
- $groupId = request()->post('group_id',0);
- if(!$result = GroupService::make()->exitGroup($this->userId, $groupId)){
- return showJson(1020, false);
- }else{
- return showJson(1019, true);
- }
- }
- /**
- * 踢出群成员
- * @return array
- */
- public function decUser()
- {
- $params = request()->post();
- if(!$result = GroupService::make()->decUser($this->userId, $params)){
- return showJson(GroupService::make()->getError(), false);
- }else{
- return showJson(GroupService::make()->getError(), true);
- }
- }
- /**
- * 添加群管理员
- * @return array
- */
- public function addManage()
- {
- $params = request()->post();
- if(!$result = GroupService::make()->addManage($this->userId, $params)){
- return showJson(GroupService::make()->getError(), false);
- }else{
- return showJson(GroupService::make()->getError(), true);
- }
- }
- /**
- * 删除群管理员
- * @return array
- */
- public function decManage()
- {
- $params = request()->post();
- if(!$result = GroupService::make()->decManage($this->userId, $params)){
- return showJson(GroupService::make()->getError(), false);
- }else{
- return showJson(GroupService::make()->getError(), true);
- }
- }
- /**
- * 邀请群成员
- * @return array
- */
- public function addUser()
- {
- $params = request()->post();
- if(!$result = GroupService::make()->addUser($this->userId, $params)){
- return showJson(GroupService::make()->getError(), false);
- }else{
- return showJson(GroupService::make()->getError(), true);
- }
- }
- /**
- * 邀请进群
- * @return array
- */
- public function invite()
- {
- $groupId = request()->post('group_id',0);
- if(!$result = GroupService::make()->invite($this->userId, $groupId)){
- return showJson(GroupService::make()->getError(), false);
- }else{
- return showJson(GroupService::make()->getError(), true);
- }
- }
- /**
- * 聊天清除消息历史
- * @return array
- */
- public function clear()
- {
- $groupId = request()->post('group_id',0);
- if(!$result = GroupService::make()->clear($this->userId, $groupId)){
- return showJson(1003, false);
- }else{
- return showJson(1002, true);
- }
- }
- public function delete()
- {
- $groupId = request()->post('group_id',0);
- if(!$result = GroupService::make()->deleteGroup($this->userId, $groupId)){
- return showJson(1003, false);
- }else{
- return showJson(1002, true);
- }
- }
- }
|