260324:2133 Refactor correspondence & rfa
This commit is contained in:
@@ -95,13 +95,23 @@ export class CirculationService {
|
||||
}
|
||||
|
||||
async findAll(searchDto: SearchCirculationDto, user: User) {
|
||||
const { status, page = 1, limit = 20 } = searchDto;
|
||||
const { status, correspondenceUuid, page = 1, limit = 20 } = searchDto;
|
||||
const query = this.circulationRepo
|
||||
.createQueryBuilder('c')
|
||||
.leftJoinAndSelect('c.creator', 'creator')
|
||||
.where('c.organizationId = :orgId', {
|
||||
.leftJoinAndSelect('c.routings', 'routings')
|
||||
.leftJoinAndSelect('routings.assignee', 'assignee')
|
||||
.leftJoinAndSelect('c.correspondence', 'correspondence');
|
||||
|
||||
if (correspondenceUuid) {
|
||||
query.where('correspondence.uuid = :corrUuid', {
|
||||
corrUuid: correspondenceUuid,
|
||||
});
|
||||
} else {
|
||||
query.where('c.organizationId = :orgId', {
|
||||
orgId: user.primaryOrganizationId,
|
||||
});
|
||||
}
|
||||
|
||||
if (status) {
|
||||
query.andWhere('c.statusCode = :status', { status });
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { IsInt, IsOptional, IsString } from 'class-validator';
|
||||
import { IsInt, IsOptional, IsString, IsUUID } from 'class-validator';
|
||||
import { Type } from 'class-transformer';
|
||||
|
||||
export class SearchCirculationDto {
|
||||
@@ -6,6 +6,10 @@ export class SearchCirculationDto {
|
||||
@IsString()
|
||||
search?: string; // ค้นหาจาก Subject หรือ No.
|
||||
|
||||
@IsOptional()
|
||||
@IsUUID('all')
|
||||
correspondenceUuid?: string; // กรองตาม correspondence UUID (ADR-019)
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
status?: string; // OPEN, COMPLETED
|
||||
|
||||
Reference in New Issue
Block a user