generated from dave/wails-template
Add go files from previous project
This commit is contained in:
38
app.go
38
app.go
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
// App struct
|
||||
@@ -19,3 +20,40 @@ func NewApp() *App {
|
||||
func (a *App) startup(ctx context.Context) {
|
||||
a.ctx = ctx
|
||||
}
|
||||
|
||||
func (a *App) GetBills() WailsBills {
|
||||
res := WailsBills{}
|
||||
bills, err := service.GetAllBills()
|
||||
if err != nil {
|
||||
res.Success = false
|
||||
res.Error = err.Error()
|
||||
return res
|
||||
}
|
||||
res.Success = true
|
||||
res.Data = bills
|
||||
return res
|
||||
}
|
||||
func (a *App) GetPaymentsForMonth(month time.Time) WailsPayments {
|
||||
res := WailsPayments{}
|
||||
payments, err := service.GetPaymentsForDate(month)
|
||||
if err != nil {
|
||||
res.Success = false
|
||||
res.Error = err.Error()
|
||||
return res
|
||||
}
|
||||
res.Success = true
|
||||
res.Data = payments
|
||||
return res
|
||||
}
|
||||
func (a *App) SetPaid(billid int64, month time.Time) WailsPayment {
|
||||
res := WailsPayment{}
|
||||
payment, err := service.MarkPaid(billid, month, time.Now())
|
||||
if err!= nil {
|
||||
res.Success = false
|
||||
res.Error = err.Error()
|
||||
return res
|
||||
}
|
||||
res.Success = true
|
||||
res.Data = payment
|
||||
return res
|
||||
}
|
Reference in New Issue
Block a user