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(() => { + @@ -210,6 +214,9 @@ onMounted(() => { + + +