feat(admin): album management pages with members and categories
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,123 @@
|
||||
/**
|
||||
* 相册域接口(对齐 @photo/contracts:albums/assets/members/categories/photos
|
||||
* 与 /admin/users 账号前缀查询)
|
||||
*
|
||||
* - 列表端点均为游标分页(cursor + limit;nextCursor 为 null 表示到底)
|
||||
* - 更新为 PATCH 部分语义;translations 数组全量替换
|
||||
* - 204 端点(移除成员/删除分类/删除照片)无响应体
|
||||
* - 资产直传 PUT 走 staging 预签名 URL(裸 fetch,不带会话头),见
|
||||
* views/albums 内的上传组件
|
||||
*/
|
||||
import request from '@/utils/http'
|
||||
|
||||
/** 相册列表(管理视角:当前用户可见,创建时间倒序) */
|
||||
export function fetchAlbumList(params: { cursor?: string; limit?: number }) {
|
||||
return request.get<Api.Album.ListResponse>({ url: '/v1/albums', params })
|
||||
}
|
||||
|
||||
/** 相册详情(完整配置 + 多语言内容 + 分类) */
|
||||
export function fetchAlbum(albumId: string) {
|
||||
return request.get<Api.Album.Detail>({ url: `/v1/albums/${albumId}` })
|
||||
}
|
||||
|
||||
/** 创建相册(创建者自动成为 owner 成员) */
|
||||
export function fetchCreateAlbum(data: Api.Album.CreatePayload) {
|
||||
return request.post<Api.Album.Detail>({ url: '/v1/albums', data })
|
||||
}
|
||||
|
||||
/** 更新相册(部分更新;translations 全量替换,须含 defaultLocale 条目) */
|
||||
export function fetchUpdateAlbum(albumId: string, data: Api.Album.UpdatePayload) {
|
||||
return request.patch<Api.Album.Detail>({ url: `/v1/albums/${albumId}`, data })
|
||||
}
|
||||
|
||||
/** 初始化资产上传(banner/cover/logo;返回 staging 直传凭证) */
|
||||
export function fetchInitAlbumAsset(albumId: string, data: Api.Album.AssetInitPayload) {
|
||||
return request.post<Api.Album.AssetInitResponse>({
|
||||
url: `/v1/albums/${albumId}/assets`,
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
/** 完成资产上传核验(幂等;返回短期签名 URL,即预览/刷新入口) */
|
||||
export function fetchCompleteAlbumAsset(albumId: string, assetId: string) {
|
||||
return request.post<Api.Album.AssetCompleteResponse>({
|
||||
url: `/v1/albums/${albumId}/assets/${assetId}/complete`
|
||||
})
|
||||
}
|
||||
|
||||
/** 成员列表(含 owner) */
|
||||
export function fetchAlbumMembers(albumId: string, params: { cursor?: string; limit?: number }) {
|
||||
return request.get<Api.Album.MemberListResponse>({
|
||||
url: `/v1/albums/${albumId}/members`,
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
/** 添加成员(按用户 ID;重复添加 409 MEMBER_CONFLICT) */
|
||||
export function fetchAddAlbumMember(albumId: string, userId: string) {
|
||||
return request.post<Api.Album.Member>({
|
||||
url: `/v1/albums/${albumId}/members`,
|
||||
data: { userId, role: 'collaborator' }
|
||||
})
|
||||
}
|
||||
|
||||
/** 移除成员(owner 不可移除 403;目标不存在幂等 204) */
|
||||
export function fetchRemoveAlbumMember(albumId: string, userId: string) {
|
||||
return request.del<void>({ url: `/v1/albums/${albumId}/members/${userId}` })
|
||||
}
|
||||
|
||||
/** 账号前缀查询(邀请协作者前置;≥2 字符,激活用户) */
|
||||
export function fetchLookupUsers(accountPrefix: string, limit = 10) {
|
||||
return request.get<{ items: Api.Album.UserLookupItem[] }>({
|
||||
url: '/v1/admin/users',
|
||||
params: { accountPrefix, limit },
|
||||
showErrorMessage: false
|
||||
})
|
||||
}
|
||||
|
||||
/** 创建分类 */
|
||||
export function fetchCreateCategory(albumId: string, data: Api.Album.CategoryCreatePayload) {
|
||||
return request.post<Api.Album.Category>({
|
||||
url: `/v1/albums/${albumId}/categories`,
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
/** 更新分类(translations 全量替换) */
|
||||
export function fetchUpdateCategory(categoryId: string, data: Api.Album.CategoryUpdatePayload) {
|
||||
return request.patch<Api.Album.Category>({ url: `/v1/categories/${categoryId}`, data })
|
||||
}
|
||||
|
||||
/** 删除分类(204;分类下有照片时服务端 400 拒绝) */
|
||||
export function fetchDeleteCategory(categoryId: string) {
|
||||
return request.del<void>({ url: `/v1/categories/${categoryId}` })
|
||||
}
|
||||
|
||||
/** 管理照片列表(全状态可见 + uploader 脱敏;uploadedAt 倒序游标) */
|
||||
export function fetchAlbumPhotos(
|
||||
albumId: string,
|
||||
params: {
|
||||
visibility?: Api.Album.PhotoVisibility
|
||||
categoryId?: string
|
||||
cursor?: string
|
||||
limit?: number
|
||||
}
|
||||
) {
|
||||
return request.get<Api.Album.AdminPhotoListResponse>({
|
||||
url: `/v1/albums/${albumId}/photos`,
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
/** 调整照片可见性(仅 hidden ↔ published) */
|
||||
export function fetchUpdatePhotoVisibility(photoId: string, visibility: 'hidden' | 'published') {
|
||||
return request.patch<Api.Album.AdminPhoto>({
|
||||
url: `/v1/photos/${photoId}`,
|
||||
data: { visibility }
|
||||
})
|
||||
}
|
||||
|
||||
/** 软删除照片(204;deleted 为员工侧终态) */
|
||||
export function fetchDeletePhoto(photoId: string) {
|
||||
return request.del<void>({ url: `/v1/photos/${photoId}` })
|
||||
}
|
||||
Reference in New Issue
Block a user