mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-26 10:55:27 +00:00
feat(ui): add collection and share link pages and management actions
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user