1 parent
9f36b7cedc
commit
f0f36c4f48
7 files changed
+43
-6
No files matched your search
@@ -4,5 +4,8 @@ export class ListIssuesQuery {
|
||||
public readonly page: number,
|
||||
public readonly userId: string,
|
||||
public readonly projectId?: string,
|
||||
public readonly status?: string,
|
||||
public readonly text?: string,
|
||||
public readonly assigneeId?: string,
|
||||
) {}
|
||||
}
|
||||
@@ -19,6 +19,9 @@ export class ListIssuesUseCase {
|
||||
page: query.page,
|
||||
userId: query.userId,
|
||||
projectId: query.projectId,
|
||||
status: query.status,
|
||||
text: query.text,
|
||||
assigneeId: query.assigneeId,
|
||||
});
|
||||
|
||||
return { list: await this.issueUserExpander.expandAll(list), meta };
|
||||
|
||||
@@ -13,6 +13,8 @@ export interface IIssueRepository {
|
||||
page: number;
|
||||
userId: string;
|
||||
status?: string;
|
||||
text?: string;
|
||||
assigneeId?: string;
|
||||
projectId?: string;
|
||||
}): Promise<{ list: Issue[]; meta: PaginationMeta }>;
|
||||
countByStatus(userId: string): Promise<Array<{ status: string; count: number }>>;
|
||||
|
||||
+18
-3
@@ -41,6 +41,8 @@ export class IssuePrismaRepository implements IIssueRepository {
|
||||
page: number;
|
||||
userId: string;
|
||||
status?: string;
|
||||
text?: string;
|
||||
assigneeId?: string;
|
||||
projectId?: string;
|
||||
}): Promise<{ list: Issue[]; meta: PaginationMeta }> {
|
||||
const page = Math.max(1, params?.page);
|
||||
@@ -48,9 +50,22 @@ export class IssuePrismaRepository implements IIssueRepository {
|
||||
|
||||
const queryArgs: IssueFindManyArgs = {
|
||||
where: {
|
||||
status: params.status,
|
||||
projectId: params.projectId,
|
||||
OR: ownedByUser(params.userId),
|
||||
AND: [
|
||||
{ OR: ownedByUser(params.userId) },
|
||||
...(params.status ? [{ status: params.status }] : []),
|
||||
...(params.assigneeId ? [{ assigneeId: params.assigneeId }] : []),
|
||||
...(params.projectId ? [{ projectId: params.projectId }] : []),
|
||||
...(params.text
|
||||
? [
|
||||
{
|
||||
OR: [
|
||||
{ title: { contains: params.text, mode: Prisma.QueryMode.insensitive } },
|
||||
{ content: { contains: params.text, mode: Prisma.QueryMode.insensitive } },
|
||||
],
|
||||
},
|
||||
]
|
||||
: []),
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -70,7 +70,15 @@ export class IssueController {
|
||||
@Get('list')
|
||||
list(@Query() query: FilterIssueDto, @Session() session: UserSession) {
|
||||
return this.listIssuesUseCase.execute(
|
||||
new ListIssuesQuery(Number(query.limit), Number(query.page), session.user.id, query.projectId),
|
||||
new ListIssuesQuery(
|
||||
Number(query.limit),
|
||||
Number(query.page),
|
||||
session.user.id,
|
||||
query.projectId,
|
||||
query.status,
|
||||
query.text,
|
||||
query.assigneeId,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,13 @@ export class FilterIssueDto {
|
||||
page: number = 1;
|
||||
|
||||
@StringDecorator({ isOptional: true })
|
||||
name?: string;
|
||||
text?: string;
|
||||
|
||||
@StringDecorator({ isOptional: true })
|
||||
assigneeId?: string;
|
||||
|
||||
@StringDecorator({ isOptional: true })
|
||||
status?: string;
|
||||
|
||||
@StringDecorator({ isOptional: true })
|
||||
projectId?: string;
|
||||
|
||||
Reference in new issue
Block a user