Files
x-server-mobile/backend/app/Model/CompanyFeishuApp.php
T
root 1f6d346f6a feat: add multi-company Feishu integration and data migration
- Add companies table enhancements (abbr, tenant_key, feishu_enabled)
- Add users table enhancements (feishu fields, sn, report_to, etc.)
- Create company_feishu_apps table for multi-app per company
- Create user_sn_pool table for user number management
- Update FeishuService to support multiple Feishu apps per company
- Add data migration script (002_merge_old_data.sql)
- Add import script (scripts/import_old_data.php)
- Update User and Company models with new scopes and relationships
- Add CompanyFeishuApp model
- Add Git workflow documentation (GIT_WORKFLOW.md)

This supports:
- Multi-company architecture with Feishu integration
- Multiple Feishu apps per company (X-Server, Ticket, CRM)
- User number assignment system
- Data migration from old project

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 18:12:18 +08:00

92 lines
1.7 KiB
PHP

<?php
namespace App\Model;
use support\Model;
class CompanyFeishuApp extends Model
{
protected $table = 'company_feishu_apps';
protected $fillable = [
'company_id',
'system_id',
'name',
'tenant_key',
'app_id',
'app_secret',
'encrypt_key',
'verification_token',
'base_uri',
'callback_url',
'mobile_callback_url',
'scopes',
'state',
'sort',
'status',
];
protected $casts = [
'company_id' => 'integer',
'system_id' => 'integer',
'sort' => 'integer',
'status' => 'integer',
'created_at' => 'datetime',
'updated_at' => 'datetime',
];
protected $hidden = [
'app_secret',
'encrypt_key',
'verification_token',
];
/**
* 关联公司
*/
public function company()
{
return $this->belongsTo(Company::class, 'company_id');
}
/**
* 获取启用的应用
*/
public function scopeActive($query)
{
return $query->where('status', 1);
}
/**
* 根据系统ID查找
*/
public function scopeBySystemId($query, int $systemId)
{
return $query->where('system_id', $systemId);
}
/**
* 获取X-Server应用
*/
public function scopeXServer($query)
{
return $query->where('system_id', 1);
}
/**
* 获取工单应用
*/
public function scopeTicket($query)
{
return $query->where('system_id', 2);
}
/**
* 获取CRM应用
*/
public function scopeCrm($query)
{
return $query->where('system_id', 3);
}
}