generated from dave/wails-template
Add json tags to types
This commit is contained in:
8
app.go
8
app.go
@@ -57,3 +57,11 @@ func (a *App) SetPaid(billid int64, month time.Time) WailsPayment {
|
|||||||
res.Data = payment
|
res.Data = payment
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// These exist only so that wails generates models for Bill and Payment
|
||||||
|
func (a *App) EmptyBill() Bill {
|
||||||
|
return Bill{}
|
||||||
|
}
|
||||||
|
func (a *App) EmptyPayment() Payment {
|
||||||
|
return Payment{}
|
||||||
|
}
|
4
frontend/wailsjs/go/main/App.d.ts
vendored
4
frontend/wailsjs/go/main/App.d.ts
vendored
@@ -3,6 +3,10 @@
|
|||||||
import {main} from '../models';
|
import {main} from '../models';
|
||||||
import {time} from '../models';
|
import {time} from '../models';
|
||||||
|
|
||||||
|
export function EmptyBill():Promise<main.Bill>;
|
||||||
|
|
||||||
|
export function EmptyPayment():Promise<main.Payment>;
|
||||||
|
|
||||||
export function GetBills():Promise<main.WailsBills>;
|
export function GetBills():Promise<main.WailsBills>;
|
||||||
|
|
||||||
export function GetPaymentsForMonth(arg1:time.Time):Promise<main.WailsPayments>;
|
export function GetPaymentsForMonth(arg1:time.Time):Promise<main.WailsPayments>;
|
||||||
|
@@ -2,6 +2,14 @@
|
|||||||
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
|
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
|
||||||
// This file is automatically generated. DO NOT EDIT
|
// This file is automatically generated. DO NOT EDIT
|
||||||
|
|
||||||
|
export function EmptyBill() {
|
||||||
|
return window['go']['main']['App']['EmptyBill']();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function EmptyPayment() {
|
||||||
|
return window['go']['main']['App']['EmptyPayment']();
|
||||||
|
}
|
||||||
|
|
||||||
export function GetBills() {
|
export function GetBills() {
|
||||||
return window['go']['main']['App']['GetBills']();
|
return window['go']['main']['App']['GetBills']();
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,59 @@
|
|||||||
export namespace main {
|
export namespace main {
|
||||||
|
|
||||||
export class WailsBills {
|
export class Bill {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
|
||||||
|
static createFrom(source: any = {}) {
|
||||||
|
return new Bill(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(source: any = {}) {
|
||||||
|
if ('string' === typeof source) source = JSON.parse(source);
|
||||||
|
this.id = source["id"];
|
||||||
|
this.name = source["name"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export class Payment {
|
||||||
|
id: number;
|
||||||
|
billId: number;
|
||||||
|
monthFor: time.Time;
|
||||||
|
paymentDate: time.Time;
|
||||||
|
|
||||||
|
static createFrom(source: any = {}) {
|
||||||
|
return new Payment(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(source: any = {}) {
|
||||||
|
if ('string' === typeof source) source = JSON.parse(source);
|
||||||
|
this.id = source["id"];
|
||||||
|
this.billId = source["billId"];
|
||||||
|
this.monthFor = this.convertValues(source["monthFor"], time.Time);
|
||||||
|
this.paymentDate = this.convertValues(source["paymentDate"], time.Time);
|
||||||
|
}
|
||||||
|
|
||||||
|
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
||||||
|
if (!a) {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
if (a.slice && a.map) {
|
||||||
|
return (a as any[]).map(elem => this.convertValues(elem, classs));
|
||||||
|
} else if ("object" === typeof a) {
|
||||||
|
if (asMap) {
|
||||||
|
for (const key of Object.keys(a)) {
|
||||||
|
a[key] = new classs(a[key]);
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
return new classs(a);
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export class WailsBills {
|
||||||
|
data: Bill[];
|
||||||
|
success: boolean;
|
||||||
|
error: string;
|
||||||
|
|
||||||
static createFrom(source: any = {}) {
|
static createFrom(source: any = {}) {
|
||||||
return new WailsBills(source);
|
return new WailsBills(source);
|
||||||
@@ -9,11 +61,33 @@ export namespace main {
|
|||||||
|
|
||||||
constructor(source: any = {}) {
|
constructor(source: any = {}) {
|
||||||
if ('string' === typeof source) source = JSON.parse(source);
|
if ('string' === typeof source) source = JSON.parse(source);
|
||||||
|
this.data = this.convertValues(source["data"], Bill);
|
||||||
|
this.success = source["success"];
|
||||||
|
this.error = source["error"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
||||||
|
if (!a) {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
if (a.slice && a.map) {
|
||||||
|
return (a as any[]).map(elem => this.convertValues(elem, classs));
|
||||||
|
} else if ("object" === typeof a) {
|
||||||
|
if (asMap) {
|
||||||
|
for (const key of Object.keys(a)) {
|
||||||
|
a[key] = new classs(a[key]);
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
return new classs(a);
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
export class WailsPayment {
|
export class WailsPayment {
|
||||||
|
data: Payment;
|
||||||
|
success: boolean;
|
||||||
|
error: string;
|
||||||
|
|
||||||
static createFrom(source: any = {}) {
|
static createFrom(source: any = {}) {
|
||||||
return new WailsPayment(source);
|
return new WailsPayment(source);
|
||||||
@@ -21,11 +95,33 @@ export namespace main {
|
|||||||
|
|
||||||
constructor(source: any = {}) {
|
constructor(source: any = {}) {
|
||||||
if ('string' === typeof source) source = JSON.parse(source);
|
if ('string' === typeof source) source = JSON.parse(source);
|
||||||
|
this.data = this.convertValues(source["data"], Payment);
|
||||||
|
this.success = source["success"];
|
||||||
|
this.error = source["error"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
||||||
|
if (!a) {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
if (a.slice && a.map) {
|
||||||
|
return (a as any[]).map(elem => this.convertValues(elem, classs));
|
||||||
|
} else if ("object" === typeof a) {
|
||||||
|
if (asMap) {
|
||||||
|
for (const key of Object.keys(a)) {
|
||||||
|
a[key] = new classs(a[key]);
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
return new classs(a);
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
export class WailsPayments {
|
export class WailsPayments {
|
||||||
|
data: Payment[];
|
||||||
|
success: boolean;
|
||||||
|
error: string;
|
||||||
|
|
||||||
static createFrom(source: any = {}) {
|
static createFrom(source: any = {}) {
|
||||||
return new WailsPayments(source);
|
return new WailsPayments(source);
|
||||||
@@ -33,8 +129,28 @@ export namespace main {
|
|||||||
|
|
||||||
constructor(source: any = {}) {
|
constructor(source: any = {}) {
|
||||||
if ('string' === typeof source) source = JSON.parse(source);
|
if ('string' === typeof source) source = JSON.parse(source);
|
||||||
|
this.data = this.convertValues(source["data"], Payment);
|
||||||
|
this.success = source["success"];
|
||||||
|
this.error = source["error"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
||||||
|
if (!a) {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
if (a.slice && a.map) {
|
||||||
|
return (a as any[]).map(elem => this.convertValues(elem, classs));
|
||||||
|
} else if ("object" === typeof a) {
|
||||||
|
if (asMap) {
|
||||||
|
for (const key of Object.keys(a)) {
|
||||||
|
a[key] = new classs(a[key]);
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
return new classs(a);
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
30
types.go
30
types.go
@@ -4,29 +4,29 @@ import "time"
|
|||||||
|
|
||||||
type (
|
type (
|
||||||
Bill struct {
|
Bill struct {
|
||||||
Id int64
|
Id int64 `json:"id"`
|
||||||
Name string
|
Name string `json:"name"`
|
||||||
}
|
}
|
||||||
Payment struct {
|
Payment struct {
|
||||||
Id int64
|
Id int64 `json:"id"`
|
||||||
BillId int64
|
BillId int64 `json:"billId"`
|
||||||
MonthFor time.Time
|
MonthFor time.Time `json:"monthFor" time_format:"2006-01-02"`
|
||||||
PaymentDate time.Time
|
PaymentDate time.Time `json:"paymentDate" time_format:"2006-01-02T15:04:05"`
|
||||||
}
|
}
|
||||||
|
|
||||||
WailsBills struct {
|
WailsBills struct {
|
||||||
Data []Bill
|
Data []Bill `json:"data"`
|
||||||
Success bool
|
Success bool `json:"success"`
|
||||||
Error string
|
Error string `json:"error"`
|
||||||
}
|
}
|
||||||
WailsPayments struct {
|
WailsPayments struct {
|
||||||
Data []Payment
|
Data []Payment `json:"data"`
|
||||||
Success bool
|
Success bool `json:"success"`
|
||||||
Error string
|
Error string `json:"error"`
|
||||||
}
|
}
|
||||||
WailsPayment struct {
|
WailsPayment struct {
|
||||||
Data Payment
|
Data Payment `json:"data"`
|
||||||
Success bool
|
Success bool `json:"success"`
|
||||||
Error string
|
Error string `json:"error"`
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user