获取fdesk对应的用户id
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace app\controller;
|
||||
|
||||
use app\model\User;
|
||||
use app\model\UserSystemMapping;
|
||||
use Webman\Http\Request;
|
||||
use Webman\Http\Response;
|
||||
|
||||
@@ -130,4 +131,36 @@ class UserController extends BaseController
|
||||
'page_size' => $pageSize,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户在指定系统的映射ID
|
||||
*/
|
||||
public function systemMapping(Request $request): Response
|
||||
{
|
||||
$userId = $this->getUserId($request);
|
||||
$systemCode = $request->get('system', 'fdesk');
|
||||
|
||||
// 获取用户信息以获取公司ID
|
||||
$user = User::find($userId);
|
||||
if (!$user) {
|
||||
return $this->error('用户不存在');
|
||||
}
|
||||
|
||||
// 查询系统映射
|
||||
$mapping = UserSystemMapping::active()
|
||||
->bySystem($systemCode)
|
||||
->where('user_id', $userId)
|
||||
->where('company_id', $user->company_id)
|
||||
->first();
|
||||
|
||||
if (!$mapping) {
|
||||
return $this->error('未找到系统映射信息,请联系管理员配置');
|
||||
}
|
||||
|
||||
return $this->success([
|
||||
'system_code' => $mapping->system_code,
|
||||
'system_user_id' => $mapping->system_user_id,
|
||||
'system_user_name' => $mapping->system_user_name,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user