Planner/core/models.go

55 lines
1.6 KiB
Go
Raw Normal View History

2025-02-12 19:29:00 +01:00
package core
2024-11-09 19:35:44 +01:00
2025-04-09 18:37:02 +02:00
import "github.com/shopspring/decimal"
2024-11-09 19:35:44 +01:00
type User struct {
2025-04-16 23:24:23 +02:00
Username string `json:"username"`
Password string `json:"password"`
2025-01-14 20:14:07 +01:00
}
type Member struct {
2025-04-16 23:24:23 +02:00
Id uint `json:"-"`
PlanId uint `json:"-"`
Name string `json:"name,omitempty"`
UserId *string `json:"username,omitempty"`
2024-11-09 19:35:44 +01:00
}
// CREATE TABLE plans(id INTEGER PRIMARY KEY AUTOINCREMENT, name STRING, owner STRING, FOREIGN KEY(owner) REFERENCES users(username))
// CREATE TABLE plan_user_relations(username STRING, plan INTEGER, PRIMARY KEY(username, plan), FOREIGN KEY username REFERENCES user(username), FOREIGN KEY plan REFERENCES plans(id))
type Plan struct {
2025-04-16 23:24:23 +02:00
Id uint `json:"id"`
Name string `json:"name"`
Owner string `json:"owner"`
Description string `json:"description"`
JoinCode string `json:"join_code,omitempty"`
2024-11-09 19:35:44 +01:00
}
2025-04-09 18:37:02 +02:00
type Expense struct {
2025-04-16 23:24:23 +02:00
Id uint `json:"id"`
PlanId uint `json:"-"`
PayerId uint `json:"-"`
2025-04-09 18:37:02 +02:00
Amount decimal.Decimal `json:"amount"`
}
type Debt struct {
2025-04-16 23:24:23 +02:00
Id uint
ExpenseId uint `json:"-"`
DebtorId uint `json:"-"`
2025-04-09 18:37:02 +02:00
Amount decimal.Decimal
Paid decimal.Decimal
}
2024-11-09 19:35:44 +01:00
// CREATE TABLE polls(id INTEGER PRIMARY KEY AUTOINCREMENT, plan INTEGER, name STRING, options JSON, FOREIGN KEY plan REFERENCES plans(id))
type Poll struct {
2025-04-16 23:24:23 +02:00
Id uint `json:"id"`
PlanId uint `json:"-"`
2024-11-09 19:35:44 +01:00
Options string `json:"options"`
}
// CREATE TABLE votes(id INTEGER, poll INTEGER, user STRING, value JSON, FOREIGN KEY poll REFERENCES polls(id), FOREIGN KEY user REFERENCES user(username))
type Vote struct {
2025-04-16 23:24:23 +02:00
PollId uint `json:"-"`
MemberId uint `json:"member_id"`
Value string `json:"value"`
2024-11-09 19:35:44 +01:00
}