Skip to content

Commit

Permalink
feat(kz_dash): 数据库公用部分迁移
Browse files Browse the repository at this point in the history
  • Loading branch information
kingzeus committed Dec 21, 2024
1 parent b35ca6c commit a629e52
Show file tree
Hide file tree
Showing 26 changed files with 48 additions and 443 deletions.
18 changes: 16 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
from components.sidebar import create_sidebar
from config import APP_NAME, DEBUG, LOG_CONFIG, ROOT_DIR, SERVER_CONFIG, THEME_CONFIG
from data_source import init_data_source
from models.database import init_database
from kz_dash.models.database import init_database
from models.account import ModelAccount, ModelPortfolio
from models.fund import ModelFund, ModelFundNav
from models.fund_user import ModelFundPosition, ModelFundTransaction
from models.task import ModelTask
from pages.account import render_account_page
from pages.home import render_home_page
from pages.task import render_task_page
Expand Down Expand Up @@ -50,7 +54,17 @@ def init_application():
logger = init_log()

# 初始化数据库
init_database()
init_database(
[
ModelAccount,
ModelPortfolio,
ModelFundPosition,
ModelFundTransaction,
ModelFundNav,
ModelFund,
ModelTask,
]
)
logger.info("数据库初始化成功")

# 初始化数据源
Expand Down
4 changes: 1 addition & 3 deletions backend/api/account.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import uuid

from flask_restx import Namespace, Resource, fields

from kz_dash.backend.api.common import create_list_response_model, create_response_model
from models.account import ModelAccount, update_account
from models.database import delete_record, get_record, get_record_list, update_record
from kz_dash.models.database import delete_record, get_record, get_record_list, update_record
from kz_dash.utility.response import format_response
from kz_dash.utility.string_helper import get_uuid

Expand Down
6 changes: 4 additions & 2 deletions backend/api/fund.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
from flask_restx import Namespace, Resource, fields

from kz_dash.backend.api.common import create_list_response_model, create_response_model
from kz_dash.models.database import (
delete_record,
update_record,
)
from models.database import (
add_fund_position,
delete_record,
get_fund_positions,
get_fund_transactions,
update_record,
)
from models.fund_user import ModelFundPosition
from kz_dash.utility.response import format_response
Expand Down
2 changes: 1 addition & 1 deletion backend/api/portfolio.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from flask_restx import Namespace, Resource, fields

from kz_dash.backend.api.common import create_list_response_model, create_response_model
from kz_dash.models.database import delete_record, get_record, get_record_list, update_record
from models.account import ModelPortfolio
from models.database import delete_record, get_record, get_record_list, update_record
from kz_dash.utility.response import format_response
from kz_dash.utility.string_helper import get_uuid

Expand Down
2 changes: 1 addition & 1 deletion backend/api/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from flask_restx import Namespace, Resource, fields

from kz_dash.backend.api.common import create_list_response_model, create_response_model
from models.database import get_record_list
from kz_dash.models.database import get_record_list
from models.task import ModelTask
from scheduler.job_manager import JobManager
from scheduler.tasks import TaskFactory
Expand Down
2 changes: 1 addition & 1 deletion kz_dash
Submodule kz_dash updated from 68038f to 69bf4e
2 changes: 1 addition & 1 deletion models/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from peewee import BooleanField, CharField, ForeignKeyField

from models.base import BaseModel
from kz_dash.models.base import BaseModel
from kz_dash.utility.string_helper import get_uuid


Expand Down
146 changes: 0 additions & 146 deletions models/base.py

This file was deleted.

Loading

0 comments on commit a629e52

Please sign in to comment.