From 8d67bc76ecc52d56573e75b2edb79eb532f2510d Mon Sep 17 00:00:00 2001 From: zk Date: Fri, 24 Jul 2026 18:27:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0ORM=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/__init__.py | 0 app/models/company.py | 36 ++++++++++++++++++++ app/models/recruit_announcement.py | 36 ++++++++++++++++++++ app/models/recruit_announcement_batch.py | 19 +++++++++++ app/models/recruit_announcement_category.py | 19 +++++++++++ app/models/recruit_announcement_city.py | 19 +++++++++++ app/models/recruit_announcement_education.py | 19 +++++++++++ app/models/recruit_announcement_tag.py | 19 +++++++++++ app/models/recruit_announcement_year.py | 19 +++++++++++ 9 files changed, 186 insertions(+) create mode 100644 app/models/__init__.py create mode 100644 app/models/company.py create mode 100644 app/models/recruit_announcement.py create mode 100644 app/models/recruit_announcement_batch.py create mode 100644 app/models/recruit_announcement_category.py create mode 100644 app/models/recruit_announcement_city.py create mode 100644 app/models/recruit_announcement_education.py create mode 100644 app/models/recruit_announcement_tag.py create mode 100644 app/models/recruit_announcement_year.py diff --git a/app/models/__init__.py b/app/models/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/models/company.py b/app/models/company.py new file mode 100644 index 0000000..1a147f0 --- /dev/null +++ b/app/models/company.py @@ -0,0 +1,36 @@ +"""MySQL: bg_company 表模型""" + +from datetime import datetime +from typing import Optional + +from sqlalchemy import BigInteger, DateTime, Integer, JSON, String, Text +from sqlalchemy.orm import Mapped, mapped_column + +from app.core.database import MysqlBase + + +class Company(MysqlBase): + """公司表""" + + __tablename__ = "bg_company" + + id: Mapped[int] = mapped_column(BigInteger, primary_key=True, comment="主键ID(雪花)") + name: Mapped[Optional[str]] = mapped_column(String(255), comment="公司全称") + short_name: Mapped[str] = mapped_column(String(128), nullable=False, comment="公司简称") + logo_url: Mapped[Optional[str]] = mapped_column(String(512), comment="Logo地址") + region_code: Mapped[Optional[str]] = mapped_column(String(20), comment="地区编码") + company_type: Mapped[Optional[str]] = mapped_column(String(32), comment="企业类型:上市企业/独角兽/国企等") + industry_id: Mapped[Optional[int]] = mapped_column(BigInteger, comment="行业ID") + tags: Mapped[Optional[list]] = mapped_column(JSON, comment="公司标签JSON数组") + summary: Mapped[Optional[str]] = mapped_column(String(512), comment="一句话简介") + description: Mapped[Optional[str]] = mapped_column(Text, comment="公司详细描述") + founded_year: Mapped[Optional[str]] = mapped_column(String(10), comment="成立年份") + address: Mapped[Optional[str]] = mapped_column(String(255), comment="总部地址") + scale: Mapped[Optional[str]] = mapped_column(String(32), comment="企业规模") + website: Mapped[Optional[str]] = mapped_column(String(255), comment="官网地址") + financing_stage: Mapped[Optional[str]] = mapped_column(String(32), comment="融资状态") + latest_valuation: Mapped[Optional[str]] = mapped_column(String(64), comment="最新估值") + news: Mapped[Optional[list]] = mapped_column(JSON, comment="相关新闻JSON数组") + status: Mapped[int] = mapped_column(Integer, default=0, comment="0=待完善 1=已完善 2=禁用 3=补充中 4=补充失败") + create_time: Mapped[datetime] = mapped_column(DateTime, nullable=False, comment="创建时间") + update_time: Mapped[datetime] = mapped_column(DateTime, nullable=False, comment="更新时间") diff --git a/app/models/recruit_announcement.py b/app/models/recruit_announcement.py new file mode 100644 index 0000000..359b4df --- /dev/null +++ b/app/models/recruit_announcement.py @@ -0,0 +1,36 @@ +"""MySQL: bg_recruit_announcement 招聘公告主表模型""" + +from datetime import datetime +from typing import Optional + +from sqlalchemy import BigInteger, DateTime, String, Text +from sqlalchemy.orm import Mapped, mapped_column + +from app.core.database import MysqlBase + + +class RecruitAnnouncement(MysqlBase): + """招聘公告主表""" + + __tablename__ = "bg_recruit_announcement" + + id: Mapped[int] = mapped_column(BigInteger, primary_key=True, comment="主键ID(雪花)") + company_id: Mapped[Optional[int]] = mapped_column(BigInteger, comment="关联企业主表id") + company_name: Mapped[str] = mapped_column(String(128), nullable=False, default="", comment="公司名称") + title: Mapped[str] = mapped_column(String(255), nullable=False, default="", comment="公告标题") + company_intro: Mapped[Optional[str]] = mapped_column(Text, comment="公司简介") + target_audience: Mapped[Optional[str]] = mapped_column(String(500), comment="面向对象,如2027届本硕博") + major_require: Mapped[Optional[str]] = mapped_column(String(500), comment="专业要求") + remark: Mapped[Optional[str]] = mapped_column(String(1000), comment="备注") + written_exam: Mapped[Optional[str]] = mapped_column(String(16), comment="是否笔试:有 / 无 / 未明确") + apply_start_time: Mapped[Optional[datetime]] = mapped_column(DateTime, comment="投递开始时间") + apply_end_time: Mapped[Optional[datetime]] = mapped_column(DateTime, comment="投递结束时间") + apply_end_desc: Mapped[Optional[str]] = mapped_column(String(64), comment='投递截止描述,如"尽快投递"') + invite_code: Mapped[Optional[str]] = mapped_column(String(64), comment="专属内推码") + announcement_url: Mapped[Optional[str]] = mapped_column(String(512), comment="公告地址") + apply_url: Mapped[Optional[str]] = mapped_column(String(512), comment="投递地址") + apply_email: Mapped[Optional[str]] = mapped_column(String(128), comment="投递邮箱") + source: Mapped[Optional[str]] = mapped_column(String(255), comment="信息来源说明") + publish_time: Mapped[Optional[datetime]] = mapped_column(DateTime, comment="公告发布/更新时间") + create_time: Mapped[datetime] = mapped_column(DateTime, nullable=False, comment="创建时间") + update_time: Mapped[datetime] = mapped_column(DateTime, nullable=False, comment="更新时间") diff --git a/app/models/recruit_announcement_batch.py b/app/models/recruit_announcement_batch.py new file mode 100644 index 0000000..d2e1d24 --- /dev/null +++ b/app/models/recruit_announcement_batch.py @@ -0,0 +1,19 @@ +"""MySQL: bg_recruit_announcement_batch 招聘公告-批次关联表模型""" + +from datetime import datetime + +from sqlalchemy import BigInteger, DateTime, String +from sqlalchemy.orm import Mapped, mapped_column + +from app.core.database import MysqlBase + + +class RecruitAnnouncementBatch(MysqlBase): + """招聘公告-批次关联表""" + + __tablename__ = "bg_recruit_announcement_batch" + + id: Mapped[int] = mapped_column(BigInteger, primary_key=True, comment="主键ID(雪花)") + announcement_id: Mapped[int] = mapped_column(BigInteger, nullable=False, comment="公告id") + batch_name: Mapped[str] = mapped_column(String(64), nullable=False, comment="批次值,如实习/暑期实习/寒假实习/秋招专场/春招提前批/春招补招") + create_time: Mapped[datetime] = mapped_column(DateTime, nullable=False, comment="创建时间") diff --git a/app/models/recruit_announcement_category.py b/app/models/recruit_announcement_category.py new file mode 100644 index 0000000..8078b9b --- /dev/null +++ b/app/models/recruit_announcement_category.py @@ -0,0 +1,19 @@ +"""MySQL: bg_recruit_announcement_category 招聘公告-岗位大类关联表模型""" + +from datetime import datetime + +from sqlalchemy import BigInteger, DateTime, String +from sqlalchemy.orm import Mapped, mapped_column + +from app.core.database import MysqlBase + + +class RecruitAnnouncementCategory(MysqlBase): + """招聘公告-岗位大类关联表""" + + __tablename__ = "bg_recruit_announcement_category" + + id: Mapped[int] = mapped_column(BigInteger, primary_key=True, comment="主键ID(雪花)") + announcement_id: Mapped[int] = mapped_column(BigInteger, nullable=False, comment="公告id") + category_name: Mapped[str] = mapped_column(String(64), nullable=False, comment="岗位大类值,如IT技术/人工智能/通信") + create_time: Mapped[datetime] = mapped_column(DateTime, nullable=False, comment="创建时间") diff --git a/app/models/recruit_announcement_city.py b/app/models/recruit_announcement_city.py new file mode 100644 index 0000000..23730af --- /dev/null +++ b/app/models/recruit_announcement_city.py @@ -0,0 +1,19 @@ +"""MySQL: bg_recruit_announcement_city 招聘公告-热招城市关联表模型""" + +from datetime import datetime + +from sqlalchemy import BigInteger, DateTime, String +from sqlalchemy.orm import Mapped, mapped_column + +from app.core.database import MysqlBase + + +class RecruitAnnouncementCity(MysqlBase): + """招聘公告-热招城市关联表""" + + __tablename__ = "bg_recruit_announcement_city" + + id: Mapped[int] = mapped_column(BigInteger, primary_key=True, comment="主键ID(雪花)") + announcement_id: Mapped[int] = mapped_column(BigInteger, nullable=False, comment="公告id") + city_name: Mapped[str] = mapped_column(String(64), nullable=False, comment="城市值,如北京市/天津市") + create_time: Mapped[datetime] = mapped_column(DateTime, nullable=False, comment="创建时间") diff --git a/app/models/recruit_announcement_education.py b/app/models/recruit_announcement_education.py new file mode 100644 index 0000000..538711e --- /dev/null +++ b/app/models/recruit_announcement_education.py @@ -0,0 +1,19 @@ +"""MySQL: bg_recruit_announcement_education 招聘公告-学历要求关联表模型""" + +from datetime import datetime + +from sqlalchemy import BigInteger, DateTime, String +from sqlalchemy.orm import Mapped, mapped_column + +from app.core.database import MysqlBase + + +class RecruitAnnouncementEducation(MysqlBase): + """招聘公告-学历要求关联表""" + + __tablename__ = "bg_recruit_announcement_education" + + id: Mapped[int] = mapped_column(BigInteger, primary_key=True, comment="主键ID(雪花)") + announcement_id: Mapped[int] = mapped_column(BigInteger, nullable=False, comment="公告id") + education_name: Mapped[str] = mapped_column(String(32), nullable=False, comment="学历值,如本科/硕士/博士") + create_time: Mapped[datetime] = mapped_column(DateTime, nullable=False, comment="创建时间") diff --git a/app/models/recruit_announcement_tag.py b/app/models/recruit_announcement_tag.py new file mode 100644 index 0000000..61e1c97 --- /dev/null +++ b/app/models/recruit_announcement_tag.py @@ -0,0 +1,19 @@ +"""MySQL: bg_recruit_announcement_tag 招聘公告-标签组关联表模型""" + +from datetime import datetime + +from sqlalchemy import BigInteger, DateTime, String +from sqlalchemy.orm import Mapped, mapped_column + +from app.core.database import MysqlBase + + +class RecruitAnnouncementTag(MysqlBase): + """招聘公告-标签组关联表""" + + __tablename__ = "bg_recruit_announcement_tag" + + id: Mapped[int] = mapped_column(BigInteger, primary_key=True, comment="主键ID(雪花)") + announcement_id: Mapped[int] = mapped_column(BigInteger, nullable=False, comment="公告id") + tag_name: Mapped[str] = mapped_column(String(64), nullable=False, comment="标签值,如秋招提前批/竞争力薪酬/校招") + create_time: Mapped[datetime] = mapped_column(DateTime, nullable=False, comment="创建时间") diff --git a/app/models/recruit_announcement_year.py b/app/models/recruit_announcement_year.py new file mode 100644 index 0000000..72533e7 --- /dev/null +++ b/app/models/recruit_announcement_year.py @@ -0,0 +1,19 @@ +"""MySQL: bg_recruit_announcement_year 招聘公告-招聘届数关联表模型""" + +from datetime import datetime + +from sqlalchemy import BigInteger, DateTime, SmallInteger +from sqlalchemy.orm import Mapped, mapped_column + +from app.core.database import MysqlBase + + +class RecruitAnnouncementYear(MysqlBase): + """招聘公告-招聘届数关联表""" + + __tablename__ = "bg_recruit_announcement_year" + + id: Mapped[int] = mapped_column(BigInteger, primary_key=True, comment="主键ID(雪花)") + announcement_id: Mapped[int] = mapped_column(BigInteger, nullable=False, comment="公告id") + recruit_year: Mapped[int] = mapped_column(SmallInteger, nullable=False, comment="招聘届数,如2027") + create_time: Mapped[datetime] = mapped_column(DateTime, nullable=False, comment="创建时间")