db: add more tables

This commit is contained in:
Muyao CHEN
2024-10-19 13:28:02 +02:00
parent 80a5f1f8a8
commit dac36db284
9 changed files with 74 additions and 11 deletions

View File

@ -27,6 +27,17 @@ type Event struct {
TotalAmount sql.NullInt32
}
type Expense struct {
ID int32
CreatedAt time.Time
UpdatedAt time.Time
Amount int32
Currency string
EventID int32
Name sql.NullInt32
Place sql.NullInt32
}
type Participation struct {
ID int32
UserID int32
@ -36,6 +47,17 @@ type Participation struct {
UpdatedAt time.Time
}
type Transaction struct {
ID int32
ExpenseID int32
UserID int32
Amount int32
Currency string
IsIncome bool
CreatedAt time.Time
UpdatedAt time.Time
}
type User struct {
ID int32
Email string

View File

@ -32,8 +32,12 @@ type ExpenseRequest struct {
Detail ExpenseDetail `json:"detail"`
}
// {{{ Entity
type ExpenseEntity struct {
ID int
ID int
CreatedAt time.Time
UpdatedAt time.Time
Amount int
Currency string
@ -42,9 +46,6 @@ type ExpenseEntity struct {
// ExpenseDetail
Name string
Place string
CreatedAt time.Time
UpdatedAt time.Time
}
type ExpenseDetail struct {
@ -52,8 +53,11 @@ type ExpenseDetail struct {
Place string `json:"place"`
}
// }}}
type Expense struct {
ID int
ID int
CreatedAt time.Time
UpdatedAt time.Time
Amount Money
@ -65,7 +69,4 @@ type Expense struct {
EventID int
Detail ExpenseDetail
CreatedAt time.Time
UpdatedAt time.Time
}

View File

@ -24,18 +24,25 @@ package model
import "time"
// {{{ Entity
type TransactionEntity Transaction
// Transaction is the association between Expenses and Users
// }}}
// {{{ Domain object
type Transaction struct {
ID int
ExpenseID Expense
ExpenseID int
UserID int
Amount int
Currency string
IsIncome bool
IsIncome bool // To note that the direction of the money (payment or income)
CreatedAt time.Time
UpdatedAt time.Time
}
// }}}
// Transaction is the association between Expenses and Users