Skip to content

Commit 23474a2

Browse files
feat: Terminology module
1 parent 1c1ecb3 commit 23474a2

13 files changed

Lines changed: 187 additions & 4 deletions

File tree

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ SECRET_KEY=y5txe1mRmS_JpOrUzFzHEu-kIQn3lf7ll0AOv9DQh0s
1212
FIRST_SUPERUSER=admin@example.com
1313
FIRST_SUPERUSER_PASSWORD=123456 # Change this to your pwd
1414

15+
TOKEN_KEY="X-SQLBOT-TOKEN"
1516

1617
# Postgres
1718
POSTGRES_SERVER=localhost

backend/alembic/env.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
# target_metadata = mymodel.Base.metadata
1919
# target_metadata = None
2020

21-
from apps.system.models.user import SQLModel # noqa
21+
# from apps.system.models.user import SQLModel # noqa
22+
from apps.settings.models.setting_models import SQLModel
2223
from common.core.config import settings # noqa
2324

2425
target_metadata = SQLModel.metadata
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
"""002_ddl_autogenerate
2+
3+
Revision ID: 1c8bcc7e25c8
4+
Revises: 5348b743b05f
5+
Create Date: 2025-04-25 17:47:18.795288
6+
7+
"""
8+
from alembic import op
9+
import sqlalchemy as sa
10+
import sqlmodel.sql.sqltypes
11+
12+
13+
# revision identifiers, used by Alembic.
14+
revision = '1c8bcc7e25c8'
15+
down_revision = '5348b743b05f'
16+
branch_labels = None
17+
depends_on = None
18+
19+
20+
def upgrade():
21+
# ### commands auto generated by Alembic - please adjust! ###
22+
op.create_table('terms',
23+
sa.Column('id', sa.Integer(), nullable=False),
24+
sa.Column('term', sqlmodel.sql.sqltypes.AutoString(length=255), nullable=False),
25+
sa.Column('definition', sqlmodel.sql.sqltypes.AutoString(length=255), nullable=False),
26+
sa.Column('domain', sqlmodel.sql.sqltypes.AutoString(length=255), nullable=False),
27+
sa.Column('create_time', sa.Integer(), nullable=False),
28+
sa.PrimaryKeyConstraint('id')
29+
)
30+
op.create_index(op.f('ix_terms_id'), 'terms', ['id'], unique=False)
31+
op.drop_table('sys_user')
32+
# ### end Alembic commands ###
33+
34+
35+
def downgrade():
36+
# ### commands auto generated by Alembic - please adjust! ###
37+
op.create_table('sys_user',
38+
sa.Column('id', sa.BIGINT(), autoincrement=True, nullable=False),
39+
sa.Column('account', sa.VARCHAR(length=255), autoincrement=False, nullable=False),
40+
sa.Column('name', sa.VARCHAR(length=255), autoincrement=False, nullable=False),
41+
sa.Column('password', sa.VARCHAR(length=255), autoincrement=False, nullable=False),
42+
sa.Column('email', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
43+
sa.Column('oid', sa.BIGINT(), autoincrement=False, nullable=False),
44+
sa.Column('status', sa.INTEGER(), autoincrement=False, nullable=False),
45+
sa.Column('create_time', sa.BIGINT(), autoincrement=False, nullable=False),
46+
sa.PrimaryKeyConstraint('id', name='sys_user_pkey')
47+
)
48+
op.drop_index(op.f('ix_terms_id'), table_name='terms')
49+
op.drop_table('terms')
50+
# ### end Alembic commands ###

backend/apps/api.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
from fastapi import APIRouter
22

33
from apps.system.api import login, user
4-
4+
from apps.settings.api import terminology
55

66
api_router = APIRouter()
77
api_router.include_router(login.router)
88
api_router.include_router(user.router)
9+
api_router.include_router(terminology.router)
910

1011

backend/apps/settings/__init__.py

Whitespace-only changes.

backend/apps/settings/api/__init__.py

Whitespace-only changes.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from typing import Optional
2+
from fastapi import APIRouter, Depends, Request
3+
from apps.settings.models.setting_models import term_model
4+
# from common.core.db import get_session
5+
from common.core.deps import SessionDep
6+
from common.core.pagination import Paginator
7+
from common.core.schemas import PaginatedResponse, PaginationParams
8+
router = APIRouter(tags=["Settings"], prefix="/settings/terminology")
9+
10+
11+
@router.get("/pager/{pageNum}/{pageSize}", response_model=PaginatedResponse[term_model])
12+
async def pager(
13+
session: SessionDep,
14+
pageNum: int,
15+
pageSize: int
16+
):
17+
pagination = PaginationParams(page=pageNum, size=pageSize)
18+
paginator = Paginator(session)
19+
filters = {}
20+
return await paginator.get_paginated_response(
21+
model=term_model,
22+
pagination=pagination,
23+
**filters)

backend/apps/settings/models/__init__.py

Whitespace-only changes.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from sqlmodel import Field, SQLModel
2+
3+
4+
class term_model(SQLModel, table=True):
5+
__tablename__ = "terms"
6+
7+
id: int = Field(primary_key=True, index=True)
8+
term: str = Field(max_length=255)
9+
definition: str = Field(max_length=255)
10+
domain: str = Field(max_length=255)
11+
create_time: int = Field(default=0)
12+

backend/apps/settings/schemas/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)