feat(ui): add collection and share link pages and management actions

This commit is contained in:
yiling
2026-06-06 12:02:51 +08:00
parent 0d76ddfc34
commit 6ebeb3f804
22 changed files with 2052 additions and 69 deletions
+6 -1
View File
@@ -7,14 +7,16 @@ import {
} from '@shumai/dtos'
export class CollectionService {
async createCollection(projectId: string, req: CreateCollectionRequest) {
async createCollection(projectId: string, req: CreateCollectionRequest, creatorId?: string) {
return await prisma.collection.create({
data: {
name: req.name,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
filter: req.filter as any,
projectId,
creatorId,
},
include: { creator: true },
})
}
@@ -26,6 +28,7 @@ export class CollectionService {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
...(req.filter && { filter: req.filter as any }),
},
include: { creator: true },
})
}
@@ -38,6 +41,7 @@ export class CollectionService {
async getCollection(collectionId: string) {
return await prisma.collection.findUnique({
where: { id: collectionId },
include: { creator: true },
})
}
@@ -46,6 +50,7 @@ export class CollectionService {
(skip, take) =>
prisma.collection.findMany({
where: { projectId },
include: { creator: true },
orderBy: { id: 'desc' },
skip,
take,
+13 -1
View File
@@ -10,7 +10,11 @@ import {
import { PaginatedData, paginateQuery } from '@shumai/core/src/pagination'
export class ShareService {
async createShareLink(projectId: string, req: CreateShareLinkRequest): Promise<ShareLinkInfo> {
async createShareLink(
projectId: string,
req: CreateShareLinkRequest,
creatorId?: string,
): Promise<ShareLinkInfo> {
let project = await prisma.project.findUnique({
where: { id: projectId },
include: { shareRoot: true },
@@ -55,7 +59,9 @@ export class ShareService {
defaultSortOrder: req.defaultSortOrder,
projectId: projectId,
rootFolderId: shareFolder.id,
creatorId,
},
include: { creator: true },
})
return this.toShareLinkInfo(shareLink)
@@ -79,6 +85,7 @@ export class ShareService {
defaultSortOrder: req.defaultSortOrder,
fieldVisibility: (req.fieldVisibility as PrismaJson.ShareLinkFieldVisibility) ?? undefined,
},
include: { creator: true },
})
if (req.name) {
@@ -116,6 +123,7 @@ export class ShareService {
async (skip, take) => {
const links = await prisma.shareLink.findMany({
where,
include: { creator: true },
skip,
take,
orderBy: { createdAt: 'desc' },
@@ -130,6 +138,7 @@ export class ShareService {
async getShareLink(shareLinkId: string): Promise<ShareLinkInfo> {
const shareLink = await prisma.shareLink.findUnique({
where: { id: shareLinkId },
include: { creator: true },
})
if (!shareLink) throw new Error('Share link not found')
return this.toShareLinkInfo(shareLink)
@@ -295,6 +304,9 @@ export class ShareService {
isExpired,
createdAt: l.createdAt.toISOString(),
updatedAt: l.updatedAt.toISOString(),
creator: l.creator
? { id: l.creator.id, name: l.creator.name, image: l.creator.image ?? undefined }
: null,
}
}
}