mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 05:10:31 +00:00
refactor: migrate item categories module to nestjs
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
Param,
|
||||
Post,
|
||||
Put,
|
||||
} from '@nestjs/common';
|
||||
import { ExpensesApplication } from './ExpensesApplication.service';
|
||||
import {
|
||||
IExpenseCreateDTO,
|
||||
IExpenseEditDTO,
|
||||
} from './interfaces/Expenses.interface';
|
||||
|
||||
@Controller('expenses')
|
||||
export class ExpensesController {
|
||||
constructor(private readonly expensesApplication: ExpensesApplication) {}
|
||||
|
||||
/**
|
||||
* Create a new expense transaction.
|
||||
* @param {IExpenseCreateDTO} expenseDTO
|
||||
*/
|
||||
@Post()
|
||||
public createExpense(@Body() expenseDTO: IExpenseCreateDTO) {
|
||||
return this.expensesApplication.createExpense(expenseDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit the given expense transaction.
|
||||
* @param {number} expenseId
|
||||
* @param {IExpenseEditDTO} expenseDTO
|
||||
*/
|
||||
@Put(':id')
|
||||
public editExpense(
|
||||
@Param('id') expenseId: number,
|
||||
@Body() expenseDTO: IExpenseEditDTO,
|
||||
) {
|
||||
return this.expensesApplication.editExpense(expenseId, expenseDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the given expense transaction.
|
||||
* @param {number} expenseId
|
||||
*/
|
||||
@Delete(':id')
|
||||
public deleteExpense(@Param('id') expenseId: number) {
|
||||
return this.expensesApplication.deleteExpense(expenseId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish the given expense transaction.
|
||||
* @param {number} expenseId
|
||||
*/
|
||||
@Post(':id/publish')
|
||||
public publishExpense(@Param('id') expenseId: number) {
|
||||
return this.expensesApplication.publishExpense(expenseId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the expense transaction details.
|
||||
* @param {number} expenseId
|
||||
*/
|
||||
@Get(':id')
|
||||
public getExpense(@Param('id') expenseId: number) {
|
||||
return this.expensesApplication.getExpense(expenseId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user