From e5d1042eef717bf861567df0278713e34713c4c9 Mon Sep 17 00:00:00 2001 From: wcq <744800102@qq.com> Date: Fri, 13 Oct 2023 17:00:07 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9B=86=E6=88=90=E9=82=AE=E4=BB=B6=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/wd-rating.iml | 6 ++-- context/common.py | 2 +- mods/rate/mods/data_collection/models.py | 39 +++++++++++++++++++++++ mods/rate/mods/data_collection/router.py | 16 ++++++++++ mods/rate/mods/data_collection/schemas.py | 12 +++++++ mods/system/router.py | 2 +- requirements.txt | 2 +- utils/file_collection_utils.py | 10 ++++++ 8 files changed, 84 insertions(+), 5 deletions(-) create mode 100644 mods/rate/mods/data_collection/models.py create mode 100644 mods/rate/mods/data_collection/router.py create mode 100644 mods/rate/mods/data_collection/schemas.py create mode 100644 utils/file_collection_utils.py diff --git a/.idea/wd-rating.iml b/.idea/wd-rating.iml index 326da4b..325eabf 100644 --- a/.idea/wd-rating.iml +++ b/.idea/wd-rating.iml @@ -1,8 +1,10 @@ - - + + + + diff --git a/context/common.py b/context/common.py index 27a33a7..f427ce9 100644 --- a/context/common.py +++ b/context/common.py @@ -26,7 +26,7 @@ conf = ConfigParser() start_model = "dev" if 'prod' in sys.argv: start_model = 'prod' -conf_file_path = Path(__file__).parent.parent / 'config' / f'common{"." + start_model if start_model else ""}.ini' +conf_file_path = Path(".") / 'config' / f'common{"." + start_model if start_model else ""}.ini' print("start_model", start_model) conf.read(conf_file_path, encoding='utf-8-sig') diff --git a/mods/rate/mods/data_collection/models.py b/mods/rate/mods/data_collection/models.py new file mode 100644 index 0000000..15968bc --- /dev/null +++ b/mods/rate/mods/data_collection/models.py @@ -0,0 +1,39 @@ +import uuid +from datetime import datetime +from typing import List + +from sqlalchemy import String, DateTime, func, Boolean, ForeignKey +from sqlalchemy.orm import Mapped, mapped_column, relationship +from utils.sqlalchemy_common_utils import SalBase +from ...common import Base + + +class UploadFileItem(Base, SalBase): + """ + 上传文件项 + """ + __tablename__ = "upload_file_item" + id: Mapped[str] = mapped_column(String(128), primary_key=True, default=lambda: uuid.uuid4().hex, comment='ID') + collection_id: Mapped[str] = mapped_column(String(255), + ForeignKey('data_collection.id', ondelete='CASCADE', onupdate='CASCADE')) + name: Mapped[str] = mapped_column(String(255), comment="收集名称") + uploaded: Mapped[bool] = mapped_column(Boolean, default=False, comment="上传状态") + upload_time: Mapped[datetime] = mapped_column(DateTime, nullable=True, + comment='上传时间') + org_file_path: Mapped[str] = mapped_column(String(255), comment="原始文件路径", nullable=True) + org_file_name: Mapped[str] = mapped_column(String(255), comment="原始文件名称", nullable=True) + upload_file_path: Mapped[str] = mapped_column(String(255), comment="上传文件路径", nullable=True) + upload_file_name: Mapped[str] = mapped_column(String(255), comment="上传文件名称", nullable=True) + + +class DataCollection(Base, SalBase): + """ + 数据收集表 + """ + __tablename__ = "data_collection" + id: Mapped[str] = mapped_column(String(128), primary_key=True, default=lambda: uuid.uuid4().hex, comment='ID') + url: Mapped[str] = mapped_column(String(255), unique=True, comment='收集链接') + passwd: Mapped[str] = mapped_column(String(255), comment='访问密码') + update_time: Mapped[datetime] = mapped_column(DateTime, server_default=func.now(), onupdate=func.now(), + comment='更新时间') + files: Mapped[List[UploadFileItem]] = relationship() diff --git a/mods/rate/mods/data_collection/router.py b/mods/rate/mods/data_collection/router.py new file mode 100644 index 0000000..6b3ea85 --- /dev/null +++ b/mods/rate/mods/data_collection/router.py @@ -0,0 +1,16 @@ +from fastapi import APIRouter +from . import schemas + +router = APIRouter(tags=["数据收集接口"], prefix='/data_collection') +need_files = [ + {"name": "资产负债表", "path": ""}, + {"name": "", "path": ""}, + {"name": "", "path": ""}, + {"name": "", "path": ""}, + {"name": "", "path": ""}, +] + + +@router.post('/create') +def data_collection_create(req: schemas.DataCollectionCreateReq): + pass diff --git a/mods/rate/mods/data_collection/schemas.py b/mods/rate/mods/data_collection/schemas.py new file mode 100644 index 0000000..148932d --- /dev/null +++ b/mods/rate/mods/data_collection/schemas.py @@ -0,0 +1,12 @@ +from enum import Enum + +from pydantic import BaseModel + + +# class FileNeedInfoItem(BaseModel): +# id: str +# name: str + + +class DataCollectionCreateReq(BaseModel): + rate_id: str diff --git a/mods/system/router.py b/mods/system/router.py index 0a475c9..5d4e2ad 100644 --- a/mods/system/router.py +++ b/mods/system/router.py @@ -12,7 +12,7 @@ router = APIRouter( def setting_get(): conf.read(conf_file_path, encoding='utf-8-sig') data = deepcopy(conf._sections) - data = {k: v for k, v in data.items() if k in ['rate_utils']} + # data = {k: v for k, v in data.items() if k in ['rate_utils']} return schemas.SettingGetRes(data=data) diff --git a/requirements.txt b/requirements.txt index 6be720b..1d3144d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,4 +13,4 @@ jurigged~=0.5.5 python-jose sqlalchemy_utils numpy~=1.25.2 -openpyxl +fastapi-mail \ No newline at end of file diff --git a/utils/file_collection_utils.py b/utils/file_collection_utils.py new file mode 100644 index 0000000..db6e40b --- /dev/null +++ b/utils/file_collection_utils.py @@ -0,0 +1,10 @@ +config = { + "url": "", + "passwd": "", + "files": [ + {"org_path": "", "name": "资产负债表", "upload_path": ""}, + {"org_path": "", "name": "利润表", "upload_path": ""}, + {"org_path": "", "name": "现金流量表", "upload_path": ""}, + {"org_path": "", "name": "经营情况表", "upload_path": ""}, + ] +}