diff --git a/.idea/boilerplate.iml b/.idea/boilerplate.iml
new file mode 100644
index 0000000..7ee078d
--- /dev/null
+++ b/.idea/boilerplate.iml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..d8e4e7f
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,148 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {
+ "associatedIndex": 8
+}
+
+
+
+
+
+ {
+ "keyToString": {
+ "DefaultGoTemplateProperty": "Go File",
+ "Go Build.go build app.executor": "Debug",
+ "RunOnceActivity.ShowReadmeOnStart": "true",
+ "RunOnceActivity.git.unshallow": "true",
+ "RunOnceActivity.go.formatter.settings.were.checked": "true",
+ "RunOnceActivity.go.migrated.go.modules.settings": "true",
+ "RunOnceActivity.go.modules.go.list.on.any.changes.was.set": "true",
+ "git-widget-placeholder": "main",
+ "go.import.settings.migrated": "true",
+ "go.sdk.automatically.set": "true",
+ "kotlin-language-version-configured": "true",
+ "last_opened_file_path": "/home/gogacoder/dev/go/nto/boilerplate",
+ "node.js.detected.package.eslint": "true",
+ "node.js.selected.package.eslint": "(autodetect)",
+ "nodejs_package_manager_path": "npm",
+ "settings.editor.selected.configurable": "go.sdk",
+ "ts.external.directory.path": "/home/gogacoder/dev/go/nto/boilerplate/frontend/node_modules/typescript/lib",
+ "vue.rearranger.settings.migration": "true"
+ }
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1739066986825
+
+
+ 1739066986825
+
+
+
+
+
+
+
+ true
+
+
\ No newline at end of file
diff --git a/frontend/bindings/app/internal/models/models.ts b/frontend/bindings/app/internal/models/models.ts
index 97c7442..2288e9b 100644
--- a/frontend/bindings/app/internal/models/models.ts
+++ b/frontend/bindings/app/internal/models/models.ts
@@ -5,163 +5,183 @@
// @ts-ignore: Unused imports
import {Create as $Create} from "@wailsio/runtime";
-export class Author {
+export class Customer {
"Id": number;
- "Name": string;
- "Posts": Post[];
- "Comments": Comment[];
+ "Title": string;
+ "Contact": string;
+ "Orders": Order[];
- /** Creates a new Author instance. */
- constructor($$source: Partial = {}) {
+ /** Creates a new Customer instance. */
+ constructor($$source: Partial = {}) {
if (!("Id" in $$source)) {
this["Id"] = 0;
}
- if (!("Name" in $$source)) {
- this["Name"] = "";
+ if (!("Title" in $$source)) {
+ this["Title"] = "";
}
- if (!("Posts" in $$source)) {
- this["Posts"] = [];
+ if (!("Contact" in $$source)) {
+ this["Contact"] = "";
}
- if (!("Comments" in $$source)) {
- this["Comments"] = [];
+ if (!("Orders" in $$source)) {
+ this["Orders"] = [];
}
Object.assign(this, $$source);
}
/**
- * Creates a new Author instance from a string or object.
+ * Creates a new Customer instance from a string or object.
*/
- static createFrom($$source: any = {}): Author {
- const $$createField2_0 = $$createType1;
- const $$createField3_0 = $$createType3;
+ static createFrom($$source: any = {}): Customer {
+ const $$createField3_0 = $$createType1;
let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
- if ("Posts" in $$parsedSource) {
- $$parsedSource["Posts"] = $$createField2_0($$parsedSource["Posts"]);
+ if ("Orders" in $$parsedSource) {
+ $$parsedSource["Orders"] = $$createField3_0($$parsedSource["Orders"]);
}
- if ("Comments" in $$parsedSource) {
- $$parsedSource["Comments"] = $$createField3_0($$parsedSource["Comments"]);
- }
- return new Author($$parsedSource as Partial);
+ return new Customer($$parsedSource as Partial);
}
}
-export class Comment {
+export class Order {
"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;
+ "Status": string;
+ "Description": string;
+ "ProductTypeId": number;
+ "ProductType": ProductType;
+ "ProductAmount": number;
+ "CustomerId": number;
+ "Customer": Customer;
+ "Tasks": Task[];
"CreatedAt": number;
- "AuthorId": number;
- "Author": Author;
- "PostTypeId": number;
- "PostType": PostType;
- "Comments": Comment[];
+ "DeadlineDate": number;
- /** Creates a new Post instance. */
- constructor($$source: Partial = {}) {
+ /** Creates a new Order instance. */
+ constructor($$source: Partial = {}) {
if (!("Id" in $$source)) {
this["Id"] = 0;
}
- if (!("Text" in $$source)) {
- this["Text"] = "";
+ if (!("Status" in $$source)) {
+ this["Status"] = "";
}
- if (!("Deadline" in $$source)) {
- this["Deadline"] = 0;
+ if (!("Description" in $$source)) {
+ this["Description"] = "";
+ }
+ if (!("ProductTypeId" in $$source)) {
+ this["ProductTypeId"] = 0;
+ }
+ if (!("ProductType" in $$source)) {
+ this["ProductType"] = (new ProductType());
+ }
+ if (!("ProductAmount" in $$source)) {
+ this["ProductAmount"] = 0;
+ }
+ if (!("CustomerId" in $$source)) {
+ this["CustomerId"] = 0;
+ }
+ if (!("Customer" in $$source)) {
+ this["Customer"] = (new Customer());
+ }
+ if (!("Tasks" in $$source)) {
+ this["Tasks"] = [];
}
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"] = [];
+ if (!("DeadlineDate" in $$source)) {
+ this["DeadlineDate"] = 0;
}
Object.assign(this, $$source);
}
/**
- * Creates a new Post instance from a string or object.
+ * Creates a new Order instance from a string or object.
*/
- static createFrom($$source: any = {}): Post {
- const $$createField5_0 = $$createType4;
- const $$createField7_0 = $$createType5;
- const $$createField8_0 = $$createType3;
+ static createFrom($$source: any = {}): Order {
+ const $$createField4_0 = $$createType2;
+ const $$createField7_0 = $$createType3;
+ const $$createField8_0 = $$createType5;
let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
- if ("Author" in $$parsedSource) {
- $$parsedSource["Author"] = $$createField5_0($$parsedSource["Author"]);
+ if ("ProductType" in $$parsedSource) {
+ $$parsedSource["ProductType"] = $$createField4_0($$parsedSource["ProductType"]);
}
- if ("PostType" in $$parsedSource) {
- $$parsedSource["PostType"] = $$createField7_0($$parsedSource["PostType"]);
+ if ("Customer" in $$parsedSource) {
+ $$parsedSource["Customer"] = $$createField7_0($$parsedSource["Customer"]);
}
- if ("Comments" in $$parsedSource) {
- $$parsedSource["Comments"] = $$createField8_0($$parsedSource["Comments"]);
+ if ("Tasks" in $$parsedSource) {
+ $$parsedSource["Tasks"] = $$createField8_0($$parsedSource["Tasks"]);
}
- return new Post($$parsedSource as Partial);
+ return new Order($$parsedSource as Partial);
}
}
-export class PostType {
+export class PrepTask {
+ "Id": number;
+ "Status": string;
+ "Description": string;
+ "TaskId": number;
+ "Task": Task;
+ "WorkAreaId": number;
+ "WorkArea": WorkArea;
+ "CreatedAt": number;
+ "Deadline": number;
+
+ /** Creates a new PrepTask instance. */
+ constructor($$source: Partial = {}) {
+ if (!("Id" in $$source)) {
+ this["Id"] = 0;
+ }
+ if (!("Status" in $$source)) {
+ this["Status"] = "";
+ }
+ if (!("Description" in $$source)) {
+ this["Description"] = "";
+ }
+ if (!("TaskId" in $$source)) {
+ this["TaskId"] = 0;
+ }
+ if (!("Task" in $$source)) {
+ this["Task"] = (new Task());
+ }
+ if (!("WorkAreaId" in $$source)) {
+ this["WorkAreaId"] = 0;
+ }
+ if (!("WorkArea" in $$source)) {
+ this["WorkArea"] = (new WorkArea());
+ }
+ if (!("CreatedAt" in $$source)) {
+ this["CreatedAt"] = 0;
+ }
+ if (!("Deadline" in $$source)) {
+ this["Deadline"] = 0;
+ }
+
+ Object.assign(this, $$source);
+ }
+
+ /**
+ * Creates a new PrepTask instance from a string or object.
+ */
+ static createFrom($$source: any = {}): PrepTask {
+ const $$createField4_0 = $$createType4;
+ const $$createField6_0 = $$createType6;
+ let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
+ if ("Task" in $$parsedSource) {
+ $$parsedSource["Task"] = $$createField4_0($$parsedSource["Task"]);
+ }
+ if ("WorkArea" in $$parsedSource) {
+ $$parsedSource["WorkArea"] = $$createField6_0($$parsedSource["WorkArea"]);
+ }
+ return new PrepTask($$parsedSource as Partial);
+ }
+}
+
+export class ProductType {
"Id": number;
"Name": string;
- /** Creates a new PostType instance. */
- constructor($$source: Partial = {}) {
+ /** Creates a new ProductType instance. */
+ constructor($$source: Partial = {}) {
if (!("Id" in $$source)) {
this["Id"] = 0;
}
@@ -173,18 +193,437 @@ export class PostType {
}
/**
- * Creates a new PostType instance from a string or object.
+ * Creates a new ProductType instance from a string or object.
*/
- static createFrom($$source: any = {}): PostType {
+ static createFrom($$source: any = {}): ProductType {
let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
- return new PostType($$parsedSource as Partial);
+ return new ProductType($$parsedSource as Partial);
+ }
+}
+
+export class Shift {
+ "Id": number;
+ "Description": string;
+ "ProductTypeId": number;
+ "ProductType": ProductType;
+ "ProductAmount": number;
+ "ShiftDate": number;
+ "WorkAreaId": number;
+ "WorkArea": WorkArea;
+ "CreatedAt": number;
+
+ /** Creates a new Shift instance. */
+ constructor($$source: Partial = {}) {
+ if (!("Id" in $$source)) {
+ this["Id"] = 0;
+ }
+ if (!("Description" in $$source)) {
+ this["Description"] = "";
+ }
+ if (!("ProductTypeId" in $$source)) {
+ this["ProductTypeId"] = 0;
+ }
+ if (!("ProductType" in $$source)) {
+ this["ProductType"] = (new ProductType());
+ }
+ if (!("ProductAmount" in $$source)) {
+ this["ProductAmount"] = 0;
+ }
+ if (!("ShiftDate" in $$source)) {
+ this["ShiftDate"] = 0;
+ }
+ if (!("WorkAreaId" in $$source)) {
+ this["WorkAreaId"] = 0;
+ }
+ if (!("WorkArea" in $$source)) {
+ this["WorkArea"] = (new WorkArea());
+ }
+ if (!("CreatedAt" in $$source)) {
+ this["CreatedAt"] = 0;
+ }
+
+ Object.assign(this, $$source);
+ }
+
+ /**
+ * Creates a new Shift instance from a string or object.
+ */
+ static createFrom($$source: any = {}): Shift {
+ const $$createField3_0 = $$createType2;
+ const $$createField7_0 = $$createType6;
+ let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
+ if ("ProductType" in $$parsedSource) {
+ $$parsedSource["ProductType"] = $$createField3_0($$parsedSource["ProductType"]);
+ }
+ if ("WorkArea" in $$parsedSource) {
+ $$parsedSource["WorkArea"] = $$createField7_0($$parsedSource["WorkArea"]);
+ }
+ return new Shift($$parsedSource as Partial);
+ }
+}
+
+export class Task {
+ "Id": number;
+ "Description": string;
+ "ProductTypeId": number;
+ "ProductType": ProductType;
+ "Workshops": (Workshop | null)[];
+ "OrderId": number;
+ "Order": Order;
+ "PrepTasks": PrepTask[];
+ "ProductionStart": number;
+ "CreatedAt": number;
+ "Amount": number;
+
+ /** Creates a new Task instance. */
+ constructor($$source: Partial = {}) {
+ if (!("Id" in $$source)) {
+ this["Id"] = 0;
+ }
+ if (!("Description" in $$source)) {
+ this["Description"] = "";
+ }
+ if (!("ProductTypeId" in $$source)) {
+ this["ProductTypeId"] = 0;
+ }
+ if (!("ProductType" in $$source)) {
+ this["ProductType"] = (new ProductType());
+ }
+ if (!("Workshops" in $$source)) {
+ this["Workshops"] = [];
+ }
+ if (!("OrderId" in $$source)) {
+ this["OrderId"] = 0;
+ }
+ if (!("Order" in $$source)) {
+ this["Order"] = (new Order());
+ }
+ if (!("PrepTasks" in $$source)) {
+ this["PrepTasks"] = [];
+ }
+ if (!("ProductionStart" in $$source)) {
+ this["ProductionStart"] = 0;
+ }
+ if (!("CreatedAt" in $$source)) {
+ this["CreatedAt"] = 0;
+ }
+ if (!("Amount" in $$source)) {
+ this["Amount"] = 0;
+ }
+
+ Object.assign(this, $$source);
+ }
+
+ /**
+ * Creates a new Task instance from a string or object.
+ */
+ static createFrom($$source: any = {}): Task {
+ const $$createField3_0 = $$createType2;
+ const $$createField4_0 = $$createType9;
+ const $$createField6_0 = $$createType0;
+ const $$createField7_0 = $$createType11;
+ let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
+ if ("ProductType" in $$parsedSource) {
+ $$parsedSource["ProductType"] = $$createField3_0($$parsedSource["ProductType"]);
+ }
+ if ("Workshops" in $$parsedSource) {
+ $$parsedSource["Workshops"] = $$createField4_0($$parsedSource["Workshops"]);
+ }
+ if ("Order" in $$parsedSource) {
+ $$parsedSource["Order"] = $$createField6_0($$parsedSource["Order"]);
+ }
+ if ("PrepTasks" in $$parsedSource) {
+ $$parsedSource["PrepTasks"] = $$createField7_0($$parsedSource["PrepTasks"]);
+ }
+ return new Task($$parsedSource as Partial);
+ }
+}
+
+export class TeamTask {
+ "Id": number;
+ "TeamTypeId": number;
+ "TeamType": TeamType;
+ "TeamLeaderId": number;
+ "TeamLeader": Worker;
+ "TeamMembers": (Worker | null)[];
+ "WorkStartDate": number;
+ "WorkAreaId": number;
+ "WorkArea": WorkArea;
+ "ShiftDuties": string;
+
+ /** Creates a new TeamTask instance. */
+ constructor($$source: Partial = {}) {
+ if (!("Id" in $$source)) {
+ this["Id"] = 0;
+ }
+ if (!("TeamTypeId" in $$source)) {
+ this["TeamTypeId"] = 0;
+ }
+ if (!("TeamType" in $$source)) {
+ this["TeamType"] = (new TeamType());
+ }
+ if (!("TeamLeaderId" in $$source)) {
+ this["TeamLeaderId"] = 0;
+ }
+ if (!("TeamLeader" in $$source)) {
+ this["TeamLeader"] = (new Worker());
+ }
+ if (!("TeamMembers" in $$source)) {
+ this["TeamMembers"] = [];
+ }
+ if (!("WorkStartDate" in $$source)) {
+ this["WorkStartDate"] = 0;
+ }
+ if (!("WorkAreaId" in $$source)) {
+ this["WorkAreaId"] = 0;
+ }
+ if (!("WorkArea" in $$source)) {
+ this["WorkArea"] = (new WorkArea());
+ }
+ if (!("ShiftDuties" in $$source)) {
+ this["ShiftDuties"] = "";
+ }
+
+ Object.assign(this, $$source);
+ }
+
+ /**
+ * Creates a new TeamTask instance from a string or object.
+ */
+ static createFrom($$source: any = {}): TeamTask {
+ const $$createField2_0 = $$createType12;
+ const $$createField4_0 = $$createType13;
+ const $$createField5_0 = $$createType15;
+ const $$createField8_0 = $$createType6;
+ let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
+ if ("TeamType" in $$parsedSource) {
+ $$parsedSource["TeamType"] = $$createField2_0($$parsedSource["TeamType"]);
+ }
+ if ("TeamLeader" in $$parsedSource) {
+ $$parsedSource["TeamLeader"] = $$createField4_0($$parsedSource["TeamLeader"]);
+ }
+ if ("TeamMembers" in $$parsedSource) {
+ $$parsedSource["TeamMembers"] = $$createField5_0($$parsedSource["TeamMembers"]);
+ }
+ if ("WorkArea" in $$parsedSource) {
+ $$parsedSource["WorkArea"] = $$createField8_0($$parsedSource["WorkArea"]);
+ }
+ return new TeamTask($$parsedSource as Partial);
+ }
+}
+
+export class TeamType {
+ "Id": number;
+ "Name": string;
+
+ /** Creates a new TeamType instance. */
+ constructor($$source: Partial = {}) {
+ if (!("Id" in $$source)) {
+ this["Id"] = 0;
+ }
+ if (!("Name" in $$source)) {
+ this["Name"] = "";
+ }
+
+ Object.assign(this, $$source);
+ }
+
+ /**
+ * Creates a new TeamType instance from a string or object.
+ */
+ static createFrom($$source: any = {}): TeamType {
+ let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
+ return new TeamType($$parsedSource as Partial);
+ }
+}
+
+export class WorkArea {
+ "Id": number;
+ "Name": string;
+ "Description": string;
+ "Performance": number;
+ "WorkshopId": number;
+ "Workshop": Workshop;
+ "PrepTasks": PrepTask[];
+ "Shifts": Shift[];
+ "TeamTasks": TeamTask[];
+
+ /** Creates a new WorkArea instance. */
+ constructor($$source: Partial = {}) {
+ if (!("Id" in $$source)) {
+ this["Id"] = 0;
+ }
+ if (!("Name" in $$source)) {
+ this["Name"] = "";
+ }
+ if (!("Description" in $$source)) {
+ this["Description"] = "";
+ }
+ if (!("Performance" in $$source)) {
+ this["Performance"] = 0;
+ }
+ if (!("WorkshopId" in $$source)) {
+ this["WorkshopId"] = 0;
+ }
+ if (!("Workshop" in $$source)) {
+ this["Workshop"] = (new Workshop());
+ }
+ if (!("PrepTasks" in $$source)) {
+ this["PrepTasks"] = [];
+ }
+ if (!("Shifts" in $$source)) {
+ this["Shifts"] = [];
+ }
+ if (!("TeamTasks" in $$source)) {
+ this["TeamTasks"] = [];
+ }
+
+ Object.assign(this, $$source);
+ }
+
+ /**
+ * Creates a new WorkArea instance from a string or object.
+ */
+ static createFrom($$source: any = {}): WorkArea {
+ const $$createField5_0 = $$createType7;
+ const $$createField6_0 = $$createType11;
+ const $$createField7_0 = $$createType17;
+ const $$createField8_0 = $$createType19;
+ let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
+ if ("Workshop" in $$parsedSource) {
+ $$parsedSource["Workshop"] = $$createField5_0($$parsedSource["Workshop"]);
+ }
+ if ("PrepTasks" in $$parsedSource) {
+ $$parsedSource["PrepTasks"] = $$createField6_0($$parsedSource["PrepTasks"]);
+ }
+ if ("Shifts" in $$parsedSource) {
+ $$parsedSource["Shifts"] = $$createField7_0($$parsedSource["Shifts"]);
+ }
+ if ("TeamTasks" in $$parsedSource) {
+ $$parsedSource["TeamTasks"] = $$createField8_0($$parsedSource["TeamTasks"]);
+ }
+ return new WorkArea($$parsedSource as Partial);
+ }
+}
+
+export class Worker {
+ "Id": number;
+ "Name": string;
+ "TeamTasks": (TeamTask | null)[];
+ "Workshop": Workshop;
+ "WorkshopId": number;
+
+ /** Creates a new Worker instance. */
+ constructor($$source: Partial = {}) {
+ if (!("Id" in $$source)) {
+ this["Id"] = 0;
+ }
+ if (!("Name" in $$source)) {
+ this["Name"] = "";
+ }
+ if (!("TeamTasks" in $$source)) {
+ this["TeamTasks"] = [];
+ }
+ if (!("Workshop" in $$source)) {
+ this["Workshop"] = (new Workshop());
+ }
+ if (!("WorkshopId" in $$source)) {
+ this["WorkshopId"] = 0;
+ }
+
+ Object.assign(this, $$source);
+ }
+
+ /**
+ * Creates a new Worker instance from a string or object.
+ */
+ static createFrom($$source: any = {}): Worker {
+ const $$createField2_0 = $$createType21;
+ const $$createField3_0 = $$createType7;
+ let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
+ if ("TeamTasks" in $$parsedSource) {
+ $$parsedSource["TeamTasks"] = $$createField2_0($$parsedSource["TeamTasks"]);
+ }
+ if ("Workshop" in $$parsedSource) {
+ $$parsedSource["Workshop"] = $$createField3_0($$parsedSource["Workshop"]);
+ }
+ return new Worker($$parsedSource as Partial);
+ }
+}
+
+export class Workshop {
+ "Id": number;
+ "Name": string;
+ "WorkAreas": WorkArea[];
+ "Tasks": (Task | null)[];
+ "Workers": Worker[];
+
+ /** Creates a new Workshop instance. */
+ constructor($$source: Partial = {}) {
+ if (!("Id" in $$source)) {
+ this["Id"] = 0;
+ }
+ if (!("Name" in $$source)) {
+ this["Name"] = "";
+ }
+ if (!("WorkAreas" in $$source)) {
+ this["WorkAreas"] = [];
+ }
+ if (!("Tasks" in $$source)) {
+ this["Tasks"] = [];
+ }
+ if (!("Workers" in $$source)) {
+ this["Workers"] = [];
+ }
+
+ Object.assign(this, $$source);
+ }
+
+ /**
+ * Creates a new Workshop instance from a string or object.
+ */
+ static createFrom($$source: any = {}): Workshop {
+ const $$createField2_0 = $$createType22;
+ const $$createField3_0 = $$createType24;
+ const $$createField4_0 = $$createType25;
+ let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
+ if ("WorkAreas" in $$parsedSource) {
+ $$parsedSource["WorkAreas"] = $$createField2_0($$parsedSource["WorkAreas"]);
+ }
+ if ("Tasks" in $$parsedSource) {
+ $$parsedSource["Tasks"] = $$createField3_0($$parsedSource["Tasks"]);
+ }
+ if ("Workers" in $$parsedSource) {
+ $$parsedSource["Workers"] = $$createField4_0($$parsedSource["Workers"]);
+ }
+ return new Workshop($$parsedSource as Partial);
}
}
// Private type creation functions
-const $$createType0 = Post.createFrom;
+const $$createType0 = Order.createFrom;
const $$createType1 = $Create.Array($$createType0);
-const $$createType2 = Comment.createFrom;
-const $$createType3 = $Create.Array($$createType2);
-const $$createType4 = Author.createFrom;
-const $$createType5 = PostType.createFrom;
+const $$createType2 = ProductType.createFrom;
+const $$createType3 = Customer.createFrom;
+const $$createType4 = Task.createFrom;
+const $$createType5 = $Create.Array($$createType4);
+const $$createType6 = WorkArea.createFrom;
+const $$createType7 = Workshop.createFrom;
+const $$createType8 = $Create.Nullable($$createType7);
+const $$createType9 = $Create.Array($$createType8);
+const $$createType10 = PrepTask.createFrom;
+const $$createType11 = $Create.Array($$createType10);
+const $$createType12 = TeamType.createFrom;
+const $$createType13 = Worker.createFrom;
+const $$createType14 = $Create.Nullable($$createType13);
+const $$createType15 = $Create.Array($$createType14);
+const $$createType16 = Shift.createFrom;
+const $$createType17 = $Create.Array($$createType16);
+const $$createType18 = TeamTask.createFrom;
+const $$createType19 = $Create.Array($$createType18);
+const $$createType20 = $Create.Nullable($$createType18);
+const $$createType21 = $Create.Array($$createType20);
+const $$createType22 = $Create.Array($$createType6);
+const $$createType23 = $Create.Nullable($$createType4);
+const $$createType24 = $Create.Array($$createType23);
+const $$createType25 = $Create.Array($$createType13);
diff --git a/frontend/bindings/app/internal/services/customerservice.ts b/frontend/bindings/app/internal/services/customerservice.ts
new file mode 100644
index 0000000..6669ed2
--- /dev/null
+++ b/frontend/bindings/app/internal/services/customerservice.ts
@@ -0,0 +1,86 @@
+// 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 utils$0 from "../utils/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(2456694737) as any;
+ return $resultPromise;
+}
+
+export function Create(item: $models.Customer): Promise<$models.Customer> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(2428713966, 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(351568709, id) as any;
+ return $resultPromise;
+}
+
+export function GetAll(): Promise<($models.Customer | null)[]> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(2094111829) 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.Customer | null> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(1898783026, id) as any;
+ let $typingPromise = $resultPromise.then(($result: any) => {
+ return $$createType1($result);
+ }) as any;
+ $typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
+ return $typingPromise;
+}
+
+export function SearchByAllTextFields(phrase: string): Promise<($models.Customer | null)[]> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(1677934916, phrase) as any;
+ let $typingPromise = $resultPromise.then(($result: any) => {
+ return $$createType2($result);
+ }) as any;
+ $typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
+ return $typingPromise;
+}
+
+export function SortedByOrder(fieldsSortingOrder: utils$0.SortField[]): Promise<($models.Customer | null)[]> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(3880190910, fieldsSortingOrder) as any;
+ let $typingPromise = $resultPromise.then(($result: any) => {
+ return $$createType2($result);
+ }) as any;
+ $typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
+ return $typingPromise;
+}
+
+export function Update(item: $models.Customer): Promise<$models.Customer> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(2724586067, 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.Customer.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
index 532a230..59c2f74 100644
--- a/frontend/bindings/app/internal/services/index.ts
+++ b/frontend/bindings/app/internal/services/index.ts
@@ -1,17 +1,31 @@
// 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 CustomerService from "./customerservice.js";
import * as ExcelModule from "./excelmodule.js";
-import * as PostService from "./postservice.js";
-import * as PostTypeService from "./posttypeservice.js";
+import * as OrderService from "./orderservice.js";
+import * as PrepTaskService from "./preptaskservice.js";
+import * as ProductTypeService from "./producttypeservice.js";
+import * as ShiftService from "./shiftservice.js";
+import * as TaskService from "./taskservice.js";
+import * as TeamTaskService from "./teamtaskservice.js";
+import * as TeamTypeService from "./teamtypeservice.js";
+import * as WorkAreaService from "./workareaservice.js";
+import * as WorkerService from "./workerservice.js";
+import * as WorkshopService from "./workshopservice.js";
export {
- AuthorService,
- CommentService,
+ CustomerService,
ExcelModule,
- PostService,
- PostTypeService
+ OrderService,
+ PrepTaskService,
+ ProductTypeService,
+ ShiftService,
+ TaskService,
+ TeamTaskService,
+ TeamTypeService,
+ WorkAreaService,
+ WorkerService,
+ WorkshopService
};
export * from "./models.js";
diff --git a/frontend/bindings/app/internal/services/models.ts b/frontend/bindings/app/internal/services/models.ts
index 41eba10..5f84c2b 100644
--- a/frontend/bindings/app/internal/services/models.ts
+++ b/frontend/bindings/app/internal/services/models.ts
@@ -9,14 +9,35 @@ import {Create as $Create} from "@wailsio/runtime";
// @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 Customer = models$0.Customer;
+export type Customer = models$0.Customer;
-export const Comment = models$0.Comment;
-export type Comment = models$0.Comment;
+export const Order = models$0.Order;
+export type Order = models$0.Order;
-export const Post = models$0.Post;
-export type Post = models$0.Post;
+export const PrepTask = models$0.PrepTask;
+export type PrepTask = models$0.PrepTask;
-export const PostType = models$0.PostType;
-export type PostType = models$0.PostType;
+export const ProductType = models$0.ProductType;
+export type ProductType = models$0.ProductType;
+
+export const Shift = models$0.Shift;
+export type Shift = models$0.Shift;
+
+export const Task = models$0.Task;
+export type Task = models$0.Task;
+
+export const TeamTask = models$0.TeamTask;
+export type TeamTask = models$0.TeamTask;
+
+export const TeamType = models$0.TeamType;
+export type TeamType = models$0.TeamType;
+
+export const WorkArea = models$0.WorkArea;
+export type WorkArea = models$0.WorkArea;
+
+export const Worker = models$0.Worker;
+export type Worker = models$0.Worker;
+
+export const Workshop = models$0.Workshop;
+export type Workshop = models$0.Workshop;
diff --git a/frontend/bindings/app/internal/services/commentservice.ts b/frontend/bindings/app/internal/services/orderservice.ts
similarity index 71%
rename from frontend/bindings/app/internal/services/commentservice.ts
rename to frontend/bindings/app/internal/services/orderservice.ts
index 13da36b..2fd0a72 100644
--- a/frontend/bindings/app/internal/services/commentservice.ts
+++ b/frontend/bindings/app/internal/services/orderservice.ts
@@ -17,12 +17,12 @@ import * as utils$0 from "../utils/models.js";
import * as $models from "./models.js";
export function Count(): Promise & { cancel(): void } {
- let $resultPromise = $Call.ByID(3225397984) as any;
+ let $resultPromise = $Call.ByID(2566189339) as any;
return $resultPromise;
}
-export function Create(item: $models.Comment): Promise<$models.Comment> & { cancel(): void } {
- let $resultPromise = $Call.ByID(4239106089, item) as any;
+export function Create(item: $models.Order): Promise<$models.Order> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(4046033040, item) as any;
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType0($result);
}) as any;
@@ -31,12 +31,12 @@ export function Create(item: $models.Comment): Promise<$models.Comment> & { canc
}
export function Delete(id: number): Promise & { cancel(): void } {
- let $resultPromise = $Call.ByID(2553503582, id) as any;
+ let $resultPromise = $Call.ByID(1974545647, id) as any;
return $resultPromise;
}
-export function GetAll(): Promise<($models.Comment | null)[]> & { cancel(): void } {
- let $resultPromise = $Call.ByID(1805763390) as any;
+export function GetAll(): Promise<($models.Order | null)[]> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(1679856851) as any;
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType2($result);
}) as any;
@@ -44,8 +44,8 @@ export function GetAll(): Promise<($models.Comment | null)[]> & { cancel(): void
return $typingPromise;
}
-export function GetById(id: number): Promise<$models.Comment | null> & { cancel(): void } {
- let $resultPromise = $Call.ByID(3217823099, id) as any;
+export function GetById(id: number): Promise<$models.Order | null> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(1201282680, id) as any;
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType1($result);
}) as any;
@@ -53,8 +53,8 @@ export function GetById(id: number): Promise<$models.Comment | null> & { cancel(
return $typingPromise;
}
-export function SearchByAllTextFields(phrase: string): Promise<($models.Comment | null)[]> & { cancel(): void } {
- let $resultPromise = $Call.ByID(480333285, phrase) as any;
+export function SearchByAllTextFields(phrase: string): Promise<($models.Order | null)[]> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(963444842, phrase) as any;
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType2($result);
}) as any;
@@ -62,8 +62,8 @@ export function SearchByAllTextFields(phrase: string): Promise<($models.Comment
return $typingPromise;
}
-export function SortedByOrder(fieldsSortingOrder: utils$0.SortField[]): Promise<($models.Comment | null)[]> & { cancel(): void } {
- let $resultPromise = $Call.ByID(4244533291, fieldsSortingOrder) as any;
+export function SortedByOrder(fieldsSortingOrder: utils$0.SortField[]): Promise<($models.Order | null)[]> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(3596187064, fieldsSortingOrder) as any;
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType2($result);
}) as any;
@@ -71,8 +71,8 @@ export function SortedByOrder(fieldsSortingOrder: utils$0.SortField[]): Promise<
return $typingPromise;
}
-export function Update(item: $models.Comment): Promise<$models.Comment> & { cancel(): void } {
- let $resultPromise = $Call.ByID(3080970936, item) as any;
+export function Update(item: $models.Order): Promise<$models.Order> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(358288261, item) as any;
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType0($result);
}) as any;
@@ -81,6 +81,6 @@ export function Update(item: $models.Comment): Promise<$models.Comment> & { canc
}
// Private type creation functions
-const $$createType0 = models$0.Comment.createFrom;
+const $$createType0 = models$0.Order.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/preptaskservice.ts
similarity index 70%
rename from frontend/bindings/app/internal/services/posttypeservice.ts
rename to frontend/bindings/app/internal/services/preptaskservice.ts
index 88211f7..e95a26d 100644
--- a/frontend/bindings/app/internal/services/posttypeservice.ts
+++ b/frontend/bindings/app/internal/services/preptaskservice.ts
@@ -17,12 +17,12 @@ import * as utils$0 from "../utils/models.js";
import * as $models from "./models.js";
export function Count(): Promise & { cancel(): void } {
- let $resultPromise = $Call.ByID(554487955) as any;
+ let $resultPromise = $Call.ByID(3107879827) as any;
return $resultPromise;
}
-export function Create(item: $models.PostType): Promise<$models.PostType> & { cancel(): void } {
- let $resultPromise = $Call.ByID(1092898136, item) as any;
+export function Create(item: $models.PrepTask): Promise<$models.PrepTask> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(3612638808, item) as any;
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType0($result);
}) as any;
@@ -31,12 +31,12 @@ export function Create(item: $models.PostType): Promise<$models.PostType> & { ca
}
export function Delete(id: number): Promise & { cancel(): void } {
- let $resultPromise = $Call.ByID(2114913543, id) as any;
+ let $resultPromise = $Call.ByID(339686919, id) as any;
return $resultPromise;
}
-export function GetAll(): Promise<($models.PostType | null)[]> & { cancel(): void } {
- let $resultPromise = $Call.ByID(416231387) as any;
+export function GetAll(): Promise<($models.PrepTask | null)[]> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(2935972059) as any;
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType2($result);
}) as any;
@@ -44,8 +44,8 @@ export function GetAll(): Promise<($models.PostType | null)[]> & { cancel(): voi
return $typingPromise;
}
-export function GetById(id: number): Promise<$models.PostType | null> & { cancel(): void } {
- let $resultPromise = $Call.ByID(3237123344, id) as any;
+export function GetById(id: number): Promise<$models.PrepTask | null> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(785365008, id) as any;
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType1($result);
}) as any;
@@ -53,8 +53,8 @@ export function GetById(id: number): Promise<$models.PostType | null> & { cancel
return $typingPromise;
}
-export function SearchByAllTextFields(phrase: string): Promise<($models.PostType | null)[]> & { cancel(): void } {
- let $resultPromise = $Call.ByID(4207540242, phrase) as any;
+export function SearchByAllTextFields(phrase: string): Promise<($models.PrepTask | null)[]> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(2705089298, phrase) as any;
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType2($result);
}) as any;
@@ -62,8 +62,8 @@ export function SearchByAllTextFields(phrase: string): Promise<($models.PostType
return $typingPromise;
}
-export function SortedByOrder(fieldsSortOrder: utils$0.SortField[]): Promise<($models.PostType | null)[]> & { cancel(): void } {
- let $resultPromise = $Call.ByID(1097313920, fieldsSortOrder) as any;
+export function SortedByOrder(fieldsSortingOrder: utils$0.SortField[]): Promise<($models.PrepTask | null)[]> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(423868800, fieldsSortingOrder) as any;
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType2($result);
}) as any;
@@ -71,8 +71,8 @@ export function SortedByOrder(fieldsSortOrder: utils$0.SortField[]): Promise<($m
return $typingPromise;
}
-export function Update(item: $models.PostType): Promise<$models.PostType> & { cancel(): void } {
- let $resultPromise = $Call.ByID(2773888269, item) as any;
+export function Update(item: $models.PrepTask): Promise<$models.PrepTask> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(998661645, item) as any;
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType0($result);
}) as any;
@@ -81,6 +81,6 @@ export function Update(item: $models.PostType): Promise<$models.PostType> & { ca
}
// Private type creation functions
-const $$createType0 = models$0.PostType.createFrom;
+const $$createType0 = models$0.PrepTask.createFrom;
const $$createType1 = $Create.Nullable($$createType0);
const $$createType2 = $Create.Array($$createType1);
diff --git a/frontend/bindings/app/internal/services/producttypeservice.ts b/frontend/bindings/app/internal/services/producttypeservice.ts
new file mode 100644
index 0000000..edbad54
--- /dev/null
+++ b/frontend/bindings/app/internal/services/producttypeservice.ts
@@ -0,0 +1,86 @@
+// 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 utils$0 from "../utils/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(3869103122) as any;
+ return $resultPromise;
+}
+
+export function Create(item: $models.ProductType): Promise<$models.ProductType> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(2892206627, 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(2075432208, id) as any;
+ return $resultPromise;
+}
+
+export function GetAll(): Promise<($models.ProductType | null)[]> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(4237247244) 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.ProductType | null> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(3965758897, id) as any;
+ let $typingPromise = $resultPromise.then(($result: any) => {
+ return $$createType1($result);
+ }) as any;
+ $typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
+ return $typingPromise;
+}
+
+export function SearchByAllTextFields(phrase: string): Promise<($models.ProductType | null)[]> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(2567053163, phrase) as any;
+ let $typingPromise = $resultPromise.then(($result: any) => {
+ return $$createType2($result);
+ }) as any;
+ $typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
+ return $typingPromise;
+}
+
+export function SortedByOrder(fieldsSortingOrder: utils$0.SortField[]): Promise<($models.ProductType | null)[]> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(2110028149, fieldsSortingOrder) as any;
+ let $typingPromise = $resultPromise.then(($result: any) => {
+ return $$createType2($result);
+ }) as any;
+ $typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
+ return $typingPromise;
+}
+
+export function Update(item: $models.ProductType): Promise<$models.ProductType> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(2015721618, 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.ProductType.createFrom;
+const $$createType1 = $Create.Nullable($$createType0);
+const $$createType2 = $Create.Array($$createType1);
diff --git a/frontend/bindings/app/internal/services/shiftservice.ts b/frontend/bindings/app/internal/services/shiftservice.ts
new file mode 100644
index 0000000..4b7e1ba
--- /dev/null
+++ b/frontend/bindings/app/internal/services/shiftservice.ts
@@ -0,0 +1,86 @@
+// 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 utils$0 from "../utils/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(3190120795) as any;
+ return $resultPromise;
+}
+
+export function Create(item: $models.Shift): Promise<$models.Shift> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(1438106576, 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(2919255855, id) as any;
+ return $resultPromise;
+}
+
+export function GetAll(): Promise<($models.Shift | null)[]> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(1919901971) 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.Shift | null> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(2418071992, id) as any;
+ let $typingPromise = $resultPromise.then(($result: any) => {
+ return $$createType1($result);
+ }) as any;
+ $typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
+ return $typingPromise;
+}
+
+export function SearchByAllTextFields(phrase: string): Promise<($models.Shift | null)[]> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(2703093162, phrase) as any;
+ let $typingPromise = $resultPromise.then(($result: any) => {
+ return $$createType2($result);
+ }) as any;
+ $typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
+ return $typingPromise;
+}
+
+export function SortedByOrder(fieldsSortingOrder: utils$0.SortField[]): Promise<($models.Shift | null)[]> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(1476306424, fieldsSortingOrder) as any;
+ let $typingPromise = $resultPromise.then(($result: any) => {
+ return $$createType2($result);
+ }) as any;
+ $typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
+ return $typingPromise;
+}
+
+export function Update(item: $models.Shift): Promise<$models.Shift> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(132402373, 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.Shift.createFrom;
+const $$createType1 = $Create.Nullable($$createType0);
+const $$createType2 = $Create.Array($$createType1);
diff --git a/frontend/bindings/app/internal/services/postservice.ts b/frontend/bindings/app/internal/services/taskservice.ts
similarity index 72%
rename from frontend/bindings/app/internal/services/postservice.ts
rename to frontend/bindings/app/internal/services/taskservice.ts
index 89d1f2c..fbd32b5 100644
--- a/frontend/bindings/app/internal/services/postservice.ts
+++ b/frontend/bindings/app/internal/services/taskservice.ts
@@ -17,12 +17,12 @@ import * as utils$0 from "../utils/models.js";
import * as $models from "./models.js";
export function Count(): Promise & { cancel(): void } {
- let $resultPromise = $Call.ByID(3109924027) as any;
+ let $resultPromise = $Call.ByID(2626684778) as any;
return $resultPromise;
}
-export function Create(item: $models.Post): Promise<$models.Post> & { cancel(): void } {
- let $resultPromise = $Call.ByID(1443399856, item) as any;
+export function Create(item: $models.Task): Promise<$models.Task> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(893779179, item) as any;
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType0($result);
}) as any;
@@ -31,12 +31,12 @@ export function Create(item: $models.Post): Promise<$models.Post> & { cancel():
}
export function Delete(id: number): Promise & { cancel(): void } {
- let $resultPromise = $Call.ByID(2924549135, id) as any;
+ let $resultPromise = $Call.ByID(3033756968, id) as any;
return $resultPromise;
}
-export function GetAll(): Promise<($models.Post | null)[]> & { cancel(): void } {
- let $resultPromise = $Call.ByID(65691059) as any;
+export function GetAll(): Promise<($models.Task | null)[]> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(1660059028) as any;
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType2($result);
}) as any;
@@ -44,8 +44,8 @@ export function GetAll(): Promise<($models.Post | null)[]> & { cancel(): void }
return $typingPromise;
}
-export function GetById(id: number): Promise<$models.Post | null> & { cancel(): void } {
- let $resultPromise = $Call.ByID(4074736792, id) as any;
+export function GetById(id: number): Promise<$models.Task | null> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(3152185033, id) as any;
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType1($result);
}) as any;
@@ -53,8 +53,8 @@ export function GetById(id: number): Promise<$models.Post | null> & { cancel():
return $typingPromise;
}
-export function SearchByAllTextFields(phrase: string): Promise<($models.Post | null)[]> & { cancel(): void } {
- let $resultPromise = $Call.ByID(591521802, phrase) as any;
+export function SearchByAllTextFields(phrase: string): Promise<($models.Task | null)[]> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(3905257587, phrase) as any;
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType2($result);
}) as any;
@@ -62,8 +62,8 @@ export function SearchByAllTextFields(phrase: string): Promise<($models.Post | n
return $typingPromise;
}
-export function SortedByOrder(fieldsSortOrder: utils$0.SortField[]): Promise<($models.Post | null)[]> & { cancel(): void } {
- let $resultPromise = $Call.ByID(471862744, fieldsSortOrder) as any;
+export function SortedByOrder(fieldsSortingOrder: utils$0.SortField[]): Promise<($models.Task | null)[]> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(2942045693, fieldsSortingOrder) as any;
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType2($result);
}) as any;
@@ -71,8 +71,8 @@ export function SortedByOrder(fieldsSortOrder: utils$0.SortField[]): Promise<($m
return $typingPromise;
}
-export function Update(item: $models.Post): Promise<$models.Post> & { cancel(): void } {
- let $resultPromise = $Call.ByID(137798821, item) as any;
+export function Update(item: $models.Task): Promise<$models.Task> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(3997472442, item) as any;
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType0($result);
}) as any;
@@ -81,6 +81,6 @@ export function Update(item: $models.Post): Promise<$models.Post> & { cancel():
}
// Private type creation functions
-const $$createType0 = models$0.Post.createFrom;
+const $$createType0 = models$0.Task.createFrom;
const $$createType1 = $Create.Nullable($$createType0);
const $$createType2 = $Create.Array($$createType1);
diff --git a/frontend/bindings/app/internal/services/teamtaskservice.ts b/frontend/bindings/app/internal/services/teamtaskservice.ts
new file mode 100644
index 0000000..dc178fc
--- /dev/null
+++ b/frontend/bindings/app/internal/services/teamtaskservice.ts
@@ -0,0 +1,86 @@
+// 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 utils$0 from "../utils/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(3706236529) as any;
+ return $resultPromise;
+}
+
+export function Create(item: $models.TeamTask): Promise<$models.TeamTask> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(757028622, 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(3016324197, id) as any;
+ return $resultPromise;
+}
+
+export function GetAll(): Promise<($models.TeamTask | null)[]> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(2153018165) 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.TeamTask | null> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(457048658, id) as any;
+ let $typingPromise = $resultPromise.then(($result: any) => {
+ return $$createType1($result);
+ }) as any;
+ $typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
+ return $typingPromise;
+}
+
+export function SearchByAllTextFields(phrase: string): Promise<($models.TeamTask | null)[]> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(352409060, phrase) as any;
+ let $typingPromise = $resultPromise.then(($result: any) => {
+ return $$createType2($result);
+ }) as any;
+ $typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
+ return $typingPromise;
+}
+
+export function SortedByOrder(fieldsSortingOrder: utils$0.SortField[]): Promise<($models.TeamTask | null)[]> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(1507635678, fieldsSortingOrder) as any;
+ let $typingPromise = $resultPromise.then(($result: any) => {
+ return $$createType2($result);
+ }) as any;
+ $typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
+ return $typingPromise;
+}
+
+export function Update(item: $models.TeamTask): Promise<$models.TeamTask> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(1052797555, 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.TeamTask.createFrom;
+const $$createType1 = $Create.Nullable($$createType0);
+const $$createType2 = $Create.Array($$createType1);
diff --git a/frontend/bindings/app/internal/services/teamtypeservice.ts b/frontend/bindings/app/internal/services/teamtypeservice.ts
new file mode 100644
index 0000000..3e29201
--- /dev/null
+++ b/frontend/bindings/app/internal/services/teamtypeservice.ts
@@ -0,0 +1,86 @@
+// 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 utils$0 from "../utils/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(1823045730) as any;
+ return $resultPromise;
+}
+
+export function Create(item: $models.TeamType): Promise<$models.TeamType> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(3331874131, 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(1006566688, id) as any;
+ return $resultPromise;
+}
+
+export function GetAll(): Promise<($models.TeamType | null)[]> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(63845852) 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.TeamType | null> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(1530543873, id) as any;
+ let $typingPromise = $resultPromise.then(($result: any) => {
+ return $$createType1($result);
+ }) as any;
+ $typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
+ return $typingPromise;
+}
+
+export function SearchByAllTextFields(phrase: string): Promise<($models.TeamType | null)[]> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(201965595, phrase) as any;
+ let $typingPromise = $resultPromise.then(($result: any) => {
+ return $$createType2($result);
+ }) as any;
+ $typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
+ return $typingPromise;
+}
+
+export function SortedByOrder(fieldsSortingOrder: utils$0.SortField[]): Promise<($models.TeamType | null)[]> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(2936929733, fieldsSortingOrder) as any;
+ let $typingPromise = $resultPromise.then(($result: any) => {
+ return $$createType2($result);
+ }) as any;
+ $typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
+ return $typingPromise;
+}
+
+export function Update(item: $models.TeamType): Promise<$models.TeamType> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(918118946, 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.TeamType.createFrom;
+const $$createType1 = $Create.Nullable($$createType0);
+const $$createType2 = $Create.Array($$createType1);
diff --git a/frontend/bindings/app/internal/services/workareaservice.ts b/frontend/bindings/app/internal/services/workareaservice.ts
new file mode 100644
index 0000000..6e53e3e
--- /dev/null
+++ b/frontend/bindings/app/internal/services/workareaservice.ts
@@ -0,0 +1,86 @@
+// 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 utils$0 from "../utils/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(2628202257) as any;
+ return $resultPromise;
+}
+
+export function Create(item: $models.WorkArea): Promise<$models.WorkArea> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(969170222, 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(421967749, id) as any;
+ return $resultPromise;
+}
+
+export function GetAll(): Promise<($models.WorkArea | null)[]> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(2440807317) 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.WorkArea | null> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(2721437042, id) as any;
+ let $typingPromise = $resultPromise.then(($result: any) => {
+ return $$createType1($result);
+ }) as any;
+ $typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
+ return $typingPromise;
+}
+
+export function SearchByAllTextFields(phrase: string): Promise<($models.WorkArea | null)[]> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(3482576004, phrase) as any;
+ let $typingPromise = $resultPromise.then(($result: any) => {
+ return $$createType2($result);
+ }) as any;
+ $typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
+ return $typingPromise;
+}
+
+export function SortedByOrder(fieldsSortingOrder: utils$0.SortField[]): Promise<($models.WorkArea | null)[]> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(571753726, fieldsSortingOrder) as any;
+ let $typingPromise = $resultPromise.then(($result: any) => {
+ return $$createType2($result);
+ }) as any;
+ $typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
+ return $typingPromise;
+}
+
+export function Update(item: $models.WorkArea): Promise<$models.WorkArea> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(2753408403, 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.WorkArea.createFrom;
+const $$createType1 = $Create.Nullable($$createType0);
+const $$createType2 = $Create.Array($$createType1);
diff --git a/frontend/bindings/app/internal/services/authorservice.ts b/frontend/bindings/app/internal/services/workerservice.ts
similarity index 72%
rename from frontend/bindings/app/internal/services/authorservice.ts
rename to frontend/bindings/app/internal/services/workerservice.ts
index 9db5ddc..bf22488 100644
--- a/frontend/bindings/app/internal/services/authorservice.ts
+++ b/frontend/bindings/app/internal/services/workerservice.ts
@@ -17,12 +17,12 @@ import * as utils$0 from "../utils/models.js";
import * as $models from "./models.js";
export function Count(): Promise & { cancel(): void } {
- let $resultPromise = $Call.ByID(3969879864) as any;
+ let $resultPromise = $Call.ByID(3131879451) as any;
return $resultPromise;
}
-export function Create(item: $models.Author): Promise<$models.Author> & { cancel(): void } {
- let $resultPromise = $Call.ByID(3684602449, item) as any;
+export function Create(item: $models.Worker): Promise<$models.Worker> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(90914192, item) as any;
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType0($result);
}) as any;
@@ -31,12 +31,12 @@ export function Create(item: $models.Author): Promise<$models.Author> & { cancel
}
export function Delete(id: number): Promise & { cancel(): void } {
- let $resultPromise = $Call.ByID(2096845974, id) as any;
+ let $resultPromise = $Call.ByID(2314394095, id) as any;
return $resultPromise;
}
-export function GetAll(): Promise<($models.Author | null)[]> & { cancel(): void } {
- let $resultPromise = $Call.ByID(3248293926) as any;
+export function GetAll(): Promise<($models.Worker | null)[]> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(2019705299) as any;
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType2($result);
}) as any;
@@ -44,8 +44,8 @@ export function GetAll(): Promise<($models.Author | null)[]> & { cancel(): void
return $typingPromise;
}
-export function GetById(id: number): Promise<$models.Author | null> & { cancel(): void } {
- let $resultPromise = $Call.ByID(1703016211, id) as any;
+export function GetById(id: number): Promise<$models.Worker | null> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(721253752, id) as any;
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType1($result);
}) as any;
@@ -53,8 +53,8 @@ export function GetById(id: number): Promise<$models.Author | null> & { cancel()
return $typingPromise;
}
-export function SearchByAllTextFields(phrase: string): Promise<($models.Author | null)[]> & { cancel(): void } {
- let $resultPromise = $Call.ByID(3812644109, phrase) as any;
+export function SearchByAllTextFields(phrase: string): Promise<($models.Worker | null)[]> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(4245847914, phrase) as any;
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType2($result);
}) as any;
@@ -62,8 +62,8 @@ export function SearchByAllTextFields(phrase: string): Promise<($models.Author |
return $typingPromise;
}
-export function SortedByOrder(fieldsSortingOrder: utils$0.SortField[]): Promise<($models.Author | null)[]> & { cancel(): void } {
- let $resultPromise = $Call.ByID(3046628691, fieldsSortingOrder) as any;
+export function SortedByOrder(fieldsSortingOrder: utils$0.SortField[]): Promise<($models.Worker | null)[]> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(3186234552, fieldsSortingOrder) as any;
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType2($result);
}) as any;
@@ -71,8 +71,8 @@ export function SortedByOrder(fieldsSortingOrder: utils$0.SortField[]): Promise<
return $typingPromise;
}
-export function Update(item: $models.Author): Promise<$models.Author> & { cancel(): void } {
- let $resultPromise = $Call.ByID(2240704960, item) as any;
+export function Update(item: $models.Worker): Promise<$models.Worker> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(698136709, item) as any;
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType0($result);
}) as any;
@@ -81,6 +81,6 @@ export function Update(item: $models.Author): Promise<$models.Author> & { cancel
}
// Private type creation functions
-const $$createType0 = models$0.Author.createFrom;
+const $$createType0 = models$0.Worker.createFrom;
const $$createType1 = $Create.Nullable($$createType0);
const $$createType2 = $Create.Array($$createType1);
diff --git a/frontend/bindings/app/internal/services/workshopservice.ts b/frontend/bindings/app/internal/services/workshopservice.ts
new file mode 100644
index 0000000..640ac5c
--- /dev/null
+++ b/frontend/bindings/app/internal/services/workshopservice.ts
@@ -0,0 +1,86 @@
+// 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 utils$0 from "../utils/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(2983034394) as any;
+ return $resultPromise;
+}
+
+export function Create(item: $models.Workshop): Promise<$models.Workshop> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(982947003, 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(3145051352, id) as any;
+ return $resultPromise;
+}
+
+export function GetAll(): Promise<($models.Workshop | null)[]> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(806282052) 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.Workshop | null> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(1829452217, id) as any;
+ let $typingPromise = $resultPromise.then(($result: any) => {
+ return $$createType1($result);
+ }) as any;
+ $typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
+ return $typingPromise;
+}
+
+export function SearchByAllTextFields(phrase: string): Promise<($models.Workshop | null)[]> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(283835139, phrase) as any;
+ let $typingPromise = $resultPromise.then(($result: any) => {
+ return $$createType2($result);
+ }) as any;
+ $typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
+ return $typingPromise;
+}
+
+export function SortedByOrder(fieldsSortingOrder: utils$0.SortField[]): Promise<($models.Workshop | null)[]> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(3581052397, fieldsSortingOrder) as any;
+ let $typingPromise = $resultPromise.then(($result: any) => {
+ return $$createType2($result);
+ }) as any;
+ $typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
+ return $typingPromise;
+}
+
+export function Update(item: $models.Workshop): Promise<$models.Workshop> & { cancel(): void } {
+ let $resultPromise = $Call.ByID(1795717546, 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.Workshop.createFrom;
+const $$createType1 = $Create.Nullable($$createType0);
+const $$createType2 = $Create.Array($$createType1);
diff --git a/frontend/src/author/AuthorScheme.vue b/frontend/src/author/AuthorScheme.vue
deleted file mode 100644
index 113b9fc..0000000
--- a/frontend/src/author/AuthorScheme.vue
+++ /dev/null
@@ -1,89 +0,0 @@
-
-
-
-
-
-
-
diff --git a/frontend/src/author/author.service.ts b/frontend/src/author/author.service.ts
deleted file mode 100644
index 88d43b3..0000000
--- a/frontend/src/author/author.service.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-import {
- GetAll,
- Create,
- Delete,
- GetById,
- Update,
- Count,
-} from "../../bindings/app/internal/services/authorservice.ts";
-import type { Author } from "../../bindings/app/internal/services";
-import type { IService } from "../types/service.type.ts";
-
-export default class AuthorService implements IService {
- async read(id: number) {
- return (await GetById(id)) as Author;
- }
-
- async readAll() {
- return (await GetAll()) as Author[];
- }
-
- async create(item: Author) {
- await Create(item);
- }
-
- async delete(id: number) {
- return await Delete(id);
- }
-
- async update(item: Author) {
- await Update(item);
- }
-
- async count() {
- return await Count();
- }
-}
diff --git a/frontend/src/comment/CommentScheme.vue b/frontend/src/comment/CommentScheme.vue
deleted file mode 100644
index af901e2..0000000
--- a/frontend/src/comment/CommentScheme.vue
+++ /dev/null
@@ -1,93 +0,0 @@
-
-
-
-
-
-
-
diff --git a/frontend/src/comment/comment.service.ts b/frontend/src/comment/comment.service.ts
deleted file mode 100644
index a1dc85e..0000000
--- a/frontend/src/comment/comment.service.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-import {
- GetAll,
- Create,
- Delete,
- GetById,
- Update,
- Count,
-} from "../../bindings/app/internal/services/commentservice.ts";
-import type { Comment } from "../../bindings/app/internal/services";
-import type { IService } from "../types/service.type.ts";
-
-export default class CommentService implements IService {
- async read(id: number) {
- return (await GetById(id)) as Comment;
- }
-
- async readAll() {
- return (await GetAll()) as Comment[];
- }
-
- async create(item: Comment) {
- await Create(item);
- }
-
- async delete(id: number) {
- return await Delete(id);
- }
-
- async update(item: Comment) {
- await Update(item);
- }
-
- async count() {
- return await Count();
- }
-}
diff --git a/frontend/src/customer/CustomerScheme.vue b/frontend/src/customer/CustomerScheme.vue
new file mode 100644
index 0000000..8a37891
--- /dev/null
+++ b/frontend/src/customer/CustomerScheme.vue
@@ -0,0 +1,95 @@
+
+
+
+
+
+
+
diff --git a/frontend/src/customer/customer.service.ts b/frontend/src/customer/customer.service.ts
new file mode 100644
index 0000000..d7a8206
--- /dev/null
+++ b/frontend/src/customer/customer.service.ts
@@ -0,0 +1,52 @@
+import {
+ GetAll,
+ Create,
+ Delete,
+ GetById,
+ Update,
+ Count,
+ SortedByOrder,
+ SearchByAllTextFields,
+} from "../../bindings/app/internal/services/customerservice";
+import type { Customer } from "../../bindings/app/internal/services";
+import type { IService } from "../types/service.type";
+import type { SortOptions } from "../types/sort-options.type";
+
+export default class CustomerService implements IService {
+ async read(id: number) {
+ return (await GetById(id)) as Customer;
+ }
+
+ async readAll() {
+ return (await GetAll()) as Customer[];
+ }
+
+ async create(item: Customer) {
+ await Create(item);
+ }
+
+ async delete(id: number) {
+ return await Delete(id);
+ }
+
+ async update(item: Customer) {
+ await Update(item);
+ }
+
+ async count() {
+ return await Count();
+ }
+
+ async search(input: string) {
+ return (await SearchByAllTextFields(input)) as Customer[];
+ }
+
+ async sort(options: SortOptions) {
+ return (await SortedByOrder(
+ Object.entries(options).map((item) => ({
+ Name: item[0],
+ Order: item[1],
+ })),
+ )) as Customer[];
+ }
+}
diff --git a/frontend/src/order/OrderScheme.vue b/frontend/src/order/OrderScheme.vue
new file mode 100644
index 0000000..1fc9f8f
--- /dev/null
+++ b/frontend/src/order/OrderScheme.vue
@@ -0,0 +1,165 @@
+
+
+
+
+
+
+
diff --git a/frontend/src/order/order.service.ts b/frontend/src/order/order.service.ts
new file mode 100644
index 0000000..f54c206
--- /dev/null
+++ b/frontend/src/order/order.service.ts
@@ -0,0 +1,52 @@
+import {
+ GetAll,
+ Create,
+ Delete,
+ GetById,
+ Update,
+ Count,
+ SortedByOrder,
+ SearchByAllTextFields,
+} from "../../bindings/app/internal/services/orderservice";
+import type { Order } from "../../bindings/app/internal/services";
+import type { IService } from "../types/service.type";
+import type { SortOptions } from "../types/sort-options.type";
+
+export default class OrderService implements IService {
+ async read(id: number) {
+ return (await GetById(id)) as Order;
+ }
+
+ async readAll() {
+ return (await GetAll()) as Order[];
+ }
+
+ async create(item: Order) {
+ await Create(item);
+ }
+
+ async delete(id: number) {
+ return await Delete(id);
+ }
+
+ async update(item: Order) {
+ await Update(item);
+ }
+
+ async count() {
+ return await Count();
+ }
+
+ async search(input: string) {
+ return (await SearchByAllTextFields(input)) as Order[];
+ }
+
+ async sort(options: SortOptions) {
+ return (await SortedByOrder(
+ Object.entries(options).map((item) => ({
+ Name: item[0],
+ Order: item[1],
+ })),
+ )) as Order[];
+ }
+}
diff --git a/frontend/src/pages/Index.vue b/frontend/src/pages/Index.vue
index ccd3edd..667d010 100644
--- a/frontend/src/pages/Index.vue
+++ b/frontend/src/pages/Index.vue
@@ -1,34 +1,43 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
- Импортировать данные
- Экспортировать данные
-
-
\ No newline at end of file
+
+
+
\ No newline at end of file
diff --git a/frontend/src/pages/pages/GrebenPage.vue b/frontend/src/pages/pages/GrebenPage.vue
deleted file mode 100644
index 8ae9ca0..0000000
--- a/frontend/src/pages/pages/GrebenPage.vue
+++ /dev/null
@@ -1,3 +0,0 @@
-
- GREBEN
-
\ No newline at end of file
diff --git a/frontend/src/pages/pages/UserPage.vue b/frontend/src/pages/pages/UserPage.vue
deleted file mode 100644
index 7b541d3..0000000
--- a/frontend/src/pages/pages/UserPage.vue
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/frontend/src/pages/tables/PostTablePage.vue b/frontend/src/pages/tables/PostTablePage.vue
deleted file mode 100644
index a0cd9f3..0000000
--- a/frontend/src/pages/tables/PostTablePage.vue
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/frontend/src/post/PostScheme.vue b/frontend/src/post/PostScheme.vue
deleted file mode 100644
index 59f7188..0000000
--- a/frontend/src/post/PostScheme.vue
+++ /dev/null
@@ -1,144 +0,0 @@
-
-
-
-
-
diff --git a/frontend/src/post/post.service.ts b/frontend/src/post/post.service.ts
deleted file mode 100644
index e2f79a6..0000000
--- a/frontend/src/post/post.service.ts
+++ /dev/null
@@ -1,47 +0,0 @@
-import {
- GetAll,
- Create,
- Delete,
- GetById,
- Update,
- Count, SortedByOrder,
-} from "../../bindings/app/internal/services/postservice.ts";
-import type { Post } from "../../bindings/app/internal/services";
-import type { IService } from "../types/service.type.ts";
-import type {SortOptions} from "../types/sort-options.type.ts";
-import {SortField} from "../../bindings/app/internal/utils";
-import { SearchByAllTextFields } from "../../bindings/app/internal/services/postservice.ts";
-
-export default class PostService implements IService {
- async read(id: number) {
- return (await GetById(id)) as Post;
- }
-
- async readAll() {
- return (await GetAll()) as Post[];
- }
-
- async create(item: Post) {
- await Create(item);
- }
-
- async delete(id: number) {
- return await Delete(id);
- }
-
- async update(item: Post) {
- await Update(item);
- }
-
- async count() {
- return await Count();
- }
-
- async sort(options: SortOptions) {
- return await SortedByOrder(Object.entries(options).map(item => ({Name: item[0], Order: item[1]}))) as Post[]
- }
-
- async search(input: string): Promise {
- return await SearchByAllTextFields(input) as Post[]
- }
-}
diff --git a/frontend/src/posttype/PosttypeScheme.vue b/frontend/src/posttype/PosttypeScheme.vue
deleted file mode 100644
index 68a96a4..0000000
--- a/frontend/src/posttype/PosttypeScheme.vue
+++ /dev/null
@@ -1,62 +0,0 @@
-
-
-
-
-
-
-
diff --git a/frontend/src/posttype/posttype.service.ts b/frontend/src/posttype/posttype.service.ts
deleted file mode 100644
index 0914bca..0000000
--- a/frontend/src/posttype/posttype.service.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-import {
- GetAll,
- Create,
- Delete,
- GetById,
- Update,
- Count,
-} from "../../bindings/app/internal/services/posttypeservice.ts";
-import type { PostType } from "../../bindings/app/internal/services";
-import type { IService } from "../types/service.type.ts";
-
-export default class PostTypeService implements IService {
- async read(id: number) {
- return (await GetById(id)) as PostType;
- }
-
- async readAll() {
- return (await GetAll()) as PostType[];
- }
-
- async create(item: PostType) {
- await Create(item);
- }
-
- async delete(id: number) {
- return await Delete(id);
- }
-
- async update(item: PostType) {
- await Update(item);
- }
-
- async count() {
- return await Count();
- }
-}
diff --git a/frontend/src/preptask/PreptaskScheme.vue b/frontend/src/preptask/PreptaskScheme.vue
new file mode 100644
index 0000000..884ddc3
--- /dev/null
+++ b/frontend/src/preptask/PreptaskScheme.vue
@@ -0,0 +1,141 @@
+
+
+
+
+
+
+
diff --git a/frontend/src/preptask/preptask.service.ts b/frontend/src/preptask/preptask.service.ts
new file mode 100644
index 0000000..0acfcd7
--- /dev/null
+++ b/frontend/src/preptask/preptask.service.ts
@@ -0,0 +1,52 @@
+import {
+ GetAll,
+ Create,
+ Delete,
+ GetById,
+ Update,
+ Count,
+ SortedByOrder,
+ SearchByAllTextFields,
+} from "../../bindings/app/internal/services/preptaskservice";
+import type { PrepTask } from "../../bindings/app/internal/services";
+import type { IService } from "../types/service.type";
+import type { SortOptions } from "../types/sort-options.type";
+
+export default class PrepTaskService implements IService {
+ async read(id: number) {
+ return (await GetById(id)) as PrepTask;
+ }
+
+ async readAll() {
+ return (await GetAll()) as PrepTask[];
+ }
+
+ async create(item: PrepTask) {
+ await Create(item);
+ }
+
+ async delete(id: number) {
+ return await Delete(id);
+ }
+
+ async update(item: PrepTask) {
+ await Update(item);
+ }
+
+ async count() {
+ return await Count();
+ }
+
+ async search(input: string) {
+ return (await SearchByAllTextFields(input)) as PrepTask[];
+ }
+
+ async sort(options: SortOptions) {
+ return (await SortedByOrder(
+ Object.entries(options).map((item) => ({
+ Name: item[0],
+ Order: item[1],
+ })),
+ )) as PrepTask[];
+ }
+}
diff --git a/frontend/src/producttype/ProducttypeScheme.vue b/frontend/src/producttype/ProducttypeScheme.vue
new file mode 100644
index 0000000..02bd819
--- /dev/null
+++ b/frontend/src/producttype/ProducttypeScheme.vue
@@ -0,0 +1,72 @@
+
+
+
+
+
+
+
diff --git a/frontend/src/producttype/producttype.service.ts b/frontend/src/producttype/producttype.service.ts
new file mode 100644
index 0000000..8032215
--- /dev/null
+++ b/frontend/src/producttype/producttype.service.ts
@@ -0,0 +1,52 @@
+import {
+ GetAll,
+ Create,
+ Delete,
+ GetById,
+ Update,
+ Count,
+ SortedByOrder,
+ SearchByAllTextFields,
+} from "../../bindings/app/internal/services/producttypeservice";
+import type { ProductType } from "../../bindings/app/internal/services";
+import type { IService } from "../types/service.type";
+import type { SortOptions } from "../types/sort-options.type";
+
+export default class ProductTypeService implements IService {
+ async read(id: number) {
+ return (await GetById(id)) as ProductType;
+ }
+
+ async readAll() {
+ return (await GetAll()) as ProductType[];
+ }
+
+ async create(item: ProductType) {
+ await Create(item);
+ }
+
+ async delete(id: number) {
+ return await Delete(id);
+ }
+
+ async update(item: ProductType) {
+ await Update(item);
+ }
+
+ async count() {
+ return await Count();
+ }
+
+ async search(input: string) {
+ return (await SearchByAllTextFields(input)) as ProductType[];
+ }
+
+ async sort(options: SortOptions) {
+ return (await SortedByOrder(
+ Object.entries(options).map((item) => ({
+ Name: item[0],
+ Order: item[1],
+ })),
+ )) as ProductType[];
+ }
+}
diff --git a/frontend/src/router/router.ts b/frontend/src/router/router.ts
index 99135c6..b8b4c01 100644
--- a/frontend/src/router/router.ts
+++ b/frontend/src/router/router.ts
@@ -1,32 +1,32 @@
import { createRouter, createWebHistory, type RouteRecordRaw } from "vue-router";
import Index from "../pages/Index.vue";
-import UserPage from "../pages/pages/UserPage.vue";
-import PostTablePage from "../pages/tables/PostTablePage.vue";
-import GrebenPage from "../pages/pages/GrebenPage.vue";
+
export const routes: RouteRecordRaw[] = [{
path: "/",
component: Index,
name: 'Главная'
-}, {
- path: '/user',
- name: 'Пользователь',
- component: UserPage,
- redirect: '/user/post',
- children: [
- {
- component: PostTablePage,
- path: '/user/post',
- name: 'Новости'
- }, {
- component: GrebenPage,
- path: '/user/greben',
- name: 'Страница гребня'
- }
- ]
-}] as const
+}, ] as const
export const router = createRouter({
history: createWebHistory(),
routes,
-});
\ No newline at end of file
+});
+
+// {
+// path: '/user',
+// name: 'Пользователь',
+// component: UserPage,
+// redirect: '/user/post',
+// children: [
+// {
+// component: PostTablePage,
+// path: '/user/post',
+// name: 'Новости'
+// }, {
+// component: GrebenPage,
+// path: '/user/greben',
+// name: 'Страница гребня'
+// }
+// ]
+// }
\ No newline at end of file
diff --git a/frontend/src/shift/ShiftScheme.vue b/frontend/src/shift/ShiftScheme.vue
new file mode 100644
index 0000000..5c7e4b1
--- /dev/null
+++ b/frontend/src/shift/ShiftScheme.vue
@@ -0,0 +1,140 @@
+
+
+
+
+
+
+
diff --git a/frontend/src/shift/shift.service.ts b/frontend/src/shift/shift.service.ts
new file mode 100644
index 0000000..f30bb59
--- /dev/null
+++ b/frontend/src/shift/shift.service.ts
@@ -0,0 +1,52 @@
+import {
+ GetAll,
+ Create,
+ Delete,
+ GetById,
+ Update,
+ Count,
+ SortedByOrder,
+ SearchByAllTextFields,
+} from "../../bindings/app/internal/services/shiftservice";
+import type { Shift } from "../../bindings/app/internal/services";
+import type { IService } from "../types/service.type";
+import type { SortOptions } from "../types/sort-options.type";
+
+export default class ShiftService implements IService {
+ async read(id: number) {
+ return (await GetById(id)) as Shift;
+ }
+
+ async readAll() {
+ return (await GetAll()) as Shift[];
+ }
+
+ async create(item: Shift) {
+ await Create(item);
+ }
+
+ async delete(id: number) {
+ return await Delete(id);
+ }
+
+ async update(item: Shift) {
+ await Update(item);
+ }
+
+ async count() {
+ return await Count();
+ }
+
+ async search(input: string) {
+ return (await SearchByAllTextFields(input)) as Shift[];
+ }
+
+ async sort(options: SortOptions) {
+ return (await SortedByOrder(
+ Object.entries(options).map((item) => ({
+ Name: item[0],
+ Order: item[1],
+ })),
+ )) as Shift[];
+ }
+}
diff --git a/frontend/src/task/TaskScheme.vue b/frontend/src/task/TaskScheme.vue
new file mode 100644
index 0000000..1d918a1
--- /dev/null
+++ b/frontend/src/task/TaskScheme.vue
@@ -0,0 +1,175 @@
+
+
+
+
+
+
+
diff --git a/frontend/src/task/task.service.ts b/frontend/src/task/task.service.ts
new file mode 100644
index 0000000..bea3705
--- /dev/null
+++ b/frontend/src/task/task.service.ts
@@ -0,0 +1,52 @@
+import {
+ GetAll,
+ Create,
+ Delete,
+ GetById,
+ Update,
+ Count,
+ SortedByOrder,
+ SearchByAllTextFields,
+} from "../../bindings/app/internal/services/taskservice";
+import type { Task } from "../../bindings/app/internal/services";
+import type { IService } from "../types/service.type";
+import type { SortOptions } from "../types/sort-options.type";
+
+export default class TaskService implements IService {
+ async read(id: number) {
+ return (await GetById(id)) as Task;
+ }
+
+ async readAll() {
+ return (await GetAll()) as Task[];
+ }
+
+ async create(item: Task) {
+ await Create(item);
+ }
+
+ async delete(id: number) {
+ return await Delete(id);
+ }
+
+ async update(item: Task) {
+ await Update(item);
+ }
+
+ async count() {
+ return await Count();
+ }
+
+ async search(input: string) {
+ return (await SearchByAllTextFields(input)) as Task[];
+ }
+
+ async sort(options: SortOptions) {
+ return (await SortedByOrder(
+ Object.entries(options).map((item) => ({
+ Name: item[0],
+ Order: item[1],
+ })),
+ )) as Task[];
+ }
+}
diff --git a/frontend/src/teamtask/TeamtaskScheme.vue b/frontend/src/teamtask/TeamtaskScheme.vue
new file mode 100644
index 0000000..48bc6b5
--- /dev/null
+++ b/frontend/src/teamtask/TeamtaskScheme.vue
@@ -0,0 +1,157 @@
+
+
+
+
+
+
+
diff --git a/frontend/src/teamtask/teamtask.service.ts b/frontend/src/teamtask/teamtask.service.ts
new file mode 100644
index 0000000..0bf1ad0
--- /dev/null
+++ b/frontend/src/teamtask/teamtask.service.ts
@@ -0,0 +1,52 @@
+import {
+ GetAll,
+ Create,
+ Delete,
+ GetById,
+ Update,
+ Count,
+ SortedByOrder,
+ SearchByAllTextFields,
+} from "../../bindings/app/internal/services/teamtaskservice";
+import type { TeamTask } from "../../bindings/app/internal/services";
+import type { IService } from "../types/service.type";
+import type { SortOptions } from "../types/sort-options.type";
+
+export default class TeamTaskService implements IService {
+ async read(id: number) {
+ return (await GetById(id)) as TeamTask;
+ }
+
+ async readAll() {
+ return (await GetAll()) as TeamTask[];
+ }
+
+ async create(item: TeamTask) {
+ await Create(item);
+ }
+
+ async delete(id: number) {
+ return await Delete(id);
+ }
+
+ async update(item: TeamTask) {
+ await Update(item);
+ }
+
+ async count() {
+ return await Count();
+ }
+
+ async search(input: string) {
+ return (await SearchByAllTextFields(input)) as TeamTask[];
+ }
+
+ async sort(options: SortOptions) {
+ return (await SortedByOrder(
+ Object.entries(options).map((item) => ({
+ Name: item[0],
+ Order: item[1],
+ })),
+ )) as TeamTask[];
+ }
+}
diff --git a/frontend/src/teamtype/TeamtypeScheme.vue b/frontend/src/teamtype/TeamtypeScheme.vue
new file mode 100644
index 0000000..b15b829
--- /dev/null
+++ b/frontend/src/teamtype/TeamtypeScheme.vue
@@ -0,0 +1,72 @@
+
+
+
+
+
+
+
diff --git a/frontend/src/teamtype/teamtype.service.ts b/frontend/src/teamtype/teamtype.service.ts
new file mode 100644
index 0000000..bb83e29
--- /dev/null
+++ b/frontend/src/teamtype/teamtype.service.ts
@@ -0,0 +1,52 @@
+import {
+ GetAll,
+ Create,
+ Delete,
+ GetById,
+ Update,
+ Count,
+ SortedByOrder,
+ SearchByAllTextFields,
+} from "../../bindings/app/internal/services/teamtypeservice";
+import type { TeamType } from "../../bindings/app/internal/services";
+import type { IService } from "../types/service.type";
+import type { SortOptions } from "../types/sort-options.type";
+
+export default class TeamTypeService implements IService {
+ async read(id: number) {
+ return (await GetById(id)) as TeamType;
+ }
+
+ async readAll() {
+ return (await GetAll()) as TeamType[];
+ }
+
+ async create(item: TeamType) {
+ await Create(item);
+ }
+
+ async delete(id: number) {
+ return await Delete(id);
+ }
+
+ async update(item: TeamType) {
+ await Update(item);
+ }
+
+ async count() {
+ return await Count();
+ }
+
+ async search(input: string) {
+ return (await SearchByAllTextFields(input)) as TeamType[];
+ }
+
+ async sort(options: SortOptions) {
+ return (await SortedByOrder(
+ Object.entries(options).map((item) => ({
+ Name: item[0],
+ Order: item[1],
+ })),
+ )) as TeamType[];
+ }
+}
diff --git a/frontend/src/workarea/WorkareaScheme.vue b/frontend/src/workarea/WorkareaScheme.vue
new file mode 100644
index 0000000..bbdfc99
--- /dev/null
+++ b/frontend/src/workarea/WorkareaScheme.vue
@@ -0,0 +1,159 @@
+
+
+
+
+
+
+
diff --git a/frontend/src/workarea/workarea.service.ts b/frontend/src/workarea/workarea.service.ts
new file mode 100644
index 0000000..a09c86e
--- /dev/null
+++ b/frontend/src/workarea/workarea.service.ts
@@ -0,0 +1,52 @@
+import {
+ GetAll,
+ Create,
+ Delete,
+ GetById,
+ Update,
+ Count,
+ SortedByOrder,
+ SearchByAllTextFields,
+} from "../../bindings/app/internal/services/workareaservice";
+import type { WorkArea } from "../../bindings/app/internal/services";
+import type { IService } from "../types/service.type";
+import type { SortOptions } from "../types/sort-options.type";
+
+export default class WorkAreaService implements IService {
+ async read(id: number) {
+ return (await GetById(id)) as WorkArea;
+ }
+
+ async readAll() {
+ return (await GetAll()) as WorkArea[];
+ }
+
+ async create(item: WorkArea) {
+ await Create(item);
+ }
+
+ async delete(id: number) {
+ return await Delete(id);
+ }
+
+ async update(item: WorkArea) {
+ await Update(item);
+ }
+
+ async count() {
+ return await Count();
+ }
+
+ async search(input: string) {
+ return (await SearchByAllTextFields(input)) as WorkArea[];
+ }
+
+ async sort(options: SortOptions) {
+ return (await SortedByOrder(
+ Object.entries(options).map((item) => ({
+ Name: item[0],
+ Order: item[1],
+ })),
+ )) as WorkArea[];
+ }
+}
diff --git a/frontend/src/worker/WorkerScheme.vue b/frontend/src/worker/WorkerScheme.vue
new file mode 100644
index 0000000..313cf0b
--- /dev/null
+++ b/frontend/src/worker/WorkerScheme.vue
@@ -0,0 +1,111 @@
+
+
+
+
+
+
+
diff --git a/frontend/src/worker/worker.service.ts b/frontend/src/worker/worker.service.ts
new file mode 100644
index 0000000..3e3e702
--- /dev/null
+++ b/frontend/src/worker/worker.service.ts
@@ -0,0 +1,52 @@
+import {
+ GetAll,
+ Create,
+ Delete,
+ GetById,
+ Update,
+ Count,
+ SortedByOrder,
+ SearchByAllTextFields,
+} from "../../bindings/app/internal/services/workerservice";
+import type { Worker } from "../../bindings/app/internal/services";
+import type { IService } from "../types/service.type";
+import type { SortOptions } from "../types/sort-options.type";
+
+export default class WorkerService implements IService {
+ async read(id: number) {
+ return (await GetById(id)) as Worker;
+ }
+
+ async readAll() {
+ return (await GetAll()) as Worker[];
+ }
+
+ async create(item: Worker) {
+ await Create(item);
+ }
+
+ async delete(id: number) {
+ return await Delete(id);
+ }
+
+ async update(item: Worker) {
+ await Update(item);
+ }
+
+ async count() {
+ return await Count();
+ }
+
+ async search(input: string) {
+ return (await SearchByAllTextFields(input)) as Worker[];
+ }
+
+ async sort(options: SortOptions) {
+ return (await SortedByOrder(
+ Object.entries(options).map((item) => ({
+ Name: item[0],
+ Order: item[1],
+ })),
+ )) as Worker[];
+ }
+}
diff --git a/frontend/src/workshop/WorkshopScheme.vue b/frontend/src/workshop/WorkshopScheme.vue
new file mode 100644
index 0000000..063162b
--- /dev/null
+++ b/frontend/src/workshop/WorkshopScheme.vue
@@ -0,0 +1,121 @@
+
+
+
+
+
+
+
diff --git a/frontend/src/workshop/workshop.service.ts b/frontend/src/workshop/workshop.service.ts
new file mode 100644
index 0000000..06b4ad2
--- /dev/null
+++ b/frontend/src/workshop/workshop.service.ts
@@ -0,0 +1,52 @@
+import {
+ GetAll,
+ Create,
+ Delete,
+ GetById,
+ Update,
+ Count,
+ SortedByOrder,
+ SearchByAllTextFields,
+} from "../../bindings/app/internal/services/workshopservice";
+import type { Workshop } from "../../bindings/app/internal/services";
+import type { IService } from "../types/service.type";
+import type { SortOptions } from "../types/sort-options.type";
+
+export default class WorkshopService implements IService {
+ async read(id: number) {
+ return (await GetById(id)) as Workshop;
+ }
+
+ async readAll() {
+ return (await GetAll()) as Workshop[];
+ }
+
+ async create(item: Workshop) {
+ await Create(item);
+ }
+
+ async delete(id: number) {
+ return await Delete(id);
+ }
+
+ async update(item: Workshop) {
+ await Update(item);
+ }
+
+ async count() {
+ return await Count();
+ }
+
+ async search(input: string) {
+ return (await SearchByAllTextFields(input)) as Workshop[];
+ }
+
+ async sort(options: SortOptions) {
+ return (await SortedByOrder(
+ Object.entries(options).map((item) => ({
+ Name: item[0],
+ Order: item[1],
+ })),
+ )) as Workshop[];
+ }
+}
diff --git a/internal/dal/authors.gen.go b/internal/dal/authors.gen.go
deleted file mode 100644
index 3037c5e..0000000
--- a/internal/dal/authors.gen.go
+++ /dev/null
@@ -1,615 +0,0 @@
-// Code generated by gorm.io/gen. DO NOT EDIT.
-// Code generated by gorm.io/gen. DO NOT EDIT.
-// Code generated by gorm.io/gen. DO NOT EDIT.
-
-package dal
-
-import (
- "app/internal/models"
- "context"
-
- "gorm.io/gorm"
- "gorm.io/gorm/clause"
- "gorm.io/gorm/schema"
-
- "gorm.io/gen"
- "gorm.io/gen/field"
-
- "gorm.io/plugin/dbresolver"
-)
-
-func newAuthor(db *gorm.DB, opts ...gen.DOOption) author {
- _author := author{}
-
- _author.authorDo.UseDB(db, opts...)
- _author.authorDo.UseModel(&models.Author{})
-
- tableName := _author.authorDo.TableName()
- _author.ALL = field.NewAsterisk(tableName)
- _author.Id = field.NewUint(tableName, "id")
- _author.Name = field.NewString(tableName, "name")
- _author.Posts = authorHasManyPosts{
- db: db.Session(&gorm.Session{}),
-
- RelationField: field.NewRelation("Posts", "models.Post"),
- Author: struct {
- field.RelationField
- Posts struct {
- field.RelationField
- }
- Comments struct {
- field.RelationField
- Author struct {
- field.RelationField
- }
- Posts struct {
- field.RelationField
- }
- }
- }{
- RelationField: field.NewRelation("Posts.Author", "models.Author"),
- Posts: struct {
- field.RelationField
- }{
- RelationField: field.NewRelation("Posts.Author.Posts", "models.Post"),
- },
- Comments: struct {
- field.RelationField
- Author struct {
- field.RelationField
- }
- Posts struct {
- field.RelationField
- }
- }{
- RelationField: field.NewRelation("Posts.Author.Comments", "models.Comment"),
- Author: struct {
- field.RelationField
- }{
- RelationField: field.NewRelation("Posts.Author.Comments.Author", "models.Author"),
- },
- Posts: struct {
- field.RelationField
- }{
- RelationField: field.NewRelation("Posts.Author.Comments.Posts", "models.Post"),
- },
- },
- },
- PostType: struct {
- field.RelationField
- }{
- RelationField: field.NewRelation("Posts.PostType", "models.PostType"),
- },
- Comments: struct {
- field.RelationField
- }{
- RelationField: field.NewRelation("Posts.Comments", "models.Comment"),
- },
- }
-
- _author.Comments = authorHasManyComments{
- db: db.Session(&gorm.Session{}),
-
- RelationField: field.NewRelation("Comments", "models.Comment"),
- }
-
- _author.fillFieldMap()
-
- return _author
-}
-
-type author struct {
- authorDo
-
- ALL field.Asterisk
- Id field.Uint
- Name field.String
- Posts authorHasManyPosts
-
- Comments authorHasManyComments
-
- fieldMap map[string]field.Expr
-}
-
-func (a author) Table(newTableName string) *author {
- a.authorDo.UseTable(newTableName)
- return a.updateTableName(newTableName)
-}
-
-func (a author) As(alias string) *author {
- a.authorDo.DO = *(a.authorDo.As(alias).(*gen.DO))
- return a.updateTableName(alias)
-}
-
-func (a *author) updateTableName(table string) *author {
- a.ALL = field.NewAsterisk(table)
- a.Id = field.NewUint(table, "id")
- a.Name = field.NewString(table, "name")
-
- a.fillFieldMap()
-
- return a
-}
-
-func (a *author) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
- _f, ok := a.fieldMap[fieldName]
- if !ok || _f == nil {
- return nil, false
- }
- _oe, ok := _f.(field.OrderExpr)
- return _oe, ok
-}
-
-func (a *author) fillFieldMap() {
- a.fieldMap = make(map[string]field.Expr, 4)
- a.fieldMap["id"] = a.Id
- a.fieldMap["name"] = a.Name
-
-}
-
-func (a author) clone(db *gorm.DB) author {
- a.authorDo.ReplaceConnPool(db.Statement.ConnPool)
- return a
-}
-
-func (a author) replaceDB(db *gorm.DB) author {
- a.authorDo.ReplaceDB(db)
- return a
-}
-
-type authorHasManyPosts struct {
- db *gorm.DB
-
- field.RelationField
-
- Author struct {
- field.RelationField
- Posts struct {
- field.RelationField
- }
- Comments struct {
- field.RelationField
- Author struct {
- field.RelationField
- }
- Posts struct {
- field.RelationField
- }
- }
- }
- PostType struct {
- field.RelationField
- }
- Comments struct {
- field.RelationField
- }
-}
-
-func (a authorHasManyPosts) Where(conds ...field.Expr) *authorHasManyPosts {
- if len(conds) == 0 {
- return &a
- }
-
- exprs := make([]clause.Expression, 0, len(conds))
- for _, cond := range conds {
- exprs = append(exprs, cond.BeCond().(clause.Expression))
- }
- a.db = a.db.Clauses(clause.Where{Exprs: exprs})
- return &a
-}
-
-func (a authorHasManyPosts) WithContext(ctx context.Context) *authorHasManyPosts {
- a.db = a.db.WithContext(ctx)
- return &a
-}
-
-func (a authorHasManyPosts) Session(session *gorm.Session) *authorHasManyPosts {
- a.db = a.db.Session(session)
- return &a
-}
-
-func (a authorHasManyPosts) Model(m *models.Author) *authorHasManyPostsTx {
- return &authorHasManyPostsTx{a.db.Model(m).Association(a.Name())}
-}
-
-type authorHasManyPostsTx struct{ tx *gorm.Association }
-
-func (a authorHasManyPostsTx) Find() (result []*models.Post, err error) {
- return result, a.tx.Find(&result)
-}
-
-func (a authorHasManyPostsTx) Append(values ...*models.Post) (err error) {
- targetValues := make([]interface{}, len(values))
- for i, v := range values {
- targetValues[i] = v
- }
- return a.tx.Append(targetValues...)
-}
-
-func (a authorHasManyPostsTx) Replace(values ...*models.Post) (err error) {
- targetValues := make([]interface{}, len(values))
- for i, v := range values {
- targetValues[i] = v
- }
- return a.tx.Replace(targetValues...)
-}
-
-func (a authorHasManyPostsTx) Delete(values ...*models.Post) (err error) {
- targetValues := make([]interface{}, len(values))
- for i, v := range values {
- targetValues[i] = v
- }
- return a.tx.Delete(targetValues...)
-}
-
-func (a authorHasManyPostsTx) Clear() error {
- return a.tx.Clear()
-}
-
-func (a authorHasManyPostsTx) Count() int64 {
- return a.tx.Count()
-}
-
-type authorHasManyComments struct {
- db *gorm.DB
-
- field.RelationField
-}
-
-func (a authorHasManyComments) Where(conds ...field.Expr) *authorHasManyComments {
- if len(conds) == 0 {
- return &a
- }
-
- exprs := make([]clause.Expression, 0, len(conds))
- for _, cond := range conds {
- exprs = append(exprs, cond.BeCond().(clause.Expression))
- }
- a.db = a.db.Clauses(clause.Where{Exprs: exprs})
- return &a
-}
-
-func (a authorHasManyComments) WithContext(ctx context.Context) *authorHasManyComments {
- a.db = a.db.WithContext(ctx)
- return &a
-}
-
-func (a authorHasManyComments) Session(session *gorm.Session) *authorHasManyComments {
- a.db = a.db.Session(session)
- return &a
-}
-
-func (a authorHasManyComments) Model(m *models.Author) *authorHasManyCommentsTx {
- return &authorHasManyCommentsTx{a.db.Model(m).Association(a.Name())}
-}
-
-type authorHasManyCommentsTx struct{ tx *gorm.Association }
-
-func (a authorHasManyCommentsTx) Find() (result []*models.Comment, err error) {
- return result, a.tx.Find(&result)
-}
-
-func (a authorHasManyCommentsTx) Append(values ...*models.Comment) (err error) {
- targetValues := make([]interface{}, len(values))
- for i, v := range values {
- targetValues[i] = v
- }
- return a.tx.Append(targetValues...)
-}
-
-func (a authorHasManyCommentsTx) Replace(values ...*models.Comment) (err error) {
- targetValues := make([]interface{}, len(values))
- for i, v := range values {
- targetValues[i] = v
- }
- return a.tx.Replace(targetValues...)
-}
-
-func (a authorHasManyCommentsTx) Delete(values ...*models.Comment) (err error) {
- targetValues := make([]interface{}, len(values))
- for i, v := range values {
- targetValues[i] = v
- }
- return a.tx.Delete(targetValues...)
-}
-
-func (a authorHasManyCommentsTx) Clear() error {
- return a.tx.Clear()
-}
-
-func (a authorHasManyCommentsTx) Count() int64 {
- return a.tx.Count()
-}
-
-type authorDo struct{ gen.DO }
-
-type IAuthorDo interface {
- gen.SubQuery
- Debug() IAuthorDo
- WithContext(ctx context.Context) IAuthorDo
- WithResult(fc func(tx gen.Dao)) gen.ResultInfo
- ReplaceDB(db *gorm.DB)
- ReadDB() IAuthorDo
- WriteDB() IAuthorDo
- As(alias string) gen.Dao
- Session(config *gorm.Session) IAuthorDo
- Columns(cols ...field.Expr) gen.Columns
- Clauses(conds ...clause.Expression) IAuthorDo
- Not(conds ...gen.Condition) IAuthorDo
- Or(conds ...gen.Condition) IAuthorDo
- Select(conds ...field.Expr) IAuthorDo
- Where(conds ...gen.Condition) IAuthorDo
- Order(conds ...field.Expr) IAuthorDo
- Distinct(cols ...field.Expr) IAuthorDo
- Omit(cols ...field.Expr) IAuthorDo
- Join(table schema.Tabler, on ...field.Expr) IAuthorDo
- LeftJoin(table schema.Tabler, on ...field.Expr) IAuthorDo
- RightJoin(table schema.Tabler, on ...field.Expr) IAuthorDo
- Group(cols ...field.Expr) IAuthorDo
- Having(conds ...gen.Condition) IAuthorDo
- Limit(limit int) IAuthorDo
- Offset(offset int) IAuthorDo
- Count() (count int64, err error)
- Scopes(funcs ...func(gen.Dao) gen.Dao) IAuthorDo
- Unscoped() IAuthorDo
- Create(values ...*models.Author) error
- CreateInBatches(values []*models.Author, batchSize int) error
- Save(values ...*models.Author) error
- First() (*models.Author, error)
- Take() (*models.Author, error)
- Last() (*models.Author, error)
- Find() ([]*models.Author, error)
- FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Author, err error)
- FindInBatches(result *[]*models.Author, batchSize int, fc func(tx gen.Dao, batch int) error) error
- Pluck(column field.Expr, dest interface{}) error
- Delete(...*models.Author) (info gen.ResultInfo, err error)
- Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
- UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
- Updates(value interface{}) (info gen.ResultInfo, err error)
- UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
- UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
- UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
- UpdateFrom(q gen.SubQuery) gen.Dao
- Attrs(attrs ...field.AssignExpr) IAuthorDo
- Assign(attrs ...field.AssignExpr) IAuthorDo
- Joins(fields ...field.RelationField) IAuthorDo
- Preload(fields ...field.RelationField) IAuthorDo
- FirstOrInit() (*models.Author, error)
- FirstOrCreate() (*models.Author, error)
- FindByPage(offset int, limit int) (result []*models.Author, count int64, err error)
- ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
- Scan(result interface{}) (err error)
- Returning(value interface{}, columns ...string) IAuthorDo
- UnderlyingDB() *gorm.DB
- schema.Tabler
-}
-
-func (a authorDo) Debug() IAuthorDo {
- return a.withDO(a.DO.Debug())
-}
-
-func (a authorDo) WithContext(ctx context.Context) IAuthorDo {
- return a.withDO(a.DO.WithContext(ctx))
-}
-
-func (a authorDo) ReadDB() IAuthorDo {
- return a.Clauses(dbresolver.Read)
-}
-
-func (a authorDo) WriteDB() IAuthorDo {
- return a.Clauses(dbresolver.Write)
-}
-
-func (a authorDo) Session(config *gorm.Session) IAuthorDo {
- return a.withDO(a.DO.Session(config))
-}
-
-func (a authorDo) Clauses(conds ...clause.Expression) IAuthorDo {
- return a.withDO(a.DO.Clauses(conds...))
-}
-
-func (a authorDo) Returning(value interface{}, columns ...string) IAuthorDo {
- return a.withDO(a.DO.Returning(value, columns...))
-}
-
-func (a authorDo) Not(conds ...gen.Condition) IAuthorDo {
- return a.withDO(a.DO.Not(conds...))
-}
-
-func (a authorDo) Or(conds ...gen.Condition) IAuthorDo {
- return a.withDO(a.DO.Or(conds...))
-}
-
-func (a authorDo) Select(conds ...field.Expr) IAuthorDo {
- return a.withDO(a.DO.Select(conds...))
-}
-
-func (a authorDo) Where(conds ...gen.Condition) IAuthorDo {
- return a.withDO(a.DO.Where(conds...))
-}
-
-func (a authorDo) Order(conds ...field.Expr) IAuthorDo {
- return a.withDO(a.DO.Order(conds...))
-}
-
-func (a authorDo) Distinct(cols ...field.Expr) IAuthorDo {
- return a.withDO(a.DO.Distinct(cols...))
-}
-
-func (a authorDo) Omit(cols ...field.Expr) IAuthorDo {
- return a.withDO(a.DO.Omit(cols...))
-}
-
-func (a authorDo) Join(table schema.Tabler, on ...field.Expr) IAuthorDo {
- return a.withDO(a.DO.Join(table, on...))
-}
-
-func (a authorDo) LeftJoin(table schema.Tabler, on ...field.Expr) IAuthorDo {
- return a.withDO(a.DO.LeftJoin(table, on...))
-}
-
-func (a authorDo) RightJoin(table schema.Tabler, on ...field.Expr) IAuthorDo {
- return a.withDO(a.DO.RightJoin(table, on...))
-}
-
-func (a authorDo) Group(cols ...field.Expr) IAuthorDo {
- return a.withDO(a.DO.Group(cols...))
-}
-
-func (a authorDo) Having(conds ...gen.Condition) IAuthorDo {
- return a.withDO(a.DO.Having(conds...))
-}
-
-func (a authorDo) Limit(limit int) IAuthorDo {
- return a.withDO(a.DO.Limit(limit))
-}
-
-func (a authorDo) Offset(offset int) IAuthorDo {
- return a.withDO(a.DO.Offset(offset))
-}
-
-func (a authorDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IAuthorDo {
- return a.withDO(a.DO.Scopes(funcs...))
-}
-
-func (a authorDo) Unscoped() IAuthorDo {
- return a.withDO(a.DO.Unscoped())
-}
-
-func (a authorDo) Create(values ...*models.Author) error {
- if len(values) == 0 {
- return nil
- }
- return a.DO.Create(values)
-}
-
-func (a authorDo) CreateInBatches(values []*models.Author, batchSize int) error {
- return a.DO.CreateInBatches(values, batchSize)
-}
-
-// Save : !!! underlying implementation is different with GORM
-// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
-func (a authorDo) Save(values ...*models.Author) error {
- if len(values) == 0 {
- return nil
- }
- return a.DO.Save(values)
-}
-
-func (a authorDo) First() (*models.Author, error) {
- if result, err := a.DO.First(); err != nil {
- return nil, err
- } else {
- return result.(*models.Author), nil
- }
-}
-
-func (a authorDo) Take() (*models.Author, error) {
- if result, err := a.DO.Take(); err != nil {
- return nil, err
- } else {
- return result.(*models.Author), nil
- }
-}
-
-func (a authorDo) Last() (*models.Author, error) {
- if result, err := a.DO.Last(); err != nil {
- return nil, err
- } else {
- return result.(*models.Author), nil
- }
-}
-
-func (a authorDo) Find() ([]*models.Author, error) {
- result, err := a.DO.Find()
- return result.([]*models.Author), err
-}
-
-func (a authorDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Author, err error) {
- buf := make([]*models.Author, 0, batchSize)
- err = a.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
- defer func() { results = append(results, buf...) }()
- return fc(tx, batch)
- })
- return results, err
-}
-
-func (a authorDo) FindInBatches(result *[]*models.Author, batchSize int, fc func(tx gen.Dao, batch int) error) error {
- return a.DO.FindInBatches(result, batchSize, fc)
-}
-
-func (a authorDo) Attrs(attrs ...field.AssignExpr) IAuthorDo {
- return a.withDO(a.DO.Attrs(attrs...))
-}
-
-func (a authorDo) Assign(attrs ...field.AssignExpr) IAuthorDo {
- return a.withDO(a.DO.Assign(attrs...))
-}
-
-func (a authorDo) Joins(fields ...field.RelationField) IAuthorDo {
- for _, _f := range fields {
- a = *a.withDO(a.DO.Joins(_f))
- }
- return &a
-}
-
-func (a authorDo) Preload(fields ...field.RelationField) IAuthorDo {
- for _, _f := range fields {
- a = *a.withDO(a.DO.Preload(_f))
- }
- return &a
-}
-
-func (a authorDo) FirstOrInit() (*models.Author, error) {
- if result, err := a.DO.FirstOrInit(); err != nil {
- return nil, err
- } else {
- return result.(*models.Author), nil
- }
-}
-
-func (a authorDo) FirstOrCreate() (*models.Author, error) {
- if result, err := a.DO.FirstOrCreate(); err != nil {
- return nil, err
- } else {
- return result.(*models.Author), nil
- }
-}
-
-func (a authorDo) FindByPage(offset int, limit int) (result []*models.Author, count int64, err error) {
- result, err = a.Offset(offset).Limit(limit).Find()
- if err != nil {
- return
- }
-
- if size := len(result); 0 < limit && 0 < size && size < limit {
- count = int64(size + offset)
- return
- }
-
- count, err = a.Offset(-1).Limit(-1).Count()
- return
-}
-
-func (a authorDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
- count, err = a.Count()
- if err != nil {
- return
- }
-
- err = a.Offset(offset).Limit(limit).Scan(result)
- return
-}
-
-func (a authorDo) Scan(result interface{}) (err error) {
- return a.DO.Scan(result)
-}
-
-func (a authorDo) Delete(models ...*models.Author) (result gen.ResultInfo, err error) {
- return a.DO.Delete(models)
-}
-
-func (a *authorDo) withDO(do gen.Dao) *authorDo {
- a.DO = *do.(*gen.DO)
- return a
-}
diff --git a/internal/dal/authors.gen_test.go b/internal/dal/authors.gen_test.go
deleted file mode 100644
index 1ec73b6..0000000
--- a/internal/dal/authors.gen_test.go
+++ /dev/null
@@ -1,145 +0,0 @@
-// Code generated by gorm.io/gen. DO NOT EDIT.
-// Code generated by gorm.io/gen. DO NOT EDIT.
-// Code generated by gorm.io/gen. DO NOT EDIT.
-
-package dal
-
-import (
- "app/internal/models"
- "context"
- "fmt"
- "testing"
-
- "gorm.io/gen"
- "gorm.io/gen/field"
- "gorm.io/gorm/clause"
-)
-
-func init() {
- InitializeDB()
- err := _gen_test_db.AutoMigrate(&models.Author{})
- if err != nil {
- fmt.Printf("Error: AutoMigrate(&models.Author{}) fail: %s", err)
- }
-}
-
-func Test_authorQuery(t *testing.T) {
- author := newAuthor(_gen_test_db)
- author = *author.As(author.TableName())
- _do := author.WithContext(context.Background()).Debug()
-
- primaryKey := field.NewString(author.TableName(), clause.PrimaryKey)
- _, err := _do.Unscoped().Where(primaryKey.IsNotNull()).Delete()
- if err != nil {
- t.Error("clean table fail:", err)
- return
- }
-
- _, ok := author.GetFieldByName("")
- if ok {
- t.Error("GetFieldByName(\"\") from author success")
- }
-
- err = _do.Create(&models.Author{})
- if err != nil {
- t.Error("create item in table fail:", err)
- }
-
- err = _do.Save(&models.Author{})
- if err != nil {
- t.Error("create item in table fail:", err)
- }
-
- err = _do.CreateInBatches([]*models.Author{{}, {}}, 10)
- if err != nil {
- t.Error("create item in table fail:", err)
- }
-
- _, err = _do.Select(author.ALL).Take()
- if err != nil {
- t.Error("Take() on table fail:", err)
- }
-
- _, err = _do.First()
- if err != nil {
- t.Error("First() on table fail:", err)
- }
-
- _, err = _do.Last()
- if err != nil {
- t.Error("First() on table fail:", err)
- }
-
- _, err = _do.Where(primaryKey.IsNotNull()).FindInBatch(10, func(tx gen.Dao, batch int) error { return nil })
- if err != nil {
- t.Error("FindInBatch() on table fail:", err)
- }
-
- err = _do.Where(primaryKey.IsNotNull()).FindInBatches(&[]*models.Author{}, 10, func(tx gen.Dao, batch int) error { return nil })
- if err != nil {
- t.Error("FindInBatches() on table fail:", err)
- }
-
- _, err = _do.Select(author.ALL).Where(primaryKey.IsNotNull()).Order(primaryKey.Desc()).Find()
- if err != nil {
- t.Error("Find() on table fail:", err)
- }
-
- _, err = _do.Distinct(primaryKey).Take()
- if err != nil {
- t.Error("select Distinct() on table fail:", err)
- }
-
- _, err = _do.Select(author.ALL).Omit(primaryKey).Take()
- if err != nil {
- t.Error("Omit() on table fail:", err)
- }
-
- _, err = _do.Group(primaryKey).Find()
- if err != nil {
- t.Error("Group() on table fail:", err)
- }
-
- _, err = _do.Scopes(func(dao gen.Dao) gen.Dao { return dao.Where(primaryKey.IsNotNull()) }).Find()
- if err != nil {
- t.Error("Scopes() on table fail:", err)
- }
-
- _, _, err = _do.FindByPage(0, 1)
- if err != nil {
- t.Error("FindByPage() on table fail:", err)
- }
-
- _, err = _do.ScanByPage(&models.Author{}, 0, 1)
- if err != nil {
- t.Error("ScanByPage() on table fail:", err)
- }
-
- _, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrInit()
- if err != nil {
- t.Error("FirstOrInit() on table fail:", err)
- }
-
- _, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrCreate()
- if err != nil {
- t.Error("FirstOrCreate() on table fail:", err)
- }
-
- var _a _another
- var _aPK = field.NewString(_a.TableName(), "id")
-
- err = _do.Join(&_a, primaryKey.EqCol(_aPK)).Scan(map[string]interface{}{})
- if err != nil {
- t.Error("Join() on table fail:", err)
- }
-
- err = _do.LeftJoin(&_a, primaryKey.EqCol(_aPK)).Scan(map[string]interface{}{})
- if err != nil {
- t.Error("LeftJoin() on table fail:", err)
- }
-
- _, err = _do.Not().Or().Clauses().Take()
- if err != nil {
- t.Error("Not/Or/Clauses on table fail:", err)
- }
-}
diff --git a/internal/dal/comments.gen.go b/internal/dal/comments.gen.go
deleted file mode 100644
index c5fdbc8..0000000
--- a/internal/dal/comments.gen.go
+++ /dev/null
@@ -1,622 +0,0 @@
-// Code generated by gorm.io/gen. DO NOT EDIT.
-// Code generated by gorm.io/gen. DO NOT EDIT.
-// Code generated by gorm.io/gen. DO NOT EDIT.
-
-package dal
-
-import (
- "app/internal/models"
- "context"
-
- "gorm.io/gorm"
- "gorm.io/gorm/clause"
- "gorm.io/gorm/schema"
-
- "gorm.io/gen"
- "gorm.io/gen/field"
-
- "gorm.io/plugin/dbresolver"
-)
-
-func newComment(db *gorm.DB, opts ...gen.DOOption) comment {
- _comment := comment{}
-
- _comment.commentDo.UseDB(db, opts...)
- _comment.commentDo.UseModel(&models.Comment{})
-
- tableName := _comment.commentDo.TableName()
- _comment.ALL = field.NewAsterisk(tableName)
- _comment.Id = field.NewUint(tableName, "id")
- _comment.Text = field.NewString(tableName, "text")
- _comment.AuthorId = field.NewUint(tableName, "author_id")
- _comment.Author = commentBelongsToAuthor{
- db: db.Session(&gorm.Session{}),
-
- RelationField: field.NewRelation("Author", "models.Author"),
- Posts: struct {
- field.RelationField
- Author struct {
- field.RelationField
- }
- PostType struct {
- field.RelationField
- }
- Comments struct {
- field.RelationField
- Author struct {
- field.RelationField
- }
- Posts struct {
- field.RelationField
- }
- }
- }{
- RelationField: field.NewRelation("Author.Posts", "models.Post"),
- Author: struct {
- field.RelationField
- }{
- RelationField: field.NewRelation("Author.Posts.Author", "models.Author"),
- },
- PostType: struct {
- field.RelationField
- }{
- RelationField: field.NewRelation("Author.Posts.PostType", "models.PostType"),
- },
- Comments: struct {
- field.RelationField
- Author struct {
- field.RelationField
- }
- Posts struct {
- field.RelationField
- }
- }{
- RelationField: field.NewRelation("Author.Posts.Comments", "models.Comment"),
- Author: struct {
- field.RelationField
- }{
- RelationField: field.NewRelation("Author.Posts.Comments.Author", "models.Author"),
- },
- Posts: struct {
- field.RelationField
- }{
- RelationField: field.NewRelation("Author.Posts.Comments.Posts", "models.Post"),
- },
- },
- },
- Comments: struct {
- field.RelationField
- }{
- RelationField: field.NewRelation("Author.Comments", "models.Comment"),
- },
- }
-
- _comment.Posts = commentManyToManyPosts{
- db: db.Session(&gorm.Session{}),
-
- RelationField: field.NewRelation("Posts", "models.Post"),
- }
-
- _comment.fillFieldMap()
-
- return _comment
-}
-
-type comment struct {
- commentDo
-
- ALL field.Asterisk
- Id field.Uint
- Text field.String
- AuthorId field.Uint
- Author commentBelongsToAuthor
-
- Posts commentManyToManyPosts
-
- fieldMap map[string]field.Expr
-}
-
-func (c comment) Table(newTableName string) *comment {
- c.commentDo.UseTable(newTableName)
- return c.updateTableName(newTableName)
-}
-
-func (c comment) As(alias string) *comment {
- c.commentDo.DO = *(c.commentDo.As(alias).(*gen.DO))
- return c.updateTableName(alias)
-}
-
-func (c *comment) updateTableName(table string) *comment {
- c.ALL = field.NewAsterisk(table)
- c.Id = field.NewUint(table, "id")
- c.Text = field.NewString(table, "text")
- c.AuthorId = field.NewUint(table, "author_id")
-
- c.fillFieldMap()
-
- return c
-}
-
-func (c *comment) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
- _f, ok := c.fieldMap[fieldName]
- if !ok || _f == nil {
- return nil, false
- }
- _oe, ok := _f.(field.OrderExpr)
- return _oe, ok
-}
-
-func (c *comment) fillFieldMap() {
- c.fieldMap = make(map[string]field.Expr, 5)
- c.fieldMap["id"] = c.Id
- c.fieldMap["text"] = c.Text
- c.fieldMap["author_id"] = c.AuthorId
-
-}
-
-func (c comment) clone(db *gorm.DB) comment {
- c.commentDo.ReplaceConnPool(db.Statement.ConnPool)
- return c
-}
-
-func (c comment) replaceDB(db *gorm.DB) comment {
- c.commentDo.ReplaceDB(db)
- return c
-}
-
-type commentBelongsToAuthor struct {
- db *gorm.DB
-
- field.RelationField
-
- Posts struct {
- field.RelationField
- Author struct {
- field.RelationField
- }
- PostType struct {
- field.RelationField
- }
- Comments struct {
- field.RelationField
- Author struct {
- field.RelationField
- }
- Posts struct {
- field.RelationField
- }
- }
- }
- Comments struct {
- field.RelationField
- }
-}
-
-func (a commentBelongsToAuthor) Where(conds ...field.Expr) *commentBelongsToAuthor {
- if len(conds) == 0 {
- return &a
- }
-
- exprs := make([]clause.Expression, 0, len(conds))
- for _, cond := range conds {
- exprs = append(exprs, cond.BeCond().(clause.Expression))
- }
- a.db = a.db.Clauses(clause.Where{Exprs: exprs})
- return &a
-}
-
-func (a commentBelongsToAuthor) WithContext(ctx context.Context) *commentBelongsToAuthor {
- a.db = a.db.WithContext(ctx)
- return &a
-}
-
-func (a commentBelongsToAuthor) Session(session *gorm.Session) *commentBelongsToAuthor {
- a.db = a.db.Session(session)
- return &a
-}
-
-func (a commentBelongsToAuthor) Model(m *models.Comment) *commentBelongsToAuthorTx {
- return &commentBelongsToAuthorTx{a.db.Model(m).Association(a.Name())}
-}
-
-type commentBelongsToAuthorTx struct{ tx *gorm.Association }
-
-func (a commentBelongsToAuthorTx) Find() (result *models.Author, err error) {
- return result, a.tx.Find(&result)
-}
-
-func (a commentBelongsToAuthorTx) Append(values ...*models.Author) (err error) {
- targetValues := make([]interface{}, len(values))
- for i, v := range values {
- targetValues[i] = v
- }
- return a.tx.Append(targetValues...)
-}
-
-func (a commentBelongsToAuthorTx) Replace(values ...*models.Author) (err error) {
- targetValues := make([]interface{}, len(values))
- for i, v := range values {
- targetValues[i] = v
- }
- return a.tx.Replace(targetValues...)
-}
-
-func (a commentBelongsToAuthorTx) Delete(values ...*models.Author) (err error) {
- targetValues := make([]interface{}, len(values))
- for i, v := range values {
- targetValues[i] = v
- }
- return a.tx.Delete(targetValues...)
-}
-
-func (a commentBelongsToAuthorTx) Clear() error {
- return a.tx.Clear()
-}
-
-func (a commentBelongsToAuthorTx) Count() int64 {
- return a.tx.Count()
-}
-
-type commentManyToManyPosts struct {
- db *gorm.DB
-
- field.RelationField
-}
-
-func (a commentManyToManyPosts) Where(conds ...field.Expr) *commentManyToManyPosts {
- if len(conds) == 0 {
- return &a
- }
-
- exprs := make([]clause.Expression, 0, len(conds))
- for _, cond := range conds {
- exprs = append(exprs, cond.BeCond().(clause.Expression))
- }
- a.db = a.db.Clauses(clause.Where{Exprs: exprs})
- return &a
-}
-
-func (a commentManyToManyPosts) WithContext(ctx context.Context) *commentManyToManyPosts {
- a.db = a.db.WithContext(ctx)
- return &a
-}
-
-func (a commentManyToManyPosts) Session(session *gorm.Session) *commentManyToManyPosts {
- a.db = a.db.Session(session)
- return &a
-}
-
-func (a commentManyToManyPosts) Model(m *models.Comment) *commentManyToManyPostsTx {
- return &commentManyToManyPostsTx{a.db.Model(m).Association(a.Name())}
-}
-
-type commentManyToManyPostsTx struct{ tx *gorm.Association }
-
-func (a commentManyToManyPostsTx) Find() (result []*models.Post, err error) {
- return result, a.tx.Find(&result)
-}
-
-func (a commentManyToManyPostsTx) Append(values ...*models.Post) (err error) {
- targetValues := make([]interface{}, len(values))
- for i, v := range values {
- targetValues[i] = v
- }
- return a.tx.Append(targetValues...)
-}
-
-func (a commentManyToManyPostsTx) Replace(values ...*models.Post) (err error) {
- targetValues := make([]interface{}, len(values))
- for i, v := range values {
- targetValues[i] = v
- }
- return a.tx.Replace(targetValues...)
-}
-
-func (a commentManyToManyPostsTx) Delete(values ...*models.Post) (err error) {
- targetValues := make([]interface{}, len(values))
- for i, v := range values {
- targetValues[i] = v
- }
- return a.tx.Delete(targetValues...)
-}
-
-func (a commentManyToManyPostsTx) Clear() error {
- return a.tx.Clear()
-}
-
-func (a commentManyToManyPostsTx) Count() int64 {
- return a.tx.Count()
-}
-
-type commentDo struct{ gen.DO }
-
-type ICommentDo interface {
- gen.SubQuery
- Debug() ICommentDo
- WithContext(ctx context.Context) ICommentDo
- WithResult(fc func(tx gen.Dao)) gen.ResultInfo
- ReplaceDB(db *gorm.DB)
- ReadDB() ICommentDo
- WriteDB() ICommentDo
- As(alias string) gen.Dao
- Session(config *gorm.Session) ICommentDo
- Columns(cols ...field.Expr) gen.Columns
- Clauses(conds ...clause.Expression) ICommentDo
- Not(conds ...gen.Condition) ICommentDo
- Or(conds ...gen.Condition) ICommentDo
- Select(conds ...field.Expr) ICommentDo
- Where(conds ...gen.Condition) ICommentDo
- Order(conds ...field.Expr) ICommentDo
- Distinct(cols ...field.Expr) ICommentDo
- Omit(cols ...field.Expr) ICommentDo
- Join(table schema.Tabler, on ...field.Expr) ICommentDo
- LeftJoin(table schema.Tabler, on ...field.Expr) ICommentDo
- RightJoin(table schema.Tabler, on ...field.Expr) ICommentDo
- Group(cols ...field.Expr) ICommentDo
- Having(conds ...gen.Condition) ICommentDo
- Limit(limit int) ICommentDo
- Offset(offset int) ICommentDo
- Count() (count int64, err error)
- Scopes(funcs ...func(gen.Dao) gen.Dao) ICommentDo
- Unscoped() ICommentDo
- Create(values ...*models.Comment) error
- CreateInBatches(values []*models.Comment, batchSize int) error
- Save(values ...*models.Comment) error
- First() (*models.Comment, error)
- Take() (*models.Comment, error)
- Last() (*models.Comment, error)
- Find() ([]*models.Comment, error)
- FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Comment, err error)
- FindInBatches(result *[]*models.Comment, batchSize int, fc func(tx gen.Dao, batch int) error) error
- Pluck(column field.Expr, dest interface{}) error
- Delete(...*models.Comment) (info gen.ResultInfo, err error)
- Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
- UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
- Updates(value interface{}) (info gen.ResultInfo, err error)
- UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
- UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
- UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
- UpdateFrom(q gen.SubQuery) gen.Dao
- Attrs(attrs ...field.AssignExpr) ICommentDo
- Assign(attrs ...field.AssignExpr) ICommentDo
- Joins(fields ...field.RelationField) ICommentDo
- Preload(fields ...field.RelationField) ICommentDo
- FirstOrInit() (*models.Comment, error)
- FirstOrCreate() (*models.Comment, error)
- FindByPage(offset int, limit int) (result []*models.Comment, count int64, err error)
- ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
- Scan(result interface{}) (err error)
- Returning(value interface{}, columns ...string) ICommentDo
- UnderlyingDB() *gorm.DB
- schema.Tabler
-}
-
-func (c commentDo) Debug() ICommentDo {
- return c.withDO(c.DO.Debug())
-}
-
-func (c commentDo) WithContext(ctx context.Context) ICommentDo {
- return c.withDO(c.DO.WithContext(ctx))
-}
-
-func (c commentDo) ReadDB() ICommentDo {
- return c.Clauses(dbresolver.Read)
-}
-
-func (c commentDo) WriteDB() ICommentDo {
- return c.Clauses(dbresolver.Write)
-}
-
-func (c commentDo) Session(config *gorm.Session) ICommentDo {
- return c.withDO(c.DO.Session(config))
-}
-
-func (c commentDo) Clauses(conds ...clause.Expression) ICommentDo {
- return c.withDO(c.DO.Clauses(conds...))
-}
-
-func (c commentDo) Returning(value interface{}, columns ...string) ICommentDo {
- return c.withDO(c.DO.Returning(value, columns...))
-}
-
-func (c commentDo) Not(conds ...gen.Condition) ICommentDo {
- return c.withDO(c.DO.Not(conds...))
-}
-
-func (c commentDo) Or(conds ...gen.Condition) ICommentDo {
- return c.withDO(c.DO.Or(conds...))
-}
-
-func (c commentDo) Select(conds ...field.Expr) ICommentDo {
- return c.withDO(c.DO.Select(conds...))
-}
-
-func (c commentDo) Where(conds ...gen.Condition) ICommentDo {
- return c.withDO(c.DO.Where(conds...))
-}
-
-func (c commentDo) Order(conds ...field.Expr) ICommentDo {
- return c.withDO(c.DO.Order(conds...))
-}
-
-func (c commentDo) Distinct(cols ...field.Expr) ICommentDo {
- return c.withDO(c.DO.Distinct(cols...))
-}
-
-func (c commentDo) Omit(cols ...field.Expr) ICommentDo {
- return c.withDO(c.DO.Omit(cols...))
-}
-
-func (c commentDo) Join(table schema.Tabler, on ...field.Expr) ICommentDo {
- return c.withDO(c.DO.Join(table, on...))
-}
-
-func (c commentDo) LeftJoin(table schema.Tabler, on ...field.Expr) ICommentDo {
- return c.withDO(c.DO.LeftJoin(table, on...))
-}
-
-func (c commentDo) RightJoin(table schema.Tabler, on ...field.Expr) ICommentDo {
- return c.withDO(c.DO.RightJoin(table, on...))
-}
-
-func (c commentDo) Group(cols ...field.Expr) ICommentDo {
- return c.withDO(c.DO.Group(cols...))
-}
-
-func (c commentDo) Having(conds ...gen.Condition) ICommentDo {
- return c.withDO(c.DO.Having(conds...))
-}
-
-func (c commentDo) Limit(limit int) ICommentDo {
- return c.withDO(c.DO.Limit(limit))
-}
-
-func (c commentDo) Offset(offset int) ICommentDo {
- return c.withDO(c.DO.Offset(offset))
-}
-
-func (c commentDo) Scopes(funcs ...func(gen.Dao) gen.Dao) ICommentDo {
- return c.withDO(c.DO.Scopes(funcs...))
-}
-
-func (c commentDo) Unscoped() ICommentDo {
- return c.withDO(c.DO.Unscoped())
-}
-
-func (c commentDo) Create(values ...*models.Comment) error {
- if len(values) == 0 {
- return nil
- }
- return c.DO.Create(values)
-}
-
-func (c commentDo) CreateInBatches(values []*models.Comment, batchSize int) error {
- return c.DO.CreateInBatches(values, batchSize)
-}
-
-// Save : !!! underlying implementation is different with GORM
-// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
-func (c commentDo) Save(values ...*models.Comment) error {
- if len(values) == 0 {
- return nil
- }
- return c.DO.Save(values)
-}
-
-func (c commentDo) First() (*models.Comment, error) {
- if result, err := c.DO.First(); err != nil {
- return nil, err
- } else {
- return result.(*models.Comment), nil
- }
-}
-
-func (c commentDo) Take() (*models.Comment, error) {
- if result, err := c.DO.Take(); err != nil {
- return nil, err
- } else {
- return result.(*models.Comment), nil
- }
-}
-
-func (c commentDo) Last() (*models.Comment, error) {
- if result, err := c.DO.Last(); err != nil {
- return nil, err
- } else {
- return result.(*models.Comment), nil
- }
-}
-
-func (c commentDo) Find() ([]*models.Comment, error) {
- result, err := c.DO.Find()
- return result.([]*models.Comment), err
-}
-
-func (c commentDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Comment, err error) {
- buf := make([]*models.Comment, 0, batchSize)
- err = c.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
- defer func() { results = append(results, buf...) }()
- return fc(tx, batch)
- })
- return results, err
-}
-
-func (c commentDo) FindInBatches(result *[]*models.Comment, batchSize int, fc func(tx gen.Dao, batch int) error) error {
- return c.DO.FindInBatches(result, batchSize, fc)
-}
-
-func (c commentDo) Attrs(attrs ...field.AssignExpr) ICommentDo {
- return c.withDO(c.DO.Attrs(attrs...))
-}
-
-func (c commentDo) Assign(attrs ...field.AssignExpr) ICommentDo {
- return c.withDO(c.DO.Assign(attrs...))
-}
-
-func (c commentDo) Joins(fields ...field.RelationField) ICommentDo {
- for _, _f := range fields {
- c = *c.withDO(c.DO.Joins(_f))
- }
- return &c
-}
-
-func (c commentDo) Preload(fields ...field.RelationField) ICommentDo {
- for _, _f := range fields {
- c = *c.withDO(c.DO.Preload(_f))
- }
- return &c
-}
-
-func (c commentDo) FirstOrInit() (*models.Comment, error) {
- if result, err := c.DO.FirstOrInit(); err != nil {
- return nil, err
- } else {
- return result.(*models.Comment), nil
- }
-}
-
-func (c commentDo) FirstOrCreate() (*models.Comment, error) {
- if result, err := c.DO.FirstOrCreate(); err != nil {
- return nil, err
- } else {
- return result.(*models.Comment), nil
- }
-}
-
-func (c commentDo) FindByPage(offset int, limit int) (result []*models.Comment, count int64, err error) {
- result, err = c.Offset(offset).Limit(limit).Find()
- if err != nil {
- return
- }
-
- if size := len(result); 0 < limit && 0 < size && size < limit {
- count = int64(size + offset)
- return
- }
-
- count, err = c.Offset(-1).Limit(-1).Count()
- return
-}
-
-func (c commentDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
- count, err = c.Count()
- if err != nil {
- return
- }
-
- err = c.Offset(offset).Limit(limit).Scan(result)
- return
-}
-
-func (c commentDo) Scan(result interface{}) (err error) {
- return c.DO.Scan(result)
-}
-
-func (c commentDo) Delete(models ...*models.Comment) (result gen.ResultInfo, err error) {
- return c.DO.Delete(models)
-}
-
-func (c *commentDo) withDO(do gen.Dao) *commentDo {
- c.DO = *do.(*gen.DO)
- return c
-}
diff --git a/internal/dal/comments.gen_test.go b/internal/dal/comments.gen_test.go
deleted file mode 100644
index f008f02..0000000
--- a/internal/dal/comments.gen_test.go
+++ /dev/null
@@ -1,145 +0,0 @@
-// Code generated by gorm.io/gen. DO NOT EDIT.
-// Code generated by gorm.io/gen. DO NOT EDIT.
-// Code generated by gorm.io/gen. DO NOT EDIT.
-
-package dal
-
-import (
- "app/internal/models"
- "context"
- "fmt"
- "testing"
-
- "gorm.io/gen"
- "gorm.io/gen/field"
- "gorm.io/gorm/clause"
-)
-
-func init() {
- InitializeDB()
- err := _gen_test_db.AutoMigrate(&models.Comment{})
- if err != nil {
- fmt.Printf("Error: AutoMigrate(&models.Comment{}) fail: %s", err)
- }
-}
-
-func Test_commentQuery(t *testing.T) {
- comment := newComment(_gen_test_db)
- comment = *comment.As(comment.TableName())
- _do := comment.WithContext(context.Background()).Debug()
-
- primaryKey := field.NewString(comment.TableName(), clause.PrimaryKey)
- _, err := _do.Unscoped().Where(primaryKey.IsNotNull()).Delete()
- if err != nil {
- t.Error("clean table fail:", err)
- return
- }
-
- _, ok := comment.GetFieldByName("")
- if ok {
- t.Error("GetFieldByName(\"\") from comment success")
- }
-
- err = _do.Create(&models.Comment{})
- if err != nil {
- t.Error("create item in table fail:", err)
- }
-
- err = _do.Save(&models.Comment{})
- if err != nil {
- t.Error("create item in table fail:", err)
- }
-
- err = _do.CreateInBatches([]*models.Comment{{}, {}}, 10)
- if err != nil {
- t.Error("create item in table fail:", err)
- }
-
- _, err = _do.Select(comment.ALL).Take()
- if err != nil {
- t.Error("Take() on table fail:", err)
- }
-
- _, err = _do.First()
- if err != nil {
- t.Error("First() on table fail:", err)
- }
-
- _, err = _do.Last()
- if err != nil {
- t.Error("First() on table fail:", err)
- }
-
- _, err = _do.Where(primaryKey.IsNotNull()).FindInBatch(10, func(tx gen.Dao, batch int) error { return nil })
- if err != nil {
- t.Error("FindInBatch() on table fail:", err)
- }
-
- err = _do.Where(primaryKey.IsNotNull()).FindInBatches(&[]*models.Comment{}, 10, func(tx gen.Dao, batch int) error { return nil })
- if err != nil {
- t.Error("FindInBatches() on table fail:", err)
- }
-
- _, err = _do.Select(comment.ALL).Where(primaryKey.IsNotNull()).Order(primaryKey.Desc()).Find()
- if err != nil {
- t.Error("Find() on table fail:", err)
- }
-
- _, err = _do.Distinct(primaryKey).Take()
- if err != nil {
- t.Error("select Distinct() on table fail:", err)
- }
-
- _, err = _do.Select(comment.ALL).Omit(primaryKey).Take()
- if err != nil {
- t.Error("Omit() on table fail:", err)
- }
-
- _, err = _do.Group(primaryKey).Find()
- if err != nil {
- t.Error("Group() on table fail:", err)
- }
-
- _, err = _do.Scopes(func(dao gen.Dao) gen.Dao { return dao.Where(primaryKey.IsNotNull()) }).Find()
- if err != nil {
- t.Error("Scopes() on table fail:", err)
- }
-
- _, _, err = _do.FindByPage(0, 1)
- if err != nil {
- t.Error("FindByPage() on table fail:", err)
- }
-
- _, err = _do.ScanByPage(&models.Comment{}, 0, 1)
- if err != nil {
- t.Error("ScanByPage() on table fail:", err)
- }
-
- _, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrInit()
- if err != nil {
- t.Error("FirstOrInit() on table fail:", err)
- }
-
- _, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrCreate()
- if err != nil {
- t.Error("FirstOrCreate() on table fail:", err)
- }
-
- var _a _another
- var _aPK = field.NewString(_a.TableName(), "id")
-
- err = _do.Join(&_a, primaryKey.EqCol(_aPK)).Scan(map[string]interface{}{})
- if err != nil {
- t.Error("Join() on table fail:", err)
- }
-
- err = _do.LeftJoin(&_a, primaryKey.EqCol(_aPK)).Scan(map[string]interface{}{})
- if err != nil {
- t.Error("LeftJoin() on table fail:", err)
- }
-
- _, err = _do.Not().Or().Clauses().Take()
- if err != nil {
- t.Error("Not/Or/Clauses on table fail:", err)
- }
-}
diff --git a/internal/dal/customers.gen.go b/internal/dal/customers.gen.go
new file mode 100644
index 0000000..6812572
--- /dev/null
+++ b/internal/dal/customers.gen.go
@@ -0,0 +1,891 @@
+// Code generated by gorm.io/gen. DO NOT EDIT.
+// Code generated by gorm.io/gen. DO NOT EDIT.
+// Code generated by gorm.io/gen. DO NOT EDIT.
+
+package dal
+
+import (
+ "app/internal/models"
+ "context"
+
+ "gorm.io/gorm"
+ "gorm.io/gorm/clause"
+ "gorm.io/gorm/schema"
+
+ "gorm.io/gen"
+ "gorm.io/gen/field"
+
+ "gorm.io/plugin/dbresolver"
+)
+
+func newCustomer(db *gorm.DB, opts ...gen.DOOption) customer {
+ _customer := customer{}
+
+ _customer.customerDo.UseDB(db, opts...)
+ _customer.customerDo.UseModel(&models.Customer{})
+
+ tableName := _customer.customerDo.TableName()
+ _customer.ALL = field.NewAsterisk(tableName)
+ _customer.Id = field.NewUint(tableName, "id")
+ _customer.Title = field.NewString(tableName, "title")
+ _customer.Contact = field.NewString(tableName, "contact")
+ _customer.Orders = customerHasManyOrders{
+ db: db.Session(&gorm.Session{}),
+
+ RelationField: field.NewRelation("Orders", "models.Order"),
+ ProductType: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Orders.ProductType", "models.ProductType"),
+ },
+ Customer: struct {
+ field.RelationField
+ Orders struct {
+ field.RelationField
+ }
+ }{
+ RelationField: field.NewRelation("Orders.Customer", "models.Customer"),
+ Orders: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Orders.Customer.Orders", "models.Order"),
+ },
+ },
+ Tasks: struct {
+ field.RelationField
+ ProductType struct {
+ field.RelationField
+ }
+ Order struct {
+ field.RelationField
+ }
+ PrepTasks struct {
+ field.RelationField
+ Task struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ Workshop struct {
+ field.RelationField
+ WorkAreas struct {
+ field.RelationField
+ }
+ Workers struct {
+ field.RelationField
+ Workshop struct {
+ field.RelationField
+ }
+ TeamTasks struct {
+ field.RelationField
+ TeamType struct {
+ field.RelationField
+ }
+ TeamLeader struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ TeamMembers struct {
+ field.RelationField
+ }
+ }
+ }
+ Tasks struct {
+ field.RelationField
+ }
+ }
+ PrepTasks struct {
+ field.RelationField
+ }
+ Shifts struct {
+ field.RelationField
+ ProductType struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ }
+ TeamTasks struct {
+ field.RelationField
+ }
+ }
+ }
+ Workshops struct {
+ field.RelationField
+ }
+ }{
+ RelationField: field.NewRelation("Orders.Tasks", "models.Task"),
+ ProductType: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Orders.Tasks.ProductType", "models.ProductType"),
+ },
+ Order: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Orders.Tasks.Order", "models.Order"),
+ },
+ PrepTasks: struct {
+ field.RelationField
+ Task struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ Workshop struct {
+ field.RelationField
+ WorkAreas struct {
+ field.RelationField
+ }
+ Workers struct {
+ field.RelationField
+ Workshop struct {
+ field.RelationField
+ }
+ TeamTasks struct {
+ field.RelationField
+ TeamType struct {
+ field.RelationField
+ }
+ TeamLeader struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ TeamMembers struct {
+ field.RelationField
+ }
+ }
+ }
+ Tasks struct {
+ field.RelationField
+ }
+ }
+ PrepTasks struct {
+ field.RelationField
+ }
+ Shifts struct {
+ field.RelationField
+ ProductType struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ }
+ TeamTasks struct {
+ field.RelationField
+ }
+ }
+ }{
+ RelationField: field.NewRelation("Orders.Tasks.PrepTasks", "models.PrepTask"),
+ Task: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Orders.Tasks.PrepTasks.Task", "models.Task"),
+ },
+ WorkArea: struct {
+ field.RelationField
+ Workshop struct {
+ field.RelationField
+ WorkAreas struct {
+ field.RelationField
+ }
+ Workers struct {
+ field.RelationField
+ Workshop struct {
+ field.RelationField
+ }
+ TeamTasks struct {
+ field.RelationField
+ TeamType struct {
+ field.RelationField
+ }
+ TeamLeader struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ TeamMembers struct {
+ field.RelationField
+ }
+ }
+ }
+ Tasks struct {
+ field.RelationField
+ }
+ }
+ PrepTasks struct {
+ field.RelationField
+ }
+ Shifts struct {
+ field.RelationField
+ ProductType struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ }
+ TeamTasks struct {
+ field.RelationField
+ }
+ }{
+ RelationField: field.NewRelation("Orders.Tasks.PrepTasks.WorkArea", "models.WorkArea"),
+ Workshop: struct {
+ field.RelationField
+ WorkAreas struct {
+ field.RelationField
+ }
+ Workers struct {
+ field.RelationField
+ Workshop struct {
+ field.RelationField
+ }
+ TeamTasks struct {
+ field.RelationField
+ TeamType struct {
+ field.RelationField
+ }
+ TeamLeader struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ TeamMembers struct {
+ field.RelationField
+ }
+ }
+ }
+ Tasks struct {
+ field.RelationField
+ }
+ }{
+ RelationField: field.NewRelation("Orders.Tasks.PrepTasks.WorkArea.Workshop", "models.Workshop"),
+ WorkAreas: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Orders.Tasks.PrepTasks.WorkArea.Workshop.WorkAreas", "models.WorkArea"),
+ },
+ Workers: struct {
+ field.RelationField
+ Workshop struct {
+ field.RelationField
+ }
+ TeamTasks struct {
+ field.RelationField
+ TeamType struct {
+ field.RelationField
+ }
+ TeamLeader struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ TeamMembers struct {
+ field.RelationField
+ }
+ }
+ }{
+ RelationField: field.NewRelation("Orders.Tasks.PrepTasks.WorkArea.Workshop.Workers", "models.Worker"),
+ Workshop: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Orders.Tasks.PrepTasks.WorkArea.Workshop.Workers.Workshop", "models.Workshop"),
+ },
+ TeamTasks: struct {
+ field.RelationField
+ TeamType struct {
+ field.RelationField
+ }
+ TeamLeader struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ TeamMembers struct {
+ field.RelationField
+ }
+ }{
+ RelationField: field.NewRelation("Orders.Tasks.PrepTasks.WorkArea.Workshop.Workers.TeamTasks", "models.TeamTask"),
+ TeamType: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Orders.Tasks.PrepTasks.WorkArea.Workshop.Workers.TeamTasks.TeamType", "models.TeamType"),
+ },
+ TeamLeader: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Orders.Tasks.PrepTasks.WorkArea.Workshop.Workers.TeamTasks.TeamLeader", "models.Worker"),
+ },
+ WorkArea: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Orders.Tasks.PrepTasks.WorkArea.Workshop.Workers.TeamTasks.WorkArea", "models.WorkArea"),
+ },
+ TeamMembers: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Orders.Tasks.PrepTasks.WorkArea.Workshop.Workers.TeamTasks.TeamMembers", "models.Worker"),
+ },
+ },
+ },
+ Tasks: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Orders.Tasks.PrepTasks.WorkArea.Workshop.Tasks", "models.Task"),
+ },
+ },
+ PrepTasks: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Orders.Tasks.PrepTasks.WorkArea.PrepTasks", "models.PrepTask"),
+ },
+ Shifts: struct {
+ field.RelationField
+ ProductType struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ }{
+ RelationField: field.NewRelation("Orders.Tasks.PrepTasks.WorkArea.Shifts", "models.Shift"),
+ ProductType: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Orders.Tasks.PrepTasks.WorkArea.Shifts.ProductType", "models.ProductType"),
+ },
+ WorkArea: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Orders.Tasks.PrepTasks.WorkArea.Shifts.WorkArea", "models.WorkArea"),
+ },
+ },
+ TeamTasks: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Orders.Tasks.PrepTasks.WorkArea.TeamTasks", "models.TeamTask"),
+ },
+ },
+ },
+ Workshops: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Orders.Tasks.Workshops", "models.Workshop"),
+ },
+ },
+ }
+
+ _customer.fillFieldMap()
+
+ return _customer
+}
+
+type customer struct {
+ customerDo
+
+ ALL field.Asterisk
+ Id field.Uint
+ Title field.String
+ Contact field.String
+ Orders customerHasManyOrders
+
+ fieldMap map[string]field.Expr
+}
+
+func (c customer) Table(newTableName string) *customer {
+ c.customerDo.UseTable(newTableName)
+ return c.updateTableName(newTableName)
+}
+
+func (c customer) As(alias string) *customer {
+ c.customerDo.DO = *(c.customerDo.As(alias).(*gen.DO))
+ return c.updateTableName(alias)
+}
+
+func (c *customer) updateTableName(table string) *customer {
+ c.ALL = field.NewAsterisk(table)
+ c.Id = field.NewUint(table, "id")
+ c.Title = field.NewString(table, "title")
+ c.Contact = field.NewString(table, "contact")
+
+ c.fillFieldMap()
+
+ return c
+}
+
+func (c *customer) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
+ _f, ok := c.fieldMap[fieldName]
+ if !ok || _f == nil {
+ return nil, false
+ }
+ _oe, ok := _f.(field.OrderExpr)
+ return _oe, ok
+}
+
+func (c *customer) fillFieldMap() {
+ c.fieldMap = make(map[string]field.Expr, 4)
+ c.fieldMap["id"] = c.Id
+ c.fieldMap["title"] = c.Title
+ c.fieldMap["contact"] = c.Contact
+
+}
+
+func (c customer) clone(db *gorm.DB) customer {
+ c.customerDo.ReplaceConnPool(db.Statement.ConnPool)
+ return c
+}
+
+func (c customer) replaceDB(db *gorm.DB) customer {
+ c.customerDo.ReplaceDB(db)
+ return c
+}
+
+type customerHasManyOrders struct {
+ db *gorm.DB
+
+ field.RelationField
+
+ ProductType struct {
+ field.RelationField
+ }
+ Customer struct {
+ field.RelationField
+ Orders struct {
+ field.RelationField
+ }
+ }
+ Tasks struct {
+ field.RelationField
+ ProductType struct {
+ field.RelationField
+ }
+ Order struct {
+ field.RelationField
+ }
+ PrepTasks struct {
+ field.RelationField
+ Task struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ Workshop struct {
+ field.RelationField
+ WorkAreas struct {
+ field.RelationField
+ }
+ Workers struct {
+ field.RelationField
+ Workshop struct {
+ field.RelationField
+ }
+ TeamTasks struct {
+ field.RelationField
+ TeamType struct {
+ field.RelationField
+ }
+ TeamLeader struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ TeamMembers struct {
+ field.RelationField
+ }
+ }
+ }
+ Tasks struct {
+ field.RelationField
+ }
+ }
+ PrepTasks struct {
+ field.RelationField
+ }
+ Shifts struct {
+ field.RelationField
+ ProductType struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ }
+ TeamTasks struct {
+ field.RelationField
+ }
+ }
+ }
+ Workshops struct {
+ field.RelationField
+ }
+ }
+}
+
+func (a customerHasManyOrders) Where(conds ...field.Expr) *customerHasManyOrders {
+ if len(conds) == 0 {
+ return &a
+ }
+
+ exprs := make([]clause.Expression, 0, len(conds))
+ for _, cond := range conds {
+ exprs = append(exprs, cond.BeCond().(clause.Expression))
+ }
+ a.db = a.db.Clauses(clause.Where{Exprs: exprs})
+ return &a
+}
+
+func (a customerHasManyOrders) WithContext(ctx context.Context) *customerHasManyOrders {
+ a.db = a.db.WithContext(ctx)
+ return &a
+}
+
+func (a customerHasManyOrders) Session(session *gorm.Session) *customerHasManyOrders {
+ a.db = a.db.Session(session)
+ return &a
+}
+
+func (a customerHasManyOrders) Model(m *models.Customer) *customerHasManyOrdersTx {
+ return &customerHasManyOrdersTx{a.db.Model(m).Association(a.Name())}
+}
+
+type customerHasManyOrdersTx struct{ tx *gorm.Association }
+
+func (a customerHasManyOrdersTx) Find() (result []*models.Order, err error) {
+ return result, a.tx.Find(&result)
+}
+
+func (a customerHasManyOrdersTx) Append(values ...*models.Order) (err error) {
+ targetValues := make([]interface{}, len(values))
+ for i, v := range values {
+ targetValues[i] = v
+ }
+ return a.tx.Append(targetValues...)
+}
+
+func (a customerHasManyOrdersTx) Replace(values ...*models.Order) (err error) {
+ targetValues := make([]interface{}, len(values))
+ for i, v := range values {
+ targetValues[i] = v
+ }
+ return a.tx.Replace(targetValues...)
+}
+
+func (a customerHasManyOrdersTx) Delete(values ...*models.Order) (err error) {
+ targetValues := make([]interface{}, len(values))
+ for i, v := range values {
+ targetValues[i] = v
+ }
+ return a.tx.Delete(targetValues...)
+}
+
+func (a customerHasManyOrdersTx) Clear() error {
+ return a.tx.Clear()
+}
+
+func (a customerHasManyOrdersTx) Count() int64 {
+ return a.tx.Count()
+}
+
+type customerDo struct{ gen.DO }
+
+type ICustomerDo interface {
+ gen.SubQuery
+ Debug() ICustomerDo
+ WithContext(ctx context.Context) ICustomerDo
+ WithResult(fc func(tx gen.Dao)) gen.ResultInfo
+ ReplaceDB(db *gorm.DB)
+ ReadDB() ICustomerDo
+ WriteDB() ICustomerDo
+ As(alias string) gen.Dao
+ Session(config *gorm.Session) ICustomerDo
+ Columns(cols ...field.Expr) gen.Columns
+ Clauses(conds ...clause.Expression) ICustomerDo
+ Not(conds ...gen.Condition) ICustomerDo
+ Or(conds ...gen.Condition) ICustomerDo
+ Select(conds ...field.Expr) ICustomerDo
+ Where(conds ...gen.Condition) ICustomerDo
+ Order(conds ...field.Expr) ICustomerDo
+ Distinct(cols ...field.Expr) ICustomerDo
+ Omit(cols ...field.Expr) ICustomerDo
+ Join(table schema.Tabler, on ...field.Expr) ICustomerDo
+ LeftJoin(table schema.Tabler, on ...field.Expr) ICustomerDo
+ RightJoin(table schema.Tabler, on ...field.Expr) ICustomerDo
+ Group(cols ...field.Expr) ICustomerDo
+ Having(conds ...gen.Condition) ICustomerDo
+ Limit(limit int) ICustomerDo
+ Offset(offset int) ICustomerDo
+ Count() (count int64, err error)
+ Scopes(funcs ...func(gen.Dao) gen.Dao) ICustomerDo
+ Unscoped() ICustomerDo
+ Create(values ...*models.Customer) error
+ CreateInBatches(values []*models.Customer, batchSize int) error
+ Save(values ...*models.Customer) error
+ First() (*models.Customer, error)
+ Take() (*models.Customer, error)
+ Last() (*models.Customer, error)
+ Find() ([]*models.Customer, error)
+ FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Customer, err error)
+ FindInBatches(result *[]*models.Customer, batchSize int, fc func(tx gen.Dao, batch int) error) error
+ Pluck(column field.Expr, dest interface{}) error
+ Delete(...*models.Customer) (info gen.ResultInfo, err error)
+ Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
+ UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
+ Updates(value interface{}) (info gen.ResultInfo, err error)
+ UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
+ UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
+ UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
+ UpdateFrom(q gen.SubQuery) gen.Dao
+ Attrs(attrs ...field.AssignExpr) ICustomerDo
+ Assign(attrs ...field.AssignExpr) ICustomerDo
+ Joins(fields ...field.RelationField) ICustomerDo
+ Preload(fields ...field.RelationField) ICustomerDo
+ FirstOrInit() (*models.Customer, error)
+ FirstOrCreate() (*models.Customer, error)
+ FindByPage(offset int, limit int) (result []*models.Customer, count int64, err error)
+ ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
+ Scan(result interface{}) (err error)
+ Returning(value interface{}, columns ...string) ICustomerDo
+ UnderlyingDB() *gorm.DB
+ schema.Tabler
+}
+
+func (c customerDo) Debug() ICustomerDo {
+ return c.withDO(c.DO.Debug())
+}
+
+func (c customerDo) WithContext(ctx context.Context) ICustomerDo {
+ return c.withDO(c.DO.WithContext(ctx))
+}
+
+func (c customerDo) ReadDB() ICustomerDo {
+ return c.Clauses(dbresolver.Read)
+}
+
+func (c customerDo) WriteDB() ICustomerDo {
+ return c.Clauses(dbresolver.Write)
+}
+
+func (c customerDo) Session(config *gorm.Session) ICustomerDo {
+ return c.withDO(c.DO.Session(config))
+}
+
+func (c customerDo) Clauses(conds ...clause.Expression) ICustomerDo {
+ return c.withDO(c.DO.Clauses(conds...))
+}
+
+func (c customerDo) Returning(value interface{}, columns ...string) ICustomerDo {
+ return c.withDO(c.DO.Returning(value, columns...))
+}
+
+func (c customerDo) Not(conds ...gen.Condition) ICustomerDo {
+ return c.withDO(c.DO.Not(conds...))
+}
+
+func (c customerDo) Or(conds ...gen.Condition) ICustomerDo {
+ return c.withDO(c.DO.Or(conds...))
+}
+
+func (c customerDo) Select(conds ...field.Expr) ICustomerDo {
+ return c.withDO(c.DO.Select(conds...))
+}
+
+func (c customerDo) Where(conds ...gen.Condition) ICustomerDo {
+ return c.withDO(c.DO.Where(conds...))
+}
+
+func (c customerDo) Order(conds ...field.Expr) ICustomerDo {
+ return c.withDO(c.DO.Order(conds...))
+}
+
+func (c customerDo) Distinct(cols ...field.Expr) ICustomerDo {
+ return c.withDO(c.DO.Distinct(cols...))
+}
+
+func (c customerDo) Omit(cols ...field.Expr) ICustomerDo {
+ return c.withDO(c.DO.Omit(cols...))
+}
+
+func (c customerDo) Join(table schema.Tabler, on ...field.Expr) ICustomerDo {
+ return c.withDO(c.DO.Join(table, on...))
+}
+
+func (c customerDo) LeftJoin(table schema.Tabler, on ...field.Expr) ICustomerDo {
+ return c.withDO(c.DO.LeftJoin(table, on...))
+}
+
+func (c customerDo) RightJoin(table schema.Tabler, on ...field.Expr) ICustomerDo {
+ return c.withDO(c.DO.RightJoin(table, on...))
+}
+
+func (c customerDo) Group(cols ...field.Expr) ICustomerDo {
+ return c.withDO(c.DO.Group(cols...))
+}
+
+func (c customerDo) Having(conds ...gen.Condition) ICustomerDo {
+ return c.withDO(c.DO.Having(conds...))
+}
+
+func (c customerDo) Limit(limit int) ICustomerDo {
+ return c.withDO(c.DO.Limit(limit))
+}
+
+func (c customerDo) Offset(offset int) ICustomerDo {
+ return c.withDO(c.DO.Offset(offset))
+}
+
+func (c customerDo) Scopes(funcs ...func(gen.Dao) gen.Dao) ICustomerDo {
+ return c.withDO(c.DO.Scopes(funcs...))
+}
+
+func (c customerDo) Unscoped() ICustomerDo {
+ return c.withDO(c.DO.Unscoped())
+}
+
+func (c customerDo) Create(values ...*models.Customer) error {
+ if len(values) == 0 {
+ return nil
+ }
+ return c.DO.Create(values)
+}
+
+func (c customerDo) CreateInBatches(values []*models.Customer, batchSize int) error {
+ return c.DO.CreateInBatches(values, batchSize)
+}
+
+// Save : !!! underlying implementation is different with GORM
+// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
+func (c customerDo) Save(values ...*models.Customer) error {
+ if len(values) == 0 {
+ return nil
+ }
+ return c.DO.Save(values)
+}
+
+func (c customerDo) First() (*models.Customer, error) {
+ if result, err := c.DO.First(); err != nil {
+ return nil, err
+ } else {
+ return result.(*models.Customer), nil
+ }
+}
+
+func (c customerDo) Take() (*models.Customer, error) {
+ if result, err := c.DO.Take(); err != nil {
+ return nil, err
+ } else {
+ return result.(*models.Customer), nil
+ }
+}
+
+func (c customerDo) Last() (*models.Customer, error) {
+ if result, err := c.DO.Last(); err != nil {
+ return nil, err
+ } else {
+ return result.(*models.Customer), nil
+ }
+}
+
+func (c customerDo) Find() ([]*models.Customer, error) {
+ result, err := c.DO.Find()
+ return result.([]*models.Customer), err
+}
+
+func (c customerDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Customer, err error) {
+ buf := make([]*models.Customer, 0, batchSize)
+ err = c.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
+ defer func() { results = append(results, buf...) }()
+ return fc(tx, batch)
+ })
+ return results, err
+}
+
+func (c customerDo) FindInBatches(result *[]*models.Customer, batchSize int, fc func(tx gen.Dao, batch int) error) error {
+ return c.DO.FindInBatches(result, batchSize, fc)
+}
+
+func (c customerDo) Attrs(attrs ...field.AssignExpr) ICustomerDo {
+ return c.withDO(c.DO.Attrs(attrs...))
+}
+
+func (c customerDo) Assign(attrs ...field.AssignExpr) ICustomerDo {
+ return c.withDO(c.DO.Assign(attrs...))
+}
+
+func (c customerDo) Joins(fields ...field.RelationField) ICustomerDo {
+ for _, _f := range fields {
+ c = *c.withDO(c.DO.Joins(_f))
+ }
+ return &c
+}
+
+func (c customerDo) Preload(fields ...field.RelationField) ICustomerDo {
+ for _, _f := range fields {
+ c = *c.withDO(c.DO.Preload(_f))
+ }
+ return &c
+}
+
+func (c customerDo) FirstOrInit() (*models.Customer, error) {
+ if result, err := c.DO.FirstOrInit(); err != nil {
+ return nil, err
+ } else {
+ return result.(*models.Customer), nil
+ }
+}
+
+func (c customerDo) FirstOrCreate() (*models.Customer, error) {
+ if result, err := c.DO.FirstOrCreate(); err != nil {
+ return nil, err
+ } else {
+ return result.(*models.Customer), nil
+ }
+}
+
+func (c customerDo) FindByPage(offset int, limit int) (result []*models.Customer, count int64, err error) {
+ result, err = c.Offset(offset).Limit(limit).Find()
+ if err != nil {
+ return
+ }
+
+ if size := len(result); 0 < limit && 0 < size && size < limit {
+ count = int64(size + offset)
+ return
+ }
+
+ count, err = c.Offset(-1).Limit(-1).Count()
+ return
+}
+
+func (c customerDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
+ count, err = c.Count()
+ if err != nil {
+ return
+ }
+
+ err = c.Offset(offset).Limit(limit).Scan(result)
+ return
+}
+
+func (c customerDo) Scan(result interface{}) (err error) {
+ return c.DO.Scan(result)
+}
+
+func (c customerDo) Delete(models ...*models.Customer) (result gen.ResultInfo, err error) {
+ return c.DO.Delete(models)
+}
+
+func (c *customerDo) withDO(do gen.Dao) *customerDo {
+ c.DO = *do.(*gen.DO)
+ return c
+}
diff --git a/internal/dal/customers.gen_test.go b/internal/dal/customers.gen_test.go
new file mode 100644
index 0000000..424cf3c
--- /dev/null
+++ b/internal/dal/customers.gen_test.go
@@ -0,0 +1,145 @@
+// Code generated by gorm.io/gen. DO NOT EDIT.
+// Code generated by gorm.io/gen. DO NOT EDIT.
+// Code generated by gorm.io/gen. DO NOT EDIT.
+
+package dal
+
+import (
+ "app/internal/models"
+ "context"
+ "fmt"
+ "testing"
+
+ "gorm.io/gen"
+ "gorm.io/gen/field"
+ "gorm.io/gorm/clause"
+)
+
+func init() {
+ InitializeDB()
+ err := _gen_test_db.AutoMigrate(&models.Customer{})
+ if err != nil {
+ fmt.Printf("Error: AutoMigrate(&models.Customer{}) fail: %s", err)
+ }
+}
+
+func Test_customerQuery(t *testing.T) {
+ customer := newCustomer(_gen_test_db)
+ customer = *customer.As(customer.TableName())
+ _do := customer.WithContext(context.Background()).Debug()
+
+ primaryKey := field.NewString(customer.TableName(), clause.PrimaryKey)
+ _, err := _do.Unscoped().Where(primaryKey.IsNotNull()).Delete()
+ if err != nil {
+ t.Error("clean table fail:", err)
+ return
+ }
+
+ _, ok := customer.GetFieldByName("")
+ if ok {
+ t.Error("GetFieldByName(\"\") from customer success")
+ }
+
+ err = _do.Create(&models.Customer{})
+ if err != nil {
+ t.Error("create item in table fail:", err)
+ }
+
+ err = _do.Save(&models.Customer{})
+ if err != nil {
+ t.Error("create item in table fail:", err)
+ }
+
+ err = _do.CreateInBatches([]*models.Customer{{}, {}}, 10)
+ if err != nil {
+ t.Error("create item in table fail:", err)
+ }
+
+ _, err = _do.Select(customer.ALL).Take()
+ if err != nil {
+ t.Error("Take() on table fail:", err)
+ }
+
+ _, err = _do.First()
+ if err != nil {
+ t.Error("First() on table fail:", err)
+ }
+
+ _, err = _do.Last()
+ if err != nil {
+ t.Error("First() on table fail:", err)
+ }
+
+ _, err = _do.Where(primaryKey.IsNotNull()).FindInBatch(10, func(tx gen.Dao, batch int) error { return nil })
+ if err != nil {
+ t.Error("FindInBatch() on table fail:", err)
+ }
+
+ err = _do.Where(primaryKey.IsNotNull()).FindInBatches(&[]*models.Customer{}, 10, func(tx gen.Dao, batch int) error { return nil })
+ if err != nil {
+ t.Error("FindInBatches() on table fail:", err)
+ }
+
+ _, err = _do.Select(customer.ALL).Where(primaryKey.IsNotNull()).Order(primaryKey.Desc()).Find()
+ if err != nil {
+ t.Error("Find() on table fail:", err)
+ }
+
+ _, err = _do.Distinct(primaryKey).Take()
+ if err != nil {
+ t.Error("select Distinct() on table fail:", err)
+ }
+
+ _, err = _do.Select(customer.ALL).Omit(primaryKey).Take()
+ if err != nil {
+ t.Error("Omit() on table fail:", err)
+ }
+
+ _, err = _do.Group(primaryKey).Find()
+ if err != nil {
+ t.Error("Group() on table fail:", err)
+ }
+
+ _, err = _do.Scopes(func(dao gen.Dao) gen.Dao { return dao.Where(primaryKey.IsNotNull()) }).Find()
+ if err != nil {
+ t.Error("Scopes() on table fail:", err)
+ }
+
+ _, _, err = _do.FindByPage(0, 1)
+ if err != nil {
+ t.Error("FindByPage() on table fail:", err)
+ }
+
+ _, err = _do.ScanByPage(&models.Customer{}, 0, 1)
+ if err != nil {
+ t.Error("ScanByPage() on table fail:", err)
+ }
+
+ _, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrInit()
+ if err != nil {
+ t.Error("FirstOrInit() on table fail:", err)
+ }
+
+ _, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrCreate()
+ if err != nil {
+ t.Error("FirstOrCreate() on table fail:", err)
+ }
+
+ var _a _another
+ var _aPK = field.NewString(_a.TableName(), "id")
+
+ err = _do.Join(&_a, primaryKey.EqCol(_aPK)).Scan(map[string]interface{}{})
+ if err != nil {
+ t.Error("Join() on table fail:", err)
+ }
+
+ err = _do.LeftJoin(&_a, primaryKey.EqCol(_aPK)).Scan(map[string]interface{}{})
+ if err != nil {
+ t.Error("LeftJoin() on table fail:", err)
+ }
+
+ _, err = _do.Not().Or().Clauses().Take()
+ if err != nil {
+ t.Error("Not/Or/Clauses on table fail:", err)
+ }
+}
diff --git a/internal/dal/gen.go b/internal/dal/gen.go
index e69fc7e..06afe41 100644
--- a/internal/dal/gen.go
+++ b/internal/dal/gen.go
@@ -16,49 +16,84 @@ import (
)
var (
- Q = new(Query)
- Author *author
- Comment *comment
- Post *post
- PostType *postType
+ Q = new(Query)
+ Customer *customer
+ Order *order
+ PrepTask *prepTask
+ ProductType *productType
+ Shift *shift
+ Task *task
+ TeamTask *teamTask
+ TeamType *teamType
+ WorkArea *workArea
+ Worker *worker
+ Workshop *workshop
)
func SetDefault(db *gorm.DB, opts ...gen.DOOption) {
*Q = *Use(db, opts...)
- Author = &Q.Author
- Comment = &Q.Comment
- Post = &Q.Post
- PostType = &Q.PostType
+ Customer = &Q.Customer
+ Order = &Q.Order
+ PrepTask = &Q.PrepTask
+ ProductType = &Q.ProductType
+ Shift = &Q.Shift
+ Task = &Q.Task
+ TeamTask = &Q.TeamTask
+ TeamType = &Q.TeamType
+ WorkArea = &Q.WorkArea
+ Worker = &Q.Worker
+ Workshop = &Q.Workshop
}
func Use(db *gorm.DB, opts ...gen.DOOption) *Query {
return &Query{
- db: db,
- Author: newAuthor(db, opts...),
- Comment: newComment(db, opts...),
- Post: newPost(db, opts...),
- PostType: newPostType(db, opts...),
+ db: db,
+ Customer: newCustomer(db, opts...),
+ Order: newOrder(db, opts...),
+ PrepTask: newPrepTask(db, opts...),
+ ProductType: newProductType(db, opts...),
+ Shift: newShift(db, opts...),
+ Task: newTask(db, opts...),
+ TeamTask: newTeamTask(db, opts...),
+ TeamType: newTeamType(db, opts...),
+ WorkArea: newWorkArea(db, opts...),
+ Worker: newWorker(db, opts...),
+ Workshop: newWorkshop(db, opts...),
}
}
type Query struct {
db *gorm.DB
- Author author
- Comment comment
- Post post
- PostType postType
+ Customer customer
+ Order order
+ PrepTask prepTask
+ ProductType productType
+ Shift shift
+ Task task
+ TeamTask teamTask
+ TeamType teamType
+ WorkArea workArea
+ Worker worker
+ Workshop workshop
}
func (q *Query) Available() bool { return q.db != nil }
func (q *Query) clone(db *gorm.DB) *Query {
return &Query{
- db: db,
- Author: q.Author.clone(db),
- Comment: q.Comment.clone(db),
- Post: q.Post.clone(db),
- PostType: q.PostType.clone(db),
+ db: db,
+ Customer: q.Customer.clone(db),
+ Order: q.Order.clone(db),
+ PrepTask: q.PrepTask.clone(db),
+ ProductType: q.ProductType.clone(db),
+ Shift: q.Shift.clone(db),
+ Task: q.Task.clone(db),
+ TeamTask: q.TeamTask.clone(db),
+ TeamType: q.TeamType.clone(db),
+ WorkArea: q.WorkArea.clone(db),
+ Worker: q.Worker.clone(db),
+ Workshop: q.Workshop.clone(db),
}
}
@@ -72,27 +107,48 @@ func (q *Query) WriteDB() *Query {
func (q *Query) ReplaceDB(db *gorm.DB) *Query {
return &Query{
- db: db,
- Author: q.Author.replaceDB(db),
- Comment: q.Comment.replaceDB(db),
- Post: q.Post.replaceDB(db),
- PostType: q.PostType.replaceDB(db),
+ db: db,
+ Customer: q.Customer.replaceDB(db),
+ Order: q.Order.replaceDB(db),
+ PrepTask: q.PrepTask.replaceDB(db),
+ ProductType: q.ProductType.replaceDB(db),
+ Shift: q.Shift.replaceDB(db),
+ Task: q.Task.replaceDB(db),
+ TeamTask: q.TeamTask.replaceDB(db),
+ TeamType: q.TeamType.replaceDB(db),
+ WorkArea: q.WorkArea.replaceDB(db),
+ Worker: q.Worker.replaceDB(db),
+ Workshop: q.Workshop.replaceDB(db),
}
}
type queryCtx struct {
- Author IAuthorDo
- Comment ICommentDo
- Post IPostDo
- PostType IPostTypeDo
+ Customer ICustomerDo
+ Order IOrderDo
+ PrepTask IPrepTaskDo
+ ProductType IProductTypeDo
+ Shift IShiftDo
+ Task ITaskDo
+ TeamTask ITeamTaskDo
+ TeamType ITeamTypeDo
+ WorkArea IWorkAreaDo
+ Worker IWorkerDo
+ Workshop IWorkshopDo
}
func (q *Query) WithContext(ctx context.Context) *queryCtx {
return &queryCtx{
- Author: q.Author.WithContext(ctx),
- Comment: q.Comment.WithContext(ctx),
- Post: q.Post.WithContext(ctx),
- PostType: q.PostType.WithContext(ctx),
+ Customer: q.Customer.WithContext(ctx),
+ Order: q.Order.WithContext(ctx),
+ PrepTask: q.PrepTask.WithContext(ctx),
+ ProductType: q.ProductType.WithContext(ctx),
+ Shift: q.Shift.WithContext(ctx),
+ Task: q.Task.WithContext(ctx),
+ TeamTask: q.TeamTask.WithContext(ctx),
+ TeamType: q.TeamType.WithContext(ctx),
+ WorkArea: q.WorkArea.WithContext(ctx),
+ Worker: q.Worker.WithContext(ctx),
+ Workshop: q.Workshop.WithContext(ctx),
}
}
diff --git a/internal/dal/gen_test.db b/internal/dal/gen_test.db
deleted file mode 100644
index ac0b67d..0000000
Binary files a/internal/dal/gen_test.db and /dev/null differ
diff --git a/internal/dal/gen_test.go b/internal/dal/gen_test.go
index dab9256..0ce6779 100644
--- a/internal/dal/gen_test.go
+++ b/internal/dal/gen_test.go
@@ -77,10 +77,17 @@ func Test_WithContext(t *testing.T) {
qCtx := query.WithContext(context.WithValue(context.Background(), key, value))
for _, ctx := range []context.Context{
- qCtx.Author.UnderlyingDB().Statement.Context,
- qCtx.Comment.UnderlyingDB().Statement.Context,
- qCtx.Post.UnderlyingDB().Statement.Context,
- qCtx.PostType.UnderlyingDB().Statement.Context,
+ qCtx.Customer.UnderlyingDB().Statement.Context,
+ qCtx.Order.UnderlyingDB().Statement.Context,
+ qCtx.PrepTask.UnderlyingDB().Statement.Context,
+ qCtx.ProductType.UnderlyingDB().Statement.Context,
+ qCtx.Shift.UnderlyingDB().Statement.Context,
+ qCtx.Task.UnderlyingDB().Statement.Context,
+ qCtx.TeamTask.UnderlyingDB().Statement.Context,
+ qCtx.TeamType.UnderlyingDB().Statement.Context,
+ qCtx.WorkArea.UnderlyingDB().Statement.Context,
+ qCtx.Worker.UnderlyingDB().Statement.Context,
+ qCtx.Workshop.UnderlyingDB().Statement.Context,
} {
if v := ctx.Value(key); v != value {
t.Errorf("get value from context fail, expect %q, got %q", value, v)
diff --git a/internal/dal/orders.gen.go b/internal/dal/orders.gen.go
new file mode 100644
index 0000000..64004e8
--- /dev/null
+++ b/internal/dal/orders.gen.go
@@ -0,0 +1,1018 @@
+// Code generated by gorm.io/gen. DO NOT EDIT.
+// Code generated by gorm.io/gen. DO NOT EDIT.
+// Code generated by gorm.io/gen. DO NOT EDIT.
+
+package dal
+
+import (
+ "app/internal/models"
+ "context"
+
+ "gorm.io/gorm"
+ "gorm.io/gorm/clause"
+ "gorm.io/gorm/schema"
+
+ "gorm.io/gen"
+ "gorm.io/gen/field"
+
+ "gorm.io/plugin/dbresolver"
+)
+
+func newOrder(db *gorm.DB, opts ...gen.DOOption) order {
+ _order := order{}
+
+ _order.orderDo.UseDB(db, opts...)
+ _order.orderDo.UseModel(&models.Order{})
+
+ tableName := _order.orderDo.TableName()
+ _order.ALL = field.NewAsterisk(tableName)
+ _order.Id = field.NewUint(tableName, "id")
+ _order.Status = field.NewString(tableName, "status")
+ _order.Description = field.NewString(tableName, "description")
+ _order.ProductTypeId = field.NewInt(tableName, "product_type_id")
+ _order.ProductAmount = field.NewUint(tableName, "product_amount")
+ _order.CustomerId = field.NewUint(tableName, "customer_id")
+ _order.CreatedAt = field.NewInt64(tableName, "created_at")
+ _order.DeadlineDate = field.NewInt64(tableName, "deadline_date")
+ _order.Tasks = orderHasManyTasks{
+ db: db.Session(&gorm.Session{}),
+
+ RelationField: field.NewRelation("Tasks", "models.Task"),
+ ProductType: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Tasks.ProductType", "models.ProductType"),
+ },
+ Order: struct {
+ field.RelationField
+ ProductType struct {
+ field.RelationField
+ }
+ Customer struct {
+ field.RelationField
+ Orders struct {
+ field.RelationField
+ }
+ }
+ Tasks struct {
+ field.RelationField
+ }
+ }{
+ RelationField: field.NewRelation("Tasks.Order", "models.Order"),
+ ProductType: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Tasks.Order.ProductType", "models.ProductType"),
+ },
+ Customer: struct {
+ field.RelationField
+ Orders struct {
+ field.RelationField
+ }
+ }{
+ RelationField: field.NewRelation("Tasks.Order.Customer", "models.Customer"),
+ Orders: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Tasks.Order.Customer.Orders", "models.Order"),
+ },
+ },
+ Tasks: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Tasks.Order.Tasks", "models.Task"),
+ },
+ },
+ PrepTasks: struct {
+ field.RelationField
+ Task struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ Workshop struct {
+ field.RelationField
+ WorkAreas struct {
+ field.RelationField
+ }
+ Workers struct {
+ field.RelationField
+ Workshop struct {
+ field.RelationField
+ }
+ TeamTasks struct {
+ field.RelationField
+ TeamType struct {
+ field.RelationField
+ }
+ TeamLeader struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ TeamMembers struct {
+ field.RelationField
+ }
+ }
+ }
+ Tasks struct {
+ field.RelationField
+ }
+ }
+ PrepTasks struct {
+ field.RelationField
+ }
+ Shifts struct {
+ field.RelationField
+ ProductType struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ }
+ TeamTasks struct {
+ field.RelationField
+ }
+ }
+ }{
+ RelationField: field.NewRelation("Tasks.PrepTasks", "models.PrepTask"),
+ Task: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Tasks.PrepTasks.Task", "models.Task"),
+ },
+ WorkArea: struct {
+ field.RelationField
+ Workshop struct {
+ field.RelationField
+ WorkAreas struct {
+ field.RelationField
+ }
+ Workers struct {
+ field.RelationField
+ Workshop struct {
+ field.RelationField
+ }
+ TeamTasks struct {
+ field.RelationField
+ TeamType struct {
+ field.RelationField
+ }
+ TeamLeader struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ TeamMembers struct {
+ field.RelationField
+ }
+ }
+ }
+ Tasks struct {
+ field.RelationField
+ }
+ }
+ PrepTasks struct {
+ field.RelationField
+ }
+ Shifts struct {
+ field.RelationField
+ ProductType struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ }
+ TeamTasks struct {
+ field.RelationField
+ }
+ }{
+ RelationField: field.NewRelation("Tasks.PrepTasks.WorkArea", "models.WorkArea"),
+ Workshop: struct {
+ field.RelationField
+ WorkAreas struct {
+ field.RelationField
+ }
+ Workers struct {
+ field.RelationField
+ Workshop struct {
+ field.RelationField
+ }
+ TeamTasks struct {
+ field.RelationField
+ TeamType struct {
+ field.RelationField
+ }
+ TeamLeader struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ TeamMembers struct {
+ field.RelationField
+ }
+ }
+ }
+ Tasks struct {
+ field.RelationField
+ }
+ }{
+ RelationField: field.NewRelation("Tasks.PrepTasks.WorkArea.Workshop", "models.Workshop"),
+ WorkAreas: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Tasks.PrepTasks.WorkArea.Workshop.WorkAreas", "models.WorkArea"),
+ },
+ Workers: struct {
+ field.RelationField
+ Workshop struct {
+ field.RelationField
+ }
+ TeamTasks struct {
+ field.RelationField
+ TeamType struct {
+ field.RelationField
+ }
+ TeamLeader struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ TeamMembers struct {
+ field.RelationField
+ }
+ }
+ }{
+ RelationField: field.NewRelation("Tasks.PrepTasks.WorkArea.Workshop.Workers", "models.Worker"),
+ Workshop: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Tasks.PrepTasks.WorkArea.Workshop.Workers.Workshop", "models.Workshop"),
+ },
+ TeamTasks: struct {
+ field.RelationField
+ TeamType struct {
+ field.RelationField
+ }
+ TeamLeader struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ TeamMembers struct {
+ field.RelationField
+ }
+ }{
+ RelationField: field.NewRelation("Tasks.PrepTasks.WorkArea.Workshop.Workers.TeamTasks", "models.TeamTask"),
+ TeamType: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Tasks.PrepTasks.WorkArea.Workshop.Workers.TeamTasks.TeamType", "models.TeamType"),
+ },
+ TeamLeader: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Tasks.PrepTasks.WorkArea.Workshop.Workers.TeamTasks.TeamLeader", "models.Worker"),
+ },
+ WorkArea: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Tasks.PrepTasks.WorkArea.Workshop.Workers.TeamTasks.WorkArea", "models.WorkArea"),
+ },
+ TeamMembers: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Tasks.PrepTasks.WorkArea.Workshop.Workers.TeamTasks.TeamMembers", "models.Worker"),
+ },
+ },
+ },
+ Tasks: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Tasks.PrepTasks.WorkArea.Workshop.Tasks", "models.Task"),
+ },
+ },
+ PrepTasks: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Tasks.PrepTasks.WorkArea.PrepTasks", "models.PrepTask"),
+ },
+ Shifts: struct {
+ field.RelationField
+ ProductType struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ }{
+ RelationField: field.NewRelation("Tasks.PrepTasks.WorkArea.Shifts", "models.Shift"),
+ ProductType: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Tasks.PrepTasks.WorkArea.Shifts.ProductType", "models.ProductType"),
+ },
+ WorkArea: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Tasks.PrepTasks.WorkArea.Shifts.WorkArea", "models.WorkArea"),
+ },
+ },
+ TeamTasks: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Tasks.PrepTasks.WorkArea.TeamTasks", "models.TeamTask"),
+ },
+ },
+ },
+ Workshops: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Tasks.Workshops", "models.Workshop"),
+ },
+ }
+
+ _order.ProductType = orderBelongsToProductType{
+ db: db.Session(&gorm.Session{}),
+
+ RelationField: field.NewRelation("ProductType", "models.ProductType"),
+ }
+
+ _order.Customer = orderBelongsToCustomer{
+ db: db.Session(&gorm.Session{}),
+
+ RelationField: field.NewRelation("Customer", "models.Customer"),
+ }
+
+ _order.fillFieldMap()
+
+ return _order
+}
+
+type order struct {
+ orderDo
+
+ ALL field.Asterisk
+ Id field.Uint
+ Status field.String
+ Description field.String
+ ProductTypeId field.Int
+ ProductAmount field.Uint
+ CustomerId field.Uint
+ CreatedAt field.Int64
+ DeadlineDate field.Int64
+ Tasks orderHasManyTasks
+
+ ProductType orderBelongsToProductType
+
+ Customer orderBelongsToCustomer
+
+ fieldMap map[string]field.Expr
+}
+
+func (o order) Table(newTableName string) *order {
+ o.orderDo.UseTable(newTableName)
+ return o.updateTableName(newTableName)
+}
+
+func (o order) As(alias string) *order {
+ o.orderDo.DO = *(o.orderDo.As(alias).(*gen.DO))
+ return o.updateTableName(alias)
+}
+
+func (o *order) updateTableName(table string) *order {
+ o.ALL = field.NewAsterisk(table)
+ o.Id = field.NewUint(table, "id")
+ o.Status = field.NewString(table, "status")
+ o.Description = field.NewString(table, "description")
+ o.ProductTypeId = field.NewInt(table, "product_type_id")
+ o.ProductAmount = field.NewUint(table, "product_amount")
+ o.CustomerId = field.NewUint(table, "customer_id")
+ o.CreatedAt = field.NewInt64(table, "created_at")
+ o.DeadlineDate = field.NewInt64(table, "deadline_date")
+
+ o.fillFieldMap()
+
+ return o
+}
+
+func (o *order) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
+ _f, ok := o.fieldMap[fieldName]
+ if !ok || _f == nil {
+ return nil, false
+ }
+ _oe, ok := _f.(field.OrderExpr)
+ return _oe, ok
+}
+
+func (o *order) fillFieldMap() {
+ o.fieldMap = make(map[string]field.Expr, 11)
+ o.fieldMap["id"] = o.Id
+ o.fieldMap["status"] = o.Status
+ o.fieldMap["description"] = o.Description
+ o.fieldMap["product_type_id"] = o.ProductTypeId
+ o.fieldMap["product_amount"] = o.ProductAmount
+ o.fieldMap["customer_id"] = o.CustomerId
+ o.fieldMap["created_at"] = o.CreatedAt
+ o.fieldMap["deadline_date"] = o.DeadlineDate
+
+}
+
+func (o order) clone(db *gorm.DB) order {
+ o.orderDo.ReplaceConnPool(db.Statement.ConnPool)
+ return o
+}
+
+func (o order) replaceDB(db *gorm.DB) order {
+ o.orderDo.ReplaceDB(db)
+ return o
+}
+
+type orderHasManyTasks struct {
+ db *gorm.DB
+
+ field.RelationField
+
+ ProductType struct {
+ field.RelationField
+ }
+ Order struct {
+ field.RelationField
+ ProductType struct {
+ field.RelationField
+ }
+ Customer struct {
+ field.RelationField
+ Orders struct {
+ field.RelationField
+ }
+ }
+ Tasks struct {
+ field.RelationField
+ }
+ }
+ PrepTasks struct {
+ field.RelationField
+ Task struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ Workshop struct {
+ field.RelationField
+ WorkAreas struct {
+ field.RelationField
+ }
+ Workers struct {
+ field.RelationField
+ Workshop struct {
+ field.RelationField
+ }
+ TeamTasks struct {
+ field.RelationField
+ TeamType struct {
+ field.RelationField
+ }
+ TeamLeader struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ TeamMembers struct {
+ field.RelationField
+ }
+ }
+ }
+ Tasks struct {
+ field.RelationField
+ }
+ }
+ PrepTasks struct {
+ field.RelationField
+ }
+ Shifts struct {
+ field.RelationField
+ ProductType struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ }
+ TeamTasks struct {
+ field.RelationField
+ }
+ }
+ }
+ Workshops struct {
+ field.RelationField
+ }
+}
+
+func (a orderHasManyTasks) Where(conds ...field.Expr) *orderHasManyTasks {
+ if len(conds) == 0 {
+ return &a
+ }
+
+ exprs := make([]clause.Expression, 0, len(conds))
+ for _, cond := range conds {
+ exprs = append(exprs, cond.BeCond().(clause.Expression))
+ }
+ a.db = a.db.Clauses(clause.Where{Exprs: exprs})
+ return &a
+}
+
+func (a orderHasManyTasks) WithContext(ctx context.Context) *orderHasManyTasks {
+ a.db = a.db.WithContext(ctx)
+ return &a
+}
+
+func (a orderHasManyTasks) Session(session *gorm.Session) *orderHasManyTasks {
+ a.db = a.db.Session(session)
+ return &a
+}
+
+func (a orderHasManyTasks) Model(m *models.Order) *orderHasManyTasksTx {
+ return &orderHasManyTasksTx{a.db.Model(m).Association(a.Name())}
+}
+
+type orderHasManyTasksTx struct{ tx *gorm.Association }
+
+func (a orderHasManyTasksTx) Find() (result []*models.Task, err error) {
+ return result, a.tx.Find(&result)
+}
+
+func (a orderHasManyTasksTx) Append(values ...*models.Task) (err error) {
+ targetValues := make([]interface{}, len(values))
+ for i, v := range values {
+ targetValues[i] = v
+ }
+ return a.tx.Append(targetValues...)
+}
+
+func (a orderHasManyTasksTx) Replace(values ...*models.Task) (err error) {
+ targetValues := make([]interface{}, len(values))
+ for i, v := range values {
+ targetValues[i] = v
+ }
+ return a.tx.Replace(targetValues...)
+}
+
+func (a orderHasManyTasksTx) Delete(values ...*models.Task) (err error) {
+ targetValues := make([]interface{}, len(values))
+ for i, v := range values {
+ targetValues[i] = v
+ }
+ return a.tx.Delete(targetValues...)
+}
+
+func (a orderHasManyTasksTx) Clear() error {
+ return a.tx.Clear()
+}
+
+func (a orderHasManyTasksTx) Count() int64 {
+ return a.tx.Count()
+}
+
+type orderBelongsToProductType struct {
+ db *gorm.DB
+
+ field.RelationField
+}
+
+func (a orderBelongsToProductType) Where(conds ...field.Expr) *orderBelongsToProductType {
+ if len(conds) == 0 {
+ return &a
+ }
+
+ exprs := make([]clause.Expression, 0, len(conds))
+ for _, cond := range conds {
+ exprs = append(exprs, cond.BeCond().(clause.Expression))
+ }
+ a.db = a.db.Clauses(clause.Where{Exprs: exprs})
+ return &a
+}
+
+func (a orderBelongsToProductType) WithContext(ctx context.Context) *orderBelongsToProductType {
+ a.db = a.db.WithContext(ctx)
+ return &a
+}
+
+func (a orderBelongsToProductType) Session(session *gorm.Session) *orderBelongsToProductType {
+ a.db = a.db.Session(session)
+ return &a
+}
+
+func (a orderBelongsToProductType) Model(m *models.Order) *orderBelongsToProductTypeTx {
+ return &orderBelongsToProductTypeTx{a.db.Model(m).Association(a.Name())}
+}
+
+type orderBelongsToProductTypeTx struct{ tx *gorm.Association }
+
+func (a orderBelongsToProductTypeTx) Find() (result *models.ProductType, err error) {
+ return result, a.tx.Find(&result)
+}
+
+func (a orderBelongsToProductTypeTx) Append(values ...*models.ProductType) (err error) {
+ targetValues := make([]interface{}, len(values))
+ for i, v := range values {
+ targetValues[i] = v
+ }
+ return a.tx.Append(targetValues...)
+}
+
+func (a orderBelongsToProductTypeTx) Replace(values ...*models.ProductType) (err error) {
+ targetValues := make([]interface{}, len(values))
+ for i, v := range values {
+ targetValues[i] = v
+ }
+ return a.tx.Replace(targetValues...)
+}
+
+func (a orderBelongsToProductTypeTx) Delete(values ...*models.ProductType) (err error) {
+ targetValues := make([]interface{}, len(values))
+ for i, v := range values {
+ targetValues[i] = v
+ }
+ return a.tx.Delete(targetValues...)
+}
+
+func (a orderBelongsToProductTypeTx) Clear() error {
+ return a.tx.Clear()
+}
+
+func (a orderBelongsToProductTypeTx) Count() int64 {
+ return a.tx.Count()
+}
+
+type orderBelongsToCustomer struct {
+ db *gorm.DB
+
+ field.RelationField
+}
+
+func (a orderBelongsToCustomer) Where(conds ...field.Expr) *orderBelongsToCustomer {
+ if len(conds) == 0 {
+ return &a
+ }
+
+ exprs := make([]clause.Expression, 0, len(conds))
+ for _, cond := range conds {
+ exprs = append(exprs, cond.BeCond().(clause.Expression))
+ }
+ a.db = a.db.Clauses(clause.Where{Exprs: exprs})
+ return &a
+}
+
+func (a orderBelongsToCustomer) WithContext(ctx context.Context) *orderBelongsToCustomer {
+ a.db = a.db.WithContext(ctx)
+ return &a
+}
+
+func (a orderBelongsToCustomer) Session(session *gorm.Session) *orderBelongsToCustomer {
+ a.db = a.db.Session(session)
+ return &a
+}
+
+func (a orderBelongsToCustomer) Model(m *models.Order) *orderBelongsToCustomerTx {
+ return &orderBelongsToCustomerTx{a.db.Model(m).Association(a.Name())}
+}
+
+type orderBelongsToCustomerTx struct{ tx *gorm.Association }
+
+func (a orderBelongsToCustomerTx) Find() (result *models.Customer, err error) {
+ return result, a.tx.Find(&result)
+}
+
+func (a orderBelongsToCustomerTx) Append(values ...*models.Customer) (err error) {
+ targetValues := make([]interface{}, len(values))
+ for i, v := range values {
+ targetValues[i] = v
+ }
+ return a.tx.Append(targetValues...)
+}
+
+func (a orderBelongsToCustomerTx) Replace(values ...*models.Customer) (err error) {
+ targetValues := make([]interface{}, len(values))
+ for i, v := range values {
+ targetValues[i] = v
+ }
+ return a.tx.Replace(targetValues...)
+}
+
+func (a orderBelongsToCustomerTx) Delete(values ...*models.Customer) (err error) {
+ targetValues := make([]interface{}, len(values))
+ for i, v := range values {
+ targetValues[i] = v
+ }
+ return a.tx.Delete(targetValues...)
+}
+
+func (a orderBelongsToCustomerTx) Clear() error {
+ return a.tx.Clear()
+}
+
+func (a orderBelongsToCustomerTx) Count() int64 {
+ return a.tx.Count()
+}
+
+type orderDo struct{ gen.DO }
+
+type IOrderDo interface {
+ gen.SubQuery
+ Debug() IOrderDo
+ WithContext(ctx context.Context) IOrderDo
+ WithResult(fc func(tx gen.Dao)) gen.ResultInfo
+ ReplaceDB(db *gorm.DB)
+ ReadDB() IOrderDo
+ WriteDB() IOrderDo
+ As(alias string) gen.Dao
+ Session(config *gorm.Session) IOrderDo
+ Columns(cols ...field.Expr) gen.Columns
+ Clauses(conds ...clause.Expression) IOrderDo
+ Not(conds ...gen.Condition) IOrderDo
+ Or(conds ...gen.Condition) IOrderDo
+ Select(conds ...field.Expr) IOrderDo
+ Where(conds ...gen.Condition) IOrderDo
+ Order(conds ...field.Expr) IOrderDo
+ Distinct(cols ...field.Expr) IOrderDo
+ Omit(cols ...field.Expr) IOrderDo
+ Join(table schema.Tabler, on ...field.Expr) IOrderDo
+ LeftJoin(table schema.Tabler, on ...field.Expr) IOrderDo
+ RightJoin(table schema.Tabler, on ...field.Expr) IOrderDo
+ Group(cols ...field.Expr) IOrderDo
+ Having(conds ...gen.Condition) IOrderDo
+ Limit(limit int) IOrderDo
+ Offset(offset int) IOrderDo
+ Count() (count int64, err error)
+ Scopes(funcs ...func(gen.Dao) gen.Dao) IOrderDo
+ Unscoped() IOrderDo
+ Create(values ...*models.Order) error
+ CreateInBatches(values []*models.Order, batchSize int) error
+ Save(values ...*models.Order) error
+ First() (*models.Order, error)
+ Take() (*models.Order, error)
+ Last() (*models.Order, error)
+ Find() ([]*models.Order, error)
+ FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Order, err error)
+ FindInBatches(result *[]*models.Order, batchSize int, fc func(tx gen.Dao, batch int) error) error
+ Pluck(column field.Expr, dest interface{}) error
+ Delete(...*models.Order) (info gen.ResultInfo, err error)
+ Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
+ UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
+ Updates(value interface{}) (info gen.ResultInfo, err error)
+ UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
+ UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
+ UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
+ UpdateFrom(q gen.SubQuery) gen.Dao
+ Attrs(attrs ...field.AssignExpr) IOrderDo
+ Assign(attrs ...field.AssignExpr) IOrderDo
+ Joins(fields ...field.RelationField) IOrderDo
+ Preload(fields ...field.RelationField) IOrderDo
+ FirstOrInit() (*models.Order, error)
+ FirstOrCreate() (*models.Order, error)
+ FindByPage(offset int, limit int) (result []*models.Order, count int64, err error)
+ ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
+ Scan(result interface{}) (err error)
+ Returning(value interface{}, columns ...string) IOrderDo
+ UnderlyingDB() *gorm.DB
+ schema.Tabler
+}
+
+func (o orderDo) Debug() IOrderDo {
+ return o.withDO(o.DO.Debug())
+}
+
+func (o orderDo) WithContext(ctx context.Context) IOrderDo {
+ return o.withDO(o.DO.WithContext(ctx))
+}
+
+func (o orderDo) ReadDB() IOrderDo {
+ return o.Clauses(dbresolver.Read)
+}
+
+func (o orderDo) WriteDB() IOrderDo {
+ return o.Clauses(dbresolver.Write)
+}
+
+func (o orderDo) Session(config *gorm.Session) IOrderDo {
+ return o.withDO(o.DO.Session(config))
+}
+
+func (o orderDo) Clauses(conds ...clause.Expression) IOrderDo {
+ return o.withDO(o.DO.Clauses(conds...))
+}
+
+func (o orderDo) Returning(value interface{}, columns ...string) IOrderDo {
+ return o.withDO(o.DO.Returning(value, columns...))
+}
+
+func (o orderDo) Not(conds ...gen.Condition) IOrderDo {
+ return o.withDO(o.DO.Not(conds...))
+}
+
+func (o orderDo) Or(conds ...gen.Condition) IOrderDo {
+ return o.withDO(o.DO.Or(conds...))
+}
+
+func (o orderDo) Select(conds ...field.Expr) IOrderDo {
+ return o.withDO(o.DO.Select(conds...))
+}
+
+func (o orderDo) Where(conds ...gen.Condition) IOrderDo {
+ return o.withDO(o.DO.Where(conds...))
+}
+
+func (o orderDo) Order(conds ...field.Expr) IOrderDo {
+ return o.withDO(o.DO.Order(conds...))
+}
+
+func (o orderDo) Distinct(cols ...field.Expr) IOrderDo {
+ return o.withDO(o.DO.Distinct(cols...))
+}
+
+func (o orderDo) Omit(cols ...field.Expr) IOrderDo {
+ return o.withDO(o.DO.Omit(cols...))
+}
+
+func (o orderDo) Join(table schema.Tabler, on ...field.Expr) IOrderDo {
+ return o.withDO(o.DO.Join(table, on...))
+}
+
+func (o orderDo) LeftJoin(table schema.Tabler, on ...field.Expr) IOrderDo {
+ return o.withDO(o.DO.LeftJoin(table, on...))
+}
+
+func (o orderDo) RightJoin(table schema.Tabler, on ...field.Expr) IOrderDo {
+ return o.withDO(o.DO.RightJoin(table, on...))
+}
+
+func (o orderDo) Group(cols ...field.Expr) IOrderDo {
+ return o.withDO(o.DO.Group(cols...))
+}
+
+func (o orderDo) Having(conds ...gen.Condition) IOrderDo {
+ return o.withDO(o.DO.Having(conds...))
+}
+
+func (o orderDo) Limit(limit int) IOrderDo {
+ return o.withDO(o.DO.Limit(limit))
+}
+
+func (o orderDo) Offset(offset int) IOrderDo {
+ return o.withDO(o.DO.Offset(offset))
+}
+
+func (o orderDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IOrderDo {
+ return o.withDO(o.DO.Scopes(funcs...))
+}
+
+func (o orderDo) Unscoped() IOrderDo {
+ return o.withDO(o.DO.Unscoped())
+}
+
+func (o orderDo) Create(values ...*models.Order) error {
+ if len(values) == 0 {
+ return nil
+ }
+ return o.DO.Create(values)
+}
+
+func (o orderDo) CreateInBatches(values []*models.Order, batchSize int) error {
+ return o.DO.CreateInBatches(values, batchSize)
+}
+
+// Save : !!! underlying implementation is different with GORM
+// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
+func (o orderDo) Save(values ...*models.Order) error {
+ if len(values) == 0 {
+ return nil
+ }
+ return o.DO.Save(values)
+}
+
+func (o orderDo) First() (*models.Order, error) {
+ if result, err := o.DO.First(); err != nil {
+ return nil, err
+ } else {
+ return result.(*models.Order), nil
+ }
+}
+
+func (o orderDo) Take() (*models.Order, error) {
+ if result, err := o.DO.Take(); err != nil {
+ return nil, err
+ } else {
+ return result.(*models.Order), nil
+ }
+}
+
+func (o orderDo) Last() (*models.Order, error) {
+ if result, err := o.DO.Last(); err != nil {
+ return nil, err
+ } else {
+ return result.(*models.Order), nil
+ }
+}
+
+func (o orderDo) Find() ([]*models.Order, error) {
+ result, err := o.DO.Find()
+ return result.([]*models.Order), err
+}
+
+func (o orderDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Order, err error) {
+ buf := make([]*models.Order, 0, batchSize)
+ err = o.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
+ defer func() { results = append(results, buf...) }()
+ return fc(tx, batch)
+ })
+ return results, err
+}
+
+func (o orderDo) FindInBatches(result *[]*models.Order, batchSize int, fc func(tx gen.Dao, batch int) error) error {
+ return o.DO.FindInBatches(result, batchSize, fc)
+}
+
+func (o orderDo) Attrs(attrs ...field.AssignExpr) IOrderDo {
+ return o.withDO(o.DO.Attrs(attrs...))
+}
+
+func (o orderDo) Assign(attrs ...field.AssignExpr) IOrderDo {
+ return o.withDO(o.DO.Assign(attrs...))
+}
+
+func (o orderDo) Joins(fields ...field.RelationField) IOrderDo {
+ for _, _f := range fields {
+ o = *o.withDO(o.DO.Joins(_f))
+ }
+ return &o
+}
+
+func (o orderDo) Preload(fields ...field.RelationField) IOrderDo {
+ for _, _f := range fields {
+ o = *o.withDO(o.DO.Preload(_f))
+ }
+ return &o
+}
+
+func (o orderDo) FirstOrInit() (*models.Order, error) {
+ if result, err := o.DO.FirstOrInit(); err != nil {
+ return nil, err
+ } else {
+ return result.(*models.Order), nil
+ }
+}
+
+func (o orderDo) FirstOrCreate() (*models.Order, error) {
+ if result, err := o.DO.FirstOrCreate(); err != nil {
+ return nil, err
+ } else {
+ return result.(*models.Order), nil
+ }
+}
+
+func (o orderDo) FindByPage(offset int, limit int) (result []*models.Order, count int64, err error) {
+ result, err = o.Offset(offset).Limit(limit).Find()
+ if err != nil {
+ return
+ }
+
+ if size := len(result); 0 < limit && 0 < size && size < limit {
+ count = int64(size + offset)
+ return
+ }
+
+ count, err = o.Offset(-1).Limit(-1).Count()
+ return
+}
+
+func (o orderDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
+ count, err = o.Count()
+ if err != nil {
+ return
+ }
+
+ err = o.Offset(offset).Limit(limit).Scan(result)
+ return
+}
+
+func (o orderDo) Scan(result interface{}) (err error) {
+ return o.DO.Scan(result)
+}
+
+func (o orderDo) Delete(models ...*models.Order) (result gen.ResultInfo, err error) {
+ return o.DO.Delete(models)
+}
+
+func (o *orderDo) withDO(do gen.Dao) *orderDo {
+ o.DO = *do.(*gen.DO)
+ return o
+}
diff --git a/internal/dal/orders.gen_test.go b/internal/dal/orders.gen_test.go
new file mode 100644
index 0000000..9b49ac4
--- /dev/null
+++ b/internal/dal/orders.gen_test.go
@@ -0,0 +1,145 @@
+// Code generated by gorm.io/gen. DO NOT EDIT.
+// Code generated by gorm.io/gen. DO NOT EDIT.
+// Code generated by gorm.io/gen. DO NOT EDIT.
+
+package dal
+
+import (
+ "app/internal/models"
+ "context"
+ "fmt"
+ "testing"
+
+ "gorm.io/gen"
+ "gorm.io/gen/field"
+ "gorm.io/gorm/clause"
+)
+
+func init() {
+ InitializeDB()
+ err := _gen_test_db.AutoMigrate(&models.Order{})
+ if err != nil {
+ fmt.Printf("Error: AutoMigrate(&models.Order{}) fail: %s", err)
+ }
+}
+
+func Test_orderQuery(t *testing.T) {
+ order := newOrder(_gen_test_db)
+ order = *order.As(order.TableName())
+ _do := order.WithContext(context.Background()).Debug()
+
+ primaryKey := field.NewString(order.TableName(), clause.PrimaryKey)
+ _, err := _do.Unscoped().Where(primaryKey.IsNotNull()).Delete()
+ if err != nil {
+ t.Error("clean table fail:", err)
+ return
+ }
+
+ _, ok := order.GetFieldByName("")
+ if ok {
+ t.Error("GetFieldByName(\"\") from order success")
+ }
+
+ err = _do.Create(&models.Order{})
+ if err != nil {
+ t.Error("create item in table fail:", err)
+ }
+
+ err = _do.Save(&models.Order{})
+ if err != nil {
+ t.Error("create item in table fail:", err)
+ }
+
+ err = _do.CreateInBatches([]*models.Order{{}, {}}, 10)
+ if err != nil {
+ t.Error("create item in table fail:", err)
+ }
+
+ _, err = _do.Select(order.ALL).Take()
+ if err != nil {
+ t.Error("Take() on table fail:", err)
+ }
+
+ _, err = _do.First()
+ if err != nil {
+ t.Error("First() on table fail:", err)
+ }
+
+ _, err = _do.Last()
+ if err != nil {
+ t.Error("First() on table fail:", err)
+ }
+
+ _, err = _do.Where(primaryKey.IsNotNull()).FindInBatch(10, func(tx gen.Dao, batch int) error { return nil })
+ if err != nil {
+ t.Error("FindInBatch() on table fail:", err)
+ }
+
+ err = _do.Where(primaryKey.IsNotNull()).FindInBatches(&[]*models.Order{}, 10, func(tx gen.Dao, batch int) error { return nil })
+ if err != nil {
+ t.Error("FindInBatches() on table fail:", err)
+ }
+
+ _, err = _do.Select(order.ALL).Where(primaryKey.IsNotNull()).Order(primaryKey.Desc()).Find()
+ if err != nil {
+ t.Error("Find() on table fail:", err)
+ }
+
+ _, err = _do.Distinct(primaryKey).Take()
+ if err != nil {
+ t.Error("select Distinct() on table fail:", err)
+ }
+
+ _, err = _do.Select(order.ALL).Omit(primaryKey).Take()
+ if err != nil {
+ t.Error("Omit() on table fail:", err)
+ }
+
+ _, err = _do.Group(primaryKey).Find()
+ if err != nil {
+ t.Error("Group() on table fail:", err)
+ }
+
+ _, err = _do.Scopes(func(dao gen.Dao) gen.Dao { return dao.Where(primaryKey.IsNotNull()) }).Find()
+ if err != nil {
+ t.Error("Scopes() on table fail:", err)
+ }
+
+ _, _, err = _do.FindByPage(0, 1)
+ if err != nil {
+ t.Error("FindByPage() on table fail:", err)
+ }
+
+ _, err = _do.ScanByPage(&models.Order{}, 0, 1)
+ if err != nil {
+ t.Error("ScanByPage() on table fail:", err)
+ }
+
+ _, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrInit()
+ if err != nil {
+ t.Error("FirstOrInit() on table fail:", err)
+ }
+
+ _, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrCreate()
+ if err != nil {
+ t.Error("FirstOrCreate() on table fail:", err)
+ }
+
+ var _a _another
+ var _aPK = field.NewString(_a.TableName(), "id")
+
+ err = _do.Join(&_a, primaryKey.EqCol(_aPK)).Scan(map[string]interface{}{})
+ if err != nil {
+ t.Error("Join() on table fail:", err)
+ }
+
+ err = _do.LeftJoin(&_a, primaryKey.EqCol(_aPK)).Scan(map[string]interface{}{})
+ if err != nil {
+ t.Error("LeftJoin() on table fail:", err)
+ }
+
+ _, err = _do.Not().Or().Clauses().Take()
+ if err != nil {
+ t.Error("Not/Or/Clauses on table fail:", err)
+ }
+}
diff --git a/internal/dal/post_types.gen.go b/internal/dal/post_types.gen.go
deleted file mode 100644
index 65f71b4..0000000
--- a/internal/dal/post_types.gen.go
+++ /dev/null
@@ -1,383 +0,0 @@
-// Code generated by gorm.io/gen. DO NOT EDIT.
-// Code generated by gorm.io/gen. DO NOT EDIT.
-// Code generated by gorm.io/gen. DO NOT EDIT.
-
-package dal
-
-import (
- "app/internal/models"
- "context"
-
- "gorm.io/gorm"
- "gorm.io/gorm/clause"
- "gorm.io/gorm/schema"
-
- "gorm.io/gen"
- "gorm.io/gen/field"
-
- "gorm.io/plugin/dbresolver"
-)
-
-func newPostType(db *gorm.DB, opts ...gen.DOOption) postType {
- _postType := postType{}
-
- _postType.postTypeDo.UseDB(db, opts...)
- _postType.postTypeDo.UseModel(&models.PostType{})
-
- tableName := _postType.postTypeDo.TableName()
- _postType.ALL = field.NewAsterisk(tableName)
- _postType.Id = field.NewUint(tableName, "id")
- _postType.Name = field.NewString(tableName, "name")
-
- _postType.fillFieldMap()
-
- return _postType
-}
-
-type postType struct {
- postTypeDo
-
- ALL field.Asterisk
- Id field.Uint
- Name field.String
-
- fieldMap map[string]field.Expr
-}
-
-func (p postType) Table(newTableName string) *postType {
- p.postTypeDo.UseTable(newTableName)
- return p.updateTableName(newTableName)
-}
-
-func (p postType) As(alias string) *postType {
- p.postTypeDo.DO = *(p.postTypeDo.As(alias).(*gen.DO))
- return p.updateTableName(alias)
-}
-
-func (p *postType) updateTableName(table string) *postType {
- p.ALL = field.NewAsterisk(table)
- p.Id = field.NewUint(table, "id")
- p.Name = field.NewString(table, "name")
-
- p.fillFieldMap()
-
- return p
-}
-
-func (p *postType) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
- _f, ok := p.fieldMap[fieldName]
- if !ok || _f == nil {
- return nil, false
- }
- _oe, ok := _f.(field.OrderExpr)
- return _oe, ok
-}
-
-func (p *postType) fillFieldMap() {
- p.fieldMap = make(map[string]field.Expr, 2)
- p.fieldMap["id"] = p.Id
- p.fieldMap["name"] = p.Name
-}
-
-func (p postType) clone(db *gorm.DB) postType {
- p.postTypeDo.ReplaceConnPool(db.Statement.ConnPool)
- return p
-}
-
-func (p postType) replaceDB(db *gorm.DB) postType {
- p.postTypeDo.ReplaceDB(db)
- return p
-}
-
-type postTypeDo struct{ gen.DO }
-
-type IPostTypeDo interface {
- gen.SubQuery
- Debug() IPostTypeDo
- WithContext(ctx context.Context) IPostTypeDo
- WithResult(fc func(tx gen.Dao)) gen.ResultInfo
- ReplaceDB(db *gorm.DB)
- ReadDB() IPostTypeDo
- WriteDB() IPostTypeDo
- As(alias string) gen.Dao
- Session(config *gorm.Session) IPostTypeDo
- Columns(cols ...field.Expr) gen.Columns
- Clauses(conds ...clause.Expression) IPostTypeDo
- Not(conds ...gen.Condition) IPostTypeDo
- Or(conds ...gen.Condition) IPostTypeDo
- Select(conds ...field.Expr) IPostTypeDo
- Where(conds ...gen.Condition) IPostTypeDo
- Order(conds ...field.Expr) IPostTypeDo
- Distinct(cols ...field.Expr) IPostTypeDo
- Omit(cols ...field.Expr) IPostTypeDo
- Join(table schema.Tabler, on ...field.Expr) IPostTypeDo
- LeftJoin(table schema.Tabler, on ...field.Expr) IPostTypeDo
- RightJoin(table schema.Tabler, on ...field.Expr) IPostTypeDo
- Group(cols ...field.Expr) IPostTypeDo
- Having(conds ...gen.Condition) IPostTypeDo
- Limit(limit int) IPostTypeDo
- Offset(offset int) IPostTypeDo
- Count() (count int64, err error)
- Scopes(funcs ...func(gen.Dao) gen.Dao) IPostTypeDo
- Unscoped() IPostTypeDo
- Create(values ...*models.PostType) error
- CreateInBatches(values []*models.PostType, batchSize int) error
- Save(values ...*models.PostType) error
- First() (*models.PostType, error)
- Take() (*models.PostType, error)
- Last() (*models.PostType, error)
- Find() ([]*models.PostType, error)
- FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.PostType, err error)
- FindInBatches(result *[]*models.PostType, batchSize int, fc func(tx gen.Dao, batch int) error) error
- Pluck(column field.Expr, dest interface{}) error
- Delete(...*models.PostType) (info gen.ResultInfo, err error)
- Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
- UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
- Updates(value interface{}) (info gen.ResultInfo, err error)
- UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
- UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
- UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
- UpdateFrom(q gen.SubQuery) gen.Dao
- Attrs(attrs ...field.AssignExpr) IPostTypeDo
- Assign(attrs ...field.AssignExpr) IPostTypeDo
- Joins(fields ...field.RelationField) IPostTypeDo
- Preload(fields ...field.RelationField) IPostTypeDo
- FirstOrInit() (*models.PostType, error)
- FirstOrCreate() (*models.PostType, error)
- FindByPage(offset int, limit int) (result []*models.PostType, count int64, err error)
- ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
- Scan(result interface{}) (err error)
- Returning(value interface{}, columns ...string) IPostTypeDo
- UnderlyingDB() *gorm.DB
- schema.Tabler
-}
-
-func (p postTypeDo) Debug() IPostTypeDo {
- return p.withDO(p.DO.Debug())
-}
-
-func (p postTypeDo) WithContext(ctx context.Context) IPostTypeDo {
- return p.withDO(p.DO.WithContext(ctx))
-}
-
-func (p postTypeDo) ReadDB() IPostTypeDo {
- return p.Clauses(dbresolver.Read)
-}
-
-func (p postTypeDo) WriteDB() IPostTypeDo {
- return p.Clauses(dbresolver.Write)
-}
-
-func (p postTypeDo) Session(config *gorm.Session) IPostTypeDo {
- return p.withDO(p.DO.Session(config))
-}
-
-func (p postTypeDo) Clauses(conds ...clause.Expression) IPostTypeDo {
- return p.withDO(p.DO.Clauses(conds...))
-}
-
-func (p postTypeDo) Returning(value interface{}, columns ...string) IPostTypeDo {
- return p.withDO(p.DO.Returning(value, columns...))
-}
-
-func (p postTypeDo) Not(conds ...gen.Condition) IPostTypeDo {
- return p.withDO(p.DO.Not(conds...))
-}
-
-func (p postTypeDo) Or(conds ...gen.Condition) IPostTypeDo {
- return p.withDO(p.DO.Or(conds...))
-}
-
-func (p postTypeDo) Select(conds ...field.Expr) IPostTypeDo {
- return p.withDO(p.DO.Select(conds...))
-}
-
-func (p postTypeDo) Where(conds ...gen.Condition) IPostTypeDo {
- return p.withDO(p.DO.Where(conds...))
-}
-
-func (p postTypeDo) Order(conds ...field.Expr) IPostTypeDo {
- return p.withDO(p.DO.Order(conds...))
-}
-
-func (p postTypeDo) Distinct(cols ...field.Expr) IPostTypeDo {
- return p.withDO(p.DO.Distinct(cols...))
-}
-
-func (p postTypeDo) Omit(cols ...field.Expr) IPostTypeDo {
- return p.withDO(p.DO.Omit(cols...))
-}
-
-func (p postTypeDo) Join(table schema.Tabler, on ...field.Expr) IPostTypeDo {
- return p.withDO(p.DO.Join(table, on...))
-}
-
-func (p postTypeDo) LeftJoin(table schema.Tabler, on ...field.Expr) IPostTypeDo {
- return p.withDO(p.DO.LeftJoin(table, on...))
-}
-
-func (p postTypeDo) RightJoin(table schema.Tabler, on ...field.Expr) IPostTypeDo {
- return p.withDO(p.DO.RightJoin(table, on...))
-}
-
-func (p postTypeDo) Group(cols ...field.Expr) IPostTypeDo {
- return p.withDO(p.DO.Group(cols...))
-}
-
-func (p postTypeDo) Having(conds ...gen.Condition) IPostTypeDo {
- return p.withDO(p.DO.Having(conds...))
-}
-
-func (p postTypeDo) Limit(limit int) IPostTypeDo {
- return p.withDO(p.DO.Limit(limit))
-}
-
-func (p postTypeDo) Offset(offset int) IPostTypeDo {
- return p.withDO(p.DO.Offset(offset))
-}
-
-func (p postTypeDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IPostTypeDo {
- return p.withDO(p.DO.Scopes(funcs...))
-}
-
-func (p postTypeDo) Unscoped() IPostTypeDo {
- return p.withDO(p.DO.Unscoped())
-}
-
-func (p postTypeDo) Create(values ...*models.PostType) error {
- if len(values) == 0 {
- return nil
- }
- return p.DO.Create(values)
-}
-
-func (p postTypeDo) CreateInBatches(values []*models.PostType, batchSize int) error {
- return p.DO.CreateInBatches(values, batchSize)
-}
-
-// Save : !!! underlying implementation is different with GORM
-// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
-func (p postTypeDo) Save(values ...*models.PostType) error {
- if len(values) == 0 {
- return nil
- }
- return p.DO.Save(values)
-}
-
-func (p postTypeDo) First() (*models.PostType, error) {
- if result, err := p.DO.First(); err != nil {
- return nil, err
- } else {
- return result.(*models.PostType), nil
- }
-}
-
-func (p postTypeDo) Take() (*models.PostType, error) {
- if result, err := p.DO.Take(); err != nil {
- return nil, err
- } else {
- return result.(*models.PostType), nil
- }
-}
-
-func (p postTypeDo) Last() (*models.PostType, error) {
- if result, err := p.DO.Last(); err != nil {
- return nil, err
- } else {
- return result.(*models.PostType), nil
- }
-}
-
-func (p postTypeDo) Find() ([]*models.PostType, error) {
- result, err := p.DO.Find()
- return result.([]*models.PostType), err
-}
-
-func (p postTypeDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.PostType, err error) {
- buf := make([]*models.PostType, 0, batchSize)
- err = p.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
- defer func() { results = append(results, buf...) }()
- return fc(tx, batch)
- })
- return results, err
-}
-
-func (p postTypeDo) FindInBatches(result *[]*models.PostType, batchSize int, fc func(tx gen.Dao, batch int) error) error {
- return p.DO.FindInBatches(result, batchSize, fc)
-}
-
-func (p postTypeDo) Attrs(attrs ...field.AssignExpr) IPostTypeDo {
- return p.withDO(p.DO.Attrs(attrs...))
-}
-
-func (p postTypeDo) Assign(attrs ...field.AssignExpr) IPostTypeDo {
- return p.withDO(p.DO.Assign(attrs...))
-}
-
-func (p postTypeDo) Joins(fields ...field.RelationField) IPostTypeDo {
- for _, _f := range fields {
- p = *p.withDO(p.DO.Joins(_f))
- }
- return &p
-}
-
-func (p postTypeDo) Preload(fields ...field.RelationField) IPostTypeDo {
- for _, _f := range fields {
- p = *p.withDO(p.DO.Preload(_f))
- }
- return &p
-}
-
-func (p postTypeDo) FirstOrInit() (*models.PostType, error) {
- if result, err := p.DO.FirstOrInit(); err != nil {
- return nil, err
- } else {
- return result.(*models.PostType), nil
- }
-}
-
-func (p postTypeDo) FirstOrCreate() (*models.PostType, error) {
- if result, err := p.DO.FirstOrCreate(); err != nil {
- return nil, err
- } else {
- return result.(*models.PostType), nil
- }
-}
-
-func (p postTypeDo) FindByPage(offset int, limit int) (result []*models.PostType, count int64, err error) {
- result, err = p.Offset(offset).Limit(limit).Find()
- if err != nil {
- return
- }
-
- if size := len(result); 0 < limit && 0 < size && size < limit {
- count = int64(size + offset)
- return
- }
-
- count, err = p.Offset(-1).Limit(-1).Count()
- return
-}
-
-func (p postTypeDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
- count, err = p.Count()
- if err != nil {
- return
- }
-
- err = p.Offset(offset).Limit(limit).Scan(result)
- return
-}
-
-func (p postTypeDo) Scan(result interface{}) (err error) {
- return p.DO.Scan(result)
-}
-
-func (p postTypeDo) Delete(models ...*models.PostType) (result gen.ResultInfo, err error) {
- return p.DO.Delete(models)
-}
-
-func (p *postTypeDo) withDO(do gen.Dao) *postTypeDo {
- p.DO = *do.(*gen.DO)
- return p
-}
diff --git a/internal/dal/post_types.gen_test.go b/internal/dal/post_types.gen_test.go
deleted file mode 100644
index df0dd22..0000000
--- a/internal/dal/post_types.gen_test.go
+++ /dev/null
@@ -1,145 +0,0 @@
-// Code generated by gorm.io/gen. DO NOT EDIT.
-// Code generated by gorm.io/gen. DO NOT EDIT.
-// Code generated by gorm.io/gen. DO NOT EDIT.
-
-package dal
-
-import (
- "app/internal/models"
- "context"
- "fmt"
- "testing"
-
- "gorm.io/gen"
- "gorm.io/gen/field"
- "gorm.io/gorm/clause"
-)
-
-func init() {
- InitializeDB()
- err := _gen_test_db.AutoMigrate(&models.PostType{})
- if err != nil {
- fmt.Printf("Error: AutoMigrate(&models.PostType{}) fail: %s", err)
- }
-}
-
-func Test_postTypeQuery(t *testing.T) {
- postType := newPostType(_gen_test_db)
- postType = *postType.As(postType.TableName())
- _do := postType.WithContext(context.Background()).Debug()
-
- primaryKey := field.NewString(postType.TableName(), clause.PrimaryKey)
- _, err := _do.Unscoped().Where(primaryKey.IsNotNull()).Delete()
- if err != nil {
- t.Error("clean table fail:", err)
- return
- }
-
- _, ok := postType.GetFieldByName("")
- if ok {
- t.Error("GetFieldByName(\"\") from postType success")
- }
-
- err = _do.Create(&models.PostType{})
- if err != nil {
- t.Error("create item in table fail:", err)
- }
-
- err = _do.Save(&models.PostType{})
- if err != nil {
- t.Error("create item in table fail:", err)
- }
-
- err = _do.CreateInBatches([]*models.PostType{{}, {}}, 10)
- if err != nil {
- t.Error("create item in table fail:", err)
- }
-
- _, err = _do.Select(postType.ALL).Take()
- if err != nil {
- t.Error("Take() on table fail:", err)
- }
-
- _, err = _do.First()
- if err != nil {
- t.Error("First() on table fail:", err)
- }
-
- _, err = _do.Last()
- if err != nil {
- t.Error("First() on table fail:", err)
- }
-
- _, err = _do.Where(primaryKey.IsNotNull()).FindInBatch(10, func(tx gen.Dao, batch int) error { return nil })
- if err != nil {
- t.Error("FindInBatch() on table fail:", err)
- }
-
- err = _do.Where(primaryKey.IsNotNull()).FindInBatches(&[]*models.PostType{}, 10, func(tx gen.Dao, batch int) error { return nil })
- if err != nil {
- t.Error("FindInBatches() on table fail:", err)
- }
-
- _, err = _do.Select(postType.ALL).Where(primaryKey.IsNotNull()).Order(primaryKey.Desc()).Find()
- if err != nil {
- t.Error("Find() on table fail:", err)
- }
-
- _, err = _do.Distinct(primaryKey).Take()
- if err != nil {
- t.Error("select Distinct() on table fail:", err)
- }
-
- _, err = _do.Select(postType.ALL).Omit(primaryKey).Take()
- if err != nil {
- t.Error("Omit() on table fail:", err)
- }
-
- _, err = _do.Group(primaryKey).Find()
- if err != nil {
- t.Error("Group() on table fail:", err)
- }
-
- _, err = _do.Scopes(func(dao gen.Dao) gen.Dao { return dao.Where(primaryKey.IsNotNull()) }).Find()
- if err != nil {
- t.Error("Scopes() on table fail:", err)
- }
-
- _, _, err = _do.FindByPage(0, 1)
- if err != nil {
- t.Error("FindByPage() on table fail:", err)
- }
-
- _, err = _do.ScanByPage(&models.PostType{}, 0, 1)
- if err != nil {
- t.Error("ScanByPage() on table fail:", err)
- }
-
- _, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrInit()
- if err != nil {
- t.Error("FirstOrInit() on table fail:", err)
- }
-
- _, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrCreate()
- if err != nil {
- t.Error("FirstOrCreate() on table fail:", err)
- }
-
- var _a _another
- var _aPK = field.NewString(_a.TableName(), "id")
-
- err = _do.Join(&_a, primaryKey.EqCol(_aPK)).Scan(map[string]interface{}{})
- if err != nil {
- t.Error("Join() on table fail:", err)
- }
-
- err = _do.LeftJoin(&_a, primaryKey.EqCol(_aPK)).Scan(map[string]interface{}{})
- if err != nil {
- t.Error("LeftJoin() on table fail:", err)
- }
-
- _, err = _do.Not().Or().Clauses().Take()
- if err != nil {
- t.Error("Not/Or/Clauses on table fail:", err)
- }
-}
diff --git a/internal/dal/posts.gen.go b/internal/dal/posts.gen.go
deleted file mode 100644
index cd6295d..0000000
--- a/internal/dal/posts.gen.go
+++ /dev/null
@@ -1,713 +0,0 @@
-// Code generated by gorm.io/gen. DO NOT EDIT.
-// Code generated by gorm.io/gen. DO NOT EDIT.
-// Code generated by gorm.io/gen. DO NOT EDIT.
-
-package dal
-
-import (
- "app/internal/models"
- "context"
-
- "gorm.io/gorm"
- "gorm.io/gorm/clause"
- "gorm.io/gorm/schema"
-
- "gorm.io/gen"
- "gorm.io/gen/field"
-
- "gorm.io/plugin/dbresolver"
-)
-
-func newPost(db *gorm.DB, opts ...gen.DOOption) post {
- _post := post{}
-
- _post.postDo.UseDB(db, opts...)
- _post.postDo.UseModel(&models.Post{})
-
- tableName := _post.postDo.TableName()
- _post.ALL = field.NewAsterisk(tableName)
- _post.Id = field.NewUint(tableName, "id")
- _post.Text = field.NewString(tableName, "text")
- _post.Deadline = field.NewInt64(tableName, "deadline")
- _post.CreatedAt = field.NewInt64(tableName, "created_at")
- _post.AuthorId = field.NewUint(tableName, "author_id")
- _post.PostTypeId = field.NewUint(tableName, "post_type_id")
- _post.Author = postBelongsToAuthor{
- db: db.Session(&gorm.Session{}),
-
- RelationField: field.NewRelation("Author", "models.Author"),
- Posts: struct {
- field.RelationField
- Author struct {
- field.RelationField
- }
- PostType struct {
- field.RelationField
- }
- Comments struct {
- field.RelationField
- Author struct {
- field.RelationField
- }
- Posts struct {
- field.RelationField
- }
- }
- }{
- RelationField: field.NewRelation("Author.Posts", "models.Post"),
- Author: struct {
- field.RelationField
- }{
- RelationField: field.NewRelation("Author.Posts.Author", "models.Author"),
- },
- PostType: struct {
- field.RelationField
- }{
- RelationField: field.NewRelation("Author.Posts.PostType", "models.PostType"),
- },
- Comments: struct {
- field.RelationField
- Author struct {
- field.RelationField
- }
- Posts struct {
- field.RelationField
- }
- }{
- RelationField: field.NewRelation("Author.Posts.Comments", "models.Comment"),
- Author: struct {
- field.RelationField
- }{
- RelationField: field.NewRelation("Author.Posts.Comments.Author", "models.Author"),
- },
- Posts: struct {
- field.RelationField
- }{
- RelationField: field.NewRelation("Author.Posts.Comments.Posts", "models.Post"),
- },
- },
- },
- Comments: struct {
- field.RelationField
- }{
- RelationField: field.NewRelation("Author.Comments", "models.Comment"),
- },
- }
-
- _post.PostType = postBelongsToPostType{
- db: db.Session(&gorm.Session{}),
-
- RelationField: field.NewRelation("PostType", "models.PostType"),
- }
-
- _post.Comments = postManyToManyComments{
- db: db.Session(&gorm.Session{}),
-
- RelationField: field.NewRelation("Comments", "models.Comment"),
- }
-
- _post.fillFieldMap()
-
- return _post
-}
-
-type post struct {
- postDo
-
- ALL field.Asterisk
- Id field.Uint
- Text field.String
- Deadline field.Int64
- CreatedAt field.Int64
- AuthorId field.Uint
- PostTypeId field.Uint
- Author postBelongsToAuthor
-
- PostType postBelongsToPostType
-
- Comments postManyToManyComments
-
- fieldMap map[string]field.Expr
-}
-
-func (p post) Table(newTableName string) *post {
- p.postDo.UseTable(newTableName)
- return p.updateTableName(newTableName)
-}
-
-func (p post) As(alias string) *post {
- p.postDo.DO = *(p.postDo.As(alias).(*gen.DO))
- return p.updateTableName(alias)
-}
-
-func (p *post) updateTableName(table string) *post {
- p.ALL = field.NewAsterisk(table)
- p.Id = field.NewUint(table, "id")
- p.Text = field.NewString(table, "text")
- p.Deadline = field.NewInt64(table, "deadline")
- p.CreatedAt = field.NewInt64(table, "created_at")
- p.AuthorId = field.NewUint(table, "author_id")
- p.PostTypeId = field.NewUint(table, "post_type_id")
-
- p.fillFieldMap()
-
- return p
-}
-
-func (p *post) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
- _f, ok := p.fieldMap[fieldName]
- if !ok || _f == nil {
- return nil, false
- }
- _oe, ok := _f.(field.OrderExpr)
- return _oe, ok
-}
-
-func (p *post) fillFieldMap() {
- p.fieldMap = make(map[string]field.Expr, 9)
- p.fieldMap["id"] = p.Id
- p.fieldMap["text"] = p.Text
- p.fieldMap["deadline"] = p.Deadline
- p.fieldMap["created_at"] = p.CreatedAt
- p.fieldMap["author_id"] = p.AuthorId
- p.fieldMap["post_type_id"] = p.PostTypeId
-
-}
-
-func (p post) clone(db *gorm.DB) post {
- p.postDo.ReplaceConnPool(db.Statement.ConnPool)
- return p
-}
-
-func (p post) replaceDB(db *gorm.DB) post {
- p.postDo.ReplaceDB(db)
- return p
-}
-
-type postBelongsToAuthor struct {
- db *gorm.DB
-
- field.RelationField
-
- Posts struct {
- field.RelationField
- Author struct {
- field.RelationField
- }
- PostType struct {
- field.RelationField
- }
- Comments struct {
- field.RelationField
- Author struct {
- field.RelationField
- }
- Posts struct {
- field.RelationField
- }
- }
- }
- Comments struct {
- field.RelationField
- }
-}
-
-func (a postBelongsToAuthor) Where(conds ...field.Expr) *postBelongsToAuthor {
- if len(conds) == 0 {
- return &a
- }
-
- exprs := make([]clause.Expression, 0, len(conds))
- for _, cond := range conds {
- exprs = append(exprs, cond.BeCond().(clause.Expression))
- }
- a.db = a.db.Clauses(clause.Where{Exprs: exprs})
- return &a
-}
-
-func (a postBelongsToAuthor) WithContext(ctx context.Context) *postBelongsToAuthor {
- a.db = a.db.WithContext(ctx)
- return &a
-}
-
-func (a postBelongsToAuthor) Session(session *gorm.Session) *postBelongsToAuthor {
- a.db = a.db.Session(session)
- return &a
-}
-
-func (a postBelongsToAuthor) Model(m *models.Post) *postBelongsToAuthorTx {
- return &postBelongsToAuthorTx{a.db.Model(m).Association(a.Name())}
-}
-
-type postBelongsToAuthorTx struct{ tx *gorm.Association }
-
-func (a postBelongsToAuthorTx) Find() (result *models.Author, err error) {
- return result, a.tx.Find(&result)
-}
-
-func (a postBelongsToAuthorTx) Append(values ...*models.Author) (err error) {
- targetValues := make([]interface{}, len(values))
- for i, v := range values {
- targetValues[i] = v
- }
- return a.tx.Append(targetValues...)
-}
-
-func (a postBelongsToAuthorTx) Replace(values ...*models.Author) (err error) {
- targetValues := make([]interface{}, len(values))
- for i, v := range values {
- targetValues[i] = v
- }
- return a.tx.Replace(targetValues...)
-}
-
-func (a postBelongsToAuthorTx) Delete(values ...*models.Author) (err error) {
- targetValues := make([]interface{}, len(values))
- for i, v := range values {
- targetValues[i] = v
- }
- return a.tx.Delete(targetValues...)
-}
-
-func (a postBelongsToAuthorTx) Clear() error {
- return a.tx.Clear()
-}
-
-func (a postBelongsToAuthorTx) Count() int64 {
- return a.tx.Count()
-}
-
-type postBelongsToPostType struct {
- db *gorm.DB
-
- field.RelationField
-}
-
-func (a postBelongsToPostType) Where(conds ...field.Expr) *postBelongsToPostType {
- if len(conds) == 0 {
- return &a
- }
-
- exprs := make([]clause.Expression, 0, len(conds))
- for _, cond := range conds {
- exprs = append(exprs, cond.BeCond().(clause.Expression))
- }
- a.db = a.db.Clauses(clause.Where{Exprs: exprs})
- return &a
-}
-
-func (a postBelongsToPostType) WithContext(ctx context.Context) *postBelongsToPostType {
- a.db = a.db.WithContext(ctx)
- return &a
-}
-
-func (a postBelongsToPostType) Session(session *gorm.Session) *postBelongsToPostType {
- a.db = a.db.Session(session)
- return &a
-}
-
-func (a postBelongsToPostType) Model(m *models.Post) *postBelongsToPostTypeTx {
- return &postBelongsToPostTypeTx{a.db.Model(m).Association(a.Name())}
-}
-
-type postBelongsToPostTypeTx struct{ tx *gorm.Association }
-
-func (a postBelongsToPostTypeTx) Find() (result *models.PostType, err error) {
- return result, a.tx.Find(&result)
-}
-
-func (a postBelongsToPostTypeTx) Append(values ...*models.PostType) (err error) {
- targetValues := make([]interface{}, len(values))
- for i, v := range values {
- targetValues[i] = v
- }
- return a.tx.Append(targetValues...)
-}
-
-func (a postBelongsToPostTypeTx) Replace(values ...*models.PostType) (err error) {
- targetValues := make([]interface{}, len(values))
- for i, v := range values {
- targetValues[i] = v
- }
- return a.tx.Replace(targetValues...)
-}
-
-func (a postBelongsToPostTypeTx) Delete(values ...*models.PostType) (err error) {
- targetValues := make([]interface{}, len(values))
- for i, v := range values {
- targetValues[i] = v
- }
- return a.tx.Delete(targetValues...)
-}
-
-func (a postBelongsToPostTypeTx) Clear() error {
- return a.tx.Clear()
-}
-
-func (a postBelongsToPostTypeTx) Count() int64 {
- return a.tx.Count()
-}
-
-type postManyToManyComments struct {
- db *gorm.DB
-
- field.RelationField
-}
-
-func (a postManyToManyComments) Where(conds ...field.Expr) *postManyToManyComments {
- if len(conds) == 0 {
- return &a
- }
-
- exprs := make([]clause.Expression, 0, len(conds))
- for _, cond := range conds {
- exprs = append(exprs, cond.BeCond().(clause.Expression))
- }
- a.db = a.db.Clauses(clause.Where{Exprs: exprs})
- return &a
-}
-
-func (a postManyToManyComments) WithContext(ctx context.Context) *postManyToManyComments {
- a.db = a.db.WithContext(ctx)
- return &a
-}
-
-func (a postManyToManyComments) Session(session *gorm.Session) *postManyToManyComments {
- a.db = a.db.Session(session)
- return &a
-}
-
-func (a postManyToManyComments) Model(m *models.Post) *postManyToManyCommentsTx {
- return &postManyToManyCommentsTx{a.db.Model(m).Association(a.Name())}
-}
-
-type postManyToManyCommentsTx struct{ tx *gorm.Association }
-
-func (a postManyToManyCommentsTx) Find() (result []*models.Comment, err error) {
- return result, a.tx.Find(&result)
-}
-
-func (a postManyToManyCommentsTx) Append(values ...*models.Comment) (err error) {
- targetValues := make([]interface{}, len(values))
- for i, v := range values {
- targetValues[i] = v
- }
- return a.tx.Append(targetValues...)
-}
-
-func (a postManyToManyCommentsTx) Replace(values ...*models.Comment) (err error) {
- targetValues := make([]interface{}, len(values))
- for i, v := range values {
- targetValues[i] = v
- }
- return a.tx.Replace(targetValues...)
-}
-
-func (a postManyToManyCommentsTx) Delete(values ...*models.Comment) (err error) {
- targetValues := make([]interface{}, len(values))
- for i, v := range values {
- targetValues[i] = v
- }
- return a.tx.Delete(targetValues...)
-}
-
-func (a postManyToManyCommentsTx) Clear() error {
- return a.tx.Clear()
-}
-
-func (a postManyToManyCommentsTx) Count() int64 {
- return a.tx.Count()
-}
-
-type postDo struct{ gen.DO }
-
-type IPostDo interface {
- gen.SubQuery
- Debug() IPostDo
- WithContext(ctx context.Context) IPostDo
- WithResult(fc func(tx gen.Dao)) gen.ResultInfo
- ReplaceDB(db *gorm.DB)
- ReadDB() IPostDo
- WriteDB() IPostDo
- As(alias string) gen.Dao
- Session(config *gorm.Session) IPostDo
- Columns(cols ...field.Expr) gen.Columns
- Clauses(conds ...clause.Expression) IPostDo
- Not(conds ...gen.Condition) IPostDo
- Or(conds ...gen.Condition) IPostDo
- Select(conds ...field.Expr) IPostDo
- Where(conds ...gen.Condition) IPostDo
- Order(conds ...field.Expr) IPostDo
- Distinct(cols ...field.Expr) IPostDo
- Omit(cols ...field.Expr) IPostDo
- Join(table schema.Tabler, on ...field.Expr) IPostDo
- LeftJoin(table schema.Tabler, on ...field.Expr) IPostDo
- RightJoin(table schema.Tabler, on ...field.Expr) IPostDo
- Group(cols ...field.Expr) IPostDo
- Having(conds ...gen.Condition) IPostDo
- Limit(limit int) IPostDo
- Offset(offset int) IPostDo
- Count() (count int64, err error)
- Scopes(funcs ...func(gen.Dao) gen.Dao) IPostDo
- Unscoped() IPostDo
- Create(values ...*models.Post) error
- CreateInBatches(values []*models.Post, batchSize int) error
- Save(values ...*models.Post) error
- First() (*models.Post, error)
- Take() (*models.Post, error)
- Last() (*models.Post, error)
- Find() ([]*models.Post, error)
- FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Post, err error)
- FindInBatches(result *[]*models.Post, batchSize int, fc func(tx gen.Dao, batch int) error) error
- Pluck(column field.Expr, dest interface{}) error
- Delete(...*models.Post) (info gen.ResultInfo, err error)
- Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
- UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
- Updates(value interface{}) (info gen.ResultInfo, err error)
- UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
- UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
- UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
- UpdateFrom(q gen.SubQuery) gen.Dao
- Attrs(attrs ...field.AssignExpr) IPostDo
- Assign(attrs ...field.AssignExpr) IPostDo
- Joins(fields ...field.RelationField) IPostDo
- Preload(fields ...field.RelationField) IPostDo
- FirstOrInit() (*models.Post, error)
- FirstOrCreate() (*models.Post, error)
- FindByPage(offset int, limit int) (result []*models.Post, count int64, err error)
- ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
- Scan(result interface{}) (err error)
- Returning(value interface{}, columns ...string) IPostDo
- UnderlyingDB() *gorm.DB
- schema.Tabler
-}
-
-func (p postDo) Debug() IPostDo {
- return p.withDO(p.DO.Debug())
-}
-
-func (p postDo) WithContext(ctx context.Context) IPostDo {
- return p.withDO(p.DO.WithContext(ctx))
-}
-
-func (p postDo) ReadDB() IPostDo {
- return p.Clauses(dbresolver.Read)
-}
-
-func (p postDo) WriteDB() IPostDo {
- return p.Clauses(dbresolver.Write)
-}
-
-func (p postDo) Session(config *gorm.Session) IPostDo {
- return p.withDO(p.DO.Session(config))
-}
-
-func (p postDo) Clauses(conds ...clause.Expression) IPostDo {
- return p.withDO(p.DO.Clauses(conds...))
-}
-
-func (p postDo) Returning(value interface{}, columns ...string) IPostDo {
- return p.withDO(p.DO.Returning(value, columns...))
-}
-
-func (p postDo) Not(conds ...gen.Condition) IPostDo {
- return p.withDO(p.DO.Not(conds...))
-}
-
-func (p postDo) Or(conds ...gen.Condition) IPostDo {
- return p.withDO(p.DO.Or(conds...))
-}
-
-func (p postDo) Select(conds ...field.Expr) IPostDo {
- return p.withDO(p.DO.Select(conds...))
-}
-
-func (p postDo) Where(conds ...gen.Condition) IPostDo {
- return p.withDO(p.DO.Where(conds...))
-}
-
-func (p postDo) Order(conds ...field.Expr) IPostDo {
- return p.withDO(p.DO.Order(conds...))
-}
-
-func (p postDo) Distinct(cols ...field.Expr) IPostDo {
- return p.withDO(p.DO.Distinct(cols...))
-}
-
-func (p postDo) Omit(cols ...field.Expr) IPostDo {
- return p.withDO(p.DO.Omit(cols...))
-}
-
-func (p postDo) Join(table schema.Tabler, on ...field.Expr) IPostDo {
- return p.withDO(p.DO.Join(table, on...))
-}
-
-func (p postDo) LeftJoin(table schema.Tabler, on ...field.Expr) IPostDo {
- return p.withDO(p.DO.LeftJoin(table, on...))
-}
-
-func (p postDo) RightJoin(table schema.Tabler, on ...field.Expr) IPostDo {
- return p.withDO(p.DO.RightJoin(table, on...))
-}
-
-func (p postDo) Group(cols ...field.Expr) IPostDo {
- return p.withDO(p.DO.Group(cols...))
-}
-
-func (p postDo) Having(conds ...gen.Condition) IPostDo {
- return p.withDO(p.DO.Having(conds...))
-}
-
-func (p postDo) Limit(limit int) IPostDo {
- return p.withDO(p.DO.Limit(limit))
-}
-
-func (p postDo) Offset(offset int) IPostDo {
- return p.withDO(p.DO.Offset(offset))
-}
-
-func (p postDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IPostDo {
- return p.withDO(p.DO.Scopes(funcs...))
-}
-
-func (p postDo) Unscoped() IPostDo {
- return p.withDO(p.DO.Unscoped())
-}
-
-func (p postDo) Create(values ...*models.Post) error {
- if len(values) == 0 {
- return nil
- }
- return p.DO.Create(values)
-}
-
-func (p postDo) CreateInBatches(values []*models.Post, batchSize int) error {
- return p.DO.CreateInBatches(values, batchSize)
-}
-
-// Save : !!! underlying implementation is different with GORM
-// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
-func (p postDo) Save(values ...*models.Post) error {
- if len(values) == 0 {
- return nil
- }
- return p.DO.Save(values)
-}
-
-func (p postDo) First() (*models.Post, error) {
- if result, err := p.DO.First(); err != nil {
- return nil, err
- } else {
- return result.(*models.Post), nil
- }
-}
-
-func (p postDo) Take() (*models.Post, error) {
- if result, err := p.DO.Take(); err != nil {
- return nil, err
- } else {
- return result.(*models.Post), nil
- }
-}
-
-func (p postDo) Last() (*models.Post, error) {
- if result, err := p.DO.Last(); err != nil {
- return nil, err
- } else {
- return result.(*models.Post), nil
- }
-}
-
-func (p postDo) Find() ([]*models.Post, error) {
- result, err := p.DO.Find()
- return result.([]*models.Post), err
-}
-
-func (p postDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Post, err error) {
- buf := make([]*models.Post, 0, batchSize)
- err = p.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
- defer func() { results = append(results, buf...) }()
- return fc(tx, batch)
- })
- return results, err
-}
-
-func (p postDo) FindInBatches(result *[]*models.Post, batchSize int, fc func(tx gen.Dao, batch int) error) error {
- return p.DO.FindInBatches(result, batchSize, fc)
-}
-
-func (p postDo) Attrs(attrs ...field.AssignExpr) IPostDo {
- return p.withDO(p.DO.Attrs(attrs...))
-}
-
-func (p postDo) Assign(attrs ...field.AssignExpr) IPostDo {
- return p.withDO(p.DO.Assign(attrs...))
-}
-
-func (p postDo) Joins(fields ...field.RelationField) IPostDo {
- for _, _f := range fields {
- p = *p.withDO(p.DO.Joins(_f))
- }
- return &p
-}
-
-func (p postDo) Preload(fields ...field.RelationField) IPostDo {
- for _, _f := range fields {
- p = *p.withDO(p.DO.Preload(_f))
- }
- return &p
-}
-
-func (p postDo) FirstOrInit() (*models.Post, error) {
- if result, err := p.DO.FirstOrInit(); err != nil {
- return nil, err
- } else {
- return result.(*models.Post), nil
- }
-}
-
-func (p postDo) FirstOrCreate() (*models.Post, error) {
- if result, err := p.DO.FirstOrCreate(); err != nil {
- return nil, err
- } else {
- return result.(*models.Post), nil
- }
-}
-
-func (p postDo) FindByPage(offset int, limit int) (result []*models.Post, count int64, err error) {
- result, err = p.Offset(offset).Limit(limit).Find()
- if err != nil {
- return
- }
-
- if size := len(result); 0 < limit && 0 < size && size < limit {
- count = int64(size + offset)
- return
- }
-
- count, err = p.Offset(-1).Limit(-1).Count()
- return
-}
-
-func (p postDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
- count, err = p.Count()
- if err != nil {
- return
- }
-
- err = p.Offset(offset).Limit(limit).Scan(result)
- return
-}
-
-func (p postDo) Scan(result interface{}) (err error) {
- return p.DO.Scan(result)
-}
-
-func (p postDo) Delete(models ...*models.Post) (result gen.ResultInfo, err error) {
- return p.DO.Delete(models)
-}
-
-func (p *postDo) withDO(do gen.Dao) *postDo {
- p.DO = *do.(*gen.DO)
- return p
-}
diff --git a/internal/dal/posts.gen_test.go b/internal/dal/posts.gen_test.go
deleted file mode 100644
index ed31c2e..0000000
--- a/internal/dal/posts.gen_test.go
+++ /dev/null
@@ -1,145 +0,0 @@
-// Code generated by gorm.io/gen. DO NOT EDIT.
-// Code generated by gorm.io/gen. DO NOT EDIT.
-// Code generated by gorm.io/gen. DO NOT EDIT.
-
-package dal
-
-import (
- "app/internal/models"
- "context"
- "fmt"
- "testing"
-
- "gorm.io/gen"
- "gorm.io/gen/field"
- "gorm.io/gorm/clause"
-)
-
-func init() {
- InitializeDB()
- err := _gen_test_db.AutoMigrate(&models.Post{})
- if err != nil {
- fmt.Printf("Error: AutoMigrate(&models.Post{}) fail: %s", err)
- }
-}
-
-func Test_postQuery(t *testing.T) {
- post := newPost(_gen_test_db)
- post = *post.As(post.TableName())
- _do := post.WithContext(context.Background()).Debug()
-
- primaryKey := field.NewString(post.TableName(), clause.PrimaryKey)
- _, err := _do.Unscoped().Where(primaryKey.IsNotNull()).Delete()
- if err != nil {
- t.Error("clean table fail:", err)
- return
- }
-
- _, ok := post.GetFieldByName("")
- if ok {
- t.Error("GetFieldByName(\"\") from post success")
- }
-
- err = _do.Create(&models.Post{})
- if err != nil {
- t.Error("create item in table fail:", err)
- }
-
- err = _do.Save(&models.Post{})
- if err != nil {
- t.Error("create item in table fail:", err)
- }
-
- err = _do.CreateInBatches([]*models.Post{{}, {}}, 10)
- if err != nil {
- t.Error("create item in table fail:", err)
- }
-
- _, err = _do.Select(post.ALL).Take()
- if err != nil {
- t.Error("Take() on table fail:", err)
- }
-
- _, err = _do.First()
- if err != nil {
- t.Error("First() on table fail:", err)
- }
-
- _, err = _do.Last()
- if err != nil {
- t.Error("First() on table fail:", err)
- }
-
- _, err = _do.Where(primaryKey.IsNotNull()).FindInBatch(10, func(tx gen.Dao, batch int) error { return nil })
- if err != nil {
- t.Error("FindInBatch() on table fail:", err)
- }
-
- err = _do.Where(primaryKey.IsNotNull()).FindInBatches(&[]*models.Post{}, 10, func(tx gen.Dao, batch int) error { return nil })
- if err != nil {
- t.Error("FindInBatches() on table fail:", err)
- }
-
- _, err = _do.Select(post.ALL).Where(primaryKey.IsNotNull()).Order(primaryKey.Desc()).Find()
- if err != nil {
- t.Error("Find() on table fail:", err)
- }
-
- _, err = _do.Distinct(primaryKey).Take()
- if err != nil {
- t.Error("select Distinct() on table fail:", err)
- }
-
- _, err = _do.Select(post.ALL).Omit(primaryKey).Take()
- if err != nil {
- t.Error("Omit() on table fail:", err)
- }
-
- _, err = _do.Group(primaryKey).Find()
- if err != nil {
- t.Error("Group() on table fail:", err)
- }
-
- _, err = _do.Scopes(func(dao gen.Dao) gen.Dao { return dao.Where(primaryKey.IsNotNull()) }).Find()
- if err != nil {
- t.Error("Scopes() on table fail:", err)
- }
-
- _, _, err = _do.FindByPage(0, 1)
- if err != nil {
- t.Error("FindByPage() on table fail:", err)
- }
-
- _, err = _do.ScanByPage(&models.Post{}, 0, 1)
- if err != nil {
- t.Error("ScanByPage() on table fail:", err)
- }
-
- _, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrInit()
- if err != nil {
- t.Error("FirstOrInit() on table fail:", err)
- }
-
- _, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrCreate()
- if err != nil {
- t.Error("FirstOrCreate() on table fail:", err)
- }
-
- var _a _another
- var _aPK = field.NewString(_a.TableName(), "id")
-
- err = _do.Join(&_a, primaryKey.EqCol(_aPK)).Scan(map[string]interface{}{})
- if err != nil {
- t.Error("Join() on table fail:", err)
- }
-
- err = _do.LeftJoin(&_a, primaryKey.EqCol(_aPK)).Scan(map[string]interface{}{})
- if err != nil {
- t.Error("LeftJoin() on table fail:", err)
- }
-
- _, err = _do.Not().Or().Clauses().Take()
- if err != nil {
- t.Error("Not/Or/Clauses on table fail:", err)
- }
-}
diff --git a/internal/dal/prep_tasks.gen.go b/internal/dal/prep_tasks.gen.go
new file mode 100644
index 0000000..48620c9
--- /dev/null
+++ b/internal/dal/prep_tasks.gen.go
@@ -0,0 +1,935 @@
+// Code generated by gorm.io/gen. DO NOT EDIT.
+// Code generated by gorm.io/gen. DO NOT EDIT.
+// Code generated by gorm.io/gen. DO NOT EDIT.
+
+package dal
+
+import (
+ "app/internal/models"
+ "context"
+
+ "gorm.io/gorm"
+ "gorm.io/gorm/clause"
+ "gorm.io/gorm/schema"
+
+ "gorm.io/gen"
+ "gorm.io/gen/field"
+
+ "gorm.io/plugin/dbresolver"
+)
+
+func newPrepTask(db *gorm.DB, opts ...gen.DOOption) prepTask {
+ _prepTask := prepTask{}
+
+ _prepTask.prepTaskDo.UseDB(db, opts...)
+ _prepTask.prepTaskDo.UseModel(&models.PrepTask{})
+
+ tableName := _prepTask.prepTaskDo.TableName()
+ _prepTask.ALL = field.NewAsterisk(tableName)
+ _prepTask.Id = field.NewUint(tableName, "id")
+ _prepTask.Status = field.NewString(tableName, "status")
+ _prepTask.Description = field.NewString(tableName, "description")
+ _prepTask.TaskId = field.NewUint(tableName, "task_id")
+ _prepTask.WorkAreaId = field.NewUint(tableName, "work_area_id")
+ _prepTask.CreatedAt = field.NewInt64(tableName, "created_at")
+ _prepTask.Deadline = field.NewInt64(tableName, "deadline")
+ _prepTask.Task = prepTaskBelongsToTask{
+ db: db.Session(&gorm.Session{}),
+
+ RelationField: field.NewRelation("Task", "models.Task"),
+ ProductType: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Task.ProductType", "models.ProductType"),
+ },
+ Order: struct {
+ field.RelationField
+ ProductType struct {
+ field.RelationField
+ }
+ Customer struct {
+ field.RelationField
+ Orders struct {
+ field.RelationField
+ }
+ }
+ Tasks struct {
+ field.RelationField
+ }
+ }{
+ RelationField: field.NewRelation("Task.Order", "models.Order"),
+ ProductType: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Task.Order.ProductType", "models.ProductType"),
+ },
+ Customer: struct {
+ field.RelationField
+ Orders struct {
+ field.RelationField
+ }
+ }{
+ RelationField: field.NewRelation("Task.Order.Customer", "models.Customer"),
+ Orders: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Task.Order.Customer.Orders", "models.Order"),
+ },
+ },
+ Tasks: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Task.Order.Tasks", "models.Task"),
+ },
+ },
+ PrepTasks: struct {
+ field.RelationField
+ Task struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ Workshop struct {
+ field.RelationField
+ WorkAreas struct {
+ field.RelationField
+ }
+ Workers struct {
+ field.RelationField
+ Workshop struct {
+ field.RelationField
+ }
+ TeamTasks struct {
+ field.RelationField
+ TeamType struct {
+ field.RelationField
+ }
+ TeamLeader struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ TeamMembers struct {
+ field.RelationField
+ }
+ }
+ }
+ Tasks struct {
+ field.RelationField
+ }
+ }
+ PrepTasks struct {
+ field.RelationField
+ }
+ Shifts struct {
+ field.RelationField
+ ProductType struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ }
+ TeamTasks struct {
+ field.RelationField
+ }
+ }
+ }{
+ RelationField: field.NewRelation("Task.PrepTasks", "models.PrepTask"),
+ Task: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Task.PrepTasks.Task", "models.Task"),
+ },
+ WorkArea: struct {
+ field.RelationField
+ Workshop struct {
+ field.RelationField
+ WorkAreas struct {
+ field.RelationField
+ }
+ Workers struct {
+ field.RelationField
+ Workshop struct {
+ field.RelationField
+ }
+ TeamTasks struct {
+ field.RelationField
+ TeamType struct {
+ field.RelationField
+ }
+ TeamLeader struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ TeamMembers struct {
+ field.RelationField
+ }
+ }
+ }
+ Tasks struct {
+ field.RelationField
+ }
+ }
+ PrepTasks struct {
+ field.RelationField
+ }
+ Shifts struct {
+ field.RelationField
+ ProductType struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ }
+ TeamTasks struct {
+ field.RelationField
+ }
+ }{
+ RelationField: field.NewRelation("Task.PrepTasks.WorkArea", "models.WorkArea"),
+ Workshop: struct {
+ field.RelationField
+ WorkAreas struct {
+ field.RelationField
+ }
+ Workers struct {
+ field.RelationField
+ Workshop struct {
+ field.RelationField
+ }
+ TeamTasks struct {
+ field.RelationField
+ TeamType struct {
+ field.RelationField
+ }
+ TeamLeader struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ TeamMembers struct {
+ field.RelationField
+ }
+ }
+ }
+ Tasks struct {
+ field.RelationField
+ }
+ }{
+ RelationField: field.NewRelation("Task.PrepTasks.WorkArea.Workshop", "models.Workshop"),
+ WorkAreas: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Task.PrepTasks.WorkArea.Workshop.WorkAreas", "models.WorkArea"),
+ },
+ Workers: struct {
+ field.RelationField
+ Workshop struct {
+ field.RelationField
+ }
+ TeamTasks struct {
+ field.RelationField
+ TeamType struct {
+ field.RelationField
+ }
+ TeamLeader struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ TeamMembers struct {
+ field.RelationField
+ }
+ }
+ }{
+ RelationField: field.NewRelation("Task.PrepTasks.WorkArea.Workshop.Workers", "models.Worker"),
+ Workshop: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Task.PrepTasks.WorkArea.Workshop.Workers.Workshop", "models.Workshop"),
+ },
+ TeamTasks: struct {
+ field.RelationField
+ TeamType struct {
+ field.RelationField
+ }
+ TeamLeader struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ TeamMembers struct {
+ field.RelationField
+ }
+ }{
+ RelationField: field.NewRelation("Task.PrepTasks.WorkArea.Workshop.Workers.TeamTasks", "models.TeamTask"),
+ TeamType: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Task.PrepTasks.WorkArea.Workshop.Workers.TeamTasks.TeamType", "models.TeamType"),
+ },
+ TeamLeader: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Task.PrepTasks.WorkArea.Workshop.Workers.TeamTasks.TeamLeader", "models.Worker"),
+ },
+ WorkArea: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Task.PrepTasks.WorkArea.Workshop.Workers.TeamTasks.WorkArea", "models.WorkArea"),
+ },
+ TeamMembers: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Task.PrepTasks.WorkArea.Workshop.Workers.TeamTasks.TeamMembers", "models.Worker"),
+ },
+ },
+ },
+ Tasks: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Task.PrepTasks.WorkArea.Workshop.Tasks", "models.Task"),
+ },
+ },
+ PrepTasks: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Task.PrepTasks.WorkArea.PrepTasks", "models.PrepTask"),
+ },
+ Shifts: struct {
+ field.RelationField
+ ProductType struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ }{
+ RelationField: field.NewRelation("Task.PrepTasks.WorkArea.Shifts", "models.Shift"),
+ ProductType: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Task.PrepTasks.WorkArea.Shifts.ProductType", "models.ProductType"),
+ },
+ WorkArea: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Task.PrepTasks.WorkArea.Shifts.WorkArea", "models.WorkArea"),
+ },
+ },
+ TeamTasks: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Task.PrepTasks.WorkArea.TeamTasks", "models.TeamTask"),
+ },
+ },
+ },
+ Workshops: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("Task.Workshops", "models.Workshop"),
+ },
+ }
+
+ _prepTask.WorkArea = prepTaskBelongsToWorkArea{
+ db: db.Session(&gorm.Session{}),
+
+ RelationField: field.NewRelation("WorkArea", "models.WorkArea"),
+ }
+
+ _prepTask.fillFieldMap()
+
+ return _prepTask
+}
+
+type prepTask struct {
+ prepTaskDo
+
+ ALL field.Asterisk
+ Id field.Uint
+ Status field.String
+ Description field.String
+ TaskId field.Uint
+ WorkAreaId field.Uint
+ CreatedAt field.Int64
+ Deadline field.Int64
+ Task prepTaskBelongsToTask
+
+ WorkArea prepTaskBelongsToWorkArea
+
+ fieldMap map[string]field.Expr
+}
+
+func (p prepTask) Table(newTableName string) *prepTask {
+ p.prepTaskDo.UseTable(newTableName)
+ return p.updateTableName(newTableName)
+}
+
+func (p prepTask) As(alias string) *prepTask {
+ p.prepTaskDo.DO = *(p.prepTaskDo.As(alias).(*gen.DO))
+ return p.updateTableName(alias)
+}
+
+func (p *prepTask) updateTableName(table string) *prepTask {
+ p.ALL = field.NewAsterisk(table)
+ p.Id = field.NewUint(table, "id")
+ p.Status = field.NewString(table, "status")
+ p.Description = field.NewString(table, "description")
+ p.TaskId = field.NewUint(table, "task_id")
+ p.WorkAreaId = field.NewUint(table, "work_area_id")
+ p.CreatedAt = field.NewInt64(table, "created_at")
+ p.Deadline = field.NewInt64(table, "deadline")
+
+ p.fillFieldMap()
+
+ return p
+}
+
+func (p *prepTask) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
+ _f, ok := p.fieldMap[fieldName]
+ if !ok || _f == nil {
+ return nil, false
+ }
+ _oe, ok := _f.(field.OrderExpr)
+ return _oe, ok
+}
+
+func (p *prepTask) fillFieldMap() {
+ p.fieldMap = make(map[string]field.Expr, 9)
+ p.fieldMap["id"] = p.Id
+ p.fieldMap["status"] = p.Status
+ p.fieldMap["description"] = p.Description
+ p.fieldMap["task_id"] = p.TaskId
+ p.fieldMap["work_area_id"] = p.WorkAreaId
+ p.fieldMap["created_at"] = p.CreatedAt
+ p.fieldMap["deadline"] = p.Deadline
+
+}
+
+func (p prepTask) clone(db *gorm.DB) prepTask {
+ p.prepTaskDo.ReplaceConnPool(db.Statement.ConnPool)
+ return p
+}
+
+func (p prepTask) replaceDB(db *gorm.DB) prepTask {
+ p.prepTaskDo.ReplaceDB(db)
+ return p
+}
+
+type prepTaskBelongsToTask struct {
+ db *gorm.DB
+
+ field.RelationField
+
+ ProductType struct {
+ field.RelationField
+ }
+ Order struct {
+ field.RelationField
+ ProductType struct {
+ field.RelationField
+ }
+ Customer struct {
+ field.RelationField
+ Orders struct {
+ field.RelationField
+ }
+ }
+ Tasks struct {
+ field.RelationField
+ }
+ }
+ PrepTasks struct {
+ field.RelationField
+ Task struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ Workshop struct {
+ field.RelationField
+ WorkAreas struct {
+ field.RelationField
+ }
+ Workers struct {
+ field.RelationField
+ Workshop struct {
+ field.RelationField
+ }
+ TeamTasks struct {
+ field.RelationField
+ TeamType struct {
+ field.RelationField
+ }
+ TeamLeader struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ TeamMembers struct {
+ field.RelationField
+ }
+ }
+ }
+ Tasks struct {
+ field.RelationField
+ }
+ }
+ PrepTasks struct {
+ field.RelationField
+ }
+ Shifts struct {
+ field.RelationField
+ ProductType struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ }
+ TeamTasks struct {
+ field.RelationField
+ }
+ }
+ }
+ Workshops struct {
+ field.RelationField
+ }
+}
+
+func (a prepTaskBelongsToTask) Where(conds ...field.Expr) *prepTaskBelongsToTask {
+ if len(conds) == 0 {
+ return &a
+ }
+
+ exprs := make([]clause.Expression, 0, len(conds))
+ for _, cond := range conds {
+ exprs = append(exprs, cond.BeCond().(clause.Expression))
+ }
+ a.db = a.db.Clauses(clause.Where{Exprs: exprs})
+ return &a
+}
+
+func (a prepTaskBelongsToTask) WithContext(ctx context.Context) *prepTaskBelongsToTask {
+ a.db = a.db.WithContext(ctx)
+ return &a
+}
+
+func (a prepTaskBelongsToTask) Session(session *gorm.Session) *prepTaskBelongsToTask {
+ a.db = a.db.Session(session)
+ return &a
+}
+
+func (a prepTaskBelongsToTask) Model(m *models.PrepTask) *prepTaskBelongsToTaskTx {
+ return &prepTaskBelongsToTaskTx{a.db.Model(m).Association(a.Name())}
+}
+
+type prepTaskBelongsToTaskTx struct{ tx *gorm.Association }
+
+func (a prepTaskBelongsToTaskTx) Find() (result *models.Task, err error) {
+ return result, a.tx.Find(&result)
+}
+
+func (a prepTaskBelongsToTaskTx) Append(values ...*models.Task) (err error) {
+ targetValues := make([]interface{}, len(values))
+ for i, v := range values {
+ targetValues[i] = v
+ }
+ return a.tx.Append(targetValues...)
+}
+
+func (a prepTaskBelongsToTaskTx) Replace(values ...*models.Task) (err error) {
+ targetValues := make([]interface{}, len(values))
+ for i, v := range values {
+ targetValues[i] = v
+ }
+ return a.tx.Replace(targetValues...)
+}
+
+func (a prepTaskBelongsToTaskTx) Delete(values ...*models.Task) (err error) {
+ targetValues := make([]interface{}, len(values))
+ for i, v := range values {
+ targetValues[i] = v
+ }
+ return a.tx.Delete(targetValues...)
+}
+
+func (a prepTaskBelongsToTaskTx) Clear() error {
+ return a.tx.Clear()
+}
+
+func (a prepTaskBelongsToTaskTx) Count() int64 {
+ return a.tx.Count()
+}
+
+type prepTaskBelongsToWorkArea struct {
+ db *gorm.DB
+
+ field.RelationField
+}
+
+func (a prepTaskBelongsToWorkArea) Where(conds ...field.Expr) *prepTaskBelongsToWorkArea {
+ if len(conds) == 0 {
+ return &a
+ }
+
+ exprs := make([]clause.Expression, 0, len(conds))
+ for _, cond := range conds {
+ exprs = append(exprs, cond.BeCond().(clause.Expression))
+ }
+ a.db = a.db.Clauses(clause.Where{Exprs: exprs})
+ return &a
+}
+
+func (a prepTaskBelongsToWorkArea) WithContext(ctx context.Context) *prepTaskBelongsToWorkArea {
+ a.db = a.db.WithContext(ctx)
+ return &a
+}
+
+func (a prepTaskBelongsToWorkArea) Session(session *gorm.Session) *prepTaskBelongsToWorkArea {
+ a.db = a.db.Session(session)
+ return &a
+}
+
+func (a prepTaskBelongsToWorkArea) Model(m *models.PrepTask) *prepTaskBelongsToWorkAreaTx {
+ return &prepTaskBelongsToWorkAreaTx{a.db.Model(m).Association(a.Name())}
+}
+
+type prepTaskBelongsToWorkAreaTx struct{ tx *gorm.Association }
+
+func (a prepTaskBelongsToWorkAreaTx) Find() (result *models.WorkArea, err error) {
+ return result, a.tx.Find(&result)
+}
+
+func (a prepTaskBelongsToWorkAreaTx) Append(values ...*models.WorkArea) (err error) {
+ targetValues := make([]interface{}, len(values))
+ for i, v := range values {
+ targetValues[i] = v
+ }
+ return a.tx.Append(targetValues...)
+}
+
+func (a prepTaskBelongsToWorkAreaTx) Replace(values ...*models.WorkArea) (err error) {
+ targetValues := make([]interface{}, len(values))
+ for i, v := range values {
+ targetValues[i] = v
+ }
+ return a.tx.Replace(targetValues...)
+}
+
+func (a prepTaskBelongsToWorkAreaTx) Delete(values ...*models.WorkArea) (err error) {
+ targetValues := make([]interface{}, len(values))
+ for i, v := range values {
+ targetValues[i] = v
+ }
+ return a.tx.Delete(targetValues...)
+}
+
+func (a prepTaskBelongsToWorkAreaTx) Clear() error {
+ return a.tx.Clear()
+}
+
+func (a prepTaskBelongsToWorkAreaTx) Count() int64 {
+ return a.tx.Count()
+}
+
+type prepTaskDo struct{ gen.DO }
+
+type IPrepTaskDo interface {
+ gen.SubQuery
+ Debug() IPrepTaskDo
+ WithContext(ctx context.Context) IPrepTaskDo
+ WithResult(fc func(tx gen.Dao)) gen.ResultInfo
+ ReplaceDB(db *gorm.DB)
+ ReadDB() IPrepTaskDo
+ WriteDB() IPrepTaskDo
+ As(alias string) gen.Dao
+ Session(config *gorm.Session) IPrepTaskDo
+ Columns(cols ...field.Expr) gen.Columns
+ Clauses(conds ...clause.Expression) IPrepTaskDo
+ Not(conds ...gen.Condition) IPrepTaskDo
+ Or(conds ...gen.Condition) IPrepTaskDo
+ Select(conds ...field.Expr) IPrepTaskDo
+ Where(conds ...gen.Condition) IPrepTaskDo
+ Order(conds ...field.Expr) IPrepTaskDo
+ Distinct(cols ...field.Expr) IPrepTaskDo
+ Omit(cols ...field.Expr) IPrepTaskDo
+ Join(table schema.Tabler, on ...field.Expr) IPrepTaskDo
+ LeftJoin(table schema.Tabler, on ...field.Expr) IPrepTaskDo
+ RightJoin(table schema.Tabler, on ...field.Expr) IPrepTaskDo
+ Group(cols ...field.Expr) IPrepTaskDo
+ Having(conds ...gen.Condition) IPrepTaskDo
+ Limit(limit int) IPrepTaskDo
+ Offset(offset int) IPrepTaskDo
+ Count() (count int64, err error)
+ Scopes(funcs ...func(gen.Dao) gen.Dao) IPrepTaskDo
+ Unscoped() IPrepTaskDo
+ Create(values ...*models.PrepTask) error
+ CreateInBatches(values []*models.PrepTask, batchSize int) error
+ Save(values ...*models.PrepTask) error
+ First() (*models.PrepTask, error)
+ Take() (*models.PrepTask, error)
+ Last() (*models.PrepTask, error)
+ Find() ([]*models.PrepTask, error)
+ FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.PrepTask, err error)
+ FindInBatches(result *[]*models.PrepTask, batchSize int, fc func(tx gen.Dao, batch int) error) error
+ Pluck(column field.Expr, dest interface{}) error
+ Delete(...*models.PrepTask) (info gen.ResultInfo, err error)
+ Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
+ UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
+ Updates(value interface{}) (info gen.ResultInfo, err error)
+ UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
+ UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
+ UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
+ UpdateFrom(q gen.SubQuery) gen.Dao
+ Attrs(attrs ...field.AssignExpr) IPrepTaskDo
+ Assign(attrs ...field.AssignExpr) IPrepTaskDo
+ Joins(fields ...field.RelationField) IPrepTaskDo
+ Preload(fields ...field.RelationField) IPrepTaskDo
+ FirstOrInit() (*models.PrepTask, error)
+ FirstOrCreate() (*models.PrepTask, error)
+ FindByPage(offset int, limit int) (result []*models.PrepTask, count int64, err error)
+ ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
+ Scan(result interface{}) (err error)
+ Returning(value interface{}, columns ...string) IPrepTaskDo
+ UnderlyingDB() *gorm.DB
+ schema.Tabler
+}
+
+func (p prepTaskDo) Debug() IPrepTaskDo {
+ return p.withDO(p.DO.Debug())
+}
+
+func (p prepTaskDo) WithContext(ctx context.Context) IPrepTaskDo {
+ return p.withDO(p.DO.WithContext(ctx))
+}
+
+func (p prepTaskDo) ReadDB() IPrepTaskDo {
+ return p.Clauses(dbresolver.Read)
+}
+
+func (p prepTaskDo) WriteDB() IPrepTaskDo {
+ return p.Clauses(dbresolver.Write)
+}
+
+func (p prepTaskDo) Session(config *gorm.Session) IPrepTaskDo {
+ return p.withDO(p.DO.Session(config))
+}
+
+func (p prepTaskDo) Clauses(conds ...clause.Expression) IPrepTaskDo {
+ return p.withDO(p.DO.Clauses(conds...))
+}
+
+func (p prepTaskDo) Returning(value interface{}, columns ...string) IPrepTaskDo {
+ return p.withDO(p.DO.Returning(value, columns...))
+}
+
+func (p prepTaskDo) Not(conds ...gen.Condition) IPrepTaskDo {
+ return p.withDO(p.DO.Not(conds...))
+}
+
+func (p prepTaskDo) Or(conds ...gen.Condition) IPrepTaskDo {
+ return p.withDO(p.DO.Or(conds...))
+}
+
+func (p prepTaskDo) Select(conds ...field.Expr) IPrepTaskDo {
+ return p.withDO(p.DO.Select(conds...))
+}
+
+func (p prepTaskDo) Where(conds ...gen.Condition) IPrepTaskDo {
+ return p.withDO(p.DO.Where(conds...))
+}
+
+func (p prepTaskDo) Order(conds ...field.Expr) IPrepTaskDo {
+ return p.withDO(p.DO.Order(conds...))
+}
+
+func (p prepTaskDo) Distinct(cols ...field.Expr) IPrepTaskDo {
+ return p.withDO(p.DO.Distinct(cols...))
+}
+
+func (p prepTaskDo) Omit(cols ...field.Expr) IPrepTaskDo {
+ return p.withDO(p.DO.Omit(cols...))
+}
+
+func (p prepTaskDo) Join(table schema.Tabler, on ...field.Expr) IPrepTaskDo {
+ return p.withDO(p.DO.Join(table, on...))
+}
+
+func (p prepTaskDo) LeftJoin(table schema.Tabler, on ...field.Expr) IPrepTaskDo {
+ return p.withDO(p.DO.LeftJoin(table, on...))
+}
+
+func (p prepTaskDo) RightJoin(table schema.Tabler, on ...field.Expr) IPrepTaskDo {
+ return p.withDO(p.DO.RightJoin(table, on...))
+}
+
+func (p prepTaskDo) Group(cols ...field.Expr) IPrepTaskDo {
+ return p.withDO(p.DO.Group(cols...))
+}
+
+func (p prepTaskDo) Having(conds ...gen.Condition) IPrepTaskDo {
+ return p.withDO(p.DO.Having(conds...))
+}
+
+func (p prepTaskDo) Limit(limit int) IPrepTaskDo {
+ return p.withDO(p.DO.Limit(limit))
+}
+
+func (p prepTaskDo) Offset(offset int) IPrepTaskDo {
+ return p.withDO(p.DO.Offset(offset))
+}
+
+func (p prepTaskDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IPrepTaskDo {
+ return p.withDO(p.DO.Scopes(funcs...))
+}
+
+func (p prepTaskDo) Unscoped() IPrepTaskDo {
+ return p.withDO(p.DO.Unscoped())
+}
+
+func (p prepTaskDo) Create(values ...*models.PrepTask) error {
+ if len(values) == 0 {
+ return nil
+ }
+ return p.DO.Create(values)
+}
+
+func (p prepTaskDo) CreateInBatches(values []*models.PrepTask, batchSize int) error {
+ return p.DO.CreateInBatches(values, batchSize)
+}
+
+// Save : !!! underlying implementation is different with GORM
+// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
+func (p prepTaskDo) Save(values ...*models.PrepTask) error {
+ if len(values) == 0 {
+ return nil
+ }
+ return p.DO.Save(values)
+}
+
+func (p prepTaskDo) First() (*models.PrepTask, error) {
+ if result, err := p.DO.First(); err != nil {
+ return nil, err
+ } else {
+ return result.(*models.PrepTask), nil
+ }
+}
+
+func (p prepTaskDo) Take() (*models.PrepTask, error) {
+ if result, err := p.DO.Take(); err != nil {
+ return nil, err
+ } else {
+ return result.(*models.PrepTask), nil
+ }
+}
+
+func (p prepTaskDo) Last() (*models.PrepTask, error) {
+ if result, err := p.DO.Last(); err != nil {
+ return nil, err
+ } else {
+ return result.(*models.PrepTask), nil
+ }
+}
+
+func (p prepTaskDo) Find() ([]*models.PrepTask, error) {
+ result, err := p.DO.Find()
+ return result.([]*models.PrepTask), err
+}
+
+func (p prepTaskDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.PrepTask, err error) {
+ buf := make([]*models.PrepTask, 0, batchSize)
+ err = p.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
+ defer func() { results = append(results, buf...) }()
+ return fc(tx, batch)
+ })
+ return results, err
+}
+
+func (p prepTaskDo) FindInBatches(result *[]*models.PrepTask, batchSize int, fc func(tx gen.Dao, batch int) error) error {
+ return p.DO.FindInBatches(result, batchSize, fc)
+}
+
+func (p prepTaskDo) Attrs(attrs ...field.AssignExpr) IPrepTaskDo {
+ return p.withDO(p.DO.Attrs(attrs...))
+}
+
+func (p prepTaskDo) Assign(attrs ...field.AssignExpr) IPrepTaskDo {
+ return p.withDO(p.DO.Assign(attrs...))
+}
+
+func (p prepTaskDo) Joins(fields ...field.RelationField) IPrepTaskDo {
+ for _, _f := range fields {
+ p = *p.withDO(p.DO.Joins(_f))
+ }
+ return &p
+}
+
+func (p prepTaskDo) Preload(fields ...field.RelationField) IPrepTaskDo {
+ for _, _f := range fields {
+ p = *p.withDO(p.DO.Preload(_f))
+ }
+ return &p
+}
+
+func (p prepTaskDo) FirstOrInit() (*models.PrepTask, error) {
+ if result, err := p.DO.FirstOrInit(); err != nil {
+ return nil, err
+ } else {
+ return result.(*models.PrepTask), nil
+ }
+}
+
+func (p prepTaskDo) FirstOrCreate() (*models.PrepTask, error) {
+ if result, err := p.DO.FirstOrCreate(); err != nil {
+ return nil, err
+ } else {
+ return result.(*models.PrepTask), nil
+ }
+}
+
+func (p prepTaskDo) FindByPage(offset int, limit int) (result []*models.PrepTask, count int64, err error) {
+ result, err = p.Offset(offset).Limit(limit).Find()
+ if err != nil {
+ return
+ }
+
+ if size := len(result); 0 < limit && 0 < size && size < limit {
+ count = int64(size + offset)
+ return
+ }
+
+ count, err = p.Offset(-1).Limit(-1).Count()
+ return
+}
+
+func (p prepTaskDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
+ count, err = p.Count()
+ if err != nil {
+ return
+ }
+
+ err = p.Offset(offset).Limit(limit).Scan(result)
+ return
+}
+
+func (p prepTaskDo) Scan(result interface{}) (err error) {
+ return p.DO.Scan(result)
+}
+
+func (p prepTaskDo) Delete(models ...*models.PrepTask) (result gen.ResultInfo, err error) {
+ return p.DO.Delete(models)
+}
+
+func (p *prepTaskDo) withDO(do gen.Dao) *prepTaskDo {
+ p.DO = *do.(*gen.DO)
+ return p
+}
diff --git a/internal/dal/prep_tasks.gen_test.go b/internal/dal/prep_tasks.gen_test.go
new file mode 100644
index 0000000..bf3cb4b
--- /dev/null
+++ b/internal/dal/prep_tasks.gen_test.go
@@ -0,0 +1,145 @@
+// Code generated by gorm.io/gen. DO NOT EDIT.
+// Code generated by gorm.io/gen. DO NOT EDIT.
+// Code generated by gorm.io/gen. DO NOT EDIT.
+
+package dal
+
+import (
+ "app/internal/models"
+ "context"
+ "fmt"
+ "testing"
+
+ "gorm.io/gen"
+ "gorm.io/gen/field"
+ "gorm.io/gorm/clause"
+)
+
+func init() {
+ InitializeDB()
+ err := _gen_test_db.AutoMigrate(&models.PrepTask{})
+ if err != nil {
+ fmt.Printf("Error: AutoMigrate(&models.PrepTask{}) fail: %s", err)
+ }
+}
+
+func Test_prepTaskQuery(t *testing.T) {
+ prepTask := newPrepTask(_gen_test_db)
+ prepTask = *prepTask.As(prepTask.TableName())
+ _do := prepTask.WithContext(context.Background()).Debug()
+
+ primaryKey := field.NewString(prepTask.TableName(), clause.PrimaryKey)
+ _, err := _do.Unscoped().Where(primaryKey.IsNotNull()).Delete()
+ if err != nil {
+ t.Error("clean table fail:", err)
+ return
+ }
+
+ _, ok := prepTask.GetFieldByName("")
+ if ok {
+ t.Error("GetFieldByName(\"\") from prepTask success")
+ }
+
+ err = _do.Create(&models.PrepTask{})
+ if err != nil {
+ t.Error("create item in table fail:", err)
+ }
+
+ err = _do.Save(&models.PrepTask{})
+ if err != nil {
+ t.Error("create item in table fail:", err)
+ }
+
+ err = _do.CreateInBatches([]*models.PrepTask{{}, {}}, 10)
+ if err != nil {
+ t.Error("create item in table fail:", err)
+ }
+
+ _, err = _do.Select(prepTask.ALL).Take()
+ if err != nil {
+ t.Error("Take() on table fail:", err)
+ }
+
+ _, err = _do.First()
+ if err != nil {
+ t.Error("First() on table fail:", err)
+ }
+
+ _, err = _do.Last()
+ if err != nil {
+ t.Error("First() on table fail:", err)
+ }
+
+ _, err = _do.Where(primaryKey.IsNotNull()).FindInBatch(10, func(tx gen.Dao, batch int) error { return nil })
+ if err != nil {
+ t.Error("FindInBatch() on table fail:", err)
+ }
+
+ err = _do.Where(primaryKey.IsNotNull()).FindInBatches(&[]*models.PrepTask{}, 10, func(tx gen.Dao, batch int) error { return nil })
+ if err != nil {
+ t.Error("FindInBatches() on table fail:", err)
+ }
+
+ _, err = _do.Select(prepTask.ALL).Where(primaryKey.IsNotNull()).Order(primaryKey.Desc()).Find()
+ if err != nil {
+ t.Error("Find() on table fail:", err)
+ }
+
+ _, err = _do.Distinct(primaryKey).Take()
+ if err != nil {
+ t.Error("select Distinct() on table fail:", err)
+ }
+
+ _, err = _do.Select(prepTask.ALL).Omit(primaryKey).Take()
+ if err != nil {
+ t.Error("Omit() on table fail:", err)
+ }
+
+ _, err = _do.Group(primaryKey).Find()
+ if err != nil {
+ t.Error("Group() on table fail:", err)
+ }
+
+ _, err = _do.Scopes(func(dao gen.Dao) gen.Dao { return dao.Where(primaryKey.IsNotNull()) }).Find()
+ if err != nil {
+ t.Error("Scopes() on table fail:", err)
+ }
+
+ _, _, err = _do.FindByPage(0, 1)
+ if err != nil {
+ t.Error("FindByPage() on table fail:", err)
+ }
+
+ _, err = _do.ScanByPage(&models.PrepTask{}, 0, 1)
+ if err != nil {
+ t.Error("ScanByPage() on table fail:", err)
+ }
+
+ _, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrInit()
+ if err != nil {
+ t.Error("FirstOrInit() on table fail:", err)
+ }
+
+ _, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrCreate()
+ if err != nil {
+ t.Error("FirstOrCreate() on table fail:", err)
+ }
+
+ var _a _another
+ var _aPK = field.NewString(_a.TableName(), "id")
+
+ err = _do.Join(&_a, primaryKey.EqCol(_aPK)).Scan(map[string]interface{}{})
+ if err != nil {
+ t.Error("Join() on table fail:", err)
+ }
+
+ err = _do.LeftJoin(&_a, primaryKey.EqCol(_aPK)).Scan(map[string]interface{}{})
+ if err != nil {
+ t.Error("LeftJoin() on table fail:", err)
+ }
+
+ _, err = _do.Not().Or().Clauses().Take()
+ if err != nil {
+ t.Error("Not/Or/Clauses on table fail:", err)
+ }
+}
diff --git a/internal/dal/product_types.gen.go b/internal/dal/product_types.gen.go
new file mode 100644
index 0000000..1ed4b28
--- /dev/null
+++ b/internal/dal/product_types.gen.go
@@ -0,0 +1,383 @@
+// Code generated by gorm.io/gen. DO NOT EDIT.
+// Code generated by gorm.io/gen. DO NOT EDIT.
+// Code generated by gorm.io/gen. DO NOT EDIT.
+
+package dal
+
+import (
+ "app/internal/models"
+ "context"
+
+ "gorm.io/gorm"
+ "gorm.io/gorm/clause"
+ "gorm.io/gorm/schema"
+
+ "gorm.io/gen"
+ "gorm.io/gen/field"
+
+ "gorm.io/plugin/dbresolver"
+)
+
+func newProductType(db *gorm.DB, opts ...gen.DOOption) productType {
+ _productType := productType{}
+
+ _productType.productTypeDo.UseDB(db, opts...)
+ _productType.productTypeDo.UseModel(&models.ProductType{})
+
+ tableName := _productType.productTypeDo.TableName()
+ _productType.ALL = field.NewAsterisk(tableName)
+ _productType.Id = field.NewUint(tableName, "id")
+ _productType.Name = field.NewString(tableName, "name")
+
+ _productType.fillFieldMap()
+
+ return _productType
+}
+
+type productType struct {
+ productTypeDo
+
+ ALL field.Asterisk
+ Id field.Uint
+ Name field.String
+
+ fieldMap map[string]field.Expr
+}
+
+func (p productType) Table(newTableName string) *productType {
+ p.productTypeDo.UseTable(newTableName)
+ return p.updateTableName(newTableName)
+}
+
+func (p productType) As(alias string) *productType {
+ p.productTypeDo.DO = *(p.productTypeDo.As(alias).(*gen.DO))
+ return p.updateTableName(alias)
+}
+
+func (p *productType) updateTableName(table string) *productType {
+ p.ALL = field.NewAsterisk(table)
+ p.Id = field.NewUint(table, "id")
+ p.Name = field.NewString(table, "name")
+
+ p.fillFieldMap()
+
+ return p
+}
+
+func (p *productType) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
+ _f, ok := p.fieldMap[fieldName]
+ if !ok || _f == nil {
+ return nil, false
+ }
+ _oe, ok := _f.(field.OrderExpr)
+ return _oe, ok
+}
+
+func (p *productType) fillFieldMap() {
+ p.fieldMap = make(map[string]field.Expr, 2)
+ p.fieldMap["id"] = p.Id
+ p.fieldMap["name"] = p.Name
+}
+
+func (p productType) clone(db *gorm.DB) productType {
+ p.productTypeDo.ReplaceConnPool(db.Statement.ConnPool)
+ return p
+}
+
+func (p productType) replaceDB(db *gorm.DB) productType {
+ p.productTypeDo.ReplaceDB(db)
+ return p
+}
+
+type productTypeDo struct{ gen.DO }
+
+type IProductTypeDo interface {
+ gen.SubQuery
+ Debug() IProductTypeDo
+ WithContext(ctx context.Context) IProductTypeDo
+ WithResult(fc func(tx gen.Dao)) gen.ResultInfo
+ ReplaceDB(db *gorm.DB)
+ ReadDB() IProductTypeDo
+ WriteDB() IProductTypeDo
+ As(alias string) gen.Dao
+ Session(config *gorm.Session) IProductTypeDo
+ Columns(cols ...field.Expr) gen.Columns
+ Clauses(conds ...clause.Expression) IProductTypeDo
+ Not(conds ...gen.Condition) IProductTypeDo
+ Or(conds ...gen.Condition) IProductTypeDo
+ Select(conds ...field.Expr) IProductTypeDo
+ Where(conds ...gen.Condition) IProductTypeDo
+ Order(conds ...field.Expr) IProductTypeDo
+ Distinct(cols ...field.Expr) IProductTypeDo
+ Omit(cols ...field.Expr) IProductTypeDo
+ Join(table schema.Tabler, on ...field.Expr) IProductTypeDo
+ LeftJoin(table schema.Tabler, on ...field.Expr) IProductTypeDo
+ RightJoin(table schema.Tabler, on ...field.Expr) IProductTypeDo
+ Group(cols ...field.Expr) IProductTypeDo
+ Having(conds ...gen.Condition) IProductTypeDo
+ Limit(limit int) IProductTypeDo
+ Offset(offset int) IProductTypeDo
+ Count() (count int64, err error)
+ Scopes(funcs ...func(gen.Dao) gen.Dao) IProductTypeDo
+ Unscoped() IProductTypeDo
+ Create(values ...*models.ProductType) error
+ CreateInBatches(values []*models.ProductType, batchSize int) error
+ Save(values ...*models.ProductType) error
+ First() (*models.ProductType, error)
+ Take() (*models.ProductType, error)
+ Last() (*models.ProductType, error)
+ Find() ([]*models.ProductType, error)
+ FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.ProductType, err error)
+ FindInBatches(result *[]*models.ProductType, batchSize int, fc func(tx gen.Dao, batch int) error) error
+ Pluck(column field.Expr, dest interface{}) error
+ Delete(...*models.ProductType) (info gen.ResultInfo, err error)
+ Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
+ UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
+ Updates(value interface{}) (info gen.ResultInfo, err error)
+ UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
+ UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
+ UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
+ UpdateFrom(q gen.SubQuery) gen.Dao
+ Attrs(attrs ...field.AssignExpr) IProductTypeDo
+ Assign(attrs ...field.AssignExpr) IProductTypeDo
+ Joins(fields ...field.RelationField) IProductTypeDo
+ Preload(fields ...field.RelationField) IProductTypeDo
+ FirstOrInit() (*models.ProductType, error)
+ FirstOrCreate() (*models.ProductType, error)
+ FindByPage(offset int, limit int) (result []*models.ProductType, count int64, err error)
+ ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
+ Scan(result interface{}) (err error)
+ Returning(value interface{}, columns ...string) IProductTypeDo
+ UnderlyingDB() *gorm.DB
+ schema.Tabler
+}
+
+func (p productTypeDo) Debug() IProductTypeDo {
+ return p.withDO(p.DO.Debug())
+}
+
+func (p productTypeDo) WithContext(ctx context.Context) IProductTypeDo {
+ return p.withDO(p.DO.WithContext(ctx))
+}
+
+func (p productTypeDo) ReadDB() IProductTypeDo {
+ return p.Clauses(dbresolver.Read)
+}
+
+func (p productTypeDo) WriteDB() IProductTypeDo {
+ return p.Clauses(dbresolver.Write)
+}
+
+func (p productTypeDo) Session(config *gorm.Session) IProductTypeDo {
+ return p.withDO(p.DO.Session(config))
+}
+
+func (p productTypeDo) Clauses(conds ...clause.Expression) IProductTypeDo {
+ return p.withDO(p.DO.Clauses(conds...))
+}
+
+func (p productTypeDo) Returning(value interface{}, columns ...string) IProductTypeDo {
+ return p.withDO(p.DO.Returning(value, columns...))
+}
+
+func (p productTypeDo) Not(conds ...gen.Condition) IProductTypeDo {
+ return p.withDO(p.DO.Not(conds...))
+}
+
+func (p productTypeDo) Or(conds ...gen.Condition) IProductTypeDo {
+ return p.withDO(p.DO.Or(conds...))
+}
+
+func (p productTypeDo) Select(conds ...field.Expr) IProductTypeDo {
+ return p.withDO(p.DO.Select(conds...))
+}
+
+func (p productTypeDo) Where(conds ...gen.Condition) IProductTypeDo {
+ return p.withDO(p.DO.Where(conds...))
+}
+
+func (p productTypeDo) Order(conds ...field.Expr) IProductTypeDo {
+ return p.withDO(p.DO.Order(conds...))
+}
+
+func (p productTypeDo) Distinct(cols ...field.Expr) IProductTypeDo {
+ return p.withDO(p.DO.Distinct(cols...))
+}
+
+func (p productTypeDo) Omit(cols ...field.Expr) IProductTypeDo {
+ return p.withDO(p.DO.Omit(cols...))
+}
+
+func (p productTypeDo) Join(table schema.Tabler, on ...field.Expr) IProductTypeDo {
+ return p.withDO(p.DO.Join(table, on...))
+}
+
+func (p productTypeDo) LeftJoin(table schema.Tabler, on ...field.Expr) IProductTypeDo {
+ return p.withDO(p.DO.LeftJoin(table, on...))
+}
+
+func (p productTypeDo) RightJoin(table schema.Tabler, on ...field.Expr) IProductTypeDo {
+ return p.withDO(p.DO.RightJoin(table, on...))
+}
+
+func (p productTypeDo) Group(cols ...field.Expr) IProductTypeDo {
+ return p.withDO(p.DO.Group(cols...))
+}
+
+func (p productTypeDo) Having(conds ...gen.Condition) IProductTypeDo {
+ return p.withDO(p.DO.Having(conds...))
+}
+
+func (p productTypeDo) Limit(limit int) IProductTypeDo {
+ return p.withDO(p.DO.Limit(limit))
+}
+
+func (p productTypeDo) Offset(offset int) IProductTypeDo {
+ return p.withDO(p.DO.Offset(offset))
+}
+
+func (p productTypeDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IProductTypeDo {
+ return p.withDO(p.DO.Scopes(funcs...))
+}
+
+func (p productTypeDo) Unscoped() IProductTypeDo {
+ return p.withDO(p.DO.Unscoped())
+}
+
+func (p productTypeDo) Create(values ...*models.ProductType) error {
+ if len(values) == 0 {
+ return nil
+ }
+ return p.DO.Create(values)
+}
+
+func (p productTypeDo) CreateInBatches(values []*models.ProductType, batchSize int) error {
+ return p.DO.CreateInBatches(values, batchSize)
+}
+
+// Save : !!! underlying implementation is different with GORM
+// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
+func (p productTypeDo) Save(values ...*models.ProductType) error {
+ if len(values) == 0 {
+ return nil
+ }
+ return p.DO.Save(values)
+}
+
+func (p productTypeDo) First() (*models.ProductType, error) {
+ if result, err := p.DO.First(); err != nil {
+ return nil, err
+ } else {
+ return result.(*models.ProductType), nil
+ }
+}
+
+func (p productTypeDo) Take() (*models.ProductType, error) {
+ if result, err := p.DO.Take(); err != nil {
+ return nil, err
+ } else {
+ return result.(*models.ProductType), nil
+ }
+}
+
+func (p productTypeDo) Last() (*models.ProductType, error) {
+ if result, err := p.DO.Last(); err != nil {
+ return nil, err
+ } else {
+ return result.(*models.ProductType), nil
+ }
+}
+
+func (p productTypeDo) Find() ([]*models.ProductType, error) {
+ result, err := p.DO.Find()
+ return result.([]*models.ProductType), err
+}
+
+func (p productTypeDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.ProductType, err error) {
+ buf := make([]*models.ProductType, 0, batchSize)
+ err = p.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
+ defer func() { results = append(results, buf...) }()
+ return fc(tx, batch)
+ })
+ return results, err
+}
+
+func (p productTypeDo) FindInBatches(result *[]*models.ProductType, batchSize int, fc func(tx gen.Dao, batch int) error) error {
+ return p.DO.FindInBatches(result, batchSize, fc)
+}
+
+func (p productTypeDo) Attrs(attrs ...field.AssignExpr) IProductTypeDo {
+ return p.withDO(p.DO.Attrs(attrs...))
+}
+
+func (p productTypeDo) Assign(attrs ...field.AssignExpr) IProductTypeDo {
+ return p.withDO(p.DO.Assign(attrs...))
+}
+
+func (p productTypeDo) Joins(fields ...field.RelationField) IProductTypeDo {
+ for _, _f := range fields {
+ p = *p.withDO(p.DO.Joins(_f))
+ }
+ return &p
+}
+
+func (p productTypeDo) Preload(fields ...field.RelationField) IProductTypeDo {
+ for _, _f := range fields {
+ p = *p.withDO(p.DO.Preload(_f))
+ }
+ return &p
+}
+
+func (p productTypeDo) FirstOrInit() (*models.ProductType, error) {
+ if result, err := p.DO.FirstOrInit(); err != nil {
+ return nil, err
+ } else {
+ return result.(*models.ProductType), nil
+ }
+}
+
+func (p productTypeDo) FirstOrCreate() (*models.ProductType, error) {
+ if result, err := p.DO.FirstOrCreate(); err != nil {
+ return nil, err
+ } else {
+ return result.(*models.ProductType), nil
+ }
+}
+
+func (p productTypeDo) FindByPage(offset int, limit int) (result []*models.ProductType, count int64, err error) {
+ result, err = p.Offset(offset).Limit(limit).Find()
+ if err != nil {
+ return
+ }
+
+ if size := len(result); 0 < limit && 0 < size && size < limit {
+ count = int64(size + offset)
+ return
+ }
+
+ count, err = p.Offset(-1).Limit(-1).Count()
+ return
+}
+
+func (p productTypeDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
+ count, err = p.Count()
+ if err != nil {
+ return
+ }
+
+ err = p.Offset(offset).Limit(limit).Scan(result)
+ return
+}
+
+func (p productTypeDo) Scan(result interface{}) (err error) {
+ return p.DO.Scan(result)
+}
+
+func (p productTypeDo) Delete(models ...*models.ProductType) (result gen.ResultInfo, err error) {
+ return p.DO.Delete(models)
+}
+
+func (p *productTypeDo) withDO(do gen.Dao) *productTypeDo {
+ p.DO = *do.(*gen.DO)
+ return p
+}
diff --git a/internal/dal/product_types.gen_test.go b/internal/dal/product_types.gen_test.go
new file mode 100644
index 0000000..3815cd3
--- /dev/null
+++ b/internal/dal/product_types.gen_test.go
@@ -0,0 +1,145 @@
+// Code generated by gorm.io/gen. DO NOT EDIT.
+// Code generated by gorm.io/gen. DO NOT EDIT.
+// Code generated by gorm.io/gen. DO NOT EDIT.
+
+package dal
+
+import (
+ "app/internal/models"
+ "context"
+ "fmt"
+ "testing"
+
+ "gorm.io/gen"
+ "gorm.io/gen/field"
+ "gorm.io/gorm/clause"
+)
+
+func init() {
+ InitializeDB()
+ err := _gen_test_db.AutoMigrate(&models.ProductType{})
+ if err != nil {
+ fmt.Printf("Error: AutoMigrate(&models.ProductType{}) fail: %s", err)
+ }
+}
+
+func Test_productTypeQuery(t *testing.T) {
+ productType := newProductType(_gen_test_db)
+ productType = *productType.As(productType.TableName())
+ _do := productType.WithContext(context.Background()).Debug()
+
+ primaryKey := field.NewString(productType.TableName(), clause.PrimaryKey)
+ _, err := _do.Unscoped().Where(primaryKey.IsNotNull()).Delete()
+ if err != nil {
+ t.Error("clean table fail:", err)
+ return
+ }
+
+ _, ok := productType.GetFieldByName("")
+ if ok {
+ t.Error("GetFieldByName(\"\") from productType success")
+ }
+
+ err = _do.Create(&models.ProductType{})
+ if err != nil {
+ t.Error("create item in table fail:", err)
+ }
+
+ err = _do.Save(&models.ProductType{})
+ if err != nil {
+ t.Error("create item in table fail:", err)
+ }
+
+ err = _do.CreateInBatches([]*models.ProductType{{}, {}}, 10)
+ if err != nil {
+ t.Error("create item in table fail:", err)
+ }
+
+ _, err = _do.Select(productType.ALL).Take()
+ if err != nil {
+ t.Error("Take() on table fail:", err)
+ }
+
+ _, err = _do.First()
+ if err != nil {
+ t.Error("First() on table fail:", err)
+ }
+
+ _, err = _do.Last()
+ if err != nil {
+ t.Error("First() on table fail:", err)
+ }
+
+ _, err = _do.Where(primaryKey.IsNotNull()).FindInBatch(10, func(tx gen.Dao, batch int) error { return nil })
+ if err != nil {
+ t.Error("FindInBatch() on table fail:", err)
+ }
+
+ err = _do.Where(primaryKey.IsNotNull()).FindInBatches(&[]*models.ProductType{}, 10, func(tx gen.Dao, batch int) error { return nil })
+ if err != nil {
+ t.Error("FindInBatches() on table fail:", err)
+ }
+
+ _, err = _do.Select(productType.ALL).Where(primaryKey.IsNotNull()).Order(primaryKey.Desc()).Find()
+ if err != nil {
+ t.Error("Find() on table fail:", err)
+ }
+
+ _, err = _do.Distinct(primaryKey).Take()
+ if err != nil {
+ t.Error("select Distinct() on table fail:", err)
+ }
+
+ _, err = _do.Select(productType.ALL).Omit(primaryKey).Take()
+ if err != nil {
+ t.Error("Omit() on table fail:", err)
+ }
+
+ _, err = _do.Group(primaryKey).Find()
+ if err != nil {
+ t.Error("Group() on table fail:", err)
+ }
+
+ _, err = _do.Scopes(func(dao gen.Dao) gen.Dao { return dao.Where(primaryKey.IsNotNull()) }).Find()
+ if err != nil {
+ t.Error("Scopes() on table fail:", err)
+ }
+
+ _, _, err = _do.FindByPage(0, 1)
+ if err != nil {
+ t.Error("FindByPage() on table fail:", err)
+ }
+
+ _, err = _do.ScanByPage(&models.ProductType{}, 0, 1)
+ if err != nil {
+ t.Error("ScanByPage() on table fail:", err)
+ }
+
+ _, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrInit()
+ if err != nil {
+ t.Error("FirstOrInit() on table fail:", err)
+ }
+
+ _, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrCreate()
+ if err != nil {
+ t.Error("FirstOrCreate() on table fail:", err)
+ }
+
+ var _a _another
+ var _aPK = field.NewString(_a.TableName(), "id")
+
+ err = _do.Join(&_a, primaryKey.EqCol(_aPK)).Scan(map[string]interface{}{})
+ if err != nil {
+ t.Error("Join() on table fail:", err)
+ }
+
+ err = _do.LeftJoin(&_a, primaryKey.EqCol(_aPK)).Scan(map[string]interface{}{})
+ if err != nil {
+ t.Error("LeftJoin() on table fail:", err)
+ }
+
+ _, err = _do.Not().Or().Clauses().Take()
+ if err != nil {
+ t.Error("Not/Or/Clauses on table fail:", err)
+ }
+}
diff --git a/internal/dal/shifts.gen.go b/internal/dal/shifts.gen.go
new file mode 100644
index 0000000..0b7939f
--- /dev/null
+++ b/internal/dal/shifts.gen.go
@@ -0,0 +1,905 @@
+// Code generated by gorm.io/gen. DO NOT EDIT.
+// Code generated by gorm.io/gen. DO NOT EDIT.
+// Code generated by gorm.io/gen. DO NOT EDIT.
+
+package dal
+
+import (
+ "app/internal/models"
+ "context"
+
+ "gorm.io/gorm"
+ "gorm.io/gorm/clause"
+ "gorm.io/gorm/schema"
+
+ "gorm.io/gen"
+ "gorm.io/gen/field"
+
+ "gorm.io/plugin/dbresolver"
+)
+
+func newShift(db *gorm.DB, opts ...gen.DOOption) shift {
+ _shift := shift{}
+
+ _shift.shiftDo.UseDB(db, opts...)
+ _shift.shiftDo.UseModel(&models.Shift{})
+
+ tableName := _shift.shiftDo.TableName()
+ _shift.ALL = field.NewAsterisk(tableName)
+ _shift.Id = field.NewUint(tableName, "id")
+ _shift.Description = field.NewString(tableName, "description")
+ _shift.ProductTypeId = field.NewUint(tableName, "product_type_id")
+ _shift.ProductAmount = field.NewUint(tableName, "product_amount")
+ _shift.ShiftDate = field.NewInt64(tableName, "shift_date")
+ _shift.WorkAreaId = field.NewUint(tableName, "work_area_id")
+ _shift.CreatedAt = field.NewInt64(tableName, "created_at")
+ _shift.ProductType = shiftBelongsToProductType{
+ db: db.Session(&gorm.Session{}),
+
+ RelationField: field.NewRelation("ProductType", "models.ProductType"),
+ }
+
+ _shift.WorkArea = shiftBelongsToWorkArea{
+ db: db.Session(&gorm.Session{}),
+
+ RelationField: field.NewRelation("WorkArea", "models.WorkArea"),
+ Workshop: struct {
+ field.RelationField
+ WorkAreas struct {
+ field.RelationField
+ }
+ Workers struct {
+ field.RelationField
+ Workshop struct {
+ field.RelationField
+ }
+ TeamTasks struct {
+ field.RelationField
+ TeamType struct {
+ field.RelationField
+ }
+ TeamLeader struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ TeamMembers struct {
+ field.RelationField
+ }
+ }
+ }
+ Tasks struct {
+ field.RelationField
+ ProductType struct {
+ field.RelationField
+ }
+ Order struct {
+ field.RelationField
+ ProductType struct {
+ field.RelationField
+ }
+ Customer struct {
+ field.RelationField
+ Orders struct {
+ field.RelationField
+ }
+ }
+ Tasks struct {
+ field.RelationField
+ }
+ }
+ PrepTasks struct {
+ field.RelationField
+ Task struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ }
+ Workshops struct {
+ field.RelationField
+ }
+ }
+ }{
+ RelationField: field.NewRelation("WorkArea.Workshop", "models.Workshop"),
+ WorkAreas: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("WorkArea.Workshop.WorkAreas", "models.WorkArea"),
+ },
+ Workers: struct {
+ field.RelationField
+ Workshop struct {
+ field.RelationField
+ }
+ TeamTasks struct {
+ field.RelationField
+ TeamType struct {
+ field.RelationField
+ }
+ TeamLeader struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ TeamMembers struct {
+ field.RelationField
+ }
+ }
+ }{
+ RelationField: field.NewRelation("WorkArea.Workshop.Workers", "models.Worker"),
+ Workshop: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("WorkArea.Workshop.Workers.Workshop", "models.Workshop"),
+ },
+ TeamTasks: struct {
+ field.RelationField
+ TeamType struct {
+ field.RelationField
+ }
+ TeamLeader struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ TeamMembers struct {
+ field.RelationField
+ }
+ }{
+ RelationField: field.NewRelation("WorkArea.Workshop.Workers.TeamTasks", "models.TeamTask"),
+ TeamType: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("WorkArea.Workshop.Workers.TeamTasks.TeamType", "models.TeamType"),
+ },
+ TeamLeader: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("WorkArea.Workshop.Workers.TeamTasks.TeamLeader", "models.Worker"),
+ },
+ WorkArea: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("WorkArea.Workshop.Workers.TeamTasks.WorkArea", "models.WorkArea"),
+ },
+ TeamMembers: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("WorkArea.Workshop.Workers.TeamTasks.TeamMembers", "models.Worker"),
+ },
+ },
+ },
+ Tasks: struct {
+ field.RelationField
+ ProductType struct {
+ field.RelationField
+ }
+ Order struct {
+ field.RelationField
+ ProductType struct {
+ field.RelationField
+ }
+ Customer struct {
+ field.RelationField
+ Orders struct {
+ field.RelationField
+ }
+ }
+ Tasks struct {
+ field.RelationField
+ }
+ }
+ PrepTasks struct {
+ field.RelationField
+ Task struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ }
+ Workshops struct {
+ field.RelationField
+ }
+ }{
+ RelationField: field.NewRelation("WorkArea.Workshop.Tasks", "models.Task"),
+ ProductType: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("WorkArea.Workshop.Tasks.ProductType", "models.ProductType"),
+ },
+ Order: struct {
+ field.RelationField
+ ProductType struct {
+ field.RelationField
+ }
+ Customer struct {
+ field.RelationField
+ Orders struct {
+ field.RelationField
+ }
+ }
+ Tasks struct {
+ field.RelationField
+ }
+ }{
+ RelationField: field.NewRelation("WorkArea.Workshop.Tasks.Order", "models.Order"),
+ ProductType: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("WorkArea.Workshop.Tasks.Order.ProductType", "models.ProductType"),
+ },
+ Customer: struct {
+ field.RelationField
+ Orders struct {
+ field.RelationField
+ }
+ }{
+ RelationField: field.NewRelation("WorkArea.Workshop.Tasks.Order.Customer", "models.Customer"),
+ Orders: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("WorkArea.Workshop.Tasks.Order.Customer.Orders", "models.Order"),
+ },
+ },
+ Tasks: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("WorkArea.Workshop.Tasks.Order.Tasks", "models.Task"),
+ },
+ },
+ PrepTasks: struct {
+ field.RelationField
+ Task struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ }{
+ RelationField: field.NewRelation("WorkArea.Workshop.Tasks.PrepTasks", "models.PrepTask"),
+ Task: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("WorkArea.Workshop.Tasks.PrepTasks.Task", "models.Task"),
+ },
+ WorkArea: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("WorkArea.Workshop.Tasks.PrepTasks.WorkArea", "models.WorkArea"),
+ },
+ },
+ Workshops: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("WorkArea.Workshop.Tasks.Workshops", "models.Workshop"),
+ },
+ },
+ },
+ PrepTasks: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("WorkArea.PrepTasks", "models.PrepTask"),
+ },
+ Shifts: struct {
+ field.RelationField
+ ProductType struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ }{
+ RelationField: field.NewRelation("WorkArea.Shifts", "models.Shift"),
+ ProductType: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("WorkArea.Shifts.ProductType", "models.ProductType"),
+ },
+ WorkArea: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("WorkArea.Shifts.WorkArea", "models.WorkArea"),
+ },
+ },
+ TeamTasks: struct {
+ field.RelationField
+ }{
+ RelationField: field.NewRelation("WorkArea.TeamTasks", "models.TeamTask"),
+ },
+ }
+
+ _shift.fillFieldMap()
+
+ return _shift
+}
+
+type shift struct {
+ shiftDo
+
+ ALL field.Asterisk
+ Id field.Uint
+ Description field.String
+ ProductTypeId field.Uint
+ ProductAmount field.Uint
+ ShiftDate field.Int64
+ WorkAreaId field.Uint
+ CreatedAt field.Int64
+ ProductType shiftBelongsToProductType
+
+ WorkArea shiftBelongsToWorkArea
+
+ fieldMap map[string]field.Expr
+}
+
+func (s shift) Table(newTableName string) *shift {
+ s.shiftDo.UseTable(newTableName)
+ return s.updateTableName(newTableName)
+}
+
+func (s shift) As(alias string) *shift {
+ s.shiftDo.DO = *(s.shiftDo.As(alias).(*gen.DO))
+ return s.updateTableName(alias)
+}
+
+func (s *shift) updateTableName(table string) *shift {
+ s.ALL = field.NewAsterisk(table)
+ s.Id = field.NewUint(table, "id")
+ s.Description = field.NewString(table, "description")
+ s.ProductTypeId = field.NewUint(table, "product_type_id")
+ s.ProductAmount = field.NewUint(table, "product_amount")
+ s.ShiftDate = field.NewInt64(table, "shift_date")
+ s.WorkAreaId = field.NewUint(table, "work_area_id")
+ s.CreatedAt = field.NewInt64(table, "created_at")
+
+ s.fillFieldMap()
+
+ return s
+}
+
+func (s *shift) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
+ _f, ok := s.fieldMap[fieldName]
+ if !ok || _f == nil {
+ return nil, false
+ }
+ _oe, ok := _f.(field.OrderExpr)
+ return _oe, ok
+}
+
+func (s *shift) fillFieldMap() {
+ s.fieldMap = make(map[string]field.Expr, 9)
+ s.fieldMap["id"] = s.Id
+ s.fieldMap["description"] = s.Description
+ s.fieldMap["product_type_id"] = s.ProductTypeId
+ s.fieldMap["product_amount"] = s.ProductAmount
+ s.fieldMap["shift_date"] = s.ShiftDate
+ s.fieldMap["work_area_id"] = s.WorkAreaId
+ s.fieldMap["created_at"] = s.CreatedAt
+
+}
+
+func (s shift) clone(db *gorm.DB) shift {
+ s.shiftDo.ReplaceConnPool(db.Statement.ConnPool)
+ return s
+}
+
+func (s shift) replaceDB(db *gorm.DB) shift {
+ s.shiftDo.ReplaceDB(db)
+ return s
+}
+
+type shiftBelongsToProductType struct {
+ db *gorm.DB
+
+ field.RelationField
+}
+
+func (a shiftBelongsToProductType) Where(conds ...field.Expr) *shiftBelongsToProductType {
+ if len(conds) == 0 {
+ return &a
+ }
+
+ exprs := make([]clause.Expression, 0, len(conds))
+ for _, cond := range conds {
+ exprs = append(exprs, cond.BeCond().(clause.Expression))
+ }
+ a.db = a.db.Clauses(clause.Where{Exprs: exprs})
+ return &a
+}
+
+func (a shiftBelongsToProductType) WithContext(ctx context.Context) *shiftBelongsToProductType {
+ a.db = a.db.WithContext(ctx)
+ return &a
+}
+
+func (a shiftBelongsToProductType) Session(session *gorm.Session) *shiftBelongsToProductType {
+ a.db = a.db.Session(session)
+ return &a
+}
+
+func (a shiftBelongsToProductType) Model(m *models.Shift) *shiftBelongsToProductTypeTx {
+ return &shiftBelongsToProductTypeTx{a.db.Model(m).Association(a.Name())}
+}
+
+type shiftBelongsToProductTypeTx struct{ tx *gorm.Association }
+
+func (a shiftBelongsToProductTypeTx) Find() (result *models.ProductType, err error) {
+ return result, a.tx.Find(&result)
+}
+
+func (a shiftBelongsToProductTypeTx) Append(values ...*models.ProductType) (err error) {
+ targetValues := make([]interface{}, len(values))
+ for i, v := range values {
+ targetValues[i] = v
+ }
+ return a.tx.Append(targetValues...)
+}
+
+func (a shiftBelongsToProductTypeTx) Replace(values ...*models.ProductType) (err error) {
+ targetValues := make([]interface{}, len(values))
+ for i, v := range values {
+ targetValues[i] = v
+ }
+ return a.tx.Replace(targetValues...)
+}
+
+func (a shiftBelongsToProductTypeTx) Delete(values ...*models.ProductType) (err error) {
+ targetValues := make([]interface{}, len(values))
+ for i, v := range values {
+ targetValues[i] = v
+ }
+ return a.tx.Delete(targetValues...)
+}
+
+func (a shiftBelongsToProductTypeTx) Clear() error {
+ return a.tx.Clear()
+}
+
+func (a shiftBelongsToProductTypeTx) Count() int64 {
+ return a.tx.Count()
+}
+
+type shiftBelongsToWorkArea struct {
+ db *gorm.DB
+
+ field.RelationField
+
+ Workshop struct {
+ field.RelationField
+ WorkAreas struct {
+ field.RelationField
+ }
+ Workers struct {
+ field.RelationField
+ Workshop struct {
+ field.RelationField
+ }
+ TeamTasks struct {
+ field.RelationField
+ TeamType struct {
+ field.RelationField
+ }
+ TeamLeader struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ TeamMembers struct {
+ field.RelationField
+ }
+ }
+ }
+ Tasks struct {
+ field.RelationField
+ ProductType struct {
+ field.RelationField
+ }
+ Order struct {
+ field.RelationField
+ ProductType struct {
+ field.RelationField
+ }
+ Customer struct {
+ field.RelationField
+ Orders struct {
+ field.RelationField
+ }
+ }
+ Tasks struct {
+ field.RelationField
+ }
+ }
+ PrepTasks struct {
+ field.RelationField
+ Task struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ }
+ Workshops struct {
+ field.RelationField
+ }
+ }
+ }
+ PrepTasks struct {
+ field.RelationField
+ }
+ Shifts struct {
+ field.RelationField
+ ProductType struct {
+ field.RelationField
+ }
+ WorkArea struct {
+ field.RelationField
+ }
+ }
+ TeamTasks struct {
+ field.RelationField
+ }
+}
+
+func (a shiftBelongsToWorkArea) Where(conds ...field.Expr) *shiftBelongsToWorkArea {
+ if len(conds) == 0 {
+ return &a
+ }
+
+ exprs := make([]clause.Expression, 0, len(conds))
+ for _, cond := range conds {
+ exprs = append(exprs, cond.BeCond().(clause.Expression))
+ }
+ a.db = a.db.Clauses(clause.Where{Exprs: exprs})
+ return &a
+}
+
+func (a shiftBelongsToWorkArea) WithContext(ctx context.Context) *shiftBelongsToWorkArea {
+ a.db = a.db.WithContext(ctx)
+ return &a
+}
+
+func (a shiftBelongsToWorkArea) Session(session *gorm.Session) *shiftBelongsToWorkArea {
+ a.db = a.db.Session(session)
+ return &a
+}
+
+func (a shiftBelongsToWorkArea) Model(m *models.Shift) *shiftBelongsToWorkAreaTx {
+ return &shiftBelongsToWorkAreaTx{a.db.Model(m).Association(a.Name())}
+}
+
+type shiftBelongsToWorkAreaTx struct{ tx *gorm.Association }
+
+func (a shiftBelongsToWorkAreaTx) Find() (result *models.WorkArea, err error) {
+ return result, a.tx.Find(&result)
+}
+
+func (a shiftBelongsToWorkAreaTx) Append(values ...*models.WorkArea) (err error) {
+ targetValues := make([]interface{}, len(values))
+ for i, v := range values {
+ targetValues[i] = v
+ }
+ return a.tx.Append(targetValues...)
+}
+
+func (a shiftBelongsToWorkAreaTx) Replace(values ...*models.WorkArea) (err error) {
+ targetValues := make([]interface{}, len(values))
+ for i, v := range values {
+ targetValues[i] = v
+ }
+ return a.tx.Replace(targetValues...)
+}
+
+func (a shiftBelongsToWorkAreaTx) Delete(values ...*models.WorkArea) (err error) {
+ targetValues := make([]interface{}, len(values))
+ for i, v := range values {
+ targetValues[i] = v
+ }
+ return a.tx.Delete(targetValues...)
+}
+
+func (a shiftBelongsToWorkAreaTx) Clear() error {
+ return a.tx.Clear()
+}
+
+func (a shiftBelongsToWorkAreaTx) Count() int64 {
+ return a.tx.Count()
+}
+
+type shiftDo struct{ gen.DO }
+
+type IShiftDo interface {
+ gen.SubQuery
+ Debug() IShiftDo
+ WithContext(ctx context.Context) IShiftDo
+ WithResult(fc func(tx gen.Dao)) gen.ResultInfo
+ ReplaceDB(db *gorm.DB)
+ ReadDB() IShiftDo
+ WriteDB() IShiftDo
+ As(alias string) gen.Dao
+ Session(config *gorm.Session) IShiftDo
+ Columns(cols ...field.Expr) gen.Columns
+ Clauses(conds ...clause.Expression) IShiftDo
+ Not(conds ...gen.Condition) IShiftDo
+ Or(conds ...gen.Condition) IShiftDo
+ Select(conds ...field.Expr) IShiftDo
+ Where(conds ...gen.Condition) IShiftDo
+ Order(conds ...field.Expr) IShiftDo
+ Distinct(cols ...field.Expr) IShiftDo
+ Omit(cols ...field.Expr) IShiftDo
+ Join(table schema.Tabler, on ...field.Expr) IShiftDo
+ LeftJoin(table schema.Tabler, on ...field.Expr) IShiftDo
+ RightJoin(table schema.Tabler, on ...field.Expr) IShiftDo
+ Group(cols ...field.Expr) IShiftDo
+ Having(conds ...gen.Condition) IShiftDo
+ Limit(limit int) IShiftDo
+ Offset(offset int) IShiftDo
+ Count() (count int64, err error)
+ Scopes(funcs ...func(gen.Dao) gen.Dao) IShiftDo
+ Unscoped() IShiftDo
+ Create(values ...*models.Shift) error
+ CreateInBatches(values []*models.Shift, batchSize int) error
+ Save(values ...*models.Shift) error
+ First() (*models.Shift, error)
+ Take() (*models.Shift, error)
+ Last() (*models.Shift, error)
+ Find() ([]*models.Shift, error)
+ FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Shift, err error)
+ FindInBatches(result *[]*models.Shift, batchSize int, fc func(tx gen.Dao, batch int) error) error
+ Pluck(column field.Expr, dest interface{}) error
+ Delete(...*models.Shift) (info gen.ResultInfo, err error)
+ Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
+ UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
+ Updates(value interface{}) (info gen.ResultInfo, err error)
+ UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
+ UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
+ UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
+ UpdateFrom(q gen.SubQuery) gen.Dao
+ Attrs(attrs ...field.AssignExpr) IShiftDo
+ Assign(attrs ...field.AssignExpr) IShiftDo
+ Joins(fields ...field.RelationField) IShiftDo
+ Preload(fields ...field.RelationField) IShiftDo
+ FirstOrInit() (*models.Shift, error)
+ FirstOrCreate() (*models.Shift, error)
+ FindByPage(offset int, limit int) (result []*models.Shift, count int64, err error)
+ ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
+ Scan(result interface{}) (err error)
+ Returning(value interface{}, columns ...string) IShiftDo
+ UnderlyingDB() *gorm.DB
+ schema.Tabler
+}
+
+func (s shiftDo) Debug() IShiftDo {
+ return s.withDO(s.DO.Debug())
+}
+
+func (s shiftDo) WithContext(ctx context.Context) IShiftDo {
+ return s.withDO(s.DO.WithContext(ctx))
+}
+
+func (s shiftDo) ReadDB() IShiftDo {
+ return s.Clauses(dbresolver.Read)
+}
+
+func (s shiftDo) WriteDB() IShiftDo {
+ return s.Clauses(dbresolver.Write)
+}
+
+func (s shiftDo) Session(config *gorm.Session) IShiftDo {
+ return s.withDO(s.DO.Session(config))
+}
+
+func (s shiftDo) Clauses(conds ...clause.Expression) IShiftDo {
+ return s.withDO(s.DO.Clauses(conds...))
+}
+
+func (s shiftDo) Returning(value interface{}, columns ...string) IShiftDo {
+ return s.withDO(s.DO.Returning(value, columns...))
+}
+
+func (s shiftDo) Not(conds ...gen.Condition) IShiftDo {
+ return s.withDO(s.DO.Not(conds...))
+}
+
+func (s shiftDo) Or(conds ...gen.Condition) IShiftDo {
+ return s.withDO(s.DO.Or(conds...))
+}
+
+func (s shiftDo) Select(conds ...field.Expr) IShiftDo {
+ return s.withDO(s.DO.Select(conds...))
+}
+
+func (s shiftDo) Where(conds ...gen.Condition) IShiftDo {
+ return s.withDO(s.DO.Where(conds...))
+}
+
+func (s shiftDo) Order(conds ...field.Expr) IShiftDo {
+ return s.withDO(s.DO.Order(conds...))
+}
+
+func (s shiftDo) Distinct(cols ...field.Expr) IShiftDo {
+ return s.withDO(s.DO.Distinct(cols...))
+}
+
+func (s shiftDo) Omit(cols ...field.Expr) IShiftDo {
+ return s.withDO(s.DO.Omit(cols...))
+}
+
+func (s shiftDo) Join(table schema.Tabler, on ...field.Expr) IShiftDo {
+ return s.withDO(s.DO.Join(table, on...))
+}
+
+func (s shiftDo) LeftJoin(table schema.Tabler, on ...field.Expr) IShiftDo {
+ return s.withDO(s.DO.LeftJoin(table, on...))
+}
+
+func (s shiftDo) RightJoin(table schema.Tabler, on ...field.Expr) IShiftDo {
+ return s.withDO(s.DO.RightJoin(table, on...))
+}
+
+func (s shiftDo) Group(cols ...field.Expr) IShiftDo {
+ return s.withDO(s.DO.Group(cols...))
+}
+
+func (s shiftDo) Having(conds ...gen.Condition) IShiftDo {
+ return s.withDO(s.DO.Having(conds...))
+}
+
+func (s shiftDo) Limit(limit int) IShiftDo {
+ return s.withDO(s.DO.Limit(limit))
+}
+
+func (s shiftDo) Offset(offset int) IShiftDo {
+ return s.withDO(s.DO.Offset(offset))
+}
+
+func (s shiftDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IShiftDo {
+ return s.withDO(s.DO.Scopes(funcs...))
+}
+
+func (s shiftDo) Unscoped() IShiftDo {
+ return s.withDO(s.DO.Unscoped())
+}
+
+func (s shiftDo) Create(values ...*models.Shift) error {
+ if len(values) == 0 {
+ return nil
+ }
+ return s.DO.Create(values)
+}
+
+func (s shiftDo) CreateInBatches(values []*models.Shift, batchSize int) error {
+ return s.DO.CreateInBatches(values, batchSize)
+}
+
+// Save : !!! underlying implementation is different with GORM
+// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
+func (s shiftDo) Save(values ...*models.Shift) error {
+ if len(values) == 0 {
+ return nil
+ }
+ return s.DO.Save(values)
+}
+
+func (s shiftDo) First() (*models.Shift, error) {
+ if result, err := s.DO.First(); err != nil {
+ return nil, err
+ } else {
+ return result.(*models.Shift), nil
+ }
+}
+
+func (s shiftDo) Take() (*models.Shift, error) {
+ if result, err := s.DO.Take(); err != nil {
+ return nil, err
+ } else {
+ return result.(*models.Shift), nil
+ }
+}
+
+func (s shiftDo) Last() (*models.Shift, error) {
+ if result, err := s.DO.Last(); err != nil {
+ return nil, err
+ } else {
+ return result.(*models.Shift), nil
+ }
+}
+
+func (s shiftDo) Find() ([]*models.Shift, error) {
+ result, err := s.DO.Find()
+ return result.([]*models.Shift), err
+}
+
+func (s shiftDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Shift, err error) {
+ buf := make([]*models.Shift, 0, batchSize)
+ err = s.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
+ defer func() { results = append(results, buf...) }()
+ return fc(tx, batch)
+ })
+ return results, err
+}
+
+func (s shiftDo) FindInBatches(result *[]*models.Shift, batchSize int, fc func(tx gen.Dao, batch int) error) error {
+ return s.DO.FindInBatches(result, batchSize, fc)
+}
+
+func (s shiftDo) Attrs(attrs ...field.AssignExpr) IShiftDo {
+ return s.withDO(s.DO.Attrs(attrs...))
+}
+
+func (s shiftDo) Assign(attrs ...field.AssignExpr) IShiftDo {
+ return s.withDO(s.DO.Assign(attrs...))
+}
+
+func (s shiftDo) Joins(fields ...field.RelationField) IShiftDo {
+ for _, _f := range fields {
+ s = *s.withDO(s.DO.Joins(_f))
+ }
+ return &s
+}
+
+func (s shiftDo) Preload(fields ...field.RelationField) IShiftDo {
+ for _, _f := range fields {
+ s = *s.withDO(s.DO.Preload(_f))
+ }
+ return &s
+}
+
+func (s shiftDo) FirstOrInit() (*models.Shift, error) {
+ if result, err := s.DO.FirstOrInit(); err != nil {
+ return nil, err
+ } else {
+ return result.(*models.Shift), nil
+ }
+}
+
+func (s shiftDo) FirstOrCreate() (*models.Shift, error) {
+ if result, err := s.DO.FirstOrCreate(); err != nil {
+ return nil, err
+ } else {
+ return result.(*models.Shift), nil
+ }
+}
+
+func (s shiftDo) FindByPage(offset int, limit int) (result []*models.Shift, count int64, err error) {
+ result, err = s.Offset(offset).Limit(limit).Find()
+ if err != nil {
+ return
+ }
+
+ if size := len(result); 0 < limit && 0 < size && size < limit {
+ count = int64(size + offset)
+ return
+ }
+
+ count, err = s.Offset(-1).Limit(-1).Count()
+ return
+}
+
+func (s shiftDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
+ count, err = s.Count()
+ if err != nil {
+ return
+ }
+
+ err = s.Offset(offset).Limit(limit).Scan(result)
+ return
+}
+
+func (s shiftDo) Scan(result interface{}) (err error) {
+ return s.DO.Scan(result)
+}
+
+func (s shiftDo) Delete(models ...*models.Shift) (result gen.ResultInfo, err error) {
+ return s.DO.Delete(models)
+}
+
+func (s *shiftDo) withDO(do gen.Dao) *shiftDo {
+ s.DO = *do.(*gen.DO)
+ return s
+}
diff --git a/internal/dal/shifts.gen_test.go b/internal/dal/shifts.gen_test.go
new file mode 100644
index 0000000..d65570c
--- /dev/null
+++ b/internal/dal/shifts.gen_test.go
@@ -0,0 +1,145 @@
+// Code generated by gorm.io/gen. DO NOT EDIT.
+// Code generated by gorm.io/gen. DO NOT EDIT.
+// Code generated by gorm.io/gen. DO NOT EDIT.
+
+package dal
+
+import (
+ "app/internal/models"
+ "context"
+ "fmt"
+ "testing"
+
+ "gorm.io/gen"
+ "gorm.io/gen/field"
+ "gorm.io/gorm/clause"
+)
+
+func init() {
+ InitializeDB()
+ err := _gen_test_db.AutoMigrate(&models.Shift{})
+ if err != nil {
+ fmt.Printf("Error: AutoMigrate(&models.Shift{}) fail: %s", err)
+ }
+}
+
+func Test_shiftQuery(t *testing.T) {
+ shift := newShift(_gen_test_db)
+ shift = *shift.As(shift.TableName())
+ _do := shift.WithContext(context.Background()).Debug()
+
+ primaryKey := field.NewString(shift.TableName(), clause.PrimaryKey)
+ _, err := _do.Unscoped().Where(primaryKey.IsNotNull()).Delete()
+ if err != nil {
+ t.Error("clean table fail:", err)
+ return
+ }
+
+ _, ok := shift.GetFieldByName("")
+ if ok {
+ t.Error("GetFieldByName(\"\") from shift success")
+ }
+
+ err = _do.Create(&models.Shift{})
+ if err != nil {
+ t.Error("create item in table fail:", err)
+ }
+
+ err = _do.Save(&models.Shift{})
+ if err != nil {
+ t.Error("create item in table fail:", err)
+ }
+
+ err = _do.CreateInBatches([]*models.Shift{{}, {}}, 10)
+ if err != nil {
+ t.Error("create item in table fail:", err)
+ }
+
+ _, err = _do.Select(shift.ALL).Take()
+ if err != nil {
+ t.Error("Take() on table fail:", err)
+ }
+
+ _, err = _do.First()
+ if err != nil {
+ t.Error("First() on table fail:", err)
+ }
+
+ _, err = _do.Last()
+ if err != nil {
+ t.Error("First() on table