From ab84f6b87d8fa867e243bc74f1672a930c1c7f6a Mon Sep 17 00:00:00 2001 From: 111 Date: Sat, 24 Jan 2026 10:20:02 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=81=E5=BE=AE=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E7=A7=9F=E6=88=B7=E4=B8=8B=E6=8B=89=E9=80=89=E6=8B=A9=20+=20co?= =?UTF-8?q?rp=5Fid=20=E8=87=AA=E5=8A=A8=E5=A1=AB=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 租户表增加 corp_id 字段(企业微信企业ID) - 租户管理页面支持配置 corp_id - 企微应用页面租户从下拉选择 - 选择租户后自动填入 corp_id 并禁用编辑 - 提示用户如租户未配置 corp_id 需先去配置 --- backend/app/models/tenant.py | 1 + backend/app/routers/tenants.py | 5 ++ .../src/views/tenant-wechat-apps/index.vue | 69 +++++++++++++++++-- frontend/src/views/tenants/index.vue | 7 ++ 4 files changed, 75 insertions(+), 7 deletions(-) diff --git a/backend/app/models/tenant.py b/backend/app/models/tenant.py index 1b2c03c..1a84620 100644 --- a/backend/app/models/tenant.py +++ b/backend/app/models/tenant.py @@ -11,6 +11,7 @@ class Tenant(Base): id = Column(BigInteger, primary_key=True, autoincrement=True) code = Column(String(50), unique=True, nullable=False) name = Column(String(100), nullable=False) + corp_id = Column(String(100)) # 企业微信企业ID contact_info = Column(JSON) status = Column(Enum('active', 'expired', 'trial'), default='active') expired_at = Column(Date) diff --git a/backend/app/routers/tenants.py b/backend/app/routers/tenants.py index 67c2cbc..48dcffc 100644 --- a/backend/app/routers/tenants.py +++ b/backend/app/routers/tenants.py @@ -20,6 +20,7 @@ router = APIRouter(prefix="/tenants", tags=["租户管理"]) class TenantCreate(BaseModel): code: str name: str + corp_id: Optional[str] = None # 企业微信企业ID contact_info: Optional[dict] = None status: str = "active" expired_at: Optional[date] = None @@ -27,6 +28,7 @@ class TenantCreate(BaseModel): class TenantUpdate(BaseModel): name: Optional[str] = None + corp_id: Optional[str] = None # 企业微信企业ID contact_info: Optional[dict] = None status: Optional[str] = None expired_at: Optional[date] = None @@ -81,6 +83,7 @@ async def list_tenants( "id": t.id, "code": t.code, "name": t.name, + "corp_id": t.corp_id, "contact_info": t.contact_info, "status": t.status, "expired_at": t.expired_at, @@ -120,6 +123,7 @@ async def get_tenant( "id": tenant.id, "code": tenant.code, "name": tenant.name, + "corp_id": tenant.corp_id, "contact_info": tenant.contact_info, "status": tenant.status, "expired_at": tenant.expired_at, @@ -159,6 +163,7 @@ async def create_tenant( tenant = Tenant( code=data.code, name=data.name, + corp_id=data.corp_id, contact_info=data.contact_info, status=data.status, expired_at=data.expired_at diff --git a/frontend/src/views/tenant-wechat-apps/index.vue b/frontend/src/views/tenant-wechat-apps/index.vue index a22fb36..27d36f7 100644 --- a/frontend/src/views/tenant-wechat-apps/index.vue +++ b/frontend/src/views/tenant-wechat-apps/index.vue @@ -1,5 +1,5 @@ @@ -208,14 +243,34 @@ onMounted(() => { - - + + + + - - + + +
+ 该租户未配置企业ID,请先到租户管理中配置 +
diff --git a/frontend/src/views/tenants/index.vue b/frontend/src/views/tenants/index.vue index eb7cb4e..5f08635 100644 --- a/frontend/src/views/tenants/index.vue +++ b/frontend/src/views/tenants/index.vue @@ -26,6 +26,7 @@ const formRef = ref(null) const form = reactive({ code: '', name: '', + corp_id: '', status: 'active', expired_at: null, contact_info: { @@ -69,6 +70,7 @@ function handleCreate() { Object.assign(form, { code: '', name: '', + corp_id: '', status: 'active', expired_at: null, contact_info: { contact: '', phone: '', email: '' } @@ -82,6 +84,7 @@ function handleEdit(row) { Object.assign(form, { code: row.code, name: row.name, + corp_id: row.corp_id || '', status: row.status, expired_at: row.expired_at, contact_info: row.contact_info || { contact: '', phone: '', email: '' } @@ -172,6 +175,7 @@ onMounted(() => { +