feat: implement project development module, transfer management features, and industrial AVM model integration
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { Inject } from '@nestjs/common';
|
||||
import { type IQueryHandler, QueryHandler } from '@nestjs/cqrs';
|
||||
import {
|
||||
PROJECT_REPOSITORY,
|
||||
type IProjectRepository,
|
||||
type ProjectDetailData,
|
||||
} from '../../../domain/repositories/project-development.repository';
|
||||
import { GetProjectQuery } from './get-project.query';
|
||||
|
||||
@QueryHandler(GetProjectQuery)
|
||||
export class GetProjectHandler implements IQueryHandler<GetProjectQuery> {
|
||||
constructor(
|
||||
@Inject(PROJECT_REPOSITORY)
|
||||
private readonly repo: IProjectRepository,
|
||||
) {}
|
||||
|
||||
async execute(query: GetProjectQuery): Promise<ProjectDetailData | null> {
|
||||
// Try slug first, then ID
|
||||
const bySlug = await this.repo.findDetailBySlug(query.slugOrId);
|
||||
if (bySlug) return bySlug;
|
||||
return this.repo.findDetailById(query.slugOrId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export class GetProjectQuery {
|
||||
constructor(public readonly slugOrId: string) {}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import { Inject } from '@nestjs/common';
|
||||
import { type IQueryHandler, QueryHandler } from '@nestjs/cqrs';
|
||||
import {
|
||||
PROJECT_REPOSITORY,
|
||||
type IProjectRepository,
|
||||
type PaginatedResult,
|
||||
type ProjectListItem,
|
||||
} from '../../../domain/repositories/project-development.repository';
|
||||
import { ListProjectsQuery } from './list-projects.query';
|
||||
|
||||
@QueryHandler(ListProjectsQuery)
|
||||
export class ListProjectsHandler implements IQueryHandler<ListProjectsQuery> {
|
||||
constructor(
|
||||
@Inject(PROJECT_REPOSITORY)
|
||||
private readonly repo: IProjectRepository,
|
||||
) {}
|
||||
|
||||
async execute(query: ListProjectsQuery): Promise<PaginatedResult<ProjectListItem>> {
|
||||
return this.repo.search({
|
||||
query: query.query,
|
||||
status: query.status,
|
||||
city: query.city,
|
||||
district: query.district,
|
||||
developer: query.developer,
|
||||
isVerified: query.isVerified,
|
||||
page: query.page,
|
||||
limit: query.limit,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import type { ProjectDevelopmentStatus } from '@prisma/client';
|
||||
|
||||
export class ListProjectsQuery {
|
||||
constructor(
|
||||
public readonly query: string | undefined,
|
||||
public readonly status: ProjectDevelopmentStatus | undefined,
|
||||
public readonly city: string | undefined,
|
||||
public readonly district: string | undefined,
|
||||
public readonly developer: string | undefined,
|
||||
public readonly isVerified: boolean | undefined,
|
||||
public readonly page: number,
|
||||
public readonly limit: number,
|
||||
) {}
|
||||
}
|
||||
Reference in New Issue
Block a user