Compare commits
16 Commits
dba38f71b1
...
rich_demo
| Author | SHA1 | Date | |
|---|---|---|---|
| 0e90ce769b | |||
| 3f8b548cd0 | |||
| 21f0c44e41 | |||
| 53872ea789 | |||
| e45943e8ca | |||
| 25ee8c2003 | |||
| a7c1c3ed1d | |||
| 2b8df155d3 | |||
| db7076182e | |||
|
|
11b96dc03e | ||
| 9a7c5ca1fe | |||
|
|
33b0eaca3d | ||
| 8924c68005 | |||
| d33e251c7a | |||
| 1e0f2b7f4a | |||
| c1e59e3bb8 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -6,3 +6,6 @@ nto-cli/
|
||||
/**/node_modules/
|
||||
/**/dist/
|
||||
.xlsx
|
||||
build/appimage
|
||||
build/nfpm
|
||||
build/nsis
|
||||
4
.idea/.gigateam/gigateam.properties
generated
4
.idea/.gigateam/gigateam.properties
generated
@@ -1,4 +0,0 @@
|
||||
## changed at Sun Feb 09 09:09:47 KRAT 2025
|
||||
#Sun Feb 09 09:09:47 KRAT 2025
|
||||
com.dtl.jetbrains.utils.IdeaSlowOperationsAssertionUtils.isUnreadDefault=false
|
||||
com.dtl.jetbrains.utils.IdeaSlowOperationsAssertionUtils.defaultValue=false
|
||||
8
.idea/.gitignore
generated
vendored
8
.idea/.gitignore
generated
vendored
@@ -1,8 +0,0 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
4
.idea/boilerplate.iml
generated
Normal file
4
.idea/boilerplate.iml
generated
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module version="4">
|
||||
<component name="Go" enabled="true" />
|
||||
</module>
|
||||
31
.idea/codeStyles/Project.xml
generated
31
.idea/codeStyles/Project.xml
generated
@@ -1,31 +0,0 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<DBN-PSQL>
|
||||
<case-options enabled="true">
|
||||
<option name="KEYWORD_CASE" value="lower" />
|
||||
<option name="FUNCTION_CASE" value="lower" />
|
||||
<option name="PARAMETER_CASE" value="lower" />
|
||||
<option name="DATATYPE_CASE" value="lower" />
|
||||
<option name="OBJECT_CASE" value="preserve" />
|
||||
</case-options>
|
||||
<formatting-settings enabled="false" />
|
||||
</DBN-PSQL>
|
||||
<DBN-SQL>
|
||||
<case-options enabled="true">
|
||||
<option name="KEYWORD_CASE" value="lower" />
|
||||
<option name="FUNCTION_CASE" value="lower" />
|
||||
<option name="PARAMETER_CASE" value="lower" />
|
||||
<option name="DATATYPE_CASE" value="lower" />
|
||||
<option name="OBJECT_CASE" value="preserve" />
|
||||
</case-options>
|
||||
<formatting-settings enabled="false">
|
||||
<option name="STATEMENT_SPACING" value="one_line" />
|
||||
<option name="CLAUSE_CHOP_DOWN" value="chop_down_if_statement_long" />
|
||||
<option name="ITERATION_ELEMENTS_WRAPPING" value="chop_down_if_not_single" />
|
||||
</formatting-settings>
|
||||
</DBN-SQL>
|
||||
<ScalaCodeStyleSettings>
|
||||
<option name="MULTILINE_STRING_CLOSING_QUOTES_ON_NEW_LINE" value="true" />
|
||||
</ScalaCodeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
||||
5
.idea/codeStyles/codeStyleConfig.xml
generated
5
.idea/codeStyles/codeStyleConfig.xml
generated
@@ -1,5 +0,0 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||
</state>
|
||||
</component>
|
||||
405
.idea/dbnavigator.xml
generated
405
.idea/dbnavigator.xml
generated
@@ -1,405 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DBNavigator.Project.DatabaseFileManager">
|
||||
<open-files />
|
||||
</component>
|
||||
<component name="DBNavigator.Project.Settings">
|
||||
<connections />
|
||||
<browser-settings>
|
||||
<general>
|
||||
<display-mode value="TABBED" />
|
||||
<navigation-history-size value="100" />
|
||||
<show-object-details value="false" />
|
||||
<enable-sticky-paths value="true" />
|
||||
</general>
|
||||
<filters>
|
||||
<object-type-filter>
|
||||
<object-type name="SCHEMA" enabled="true" />
|
||||
<object-type name="USER" enabled="true" />
|
||||
<object-type name="ROLE" enabled="true" />
|
||||
<object-type name="PRIVILEGE" enabled="true" />
|
||||
<object-type name="CHARSET" enabled="true" />
|
||||
<object-type name="TABLE" enabled="true" />
|
||||
<object-type name="VIEW" enabled="true" />
|
||||
<object-type name="MATERIALIZED_VIEW" enabled="true" />
|
||||
<object-type name="NESTED_TABLE" enabled="true" />
|
||||
<object-type name="COLUMN" enabled="true" />
|
||||
<object-type name="INDEX" enabled="true" />
|
||||
<object-type name="CONSTRAINT" enabled="true" />
|
||||
<object-type name="DATASET_TRIGGER" enabled="true" />
|
||||
<object-type name="DATABASE_TRIGGER" enabled="true" />
|
||||
<object-type name="SYNONYM" enabled="true" />
|
||||
<object-type name="SEQUENCE" enabled="true" />
|
||||
<object-type name="PROCEDURE" enabled="true" />
|
||||
<object-type name="FUNCTION" enabled="true" />
|
||||
<object-type name="PACKAGE" enabled="true" />
|
||||
<object-type name="TYPE" enabled="true" />
|
||||
<object-type name="TYPE_ATTRIBUTE" enabled="true" />
|
||||
<object-type name="ARGUMENT" enabled="true" />
|
||||
<object-type name="DIMENSION" enabled="true" />
|
||||
<object-type name="CLUSTER" enabled="true" />
|
||||
<object-type name="DBLINK" enabled="true" />
|
||||
</object-type-filter>
|
||||
</filters>
|
||||
<sorting>
|
||||
<object-type name="COLUMN" sorting-type="NAME" />
|
||||
<object-type name="FUNCTION" sorting-type="NAME" />
|
||||
<object-type name="PROCEDURE" sorting-type="NAME" />
|
||||
<object-type name="ARGUMENT" sorting-type="POSITION" />
|
||||
<object-type name="TYPE ATTRIBUTE" sorting-type="POSITION" />
|
||||
</sorting>
|
||||
<default-editors>
|
||||
<object-type name="VIEW" editor-type="SELECTION" />
|
||||
<object-type name="PACKAGE" editor-type="SELECTION" />
|
||||
<object-type name="TYPE" editor-type="SELECTION" />
|
||||
</default-editors>
|
||||
</browser-settings>
|
||||
<navigation-settings>
|
||||
<lookup-filters>
|
||||
<lookup-objects>
|
||||
<object-type name="SCHEMA" enabled="true" />
|
||||
<object-type name="USER" enabled="false" />
|
||||
<object-type name="ROLE" enabled="false" />
|
||||
<object-type name="PRIVILEGE" enabled="false" />
|
||||
<object-type name="CHARSET" enabled="false" />
|
||||
<object-type name="TABLE" enabled="true" />
|
||||
<object-type name="VIEW" enabled="true" />
|
||||
<object-type name="MATERIALIZED VIEW" enabled="true" />
|
||||
<object-type name="INDEX" enabled="true" />
|
||||
<object-type name="CONSTRAINT" enabled="true" />
|
||||
<object-type name="DATASET TRIGGER" enabled="true" />
|
||||
<object-type name="DATABASE TRIGGER" enabled="true" />
|
||||
<object-type name="SYNONYM" enabled="false" />
|
||||
<object-type name="SEQUENCE" enabled="true" />
|
||||
<object-type name="PROCEDURE" enabled="true" />
|
||||
<object-type name="FUNCTION" enabled="true" />
|
||||
<object-type name="PACKAGE" enabled="true" />
|
||||
<object-type name="TYPE" enabled="true" />
|
||||
<object-type name="DIMENSION" enabled="false" />
|
||||
<object-type name="CLUSTER" enabled="false" />
|
||||
<object-type name="DBLINK" enabled="true" />
|
||||
</lookup-objects>
|
||||
<force-database-load value="false" />
|
||||
<prompt-connection-selection value="true" />
|
||||
<prompt-schema-selection value="true" />
|
||||
</lookup-filters>
|
||||
</navigation-settings>
|
||||
<dataset-grid-settings>
|
||||
<general>
|
||||
<enable-zooming value="true" />
|
||||
<enable-column-tooltip value="true" />
|
||||
</general>
|
||||
<sorting>
|
||||
<nulls-first value="true" />
|
||||
<max-sorting-columns value="4" />
|
||||
</sorting>
|
||||
<audit-columns>
|
||||
<column-names value="" />
|
||||
<visible value="true" />
|
||||
<editable value="false" />
|
||||
</audit-columns>
|
||||
</dataset-grid-settings>
|
||||
<dataset-editor-settings>
|
||||
<text-editor-popup>
|
||||
<active value="false" />
|
||||
<active-if-empty value="false" />
|
||||
<data-length-threshold value="100" />
|
||||
<popup-delay value="1000" />
|
||||
</text-editor-popup>
|
||||
<values-actions-popup>
|
||||
<show-popup-button value="true" />
|
||||
<element-count-threshold value="1000" />
|
||||
<data-length-threshold value="250" />
|
||||
</values-actions-popup>
|
||||
<general>
|
||||
<fetch-block-size value="100" />
|
||||
<fetch-timeout value="30" />
|
||||
<trim-whitespaces value="true" />
|
||||
<convert-empty-strings-to-null value="true" />
|
||||
<select-content-on-cell-edit value="true" />
|
||||
<large-value-preview-active value="true" />
|
||||
</general>
|
||||
<filters>
|
||||
<prompt-filter-dialog value="true" />
|
||||
<default-filter-type value="BASIC" />
|
||||
</filters>
|
||||
<qualified-text-editor text-length-threshold="300">
|
||||
<content-types>
|
||||
<content-type name="Text" enabled="true" />
|
||||
<content-type name="Properties" enabled="true" />
|
||||
<content-type name="XML" enabled="true" />
|
||||
<content-type name="DTD" enabled="true" />
|
||||
<content-type name="HTML" enabled="true" />
|
||||
<content-type name="XHTML" enabled="true" />
|
||||
<content-type name="CSS" enabled="true" />
|
||||
<content-type name="Java" enabled="true" />
|
||||
<content-type name="SQL" enabled="true" />
|
||||
<content-type name="PL/SQL" enabled="true" />
|
||||
<content-type name="JavaScript" enabled="true" />
|
||||
<content-type name="JSON" enabled="true" />
|
||||
<content-type name="JSON5" enabled="true" />
|
||||
<content-type name="Groovy" enabled="true" />
|
||||
<content-type name="YAML" enabled="true" />
|
||||
<content-type name="Manifest" enabled="true" />
|
||||
</content-types>
|
||||
</qualified-text-editor>
|
||||
<record-navigation>
|
||||
<navigation-target value="VIEWER" />
|
||||
</record-navigation>
|
||||
</dataset-editor-settings>
|
||||
<code-editor-settings>
|
||||
<general>
|
||||
<show-object-navigation-gutter value="false" />
|
||||
<show-spec-declaration-navigation-gutter value="true" />
|
||||
<enable-spellchecking value="true" />
|
||||
<enable-reference-spellchecking value="false" />
|
||||
</general>
|
||||
<confirmations>
|
||||
<save-changes value="false" />
|
||||
<revert-changes value="true" />
|
||||
<exit-on-changes value="ASK" />
|
||||
</confirmations>
|
||||
</code-editor-settings>
|
||||
<code-completion-settings>
|
||||
<filters>
|
||||
<basic-filter>
|
||||
<filter-element type="RESERVED_WORD" id="keyword" selected="true" />
|
||||
<filter-element type="RESERVED_WORD" id="function" selected="true" />
|
||||
<filter-element type="RESERVED_WORD" id="parameter" selected="true" />
|
||||
<filter-element type="RESERVED_WORD" id="datatype" selected="true" />
|
||||
<filter-element type="RESERVED_WORD" id="exception" selected="true" />
|
||||
<filter-element type="OBJECT" id="schema" selected="true" />
|
||||
<filter-element type="OBJECT" id="role" selected="true" />
|
||||
<filter-element type="OBJECT" id="user" selected="true" />
|
||||
<filter-element type="OBJECT" id="privilege" selected="true" />
|
||||
<user-schema>
|
||||
<filter-element type="OBJECT" id="table" selected="true" />
|
||||
<filter-element type="OBJECT" id="view" selected="true" />
|
||||
<filter-element type="OBJECT" id="materialized view" selected="true" />
|
||||
<filter-element type="OBJECT" id="index" selected="true" />
|
||||
<filter-element type="OBJECT" id="constraint" selected="true" />
|
||||
<filter-element type="OBJECT" id="trigger" selected="true" />
|
||||
<filter-element type="OBJECT" id="synonym" selected="false" />
|
||||
<filter-element type="OBJECT" id="sequence" selected="true" />
|
||||
<filter-element type="OBJECT" id="procedure" selected="true" />
|
||||
<filter-element type="OBJECT" id="function" selected="true" />
|
||||
<filter-element type="OBJECT" id="package" selected="true" />
|
||||
<filter-element type="OBJECT" id="type" selected="true" />
|
||||
<filter-element type="OBJECT" id="dimension" selected="true" />
|
||||
<filter-element type="OBJECT" id="cluster" selected="true" />
|
||||
<filter-element type="OBJECT" id="dblink" selected="true" />
|
||||
</user-schema>
|
||||
<public-schema>
|
||||
<filter-element type="OBJECT" id="table" selected="false" />
|
||||
<filter-element type="OBJECT" id="view" selected="false" />
|
||||
<filter-element type="OBJECT" id="materialized view" selected="false" />
|
||||
<filter-element type="OBJECT" id="index" selected="false" />
|
||||
<filter-element type="OBJECT" id="constraint" selected="false" />
|
||||
<filter-element type="OBJECT" id="trigger" selected="false" />
|
||||
<filter-element type="OBJECT" id="synonym" selected="false" />
|
||||
<filter-element type="OBJECT" id="sequence" selected="false" />
|
||||
<filter-element type="OBJECT" id="procedure" selected="false" />
|
||||
<filter-element type="OBJECT" id="function" selected="false" />
|
||||
<filter-element type="OBJECT" id="package" selected="false" />
|
||||
<filter-element type="OBJECT" id="type" selected="false" />
|
||||
<filter-element type="OBJECT" id="dimension" selected="false" />
|
||||
<filter-element type="OBJECT" id="cluster" selected="false" />
|
||||
<filter-element type="OBJECT" id="dblink" selected="false" />
|
||||
</public-schema>
|
||||
<any-schema>
|
||||
<filter-element type="OBJECT" id="table" selected="true" />
|
||||
<filter-element type="OBJECT" id="view" selected="true" />
|
||||
<filter-element type="OBJECT" id="materialized view" selected="true" />
|
||||
<filter-element type="OBJECT" id="index" selected="true" />
|
||||
<filter-element type="OBJECT" id="constraint" selected="true" />
|
||||
<filter-element type="OBJECT" id="trigger" selected="true" />
|
||||
<filter-element type="OBJECT" id="synonym" selected="true" />
|
||||
<filter-element type="OBJECT" id="sequence" selected="true" />
|
||||
<filter-element type="OBJECT" id="procedure" selected="true" />
|
||||
<filter-element type="OBJECT" id="function" selected="true" />
|
||||
<filter-element type="OBJECT" id="package" selected="true" />
|
||||
<filter-element type="OBJECT" id="type" selected="true" />
|
||||
<filter-element type="OBJECT" id="dimension" selected="true" />
|
||||
<filter-element type="OBJECT" id="cluster" selected="true" />
|
||||
<filter-element type="OBJECT" id="dblink" selected="true" />
|
||||
</any-schema>
|
||||
</basic-filter>
|
||||
<extended-filter>
|
||||
<filter-element type="RESERVED_WORD" id="keyword" selected="true" />
|
||||
<filter-element type="RESERVED_WORD" id="function" selected="true" />
|
||||
<filter-element type="RESERVED_WORD" id="parameter" selected="true" />
|
||||
<filter-element type="RESERVED_WORD" id="datatype" selected="true" />
|
||||
<filter-element type="RESERVED_WORD" id="exception" selected="true" />
|
||||
<filter-element type="OBJECT" id="schema" selected="true" />
|
||||
<filter-element type="OBJECT" id="user" selected="true" />
|
||||
<filter-element type="OBJECT" id="role" selected="true" />
|
||||
<filter-element type="OBJECT" id="privilege" selected="true" />
|
||||
<user-schema>
|
||||
<filter-element type="OBJECT" id="table" selected="true" />
|
||||
<filter-element type="OBJECT" id="view" selected="true" />
|
||||
<filter-element type="OBJECT" id="materialized view" selected="true" />
|
||||
<filter-element type="OBJECT" id="index" selected="true" />
|
||||
<filter-element type="OBJECT" id="constraint" selected="true" />
|
||||
<filter-element type="OBJECT" id="trigger" selected="true" />
|
||||
<filter-element type="OBJECT" id="synonym" selected="true" />
|
||||
<filter-element type="OBJECT" id="sequence" selected="true" />
|
||||
<filter-element type="OBJECT" id="procedure" selected="true" />
|
||||
<filter-element type="OBJECT" id="function" selected="true" />
|
||||
<filter-element type="OBJECT" id="package" selected="true" />
|
||||
<filter-element type="OBJECT" id="type" selected="true" />
|
||||
<filter-element type="OBJECT" id="dimension" selected="true" />
|
||||
<filter-element type="OBJECT" id="cluster" selected="true" />
|
||||
<filter-element type="OBJECT" id="dblink" selected="true" />
|
||||
</user-schema>
|
||||
<public-schema>
|
||||
<filter-element type="OBJECT" id="table" selected="true" />
|
||||
<filter-element type="OBJECT" id="view" selected="true" />
|
||||
<filter-element type="OBJECT" id="materialized view" selected="true" />
|
||||
<filter-element type="OBJECT" id="index" selected="true" />
|
||||
<filter-element type="OBJECT" id="constraint" selected="true" />
|
||||
<filter-element type="OBJECT" id="trigger" selected="true" />
|
||||
<filter-element type="OBJECT" id="synonym" selected="true" />
|
||||
<filter-element type="OBJECT" id="sequence" selected="true" />
|
||||
<filter-element type="OBJECT" id="procedure" selected="true" />
|
||||
<filter-element type="OBJECT" id="function" selected="true" />
|
||||
<filter-element type="OBJECT" id="package" selected="true" />
|
||||
<filter-element type="OBJECT" id="type" selected="true" />
|
||||
<filter-element type="OBJECT" id="dimension" selected="true" />
|
||||
<filter-element type="OBJECT" id="cluster" selected="true" />
|
||||
<filter-element type="OBJECT" id="dblink" selected="true" />
|
||||
</public-schema>
|
||||
<any-schema>
|
||||
<filter-element type="OBJECT" id="table" selected="true" />
|
||||
<filter-element type="OBJECT" id="view" selected="true" />
|
||||
<filter-element type="OBJECT" id="materialized view" selected="true" />
|
||||
<filter-element type="OBJECT" id="index" selected="true" />
|
||||
<filter-element type="OBJECT" id="constraint" selected="true" />
|
||||
<filter-element type="OBJECT" id="trigger" selected="true" />
|
||||
<filter-element type="OBJECT" id="synonym" selected="true" />
|
||||
<filter-element type="OBJECT" id="sequence" selected="true" />
|
||||
<filter-element type="OBJECT" id="procedure" selected="true" />
|
||||
<filter-element type="OBJECT" id="function" selected="true" />
|
||||
<filter-element type="OBJECT" id="package" selected="true" />
|
||||
<filter-element type="OBJECT" id="type" selected="true" />
|
||||
<filter-element type="OBJECT" id="dimension" selected="true" />
|
||||
<filter-element type="OBJECT" id="cluster" selected="true" />
|
||||
<filter-element type="OBJECT" id="dblink" selected="true" />
|
||||
</any-schema>
|
||||
</extended-filter>
|
||||
</filters>
|
||||
<sorting enabled="true">
|
||||
<sorting-element type="RESERVED_WORD" id="keyword" />
|
||||
<sorting-element type="RESERVED_WORD" id="datatype" />
|
||||
<sorting-element type="OBJECT" id="column" />
|
||||
<sorting-element type="OBJECT" id="table" />
|
||||
<sorting-element type="OBJECT" id="view" />
|
||||
<sorting-element type="OBJECT" id="materialized view" />
|
||||
<sorting-element type="OBJECT" id="index" />
|
||||
<sorting-element type="OBJECT" id="constraint" />
|
||||
<sorting-element type="OBJECT" id="trigger" />
|
||||
<sorting-element type="OBJECT" id="synonym" />
|
||||
<sorting-element type="OBJECT" id="sequence" />
|
||||
<sorting-element type="OBJECT" id="procedure" />
|
||||
<sorting-element type="OBJECT" id="function" />
|
||||
<sorting-element type="OBJECT" id="package" />
|
||||
<sorting-element type="OBJECT" id="type" />
|
||||
<sorting-element type="OBJECT" id="dimension" />
|
||||
<sorting-element type="OBJECT" id="cluster" />
|
||||
<sorting-element type="OBJECT" id="dblink" />
|
||||
<sorting-element type="OBJECT" id="schema" />
|
||||
<sorting-element type="OBJECT" id="role" />
|
||||
<sorting-element type="OBJECT" id="user" />
|
||||
<sorting-element type="RESERVED_WORD" id="function" />
|
||||
<sorting-element type="RESERVED_WORD" id="parameter" />
|
||||
</sorting>
|
||||
<format>
|
||||
<enforce-code-style-case value="true" />
|
||||
</format>
|
||||
</code-completion-settings>
|
||||
<execution-engine-settings>
|
||||
<statement-execution>
|
||||
<fetch-block-size value="100" />
|
||||
<execution-timeout value="20" />
|
||||
<debug-execution-timeout value="600" />
|
||||
<focus-result value="false" />
|
||||
<prompt-execution value="false" />
|
||||
</statement-execution>
|
||||
<script-execution>
|
||||
<command-line-interfaces />
|
||||
<execution-timeout value="300" />
|
||||
</script-execution>
|
||||
<method-execution>
|
||||
<execution-timeout value="30" />
|
||||
<debug-execution-timeout value="600" />
|
||||
<parameter-history-size value="10" />
|
||||
</method-execution>
|
||||
</execution-engine-settings>
|
||||
<operation-settings>
|
||||
<transactions>
|
||||
<uncommitted-changes>
|
||||
<on-project-close value="ASK" />
|
||||
<on-disconnect value="ASK" />
|
||||
<on-autocommit-toggle value="ASK" />
|
||||
</uncommitted-changes>
|
||||
<multiple-uncommitted-changes>
|
||||
<on-commit value="ASK" />
|
||||
<on-rollback value="ASK" />
|
||||
</multiple-uncommitted-changes>
|
||||
</transactions>
|
||||
<session-browser>
|
||||
<disconnect-session value="ASK" />
|
||||
<kill-session value="ASK" />
|
||||
<reload-on-filter-change value="false" />
|
||||
</session-browser>
|
||||
<compiler>
|
||||
<compile-type value="KEEP" />
|
||||
<compile-dependencies value="ASK" />
|
||||
<always-show-controls value="false" />
|
||||
</compiler>
|
||||
</operation-settings>
|
||||
<ddl-file-settings>
|
||||
<extensions>
|
||||
<mapping file-type-id="VIEW" extensions="vw" />
|
||||
<mapping file-type-id="TRIGGER" extensions="trg" />
|
||||
<mapping file-type-id="PROCEDURE" extensions="prc" />
|
||||
<mapping file-type-id="FUNCTION" extensions="fnc" />
|
||||
<mapping file-type-id="PACKAGE" extensions="pkg" />
|
||||
<mapping file-type-id="PACKAGE_SPEC" extensions="pks" />
|
||||
<mapping file-type-id="PACKAGE_BODY" extensions="pkb" />
|
||||
<mapping file-type-id="TYPE" extensions="tpe" />
|
||||
<mapping file-type-id="TYPE_SPEC" extensions="tps" />
|
||||
<mapping file-type-id="TYPE_BODY" extensions="tpb" />
|
||||
</extensions>
|
||||
<general>
|
||||
<lookup-ddl-files value="true" />
|
||||
<create-ddl-files value="false" />
|
||||
<synchronize-ddl-files value="true" />
|
||||
<use-qualified-names value="false" />
|
||||
<make-scripts-rerunnable value="true" />
|
||||
</general>
|
||||
</ddl-file-settings>
|
||||
<general-settings>
|
||||
<regional-settings>
|
||||
<date-format value="MEDIUM" />
|
||||
<number-format value="UNGROUPED" />
|
||||
<locale value="SYSTEM_DEFAULT" />
|
||||
<use-custom-formats value="false" />
|
||||
</regional-settings>
|
||||
<environment>
|
||||
<environment-types>
|
||||
<environment-type id="development" name="Development" description="Development environment" color="-2430209/-12296320" readonly-code="false" readonly-data="false" />
|
||||
<environment-type id="integration" name="Integration" description="Integration environment" color="-2621494/-12163514" readonly-code="true" readonly-data="false" />
|
||||
<environment-type id="production" name="Production" description="Productive environment" color="-11574/-10271420" readonly-code="true" readonly-data="true" />
|
||||
<environment-type id="other" name="Other" description="" color="-1576/-10724543" readonly-code="false" readonly-data="false" />
|
||||
</environment-types>
|
||||
<visibility-settings>
|
||||
<connection-tabs value="true" />
|
||||
<dialog-headers value="true" />
|
||||
<object-editor-tabs value="true" />
|
||||
<script-editor-tabs value="false" />
|
||||
<execution-result-tabs value="true" />
|
||||
</visibility-settings>
|
||||
</environment>
|
||||
</general-settings>
|
||||
</component>
|
||||
</project>
|
||||
8
.idea/modules.xml
generated
8
.idea/modules.xml
generated
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/nto_starterkit.iml" filepath="$PROJECT_DIR$/.idea/nto_starterkit.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
9
.idea/nto_starterkit.iml
generated
9
.idea/nto_starterkit.iml
generated
@@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="Go" enabled="true" />
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
2
.idea/vcs.xml
generated
2
.idea/vcs.xml
generated
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
112
.idea/workspace.xml
generated
Normal file
112
.idea/workspace.xml
generated
Normal file
@@ -0,0 +1,112 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AutoImportSettings">
|
||||
<option name="autoReloadType" value="ALL" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="0f2c8145-9000-45fe-a871-9ff0914e0e13" name="Changes" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="FileTemplateManagerImpl">
|
||||
<option name="RECENT_TEMPLATES">
|
||||
<list>
|
||||
<option value="Go File" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="GOROOT" url="file://$USER_HOME$/go/go1.24.1" />
|
||||
<component name="Git.Settings">
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="ProjectCodeStyleSettingsMigration">
|
||||
<option name="version" value="2" />
|
||||
</component>
|
||||
<component name="ProjectColorInfo">{
|
||||
"associatedIndex": 8
|
||||
}</component>
|
||||
<component name="ProjectId" id="2sRWGnZjOMe2yOSS8et0US4qUZq" />
|
||||
<component name="ProjectViewState">
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"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": "rich__demo",
|
||||
"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"
|
||||
}
|
||||
}]]></component>
|
||||
<component name="RecentsManager">
|
||||
<key name="MoveFile.RECENT_KEYS">
|
||||
<recent name="$PROJECT_DIR$/internal/addons/excel" />
|
||||
<recent name="$PROJECT_DIR$/internal/utils" />
|
||||
<recent name="$PROJECT_DIR$/internal/extras" />
|
||||
</key>
|
||||
</component>
|
||||
<component name="RunManager">
|
||||
<configuration name="go build app" type="GoApplicationRunConfiguration" factoryName="Go Application" nameIsGenerated="true">
|
||||
<module name="nto_starterkit" />
|
||||
<working_directory value="$PROJECT_DIR$" />
|
||||
<kind value="PACKAGE" />
|
||||
<package value="app" />
|
||||
<directory value="$PROJECT_DIR$" />
|
||||
<filePath value="$PROJECT_DIR$" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="go build app" type="GoApplicationRunConfiguration" factoryName="Go Application" nameIsGenerated="true">
|
||||
<module name="nto_starterkit" />
|
||||
<working_directory value="$PROJECT_DIR$" />
|
||||
<kind value="PACKAGE" />
|
||||
<package value="app" />
|
||||
<directory value="$PROJECT_DIR$" />
|
||||
<filePath value="$PROJECT_DIR$" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
||||
<component name="SharedIndexes">
|
||||
<attachedChunks>
|
||||
<set>
|
||||
<option value="bundled-gosdk-d297c17c1fbd-57c114c3cede-org.jetbrains.plugins.go.sharedIndexes.bundled-GO-243.25659.52" />
|
||||
<option value="bundled-js-predefined-d6986cc7102b-1632447f56bf-JavaScript-GO-243.25659.52" />
|
||||
</set>
|
||||
</attachedChunks>
|
||||
</component>
|
||||
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
||||
<component name="TaskManager">
|
||||
<task active="true" id="Default" summary="Default task">
|
||||
<changelist id="0f2c8145-9000-45fe-a871-9ff0914e0e13" name="Changes" comment="" />
|
||||
<created>1739066986825</created>
|
||||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1739066986825</updated>
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
<option name="version" value="3" />
|
||||
</component>
|
||||
<component name="VgoProject">
|
||||
<settings-migrated>true</settings-migrated>
|
||||
</component>
|
||||
</project>
|
||||
27
README.md
27
README.md
@@ -6,9 +6,9 @@
|
||||
- [x] Crud service generator (based on gorm gen)
|
||||
- [ ] Easy init without git repository (like create-nto-app)
|
||||
- [x] Excel export
|
||||
- [ ] Models validation logic (callbacks and other stuff)
|
||||
- [x] Models validation logic (callbacks and other stuff)
|
||||
- [ ] Models [linter](https://git.gogacoder.ru/NTO/gormlint)
|
||||
- [ ] Auto-generated frontend
|
||||
- [x] Auto-generated frontend
|
||||
|
||||
## Установка
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
- [UPX](https://github.com/upx/upx/releases/latest) - для сжатия.
|
||||
**Необходимо зазеркалировать с Github и добавить в PATH!!!**
|
||||
- [Git](https://git-scm.com/)
|
||||
- Wails3:`go install -v github.com/wailsapp/wails/v3/cmd/wails3@latest`
|
||||
- Wails3
|
||||
- MinGw-64: https://jmeubank.github.io/tdm-gcc/
|
||||
**Необходимо зазеркалировать с Github!!!**
|
||||
|
||||
@@ -34,9 +34,6 @@
|
||||
wails3 dev
|
||||
```
|
||||
|
||||
DevServer также можно открыть по адресу http://localhost:34115.
|
||||
Этот инструмент предоставляет возможность вызывать Go код прямо из инструментов разработчика.
|
||||
|
||||
### Генерация TS биндингов
|
||||
|
||||
Для обновления API для TypeScript используйте команду:
|
||||
@@ -45,14 +42,32 @@ DevServer также можно открыть по адресу http://localhos
|
||||
wails3 generate bindings -ts
|
||||
```
|
||||
|
||||
## Начало работы
|
||||
Установите следующие утилиты перед началом работы:
|
||||
```shell
|
||||
go install -v github.com/wailsapp/wails/v3/cmd/wails3@latest
|
||||
```
|
||||
```shell
|
||||
go install github.com/opbnq-q/nto-cli@latest
|
||||
```
|
||||
```shell
|
||||
go install git.gogacoder.ru/NTO/crudgen/cmd/crudgen@latest
|
||||
```
|
||||
|
||||
## Сборка
|
||||
|
||||
Для финальной сборки запустите эту команду в директории проекта:
|
||||
|
||||
На Linux/Mac OS:
|
||||
```
|
||||
PRODUCTION=true wails3 build
|
||||
```
|
||||
|
||||
На Windows:
|
||||
```
|
||||
$env:PRODUCTION="true"; wails3 build
|
||||
```
|
||||
|
||||
**Перед релизом не забыть**:
|
||||
- убедиться, что дефолтные данные правильные
|
||||
- убедиться, что приложение запускается
|
||||
|
||||
@@ -10,6 +10,7 @@ tasks:
|
||||
- ../dal/*.go
|
||||
cmds:
|
||||
- go run gen.go
|
||||
method: none
|
||||
|
||||
go:gen:crudgen:
|
||||
summary: Runs crudgen for crud generating
|
||||
@@ -21,6 +22,7 @@ tasks:
|
||||
- go:gen:dal
|
||||
cmds:
|
||||
- crudgen -p internal
|
||||
method: none
|
||||
|
||||
go:mod:tidy:
|
||||
summary: Runs `go mod tidy`
|
||||
|
||||
@@ -13,7 +13,7 @@ tasks:
|
||||
cmds:
|
||||
- go build {{.BUILD_FLAGS}} -o {{.BIN_DIR}}/{{.APP_NAME}}
|
||||
vars:
|
||||
BUILD_FLAGS: '{{if eq .PRODUCTION "true"}}-tags "production sqlite_icu" -trimpath -ldflags="-w -s"{{else}}-gcflags=all="-l" -tags "sqlite_icu"{{end}}'
|
||||
BUILD_FLAGS: '{{if eq .PRODUCTION "true"}}-tags "production" -trimpath -ldflags="-w -s"{{else}}-gcflags=all="-l" {{end}}'
|
||||
env:
|
||||
GOOS: darwin
|
||||
CGO_ENABLED: 1
|
||||
|
||||
@@ -13,7 +13,7 @@ tasks:
|
||||
cmds:
|
||||
- go build {{.BUILD_FLAGS}} -o {{.BIN_DIR}}/{{.APP_NAME}}
|
||||
vars:
|
||||
BUILD_FLAGS: '{{if eq .PRODUCTION "true"}}-tags "production sqlite_icu" -trimpath -ldflags="-w -s"{{else}}-gcflags=all="-l" -tags "sqlite_icu" {{end}}'
|
||||
BUILD_FLAGS: '{{if eq .PRODUCTION "true"}}-tags "production" -trimpath -ldflags="-w -s"{{else}}-gcflags=all="-l" {{end}}'
|
||||
env:
|
||||
GOOS: linux
|
||||
CGO_ENABLED: 1
|
||||
|
||||
@@ -18,10 +18,10 @@ tasks:
|
||||
- cmd: rm -f *.syso
|
||||
platforms: [linux, darwin]
|
||||
vars:
|
||||
BUILD_FLAGS: '{{if eq .PRODUCTION "true"}}-tags "production sqlite_icu" -trimpath -ldflags="-w -s -H windowsgui"{{else}}-gcflags=all="-l" -tags "sqlite_icu"{{end}}'
|
||||
BUILD_FLAGS: '{{if eq .PRODUCTION "true"}}-tags "production" -trimpath -ldflags="-w -s -H windowsgui"{{else}}-gcflags=all="-l" {{end}}'
|
||||
env:
|
||||
GOOS: windows
|
||||
CGO_ENABLED: 1
|
||||
CGO_ENABLED: 0
|
||||
GOARCH: '{{.ARCH | default ARCH}}'
|
||||
PRODUCTION: '{{.PRODUCTION | default "false"}}'
|
||||
|
||||
|
||||
@@ -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<Author> = {}) {
|
||||
/** Creates a new Customer instance. */
|
||||
constructor($$source: Partial<Customer> = {}) {
|
||||
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<Author>);
|
||||
return new Customer($$parsedSource as Partial<Customer>);
|
||||
}
|
||||
}
|
||||
|
||||
export class Comment {
|
||||
export class Order {
|
||||
"Id": number;
|
||||
"Text": string;
|
||||
"AuthorId": number;
|
||||
"Author": Author;
|
||||
"Posts": Post[];
|
||||
|
||||
/** Creates a new Comment instance. */
|
||||
constructor($$source: Partial<Comment> = {}) {
|
||||
if (!("Id" in $$source)) {
|
||||
this["Id"] = 0;
|
||||
}
|
||||
if (!("Text" in $$source)) {
|
||||
this["Text"] = "";
|
||||
}
|
||||
if (!("AuthorId" in $$source)) {
|
||||
this["AuthorId"] = 0;
|
||||
}
|
||||
if (!("Author" in $$source)) {
|
||||
this["Author"] = (new Author());
|
||||
}
|
||||
if (!("Posts" in $$source)) {
|
||||
this["Posts"] = [];
|
||||
}
|
||||
|
||||
Object.assign(this, $$source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Comment instance from a string or object.
|
||||
*/
|
||||
static createFrom($$source: any = {}): Comment {
|
||||
const $$createField3_0 = $$createType4;
|
||||
const $$createField4_0 = $$createType1;
|
||||
let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
|
||||
if ("Author" in $$parsedSource) {
|
||||
$$parsedSource["Author"] = $$createField3_0($$parsedSource["Author"]);
|
||||
}
|
||||
if ("Posts" in $$parsedSource) {
|
||||
$$parsedSource["Posts"] = $$createField4_0($$parsedSource["Posts"]);
|
||||
}
|
||||
return new Comment($$parsedSource as Partial<Comment>);
|
||||
}
|
||||
}
|
||||
|
||||
export class Post {
|
||||
"Id": number;
|
||||
"Text": string;
|
||||
"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<Post> = {}) {
|
||||
/** Creates a new Order instance. */
|
||||
constructor($$source: Partial<Order> = {}) {
|
||||
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<Post>);
|
||||
return new Order($$parsedSource as Partial<Order>);
|
||||
}
|
||||
}
|
||||
|
||||
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<PrepTask> = {}) {
|
||||
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<PrepTask>);
|
||||
}
|
||||
}
|
||||
|
||||
export class ProductType {
|
||||
"Id": number;
|
||||
"Name": string;
|
||||
|
||||
/** Creates a new PostType instance. */
|
||||
constructor($$source: Partial<PostType> = {}) {
|
||||
/** Creates a new ProductType instance. */
|
||||
constructor($$source: Partial<ProductType> = {}) {
|
||||
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<PostType>);
|
||||
return new ProductType($$parsedSource as Partial<ProductType>);
|
||||
}
|
||||
}
|
||||
|
||||
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<Shift> = {}) {
|
||||
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<Shift>);
|
||||
}
|
||||
}
|
||||
|
||||
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<Task> = {}) {
|
||||
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<Task>);
|
||||
}
|
||||
}
|
||||
|
||||
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<TeamTask> = {}) {
|
||||
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<TeamTask>);
|
||||
}
|
||||
}
|
||||
|
||||
export class TeamType {
|
||||
"Id": number;
|
||||
"Name": string;
|
||||
|
||||
/** Creates a new TeamType instance. */
|
||||
constructor($$source: Partial<TeamType> = {}) {
|
||||
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<TeamType>);
|
||||
}
|
||||
}
|
||||
|
||||
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<WorkArea> = {}) {
|
||||
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<WorkArea>);
|
||||
}
|
||||
}
|
||||
|
||||
export class Worker {
|
||||
"Id": number;
|
||||
"Name": string;
|
||||
"TeamTasks": (TeamTask | null)[];
|
||||
"Workshop": Workshop;
|
||||
"WorkshopId": number;
|
||||
|
||||
/** Creates a new Worker instance. */
|
||||
constructor($$source: Partial<Worker> = {}) {
|
||||
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<Worker>);
|
||||
}
|
||||
}
|
||||
|
||||
export class Workshop {
|
||||
"Id": number;
|
||||
"Name": string;
|
||||
"WorkAreas": WorkArea[];
|
||||
"Tasks": (Task | null)[];
|
||||
"Workers": Worker[];
|
||||
|
||||
/** Creates a new Workshop instance. */
|
||||
constructor($$source: Partial<Workshop> = {}) {
|
||||
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<Workshop>);
|
||||
}
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
86
frontend/bindings/app/internal/services/customerservice.ts
Normal file
86
frontend/bindings/app/internal/services/customerservice.ts
Normal file
@@ -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<number> & { 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<void> & { 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);
|
||||
@@ -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";
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -8,18 +8,21 @@ 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<number> & { 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;
|
||||
@@ -28,12 +31,12 @@ export function Create(item: $models.Comment): Promise<$models.Comment> & { canc
|
||||
}
|
||||
|
||||
export function Delete(id: number): Promise<void> & { 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;
|
||||
@@ -41,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;
|
||||
@@ -50,8 +53,8 @@ export function GetById(id: number): Promise<$models.Comment | null> & { cancel(
|
||||
return $typingPromise;
|
||||
}
|
||||
|
||||
export function SortedByOrder(fieldsSortOrder: { [_: string]: string }): Promise<($models.Comment | null)[]> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(4244533291, fieldsSortOrder) 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;
|
||||
@@ -59,8 +62,17 @@ export function SortedByOrder(fieldsSortOrder: { [_: string]: string }): Promise
|
||||
return $typingPromise;
|
||||
}
|
||||
|
||||
export function Update(item: $models.Comment): Promise<$models.Comment> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(3080970936, item) 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;
|
||||
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
|
||||
return $typingPromise;
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -69,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);
|
||||
@@ -8,18 +8,21 @@ 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<number> & { 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;
|
||||
@@ -28,12 +31,12 @@ export function Create(item: $models.PostType): Promise<$models.PostType> & { ca
|
||||
}
|
||||
|
||||
export function Delete(id: number): Promise<void> & { 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;
|
||||
@@ -41,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;
|
||||
@@ -50,8 +53,8 @@ export function GetById(id: number): Promise<$models.PostType | null> & { cancel
|
||||
return $typingPromise;
|
||||
}
|
||||
|
||||
export function SortedByOrder(fieldsSortOrder: { [_: string]: string }): Promise<($models.PostType | null)[]> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(1097313920, fieldsSortOrder) 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;
|
||||
@@ -59,8 +62,17 @@ export function SortedByOrder(fieldsSortOrder: { [_: string]: string }): Promise
|
||||
return $typingPromise;
|
||||
}
|
||||
|
||||
export function Update(item: $models.PostType): Promise<$models.PostType> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(2773888269, item) 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;
|
||||
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
|
||||
return $typingPromise;
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -69,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);
|
||||
@@ -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<number> & { 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<void> & { 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);
|
||||
86
frontend/bindings/app/internal/services/shiftservice.ts
Normal file
86
frontend/bindings/app/internal/services/shiftservice.ts
Normal file
@@ -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<number> & { 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<void> & { 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);
|
||||
@@ -8,18 +8,21 @@ 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<number> & { 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;
|
||||
@@ -28,12 +31,12 @@ export function Create(item: $models.Post): Promise<$models.Post> & { cancel():
|
||||
}
|
||||
|
||||
export function Delete(id: number): Promise<void> & { 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;
|
||||
@@ -41,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;
|
||||
@@ -50,8 +53,8 @@ export function GetById(id: number): Promise<$models.Post | null> & { cancel():
|
||||
return $typingPromise;
|
||||
}
|
||||
|
||||
export function SortedByOrder(fieldsSortOrder: { [_: string]: string }): Promise<($models.Post | null)[]> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(471862744, fieldsSortOrder) 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;
|
||||
@@ -59,8 +62,17 @@ export function SortedByOrder(fieldsSortOrder: { [_: string]: string }): Promise
|
||||
return $typingPromise;
|
||||
}
|
||||
|
||||
export function Update(item: $models.Post): Promise<$models.Post> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(137798821, item) 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;
|
||||
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
|
||||
return $typingPromise;
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -69,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);
|
||||
86
frontend/bindings/app/internal/services/teamtaskservice.ts
Normal file
86
frontend/bindings/app/internal/services/teamtaskservice.ts
Normal file
@@ -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<number> & { 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<void> & { 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);
|
||||
86
frontend/bindings/app/internal/services/teamtypeservice.ts
Normal file
86
frontend/bindings/app/internal/services/teamtypeservice.ts
Normal file
@@ -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<number> & { 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<void> & { 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);
|
||||
86
frontend/bindings/app/internal/services/workareaservice.ts
Normal file
86
frontend/bindings/app/internal/services/workareaservice.ts
Normal file
@@ -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<number> & { 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<void> & { 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);
|
||||
@@ -8,18 +8,21 @@ 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<number> & { 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;
|
||||
@@ -28,12 +31,12 @@ export function Create(item: $models.Author): Promise<$models.Author> & { cancel
|
||||
}
|
||||
|
||||
export function Delete(id: number): Promise<void> & { 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;
|
||||
@@ -41,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;
|
||||
@@ -50,8 +53,8 @@ export function GetById(id: number): Promise<$models.Author | null> & { cancel()
|
||||
return $typingPromise;
|
||||
}
|
||||
|
||||
export function SortedByOrder(fieldsSortOrder: { [_: string]: string }): Promise<($models.Author | null)[]> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(3046628691, fieldsSortOrder) 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;
|
||||
@@ -59,8 +62,17 @@ export function SortedByOrder(fieldsSortOrder: { [_: string]: string }): Promise
|
||||
return $typingPromise;
|
||||
}
|
||||
|
||||
export function Update(item: $models.Author): Promise<$models.Author> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(2240704960, item) 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;
|
||||
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
|
||||
return $typingPromise;
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -69,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);
|
||||
86
frontend/bindings/app/internal/services/workshopservice.ts
Normal file
86
frontend/bindings/app/internal/services/workshopservice.ts
Normal file
@@ -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<number> & { 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<void> & { 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);
|
||||
4
frontend/bindings/app/internal/utils/index.ts
Normal file
4
frontend/bindings/app/internal/utils/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
|
||||
// This file is automatically generated. DO NOT EDIT
|
||||
|
||||
export * from "./models.js";
|
||||
31
frontend/bindings/app/internal/utils/models.ts
Normal file
31
frontend/bindings/app/internal/utils/models.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
|
||||
// This file is automatically generated. DO NOT EDIT
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore: Unused imports
|
||||
import {Create as $Create} from "@wailsio/runtime";
|
||||
|
||||
export class SortField {
|
||||
"Name": string;
|
||||
"Order": string;
|
||||
|
||||
/** Creates a new SortField instance. */
|
||||
constructor($$source: Partial<SortField> = {}) {
|
||||
if (!("Name" in $$source)) {
|
||||
this["Name"] = "";
|
||||
}
|
||||
if (!("Order" in $$source)) {
|
||||
this["Order"] = "";
|
||||
}
|
||||
|
||||
Object.assign(this, $$source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new SortField instance from a string or object.
|
||||
*/
|
||||
static createFrom($$source: any = {}): SortField {
|
||||
let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
|
||||
return new SortField($$parsedSource as Partial<SortField>);
|
||||
}
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import Table from "../table/Table.vue";
|
||||
import { onMounted, reactive } from "vue";
|
||||
import { getDefaultValues } from "../utils/structs/defaults.util";
|
||||
import Service from "./author.service.ts";
|
||||
import type { Scheme } from "../types/scheme.type";
|
||||
import { Author } from "../../bindings/app/internal/services";
|
||||
import { SortedByOrder } from "../../bindings/app/internal/services/authorservice.ts";
|
||||
import { ref } from "vue";
|
||||
import type { Validate } from "../types/validate.type";
|
||||
|
||||
import PostService from "../post/post.service.ts";
|
||||
const postService = new PostService();
|
||||
|
||||
import CommentService from "../comment/comment.service.ts";
|
||||
const commentService = new CommentService();
|
||||
|
||||
const service = new Service();
|
||||
|
||||
const items = ref<Author[]>([]);
|
||||
|
||||
const load = async () => {
|
||||
(scheme as any).Posts.type!.nested!.values = await postService.readAll();
|
||||
|
||||
(scheme as any).Comments.type!.nested!.values =
|
||||
await commentService.readAll();
|
||||
|
||||
items.value = await service.readAll();
|
||||
return items.value;
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
await load();
|
||||
});
|
||||
|
||||
const scheme: Scheme<Author> = reactive({
|
||||
entityId: "AuthorId",
|
||||
|
||||
Id: {
|
||||
hidden: true,
|
||||
type: {
|
||||
primitive: "number",
|
||||
},
|
||||
},
|
||||
|
||||
Name: {
|
||||
russian: "Имя",
|
||||
type: {
|
||||
primitive: "string",
|
||||
},
|
||||
},
|
||||
|
||||
Posts: {
|
||||
russian: "Посты",
|
||||
many: true,
|
||||
type: {
|
||||
nested: {
|
||||
values: [],
|
||||
field: ["Text"],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Comments: {
|
||||
russian: "Комментарии",
|
||||
many: true,
|
||||
type: {
|
||||
nested: {
|
||||
values: [],
|
||||
field: ["Text"],
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const getDefaults = () => getDefaultValues(scheme);
|
||||
|
||||
const validate: Validate<Author> = (entity) => {
|
||||
return {
|
||||
status: "success",
|
||||
};
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main class="w-screen h-screen">
|
||||
<Table name="Author" :scheme :service :get-defaults :load :items :validate></Table>
|
||||
</main>
|
||||
</template>
|
||||
@@ -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<Author> {
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import Table from "../table/Table.vue";
|
||||
import { onMounted, reactive } from "vue";
|
||||
import { getDefaultValues } from "../utils/structs/defaults.util";
|
||||
import Service from "./comment.service.ts";
|
||||
import type { Scheme } from "../types/scheme.type";
|
||||
import { Comment } from "../../bindings/app/internal/services";
|
||||
import { ref } from "vue";
|
||||
import type { Validate } from "../types/validate.type";
|
||||
|
||||
import AuthorService from "../author/author.service.ts";
|
||||
const authorService = new AuthorService();
|
||||
|
||||
import PostService from "../post/post.service.ts";
|
||||
const postService = new PostService();
|
||||
|
||||
const service = new Service();
|
||||
|
||||
const items = ref<Comment[]>([]);
|
||||
|
||||
const load = async () => {
|
||||
(scheme as any).Author.type!.nested!.values = await authorService.readAll();
|
||||
|
||||
(scheme as any).Posts.type!.nested!.values = await postService.readAll();
|
||||
|
||||
items.value = await service.readAll();
|
||||
return items.value;
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
load();
|
||||
});
|
||||
|
||||
const scheme: Scheme<Comment> = reactive({
|
||||
entityId: "CommentId",
|
||||
|
||||
Id: {
|
||||
hidden: true,
|
||||
type: {
|
||||
primitive: "number",
|
||||
},
|
||||
},
|
||||
|
||||
Text: {
|
||||
russian: "Текст",
|
||||
type: {
|
||||
primitive: "string",
|
||||
},
|
||||
},
|
||||
|
||||
AuthorId: {
|
||||
hidden: true,
|
||||
type: {
|
||||
primitive: "number",
|
||||
},
|
||||
},
|
||||
|
||||
Author: {
|
||||
russian: "Автор",
|
||||
type: {
|
||||
nested: {
|
||||
values: [],
|
||||
field: ["Name"],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Posts: {
|
||||
russian: "Посты",
|
||||
many: true,
|
||||
type: {
|
||||
nested: {
|
||||
values: [],
|
||||
field: ["Text"],
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const getDefaults = () => getDefaultValues(scheme);
|
||||
|
||||
const validate: Validate<Comment> = (entity) => {
|
||||
return {
|
||||
status: "success",
|
||||
};
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main class="w-screen h-screen">
|
||||
<Table :scheme :service :get-defaults :load :items :validate></Table>
|
||||
</main>
|
||||
</template>
|
||||
@@ -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<Comment> {
|
||||
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();
|
||||
}
|
||||
}
|
||||
95
frontend/src/customer/CustomerScheme.vue
Normal file
95
frontend/src/customer/CustomerScheme.vue
Normal file
@@ -0,0 +1,95 @@
|
||||
<script setup lang="ts">
|
||||
import Table from "../table/Table.vue";
|
||||
import { onMounted, reactive } from "vue";
|
||||
import { getDefaultValues } from "../utils/structs/defaults.util";
|
||||
import Service from "./customer.service";
|
||||
import type { Scheme } from "../types/scheme.type";
|
||||
import { Customer } from "../../bindings/app/internal/services";
|
||||
import { ref } from "vue";
|
||||
import type { Validate } from "../types/validate.type";
|
||||
import { getDefaultSortOptions } from "../utils/structs/default-sort-options.util";
|
||||
|
||||
import OrderService from "../order/order.service";
|
||||
const orderService = new OrderService();
|
||||
|
||||
const service = new Service();
|
||||
|
||||
const items = ref<Customer[]>([]);
|
||||
|
||||
const load = async () => {
|
||||
(scheme as any).Orders.type!.nested!.values = await orderService.readAll();
|
||||
|
||||
items.value = await service.sort(sortOptions.value);
|
||||
return items.value;
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
load();
|
||||
});
|
||||
|
||||
const scheme: Scheme<Customer> = reactive({
|
||||
entityId: "CustomerId",
|
||||
|
||||
Id: {
|
||||
russian: "ID",
|
||||
readonly: true,
|
||||
type: {
|
||||
primitive: "number",
|
||||
},
|
||||
},
|
||||
|
||||
Title: {
|
||||
russian: "Название",
|
||||
type: {
|
||||
primitive: "string",
|
||||
},
|
||||
},
|
||||
|
||||
Contact: {
|
||||
russian: "Контакт",
|
||||
type: {
|
||||
primitive: "string",
|
||||
},
|
||||
},
|
||||
|
||||
Orders: {
|
||||
hidden: true,
|
||||
many: true,
|
||||
type: {
|
||||
nested: {
|
||||
values: [],
|
||||
field: [""],
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const getDefaults = () => getDefaultValues(scheme);
|
||||
|
||||
const validate: Validate<Customer> = (entity) => {
|
||||
return {
|
||||
status: "success",
|
||||
};
|
||||
};
|
||||
|
||||
const search = async (input: string) => {
|
||||
items.value = await service.search(input);
|
||||
};
|
||||
|
||||
const sortOptions = ref(getDefaultSortOptions(scheme));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main class="w-screen h-screen">
|
||||
<Table
|
||||
:scheme
|
||||
:service
|
||||
:get-defaults
|
||||
:load
|
||||
:items
|
||||
:validate
|
||||
@on-search="search"
|
||||
v-model:sort-options="sortOptions"
|
||||
></Table>
|
||||
</main>
|
||||
</template>
|
||||
52
frontend/src/customer/customer.service.ts
Normal file
52
frontend/src/customer/customer.service.ts
Normal file
@@ -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<Customer> {
|
||||
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<Customer>) {
|
||||
return (await SortedByOrder(
|
||||
Object.entries(options).map((item) => ({
|
||||
Name: item[0],
|
||||
Order: item[1],
|
||||
})),
|
||||
)) as Customer[];
|
||||
}
|
||||
}
|
||||
165
frontend/src/order/OrderScheme.vue
Normal file
165
frontend/src/order/OrderScheme.vue
Normal file
@@ -0,0 +1,165 @@
|
||||
<script setup lang="ts">
|
||||
import Table from "../table/Table.vue";
|
||||
import { onMounted, reactive } from "vue";
|
||||
import { getDefaultValues } from "../utils/structs/defaults.util";
|
||||
import Service from "./order.service";
|
||||
import type { Scheme } from "../types/scheme.type";
|
||||
import { Order } from "../../bindings/app/internal/services";
|
||||
import { ref } from "vue";
|
||||
import type { Validate } from "../types/validate.type";
|
||||
import { getDefaultSortOptions } from "../utils/structs/default-sort-options.util";
|
||||
|
||||
import ProducttypeService from "../producttype/producttype.service";
|
||||
const producttypeService = new ProducttypeService();
|
||||
|
||||
import CustomerService from "../customer/customer.service";
|
||||
const customerService = new CustomerService();
|
||||
|
||||
import TaskService from "../task/task.service";
|
||||
const taskService = new TaskService();
|
||||
|
||||
const service = new Service();
|
||||
|
||||
const items = ref<Order[]>([]);
|
||||
|
||||
const load = async () => {
|
||||
(scheme as any).ProductType.type!.nested!.values =
|
||||
await producttypeService.readAll();
|
||||
|
||||
(scheme as any).Customer.type!.nested!.values =
|
||||
await customerService.readAll();
|
||||
|
||||
(scheme as any).Tasks.type!.nested!.values = await taskService.readAll();
|
||||
|
||||
items.value = await service.sort(sortOptions.value);
|
||||
return items.value;
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
load();
|
||||
});
|
||||
|
||||
const scheme: Scheme<Order> = reactive({
|
||||
entityId: "OrderId",
|
||||
|
||||
Id: {
|
||||
russian: "ID",
|
||||
readonly: true,
|
||||
type: {
|
||||
primitive: "number",
|
||||
},
|
||||
},
|
||||
|
||||
Status: {
|
||||
russian: "Статус",
|
||||
type: {
|
||||
primitive: "string",
|
||||
},
|
||||
},
|
||||
|
||||
Description: {
|
||||
russian: "Описание",
|
||||
type: {
|
||||
primitive: "string",
|
||||
},
|
||||
},
|
||||
|
||||
ProductTypeId: {
|
||||
hidden: true,
|
||||
type: {
|
||||
primitive: "number",
|
||||
},
|
||||
},
|
||||
|
||||
ProductType: {
|
||||
russian: "Тип",
|
||||
type: {
|
||||
nested: {
|
||||
values: [],
|
||||
field: ["Name"],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
ProductAmount: {
|
||||
russian: "Количество продукции",
|
||||
type: {
|
||||
primitive: "number",
|
||||
},
|
||||
},
|
||||
|
||||
CustomerId: {
|
||||
hidden: true,
|
||||
type: {
|
||||
primitive: "number",
|
||||
},
|
||||
},
|
||||
|
||||
Customer: {
|
||||
russian: "Клиент",
|
||||
type: {
|
||||
nested: {
|
||||
values: [],
|
||||
field: ["Title"],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Tasks: {
|
||||
hidden: true,
|
||||
many: true,
|
||||
type: {
|
||||
nested: {
|
||||
values: [],
|
||||
field: [""],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
CreatedAt: {
|
||||
russian: "Дата создания",
|
||||
readonly: true,
|
||||
date: true,
|
||||
type: {
|
||||
primitive: "date",
|
||||
},
|
||||
},
|
||||
|
||||
DeadlineDate: {
|
||||
russian: "Крайний срок",
|
||||
date: true,
|
||||
type: {
|
||||
primitive: "date",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const getDefaults = () => getDefaultValues(scheme);
|
||||
|
||||
const validate: Validate<Order> = (entity) => {
|
||||
return {
|
||||
status: "success",
|
||||
};
|
||||
};
|
||||
|
||||
const search = async (input: string) => {
|
||||
items.value = await service.search(input);
|
||||
};
|
||||
|
||||
const sortOptions = ref(getDefaultSortOptions(scheme));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main class="w-screen h-screen">
|
||||
<Table
|
||||
:scheme
|
||||
:service
|
||||
:get-defaults
|
||||
:load
|
||||
:items
|
||||
:validate
|
||||
@on-search="search"
|
||||
v-model:sort-options="sortOptions"
|
||||
></Table>
|
||||
</main>
|
||||
</template>
|
||||
52
frontend/src/order/order.service.ts
Normal file
52
frontend/src/order/order.service.ts
Normal file
@@ -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<Order> {
|
||||
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<Order>) {
|
||||
return (await SortedByOrder(
|
||||
Object.entries(options).map((item) => ({
|
||||
Name: item[0],
|
||||
Order: item[1],
|
||||
})),
|
||||
)) as Order[];
|
||||
}
|
||||
}
|
||||
@@ -1,34 +1,43 @@
|
||||
<script setup lang="ts">
|
||||
import { Button } from 'primevue';
|
||||
import NavCard from '../components/cards/NavCard.vue';
|
||||
import { ExportAllEntities, ImportAllEntities } from '../../bindings/app/internal/services/excelmodule';
|
||||
import { useErrorStore } from '../stores/error.store';
|
||||
|
||||
const errorStore = useErrorStore()
|
||||
<!--<script setup lang="ts">-->
|
||||
<!--import { Button } from 'primevue';-->
|
||||
<!--import NavCard from '../components/cards/NavCard.vue';-->
|
||||
<!--import { ExportAllEntities, ImportAllEntities } from '../../bindings/app/internal/services/excelmodule';-->
|
||||
<!--import { useErrorStore } from '../stores/error.store';-->
|
||||
|
||||
const importFromExcel = async () => {
|
||||
try {
|
||||
await ImportAllEntities()
|
||||
} catch(e) {
|
||||
errorStore.summon((e as Error).message)
|
||||
}
|
||||
}
|
||||
<!--const errorStore = useErrorStore()-->
|
||||
|
||||
const exportFromExcel = async () => {
|
||||
try {
|
||||
await ExportAllEntities()
|
||||
} catch(e) {
|
||||
errorStore.summon((e as Error).message)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<!--const importFromExcel = async () => {-->
|
||||
<!-- try {-->
|
||||
<!-- await ImportAllEntities()-->
|
||||
<!-- } catch(e) {-->
|
||||
<!-- errorStore.summon((e as Error).message)-->
|
||||
<!-- }-->
|
||||
<!--}-->
|
||||
|
||||
<!--const exportFromExcel = async () => {-->
|
||||
<!-- try {-->
|
||||
<!-- await ExportAllEntities()-->
|
||||
<!-- } catch(e) {-->
|
||||
<!-- errorStore.summon((e as Error).message)-->
|
||||
<!-- }-->
|
||||
<!--}-->
|
||||
<!--</script>-->
|
||||
|
||||
<!--<template>-->
|
||||
<!-- <div class="flex w-screen h-screen items-center gap-5 justify-center">-->
|
||||
<!-- <NavCard :title="'Пользователь'" :to="'/user'" :content="'Не может пользоваться туалетной бумагой'" />-->
|
||||
<!-- </div>-->
|
||||
<!-- <footer class="fixed w-full bottom-10 flex items-center justify-center gap-2">-->
|
||||
<!-- <Button severity="secondary" @click="importFromExcel">Импортировать данные</Button>-->
|
||||
<!-- <Button severity="secondary" @click="exportFromExcel">Экспортировать данные</Button>-->
|
||||
<!-- </footer>-->
|
||||
<!--</template>-->
|
||||
|
||||
<template>
|
||||
<div class="flex w-screen h-screen items-center gap-5 justify-center">
|
||||
<NavCard :title="'Пользователь'" :to="'/user'" :content="'Не может пользоваться туалетной бумагой'" />
|
||||
</div>
|
||||
<footer class="fixed w-full bottom-10 flex items-center justify-center gap-2">
|
||||
<Button severity="secondary" @click="importFromExcel">Импортировать данные</Button>
|
||||
<Button severity="secondary" @click="exportFromExcel">Экспортировать данные</Button>
|
||||
</footer>
|
||||
<TaskScheme></TaskScheme>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import ProducttypeScheme from "../producttype/ProducttypeScheme.vue";
|
||||
import TaskScheme from "../task/TaskScheme.vue";
|
||||
</script>
|
||||
@@ -1,3 +0,0 @@
|
||||
<template>
|
||||
<h1>GREBEN</h1>
|
||||
</template>
|
||||
@@ -1,14 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { RouterView, useRoute, type RouteRecordRaw } from 'vue-router';
|
||||
import NavModal, { type Route } from '../../components/modals/NavModal.vue';
|
||||
import { routes } from '../../router/router';
|
||||
|
||||
const route = useRoute()
|
||||
|
||||
const lastRouteName = route.matched[route.matched.length - 2].path
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<NavModal :routes="<Route[]>routes[routes.findIndex(r => r.path == lastRouteName)].children" />
|
||||
<RouterView />
|
||||
</template>
|
||||
@@ -1,7 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import PostScheme from '../../post/PostScheme.vue';
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<PostScheme />
|
||||
</template>
|
||||
@@ -1,144 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import Table from "../table/Table.vue";
|
||||
import {onMounted, reactive, watch} from "vue";
|
||||
import { getDefaultValues } from "../utils/structs/defaults.util";
|
||||
import Service from "./post.service.ts";
|
||||
import type { Scheme } from "../types/scheme.type";
|
||||
import { Author, Post } from "../../bindings/app/internal/services";
|
||||
import { ref } from "vue";
|
||||
import type { Validate } from "../types/validate.type";
|
||||
|
||||
import AuthorService from "../author/author.service.ts";
|
||||
const authorService = new AuthorService();
|
||||
|
||||
import PosttypeService from "../posttype/posttype.service.ts";
|
||||
const posttypeService = new PosttypeService();
|
||||
|
||||
import CommentService from "../comment/comment.service.ts";
|
||||
import { SortedByOrder } from "../../bindings/app/internal/services/postservice.ts";
|
||||
import {getDefaultSortOptions} from "../utils/structs/default-sort-options.util.ts";
|
||||
|
||||
const commentService = new CommentService();
|
||||
|
||||
const service = new Service();
|
||||
|
||||
const items = ref<Post[]>([]);
|
||||
|
||||
const load = async () => {
|
||||
(scheme as any).Author.type!.nested!.values = await authorService.readAll();
|
||||
|
||||
(scheme as any).PostType.type!.nested!.values =
|
||||
await posttypeService.readAll();
|
||||
|
||||
(scheme as any).Comments.type!.nested!.values =
|
||||
await commentService.readAll();
|
||||
|
||||
items.value = await service.sort(sortOptions.value) ;
|
||||
return items.value;
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
await load();
|
||||
});
|
||||
|
||||
const scheme: Scheme<Post> = reactive({
|
||||
entityId: "PostId",
|
||||
|
||||
Id: {
|
||||
hidden: true,
|
||||
russian: 'Id',
|
||||
type: {
|
||||
primitive: "number",
|
||||
}
|
||||
},
|
||||
|
||||
Text: {
|
||||
russian: "Текст",
|
||||
type: {
|
||||
primitive: "string",
|
||||
},
|
||||
},
|
||||
|
||||
Deadline: {
|
||||
russian: "Дедлайн",
|
||||
date: true,
|
||||
type: {
|
||||
primitive: "date",
|
||||
},
|
||||
},
|
||||
|
||||
CreatedAt: {
|
||||
russian: "Дата создания",
|
||||
type: {
|
||||
primitive: "date",
|
||||
},
|
||||
},
|
||||
|
||||
AuthorId: {
|
||||
hidden: true,
|
||||
type: {
|
||||
primitive: "number",
|
||||
},
|
||||
},
|
||||
|
||||
Author: {
|
||||
russian: "Автор",
|
||||
type: {
|
||||
nested: {
|
||||
values: [],
|
||||
field: ["Name"],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
PostTypeId: {
|
||||
hidden: true,
|
||||
type: {
|
||||
primitive: "number",
|
||||
},
|
||||
},
|
||||
|
||||
PostType: {
|
||||
russian: "Тип",
|
||||
type: {
|
||||
nested: {
|
||||
values: [],
|
||||
field: ["Name"],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Comments: {
|
||||
russian: "Комментарии",
|
||||
many: true,
|
||||
type: {
|
||||
nested: {
|
||||
values: [],
|
||||
field: ["Text"],
|
||||
},
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const getDefaults = () => {
|
||||
return ({ ...getDefaultValues(scheme), AuthorId: 1, PostTypeId: 1 });
|
||||
};
|
||||
|
||||
const validate: Validate<Post> = (entity) => {
|
||||
return {
|
||||
status: "success",
|
||||
};
|
||||
};
|
||||
|
||||
const search = async (input: string) => {
|
||||
|
||||
}
|
||||
|
||||
const sortOptions = ref(getDefaultSortOptions(scheme))
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Table :scheme :service :get-defaults :load :items :validate @on-search="search" v-model:sort-options="sortOptions"></Table>
|
||||
</template>
|
||||
@@ -1,41 +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";
|
||||
|
||||
export default class PostService implements IService<Post> {
|
||||
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<Post>) {
|
||||
return await SortedByOrder(options) as Post[]
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import Table from "../table/Table.vue";
|
||||
import { onMounted, reactive } from "vue";
|
||||
import { getDefaultValues } from "../utils/structs/defaults.util";
|
||||
import Service from "./posttype.service.ts";
|
||||
import type { Scheme } from "../types/scheme.type";
|
||||
import { PostType } from "../../bindings/app/internal/services";
|
||||
import { ref } from "vue";
|
||||
import type { Validate } from "../types/validate.type";
|
||||
|
||||
const service = new Service();
|
||||
|
||||
const items = ref<PostType[]>([]);
|
||||
|
||||
const load = async () => {
|
||||
items.value = await service.readAll();
|
||||
return items.value;
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
await load();
|
||||
});
|
||||
|
||||
const scheme: Scheme<PostType> = reactive({
|
||||
entityId: "PostTypeId",
|
||||
|
||||
Id: {
|
||||
hidden: true,
|
||||
type: {
|
||||
primitive: "number",
|
||||
},
|
||||
},
|
||||
|
||||
Name: {
|
||||
russian: "Название",
|
||||
type: {
|
||||
primitive: "string",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const getDefaults = () => getDefaultValues(scheme);
|
||||
|
||||
const validate: Validate<PostType> = (entity) => {
|
||||
return {
|
||||
status: "success",
|
||||
};
|
||||
};
|
||||
|
||||
const colorize = (data: PostType): string => {
|
||||
if (data.Name === "test") {
|
||||
return "red";
|
||||
}
|
||||
return ''
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main class="w-screen h-screen">
|
||||
<Table :scheme :service :get-defaults :load :items :validate :colorize></Table>
|
||||
</main>
|
||||
</template>
|
||||
@@ -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<PostType> {
|
||||
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();
|
||||
}
|
||||
}
|
||||
141
frontend/src/preptask/PreptaskScheme.vue
Normal file
141
frontend/src/preptask/PreptaskScheme.vue
Normal file
@@ -0,0 +1,141 @@
|
||||
<script setup lang="ts">
|
||||
import Table from "../table/Table.vue";
|
||||
import { onMounted, reactive } from "vue";
|
||||
import { getDefaultValues } from "../utils/structs/defaults.util";
|
||||
import Service from "./preptask.service";
|
||||
import type { Scheme } from "../types/scheme.type";
|
||||
import { PrepTask } from "../../bindings/app/internal/services";
|
||||
import { ref } from "vue";
|
||||
import type { Validate } from "../types/validate.type";
|
||||
import { getDefaultSortOptions } from "../utils/structs/default-sort-options.util";
|
||||
|
||||
import TaskService from "../task/task.service";
|
||||
const taskService = new TaskService();
|
||||
|
||||
import WorkareaService from "../workarea/workarea.service";
|
||||
const workareaService = new WorkareaService();
|
||||
|
||||
const service = new Service();
|
||||
|
||||
const items = ref<PrepTask[]>([]);
|
||||
|
||||
const load = async () => {
|
||||
(scheme as any).Task.type!.nested!.values = await taskService.readAll();
|
||||
|
||||
(scheme as any).WorkArea.type!.nested!.values =
|
||||
await workareaService.readAll();
|
||||
|
||||
items.value = await service.sort(sortOptions.value);
|
||||
return items.value;
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
load();
|
||||
});
|
||||
|
||||
const scheme: Scheme<PrepTask> = reactive({
|
||||
entityId: "PrepTaskId",
|
||||
|
||||
Id: {
|
||||
russian: "ID",
|
||||
readonly: true,
|
||||
type: {
|
||||
primitive: "number",
|
||||
},
|
||||
},
|
||||
|
||||
Status: {
|
||||
russian: "Статус",
|
||||
type: {
|
||||
primitive: "string",
|
||||
},
|
||||
},
|
||||
|
||||
Description: {
|
||||
russian: "Описание",
|
||||
type: {
|
||||
primitive: "string",
|
||||
},
|
||||
},
|
||||
|
||||
TaskId: {
|
||||
hidden: true,
|
||||
type: {
|
||||
primitive: "number",
|
||||
},
|
||||
},
|
||||
|
||||
Task: {
|
||||
russian: "Задача",
|
||||
type: {
|
||||
nested: {
|
||||
values: [],
|
||||
field: ["Description"],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
WorkAreaId: {
|
||||
hidden: true,
|
||||
type: {
|
||||
primitive: "number",
|
||||
},
|
||||
},
|
||||
|
||||
WorkArea: {
|
||||
russian: "Рабочая зона",
|
||||
type: {
|
||||
nested: {
|
||||
values: [],
|
||||
field: ["Name"],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
CreatedAt: {
|
||||
russian: "Дата создания",
|
||||
readonly: true,
|
||||
date: true,
|
||||
type: {
|
||||
primitive: "date",
|
||||
},
|
||||
},
|
||||
|
||||
Deadline: {
|
||||
russian: "Крайний срок",
|
||||
date: true,
|
||||
type: {
|
||||
primitive: "date",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const getDefaults = () => getDefaultValues(scheme);
|
||||
|
||||
const validate: Validate<PrepTask> = (entity) => {
|
||||
return {
|
||||
status: "success",
|
||||
};
|
||||
};
|
||||
|
||||
const search = async (input: string) => {
|
||||
items.value = await service.search(input);
|
||||
};
|
||||
|
||||
const sortOptions = ref(getDefaultSortOptions(scheme));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main class="w-screen h-screen">
|
||||
<Table
|
||||
:scheme
|
||||
:service
|
||||
:get-defaults
|
||||
:load
|
||||
:items
|
||||
:validate
|
||||
@on-search="search"
|
||||
v-model:sort-options="sortOptions"
|
||||
></Table>
|
||||
</main>
|
||||
</template>
|
||||
52
frontend/src/preptask/preptask.service.ts
Normal file
52
frontend/src/preptask/preptask.service.ts
Normal file
@@ -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<PrepTask> {
|
||||
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<PrepTask>) {
|
||||
return (await SortedByOrder(
|
||||
Object.entries(options).map((item) => ({
|
||||
Name: item[0],
|
||||
Order: item[1],
|
||||
})),
|
||||
)) as PrepTask[];
|
||||
}
|
||||
}
|
||||
72
frontend/src/producttype/ProducttypeScheme.vue
Normal file
72
frontend/src/producttype/ProducttypeScheme.vue
Normal file
@@ -0,0 +1,72 @@
|
||||
<script setup lang="ts">
|
||||
import Table from "../table/Table.vue";
|
||||
import { onMounted, reactive } from "vue";
|
||||
import { getDefaultValues } from "../utils/structs/defaults.util";
|
||||
import Service from "./producttype.service";
|
||||
import type { Scheme } from "../types/scheme.type";
|
||||
import { ProductType } from "../../bindings/app/internal/services";
|
||||
import { ref } from "vue";
|
||||
import type { Validate } from "../types/validate.type";
|
||||
import { getDefaultSortOptions } from "../utils/structs/default-sort-options.util";
|
||||
|
||||
const service = new Service();
|
||||
|
||||
const items = ref<ProductType[]>([]);
|
||||
|
||||
const load = async () => {
|
||||
items.value = await service.sort(sortOptions.value);
|
||||
return items.value;
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
load();
|
||||
});
|
||||
|
||||
const scheme: Scheme<ProductType> = reactive({
|
||||
entityId: "ProductTypeId",
|
||||
|
||||
Id: {
|
||||
russian: "ID",
|
||||
readonly: true,
|
||||
type: {
|
||||
primitive: "number",
|
||||
},
|
||||
},
|
||||
|
||||
Name: {
|
||||
russian: "Название",
|
||||
type: {
|
||||
primitive: "string",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const getDefaults = () => getDefaultValues(scheme);
|
||||
|
||||
const validate: Validate<ProductType> = (entity) => {
|
||||
return {
|
||||
status: "success",
|
||||
};
|
||||
};
|
||||
|
||||
const search = async (input: string) => {
|
||||
items.value = await service.search(input);
|
||||
};
|
||||
|
||||
const sortOptions = ref(getDefaultSortOptions(scheme));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main class="w-screen h-screen">
|
||||
<Table
|
||||
:scheme
|
||||
:service
|
||||
:get-defaults
|
||||
:load
|
||||
:items
|
||||
:validate
|
||||
@on-search="search"
|
||||
v-model:sort-options="sortOptions"
|
||||
></Table>
|
||||
</main>
|
||||
</template>
|
||||
52
frontend/src/producttype/producttype.service.ts
Normal file
52
frontend/src/producttype/producttype.service.ts
Normal file
@@ -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<ProductType> {
|
||||
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<ProductType>) {
|
||||
return (await SortedByOrder(
|
||||
Object.entries(options).map((item) => ({
|
||||
Name: item[0],
|
||||
Order: item[1],
|
||||
})),
|
||||
)) as ProductType[];
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
});
|
||||
|
||||
// {
|
||||
// path: '/user',
|
||||
// name: 'Пользователь',
|
||||
// component: UserPage,
|
||||
// redirect: '/user/post',
|
||||
// children: [
|
||||
// {
|
||||
// component: PostTablePage,
|
||||
// path: '/user/post',
|
||||
// name: 'Новости'
|
||||
// }, {
|
||||
// component: GrebenPage,
|
||||
// path: '/user/greben',
|
||||
// name: 'Страница гребня'
|
||||
// }
|
||||
// ]
|
||||
// }
|
||||
140
frontend/src/shift/ShiftScheme.vue
Normal file
140
frontend/src/shift/ShiftScheme.vue
Normal file
@@ -0,0 +1,140 @@
|
||||
<script setup lang="ts">
|
||||
import Table from "../table/Table.vue";
|
||||
import { onMounted, reactive } from "vue";
|
||||
import { getDefaultValues } from "../utils/structs/defaults.util";
|
||||
import Service from "./shift.service";
|
||||
import type { Scheme } from "../types/scheme.type";
|
||||
import { Shift } from "../../bindings/app/internal/services";
|
||||
import { ref } from "vue";
|
||||
import type { Validate } from "../types/validate.type";
|
||||
import { getDefaultSortOptions } from "../utils/structs/default-sort-options.util";
|
||||
|
||||
import ProducttypeService from "../producttype/producttype.service";
|
||||
const producttypeService = new ProducttypeService();
|
||||
|
||||
import WorkareaService from "../workarea/workarea.service";
|
||||
const workareaService = new WorkareaService();
|
||||
|
||||
const service = new Service();
|
||||
|
||||
const items = ref<Shift[]>([]);
|
||||
|
||||
const load = async () => {
|
||||
(scheme as any).ProductType.type!.nested!.values =
|
||||
await producttypeService.readAll();
|
||||
|
||||
(scheme as any).WorkArea.type!.nested!.values =
|
||||
await workareaService.readAll();
|
||||
|
||||
items.value = await service.sort(sortOptions.value);
|
||||
return items.value;
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
load();
|
||||
});
|
||||
|
||||
const scheme: Scheme<Shift> = reactive({
|
||||
entityId: "ShiftId",
|
||||
|
||||
Id: {
|
||||
russian: "ID",
|
||||
readonly: true,
|
||||
type: {
|
||||
primitive: "number",
|
||||
},
|
||||
},
|
||||
|
||||
Description: {
|
||||
russian: "Описание",
|
||||
type: {
|
||||
primitive: "string",
|
||||
},
|
||||
},
|
||||
|
||||
ProductTypeId: {
|
||||
hidden: true,
|
||||
type: {
|
||||
primitive: "number",
|
||||
},
|
||||
},
|
||||
|
||||
ProductType: {
|
||||
type: {
|
||||
nested: {
|
||||
values: [],
|
||||
field: ["Name"],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
ProductAmount: {
|
||||
russian: "Количество продукции",
|
||||
type: {
|
||||
primitive: "number",
|
||||
},
|
||||
},
|
||||
|
||||
ShiftDate: {
|
||||
russian: "Дата смены",
|
||||
date: true,
|
||||
type: {
|
||||
primitive: "date",
|
||||
},
|
||||
},
|
||||
|
||||
WorkAreaId: {
|
||||
hidden: true,
|
||||
type: {
|
||||
primitive: "number",
|
||||
},
|
||||
},
|
||||
|
||||
WorkArea: {
|
||||
type: {
|
||||
nested: {
|
||||
values: [],
|
||||
field: ["Name"],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
CreatedAt: {
|
||||
russian: "Дата создания",
|
||||
readonly: true,
|
||||
date: true,
|
||||
type: {
|
||||
primitive: "date",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const getDefaults = () => getDefaultValues(scheme);
|
||||
|
||||
const validate: Validate<Shift> = (entity) => {
|
||||
return {
|
||||
status: "success",
|
||||
};
|
||||
};
|
||||
|
||||
const search = async (input: string) => {
|
||||
items.value = await service.search(input);
|
||||
};
|
||||
|
||||
const sortOptions = ref(getDefaultSortOptions(scheme));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main class="w-screen h-screen">
|
||||
<Table
|
||||
:scheme
|
||||
:service
|
||||
:get-defaults
|
||||
:load
|
||||
:items
|
||||
:validate
|
||||
@on-search="search"
|
||||
v-model:sort-options="sortOptions"
|
||||
></Table>
|
||||
</main>
|
||||
</template>
|
||||
52
frontend/src/shift/shift.service.ts
Normal file
52
frontend/src/shift/shift.service.ts
Normal file
@@ -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<Shift> {
|
||||
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<Shift>) {
|
||||
return (await SortedByOrder(
|
||||
Object.entries(options).map((item) => ({
|
||||
Name: item[0],
|
||||
Order: item[1],
|
||||
})),
|
||||
)) as Shift[];
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,13 @@ defineProps<{
|
||||
<ul class="flex flex-col gap-2 native-border secondary-background p-3 rounded-md">
|
||||
<li v-for="optionKey in optionsKeys" class="flex items-center justify-between w-full">
|
||||
<h1>{{ scheme[optionKey].russian }}</h1>
|
||||
<Select size="small" class="w-24" :options="['ASC', 'DESC']" v-model="options![optionKey]" @value-change="load"></Select>
|
||||
<Select size="small" class="w-24" :options="['NONE', 'ASC', 'DESC']" v-model="options![optionKey]" @value-change="load">
|
||||
<template #value="{ value }">
|
||||
<span class="pi pi-sort-amount-up-alt" v-if="value == 'ASC'"></span>
|
||||
<span class="pi pi-sort-amount-down" v-else-if="value == 'DESC'"></span>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</Select>
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
|
||||
175
frontend/src/task/TaskScheme.vue
Normal file
175
frontend/src/task/TaskScheme.vue
Normal file
@@ -0,0 +1,175 @@
|
||||
<script setup lang="ts">
|
||||
import Table from "../table/Table.vue";
|
||||
import { onMounted, reactive } from "vue";
|
||||
import { getDefaultValues } from "../utils/structs/defaults.util";
|
||||
import Service from "./task.service";
|
||||
import type { Scheme } from "../types/scheme.type";
|
||||
import { Task } from "../../bindings/app/internal/services";
|
||||
import { ref } from "vue";
|
||||
import type { Validate } from "../types/validate.type";
|
||||
import { getDefaultSortOptions } from "../utils/structs/default-sort-options.util";
|
||||
|
||||
import ProducttypeService from "../producttype/producttype.service";
|
||||
const producttypeService = new ProducttypeService();
|
||||
|
||||
import WorkshopService from "../workshop/workshop.service";
|
||||
const workshopService = new WorkshopService();
|
||||
|
||||
import OrderService from "../order/order.service";
|
||||
const orderService = new OrderService();
|
||||
|
||||
import PreptaskService from "../preptask/preptask.service";
|
||||
const preptaskService = new PreptaskService();
|
||||
|
||||
const service = new Service();
|
||||
|
||||
const items = ref<Task[]>([]);
|
||||
|
||||
const load = async () => {
|
||||
(scheme as any).ProductType.type!.nested!.values =
|
||||
await producttypeService.readAll();
|
||||
|
||||
(scheme as any).Workshops.type!.nested!.values =
|
||||
await workshopService.readAll();
|
||||
|
||||
(scheme as any).Order.type!.nested!.values = await orderService.readAll();
|
||||
|
||||
(scheme as any).PrepTasks.type!.nested!.values =
|
||||
await preptaskService.readAll();
|
||||
|
||||
items.value = await service.sort(sortOptions.value);
|
||||
return items.value;
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
load();
|
||||
});
|
||||
|
||||
const scheme: Scheme<Task> = reactive({
|
||||
entityId: "TaskId",
|
||||
|
||||
Id: {
|
||||
russian: "ID",
|
||||
readonly: true,
|
||||
type: {
|
||||
primitive: "number",
|
||||
},
|
||||
},
|
||||
|
||||
Description: {
|
||||
russian: "Описание",
|
||||
type: {
|
||||
primitive: "string",
|
||||
},
|
||||
},
|
||||
|
||||
ProductTypeId: {
|
||||
hidden: true,
|
||||
type: {
|
||||
primitive: "number",
|
||||
},
|
||||
},
|
||||
|
||||
ProductType: {
|
||||
russian: "Тип",
|
||||
type: {
|
||||
nested: {
|
||||
values: [],
|
||||
field: ["Name"],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Workshops: {
|
||||
hidden: true,
|
||||
many: true,
|
||||
type: {
|
||||
nested: {
|
||||
values: [],
|
||||
field: [""],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
OrderId: {
|
||||
hidden: true,
|
||||
type: {
|
||||
primitive: "number",
|
||||
},
|
||||
},
|
||||
|
||||
Order: {
|
||||
russian: "Заказ",
|
||||
type: {
|
||||
nested: {
|
||||
values: [],
|
||||
field: ["Description"],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
PrepTasks: {
|
||||
hidden: true,
|
||||
many: true,
|
||||
type: {
|
||||
nested: {
|
||||
values: [],
|
||||
field: [""],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
ProductionStart: {
|
||||
russian: "Дата начала производства",
|
||||
date: true,
|
||||
type: {
|
||||
primitive: "date",
|
||||
},
|
||||
},
|
||||
|
||||
CreatedAt: {
|
||||
russian: "Дата создания",
|
||||
readonly: true,
|
||||
date: true,
|
||||
type: {
|
||||
primitive: "date",
|
||||
},
|
||||
},
|
||||
|
||||
Amount: {
|
||||
russian: "Количество",
|
||||
type: {
|
||||
primitive: "number",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const getDefaults = () => getDefaultValues(scheme);
|
||||
|
||||
const validate: Validate<Task> = (entity) => {
|
||||
return {
|
||||
status: "success",
|
||||
};
|
||||
};
|
||||
|
||||
const search = async (input: string) => {
|
||||
items.value = await service.search(input);
|
||||
};
|
||||
|
||||
const sortOptions = ref(getDefaultSortOptions(scheme));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main class="w-screen h-screen">
|
||||
<Table
|
||||
:scheme
|
||||
:service
|
||||
:get-defaults
|
||||
:load
|
||||
:items
|
||||
:validate
|
||||
@on-search="search"
|
||||
v-model:sort-options="sortOptions"
|
||||
></Table>
|
||||
</main>
|
||||
</template>
|
||||
56
frontend/src/task/task.service.ts
Normal file
56
frontend/src/task/task.service.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
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<Task> {
|
||||
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<Task>) {
|
||||
return (await SortedByOrder(
|
||||
Object.entries(options).map((item) => {
|
||||
if (item[1] !== 'NONE') {
|
||||
return ({
|
||||
Name: item[0],
|
||||
Order: item[1],
|
||||
})
|
||||
}
|
||||
}).filter(item => !!item)
|
||||
)) as Task[];
|
||||
}
|
||||
}
|
||||
157
frontend/src/teamtask/TeamtaskScheme.vue
Normal file
157
frontend/src/teamtask/TeamtaskScheme.vue
Normal file
@@ -0,0 +1,157 @@
|
||||
<script setup lang="ts">
|
||||
import Table from "../table/Table.vue";
|
||||
import { onMounted, reactive } from "vue";
|
||||
import { getDefaultValues } from "../utils/structs/defaults.util";
|
||||
import Service from "./teamtask.service";
|
||||
import type { Scheme } from "../types/scheme.type";
|
||||
import { TeamTask } from "../../bindings/app/internal/services";
|
||||
import { ref } from "vue";
|
||||
import type { Validate } from "../types/validate.type";
|
||||
import { getDefaultSortOptions } from "../utils/structs/default-sort-options.util";
|
||||
|
||||
import TeamtypeService from "../teamtype/teamtype.service";
|
||||
const teamtypeService = new TeamtypeService();
|
||||
|
||||
import WorkerService from "../worker/worker.service";
|
||||
const workerService = new WorkerService();
|
||||
|
||||
import WorkareaService from "../workarea/workarea.service";
|
||||
const workareaService = new WorkareaService();
|
||||
|
||||
const service = new Service();
|
||||
|
||||
const items = ref<TeamTask[]>([]);
|
||||
|
||||
const load = async () => {
|
||||
(scheme as any).TeamType.type!.nested!.values =
|
||||
await teamtypeService.readAll();
|
||||
|
||||
(scheme as any).TeamLeader.type!.nested!.values =
|
||||
await workerService.readAll();
|
||||
|
||||
(scheme as any).WorkArea.type!.nested!.values =
|
||||
await workareaService.readAll();
|
||||
|
||||
items.value = await service.sort(sortOptions.value);
|
||||
return items.value;
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
load();
|
||||
});
|
||||
|
||||
const scheme: Scheme<TeamTask> = reactive({
|
||||
entityId: "TeamTaskId",
|
||||
|
||||
Id: {
|
||||
russian: "ID",
|
||||
readonly: true,
|
||||
type: {
|
||||
primitive: "number",
|
||||
},
|
||||
},
|
||||
|
||||
TeamTypeId: {
|
||||
hidden: true,
|
||||
type: {
|
||||
primitive: "number",
|
||||
},
|
||||
},
|
||||
|
||||
TeamType: {
|
||||
type: {
|
||||
nested: {
|
||||
values: [],
|
||||
field: ["Name"],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
TeamLeaderId: {
|
||||
hidden: true,
|
||||
type: {
|
||||
primitive: "number",
|
||||
},
|
||||
},
|
||||
|
||||
TeamLeader: {
|
||||
type: {
|
||||
nested: {
|
||||
values: [],
|
||||
field: ["Name"],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
TeamMembers: {
|
||||
hidden: true,
|
||||
many: true,
|
||||
type: {
|
||||
nested: {
|
||||
values: [],
|
||||
field: [""],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
WorkStartDate: {
|
||||
russian: "Дата начала работ",
|
||||
date: true,
|
||||
type: {
|
||||
primitive: "date",
|
||||
},
|
||||
},
|
||||
|
||||
WorkAreaId: {
|
||||
hidden: true,
|
||||
type: {
|
||||
primitive: "number",
|
||||
},
|
||||
},
|
||||
|
||||
WorkArea: {
|
||||
type: {
|
||||
nested: {
|
||||
values: [],
|
||||
field: ["Name"],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
ShiftDuties: {
|
||||
russian: "Обязанности смены",
|
||||
type: {
|
||||
primitive: "string",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const getDefaults = () => getDefaultValues(scheme);
|
||||
|
||||
const validate: Validate<TeamTask> = (entity) => {
|
||||
return {
|
||||
status: "success",
|
||||
};
|
||||
};
|
||||
|
||||
const search = async (input: string) => {
|
||||
items.value = await service.search(input);
|
||||
};
|
||||
|
||||
const sortOptions = ref(getDefaultSortOptions(scheme));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main class="w-screen h-screen">
|
||||
<Table
|
||||
:scheme
|
||||
:service
|
||||
:get-defaults
|
||||
:load
|
||||
:items
|
||||
:validate
|
||||
@on-search="search"
|
||||
v-model:sort-options="sortOptions"
|
||||
></Table>
|
||||
</main>
|
||||
</template>
|
||||
52
frontend/src/teamtask/teamtask.service.ts
Normal file
52
frontend/src/teamtask/teamtask.service.ts
Normal file
@@ -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<TeamTask> {
|
||||
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<TeamTask>) {
|
||||
return (await SortedByOrder(
|
||||
Object.entries(options).map((item) => ({
|
||||
Name: item[0],
|
||||
Order: item[1],
|
||||
})),
|
||||
)) as TeamTask[];
|
||||
}
|
||||
}
|
||||
72
frontend/src/teamtype/TeamtypeScheme.vue
Normal file
72
frontend/src/teamtype/TeamtypeScheme.vue
Normal file
@@ -0,0 +1,72 @@
|
||||
<script setup lang="ts">
|
||||
import Table from "../table/Table.vue";
|
||||
import { onMounted, reactive } from "vue";
|
||||
import { getDefaultValues } from "../utils/structs/defaults.util";
|
||||
import Service from "./teamtype.service";
|
||||
import type { Scheme } from "../types/scheme.type";
|
||||
import { TeamType } from "../../bindings/app/internal/services";
|
||||
import { ref } from "vue";
|
||||
import type { Validate } from "../types/validate.type";
|
||||
import { getDefaultSortOptions } from "../utils/structs/default-sort-options.util";
|
||||
|
||||
const service = new Service();
|
||||
|
||||
const items = ref<TeamType[]>([]);
|
||||
|
||||
const load = async () => {
|
||||
items.value = await service.sort(sortOptions.value);
|
||||
return items.value;
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
load();
|
||||
});
|
||||
|
||||
const scheme: Scheme<TeamType> = reactive({
|
||||
entityId: "TeamTypeId",
|
||||
|
||||
Id: {
|
||||
russian: "ID",
|
||||
readonly: true,
|
||||
type: {
|
||||
primitive: "number",
|
||||
},
|
||||
},
|
||||
|
||||
Name: {
|
||||
russian: "Название",
|
||||
type: {
|
||||
primitive: "string",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const getDefaults = () => getDefaultValues(scheme);
|
||||
|
||||
const validate: Validate<TeamType> = (entity) => {
|
||||
return {
|
||||
status: "success",
|
||||
};
|
||||
};
|
||||
|
||||
const search = async (input: string) => {
|
||||
items.value = await service.search(input);
|
||||
};
|
||||
|
||||
const sortOptions = ref(getDefaultSortOptions(scheme));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main class="w-screen h-screen">
|
||||
<Table
|
||||
:scheme
|
||||
:service
|
||||
:get-defaults
|
||||
:load
|
||||
:items
|
||||
:validate
|
||||
@on-search="search"
|
||||
v-model:sort-options="sortOptions"
|
||||
></Table>
|
||||
</main>
|
||||
</template>
|
||||
52
frontend/src/teamtype/teamtype.service.ts
Normal file
52
frontend/src/teamtype/teamtype.service.ts
Normal file
@@ -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<TeamType> {
|
||||
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<TeamType>) {
|
||||
return (await SortedByOrder(
|
||||
Object.entries(options).map((item) => ({
|
||||
Name: item[0],
|
||||
Order: item[1],
|
||||
})),
|
||||
)) as TeamType[];
|
||||
}
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
export type Sorting = "DESC" | "ASC"
|
||||
export type Sorting = "DESC" | "ASC" | "NONE"
|
||||
@@ -8,7 +8,7 @@ export const getDefaultSortOptions = <T extends IEntity>(scheme: Scheme<T>): Sor
|
||||
|
||||
keys.forEach(key => {
|
||||
if (!scheme[key].hidden && key !== 'entityId' && !scheme[key].many) {
|
||||
result[key] = 'ASC'
|
||||
result[key] = 'NONE'
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
159
frontend/src/workarea/WorkareaScheme.vue
Normal file
159
frontend/src/workarea/WorkareaScheme.vue
Normal file
@@ -0,0 +1,159 @@
|
||||
<script setup lang="ts">
|
||||
import Table from "../table/Table.vue";
|
||||
import { onMounted, reactive } from "vue";
|
||||
import { getDefaultValues } from "../utils/structs/defaults.util";
|
||||
import Service from "./workarea.service";
|
||||
import type { Scheme } from "../types/scheme.type";
|
||||
import { WorkArea } from "../../bindings/app/internal/services";
|
||||
import { ref } from "vue";
|
||||
import type { Validate } from "../types/validate.type";
|
||||
import { getDefaultSortOptions } from "../utils/structs/default-sort-options.util";
|
||||
|
||||
import WorkshopService from "../workshop/workshop.service";
|
||||
const workshopService = new WorkshopService();
|
||||
|
||||
import PreptaskService from "../preptask/preptask.service";
|
||||
const preptaskService = new PreptaskService();
|
||||
|
||||
import ShiftService from "../shift/shift.service";
|
||||
const shiftService = new ShiftService();
|
||||
|
||||
import TeamtaskService from "../teamtask/teamtask.service";
|
||||
const teamtaskService = new TeamtaskService();
|
||||
|
||||
const service = new Service();
|
||||
|
||||
const items = ref<WorkArea[]>([]);
|
||||
|
||||
const load = async () => {
|
||||
(scheme as any).Workshop.type!.nested!.values =
|
||||
await workshopService.readAll();
|
||||
|
||||
(scheme as any).PrepTasks.type!.nested!.values =
|
||||
await preptaskService.readAll();
|
||||
|
||||
(scheme as any).Shifts.type!.nested!.values = await shiftService.readAll();
|
||||
|
||||
(scheme as any).TeamTasks.type!.nested!.values =
|
||||
await teamtaskService.readAll();
|
||||
|
||||
items.value = await service.sort(sortOptions.value);
|
||||
return items.value;
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
load();
|
||||
});
|
||||
|
||||
const scheme: Scheme<WorkArea> = reactive({
|
||||
entityId: "WorkAreaId",
|
||||
|
||||
Id: {
|
||||
russian: "ID",
|
||||
readonly: true,
|
||||
type: {
|
||||
primitive: "number",
|
||||
},
|
||||
},
|
||||
|
||||
Name: {
|
||||
russian: "Наименование",
|
||||
type: {
|
||||
primitive: "string",
|
||||
},
|
||||
},
|
||||
|
||||
Description: {
|
||||
russian: "Описание",
|
||||
type: {
|
||||
primitive: "string",
|
||||
},
|
||||
},
|
||||
|
||||
Performance: {
|
||||
russian: "Производительность",
|
||||
type: {
|
||||
primitive: "number",
|
||||
},
|
||||
},
|
||||
|
||||
WorkshopId: {
|
||||
hidden: true,
|
||||
type: {
|
||||
primitive: "number",
|
||||
},
|
||||
},
|
||||
|
||||
Workshop: {
|
||||
russian: "Цех",
|
||||
type: {
|
||||
nested: {
|
||||
values: [],
|
||||
field: ["Name"],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
PrepTasks: {
|
||||
hidden: true,
|
||||
many: true,
|
||||
type: {
|
||||
nested: {
|
||||
values: [],
|
||||
field: [""],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Shifts: {
|
||||
hidden: true,
|
||||
many: true,
|
||||
type: {
|
||||
nested: {
|
||||
values: [],
|
||||
field: [""],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
TeamTasks: {
|
||||
hidden: true,
|
||||
many: true,
|
||||
type: {
|
||||
nested: {
|
||||
values: [],
|
||||
field: [""],
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const getDefaults = () => getDefaultValues(scheme);
|
||||
|
||||
const validate: Validate<WorkArea> = (entity) => {
|
||||
return {
|
||||
status: "success",
|
||||
};
|
||||
};
|
||||
|
||||
const search = async (input: string) => {
|
||||
items.value = await service.search(input);
|
||||
};
|
||||
|
||||
const sortOptions = ref(getDefaultSortOptions(scheme));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main class="w-screen h-screen">
|
||||
<Table
|
||||
:scheme
|
||||
:service
|
||||
:get-defaults
|
||||
:load
|
||||
:items
|
||||
:validate
|
||||
@on-search="search"
|
||||
v-model:sort-options="sortOptions"
|
||||
></Table>
|
||||
</main>
|
||||
</template>
|
||||
52
frontend/src/workarea/workarea.service.ts
Normal file
52
frontend/src/workarea/workarea.service.ts
Normal file
@@ -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<WorkArea> {
|
||||
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<WorkArea>) {
|
||||
return (await SortedByOrder(
|
||||
Object.entries(options).map((item) => ({
|
||||
Name: item[0],
|
||||
Order: item[1],
|
||||
})),
|
||||
)) as WorkArea[];
|
||||
}
|
||||
}
|
||||
111
frontend/src/worker/WorkerScheme.vue
Normal file
111
frontend/src/worker/WorkerScheme.vue
Normal file
@@ -0,0 +1,111 @@
|
||||
<script setup lang="ts">
|
||||
import Table from "../table/Table.vue";
|
||||
import { onMounted, reactive } from "vue";
|
||||
import { getDefaultValues } from "../utils/structs/defaults.util";
|
||||
import Service from "./worker.service";
|
||||
import type { Scheme } from "../types/scheme.type";
|
||||
import { Worker } from "../../bindings/app/internal/services";
|
||||
import { ref } from "vue";
|
||||
import type { Validate } from "../types/validate.type";
|
||||
import { getDefaultSortOptions } from "../utils/structs/default-sort-options.util";
|
||||
|
||||
import TeamtaskService from "../teamtask/teamtask.service";
|
||||
const teamtaskService = new TeamtaskService();
|
||||
|
||||
import WorkshopService from "../workshop/workshop.service";
|
||||
const workshopService = new WorkshopService();
|
||||
|
||||
const service = new Service();
|
||||
|
||||
const items = ref<Worker[]>([]);
|
||||
|
||||
const load = async () => {
|
||||
(scheme as any).TeamTasks.type!.nested!.values =
|
||||
await teamtaskService.readAll();
|
||||
|
||||
(scheme as any).Workshop.type!.nested!.values =
|
||||
await workshopService.readAll();
|
||||
|
||||
items.value = await service.sort(sortOptions.value);
|
||||
return items.value;
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
load();
|
||||
});
|
||||
|
||||
const scheme: Scheme<Worker> = reactive({
|
||||
entityId: "WorkerId",
|
||||
|
||||
Id: {
|
||||
russian: "ID",
|
||||
readonly: true,
|
||||
type: {
|
||||
primitive: "number",
|
||||
},
|
||||
},
|
||||
|
||||
Name: {
|
||||
russian: "Имя",
|
||||
type: {
|
||||
primitive: "string",
|
||||
},
|
||||
},
|
||||
|
||||
TeamTasks: {
|
||||
hidden: true,
|
||||
many: true,
|
||||
type: {
|
||||
nested: {
|
||||
values: [],
|
||||
field: [""],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Workshop: {
|
||||
type: {
|
||||
nested: {
|
||||
values: [],
|
||||
field: ["Name"],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
WorkshopId: {
|
||||
hidden: true,
|
||||
type: {
|
||||
primitive: "number",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const getDefaults = () => getDefaultValues(scheme);
|
||||
|
||||
const validate: Validate<Worker> = (entity) => {
|
||||
return {
|
||||
status: "success",
|
||||
};
|
||||
};
|
||||
|
||||
const search = async (input: string) => {
|
||||
items.value = await service.search(input);
|
||||
};
|
||||
|
||||
const sortOptions = ref(getDefaultSortOptions(scheme));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main class="w-screen h-screen">
|
||||
<Table
|
||||
:scheme
|
||||
:service
|
||||
:get-defaults
|
||||
:load
|
||||
:items
|
||||
:validate
|
||||
@on-search="search"
|
||||
v-model:sort-options="sortOptions"
|
||||
></Table>
|
||||
</main>
|
||||
</template>
|
||||
52
frontend/src/worker/worker.service.ts
Normal file
52
frontend/src/worker/worker.service.ts
Normal file
@@ -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<Worker> {
|
||||
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<Worker>) {
|
||||
return (await SortedByOrder(
|
||||
Object.entries(options).map((item) => ({
|
||||
Name: item[0],
|
||||
Order: item[1],
|
||||
})),
|
||||
)) as Worker[];
|
||||
}
|
||||
}
|
||||
121
frontend/src/workshop/WorkshopScheme.vue
Normal file
121
frontend/src/workshop/WorkshopScheme.vue
Normal file
@@ -0,0 +1,121 @@
|
||||
<script setup lang="ts">
|
||||
import Table from "../table/Table.vue";
|
||||
import { onMounted, reactive } from "vue";
|
||||
import { getDefaultValues } from "../utils/structs/defaults.util";
|
||||
import Service from "./workshop.service";
|
||||
import type { Scheme } from "../types/scheme.type";
|
||||
import { Workshop } from "../../bindings/app/internal/services";
|
||||
import { ref } from "vue";
|
||||
import type { Validate } from "../types/validate.type";
|
||||
import { getDefaultSortOptions } from "../utils/structs/default-sort-options.util";
|
||||
|
||||
import WorkareaService from "../workarea/workarea.service";
|
||||
const workareaService = new WorkareaService();
|
||||
|
||||
import TaskService from "../task/task.service";
|
||||
const taskService = new TaskService();
|
||||
|
||||
import WorkerService from "../worker/worker.service";
|
||||
const workerService = new WorkerService();
|
||||
|
||||
const service = new Service();
|
||||
|
||||
const items = ref<Workshop[]>([]);
|
||||
|
||||
const load = async () => {
|
||||
(scheme as any).WorkAreas.type!.nested!.values =
|
||||
await workareaService.readAll();
|
||||
|
||||
(scheme as any).Tasks.type!.nested!.values = await taskService.readAll();
|
||||
|
||||
(scheme as any).Workers.type!.nested!.values = await workerService.readAll();
|
||||
|
||||
items.value = await service.sort(sortOptions.value);
|
||||
return items.value;
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
load();
|
||||
});
|
||||
|
||||
const scheme: Scheme<Workshop> = reactive({
|
||||
entityId: "WorkshopId",
|
||||
|
||||
Id: {
|
||||
russian: "ID",
|
||||
readonly: true,
|
||||
type: {
|
||||
primitive: "number",
|
||||
},
|
||||
},
|
||||
|
||||
Name: {
|
||||
russian: "Наименование",
|
||||
type: {
|
||||
primitive: "string",
|
||||
},
|
||||
},
|
||||
|
||||
WorkAreas: {
|
||||
hidden: true,
|
||||
many: true,
|
||||
type: {
|
||||
nested: {
|
||||
values: [],
|
||||
field: [""],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Tasks: {
|
||||
hidden: true,
|
||||
many: true,
|
||||
type: {
|
||||
nested: {
|
||||
values: [],
|
||||
field: [""],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Workers: {
|
||||
hidden: true,
|
||||
many: true,
|
||||
type: {
|
||||
nested: {
|
||||
values: [],
|
||||
field: [""],
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const getDefaults = () => getDefaultValues(scheme);
|
||||
|
||||
const validate: Validate<Workshop> = (entity) => {
|
||||
return {
|
||||
status: "success",
|
||||
};
|
||||
};
|
||||
|
||||
const search = async (input: string) => {
|
||||
items.value = await service.search(input);
|
||||
};
|
||||
|
||||
const sortOptions = ref(getDefaultSortOptions(scheme));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main class="w-screen h-screen">
|
||||
<Table
|
||||
:scheme
|
||||
:service
|
||||
:get-defaults
|
||||
:load
|
||||
:items
|
||||
:validate
|
||||
@on-search="search"
|
||||
v-model:sort-options="sortOptions"
|
||||
></Table>
|
||||
</main>
|
||||
</template>
|
||||
52
frontend/src/workshop/workshop.service.ts
Normal file
52
frontend/src/workshop/workshop.service.ts
Normal file
@@ -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<Workshop> {
|
||||
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<Workshop>) {
|
||||
return (await SortedByOrder(
|
||||
Object.entries(options).map((item) => ({
|
||||
Name: item[0],
|
||||
Order: item[1],
|
||||
})),
|
||||
)) as Workshop[];
|
||||
}
|
||||
}
|
||||
10
go.mod
10
go.mod
@@ -6,6 +6,8 @@ toolchain go1.24.1
|
||||
|
||||
require (
|
||||
github.com/kuzgoga/fogg v0.1.2
|
||||
github.com/ncruces/go-sqlite3 v0.24.1
|
||||
github.com/ncruces/go-sqlite3/gormlite v0.24.0
|
||||
github.com/wailsapp/wails/v3 v3.0.0-alpha.9
|
||||
github.com/xuri/excelize/v2 v2.9.0
|
||||
golang.org/x/text v0.23.0
|
||||
@@ -44,8 +46,9 @@ require (
|
||||
github.com/lmittmann/tint v1.0.4 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mattn/go-sqlite3 v1.14.22 // indirect
|
||||
github.com/mattn/go-sqlite3 v1.14.24 // indirect
|
||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
|
||||
github.com/ncruces/julianday v1.0.0 // indirect
|
||||
github.com/pjbgf/sha1cd v0.3.0 // indirect
|
||||
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
|
||||
github.com/richardlehane/mscfb v1.0.4 // indirect
|
||||
@@ -54,17 +57,18 @@ require (
|
||||
github.com/samber/lo v1.38.1 // indirect
|
||||
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
|
||||
github.com/skeema/knownhosts v1.2.2 // indirect
|
||||
github.com/tetratelabs/wazero v1.9.0 // indirect
|
||||
github.com/wailsapp/go-webview2 v1.0.19 // indirect
|
||||
github.com/wailsapp/mimetype v1.4.1 // indirect
|
||||
github.com/xanzy/ssh-agent v0.3.3 // indirect
|
||||
github.com/xuri/efp v0.0.0-20240408161823-9ad904a10d6d // indirect
|
||||
github.com/xuri/nfp v0.0.0-20240318013403-ab9948c2c4a7 // indirect
|
||||
golang.org/x/crypto v0.30.0 // indirect
|
||||
golang.org/x/crypto v0.36.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
|
||||
golang.org/x/mod v0.22.0 // indirect
|
||||
golang.org/x/net v0.32.0 // indirect
|
||||
golang.org/x/sync v0.12.0 // indirect
|
||||
golang.org/x/sys v0.28.0 // indirect
|
||||
golang.org/x/sys v0.31.0 // indirect
|
||||
golang.org/x/tools v0.28.0 // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
gopkg.in/warnings.v0 v0.1.2 // indirect
|
||||
|
||||
24
go.sum
24
go.sum
@@ -99,12 +99,18 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
|
||||
github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
|
||||
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
|
||||
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
|
||||
github.com/mattn/go-sqlite3 v1.14.24 h1:tpSp2G2KyMnnQu99ngJ47EIkWVmliIizyZBfPrBWDRM=
|
||||
github.com/mattn/go-sqlite3 v1.14.24/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
|
||||
github.com/microsoft/go-mssqldb v1.7.2 h1:CHkFJiObW7ItKTJfHo1QX7QBBD1iV+mn1eOyRP3b/PA=
|
||||
github.com/microsoft/go-mssqldb v1.7.2/go.mod h1:kOvZKUdrhhFQmxLZqbwUV0rHkNkZpthMITIb2Ko1IoA=
|
||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw=
|
||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
|
||||
github.com/ncruces/go-sqlite3 v0.24.1 h1:qHlIz+dlH3Y0wCUErFZXon5hCvw1Kc9eEkZVYYi8p14=
|
||||
github.com/ncruces/go-sqlite3 v0.24.1/go.mod h1:n6Z7036yFilJx04yV0mi5JWaF66rUmXn1It9Ux8dx68=
|
||||
github.com/ncruces/go-sqlite3/gormlite v0.24.0 h1:81sHeq3CCdhjoqAB650n5wEdRlLO9VBvosArskcN3+c=
|
||||
github.com/ncruces/go-sqlite3/gormlite v0.24.0/go.mod h1:vXfVWdBfg7qOgqQqHpzUWl9LLswD0h+8mK4oouaV2oc=
|
||||
github.com/ncruces/julianday v1.0.0 h1:fH0OKwa7NWvniGQtxdJRxAgkBMolni2BjDHaWTxqt7M=
|
||||
github.com/ncruces/julianday v1.0.0/go.mod h1:Dusn2KvZrrovOMJuOt0TNXL6tB7U2E8kvza5fFc9G7g=
|
||||
github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k=
|
||||
github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY=
|
||||
github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4=
|
||||
@@ -137,6 +143,8 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/tetratelabs/wazero v1.9.0 h1:IcZ56OuxrtaEz8UYNRHBrUa9bYeX9oVY93KspZZBf/I=
|
||||
github.com/tetratelabs/wazero v1.9.0/go.mod h1:TSbcXCfFP0L2FGkRPxHphadXPjo1T6W+CseNNY7EkjM=
|
||||
github.com/wailsapp/go-webview2 v1.0.19 h1:7U3QcDj1PrBPaxJNCui2k1SkWml+Q5kvFUFyTImA6NU=
|
||||
github.com/wailsapp/go-webview2 v1.0.19/go.mod h1:qJmWAmAmaniuKGZPWwne+uor3AHMB5PFhqiK0Bbj8kc=
|
||||
github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhwHs=
|
||||
@@ -157,8 +165,8 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y
|
||||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
|
||||
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
|
||||
golang.org/x/crypto v0.30.0 h1:RwoQn3GkWiMkzlX562cLB7OxWvjH1L8xutO2WoJcRoY=
|
||||
golang.org/x/crypto v0.30.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
|
||||
golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=
|
||||
golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
|
||||
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8=
|
||||
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY=
|
||||
golang.org/x/image v0.21.0 h1:c5qV36ajHpdj4Qi0GnE0jUc/yuo33OLFaa0d+crTD5s=
|
||||
@@ -199,15 +207,15 @@ golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
|
||||
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
|
||||
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
|
||||
golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q=
|
||||
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
|
||||
golang.org/x/term v0.30.0 h1:PQ39fJZ+mfadBm0y5WlL4vlM7Sx1Hgf13sMIY2+QS9Y=
|
||||
golang.org/x/term v0.30.0/go.mod h1:NYYFdzHoI5wRh/h5tDMdMqCqPJZEuNqVR5xJLd/n67g=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
|
||||
0
internal/addons/excel/README.md
Normal file
0
internal/addons/excel/README.md
Normal file
@@ -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
|
||||
}
|
||||
@@ -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 <authors> 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 <authors> fail:", err)
|
||||
}
|
||||
|
||||
err = _do.Save(&models.Author{})
|
||||
if err != nil {
|
||||
t.Error("create item in table <authors> fail:", err)
|
||||
}
|
||||
|
||||
err = _do.CreateInBatches([]*models.Author{{}, {}}, 10)
|
||||
if err != nil {
|
||||
t.Error("create item in table <authors> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Select(author.ALL).Take()
|
||||
if err != nil {
|
||||
t.Error("Take() on table <authors> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.First()
|
||||
if err != nil {
|
||||
t.Error("First() on table <authors> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Last()
|
||||
if err != nil {
|
||||
t.Error("First() on table <authors> 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 <authors> 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 <authors> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Select(author.ALL).Where(primaryKey.IsNotNull()).Order(primaryKey.Desc()).Find()
|
||||
if err != nil {
|
||||
t.Error("Find() on table <authors> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Distinct(primaryKey).Take()
|
||||
if err != nil {
|
||||
t.Error("select Distinct() on table <authors> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Select(author.ALL).Omit(primaryKey).Take()
|
||||
if err != nil {
|
||||
t.Error("Omit() on table <authors> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Group(primaryKey).Find()
|
||||
if err != nil {
|
||||
t.Error("Group() on table <authors> 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 <authors> fail:", err)
|
||||
}
|
||||
|
||||
_, _, err = _do.FindByPage(0, 1)
|
||||
if err != nil {
|
||||
t.Error("FindByPage() on table <authors> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.ScanByPage(&models.Author{}, 0, 1)
|
||||
if err != nil {
|
||||
t.Error("ScanByPage() on table <authors> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrInit()
|
||||
if err != nil {
|
||||
t.Error("FirstOrInit() on table <authors> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrCreate()
|
||||
if err != nil {
|
||||
t.Error("FirstOrCreate() on table <authors> 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 <authors> fail:", err)
|
||||
}
|
||||
|
||||
err = _do.LeftJoin(&_a, primaryKey.EqCol(_aPK)).Scan(map[string]interface{}{})
|
||||
if err != nil {
|
||||
t.Error("LeftJoin() on table <authors> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Not().Or().Clauses().Take()
|
||||
if err != nil {
|
||||
t.Error("Not/Or/Clauses on table <authors> fail:", err)
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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 <comments> 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 <comments> fail:", err)
|
||||
}
|
||||
|
||||
err = _do.Save(&models.Comment{})
|
||||
if err != nil {
|
||||
t.Error("create item in table <comments> fail:", err)
|
||||
}
|
||||
|
||||
err = _do.CreateInBatches([]*models.Comment{{}, {}}, 10)
|
||||
if err != nil {
|
||||
t.Error("create item in table <comments> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Select(comment.ALL).Take()
|
||||
if err != nil {
|
||||
t.Error("Take() on table <comments> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.First()
|
||||
if err != nil {
|
||||
t.Error("First() on table <comments> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Last()
|
||||
if err != nil {
|
||||
t.Error("First() on table <comments> 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 <comments> 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 <comments> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Select(comment.ALL).Where(primaryKey.IsNotNull()).Order(primaryKey.Desc()).Find()
|
||||
if err != nil {
|
||||
t.Error("Find() on table <comments> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Distinct(primaryKey).Take()
|
||||
if err != nil {
|
||||
t.Error("select Distinct() on table <comments> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Select(comment.ALL).Omit(primaryKey).Take()
|
||||
if err != nil {
|
||||
t.Error("Omit() on table <comments> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Group(primaryKey).Find()
|
||||
if err != nil {
|
||||
t.Error("Group() on table <comments> 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 <comments> fail:", err)
|
||||
}
|
||||
|
||||
_, _, err = _do.FindByPage(0, 1)
|
||||
if err != nil {
|
||||
t.Error("FindByPage() on table <comments> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.ScanByPage(&models.Comment{}, 0, 1)
|
||||
if err != nil {
|
||||
t.Error("ScanByPage() on table <comments> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrInit()
|
||||
if err != nil {
|
||||
t.Error("FirstOrInit() on table <comments> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrCreate()
|
||||
if err != nil {
|
||||
t.Error("FirstOrCreate() on table <comments> 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 <comments> fail:", err)
|
||||
}
|
||||
|
||||
err = _do.LeftJoin(&_a, primaryKey.EqCol(_aPK)).Scan(map[string]interface{}{})
|
||||
if err != nil {
|
||||
t.Error("LeftJoin() on table <comments> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Not().Or().Clauses().Take()
|
||||
if err != nil {
|
||||
t.Error("Not/Or/Clauses on table <comments> fail:", err)
|
||||
}
|
||||
}
|
||||
891
internal/dal/customers.gen.go
Normal file
891
internal/dal/customers.gen.go
Normal file
@@ -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
|
||||
}
|
||||
145
internal/dal/customers.gen_test.go
Normal file
145
internal/dal/customers.gen_test.go
Normal file
@@ -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 <customers> 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 <customers> fail:", err)
|
||||
}
|
||||
|
||||
err = _do.Save(&models.Customer{})
|
||||
if err != nil {
|
||||
t.Error("create item in table <customers> fail:", err)
|
||||
}
|
||||
|
||||
err = _do.CreateInBatches([]*models.Customer{{}, {}}, 10)
|
||||
if err != nil {
|
||||
t.Error("create item in table <customers> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Select(customer.ALL).Take()
|
||||
if err != nil {
|
||||
t.Error("Take() on table <customers> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.First()
|
||||
if err != nil {
|
||||
t.Error("First() on table <customers> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Last()
|
||||
if err != nil {
|
||||
t.Error("First() on table <customers> 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 <customers> 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 <customers> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Select(customer.ALL).Where(primaryKey.IsNotNull()).Order(primaryKey.Desc()).Find()
|
||||
if err != nil {
|
||||
t.Error("Find() on table <customers> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Distinct(primaryKey).Take()
|
||||
if err != nil {
|
||||
t.Error("select Distinct() on table <customers> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Select(customer.ALL).Omit(primaryKey).Take()
|
||||
if err != nil {
|
||||
t.Error("Omit() on table <customers> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Group(primaryKey).Find()
|
||||
if err != nil {
|
||||
t.Error("Group() on table <customers> 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 <customers> fail:", err)
|
||||
}
|
||||
|
||||
_, _, err = _do.FindByPage(0, 1)
|
||||
if err != nil {
|
||||
t.Error("FindByPage() on table <customers> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.ScanByPage(&models.Customer{}, 0, 1)
|
||||
if err != nil {
|
||||
t.Error("ScanByPage() on table <customers> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrInit()
|
||||
if err != nil {
|
||||
t.Error("FirstOrInit() on table <customers> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrCreate()
|
||||
if err != nil {
|
||||
t.Error("FirstOrCreate() on table <customers> 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 <customers> fail:", err)
|
||||
}
|
||||
|
||||
err = _do.LeftJoin(&_a, primaryKey.EqCol(_aPK)).Scan(map[string]interface{}{})
|
||||
if err != nil {
|
||||
t.Error("LeftJoin() on table <customers> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Not().Or().Clauses().Take()
|
||||
if err != nil {
|
||||
t.Error("Not/Or/Clauses on table <customers> fail:", err)
|
||||
}
|
||||
}
|
||||
@@ -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),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
@@ -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)
|
||||
|
||||
1018
internal/dal/orders.gen.go
Normal file
1018
internal/dal/orders.gen.go
Normal file
File diff suppressed because it is too large
Load Diff
145
internal/dal/orders.gen_test.go
Normal file
145
internal/dal/orders.gen_test.go
Normal file
@@ -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 <orders> 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 <orders> fail:", err)
|
||||
}
|
||||
|
||||
err = _do.Save(&models.Order{})
|
||||
if err != nil {
|
||||
t.Error("create item in table <orders> fail:", err)
|
||||
}
|
||||
|
||||
err = _do.CreateInBatches([]*models.Order{{}, {}}, 10)
|
||||
if err != nil {
|
||||
t.Error("create item in table <orders> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Select(order.ALL).Take()
|
||||
if err != nil {
|
||||
t.Error("Take() on table <orders> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.First()
|
||||
if err != nil {
|
||||
t.Error("First() on table <orders> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Last()
|
||||
if err != nil {
|
||||
t.Error("First() on table <orders> 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 <orders> 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 <orders> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Select(order.ALL).Where(primaryKey.IsNotNull()).Order(primaryKey.Desc()).Find()
|
||||
if err != nil {
|
||||
t.Error("Find() on table <orders> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Distinct(primaryKey).Take()
|
||||
if err != nil {
|
||||
t.Error("select Distinct() on table <orders> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Select(order.ALL).Omit(primaryKey).Take()
|
||||
if err != nil {
|
||||
t.Error("Omit() on table <orders> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Group(primaryKey).Find()
|
||||
if err != nil {
|
||||
t.Error("Group() on table <orders> 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 <orders> fail:", err)
|
||||
}
|
||||
|
||||
_, _, err = _do.FindByPage(0, 1)
|
||||
if err != nil {
|
||||
t.Error("FindByPage() on table <orders> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.ScanByPage(&models.Order{}, 0, 1)
|
||||
if err != nil {
|
||||
t.Error("ScanByPage() on table <orders> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrInit()
|
||||
if err != nil {
|
||||
t.Error("FirstOrInit() on table <orders> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrCreate()
|
||||
if err != nil {
|
||||
t.Error("FirstOrCreate() on table <orders> 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 <orders> fail:", err)
|
||||
}
|
||||
|
||||
err = _do.LeftJoin(&_a, primaryKey.EqCol(_aPK)).Scan(map[string]interface{}{})
|
||||
if err != nil {
|
||||
t.Error("LeftJoin() on table <orders> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Not().Or().Clauses().Take()
|
||||
if err != nil {
|
||||
t.Error("Not/Or/Clauses on table <orders> fail:", err)
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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 <post_types> 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 <post_types> fail:", err)
|
||||
}
|
||||
|
||||
err = _do.Save(&models.PostType{})
|
||||
if err != nil {
|
||||
t.Error("create item in table <post_types> fail:", err)
|
||||
}
|
||||
|
||||
err = _do.CreateInBatches([]*models.PostType{{}, {}}, 10)
|
||||
if err != nil {
|
||||
t.Error("create item in table <post_types> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Select(postType.ALL).Take()
|
||||
if err != nil {
|
||||
t.Error("Take() on table <post_types> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.First()
|
||||
if err != nil {
|
||||
t.Error("First() on table <post_types> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Last()
|
||||
if err != nil {
|
||||
t.Error("First() on table <post_types> 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 <post_types> 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 <post_types> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Select(postType.ALL).Where(primaryKey.IsNotNull()).Order(primaryKey.Desc()).Find()
|
||||
if err != nil {
|
||||
t.Error("Find() on table <post_types> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Distinct(primaryKey).Take()
|
||||
if err != nil {
|
||||
t.Error("select Distinct() on table <post_types> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Select(postType.ALL).Omit(primaryKey).Take()
|
||||
if err != nil {
|
||||
t.Error("Omit() on table <post_types> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Group(primaryKey).Find()
|
||||
if err != nil {
|
||||
t.Error("Group() on table <post_types> 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 <post_types> fail:", err)
|
||||
}
|
||||
|
||||
_, _, err = _do.FindByPage(0, 1)
|
||||
if err != nil {
|
||||
t.Error("FindByPage() on table <post_types> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.ScanByPage(&models.PostType{}, 0, 1)
|
||||
if err != nil {
|
||||
t.Error("ScanByPage() on table <post_types> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrInit()
|
||||
if err != nil {
|
||||
t.Error("FirstOrInit() on table <post_types> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrCreate()
|
||||
if err != nil {
|
||||
t.Error("FirstOrCreate() on table <post_types> 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 <post_types> fail:", err)
|
||||
}
|
||||
|
||||
err = _do.LeftJoin(&_a, primaryKey.EqCol(_aPK)).Scan(map[string]interface{}{})
|
||||
if err != nil {
|
||||
t.Error("LeftJoin() on table <post_types> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Not().Or().Clauses().Take()
|
||||
if err != nil {
|
||||
t.Error("Not/Or/Clauses on table <post_types> fail:", err)
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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 <posts> 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 <posts> fail:", err)
|
||||
}
|
||||
|
||||
err = _do.Save(&models.Post{})
|
||||
if err != nil {
|
||||
t.Error("create item in table <posts> fail:", err)
|
||||
}
|
||||
|
||||
err = _do.CreateInBatches([]*models.Post{{}, {}}, 10)
|
||||
if err != nil {
|
||||
t.Error("create item in table <posts> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Select(post.ALL).Take()
|
||||
if err != nil {
|
||||
t.Error("Take() on table <posts> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.First()
|
||||
if err != nil {
|
||||
t.Error("First() on table <posts> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Last()
|
||||
if err != nil {
|
||||
t.Error("First() on table <posts> 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 <posts> 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 <posts> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Select(post.ALL).Where(primaryKey.IsNotNull()).Order(primaryKey.Desc()).Find()
|
||||
if err != nil {
|
||||
t.Error("Find() on table <posts> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Distinct(primaryKey).Take()
|
||||
if err != nil {
|
||||
t.Error("select Distinct() on table <posts> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Select(post.ALL).Omit(primaryKey).Take()
|
||||
if err != nil {
|
||||
t.Error("Omit() on table <posts> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Group(primaryKey).Find()
|
||||
if err != nil {
|
||||
t.Error("Group() on table <posts> 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 <posts> fail:", err)
|
||||
}
|
||||
|
||||
_, _, err = _do.FindByPage(0, 1)
|
||||
if err != nil {
|
||||
t.Error("FindByPage() on table <posts> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.ScanByPage(&models.Post{}, 0, 1)
|
||||
if err != nil {
|
||||
t.Error("ScanByPage() on table <posts> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrInit()
|
||||
if err != nil {
|
||||
t.Error("FirstOrInit() on table <posts> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrCreate()
|
||||
if err != nil {
|
||||
t.Error("FirstOrCreate() on table <posts> 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 <posts> fail:", err)
|
||||
}
|
||||
|
||||
err = _do.LeftJoin(&_a, primaryKey.EqCol(_aPK)).Scan(map[string]interface{}{})
|
||||
if err != nil {
|
||||
t.Error("LeftJoin() on table <posts> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Not().Or().Clauses().Take()
|
||||
if err != nil {
|
||||
t.Error("Not/Or/Clauses on table <posts> fail:", err)
|
||||
}
|
||||
}
|
||||
935
internal/dal/prep_tasks.gen.go
Normal file
935
internal/dal/prep_tasks.gen.go
Normal file
@@ -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
|
||||
}
|
||||
145
internal/dal/prep_tasks.gen_test.go
Normal file
145
internal/dal/prep_tasks.gen_test.go
Normal file
@@ -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 <prep_tasks> 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 <prep_tasks> fail:", err)
|
||||
}
|
||||
|
||||
err = _do.Save(&models.PrepTask{})
|
||||
if err != nil {
|
||||
t.Error("create item in table <prep_tasks> fail:", err)
|
||||
}
|
||||
|
||||
err = _do.CreateInBatches([]*models.PrepTask{{}, {}}, 10)
|
||||
if err != nil {
|
||||
t.Error("create item in table <prep_tasks> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Select(prepTask.ALL).Take()
|
||||
if err != nil {
|
||||
t.Error("Take() on table <prep_tasks> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.First()
|
||||
if err != nil {
|
||||
t.Error("First() on table <prep_tasks> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Last()
|
||||
if err != nil {
|
||||
t.Error("First() on table <prep_tasks> 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 <prep_tasks> 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 <prep_tasks> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Select(prepTask.ALL).Where(primaryKey.IsNotNull()).Order(primaryKey.Desc()).Find()
|
||||
if err != nil {
|
||||
t.Error("Find() on table <prep_tasks> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Distinct(primaryKey).Take()
|
||||
if err != nil {
|
||||
t.Error("select Distinct() on table <prep_tasks> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Select(prepTask.ALL).Omit(primaryKey).Take()
|
||||
if err != nil {
|
||||
t.Error("Omit() on table <prep_tasks> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Group(primaryKey).Find()
|
||||
if err != nil {
|
||||
t.Error("Group() on table <prep_tasks> 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 <prep_tasks> fail:", err)
|
||||
}
|
||||
|
||||
_, _, err = _do.FindByPage(0, 1)
|
||||
if err != nil {
|
||||
t.Error("FindByPage() on table <prep_tasks> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.ScanByPage(&models.PrepTask{}, 0, 1)
|
||||
if err != nil {
|
||||
t.Error("ScanByPage() on table <prep_tasks> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrInit()
|
||||
if err != nil {
|
||||
t.Error("FirstOrInit() on table <prep_tasks> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrCreate()
|
||||
if err != nil {
|
||||
t.Error("FirstOrCreate() on table <prep_tasks> 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 <prep_tasks> fail:", err)
|
||||
}
|
||||
|
||||
err = _do.LeftJoin(&_a, primaryKey.EqCol(_aPK)).Scan(map[string]interface{}{})
|
||||
if err != nil {
|
||||
t.Error("LeftJoin() on table <prep_tasks> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Not().Or().Clauses().Take()
|
||||
if err != nil {
|
||||
t.Error("Not/Or/Clauses on table <prep_tasks> fail:", err)
|
||||
}
|
||||
}
|
||||
383
internal/dal/product_types.gen.go
Normal file
383
internal/dal/product_types.gen.go
Normal file
@@ -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
|
||||
}
|
||||
145
internal/dal/product_types.gen_test.go
Normal file
145
internal/dal/product_types.gen_test.go
Normal file
@@ -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 <product_types> 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 <product_types> fail:", err)
|
||||
}
|
||||
|
||||
err = _do.Save(&models.ProductType{})
|
||||
if err != nil {
|
||||
t.Error("create item in table <product_types> fail:", err)
|
||||
}
|
||||
|
||||
err = _do.CreateInBatches([]*models.ProductType{{}, {}}, 10)
|
||||
if err != nil {
|
||||
t.Error("create item in table <product_types> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Select(productType.ALL).Take()
|
||||
if err != nil {
|
||||
t.Error("Take() on table <product_types> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.First()
|
||||
if err != nil {
|
||||
t.Error("First() on table <product_types> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Last()
|
||||
if err != nil {
|
||||
t.Error("First() on table <product_types> 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 <product_types> 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 <product_types> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Select(productType.ALL).Where(primaryKey.IsNotNull()).Order(primaryKey.Desc()).Find()
|
||||
if err != nil {
|
||||
t.Error("Find() on table <product_types> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Distinct(primaryKey).Take()
|
||||
if err != nil {
|
||||
t.Error("select Distinct() on table <product_types> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Select(productType.ALL).Omit(primaryKey).Take()
|
||||
if err != nil {
|
||||
t.Error("Omit() on table <product_types> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Group(primaryKey).Find()
|
||||
if err != nil {
|
||||
t.Error("Group() on table <product_types> 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 <product_types> fail:", err)
|
||||
}
|
||||
|
||||
_, _, err = _do.FindByPage(0, 1)
|
||||
if err != nil {
|
||||
t.Error("FindByPage() on table <product_types> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.ScanByPage(&models.ProductType{}, 0, 1)
|
||||
if err != nil {
|
||||
t.Error("ScanByPage() on table <product_types> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrInit()
|
||||
if err != nil {
|
||||
t.Error("FirstOrInit() on table <product_types> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrCreate()
|
||||
if err != nil {
|
||||
t.Error("FirstOrCreate() on table <product_types> 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 <product_types> fail:", err)
|
||||
}
|
||||
|
||||
err = _do.LeftJoin(&_a, primaryKey.EqCol(_aPK)).Scan(map[string]interface{}{})
|
||||
if err != nil {
|
||||
t.Error("LeftJoin() on table <product_types> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Not().Or().Clauses().Take()
|
||||
if err != nil {
|
||||
t.Error("Not/Or/Clauses on table <product_types> fail:", err)
|
||||
}
|
||||
}
|
||||
905
internal/dal/shifts.gen.go
Normal file
905
internal/dal/shifts.gen.go
Normal file
@@ -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
|
||||
}
|
||||
145
internal/dal/shifts.gen_test.go
Normal file
145
internal/dal/shifts.gen_test.go
Normal file
@@ -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 <shifts> 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 <shifts> fail:", err)
|
||||
}
|
||||
|
||||
err = _do.Save(&models.Shift{})
|
||||
if err != nil {
|
||||
t.Error("create item in table <shifts> fail:", err)
|
||||
}
|
||||
|
||||
err = _do.CreateInBatches([]*models.Shift{{}, {}}, 10)
|
||||
if err != nil {
|
||||
t.Error("create item in table <shifts> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Select(shift.ALL).Take()
|
||||
if err != nil {
|
||||
t.Error("Take() on table <shifts> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.First()
|
||||
if err != nil {
|
||||
t.Error("First() on table <shifts> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Last()
|
||||
if err != nil {
|
||||
t.Error("First() on table <shifts> 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 <shifts> fail:", err)
|
||||
}
|
||||
|
||||
err = _do.Where(primaryKey.IsNotNull()).FindInBatches(&[]*models.Shift{}, 10, func(tx gen.Dao, batch int) error { return nil })
|
||||
if err != nil {
|
||||
t.Error("FindInBatches() on table <shifts> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Select(shift.ALL).Where(primaryKey.IsNotNull()).Order(primaryKey.Desc()).Find()
|
||||
if err != nil {
|
||||
t.Error("Find() on table <shifts> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Distinct(primaryKey).Take()
|
||||
if err != nil {
|
||||
t.Error("select Distinct() on table <shifts> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Select(shift.ALL).Omit(primaryKey).Take()
|
||||
if err != nil {
|
||||
t.Error("Omit() on table <shifts> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Group(primaryKey).Find()
|
||||
if err != nil {
|
||||
t.Error("Group() on table <shifts> 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 <shifts> fail:", err)
|
||||
}
|
||||
|
||||
_, _, err = _do.FindByPage(0, 1)
|
||||
if err != nil {
|
||||
t.Error("FindByPage() on table <shifts> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.ScanByPage(&models.Shift{}, 0, 1)
|
||||
if err != nil {
|
||||
t.Error("ScanByPage() on table <shifts> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrInit()
|
||||
if err != nil {
|
||||
t.Error("FirstOrInit() on table <shifts> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrCreate()
|
||||
if err != nil {
|
||||
t.Error("FirstOrCreate() on table <shifts> 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 <shifts> fail:", err)
|
||||
}
|
||||
|
||||
err = _do.LeftJoin(&_a, primaryKey.EqCol(_aPK)).Scan(map[string]interface{}{})
|
||||
if err != nil {
|
||||
t.Error("LeftJoin() on table <shifts> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Not().Or().Clauses().Take()
|
||||
if err != nil {
|
||||
t.Error("Not/Or/Clauses on table <shifts> fail:", err)
|
||||
}
|
||||
}
|
||||
1114
internal/dal/tasks.gen.go
Normal file
1114
internal/dal/tasks.gen.go
Normal file
File diff suppressed because it is too large
Load Diff
145
internal/dal/tasks.gen_test.go
Normal file
145
internal/dal/tasks.gen_test.go
Normal file
@@ -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.Task{})
|
||||
if err != nil {
|
||||
fmt.Printf("Error: AutoMigrate(&models.Task{}) fail: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func Test_taskQuery(t *testing.T) {
|
||||
task := newTask(_gen_test_db)
|
||||
task = *task.As(task.TableName())
|
||||
_do := task.WithContext(context.Background()).Debug()
|
||||
|
||||
primaryKey := field.NewString(task.TableName(), clause.PrimaryKey)
|
||||
_, err := _do.Unscoped().Where(primaryKey.IsNotNull()).Delete()
|
||||
if err != nil {
|
||||
t.Error("clean table <tasks> fail:", err)
|
||||
return
|
||||
}
|
||||
|
||||
_, ok := task.GetFieldByName("")
|
||||
if ok {
|
||||
t.Error("GetFieldByName(\"\") from task success")
|
||||
}
|
||||
|
||||
err = _do.Create(&models.Task{})
|
||||
if err != nil {
|
||||
t.Error("create item in table <tasks> fail:", err)
|
||||
}
|
||||
|
||||
err = _do.Save(&models.Task{})
|
||||
if err != nil {
|
||||
t.Error("create item in table <tasks> fail:", err)
|
||||
}
|
||||
|
||||
err = _do.CreateInBatches([]*models.Task{{}, {}}, 10)
|
||||
if err != nil {
|
||||
t.Error("create item in table <tasks> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Select(task.ALL).Take()
|
||||
if err != nil {
|
||||
t.Error("Take() on table <tasks> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.First()
|
||||
if err != nil {
|
||||
t.Error("First() on table <tasks> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Last()
|
||||
if err != nil {
|
||||
t.Error("First() on table <tasks> 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 <tasks> fail:", err)
|
||||
}
|
||||
|
||||
err = _do.Where(primaryKey.IsNotNull()).FindInBatches(&[]*models.Task{}, 10, func(tx gen.Dao, batch int) error { return nil })
|
||||
if err != nil {
|
||||
t.Error("FindInBatches() on table <tasks> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Select(task.ALL).Where(primaryKey.IsNotNull()).Order(primaryKey.Desc()).Find()
|
||||
if err != nil {
|
||||
t.Error("Find() on table <tasks> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Distinct(primaryKey).Take()
|
||||
if err != nil {
|
||||
t.Error("select Distinct() on table <tasks> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Select(task.ALL).Omit(primaryKey).Take()
|
||||
if err != nil {
|
||||
t.Error("Omit() on table <tasks> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Group(primaryKey).Find()
|
||||
if err != nil {
|
||||
t.Error("Group() on table <tasks> 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 <tasks> fail:", err)
|
||||
}
|
||||
|
||||
_, _, err = _do.FindByPage(0, 1)
|
||||
if err != nil {
|
||||
t.Error("FindByPage() on table <tasks> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.ScanByPage(&models.Task{}, 0, 1)
|
||||
if err != nil {
|
||||
t.Error("ScanByPage() on table <tasks> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrInit()
|
||||
if err != nil {
|
||||
t.Error("FirstOrInit() on table <tasks> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrCreate()
|
||||
if err != nil {
|
||||
t.Error("FirstOrCreate() on table <tasks> 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 <tasks> fail:", err)
|
||||
}
|
||||
|
||||
err = _do.LeftJoin(&_a, primaryKey.EqCol(_aPK)).Scan(map[string]interface{}{})
|
||||
if err != nil {
|
||||
t.Error("LeftJoin() on table <tasks> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Not().Or().Clauses().Take()
|
||||
if err != nil {
|
||||
t.Error("Not/Or/Clauses on table <tasks> fail:", err)
|
||||
}
|
||||
}
|
||||
1131
internal/dal/team_tasks.gen.go
Normal file
1131
internal/dal/team_tasks.gen.go
Normal file
File diff suppressed because it is too large
Load Diff
145
internal/dal/team_tasks.gen_test.go
Normal file
145
internal/dal/team_tasks.gen_test.go
Normal file
@@ -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.TeamTask{})
|
||||
if err != nil {
|
||||
fmt.Printf("Error: AutoMigrate(&models.TeamTask{}) fail: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func Test_teamTaskQuery(t *testing.T) {
|
||||
teamTask := newTeamTask(_gen_test_db)
|
||||
teamTask = *teamTask.As(teamTask.TableName())
|
||||
_do := teamTask.WithContext(context.Background()).Debug()
|
||||
|
||||
primaryKey := field.NewString(teamTask.TableName(), clause.PrimaryKey)
|
||||
_, err := _do.Unscoped().Where(primaryKey.IsNotNull()).Delete()
|
||||
if err != nil {
|
||||
t.Error("clean table <team_tasks> fail:", err)
|
||||
return
|
||||
}
|
||||
|
||||
_, ok := teamTask.GetFieldByName("")
|
||||
if ok {
|
||||
t.Error("GetFieldByName(\"\") from teamTask success")
|
||||
}
|
||||
|
||||
err = _do.Create(&models.TeamTask{})
|
||||
if err != nil {
|
||||
t.Error("create item in table <team_tasks> fail:", err)
|
||||
}
|
||||
|
||||
err = _do.Save(&models.TeamTask{})
|
||||
if err != nil {
|
||||
t.Error("create item in table <team_tasks> fail:", err)
|
||||
}
|
||||
|
||||
err = _do.CreateInBatches([]*models.TeamTask{{}, {}}, 10)
|
||||
if err != nil {
|
||||
t.Error("create item in table <team_tasks> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Select(teamTask.ALL).Take()
|
||||
if err != nil {
|
||||
t.Error("Take() on table <team_tasks> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.First()
|
||||
if err != nil {
|
||||
t.Error("First() on table <team_tasks> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Last()
|
||||
if err != nil {
|
||||
t.Error("First() on table <team_tasks> 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 <team_tasks> fail:", err)
|
||||
}
|
||||
|
||||
err = _do.Where(primaryKey.IsNotNull()).FindInBatches(&[]*models.TeamTask{}, 10, func(tx gen.Dao, batch int) error { return nil })
|
||||
if err != nil {
|
||||
t.Error("FindInBatches() on table <team_tasks> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Select(teamTask.ALL).Where(primaryKey.IsNotNull()).Order(primaryKey.Desc()).Find()
|
||||
if err != nil {
|
||||
t.Error("Find() on table <team_tasks> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Distinct(primaryKey).Take()
|
||||
if err != nil {
|
||||
t.Error("select Distinct() on table <team_tasks> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Select(teamTask.ALL).Omit(primaryKey).Take()
|
||||
if err != nil {
|
||||
t.Error("Omit() on table <team_tasks> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Group(primaryKey).Find()
|
||||
if err != nil {
|
||||
t.Error("Group() on table <team_tasks> 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 <team_tasks> fail:", err)
|
||||
}
|
||||
|
||||
_, _, err = _do.FindByPage(0, 1)
|
||||
if err != nil {
|
||||
t.Error("FindByPage() on table <team_tasks> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.ScanByPage(&models.TeamTask{}, 0, 1)
|
||||
if err != nil {
|
||||
t.Error("ScanByPage() on table <team_tasks> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrInit()
|
||||
if err != nil {
|
||||
t.Error("FirstOrInit() on table <team_tasks> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrCreate()
|
||||
if err != nil {
|
||||
t.Error("FirstOrCreate() on table <team_tasks> 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 <team_tasks> fail:", err)
|
||||
}
|
||||
|
||||
err = _do.LeftJoin(&_a, primaryKey.EqCol(_aPK)).Scan(map[string]interface{}{})
|
||||
if err != nil {
|
||||
t.Error("LeftJoin() on table <team_tasks> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Not().Or().Clauses().Take()
|
||||
if err != nil {
|
||||
t.Error("Not/Or/Clauses on table <team_tasks> fail:", err)
|
||||
}
|
||||
}
|
||||
383
internal/dal/team_types.gen.go
Normal file
383
internal/dal/team_types.gen.go
Normal file
@@ -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 newTeamType(db *gorm.DB, opts ...gen.DOOption) teamType {
|
||||
_teamType := teamType{}
|
||||
|
||||
_teamType.teamTypeDo.UseDB(db, opts...)
|
||||
_teamType.teamTypeDo.UseModel(&models.TeamType{})
|
||||
|
||||
tableName := _teamType.teamTypeDo.TableName()
|
||||
_teamType.ALL = field.NewAsterisk(tableName)
|
||||
_teamType.Id = field.NewUint(tableName, "id")
|
||||
_teamType.Name = field.NewString(tableName, "name")
|
||||
|
||||
_teamType.fillFieldMap()
|
||||
|
||||
return _teamType
|
||||
}
|
||||
|
||||
type teamType struct {
|
||||
teamTypeDo
|
||||
|
||||
ALL field.Asterisk
|
||||
Id field.Uint
|
||||
Name field.String
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (t teamType) Table(newTableName string) *teamType {
|
||||
t.teamTypeDo.UseTable(newTableName)
|
||||
return t.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (t teamType) As(alias string) *teamType {
|
||||
t.teamTypeDo.DO = *(t.teamTypeDo.As(alias).(*gen.DO))
|
||||
return t.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (t *teamType) updateTableName(table string) *teamType {
|
||||
t.ALL = field.NewAsterisk(table)
|
||||
t.Id = field.NewUint(table, "id")
|
||||
t.Name = field.NewString(table, "name")
|
||||
|
||||
t.fillFieldMap()
|
||||
|
||||
return t
|
||||
}
|
||||
|
||||
func (t *teamType) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := t.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (t *teamType) fillFieldMap() {
|
||||
t.fieldMap = make(map[string]field.Expr, 2)
|
||||
t.fieldMap["id"] = t.Id
|
||||
t.fieldMap["name"] = t.Name
|
||||
}
|
||||
|
||||
func (t teamType) clone(db *gorm.DB) teamType {
|
||||
t.teamTypeDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return t
|
||||
}
|
||||
|
||||
func (t teamType) replaceDB(db *gorm.DB) teamType {
|
||||
t.teamTypeDo.ReplaceDB(db)
|
||||
return t
|
||||
}
|
||||
|
||||
type teamTypeDo struct{ gen.DO }
|
||||
|
||||
type ITeamTypeDo interface {
|
||||
gen.SubQuery
|
||||
Debug() ITeamTypeDo
|
||||
WithContext(ctx context.Context) ITeamTypeDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() ITeamTypeDo
|
||||
WriteDB() ITeamTypeDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) ITeamTypeDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) ITeamTypeDo
|
||||
Not(conds ...gen.Condition) ITeamTypeDo
|
||||
Or(conds ...gen.Condition) ITeamTypeDo
|
||||
Select(conds ...field.Expr) ITeamTypeDo
|
||||
Where(conds ...gen.Condition) ITeamTypeDo
|
||||
Order(conds ...field.Expr) ITeamTypeDo
|
||||
Distinct(cols ...field.Expr) ITeamTypeDo
|
||||
Omit(cols ...field.Expr) ITeamTypeDo
|
||||
Join(table schema.Tabler, on ...field.Expr) ITeamTypeDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) ITeamTypeDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) ITeamTypeDo
|
||||
Group(cols ...field.Expr) ITeamTypeDo
|
||||
Having(conds ...gen.Condition) ITeamTypeDo
|
||||
Limit(limit int) ITeamTypeDo
|
||||
Offset(offset int) ITeamTypeDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) ITeamTypeDo
|
||||
Unscoped() ITeamTypeDo
|
||||
Create(values ...*models.TeamType) error
|
||||
CreateInBatches(values []*models.TeamType, batchSize int) error
|
||||
Save(values ...*models.TeamType) error
|
||||
First() (*models.TeamType, error)
|
||||
Take() (*models.TeamType, error)
|
||||
Last() (*models.TeamType, error)
|
||||
Find() ([]*models.TeamType, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.TeamType, err error)
|
||||
FindInBatches(result *[]*models.TeamType, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*models.TeamType) (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) ITeamTypeDo
|
||||
Assign(attrs ...field.AssignExpr) ITeamTypeDo
|
||||
Joins(fields ...field.RelationField) ITeamTypeDo
|
||||
Preload(fields ...field.RelationField) ITeamTypeDo
|
||||
FirstOrInit() (*models.TeamType, error)
|
||||
FirstOrCreate() (*models.TeamType, error)
|
||||
FindByPage(offset int, limit int) (result []*models.TeamType, 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) ITeamTypeDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (t teamTypeDo) Debug() ITeamTypeDo {
|
||||
return t.withDO(t.DO.Debug())
|
||||
}
|
||||
|
||||
func (t teamTypeDo) WithContext(ctx context.Context) ITeamTypeDo {
|
||||
return t.withDO(t.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (t teamTypeDo) ReadDB() ITeamTypeDo {
|
||||
return t.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (t teamTypeDo) WriteDB() ITeamTypeDo {
|
||||
return t.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (t teamTypeDo) Session(config *gorm.Session) ITeamTypeDo {
|
||||
return t.withDO(t.DO.Session(config))
|
||||
}
|
||||
|
||||
func (t teamTypeDo) Clauses(conds ...clause.Expression) ITeamTypeDo {
|
||||
return t.withDO(t.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (t teamTypeDo) Returning(value interface{}, columns ...string) ITeamTypeDo {
|
||||
return t.withDO(t.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (t teamTypeDo) Not(conds ...gen.Condition) ITeamTypeDo {
|
||||
return t.withDO(t.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (t teamTypeDo) Or(conds ...gen.Condition) ITeamTypeDo {
|
||||
return t.withDO(t.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (t teamTypeDo) Select(conds ...field.Expr) ITeamTypeDo {
|
||||
return t.withDO(t.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (t teamTypeDo) Where(conds ...gen.Condition) ITeamTypeDo {
|
||||
return t.withDO(t.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (t teamTypeDo) Order(conds ...field.Expr) ITeamTypeDo {
|
||||
return t.withDO(t.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (t teamTypeDo) Distinct(cols ...field.Expr) ITeamTypeDo {
|
||||
return t.withDO(t.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (t teamTypeDo) Omit(cols ...field.Expr) ITeamTypeDo {
|
||||
return t.withDO(t.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (t teamTypeDo) Join(table schema.Tabler, on ...field.Expr) ITeamTypeDo {
|
||||
return t.withDO(t.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (t teamTypeDo) LeftJoin(table schema.Tabler, on ...field.Expr) ITeamTypeDo {
|
||||
return t.withDO(t.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (t teamTypeDo) RightJoin(table schema.Tabler, on ...field.Expr) ITeamTypeDo {
|
||||
return t.withDO(t.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (t teamTypeDo) Group(cols ...field.Expr) ITeamTypeDo {
|
||||
return t.withDO(t.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (t teamTypeDo) Having(conds ...gen.Condition) ITeamTypeDo {
|
||||
return t.withDO(t.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (t teamTypeDo) Limit(limit int) ITeamTypeDo {
|
||||
return t.withDO(t.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (t teamTypeDo) Offset(offset int) ITeamTypeDo {
|
||||
return t.withDO(t.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (t teamTypeDo) Scopes(funcs ...func(gen.Dao) gen.Dao) ITeamTypeDo {
|
||||
return t.withDO(t.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (t teamTypeDo) Unscoped() ITeamTypeDo {
|
||||
return t.withDO(t.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (t teamTypeDo) Create(values ...*models.TeamType) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return t.DO.Create(values)
|
||||
}
|
||||
|
||||
func (t teamTypeDo) CreateInBatches(values []*models.TeamType, batchSize int) error {
|
||||
return t.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 (t teamTypeDo) Save(values ...*models.TeamType) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return t.DO.Save(values)
|
||||
}
|
||||
|
||||
func (t teamTypeDo) First() (*models.TeamType, error) {
|
||||
if result, err := t.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.TeamType), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (t teamTypeDo) Take() (*models.TeamType, error) {
|
||||
if result, err := t.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.TeamType), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (t teamTypeDo) Last() (*models.TeamType, error) {
|
||||
if result, err := t.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.TeamType), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (t teamTypeDo) Find() ([]*models.TeamType, error) {
|
||||
result, err := t.DO.Find()
|
||||
return result.([]*models.TeamType), err
|
||||
}
|
||||
|
||||
func (t teamTypeDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.TeamType, err error) {
|
||||
buf := make([]*models.TeamType, 0, batchSize)
|
||||
err = t.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 (t teamTypeDo) FindInBatches(result *[]*models.TeamType, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return t.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (t teamTypeDo) Attrs(attrs ...field.AssignExpr) ITeamTypeDo {
|
||||
return t.withDO(t.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (t teamTypeDo) Assign(attrs ...field.AssignExpr) ITeamTypeDo {
|
||||
return t.withDO(t.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (t teamTypeDo) Joins(fields ...field.RelationField) ITeamTypeDo {
|
||||
for _, _f := range fields {
|
||||
t = *t.withDO(t.DO.Joins(_f))
|
||||
}
|
||||
return &t
|
||||
}
|
||||
|
||||
func (t teamTypeDo) Preload(fields ...field.RelationField) ITeamTypeDo {
|
||||
for _, _f := range fields {
|
||||
t = *t.withDO(t.DO.Preload(_f))
|
||||
}
|
||||
return &t
|
||||
}
|
||||
|
||||
func (t teamTypeDo) FirstOrInit() (*models.TeamType, error) {
|
||||
if result, err := t.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.TeamType), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (t teamTypeDo) FirstOrCreate() (*models.TeamType, error) {
|
||||
if result, err := t.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.TeamType), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (t teamTypeDo) FindByPage(offset int, limit int) (result []*models.TeamType, count int64, err error) {
|
||||
result, err = t.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 = t.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (t teamTypeDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = t.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = t.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (t teamTypeDo) Scan(result interface{}) (err error) {
|
||||
return t.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (t teamTypeDo) Delete(models ...*models.TeamType) (result gen.ResultInfo, err error) {
|
||||
return t.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (t *teamTypeDo) withDO(do gen.Dao) *teamTypeDo {
|
||||
t.DO = *do.(*gen.DO)
|
||||
return t
|
||||
}
|
||||
145
internal/dal/team_types.gen_test.go
Normal file
145
internal/dal/team_types.gen_test.go
Normal file
@@ -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.TeamType{})
|
||||
if err != nil {
|
||||
fmt.Printf("Error: AutoMigrate(&models.TeamType{}) fail: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func Test_teamTypeQuery(t *testing.T) {
|
||||
teamType := newTeamType(_gen_test_db)
|
||||
teamType = *teamType.As(teamType.TableName())
|
||||
_do := teamType.WithContext(context.Background()).Debug()
|
||||
|
||||
primaryKey := field.NewString(teamType.TableName(), clause.PrimaryKey)
|
||||
_, err := _do.Unscoped().Where(primaryKey.IsNotNull()).Delete()
|
||||
if err != nil {
|
||||
t.Error("clean table <team_types> fail:", err)
|
||||
return
|
||||
}
|
||||
|
||||
_, ok := teamType.GetFieldByName("")
|
||||
if ok {
|
||||
t.Error("GetFieldByName(\"\") from teamType success")
|
||||
}
|
||||
|
||||
err = _do.Create(&models.TeamType{})
|
||||
if err != nil {
|
||||
t.Error("create item in table <team_types> fail:", err)
|
||||
}
|
||||
|
||||
err = _do.Save(&models.TeamType{})
|
||||
if err != nil {
|
||||
t.Error("create item in table <team_types> fail:", err)
|
||||
}
|
||||
|
||||
err = _do.CreateInBatches([]*models.TeamType{{}, {}}, 10)
|
||||
if err != nil {
|
||||
t.Error("create item in table <team_types> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Select(teamType.ALL).Take()
|
||||
if err != nil {
|
||||
t.Error("Take() on table <team_types> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.First()
|
||||
if err != nil {
|
||||
t.Error("First() on table <team_types> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Last()
|
||||
if err != nil {
|
||||
t.Error("First() on table <team_types> 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 <team_types> fail:", err)
|
||||
}
|
||||
|
||||
err = _do.Where(primaryKey.IsNotNull()).FindInBatches(&[]*models.TeamType{}, 10, func(tx gen.Dao, batch int) error { return nil })
|
||||
if err != nil {
|
||||
t.Error("FindInBatches() on table <team_types> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Select(teamType.ALL).Where(primaryKey.IsNotNull()).Order(primaryKey.Desc()).Find()
|
||||
if err != nil {
|
||||
t.Error("Find() on table <team_types> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Distinct(primaryKey).Take()
|
||||
if err != nil {
|
||||
t.Error("select Distinct() on table <team_types> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Select(teamType.ALL).Omit(primaryKey).Take()
|
||||
if err != nil {
|
||||
t.Error("Omit() on table <team_types> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Group(primaryKey).Find()
|
||||
if err != nil {
|
||||
t.Error("Group() on table <team_types> 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 <team_types> fail:", err)
|
||||
}
|
||||
|
||||
_, _, err = _do.FindByPage(0, 1)
|
||||
if err != nil {
|
||||
t.Error("FindByPage() on table <team_types> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.ScanByPage(&models.TeamType{}, 0, 1)
|
||||
if err != nil {
|
||||
t.Error("ScanByPage() on table <team_types> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrInit()
|
||||
if err != nil {
|
||||
t.Error("FirstOrInit() on table <team_types> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrCreate()
|
||||
if err != nil {
|
||||
t.Error("FirstOrCreate() on table <team_types> 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 <team_types> fail:", err)
|
||||
}
|
||||
|
||||
err = _do.LeftJoin(&_a, primaryKey.EqCol(_aPK)).Scan(map[string]interface{}{})
|
||||
if err != nil {
|
||||
t.Error("LeftJoin() on table <team_types> fail:", err)
|
||||
}
|
||||
|
||||
_, err = _do.Not().Or().Clauses().Take()
|
||||
if err != nil {
|
||||
t.Error("Not/Or/Clauses on table <team_types> fail:", err)
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user