Merge pull request 'add getAreaManager method' () from zhangwei into dev

Reviewed-on: 
This commit is contained in:
weiz 2023-10-07 09:48:14 +08:00
commit 5b475d66d0

@ -4,7 +4,6 @@ namespace app\common\controller;
use alioss\alioss;
use app\common\model\auth\Admin;
use app\common\model\auth\AdminRole;
use app\common\model\Company;
use app\common\model\im\UserImMessage;
use app\common\model\user\User;
@ -115,7 +114,7 @@ class ImController extends BaseLikeAdminController
'to_user_id' => $params['to_user_id'],
'content' => $params['content'],
'type' => $params['type'],
'is_read' => 0,
'is_read' => 1,
'is_undo' => 0,
'is_delete' => 0,
'create_time' => time(),
@ -209,7 +208,7 @@ class ImController extends BaseLikeAdminController
'to_user_id' => $params['to_user_id'],
'content' => $result['data'],
'type' => $params['type'],
'is_read' => 0,
'is_read' => 1,
'is_undo' => 0,
'is_delete' => 0,
'create_time' => time(),
@ -336,4 +335,32 @@ class ImController extends BaseLikeAdminController
//返回数据
return $this->success('请求成功',$users);
}
public function getAreaManager(): Json
{
//验证请求方式
if(!$this->request->isPost()){
return $this->fail('请求方式错误');
}
//获取请求参数
$params = $this->request->post(['user_id']);
if(empty($params['user_id'])){
return $this->fail('参数错误');
}
//获取其用户的公司id
$userInfo = User::field('id,company_id')->where('id',$params['user_id'])->findOrEmpty();
if(empty($userInfo)){
return $this->fail('未获取到用户信息');
}
//获取公司信息
$companyInfo = Company::field('area_manager')->where('id',$userInfo['company_id'])->findOrEmpty();
if(empty($companyInfo)){
return $this->fail('用户信息错误');
}
if($params['user_id'] == $companyInfo['area_manager']){
return $this->fail('用户身份错误错误');
}
//返回
return $this->success('请求成功',['to_user_id'=>$companyInfo['area_manager']]);
}
}