tfse-admin-api-v0.2/Manage/Company/CompanyObj.py

250 lines
9.3 KiB
Python
Raw Normal View History

2022-04-13 17:04:07 +08:00
from Utils.ObjUtil import SpecObject
2022-04-18 17:04:44 +08:00
from Utils.ValidateUtil import ValidateAttr, Validate
2022-04-13 17:04:07 +08:00
2022-04-18 11:12:47 +08:00
class SearchCompanyApi(SpecObject):
"""企业查询请求接口"""
2022-04-13 17:04:07 +08:00
class SearchBody(SpecObject):
""""""
cid = ValidateAttr(field='cid', type=str)
name = ValidateAttr(field='name', type=str)
industry = ValidateAttr(field='industry', type=str)
2022-04-14 13:47:48 +08:00
credit_level = ValidateAttr(field='credit_level', type=list, in_list=["AAA", "AA+", "AA", "AA-", "A+", "A", "A-", "BBB+", "BBB", "BBB-", "BB+", "BB", "BB-", "B+", "B", "B-", "CCC+", "CCC", "CCC-", "CC+", "CC", "CC-", "C+", "C", "C-"])
esg_level = ValidateAttr(field='esg_level', type=list, in_list=["A", "B", "C", "D", "E"])
2022-04-13 17:04:07 +08:00
fields_map = {
"cid": "企业ID",
"name": "企业名称",
"industry": "一级行业",
"credit_level": "综信评价",
"esg_level": "ESG评价"
}
def make_search_body(self):
""""""
search_keys = list(self.__dict__.keys())
body = dict()
if "cid" in search_keys:
body['企业ID'] = self.cid
if "name" in search_keys:
body['企业名称'] = {"$regex": self.name}
if "industry" in search_keys:
body['一级行业'] = {"$in": self.industry}
if "credit_level" in search_keys:
body['综信评价结果.信用等级'] = {"$in": self.credit_level}
if "esg_level" in search_keys:
body['ESG评价结果.评价等级'] = {"$in": self.esg_level}
return body
class SortBody(SpecObject):
""""""
2022-04-14 03:12:36 +08:00
field = ValidateAttr(field='field', type=str)
sort = ValidateAttr(field='sort', in_list=["asc", "desc"])
fields_map = {
"field": "排序字段",
"sort": "排序方式"
}
def make_sort_body(self):
""""""
if self.__dict__ != {}:
columns_map = {
"企业ID": "企业ID",
"企业名称": "企业名称",
"一级行业": "一级行业",
"信用等级": "综信评价结果.信用等级",
"ESG等级": "ESG评价结果.评价等级"
}
asc_or_desc = 1 if self.sort == "asc" else -1
sort_column = columns_map[self.field]
body = {sort_column: asc_or_desc}
else:
body = {"更新时间.工商信息": -1}
return body
2022-04-13 17:04:07 +08:00
search = ValidateAttr(field='search', type=SearchBody)
2022-04-14 03:12:36 +08:00
sort = ValidateAttr(field='sort', type=SortBody)
2022-04-13 17:04:07 +08:00
page_size = ValidateAttr(field='page_size', type=int)
page_no = ValidateAttr(field='page_no', type=int)
fields_map = {
"search": "搜索体",
"sort": "排序",
"page_size": "显示数量",
"page_no": "页码"
}
2022-04-14 03:12:36 +08:00
def condition_search(self):
"""条件查询"""
2022-04-13 17:04:07 +08:00
class SearchCompanyResult(SpecObject):
2022-04-18 11:12:47 +08:00
"""企业查询返回结果"""
2022-04-14 03:12:36 +08:00
cid = ValidateAttr(field='cid', type=str)
name = ValidateAttr(field='name', type=str, default=None)
industry = ValidateAttr(field='industry', type=str, default=None)
credit_level = ValidateAttr(field='credit_level', type=str, default=None)
esg_level = ValidateAttr(field='esg_level', type=str, default=None)
2022-04-13 17:04:07 +08:00
fields_map = {
"cid": "企业ID",
"name": "企业名称",
"industry": "一级行业",
2022-04-14 03:12:36 +08:00
"credit_level": "信用等级",
"esg_level": "ESG等级"
2022-04-13 17:04:07 +08:00
}
2022-04-14 17:04:04 +08:00
2022-04-18 11:12:47 +08:00
class CompanyIndexApi(SpecObject):
"""企业主页接口"""
2022-04-14 17:04:04 +08:00
2022-04-18 11:12:47 +08:00
class HeadInfo(SpecObject):
"""头部信息"""
name = ValidateAttr(field='name', type=str)
cid = ValidateAttr(field='cid', type=str)
email = ValidateAttr(field='email', type=str)
industry = ValidateAttr(field='industry', type=str)
fields_map = {
"name": "企业名称",
"cid": "企业ID",
2022-04-18 11:19:15 +08:00
"email": "账户邮箱",
"industry": "所属行业",
2022-04-18 11:12:47 +08:00
}
2022-04-18 12:23:22 +08:00
class UpdateTime(SpecObject):
"""更新时间"""
table_map = {
"工商信息": "基本工商信息",
"经营风险": "经营风险分析",
"财务分析": "财务要素分析",
"综合信用分析": "综合信用分析",
"ESG评价分析": "ESG评价分析"
}
cid = ValidateAttr(field='cid', type=str, length=8)
table = ValidateAttr(field='table', type=str, in_list=list(table_map.keys()))
update_time = ValidateAttr(field='update_time', type=list)
fields_map = {
"cid": "企业ID",
"table": "table",
"update_time": "update_time"
}
2022-04-18 17:04:44 +08:00
class BasicInfo(SpecObject):
class BusinessInfo(SpecObject):
"""基本工商信息"""
status = ValidateAttr(field="status", type=str, default=None)
legal_person = ValidateAttr(field="legal_person", type=str, default=None)
company_type = ValidateAttr(field="company_type", type=str, default=None)
taxpayer_id = ValidateAttr(field="taxpayer_id", type=str, default=None)
business_scope = ValidateAttr(field="business_scope", type=str, default=None)
registered_capital = ValidateAttr(field="registered_capital", type=str, default=None)
paid_capital = ValidateAttr(field="paid_capital", type=str, default=None)
registered_address = ValidateAttr(field="registered_address", type=str, default=None)
registration_authority = ValidateAttr(field="registration_authority", type=str, default=None)
industry = ValidateAttr(field="industry", type=str, default=None)
staff_size = ValidateAttr(field="staff_size", type=str, default=None)
people_insured_num = ValidateAttr(field="people_insured_num", type=int, default=None)
micro_company = ValidateAttr(field="micro_company", type=str, in_list=["", ""], default=None)
fields_map = {
"status": "企业状态",
"legal_person": "法定代表人",
"company_type": "企业类型",
"taxpayer_id": "纳税人识别号",
"business_scope": "经营范围",
"registered_capital": "注册资本",
"paid_capital": "实缴资本",
"registered_address": "注册地址",
"registration_authority": "登记机关",
"industry": "行业",
"staff_size": "人员规模",
"people_insured_num": "参保人数",
"micro_company": "小微企业"
}
class ShareHolder(SpecObject):
"""股东信息"""
name = ValidateAttr(field='name', type=str)
share_holder_type = ValidateAttr(field='share_holder_type', type=str, default=None)
share_holding_ratio = ValidateAttr(field="share_holding_ratio", type=str, default=None)
subscription_amount = ValidateAttr(field="subscription_amount", type=str, default=None)
subscription_date = ValidateAttr(field="subscription_date", type=str, default=None)
paid_amount = ValidateAttr(field="paid_amount", type=list, default=[])
payment_method = ValidateAttr(field="payment_method", type=list, default=[])
payment_time = ValidateAttr(field="payment_time", type=list, default=[])
fields_map = {
"name": "股东",
"share_holder_type": "股东类型",
"share_holding_ratio": "持股比例",
"subscription_amount": "认缴金额",
"subscription_date": "认缴日期",
"paid_amount": "实缴金额",
"payment_method": "实缴方式",
"payment_time": "实缴时间"
}
class MainMember(SpecObject):
"""主要成员"""
name = ValidateAttr(field="name", type=str)
job_title = ValidateAttr(field="job_title", type=list, default=None)
fields_map = {
"name": "姓名",
"job_title": "职务"
}
cid = ValidateAttr(field='cid', type=str, length=8)
update_time = ValidateAttr(field='update_time', func=Validate.time_format)
business_info = ValidateAttr(field="business_info", type=BusinessInfo)
share_holder = ValidateAttr(field='share_holder', instance_list=ShareHolder)
main_member = ValidateAttr(field='main_member', instance_list=MainMember)
fields_map = {
"cid": "企业ID",
"update_time": "更新时间",
"business_info": "工商信息",
"share_holder": "股东信息",
"main_member": "主要成员"
}
2022-04-18 11:12:47 +08:00
def get_head_info(self):
"""头部信息"""
2022-04-18 12:23:22 +08:00
def get_update_time(self):
2022-04-18 11:12:47 +08:00
"""更新时间"""
def get_basic_info(self):
"""工商信息"""
def get_financial_data(self):
"""财务数据"""
def get_operating_risk(self):
"""经营风险"""
def get_financial_analysis(self):
"""财务分析"""
def get_cc_rating(self):
"""综合信用分析"""
def get_esg_rating(self):
"""ESG评价分析"""