mirror of
https://github.com/fastapi-practices/fastapi-best-architecture.git
synced 2026-09-21 13:12:24 +00:00
* define the basic architecture * Update script and deployment file locations * Update the route registration * Fix CI download dependencies * Updated ruff to 0.3.3 * Update app subdirectory naming * Update the model import * fix pre-commit pdm lock * Update the service directory naming * Add CRUD method documents * Fix the issue of circular import * Update the README document * Update the SQL statement for create tables * Update docker scripts and documentation * Fix docker scripts * Update the backend README.md * Add the security folder and move the redis client * Update the configuration item * Fix environment configuration reads * Update the default configuration * Updated README description * Updated the user registration API * Fix test cases * Update the celery configuration * Update and fix celery configuration * Updated the celery structure * Update celery tasks and api * Add celery flower * Update the import style * Update contributors
66 lines
2.0 KiB
Python
66 lines
2.0 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
from typing import Annotated
|
|
|
|
from fastapi import APIRouter, Depends, Query
|
|
|
|
from backend.app.admin.schema.opera_log import GetOperaLogListDetails
|
|
from backend.app.admin.service.opera_log_service import opera_log_service
|
|
from backend.common.pagination import DependsPagination, paging_data
|
|
from backend.common.response.response_schema import ResponseModel, response_base
|
|
from backend.common.security.jwt import DependsJwtAuth
|
|
from backend.common.security.permission import RequestPermission
|
|
from backend.common.security.rbac import DependsRBAC
|
|
from backend.database.db_mysql import CurrentSession
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get(
|
|
'',
|
|
summary='(模糊条件)分页获取操作日志',
|
|
dependencies=[
|
|
DependsJwtAuth,
|
|
DependsPagination,
|
|
],
|
|
)
|
|
async def get_pagination_opera_logs(
|
|
db: CurrentSession,
|
|
username: Annotated[str | None, Query()] = None,
|
|
status: Annotated[int | None, Query()] = None,
|
|
ip: Annotated[str | None, Query()] = None,
|
|
) -> ResponseModel:
|
|
log_select = await opera_log_service.get_select(username=username, status=status, ip=ip)
|
|
page_data = await paging_data(db, log_select, GetOperaLogListDetails)
|
|
return await response_base.success(data=page_data)
|
|
|
|
|
|
@router.delete(
|
|
'',
|
|
summary='(批量)删除操作日志',
|
|
dependencies=[
|
|
Depends(RequestPermission('log:opera:del')),
|
|
DependsRBAC,
|
|
],
|
|
)
|
|
async def delete_opera_log(pk: Annotated[list[int], Query(...)]) -> ResponseModel:
|
|
count = await opera_log_service.delete(pk=pk)
|
|
if count > 0:
|
|
return await response_base.success()
|
|
return await response_base.fail()
|
|
|
|
|
|
@router.delete(
|
|
'/all',
|
|
summary='清空操作日志',
|
|
dependencies=[
|
|
Depends(RequestPermission('log:opera:empty')),
|
|
DependsRBAC,
|
|
],
|
|
)
|
|
async def delete_all_opera_logs() -> ResponseModel:
|
|
count = await opera_log_service.delete_all()
|
|
if count > 0:
|
|
return await response_base.success()
|
|
return await response_base.fail()
|