- Add company module (3-tier org, CEO planning, parallel departments) - Add company orchestrator, knowledge extractor, presets, scheduler - Add company API endpoints, models, and frontend views - Add 今天吃啥 PWA app (69 dishes, real images, offline support) - Add team_projects output directory structure - Add unified manage.ps1 for service lifecycle - Add Windows startup guide v1.0 - Add TTS troubleshooting doc - Update frontend (AgentChat UX overhaul, new views) - Update backend (voice engine fix, multi-tenant, RBAC) - Remove deprecated startup scripts and old docs Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
39 lines
1.7 KiB
Python
39 lines
1.7 KiB
Python
"""
|
|
公司知识库模型 — 从项目执行结果自动沉淀的结构化知识
|
|
"""
|
|
from sqlalchemy import Column, String, Text, JSON, DateTime, ForeignKey, func
|
|
from sqlalchemy.dialects.mysql import CHAR
|
|
from app.core.database import Base
|
|
import uuid
|
|
|
|
|
|
class CompanyKnowledge(Base):
|
|
"""公司知识库表"""
|
|
__tablename__ = "company_knowledge"
|
|
|
|
id = Column(CHAR(36), primary_key=True, default=lambda: str(uuid.uuid4()), comment="知识ID")
|
|
company_id = Column(CHAR(36), ForeignKey("companies.id"), nullable=False, comment="所属公司ID")
|
|
project_id = Column(CHAR(36), ForeignKey("company_projects.id"), nullable=True, comment="来源项目ID")
|
|
title = Column(String(300), nullable=False, comment="知识标题")
|
|
content = Column(Text, nullable=False, comment="知识内容(Markdown)")
|
|
category = Column(String(50), nullable=False, default="general", comment="分类: ceo_plan/dept_output/review/insight/general")
|
|
tags = Column(JSON, nullable=True, comment="标签列表")
|
|
source_dept = Column(String(200), nullable=True, comment="来源部门名称")
|
|
created_at = Column(DateTime, default=func.now(), comment="创建时间")
|
|
|
|
def __repr__(self):
|
|
return f"<CompanyKnowledge(id={self.id}, title={self.title})>"
|
|
|
|
def to_dict(self):
|
|
return {
|
|
"id": self.id,
|
|
"company_id": self.company_id,
|
|
"project_id": self.project_id,
|
|
"title": self.title,
|
|
"content": self.content,
|
|
"category": self.category,
|
|
"tags": self.tags,
|
|
"source_dept": self.source_dept,
|
|
"created_at": self.created_at.isoformat() if self.created_at else None,
|
|
}
|