modeling out expense entities and dtos
This commit is contained in:
parent
acdb7ad9c9
commit
c2180e4ee9
6 changed files with 41 additions and 9 deletions
|
|
@ -1 +0,0 @@
|
|||
export class CreateExpenseDto {}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
import { PartialType } from '@nestjs/mapped-types';
|
||||
import { CreateExpenseDto } from './create-expense.dto';
|
||||
|
||||
export class CreateExpenseDto {}
|
||||
|
||||
export class UpdateExpenseDto extends PartialType(CreateExpenseDto) {}
|
||||
32
src/controllers/expenses/expense.entities.ts
Normal file
32
src/controllers/expenses/expense.entities.ts
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
export class Expense {
|
||||
id: number;
|
||||
year: string;
|
||||
month: string;
|
||||
day: string;
|
||||
cents: number;
|
||||
category: Category;
|
||||
subcategory?: SubCategory[];
|
||||
merchant?: Merchant;
|
||||
tags?: Tag[];
|
||||
description?: string;
|
||||
}
|
||||
|
||||
export class Category {
|
||||
id: number;
|
||||
category: string;
|
||||
}
|
||||
|
||||
export class SubCategory {
|
||||
id: number;
|
||||
subcategory: string;
|
||||
}
|
||||
|
||||
export class Merchant {
|
||||
id: number;
|
||||
merchant: string;
|
||||
}
|
||||
|
||||
export class Tag {
|
||||
id: number;
|
||||
tag: string;
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
export class Expense {}
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
|
||||
import { ExpensesService } from '../../services/expenses.service';
|
||||
import { CreateExpenseDto } from './create-expense.dto';
|
||||
import { UpdateExpenseDto } from './update-expense.dto';
|
||||
import { CreateExpenseDto, UpdateExpenseDto } from './expense.dto';
|
||||
|
||||
@Controller('expenses')
|
||||
export class ExpensesController {
|
||||
|
|
|
|||
|
|
@ -1,15 +1,17 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { CreateExpenseDto } from '../controllers/expenses/create-expense.dto';
|
||||
import { UpdateExpenseDto } from '../controllers/expenses/update-expense.dto';
|
||||
import { Expense } from '../controllers/expenses/expense.entities';
|
||||
import { CreateExpenseDto, UpdateExpenseDto } from '../controllers/expenses/expense.dto';
|
||||
|
||||
@Injectable()
|
||||
export class ExpensesService {
|
||||
private fakeTempData: Expense[] = [];
|
||||
|
||||
create(createExpenseDto: CreateExpenseDto) {
|
||||
return 'This action adds a new expense';
|
||||
}
|
||||
|
||||
findAll() {
|
||||
return `This action returns all expenses`;
|
||||
findAll(): Expense[] {
|
||||
return this.fakeTempData;
|
||||
}
|
||||
|
||||
findOne(id: number) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue