MCPcopy Create free account

hub / github.com/acelee0621/fastapi-demo-project / functions

Functions129 in github.com/acelee0621/fastapi-demo-project

↓ 13 callersMethodget
(self, *, id: int)
app/domains/collections/collections_service.py:30
↓ 6 callersMethod_get_scoped_repo
一个内部辅助方法,用于获取一个临时的、带用户作用域的仓库代理。
app/domains/collections/collections_service.py:65
↓ 4 callersMethoddelete
Delete a hero.
app/domains/heroes/heroes_repository.py:249
↓ 3 callersMethod__init__
(self, detail: str = "Resource not found")
app/core/exceptions.py:8
↓ 3 callersMethodget_by_username
(self, username: str)
app/domains/users/user_repository.py:41
↓ 3 callersMethodget_hero
获取单个 Hero,优先从缓存中读取。 Args: hero_id: Hero 的 ID。 Returns: 包含 Hero 数据的标准响应体。
app/domains/heroes/heroes_serv.py:47
↓ 2 callersFunctionclose_database_connection
关闭全局的数据库引擎连接池。 这是一个通用的关闭函数,可以在 FastAPI 关闭时调用。
app/core/database.py:58
↓ 2 callersMethodcreate
创建一个新的 Hero。 重写此方法以提供针对 'alias' 字段的、更具体的唯一性冲突错误信息。
app/domains/heroes/heroes_repo.py:24
↓ 2 callersMethodcreate_hero
创建一个新的 Hero。 Args: obj_in: 创建 Hero 所需的数据。 Returns: 包含新创建 Hero 数据的标准响应体。
app/domains/heroes/heroes_serv.py:28
↓ 2 callersMethoddelete_hero
删除一个 Hero,并清除相关缓存。
app/domains/heroes/heroes_serv.py:147
↓ 2 callersMethodget_by_id
Fetch a hero by id.
app/domains/heroes/heroes_repository.py:32
↓ 2 callersMethodget_hero_with_story
获取英雄信息,并动态生成一段背景故事。 这个方法完美展示了服务层的业务逻辑处理能力。
app/domains/heroes/heroes_serv.py:160
↓ 2 callersMethodget_heroes
获取 Hero 列表。 此方法接收 limit 和 offset,并负责将仓库层返回的原始数据 组装成标准的 ListResponse 响应体。
app/domains/heroes/heroes_serv.py:74
↓ 2 callersFunctionget_project_version
从 pyproject.toml 文件中动态读取项目版本号。
app/core/config.py:15
↓ 2 callersFunctionget_settings
创建并返回一个配置实例。 使用 @lru_cache 装饰器实现以下目标: 1. 性能: 配置只在应用启动时被加载和解析一次,而不是在每个请求中。 2. 一致性 (单例): 应用的任何部分调用此函数都将获得完全相同的配置对象实例。 这意味着,如果你在应用
app/core/config.py:94
↓ 2 callersFunctionsetup_database_connection
初始化全局的数据库引擎和会话工厂。 这是一个通用的设置函数,可以在 FastAPI 启动时调用。
app/core/database.py:33
↓ 2 callersMethodupdate
Update an existing hero.
app/domains/heroes/heroes_repository.py:234
↓ 2 callersMethodupdate_hero
更新一个 Hero,并清除相关缓存。 Args: hero_id: 要更新的 Hero 的 ID。 obj_in: 更新所需的数据。
app/domains/heroes/heroes_serv.py:115
↓ 1 callersMethodadd_hero
(self, *, collection_id: int, hero_id: int)
app/domains/collections/collections_service.py:54
↓ 1 callersMethodadd_hero_to_collection
( self, *, collection_id: int, hero_id: int, current_user: User )
app/domains/collections/collections_service.py:126
↓ 1 callersMethodauthenticate
Authenticate user and return token.
app/domains/users/user_service.py:25
↓ 1 callersMethodcreate
(self, user_data: UserCreate)
app/domains/users/user_repository.py:17
↓ 1 callersMethodcreate
(self, *, obj_in: CollectionCreate)
app/domains/collections/collections_service.py:27
↓ 1 callersFunctioncreate_access_token
Create JWT access token.
app/core/security.py:26
↓ 1 callersFunctioncreate_auth_redis
()
app/core/redis_db.py:6
↓ 1 callersFunctioncreate_cache_redis
()
app/core/redis_db.py:13
↓ 1 callersMethodcreate_collection
( self, *, obj_in: CollectionCreate, current_user: User )
app/domains/collections/collections_service.py:69
↓ 1 callersMethodcreate_user
Create a new user.
app/domains/users/user_service.py:20
↓ 1 callersMethoddelete
(self, *, id: int)
app/domains/collections/collections_service.py:48
↓ 1 callersMethoddelete_collection
( self, *, collection_id: int, current_user: User )
app/domains/collections/collections_service.py:120
↓ 1 callersFunctionfill_fake_data
()
fill_fake_heroes.py:39
↓ 1 callersMethodget
根据 ID 高效获取单个记录。 如果未找到,则直接抛出 NotFoundException 异常。
app/core/repository.py:24
↓ 1 callersMethodget_all
( self, *, search: str | None = None, order_by: list[str] | None = None,
app/domains/heroes/heroes_repository.py:176
↓ 1 callersMethodget_by_id
(self, user_id: int)
app/domains/users/user_repository.py:33
↓ 1 callersMethodget_collection
( self, *, collection_id: int, current_user: User )
app/domains/collections/collections_service.py:77
↓ 1 callersMethodget_collections
( self, *, limit: int | None, offset: int | None, current_user: U
app/domains/collections/collections_service.py:85
↓ 1 callersMethodget_list
获取 Hero 列表,并定义此仓库的特定搜索策略。 此方法调用父类的通用列表查询,并返回一个包含 (总数, Hero ORM 对象列表) 的元组。
app/domains/heroes/heroes_repo.py:40
↓ 1 callersMethodget_list
(self, **kwargs)
app/domains/collections/collections_service.py:37
↓ 1 callersFunctionget_password_hash
(password: str)
app/core/security.py:22
↓ 1 callersFunctionget_service
(service_cls: Type[T], repo_cls: Type[R])
app/core/dependencies.py:33
↓ 1 callersFunctionget_session_factory
()
app/core/database.py:24
↓ 1 callersMethodget_user_by_username
Get user by username.
app/domains/users/user_service.py:50
↓ 1 callersFunctionregister_exception_handlers
向 FastAPI app 实例注册全局异常处理器。
app/core/exceptions.py:33
↓ 1 callersFunctionrun_async_migrations
In this scenario we need to create an Engine and associate a connection with the context.
alembic/env.py:89
↓ 1 callersFunctionrun_migrations_offline
Run migrations in 'offline' mode. This configures the context with just a URL and not an Engine, though an Engine is acceptable here as w
alembic/env.py:58
↓ 1 callersFunctionrun_migrations_online
Run migrations in 'online' mode.
alembic/env.py:107
↓ 1 callersMethodupdate
从 Pydantic Schema 更新一个已存在的对象。
app/core/repository.py:53
↓ 1 callersMethodupdate
(self, *, id: int, obj_in: CollectionUpdate)
app/domains/collections/collections_service.py:42
↓ 1 callersMethodupdate_collection
( self, *, collection_id: int, obj_in: CollectionUpdate, current_user: User )
app/domains/collections/collections_service.py:110
↓ 1 callersFunctionverify_password
(plain_password: str, password_hash: str)
app/core/security.py:18
MethodDATABASE_URL
生成异步 PostgreSQL 连接字符串。
app/core/config.py:49
Method__init__
(self, detail: str = "Resource already exists")
app/core/exceptions.py:12
Method__init__
(self, detail: str = "Unauthorized access")
app/core/exceptions.py:16
Method__init__
(self, detail: str = "Access forbidden")
app/core/exceptions.py:20
Method__init__
(self, model: Type[ModelType], session: AsyncSession)
app/core/repository.py:20
Method__init__
(self, session: AsyncSession)
app/core/dependencies.py:18
Method__init__
(self, repository: Any)
app/core/dependencies.py:24
Method__init__
(self, repository: UserRepository)
app/domains/users/user_service.py:17
Method__init__
(self, session: AsyncSession)
app/domains/users/user_repository.py:14
Method__init__
(self, session: AsyncSession)
app/domains/heroes/heroes_repository.py:15
Method__init__
初始化 HeroRepository。
app/domains/heroes/heroes_repo.py:17
Method__init__
Service layer for hero operations.
app/domains/heroes/heroes_services.py:17
Method__init__
初始化服务层。 Args: repository: HeroRepository 的实例。 redis: Redis 客户端的异步实例。
app/domains/heroes/heroes_serv.py:17
Method__init__
初始化 CollectionRepository。
app/domains/collections/collections_repository.py:20
Method__init__
(self, repository: CollectionRepository, user: User)
app/domains/collections/collections_service.py:23
Method__init__
(self, repository: CollectionRepository)
app/domains/collections/collections_service.py:62
Method__repr__
(self)
app/models/heroes.py:16
Method__repr__
(self)
app/models/collections.py:44
Method__repr__
(self)
app/models/users.py:31
Function_factory
(session: AsyncSession = Depends(get_db))
app/core/dependencies.py:34
Function_username_from_token
把 token 解包,直接返回 username;不合法就抛 401。
app/domains/users/auth_dependencies.py:60
Methodadd_hero
向 Collection 添加 Hero (多对多关系)。
app/domains/collections/collections_repository.py:28
Functionadd_hero_to_collection
( collection_id: int, payload: HeroAttachRequest, service: CollectionService = Depends(get_coll
app/api/v1/collections_route.py:136
Methodcreate
从 Pydantic Schema 创建一个新对象,并处理唯一性约束异常。
app/core/repository.py:34
Methodcreate
Create a new hero.
app/domains/heroes/heroes_repository.py:18
Functioncreate_collection
( data: CollectionCreate, service: CollectionService = Depends(get_collection_service), current
app/api/v1/collections_route.py:37
Functioncreate_db_and_tables
()
app/core/database.py:115
Functioncreate_hero
Create new hero.
app/api/v1/heroes_route.py:38
Functioncreate_hero
创建一条新的英雄记录。 - **name**: 英雄的真实姓名 - **alias**: 英雄的别名/代号 (必须唯一)
app/api/v1/new_hero_route.py:28
Methodcreate_hero
(self, data: HeroCreate)
app/domains/heroes/heroes_services.py:23
Functiondb_check
一个简单的端点,用于检查数据库连接是否正常工作。
app/main.py:94
Methoddelete
删除一个对象
app/core/repository.py:71
Functiondelete_collection
( collection_id: int, service: CollectionService = Depends(get_collection_service), current_use
app/api/v1/collections_route.py:120
Functiondelete_hero
Delete hero.
app/api/v1/heroes_route.py:244
Functiondelete_hero
根据 ID 删除一个英雄。
app/api/v1/new_hero_route.py:107
Methoddelete_hero
(self, hero_id: int)
app/domains/heroes/heroes_services.py:126
Functiondo_run_migrations
(connection: Connection)
alembic/env.py:82
Functiondowngrade
Downgrade schema.
alembic/versions/902aac14d239_add_powers_column_to_heroes_table.py:28
Functiondowngrade
Downgrade schema.
alembic/versions/42022bfd0269_intergrate_hero_with_dateimemixin.py:30
Functiondowngrade
Downgrade schema.
alembic/versions/6185a991de0c_initial_migration.py:45
Functiondowngrade
Downgrade schema.
alembic/versions/f321df2cf6a5_add_collections_table.py:47
Functiongenerate_hero_story
Generate hero story.
app/api/v1/heroes_route.py:258
Functionget_auth_redis
(request: Request)
app/core/redis_db.py:21
Functionget_cache_redis
(request: Request)
app/core/redis_db.py:24
Functionget_collection
( collection_id: int, service: CollectionService = Depends(get_collection_service), current_use
app/api/v1/collections_route.py:88
Functionget_current_user
1. 先查缓存 2. 缓存没命中 -> 查数据库 -> 写回缓存 3. 用户不存在 -> 401
app/domains/users/auth_dependencies.py:82
Functionget_db
依赖注入函数:为每个请求提供一个数据库会话, 并将其包裹在一个能自动提交/回滚的事务中(工作单元模式)。
app/core/database.py:87
Functionget_engine
()
app/core/database.py:18
Functionget_hero
Get hero by id.
app/api/v1/heroes_route.py:213
Functionget_hero
根据 ID 获取单个英雄的详细信息。
app/api/v1/new_hero_route.py:73
next →1–100 of 129, ranked by callers