mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-26 21:54:54 +00:00
resolve conflicts
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import { Controller, Get, HttpException, HttpStatus } from '@nestjs/common';
|
||||
import { Controller, Get } from '@nestjs/common';
|
||||
import { RegionService } from '../services/region.service';
|
||||
import { ApiTags, ApiOperation } from '@nestjs/swagger';
|
||||
import { ControllerRoute } from '@app/common/constants/controller-route';
|
||||
@ -18,13 +18,6 @@ export class RegionController {
|
||||
description: ControllerRoute.REGION.ACTIONS.GET_REGIONS_DESCRIPTION,
|
||||
})
|
||||
async getAllRegions() {
|
||||
try {
|
||||
return await this.regionService.getAllRegions();
|
||||
} catch (error) {
|
||||
throw new HttpException(
|
||||
error.message || 'Internal server error',
|
||||
error.status || HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
);
|
||||
}
|
||||
return await this.regionService.getAllRegions();
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,9 +3,10 @@ import { RegionService } from './services/region.service';
|
||||
import { RegionController } from './controllers/region.controller';
|
||||
import { ConfigModule } from '@nestjs/config';
|
||||
import { RegionRepository } from '@app/common/modules/region/repositories';
|
||||
import { CommonModule } from '@app/common';
|
||||
|
||||
@Module({
|
||||
imports: [ConfigModule],
|
||||
imports: [ConfigModule, CommonModule],
|
||||
controllers: [RegionController],
|
||||
providers: [RegionService, RegionRepository],
|
||||
exports: [RegionService],
|
||||
|
||||
@ -2,23 +2,33 @@ import {
|
||||
BadRequestException,
|
||||
HttpException,
|
||||
HttpStatus,
|
||||
Inject,
|
||||
Injectable,
|
||||
} from '@nestjs/common';
|
||||
import { RegionRepository } from '@app/common/modules/region/repositories';
|
||||
import { ErrorMessageService } from 'src/error-message/error-message.service';
|
||||
|
||||
@Injectable()
|
||||
export class RegionService {
|
||||
constructor(private readonly regionRepository: RegionRepository) {}
|
||||
constructor(
|
||||
private readonly regionRepository: RegionRepository,
|
||||
@Inject(ErrorMessageService)
|
||||
private readonly errorMessageService: ErrorMessageService,
|
||||
) {}
|
||||
async getAllRegions() {
|
||||
try {
|
||||
const regions = await this.regionRepository.find();
|
||||
|
||||
return regions;
|
||||
} catch (err) {
|
||||
if (err instanceof BadRequestException) {
|
||||
throw err; // Re-throw BadRequestException
|
||||
} else {
|
||||
throw new HttpException('Regions found', HttpStatus.NOT_FOUND);
|
||||
throw new HttpException(
|
||||
this.errorMessageService.getMessage('NOT_FOUND', {
|
||||
entity: 'Regions',
|
||||
}),
|
||||
HttpStatus.NOT_FOUND,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user