-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from Nabute/feature/add-transaction-interceptor
feat: add db transaction interceptor and made it atomic
- Loading branch information
Showing
25 changed files
with
1,283 additions
and
1,087 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { | ||
Controller, | ||
Post, | ||
Body, | ||
Get, | ||
Param, | ||
Req, | ||
} from '@nestjs/common'; | ||
import { ApiTags, ApiOperation } from '@nestjs/swagger'; | ||
import { CreateDataLookupDto } from '../dtos/core.dto'; | ||
import { DataLookupService } from '../services/data-lookup.service'; | ||
import { ConfigService } from '@nestjs/config'; | ||
|
||
const config = new ConfigService(); | ||
|
||
/** | ||
* Controller for managing lookup data. | ||
*/ | ||
@ApiTags('Configurations') | ||
@Controller({ path: 'core/lookup-data', version: config.get('API_VERSION') }) | ||
export class DataLookupController { | ||
constructor(private readonly dataLookupService: DataLookupService) { } | ||
|
||
/** | ||
* Creates a new data lookup entry. | ||
* | ||
* @param createDataLookupDto - DTO containing the data to create a new data lookup entry. | ||
* @param req - The HTTP request object, which contains the transaction manager. | ||
* @returns The newly created DataLookup entity. | ||
*/ | ||
@Post() | ||
@ApiOperation({ summary: 'Create a new data lookup entry' }) | ||
async create(@Body() createDataLookupDto: CreateDataLookupDto, @Req() req: any) { | ||
const entityManager = req.transactionManager; | ||
return this.dataLookupService.create(createDataLookupDto, entityManager); | ||
} | ||
|
||
/** | ||
* Creates multiple data lookup entries in bulk. | ||
* | ||
* @param createDataLookupDtos - Array of DTOs containing the data to create multiple data lookup entries. | ||
* @param req - The HTTP request object, which contains the transaction manager. | ||
* @returns An array of created DataLookup entities. | ||
*/ | ||
@Post('bulk') | ||
@ApiOperation({ summary: 'Create multiple data lookup entries in bulk' }) | ||
async createBulk(@Body() createDataLookupDtos: CreateDataLookupDto[], @Req() req: any) { | ||
const entityManager = req.transactionManager; | ||
return this.dataLookupService.createBulk(createDataLookupDtos, entityManager); | ||
} | ||
|
||
/** | ||
* Retrieves all data lookup entries. | ||
* | ||
* @param req - The HTTP request object, which contains the transaction manager. | ||
* @returns An array of DataLookup entities. | ||
*/ | ||
@Get() | ||
@ApiOperation({ summary: 'Retrieve all data lookup entries' }) | ||
async findAll(@Req() req: any) { | ||
const entityManager = req.transactionManager; | ||
return this.dataLookupService.findAll(entityManager); | ||
} | ||
|
||
/** | ||
* Retrieves a single data lookup entry by ID. | ||
* | ||
* @param id - The ID of the data lookup entry to retrieve. | ||
* @param req - The HTTP request object, which contains the transaction manager. | ||
* @returns The found DataLookup entity. | ||
*/ | ||
@Get(':id') | ||
@ApiOperation({ summary: 'Retrieve a single data lookup entry by ID' }) | ||
async findOne(@Param('id') id: string, @Req() req: any) { | ||
const entityManager = req.transactionManager; | ||
return this.dataLookupService.findOne(id, entityManager); | ||
} | ||
} |
Oops, something went wrong.