Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9421a95
Merge pull request #30 from mizhexiaoxiao/dev
mizhexiaoxiao May 30, 2024
301fc64
Merge pull request #31 from mizhexiaoxiao/dev
mizhexiaoxiao Jun 4, 2024
3ad476c
Merge pull request #32 from mizhexiaoxiao/dev
mizhexiaoxiao Jun 6, 2024
2851c32
Merge pull request #33 from mizhexiaoxiao/dev
mizhexiaoxiao Jun 6, 2024
be45db7
Merge pull request #34 from mizhexiaoxiao/dev
mizhexiaoxiao Jun 8, 2024
08c84df
Merge pull request #35 from mizhexiaoxiao/dev
mizhexiaoxiao Jun 17, 2024
9b0dd94
Merge pull request #36 from mizhexiaoxiao/dev
mizhexiaoxiao Jun 18, 2024
70cbb68
Merge pull request #37 from mizhexiaoxiao/dev
mizhexiaoxiao Jun 19, 2024
1ecbf2c
Merge pull request #38 from mizhexiaoxiao/dev
mizhexiaoxiao Jun 24, 2024
fd72748
Merge pull request #39 from mizhexiaoxiao/dev
mizhexiaoxiao Jul 31, 2024
ba22c2a
Merge pull request #40 from mizhexiaoxiao/dev
mizhexiaoxiao Aug 7, 2024
7d88b9b
Update README.md
mizhexiaoxiao Aug 30, 2024
f4013e8
Merge pull request #44 from mizhexiaoxiao/mizhexiaoxiao-patch-1
mizhexiaoxiao Aug 30, 2024
3985154
Merge pull request #45 from mizhexiaoxiao/dev
mizhexiaoxiao Sep 10, 2024
08be0c9
Merge pull request #46 from mizhexiaoxiao/dev
mizhexiaoxiao Sep 11, 2024
dd89699
Merge pull request #48 from mizhexiaoxiao/dev
mizhexiaoxiao Sep 13, 2024
4d808e2
Merge pull request #50 from mizhexiaoxiao/dev
mizhexiaoxiao Sep 20, 2024
28492e0
Merge pull request #52 from mizhexiaoxiao/dev
mizhexiaoxiao Sep 23, 2024
1352437
Merge pull request #53 from mizhexiaoxiao/dev
mizhexiaoxiao Sep 25, 2024
13275ca
Merge pull request #58 from mizhexiaoxiao/dev
mizhexiaoxiao Feb 25, 2025
296b7f3
Merge pull request #59 from mizhexiaoxiao/dev
mizhexiaoxiao Feb 26, 2025
1f046e2
Update README.md
mizhexiaoxiao Feb 26, 2025
3ef5772
Merge pull request #60 from mizhexiaoxiao/mizhexiaoxiao-patch-2
mizhexiaoxiao Feb 26, 2025
b7492be
Merge pull request #61 from mizhexiaoxiao/dev
mizhexiaoxiao Feb 26, 2025
9b6dcd9
Merge pull request #62 from mizhexiaoxiao/dev
mizhexiaoxiao Mar 3, 2025
7876f24
feat: 在 list 方法中支持预加载关联字段
sqyyyy Mar 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
- **细粒度权限控制**:实现按钮和接口级别的权限控制,确保不同用户或角色在界面操作和接口访问时具有不同的权限限制。

### 在线预览
- http://139.9.100.77:9999
- http://vue-fastapi-admin.com
- username: admin
- password: 123456

Expand Down
10 changes: 8 additions & 2 deletions app/core/crud.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Dict, Generic, List, NewType, Tuple, Type, TypeVar, Union
from typing import Any, Dict, Generic, List, NewType, Tuple, Type, TypeVar, Union,Optional

from pydantic import BaseModel
from tortoise.expressions import Q
Expand All @@ -17,8 +17,14 @@ def __init__(self, model: Type[ModelType]):
async def get(self, id: int) -> ModelType:
return await self.model.get(id=id)

async def list(self, page: int, page_size: int, search: Q = Q(), order: list = []) -> Tuple[Total, List[ModelType]]:

async def list(self,page: int,page_size: int,search: Q = Q(),order: list = [],prefetch_related_fields: Optional[List[str]] = None) -> Tuple[Total, List[ModelType]]:
query = self.model.filter(search)

if prefetch_related_fields:
for field in prefetch_related_fields:
query = query.prefetch_related(field)

return await query.count(), await query.offset((page - 1) * page_size).limit(page_size).order_by(*order)

async def create(self, obj_in: CreateSchemaType) -> ModelType:
Expand Down