diff --git a/Server/application/api/controller/AccountController.php b/Server/application/api/controller/AccountController.php index b8569a07..b0856f36 100644 --- a/Server/application/api/controller/AccountController.php +++ b/Server/application/api/controller/AccountController.php @@ -12,12 +12,16 @@ class AccountController extends BaseController * 获取公司账号列表 * @return \think\response\Json */ - public function getlist() + public function getlist($pageIndex = '',$pageSize = '',$isJob = false) { // 获取授权token - $authorization = trim($this->request->header('authorization', '')); + $authorization = trim($this->request->header('authorization', $this->authorization)); if (empty($authorization)) { - return errorJson('缺少授权信息'); + if($isJob){ + return json_encode(['code'=>500,'msg'=>'缺少授权信息']); + }else{ + return errorJson('缺少授权信息'); + } } try { @@ -26,8 +30,8 @@ class AccountController extends BaseController 'showNormalAccount' => $this->request->param('showNormalAccount', ''), 'keyword' => $this->request->param('keyword', ''), 'departmentId' => $this->request->param('companyId', ''), - 'pageIndex' => $this->request->param('pageIndex', 0), - 'pageSize' => $this->request->param('pageSize', 12) + 'pageIndex' => !empty($pageIndex) ? $pageIndex : $this->request->param('pageIndex', 0), + 'pageSize' => !empty($pageSize) ? $pageSize : $this->request->param('pageSize',20) ]; // 设置请求头 @@ -58,7 +62,7 @@ class AccountController extends BaseController public function createDepartment() { // 获取授权token - $authorization = trim($this->request->header('authorization', '')); + $authorization = trim($this->request->header('authorization', $this->authorization)); if (empty($authorization)) { return errorJson('缺少授权信息'); } @@ -112,7 +116,7 @@ class AccountController extends BaseController public function createAccount() { // 获取授权token - $authorization = trim($this->request->header('authorization', '')); + $authorization = trim($this->request->header('authorization', $this->authorization)); if (empty($authorization)) { return errorJson('缺少授权信息'); } @@ -194,7 +198,7 @@ class AccountController extends BaseController public function getDepartmentList() { // 获取授权token - $authorization = trim($this->request->header('authorization', '')); + $authorization = trim($this->request->header('authorization', $this->authorization)); if (empty($authorization)) { return errorJson('缺少授权信息'); } diff --git a/Server/application/api/controller/BaseController.php b/Server/application/api/controller/BaseController.php index 92383990..de73bfca 100644 --- a/Server/application/api/controller/BaseController.php +++ b/Server/application/api/controller/BaseController.php @@ -4,6 +4,7 @@ namespace app\api\controller; use think\Controller; use think\facade\Env; +use app\common\service\AuthService; class BaseController extends Controller { @@ -17,6 +18,8 @@ class BaseController extends Controller { protected $baseUrl; + protected $authorization = ''; + public function __construct() { parent::__construct(); $this->baseUrl = Env::get('api.wechat_url'); @@ -24,6 +27,10 @@ class BaseController extends Controller { header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Methods: *'); header('Access-Control-Allow-Headers: *'); + + $this->authorization = AuthService::getSystemAuthorization(); + + } diff --git a/Server/application/api/controller/DeviceController.php b/Server/application/api/controller/DeviceController.php index fa1d52d5..d0f92ed2 100644 --- a/Server/application/api/controller/DeviceController.php +++ b/Server/application/api/controller/DeviceController.php @@ -14,10 +14,10 @@ class DeviceController extends BaseController * 获取设备列表 * @return \think\response\Json */ - public function getlist($pageIndex = '',$pageSize = '',$authorization = '',$isJob = false) + public function getlist($pageIndex = '',$pageSize = '',$isJob = false) { // 获取授权token - $authorization = !empty($authorization) ? $authorization : trim($this->request->header('authorization', '')); + $authorization = trim($this->request->header('authorization', $this->authorization)); if (empty($authorization)) { if($isJob){ return json_encode(['code'=>500,'msg'=>'缺少授权信息']); @@ -146,7 +146,7 @@ class DeviceController extends BaseController public function addDevice($accountId = 0) { if (empty($accountId)) { - $accountId = $this->request->param('accountId', 5555); + $accountId = $this->request->param('accountId', ''); } if (empty($accountId)) { diff --git a/Server/application/api/controller/FriendTaskController.php b/Server/application/api/controller/FriendTaskController.php index c9fbdbf5..a1eebcb0 100644 --- a/Server/application/api/controller/FriendTaskController.php +++ b/Server/application/api/controller/FriendTaskController.php @@ -11,10 +11,10 @@ class FriendTaskController extends BaseController * 获取添加好友记录列表 * @return \think\response\Json */ - public function getlist($pageIndex,$pageSize,$authorization,$isJob = false) + public function getlist($pageIndex,$pageSize,$isJob = false) { // 获取授权token - $authorization = !empty($authorization) ? $authorization : trim($this->request->header('authorization', '')); + $authorization = trim($this->request->header('authorization', $this->authorization)); if (empty($authorization)) { if($isJob){ return json_encode(['code'=>500,'msg'=>'缺少授权信息']); @@ -68,7 +68,7 @@ class FriendTaskController extends BaseController public function addFriendTask() { // 获取授权token - $authorization = trim($this->request->header('authorization', '')); + $authorization = trim($this->request->header('authorization', $this->authorization)); if (empty($authorization)) { return errorJson('缺少授权信息'); } diff --git a/Server/application/api/controller/MessageController.php b/Server/application/api/controller/MessageController.php index b76e05f7..0f23a477 100644 --- a/Server/application/api/controller/MessageController.php +++ b/Server/application/api/controller/MessageController.php @@ -12,10 +12,10 @@ class MessageController extends BaseController * 获取微信好友列表 * @return \think\response\Json */ - public function getFriendsList($pageIndex = '',$pageSize = '',$authorization = '',$isJob = false) + public function getFriendsList($pageIndex = '',$pageSize = '',$isJob = false) { // 获取授权token - $authorization = !empty($authorization) ? $authorization : trim($this->request->header('authorization', '')); + $authorization = trim($this->request->header('authorization', $this->authorization)); if (empty($authorization)) { if($isJob){ return json_encode(['code'=>500,'msg'=>'缺少授权信息']); @@ -167,10 +167,10 @@ class MessageController extends BaseController * 获取微信群聊列表 * @return \think\response\Json */ - public function getChatroomList($pageIndex = '',$pageSize = '',$authorization = '',$isJob = false) + public function getChatroomList($pageIndex = '',$pageSize = '',$isJob = false) { // 获取授权token - $authorization = !empty($authorization) ? $authorization : trim($this->request->header('authorization', '')); + $authorization = trim($this->request->header('authorization', $this->authorization)); if (empty($authorization)) { if($isJob){ return json_encode(['code'=>500,'msg'=>'缺少授权信息']); @@ -363,7 +363,7 @@ class MessageController extends BaseController public function getMessageList() { // 获取授权token - $authorization = trim($this->request->header('authorization', '')); + $authorization = trim($this->request->header('authorization', $this->authorization)); if (empty($authorization)) { return errorJson('缺少授权信息'); } @@ -422,7 +422,7 @@ class MessageController extends BaseController public function getChatroomMessages() { // 获取授权token - $authorization = trim($this->request->header('authorization', '')); + $authorization = trim($this->request->header('authorization', $this->authorization)); if (empty($authorization)) { return errorJson('缺少授权信息'); } diff --git a/Server/application/api/controller/MomentsController.php b/Server/application/api/controller/MomentsController.php index 73d44dd9..2eb2ca89 100644 --- a/Server/application/api/controller/MomentsController.php +++ b/Server/application/api/controller/MomentsController.php @@ -13,7 +13,7 @@ class MomentsController extends BaseController public function addJob() { // 获取授权token - $authorization = trim($this->request->header('authorization', '')); + $authorization = trim($this->request->header('authorization', $this->authorization)); if (empty($authorization)) { return errorJson('缺少授权信息'); } @@ -107,7 +107,7 @@ class MomentsController extends BaseController public function getList() { // 获取授权token - $authorization = trim($this->request->header('authorization', '')); + $authorization = trim($this->request->header('authorization', $this->authorization)); if (empty($authorization)) { return errorJson('缺少授权信息'); } diff --git a/Server/application/api/controller/StatsController.php b/Server/application/api/controller/StatsController.php index 0b89a2a6..8ae0bb16 100644 --- a/Server/application/api/controller/StatsController.php +++ b/Server/application/api/controller/StatsController.php @@ -20,7 +20,7 @@ class StatsController extends BaseController */ public function basicData() { - $authorization = trim($this->request->header('authorization', '')); + $authorization = trim($this->request->header('authorization', $this->authorization)); if (empty($authorization)) { return errorJson('缺少授权信息'); } @@ -46,7 +46,7 @@ class StatsController extends BaseController from to 时间 当lidu为 0时(2025-03-12 09:54:42) 当lidu为 1时(2025-03-12) 当lidu为 2时(2025-03) */ - $authorization = trim($this->request->header('authorization', '')); + $authorization = trim($this->request->header('authorization', $this->authorization)); $lidu = trim($this->request->param('lidu', '')); $from = trim($this->request->param('from', '')); $to = trim($this->request->param('to', '')); diff --git a/Server/application/api/controller/UserController.php b/Server/application/api/controller/UserController.php index af558031..b36c9554 100644 --- a/Server/application/api/controller/UserController.php +++ b/Server/application/api/controller/UserController.php @@ -105,7 +105,7 @@ class UserController extends BaseController { $grant_type = $this->request->param('grant_type', 'refresh_token'); $refresh_token = $this->request->param('refresh_token', ''); - $authorization = $this->request->header('authorization', ''); + $authorization = $this->request->header('authorization', $this->authorization); if (empty($grant_type) || empty($authorization)) { return errorJson('参数错误'); @@ -144,7 +144,7 @@ class UserController extends BaseController */ public function getAccountInfo() { - $authorization = trim($this->request->header('authorization', '')); + $authorization = trim($this->request->header('authorization', $this->authorization)); if (empty($authorization)) { return errorJson('缺少授权信息'); } @@ -209,7 +209,7 @@ class UserController extends BaseController return $params; } - $authorization = trim($this->request->header('authorization', '')); + $authorization = trim($this->request->header('authorization', $this->authorization)); if (empty($authorization)) { return errorJson('缺少授权信息'); } @@ -244,7 +244,7 @@ class UserController extends BaseController */ public function logout() { - $authorization = trim($this->request->header('authorization', '')); + $authorization = trim($this->request->header('authorization', $this->authorization)); if (empty($authorization)) { return errorJson('缺少授权信息'); } diff --git a/Server/application/api/controller/WebSocketController.php b/Server/application/api/controller/WebSocketController.php index f04a43b6..e389c2a6 100644 --- a/Server/application/api/controller/WebSocketController.php +++ b/Server/application/api/controller/WebSocketController.php @@ -18,7 +18,7 @@ class WebSocketController extends BaseController public function __construct() { parent::__construct(); - $this->authorized = $this->request->header('authorized', ''); + $this->authorized = $this->request->header('authorization', $this->authorization); $this->accountId = $this->request->param('accountId', ''); if (empty($this->authorized) || empty($this->accountId)) { $data['authorized'] = $this->authorized; @@ -54,6 +54,109 @@ class WebSocketController extends BaseController } + /** + * 朋友圈点赞 + */ + public function momentInteract() + { + if ($this->request->isPost()) { + $data = $this->request->param(); + + if (empty($data)) { + $this->error('参数缺失'); + } + $dataArray = $data; + if (!is_array($dataArray)) { + $this->error('数据格式错误'); + } + + //过滤消息 + if (empty($dataArray['snsId'])) { + $this->error('snsId不能为空'); + } + if (empty($dataArray['wechatAccountId'])) { + $this->error('微信id不能为空'); + } + + + $result = [ + "cmdType" => "CmdMomentInteract", + "momentInteractType" => 1, + "seq" => time(), + "snsId" => $dataArray['snsId'], + "wechatAccountId" => $dataArray['wechatAccountId'], + "wechatFriendId" => 0, + ]; + + $result = json_encode($result); + $this->client->send($result); + $message = $this->client->receive(); + $message = json_decode($message, 1); + //关闭WS链接 + $this->client->close(); + //Log::write('WS个人消息发送'); + successJson($message, '点赞成功'); + } else { + errorJson('非法请求'); + } + } + + + /** + * 朋友圈取消点赞 + */ + public function momentCancelInteract() + { + if ($this->request->isPost()) { + $data = $this->request->param(); + + if (empty($data)) { + $this->error('参数缺失'); + } + $dataArray = $data; + if (!is_array($dataArray)) { + $this->error('数据格式错误'); + } + + //过滤消息 + if (empty($dataArray['snsId'])) { + $this->error('snsId不能为空'); + } + if (empty($dataArray['wechatAccountId'])) { + $this->error('微信id不能为空'); + } + + + $result = [ + "CommentId2" => '', + "CommentTime" => 0, + "cmdType" => "CmdMomentCancelInteract", + "optType" => 1, + "seq" => time(), + "snsId" => $dataArray['snsId'], + "wechatAccountId" => $dataArray['wechatAccountId'], + "wechatFriendId" => 0, + ]; + + $result = json_encode($result); + $this->client->send($result); + $message = $this->client->receive(); + $message = json_decode($message, 1); + //关闭WS链接 + $this->client->close(); + //Log::write('WS个人消息发送'); + successJson($message, '取消点赞成功'); + } else { + errorJson('非法请求'); + } + } + + + + + + + /** * 个人消息发送 */ diff --git a/Server/application/api/controller/WechatChatroomController.php b/Server/application/api/controller/WechatChatroomController.php index 0e9059e3..0faeb5b4 100644 --- a/Server/application/api/controller/WechatChatroomController.php +++ b/Server/application/api/controller/WechatChatroomController.php @@ -16,7 +16,7 @@ class WechatChatroomController extends BaseController public function getlist($pageIndex = '',$pageSize = '',$authorization = '',$isJob = false) { // 获取授权token - $authorization = !empty($authorization) ? $authorization : trim($this->request->header('authorization', '')); + $authorization = !empty($authorization) ? $authorization : trim($this->request->header('authorization', $this->authorization)); if (empty($authorization)) { if($isJob){ return json_encode(['code'=>500,'msg'=>'缺少授权信息']); @@ -123,7 +123,7 @@ class WechatChatroomController extends BaseController public function listChatroomMember($wechatChatroomId = '') { // 获取授权token - $authorization = trim($this->request->header('authorization', '')); + $authorization = trim($this->request->header('authorization', $this->authorization)); if (empty($authorization)) { return errorJson('缺少授权信息'); } diff --git a/Server/application/api/controller/WechatController.php b/Server/application/api/controller/WechatController.php index b14c50d6..e9230b72 100644 --- a/Server/application/api/controller/WechatController.php +++ b/Server/application/api/controller/WechatController.php @@ -59,10 +59,10 @@ class WechatController extends BaseController } } - public function getlist($pageIndex = '',$pageSize = '',$authorization = '',$isJob = false) + public function getlist($pageIndex = '',$pageSize = '',$isJob = false) { // 获取授权token - $authorization = !empty($authorization) ? $authorization : trim($this->request->header('authorization', '')); + $authorization = trim($this->request->header('authorization', $this->authorization)); if (empty($authorization)) { if($isJob){ return json_encode(['code'=>500,'msg'=>'缺少授权信息']); diff --git a/Server/application/api/controller/WechatFriendController.php b/Server/application/api/controller/WechatFriendController.php index cbdcd360..65d873fe 100644 --- a/Server/application/api/controller/WechatFriendController.php +++ b/Server/application/api/controller/WechatFriendController.php @@ -12,10 +12,10 @@ class WechatFriendController extends BaseController * 获取微信好友列表数据 * @return \think\response\Json */ - public function getlist($pageIndex = '',$pageSize = '',$preFriendId = '',$authorization = '',$isJob = false) + public function getlist($pageIndex = '',$pageSize = '',$preFriendId = '',$isJob = false) { // 获取授权token - $authorization = !empty($authorization) ? $authorization : trim($this->request->header('authorization', '')); + $authorization = trim($this->request->header('authorization', $this->authorization)); if (empty($authorization)) { if($isJob){ return json_encode(['code'=>500,'msg'=>'缺少授权信息']); diff --git a/Server/application/job/AccountListJob.php b/Server/application/job/AccountListJob.php index 6218418d..08f23142 100644 --- a/Server/application/job/AccountListJob.php +++ b/Server/application/job/AccountListJob.php @@ -7,7 +7,6 @@ use think\facade\Log; use think\Queue; use think\facade\Config; use app\api\controller\AccountController; -use app\common\service\AuthService; class AccountListJob { @@ -73,15 +72,8 @@ class AccountListJob $request = request(); $request->withGet($params); - // 获取系统授权信息 - $authorization = AuthService::getSystemAuthorization(); - if (empty($authorization)) { - Log::error('获取系统授权信息失败'); - return false; - } - // 调用公司账号列表获取方法 - $result = $accountController->getlist($pageIndex,$pageSize,$authorization); + $result = $accountController->getlist($pageIndex,$pageSize,true); $response = json_decode($result,true); diff --git a/Server/application/job/DeviceListJob.php b/Server/application/job/DeviceListJob.php index 9e383b8a..d9c3a41b 100644 --- a/Server/application/job/DeviceListJob.php +++ b/Server/application/job/DeviceListJob.php @@ -7,7 +7,6 @@ use think\facade\Log; use think\Queue; use think\facade\Config; use app\api\controller\DeviceController; -use app\common\service\AuthService; class DeviceListJob { @@ -73,15 +72,10 @@ class DeviceListJob $request = request(); $request->withGet($params); - // 获取系统授权信息 - $authorization = AuthService::getSystemAuthorization(); - if (empty($authorization)) { - Log::error('获取系统授权信息失败'); - return false; - } + // 调用设备列表获取方法 - $result = $deviceController->getlist($pageIndex,$pageSize,$authorization,true); + $result = $deviceController->getlist($pageIndex,$pageSize,true); $response = json_decode($result,true); diff --git a/Server/application/job/FriendTaskJob.php b/Server/application/job/FriendTaskJob.php index 6ad03f40..9e217412 100644 --- a/Server/application/job/FriendTaskJob.php +++ b/Server/application/job/FriendTaskJob.php @@ -7,7 +7,6 @@ use think\facade\Log; use think\Queue; use think\facade\Config; use app\api\controller\FriendTaskController; -use app\common\service\AuthService; class FriendTaskJob { @@ -72,16 +71,9 @@ class FriendTaskJob // 设置请求信息 $request = request(); $request->withGet($params); - - // 获取系统授权信息 - $authorization = AuthService::getSystemAuthorization(); - if (empty($authorization)) { - Log::error('获取系统授权信息失败'); - return false; - } // 调用添加好友任务获取方法 - $result = $friendTaskController->getlist($pageIndex,$pageSize,$authorization,true); + $result = $friendTaskController->getlist($pageIndex,$pageSize,true); $response = json_decode($result,true); diff --git a/Server/application/job/MessageChatroomListJob.php b/Server/application/job/MessageChatroomListJob.php index 6e6c4c1a..e3db929d 100644 --- a/Server/application/job/MessageChatroomListJob.php +++ b/Server/application/job/MessageChatroomListJob.php @@ -7,7 +7,6 @@ use think\facade\Log; use think\Queue; use think\facade\Config; use app\api\controller\MessageController; -use app\common\service\AuthService; class MessageChatroomListJob { @@ -73,15 +72,8 @@ class MessageChatroomListJob $request = request(); $request->withGet($params); - // 获取系统授权信息 - $authorization = AuthService::getSystemAuthorization(); - if (empty($authorization)) { - Log::error('获取系统授权信息失败'); - return false; - } - // 调用添加好友任务获取方法 - $result = $messageController->getChatroomList($pageIndex,$pageSize,$authorization,true); + $result = $messageController->getChatroomList($pageIndex,$pageSize,true); $response = json_decode($result,true); diff --git a/Server/application/job/MessageFriendsListJob.php b/Server/application/job/MessageFriendsListJob.php index 185d0d92..9d125eb9 100644 --- a/Server/application/job/MessageFriendsListJob.php +++ b/Server/application/job/MessageFriendsListJob.php @@ -7,7 +7,6 @@ use think\facade\Log; use think\Queue; use think\facade\Config; use app\api\controller\MessageController; -use app\common\service\AuthService; class MessageFriendsListJob { @@ -73,16 +72,10 @@ class MessageFriendsListJob $request = request(); $request->withGet($params); - // 获取系统授权信息 - $authorization = AuthService::getSystemAuthorization(); - if (empty($authorization)) { - Log::error('获取系统授权信息失败'); - return false; - } // 调用添加好友任务获取方法 - $result = $messageController->getFriendsList($pageIndex,$pageSize,$authorization,true); + $result = $messageController->getFriendsList($pageIndex,$pageSize,true); $response = json_decode($result,true); diff --git a/Server/application/job/WechatChatroomJob.php b/Server/application/job/WechatChatroomJob.php index ec20bf8a..30421ada 100644 --- a/Server/application/job/WechatChatroomJob.php +++ b/Server/application/job/WechatChatroomJob.php @@ -7,7 +7,6 @@ use think\facade\Log; use think\Queue; use think\facade\Config; use app\api\controller\WechatChatroomController; -use app\common\service\AuthService; class WechatChatroomJob { @@ -73,15 +72,8 @@ class WechatChatroomJob $request = request(); $request->withGet($params); - // 获取系统授权信息 - $authorization = AuthService::getSystemAuthorization(); - if (empty($authorization)) { - Log::error('获取系统授权信息失败'); - return false; - } - // 调用设备列表获取方法 - $result = $wechatChatroomController->getlist($pageIndex,$pageSize,$authorization,true); + $result = $wechatChatroomController->getlist($pageIndex,$pageSize,true); $response = json_decode($result,true); diff --git a/Server/application/job/WechatFriendJob.php b/Server/application/job/WechatFriendJob.php index a427f862..4224e59a 100644 --- a/Server/application/job/WechatFriendJob.php +++ b/Server/application/job/WechatFriendJob.php @@ -7,7 +7,6 @@ use think\facade\Log; use think\Queue; use think\facade\Config; use app\api\controller\WechatFriendController; -use app\common\service\AuthService; class WechatFriendJob { @@ -75,15 +74,9 @@ class WechatFriendJob $request = request(); $request->withGet($params); - // 获取系统授权信息 - $authorization = AuthService::getSystemAuthorization(); - if (empty($authorization)) { - Log::error('获取系统授权信息失败'); - return false; - } // 调用设备列表获取方法 - $result = $wechatFriendController->getlist($pageIndex,$pageSize,$preFriendId,$authorization,true); + $result = $wechatFriendController->getlist($pageIndex,$pageSize,$preFriendId,true); $response = json_decode($result,true); diff --git a/Server/application/job/WechatListJob.php b/Server/application/job/WechatListJob.php index 9e137b2e..14adf21f 100644 --- a/Server/application/job/WechatListJob.php +++ b/Server/application/job/WechatListJob.php @@ -7,7 +7,6 @@ use think\facade\Log; use think\Queue; use think\facade\Config; use app\api\controller\WechatController; -use app\common\service\AuthService; class WechatListJob { @@ -73,15 +72,9 @@ class WechatListJob $request = request(); $request->withGet($params); - // 获取系统授权信息 - $authorization = AuthService::getSystemAuthorization(); - if (empty($authorization)) { - Log::error('获取系统授权信息失败'); - return false; - } // 调用设备列表获取方法 - $result = $wechatController->getlist($pageIndex,$pageSize,$authorization,true); + $result = $wechatController->getlist($pageIndex,$pageSize,true); $response = json_decode($result,true);