Skip to content

Commit

Permalink
feat: update design add a lot of features change
Browse files Browse the repository at this point in the history
  • Loading branch information
wangxin688 committed Jul 6, 2024
1 parent 44251c4 commit 2cedfa7
Show file tree
Hide file tree
Showing 38 changed files with 1,354 additions and 456 deletions.
1 change: 1 addition & 0 deletions backend/_typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ extend-exclude = [
[default]
extend-ignore-identifiers-re = [
"selectin",
"equipments",
]
5 changes: 4 additions & 1 deletion backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ dependencies = [
"passlib>=1.7.4",
"cryptography>=42.0.8",
"celery>=5.4.0",
"icmplib>=3.0.4",
"tcppinglib>=2.0.3",
"netmiko>=4.3.0",
]
readme = "README.md"
requires-python = ">= 3.11"
Expand All @@ -43,7 +46,7 @@ dev-dependencies = [
"pre-commit>=3.5.0",
"ruff>=0.1.11",
"pytest-cov>=4.1.0",
"pytest-asyncio>=0.23.3",
"pytest-asyncio>=0.23.7",
"black>=23.12.1",
"mypy>=1.8.0",
]
Expand Down
29 changes: 28 additions & 1 deletion backend/requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ asyncpg==0.29.0
# via netsight
bcrypt==4.0.1
# via netsight
# via paramiko
billiard==4.2.0
# via celery
black==23.12.1
Expand All @@ -33,6 +34,7 @@ certifi==2023.11.17
# via sentry-sdk
cffi==1.16.0
# via cryptography
# via pynacl
cfgv==3.4.0
# via pre-commit
click==8.1.7
Expand All @@ -53,6 +55,7 @@ coverage==7.4.0
# via pytest-cov
cryptography==42.0.8
# via netsight
# via paramiko
distlib==0.3.8
# via virtualenv
dnspython==2.5.0
Expand All @@ -66,6 +69,8 @@ fastapi-cli==0.0.4
# via fastapi
filelock==3.13.1
# via virtualenv
future==1.0.0
# via textfsm
greenlet==3.0.3
# via sqlalchemy
gunicorn==21.2.0
Expand All @@ -80,6 +85,8 @@ httptools==0.6.1
httpx==0.26.0
# via fastapi
# via netsight
icmplib==3.0.4
# via netsight
identify==2.5.33
# via pre-commit
idna==3.6
Expand All @@ -105,8 +112,12 @@ mypy==1.8.0
mypy-extensions==1.0.0
# via black
# via mypy
netmiko==4.3.0
# via netsight
nodeenv==1.8.0
# via pre-commit
ntc-templates==5.1.0
# via netmiko
numpy==1.26.4
# via netsight
# via pandas
Expand All @@ -118,6 +129,9 @@ packaging==23.2
# via pytest
pandas==2.2.0
# via netsight
paramiko==3.4.0
# via netmiko
# via scp
passlib==1.7.4
# via netsight
pathspec==0.12.1
Expand Down Expand Up @@ -148,10 +162,14 @@ pygments==2.18.0
# via rich
pyjwt==2.8.0
# via netsight
pynacl==1.5.0
# via paramiko
pyserial==3.5
# via netmiko
pytest==7.4.4
# via pytest-asyncio
# via pytest-cov
pytest-asyncio==0.23.3
pytest-asyncio==0.23.7
pytest-cov==4.1.0
python-dateutil==2.8.2
# via celery
Expand All @@ -165,13 +183,16 @@ python-multipart==0.0.9
pytz==2024.1
# via pandas
pyyaml==6.0.1
# via netmiko
# via pre-commit
# via uvicorn
redis==5.0.1
# via netsight
rich==13.7.1
# via typer
ruff==0.1.11
scp==0.15.0
# via netmiko
sentry-sdk==1.39.2
# via netsight
setuptools==69.0.3
Expand All @@ -180,6 +201,7 @@ shellingham==1.5.4
# via typer
six==1.16.0
# via python-dateutil
# via textfsm
sniffio==1.3.0
# via anyio
# via httpx
Expand All @@ -191,6 +213,11 @@ sqlalchemy-utils==0.41.1
# via netsight
starlette==0.37.2
# via fastapi
tcppinglib==2.0.3
# via netsight
textfsm==1.1.3
# via netmiko
# via ntc-templates
typer==0.12.3
# via fastapi-cli
typing-extensions==4.9.0
Expand Down
27 changes: 27 additions & 0 deletions backend/requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ asyncpg==0.29.0
# via netsight
bcrypt==4.0.1
# via netsight
# via paramiko
billiard==4.2.0
# via celery
celery==5.4.0
Expand All @@ -32,6 +33,7 @@ certifi==2023.11.17
# via sentry-sdk
cffi==1.16.0
# via cryptography
# via pynacl
click==8.1.7
# via celery
# via click-didyoumean
Expand All @@ -47,6 +49,7 @@ click-repl==0.3.0
# via celery
cryptography==42.0.8
# via netsight
# via paramiko
dnspython==2.5.0
# via email-validator
email-validator==2.1.0.post1
Expand All @@ -56,6 +59,8 @@ fastapi==0.111.0
# via netsight
fastapi-cli==0.0.4
# via fastapi
future==1.0.0
# via textfsm
greenlet==3.0.3
# via sqlalchemy
gunicorn==21.2.0
Expand All @@ -70,6 +75,8 @@ httptools==0.6.1
httpx==0.26.0
# via fastapi
# via netsight
icmplib==3.0.4
# via netsight
idna==3.6
# via anyio
# via email-validator
Expand All @@ -87,6 +94,10 @@ markupsafe==2.1.3
# via mako
mdurl==0.1.2
# via markdown-it-py
netmiko==4.3.0
# via netsight
ntc-templates==5.1.0
# via netmiko
numpy==1.26.4
# via netsight
# via pandas
Expand All @@ -96,6 +107,9 @@ packaging==23.2
# via gunicorn
pandas==2.2.0
# via netsight
paramiko==3.4.0
# via netmiko
# via scp
passlib==1.7.4
# via netsight
phonenumbers==8.13.27
Expand All @@ -118,6 +132,10 @@ pygments==2.18.0
# via rich
pyjwt==2.8.0
# via netsight
pynacl==1.5.0
# via paramiko
pyserial==3.5
# via netmiko
python-dateutil==2.8.2
# via celery
# via pandas
Expand All @@ -130,17 +148,21 @@ python-multipart==0.0.9
pytz==2024.1
# via pandas
pyyaml==6.0.1
# via netmiko
# via uvicorn
redis==5.0.1
# via netsight
rich==13.7.1
# via typer
scp==0.15.0
# via netmiko
sentry-sdk==1.39.2
# via netsight
shellingham==1.5.4
# via typer
six==1.16.0
# via python-dateutil
# via textfsm
sniffio==1.3.0
# via anyio
# via httpx
Expand All @@ -152,6 +174,11 @@ sqlalchemy-utils==0.41.1
# via netsight
starlette==0.37.2
# via fastapi
tcppinglib==2.0.3
# via netsight
textfsm==1.1.3
# via netmiko
# via ntc-templates
typer==0.12.3
# via fastapi-cli
typing-extensions==4.9.0
Expand Down
3 changes: 0 additions & 3 deletions backend/src/core/errors/err_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,3 @@ def dict(self): # noqa: ANN201
ERR_10003 = ErrorCode(10003, "admin.token_expired")
ERR_10004 = ErrorCode(10004, "admin.token_invalid_for_refresh")
ERR_10005 = ErrorCode(10005, "admin.permission_deny")


ERR_20001 = ErrorCode(20001, "admin.user_not_found")
10 changes: 5 additions & 5 deletions backend/src/core/repositories/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,8 @@ async def create(
if m2m:
for key, value in m2m.items():
if hasattr(obj_in, key) and getattr(obj_in, key) is not None:
dto_m2m = BaseRepository(value)
db_m2m = await dto_m2m.get_multi_by_pks_or_404(session, [r.id for r in getattr(obj_in, key)])
service_m2m = BaseRepository(value)
db_m2m = await service_m2m.get_multi_by_pks_or_404(session, getattr(obj_in, key))
setattr(new_obj, key, db_m2m)
setattr(obj_in, key, value)
if commit:
Expand Down Expand Up @@ -632,7 +632,7 @@ async def update(
for key, value in m2m.items():
if hasattr(obj_in, key) and getattr(obj_in, key) is not None:
await self.update_relationship_field(
session, db_obj, value, key, [r.id for r in getattr(obj_in, key)], self.id_attribute
session, db_obj, value, key, getattr(obj_in, key), self.id_attribute
)
db_obj = self._update_mutable_tracking(obj_in, db_obj, excludes)
if commit:
Expand Down Expand Up @@ -671,9 +671,9 @@ async def update_relationship_field(
if getattr(fk_value, relationship_pk_name) not in fk_values:
getattr(obj, relationship_name).remove(fk_value)
for fk_value in fk_values:
target_dto = BaseRepository(model=m2m_model)
target_service = BaseRepository(model=m2m_model)
if fk_value not in local_fk_value_ids:
target_obj = await target_dto.get_one_or_404(session, fk_value)
target_obj = await target_service.get_one_or_404(session, fk_value)
getattr(obj, relationship_name).append(target_obj)
else:
setattr(obj, relationship_name, None)
Expand Down
14 changes: 5 additions & 9 deletions backend/src/features/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,16 @@ class AuditTime(BaseModel):
updated_at: datetime | None = None


class AuditUserBase(BaseModel):
class AuthUserBase(BaseModel):
id: int
name: str
email: str | None = None
phone: str | None = None
avatar: str | None = None


class AuditUser(BaseModel):
created_by: AuditUserBase | None = None
updated_by: AuditUserBase | None = None
class AuditUser(AuditTime):
created_by: AuthUserBase | None = None
updated_by: AuthUserBase | None = None


class AuditLog(BaseModel):
Expand All @@ -62,7 +61,7 @@ class AuditLog(BaseModel):
request_id: str
action: str
diff: dict | None = None
user: AuditUserBase | None = None
user: AuthUserBase | None = None


class ListT(BaseModel, Generic[T]):
Expand Down Expand Up @@ -115,6 +114,3 @@ class I18nField(BaseModel):

class IdResponse(BaseModel):
id: int


class IdCreate(IdResponse): ...
Loading

0 comments on commit 2cedfa7

Please sign in to comment.