Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/acelee0621/fastapi-demo-project
/ functions
Functions
129 in github.com/acelee0621/fastapi-demo-project
⨍
Functions
129
◇
Types & classes
53
↳
Endpoints
25
↓ 13 callers
Method
get
(self, *, id: int)
app/domains/collections/collections_service.py:30
↓ 6 callers
Method
_get_scoped_repo
一个内部辅助方法,用于获取一个临时的、带用户作用域的仓库代理。
app/domains/collections/collections_service.py:65
↓ 4 callers
Method
delete
Delete a hero.
app/domains/heroes/heroes_repository.py:249
↓ 3 callers
Method
__init__
(self, detail: str = "Resource not found")
app/core/exceptions.py:8
↓ 3 callers
Method
get_by_username
(self, username: str)
app/domains/users/user_repository.py:41
↓ 3 callers
Method
get_hero
获取单个 Hero,优先从缓存中读取。 Args: hero_id: Hero 的 ID。 Returns: 包含 Hero 数据的标准响应体。
app/domains/heroes/heroes_serv.py:47
↓ 2 callers
Function
close_database_connection
关闭全局的数据库引擎连接池。 这是一个通用的关闭函数,可以在 FastAPI 关闭时调用。
app/core/database.py:58
↓ 2 callers
Method
create
创建一个新的 Hero。 重写此方法以提供针对 'alias' 字段的、更具体的唯一性冲突错误信息。
app/domains/heroes/heroes_repo.py:24
↓ 2 callers
Method
create_hero
创建一个新的 Hero。 Args: obj_in: 创建 Hero 所需的数据。 Returns: 包含新创建 Hero 数据的标准响应体。
app/domains/heroes/heroes_serv.py:28
↓ 2 callers
Method
delete_hero
删除一个 Hero,并清除相关缓存。
app/domains/heroes/heroes_serv.py:147
↓ 2 callers
Method
get_by_id
Fetch a hero by id.
app/domains/heroes/heroes_repository.py:32
↓ 2 callers
Method
get_hero_with_story
获取英雄信息,并动态生成一段背景故事。 这个方法完美展示了服务层的业务逻辑处理能力。
app/domains/heroes/heroes_serv.py:160
↓ 2 callers
Method
get_heroes
获取 Hero 列表。 此方法接收 limit 和 offset,并负责将仓库层返回的原始数据 组装成标准的 ListResponse 响应体。
app/domains/heroes/heroes_serv.py:74
↓ 2 callers
Function
get_project_version
从 pyproject.toml 文件中动态读取项目版本号。
app/core/config.py:15
↓ 2 callers
Function
get_settings
创建并返回一个配置实例。 使用 @lru_cache 装饰器实现以下目标: 1. 性能: 配置只在应用启动时被加载和解析一次,而不是在每个请求中。 2. 一致性 (单例): 应用的任何部分调用此函数都将获得完全相同的配置对象实例。 这意味着,如果你在应用
app/core/config.py:94
↓ 2 callers
Function
setup_database_connection
初始化全局的数据库引擎和会话工厂。 这是一个通用的设置函数,可以在 FastAPI 启动时调用。
app/core/database.py:33
↓ 2 callers
Method
update
Update an existing hero.
app/domains/heroes/heroes_repository.py:234
↓ 2 callers
Method
update_hero
更新一个 Hero,并清除相关缓存。 Args: hero_id: 要更新的 Hero 的 ID。 obj_in: 更新所需的数据。
app/domains/heroes/heroes_serv.py:115
↓ 1 callers
Method
add_hero
(self, *, collection_id: int, hero_id: int)
app/domains/collections/collections_service.py:54
↓ 1 callers
Method
add_hero_to_collection
( self, *, collection_id: int, hero_id: int, current_user: User )
app/domains/collections/collections_service.py:126
↓ 1 callers
Method
authenticate
Authenticate user and return token.
app/domains/users/user_service.py:25
↓ 1 callers
Method
create
(self, user_data: UserCreate)
app/domains/users/user_repository.py:17
↓ 1 callers
Method
create
(self, *, obj_in: CollectionCreate)
app/domains/collections/collections_service.py:27
↓ 1 callers
Function
create_access_token
Create JWT access token.
app/core/security.py:26
↓ 1 callers
Function
create_auth_redis
()
app/core/redis_db.py:6
↓ 1 callers
Function
create_cache_redis
()
app/core/redis_db.py:13
↓ 1 callers
Method
create_collection
( self, *, obj_in: CollectionCreate, current_user: User )
app/domains/collections/collections_service.py:69
↓ 1 callers
Method
create_user
Create a new user.
app/domains/users/user_service.py:20
↓ 1 callers
Method
delete
(self, *, id: int)
app/domains/collections/collections_service.py:48
↓ 1 callers
Method
delete_collection
( self, *, collection_id: int, current_user: User )
app/domains/collections/collections_service.py:120
↓ 1 callers
Function
fill_fake_data
()
fill_fake_heroes.py:39
↓ 1 callers
Method
get
根据 ID 高效获取单个记录。 如果未找到,则直接抛出 NotFoundException 异常。
app/core/repository.py:24
↓ 1 callers
Method
get_all
( self, *, search: str | None = None, order_by: list[str] | None = None,
app/domains/heroes/heroes_repository.py:176
↓ 1 callers
Method
get_by_id
(self, user_id: int)
app/domains/users/user_repository.py:33
↓ 1 callers
Method
get_collection
( self, *, collection_id: int, current_user: User )
app/domains/collections/collections_service.py:77
↓ 1 callers
Method
get_collections
( self, *, limit: int | None, offset: int | None, current_user: U
app/domains/collections/collections_service.py:85
↓ 1 callers
Method
get_list
获取 Hero 列表,并定义此仓库的特定搜索策略。 此方法调用父类的通用列表查询,并返回一个包含 (总数, Hero ORM 对象列表) 的元组。
app/domains/heroes/heroes_repo.py:40
↓ 1 callers
Method
get_list
(self, **kwargs)
app/domains/collections/collections_service.py:37
↓ 1 callers
Function
get_password_hash
(password: str)
app/core/security.py:22
↓ 1 callers
Function
get_service
(service_cls: Type[T], repo_cls: Type[R])
app/core/dependencies.py:33
↓ 1 callers
Function
get_session_factory
()
app/core/database.py:24
↓ 1 callers
Method
get_user_by_username
Get user by username.
app/domains/users/user_service.py:50
↓ 1 callers
Function
register_exception_handlers
向 FastAPI app 实例注册全局异常处理器。
app/core/exceptions.py:33
↓ 1 callers
Function
run_async_migrations
In this scenario we need to create an Engine and associate a connection with the context.
alembic/env.py:89
↓ 1 callers
Function
run_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 callers
Function
run_migrations_online
Run migrations in 'online' mode.
alembic/env.py:107
↓ 1 callers
Method
update
从 Pydantic Schema 更新一个已存在的对象。
app/core/repository.py:53
↓ 1 callers
Method
update
(self, *, id: int, obj_in: CollectionUpdate)
app/domains/collections/collections_service.py:42
↓ 1 callers
Method
update_collection
( self, *, collection_id: int, obj_in: CollectionUpdate, current_user: User )
app/domains/collections/collections_service.py:110
↓ 1 callers
Function
verify_password
(plain_password: str, password_hash: str)
app/core/security.py:18
Method
DATABASE_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
Method
add_hero
向 Collection 添加 Hero (多对多关系)。
app/domains/collections/collections_repository.py:28
Function
add_hero_to_collection
( collection_id: int, payload: HeroAttachRequest, service: CollectionService = Depends(get_coll
app/api/v1/collections_route.py:136
Method
create
从 Pydantic Schema 创建一个新对象,并处理唯一性约束异常。
app/core/repository.py:34
Method
create
Create a new hero.
app/domains/heroes/heroes_repository.py:18
Function
create_collection
( data: CollectionCreate, service: CollectionService = Depends(get_collection_service), current
app/api/v1/collections_route.py:37
Function
create_db_and_tables
()
app/core/database.py:115
Function
create_hero
Create new hero.
app/api/v1/heroes_route.py:38
Function
create_hero
创建一条新的英雄记录。 - **name**: 英雄的真实姓名 - **alias**: 英雄的别名/代号 (必须唯一)
app/api/v1/new_hero_route.py:28
Method
create_hero
(self, data: HeroCreate)
app/domains/heroes/heroes_services.py:23
Function
db_check
一个简单的端点,用于检查数据库连接是否正常工作。
app/main.py:94
Method
delete
删除一个对象
app/core/repository.py:71
Function
delete_collection
( collection_id: int, service: CollectionService = Depends(get_collection_service), current_use
app/api/v1/collections_route.py:120
Function
delete_hero
Delete hero.
app/api/v1/heroes_route.py:244
Function
delete_hero
根据 ID 删除一个英雄。
app/api/v1/new_hero_route.py:107
Method
delete_hero
(self, hero_id: int)
app/domains/heroes/heroes_services.py:126
Function
do_run_migrations
(connection: Connection)
alembic/env.py:82
Function
downgrade
Downgrade schema.
alembic/versions/902aac14d239_add_powers_column_to_heroes_table.py:28
Function
downgrade
Downgrade schema.
alembic/versions/42022bfd0269_intergrate_hero_with_dateimemixin.py:30
Function
downgrade
Downgrade schema.
alembic/versions/6185a991de0c_initial_migration.py:45
Function
downgrade
Downgrade schema.
alembic/versions/f321df2cf6a5_add_collections_table.py:47
Function
generate_hero_story
Generate hero story.
app/api/v1/heroes_route.py:258
Function
get_auth_redis
(request: Request)
app/core/redis_db.py:21
Function
get_cache_redis
(request: Request)
app/core/redis_db.py:24
Function
get_collection
( collection_id: int, service: CollectionService = Depends(get_collection_service), current_use
app/api/v1/collections_route.py:88
Function
get_current_user
1. 先查缓存 2. 缓存没命中 -> 查数据库 -> 写回缓存 3. 用户不存在 -> 401
app/domains/users/auth_dependencies.py:82
Function
get_db
依赖注入函数:为每个请求提供一个数据库会话, 并将其包裹在一个能自动提交/回滚的事务中(工作单元模式)。
app/core/database.py:87
Function
get_engine
()
app/core/database.py:18
Function
get_hero
Get hero by id.
app/api/v1/heroes_route.py:213
Function
get_hero
根据 ID 获取单个英雄的详细信息。
app/api/v1/new_hero_route.py:73
next →
1–100 of 129, ranked by callers