From 65b3a7074b561f97a93f0b5410e210da649b9b46 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Fri, 8 Nov 2024 19:57:23 +0800 Subject: [PATCH] feat: face image --- alembic/env.py | 1 + alembic/versions/a41d2f3443c8_face_image.py | 63 ++++++++ src/frontend/sa-frame/com/sa-td.vue | 7 + src/frontend/sa-frame/menu-list.js | 66 ++------ src/frontend/sa-view/face/swiper-add.html | 138 ++++++++++++++++ src/frontend/sa-view/face/swiper-list.html | 127 +++++++++++++++ src/frontend/static/kj/upload-util.js | 12 ++ src/route/face_image.py | 169 ++++++++++++++++++++ src/services/face_image/__init__.py | 0 src/services/face_image/models.py | 14 ++ src/services/face_image/repositories.py | 54 +++++++ src/services/face_image/schemas.py | 19 +++ src/services/face_image/services.py | 55 +++++++ src/services/users/models.py | 9 ++ src/services/users/repositories.py | 2 +- src/utils/_path.py | 3 + src/utils/upload_file.py | 44 ++++- 17 files changed, 726 insertions(+), 57 deletions(-) create mode 100644 alembic/versions/a41d2f3443c8_face_image.py create mode 100644 src/frontend/sa-view/face/swiper-add.html create mode 100644 src/frontend/sa-view/face/swiper-list.html create mode 100644 src/route/face_image.py create mode 100644 src/services/face_image/__init__.py create mode 100644 src/services/face_image/models.py create mode 100644 src/services/face_image/repositories.py create mode 100644 src/services/face_image/schemas.py create mode 100644 src/services/face_image/services.py diff --git a/alembic/env.py b/alembic/env.py index bfe7111..935e915 100644 --- a/alembic/env.py +++ b/alembic/env.py @@ -36,6 +36,7 @@ def import_models(): """导入我们所有的 models,使 alembic 可以自动对比 db scheme 创建 migration revision""" for pkg in scan_models(): try: + print(f"导入 {pkg}") import_module(pkg) # 导入 models except Exception as e: # pylint: disable=W0703 print( diff --git a/alembic/versions/a41d2f3443c8_face_image.py b/alembic/versions/a41d2f3443c8_face_image.py new file mode 100644 index 0000000..d072837 --- /dev/null +++ b/alembic/versions/a41d2f3443c8_face_image.py @@ -0,0 +1,63 @@ +"""face_image + +Revision ID: a41d2f3443c8 +Revises: 1d50ca81be81 +Create Date: 2024-11-08 16:20:23.106957 + +""" + +from alembic import op +import sqlalchemy as sa +import sqlmodel + + +# revision identifiers, used by Alembic. +revision = "a41d2f3443c8" +down_revision = "1d50ca81be81" +branch_labels = None +depends_on = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.create_table( + "face_image", + sa.Column("delete_time", sa.DateTime(), nullable=True), + sa.Column( + "update_time", + sa.DateTime(), + server_default=sa.text("now()"), + nullable=True, + ), + sa.Column("create_time", sa.DateTime(), nullable=False), + sa.Column("id", sa.Integer(), autoincrement=True, nullable=False), + sa.Column( + "image", + sqlmodel.sql.sqltypes.AutoString(length=255), + nullable=False, + ), + sa.Column("is_approved", sa.Boolean(), nullable=False), + sa.Column("user_id", sa.Integer(), nullable=False), + sa.PrimaryKeyConstraint("id"), + ) + op.create_index( + op.f("ix_face_image_create_time"), + "face_image", + ["create_time"], + unique=False, + ) + op.create_index( + op.f("ix_face_image_update_time"), + "face_image", + ["update_time"], + unique=False, + ) + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.drop_index(op.f("ix_face_image_update_time"), table_name="face_image") + op.drop_index(op.f("ix_face_image_create_time"), table_name="face_image") + op.drop_table("face_image") + # ### end Alembic commands ### diff --git a/src/frontend/sa-frame/com/sa-td.vue b/src/frontend/sa-frame/com/sa-td.vue index 91d8db1..19e070d 100644 --- a/src/frontend/sa-frame/com/sa-td.vue +++ b/src/frontend/sa-frame/com/sa-td.vue @@ -16,6 +16,13 @@ {{not}} + + + +