251210:1709 Frontend: reeactor organization and run build
This commit is contained in:
@@ -43,6 +43,30 @@ export class MasterController {
|
||||
return this.masterService.findAllCorrespondenceTypes();
|
||||
}
|
||||
|
||||
@Post('correspondence-types')
|
||||
@RequirePermission('master_data.manage')
|
||||
@ApiOperation({ summary: 'Create Correspondence Type' })
|
||||
createCorrespondenceType(@Body() dto: any) {
|
||||
return this.masterService.createCorrespondenceType(dto);
|
||||
}
|
||||
|
||||
@Patch('correspondence-types/:id')
|
||||
@RequirePermission('master_data.manage')
|
||||
@ApiOperation({ summary: 'Update Correspondence Type' })
|
||||
updateCorrespondenceType(
|
||||
@Param('id', ParseIntPipe) id: number,
|
||||
@Body() dto: any
|
||||
) {
|
||||
return this.masterService.updateCorrespondenceType(id, dto);
|
||||
}
|
||||
|
||||
@Delete('correspondence-types/:id')
|
||||
@RequirePermission('master_data.manage')
|
||||
@ApiOperation({ summary: 'Delete Correspondence Type' })
|
||||
deleteCorrespondenceType(@Param('id', ParseIntPipe) id: number) {
|
||||
return this.masterService.deleteCorrespondenceType(id);
|
||||
}
|
||||
|
||||
@Get('correspondence-statuses')
|
||||
@ApiOperation({ summary: 'Get all active correspondence statuses' })
|
||||
getCorrespondenceStatuses() {
|
||||
@@ -51,8 +75,33 @@ export class MasterController {
|
||||
|
||||
@Get('rfa-types')
|
||||
@ApiOperation({ summary: 'Get all active RFA types' })
|
||||
getRfaTypes() {
|
||||
return this.masterService.findAllRfaTypes();
|
||||
@ApiQuery({ name: 'contractId', required: false, type: Number })
|
||||
getRfaTypes(@Query('contractId') contractId?: number) {
|
||||
return this.masterService.findAllRfaTypes(contractId);
|
||||
}
|
||||
|
||||
@Post('rfa-types')
|
||||
@RequirePermission('master_data.manage')
|
||||
@ApiOperation({ summary: 'Create RFA Type' })
|
||||
createRfaType(@Body() dto: any) {
|
||||
// Note: Should use proper DTO. Delegating to service.
|
||||
// Need to add createRfaType to MasterService or RfaService?
|
||||
// Given the context, MasterService seems appropriate for "Reference Data".
|
||||
return this.masterService.createRfaType(dto);
|
||||
}
|
||||
|
||||
@Patch('rfa-types/:id')
|
||||
@RequirePermission('master_data.manage')
|
||||
@ApiOperation({ summary: 'Update RFA Type' })
|
||||
updateRfaType(@Param('id', ParseIntPipe) id: number, @Body() dto: any) {
|
||||
return this.masterService.updateRfaType(id, dto);
|
||||
}
|
||||
|
||||
@Delete('rfa-types/:id')
|
||||
@RequirePermission('master_data.manage')
|
||||
@ApiOperation({ summary: 'Delete RFA Type' })
|
||||
deleteRfaType(@Param('id', ParseIntPipe) id: number) {
|
||||
return this.masterService.deleteRfaType(id);
|
||||
}
|
||||
|
||||
@Get('rfa-statuses')
|
||||
@@ -108,7 +157,7 @@ export class MasterController {
|
||||
@ApiQuery({ name: 'typeId', required: false, type: Number })
|
||||
getSubTypes(
|
||||
@Query('contractId') contractId?: number,
|
||||
@Query('typeId') typeId?: number,
|
||||
@Query('typeId') typeId?: number
|
||||
) {
|
||||
return this.masterService.findAllSubTypes(contractId, typeId);
|
||||
}
|
||||
@@ -136,7 +185,7 @@ export class MasterController {
|
||||
@ApiOperation({ summary: 'Get numbering format for specific project/type' })
|
||||
getNumberFormat(
|
||||
@Query('projectId', ParseIntPipe) projectId: number,
|
||||
@Query('typeId', ParseIntPipe) typeId: number,
|
||||
@Query('typeId', ParseIntPipe) typeId: number
|
||||
) {
|
||||
return this.masterService.findNumberFormat(projectId, typeId);
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ export class MasterService {
|
||||
@InjectRepository(CorrespondenceSubType)
|
||||
private readonly subTypeRepo: Repository<CorrespondenceSubType>,
|
||||
@InjectRepository(DocumentNumberFormat)
|
||||
private readonly formatRepo: Repository<DocumentNumberFormat>,
|
||||
private readonly formatRepo: Repository<DocumentNumberFormat>
|
||||
) {}
|
||||
|
||||
// ... (Method เดิม: findAllCorrespondenceTypes, findAllCorrespondenceStatuses, ฯลฯ เก็บไว้เหมือนเดิม) ...
|
||||
@@ -67,18 +67,62 @@ export class MasterService {
|
||||
order: { sortOrder: 'ASC' },
|
||||
});
|
||||
}
|
||||
|
||||
async createCorrespondenceType(dto: any) {
|
||||
const item = this.corrTypeRepo.create(dto);
|
||||
return this.corrTypeRepo.save(item);
|
||||
}
|
||||
|
||||
async updateCorrespondenceType(id: number, dto: any) {
|
||||
const item = await this.corrTypeRepo.findOne({ where: { id } });
|
||||
if (!item) throw new NotFoundException('Correspondence Type not found');
|
||||
Object.assign(item, dto);
|
||||
return this.corrTypeRepo.save(item);
|
||||
}
|
||||
|
||||
async deleteCorrespondenceType(id: number) {
|
||||
const result = await this.corrTypeRepo.delete(id);
|
||||
if (result.affected === 0)
|
||||
throw new NotFoundException('Correspondence Type not found');
|
||||
return { deleted: true };
|
||||
}
|
||||
async findAllCorrespondenceStatuses() {
|
||||
return this.corrStatusRepo.find({
|
||||
where: { isActive: true },
|
||||
order: { sortOrder: 'ASC' },
|
||||
});
|
||||
}
|
||||
async findAllRfaTypes() {
|
||||
async findAllRfaTypes(contractId?: number) {
|
||||
const where: any = { isActive: true };
|
||||
if (contractId) {
|
||||
where.contractId = contractId;
|
||||
}
|
||||
return this.rfaTypeRepo.find({
|
||||
where: { isActive: true },
|
||||
order: { sortOrder: 'ASC' },
|
||||
where,
|
||||
order: { typeCode: 'ASC' },
|
||||
relations: contractId ? [] : [], // Add relations if needed later
|
||||
});
|
||||
}
|
||||
|
||||
async createRfaType(dto: any) {
|
||||
// Validate unique code if needed
|
||||
const rfaType = this.rfaTypeRepo.create(dto);
|
||||
return this.rfaTypeRepo.save(rfaType);
|
||||
}
|
||||
|
||||
async updateRfaType(id: number, dto: any) {
|
||||
const rfaType = await this.rfaTypeRepo.findOne({ where: { id } });
|
||||
if (!rfaType) throw new NotFoundException('RFA Type not found');
|
||||
Object.assign(rfaType, dto);
|
||||
return this.rfaTypeRepo.save(rfaType);
|
||||
}
|
||||
|
||||
async deleteRfaType(id: number) {
|
||||
const result = await this.rfaTypeRepo.delete(id);
|
||||
if (result.affected === 0)
|
||||
throw new NotFoundException('RFA Type not found');
|
||||
return { deleted: true };
|
||||
}
|
||||
async findAllRfaStatuses() {
|
||||
return this.rfaStatusRepo.find({
|
||||
where: { isActive: true },
|
||||
@@ -123,7 +167,7 @@ export class MasterService {
|
||||
});
|
||||
if (exists)
|
||||
throw new ConflictException(
|
||||
'Discipline code already exists in this contract',
|
||||
'Discipline code already exists in this contract'
|
||||
);
|
||||
|
||||
const discipline = this.disciplineRepo.create(dto);
|
||||
|
||||
Reference in New Issue
Block a user