feat: entities

This commit is contained in:
2025-03-09 21:51:16 +07:00
parent bd4be08c37
commit baf4c67cfb
21 changed files with 2171 additions and 62 deletions

View File

@@ -9,6 +9,7 @@ export class Author {
"Id": number;
"Name": string;
"Posts": Post[];
"Comments": Comment[];
/** Creates a new Author instance. */
constructor($$source: Partial<Author> = {}) {
@@ -21,6 +22,9 @@ export class Author {
if (!("Posts" in $$source)) {
this["Posts"] = [];
}
if (!("Comments" in $$source)) {
this["Comments"] = [];
}
Object.assign(this, $$source);
}
@@ -30,14 +34,63 @@ export class Author {
*/
static createFrom($$source: any = {}): Author {
const $$createField2_0 = $$createType1;
const $$createField3_0 = $$createType3;
let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
if ("Posts" in $$parsedSource) {
$$parsedSource["Posts"] = $$createField2_0($$parsedSource["Posts"]);
}
if ("Comments" in $$parsedSource) {
$$parsedSource["Comments"] = $$createField3_0($$parsedSource["Comments"]);
}
return new Author($$parsedSource as Partial<Author>);
}
}
export class Comment {
"Id": number;
"Text": string;
"AuthorId": number;
"Author": Author;
"Posts": Post[];
/** Creates a new Comment instance. */
constructor($$source: Partial<Comment> = {}) {
if (!("Id" in $$source)) {
this["Id"] = 0;
}
if (!("Text" in $$source)) {
this["Text"] = "";
}
if (!("AuthorId" in $$source)) {
this["AuthorId"] = 0;
}
if (!("Author" in $$source)) {
this["Author"] = (new Author());
}
if (!("Posts" in $$source)) {
this["Posts"] = [];
}
Object.assign(this, $$source);
}
/**
* Creates a new Comment instance from a string or object.
*/
static createFrom($$source: any = {}): Comment {
const $$createField3_0 = $$createType4;
const $$createField4_0 = $$createType1;
let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
if ("Author" in $$parsedSource) {
$$parsedSource["Author"] = $$createField3_0($$parsedSource["Author"]);
}
if ("Posts" in $$parsedSource) {
$$parsedSource["Posts"] = $$createField4_0($$parsedSource["Posts"]);
}
return new Comment($$parsedSource as Partial<Comment>);
}
}
export class Post {
"Id": number;
"Text": string;
@@ -45,6 +98,9 @@ export class Post {
"CreatedAt": number;
"AuthorId": number;
"Author": Author;
"PostTypeId": number;
"PostType": PostType;
"Comments": Comment[];
/** Creates a new Post instance. */
constructor($$source: Partial<Post> = {}) {
@@ -66,6 +122,15 @@ export class Post {
if (!("Author" in $$source)) {
this["Author"] = (new Author());
}
if (!("PostTypeId" in $$source)) {
this["PostTypeId"] = 0;
}
if (!("PostType" in $$source)) {
this["PostType"] = (new PostType());
}
if (!("Comments" in $$source)) {
this["Comments"] = [];
}
Object.assign(this, $$source);
}
@@ -74,16 +139,52 @@ export class Post {
* Creates a new Post instance from a string or object.
*/
static createFrom($$source: any = {}): Post {
const $$createField5_0 = $$createType2;
const $$createField5_0 = $$createType4;
const $$createField7_0 = $$createType5;
const $$createField8_0 = $$createType3;
let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
if ("Author" in $$parsedSource) {
$$parsedSource["Author"] = $$createField5_0($$parsedSource["Author"]);
}
if ("PostType" in $$parsedSource) {
$$parsedSource["PostType"] = $$createField7_0($$parsedSource["PostType"]);
}
if ("Comments" in $$parsedSource) {
$$parsedSource["Comments"] = $$createField8_0($$parsedSource["Comments"]);
}
return new Post($$parsedSource as Partial<Post>);
}
}
export class PostType {
"Id": number;
"Name": string;
/** Creates a new PostType instance. */
constructor($$source: Partial<PostType> = {}) {
if (!("Id" in $$source)) {
this["Id"] = 0;
}
if (!("Name" in $$source)) {
this["Name"] = "";
}
Object.assign(this, $$source);
}
/**
* Creates a new PostType instance from a string or object.
*/
static createFrom($$source: any = {}): PostType {
let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
return new PostType($$parsedSource as Partial<PostType>);
}
}
// Private type creation functions
const $$createType0 = Post.createFrom;
const $$createType1 = $Create.Array($$createType0);
const $$createType2 = Author.createFrom;
const $$createType2 = Comment.createFrom;
const $$createType3 = $Create.Array($$createType2);
const $$createType4 = Author.createFrom;
const $$createType5 = PostType.createFrom;

View File

@@ -20,7 +20,7 @@ export function Count(): Promise<number> & { cancel(): void } {
export function Create(item: $models.Author): Promise<$models.Author> & { cancel(): void } {
let $resultPromise = $Call.ByID(3684602449, item) as any;
let $typingPromise = $resultPromise.then(($result: any) => {
let $typingPromise = $resultPromise.then(($result) => {
return $$createType0($result);
}) as any;
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
@@ -34,7 +34,7 @@ export function Delete(id: number): Promise<void> & { cancel(): void } {
export function GetAll(): Promise<($models.Author | null)[]> & { cancel(): void } {
let $resultPromise = $Call.ByID(3248293926) as any;
let $typingPromise = $resultPromise.then(($result: any) => {
let $typingPromise = $resultPromise.then(($result) => {
return $$createType2($result);
}) as any;
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
@@ -43,7 +43,7 @@ export function GetAll(): Promise<($models.Author | null)[]> & { cancel(): void
export function GetById(id: number): Promise<$models.Author | null> & { cancel(): void } {
let $resultPromise = $Call.ByID(1703016211, id) as any;
let $typingPromise = $resultPromise.then(($result: any) => {
let $typingPromise = $resultPromise.then(($result) => {
return $$createType1($result);
}) as any;
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
@@ -52,7 +52,7 @@ export function GetById(id: number): Promise<$models.Author | null> & { cancel()
export function Update(item: $models.Author): Promise<$models.Author> & { cancel(): void } {
let $resultPromise = $Call.ByID(2240704960, item) as any;
let $typingPromise = $resultPromise.then(($result: any) => {
let $typingPromise = $resultPromise.then(($result) => {
return $$createType0($result);
}) as any;
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);

View File

@@ -0,0 +1,65 @@
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
// This file is automatically generated. DO NOT EDIT
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Unused imports
import {Call as $Call, Create as $Create} from "@wailsio/runtime";
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Unused imports
import * as models$0 from "../models/models.js";
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Unused imports
import * as $models from "./models.js";
export function Count(): Promise<number> & { cancel(): void } {
let $resultPromise = $Call.ByID(3225397984) as any;
return $resultPromise;
}
export function Create(item: $models.Comment): Promise<$models.Comment> & { cancel(): void } {
let $resultPromise = $Call.ByID(4239106089, item) as any;
let $typingPromise = $resultPromise.then(($result) => {
return $$createType0($result);
}) as any;
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
return $typingPromise;
}
export function Delete(id: number): Promise<void> & { cancel(): void } {
let $resultPromise = $Call.ByID(2553503582, id) as any;
return $resultPromise;
}
export function GetAll(): Promise<($models.Comment | null)[]> & { cancel(): void } {
let $resultPromise = $Call.ByID(1805763390) as any;
let $typingPromise = $resultPromise.then(($result) => {
return $$createType2($result);
}) as any;
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
return $typingPromise;
}
export function GetById(id: number): Promise<$models.Comment | null> & { cancel(): void } {
let $resultPromise = $Call.ByID(3217823099, id) as any;
let $typingPromise = $resultPromise.then(($result) => {
return $$createType1($result);
}) as any;
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
return $typingPromise;
}
export function Update(item: $models.Comment): Promise<$models.Comment> & { cancel(): void } {
let $resultPromise = $Call.ByID(3080970936, item) as any;
let $typingPromise = $resultPromise.then(($result) => {
return $$createType0($result);
}) as any;
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
return $typingPromise;
}
// Private type creation functions
const $$createType0 = models$0.Comment.createFrom;
const $$createType1 = $Create.Nullable($$createType0);
const $$createType2 = $Create.Array($$createType1);

View File

@@ -2,10 +2,14 @@
// This file is automatically generated. DO NOT EDIT
import * as AuthorService from "./authorservice.js";
import * as CommentService from "./commentservice.js";
import * as PostService from "./postservice.js";
import * as PostTypeService from "./posttypeservice.js";
export {
AuthorService,
PostService
CommentService,
PostService,
PostTypeService
};
export * from "./models.js";

View File

@@ -12,5 +12,11 @@ import * as models$0 from "../models/models.js";
export const Author = models$0.Author;
export type Author = models$0.Author;
export const Comment = models$0.Comment;
export type Comment = models$0.Comment;
export const Post = models$0.Post;
export type Post = models$0.Post;
export const PostType = models$0.PostType;
export type PostType = models$0.PostType;

View File

@@ -20,7 +20,7 @@ export function Count(): Promise<number> & { cancel(): void } {
export function Create(item: $models.Post): Promise<$models.Post> & { cancel(): void } {
let $resultPromise = $Call.ByID(1443399856, item) as any;
let $typingPromise = $resultPromise.then(($result: any) => {
let $typingPromise = $resultPromise.then(($result) => {
return $$createType0($result);
}) as any;
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
@@ -39,7 +39,7 @@ export function ExportToExcel(): Promise<void> & { cancel(): void } {
export function GetAll(): Promise<($models.Post | null)[]> & { cancel(): void } {
let $resultPromise = $Call.ByID(65691059) as any;
let $typingPromise = $resultPromise.then(($result: any) => {
let $typingPromise = $resultPromise.then(($result) => {
return $$createType2($result);
}) as any;
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
@@ -48,7 +48,7 @@ export function GetAll(): Promise<($models.Post | null)[]> & { cancel(): void }
export function GetById(id: number): Promise<$models.Post | null> & { cancel(): void } {
let $resultPromise = $Call.ByID(4074736792, id) as any;
let $typingPromise = $resultPromise.then(($result: any) => {
let $typingPromise = $resultPromise.then(($result) => {
return $$createType1($result);
}) as any;
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
@@ -57,7 +57,7 @@ export function GetById(id: number): Promise<$models.Post | null> & { cancel():
export function Update(item: $models.Post): Promise<$models.Post> & { cancel(): void } {
let $resultPromise = $Call.ByID(137798821, item) as any;
let $typingPromise = $resultPromise.then(($result: any) => {
let $typingPromise = $resultPromise.then(($result) => {
return $$createType0($result);
}) as any;
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);

View File

@@ -0,0 +1,65 @@
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
// This file is automatically generated. DO NOT EDIT
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Unused imports
import {Call as $Call, Create as $Create} from "@wailsio/runtime";
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Unused imports
import * as models$0 from "../models/models.js";
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Unused imports
import * as $models from "./models.js";
export function Count(): Promise<number> & { cancel(): void } {
let $resultPromise = $Call.ByID(554487955) as any;
return $resultPromise;
}
export function Create(item: $models.PostType): Promise<$models.PostType> & { cancel(): void } {
let $resultPromise = $Call.ByID(1092898136, item) as any;
let $typingPromise = $resultPromise.then(($result) => {
return $$createType0($result);
}) as any;
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
return $typingPromise;
}
export function Delete(id: number): Promise<void> & { cancel(): void } {
let $resultPromise = $Call.ByID(2114913543, id) as any;
return $resultPromise;
}
export function GetAll(): Promise<($models.PostType | null)[]> & { cancel(): void } {
let $resultPromise = $Call.ByID(416231387) as any;
let $typingPromise = $resultPromise.then(($result) => {
return $$createType2($result);
}) as any;
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
return $typingPromise;
}
export function GetById(id: number): Promise<$models.PostType | null> & { cancel(): void } {
let $resultPromise = $Call.ByID(3237123344, id) as any;
let $typingPromise = $resultPromise.then(($result) => {
return $$createType1($result);
}) as any;
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
return $typingPromise;
}
export function Update(item: $models.PostType): Promise<$models.PostType> & { cancel(): void } {
let $resultPromise = $Call.ByID(2773888269, item) as any;
let $typingPromise = $resultPromise.then(($result) => {
return $$createType0($result);
}) as any;
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
return $typingPromise;
}
// Private type creation functions
const $$createType0 = models$0.PostType.createFrom;
const $$createType1 = $Create.Nullable($$createType0);
const $$createType2 = $Create.Array($$createType1);