diff --git a/frontend/bindings/app/internal/models/index.ts b/frontend/bindings/app/internal/models/index.ts new file mode 100644 index 0000000..c9d993a --- /dev/null +++ b/frontend/bindings/app/internal/models/index.ts @@ -0,0 +1,4 @@ +// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL +// This file is automatically generated. DO NOT EDIT + +export * from "./models.js"; diff --git a/frontend/bindings/app/internal/models/models.ts b/frontend/bindings/app/internal/models/models.ts new file mode 100644 index 0000000..97c7442 --- /dev/null +++ b/frontend/bindings/app/internal/models/models.ts @@ -0,0 +1,190 @@ +// 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 {Create as $Create} from "@wailsio/runtime"; + +export class Author { + "Id": number; + "Name": string; + "Posts": Post[]; + "Comments": Comment[]; + + /** Creates a new Author instance. */ + constructor($$source: Partial = {}) { + if (!("Id" in $$source)) { + this["Id"] = 0; + } + if (!("Name" in $$source)) { + this["Name"] = ""; + } + if (!("Posts" in $$source)) { + this["Posts"] = []; + } + if (!("Comments" in $$source)) { + this["Comments"] = []; + } + + Object.assign(this, $$source); + } + + /** + * Creates a new Author instance from a string or object. + */ + 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); + } +} + +export class Comment { + "Id": number; + "Text": string; + "AuthorId": number; + "Author": Author; + "Posts": Post[]; + + /** Creates a new Comment instance. */ + constructor($$source: Partial = {}) { + 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); + } +} + +export class Post { + "Id": number; + "Text": string; + "Deadline": number; + "CreatedAt": number; + "AuthorId": number; + "Author": Author; + "PostTypeId": number; + "PostType": PostType; + "Comments": Comment[]; + + /** Creates a new Post instance. */ + constructor($$source: Partial = {}) { + if (!("Id" in $$source)) { + this["Id"] = 0; + } + if (!("Text" in $$source)) { + this["Text"] = ""; + } + if (!("Deadline" in $$source)) { + this["Deadline"] = 0; + } + if (!("CreatedAt" in $$source)) { + this["CreatedAt"] = 0; + } + if (!("AuthorId" in $$source)) { + this["AuthorId"] = 0; + } + 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); + } + + /** + * Creates a new Post instance from a string or object. + */ + static createFrom($$source: any = {}): Post { + 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); + } +} + +export class PostType { + "Id": number; + "Name": string; + + /** Creates a new PostType instance. */ + constructor($$source: Partial = {}) { + 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); + } +} + +// Private type creation functions +const $$createType0 = Post.createFrom; +const $$createType1 = $Create.Array($$createType0); +const $$createType2 = Comment.createFrom; +const $$createType3 = $Create.Array($$createType2); +const $$createType4 = Author.createFrom; +const $$createType5 = PostType.createFrom; diff --git a/frontend/bindings/app/internal/services/authorservice.ts b/frontend/bindings/app/internal/services/authorservice.ts new file mode 100644 index 0000000..b6380f1 --- /dev/null +++ b/frontend/bindings/app/internal/services/authorservice.ts @@ -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 & { cancel(): void } { + let $resultPromise = $Call.ByID(3969879864) as any; + return $resultPromise; +} + +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) => { + return $$createType0($result); + }) as any; + $typingPromise.cancel = $resultPromise.cancel.bind($resultPromise); + return $typingPromise; +} + +export function Delete(id: number): Promise & { cancel(): void } { + let $resultPromise = $Call.ByID(2096845974, id) as any; + return $resultPromise; +} + +export function GetAll(): Promise<($models.Author | null)[]> & { cancel(): void } { + let $resultPromise = $Call.ByID(3248293926) as any; + let $typingPromise = $resultPromise.then(($result: any) => { + return $$createType2($result); + }) as any; + $typingPromise.cancel = $resultPromise.cancel.bind($resultPromise); + return $typingPromise; +} + +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) => { + return $$createType1($result); + }) as any; + $typingPromise.cancel = $resultPromise.cancel.bind($resultPromise); + return $typingPromise; +} + +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) => { + return $$createType0($result); + }) as any; + $typingPromise.cancel = $resultPromise.cancel.bind($resultPromise); + return $typingPromise; +} + +// Private type creation functions +const $$createType0 = models$0.Author.createFrom; +const $$createType1 = $Create.Nullable($$createType0); +const $$createType2 = $Create.Array($$createType1); diff --git a/frontend/bindings/app/internal/services/commentservice.ts b/frontend/bindings/app/internal/services/commentservice.ts new file mode 100644 index 0000000..f7ccaf9 --- /dev/null +++ b/frontend/bindings/app/internal/services/commentservice.ts @@ -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 & { 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: any) => { + return $$createType0($result); + }) as any; + $typingPromise.cancel = $resultPromise.cancel.bind($resultPromise); + return $typingPromise; +} + +export function Delete(id: number): Promise & { 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: any) => { + 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: any) => { + 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: any) => { + 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); diff --git a/frontend/bindings/app/internal/services/index.ts b/frontend/bindings/app/internal/services/index.ts new file mode 100644 index 0000000..50666ce --- /dev/null +++ b/frontend/bindings/app/internal/services/index.ts @@ -0,0 +1,15 @@ +// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL +// 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, + CommentService, + PostService, + PostTypeService +}; + +export * from "./models.js"; diff --git a/frontend/bindings/app/internal/services/models.ts b/frontend/bindings/app/internal/services/models.ts new file mode 100644 index 0000000..41eba10 --- /dev/null +++ b/frontend/bindings/app/internal/services/models.ts @@ -0,0 +1,22 @@ +// 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 {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"; + +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; diff --git a/frontend/bindings/app/internal/services/postservice.ts b/frontend/bindings/app/internal/services/postservice.ts new file mode 100644 index 0000000..72d6196 --- /dev/null +++ b/frontend/bindings/app/internal/services/postservice.ts @@ -0,0 +1,70 @@ +// 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 & { cancel(): void } { + let $resultPromise = $Call.ByID(3109924027) as any; + return $resultPromise; +} + +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) => { + return $$createType0($result); + }) as any; + $typingPromise.cancel = $resultPromise.cancel.bind($resultPromise); + return $typingPromise; +} + +export function Delete(id: number): Promise & { cancel(): void } { + let $resultPromise = $Call.ByID(2924549135, id) as any; + return $resultPromise; +} + +export function ExportToExcel(): Promise & { cancel(): void } { + let $resultPromise = $Call.ByID(75322242) as any; + return $resultPromise; +} + +export function GetAll(): Promise<($models.Post | null)[]> & { cancel(): void } { + let $resultPromise = $Call.ByID(65691059) as any; + let $typingPromise = $resultPromise.then(($result: any) => { + return $$createType2($result); + }) as any; + $typingPromise.cancel = $resultPromise.cancel.bind($resultPromise); + return $typingPromise; +} + +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) => { + return $$createType1($result); + }) as any; + $typingPromise.cancel = $resultPromise.cancel.bind($resultPromise); + return $typingPromise; +} + +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) => { + return $$createType0($result); + }) as any; + $typingPromise.cancel = $resultPromise.cancel.bind($resultPromise); + return $typingPromise; +} + +// Private type creation functions +const $$createType0 = models$0.Post.createFrom; +const $$createType1 = $Create.Nullable($$createType0); +const $$createType2 = $Create.Array($$createType1); diff --git a/frontend/bindings/app/internal/services/posttypeservice.ts b/frontend/bindings/app/internal/services/posttypeservice.ts new file mode 100644 index 0000000..f4445ff --- /dev/null +++ b/frontend/bindings/app/internal/services/posttypeservice.ts @@ -0,0 +1,70 @@ +// 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 & { 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: any) => { + return $$createType0($result); + }) as any; + $typingPromise.cancel = $resultPromise.cancel.bind($resultPromise); + return $typingPromise; +} + +export function Delete(id: number): Promise & { 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: any) => { + 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: any) => { + return $$createType1($result); + }) as any; + $typingPromise.cancel = $resultPromise.cancel.bind($resultPromise); + return $typingPromise; +} + +export function ImportFromExcel(): Promise & { cancel(): void } { + let $resultPromise = $Call.ByID(1671814244) as any; + return $resultPromise; +} + +export function Update(item: $models.PostType): Promise<$models.PostType> & { cancel(): void } { + let $resultPromise = $Call.ByID(2773888269, item) as any; + let $typingPromise = $resultPromise.then(($result: any) => { + 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); diff --git a/frontend/src/App.vue b/frontend/src/App.vue index ac0e30f..35b459a 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -2,6 +2,7 @@ import { Dialog } from "primevue"; import { useErrorStore } from "./stores/error.store"; import { RouterView, useRoute } from "vue-router"; +import PosttypeScheme from "./posttype/PosttypeScheme.vue"; const errorStore = useErrorStore(); @@ -19,5 +20,6 @@ const route = useRoute();
+
diff --git a/internal/extras/excel/export.go b/internal/extras/excel/export.go index 26311f0..bc17675 100644 --- a/internal/extras/excel/export.go +++ b/internal/extras/excel/export.go @@ -86,6 +86,11 @@ func ExportEntityToSpreadsheet[T any](file *excelize.File, sheetName string, ent return err } + dataStyleId, err := LoadDataStyle(file) + if err != nil { + return err + } + // TODO: appearance for i, item := range items { structValue := reflect.ValueOf(item).Elem() @@ -143,6 +148,11 @@ func ExportEntityToSpreadsheet[T any](file *excelize.File, sheetName string, ent if err != nil { return err } + + err = file.SetCellStyle(sheetName, cellName, cellName, dataStyleId) + if err != nil { + return err + } } } } @@ -299,42 +309,6 @@ func GetStyleId(f *excelize.File, style *excelize.Style) (int, error) { return styleId, nil } -func LoadHeadersStyle(file *excelize.File) (int, error) { - headersStyle := excelize.Style{ - Alignment: &excelize.Alignment{ - Horizontal: "center", - Vertical: "center", - }, - Border: []excelize.Border{ - { - Type: "left", - Color: "000000", - Style: 1, - }, - { - Type: "right", - Color: "000000", - Style: 1, - }, - { - Type: "top", - Color: "000000", - Style: 1, - }, - { - Type: "bottom", - Color: "000000", - Style: 1, - }, - }, - Font: &excelize.Font{ - Bold: true, - VertAlign: "center", - }, - } - return GetStyleId(file, &headersStyle) -} - func ApplyStyleHeaders(file *excelize.File, sheetName string, headers TableHeaders) error { styleId, err := LoadHeadersStyle(file) if err != nil { diff --git a/internal/extras/excel/styles.go b/internal/extras/excel/styles.go new file mode 100644 index 0000000..ad71eb6 --- /dev/null +++ b/internal/extras/excel/styles.go @@ -0,0 +1,52 @@ +package excel + +import "github.com/xuri/excelize/v2" + +func LoadHeadersStyle(file *excelize.File) (int, error) { + headersStyle := excelize.Style{ + Alignment: &excelize.Alignment{ + Horizontal: "center", + Vertical: "center", + }, + Border: []excelize.Border{ + { + Type: "left", + Color: "000000", + Style: 1, + }, + { + Type: "right", + Color: "000000", + Style: 1, + }, + { + Type: "top", + Color: "000000", + Style: 1, + }, + { + Type: "bottom", + Color: "000000", + Style: 1, + }, + }, + Font: &excelize.Font{ + Bold: true, + VertAlign: "center", + }, + } + return GetStyleId(file, &headersStyle) +} + +func LoadDataStyle(file *excelize.File) (int, error) { + dataStyle := excelize.Style{ + Alignment: &excelize.Alignment{ + Horizontal: "center", + Vertical: "center", + }, + Font: &excelize.Font{ + VertAlign: "center", + }, + } + return GetStyleId(file, &dataStyle) +}