67 lines
3.0 KiB
Python
67 lines
3.0 KiB
Python
from sqlalchemy.orm import relationship
|
||
from context.common import common_db
|
||
from sqlalchemy import Column, Integer, String, ForeignKey, Text, DateTime, func, Date, Double
|
||
|
||
|
||
class CompanyRate(common_db.Base):
|
||
"""
|
||
公司评级数据表
|
||
"""
|
||
__tablename__ = "company_rate"
|
||
|
||
id = Column(Integer, primary_key=True, comment="id")
|
||
company_name = Column(String(255), comment="公司名称")
|
||
file_md = Column(String(255), comment="文件路径", nullable=True)
|
||
report_file_md = Column(String(255), comment="报告文件md", nullable=True)
|
||
file_data = Column(Text, comment="文件解析数据", nullable=True)
|
||
wj_data = Column(Text, comment="问卷解析后的数据", nullable=True)
|
||
file_data_state = Column(String(255), comment="文件解析数据状态", nullable=True) # 未解析,已解析
|
||
api_data = Column(Text, comment="接口数据", nullable=True)
|
||
api_data_state = Column(String(255), comment="接口数据状态", nullable=True) # 未导入、已导入
|
||
man_data = Column(Text, comment="手动填报数据", nullable=True)
|
||
man_data_state = Column(String(255), comment="手动填报数据状态", nullable=True)
|
||
mgr_data = Column(Text, comment="合并数据", nullable=True)
|
||
mgr_data_state = Column(Text, comment="合并数据校验状态", nullable=True) # 未就绪 已就绪
|
||
rate_time = Column(DateTime, comment="评级时间", nullable=True)
|
||
rate_data = Column(Text, comment="评级数据", nullable=True)
|
||
rate_state = Column(String(255), comment="评级状态", nullable=True) # 未评级,已评级,评级失败
|
||
rate_level = Column(String(255), comment="信誉级别", nullable=True)
|
||
rate_scope = Column(Double, comment="评级分数", nullable=True)
|
||
badge = Column(String(255), comment="奖牌", nullable=True) # 1,2,3
|
||
publish_state = Column(String(255), comment="披露状态", nullable=True) # 未披露,已披露
|
||
result_data = Column(Text, comment="结果展示数据", nullable=True)
|
||
create_time = Column(DateTime, comment="创建时间", server_default=func.now())
|
||
|
||
def to_dict(self):
|
||
data = {c.name: getattr(self, c.name) for c in self.__table__.columns}
|
||
return data
|
||
|
||
def to_lite_dict(self):
|
||
data = {c.name: getattr(self, c.name) for c in self.__table__.columns if c.name in [
|
||
"id", "company_name", "file_md", "file_data_state", "api_data_state", "man_data_state", "mgr_data_state",
|
||
"rate_time",
|
||
"rate_state",
|
||
"rate_level",
|
||
"rate_scope",
|
||
"badge",
|
||
"publish_state",
|
||
"result_data",
|
||
"create_time",
|
||
"report_file_md"
|
||
]}
|
||
return data
|
||
|
||
def to_rank_dict(self):
|
||
data = {c.name: getattr(self, c.name) for c in self.__table__.columns if c.name in [
|
||
"id",
|
||
"company_name",
|
||
"rate_time",
|
||
"rate_state",
|
||
"rate_level",
|
||
"rate_scope",
|
||
"badge",
|
||
"create_time",
|
||
"report_file_md"
|
||
]}
|
||
return data
|