diff --git a/backend/app/Model/Company.php b/backend/app/Model/Company.php index ba7f04d..5520b09 100644 --- a/backend/app/Model/Company.php +++ b/backend/app/Model/Company.php @@ -73,21 +73,24 @@ class Company extends Model } /** - * 获取飞书应用配置 + * 获取默认飞书应用配置 */ - public function feishuApps() + public function getDefaultFeishuApp(): ?array { - return $this->hasMany(CompanyFeishuApp::class, 'company_id'); + $sql = "SELECT * FROM company_feishu_apps WHERE company_id = ? AND system_id = 1 AND status = 1 ORDER BY sort ASC LIMIT 1"; + $stmt = \App\Util\Db::connection()->getPdo()->prepare($sql); + $stmt->execute([$this->id]); + return $stmt->fetch(PDO::FETCH_ASSOC); } /** - * 获取默认飞书应用(X-Server) + * 获取所有飞书应用配置 */ - public function getDefaultFeishuApp() + public function getFeishuApps(): array { - return $this->hasOne(CompanyFeishuApp::class, 'company_id') - ->where('system_id', 1) - ->where('status', 1) - ->orderBy('sort'); + $sql = "SELECT * FROM company_feishu_apps WHERE company_id = ? AND status = 1 ORDER BY sort"; + $stmt = \App\Util\Db::connection()->getPdo()->prepare($sql); + $stmt->execute([$this->id]); + return $stmt->fetchAll(PDO::FETCH_ASSOC); } }