| 123456789101112131415161718192021222324252627282930313233 |
- <?php namespace App\Servers\DB;
- use App\Models\Manager\CompanyDbConfig;
- use App\Models\OpenWork\Corp\AuthCorp;
- class DbService
- {
- /**
- * 切换企微数据库
- * @param string $corpId 企微ID
- *
- */
- public function getConnectionNameByCorpId($corpId)
- {
- //通过企微ID获取商户ID
- $companyId = (new AuthCorp)->getOneByCorpid($corpId,'company_id');
- // 切换商户数据库
- return $this->getConnectionNameByCompanyId($companyId);
- }
- /**
- * 切换商户数据库
- * @param int $companyId 商户ID
- *
- */
- public function getConnectionNameByCompanyId($companyId)
- {
- // 从数据库缓存获取
- return (new CompanyDbConfig)->reconnectDb($companyId); //商户数据库配置表
- }
- }
|