diff --git a/db/schema.sql b/db/schema.sql new file mode 100644 index 0000000..7b4e8e8 --- /dev/null +++ b/db/schema.sql @@ -0,0 +1,143 @@ +CREATE TABLE IF NOT EXISTS `epic_artifact_info` ( + `id` BIGINT AUTO_INCREMENT NOT NULL PRIMARY KEY, + `artifact_name` VARCHAR(255) NOT NULL, + `artifact_code` VARCHAR(255) NOT NULL, + `creator` VARCHAR(255) NOT NULL, + `create_time` DATETIME NULL, + `updater` VARCHAR(255) NOT NULL, + `update_time` DATETIME NULL, + `deleted` TINYINT(1) NOT NULL, + `stats_health` INT NOT NULL, + `stats_attack` INT NOT NULL, + `stats_defense` INT NOT NULL, + `rarity` VARCHAR(255) NOT NULL, + `role` VARCHAR(255) NOT NULL, + `artifact_name_en` VARCHAR(255) NOT NULL, + `image_url` VARCHAR(255) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +CREATE TABLE IF NOT EXISTS `epic_gvg_attack_teams` ( + `id` BIGINT AUTO_INCREMENT NOT NULL PRIMARY KEY, + `attack_heroes` VARCHAR(255) NOT NULL, + `creator` VARCHAR(255) NOT NULL, + `create_time` DATETIME NULL, + `updater` VARCHAR(255) NOT NULL, + `update_time` DATETIME NULL, + `deleted` TINYINT(1) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +CREATE TABLE IF NOT EXISTS `epic_gvg_defense_attack_mapping` ( + `id` BIGINT AUTO_INCREMENT NOT NULL PRIMARY KEY, + `defense_id` BIGINT NOT NULL, + `attack_id` BIGINT NOT NULL, + `equipment_info` VARCHAR(255) NOT NULL, + `artifacts` VARCHAR(255) NOT NULL, + `battle_strategy` VARCHAR(255) NOT NULL, + `prerequisites` VARCHAR(255) NOT NULL, + `important_notes` VARCHAR(255) NOT NULL, + `creator` VARCHAR(255) NOT NULL, + `create_time` DATETIME NULL, + `updater` VARCHAR(255) NOT NULL, + `update_time` DATETIME NULL, + `deleted` TINYINT(1) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +CREATE TABLE IF NOT EXISTS `epic_gvg_defense_teams` ( + `id` BIGINT AUTO_INCREMENT NOT NULL PRIMARY KEY, + `defense_heroes` VARCHAR(255) NOT NULL, + `creator` VARCHAR(255) NOT NULL, + `create_time` DATETIME NULL, + `updater` VARCHAR(255) NOT NULL, + `update_time` DATETIME NULL, + `deleted` TINYINT(1) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +CREATE TABLE IF NOT EXISTS `epic_hero_info` ( + `id` BIGINT AUTO_INCREMENT NOT NULL PRIMARY KEY, + `hero_name` VARCHAR(255) NOT NULL, + `hero_code` VARCHAR(255) NOT NULL, + `hero_attr_lv60` VARCHAR(255) NOT NULL, + `creator` VARCHAR(255) NOT NULL, + `create_time` DATETIME NULL, + `updater` VARCHAR(255) NOT NULL, + `update_time` DATETIME NULL, + `deleted` TINYINT(1) NOT NULL, + `nick_name` VARCHAR(255) NOT NULL, + `rarity` VARCHAR(255) NOT NULL, + `role` VARCHAR(255) NOT NULL, + `zodiac` VARCHAR(255) NOT NULL, + `head_img_url` VARCHAR(255) NOT NULL, + `attribute` VARCHAR(255) NOT NULL, + `remark` VARCHAR(255) NOT NULL, + `raw_json` VARCHAR(255) NOT NULL, + `set_content_json` VARCHAR(255) NOT NULL, + `set_update_time` DATETIME NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +CREATE TABLE IF NOT EXISTS `epic_hero_user_build` ( + `id` BIGINT AUTO_INCREMENT NOT NULL PRIMARY KEY, + `artifact_code` VARCHAR(255) NOT NULL, + `hero_code` VARCHAR(255) NOT NULL, + `hero_heath_build` DOUBLE NOT NULL, + `hero_attack_build` DOUBLE NOT NULL, + `hero_def_build` DOUBLE NOT NULL, + `creator` VARCHAR(255) NOT NULL, + `create_time` DATETIME NULL, + `updater` VARCHAR(255) NOT NULL, + `update_time` DATETIME NULL, + `deleted` TINYINT(1) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +CREATE TABLE IF NOT EXISTS `epic_i18n_mappings` ( + `id` BIGINT AUTO_INCREMENT NOT NULL PRIMARY KEY, + `key_name` VARCHAR(255) NOT NULL, + `language` VARCHAR(255) NOT NULL, + `value` VARCHAR(255) NOT NULL, + `category` VARCHAR(255) NOT NULL, + `status` INT NOT NULL, + `creator` VARCHAR(255) NOT NULL, + `create_time` DATETIME NULL, + `updater` VARCHAR(255) NOT NULL, + `update_time` DATETIME NULL, + `deleted` INT NOT NULL, + `code` VARCHAR(255) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +CREATE TABLE IF NOT EXISTS `fribble_hero_set` ( + `id` BIGINT AUTO_INCREMENT NOT NULL PRIMARY KEY, + `hero_code` VARCHAR(255) NOT NULL, + `json_content` VARCHAR(255) NOT NULL, + `hero_name` VARCHAR(255) NOT NULL, + `creator` VARCHAR(255) NOT NULL, + `create_time` DATETIME NULL, + `updater` VARCHAR(255) NOT NULL, + `update_time` DATETIME NULL, + `deleted` TINYINT(1) NOT NULL, + `success_get` INT NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +CREATE TABLE IF NOT EXISTS `gear_set_info` ( + `id` BIGINT AUTO_INCREMENT NOT NULL PRIMARY KEY, + `level` INT NOT NULL, + `gear_id` BIGINT NOT NULL, + `enhance` INT NOT NULL, + `gear_type` VARCHAR(255) NOT NULL, + `gear_set_type` VARCHAR(255) NOT NULL, + `main_stat_type` VARCHAR(255) NOT NULL, + `main_stat_value` INT NOT NULL, + `sub_stat_one_type` VARCHAR(255) NOT NULL, + `sub_stat_one_value` INT NOT NULL, + `sub_stat_two_type` VARCHAR(255) NOT NULL, + `sub_stat_two_value` INT NOT NULL, + `sub_stat_three_type` VARCHAR(255) NOT NULL, + `sub_stat_three_value` INT NOT NULL, + `sub_stat_four_type` VARCHAR(255) NOT NULL, + `sub_stat_four_value` INT NOT NULL, + `account_code` VARCHAR(255) NOT NULL, + `creator` VARCHAR(255) NOT NULL, + `create_time` DATETIME NULL, + `updater` VARCHAR(255) NOT NULL, + `update_time` DATETIME NULL, + `deleted` TINYINT(1) NOT NULL, + `tenant_id` BIGINT NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; diff --git a/go.mod b/go.mod index 41b2d78..53a1c5b 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module epic-ent go 1.24.0 require ( + entgo.io/ent v0.14.5 github.com/go-sql-driver/mysql v1.9.3 github.com/labstack/echo/v4 v4.15.0 github.com/redis/go-redis/v9 v9.17.2 @@ -13,27 +14,38 @@ require ( ) require ( + ariga.io/atlas v0.32.1-0.20250325101103-175b25e1c1b9 // indirect filippo.io/edwards25519 v1.1.0 // indirect + github.com/agext/levenshtein v1.2.3 // indirect + github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect + github.com/bmatcuk/doublestar v1.3.4 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/fsnotify/fsnotify v1.9.0 // indirect + github.com/go-openapi/inflect v0.19.0 // indirect github.com/go-viper/mapstructure/v2 v2.5.0 // indirect + github.com/google/go-cmp v0.6.0 // indirect + github.com/google/uuid v1.3.0 // indirect + github.com/hashicorp/hcl/v2 v2.18.1 // indirect github.com/labstack/gommon v0.4.2 // indirect github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect + github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/pelletier/go-toml/v2 v2.2.4 // indirect github.com/sagikazarmark/locafero v0.12.0 // indirect - github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 // indirect github.com/spf13/afero v1.15.0 // indirect github.com/spf13/cast v1.10.0 // indirect github.com/spf13/pflag v1.0.10 // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasttemplate v1.2.2 // indirect + github.com/zclconf/go-cty v1.14.4 // indirect + github.com/zclconf/go-cty-yaml v1.1.0 // indirect go.uber.org/dig v1.19.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.yaml.in/yaml/v3 v3.0.4 // indirect golang.org/x/crypto v0.47.0 // indirect + golang.org/x/mod v0.31.0 // indirect golang.org/x/net v0.49.0 // indirect golang.org/x/sys v0.40.0 // indirect golang.org/x/text v0.33.0 // indirect diff --git a/go.sum b/go.sum index 95ca2bb..92c1524 100644 --- a/go.sum +++ b/go.sum @@ -1,17 +1,51 @@ +ariga.io/atlas v0.32.1-0.20250325101103-175b25e1c1b9 h1:E0wvcUXTkgyN4wy4LGtNzMNGMytJN8afmIWXJVMi4cc= +ariga.io/atlas v0.32.1-0.20250325101103-175b25e1c1b9/go.mod h1:Oe1xWPuu5q9LzyrWfbZmEZxFYeu4BHTyzfjeW2aZp/w= +entgo.io/ent v0.14.5 h1:Rj2WOYJtCkWyFo6a+5wB3EfBRP0rnx1fMk6gGA0UUe4= +entgo.io/ent v0.14.5/go.mod h1:zTzLmWtPvGpmSwtkaayM2cm5m819NdM7z7tYPq3vN0U= filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= +github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= +github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= +github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= +github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= +github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY= +github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= +github.com/bmatcuk/doublestar v1.3.4 h1:gPypJ5xD31uhX6Tf54sDPUOBXTqKH4c9aPY66CyQrS0= +github.com/bmatcuk/doublestar v1.3.4/go.mod h1:wiQtGV+rzVYxB7WIlirSN++5HPtPlXEo9MEoZQC/PmE= +github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs= +github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c= +github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA= +github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= +github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= +github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k= github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= -github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= +github.com/go-openapi/inflect v0.19.0 h1:9jCH9scKIbHeV9m12SmPilScz6krDxKRasNNSNPXu/4= +github.com/go-openapi/inflect v0.19.0/go.mod h1:lHpZVlpIQqLyKwJ4N+YSc9hchQy/i12fJykb83CRBH4= github.com/go-sql-driver/mysql v1.9.3 h1:U/N249h2WzJ3Ukj8SowVFjdtZKfu9vlLZxjPXV1aweo= github.com/go-sql-driver/mysql v1.9.3/go.mod h1:qn46aNg1333BRMNU69Lq93t8du/dwxI64Gl8i5p1WMU= +github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= +github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/go-viper/mapstructure/v2 v2.5.0 h1:vM5IJoUAy3d7zRSVtIwQgBj7BiWtMPfmPEgAXnvj1Ro= github.com/go-viper/mapstructure/v2 v2.5.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= -github.com/labstack/echo/v4 v4.11.4/go.mod h1:noh7EvLwqDsmh/X/HWKPUl1AjzJrhyptRyEbQJfxen8= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/hashicorp/hcl/v2 v2.18.1 h1:6nxnOJFku1EuSawSD81fuviYUV8DxFr3fp2dUi3ZYSo= +github.com/hashicorp/hcl/v2 v2.18.1/go.mod h1:ThLC89FV4p9MPW804KVbe/cEXoQ8NZEh+JtMeeGErHE= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/labstack/echo/v4 v4.15.0 h1:hoRTKWcnR5STXZFe9BmYun9AMTNeSbjHi2vtDuADJ24= github.com/labstack/echo/v4 v4.15.0/go.mod h1:xmw1clThob0BSVRX1CRQkGQ/vjwcpOMjQZSZa9fKA/c= github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0= @@ -20,46 +54,62 @@ github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHP github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-sqlite3 v1.14.17 h1:mCRHCLDUBXgpKAqIKsaAaAsrAlbkeomtRFKXh2L6YIM= +github.com/mattn/go-sqlite3 v1.14.17/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= +github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= +github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4= github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY= -github.com/redis/go-redis/v9 v9.5.1/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/redis/go-redis/v9 v9.17.2 h1:P2EGsA4qVIM3Pp+aPocCJ7DguDHhqrXNhVcEp4ViluI= github.com/redis/go-redis/v9 v9.17.2/go.mod h1:u410H11HMLoB+TP67dz8rL9s6QW2j76l0//kSOd3370= github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= +github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/sagikazarmark/locafero v0.12.0 h1:/NQhBAkUb4+fH1jivKHWusDYFjMOOKU88eegjfxfHb4= github.com/sagikazarmark/locafero v0.12.0/go.mod h1:sZh36u/YSZ918v0Io+U9ogLYQJ9tLLBmM4eneO6WwsI= -github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 h1:+jumHNA0Wrelhe64i8F6HNlS8pkoyMv5sreGx2Ry5Rw= -github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8/go.mod h1:3n1Cwaq1E1/1lhQhtRK2ts/ZwZEhjcQeJQ1RuC6Q/8U= +github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= +github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= github.com/spf13/afero v1.15.0 h1:b/YBCLWAJdFWJTN9cLhiXXcD7mzKn9Dm86dNnfyQw1I= github.com/spf13/afero v1.15.0/go.mod h1:NC2ByUVxtQs4b3sIUphxK0NioZnmxgyCrfzeuq8lxMg= github.com/spf13/cast v1.10.0 h1:h2x0u2shc1QuLHfxi+cTJvs30+ZAHOGRic8uyGTDWxY= github.com/spf13/cast v1.10.0/go.mod h1:jNfB8QC9IA6ZuY2ZjDp0KtFO2LZZlg4S/7bzP6qqeHo= github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk= github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spf13/viper v1.18.2/go.mod h1:EKmWIqdnk5lOcmR72yw6hS+8OPYcwD0jteitLMVB+yk= github.com/spf13/viper v1.21.0 h1:x5S+0EU27Lbphp4UKm1C+1oQO+rKx36vfCoaVebLFSU= github.com/spf13/viper v1.21.0/go.mod h1:P0lhsswPGWD/1lZJ9ny3fYnVqxiegrlNrEmgLjbTCAY= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo= github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= +github.com/zclconf/go-cty v1.14.4 h1:uXXczd9QDGsgu0i/QFR/hzI5NYCHLf6NQw/atrbnhq8= +github.com/zclconf/go-cty v1.14.4/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= +github.com/zclconf/go-cty-yaml v1.1.0 h1:nP+jp0qPHv2IhUVqmQSzjvqAWcObN0KBkUl2rWBdig0= +github.com/zclconf/go-cty-yaml v1.1.0/go.mod h1:9YLUH4g7lOhVWqUbctnVlZ5KLpg7JAprQNgxSZ1Gyxs= go.uber.org/dig v1.19.0 h1:BACLhebsYdpQ7IROQ1AGPjrXcP5dF80U3gKoFzbaq/4= go.uber.org/dig v1.19.0/go.mod h1:Us0rSJiThwCv2GteUN0Q7OKvU7n5J4dxZ9JKUXozFdE= -go.uber.org/fx v1.22.2/go.mod h1:o/D9n+2mLP6v1EG+qsdT1O8wKopYAsqZasju97SDFCU= go.uber.org/fx v1.24.0 h1:wE8mruvpg2kiiL1Vqd0CC+tr0/24XIB10Iwp2lLWzkg= go.uber.org/fx v1.24.0/go.mod h1:AmDeGyS+ZARGKM4tlH4FY2Jr63VjbEDJHtqXTGP5hbo= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= go.uber.org/zap v1.27.1 h1:08RqriUEv8+ArZRYSTXy1LeBScaMpVSTBhCeaZYfMYc= go.uber.org/zap v1.27.1/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= golang.org/x/crypto v0.47.0 h1:V6e3FRj+n4dbpw86FJ8Fv7XVOql7TEwpHapKoMJ/GO8= golang.org/x/crypto v0.47.0/go.mod h1:ff3Y9VzzKbwSSEzWqJsJVBnWmRwRSHt/6Op5n9bQc4A= +golang.org/x/mod v0.31.0 h1:HaW9xtz0+kOcWKwli0ZXy79Ix+UW/vOfmWI5QVd2tgI= +golang.org/x/mod v0.31.0/go.mod h1:43JraMp9cGx1Rx3AqioxrbrhNsLl2l/iNAvuBkrezpg= golang.org/x/net v0.49.0 h1:eeHFmOGUTtaaPSGNmjBKpbng9MulQsJURQUAfUwY++o= golang.org/x/net v0.49.0/go.mod h1:/ysNB2EvaqvesRkuLAyjI1ycPZlQHM3q01F02UY/MV8= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -68,3 +118,7 @@ golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= golang.org/x/text v0.33.0 h1:B3njUFyqtHDUI5jMn1YIr5B0IE2U0qck04r6d4KPAxE= golang.org/x/text v0.33.0/go.mod h1:LuMebE6+rBincTi9+xWTY8TztLzKHc/9C1uBCG27+q8= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/internal/controller/health_controller.go b/internal/controller/health_controller.go deleted file mode 100644 index 509f7b9..0000000 --- a/internal/controller/health_controller.go +++ /dev/null @@ -1,22 +0,0 @@ -package controller - -import ( - "net/http" - - "github.com/labstack/echo/v4" - - "epic-ent/internal/service" -) - -type HealthController struct { - svc *service.HealthService -} - -func NewHealthController(svc *service.HealthService) *HealthController { - return &HealthController{svc: svc} -} - -func (h *HealthController) Health(c echo.Context) error { - status := h.svc.Check() - return c.JSON(http.StatusOK, status) -} diff --git a/internal/controller/hero_controller.go b/internal/controller/hero_controller.go new file mode 100644 index 0000000..b0a38fe --- /dev/null +++ b/internal/controller/hero_controller.go @@ -0,0 +1,94 @@ +package controller + +import ( + "database/sql" + "net/http" + "strconv" + + "github.com/labstack/echo/v4" + + "epic-ent/internal/domain/dto" + "epic-ent/internal/domain/vo" + "epic-ent/internal/service" +) + +type HeroController struct { + svc *service.HeroService +} + +func NewHeroController(svc *service.HeroService) *HeroController { + return &HeroController{svc: svc} +} + +func (h *HeroController) Create(c echo.Context) error { + var req dto.HeroCreateRequest + if err := c.Bind(&req); err != nil { + return echo.NewHTTPError(http.StatusBadRequest, "invalid request") + } + + hero, err := h.svc.Create(c.Request().Context(), req) + if err != nil { + return err + } + + return c.JSON(http.StatusCreated, vo.OK(hero)) +} + +func (h *HeroController) GetByID(c echo.Context) error { + id, err := parseID(c.Param("id")) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, "invalid id") + } + + hero, err := h.svc.GetByID(c.Request().Context(), id) + if err != nil { + if err == sql.ErrNoRows { + return echo.NewHTTPError(http.StatusNotFound, "hero not found") + } + return err + } + + return c.JSON(http.StatusOK, vo.OK(hero)) +} + +func (h *HeroController) Update(c echo.Context) error { + id, err := parseID(c.Param("id")) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, "invalid id") + } + + var req dto.HeroUpdateRequest + if err := c.Bind(&req); err != nil { + return echo.NewHTTPError(http.StatusBadRequest, "invalid request") + } + + hero, err := h.svc.Update(c.Request().Context(), id, req) + if err != nil { + if err == sql.ErrNoRows { + return echo.NewHTTPError(http.StatusNotFound, "hero not found") + } + return err + } + + return c.JSON(http.StatusOK, vo.OK(hero)) +} + +func (h *HeroController) Delete(c echo.Context) error { + id, err := parseID(c.Param("id")) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, "invalid id") + } + + if err := h.svc.Delete(c.Request().Context(), id); err != nil { + if err == sql.ErrNoRows { + return echo.NewHTTPError(http.StatusNotFound, "hero not found") + } + return err + } + + return c.JSON(http.StatusOK, vo.OK(nil)) +} + +func parseID(raw string) (int64, error) { + return strconv.ParseInt(raw, 10, 64) +} diff --git a/internal/controller/module.go b/internal/controller/module.go index 96b022d..706b18d 100644 --- a/internal/controller/module.go +++ b/internal/controller/module.go @@ -5,7 +5,7 @@ import "go.uber.org/fx" var Module = fx.Options( fx.Provide( - NewHealthController, + NewHeroController, ), fx.Invoke( RegisterRoutes, diff --git a/internal/controller/routes.go b/internal/controller/routes.go index 9f278ec..e03a330 100644 --- a/internal/controller/routes.go +++ b/internal/controller/routes.go @@ -8,10 +8,13 @@ import ( type RouteParams struct { fx.In - Echo *echo.Echo - Health *HealthController + Echo *echo.Echo + Hero *HeroController } func RegisterRoutes(p RouteParams) { - p.Echo.GET("/health", p.Health.Health) + p.Echo.POST("/heroes", p.Hero.Create) + p.Echo.GET("/heroes/:id", p.Hero.GetByID) + p.Echo.PUT("/heroes/:id", p.Hero.Update) + p.Echo.DELETE("/heroes/:id", p.Hero.Delete) } diff --git a/internal/controller/user_controller.go b/internal/controller/user_controller.go deleted file mode 100644 index 84824bb..0000000 --- a/internal/controller/user_controller.go +++ /dev/null @@ -1,22 +0,0 @@ -package controller - -import ( - "net/http" - - "github.com/labstack/echo/v4" - - "epic-ent/internal/service" -) - -type UserController struct { - svc *service.HealthService -} - -func NewUserController(svc *service.HealthService) *HealthController { - return &HealthController{svc: svc} -} - -func (h *UserController) Health(c echo.Context) error { - //status := h.svc.Check() - return c.JSON(http.StatusOK, "你好") -} diff --git a/internal/domain/dto/hero.go b/internal/domain/dto/hero.go new file mode 100644 index 0000000..7ce5a16 --- /dev/null +++ b/internal/domain/dto/hero.go @@ -0,0 +1,43 @@ +package dto + +import "time" + +type HeroCreateRequest struct { + HeroName *string `json:"heroName"` + HeroCode *string `json:"heroCode"` + HeroAttrLv60 *string `json:"heroAttrLv60"` + Creator *string `json:"creator"` + CreateTime *time.Time `json:"createTime"` + Updater *string `json:"updater"` + UpdateTime *time.Time `json:"updateTime"` + Deleted *bool `json:"deleted"` + NickName *string `json:"nickName"` + Rarity *string `json:"rarity"` + Role *string `json:"role"` + Zodiac *string `json:"zodiac"` + HeadImgURL *string `json:"headImgUrl"` + Attribute *string `json:"attribute"` + Remark *string `json:"remark"` + RawJSON *string `json:"rawJson"` + SetContentJSON *string `json:"setContentJson"` + SetUpdateTime *time.Time `json:"setUpdateTime"` +} + +type HeroUpdateRequest struct { + HeroName *string `json:"heroName"` + HeroCode *string `json:"heroCode"` + HeroAttrLv60 *string `json:"heroAttrLv60"` + Updater *string `json:"updater"` + UpdateTime *time.Time `json:"updateTime"` + Deleted *bool `json:"deleted"` + NickName *string `json:"nickName"` + Rarity *string `json:"rarity"` + Role *string `json:"role"` + Zodiac *string `json:"zodiac"` + HeadImgURL *string `json:"headImgUrl"` + Attribute *string `json:"attribute"` + Remark *string `json:"remark"` + RawJSON *string `json:"rawJson"` + SetContentJSON *string `json:"setContentJson"` + SetUpdateTime *time.Time `json:"setUpdateTime"` +} diff --git a/internal/domain/entity/epic_artifact_info.go b/internal/domain/entity/epic_artifact_info.go new file mode 100644 index 0000000..44656af --- /dev/null +++ b/internal/domain/entity/epic_artifact_info.go @@ -0,0 +1,34 @@ +package entity + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/field" +) + +type EpicArtifactInfo struct { + ent.Schema +} + +func (EpicArtifactInfo) Table() string { + return "epic_artifact_info" +} + +func (EpicArtifactInfo) Fields() []ent.Field { + return []ent.Field{ + field.Int64("id").Immutable().Unique(), + field.String("artifact_name").MaxLen(255), + field.String("artifact_code").MaxLen(255), + field.String("creator").MaxLen(255), + field.Time("create_time").Optional().Nillable(), + field.String("updater").MaxLen(255), + field.Time("update_time").Optional().Nillable(), + field.Bool("deleted"), + field.Int("stats_health"), + field.Int("stats_attack"), + field.Int("stats_defense"), + field.String("rarity").MaxLen(255), + field.String("role").MaxLen(255), + field.String("artifact_name_en").MaxLen(255), + field.String("image_url").MaxLen(255), + } +} diff --git a/internal/domain/entity/epic_gvg_attack_teams.go b/internal/domain/entity/epic_gvg_attack_teams.go new file mode 100644 index 0000000..f7e8c8f --- /dev/null +++ b/internal/domain/entity/epic_gvg_attack_teams.go @@ -0,0 +1,26 @@ +package entity + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/field" +) + +type EpicGvgAttackTeams struct { + ent.Schema +} + +func (EpicGvgAttackTeams) Table() string { + return "epic_gvg_attack_teams" +} + +func (EpicGvgAttackTeams) Fields() []ent.Field { + return []ent.Field{ + field.Int64("id").Immutable().Unique(), + field.String("attack_heroes").MaxLen(255), + field.String("creator").MaxLen(255), + field.Time("create_time").Optional().Nillable(), + field.String("updater").MaxLen(255), + field.Time("update_time").Optional().Nillable(), + field.Bool("deleted"), + } +} diff --git a/internal/domain/entity/epic_gvg_defense_attack_mapping.go b/internal/domain/entity/epic_gvg_defense_attack_mapping.go new file mode 100644 index 0000000..0c240b8 --- /dev/null +++ b/internal/domain/entity/epic_gvg_defense_attack_mapping.go @@ -0,0 +1,32 @@ +package entity + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/field" +) + +type EpicGvgDefenseAttackMapping struct { + ent.Schema +} + +func (EpicGvgDefenseAttackMapping) Table() string { + return "epic_gvg_defense_attack_mapping" +} + +func (EpicGvgDefenseAttackMapping) Fields() []ent.Field { + return []ent.Field{ + field.Int64("id").Immutable().Unique(), + field.Int64("defense_id"), + field.Int64("attack_id"), + field.String("equipment_info").MaxLen(255), + field.String("artifacts").MaxLen(255), + field.String("battle_strategy").MaxLen(255), + field.String("prerequisites").MaxLen(255), + field.String("important_notes").MaxLen(255), + field.String("creator").MaxLen(255), + field.Time("create_time").Optional().Nillable(), + field.String("updater").MaxLen(255), + field.Time("update_time").Optional().Nillable(), + field.Bool("deleted"), + } +} diff --git a/internal/domain/entity/epic_gvg_defense_teams.go b/internal/domain/entity/epic_gvg_defense_teams.go new file mode 100644 index 0000000..aba51c6 --- /dev/null +++ b/internal/domain/entity/epic_gvg_defense_teams.go @@ -0,0 +1,26 @@ +package entity + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/field" +) + +type EpicGvgDefenseTeams struct { + ent.Schema +} + +func (EpicGvgDefenseTeams) Table() string { + return "epic_gvg_defense_teams" +} + +func (EpicGvgDefenseTeams) Fields() []ent.Field { + return []ent.Field{ + field.Int64("id").Immutable().Unique(), + field.String("defense_heroes").MaxLen(255), + field.String("creator").MaxLen(255), + field.Time("create_time").Optional().Nillable(), + field.String("updater").MaxLen(255), + field.Time("update_time").Optional().Nillable(), + field.Bool("deleted"), + } +} diff --git a/internal/domain/entity/epic_hero_info.go b/internal/domain/entity/epic_hero_info.go new file mode 100644 index 0000000..7dd9beb --- /dev/null +++ b/internal/domain/entity/epic_hero_info.go @@ -0,0 +1,38 @@ +package entity + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/field" +) + +type EpicHeroInfo struct { + ent.Schema +} + +func (EpicHeroInfo) Table() string { + return "epic_hero_info" +} + +func (EpicHeroInfo) Fields() []ent.Field { + return []ent.Field{ + field.Int64("id").Immutable().Unique(), + field.String("hero_name").MaxLen(255), + field.String("hero_code").MaxLen(255), + field.String("hero_attr_lv60").MaxLen(255), + field.String("creator").MaxLen(255), + field.Time("create_time").Optional().Nillable(), + field.String("updater").MaxLen(255), + field.Time("update_time").Optional().Nillable(), + field.Bool("deleted"), + field.String("nick_name").MaxLen(255), + field.String("rarity").MaxLen(255), + field.String("role").MaxLen(255), + field.String("zodiac").MaxLen(255), + field.String("head_img_url").MaxLen(255), + field.String("attribute").MaxLen(255), + field.String("remark").MaxLen(255), + field.String("raw_json").MaxLen(255), + field.String("set_content_json").MaxLen(255), + field.Time("set_update_time").Optional().Nillable(), + } +} diff --git a/internal/domain/entity/epic_hero_user_build.go b/internal/domain/entity/epic_hero_user_build.go new file mode 100644 index 0000000..706392a --- /dev/null +++ b/internal/domain/entity/epic_hero_user_build.go @@ -0,0 +1,30 @@ +package entity + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/field" +) + +type EpicHeroUserBuild struct { + ent.Schema +} + +func (EpicHeroUserBuild) Table() string { + return "epic_hero_user_build" +} + +func (EpicHeroUserBuild) Fields() []ent.Field { + return []ent.Field{ + field.Int64("id").Immutable().Unique(), + field.String("artifact_code").MaxLen(255), + field.String("hero_code").MaxLen(255), + field.Float("hero_heath_build"), + field.Float("hero_attack_build"), + field.Float("hero_def_build"), + field.String("creator").MaxLen(255), + field.Time("create_time").Optional().Nillable(), + field.String("updater").MaxLen(255), + field.Time("update_time").Optional().Nillable(), + field.Bool("deleted"), + } +} diff --git a/internal/domain/entity/epic_i18n_mappings.go b/internal/domain/entity/epic_i18n_mappings.go new file mode 100644 index 0000000..774841b --- /dev/null +++ b/internal/domain/entity/epic_i18n_mappings.go @@ -0,0 +1,31 @@ +package entity + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/field" +) + +type EpicI18NMappings struct { + ent.Schema +} + +func (EpicI18NMappings) Table() string { + return "epic_i18n_mappings" +} + +func (EpicI18NMappings) Fields() []ent.Field { + return []ent.Field{ + field.Int64("id").Immutable().Unique(), + field.String("key_name").MaxLen(255), + field.String("language").MaxLen(255), + field.String("value").MaxLen(255), + field.String("category").MaxLen(255), + field.Int("status"), + field.String("creator").MaxLen(255), + field.Time("create_time").Optional().Nillable(), + field.String("updater").MaxLen(255), + field.Time("update_time").Optional().Nillable(), + field.Int("deleted"), + field.String("code").MaxLen(255), + } +} diff --git a/internal/domain/entity/fribble_hero_set.go b/internal/domain/entity/fribble_hero_set.go new file mode 100644 index 0000000..baebed1 --- /dev/null +++ b/internal/domain/entity/fribble_hero_set.go @@ -0,0 +1,29 @@ +package entity + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/field" +) + +type FribbleHeroSet struct { + ent.Schema +} + +func (FribbleHeroSet) Table() string { + return "fribble_hero_set" +} + +func (FribbleHeroSet) Fields() []ent.Field { + return []ent.Field{ + field.Int64("id").Immutable().Unique(), + field.String("hero_code").MaxLen(255), + field.String("json_content").MaxLen(255), + field.String("hero_name").MaxLen(255), + field.String("creator").MaxLen(255), + field.Time("create_time").Optional().Nillable(), + field.String("updater").MaxLen(255), + field.Time("update_time").Optional().Nillable(), + field.Bool("deleted"), + field.Int("success_get"), + } +} diff --git a/internal/domain/entity/gear_set_info.go b/internal/domain/entity/gear_set_info.go new file mode 100644 index 0000000..6dbb8d3 --- /dev/null +++ b/internal/domain/entity/gear_set_info.go @@ -0,0 +1,42 @@ +package entity + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/field" +) + +type GearSetInfo struct { + ent.Schema +} + +func (GearSetInfo) Table() string { + return "gear_set_info" +} + +func (GearSetInfo) Fields() []ent.Field { + return []ent.Field{ + field.Int64("id").Immutable().Unique(), + field.Int("level"), + field.Int64("gear_id"), + field.Int("enhance"), + field.String("gear_type").MaxLen(255), + field.String("gear_set_type").MaxLen(255), + field.String("main_stat_type").MaxLen(255), + field.Int("main_stat_value"), + field.String("sub_stat_one_type").MaxLen(255), + field.Int("sub_stat_one_value"), + field.String("sub_stat_two_type").MaxLen(255), + field.Int("sub_stat_two_value"), + field.String("sub_stat_three_type").MaxLen(255), + field.Int("sub_stat_three_value"), + field.String("sub_stat_four_type").MaxLen(255), + field.Int("sub_stat_four_value"), + field.String("account_code").MaxLen(255), + field.String("creator").MaxLen(255), + field.Time("create_time").Optional().Nillable(), + field.String("updater").MaxLen(255), + field.Time("update_time").Optional().Nillable(), + field.Bool("deleted"), + field.Int64("tenant_id"), + } +} diff --git a/internal/domain/vo/hero.go b/internal/domain/vo/hero.go new file mode 100644 index 0000000..ce3ceb9 --- /dev/null +++ b/internal/domain/vo/hero.go @@ -0,0 +1,25 @@ +package vo + +import "time" + +type Hero struct { + ID int64 `json:"id"` + HeroName string `json:"heroName"` + HeroCode string `json:"heroCode"` + HeroAttrLv60 string `json:"heroAttrLv60"` + Creator string `json:"creator"` + CreateTime *time.Time `json:"createTime"` + Updater string `json:"updater"` + UpdateTime *time.Time `json:"updateTime"` + Deleted bool `json:"deleted"` + NickName string `json:"nickName"` + Rarity string `json:"rarity"` + Role string `json:"role"` + Zodiac string `json:"zodiac"` + HeadImgURL string `json:"headImgUrl"` + Attribute string `json:"attribute"` + Remark string `json:"remark"` + RawJSON string `json:"rawJson"` + SetContentJSON string `json:"setContentJson"` + SetUpdateTime *time.Time `json:"setUpdateTime"` +} diff --git a/internal/domain/vo/response.go b/internal/domain/vo/response.go new file mode 100644 index 0000000..86bcd44 --- /dev/null +++ b/internal/domain/vo/response.go @@ -0,0 +1,22 @@ +package vo + +type Response struct { + Code string `json:"code"` + Message string `json:"message"` + Data any `json:"data,omitempty"` +} + +func OK(data any) Response { + return Response{ + Code: "OK", + Message: "success", + Data: data, + } +} + +func Error(message string) Response { + return Response{ + Code: "ERROR", + Message: message, + } +} diff --git a/internal/ent/client.go b/internal/ent/client.go new file mode 100644 index 0000000..5d9ef39 --- /dev/null +++ b/internal/ent/client.go @@ -0,0 +1,1485 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "log" + "reflect" + + "epic-ent/internal/ent/migrate" + + "epic-ent/internal/ent/epicartifactinfo" + "epic-ent/internal/ent/epicgvgattackteams" + "epic-ent/internal/ent/epicgvgdefenseattackmapping" + "epic-ent/internal/ent/epicgvgdefenseteams" + "epic-ent/internal/ent/epicheroinfo" + "epic-ent/internal/ent/epicherouserbuild" + "epic-ent/internal/ent/epici18nmappings" + "epic-ent/internal/ent/fribbleheroset" + "epic-ent/internal/ent/gearsetinfo" + + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" +) + +// Client is the client that holds all ent builders. +type Client struct { + config + // Schema is the client for creating, migrating and dropping schema. + Schema *migrate.Schema + // EpicArtifactInfo is the client for interacting with the EpicArtifactInfo builders. + EpicArtifactInfo *EpicArtifactInfoClient + // EpicGvgAttackTeams is the client for interacting with the EpicGvgAttackTeams builders. + EpicGvgAttackTeams *EpicGvgAttackTeamsClient + // EpicGvgDefenseAttackMapping is the client for interacting with the EpicGvgDefenseAttackMapping builders. + EpicGvgDefenseAttackMapping *EpicGvgDefenseAttackMappingClient + // EpicGvgDefenseTeams is the client for interacting with the EpicGvgDefenseTeams builders. + EpicGvgDefenseTeams *EpicGvgDefenseTeamsClient + // EpicHeroInfo is the client for interacting with the EpicHeroInfo builders. + EpicHeroInfo *EpicHeroInfoClient + // EpicHeroUserBuild is the client for interacting with the EpicHeroUserBuild builders. + EpicHeroUserBuild *EpicHeroUserBuildClient + // EpicI18NMappings is the client for interacting with the EpicI18NMappings builders. + EpicI18NMappings *EpicI18NMappingsClient + // FribbleHeroSet is the client for interacting with the FribbleHeroSet builders. + FribbleHeroSet *FribbleHeroSetClient + // GearSetInfo is the client for interacting with the GearSetInfo builders. + GearSetInfo *GearSetInfoClient +} + +// NewClient creates a new client configured with the given options. +func NewClient(opts ...Option) *Client { + client := &Client{config: newConfig(opts...)} + client.init() + return client +} + +func (c *Client) init() { + c.Schema = migrate.NewSchema(c.driver) + c.EpicArtifactInfo = NewEpicArtifactInfoClient(c.config) + c.EpicGvgAttackTeams = NewEpicGvgAttackTeamsClient(c.config) + c.EpicGvgDefenseAttackMapping = NewEpicGvgDefenseAttackMappingClient(c.config) + c.EpicGvgDefenseTeams = NewEpicGvgDefenseTeamsClient(c.config) + c.EpicHeroInfo = NewEpicHeroInfoClient(c.config) + c.EpicHeroUserBuild = NewEpicHeroUserBuildClient(c.config) + c.EpicI18NMappings = NewEpicI18NMappingsClient(c.config) + c.FribbleHeroSet = NewFribbleHeroSetClient(c.config) + c.GearSetInfo = NewGearSetInfoClient(c.config) +} + +type ( + // config is the configuration for the client and its builder. + config struct { + // driver used for executing database requests. + driver dialect.Driver + // debug enable a debug logging. + debug bool + // log used for logging on debug mode. + log func(...any) + // hooks to execute on mutations. + hooks *hooks + // interceptors to execute on queries. + inters *inters + } + // Option function to configure the client. + Option func(*config) +) + +// newConfig creates a new config for the client. +func newConfig(opts ...Option) config { + cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} + cfg.options(opts...) + return cfg +} + +// options applies the options on the config object. +func (c *config) options(opts ...Option) { + for _, opt := range opts { + opt(c) + } + if c.debug { + c.driver = dialect.Debug(c.driver, c.log) + } +} + +// Debug enables debug logging on the ent.Driver. +func Debug() Option { + return func(c *config) { + c.debug = true + } +} + +// Log sets the logging function for debug mode. +func Log(fn func(...any)) Option { + return func(c *config) { + c.log = fn + } +} + +// Driver configures the client driver. +func Driver(driver dialect.Driver) Option { + return func(c *config) { + c.driver = driver + } +} + +// Open opens a database/sql.DB specified by the driver name and +// the data source name, and returns a new client attached to it. +// Optional parameters can be added for configuring the client. +func Open(driverName, dataSourceName string, options ...Option) (*Client, error) { + switch driverName { + case dialect.MySQL, dialect.Postgres, dialect.SQLite: + drv, err := sql.Open(driverName, dataSourceName) + if err != nil { + return nil, err + } + return NewClient(append(options, Driver(drv))...), nil + default: + return nil, fmt.Errorf("unsupported driver: %q", driverName) + } +} + +// ErrTxStarted is returned when trying to start a new transaction from a transactional client. +var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction") + +// Tx returns a new transactional client. The provided context +// is used until the transaction is committed or rolled back. +func (c *Client) Tx(ctx context.Context) (*Tx, error) { + if _, ok := c.driver.(*txDriver); ok { + return nil, ErrTxStarted + } + tx, err := newTx(ctx, c.driver) + if err != nil { + return nil, fmt.Errorf("ent: starting a transaction: %w", err) + } + cfg := c.config + cfg.driver = tx + return &Tx{ + ctx: ctx, + config: cfg, + EpicArtifactInfo: NewEpicArtifactInfoClient(cfg), + EpicGvgAttackTeams: NewEpicGvgAttackTeamsClient(cfg), + EpicGvgDefenseAttackMapping: NewEpicGvgDefenseAttackMappingClient(cfg), + EpicGvgDefenseTeams: NewEpicGvgDefenseTeamsClient(cfg), + EpicHeroInfo: NewEpicHeroInfoClient(cfg), + EpicHeroUserBuild: NewEpicHeroUserBuildClient(cfg), + EpicI18NMappings: NewEpicI18NMappingsClient(cfg), + FribbleHeroSet: NewFribbleHeroSetClient(cfg), + GearSetInfo: NewGearSetInfoClient(cfg), + }, nil +} + +// BeginTx returns a transactional client with specified options. +func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) { + if _, ok := c.driver.(*txDriver); ok { + return nil, errors.New("ent: cannot start a transaction within a transaction") + } + tx, err := c.driver.(interface { + BeginTx(context.Context, *sql.TxOptions) (dialect.Tx, error) + }).BeginTx(ctx, opts) + if err != nil { + return nil, fmt.Errorf("ent: starting a transaction: %w", err) + } + cfg := c.config + cfg.driver = &txDriver{tx: tx, drv: c.driver} + return &Tx{ + ctx: ctx, + config: cfg, + EpicArtifactInfo: NewEpicArtifactInfoClient(cfg), + EpicGvgAttackTeams: NewEpicGvgAttackTeamsClient(cfg), + EpicGvgDefenseAttackMapping: NewEpicGvgDefenseAttackMappingClient(cfg), + EpicGvgDefenseTeams: NewEpicGvgDefenseTeamsClient(cfg), + EpicHeroInfo: NewEpicHeroInfoClient(cfg), + EpicHeroUserBuild: NewEpicHeroUserBuildClient(cfg), + EpicI18NMappings: NewEpicI18NMappingsClient(cfg), + FribbleHeroSet: NewFribbleHeroSetClient(cfg), + GearSetInfo: NewGearSetInfoClient(cfg), + }, nil +} + +// Debug returns a new debug-client. It's used to get verbose logging on specific operations. +// +// client.Debug(). +// EpicArtifactInfo. +// Query(). +// Count(ctx) +func (c *Client) Debug() *Client { + if c.debug { + return c + } + cfg := c.config + cfg.driver = dialect.Debug(c.driver, c.log) + client := &Client{config: cfg} + client.init() + return client +} + +// Close closes the database connection and prevents new queries from starting. +func (c *Client) Close() error { + return c.driver.Close() +} + +// Use adds the mutation hooks to all the entity clients. +// In order to add hooks to a specific client, call: `client.Node.Use(...)`. +func (c *Client) Use(hooks ...Hook) { + for _, n := range []interface{ Use(...Hook) }{ + c.EpicArtifactInfo, c.EpicGvgAttackTeams, c.EpicGvgDefenseAttackMapping, + c.EpicGvgDefenseTeams, c.EpicHeroInfo, c.EpicHeroUserBuild, c.EpicI18NMappings, + c.FribbleHeroSet, c.GearSetInfo, + } { + n.Use(hooks...) + } +} + +// Intercept adds the query interceptors to all the entity clients. +// In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`. +func (c *Client) Intercept(interceptors ...Interceptor) { + for _, n := range []interface{ Intercept(...Interceptor) }{ + c.EpicArtifactInfo, c.EpicGvgAttackTeams, c.EpicGvgDefenseAttackMapping, + c.EpicGvgDefenseTeams, c.EpicHeroInfo, c.EpicHeroUserBuild, c.EpicI18NMappings, + c.FribbleHeroSet, c.GearSetInfo, + } { + n.Intercept(interceptors...) + } +} + +// Mutate implements the ent.Mutator interface. +func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { + switch m := m.(type) { + case *EpicArtifactInfoMutation: + return c.EpicArtifactInfo.mutate(ctx, m) + case *EpicGvgAttackTeamsMutation: + return c.EpicGvgAttackTeams.mutate(ctx, m) + case *EpicGvgDefenseAttackMappingMutation: + return c.EpicGvgDefenseAttackMapping.mutate(ctx, m) + case *EpicGvgDefenseTeamsMutation: + return c.EpicGvgDefenseTeams.mutate(ctx, m) + case *EpicHeroInfoMutation: + return c.EpicHeroInfo.mutate(ctx, m) + case *EpicHeroUserBuildMutation: + return c.EpicHeroUserBuild.mutate(ctx, m) + case *EpicI18NMappingsMutation: + return c.EpicI18NMappings.mutate(ctx, m) + case *FribbleHeroSetMutation: + return c.FribbleHeroSet.mutate(ctx, m) + case *GearSetInfoMutation: + return c.GearSetInfo.mutate(ctx, m) + default: + return nil, fmt.Errorf("ent: unknown mutation type %T", m) + } +} + +// EpicArtifactInfoClient is a client for the EpicArtifactInfo schema. +type EpicArtifactInfoClient struct { + config +} + +// NewEpicArtifactInfoClient returns a client for the EpicArtifactInfo from the given config. +func NewEpicArtifactInfoClient(c config) *EpicArtifactInfoClient { + return &EpicArtifactInfoClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `epicartifactinfo.Hooks(f(g(h())))`. +func (c *EpicArtifactInfoClient) Use(hooks ...Hook) { + c.hooks.EpicArtifactInfo = append(c.hooks.EpicArtifactInfo, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `epicartifactinfo.Intercept(f(g(h())))`. +func (c *EpicArtifactInfoClient) Intercept(interceptors ...Interceptor) { + c.inters.EpicArtifactInfo = append(c.inters.EpicArtifactInfo, interceptors...) +} + +// Create returns a builder for creating a EpicArtifactInfo entity. +func (c *EpicArtifactInfoClient) Create() *EpicArtifactInfoCreate { + mutation := newEpicArtifactInfoMutation(c.config, OpCreate) + return &EpicArtifactInfoCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of EpicArtifactInfo entities. +func (c *EpicArtifactInfoClient) CreateBulk(builders ...*EpicArtifactInfoCreate) *EpicArtifactInfoCreateBulk { + return &EpicArtifactInfoCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *EpicArtifactInfoClient) MapCreateBulk(slice any, setFunc func(*EpicArtifactInfoCreate, int)) *EpicArtifactInfoCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &EpicArtifactInfoCreateBulk{err: fmt.Errorf("calling to EpicArtifactInfoClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*EpicArtifactInfoCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &EpicArtifactInfoCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for EpicArtifactInfo. +func (c *EpicArtifactInfoClient) Update() *EpicArtifactInfoUpdate { + mutation := newEpicArtifactInfoMutation(c.config, OpUpdate) + return &EpicArtifactInfoUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *EpicArtifactInfoClient) UpdateOne(_m *EpicArtifactInfo) *EpicArtifactInfoUpdateOne { + mutation := newEpicArtifactInfoMutation(c.config, OpUpdateOne, withEpicArtifactInfo(_m)) + return &EpicArtifactInfoUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *EpicArtifactInfoClient) UpdateOneID(id int64) *EpicArtifactInfoUpdateOne { + mutation := newEpicArtifactInfoMutation(c.config, OpUpdateOne, withEpicArtifactInfoID(id)) + return &EpicArtifactInfoUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for EpicArtifactInfo. +func (c *EpicArtifactInfoClient) Delete() *EpicArtifactInfoDelete { + mutation := newEpicArtifactInfoMutation(c.config, OpDelete) + return &EpicArtifactInfoDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *EpicArtifactInfoClient) DeleteOne(_m *EpicArtifactInfo) *EpicArtifactInfoDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *EpicArtifactInfoClient) DeleteOneID(id int64) *EpicArtifactInfoDeleteOne { + builder := c.Delete().Where(epicartifactinfo.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &EpicArtifactInfoDeleteOne{builder} +} + +// Query returns a query builder for EpicArtifactInfo. +func (c *EpicArtifactInfoClient) Query() *EpicArtifactInfoQuery { + return &EpicArtifactInfoQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeEpicArtifactInfo}, + inters: c.Interceptors(), + } +} + +// Get returns a EpicArtifactInfo entity by its id. +func (c *EpicArtifactInfoClient) Get(ctx context.Context, id int64) (*EpicArtifactInfo, error) { + return c.Query().Where(epicartifactinfo.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *EpicArtifactInfoClient) GetX(ctx context.Context, id int64) *EpicArtifactInfo { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *EpicArtifactInfoClient) Hooks() []Hook { + return c.hooks.EpicArtifactInfo +} + +// Interceptors returns the client interceptors. +func (c *EpicArtifactInfoClient) Interceptors() []Interceptor { + return c.inters.EpicArtifactInfo +} + +func (c *EpicArtifactInfoClient) mutate(ctx context.Context, m *EpicArtifactInfoMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&EpicArtifactInfoCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&EpicArtifactInfoUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&EpicArtifactInfoUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&EpicArtifactInfoDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown EpicArtifactInfo mutation op: %q", m.Op()) + } +} + +// EpicGvgAttackTeamsClient is a client for the EpicGvgAttackTeams schema. +type EpicGvgAttackTeamsClient struct { + config +} + +// NewEpicGvgAttackTeamsClient returns a client for the EpicGvgAttackTeams from the given config. +func NewEpicGvgAttackTeamsClient(c config) *EpicGvgAttackTeamsClient { + return &EpicGvgAttackTeamsClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `epicgvgattackteams.Hooks(f(g(h())))`. +func (c *EpicGvgAttackTeamsClient) Use(hooks ...Hook) { + c.hooks.EpicGvgAttackTeams = append(c.hooks.EpicGvgAttackTeams, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `epicgvgattackteams.Intercept(f(g(h())))`. +func (c *EpicGvgAttackTeamsClient) Intercept(interceptors ...Interceptor) { + c.inters.EpicGvgAttackTeams = append(c.inters.EpicGvgAttackTeams, interceptors...) +} + +// Create returns a builder for creating a EpicGvgAttackTeams entity. +func (c *EpicGvgAttackTeamsClient) Create() *EpicGvgAttackTeamsCreate { + mutation := newEpicGvgAttackTeamsMutation(c.config, OpCreate) + return &EpicGvgAttackTeamsCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of EpicGvgAttackTeams entities. +func (c *EpicGvgAttackTeamsClient) CreateBulk(builders ...*EpicGvgAttackTeamsCreate) *EpicGvgAttackTeamsCreateBulk { + return &EpicGvgAttackTeamsCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *EpicGvgAttackTeamsClient) MapCreateBulk(slice any, setFunc func(*EpicGvgAttackTeamsCreate, int)) *EpicGvgAttackTeamsCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &EpicGvgAttackTeamsCreateBulk{err: fmt.Errorf("calling to EpicGvgAttackTeamsClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*EpicGvgAttackTeamsCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &EpicGvgAttackTeamsCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for EpicGvgAttackTeams. +func (c *EpicGvgAttackTeamsClient) Update() *EpicGvgAttackTeamsUpdate { + mutation := newEpicGvgAttackTeamsMutation(c.config, OpUpdate) + return &EpicGvgAttackTeamsUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *EpicGvgAttackTeamsClient) UpdateOne(_m *EpicGvgAttackTeams) *EpicGvgAttackTeamsUpdateOne { + mutation := newEpicGvgAttackTeamsMutation(c.config, OpUpdateOne, withEpicGvgAttackTeams(_m)) + return &EpicGvgAttackTeamsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *EpicGvgAttackTeamsClient) UpdateOneID(id int64) *EpicGvgAttackTeamsUpdateOne { + mutation := newEpicGvgAttackTeamsMutation(c.config, OpUpdateOne, withEpicGvgAttackTeamsID(id)) + return &EpicGvgAttackTeamsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for EpicGvgAttackTeams. +func (c *EpicGvgAttackTeamsClient) Delete() *EpicGvgAttackTeamsDelete { + mutation := newEpicGvgAttackTeamsMutation(c.config, OpDelete) + return &EpicGvgAttackTeamsDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *EpicGvgAttackTeamsClient) DeleteOne(_m *EpicGvgAttackTeams) *EpicGvgAttackTeamsDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *EpicGvgAttackTeamsClient) DeleteOneID(id int64) *EpicGvgAttackTeamsDeleteOne { + builder := c.Delete().Where(epicgvgattackteams.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &EpicGvgAttackTeamsDeleteOne{builder} +} + +// Query returns a query builder for EpicGvgAttackTeams. +func (c *EpicGvgAttackTeamsClient) Query() *EpicGvgAttackTeamsQuery { + return &EpicGvgAttackTeamsQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeEpicGvgAttackTeams}, + inters: c.Interceptors(), + } +} + +// Get returns a EpicGvgAttackTeams entity by its id. +func (c *EpicGvgAttackTeamsClient) Get(ctx context.Context, id int64) (*EpicGvgAttackTeams, error) { + return c.Query().Where(epicgvgattackteams.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *EpicGvgAttackTeamsClient) GetX(ctx context.Context, id int64) *EpicGvgAttackTeams { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *EpicGvgAttackTeamsClient) Hooks() []Hook { + return c.hooks.EpicGvgAttackTeams +} + +// Interceptors returns the client interceptors. +func (c *EpicGvgAttackTeamsClient) Interceptors() []Interceptor { + return c.inters.EpicGvgAttackTeams +} + +func (c *EpicGvgAttackTeamsClient) mutate(ctx context.Context, m *EpicGvgAttackTeamsMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&EpicGvgAttackTeamsCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&EpicGvgAttackTeamsUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&EpicGvgAttackTeamsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&EpicGvgAttackTeamsDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown EpicGvgAttackTeams mutation op: %q", m.Op()) + } +} + +// EpicGvgDefenseAttackMappingClient is a client for the EpicGvgDefenseAttackMapping schema. +type EpicGvgDefenseAttackMappingClient struct { + config +} + +// NewEpicGvgDefenseAttackMappingClient returns a client for the EpicGvgDefenseAttackMapping from the given config. +func NewEpicGvgDefenseAttackMappingClient(c config) *EpicGvgDefenseAttackMappingClient { + return &EpicGvgDefenseAttackMappingClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `epicgvgdefenseattackmapping.Hooks(f(g(h())))`. +func (c *EpicGvgDefenseAttackMappingClient) Use(hooks ...Hook) { + c.hooks.EpicGvgDefenseAttackMapping = append(c.hooks.EpicGvgDefenseAttackMapping, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `epicgvgdefenseattackmapping.Intercept(f(g(h())))`. +func (c *EpicGvgDefenseAttackMappingClient) Intercept(interceptors ...Interceptor) { + c.inters.EpicGvgDefenseAttackMapping = append(c.inters.EpicGvgDefenseAttackMapping, interceptors...) +} + +// Create returns a builder for creating a EpicGvgDefenseAttackMapping entity. +func (c *EpicGvgDefenseAttackMappingClient) Create() *EpicGvgDefenseAttackMappingCreate { + mutation := newEpicGvgDefenseAttackMappingMutation(c.config, OpCreate) + return &EpicGvgDefenseAttackMappingCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of EpicGvgDefenseAttackMapping entities. +func (c *EpicGvgDefenseAttackMappingClient) CreateBulk(builders ...*EpicGvgDefenseAttackMappingCreate) *EpicGvgDefenseAttackMappingCreateBulk { + return &EpicGvgDefenseAttackMappingCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *EpicGvgDefenseAttackMappingClient) MapCreateBulk(slice any, setFunc func(*EpicGvgDefenseAttackMappingCreate, int)) *EpicGvgDefenseAttackMappingCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &EpicGvgDefenseAttackMappingCreateBulk{err: fmt.Errorf("calling to EpicGvgDefenseAttackMappingClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*EpicGvgDefenseAttackMappingCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &EpicGvgDefenseAttackMappingCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for EpicGvgDefenseAttackMapping. +func (c *EpicGvgDefenseAttackMappingClient) Update() *EpicGvgDefenseAttackMappingUpdate { + mutation := newEpicGvgDefenseAttackMappingMutation(c.config, OpUpdate) + return &EpicGvgDefenseAttackMappingUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *EpicGvgDefenseAttackMappingClient) UpdateOne(_m *EpicGvgDefenseAttackMapping) *EpicGvgDefenseAttackMappingUpdateOne { + mutation := newEpicGvgDefenseAttackMappingMutation(c.config, OpUpdateOne, withEpicGvgDefenseAttackMapping(_m)) + return &EpicGvgDefenseAttackMappingUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *EpicGvgDefenseAttackMappingClient) UpdateOneID(id int64) *EpicGvgDefenseAttackMappingUpdateOne { + mutation := newEpicGvgDefenseAttackMappingMutation(c.config, OpUpdateOne, withEpicGvgDefenseAttackMappingID(id)) + return &EpicGvgDefenseAttackMappingUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for EpicGvgDefenseAttackMapping. +func (c *EpicGvgDefenseAttackMappingClient) Delete() *EpicGvgDefenseAttackMappingDelete { + mutation := newEpicGvgDefenseAttackMappingMutation(c.config, OpDelete) + return &EpicGvgDefenseAttackMappingDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *EpicGvgDefenseAttackMappingClient) DeleteOne(_m *EpicGvgDefenseAttackMapping) *EpicGvgDefenseAttackMappingDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *EpicGvgDefenseAttackMappingClient) DeleteOneID(id int64) *EpicGvgDefenseAttackMappingDeleteOne { + builder := c.Delete().Where(epicgvgdefenseattackmapping.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &EpicGvgDefenseAttackMappingDeleteOne{builder} +} + +// Query returns a query builder for EpicGvgDefenseAttackMapping. +func (c *EpicGvgDefenseAttackMappingClient) Query() *EpicGvgDefenseAttackMappingQuery { + return &EpicGvgDefenseAttackMappingQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeEpicGvgDefenseAttackMapping}, + inters: c.Interceptors(), + } +} + +// Get returns a EpicGvgDefenseAttackMapping entity by its id. +func (c *EpicGvgDefenseAttackMappingClient) Get(ctx context.Context, id int64) (*EpicGvgDefenseAttackMapping, error) { + return c.Query().Where(epicgvgdefenseattackmapping.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *EpicGvgDefenseAttackMappingClient) GetX(ctx context.Context, id int64) *EpicGvgDefenseAttackMapping { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *EpicGvgDefenseAttackMappingClient) Hooks() []Hook { + return c.hooks.EpicGvgDefenseAttackMapping +} + +// Interceptors returns the client interceptors. +func (c *EpicGvgDefenseAttackMappingClient) Interceptors() []Interceptor { + return c.inters.EpicGvgDefenseAttackMapping +} + +func (c *EpicGvgDefenseAttackMappingClient) mutate(ctx context.Context, m *EpicGvgDefenseAttackMappingMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&EpicGvgDefenseAttackMappingCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&EpicGvgDefenseAttackMappingUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&EpicGvgDefenseAttackMappingUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&EpicGvgDefenseAttackMappingDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown EpicGvgDefenseAttackMapping mutation op: %q", m.Op()) + } +} + +// EpicGvgDefenseTeamsClient is a client for the EpicGvgDefenseTeams schema. +type EpicGvgDefenseTeamsClient struct { + config +} + +// NewEpicGvgDefenseTeamsClient returns a client for the EpicGvgDefenseTeams from the given config. +func NewEpicGvgDefenseTeamsClient(c config) *EpicGvgDefenseTeamsClient { + return &EpicGvgDefenseTeamsClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `epicgvgdefenseteams.Hooks(f(g(h())))`. +func (c *EpicGvgDefenseTeamsClient) Use(hooks ...Hook) { + c.hooks.EpicGvgDefenseTeams = append(c.hooks.EpicGvgDefenseTeams, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `epicgvgdefenseteams.Intercept(f(g(h())))`. +func (c *EpicGvgDefenseTeamsClient) Intercept(interceptors ...Interceptor) { + c.inters.EpicGvgDefenseTeams = append(c.inters.EpicGvgDefenseTeams, interceptors...) +} + +// Create returns a builder for creating a EpicGvgDefenseTeams entity. +func (c *EpicGvgDefenseTeamsClient) Create() *EpicGvgDefenseTeamsCreate { + mutation := newEpicGvgDefenseTeamsMutation(c.config, OpCreate) + return &EpicGvgDefenseTeamsCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of EpicGvgDefenseTeams entities. +func (c *EpicGvgDefenseTeamsClient) CreateBulk(builders ...*EpicGvgDefenseTeamsCreate) *EpicGvgDefenseTeamsCreateBulk { + return &EpicGvgDefenseTeamsCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *EpicGvgDefenseTeamsClient) MapCreateBulk(slice any, setFunc func(*EpicGvgDefenseTeamsCreate, int)) *EpicGvgDefenseTeamsCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &EpicGvgDefenseTeamsCreateBulk{err: fmt.Errorf("calling to EpicGvgDefenseTeamsClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*EpicGvgDefenseTeamsCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &EpicGvgDefenseTeamsCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for EpicGvgDefenseTeams. +func (c *EpicGvgDefenseTeamsClient) Update() *EpicGvgDefenseTeamsUpdate { + mutation := newEpicGvgDefenseTeamsMutation(c.config, OpUpdate) + return &EpicGvgDefenseTeamsUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *EpicGvgDefenseTeamsClient) UpdateOne(_m *EpicGvgDefenseTeams) *EpicGvgDefenseTeamsUpdateOne { + mutation := newEpicGvgDefenseTeamsMutation(c.config, OpUpdateOne, withEpicGvgDefenseTeams(_m)) + return &EpicGvgDefenseTeamsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *EpicGvgDefenseTeamsClient) UpdateOneID(id int64) *EpicGvgDefenseTeamsUpdateOne { + mutation := newEpicGvgDefenseTeamsMutation(c.config, OpUpdateOne, withEpicGvgDefenseTeamsID(id)) + return &EpicGvgDefenseTeamsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for EpicGvgDefenseTeams. +func (c *EpicGvgDefenseTeamsClient) Delete() *EpicGvgDefenseTeamsDelete { + mutation := newEpicGvgDefenseTeamsMutation(c.config, OpDelete) + return &EpicGvgDefenseTeamsDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *EpicGvgDefenseTeamsClient) DeleteOne(_m *EpicGvgDefenseTeams) *EpicGvgDefenseTeamsDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *EpicGvgDefenseTeamsClient) DeleteOneID(id int64) *EpicGvgDefenseTeamsDeleteOne { + builder := c.Delete().Where(epicgvgdefenseteams.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &EpicGvgDefenseTeamsDeleteOne{builder} +} + +// Query returns a query builder for EpicGvgDefenseTeams. +func (c *EpicGvgDefenseTeamsClient) Query() *EpicGvgDefenseTeamsQuery { + return &EpicGvgDefenseTeamsQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeEpicGvgDefenseTeams}, + inters: c.Interceptors(), + } +} + +// Get returns a EpicGvgDefenseTeams entity by its id. +func (c *EpicGvgDefenseTeamsClient) Get(ctx context.Context, id int64) (*EpicGvgDefenseTeams, error) { + return c.Query().Where(epicgvgdefenseteams.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *EpicGvgDefenseTeamsClient) GetX(ctx context.Context, id int64) *EpicGvgDefenseTeams { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *EpicGvgDefenseTeamsClient) Hooks() []Hook { + return c.hooks.EpicGvgDefenseTeams +} + +// Interceptors returns the client interceptors. +func (c *EpicGvgDefenseTeamsClient) Interceptors() []Interceptor { + return c.inters.EpicGvgDefenseTeams +} + +func (c *EpicGvgDefenseTeamsClient) mutate(ctx context.Context, m *EpicGvgDefenseTeamsMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&EpicGvgDefenseTeamsCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&EpicGvgDefenseTeamsUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&EpicGvgDefenseTeamsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&EpicGvgDefenseTeamsDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown EpicGvgDefenseTeams mutation op: %q", m.Op()) + } +} + +// EpicHeroInfoClient is a client for the EpicHeroInfo schema. +type EpicHeroInfoClient struct { + config +} + +// NewEpicHeroInfoClient returns a client for the EpicHeroInfo from the given config. +func NewEpicHeroInfoClient(c config) *EpicHeroInfoClient { + return &EpicHeroInfoClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `epicheroinfo.Hooks(f(g(h())))`. +func (c *EpicHeroInfoClient) Use(hooks ...Hook) { + c.hooks.EpicHeroInfo = append(c.hooks.EpicHeroInfo, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `epicheroinfo.Intercept(f(g(h())))`. +func (c *EpicHeroInfoClient) Intercept(interceptors ...Interceptor) { + c.inters.EpicHeroInfo = append(c.inters.EpicHeroInfo, interceptors...) +} + +// Create returns a builder for creating a EpicHeroInfo entity. +func (c *EpicHeroInfoClient) Create() *EpicHeroInfoCreate { + mutation := newEpicHeroInfoMutation(c.config, OpCreate) + return &EpicHeroInfoCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of EpicHeroInfo entities. +func (c *EpicHeroInfoClient) CreateBulk(builders ...*EpicHeroInfoCreate) *EpicHeroInfoCreateBulk { + return &EpicHeroInfoCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *EpicHeroInfoClient) MapCreateBulk(slice any, setFunc func(*EpicHeroInfoCreate, int)) *EpicHeroInfoCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &EpicHeroInfoCreateBulk{err: fmt.Errorf("calling to EpicHeroInfoClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*EpicHeroInfoCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &EpicHeroInfoCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for EpicHeroInfo. +func (c *EpicHeroInfoClient) Update() *EpicHeroInfoUpdate { + mutation := newEpicHeroInfoMutation(c.config, OpUpdate) + return &EpicHeroInfoUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *EpicHeroInfoClient) UpdateOne(_m *EpicHeroInfo) *EpicHeroInfoUpdateOne { + mutation := newEpicHeroInfoMutation(c.config, OpUpdateOne, withEpicHeroInfo(_m)) + return &EpicHeroInfoUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *EpicHeroInfoClient) UpdateOneID(id int64) *EpicHeroInfoUpdateOne { + mutation := newEpicHeroInfoMutation(c.config, OpUpdateOne, withEpicHeroInfoID(id)) + return &EpicHeroInfoUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for EpicHeroInfo. +func (c *EpicHeroInfoClient) Delete() *EpicHeroInfoDelete { + mutation := newEpicHeroInfoMutation(c.config, OpDelete) + return &EpicHeroInfoDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *EpicHeroInfoClient) DeleteOne(_m *EpicHeroInfo) *EpicHeroInfoDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *EpicHeroInfoClient) DeleteOneID(id int64) *EpicHeroInfoDeleteOne { + builder := c.Delete().Where(epicheroinfo.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &EpicHeroInfoDeleteOne{builder} +} + +// Query returns a query builder for EpicHeroInfo. +func (c *EpicHeroInfoClient) Query() *EpicHeroInfoQuery { + return &EpicHeroInfoQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeEpicHeroInfo}, + inters: c.Interceptors(), + } +} + +// Get returns a EpicHeroInfo entity by its id. +func (c *EpicHeroInfoClient) Get(ctx context.Context, id int64) (*EpicHeroInfo, error) { + return c.Query().Where(epicheroinfo.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *EpicHeroInfoClient) GetX(ctx context.Context, id int64) *EpicHeroInfo { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *EpicHeroInfoClient) Hooks() []Hook { + return c.hooks.EpicHeroInfo +} + +// Interceptors returns the client interceptors. +func (c *EpicHeroInfoClient) Interceptors() []Interceptor { + return c.inters.EpicHeroInfo +} + +func (c *EpicHeroInfoClient) mutate(ctx context.Context, m *EpicHeroInfoMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&EpicHeroInfoCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&EpicHeroInfoUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&EpicHeroInfoUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&EpicHeroInfoDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown EpicHeroInfo mutation op: %q", m.Op()) + } +} + +// EpicHeroUserBuildClient is a client for the EpicHeroUserBuild schema. +type EpicHeroUserBuildClient struct { + config +} + +// NewEpicHeroUserBuildClient returns a client for the EpicHeroUserBuild from the given config. +func NewEpicHeroUserBuildClient(c config) *EpicHeroUserBuildClient { + return &EpicHeroUserBuildClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `epicherouserbuild.Hooks(f(g(h())))`. +func (c *EpicHeroUserBuildClient) Use(hooks ...Hook) { + c.hooks.EpicHeroUserBuild = append(c.hooks.EpicHeroUserBuild, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `epicherouserbuild.Intercept(f(g(h())))`. +func (c *EpicHeroUserBuildClient) Intercept(interceptors ...Interceptor) { + c.inters.EpicHeroUserBuild = append(c.inters.EpicHeroUserBuild, interceptors...) +} + +// Create returns a builder for creating a EpicHeroUserBuild entity. +func (c *EpicHeroUserBuildClient) Create() *EpicHeroUserBuildCreate { + mutation := newEpicHeroUserBuildMutation(c.config, OpCreate) + return &EpicHeroUserBuildCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of EpicHeroUserBuild entities. +func (c *EpicHeroUserBuildClient) CreateBulk(builders ...*EpicHeroUserBuildCreate) *EpicHeroUserBuildCreateBulk { + return &EpicHeroUserBuildCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *EpicHeroUserBuildClient) MapCreateBulk(slice any, setFunc func(*EpicHeroUserBuildCreate, int)) *EpicHeroUserBuildCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &EpicHeroUserBuildCreateBulk{err: fmt.Errorf("calling to EpicHeroUserBuildClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*EpicHeroUserBuildCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &EpicHeroUserBuildCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for EpicHeroUserBuild. +func (c *EpicHeroUserBuildClient) Update() *EpicHeroUserBuildUpdate { + mutation := newEpicHeroUserBuildMutation(c.config, OpUpdate) + return &EpicHeroUserBuildUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *EpicHeroUserBuildClient) UpdateOne(_m *EpicHeroUserBuild) *EpicHeroUserBuildUpdateOne { + mutation := newEpicHeroUserBuildMutation(c.config, OpUpdateOne, withEpicHeroUserBuild(_m)) + return &EpicHeroUserBuildUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *EpicHeroUserBuildClient) UpdateOneID(id int64) *EpicHeroUserBuildUpdateOne { + mutation := newEpicHeroUserBuildMutation(c.config, OpUpdateOne, withEpicHeroUserBuildID(id)) + return &EpicHeroUserBuildUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for EpicHeroUserBuild. +func (c *EpicHeroUserBuildClient) Delete() *EpicHeroUserBuildDelete { + mutation := newEpicHeroUserBuildMutation(c.config, OpDelete) + return &EpicHeroUserBuildDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *EpicHeroUserBuildClient) DeleteOne(_m *EpicHeroUserBuild) *EpicHeroUserBuildDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *EpicHeroUserBuildClient) DeleteOneID(id int64) *EpicHeroUserBuildDeleteOne { + builder := c.Delete().Where(epicherouserbuild.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &EpicHeroUserBuildDeleteOne{builder} +} + +// Query returns a query builder for EpicHeroUserBuild. +func (c *EpicHeroUserBuildClient) Query() *EpicHeroUserBuildQuery { + return &EpicHeroUserBuildQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeEpicHeroUserBuild}, + inters: c.Interceptors(), + } +} + +// Get returns a EpicHeroUserBuild entity by its id. +func (c *EpicHeroUserBuildClient) Get(ctx context.Context, id int64) (*EpicHeroUserBuild, error) { + return c.Query().Where(epicherouserbuild.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *EpicHeroUserBuildClient) GetX(ctx context.Context, id int64) *EpicHeroUserBuild { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *EpicHeroUserBuildClient) Hooks() []Hook { + return c.hooks.EpicHeroUserBuild +} + +// Interceptors returns the client interceptors. +func (c *EpicHeroUserBuildClient) Interceptors() []Interceptor { + return c.inters.EpicHeroUserBuild +} + +func (c *EpicHeroUserBuildClient) mutate(ctx context.Context, m *EpicHeroUserBuildMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&EpicHeroUserBuildCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&EpicHeroUserBuildUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&EpicHeroUserBuildUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&EpicHeroUserBuildDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown EpicHeroUserBuild mutation op: %q", m.Op()) + } +} + +// EpicI18NMappingsClient is a client for the EpicI18NMappings schema. +type EpicI18NMappingsClient struct { + config +} + +// NewEpicI18NMappingsClient returns a client for the EpicI18NMappings from the given config. +func NewEpicI18NMappingsClient(c config) *EpicI18NMappingsClient { + return &EpicI18NMappingsClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `epici18nmappings.Hooks(f(g(h())))`. +func (c *EpicI18NMappingsClient) Use(hooks ...Hook) { + c.hooks.EpicI18NMappings = append(c.hooks.EpicI18NMappings, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `epici18nmappings.Intercept(f(g(h())))`. +func (c *EpicI18NMappingsClient) Intercept(interceptors ...Interceptor) { + c.inters.EpicI18NMappings = append(c.inters.EpicI18NMappings, interceptors...) +} + +// Create returns a builder for creating a EpicI18NMappings entity. +func (c *EpicI18NMappingsClient) Create() *EpicI18NMappingsCreate { + mutation := newEpicI18NMappingsMutation(c.config, OpCreate) + return &EpicI18NMappingsCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of EpicI18NMappings entities. +func (c *EpicI18NMappingsClient) CreateBulk(builders ...*EpicI18NMappingsCreate) *EpicI18NMappingsCreateBulk { + return &EpicI18NMappingsCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *EpicI18NMappingsClient) MapCreateBulk(slice any, setFunc func(*EpicI18NMappingsCreate, int)) *EpicI18NMappingsCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &EpicI18NMappingsCreateBulk{err: fmt.Errorf("calling to EpicI18NMappingsClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*EpicI18NMappingsCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &EpicI18NMappingsCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for EpicI18NMappings. +func (c *EpicI18NMappingsClient) Update() *EpicI18NMappingsUpdate { + mutation := newEpicI18NMappingsMutation(c.config, OpUpdate) + return &EpicI18NMappingsUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *EpicI18NMappingsClient) UpdateOne(_m *EpicI18NMappings) *EpicI18NMappingsUpdateOne { + mutation := newEpicI18NMappingsMutation(c.config, OpUpdateOne, withEpicI18NMappings(_m)) + return &EpicI18NMappingsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *EpicI18NMappingsClient) UpdateOneID(id int64) *EpicI18NMappingsUpdateOne { + mutation := newEpicI18NMappingsMutation(c.config, OpUpdateOne, withEpicI18NMappingsID(id)) + return &EpicI18NMappingsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for EpicI18NMappings. +func (c *EpicI18NMappingsClient) Delete() *EpicI18NMappingsDelete { + mutation := newEpicI18NMappingsMutation(c.config, OpDelete) + return &EpicI18NMappingsDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *EpicI18NMappingsClient) DeleteOne(_m *EpicI18NMappings) *EpicI18NMappingsDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *EpicI18NMappingsClient) DeleteOneID(id int64) *EpicI18NMappingsDeleteOne { + builder := c.Delete().Where(epici18nmappings.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &EpicI18NMappingsDeleteOne{builder} +} + +// Query returns a query builder for EpicI18NMappings. +func (c *EpicI18NMappingsClient) Query() *EpicI18NMappingsQuery { + return &EpicI18NMappingsQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeEpicI18NMappings}, + inters: c.Interceptors(), + } +} + +// Get returns a EpicI18NMappings entity by its id. +func (c *EpicI18NMappingsClient) Get(ctx context.Context, id int64) (*EpicI18NMappings, error) { + return c.Query().Where(epici18nmappings.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *EpicI18NMappingsClient) GetX(ctx context.Context, id int64) *EpicI18NMappings { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *EpicI18NMappingsClient) Hooks() []Hook { + return c.hooks.EpicI18NMappings +} + +// Interceptors returns the client interceptors. +func (c *EpicI18NMappingsClient) Interceptors() []Interceptor { + return c.inters.EpicI18NMappings +} + +func (c *EpicI18NMappingsClient) mutate(ctx context.Context, m *EpicI18NMappingsMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&EpicI18NMappingsCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&EpicI18NMappingsUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&EpicI18NMappingsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&EpicI18NMappingsDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown EpicI18NMappings mutation op: %q", m.Op()) + } +} + +// FribbleHeroSetClient is a client for the FribbleHeroSet schema. +type FribbleHeroSetClient struct { + config +} + +// NewFribbleHeroSetClient returns a client for the FribbleHeroSet from the given config. +func NewFribbleHeroSetClient(c config) *FribbleHeroSetClient { + return &FribbleHeroSetClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `fribbleheroset.Hooks(f(g(h())))`. +func (c *FribbleHeroSetClient) Use(hooks ...Hook) { + c.hooks.FribbleHeroSet = append(c.hooks.FribbleHeroSet, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `fribbleheroset.Intercept(f(g(h())))`. +func (c *FribbleHeroSetClient) Intercept(interceptors ...Interceptor) { + c.inters.FribbleHeroSet = append(c.inters.FribbleHeroSet, interceptors...) +} + +// Create returns a builder for creating a FribbleHeroSet entity. +func (c *FribbleHeroSetClient) Create() *FribbleHeroSetCreate { + mutation := newFribbleHeroSetMutation(c.config, OpCreate) + return &FribbleHeroSetCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of FribbleHeroSet entities. +func (c *FribbleHeroSetClient) CreateBulk(builders ...*FribbleHeroSetCreate) *FribbleHeroSetCreateBulk { + return &FribbleHeroSetCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *FribbleHeroSetClient) MapCreateBulk(slice any, setFunc func(*FribbleHeroSetCreate, int)) *FribbleHeroSetCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &FribbleHeroSetCreateBulk{err: fmt.Errorf("calling to FribbleHeroSetClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*FribbleHeroSetCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &FribbleHeroSetCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for FribbleHeroSet. +func (c *FribbleHeroSetClient) Update() *FribbleHeroSetUpdate { + mutation := newFribbleHeroSetMutation(c.config, OpUpdate) + return &FribbleHeroSetUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *FribbleHeroSetClient) UpdateOne(_m *FribbleHeroSet) *FribbleHeroSetUpdateOne { + mutation := newFribbleHeroSetMutation(c.config, OpUpdateOne, withFribbleHeroSet(_m)) + return &FribbleHeroSetUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *FribbleHeroSetClient) UpdateOneID(id int64) *FribbleHeroSetUpdateOne { + mutation := newFribbleHeroSetMutation(c.config, OpUpdateOne, withFribbleHeroSetID(id)) + return &FribbleHeroSetUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for FribbleHeroSet. +func (c *FribbleHeroSetClient) Delete() *FribbleHeroSetDelete { + mutation := newFribbleHeroSetMutation(c.config, OpDelete) + return &FribbleHeroSetDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *FribbleHeroSetClient) DeleteOne(_m *FribbleHeroSet) *FribbleHeroSetDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *FribbleHeroSetClient) DeleteOneID(id int64) *FribbleHeroSetDeleteOne { + builder := c.Delete().Where(fribbleheroset.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &FribbleHeroSetDeleteOne{builder} +} + +// Query returns a query builder for FribbleHeroSet. +func (c *FribbleHeroSetClient) Query() *FribbleHeroSetQuery { + return &FribbleHeroSetQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeFribbleHeroSet}, + inters: c.Interceptors(), + } +} + +// Get returns a FribbleHeroSet entity by its id. +func (c *FribbleHeroSetClient) Get(ctx context.Context, id int64) (*FribbleHeroSet, error) { + return c.Query().Where(fribbleheroset.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *FribbleHeroSetClient) GetX(ctx context.Context, id int64) *FribbleHeroSet { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *FribbleHeroSetClient) Hooks() []Hook { + return c.hooks.FribbleHeroSet +} + +// Interceptors returns the client interceptors. +func (c *FribbleHeroSetClient) Interceptors() []Interceptor { + return c.inters.FribbleHeroSet +} + +func (c *FribbleHeroSetClient) mutate(ctx context.Context, m *FribbleHeroSetMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&FribbleHeroSetCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&FribbleHeroSetUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&FribbleHeroSetUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&FribbleHeroSetDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown FribbleHeroSet mutation op: %q", m.Op()) + } +} + +// GearSetInfoClient is a client for the GearSetInfo schema. +type GearSetInfoClient struct { + config +} + +// NewGearSetInfoClient returns a client for the GearSetInfo from the given config. +func NewGearSetInfoClient(c config) *GearSetInfoClient { + return &GearSetInfoClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `gearsetinfo.Hooks(f(g(h())))`. +func (c *GearSetInfoClient) Use(hooks ...Hook) { + c.hooks.GearSetInfo = append(c.hooks.GearSetInfo, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `gearsetinfo.Intercept(f(g(h())))`. +func (c *GearSetInfoClient) Intercept(interceptors ...Interceptor) { + c.inters.GearSetInfo = append(c.inters.GearSetInfo, interceptors...) +} + +// Create returns a builder for creating a GearSetInfo entity. +func (c *GearSetInfoClient) Create() *GearSetInfoCreate { + mutation := newGearSetInfoMutation(c.config, OpCreate) + return &GearSetInfoCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of GearSetInfo entities. +func (c *GearSetInfoClient) CreateBulk(builders ...*GearSetInfoCreate) *GearSetInfoCreateBulk { + return &GearSetInfoCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *GearSetInfoClient) MapCreateBulk(slice any, setFunc func(*GearSetInfoCreate, int)) *GearSetInfoCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &GearSetInfoCreateBulk{err: fmt.Errorf("calling to GearSetInfoClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*GearSetInfoCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &GearSetInfoCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for GearSetInfo. +func (c *GearSetInfoClient) Update() *GearSetInfoUpdate { + mutation := newGearSetInfoMutation(c.config, OpUpdate) + return &GearSetInfoUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *GearSetInfoClient) UpdateOne(_m *GearSetInfo) *GearSetInfoUpdateOne { + mutation := newGearSetInfoMutation(c.config, OpUpdateOne, withGearSetInfo(_m)) + return &GearSetInfoUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *GearSetInfoClient) UpdateOneID(id int64) *GearSetInfoUpdateOne { + mutation := newGearSetInfoMutation(c.config, OpUpdateOne, withGearSetInfoID(id)) + return &GearSetInfoUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for GearSetInfo. +func (c *GearSetInfoClient) Delete() *GearSetInfoDelete { + mutation := newGearSetInfoMutation(c.config, OpDelete) + return &GearSetInfoDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *GearSetInfoClient) DeleteOne(_m *GearSetInfo) *GearSetInfoDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *GearSetInfoClient) DeleteOneID(id int64) *GearSetInfoDeleteOne { + builder := c.Delete().Where(gearsetinfo.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &GearSetInfoDeleteOne{builder} +} + +// Query returns a query builder for GearSetInfo. +func (c *GearSetInfoClient) Query() *GearSetInfoQuery { + return &GearSetInfoQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeGearSetInfo}, + inters: c.Interceptors(), + } +} + +// Get returns a GearSetInfo entity by its id. +func (c *GearSetInfoClient) Get(ctx context.Context, id int64) (*GearSetInfo, error) { + return c.Query().Where(gearsetinfo.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *GearSetInfoClient) GetX(ctx context.Context, id int64) *GearSetInfo { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *GearSetInfoClient) Hooks() []Hook { + return c.hooks.GearSetInfo +} + +// Interceptors returns the client interceptors. +func (c *GearSetInfoClient) Interceptors() []Interceptor { + return c.inters.GearSetInfo +} + +func (c *GearSetInfoClient) mutate(ctx context.Context, m *GearSetInfoMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&GearSetInfoCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&GearSetInfoUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&GearSetInfoUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&GearSetInfoDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown GearSetInfo mutation op: %q", m.Op()) + } +} + +// hooks and interceptors per client, for fast access. +type ( + hooks struct { + EpicArtifactInfo, EpicGvgAttackTeams, EpicGvgDefenseAttackMapping, + EpicGvgDefenseTeams, EpicHeroInfo, EpicHeroUserBuild, EpicI18NMappings, + FribbleHeroSet, GearSetInfo []ent.Hook + } + inters struct { + EpicArtifactInfo, EpicGvgAttackTeams, EpicGvgDefenseAttackMapping, + EpicGvgDefenseTeams, EpicHeroInfo, EpicHeroUserBuild, EpicI18NMappings, + FribbleHeroSet, GearSetInfo []ent.Interceptor + } +) diff --git a/internal/ent/doc.go b/internal/ent/doc.go new file mode 100644 index 0000000..e55842a --- /dev/null +++ b/internal/ent/doc.go @@ -0,0 +1 @@ +package ent diff --git a/internal/ent/ent.go b/internal/ent/ent.go new file mode 100644 index 0000000..9120496 --- /dev/null +++ b/internal/ent/ent.go @@ -0,0 +1,624 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "epic-ent/internal/ent/epicartifactinfo" + "epic-ent/internal/ent/epicgvgattackteams" + "epic-ent/internal/ent/epicgvgdefenseattackmapping" + "epic-ent/internal/ent/epicgvgdefenseteams" + "epic-ent/internal/ent/epicheroinfo" + "epic-ent/internal/ent/epicherouserbuild" + "epic-ent/internal/ent/epici18nmappings" + "epic-ent/internal/ent/fribbleheroset" + "epic-ent/internal/ent/gearsetinfo" + "errors" + "fmt" + "reflect" + "sync" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ent aliases to avoid import conflicts in user's code. +type ( + Op = ent.Op + Hook = ent.Hook + Value = ent.Value + Query = ent.Query + QueryContext = ent.QueryContext + Querier = ent.Querier + QuerierFunc = ent.QuerierFunc + Interceptor = ent.Interceptor + InterceptFunc = ent.InterceptFunc + Traverser = ent.Traverser + TraverseFunc = ent.TraverseFunc + Policy = ent.Policy + Mutator = ent.Mutator + Mutation = ent.Mutation + MutateFunc = ent.MutateFunc +) + +type clientCtxKey struct{} + +// FromContext returns a Client stored inside a context, or nil if there isn't one. +func FromContext(ctx context.Context) *Client { + c, _ := ctx.Value(clientCtxKey{}).(*Client) + return c +} + +// NewContext returns a new context with the given Client attached. +func NewContext(parent context.Context, c *Client) context.Context { + return context.WithValue(parent, clientCtxKey{}, c) +} + +type txCtxKey struct{} + +// TxFromContext returns a Tx stored inside a context, or nil if there isn't one. +func TxFromContext(ctx context.Context) *Tx { + tx, _ := ctx.Value(txCtxKey{}).(*Tx) + return tx +} + +// NewTxContext returns a new context with the given Tx attached. +func NewTxContext(parent context.Context, tx *Tx) context.Context { + return context.WithValue(parent, txCtxKey{}, tx) +} + +// OrderFunc applies an ordering on the sql selector. +// Deprecated: Use Asc/Desc functions or the package builders instead. +type OrderFunc func(*sql.Selector) + +var ( + initCheck sync.Once + columnCheck sql.ColumnCheck +) + +// checkColumn checks if the column exists in the given table. +func checkColumn(t, c string) error { + initCheck.Do(func() { + columnCheck = sql.NewColumnCheck(map[string]func(string) bool{ + epicartifactinfo.Table: epicartifactinfo.ValidColumn, + epicgvgattackteams.Table: epicgvgattackteams.ValidColumn, + epicgvgdefenseattackmapping.Table: epicgvgdefenseattackmapping.ValidColumn, + epicgvgdefenseteams.Table: epicgvgdefenseteams.ValidColumn, + epicheroinfo.Table: epicheroinfo.ValidColumn, + epicherouserbuild.Table: epicherouserbuild.ValidColumn, + epici18nmappings.Table: epici18nmappings.ValidColumn, + fribbleheroset.Table: fribbleheroset.ValidColumn, + gearsetinfo.Table: gearsetinfo.ValidColumn, + }) + }) + return columnCheck(t, c) +} + +// Asc applies the given fields in ASC order. +func Asc(fields ...string) func(*sql.Selector) { + return func(s *sql.Selector) { + for _, f := range fields { + if err := checkColumn(s.TableName(), f); err != nil { + s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)}) + } + s.OrderBy(sql.Asc(s.C(f))) + } + } +} + +// Desc applies the given fields in DESC order. +func Desc(fields ...string) func(*sql.Selector) { + return func(s *sql.Selector) { + for _, f := range fields { + if err := checkColumn(s.TableName(), f); err != nil { + s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)}) + } + s.OrderBy(sql.Desc(s.C(f))) + } + } +} + +// AggregateFunc applies an aggregation step on the group-by traversal/selector. +type AggregateFunc func(*sql.Selector) string + +// As is a pseudo aggregation function for renaming another other functions with custom names. For example: +// +// GroupBy(field1, field2). +// Aggregate(ent.As(ent.Sum(field1), "sum_field1"), (ent.As(ent.Sum(field2), "sum_field2")). +// Scan(ctx, &v) +func As(fn AggregateFunc, end string) AggregateFunc { + return func(s *sql.Selector) string { + return sql.As(fn(s), end) + } +} + +// Count applies the "count" aggregation function on each group. +func Count() AggregateFunc { + return func(s *sql.Selector) string { + return sql.Count("*") + } +} + +// Max applies the "max" aggregation function on the given field of each group. +func Max(field string) AggregateFunc { + return func(s *sql.Selector) string { + if err := checkColumn(s.TableName(), field); err != nil { + s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) + return "" + } + return sql.Max(s.C(field)) + } +} + +// Mean applies the "mean" aggregation function on the given field of each group. +func Mean(field string) AggregateFunc { + return func(s *sql.Selector) string { + if err := checkColumn(s.TableName(), field); err != nil { + s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) + return "" + } + return sql.Avg(s.C(field)) + } +} + +// Min applies the "min" aggregation function on the given field of each group. +func Min(field string) AggregateFunc { + return func(s *sql.Selector) string { + if err := checkColumn(s.TableName(), field); err != nil { + s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) + return "" + } + return sql.Min(s.C(field)) + } +} + +// Sum applies the "sum" aggregation function on the given field of each group. +func Sum(field string) AggregateFunc { + return func(s *sql.Selector) string { + if err := checkColumn(s.TableName(), field); err != nil { + s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) + return "" + } + return sql.Sum(s.C(field)) + } +} + +// ValidationError returns when validating a field or edge fails. +type ValidationError struct { + Name string // Field or edge name. + err error +} + +// Error implements the error interface. +func (e *ValidationError) Error() string { + return e.err.Error() +} + +// Unwrap implements the errors.Wrapper interface. +func (e *ValidationError) Unwrap() error { + return e.err +} + +// IsValidationError returns a boolean indicating whether the error is a validation error. +func IsValidationError(err error) bool { + if err == nil { + return false + } + var e *ValidationError + return errors.As(err, &e) +} + +// NotFoundError returns when trying to fetch a specific entity and it was not found in the database. +type NotFoundError struct { + label string +} + +// Error implements the error interface. +func (e *NotFoundError) Error() string { + return "ent: " + e.label + " not found" +} + +// IsNotFound returns a boolean indicating whether the error is a not found error. +func IsNotFound(err error) bool { + if err == nil { + return false + } + var e *NotFoundError + return errors.As(err, &e) +} + +// MaskNotFound masks not found error. +func MaskNotFound(err error) error { + if IsNotFound(err) { + return nil + } + return err +} + +// NotSingularError returns when trying to fetch a singular entity and more then one was found in the database. +type NotSingularError struct { + label string +} + +// Error implements the error interface. +func (e *NotSingularError) Error() string { + return "ent: " + e.label + " not singular" +} + +// IsNotSingular returns a boolean indicating whether the error is a not singular error. +func IsNotSingular(err error) bool { + if err == nil { + return false + } + var e *NotSingularError + return errors.As(err, &e) +} + +// NotLoadedError returns when trying to get a node that was not loaded by the query. +type NotLoadedError struct { + edge string +} + +// Error implements the error interface. +func (e *NotLoadedError) Error() string { + return "ent: " + e.edge + " edge was not loaded" +} + +// IsNotLoaded returns a boolean indicating whether the error is a not loaded error. +func IsNotLoaded(err error) bool { + if err == nil { + return false + } + var e *NotLoadedError + return errors.As(err, &e) +} + +// ConstraintError returns when trying to create/update one or more entities and +// one or more of their constraints failed. For example, violation of edge or +// field uniqueness. +type ConstraintError struct { + msg string + wrap error +} + +// Error implements the error interface. +func (e ConstraintError) Error() string { + return "ent: constraint failed: " + e.msg +} + +// Unwrap implements the errors.Wrapper interface. +func (e *ConstraintError) Unwrap() error { + return e.wrap +} + +// IsConstraintError returns a boolean indicating whether the error is a constraint failure. +func IsConstraintError(err error) bool { + if err == nil { + return false + } + var e *ConstraintError + return errors.As(err, &e) +} + +// selector embedded by the different Select/GroupBy builders. +type selector struct { + label string + flds *[]string + fns []AggregateFunc + scan func(context.Context, any) error +} + +// ScanX is like Scan, but panics if an error occurs. +func (s *selector) ScanX(ctx context.Context, v any) { + if err := s.scan(ctx, v); err != nil { + panic(err) + } +} + +// Strings returns list of strings from a selector. It is only allowed when selecting one field. +func (s *selector) Strings(ctx context.Context) ([]string, error) { + if len(*s.flds) > 1 { + return nil, errors.New("ent: Strings is not achievable when selecting more than 1 field") + } + var v []string + if err := s.scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// StringsX is like Strings, but panics if an error occurs. +func (s *selector) StringsX(ctx context.Context) []string { + v, err := s.Strings(ctx) + if err != nil { + panic(err) + } + return v +} + +// String returns a single string from a selector. It is only allowed when selecting one field. +func (s *selector) String(ctx context.Context) (_ string, err error) { + var v []string + if v, err = s.Strings(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{s.label} + default: + err = fmt.Errorf("ent: Strings returned %d results when one was expected", len(v)) + } + return +} + +// StringX is like String, but panics if an error occurs. +func (s *selector) StringX(ctx context.Context) string { + v, err := s.String(ctx) + if err != nil { + panic(err) + } + return v +} + +// Ints returns list of ints from a selector. It is only allowed when selecting one field. +func (s *selector) Ints(ctx context.Context) ([]int, error) { + if len(*s.flds) > 1 { + return nil, errors.New("ent: Ints is not achievable when selecting more than 1 field") + } + var v []int + if err := s.scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// IntsX is like Ints, but panics if an error occurs. +func (s *selector) IntsX(ctx context.Context) []int { + v, err := s.Ints(ctx) + if err != nil { + panic(err) + } + return v +} + +// Int returns a single int from a selector. It is only allowed when selecting one field. +func (s *selector) Int(ctx context.Context) (_ int, err error) { + var v []int + if v, err = s.Ints(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{s.label} + default: + err = fmt.Errorf("ent: Ints returned %d results when one was expected", len(v)) + } + return +} + +// IntX is like Int, but panics if an error occurs. +func (s *selector) IntX(ctx context.Context) int { + v, err := s.Int(ctx) + if err != nil { + panic(err) + } + return v +} + +// Float64s returns list of float64s from a selector. It is only allowed when selecting one field. +func (s *selector) Float64s(ctx context.Context) ([]float64, error) { + if len(*s.flds) > 1 { + return nil, errors.New("ent: Float64s is not achievable when selecting more than 1 field") + } + var v []float64 + if err := s.scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// Float64sX is like Float64s, but panics if an error occurs. +func (s *selector) Float64sX(ctx context.Context) []float64 { + v, err := s.Float64s(ctx) + if err != nil { + panic(err) + } + return v +} + +// Float64 returns a single float64 from a selector. It is only allowed when selecting one field. +func (s *selector) Float64(ctx context.Context) (_ float64, err error) { + var v []float64 + if v, err = s.Float64s(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{s.label} + default: + err = fmt.Errorf("ent: Float64s returned %d results when one was expected", len(v)) + } + return +} + +// Float64X is like Float64, but panics if an error occurs. +func (s *selector) Float64X(ctx context.Context) float64 { + v, err := s.Float64(ctx) + if err != nil { + panic(err) + } + return v +} + +// Bools returns list of bools from a selector. It is only allowed when selecting one field. +func (s *selector) Bools(ctx context.Context) ([]bool, error) { + if len(*s.flds) > 1 { + return nil, errors.New("ent: Bools is not achievable when selecting more than 1 field") + } + var v []bool + if err := s.scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// BoolsX is like Bools, but panics if an error occurs. +func (s *selector) BoolsX(ctx context.Context) []bool { + v, err := s.Bools(ctx) + if err != nil { + panic(err) + } + return v +} + +// Bool returns a single bool from a selector. It is only allowed when selecting one field. +func (s *selector) Bool(ctx context.Context) (_ bool, err error) { + var v []bool + if v, err = s.Bools(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{s.label} + default: + err = fmt.Errorf("ent: Bools returned %d results when one was expected", len(v)) + } + return +} + +// BoolX is like Bool, but panics if an error occurs. +func (s *selector) BoolX(ctx context.Context) bool { + v, err := s.Bool(ctx) + if err != nil { + panic(err) + } + return v +} + +// withHooks invokes the builder operation with the given hooks, if any. +func withHooks[V Value, M any, PM interface { + *M + Mutation +}](ctx context.Context, exec func(context.Context) (V, error), mutation PM, hooks []Hook) (value V, err error) { + if len(hooks) == 0 { + return exec(ctx) + } + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutationT, ok := any(m).(PM) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + // Set the mutation to the builder. + *mutation = *mutationT + return exec(ctx) + }) + for i := len(hooks) - 1; i >= 0; i-- { + if hooks[i] == nil { + return value, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") + } + mut = hooks[i](mut) + } + v, err := mut.Mutate(ctx, mutation) + if err != nil { + return value, err + } + nv, ok := v.(V) + if !ok { + return value, fmt.Errorf("unexpected node type %T returned from %T", v, mutation) + } + return nv, nil +} + +// setContextOp returns a new context with the given QueryContext attached (including its op) in case it does not exist. +func setContextOp(ctx context.Context, qc *QueryContext, op string) context.Context { + if ent.QueryFromContext(ctx) == nil { + qc.Op = op + ctx = ent.NewQueryContext(ctx, qc) + } + return ctx +} + +func querierAll[V Value, Q interface { + sqlAll(context.Context, ...queryHook) (V, error) +}]() Querier { + return QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + query, ok := q.(Q) + if !ok { + return nil, fmt.Errorf("unexpected query type %T", q) + } + return query.sqlAll(ctx) + }) +} + +func querierCount[Q interface { + sqlCount(context.Context) (int, error) +}]() Querier { + return QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + query, ok := q.(Q) + if !ok { + return nil, fmt.Errorf("unexpected query type %T", q) + } + return query.sqlCount(ctx) + }) +} + +func withInterceptors[V Value](ctx context.Context, q Query, qr Querier, inters []Interceptor) (v V, err error) { + for i := len(inters) - 1; i >= 0; i-- { + qr = inters[i].Intercept(qr) + } + rv, err := qr.Query(ctx, q) + if err != nil { + return v, err + } + vt, ok := rv.(V) + if !ok { + return v, fmt.Errorf("unexpected type %T returned from %T. expected type: %T", vt, q, v) + } + return vt, nil +} + +func scanWithInterceptors[Q1 ent.Query, Q2 interface { + sqlScan(context.Context, Q1, any) error +}](ctx context.Context, rootQuery Q1, selectOrGroup Q2, inters []Interceptor, v any) error { + rv := reflect.ValueOf(v) + var qr Querier = QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + query, ok := q.(Q1) + if !ok { + return nil, fmt.Errorf("unexpected query type %T", q) + } + if err := selectOrGroup.sqlScan(ctx, query, v); err != nil { + return nil, err + } + if k := rv.Kind(); k == reflect.Pointer && rv.Elem().CanInterface() { + return rv.Elem().Interface(), nil + } + return v, nil + }) + for i := len(inters) - 1; i >= 0; i-- { + qr = inters[i].Intercept(qr) + } + vv, err := qr.Query(ctx, rootQuery) + if err != nil { + return err + } + switch rv2 := reflect.ValueOf(vv); { + case rv.IsNil(), rv2.IsNil(), rv.Kind() != reflect.Pointer: + case rv.Type() == rv2.Type(): + rv.Elem().Set(rv2.Elem()) + case rv.Elem().Type() == rv2.Type(): + rv.Elem().Set(rv2) + } + return nil +} + +// queryHook describes an internal hook for the different sqlAll methods. +type queryHook func(context.Context, *sqlgraph.QuerySpec) diff --git a/internal/ent/enttest/enttest.go b/internal/ent/enttest/enttest.go new file mode 100644 index 0000000..82281ff --- /dev/null +++ b/internal/ent/enttest/enttest.go @@ -0,0 +1,85 @@ +// Code generated by ent, DO NOT EDIT. + +package enttest + +import ( + "context" + + "epic-ent/internal/ent" + // required by schema hooks. + _ "epic-ent/internal/ent/runtime" + + "epic-ent/internal/ent/migrate" + + "entgo.io/ent/dialect/sql/schema" +) + +type ( + // TestingT is the interface that is shared between + // testing.T and testing.B and used by enttest. + TestingT interface { + FailNow() + Error(...any) + } + + // Option configures client creation. + Option func(*options) + + options struct { + opts []ent.Option + migrateOpts []schema.MigrateOption + } +) + +// WithOptions forwards options to client creation. +func WithOptions(opts ...ent.Option) Option { + return func(o *options) { + o.opts = append(o.opts, opts...) + } +} + +// WithMigrateOptions forwards options to auto migration. +func WithMigrateOptions(opts ...schema.MigrateOption) Option { + return func(o *options) { + o.migrateOpts = append(o.migrateOpts, opts...) + } +} + +func newOptions(opts []Option) *options { + o := &options{} + for _, opt := range opts { + opt(o) + } + return o +} + +// Open calls ent.Open and auto-run migration. +func Open(t TestingT, driverName, dataSourceName string, opts ...Option) *ent.Client { + o := newOptions(opts) + c, err := ent.Open(driverName, dataSourceName, o.opts...) + if err != nil { + t.Error(err) + t.FailNow() + } + migrateSchema(t, c, o) + return c +} + +// NewClient calls ent.NewClient and auto-run migration. +func NewClient(t TestingT, opts ...Option) *ent.Client { + o := newOptions(opts) + c := ent.NewClient(o.opts...) + migrateSchema(t, c, o) + return c +} +func migrateSchema(t TestingT, c *ent.Client, o *options) { + tables, err := schema.CopyTables(migrate.Tables) + if err != nil { + t.Error(err) + t.FailNow() + } + if err := migrate.Create(context.Background(), c.Schema, tables, o.migrateOpts...); err != nil { + t.Error(err) + t.FailNow() + } +} diff --git a/internal/ent/epicartifactinfo.go b/internal/ent/epicartifactinfo.go new file mode 100644 index 0000000..0ecbdf6 --- /dev/null +++ b/internal/ent/epicartifactinfo.go @@ -0,0 +1,257 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "epic-ent/internal/ent/epicartifactinfo" + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// EpicArtifactInfo is the model entity for the EpicArtifactInfo schema. +type EpicArtifactInfo struct { + config `json:"-"` + // ID of the ent. + ID int64 `json:"id,omitempty"` + // ArtifactName holds the value of the "artifact_name" field. + ArtifactName string `json:"artifact_name,omitempty"` + // ArtifactCode holds the value of the "artifact_code" field. + ArtifactCode string `json:"artifact_code,omitempty"` + // Creator holds the value of the "creator" field. + Creator string `json:"creator,omitempty"` + // CreateTime holds the value of the "create_time" field. + CreateTime *time.Time `json:"create_time,omitempty"` + // Updater holds the value of the "updater" field. + Updater string `json:"updater,omitempty"` + // UpdateTime holds the value of the "update_time" field. + UpdateTime *time.Time `json:"update_time,omitempty"` + // Deleted holds the value of the "deleted" field. + Deleted bool `json:"deleted,omitempty"` + // StatsHealth holds the value of the "stats_health" field. + StatsHealth int `json:"stats_health,omitempty"` + // StatsAttack holds the value of the "stats_attack" field. + StatsAttack int `json:"stats_attack,omitempty"` + // StatsDefense holds the value of the "stats_defense" field. + StatsDefense int `json:"stats_defense,omitempty"` + // Rarity holds the value of the "rarity" field. + Rarity string `json:"rarity,omitempty"` + // Role holds the value of the "role" field. + Role string `json:"role,omitempty"` + // ArtifactNameEn holds the value of the "artifact_name_en" field. + ArtifactNameEn string `json:"artifact_name_en,omitempty"` + // ImageURL holds the value of the "image_url" field. + ImageURL string `json:"image_url,omitempty"` + selectValues sql.SelectValues +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*EpicArtifactInfo) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case epicartifactinfo.FieldDeleted: + values[i] = new(sql.NullBool) + case epicartifactinfo.FieldID, epicartifactinfo.FieldStatsHealth, epicartifactinfo.FieldStatsAttack, epicartifactinfo.FieldStatsDefense: + values[i] = new(sql.NullInt64) + case epicartifactinfo.FieldArtifactName, epicartifactinfo.FieldArtifactCode, epicartifactinfo.FieldCreator, epicartifactinfo.FieldUpdater, epicartifactinfo.FieldRarity, epicartifactinfo.FieldRole, epicartifactinfo.FieldArtifactNameEn, epicartifactinfo.FieldImageURL: + values[i] = new(sql.NullString) + case epicartifactinfo.FieldCreateTime, epicartifactinfo.FieldUpdateTime: + values[i] = new(sql.NullTime) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the EpicArtifactInfo fields. +func (_m *EpicArtifactInfo) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case epicartifactinfo.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + _m.ID = int64(value.Int64) + case epicartifactinfo.FieldArtifactName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field artifact_name", values[i]) + } else if value.Valid { + _m.ArtifactName = value.String + } + case epicartifactinfo.FieldArtifactCode: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field artifact_code", values[i]) + } else if value.Valid { + _m.ArtifactCode = value.String + } + case epicartifactinfo.FieldCreator: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field creator", values[i]) + } else if value.Valid { + _m.Creator = value.String + } + case epicartifactinfo.FieldCreateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field create_time", values[i]) + } else if value.Valid { + _m.CreateTime = new(time.Time) + *_m.CreateTime = value.Time + } + case epicartifactinfo.FieldUpdater: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field updater", values[i]) + } else if value.Valid { + _m.Updater = value.String + } + case epicartifactinfo.FieldUpdateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field update_time", values[i]) + } else if value.Valid { + _m.UpdateTime = new(time.Time) + *_m.UpdateTime = value.Time + } + case epicartifactinfo.FieldDeleted: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field deleted", values[i]) + } else if value.Valid { + _m.Deleted = value.Bool + } + case epicartifactinfo.FieldStatsHealth: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field stats_health", values[i]) + } else if value.Valid { + _m.StatsHealth = int(value.Int64) + } + case epicartifactinfo.FieldStatsAttack: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field stats_attack", values[i]) + } else if value.Valid { + _m.StatsAttack = int(value.Int64) + } + case epicartifactinfo.FieldStatsDefense: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field stats_defense", values[i]) + } else if value.Valid { + _m.StatsDefense = int(value.Int64) + } + case epicartifactinfo.FieldRarity: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field rarity", values[i]) + } else if value.Valid { + _m.Rarity = value.String + } + case epicartifactinfo.FieldRole: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field role", values[i]) + } else if value.Valid { + _m.Role = value.String + } + case epicartifactinfo.FieldArtifactNameEn: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field artifact_name_en", values[i]) + } else if value.Valid { + _m.ArtifactNameEn = value.String + } + case epicartifactinfo.FieldImageURL: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field image_url", values[i]) + } else if value.Valid { + _m.ImageURL = value.String + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the EpicArtifactInfo. +// This includes values selected through modifiers, order, etc. +func (_m *EpicArtifactInfo) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// Update returns a builder for updating this EpicArtifactInfo. +// Note that you need to call EpicArtifactInfo.Unwrap() before calling this method if this EpicArtifactInfo +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *EpicArtifactInfo) Update() *EpicArtifactInfoUpdateOne { + return NewEpicArtifactInfoClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the EpicArtifactInfo entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (_m *EpicArtifactInfo) Unwrap() *EpicArtifactInfo { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("ent: EpicArtifactInfo is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *EpicArtifactInfo) String() string { + var builder strings.Builder + builder.WriteString("EpicArtifactInfo(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("artifact_name=") + builder.WriteString(_m.ArtifactName) + builder.WriteString(", ") + builder.WriteString("artifact_code=") + builder.WriteString(_m.ArtifactCode) + builder.WriteString(", ") + builder.WriteString("creator=") + builder.WriteString(_m.Creator) + builder.WriteString(", ") + if v := _m.CreateTime; v != nil { + builder.WriteString("create_time=") + builder.WriteString(v.Format(time.ANSIC)) + } + builder.WriteString(", ") + builder.WriteString("updater=") + builder.WriteString(_m.Updater) + builder.WriteString(", ") + if v := _m.UpdateTime; v != nil { + builder.WriteString("update_time=") + builder.WriteString(v.Format(time.ANSIC)) + } + builder.WriteString(", ") + builder.WriteString("deleted=") + builder.WriteString(fmt.Sprintf("%v", _m.Deleted)) + builder.WriteString(", ") + builder.WriteString("stats_health=") + builder.WriteString(fmt.Sprintf("%v", _m.StatsHealth)) + builder.WriteString(", ") + builder.WriteString("stats_attack=") + builder.WriteString(fmt.Sprintf("%v", _m.StatsAttack)) + builder.WriteString(", ") + builder.WriteString("stats_defense=") + builder.WriteString(fmt.Sprintf("%v", _m.StatsDefense)) + builder.WriteString(", ") + builder.WriteString("rarity=") + builder.WriteString(_m.Rarity) + builder.WriteString(", ") + builder.WriteString("role=") + builder.WriteString(_m.Role) + builder.WriteString(", ") + builder.WriteString("artifact_name_en=") + builder.WriteString(_m.ArtifactNameEn) + builder.WriteString(", ") + builder.WriteString("image_url=") + builder.WriteString(_m.ImageURL) + builder.WriteByte(')') + return builder.String() +} + +// EpicArtifactInfos is a parsable slice of EpicArtifactInfo. +type EpicArtifactInfos []*EpicArtifactInfo diff --git a/internal/ent/epicartifactinfo/epicartifactinfo.go b/internal/ent/epicartifactinfo/epicartifactinfo.go new file mode 100644 index 0000000..23e57b7 --- /dev/null +++ b/internal/ent/epicartifactinfo/epicartifactinfo.go @@ -0,0 +1,170 @@ +// Code generated by ent, DO NOT EDIT. + +package epicartifactinfo + +import ( + "entgo.io/ent/dialect/sql" +) + +const ( + // Label holds the string label denoting the epicartifactinfo type in the database. + Label = "epic_artifact_info" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldArtifactName holds the string denoting the artifact_name field in the database. + FieldArtifactName = "artifact_name" + // FieldArtifactCode holds the string denoting the artifact_code field in the database. + FieldArtifactCode = "artifact_code" + // FieldCreator holds the string denoting the creator field in the database. + FieldCreator = "creator" + // FieldCreateTime holds the string denoting the create_time field in the database. + FieldCreateTime = "create_time" + // FieldUpdater holds the string denoting the updater field in the database. + FieldUpdater = "updater" + // FieldUpdateTime holds the string denoting the update_time field in the database. + FieldUpdateTime = "update_time" + // FieldDeleted holds the string denoting the deleted field in the database. + FieldDeleted = "deleted" + // FieldStatsHealth holds the string denoting the stats_health field in the database. + FieldStatsHealth = "stats_health" + // FieldStatsAttack holds the string denoting the stats_attack field in the database. + FieldStatsAttack = "stats_attack" + // FieldStatsDefense holds the string denoting the stats_defense field in the database. + FieldStatsDefense = "stats_defense" + // FieldRarity holds the string denoting the rarity field in the database. + FieldRarity = "rarity" + // FieldRole holds the string denoting the role field in the database. + FieldRole = "role" + // FieldArtifactNameEn holds the string denoting the artifact_name_en field in the database. + FieldArtifactNameEn = "artifact_name_en" + // FieldImageURL holds the string denoting the image_url field in the database. + FieldImageURL = "image_url" + // Table holds the table name of the epicartifactinfo in the database. + Table = "epic_artifact_infos" +) + +// Columns holds all SQL columns for epicartifactinfo fields. +var Columns = []string{ + FieldID, + FieldArtifactName, + FieldArtifactCode, + FieldCreator, + FieldCreateTime, + FieldUpdater, + FieldUpdateTime, + FieldDeleted, + FieldStatsHealth, + FieldStatsAttack, + FieldStatsDefense, + FieldRarity, + FieldRole, + FieldArtifactNameEn, + FieldImageURL, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // ArtifactNameValidator is a validator for the "artifact_name" field. It is called by the builders before save. + ArtifactNameValidator func(string) error + // ArtifactCodeValidator is a validator for the "artifact_code" field. It is called by the builders before save. + ArtifactCodeValidator func(string) error + // CreatorValidator is a validator for the "creator" field. It is called by the builders before save. + CreatorValidator func(string) error + // UpdaterValidator is a validator for the "updater" field. It is called by the builders before save. + UpdaterValidator func(string) error + // RarityValidator is a validator for the "rarity" field. It is called by the builders before save. + RarityValidator func(string) error + // RoleValidator is a validator for the "role" field. It is called by the builders before save. + RoleValidator func(string) error + // ArtifactNameEnValidator is a validator for the "artifact_name_en" field. It is called by the builders before save. + ArtifactNameEnValidator func(string) error + // ImageURLValidator is a validator for the "image_url" field. It is called by the builders before save. + ImageURLValidator func(string) error +) + +// OrderOption defines the ordering options for the EpicArtifactInfo queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByArtifactName orders the results by the artifact_name field. +func ByArtifactName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldArtifactName, opts...).ToFunc() +} + +// ByArtifactCode orders the results by the artifact_code field. +func ByArtifactCode(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldArtifactCode, opts...).ToFunc() +} + +// ByCreator orders the results by the creator field. +func ByCreator(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreator, opts...).ToFunc() +} + +// ByCreateTime orders the results by the create_time field. +func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateTime, opts...).ToFunc() +} + +// ByUpdater orders the results by the updater field. +func ByUpdater(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdater, opts...).ToFunc() +} + +// ByUpdateTime orders the results by the update_time field. +func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() +} + +// ByDeleted orders the results by the deleted field. +func ByDeleted(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeleted, opts...).ToFunc() +} + +// ByStatsHealth orders the results by the stats_health field. +func ByStatsHealth(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStatsHealth, opts...).ToFunc() +} + +// ByStatsAttack orders the results by the stats_attack field. +func ByStatsAttack(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStatsAttack, opts...).ToFunc() +} + +// ByStatsDefense orders the results by the stats_defense field. +func ByStatsDefense(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStatsDefense, opts...).ToFunc() +} + +// ByRarity orders the results by the rarity field. +func ByRarity(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldRarity, opts...).ToFunc() +} + +// ByRole orders the results by the role field. +func ByRole(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldRole, opts...).ToFunc() +} + +// ByArtifactNameEn orders the results by the artifact_name_en field. +func ByArtifactNameEn(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldArtifactNameEn, opts...).ToFunc() +} + +// ByImageURL orders the results by the image_url field. +func ByImageURL(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldImageURL, opts...).ToFunc() +} diff --git a/internal/ent/epicartifactinfo/where.go b/internal/ent/epicartifactinfo/where.go new file mode 100644 index 0000000..b3aafbd --- /dev/null +++ b/internal/ent/epicartifactinfo/where.go @@ -0,0 +1,890 @@ +// Code generated by ent, DO NOT EDIT. + +package epicartifactinfo + +import ( + "epic-ent/internal/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" +) + +// ID filters vertices based on their ID field. +func ID(id int64) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int64) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int64) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int64) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int64) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int64) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int64) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int64) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int64) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldLTE(FieldID, id)) +} + +// ArtifactName applies equality check predicate on the "artifact_name" field. It's identical to ArtifactNameEQ. +func ArtifactName(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldEQ(FieldArtifactName, v)) +} + +// ArtifactCode applies equality check predicate on the "artifact_code" field. It's identical to ArtifactCodeEQ. +func ArtifactCode(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldEQ(FieldArtifactCode, v)) +} + +// Creator applies equality check predicate on the "creator" field. It's identical to CreatorEQ. +func Creator(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldEQ(FieldCreator, v)) +} + +// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. +func CreateTime(v time.Time) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldEQ(FieldCreateTime, v)) +} + +// Updater applies equality check predicate on the "updater" field. It's identical to UpdaterEQ. +func Updater(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldEQ(FieldUpdater, v)) +} + +// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. +func UpdateTime(v time.Time) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldEQ(FieldUpdateTime, v)) +} + +// Deleted applies equality check predicate on the "deleted" field. It's identical to DeletedEQ. +func Deleted(v bool) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldEQ(FieldDeleted, v)) +} + +// StatsHealth applies equality check predicate on the "stats_health" field. It's identical to StatsHealthEQ. +func StatsHealth(v int) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldEQ(FieldStatsHealth, v)) +} + +// StatsAttack applies equality check predicate on the "stats_attack" field. It's identical to StatsAttackEQ. +func StatsAttack(v int) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldEQ(FieldStatsAttack, v)) +} + +// StatsDefense applies equality check predicate on the "stats_defense" field. It's identical to StatsDefenseEQ. +func StatsDefense(v int) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldEQ(FieldStatsDefense, v)) +} + +// Rarity applies equality check predicate on the "rarity" field. It's identical to RarityEQ. +func Rarity(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldEQ(FieldRarity, v)) +} + +// Role applies equality check predicate on the "role" field. It's identical to RoleEQ. +func Role(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldEQ(FieldRole, v)) +} + +// ArtifactNameEn applies equality check predicate on the "artifact_name_en" field. It's identical to ArtifactNameEnEQ. +func ArtifactNameEn(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldEQ(FieldArtifactNameEn, v)) +} + +// ImageURL applies equality check predicate on the "image_url" field. It's identical to ImageURLEQ. +func ImageURL(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldEQ(FieldImageURL, v)) +} + +// ArtifactNameEQ applies the EQ predicate on the "artifact_name" field. +func ArtifactNameEQ(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldEQ(FieldArtifactName, v)) +} + +// ArtifactNameNEQ applies the NEQ predicate on the "artifact_name" field. +func ArtifactNameNEQ(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldNEQ(FieldArtifactName, v)) +} + +// ArtifactNameIn applies the In predicate on the "artifact_name" field. +func ArtifactNameIn(vs ...string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldIn(FieldArtifactName, vs...)) +} + +// ArtifactNameNotIn applies the NotIn predicate on the "artifact_name" field. +func ArtifactNameNotIn(vs ...string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldNotIn(FieldArtifactName, vs...)) +} + +// ArtifactNameGT applies the GT predicate on the "artifact_name" field. +func ArtifactNameGT(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldGT(FieldArtifactName, v)) +} + +// ArtifactNameGTE applies the GTE predicate on the "artifact_name" field. +func ArtifactNameGTE(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldGTE(FieldArtifactName, v)) +} + +// ArtifactNameLT applies the LT predicate on the "artifact_name" field. +func ArtifactNameLT(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldLT(FieldArtifactName, v)) +} + +// ArtifactNameLTE applies the LTE predicate on the "artifact_name" field. +func ArtifactNameLTE(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldLTE(FieldArtifactName, v)) +} + +// ArtifactNameContains applies the Contains predicate on the "artifact_name" field. +func ArtifactNameContains(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldContains(FieldArtifactName, v)) +} + +// ArtifactNameHasPrefix applies the HasPrefix predicate on the "artifact_name" field. +func ArtifactNameHasPrefix(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldHasPrefix(FieldArtifactName, v)) +} + +// ArtifactNameHasSuffix applies the HasSuffix predicate on the "artifact_name" field. +func ArtifactNameHasSuffix(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldHasSuffix(FieldArtifactName, v)) +} + +// ArtifactNameEqualFold applies the EqualFold predicate on the "artifact_name" field. +func ArtifactNameEqualFold(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldEqualFold(FieldArtifactName, v)) +} + +// ArtifactNameContainsFold applies the ContainsFold predicate on the "artifact_name" field. +func ArtifactNameContainsFold(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldContainsFold(FieldArtifactName, v)) +} + +// ArtifactCodeEQ applies the EQ predicate on the "artifact_code" field. +func ArtifactCodeEQ(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldEQ(FieldArtifactCode, v)) +} + +// ArtifactCodeNEQ applies the NEQ predicate on the "artifact_code" field. +func ArtifactCodeNEQ(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldNEQ(FieldArtifactCode, v)) +} + +// ArtifactCodeIn applies the In predicate on the "artifact_code" field. +func ArtifactCodeIn(vs ...string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldIn(FieldArtifactCode, vs...)) +} + +// ArtifactCodeNotIn applies the NotIn predicate on the "artifact_code" field. +func ArtifactCodeNotIn(vs ...string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldNotIn(FieldArtifactCode, vs...)) +} + +// ArtifactCodeGT applies the GT predicate on the "artifact_code" field. +func ArtifactCodeGT(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldGT(FieldArtifactCode, v)) +} + +// ArtifactCodeGTE applies the GTE predicate on the "artifact_code" field. +func ArtifactCodeGTE(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldGTE(FieldArtifactCode, v)) +} + +// ArtifactCodeLT applies the LT predicate on the "artifact_code" field. +func ArtifactCodeLT(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldLT(FieldArtifactCode, v)) +} + +// ArtifactCodeLTE applies the LTE predicate on the "artifact_code" field. +func ArtifactCodeLTE(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldLTE(FieldArtifactCode, v)) +} + +// ArtifactCodeContains applies the Contains predicate on the "artifact_code" field. +func ArtifactCodeContains(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldContains(FieldArtifactCode, v)) +} + +// ArtifactCodeHasPrefix applies the HasPrefix predicate on the "artifact_code" field. +func ArtifactCodeHasPrefix(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldHasPrefix(FieldArtifactCode, v)) +} + +// ArtifactCodeHasSuffix applies the HasSuffix predicate on the "artifact_code" field. +func ArtifactCodeHasSuffix(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldHasSuffix(FieldArtifactCode, v)) +} + +// ArtifactCodeEqualFold applies the EqualFold predicate on the "artifact_code" field. +func ArtifactCodeEqualFold(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldEqualFold(FieldArtifactCode, v)) +} + +// ArtifactCodeContainsFold applies the ContainsFold predicate on the "artifact_code" field. +func ArtifactCodeContainsFold(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldContainsFold(FieldArtifactCode, v)) +} + +// CreatorEQ applies the EQ predicate on the "creator" field. +func CreatorEQ(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldEQ(FieldCreator, v)) +} + +// CreatorNEQ applies the NEQ predicate on the "creator" field. +func CreatorNEQ(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldNEQ(FieldCreator, v)) +} + +// CreatorIn applies the In predicate on the "creator" field. +func CreatorIn(vs ...string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldIn(FieldCreator, vs...)) +} + +// CreatorNotIn applies the NotIn predicate on the "creator" field. +func CreatorNotIn(vs ...string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldNotIn(FieldCreator, vs...)) +} + +// CreatorGT applies the GT predicate on the "creator" field. +func CreatorGT(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldGT(FieldCreator, v)) +} + +// CreatorGTE applies the GTE predicate on the "creator" field. +func CreatorGTE(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldGTE(FieldCreator, v)) +} + +// CreatorLT applies the LT predicate on the "creator" field. +func CreatorLT(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldLT(FieldCreator, v)) +} + +// CreatorLTE applies the LTE predicate on the "creator" field. +func CreatorLTE(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldLTE(FieldCreator, v)) +} + +// CreatorContains applies the Contains predicate on the "creator" field. +func CreatorContains(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldContains(FieldCreator, v)) +} + +// CreatorHasPrefix applies the HasPrefix predicate on the "creator" field. +func CreatorHasPrefix(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldHasPrefix(FieldCreator, v)) +} + +// CreatorHasSuffix applies the HasSuffix predicate on the "creator" field. +func CreatorHasSuffix(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldHasSuffix(FieldCreator, v)) +} + +// CreatorEqualFold applies the EqualFold predicate on the "creator" field. +func CreatorEqualFold(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldEqualFold(FieldCreator, v)) +} + +// CreatorContainsFold applies the ContainsFold predicate on the "creator" field. +func CreatorContainsFold(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldContainsFold(FieldCreator, v)) +} + +// CreateTimeEQ applies the EQ predicate on the "create_time" field. +func CreateTimeEQ(v time.Time) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldEQ(FieldCreateTime, v)) +} + +// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. +func CreateTimeNEQ(v time.Time) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldNEQ(FieldCreateTime, v)) +} + +// CreateTimeIn applies the In predicate on the "create_time" field. +func CreateTimeIn(vs ...time.Time) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldIn(FieldCreateTime, vs...)) +} + +// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. +func CreateTimeNotIn(vs ...time.Time) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldNotIn(FieldCreateTime, vs...)) +} + +// CreateTimeGT applies the GT predicate on the "create_time" field. +func CreateTimeGT(v time.Time) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldGT(FieldCreateTime, v)) +} + +// CreateTimeGTE applies the GTE predicate on the "create_time" field. +func CreateTimeGTE(v time.Time) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldGTE(FieldCreateTime, v)) +} + +// CreateTimeLT applies the LT predicate on the "create_time" field. +func CreateTimeLT(v time.Time) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldLT(FieldCreateTime, v)) +} + +// CreateTimeLTE applies the LTE predicate on the "create_time" field. +func CreateTimeLTE(v time.Time) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldLTE(FieldCreateTime, v)) +} + +// CreateTimeIsNil applies the IsNil predicate on the "create_time" field. +func CreateTimeIsNil() predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldIsNull(FieldCreateTime)) +} + +// CreateTimeNotNil applies the NotNil predicate on the "create_time" field. +func CreateTimeNotNil() predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldNotNull(FieldCreateTime)) +} + +// UpdaterEQ applies the EQ predicate on the "updater" field. +func UpdaterEQ(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldEQ(FieldUpdater, v)) +} + +// UpdaterNEQ applies the NEQ predicate on the "updater" field. +func UpdaterNEQ(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldNEQ(FieldUpdater, v)) +} + +// UpdaterIn applies the In predicate on the "updater" field. +func UpdaterIn(vs ...string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldIn(FieldUpdater, vs...)) +} + +// UpdaterNotIn applies the NotIn predicate on the "updater" field. +func UpdaterNotIn(vs ...string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldNotIn(FieldUpdater, vs...)) +} + +// UpdaterGT applies the GT predicate on the "updater" field. +func UpdaterGT(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldGT(FieldUpdater, v)) +} + +// UpdaterGTE applies the GTE predicate on the "updater" field. +func UpdaterGTE(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldGTE(FieldUpdater, v)) +} + +// UpdaterLT applies the LT predicate on the "updater" field. +func UpdaterLT(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldLT(FieldUpdater, v)) +} + +// UpdaterLTE applies the LTE predicate on the "updater" field. +func UpdaterLTE(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldLTE(FieldUpdater, v)) +} + +// UpdaterContains applies the Contains predicate on the "updater" field. +func UpdaterContains(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldContains(FieldUpdater, v)) +} + +// UpdaterHasPrefix applies the HasPrefix predicate on the "updater" field. +func UpdaterHasPrefix(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldHasPrefix(FieldUpdater, v)) +} + +// UpdaterHasSuffix applies the HasSuffix predicate on the "updater" field. +func UpdaterHasSuffix(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldHasSuffix(FieldUpdater, v)) +} + +// UpdaterEqualFold applies the EqualFold predicate on the "updater" field. +func UpdaterEqualFold(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldEqualFold(FieldUpdater, v)) +} + +// UpdaterContainsFold applies the ContainsFold predicate on the "updater" field. +func UpdaterContainsFold(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldContainsFold(FieldUpdater, v)) +} + +// UpdateTimeEQ applies the EQ predicate on the "update_time" field. +func UpdateTimeEQ(v time.Time) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldEQ(FieldUpdateTime, v)) +} + +// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. +func UpdateTimeNEQ(v time.Time) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldNEQ(FieldUpdateTime, v)) +} + +// UpdateTimeIn applies the In predicate on the "update_time" field. +func UpdateTimeIn(vs ...time.Time) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. +func UpdateTimeNotIn(vs ...time.Time) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldNotIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeGT applies the GT predicate on the "update_time" field. +func UpdateTimeGT(v time.Time) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldGT(FieldUpdateTime, v)) +} + +// UpdateTimeGTE applies the GTE predicate on the "update_time" field. +func UpdateTimeGTE(v time.Time) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldGTE(FieldUpdateTime, v)) +} + +// UpdateTimeLT applies the LT predicate on the "update_time" field. +func UpdateTimeLT(v time.Time) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldLT(FieldUpdateTime, v)) +} + +// UpdateTimeLTE applies the LTE predicate on the "update_time" field. +func UpdateTimeLTE(v time.Time) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldLTE(FieldUpdateTime, v)) +} + +// UpdateTimeIsNil applies the IsNil predicate on the "update_time" field. +func UpdateTimeIsNil() predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldIsNull(FieldUpdateTime)) +} + +// UpdateTimeNotNil applies the NotNil predicate on the "update_time" field. +func UpdateTimeNotNil() predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldNotNull(FieldUpdateTime)) +} + +// DeletedEQ applies the EQ predicate on the "deleted" field. +func DeletedEQ(v bool) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldEQ(FieldDeleted, v)) +} + +// DeletedNEQ applies the NEQ predicate on the "deleted" field. +func DeletedNEQ(v bool) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldNEQ(FieldDeleted, v)) +} + +// StatsHealthEQ applies the EQ predicate on the "stats_health" field. +func StatsHealthEQ(v int) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldEQ(FieldStatsHealth, v)) +} + +// StatsHealthNEQ applies the NEQ predicate on the "stats_health" field. +func StatsHealthNEQ(v int) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldNEQ(FieldStatsHealth, v)) +} + +// StatsHealthIn applies the In predicate on the "stats_health" field. +func StatsHealthIn(vs ...int) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldIn(FieldStatsHealth, vs...)) +} + +// StatsHealthNotIn applies the NotIn predicate on the "stats_health" field. +func StatsHealthNotIn(vs ...int) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldNotIn(FieldStatsHealth, vs...)) +} + +// StatsHealthGT applies the GT predicate on the "stats_health" field. +func StatsHealthGT(v int) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldGT(FieldStatsHealth, v)) +} + +// StatsHealthGTE applies the GTE predicate on the "stats_health" field. +func StatsHealthGTE(v int) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldGTE(FieldStatsHealth, v)) +} + +// StatsHealthLT applies the LT predicate on the "stats_health" field. +func StatsHealthLT(v int) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldLT(FieldStatsHealth, v)) +} + +// StatsHealthLTE applies the LTE predicate on the "stats_health" field. +func StatsHealthLTE(v int) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldLTE(FieldStatsHealth, v)) +} + +// StatsAttackEQ applies the EQ predicate on the "stats_attack" field. +func StatsAttackEQ(v int) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldEQ(FieldStatsAttack, v)) +} + +// StatsAttackNEQ applies the NEQ predicate on the "stats_attack" field. +func StatsAttackNEQ(v int) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldNEQ(FieldStatsAttack, v)) +} + +// StatsAttackIn applies the In predicate on the "stats_attack" field. +func StatsAttackIn(vs ...int) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldIn(FieldStatsAttack, vs...)) +} + +// StatsAttackNotIn applies the NotIn predicate on the "stats_attack" field. +func StatsAttackNotIn(vs ...int) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldNotIn(FieldStatsAttack, vs...)) +} + +// StatsAttackGT applies the GT predicate on the "stats_attack" field. +func StatsAttackGT(v int) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldGT(FieldStatsAttack, v)) +} + +// StatsAttackGTE applies the GTE predicate on the "stats_attack" field. +func StatsAttackGTE(v int) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldGTE(FieldStatsAttack, v)) +} + +// StatsAttackLT applies the LT predicate on the "stats_attack" field. +func StatsAttackLT(v int) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldLT(FieldStatsAttack, v)) +} + +// StatsAttackLTE applies the LTE predicate on the "stats_attack" field. +func StatsAttackLTE(v int) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldLTE(FieldStatsAttack, v)) +} + +// StatsDefenseEQ applies the EQ predicate on the "stats_defense" field. +func StatsDefenseEQ(v int) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldEQ(FieldStatsDefense, v)) +} + +// StatsDefenseNEQ applies the NEQ predicate on the "stats_defense" field. +func StatsDefenseNEQ(v int) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldNEQ(FieldStatsDefense, v)) +} + +// StatsDefenseIn applies the In predicate on the "stats_defense" field. +func StatsDefenseIn(vs ...int) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldIn(FieldStatsDefense, vs...)) +} + +// StatsDefenseNotIn applies the NotIn predicate on the "stats_defense" field. +func StatsDefenseNotIn(vs ...int) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldNotIn(FieldStatsDefense, vs...)) +} + +// StatsDefenseGT applies the GT predicate on the "stats_defense" field. +func StatsDefenseGT(v int) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldGT(FieldStatsDefense, v)) +} + +// StatsDefenseGTE applies the GTE predicate on the "stats_defense" field. +func StatsDefenseGTE(v int) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldGTE(FieldStatsDefense, v)) +} + +// StatsDefenseLT applies the LT predicate on the "stats_defense" field. +func StatsDefenseLT(v int) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldLT(FieldStatsDefense, v)) +} + +// StatsDefenseLTE applies the LTE predicate on the "stats_defense" field. +func StatsDefenseLTE(v int) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldLTE(FieldStatsDefense, v)) +} + +// RarityEQ applies the EQ predicate on the "rarity" field. +func RarityEQ(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldEQ(FieldRarity, v)) +} + +// RarityNEQ applies the NEQ predicate on the "rarity" field. +func RarityNEQ(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldNEQ(FieldRarity, v)) +} + +// RarityIn applies the In predicate on the "rarity" field. +func RarityIn(vs ...string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldIn(FieldRarity, vs...)) +} + +// RarityNotIn applies the NotIn predicate on the "rarity" field. +func RarityNotIn(vs ...string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldNotIn(FieldRarity, vs...)) +} + +// RarityGT applies the GT predicate on the "rarity" field. +func RarityGT(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldGT(FieldRarity, v)) +} + +// RarityGTE applies the GTE predicate on the "rarity" field. +func RarityGTE(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldGTE(FieldRarity, v)) +} + +// RarityLT applies the LT predicate on the "rarity" field. +func RarityLT(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldLT(FieldRarity, v)) +} + +// RarityLTE applies the LTE predicate on the "rarity" field. +func RarityLTE(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldLTE(FieldRarity, v)) +} + +// RarityContains applies the Contains predicate on the "rarity" field. +func RarityContains(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldContains(FieldRarity, v)) +} + +// RarityHasPrefix applies the HasPrefix predicate on the "rarity" field. +func RarityHasPrefix(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldHasPrefix(FieldRarity, v)) +} + +// RarityHasSuffix applies the HasSuffix predicate on the "rarity" field. +func RarityHasSuffix(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldHasSuffix(FieldRarity, v)) +} + +// RarityEqualFold applies the EqualFold predicate on the "rarity" field. +func RarityEqualFold(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldEqualFold(FieldRarity, v)) +} + +// RarityContainsFold applies the ContainsFold predicate on the "rarity" field. +func RarityContainsFold(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldContainsFold(FieldRarity, v)) +} + +// RoleEQ applies the EQ predicate on the "role" field. +func RoleEQ(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldEQ(FieldRole, v)) +} + +// RoleNEQ applies the NEQ predicate on the "role" field. +func RoleNEQ(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldNEQ(FieldRole, v)) +} + +// RoleIn applies the In predicate on the "role" field. +func RoleIn(vs ...string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldIn(FieldRole, vs...)) +} + +// RoleNotIn applies the NotIn predicate on the "role" field. +func RoleNotIn(vs ...string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldNotIn(FieldRole, vs...)) +} + +// RoleGT applies the GT predicate on the "role" field. +func RoleGT(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldGT(FieldRole, v)) +} + +// RoleGTE applies the GTE predicate on the "role" field. +func RoleGTE(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldGTE(FieldRole, v)) +} + +// RoleLT applies the LT predicate on the "role" field. +func RoleLT(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldLT(FieldRole, v)) +} + +// RoleLTE applies the LTE predicate on the "role" field. +func RoleLTE(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldLTE(FieldRole, v)) +} + +// RoleContains applies the Contains predicate on the "role" field. +func RoleContains(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldContains(FieldRole, v)) +} + +// RoleHasPrefix applies the HasPrefix predicate on the "role" field. +func RoleHasPrefix(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldHasPrefix(FieldRole, v)) +} + +// RoleHasSuffix applies the HasSuffix predicate on the "role" field. +func RoleHasSuffix(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldHasSuffix(FieldRole, v)) +} + +// RoleEqualFold applies the EqualFold predicate on the "role" field. +func RoleEqualFold(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldEqualFold(FieldRole, v)) +} + +// RoleContainsFold applies the ContainsFold predicate on the "role" field. +func RoleContainsFold(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldContainsFold(FieldRole, v)) +} + +// ArtifactNameEnEQ applies the EQ predicate on the "artifact_name_en" field. +func ArtifactNameEnEQ(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldEQ(FieldArtifactNameEn, v)) +} + +// ArtifactNameEnNEQ applies the NEQ predicate on the "artifact_name_en" field. +func ArtifactNameEnNEQ(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldNEQ(FieldArtifactNameEn, v)) +} + +// ArtifactNameEnIn applies the In predicate on the "artifact_name_en" field. +func ArtifactNameEnIn(vs ...string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldIn(FieldArtifactNameEn, vs...)) +} + +// ArtifactNameEnNotIn applies the NotIn predicate on the "artifact_name_en" field. +func ArtifactNameEnNotIn(vs ...string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldNotIn(FieldArtifactNameEn, vs...)) +} + +// ArtifactNameEnGT applies the GT predicate on the "artifact_name_en" field. +func ArtifactNameEnGT(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldGT(FieldArtifactNameEn, v)) +} + +// ArtifactNameEnGTE applies the GTE predicate on the "artifact_name_en" field. +func ArtifactNameEnGTE(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldGTE(FieldArtifactNameEn, v)) +} + +// ArtifactNameEnLT applies the LT predicate on the "artifact_name_en" field. +func ArtifactNameEnLT(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldLT(FieldArtifactNameEn, v)) +} + +// ArtifactNameEnLTE applies the LTE predicate on the "artifact_name_en" field. +func ArtifactNameEnLTE(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldLTE(FieldArtifactNameEn, v)) +} + +// ArtifactNameEnContains applies the Contains predicate on the "artifact_name_en" field. +func ArtifactNameEnContains(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldContains(FieldArtifactNameEn, v)) +} + +// ArtifactNameEnHasPrefix applies the HasPrefix predicate on the "artifact_name_en" field. +func ArtifactNameEnHasPrefix(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldHasPrefix(FieldArtifactNameEn, v)) +} + +// ArtifactNameEnHasSuffix applies the HasSuffix predicate on the "artifact_name_en" field. +func ArtifactNameEnHasSuffix(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldHasSuffix(FieldArtifactNameEn, v)) +} + +// ArtifactNameEnEqualFold applies the EqualFold predicate on the "artifact_name_en" field. +func ArtifactNameEnEqualFold(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldEqualFold(FieldArtifactNameEn, v)) +} + +// ArtifactNameEnContainsFold applies the ContainsFold predicate on the "artifact_name_en" field. +func ArtifactNameEnContainsFold(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldContainsFold(FieldArtifactNameEn, v)) +} + +// ImageURLEQ applies the EQ predicate on the "image_url" field. +func ImageURLEQ(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldEQ(FieldImageURL, v)) +} + +// ImageURLNEQ applies the NEQ predicate on the "image_url" field. +func ImageURLNEQ(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldNEQ(FieldImageURL, v)) +} + +// ImageURLIn applies the In predicate on the "image_url" field. +func ImageURLIn(vs ...string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldIn(FieldImageURL, vs...)) +} + +// ImageURLNotIn applies the NotIn predicate on the "image_url" field. +func ImageURLNotIn(vs ...string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldNotIn(FieldImageURL, vs...)) +} + +// ImageURLGT applies the GT predicate on the "image_url" field. +func ImageURLGT(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldGT(FieldImageURL, v)) +} + +// ImageURLGTE applies the GTE predicate on the "image_url" field. +func ImageURLGTE(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldGTE(FieldImageURL, v)) +} + +// ImageURLLT applies the LT predicate on the "image_url" field. +func ImageURLLT(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldLT(FieldImageURL, v)) +} + +// ImageURLLTE applies the LTE predicate on the "image_url" field. +func ImageURLLTE(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldLTE(FieldImageURL, v)) +} + +// ImageURLContains applies the Contains predicate on the "image_url" field. +func ImageURLContains(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldContains(FieldImageURL, v)) +} + +// ImageURLHasPrefix applies the HasPrefix predicate on the "image_url" field. +func ImageURLHasPrefix(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldHasPrefix(FieldImageURL, v)) +} + +// ImageURLHasSuffix applies the HasSuffix predicate on the "image_url" field. +func ImageURLHasSuffix(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldHasSuffix(FieldImageURL, v)) +} + +// ImageURLEqualFold applies the EqualFold predicate on the "image_url" field. +func ImageURLEqualFold(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldEqualFold(FieldImageURL, v)) +} + +// ImageURLContainsFold applies the ContainsFold predicate on the "image_url" field. +func ImageURLContainsFold(v string) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.FieldContainsFold(FieldImageURL, v)) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.EpicArtifactInfo) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.EpicArtifactInfo) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.EpicArtifactInfo) predicate.EpicArtifactInfo { + return predicate.EpicArtifactInfo(sql.NotPredicates(p)) +} diff --git a/internal/ent/epicartifactinfo_create.go b/internal/ent/epicartifactinfo_create.go new file mode 100644 index 0000000..0d1ed73 --- /dev/null +++ b/internal/ent/epicartifactinfo_create.go @@ -0,0 +1,415 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "epic-ent/internal/ent/epicartifactinfo" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// EpicArtifactInfoCreate is the builder for creating a EpicArtifactInfo entity. +type EpicArtifactInfoCreate struct { + config + mutation *EpicArtifactInfoMutation + hooks []Hook +} + +// SetArtifactName sets the "artifact_name" field. +func (_c *EpicArtifactInfoCreate) SetArtifactName(v string) *EpicArtifactInfoCreate { + _c.mutation.SetArtifactName(v) + return _c +} + +// SetArtifactCode sets the "artifact_code" field. +func (_c *EpicArtifactInfoCreate) SetArtifactCode(v string) *EpicArtifactInfoCreate { + _c.mutation.SetArtifactCode(v) + return _c +} + +// SetCreator sets the "creator" field. +func (_c *EpicArtifactInfoCreate) SetCreator(v string) *EpicArtifactInfoCreate { + _c.mutation.SetCreator(v) + return _c +} + +// SetCreateTime sets the "create_time" field. +func (_c *EpicArtifactInfoCreate) SetCreateTime(v time.Time) *EpicArtifactInfoCreate { + _c.mutation.SetCreateTime(v) + return _c +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (_c *EpicArtifactInfoCreate) SetNillableCreateTime(v *time.Time) *EpicArtifactInfoCreate { + if v != nil { + _c.SetCreateTime(*v) + } + return _c +} + +// SetUpdater sets the "updater" field. +func (_c *EpicArtifactInfoCreate) SetUpdater(v string) *EpicArtifactInfoCreate { + _c.mutation.SetUpdater(v) + return _c +} + +// SetUpdateTime sets the "update_time" field. +func (_c *EpicArtifactInfoCreate) SetUpdateTime(v time.Time) *EpicArtifactInfoCreate { + _c.mutation.SetUpdateTime(v) + return _c +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (_c *EpicArtifactInfoCreate) SetNillableUpdateTime(v *time.Time) *EpicArtifactInfoCreate { + if v != nil { + _c.SetUpdateTime(*v) + } + return _c +} + +// SetDeleted sets the "deleted" field. +func (_c *EpicArtifactInfoCreate) SetDeleted(v bool) *EpicArtifactInfoCreate { + _c.mutation.SetDeleted(v) + return _c +} + +// SetStatsHealth sets the "stats_health" field. +func (_c *EpicArtifactInfoCreate) SetStatsHealth(v int) *EpicArtifactInfoCreate { + _c.mutation.SetStatsHealth(v) + return _c +} + +// SetStatsAttack sets the "stats_attack" field. +func (_c *EpicArtifactInfoCreate) SetStatsAttack(v int) *EpicArtifactInfoCreate { + _c.mutation.SetStatsAttack(v) + return _c +} + +// SetStatsDefense sets the "stats_defense" field. +func (_c *EpicArtifactInfoCreate) SetStatsDefense(v int) *EpicArtifactInfoCreate { + _c.mutation.SetStatsDefense(v) + return _c +} + +// SetRarity sets the "rarity" field. +func (_c *EpicArtifactInfoCreate) SetRarity(v string) *EpicArtifactInfoCreate { + _c.mutation.SetRarity(v) + return _c +} + +// SetRole sets the "role" field. +func (_c *EpicArtifactInfoCreate) SetRole(v string) *EpicArtifactInfoCreate { + _c.mutation.SetRole(v) + return _c +} + +// SetArtifactNameEn sets the "artifact_name_en" field. +func (_c *EpicArtifactInfoCreate) SetArtifactNameEn(v string) *EpicArtifactInfoCreate { + _c.mutation.SetArtifactNameEn(v) + return _c +} + +// SetImageURL sets the "image_url" field. +func (_c *EpicArtifactInfoCreate) SetImageURL(v string) *EpicArtifactInfoCreate { + _c.mutation.SetImageURL(v) + return _c +} + +// SetID sets the "id" field. +func (_c *EpicArtifactInfoCreate) SetID(v int64) *EpicArtifactInfoCreate { + _c.mutation.SetID(v) + return _c +} + +// Mutation returns the EpicArtifactInfoMutation object of the builder. +func (_c *EpicArtifactInfoCreate) Mutation() *EpicArtifactInfoMutation { + return _c.mutation +} + +// Save creates the EpicArtifactInfo in the database. +func (_c *EpicArtifactInfoCreate) Save(ctx context.Context) (*EpicArtifactInfo, error) { + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *EpicArtifactInfoCreate) SaveX(ctx context.Context) *EpicArtifactInfo { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *EpicArtifactInfoCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *EpicArtifactInfoCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *EpicArtifactInfoCreate) check() error { + if _, ok := _c.mutation.ArtifactName(); !ok { + return &ValidationError{Name: "artifact_name", err: errors.New(`ent: missing required field "EpicArtifactInfo.artifact_name"`)} + } + if v, ok := _c.mutation.ArtifactName(); ok { + if err := epicartifactinfo.ArtifactNameValidator(v); err != nil { + return &ValidationError{Name: "artifact_name", err: fmt.Errorf(`ent: validator failed for field "EpicArtifactInfo.artifact_name": %w`, err)} + } + } + if _, ok := _c.mutation.ArtifactCode(); !ok { + return &ValidationError{Name: "artifact_code", err: errors.New(`ent: missing required field "EpicArtifactInfo.artifact_code"`)} + } + if v, ok := _c.mutation.ArtifactCode(); ok { + if err := epicartifactinfo.ArtifactCodeValidator(v); err != nil { + return &ValidationError{Name: "artifact_code", err: fmt.Errorf(`ent: validator failed for field "EpicArtifactInfo.artifact_code": %w`, err)} + } + } + if _, ok := _c.mutation.Creator(); !ok { + return &ValidationError{Name: "creator", err: errors.New(`ent: missing required field "EpicArtifactInfo.creator"`)} + } + if v, ok := _c.mutation.Creator(); ok { + if err := epicartifactinfo.CreatorValidator(v); err != nil { + return &ValidationError{Name: "creator", err: fmt.Errorf(`ent: validator failed for field "EpicArtifactInfo.creator": %w`, err)} + } + } + if _, ok := _c.mutation.Updater(); !ok { + return &ValidationError{Name: "updater", err: errors.New(`ent: missing required field "EpicArtifactInfo.updater"`)} + } + if v, ok := _c.mutation.Updater(); ok { + if err := epicartifactinfo.UpdaterValidator(v); err != nil { + return &ValidationError{Name: "updater", err: fmt.Errorf(`ent: validator failed for field "EpicArtifactInfo.updater": %w`, err)} + } + } + if _, ok := _c.mutation.Deleted(); !ok { + return &ValidationError{Name: "deleted", err: errors.New(`ent: missing required field "EpicArtifactInfo.deleted"`)} + } + if _, ok := _c.mutation.StatsHealth(); !ok { + return &ValidationError{Name: "stats_health", err: errors.New(`ent: missing required field "EpicArtifactInfo.stats_health"`)} + } + if _, ok := _c.mutation.StatsAttack(); !ok { + return &ValidationError{Name: "stats_attack", err: errors.New(`ent: missing required field "EpicArtifactInfo.stats_attack"`)} + } + if _, ok := _c.mutation.StatsDefense(); !ok { + return &ValidationError{Name: "stats_defense", err: errors.New(`ent: missing required field "EpicArtifactInfo.stats_defense"`)} + } + if _, ok := _c.mutation.Rarity(); !ok { + return &ValidationError{Name: "rarity", err: errors.New(`ent: missing required field "EpicArtifactInfo.rarity"`)} + } + if v, ok := _c.mutation.Rarity(); ok { + if err := epicartifactinfo.RarityValidator(v); err != nil { + return &ValidationError{Name: "rarity", err: fmt.Errorf(`ent: validator failed for field "EpicArtifactInfo.rarity": %w`, err)} + } + } + if _, ok := _c.mutation.Role(); !ok { + return &ValidationError{Name: "role", err: errors.New(`ent: missing required field "EpicArtifactInfo.role"`)} + } + if v, ok := _c.mutation.Role(); ok { + if err := epicartifactinfo.RoleValidator(v); err != nil { + return &ValidationError{Name: "role", err: fmt.Errorf(`ent: validator failed for field "EpicArtifactInfo.role": %w`, err)} + } + } + if _, ok := _c.mutation.ArtifactNameEn(); !ok { + return &ValidationError{Name: "artifact_name_en", err: errors.New(`ent: missing required field "EpicArtifactInfo.artifact_name_en"`)} + } + if v, ok := _c.mutation.ArtifactNameEn(); ok { + if err := epicartifactinfo.ArtifactNameEnValidator(v); err != nil { + return &ValidationError{Name: "artifact_name_en", err: fmt.Errorf(`ent: validator failed for field "EpicArtifactInfo.artifact_name_en": %w`, err)} + } + } + if _, ok := _c.mutation.ImageURL(); !ok { + return &ValidationError{Name: "image_url", err: errors.New(`ent: missing required field "EpicArtifactInfo.image_url"`)} + } + if v, ok := _c.mutation.ImageURL(); ok { + if err := epicartifactinfo.ImageURLValidator(v); err != nil { + return &ValidationError{Name: "image_url", err: fmt.Errorf(`ent: validator failed for field "EpicArtifactInfo.image_url": %w`, err)} + } + } + return nil +} + +func (_c *EpicArtifactInfoCreate) sqlSave(ctx context.Context) (*EpicArtifactInfo, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != _node.ID { + id := _spec.ID.Value.(int64) + _node.ID = int64(id) + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *EpicArtifactInfoCreate) createSpec() (*EpicArtifactInfo, *sqlgraph.CreateSpec) { + var ( + _node = &EpicArtifactInfo{config: _c.config} + _spec = sqlgraph.NewCreateSpec(epicartifactinfo.Table, sqlgraph.NewFieldSpec(epicartifactinfo.FieldID, field.TypeInt64)) + ) + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := _c.mutation.ArtifactName(); ok { + _spec.SetField(epicartifactinfo.FieldArtifactName, field.TypeString, value) + _node.ArtifactName = value + } + if value, ok := _c.mutation.ArtifactCode(); ok { + _spec.SetField(epicartifactinfo.FieldArtifactCode, field.TypeString, value) + _node.ArtifactCode = value + } + if value, ok := _c.mutation.Creator(); ok { + _spec.SetField(epicartifactinfo.FieldCreator, field.TypeString, value) + _node.Creator = value + } + if value, ok := _c.mutation.CreateTime(); ok { + _spec.SetField(epicartifactinfo.FieldCreateTime, field.TypeTime, value) + _node.CreateTime = &value + } + if value, ok := _c.mutation.Updater(); ok { + _spec.SetField(epicartifactinfo.FieldUpdater, field.TypeString, value) + _node.Updater = value + } + if value, ok := _c.mutation.UpdateTime(); ok { + _spec.SetField(epicartifactinfo.FieldUpdateTime, field.TypeTime, value) + _node.UpdateTime = &value + } + if value, ok := _c.mutation.Deleted(); ok { + _spec.SetField(epicartifactinfo.FieldDeleted, field.TypeBool, value) + _node.Deleted = value + } + if value, ok := _c.mutation.StatsHealth(); ok { + _spec.SetField(epicartifactinfo.FieldStatsHealth, field.TypeInt, value) + _node.StatsHealth = value + } + if value, ok := _c.mutation.StatsAttack(); ok { + _spec.SetField(epicartifactinfo.FieldStatsAttack, field.TypeInt, value) + _node.StatsAttack = value + } + if value, ok := _c.mutation.StatsDefense(); ok { + _spec.SetField(epicartifactinfo.FieldStatsDefense, field.TypeInt, value) + _node.StatsDefense = value + } + if value, ok := _c.mutation.Rarity(); ok { + _spec.SetField(epicartifactinfo.FieldRarity, field.TypeString, value) + _node.Rarity = value + } + if value, ok := _c.mutation.Role(); ok { + _spec.SetField(epicartifactinfo.FieldRole, field.TypeString, value) + _node.Role = value + } + if value, ok := _c.mutation.ArtifactNameEn(); ok { + _spec.SetField(epicartifactinfo.FieldArtifactNameEn, field.TypeString, value) + _node.ArtifactNameEn = value + } + if value, ok := _c.mutation.ImageURL(); ok { + _spec.SetField(epicartifactinfo.FieldImageURL, field.TypeString, value) + _node.ImageURL = value + } + return _node, _spec +} + +// EpicArtifactInfoCreateBulk is the builder for creating many EpicArtifactInfo entities in bulk. +type EpicArtifactInfoCreateBulk struct { + config + err error + builders []*EpicArtifactInfoCreate +} + +// Save creates the EpicArtifactInfo entities in the database. +func (_c *EpicArtifactInfoCreateBulk) Save(ctx context.Context) ([]*EpicArtifactInfo, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*EpicArtifactInfo, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*EpicArtifactInfoMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil && nodes[i].ID == 0 { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int64(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *EpicArtifactInfoCreateBulk) SaveX(ctx context.Context) []*EpicArtifactInfo { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *EpicArtifactInfoCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *EpicArtifactInfoCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/ent/epicartifactinfo_delete.go b/internal/ent/epicartifactinfo_delete.go new file mode 100644 index 0000000..7e7e232 --- /dev/null +++ b/internal/ent/epicartifactinfo_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "epic-ent/internal/ent/epicartifactinfo" + "epic-ent/internal/ent/predicate" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// EpicArtifactInfoDelete is the builder for deleting a EpicArtifactInfo entity. +type EpicArtifactInfoDelete struct { + config + hooks []Hook + mutation *EpicArtifactInfoMutation +} + +// Where appends a list predicates to the EpicArtifactInfoDelete builder. +func (_d *EpicArtifactInfoDelete) Where(ps ...predicate.EpicArtifactInfo) *EpicArtifactInfoDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *EpicArtifactInfoDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *EpicArtifactInfoDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *EpicArtifactInfoDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(epicartifactinfo.Table, sqlgraph.NewFieldSpec(epicartifactinfo.FieldID, field.TypeInt64)) + if ps := _d.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + _d.mutation.done = true + return affected, err +} + +// EpicArtifactInfoDeleteOne is the builder for deleting a single EpicArtifactInfo entity. +type EpicArtifactInfoDeleteOne struct { + _d *EpicArtifactInfoDelete +} + +// Where appends a list predicates to the EpicArtifactInfoDelete builder. +func (_d *EpicArtifactInfoDeleteOne) Where(ps ...predicate.EpicArtifactInfo) *EpicArtifactInfoDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *EpicArtifactInfoDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{epicartifactinfo.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *EpicArtifactInfoDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/ent/epicartifactinfo_query.go b/internal/ent/epicartifactinfo_query.go new file mode 100644 index 0000000..c2b4e7e --- /dev/null +++ b/internal/ent/epicartifactinfo_query.go @@ -0,0 +1,527 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "epic-ent/internal/ent/epicartifactinfo" + "epic-ent/internal/ent/predicate" + "fmt" + "math" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// EpicArtifactInfoQuery is the builder for querying EpicArtifactInfo entities. +type EpicArtifactInfoQuery struct { + config + ctx *QueryContext + order []epicartifactinfo.OrderOption + inters []Interceptor + predicates []predicate.EpicArtifactInfo + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the EpicArtifactInfoQuery builder. +func (_q *EpicArtifactInfoQuery) Where(ps ...predicate.EpicArtifactInfo) *EpicArtifactInfoQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *EpicArtifactInfoQuery) Limit(limit int) *EpicArtifactInfoQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *EpicArtifactInfoQuery) Offset(offset int) *EpicArtifactInfoQuery { + _q.ctx.Offset = &offset + return _q +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (_q *EpicArtifactInfoQuery) Unique(unique bool) *EpicArtifactInfoQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *EpicArtifactInfoQuery) Order(o ...epicartifactinfo.OrderOption) *EpicArtifactInfoQuery { + _q.order = append(_q.order, o...) + return _q +} + +// First returns the first EpicArtifactInfo entity from the query. +// Returns a *NotFoundError when no EpicArtifactInfo was found. +func (_q *EpicArtifactInfoQuery) First(ctx context.Context) (*EpicArtifactInfo, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{epicartifactinfo.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *EpicArtifactInfoQuery) FirstX(ctx context.Context) *EpicArtifactInfo { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first EpicArtifactInfo ID from the query. +// Returns a *NotFoundError when no EpicArtifactInfo ID was found. +func (_q *EpicArtifactInfoQuery) FirstID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{epicartifactinfo.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *EpicArtifactInfoQuery) FirstIDX(ctx context.Context) int64 { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single EpicArtifactInfo entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one EpicArtifactInfo entity is found. +// Returns a *NotFoundError when no EpicArtifactInfo entities are found. +func (_q *EpicArtifactInfoQuery) Only(ctx context.Context) (*EpicArtifactInfo, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{epicartifactinfo.Label} + default: + return nil, &NotSingularError{epicartifactinfo.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *EpicArtifactInfoQuery) OnlyX(ctx context.Context) *EpicArtifactInfo { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only EpicArtifactInfo ID in the query. +// Returns a *NotSingularError when more than one EpicArtifactInfo ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *EpicArtifactInfoQuery) OnlyID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{epicartifactinfo.Label} + default: + err = &NotSingularError{epicartifactinfo.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *EpicArtifactInfoQuery) OnlyIDX(ctx context.Context) int64 { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of EpicArtifactInfos. +func (_q *EpicArtifactInfoQuery) All(ctx context.Context) ([]*EpicArtifactInfo, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*EpicArtifactInfo, *EpicArtifactInfoQuery]() + return withInterceptors[[]*EpicArtifactInfo](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *EpicArtifactInfoQuery) AllX(ctx context.Context) []*EpicArtifactInfo { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of EpicArtifactInfo IDs. +func (_q *EpicArtifactInfoQuery) IDs(ctx context.Context) (ids []int64, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(epicartifactinfo.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *EpicArtifactInfoQuery) IDsX(ctx context.Context) []int64 { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *EpicArtifactInfoQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, _q, querierCount[*EpicArtifactInfoQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *EpicArtifactInfoQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (_q *EpicArtifactInfoQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *EpicArtifactInfoQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the EpicArtifactInfoQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (_q *EpicArtifactInfoQuery) Clone() *EpicArtifactInfoQuery { + if _q == nil { + return nil + } + return &EpicArtifactInfoQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]epicartifactinfo.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.EpicArtifactInfo{}, _q.predicates...), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + } +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// ArtifactName string `json:"artifact_name,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.EpicArtifactInfo.Query(). +// GroupBy(epicartifactinfo.FieldArtifactName). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *EpicArtifactInfoQuery) GroupBy(field string, fields ...string) *EpicArtifactInfoGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &EpicArtifactInfoGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = epicartifactinfo.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// ArtifactName string `json:"artifact_name,omitempty"` +// } +// +// client.EpicArtifactInfo.Query(). +// Select(epicartifactinfo.FieldArtifactName). +// Scan(ctx, &v) +func (_q *EpicArtifactInfoQuery) Select(fields ...string) *EpicArtifactInfoSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &EpicArtifactInfoSelect{EpicArtifactInfoQuery: _q} + sbuild.label = epicartifactinfo.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a EpicArtifactInfoSelect configured with the given aggregations. +func (_q *EpicArtifactInfoQuery) Aggregate(fns ...AggregateFunc) *EpicArtifactInfoSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *EpicArtifactInfoQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !epicartifactinfo.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if _q.path != nil { + prev, err := _q.path(ctx) + if err != nil { + return err + } + _q.sql = prev + } + return nil +} + +func (_q *EpicArtifactInfoQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*EpicArtifactInfo, error) { + var ( + nodes = []*EpicArtifactInfo{} + _spec = _q.querySpec() + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*EpicArtifactInfo).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &EpicArtifactInfo{config: _q.config} + nodes = append(nodes, node) + return node.assignValues(columns, values) + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + return nodes, nil +} + +func (_q *EpicArtifactInfoQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique + } + return sqlgraph.CountNodes(ctx, _q.driver, _spec) +} + +func (_q *EpicArtifactInfoQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(epicartifactinfo.Table, epicartifactinfo.Columns, sqlgraph.NewFieldSpec(epicartifactinfo.FieldID, field.TypeInt64)) + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if _q.path != nil { + _spec.Unique = true + } + if fields := _q.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, epicartifactinfo.FieldID) + for i := range fields { + if fields[i] != epicartifactinfo.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := _q.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := _q.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := _q.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := _q.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (_q *EpicArtifactInfoQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(epicartifactinfo.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = epicartifactinfo.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if _q.sql != nil { + selector = _q.sql + selector.Select(selector.Columns(columns...)...) + } + if _q.ctx.Unique != nil && *_q.ctx.Unique { + selector.Distinct() + } + for _, p := range _q.predicates { + p(selector) + } + for _, p := range _q.order { + p(selector) + } + if offset := _q.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := _q.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// EpicArtifactInfoGroupBy is the group-by builder for EpicArtifactInfo entities. +type EpicArtifactInfoGroupBy struct { + selector + build *EpicArtifactInfoQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *EpicArtifactInfoGroupBy) Aggregate(fns ...AggregateFunc) *EpicArtifactInfoGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *EpicArtifactInfoGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*EpicArtifactInfoQuery, *EpicArtifactInfoGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *EpicArtifactInfoGroupBy) sqlScan(ctx context.Context, root *EpicArtifactInfoQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*_g.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// EpicArtifactInfoSelect is the builder for selecting fields of EpicArtifactInfo entities. +type EpicArtifactInfoSelect struct { + *EpicArtifactInfoQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *EpicArtifactInfoSelect) Aggregate(fns ...AggregateFunc) *EpicArtifactInfoSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *EpicArtifactInfoSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*EpicArtifactInfoQuery, *EpicArtifactInfoSelect](ctx, _s.EpicArtifactInfoQuery, _s, _s.inters, v) +} + +func (_s *EpicArtifactInfoSelect) sqlScan(ctx context.Context, root *EpicArtifactInfoQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/internal/ent/epicartifactinfo_update.go b/internal/ent/epicartifactinfo_update.go new file mode 100644 index 0000000..dcc30fc --- /dev/null +++ b/internal/ent/epicartifactinfo_update.go @@ -0,0 +1,844 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "epic-ent/internal/ent/epicartifactinfo" + "epic-ent/internal/ent/predicate" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// EpicArtifactInfoUpdate is the builder for updating EpicArtifactInfo entities. +type EpicArtifactInfoUpdate struct { + config + hooks []Hook + mutation *EpicArtifactInfoMutation +} + +// Where appends a list predicates to the EpicArtifactInfoUpdate builder. +func (_u *EpicArtifactInfoUpdate) Where(ps ...predicate.EpicArtifactInfo) *EpicArtifactInfoUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetArtifactName sets the "artifact_name" field. +func (_u *EpicArtifactInfoUpdate) SetArtifactName(v string) *EpicArtifactInfoUpdate { + _u.mutation.SetArtifactName(v) + return _u +} + +// SetNillableArtifactName sets the "artifact_name" field if the given value is not nil. +func (_u *EpicArtifactInfoUpdate) SetNillableArtifactName(v *string) *EpicArtifactInfoUpdate { + if v != nil { + _u.SetArtifactName(*v) + } + return _u +} + +// SetArtifactCode sets the "artifact_code" field. +func (_u *EpicArtifactInfoUpdate) SetArtifactCode(v string) *EpicArtifactInfoUpdate { + _u.mutation.SetArtifactCode(v) + return _u +} + +// SetNillableArtifactCode sets the "artifact_code" field if the given value is not nil. +func (_u *EpicArtifactInfoUpdate) SetNillableArtifactCode(v *string) *EpicArtifactInfoUpdate { + if v != nil { + _u.SetArtifactCode(*v) + } + return _u +} + +// SetCreator sets the "creator" field. +func (_u *EpicArtifactInfoUpdate) SetCreator(v string) *EpicArtifactInfoUpdate { + _u.mutation.SetCreator(v) + return _u +} + +// SetNillableCreator sets the "creator" field if the given value is not nil. +func (_u *EpicArtifactInfoUpdate) SetNillableCreator(v *string) *EpicArtifactInfoUpdate { + if v != nil { + _u.SetCreator(*v) + } + return _u +} + +// SetCreateTime sets the "create_time" field. +func (_u *EpicArtifactInfoUpdate) SetCreateTime(v time.Time) *EpicArtifactInfoUpdate { + _u.mutation.SetCreateTime(v) + return _u +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (_u *EpicArtifactInfoUpdate) SetNillableCreateTime(v *time.Time) *EpicArtifactInfoUpdate { + if v != nil { + _u.SetCreateTime(*v) + } + return _u +} + +// ClearCreateTime clears the value of the "create_time" field. +func (_u *EpicArtifactInfoUpdate) ClearCreateTime() *EpicArtifactInfoUpdate { + _u.mutation.ClearCreateTime() + return _u +} + +// SetUpdater sets the "updater" field. +func (_u *EpicArtifactInfoUpdate) SetUpdater(v string) *EpicArtifactInfoUpdate { + _u.mutation.SetUpdater(v) + return _u +} + +// SetNillableUpdater sets the "updater" field if the given value is not nil. +func (_u *EpicArtifactInfoUpdate) SetNillableUpdater(v *string) *EpicArtifactInfoUpdate { + if v != nil { + _u.SetUpdater(*v) + } + return _u +} + +// SetUpdateTime sets the "update_time" field. +func (_u *EpicArtifactInfoUpdate) SetUpdateTime(v time.Time) *EpicArtifactInfoUpdate { + _u.mutation.SetUpdateTime(v) + return _u +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (_u *EpicArtifactInfoUpdate) SetNillableUpdateTime(v *time.Time) *EpicArtifactInfoUpdate { + if v != nil { + _u.SetUpdateTime(*v) + } + return _u +} + +// ClearUpdateTime clears the value of the "update_time" field. +func (_u *EpicArtifactInfoUpdate) ClearUpdateTime() *EpicArtifactInfoUpdate { + _u.mutation.ClearUpdateTime() + return _u +} + +// SetDeleted sets the "deleted" field. +func (_u *EpicArtifactInfoUpdate) SetDeleted(v bool) *EpicArtifactInfoUpdate { + _u.mutation.SetDeleted(v) + return _u +} + +// SetNillableDeleted sets the "deleted" field if the given value is not nil. +func (_u *EpicArtifactInfoUpdate) SetNillableDeleted(v *bool) *EpicArtifactInfoUpdate { + if v != nil { + _u.SetDeleted(*v) + } + return _u +} + +// SetStatsHealth sets the "stats_health" field. +func (_u *EpicArtifactInfoUpdate) SetStatsHealth(v int) *EpicArtifactInfoUpdate { + _u.mutation.ResetStatsHealth() + _u.mutation.SetStatsHealth(v) + return _u +} + +// SetNillableStatsHealth sets the "stats_health" field if the given value is not nil. +func (_u *EpicArtifactInfoUpdate) SetNillableStatsHealth(v *int) *EpicArtifactInfoUpdate { + if v != nil { + _u.SetStatsHealth(*v) + } + return _u +} + +// AddStatsHealth adds value to the "stats_health" field. +func (_u *EpicArtifactInfoUpdate) AddStatsHealth(v int) *EpicArtifactInfoUpdate { + _u.mutation.AddStatsHealth(v) + return _u +} + +// SetStatsAttack sets the "stats_attack" field. +func (_u *EpicArtifactInfoUpdate) SetStatsAttack(v int) *EpicArtifactInfoUpdate { + _u.mutation.ResetStatsAttack() + _u.mutation.SetStatsAttack(v) + return _u +} + +// SetNillableStatsAttack sets the "stats_attack" field if the given value is not nil. +func (_u *EpicArtifactInfoUpdate) SetNillableStatsAttack(v *int) *EpicArtifactInfoUpdate { + if v != nil { + _u.SetStatsAttack(*v) + } + return _u +} + +// AddStatsAttack adds value to the "stats_attack" field. +func (_u *EpicArtifactInfoUpdate) AddStatsAttack(v int) *EpicArtifactInfoUpdate { + _u.mutation.AddStatsAttack(v) + return _u +} + +// SetStatsDefense sets the "stats_defense" field. +func (_u *EpicArtifactInfoUpdate) SetStatsDefense(v int) *EpicArtifactInfoUpdate { + _u.mutation.ResetStatsDefense() + _u.mutation.SetStatsDefense(v) + return _u +} + +// SetNillableStatsDefense sets the "stats_defense" field if the given value is not nil. +func (_u *EpicArtifactInfoUpdate) SetNillableStatsDefense(v *int) *EpicArtifactInfoUpdate { + if v != nil { + _u.SetStatsDefense(*v) + } + return _u +} + +// AddStatsDefense adds value to the "stats_defense" field. +func (_u *EpicArtifactInfoUpdate) AddStatsDefense(v int) *EpicArtifactInfoUpdate { + _u.mutation.AddStatsDefense(v) + return _u +} + +// SetRarity sets the "rarity" field. +func (_u *EpicArtifactInfoUpdate) SetRarity(v string) *EpicArtifactInfoUpdate { + _u.mutation.SetRarity(v) + return _u +} + +// SetNillableRarity sets the "rarity" field if the given value is not nil. +func (_u *EpicArtifactInfoUpdate) SetNillableRarity(v *string) *EpicArtifactInfoUpdate { + if v != nil { + _u.SetRarity(*v) + } + return _u +} + +// SetRole sets the "role" field. +func (_u *EpicArtifactInfoUpdate) SetRole(v string) *EpicArtifactInfoUpdate { + _u.mutation.SetRole(v) + return _u +} + +// SetNillableRole sets the "role" field if the given value is not nil. +func (_u *EpicArtifactInfoUpdate) SetNillableRole(v *string) *EpicArtifactInfoUpdate { + if v != nil { + _u.SetRole(*v) + } + return _u +} + +// SetArtifactNameEn sets the "artifact_name_en" field. +func (_u *EpicArtifactInfoUpdate) SetArtifactNameEn(v string) *EpicArtifactInfoUpdate { + _u.mutation.SetArtifactNameEn(v) + return _u +} + +// SetNillableArtifactNameEn sets the "artifact_name_en" field if the given value is not nil. +func (_u *EpicArtifactInfoUpdate) SetNillableArtifactNameEn(v *string) *EpicArtifactInfoUpdate { + if v != nil { + _u.SetArtifactNameEn(*v) + } + return _u +} + +// SetImageURL sets the "image_url" field. +func (_u *EpicArtifactInfoUpdate) SetImageURL(v string) *EpicArtifactInfoUpdate { + _u.mutation.SetImageURL(v) + return _u +} + +// SetNillableImageURL sets the "image_url" field if the given value is not nil. +func (_u *EpicArtifactInfoUpdate) SetNillableImageURL(v *string) *EpicArtifactInfoUpdate { + if v != nil { + _u.SetImageURL(*v) + } + return _u +} + +// Mutation returns the EpicArtifactInfoMutation object of the builder. +func (_u *EpicArtifactInfoUpdate) Mutation() *EpicArtifactInfoMutation { + return _u.mutation +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *EpicArtifactInfoUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *EpicArtifactInfoUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *EpicArtifactInfoUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *EpicArtifactInfoUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *EpicArtifactInfoUpdate) check() error { + if v, ok := _u.mutation.ArtifactName(); ok { + if err := epicartifactinfo.ArtifactNameValidator(v); err != nil { + return &ValidationError{Name: "artifact_name", err: fmt.Errorf(`ent: validator failed for field "EpicArtifactInfo.artifact_name": %w`, err)} + } + } + if v, ok := _u.mutation.ArtifactCode(); ok { + if err := epicartifactinfo.ArtifactCodeValidator(v); err != nil { + return &ValidationError{Name: "artifact_code", err: fmt.Errorf(`ent: validator failed for field "EpicArtifactInfo.artifact_code": %w`, err)} + } + } + if v, ok := _u.mutation.Creator(); ok { + if err := epicartifactinfo.CreatorValidator(v); err != nil { + return &ValidationError{Name: "creator", err: fmt.Errorf(`ent: validator failed for field "EpicArtifactInfo.creator": %w`, err)} + } + } + if v, ok := _u.mutation.Updater(); ok { + if err := epicartifactinfo.UpdaterValidator(v); err != nil { + return &ValidationError{Name: "updater", err: fmt.Errorf(`ent: validator failed for field "EpicArtifactInfo.updater": %w`, err)} + } + } + if v, ok := _u.mutation.Rarity(); ok { + if err := epicartifactinfo.RarityValidator(v); err != nil { + return &ValidationError{Name: "rarity", err: fmt.Errorf(`ent: validator failed for field "EpicArtifactInfo.rarity": %w`, err)} + } + } + if v, ok := _u.mutation.Role(); ok { + if err := epicartifactinfo.RoleValidator(v); err != nil { + return &ValidationError{Name: "role", err: fmt.Errorf(`ent: validator failed for field "EpicArtifactInfo.role": %w`, err)} + } + } + if v, ok := _u.mutation.ArtifactNameEn(); ok { + if err := epicartifactinfo.ArtifactNameEnValidator(v); err != nil { + return &ValidationError{Name: "artifact_name_en", err: fmt.Errorf(`ent: validator failed for field "EpicArtifactInfo.artifact_name_en": %w`, err)} + } + } + if v, ok := _u.mutation.ImageURL(); ok { + if err := epicartifactinfo.ImageURLValidator(v); err != nil { + return &ValidationError{Name: "image_url", err: fmt.Errorf(`ent: validator failed for field "EpicArtifactInfo.image_url": %w`, err)} + } + } + return nil +} + +func (_u *EpicArtifactInfoUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(epicartifactinfo.Table, epicartifactinfo.Columns, sqlgraph.NewFieldSpec(epicartifactinfo.FieldID, field.TypeInt64)) + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.ArtifactName(); ok { + _spec.SetField(epicartifactinfo.FieldArtifactName, field.TypeString, value) + } + if value, ok := _u.mutation.ArtifactCode(); ok { + _spec.SetField(epicartifactinfo.FieldArtifactCode, field.TypeString, value) + } + if value, ok := _u.mutation.Creator(); ok { + _spec.SetField(epicartifactinfo.FieldCreator, field.TypeString, value) + } + if value, ok := _u.mutation.CreateTime(); ok { + _spec.SetField(epicartifactinfo.FieldCreateTime, field.TypeTime, value) + } + if _u.mutation.CreateTimeCleared() { + _spec.ClearField(epicartifactinfo.FieldCreateTime, field.TypeTime) + } + if value, ok := _u.mutation.Updater(); ok { + _spec.SetField(epicartifactinfo.FieldUpdater, field.TypeString, value) + } + if value, ok := _u.mutation.UpdateTime(); ok { + _spec.SetField(epicartifactinfo.FieldUpdateTime, field.TypeTime, value) + } + if _u.mutation.UpdateTimeCleared() { + _spec.ClearField(epicartifactinfo.FieldUpdateTime, field.TypeTime) + } + if value, ok := _u.mutation.Deleted(); ok { + _spec.SetField(epicartifactinfo.FieldDeleted, field.TypeBool, value) + } + if value, ok := _u.mutation.StatsHealth(); ok { + _spec.SetField(epicartifactinfo.FieldStatsHealth, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedStatsHealth(); ok { + _spec.AddField(epicartifactinfo.FieldStatsHealth, field.TypeInt, value) + } + if value, ok := _u.mutation.StatsAttack(); ok { + _spec.SetField(epicartifactinfo.FieldStatsAttack, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedStatsAttack(); ok { + _spec.AddField(epicartifactinfo.FieldStatsAttack, field.TypeInt, value) + } + if value, ok := _u.mutation.StatsDefense(); ok { + _spec.SetField(epicartifactinfo.FieldStatsDefense, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedStatsDefense(); ok { + _spec.AddField(epicartifactinfo.FieldStatsDefense, field.TypeInt, value) + } + if value, ok := _u.mutation.Rarity(); ok { + _spec.SetField(epicartifactinfo.FieldRarity, field.TypeString, value) + } + if value, ok := _u.mutation.Role(); ok { + _spec.SetField(epicartifactinfo.FieldRole, field.TypeString, value) + } + if value, ok := _u.mutation.ArtifactNameEn(); ok { + _spec.SetField(epicartifactinfo.FieldArtifactNameEn, field.TypeString, value) + } + if value, ok := _u.mutation.ImageURL(); ok { + _spec.SetField(epicartifactinfo.FieldImageURL, field.TypeString, value) + } + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{epicartifactinfo.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// EpicArtifactInfoUpdateOne is the builder for updating a single EpicArtifactInfo entity. +type EpicArtifactInfoUpdateOne struct { + config + fields []string + hooks []Hook + mutation *EpicArtifactInfoMutation +} + +// SetArtifactName sets the "artifact_name" field. +func (_u *EpicArtifactInfoUpdateOne) SetArtifactName(v string) *EpicArtifactInfoUpdateOne { + _u.mutation.SetArtifactName(v) + return _u +} + +// SetNillableArtifactName sets the "artifact_name" field if the given value is not nil. +func (_u *EpicArtifactInfoUpdateOne) SetNillableArtifactName(v *string) *EpicArtifactInfoUpdateOne { + if v != nil { + _u.SetArtifactName(*v) + } + return _u +} + +// SetArtifactCode sets the "artifact_code" field. +func (_u *EpicArtifactInfoUpdateOne) SetArtifactCode(v string) *EpicArtifactInfoUpdateOne { + _u.mutation.SetArtifactCode(v) + return _u +} + +// SetNillableArtifactCode sets the "artifact_code" field if the given value is not nil. +func (_u *EpicArtifactInfoUpdateOne) SetNillableArtifactCode(v *string) *EpicArtifactInfoUpdateOne { + if v != nil { + _u.SetArtifactCode(*v) + } + return _u +} + +// SetCreator sets the "creator" field. +func (_u *EpicArtifactInfoUpdateOne) SetCreator(v string) *EpicArtifactInfoUpdateOne { + _u.mutation.SetCreator(v) + return _u +} + +// SetNillableCreator sets the "creator" field if the given value is not nil. +func (_u *EpicArtifactInfoUpdateOne) SetNillableCreator(v *string) *EpicArtifactInfoUpdateOne { + if v != nil { + _u.SetCreator(*v) + } + return _u +} + +// SetCreateTime sets the "create_time" field. +func (_u *EpicArtifactInfoUpdateOne) SetCreateTime(v time.Time) *EpicArtifactInfoUpdateOne { + _u.mutation.SetCreateTime(v) + return _u +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (_u *EpicArtifactInfoUpdateOne) SetNillableCreateTime(v *time.Time) *EpicArtifactInfoUpdateOne { + if v != nil { + _u.SetCreateTime(*v) + } + return _u +} + +// ClearCreateTime clears the value of the "create_time" field. +func (_u *EpicArtifactInfoUpdateOne) ClearCreateTime() *EpicArtifactInfoUpdateOne { + _u.mutation.ClearCreateTime() + return _u +} + +// SetUpdater sets the "updater" field. +func (_u *EpicArtifactInfoUpdateOne) SetUpdater(v string) *EpicArtifactInfoUpdateOne { + _u.mutation.SetUpdater(v) + return _u +} + +// SetNillableUpdater sets the "updater" field if the given value is not nil. +func (_u *EpicArtifactInfoUpdateOne) SetNillableUpdater(v *string) *EpicArtifactInfoUpdateOne { + if v != nil { + _u.SetUpdater(*v) + } + return _u +} + +// SetUpdateTime sets the "update_time" field. +func (_u *EpicArtifactInfoUpdateOne) SetUpdateTime(v time.Time) *EpicArtifactInfoUpdateOne { + _u.mutation.SetUpdateTime(v) + return _u +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (_u *EpicArtifactInfoUpdateOne) SetNillableUpdateTime(v *time.Time) *EpicArtifactInfoUpdateOne { + if v != nil { + _u.SetUpdateTime(*v) + } + return _u +} + +// ClearUpdateTime clears the value of the "update_time" field. +func (_u *EpicArtifactInfoUpdateOne) ClearUpdateTime() *EpicArtifactInfoUpdateOne { + _u.mutation.ClearUpdateTime() + return _u +} + +// SetDeleted sets the "deleted" field. +func (_u *EpicArtifactInfoUpdateOne) SetDeleted(v bool) *EpicArtifactInfoUpdateOne { + _u.mutation.SetDeleted(v) + return _u +} + +// SetNillableDeleted sets the "deleted" field if the given value is not nil. +func (_u *EpicArtifactInfoUpdateOne) SetNillableDeleted(v *bool) *EpicArtifactInfoUpdateOne { + if v != nil { + _u.SetDeleted(*v) + } + return _u +} + +// SetStatsHealth sets the "stats_health" field. +func (_u *EpicArtifactInfoUpdateOne) SetStatsHealth(v int) *EpicArtifactInfoUpdateOne { + _u.mutation.ResetStatsHealth() + _u.mutation.SetStatsHealth(v) + return _u +} + +// SetNillableStatsHealth sets the "stats_health" field if the given value is not nil. +func (_u *EpicArtifactInfoUpdateOne) SetNillableStatsHealth(v *int) *EpicArtifactInfoUpdateOne { + if v != nil { + _u.SetStatsHealth(*v) + } + return _u +} + +// AddStatsHealth adds value to the "stats_health" field. +func (_u *EpicArtifactInfoUpdateOne) AddStatsHealth(v int) *EpicArtifactInfoUpdateOne { + _u.mutation.AddStatsHealth(v) + return _u +} + +// SetStatsAttack sets the "stats_attack" field. +func (_u *EpicArtifactInfoUpdateOne) SetStatsAttack(v int) *EpicArtifactInfoUpdateOne { + _u.mutation.ResetStatsAttack() + _u.mutation.SetStatsAttack(v) + return _u +} + +// SetNillableStatsAttack sets the "stats_attack" field if the given value is not nil. +func (_u *EpicArtifactInfoUpdateOne) SetNillableStatsAttack(v *int) *EpicArtifactInfoUpdateOne { + if v != nil { + _u.SetStatsAttack(*v) + } + return _u +} + +// AddStatsAttack adds value to the "stats_attack" field. +func (_u *EpicArtifactInfoUpdateOne) AddStatsAttack(v int) *EpicArtifactInfoUpdateOne { + _u.mutation.AddStatsAttack(v) + return _u +} + +// SetStatsDefense sets the "stats_defense" field. +func (_u *EpicArtifactInfoUpdateOne) SetStatsDefense(v int) *EpicArtifactInfoUpdateOne { + _u.mutation.ResetStatsDefense() + _u.mutation.SetStatsDefense(v) + return _u +} + +// SetNillableStatsDefense sets the "stats_defense" field if the given value is not nil. +func (_u *EpicArtifactInfoUpdateOne) SetNillableStatsDefense(v *int) *EpicArtifactInfoUpdateOne { + if v != nil { + _u.SetStatsDefense(*v) + } + return _u +} + +// AddStatsDefense adds value to the "stats_defense" field. +func (_u *EpicArtifactInfoUpdateOne) AddStatsDefense(v int) *EpicArtifactInfoUpdateOne { + _u.mutation.AddStatsDefense(v) + return _u +} + +// SetRarity sets the "rarity" field. +func (_u *EpicArtifactInfoUpdateOne) SetRarity(v string) *EpicArtifactInfoUpdateOne { + _u.mutation.SetRarity(v) + return _u +} + +// SetNillableRarity sets the "rarity" field if the given value is not nil. +func (_u *EpicArtifactInfoUpdateOne) SetNillableRarity(v *string) *EpicArtifactInfoUpdateOne { + if v != nil { + _u.SetRarity(*v) + } + return _u +} + +// SetRole sets the "role" field. +func (_u *EpicArtifactInfoUpdateOne) SetRole(v string) *EpicArtifactInfoUpdateOne { + _u.mutation.SetRole(v) + return _u +} + +// SetNillableRole sets the "role" field if the given value is not nil. +func (_u *EpicArtifactInfoUpdateOne) SetNillableRole(v *string) *EpicArtifactInfoUpdateOne { + if v != nil { + _u.SetRole(*v) + } + return _u +} + +// SetArtifactNameEn sets the "artifact_name_en" field. +func (_u *EpicArtifactInfoUpdateOne) SetArtifactNameEn(v string) *EpicArtifactInfoUpdateOne { + _u.mutation.SetArtifactNameEn(v) + return _u +} + +// SetNillableArtifactNameEn sets the "artifact_name_en" field if the given value is not nil. +func (_u *EpicArtifactInfoUpdateOne) SetNillableArtifactNameEn(v *string) *EpicArtifactInfoUpdateOne { + if v != nil { + _u.SetArtifactNameEn(*v) + } + return _u +} + +// SetImageURL sets the "image_url" field. +func (_u *EpicArtifactInfoUpdateOne) SetImageURL(v string) *EpicArtifactInfoUpdateOne { + _u.mutation.SetImageURL(v) + return _u +} + +// SetNillableImageURL sets the "image_url" field if the given value is not nil. +func (_u *EpicArtifactInfoUpdateOne) SetNillableImageURL(v *string) *EpicArtifactInfoUpdateOne { + if v != nil { + _u.SetImageURL(*v) + } + return _u +} + +// Mutation returns the EpicArtifactInfoMutation object of the builder. +func (_u *EpicArtifactInfoUpdateOne) Mutation() *EpicArtifactInfoMutation { + return _u.mutation +} + +// Where appends a list predicates to the EpicArtifactInfoUpdate builder. +func (_u *EpicArtifactInfoUpdateOne) Where(ps ...predicate.EpicArtifactInfo) *EpicArtifactInfoUpdateOne { + _u.mutation.Where(ps...) + return _u +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (_u *EpicArtifactInfoUpdateOne) Select(field string, fields ...string) *EpicArtifactInfoUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated EpicArtifactInfo entity. +func (_u *EpicArtifactInfoUpdateOne) Save(ctx context.Context) (*EpicArtifactInfo, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *EpicArtifactInfoUpdateOne) SaveX(ctx context.Context) *EpicArtifactInfo { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *EpicArtifactInfoUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *EpicArtifactInfoUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *EpicArtifactInfoUpdateOne) check() error { + if v, ok := _u.mutation.ArtifactName(); ok { + if err := epicartifactinfo.ArtifactNameValidator(v); err != nil { + return &ValidationError{Name: "artifact_name", err: fmt.Errorf(`ent: validator failed for field "EpicArtifactInfo.artifact_name": %w`, err)} + } + } + if v, ok := _u.mutation.ArtifactCode(); ok { + if err := epicartifactinfo.ArtifactCodeValidator(v); err != nil { + return &ValidationError{Name: "artifact_code", err: fmt.Errorf(`ent: validator failed for field "EpicArtifactInfo.artifact_code": %w`, err)} + } + } + if v, ok := _u.mutation.Creator(); ok { + if err := epicartifactinfo.CreatorValidator(v); err != nil { + return &ValidationError{Name: "creator", err: fmt.Errorf(`ent: validator failed for field "EpicArtifactInfo.creator": %w`, err)} + } + } + if v, ok := _u.mutation.Updater(); ok { + if err := epicartifactinfo.UpdaterValidator(v); err != nil { + return &ValidationError{Name: "updater", err: fmt.Errorf(`ent: validator failed for field "EpicArtifactInfo.updater": %w`, err)} + } + } + if v, ok := _u.mutation.Rarity(); ok { + if err := epicartifactinfo.RarityValidator(v); err != nil { + return &ValidationError{Name: "rarity", err: fmt.Errorf(`ent: validator failed for field "EpicArtifactInfo.rarity": %w`, err)} + } + } + if v, ok := _u.mutation.Role(); ok { + if err := epicartifactinfo.RoleValidator(v); err != nil { + return &ValidationError{Name: "role", err: fmt.Errorf(`ent: validator failed for field "EpicArtifactInfo.role": %w`, err)} + } + } + if v, ok := _u.mutation.ArtifactNameEn(); ok { + if err := epicartifactinfo.ArtifactNameEnValidator(v); err != nil { + return &ValidationError{Name: "artifact_name_en", err: fmt.Errorf(`ent: validator failed for field "EpicArtifactInfo.artifact_name_en": %w`, err)} + } + } + if v, ok := _u.mutation.ImageURL(); ok { + if err := epicartifactinfo.ImageURLValidator(v); err != nil { + return &ValidationError{Name: "image_url", err: fmt.Errorf(`ent: validator failed for field "EpicArtifactInfo.image_url": %w`, err)} + } + } + return nil +} + +func (_u *EpicArtifactInfoUpdateOne) sqlSave(ctx context.Context) (_node *EpicArtifactInfo, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(epicartifactinfo.Table, epicartifactinfo.Columns, sqlgraph.NewFieldSpec(epicartifactinfo.FieldID, field.TypeInt64)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "EpicArtifactInfo.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := _u.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, epicartifactinfo.FieldID) + for _, f := range fields { + if !epicartifactinfo.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != epicartifactinfo.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.ArtifactName(); ok { + _spec.SetField(epicartifactinfo.FieldArtifactName, field.TypeString, value) + } + if value, ok := _u.mutation.ArtifactCode(); ok { + _spec.SetField(epicartifactinfo.FieldArtifactCode, field.TypeString, value) + } + if value, ok := _u.mutation.Creator(); ok { + _spec.SetField(epicartifactinfo.FieldCreator, field.TypeString, value) + } + if value, ok := _u.mutation.CreateTime(); ok { + _spec.SetField(epicartifactinfo.FieldCreateTime, field.TypeTime, value) + } + if _u.mutation.CreateTimeCleared() { + _spec.ClearField(epicartifactinfo.FieldCreateTime, field.TypeTime) + } + if value, ok := _u.mutation.Updater(); ok { + _spec.SetField(epicartifactinfo.FieldUpdater, field.TypeString, value) + } + if value, ok := _u.mutation.UpdateTime(); ok { + _spec.SetField(epicartifactinfo.FieldUpdateTime, field.TypeTime, value) + } + if _u.mutation.UpdateTimeCleared() { + _spec.ClearField(epicartifactinfo.FieldUpdateTime, field.TypeTime) + } + if value, ok := _u.mutation.Deleted(); ok { + _spec.SetField(epicartifactinfo.FieldDeleted, field.TypeBool, value) + } + if value, ok := _u.mutation.StatsHealth(); ok { + _spec.SetField(epicartifactinfo.FieldStatsHealth, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedStatsHealth(); ok { + _spec.AddField(epicartifactinfo.FieldStatsHealth, field.TypeInt, value) + } + if value, ok := _u.mutation.StatsAttack(); ok { + _spec.SetField(epicartifactinfo.FieldStatsAttack, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedStatsAttack(); ok { + _spec.AddField(epicartifactinfo.FieldStatsAttack, field.TypeInt, value) + } + if value, ok := _u.mutation.StatsDefense(); ok { + _spec.SetField(epicartifactinfo.FieldStatsDefense, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedStatsDefense(); ok { + _spec.AddField(epicartifactinfo.FieldStatsDefense, field.TypeInt, value) + } + if value, ok := _u.mutation.Rarity(); ok { + _spec.SetField(epicartifactinfo.FieldRarity, field.TypeString, value) + } + if value, ok := _u.mutation.Role(); ok { + _spec.SetField(epicartifactinfo.FieldRole, field.TypeString, value) + } + if value, ok := _u.mutation.ArtifactNameEn(); ok { + _spec.SetField(epicartifactinfo.FieldArtifactNameEn, field.TypeString, value) + } + if value, ok := _u.mutation.ImageURL(); ok { + _spec.SetField(epicartifactinfo.FieldImageURL, field.TypeString, value) + } + _node = &EpicArtifactInfo{config: _u.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{epicartifactinfo.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} diff --git a/internal/ent/epicgvgattackteams.go b/internal/ent/epicgvgattackteams.go new file mode 100644 index 0000000..725274b --- /dev/null +++ b/internal/ent/epicgvgattackteams.go @@ -0,0 +1,169 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "epic-ent/internal/ent/epicgvgattackteams" + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// EpicGvgAttackTeams is the model entity for the EpicGvgAttackTeams schema. +type EpicGvgAttackTeams struct { + config `json:"-"` + // ID of the ent. + ID int64 `json:"id,omitempty"` + // AttackHeroes holds the value of the "attack_heroes" field. + AttackHeroes string `json:"attack_heroes,omitempty"` + // Creator holds the value of the "creator" field. + Creator string `json:"creator,omitempty"` + // CreateTime holds the value of the "create_time" field. + CreateTime *time.Time `json:"create_time,omitempty"` + // Updater holds the value of the "updater" field. + Updater string `json:"updater,omitempty"` + // UpdateTime holds the value of the "update_time" field. + UpdateTime *time.Time `json:"update_time,omitempty"` + // Deleted holds the value of the "deleted" field. + Deleted bool `json:"deleted,omitempty"` + selectValues sql.SelectValues +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*EpicGvgAttackTeams) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case epicgvgattackteams.FieldDeleted: + values[i] = new(sql.NullBool) + case epicgvgattackteams.FieldID: + values[i] = new(sql.NullInt64) + case epicgvgattackteams.FieldAttackHeroes, epicgvgattackteams.FieldCreator, epicgvgattackteams.FieldUpdater: + values[i] = new(sql.NullString) + case epicgvgattackteams.FieldCreateTime, epicgvgattackteams.FieldUpdateTime: + values[i] = new(sql.NullTime) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the EpicGvgAttackTeams fields. +func (_m *EpicGvgAttackTeams) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case epicgvgattackteams.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + _m.ID = int64(value.Int64) + case epicgvgattackteams.FieldAttackHeroes: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field attack_heroes", values[i]) + } else if value.Valid { + _m.AttackHeroes = value.String + } + case epicgvgattackteams.FieldCreator: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field creator", values[i]) + } else if value.Valid { + _m.Creator = value.String + } + case epicgvgattackteams.FieldCreateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field create_time", values[i]) + } else if value.Valid { + _m.CreateTime = new(time.Time) + *_m.CreateTime = value.Time + } + case epicgvgattackteams.FieldUpdater: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field updater", values[i]) + } else if value.Valid { + _m.Updater = value.String + } + case epicgvgattackteams.FieldUpdateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field update_time", values[i]) + } else if value.Valid { + _m.UpdateTime = new(time.Time) + *_m.UpdateTime = value.Time + } + case epicgvgattackteams.FieldDeleted: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field deleted", values[i]) + } else if value.Valid { + _m.Deleted = value.Bool + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the EpicGvgAttackTeams. +// This includes values selected through modifiers, order, etc. +func (_m *EpicGvgAttackTeams) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// Update returns a builder for updating this EpicGvgAttackTeams. +// Note that you need to call EpicGvgAttackTeams.Unwrap() before calling this method if this EpicGvgAttackTeams +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *EpicGvgAttackTeams) Update() *EpicGvgAttackTeamsUpdateOne { + return NewEpicGvgAttackTeamsClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the EpicGvgAttackTeams entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (_m *EpicGvgAttackTeams) Unwrap() *EpicGvgAttackTeams { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("ent: EpicGvgAttackTeams is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *EpicGvgAttackTeams) String() string { + var builder strings.Builder + builder.WriteString("EpicGvgAttackTeams(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("attack_heroes=") + builder.WriteString(_m.AttackHeroes) + builder.WriteString(", ") + builder.WriteString("creator=") + builder.WriteString(_m.Creator) + builder.WriteString(", ") + if v := _m.CreateTime; v != nil { + builder.WriteString("create_time=") + builder.WriteString(v.Format(time.ANSIC)) + } + builder.WriteString(", ") + builder.WriteString("updater=") + builder.WriteString(_m.Updater) + builder.WriteString(", ") + if v := _m.UpdateTime; v != nil { + builder.WriteString("update_time=") + builder.WriteString(v.Format(time.ANSIC)) + } + builder.WriteString(", ") + builder.WriteString("deleted=") + builder.WriteString(fmt.Sprintf("%v", _m.Deleted)) + builder.WriteByte(')') + return builder.String() +} + +// EpicGvgAttackTeamsSlice is a parsable slice of EpicGvgAttackTeams. +type EpicGvgAttackTeamsSlice []*EpicGvgAttackTeams diff --git a/internal/ent/epicgvgattackteams/epicgvgattackteams.go b/internal/ent/epicgvgattackteams/epicgvgattackteams.go new file mode 100644 index 0000000..4d4365f --- /dev/null +++ b/internal/ent/epicgvgattackteams/epicgvgattackteams.go @@ -0,0 +1,96 @@ +// Code generated by ent, DO NOT EDIT. + +package epicgvgattackteams + +import ( + "entgo.io/ent/dialect/sql" +) + +const ( + // Label holds the string label denoting the epicgvgattackteams type in the database. + Label = "epic_gvg_attack_teams" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldAttackHeroes holds the string denoting the attack_heroes field in the database. + FieldAttackHeroes = "attack_heroes" + // FieldCreator holds the string denoting the creator field in the database. + FieldCreator = "creator" + // FieldCreateTime holds the string denoting the create_time field in the database. + FieldCreateTime = "create_time" + // FieldUpdater holds the string denoting the updater field in the database. + FieldUpdater = "updater" + // FieldUpdateTime holds the string denoting the update_time field in the database. + FieldUpdateTime = "update_time" + // FieldDeleted holds the string denoting the deleted field in the database. + FieldDeleted = "deleted" + // Table holds the table name of the epicgvgattackteams in the database. + Table = "epic_gvg_attack_teams" +) + +// Columns holds all SQL columns for epicgvgattackteams fields. +var Columns = []string{ + FieldID, + FieldAttackHeroes, + FieldCreator, + FieldCreateTime, + FieldUpdater, + FieldUpdateTime, + FieldDeleted, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // AttackHeroesValidator is a validator for the "attack_heroes" field. It is called by the builders before save. + AttackHeroesValidator func(string) error + // CreatorValidator is a validator for the "creator" field. It is called by the builders before save. + CreatorValidator func(string) error + // UpdaterValidator is a validator for the "updater" field. It is called by the builders before save. + UpdaterValidator func(string) error +) + +// OrderOption defines the ordering options for the EpicGvgAttackTeams queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByAttackHeroes orders the results by the attack_heroes field. +func ByAttackHeroes(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldAttackHeroes, opts...).ToFunc() +} + +// ByCreator orders the results by the creator field. +func ByCreator(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreator, opts...).ToFunc() +} + +// ByCreateTime orders the results by the create_time field. +func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateTime, opts...).ToFunc() +} + +// ByUpdater orders the results by the updater field. +func ByUpdater(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdater, opts...).ToFunc() +} + +// ByUpdateTime orders the results by the update_time field. +func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() +} + +// ByDeleted orders the results by the deleted field. +func ByDeleted(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeleted, opts...).ToFunc() +} diff --git a/internal/ent/epicgvgattackteams/where.go b/internal/ent/epicgvgattackteams/where.go new file mode 100644 index 0000000..836bd59 --- /dev/null +++ b/internal/ent/epicgvgattackteams/where.go @@ -0,0 +1,405 @@ +// Code generated by ent, DO NOT EDIT. + +package epicgvgattackteams + +import ( + "epic-ent/internal/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" +) + +// ID filters vertices based on their ID field. +func ID(id int64) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int64) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int64) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int64) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int64) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int64) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int64) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int64) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int64) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldLTE(FieldID, id)) +} + +// AttackHeroes applies equality check predicate on the "attack_heroes" field. It's identical to AttackHeroesEQ. +func AttackHeroes(v string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldEQ(FieldAttackHeroes, v)) +} + +// Creator applies equality check predicate on the "creator" field. It's identical to CreatorEQ. +func Creator(v string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldEQ(FieldCreator, v)) +} + +// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. +func CreateTime(v time.Time) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldEQ(FieldCreateTime, v)) +} + +// Updater applies equality check predicate on the "updater" field. It's identical to UpdaterEQ. +func Updater(v string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldEQ(FieldUpdater, v)) +} + +// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. +func UpdateTime(v time.Time) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldEQ(FieldUpdateTime, v)) +} + +// Deleted applies equality check predicate on the "deleted" field. It's identical to DeletedEQ. +func Deleted(v bool) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldEQ(FieldDeleted, v)) +} + +// AttackHeroesEQ applies the EQ predicate on the "attack_heroes" field. +func AttackHeroesEQ(v string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldEQ(FieldAttackHeroes, v)) +} + +// AttackHeroesNEQ applies the NEQ predicate on the "attack_heroes" field. +func AttackHeroesNEQ(v string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldNEQ(FieldAttackHeroes, v)) +} + +// AttackHeroesIn applies the In predicate on the "attack_heroes" field. +func AttackHeroesIn(vs ...string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldIn(FieldAttackHeroes, vs...)) +} + +// AttackHeroesNotIn applies the NotIn predicate on the "attack_heroes" field. +func AttackHeroesNotIn(vs ...string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldNotIn(FieldAttackHeroes, vs...)) +} + +// AttackHeroesGT applies the GT predicate on the "attack_heroes" field. +func AttackHeroesGT(v string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldGT(FieldAttackHeroes, v)) +} + +// AttackHeroesGTE applies the GTE predicate on the "attack_heroes" field. +func AttackHeroesGTE(v string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldGTE(FieldAttackHeroes, v)) +} + +// AttackHeroesLT applies the LT predicate on the "attack_heroes" field. +func AttackHeroesLT(v string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldLT(FieldAttackHeroes, v)) +} + +// AttackHeroesLTE applies the LTE predicate on the "attack_heroes" field. +func AttackHeroesLTE(v string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldLTE(FieldAttackHeroes, v)) +} + +// AttackHeroesContains applies the Contains predicate on the "attack_heroes" field. +func AttackHeroesContains(v string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldContains(FieldAttackHeroes, v)) +} + +// AttackHeroesHasPrefix applies the HasPrefix predicate on the "attack_heroes" field. +func AttackHeroesHasPrefix(v string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldHasPrefix(FieldAttackHeroes, v)) +} + +// AttackHeroesHasSuffix applies the HasSuffix predicate on the "attack_heroes" field. +func AttackHeroesHasSuffix(v string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldHasSuffix(FieldAttackHeroes, v)) +} + +// AttackHeroesEqualFold applies the EqualFold predicate on the "attack_heroes" field. +func AttackHeroesEqualFold(v string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldEqualFold(FieldAttackHeroes, v)) +} + +// AttackHeroesContainsFold applies the ContainsFold predicate on the "attack_heroes" field. +func AttackHeroesContainsFold(v string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldContainsFold(FieldAttackHeroes, v)) +} + +// CreatorEQ applies the EQ predicate on the "creator" field. +func CreatorEQ(v string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldEQ(FieldCreator, v)) +} + +// CreatorNEQ applies the NEQ predicate on the "creator" field. +func CreatorNEQ(v string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldNEQ(FieldCreator, v)) +} + +// CreatorIn applies the In predicate on the "creator" field. +func CreatorIn(vs ...string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldIn(FieldCreator, vs...)) +} + +// CreatorNotIn applies the NotIn predicate on the "creator" field. +func CreatorNotIn(vs ...string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldNotIn(FieldCreator, vs...)) +} + +// CreatorGT applies the GT predicate on the "creator" field. +func CreatorGT(v string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldGT(FieldCreator, v)) +} + +// CreatorGTE applies the GTE predicate on the "creator" field. +func CreatorGTE(v string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldGTE(FieldCreator, v)) +} + +// CreatorLT applies the LT predicate on the "creator" field. +func CreatorLT(v string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldLT(FieldCreator, v)) +} + +// CreatorLTE applies the LTE predicate on the "creator" field. +func CreatorLTE(v string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldLTE(FieldCreator, v)) +} + +// CreatorContains applies the Contains predicate on the "creator" field. +func CreatorContains(v string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldContains(FieldCreator, v)) +} + +// CreatorHasPrefix applies the HasPrefix predicate on the "creator" field. +func CreatorHasPrefix(v string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldHasPrefix(FieldCreator, v)) +} + +// CreatorHasSuffix applies the HasSuffix predicate on the "creator" field. +func CreatorHasSuffix(v string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldHasSuffix(FieldCreator, v)) +} + +// CreatorEqualFold applies the EqualFold predicate on the "creator" field. +func CreatorEqualFold(v string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldEqualFold(FieldCreator, v)) +} + +// CreatorContainsFold applies the ContainsFold predicate on the "creator" field. +func CreatorContainsFold(v string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldContainsFold(FieldCreator, v)) +} + +// CreateTimeEQ applies the EQ predicate on the "create_time" field. +func CreateTimeEQ(v time.Time) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldEQ(FieldCreateTime, v)) +} + +// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. +func CreateTimeNEQ(v time.Time) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldNEQ(FieldCreateTime, v)) +} + +// CreateTimeIn applies the In predicate on the "create_time" field. +func CreateTimeIn(vs ...time.Time) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldIn(FieldCreateTime, vs...)) +} + +// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. +func CreateTimeNotIn(vs ...time.Time) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldNotIn(FieldCreateTime, vs...)) +} + +// CreateTimeGT applies the GT predicate on the "create_time" field. +func CreateTimeGT(v time.Time) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldGT(FieldCreateTime, v)) +} + +// CreateTimeGTE applies the GTE predicate on the "create_time" field. +func CreateTimeGTE(v time.Time) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldGTE(FieldCreateTime, v)) +} + +// CreateTimeLT applies the LT predicate on the "create_time" field. +func CreateTimeLT(v time.Time) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldLT(FieldCreateTime, v)) +} + +// CreateTimeLTE applies the LTE predicate on the "create_time" field. +func CreateTimeLTE(v time.Time) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldLTE(FieldCreateTime, v)) +} + +// CreateTimeIsNil applies the IsNil predicate on the "create_time" field. +func CreateTimeIsNil() predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldIsNull(FieldCreateTime)) +} + +// CreateTimeNotNil applies the NotNil predicate on the "create_time" field. +func CreateTimeNotNil() predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldNotNull(FieldCreateTime)) +} + +// UpdaterEQ applies the EQ predicate on the "updater" field. +func UpdaterEQ(v string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldEQ(FieldUpdater, v)) +} + +// UpdaterNEQ applies the NEQ predicate on the "updater" field. +func UpdaterNEQ(v string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldNEQ(FieldUpdater, v)) +} + +// UpdaterIn applies the In predicate on the "updater" field. +func UpdaterIn(vs ...string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldIn(FieldUpdater, vs...)) +} + +// UpdaterNotIn applies the NotIn predicate on the "updater" field. +func UpdaterNotIn(vs ...string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldNotIn(FieldUpdater, vs...)) +} + +// UpdaterGT applies the GT predicate on the "updater" field. +func UpdaterGT(v string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldGT(FieldUpdater, v)) +} + +// UpdaterGTE applies the GTE predicate on the "updater" field. +func UpdaterGTE(v string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldGTE(FieldUpdater, v)) +} + +// UpdaterLT applies the LT predicate on the "updater" field. +func UpdaterLT(v string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldLT(FieldUpdater, v)) +} + +// UpdaterLTE applies the LTE predicate on the "updater" field. +func UpdaterLTE(v string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldLTE(FieldUpdater, v)) +} + +// UpdaterContains applies the Contains predicate on the "updater" field. +func UpdaterContains(v string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldContains(FieldUpdater, v)) +} + +// UpdaterHasPrefix applies the HasPrefix predicate on the "updater" field. +func UpdaterHasPrefix(v string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldHasPrefix(FieldUpdater, v)) +} + +// UpdaterHasSuffix applies the HasSuffix predicate on the "updater" field. +func UpdaterHasSuffix(v string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldHasSuffix(FieldUpdater, v)) +} + +// UpdaterEqualFold applies the EqualFold predicate on the "updater" field. +func UpdaterEqualFold(v string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldEqualFold(FieldUpdater, v)) +} + +// UpdaterContainsFold applies the ContainsFold predicate on the "updater" field. +func UpdaterContainsFold(v string) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldContainsFold(FieldUpdater, v)) +} + +// UpdateTimeEQ applies the EQ predicate on the "update_time" field. +func UpdateTimeEQ(v time.Time) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldEQ(FieldUpdateTime, v)) +} + +// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. +func UpdateTimeNEQ(v time.Time) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldNEQ(FieldUpdateTime, v)) +} + +// UpdateTimeIn applies the In predicate on the "update_time" field. +func UpdateTimeIn(vs ...time.Time) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. +func UpdateTimeNotIn(vs ...time.Time) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldNotIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeGT applies the GT predicate on the "update_time" field. +func UpdateTimeGT(v time.Time) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldGT(FieldUpdateTime, v)) +} + +// UpdateTimeGTE applies the GTE predicate on the "update_time" field. +func UpdateTimeGTE(v time.Time) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldGTE(FieldUpdateTime, v)) +} + +// UpdateTimeLT applies the LT predicate on the "update_time" field. +func UpdateTimeLT(v time.Time) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldLT(FieldUpdateTime, v)) +} + +// UpdateTimeLTE applies the LTE predicate on the "update_time" field. +func UpdateTimeLTE(v time.Time) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldLTE(FieldUpdateTime, v)) +} + +// UpdateTimeIsNil applies the IsNil predicate on the "update_time" field. +func UpdateTimeIsNil() predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldIsNull(FieldUpdateTime)) +} + +// UpdateTimeNotNil applies the NotNil predicate on the "update_time" field. +func UpdateTimeNotNil() predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldNotNull(FieldUpdateTime)) +} + +// DeletedEQ applies the EQ predicate on the "deleted" field. +func DeletedEQ(v bool) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldEQ(FieldDeleted, v)) +} + +// DeletedNEQ applies the NEQ predicate on the "deleted" field. +func DeletedNEQ(v bool) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.FieldNEQ(FieldDeleted, v)) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.EpicGvgAttackTeams) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.EpicGvgAttackTeams) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.EpicGvgAttackTeams) predicate.EpicGvgAttackTeams { + return predicate.EpicGvgAttackTeams(sql.NotPredicates(p)) +} diff --git a/internal/ent/epicgvgattackteams_create.go b/internal/ent/epicgvgattackteams_create.go new file mode 100644 index 0000000..5a11f17 --- /dev/null +++ b/internal/ent/epicgvgattackteams_create.go @@ -0,0 +1,286 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "epic-ent/internal/ent/epicgvgattackteams" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// EpicGvgAttackTeamsCreate is the builder for creating a EpicGvgAttackTeams entity. +type EpicGvgAttackTeamsCreate struct { + config + mutation *EpicGvgAttackTeamsMutation + hooks []Hook +} + +// SetAttackHeroes sets the "attack_heroes" field. +func (_c *EpicGvgAttackTeamsCreate) SetAttackHeroes(v string) *EpicGvgAttackTeamsCreate { + _c.mutation.SetAttackHeroes(v) + return _c +} + +// SetCreator sets the "creator" field. +func (_c *EpicGvgAttackTeamsCreate) SetCreator(v string) *EpicGvgAttackTeamsCreate { + _c.mutation.SetCreator(v) + return _c +} + +// SetCreateTime sets the "create_time" field. +func (_c *EpicGvgAttackTeamsCreate) SetCreateTime(v time.Time) *EpicGvgAttackTeamsCreate { + _c.mutation.SetCreateTime(v) + return _c +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (_c *EpicGvgAttackTeamsCreate) SetNillableCreateTime(v *time.Time) *EpicGvgAttackTeamsCreate { + if v != nil { + _c.SetCreateTime(*v) + } + return _c +} + +// SetUpdater sets the "updater" field. +func (_c *EpicGvgAttackTeamsCreate) SetUpdater(v string) *EpicGvgAttackTeamsCreate { + _c.mutation.SetUpdater(v) + return _c +} + +// SetUpdateTime sets the "update_time" field. +func (_c *EpicGvgAttackTeamsCreate) SetUpdateTime(v time.Time) *EpicGvgAttackTeamsCreate { + _c.mutation.SetUpdateTime(v) + return _c +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (_c *EpicGvgAttackTeamsCreate) SetNillableUpdateTime(v *time.Time) *EpicGvgAttackTeamsCreate { + if v != nil { + _c.SetUpdateTime(*v) + } + return _c +} + +// SetDeleted sets the "deleted" field. +func (_c *EpicGvgAttackTeamsCreate) SetDeleted(v bool) *EpicGvgAttackTeamsCreate { + _c.mutation.SetDeleted(v) + return _c +} + +// SetID sets the "id" field. +func (_c *EpicGvgAttackTeamsCreate) SetID(v int64) *EpicGvgAttackTeamsCreate { + _c.mutation.SetID(v) + return _c +} + +// Mutation returns the EpicGvgAttackTeamsMutation object of the builder. +func (_c *EpicGvgAttackTeamsCreate) Mutation() *EpicGvgAttackTeamsMutation { + return _c.mutation +} + +// Save creates the EpicGvgAttackTeams in the database. +func (_c *EpicGvgAttackTeamsCreate) Save(ctx context.Context) (*EpicGvgAttackTeams, error) { + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *EpicGvgAttackTeamsCreate) SaveX(ctx context.Context) *EpicGvgAttackTeams { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *EpicGvgAttackTeamsCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *EpicGvgAttackTeamsCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *EpicGvgAttackTeamsCreate) check() error { + if _, ok := _c.mutation.AttackHeroes(); !ok { + return &ValidationError{Name: "attack_heroes", err: errors.New(`ent: missing required field "EpicGvgAttackTeams.attack_heroes"`)} + } + if v, ok := _c.mutation.AttackHeroes(); ok { + if err := epicgvgattackteams.AttackHeroesValidator(v); err != nil { + return &ValidationError{Name: "attack_heroes", err: fmt.Errorf(`ent: validator failed for field "EpicGvgAttackTeams.attack_heroes": %w`, err)} + } + } + if _, ok := _c.mutation.Creator(); !ok { + return &ValidationError{Name: "creator", err: errors.New(`ent: missing required field "EpicGvgAttackTeams.creator"`)} + } + if v, ok := _c.mutation.Creator(); ok { + if err := epicgvgattackteams.CreatorValidator(v); err != nil { + return &ValidationError{Name: "creator", err: fmt.Errorf(`ent: validator failed for field "EpicGvgAttackTeams.creator": %w`, err)} + } + } + if _, ok := _c.mutation.Updater(); !ok { + return &ValidationError{Name: "updater", err: errors.New(`ent: missing required field "EpicGvgAttackTeams.updater"`)} + } + if v, ok := _c.mutation.Updater(); ok { + if err := epicgvgattackteams.UpdaterValidator(v); err != nil { + return &ValidationError{Name: "updater", err: fmt.Errorf(`ent: validator failed for field "EpicGvgAttackTeams.updater": %w`, err)} + } + } + if _, ok := _c.mutation.Deleted(); !ok { + return &ValidationError{Name: "deleted", err: errors.New(`ent: missing required field "EpicGvgAttackTeams.deleted"`)} + } + return nil +} + +func (_c *EpicGvgAttackTeamsCreate) sqlSave(ctx context.Context) (*EpicGvgAttackTeams, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != _node.ID { + id := _spec.ID.Value.(int64) + _node.ID = int64(id) + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *EpicGvgAttackTeamsCreate) createSpec() (*EpicGvgAttackTeams, *sqlgraph.CreateSpec) { + var ( + _node = &EpicGvgAttackTeams{config: _c.config} + _spec = sqlgraph.NewCreateSpec(epicgvgattackteams.Table, sqlgraph.NewFieldSpec(epicgvgattackteams.FieldID, field.TypeInt64)) + ) + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := _c.mutation.AttackHeroes(); ok { + _spec.SetField(epicgvgattackteams.FieldAttackHeroes, field.TypeString, value) + _node.AttackHeroes = value + } + if value, ok := _c.mutation.Creator(); ok { + _spec.SetField(epicgvgattackteams.FieldCreator, field.TypeString, value) + _node.Creator = value + } + if value, ok := _c.mutation.CreateTime(); ok { + _spec.SetField(epicgvgattackteams.FieldCreateTime, field.TypeTime, value) + _node.CreateTime = &value + } + if value, ok := _c.mutation.Updater(); ok { + _spec.SetField(epicgvgattackteams.FieldUpdater, field.TypeString, value) + _node.Updater = value + } + if value, ok := _c.mutation.UpdateTime(); ok { + _spec.SetField(epicgvgattackteams.FieldUpdateTime, field.TypeTime, value) + _node.UpdateTime = &value + } + if value, ok := _c.mutation.Deleted(); ok { + _spec.SetField(epicgvgattackteams.FieldDeleted, field.TypeBool, value) + _node.Deleted = value + } + return _node, _spec +} + +// EpicGvgAttackTeamsCreateBulk is the builder for creating many EpicGvgAttackTeams entities in bulk. +type EpicGvgAttackTeamsCreateBulk struct { + config + err error + builders []*EpicGvgAttackTeamsCreate +} + +// Save creates the EpicGvgAttackTeams entities in the database. +func (_c *EpicGvgAttackTeamsCreateBulk) Save(ctx context.Context) ([]*EpicGvgAttackTeams, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*EpicGvgAttackTeams, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*EpicGvgAttackTeamsMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil && nodes[i].ID == 0 { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int64(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *EpicGvgAttackTeamsCreateBulk) SaveX(ctx context.Context) []*EpicGvgAttackTeams { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *EpicGvgAttackTeamsCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *EpicGvgAttackTeamsCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/ent/epicgvgattackteams_delete.go b/internal/ent/epicgvgattackteams_delete.go new file mode 100644 index 0000000..35fe1c1 --- /dev/null +++ b/internal/ent/epicgvgattackteams_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "epic-ent/internal/ent/epicgvgattackteams" + "epic-ent/internal/ent/predicate" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// EpicGvgAttackTeamsDelete is the builder for deleting a EpicGvgAttackTeams entity. +type EpicGvgAttackTeamsDelete struct { + config + hooks []Hook + mutation *EpicGvgAttackTeamsMutation +} + +// Where appends a list predicates to the EpicGvgAttackTeamsDelete builder. +func (_d *EpicGvgAttackTeamsDelete) Where(ps ...predicate.EpicGvgAttackTeams) *EpicGvgAttackTeamsDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *EpicGvgAttackTeamsDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *EpicGvgAttackTeamsDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *EpicGvgAttackTeamsDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(epicgvgattackteams.Table, sqlgraph.NewFieldSpec(epicgvgattackteams.FieldID, field.TypeInt64)) + if ps := _d.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + _d.mutation.done = true + return affected, err +} + +// EpicGvgAttackTeamsDeleteOne is the builder for deleting a single EpicGvgAttackTeams entity. +type EpicGvgAttackTeamsDeleteOne struct { + _d *EpicGvgAttackTeamsDelete +} + +// Where appends a list predicates to the EpicGvgAttackTeamsDelete builder. +func (_d *EpicGvgAttackTeamsDeleteOne) Where(ps ...predicate.EpicGvgAttackTeams) *EpicGvgAttackTeamsDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *EpicGvgAttackTeamsDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{epicgvgattackteams.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *EpicGvgAttackTeamsDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/ent/epicgvgattackteams_query.go b/internal/ent/epicgvgattackteams_query.go new file mode 100644 index 0000000..a30e0c3 --- /dev/null +++ b/internal/ent/epicgvgattackteams_query.go @@ -0,0 +1,527 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "epic-ent/internal/ent/epicgvgattackteams" + "epic-ent/internal/ent/predicate" + "fmt" + "math" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// EpicGvgAttackTeamsQuery is the builder for querying EpicGvgAttackTeams entities. +type EpicGvgAttackTeamsQuery struct { + config + ctx *QueryContext + order []epicgvgattackteams.OrderOption + inters []Interceptor + predicates []predicate.EpicGvgAttackTeams + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the EpicGvgAttackTeamsQuery builder. +func (_q *EpicGvgAttackTeamsQuery) Where(ps ...predicate.EpicGvgAttackTeams) *EpicGvgAttackTeamsQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *EpicGvgAttackTeamsQuery) Limit(limit int) *EpicGvgAttackTeamsQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *EpicGvgAttackTeamsQuery) Offset(offset int) *EpicGvgAttackTeamsQuery { + _q.ctx.Offset = &offset + return _q +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (_q *EpicGvgAttackTeamsQuery) Unique(unique bool) *EpicGvgAttackTeamsQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *EpicGvgAttackTeamsQuery) Order(o ...epicgvgattackteams.OrderOption) *EpicGvgAttackTeamsQuery { + _q.order = append(_q.order, o...) + return _q +} + +// First returns the first EpicGvgAttackTeams entity from the query. +// Returns a *NotFoundError when no EpicGvgAttackTeams was found. +func (_q *EpicGvgAttackTeamsQuery) First(ctx context.Context) (*EpicGvgAttackTeams, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{epicgvgattackteams.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *EpicGvgAttackTeamsQuery) FirstX(ctx context.Context) *EpicGvgAttackTeams { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first EpicGvgAttackTeams ID from the query. +// Returns a *NotFoundError when no EpicGvgAttackTeams ID was found. +func (_q *EpicGvgAttackTeamsQuery) FirstID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{epicgvgattackteams.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *EpicGvgAttackTeamsQuery) FirstIDX(ctx context.Context) int64 { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single EpicGvgAttackTeams entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one EpicGvgAttackTeams entity is found. +// Returns a *NotFoundError when no EpicGvgAttackTeams entities are found. +func (_q *EpicGvgAttackTeamsQuery) Only(ctx context.Context) (*EpicGvgAttackTeams, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{epicgvgattackteams.Label} + default: + return nil, &NotSingularError{epicgvgattackteams.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *EpicGvgAttackTeamsQuery) OnlyX(ctx context.Context) *EpicGvgAttackTeams { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only EpicGvgAttackTeams ID in the query. +// Returns a *NotSingularError when more than one EpicGvgAttackTeams ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *EpicGvgAttackTeamsQuery) OnlyID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{epicgvgattackteams.Label} + default: + err = &NotSingularError{epicgvgattackteams.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *EpicGvgAttackTeamsQuery) OnlyIDX(ctx context.Context) int64 { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of EpicGvgAttackTeamsSlice. +func (_q *EpicGvgAttackTeamsQuery) All(ctx context.Context) ([]*EpicGvgAttackTeams, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*EpicGvgAttackTeams, *EpicGvgAttackTeamsQuery]() + return withInterceptors[[]*EpicGvgAttackTeams](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *EpicGvgAttackTeamsQuery) AllX(ctx context.Context) []*EpicGvgAttackTeams { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of EpicGvgAttackTeams IDs. +func (_q *EpicGvgAttackTeamsQuery) IDs(ctx context.Context) (ids []int64, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(epicgvgattackteams.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *EpicGvgAttackTeamsQuery) IDsX(ctx context.Context) []int64 { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *EpicGvgAttackTeamsQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, _q, querierCount[*EpicGvgAttackTeamsQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *EpicGvgAttackTeamsQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (_q *EpicGvgAttackTeamsQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *EpicGvgAttackTeamsQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the EpicGvgAttackTeamsQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (_q *EpicGvgAttackTeamsQuery) Clone() *EpicGvgAttackTeamsQuery { + if _q == nil { + return nil + } + return &EpicGvgAttackTeamsQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]epicgvgattackteams.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.EpicGvgAttackTeams{}, _q.predicates...), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + } +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// AttackHeroes string `json:"attack_heroes,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.EpicGvgAttackTeams.Query(). +// GroupBy(epicgvgattackteams.FieldAttackHeroes). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *EpicGvgAttackTeamsQuery) GroupBy(field string, fields ...string) *EpicGvgAttackTeamsGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &EpicGvgAttackTeamsGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = epicgvgattackteams.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// AttackHeroes string `json:"attack_heroes,omitempty"` +// } +// +// client.EpicGvgAttackTeams.Query(). +// Select(epicgvgattackteams.FieldAttackHeroes). +// Scan(ctx, &v) +func (_q *EpicGvgAttackTeamsQuery) Select(fields ...string) *EpicGvgAttackTeamsSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &EpicGvgAttackTeamsSelect{EpicGvgAttackTeamsQuery: _q} + sbuild.label = epicgvgattackteams.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a EpicGvgAttackTeamsSelect configured with the given aggregations. +func (_q *EpicGvgAttackTeamsQuery) Aggregate(fns ...AggregateFunc) *EpicGvgAttackTeamsSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *EpicGvgAttackTeamsQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !epicgvgattackteams.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if _q.path != nil { + prev, err := _q.path(ctx) + if err != nil { + return err + } + _q.sql = prev + } + return nil +} + +func (_q *EpicGvgAttackTeamsQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*EpicGvgAttackTeams, error) { + var ( + nodes = []*EpicGvgAttackTeams{} + _spec = _q.querySpec() + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*EpicGvgAttackTeams).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &EpicGvgAttackTeams{config: _q.config} + nodes = append(nodes, node) + return node.assignValues(columns, values) + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + return nodes, nil +} + +func (_q *EpicGvgAttackTeamsQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique + } + return sqlgraph.CountNodes(ctx, _q.driver, _spec) +} + +func (_q *EpicGvgAttackTeamsQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(epicgvgattackteams.Table, epicgvgattackteams.Columns, sqlgraph.NewFieldSpec(epicgvgattackteams.FieldID, field.TypeInt64)) + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if _q.path != nil { + _spec.Unique = true + } + if fields := _q.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, epicgvgattackteams.FieldID) + for i := range fields { + if fields[i] != epicgvgattackteams.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := _q.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := _q.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := _q.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := _q.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (_q *EpicGvgAttackTeamsQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(epicgvgattackteams.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = epicgvgattackteams.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if _q.sql != nil { + selector = _q.sql + selector.Select(selector.Columns(columns...)...) + } + if _q.ctx.Unique != nil && *_q.ctx.Unique { + selector.Distinct() + } + for _, p := range _q.predicates { + p(selector) + } + for _, p := range _q.order { + p(selector) + } + if offset := _q.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := _q.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// EpicGvgAttackTeamsGroupBy is the group-by builder for EpicGvgAttackTeams entities. +type EpicGvgAttackTeamsGroupBy struct { + selector + build *EpicGvgAttackTeamsQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *EpicGvgAttackTeamsGroupBy) Aggregate(fns ...AggregateFunc) *EpicGvgAttackTeamsGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *EpicGvgAttackTeamsGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*EpicGvgAttackTeamsQuery, *EpicGvgAttackTeamsGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *EpicGvgAttackTeamsGroupBy) sqlScan(ctx context.Context, root *EpicGvgAttackTeamsQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*_g.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// EpicGvgAttackTeamsSelect is the builder for selecting fields of EpicGvgAttackTeams entities. +type EpicGvgAttackTeamsSelect struct { + *EpicGvgAttackTeamsQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *EpicGvgAttackTeamsSelect) Aggregate(fns ...AggregateFunc) *EpicGvgAttackTeamsSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *EpicGvgAttackTeamsSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*EpicGvgAttackTeamsQuery, *EpicGvgAttackTeamsSelect](ctx, _s.EpicGvgAttackTeamsQuery, _s, _s.inters, v) +} + +func (_s *EpicGvgAttackTeamsSelect) sqlScan(ctx context.Context, root *EpicGvgAttackTeamsQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/internal/ent/epicgvgattackteams_update.go b/internal/ent/epicgvgattackteams_update.go new file mode 100644 index 0000000..7ceaff2 --- /dev/null +++ b/internal/ent/epicgvgattackteams_update.go @@ -0,0 +1,462 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "epic-ent/internal/ent/epicgvgattackteams" + "epic-ent/internal/ent/predicate" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// EpicGvgAttackTeamsUpdate is the builder for updating EpicGvgAttackTeams entities. +type EpicGvgAttackTeamsUpdate struct { + config + hooks []Hook + mutation *EpicGvgAttackTeamsMutation +} + +// Where appends a list predicates to the EpicGvgAttackTeamsUpdate builder. +func (_u *EpicGvgAttackTeamsUpdate) Where(ps ...predicate.EpicGvgAttackTeams) *EpicGvgAttackTeamsUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetAttackHeroes sets the "attack_heroes" field. +func (_u *EpicGvgAttackTeamsUpdate) SetAttackHeroes(v string) *EpicGvgAttackTeamsUpdate { + _u.mutation.SetAttackHeroes(v) + return _u +} + +// SetNillableAttackHeroes sets the "attack_heroes" field if the given value is not nil. +func (_u *EpicGvgAttackTeamsUpdate) SetNillableAttackHeroes(v *string) *EpicGvgAttackTeamsUpdate { + if v != nil { + _u.SetAttackHeroes(*v) + } + return _u +} + +// SetCreator sets the "creator" field. +func (_u *EpicGvgAttackTeamsUpdate) SetCreator(v string) *EpicGvgAttackTeamsUpdate { + _u.mutation.SetCreator(v) + return _u +} + +// SetNillableCreator sets the "creator" field if the given value is not nil. +func (_u *EpicGvgAttackTeamsUpdate) SetNillableCreator(v *string) *EpicGvgAttackTeamsUpdate { + if v != nil { + _u.SetCreator(*v) + } + return _u +} + +// SetCreateTime sets the "create_time" field. +func (_u *EpicGvgAttackTeamsUpdate) SetCreateTime(v time.Time) *EpicGvgAttackTeamsUpdate { + _u.mutation.SetCreateTime(v) + return _u +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (_u *EpicGvgAttackTeamsUpdate) SetNillableCreateTime(v *time.Time) *EpicGvgAttackTeamsUpdate { + if v != nil { + _u.SetCreateTime(*v) + } + return _u +} + +// ClearCreateTime clears the value of the "create_time" field. +func (_u *EpicGvgAttackTeamsUpdate) ClearCreateTime() *EpicGvgAttackTeamsUpdate { + _u.mutation.ClearCreateTime() + return _u +} + +// SetUpdater sets the "updater" field. +func (_u *EpicGvgAttackTeamsUpdate) SetUpdater(v string) *EpicGvgAttackTeamsUpdate { + _u.mutation.SetUpdater(v) + return _u +} + +// SetNillableUpdater sets the "updater" field if the given value is not nil. +func (_u *EpicGvgAttackTeamsUpdate) SetNillableUpdater(v *string) *EpicGvgAttackTeamsUpdate { + if v != nil { + _u.SetUpdater(*v) + } + return _u +} + +// SetUpdateTime sets the "update_time" field. +func (_u *EpicGvgAttackTeamsUpdate) SetUpdateTime(v time.Time) *EpicGvgAttackTeamsUpdate { + _u.mutation.SetUpdateTime(v) + return _u +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (_u *EpicGvgAttackTeamsUpdate) SetNillableUpdateTime(v *time.Time) *EpicGvgAttackTeamsUpdate { + if v != nil { + _u.SetUpdateTime(*v) + } + return _u +} + +// ClearUpdateTime clears the value of the "update_time" field. +func (_u *EpicGvgAttackTeamsUpdate) ClearUpdateTime() *EpicGvgAttackTeamsUpdate { + _u.mutation.ClearUpdateTime() + return _u +} + +// SetDeleted sets the "deleted" field. +func (_u *EpicGvgAttackTeamsUpdate) SetDeleted(v bool) *EpicGvgAttackTeamsUpdate { + _u.mutation.SetDeleted(v) + return _u +} + +// SetNillableDeleted sets the "deleted" field if the given value is not nil. +func (_u *EpicGvgAttackTeamsUpdate) SetNillableDeleted(v *bool) *EpicGvgAttackTeamsUpdate { + if v != nil { + _u.SetDeleted(*v) + } + return _u +} + +// Mutation returns the EpicGvgAttackTeamsMutation object of the builder. +func (_u *EpicGvgAttackTeamsUpdate) Mutation() *EpicGvgAttackTeamsMutation { + return _u.mutation +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *EpicGvgAttackTeamsUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *EpicGvgAttackTeamsUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *EpicGvgAttackTeamsUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *EpicGvgAttackTeamsUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *EpicGvgAttackTeamsUpdate) check() error { + if v, ok := _u.mutation.AttackHeroes(); ok { + if err := epicgvgattackteams.AttackHeroesValidator(v); err != nil { + return &ValidationError{Name: "attack_heroes", err: fmt.Errorf(`ent: validator failed for field "EpicGvgAttackTeams.attack_heroes": %w`, err)} + } + } + if v, ok := _u.mutation.Creator(); ok { + if err := epicgvgattackteams.CreatorValidator(v); err != nil { + return &ValidationError{Name: "creator", err: fmt.Errorf(`ent: validator failed for field "EpicGvgAttackTeams.creator": %w`, err)} + } + } + if v, ok := _u.mutation.Updater(); ok { + if err := epicgvgattackteams.UpdaterValidator(v); err != nil { + return &ValidationError{Name: "updater", err: fmt.Errorf(`ent: validator failed for field "EpicGvgAttackTeams.updater": %w`, err)} + } + } + return nil +} + +func (_u *EpicGvgAttackTeamsUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(epicgvgattackteams.Table, epicgvgattackteams.Columns, sqlgraph.NewFieldSpec(epicgvgattackteams.FieldID, field.TypeInt64)) + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.AttackHeroes(); ok { + _spec.SetField(epicgvgattackteams.FieldAttackHeroes, field.TypeString, value) + } + if value, ok := _u.mutation.Creator(); ok { + _spec.SetField(epicgvgattackteams.FieldCreator, field.TypeString, value) + } + if value, ok := _u.mutation.CreateTime(); ok { + _spec.SetField(epicgvgattackteams.FieldCreateTime, field.TypeTime, value) + } + if _u.mutation.CreateTimeCleared() { + _spec.ClearField(epicgvgattackteams.FieldCreateTime, field.TypeTime) + } + if value, ok := _u.mutation.Updater(); ok { + _spec.SetField(epicgvgattackteams.FieldUpdater, field.TypeString, value) + } + if value, ok := _u.mutation.UpdateTime(); ok { + _spec.SetField(epicgvgattackteams.FieldUpdateTime, field.TypeTime, value) + } + if _u.mutation.UpdateTimeCleared() { + _spec.ClearField(epicgvgattackteams.FieldUpdateTime, field.TypeTime) + } + if value, ok := _u.mutation.Deleted(); ok { + _spec.SetField(epicgvgattackteams.FieldDeleted, field.TypeBool, value) + } + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{epicgvgattackteams.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// EpicGvgAttackTeamsUpdateOne is the builder for updating a single EpicGvgAttackTeams entity. +type EpicGvgAttackTeamsUpdateOne struct { + config + fields []string + hooks []Hook + mutation *EpicGvgAttackTeamsMutation +} + +// SetAttackHeroes sets the "attack_heroes" field. +func (_u *EpicGvgAttackTeamsUpdateOne) SetAttackHeroes(v string) *EpicGvgAttackTeamsUpdateOne { + _u.mutation.SetAttackHeroes(v) + return _u +} + +// SetNillableAttackHeroes sets the "attack_heroes" field if the given value is not nil. +func (_u *EpicGvgAttackTeamsUpdateOne) SetNillableAttackHeroes(v *string) *EpicGvgAttackTeamsUpdateOne { + if v != nil { + _u.SetAttackHeroes(*v) + } + return _u +} + +// SetCreator sets the "creator" field. +func (_u *EpicGvgAttackTeamsUpdateOne) SetCreator(v string) *EpicGvgAttackTeamsUpdateOne { + _u.mutation.SetCreator(v) + return _u +} + +// SetNillableCreator sets the "creator" field if the given value is not nil. +func (_u *EpicGvgAttackTeamsUpdateOne) SetNillableCreator(v *string) *EpicGvgAttackTeamsUpdateOne { + if v != nil { + _u.SetCreator(*v) + } + return _u +} + +// SetCreateTime sets the "create_time" field. +func (_u *EpicGvgAttackTeamsUpdateOne) SetCreateTime(v time.Time) *EpicGvgAttackTeamsUpdateOne { + _u.mutation.SetCreateTime(v) + return _u +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (_u *EpicGvgAttackTeamsUpdateOne) SetNillableCreateTime(v *time.Time) *EpicGvgAttackTeamsUpdateOne { + if v != nil { + _u.SetCreateTime(*v) + } + return _u +} + +// ClearCreateTime clears the value of the "create_time" field. +func (_u *EpicGvgAttackTeamsUpdateOne) ClearCreateTime() *EpicGvgAttackTeamsUpdateOne { + _u.mutation.ClearCreateTime() + return _u +} + +// SetUpdater sets the "updater" field. +func (_u *EpicGvgAttackTeamsUpdateOne) SetUpdater(v string) *EpicGvgAttackTeamsUpdateOne { + _u.mutation.SetUpdater(v) + return _u +} + +// SetNillableUpdater sets the "updater" field if the given value is not nil. +func (_u *EpicGvgAttackTeamsUpdateOne) SetNillableUpdater(v *string) *EpicGvgAttackTeamsUpdateOne { + if v != nil { + _u.SetUpdater(*v) + } + return _u +} + +// SetUpdateTime sets the "update_time" field. +func (_u *EpicGvgAttackTeamsUpdateOne) SetUpdateTime(v time.Time) *EpicGvgAttackTeamsUpdateOne { + _u.mutation.SetUpdateTime(v) + return _u +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (_u *EpicGvgAttackTeamsUpdateOne) SetNillableUpdateTime(v *time.Time) *EpicGvgAttackTeamsUpdateOne { + if v != nil { + _u.SetUpdateTime(*v) + } + return _u +} + +// ClearUpdateTime clears the value of the "update_time" field. +func (_u *EpicGvgAttackTeamsUpdateOne) ClearUpdateTime() *EpicGvgAttackTeamsUpdateOne { + _u.mutation.ClearUpdateTime() + return _u +} + +// SetDeleted sets the "deleted" field. +func (_u *EpicGvgAttackTeamsUpdateOne) SetDeleted(v bool) *EpicGvgAttackTeamsUpdateOne { + _u.mutation.SetDeleted(v) + return _u +} + +// SetNillableDeleted sets the "deleted" field if the given value is not nil. +func (_u *EpicGvgAttackTeamsUpdateOne) SetNillableDeleted(v *bool) *EpicGvgAttackTeamsUpdateOne { + if v != nil { + _u.SetDeleted(*v) + } + return _u +} + +// Mutation returns the EpicGvgAttackTeamsMutation object of the builder. +func (_u *EpicGvgAttackTeamsUpdateOne) Mutation() *EpicGvgAttackTeamsMutation { + return _u.mutation +} + +// Where appends a list predicates to the EpicGvgAttackTeamsUpdate builder. +func (_u *EpicGvgAttackTeamsUpdateOne) Where(ps ...predicate.EpicGvgAttackTeams) *EpicGvgAttackTeamsUpdateOne { + _u.mutation.Where(ps...) + return _u +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (_u *EpicGvgAttackTeamsUpdateOne) Select(field string, fields ...string) *EpicGvgAttackTeamsUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated EpicGvgAttackTeams entity. +func (_u *EpicGvgAttackTeamsUpdateOne) Save(ctx context.Context) (*EpicGvgAttackTeams, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *EpicGvgAttackTeamsUpdateOne) SaveX(ctx context.Context) *EpicGvgAttackTeams { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *EpicGvgAttackTeamsUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *EpicGvgAttackTeamsUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *EpicGvgAttackTeamsUpdateOne) check() error { + if v, ok := _u.mutation.AttackHeroes(); ok { + if err := epicgvgattackteams.AttackHeroesValidator(v); err != nil { + return &ValidationError{Name: "attack_heroes", err: fmt.Errorf(`ent: validator failed for field "EpicGvgAttackTeams.attack_heroes": %w`, err)} + } + } + if v, ok := _u.mutation.Creator(); ok { + if err := epicgvgattackteams.CreatorValidator(v); err != nil { + return &ValidationError{Name: "creator", err: fmt.Errorf(`ent: validator failed for field "EpicGvgAttackTeams.creator": %w`, err)} + } + } + if v, ok := _u.mutation.Updater(); ok { + if err := epicgvgattackteams.UpdaterValidator(v); err != nil { + return &ValidationError{Name: "updater", err: fmt.Errorf(`ent: validator failed for field "EpicGvgAttackTeams.updater": %w`, err)} + } + } + return nil +} + +func (_u *EpicGvgAttackTeamsUpdateOne) sqlSave(ctx context.Context) (_node *EpicGvgAttackTeams, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(epicgvgattackteams.Table, epicgvgattackteams.Columns, sqlgraph.NewFieldSpec(epicgvgattackteams.FieldID, field.TypeInt64)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "EpicGvgAttackTeams.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := _u.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, epicgvgattackteams.FieldID) + for _, f := range fields { + if !epicgvgattackteams.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != epicgvgattackteams.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.AttackHeroes(); ok { + _spec.SetField(epicgvgattackteams.FieldAttackHeroes, field.TypeString, value) + } + if value, ok := _u.mutation.Creator(); ok { + _spec.SetField(epicgvgattackteams.FieldCreator, field.TypeString, value) + } + if value, ok := _u.mutation.CreateTime(); ok { + _spec.SetField(epicgvgattackteams.FieldCreateTime, field.TypeTime, value) + } + if _u.mutation.CreateTimeCleared() { + _spec.ClearField(epicgvgattackteams.FieldCreateTime, field.TypeTime) + } + if value, ok := _u.mutation.Updater(); ok { + _spec.SetField(epicgvgattackteams.FieldUpdater, field.TypeString, value) + } + if value, ok := _u.mutation.UpdateTime(); ok { + _spec.SetField(epicgvgattackteams.FieldUpdateTime, field.TypeTime, value) + } + if _u.mutation.UpdateTimeCleared() { + _spec.ClearField(epicgvgattackteams.FieldUpdateTime, field.TypeTime) + } + if value, ok := _u.mutation.Deleted(); ok { + _spec.SetField(epicgvgattackteams.FieldDeleted, field.TypeBool, value) + } + _node = &EpicGvgAttackTeams{config: _u.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{epicgvgattackteams.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} diff --git a/internal/ent/epicgvgdefenseattackmapping.go b/internal/ent/epicgvgdefenseattackmapping.go new file mode 100644 index 0000000..b3b2914 --- /dev/null +++ b/internal/ent/epicgvgdefenseattackmapping.go @@ -0,0 +1,235 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "epic-ent/internal/ent/epicgvgdefenseattackmapping" + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// EpicGvgDefenseAttackMapping is the model entity for the EpicGvgDefenseAttackMapping schema. +type EpicGvgDefenseAttackMapping struct { + config `json:"-"` + // ID of the ent. + ID int64 `json:"id,omitempty"` + // DefenseID holds the value of the "defense_id" field. + DefenseID int64 `json:"defense_id,omitempty"` + // AttackID holds the value of the "attack_id" field. + AttackID int64 `json:"attack_id,omitempty"` + // EquipmentInfo holds the value of the "equipment_info" field. + EquipmentInfo string `json:"equipment_info,omitempty"` + // Artifacts holds the value of the "artifacts" field. + Artifacts string `json:"artifacts,omitempty"` + // BattleStrategy holds the value of the "battle_strategy" field. + BattleStrategy string `json:"battle_strategy,omitempty"` + // Prerequisites holds the value of the "prerequisites" field. + Prerequisites string `json:"prerequisites,omitempty"` + // ImportantNotes holds the value of the "important_notes" field. + ImportantNotes string `json:"important_notes,omitempty"` + // Creator holds the value of the "creator" field. + Creator string `json:"creator,omitempty"` + // CreateTime holds the value of the "create_time" field. + CreateTime *time.Time `json:"create_time,omitempty"` + // Updater holds the value of the "updater" field. + Updater string `json:"updater,omitempty"` + // UpdateTime holds the value of the "update_time" field. + UpdateTime *time.Time `json:"update_time,omitempty"` + // Deleted holds the value of the "deleted" field. + Deleted bool `json:"deleted,omitempty"` + selectValues sql.SelectValues +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*EpicGvgDefenseAttackMapping) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case epicgvgdefenseattackmapping.FieldDeleted: + values[i] = new(sql.NullBool) + case epicgvgdefenseattackmapping.FieldID, epicgvgdefenseattackmapping.FieldDefenseID, epicgvgdefenseattackmapping.FieldAttackID: + values[i] = new(sql.NullInt64) + case epicgvgdefenseattackmapping.FieldEquipmentInfo, epicgvgdefenseattackmapping.FieldArtifacts, epicgvgdefenseattackmapping.FieldBattleStrategy, epicgvgdefenseattackmapping.FieldPrerequisites, epicgvgdefenseattackmapping.FieldImportantNotes, epicgvgdefenseattackmapping.FieldCreator, epicgvgdefenseattackmapping.FieldUpdater: + values[i] = new(sql.NullString) + case epicgvgdefenseattackmapping.FieldCreateTime, epicgvgdefenseattackmapping.FieldUpdateTime: + values[i] = new(sql.NullTime) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the EpicGvgDefenseAttackMapping fields. +func (_m *EpicGvgDefenseAttackMapping) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case epicgvgdefenseattackmapping.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + _m.ID = int64(value.Int64) + case epicgvgdefenseattackmapping.FieldDefenseID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field defense_id", values[i]) + } else if value.Valid { + _m.DefenseID = value.Int64 + } + case epicgvgdefenseattackmapping.FieldAttackID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field attack_id", values[i]) + } else if value.Valid { + _m.AttackID = value.Int64 + } + case epicgvgdefenseattackmapping.FieldEquipmentInfo: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field equipment_info", values[i]) + } else if value.Valid { + _m.EquipmentInfo = value.String + } + case epicgvgdefenseattackmapping.FieldArtifacts: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field artifacts", values[i]) + } else if value.Valid { + _m.Artifacts = value.String + } + case epicgvgdefenseattackmapping.FieldBattleStrategy: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field battle_strategy", values[i]) + } else if value.Valid { + _m.BattleStrategy = value.String + } + case epicgvgdefenseattackmapping.FieldPrerequisites: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field prerequisites", values[i]) + } else if value.Valid { + _m.Prerequisites = value.String + } + case epicgvgdefenseattackmapping.FieldImportantNotes: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field important_notes", values[i]) + } else if value.Valid { + _m.ImportantNotes = value.String + } + case epicgvgdefenseattackmapping.FieldCreator: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field creator", values[i]) + } else if value.Valid { + _m.Creator = value.String + } + case epicgvgdefenseattackmapping.FieldCreateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field create_time", values[i]) + } else if value.Valid { + _m.CreateTime = new(time.Time) + *_m.CreateTime = value.Time + } + case epicgvgdefenseattackmapping.FieldUpdater: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field updater", values[i]) + } else if value.Valid { + _m.Updater = value.String + } + case epicgvgdefenseattackmapping.FieldUpdateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field update_time", values[i]) + } else if value.Valid { + _m.UpdateTime = new(time.Time) + *_m.UpdateTime = value.Time + } + case epicgvgdefenseattackmapping.FieldDeleted: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field deleted", values[i]) + } else if value.Valid { + _m.Deleted = value.Bool + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the EpicGvgDefenseAttackMapping. +// This includes values selected through modifiers, order, etc. +func (_m *EpicGvgDefenseAttackMapping) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// Update returns a builder for updating this EpicGvgDefenseAttackMapping. +// Note that you need to call EpicGvgDefenseAttackMapping.Unwrap() before calling this method if this EpicGvgDefenseAttackMapping +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *EpicGvgDefenseAttackMapping) Update() *EpicGvgDefenseAttackMappingUpdateOne { + return NewEpicGvgDefenseAttackMappingClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the EpicGvgDefenseAttackMapping entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (_m *EpicGvgDefenseAttackMapping) Unwrap() *EpicGvgDefenseAttackMapping { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("ent: EpicGvgDefenseAttackMapping is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *EpicGvgDefenseAttackMapping) String() string { + var builder strings.Builder + builder.WriteString("EpicGvgDefenseAttackMapping(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("defense_id=") + builder.WriteString(fmt.Sprintf("%v", _m.DefenseID)) + builder.WriteString(", ") + builder.WriteString("attack_id=") + builder.WriteString(fmt.Sprintf("%v", _m.AttackID)) + builder.WriteString(", ") + builder.WriteString("equipment_info=") + builder.WriteString(_m.EquipmentInfo) + builder.WriteString(", ") + builder.WriteString("artifacts=") + builder.WriteString(_m.Artifacts) + builder.WriteString(", ") + builder.WriteString("battle_strategy=") + builder.WriteString(_m.BattleStrategy) + builder.WriteString(", ") + builder.WriteString("prerequisites=") + builder.WriteString(_m.Prerequisites) + builder.WriteString(", ") + builder.WriteString("important_notes=") + builder.WriteString(_m.ImportantNotes) + builder.WriteString(", ") + builder.WriteString("creator=") + builder.WriteString(_m.Creator) + builder.WriteString(", ") + if v := _m.CreateTime; v != nil { + builder.WriteString("create_time=") + builder.WriteString(v.Format(time.ANSIC)) + } + builder.WriteString(", ") + builder.WriteString("updater=") + builder.WriteString(_m.Updater) + builder.WriteString(", ") + if v := _m.UpdateTime; v != nil { + builder.WriteString("update_time=") + builder.WriteString(v.Format(time.ANSIC)) + } + builder.WriteString(", ") + builder.WriteString("deleted=") + builder.WriteString(fmt.Sprintf("%v", _m.Deleted)) + builder.WriteByte(')') + return builder.String() +} + +// EpicGvgDefenseAttackMappings is a parsable slice of EpicGvgDefenseAttackMapping. +type EpicGvgDefenseAttackMappings []*EpicGvgDefenseAttackMapping diff --git a/internal/ent/epicgvgdefenseattackmapping/epicgvgdefenseattackmapping.go b/internal/ent/epicgvgdefenseattackmapping/epicgvgdefenseattackmapping.go new file mode 100644 index 0000000..36edde6 --- /dev/null +++ b/internal/ent/epicgvgdefenseattackmapping/epicgvgdefenseattackmapping.go @@ -0,0 +1,152 @@ +// Code generated by ent, DO NOT EDIT. + +package epicgvgdefenseattackmapping + +import ( + "entgo.io/ent/dialect/sql" +) + +const ( + // Label holds the string label denoting the epicgvgdefenseattackmapping type in the database. + Label = "epic_gvg_defense_attack_mapping" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldDefenseID holds the string denoting the defense_id field in the database. + FieldDefenseID = "defense_id" + // FieldAttackID holds the string denoting the attack_id field in the database. + FieldAttackID = "attack_id" + // FieldEquipmentInfo holds the string denoting the equipment_info field in the database. + FieldEquipmentInfo = "equipment_info" + // FieldArtifacts holds the string denoting the artifacts field in the database. + FieldArtifacts = "artifacts" + // FieldBattleStrategy holds the string denoting the battle_strategy field in the database. + FieldBattleStrategy = "battle_strategy" + // FieldPrerequisites holds the string denoting the prerequisites field in the database. + FieldPrerequisites = "prerequisites" + // FieldImportantNotes holds the string denoting the important_notes field in the database. + FieldImportantNotes = "important_notes" + // FieldCreator holds the string denoting the creator field in the database. + FieldCreator = "creator" + // FieldCreateTime holds the string denoting the create_time field in the database. + FieldCreateTime = "create_time" + // FieldUpdater holds the string denoting the updater field in the database. + FieldUpdater = "updater" + // FieldUpdateTime holds the string denoting the update_time field in the database. + FieldUpdateTime = "update_time" + // FieldDeleted holds the string denoting the deleted field in the database. + FieldDeleted = "deleted" + // Table holds the table name of the epicgvgdefenseattackmapping in the database. + Table = "epic_gvg_defense_attack_mappings" +) + +// Columns holds all SQL columns for epicgvgdefenseattackmapping fields. +var Columns = []string{ + FieldID, + FieldDefenseID, + FieldAttackID, + FieldEquipmentInfo, + FieldArtifacts, + FieldBattleStrategy, + FieldPrerequisites, + FieldImportantNotes, + FieldCreator, + FieldCreateTime, + FieldUpdater, + FieldUpdateTime, + FieldDeleted, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // EquipmentInfoValidator is a validator for the "equipment_info" field. It is called by the builders before save. + EquipmentInfoValidator func(string) error + // ArtifactsValidator is a validator for the "artifacts" field. It is called by the builders before save. + ArtifactsValidator func(string) error + // BattleStrategyValidator is a validator for the "battle_strategy" field. It is called by the builders before save. + BattleStrategyValidator func(string) error + // PrerequisitesValidator is a validator for the "prerequisites" field. It is called by the builders before save. + PrerequisitesValidator func(string) error + // ImportantNotesValidator is a validator for the "important_notes" field. It is called by the builders before save. + ImportantNotesValidator func(string) error + // CreatorValidator is a validator for the "creator" field. It is called by the builders before save. + CreatorValidator func(string) error + // UpdaterValidator is a validator for the "updater" field. It is called by the builders before save. + UpdaterValidator func(string) error +) + +// OrderOption defines the ordering options for the EpicGvgDefenseAttackMapping queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByDefenseID orders the results by the defense_id field. +func ByDefenseID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDefenseID, opts...).ToFunc() +} + +// ByAttackID orders the results by the attack_id field. +func ByAttackID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldAttackID, opts...).ToFunc() +} + +// ByEquipmentInfo orders the results by the equipment_info field. +func ByEquipmentInfo(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldEquipmentInfo, opts...).ToFunc() +} + +// ByArtifacts orders the results by the artifacts field. +func ByArtifacts(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldArtifacts, opts...).ToFunc() +} + +// ByBattleStrategy orders the results by the battle_strategy field. +func ByBattleStrategy(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldBattleStrategy, opts...).ToFunc() +} + +// ByPrerequisites orders the results by the prerequisites field. +func ByPrerequisites(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPrerequisites, opts...).ToFunc() +} + +// ByImportantNotes orders the results by the important_notes field. +func ByImportantNotes(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldImportantNotes, opts...).ToFunc() +} + +// ByCreator orders the results by the creator field. +func ByCreator(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreator, opts...).ToFunc() +} + +// ByCreateTime orders the results by the create_time field. +func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateTime, opts...).ToFunc() +} + +// ByUpdater orders the results by the updater field. +func ByUpdater(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdater, opts...).ToFunc() +} + +// ByUpdateTime orders the results by the update_time field. +func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() +} + +// ByDeleted orders the results by the deleted field. +func ByDeleted(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeleted, opts...).ToFunc() +} diff --git a/internal/ent/epicgvgdefenseattackmapping/where.go b/internal/ent/epicgvgdefenseattackmapping/where.go new file mode 100644 index 0000000..74cbf8f --- /dev/null +++ b/internal/ent/epicgvgdefenseattackmapping/where.go @@ -0,0 +1,775 @@ +// Code generated by ent, DO NOT EDIT. + +package epicgvgdefenseattackmapping + +import ( + "epic-ent/internal/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" +) + +// ID filters vertices based on their ID field. +func ID(id int64) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int64) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int64) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int64) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int64) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int64) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int64) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int64) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int64) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldLTE(FieldID, id)) +} + +// DefenseID applies equality check predicate on the "defense_id" field. It's identical to DefenseIDEQ. +func DefenseID(v int64) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldEQ(FieldDefenseID, v)) +} + +// AttackID applies equality check predicate on the "attack_id" field. It's identical to AttackIDEQ. +func AttackID(v int64) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldEQ(FieldAttackID, v)) +} + +// EquipmentInfo applies equality check predicate on the "equipment_info" field. It's identical to EquipmentInfoEQ. +func EquipmentInfo(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldEQ(FieldEquipmentInfo, v)) +} + +// Artifacts applies equality check predicate on the "artifacts" field. It's identical to ArtifactsEQ. +func Artifacts(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldEQ(FieldArtifacts, v)) +} + +// BattleStrategy applies equality check predicate on the "battle_strategy" field. It's identical to BattleStrategyEQ. +func BattleStrategy(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldEQ(FieldBattleStrategy, v)) +} + +// Prerequisites applies equality check predicate on the "prerequisites" field. It's identical to PrerequisitesEQ. +func Prerequisites(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldEQ(FieldPrerequisites, v)) +} + +// ImportantNotes applies equality check predicate on the "important_notes" field. It's identical to ImportantNotesEQ. +func ImportantNotes(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldEQ(FieldImportantNotes, v)) +} + +// Creator applies equality check predicate on the "creator" field. It's identical to CreatorEQ. +func Creator(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldEQ(FieldCreator, v)) +} + +// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. +func CreateTime(v time.Time) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldEQ(FieldCreateTime, v)) +} + +// Updater applies equality check predicate on the "updater" field. It's identical to UpdaterEQ. +func Updater(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldEQ(FieldUpdater, v)) +} + +// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. +func UpdateTime(v time.Time) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldEQ(FieldUpdateTime, v)) +} + +// Deleted applies equality check predicate on the "deleted" field. It's identical to DeletedEQ. +func Deleted(v bool) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldEQ(FieldDeleted, v)) +} + +// DefenseIDEQ applies the EQ predicate on the "defense_id" field. +func DefenseIDEQ(v int64) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldEQ(FieldDefenseID, v)) +} + +// DefenseIDNEQ applies the NEQ predicate on the "defense_id" field. +func DefenseIDNEQ(v int64) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldNEQ(FieldDefenseID, v)) +} + +// DefenseIDIn applies the In predicate on the "defense_id" field. +func DefenseIDIn(vs ...int64) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldIn(FieldDefenseID, vs...)) +} + +// DefenseIDNotIn applies the NotIn predicate on the "defense_id" field. +func DefenseIDNotIn(vs ...int64) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldNotIn(FieldDefenseID, vs...)) +} + +// DefenseIDGT applies the GT predicate on the "defense_id" field. +func DefenseIDGT(v int64) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldGT(FieldDefenseID, v)) +} + +// DefenseIDGTE applies the GTE predicate on the "defense_id" field. +func DefenseIDGTE(v int64) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldGTE(FieldDefenseID, v)) +} + +// DefenseIDLT applies the LT predicate on the "defense_id" field. +func DefenseIDLT(v int64) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldLT(FieldDefenseID, v)) +} + +// DefenseIDLTE applies the LTE predicate on the "defense_id" field. +func DefenseIDLTE(v int64) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldLTE(FieldDefenseID, v)) +} + +// AttackIDEQ applies the EQ predicate on the "attack_id" field. +func AttackIDEQ(v int64) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldEQ(FieldAttackID, v)) +} + +// AttackIDNEQ applies the NEQ predicate on the "attack_id" field. +func AttackIDNEQ(v int64) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldNEQ(FieldAttackID, v)) +} + +// AttackIDIn applies the In predicate on the "attack_id" field. +func AttackIDIn(vs ...int64) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldIn(FieldAttackID, vs...)) +} + +// AttackIDNotIn applies the NotIn predicate on the "attack_id" field. +func AttackIDNotIn(vs ...int64) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldNotIn(FieldAttackID, vs...)) +} + +// AttackIDGT applies the GT predicate on the "attack_id" field. +func AttackIDGT(v int64) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldGT(FieldAttackID, v)) +} + +// AttackIDGTE applies the GTE predicate on the "attack_id" field. +func AttackIDGTE(v int64) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldGTE(FieldAttackID, v)) +} + +// AttackIDLT applies the LT predicate on the "attack_id" field. +func AttackIDLT(v int64) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldLT(FieldAttackID, v)) +} + +// AttackIDLTE applies the LTE predicate on the "attack_id" field. +func AttackIDLTE(v int64) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldLTE(FieldAttackID, v)) +} + +// EquipmentInfoEQ applies the EQ predicate on the "equipment_info" field. +func EquipmentInfoEQ(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldEQ(FieldEquipmentInfo, v)) +} + +// EquipmentInfoNEQ applies the NEQ predicate on the "equipment_info" field. +func EquipmentInfoNEQ(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldNEQ(FieldEquipmentInfo, v)) +} + +// EquipmentInfoIn applies the In predicate on the "equipment_info" field. +func EquipmentInfoIn(vs ...string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldIn(FieldEquipmentInfo, vs...)) +} + +// EquipmentInfoNotIn applies the NotIn predicate on the "equipment_info" field. +func EquipmentInfoNotIn(vs ...string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldNotIn(FieldEquipmentInfo, vs...)) +} + +// EquipmentInfoGT applies the GT predicate on the "equipment_info" field. +func EquipmentInfoGT(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldGT(FieldEquipmentInfo, v)) +} + +// EquipmentInfoGTE applies the GTE predicate on the "equipment_info" field. +func EquipmentInfoGTE(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldGTE(FieldEquipmentInfo, v)) +} + +// EquipmentInfoLT applies the LT predicate on the "equipment_info" field. +func EquipmentInfoLT(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldLT(FieldEquipmentInfo, v)) +} + +// EquipmentInfoLTE applies the LTE predicate on the "equipment_info" field. +func EquipmentInfoLTE(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldLTE(FieldEquipmentInfo, v)) +} + +// EquipmentInfoContains applies the Contains predicate on the "equipment_info" field. +func EquipmentInfoContains(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldContains(FieldEquipmentInfo, v)) +} + +// EquipmentInfoHasPrefix applies the HasPrefix predicate on the "equipment_info" field. +func EquipmentInfoHasPrefix(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldHasPrefix(FieldEquipmentInfo, v)) +} + +// EquipmentInfoHasSuffix applies the HasSuffix predicate on the "equipment_info" field. +func EquipmentInfoHasSuffix(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldHasSuffix(FieldEquipmentInfo, v)) +} + +// EquipmentInfoEqualFold applies the EqualFold predicate on the "equipment_info" field. +func EquipmentInfoEqualFold(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldEqualFold(FieldEquipmentInfo, v)) +} + +// EquipmentInfoContainsFold applies the ContainsFold predicate on the "equipment_info" field. +func EquipmentInfoContainsFold(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldContainsFold(FieldEquipmentInfo, v)) +} + +// ArtifactsEQ applies the EQ predicate on the "artifacts" field. +func ArtifactsEQ(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldEQ(FieldArtifacts, v)) +} + +// ArtifactsNEQ applies the NEQ predicate on the "artifacts" field. +func ArtifactsNEQ(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldNEQ(FieldArtifacts, v)) +} + +// ArtifactsIn applies the In predicate on the "artifacts" field. +func ArtifactsIn(vs ...string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldIn(FieldArtifacts, vs...)) +} + +// ArtifactsNotIn applies the NotIn predicate on the "artifacts" field. +func ArtifactsNotIn(vs ...string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldNotIn(FieldArtifacts, vs...)) +} + +// ArtifactsGT applies the GT predicate on the "artifacts" field. +func ArtifactsGT(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldGT(FieldArtifacts, v)) +} + +// ArtifactsGTE applies the GTE predicate on the "artifacts" field. +func ArtifactsGTE(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldGTE(FieldArtifacts, v)) +} + +// ArtifactsLT applies the LT predicate on the "artifacts" field. +func ArtifactsLT(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldLT(FieldArtifacts, v)) +} + +// ArtifactsLTE applies the LTE predicate on the "artifacts" field. +func ArtifactsLTE(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldLTE(FieldArtifacts, v)) +} + +// ArtifactsContains applies the Contains predicate on the "artifacts" field. +func ArtifactsContains(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldContains(FieldArtifacts, v)) +} + +// ArtifactsHasPrefix applies the HasPrefix predicate on the "artifacts" field. +func ArtifactsHasPrefix(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldHasPrefix(FieldArtifacts, v)) +} + +// ArtifactsHasSuffix applies the HasSuffix predicate on the "artifacts" field. +func ArtifactsHasSuffix(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldHasSuffix(FieldArtifacts, v)) +} + +// ArtifactsEqualFold applies the EqualFold predicate on the "artifacts" field. +func ArtifactsEqualFold(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldEqualFold(FieldArtifacts, v)) +} + +// ArtifactsContainsFold applies the ContainsFold predicate on the "artifacts" field. +func ArtifactsContainsFold(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldContainsFold(FieldArtifacts, v)) +} + +// BattleStrategyEQ applies the EQ predicate on the "battle_strategy" field. +func BattleStrategyEQ(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldEQ(FieldBattleStrategy, v)) +} + +// BattleStrategyNEQ applies the NEQ predicate on the "battle_strategy" field. +func BattleStrategyNEQ(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldNEQ(FieldBattleStrategy, v)) +} + +// BattleStrategyIn applies the In predicate on the "battle_strategy" field. +func BattleStrategyIn(vs ...string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldIn(FieldBattleStrategy, vs...)) +} + +// BattleStrategyNotIn applies the NotIn predicate on the "battle_strategy" field. +func BattleStrategyNotIn(vs ...string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldNotIn(FieldBattleStrategy, vs...)) +} + +// BattleStrategyGT applies the GT predicate on the "battle_strategy" field. +func BattleStrategyGT(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldGT(FieldBattleStrategy, v)) +} + +// BattleStrategyGTE applies the GTE predicate on the "battle_strategy" field. +func BattleStrategyGTE(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldGTE(FieldBattleStrategy, v)) +} + +// BattleStrategyLT applies the LT predicate on the "battle_strategy" field. +func BattleStrategyLT(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldLT(FieldBattleStrategy, v)) +} + +// BattleStrategyLTE applies the LTE predicate on the "battle_strategy" field. +func BattleStrategyLTE(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldLTE(FieldBattleStrategy, v)) +} + +// BattleStrategyContains applies the Contains predicate on the "battle_strategy" field. +func BattleStrategyContains(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldContains(FieldBattleStrategy, v)) +} + +// BattleStrategyHasPrefix applies the HasPrefix predicate on the "battle_strategy" field. +func BattleStrategyHasPrefix(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldHasPrefix(FieldBattleStrategy, v)) +} + +// BattleStrategyHasSuffix applies the HasSuffix predicate on the "battle_strategy" field. +func BattleStrategyHasSuffix(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldHasSuffix(FieldBattleStrategy, v)) +} + +// BattleStrategyEqualFold applies the EqualFold predicate on the "battle_strategy" field. +func BattleStrategyEqualFold(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldEqualFold(FieldBattleStrategy, v)) +} + +// BattleStrategyContainsFold applies the ContainsFold predicate on the "battle_strategy" field. +func BattleStrategyContainsFold(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldContainsFold(FieldBattleStrategy, v)) +} + +// PrerequisitesEQ applies the EQ predicate on the "prerequisites" field. +func PrerequisitesEQ(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldEQ(FieldPrerequisites, v)) +} + +// PrerequisitesNEQ applies the NEQ predicate on the "prerequisites" field. +func PrerequisitesNEQ(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldNEQ(FieldPrerequisites, v)) +} + +// PrerequisitesIn applies the In predicate on the "prerequisites" field. +func PrerequisitesIn(vs ...string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldIn(FieldPrerequisites, vs...)) +} + +// PrerequisitesNotIn applies the NotIn predicate on the "prerequisites" field. +func PrerequisitesNotIn(vs ...string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldNotIn(FieldPrerequisites, vs...)) +} + +// PrerequisitesGT applies the GT predicate on the "prerequisites" field. +func PrerequisitesGT(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldGT(FieldPrerequisites, v)) +} + +// PrerequisitesGTE applies the GTE predicate on the "prerequisites" field. +func PrerequisitesGTE(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldGTE(FieldPrerequisites, v)) +} + +// PrerequisitesLT applies the LT predicate on the "prerequisites" field. +func PrerequisitesLT(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldLT(FieldPrerequisites, v)) +} + +// PrerequisitesLTE applies the LTE predicate on the "prerequisites" field. +func PrerequisitesLTE(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldLTE(FieldPrerequisites, v)) +} + +// PrerequisitesContains applies the Contains predicate on the "prerequisites" field. +func PrerequisitesContains(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldContains(FieldPrerequisites, v)) +} + +// PrerequisitesHasPrefix applies the HasPrefix predicate on the "prerequisites" field. +func PrerequisitesHasPrefix(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldHasPrefix(FieldPrerequisites, v)) +} + +// PrerequisitesHasSuffix applies the HasSuffix predicate on the "prerequisites" field. +func PrerequisitesHasSuffix(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldHasSuffix(FieldPrerequisites, v)) +} + +// PrerequisitesEqualFold applies the EqualFold predicate on the "prerequisites" field. +func PrerequisitesEqualFold(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldEqualFold(FieldPrerequisites, v)) +} + +// PrerequisitesContainsFold applies the ContainsFold predicate on the "prerequisites" field. +func PrerequisitesContainsFold(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldContainsFold(FieldPrerequisites, v)) +} + +// ImportantNotesEQ applies the EQ predicate on the "important_notes" field. +func ImportantNotesEQ(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldEQ(FieldImportantNotes, v)) +} + +// ImportantNotesNEQ applies the NEQ predicate on the "important_notes" field. +func ImportantNotesNEQ(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldNEQ(FieldImportantNotes, v)) +} + +// ImportantNotesIn applies the In predicate on the "important_notes" field. +func ImportantNotesIn(vs ...string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldIn(FieldImportantNotes, vs...)) +} + +// ImportantNotesNotIn applies the NotIn predicate on the "important_notes" field. +func ImportantNotesNotIn(vs ...string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldNotIn(FieldImportantNotes, vs...)) +} + +// ImportantNotesGT applies the GT predicate on the "important_notes" field. +func ImportantNotesGT(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldGT(FieldImportantNotes, v)) +} + +// ImportantNotesGTE applies the GTE predicate on the "important_notes" field. +func ImportantNotesGTE(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldGTE(FieldImportantNotes, v)) +} + +// ImportantNotesLT applies the LT predicate on the "important_notes" field. +func ImportantNotesLT(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldLT(FieldImportantNotes, v)) +} + +// ImportantNotesLTE applies the LTE predicate on the "important_notes" field. +func ImportantNotesLTE(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldLTE(FieldImportantNotes, v)) +} + +// ImportantNotesContains applies the Contains predicate on the "important_notes" field. +func ImportantNotesContains(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldContains(FieldImportantNotes, v)) +} + +// ImportantNotesHasPrefix applies the HasPrefix predicate on the "important_notes" field. +func ImportantNotesHasPrefix(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldHasPrefix(FieldImportantNotes, v)) +} + +// ImportantNotesHasSuffix applies the HasSuffix predicate on the "important_notes" field. +func ImportantNotesHasSuffix(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldHasSuffix(FieldImportantNotes, v)) +} + +// ImportantNotesEqualFold applies the EqualFold predicate on the "important_notes" field. +func ImportantNotesEqualFold(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldEqualFold(FieldImportantNotes, v)) +} + +// ImportantNotesContainsFold applies the ContainsFold predicate on the "important_notes" field. +func ImportantNotesContainsFold(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldContainsFold(FieldImportantNotes, v)) +} + +// CreatorEQ applies the EQ predicate on the "creator" field. +func CreatorEQ(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldEQ(FieldCreator, v)) +} + +// CreatorNEQ applies the NEQ predicate on the "creator" field. +func CreatorNEQ(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldNEQ(FieldCreator, v)) +} + +// CreatorIn applies the In predicate on the "creator" field. +func CreatorIn(vs ...string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldIn(FieldCreator, vs...)) +} + +// CreatorNotIn applies the NotIn predicate on the "creator" field. +func CreatorNotIn(vs ...string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldNotIn(FieldCreator, vs...)) +} + +// CreatorGT applies the GT predicate on the "creator" field. +func CreatorGT(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldGT(FieldCreator, v)) +} + +// CreatorGTE applies the GTE predicate on the "creator" field. +func CreatorGTE(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldGTE(FieldCreator, v)) +} + +// CreatorLT applies the LT predicate on the "creator" field. +func CreatorLT(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldLT(FieldCreator, v)) +} + +// CreatorLTE applies the LTE predicate on the "creator" field. +func CreatorLTE(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldLTE(FieldCreator, v)) +} + +// CreatorContains applies the Contains predicate on the "creator" field. +func CreatorContains(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldContains(FieldCreator, v)) +} + +// CreatorHasPrefix applies the HasPrefix predicate on the "creator" field. +func CreatorHasPrefix(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldHasPrefix(FieldCreator, v)) +} + +// CreatorHasSuffix applies the HasSuffix predicate on the "creator" field. +func CreatorHasSuffix(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldHasSuffix(FieldCreator, v)) +} + +// CreatorEqualFold applies the EqualFold predicate on the "creator" field. +func CreatorEqualFold(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldEqualFold(FieldCreator, v)) +} + +// CreatorContainsFold applies the ContainsFold predicate on the "creator" field. +func CreatorContainsFold(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldContainsFold(FieldCreator, v)) +} + +// CreateTimeEQ applies the EQ predicate on the "create_time" field. +func CreateTimeEQ(v time.Time) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldEQ(FieldCreateTime, v)) +} + +// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. +func CreateTimeNEQ(v time.Time) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldNEQ(FieldCreateTime, v)) +} + +// CreateTimeIn applies the In predicate on the "create_time" field. +func CreateTimeIn(vs ...time.Time) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldIn(FieldCreateTime, vs...)) +} + +// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. +func CreateTimeNotIn(vs ...time.Time) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldNotIn(FieldCreateTime, vs...)) +} + +// CreateTimeGT applies the GT predicate on the "create_time" field. +func CreateTimeGT(v time.Time) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldGT(FieldCreateTime, v)) +} + +// CreateTimeGTE applies the GTE predicate on the "create_time" field. +func CreateTimeGTE(v time.Time) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldGTE(FieldCreateTime, v)) +} + +// CreateTimeLT applies the LT predicate on the "create_time" field. +func CreateTimeLT(v time.Time) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldLT(FieldCreateTime, v)) +} + +// CreateTimeLTE applies the LTE predicate on the "create_time" field. +func CreateTimeLTE(v time.Time) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldLTE(FieldCreateTime, v)) +} + +// CreateTimeIsNil applies the IsNil predicate on the "create_time" field. +func CreateTimeIsNil() predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldIsNull(FieldCreateTime)) +} + +// CreateTimeNotNil applies the NotNil predicate on the "create_time" field. +func CreateTimeNotNil() predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldNotNull(FieldCreateTime)) +} + +// UpdaterEQ applies the EQ predicate on the "updater" field. +func UpdaterEQ(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldEQ(FieldUpdater, v)) +} + +// UpdaterNEQ applies the NEQ predicate on the "updater" field. +func UpdaterNEQ(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldNEQ(FieldUpdater, v)) +} + +// UpdaterIn applies the In predicate on the "updater" field. +func UpdaterIn(vs ...string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldIn(FieldUpdater, vs...)) +} + +// UpdaterNotIn applies the NotIn predicate on the "updater" field. +func UpdaterNotIn(vs ...string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldNotIn(FieldUpdater, vs...)) +} + +// UpdaterGT applies the GT predicate on the "updater" field. +func UpdaterGT(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldGT(FieldUpdater, v)) +} + +// UpdaterGTE applies the GTE predicate on the "updater" field. +func UpdaterGTE(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldGTE(FieldUpdater, v)) +} + +// UpdaterLT applies the LT predicate on the "updater" field. +func UpdaterLT(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldLT(FieldUpdater, v)) +} + +// UpdaterLTE applies the LTE predicate on the "updater" field. +func UpdaterLTE(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldLTE(FieldUpdater, v)) +} + +// UpdaterContains applies the Contains predicate on the "updater" field. +func UpdaterContains(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldContains(FieldUpdater, v)) +} + +// UpdaterHasPrefix applies the HasPrefix predicate on the "updater" field. +func UpdaterHasPrefix(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldHasPrefix(FieldUpdater, v)) +} + +// UpdaterHasSuffix applies the HasSuffix predicate on the "updater" field. +func UpdaterHasSuffix(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldHasSuffix(FieldUpdater, v)) +} + +// UpdaterEqualFold applies the EqualFold predicate on the "updater" field. +func UpdaterEqualFold(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldEqualFold(FieldUpdater, v)) +} + +// UpdaterContainsFold applies the ContainsFold predicate on the "updater" field. +func UpdaterContainsFold(v string) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldContainsFold(FieldUpdater, v)) +} + +// UpdateTimeEQ applies the EQ predicate on the "update_time" field. +func UpdateTimeEQ(v time.Time) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldEQ(FieldUpdateTime, v)) +} + +// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. +func UpdateTimeNEQ(v time.Time) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldNEQ(FieldUpdateTime, v)) +} + +// UpdateTimeIn applies the In predicate on the "update_time" field. +func UpdateTimeIn(vs ...time.Time) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. +func UpdateTimeNotIn(vs ...time.Time) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldNotIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeGT applies the GT predicate on the "update_time" field. +func UpdateTimeGT(v time.Time) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldGT(FieldUpdateTime, v)) +} + +// UpdateTimeGTE applies the GTE predicate on the "update_time" field. +func UpdateTimeGTE(v time.Time) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldGTE(FieldUpdateTime, v)) +} + +// UpdateTimeLT applies the LT predicate on the "update_time" field. +func UpdateTimeLT(v time.Time) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldLT(FieldUpdateTime, v)) +} + +// UpdateTimeLTE applies the LTE predicate on the "update_time" field. +func UpdateTimeLTE(v time.Time) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldLTE(FieldUpdateTime, v)) +} + +// UpdateTimeIsNil applies the IsNil predicate on the "update_time" field. +func UpdateTimeIsNil() predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldIsNull(FieldUpdateTime)) +} + +// UpdateTimeNotNil applies the NotNil predicate on the "update_time" field. +func UpdateTimeNotNil() predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldNotNull(FieldUpdateTime)) +} + +// DeletedEQ applies the EQ predicate on the "deleted" field. +func DeletedEQ(v bool) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldEQ(FieldDeleted, v)) +} + +// DeletedNEQ applies the NEQ predicate on the "deleted" field. +func DeletedNEQ(v bool) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.FieldNEQ(FieldDeleted, v)) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.EpicGvgDefenseAttackMapping) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.EpicGvgDefenseAttackMapping) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.EpicGvgDefenseAttackMapping) predicate.EpicGvgDefenseAttackMapping { + return predicate.EpicGvgDefenseAttackMapping(sql.NotPredicates(p)) +} diff --git a/internal/ent/epicgvgdefenseattackmapping_create.go b/internal/ent/epicgvgdefenseattackmapping_create.go new file mode 100644 index 0000000..565b125 --- /dev/null +++ b/internal/ent/epicgvgdefenseattackmapping_create.go @@ -0,0 +1,384 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "epic-ent/internal/ent/epicgvgdefenseattackmapping" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// EpicGvgDefenseAttackMappingCreate is the builder for creating a EpicGvgDefenseAttackMapping entity. +type EpicGvgDefenseAttackMappingCreate struct { + config + mutation *EpicGvgDefenseAttackMappingMutation + hooks []Hook +} + +// SetDefenseID sets the "defense_id" field. +func (_c *EpicGvgDefenseAttackMappingCreate) SetDefenseID(v int64) *EpicGvgDefenseAttackMappingCreate { + _c.mutation.SetDefenseID(v) + return _c +} + +// SetAttackID sets the "attack_id" field. +func (_c *EpicGvgDefenseAttackMappingCreate) SetAttackID(v int64) *EpicGvgDefenseAttackMappingCreate { + _c.mutation.SetAttackID(v) + return _c +} + +// SetEquipmentInfo sets the "equipment_info" field. +func (_c *EpicGvgDefenseAttackMappingCreate) SetEquipmentInfo(v string) *EpicGvgDefenseAttackMappingCreate { + _c.mutation.SetEquipmentInfo(v) + return _c +} + +// SetArtifacts sets the "artifacts" field. +func (_c *EpicGvgDefenseAttackMappingCreate) SetArtifacts(v string) *EpicGvgDefenseAttackMappingCreate { + _c.mutation.SetArtifacts(v) + return _c +} + +// SetBattleStrategy sets the "battle_strategy" field. +func (_c *EpicGvgDefenseAttackMappingCreate) SetBattleStrategy(v string) *EpicGvgDefenseAttackMappingCreate { + _c.mutation.SetBattleStrategy(v) + return _c +} + +// SetPrerequisites sets the "prerequisites" field. +func (_c *EpicGvgDefenseAttackMappingCreate) SetPrerequisites(v string) *EpicGvgDefenseAttackMappingCreate { + _c.mutation.SetPrerequisites(v) + return _c +} + +// SetImportantNotes sets the "important_notes" field. +func (_c *EpicGvgDefenseAttackMappingCreate) SetImportantNotes(v string) *EpicGvgDefenseAttackMappingCreate { + _c.mutation.SetImportantNotes(v) + return _c +} + +// SetCreator sets the "creator" field. +func (_c *EpicGvgDefenseAttackMappingCreate) SetCreator(v string) *EpicGvgDefenseAttackMappingCreate { + _c.mutation.SetCreator(v) + return _c +} + +// SetCreateTime sets the "create_time" field. +func (_c *EpicGvgDefenseAttackMappingCreate) SetCreateTime(v time.Time) *EpicGvgDefenseAttackMappingCreate { + _c.mutation.SetCreateTime(v) + return _c +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (_c *EpicGvgDefenseAttackMappingCreate) SetNillableCreateTime(v *time.Time) *EpicGvgDefenseAttackMappingCreate { + if v != nil { + _c.SetCreateTime(*v) + } + return _c +} + +// SetUpdater sets the "updater" field. +func (_c *EpicGvgDefenseAttackMappingCreate) SetUpdater(v string) *EpicGvgDefenseAttackMappingCreate { + _c.mutation.SetUpdater(v) + return _c +} + +// SetUpdateTime sets the "update_time" field. +func (_c *EpicGvgDefenseAttackMappingCreate) SetUpdateTime(v time.Time) *EpicGvgDefenseAttackMappingCreate { + _c.mutation.SetUpdateTime(v) + return _c +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (_c *EpicGvgDefenseAttackMappingCreate) SetNillableUpdateTime(v *time.Time) *EpicGvgDefenseAttackMappingCreate { + if v != nil { + _c.SetUpdateTime(*v) + } + return _c +} + +// SetDeleted sets the "deleted" field. +func (_c *EpicGvgDefenseAttackMappingCreate) SetDeleted(v bool) *EpicGvgDefenseAttackMappingCreate { + _c.mutation.SetDeleted(v) + return _c +} + +// SetID sets the "id" field. +func (_c *EpicGvgDefenseAttackMappingCreate) SetID(v int64) *EpicGvgDefenseAttackMappingCreate { + _c.mutation.SetID(v) + return _c +} + +// Mutation returns the EpicGvgDefenseAttackMappingMutation object of the builder. +func (_c *EpicGvgDefenseAttackMappingCreate) Mutation() *EpicGvgDefenseAttackMappingMutation { + return _c.mutation +} + +// Save creates the EpicGvgDefenseAttackMapping in the database. +func (_c *EpicGvgDefenseAttackMappingCreate) Save(ctx context.Context) (*EpicGvgDefenseAttackMapping, error) { + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *EpicGvgDefenseAttackMappingCreate) SaveX(ctx context.Context) *EpicGvgDefenseAttackMapping { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *EpicGvgDefenseAttackMappingCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *EpicGvgDefenseAttackMappingCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *EpicGvgDefenseAttackMappingCreate) check() error { + if _, ok := _c.mutation.DefenseID(); !ok { + return &ValidationError{Name: "defense_id", err: errors.New(`ent: missing required field "EpicGvgDefenseAttackMapping.defense_id"`)} + } + if _, ok := _c.mutation.AttackID(); !ok { + return &ValidationError{Name: "attack_id", err: errors.New(`ent: missing required field "EpicGvgDefenseAttackMapping.attack_id"`)} + } + if _, ok := _c.mutation.EquipmentInfo(); !ok { + return &ValidationError{Name: "equipment_info", err: errors.New(`ent: missing required field "EpicGvgDefenseAttackMapping.equipment_info"`)} + } + if v, ok := _c.mutation.EquipmentInfo(); ok { + if err := epicgvgdefenseattackmapping.EquipmentInfoValidator(v); err != nil { + return &ValidationError{Name: "equipment_info", err: fmt.Errorf(`ent: validator failed for field "EpicGvgDefenseAttackMapping.equipment_info": %w`, err)} + } + } + if _, ok := _c.mutation.Artifacts(); !ok { + return &ValidationError{Name: "artifacts", err: errors.New(`ent: missing required field "EpicGvgDefenseAttackMapping.artifacts"`)} + } + if v, ok := _c.mutation.Artifacts(); ok { + if err := epicgvgdefenseattackmapping.ArtifactsValidator(v); err != nil { + return &ValidationError{Name: "artifacts", err: fmt.Errorf(`ent: validator failed for field "EpicGvgDefenseAttackMapping.artifacts": %w`, err)} + } + } + if _, ok := _c.mutation.BattleStrategy(); !ok { + return &ValidationError{Name: "battle_strategy", err: errors.New(`ent: missing required field "EpicGvgDefenseAttackMapping.battle_strategy"`)} + } + if v, ok := _c.mutation.BattleStrategy(); ok { + if err := epicgvgdefenseattackmapping.BattleStrategyValidator(v); err != nil { + return &ValidationError{Name: "battle_strategy", err: fmt.Errorf(`ent: validator failed for field "EpicGvgDefenseAttackMapping.battle_strategy": %w`, err)} + } + } + if _, ok := _c.mutation.Prerequisites(); !ok { + return &ValidationError{Name: "prerequisites", err: errors.New(`ent: missing required field "EpicGvgDefenseAttackMapping.prerequisites"`)} + } + if v, ok := _c.mutation.Prerequisites(); ok { + if err := epicgvgdefenseattackmapping.PrerequisitesValidator(v); err != nil { + return &ValidationError{Name: "prerequisites", err: fmt.Errorf(`ent: validator failed for field "EpicGvgDefenseAttackMapping.prerequisites": %w`, err)} + } + } + if _, ok := _c.mutation.ImportantNotes(); !ok { + return &ValidationError{Name: "important_notes", err: errors.New(`ent: missing required field "EpicGvgDefenseAttackMapping.important_notes"`)} + } + if v, ok := _c.mutation.ImportantNotes(); ok { + if err := epicgvgdefenseattackmapping.ImportantNotesValidator(v); err != nil { + return &ValidationError{Name: "important_notes", err: fmt.Errorf(`ent: validator failed for field "EpicGvgDefenseAttackMapping.important_notes": %w`, err)} + } + } + if _, ok := _c.mutation.Creator(); !ok { + return &ValidationError{Name: "creator", err: errors.New(`ent: missing required field "EpicGvgDefenseAttackMapping.creator"`)} + } + if v, ok := _c.mutation.Creator(); ok { + if err := epicgvgdefenseattackmapping.CreatorValidator(v); err != nil { + return &ValidationError{Name: "creator", err: fmt.Errorf(`ent: validator failed for field "EpicGvgDefenseAttackMapping.creator": %w`, err)} + } + } + if _, ok := _c.mutation.Updater(); !ok { + return &ValidationError{Name: "updater", err: errors.New(`ent: missing required field "EpicGvgDefenseAttackMapping.updater"`)} + } + if v, ok := _c.mutation.Updater(); ok { + if err := epicgvgdefenseattackmapping.UpdaterValidator(v); err != nil { + return &ValidationError{Name: "updater", err: fmt.Errorf(`ent: validator failed for field "EpicGvgDefenseAttackMapping.updater": %w`, err)} + } + } + if _, ok := _c.mutation.Deleted(); !ok { + return &ValidationError{Name: "deleted", err: errors.New(`ent: missing required field "EpicGvgDefenseAttackMapping.deleted"`)} + } + return nil +} + +func (_c *EpicGvgDefenseAttackMappingCreate) sqlSave(ctx context.Context) (*EpicGvgDefenseAttackMapping, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != _node.ID { + id := _spec.ID.Value.(int64) + _node.ID = int64(id) + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *EpicGvgDefenseAttackMappingCreate) createSpec() (*EpicGvgDefenseAttackMapping, *sqlgraph.CreateSpec) { + var ( + _node = &EpicGvgDefenseAttackMapping{config: _c.config} + _spec = sqlgraph.NewCreateSpec(epicgvgdefenseattackmapping.Table, sqlgraph.NewFieldSpec(epicgvgdefenseattackmapping.FieldID, field.TypeInt64)) + ) + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := _c.mutation.DefenseID(); ok { + _spec.SetField(epicgvgdefenseattackmapping.FieldDefenseID, field.TypeInt64, value) + _node.DefenseID = value + } + if value, ok := _c.mutation.AttackID(); ok { + _spec.SetField(epicgvgdefenseattackmapping.FieldAttackID, field.TypeInt64, value) + _node.AttackID = value + } + if value, ok := _c.mutation.EquipmentInfo(); ok { + _spec.SetField(epicgvgdefenseattackmapping.FieldEquipmentInfo, field.TypeString, value) + _node.EquipmentInfo = value + } + if value, ok := _c.mutation.Artifacts(); ok { + _spec.SetField(epicgvgdefenseattackmapping.FieldArtifacts, field.TypeString, value) + _node.Artifacts = value + } + if value, ok := _c.mutation.BattleStrategy(); ok { + _spec.SetField(epicgvgdefenseattackmapping.FieldBattleStrategy, field.TypeString, value) + _node.BattleStrategy = value + } + if value, ok := _c.mutation.Prerequisites(); ok { + _spec.SetField(epicgvgdefenseattackmapping.FieldPrerequisites, field.TypeString, value) + _node.Prerequisites = value + } + if value, ok := _c.mutation.ImportantNotes(); ok { + _spec.SetField(epicgvgdefenseattackmapping.FieldImportantNotes, field.TypeString, value) + _node.ImportantNotes = value + } + if value, ok := _c.mutation.Creator(); ok { + _spec.SetField(epicgvgdefenseattackmapping.FieldCreator, field.TypeString, value) + _node.Creator = value + } + if value, ok := _c.mutation.CreateTime(); ok { + _spec.SetField(epicgvgdefenseattackmapping.FieldCreateTime, field.TypeTime, value) + _node.CreateTime = &value + } + if value, ok := _c.mutation.Updater(); ok { + _spec.SetField(epicgvgdefenseattackmapping.FieldUpdater, field.TypeString, value) + _node.Updater = value + } + if value, ok := _c.mutation.UpdateTime(); ok { + _spec.SetField(epicgvgdefenseattackmapping.FieldUpdateTime, field.TypeTime, value) + _node.UpdateTime = &value + } + if value, ok := _c.mutation.Deleted(); ok { + _spec.SetField(epicgvgdefenseattackmapping.FieldDeleted, field.TypeBool, value) + _node.Deleted = value + } + return _node, _spec +} + +// EpicGvgDefenseAttackMappingCreateBulk is the builder for creating many EpicGvgDefenseAttackMapping entities in bulk. +type EpicGvgDefenseAttackMappingCreateBulk struct { + config + err error + builders []*EpicGvgDefenseAttackMappingCreate +} + +// Save creates the EpicGvgDefenseAttackMapping entities in the database. +func (_c *EpicGvgDefenseAttackMappingCreateBulk) Save(ctx context.Context) ([]*EpicGvgDefenseAttackMapping, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*EpicGvgDefenseAttackMapping, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*EpicGvgDefenseAttackMappingMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil && nodes[i].ID == 0 { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int64(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *EpicGvgDefenseAttackMappingCreateBulk) SaveX(ctx context.Context) []*EpicGvgDefenseAttackMapping { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *EpicGvgDefenseAttackMappingCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *EpicGvgDefenseAttackMappingCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/ent/epicgvgdefenseattackmapping_delete.go b/internal/ent/epicgvgdefenseattackmapping_delete.go new file mode 100644 index 0000000..526ccc5 --- /dev/null +++ b/internal/ent/epicgvgdefenseattackmapping_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "epic-ent/internal/ent/epicgvgdefenseattackmapping" + "epic-ent/internal/ent/predicate" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// EpicGvgDefenseAttackMappingDelete is the builder for deleting a EpicGvgDefenseAttackMapping entity. +type EpicGvgDefenseAttackMappingDelete struct { + config + hooks []Hook + mutation *EpicGvgDefenseAttackMappingMutation +} + +// Where appends a list predicates to the EpicGvgDefenseAttackMappingDelete builder. +func (_d *EpicGvgDefenseAttackMappingDelete) Where(ps ...predicate.EpicGvgDefenseAttackMapping) *EpicGvgDefenseAttackMappingDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *EpicGvgDefenseAttackMappingDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *EpicGvgDefenseAttackMappingDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *EpicGvgDefenseAttackMappingDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(epicgvgdefenseattackmapping.Table, sqlgraph.NewFieldSpec(epicgvgdefenseattackmapping.FieldID, field.TypeInt64)) + if ps := _d.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + _d.mutation.done = true + return affected, err +} + +// EpicGvgDefenseAttackMappingDeleteOne is the builder for deleting a single EpicGvgDefenseAttackMapping entity. +type EpicGvgDefenseAttackMappingDeleteOne struct { + _d *EpicGvgDefenseAttackMappingDelete +} + +// Where appends a list predicates to the EpicGvgDefenseAttackMappingDelete builder. +func (_d *EpicGvgDefenseAttackMappingDeleteOne) Where(ps ...predicate.EpicGvgDefenseAttackMapping) *EpicGvgDefenseAttackMappingDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *EpicGvgDefenseAttackMappingDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{epicgvgdefenseattackmapping.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *EpicGvgDefenseAttackMappingDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/ent/epicgvgdefenseattackmapping_query.go b/internal/ent/epicgvgdefenseattackmapping_query.go new file mode 100644 index 0000000..e552ad7 --- /dev/null +++ b/internal/ent/epicgvgdefenseattackmapping_query.go @@ -0,0 +1,527 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "epic-ent/internal/ent/epicgvgdefenseattackmapping" + "epic-ent/internal/ent/predicate" + "fmt" + "math" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// EpicGvgDefenseAttackMappingQuery is the builder for querying EpicGvgDefenseAttackMapping entities. +type EpicGvgDefenseAttackMappingQuery struct { + config + ctx *QueryContext + order []epicgvgdefenseattackmapping.OrderOption + inters []Interceptor + predicates []predicate.EpicGvgDefenseAttackMapping + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the EpicGvgDefenseAttackMappingQuery builder. +func (_q *EpicGvgDefenseAttackMappingQuery) Where(ps ...predicate.EpicGvgDefenseAttackMapping) *EpicGvgDefenseAttackMappingQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *EpicGvgDefenseAttackMappingQuery) Limit(limit int) *EpicGvgDefenseAttackMappingQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *EpicGvgDefenseAttackMappingQuery) Offset(offset int) *EpicGvgDefenseAttackMappingQuery { + _q.ctx.Offset = &offset + return _q +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (_q *EpicGvgDefenseAttackMappingQuery) Unique(unique bool) *EpicGvgDefenseAttackMappingQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *EpicGvgDefenseAttackMappingQuery) Order(o ...epicgvgdefenseattackmapping.OrderOption) *EpicGvgDefenseAttackMappingQuery { + _q.order = append(_q.order, o...) + return _q +} + +// First returns the first EpicGvgDefenseAttackMapping entity from the query. +// Returns a *NotFoundError when no EpicGvgDefenseAttackMapping was found. +func (_q *EpicGvgDefenseAttackMappingQuery) First(ctx context.Context) (*EpicGvgDefenseAttackMapping, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{epicgvgdefenseattackmapping.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *EpicGvgDefenseAttackMappingQuery) FirstX(ctx context.Context) *EpicGvgDefenseAttackMapping { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first EpicGvgDefenseAttackMapping ID from the query. +// Returns a *NotFoundError when no EpicGvgDefenseAttackMapping ID was found. +func (_q *EpicGvgDefenseAttackMappingQuery) FirstID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{epicgvgdefenseattackmapping.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *EpicGvgDefenseAttackMappingQuery) FirstIDX(ctx context.Context) int64 { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single EpicGvgDefenseAttackMapping entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one EpicGvgDefenseAttackMapping entity is found. +// Returns a *NotFoundError when no EpicGvgDefenseAttackMapping entities are found. +func (_q *EpicGvgDefenseAttackMappingQuery) Only(ctx context.Context) (*EpicGvgDefenseAttackMapping, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{epicgvgdefenseattackmapping.Label} + default: + return nil, &NotSingularError{epicgvgdefenseattackmapping.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *EpicGvgDefenseAttackMappingQuery) OnlyX(ctx context.Context) *EpicGvgDefenseAttackMapping { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only EpicGvgDefenseAttackMapping ID in the query. +// Returns a *NotSingularError when more than one EpicGvgDefenseAttackMapping ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *EpicGvgDefenseAttackMappingQuery) OnlyID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{epicgvgdefenseattackmapping.Label} + default: + err = &NotSingularError{epicgvgdefenseattackmapping.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *EpicGvgDefenseAttackMappingQuery) OnlyIDX(ctx context.Context) int64 { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of EpicGvgDefenseAttackMappings. +func (_q *EpicGvgDefenseAttackMappingQuery) All(ctx context.Context) ([]*EpicGvgDefenseAttackMapping, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*EpicGvgDefenseAttackMapping, *EpicGvgDefenseAttackMappingQuery]() + return withInterceptors[[]*EpicGvgDefenseAttackMapping](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *EpicGvgDefenseAttackMappingQuery) AllX(ctx context.Context) []*EpicGvgDefenseAttackMapping { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of EpicGvgDefenseAttackMapping IDs. +func (_q *EpicGvgDefenseAttackMappingQuery) IDs(ctx context.Context) (ids []int64, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(epicgvgdefenseattackmapping.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *EpicGvgDefenseAttackMappingQuery) IDsX(ctx context.Context) []int64 { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *EpicGvgDefenseAttackMappingQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, _q, querierCount[*EpicGvgDefenseAttackMappingQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *EpicGvgDefenseAttackMappingQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (_q *EpicGvgDefenseAttackMappingQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *EpicGvgDefenseAttackMappingQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the EpicGvgDefenseAttackMappingQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (_q *EpicGvgDefenseAttackMappingQuery) Clone() *EpicGvgDefenseAttackMappingQuery { + if _q == nil { + return nil + } + return &EpicGvgDefenseAttackMappingQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]epicgvgdefenseattackmapping.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.EpicGvgDefenseAttackMapping{}, _q.predicates...), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + } +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// DefenseID int64 `json:"defense_id,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.EpicGvgDefenseAttackMapping.Query(). +// GroupBy(epicgvgdefenseattackmapping.FieldDefenseID). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *EpicGvgDefenseAttackMappingQuery) GroupBy(field string, fields ...string) *EpicGvgDefenseAttackMappingGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &EpicGvgDefenseAttackMappingGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = epicgvgdefenseattackmapping.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// DefenseID int64 `json:"defense_id,omitempty"` +// } +// +// client.EpicGvgDefenseAttackMapping.Query(). +// Select(epicgvgdefenseattackmapping.FieldDefenseID). +// Scan(ctx, &v) +func (_q *EpicGvgDefenseAttackMappingQuery) Select(fields ...string) *EpicGvgDefenseAttackMappingSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &EpicGvgDefenseAttackMappingSelect{EpicGvgDefenseAttackMappingQuery: _q} + sbuild.label = epicgvgdefenseattackmapping.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a EpicGvgDefenseAttackMappingSelect configured with the given aggregations. +func (_q *EpicGvgDefenseAttackMappingQuery) Aggregate(fns ...AggregateFunc) *EpicGvgDefenseAttackMappingSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *EpicGvgDefenseAttackMappingQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !epicgvgdefenseattackmapping.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if _q.path != nil { + prev, err := _q.path(ctx) + if err != nil { + return err + } + _q.sql = prev + } + return nil +} + +func (_q *EpicGvgDefenseAttackMappingQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*EpicGvgDefenseAttackMapping, error) { + var ( + nodes = []*EpicGvgDefenseAttackMapping{} + _spec = _q.querySpec() + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*EpicGvgDefenseAttackMapping).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &EpicGvgDefenseAttackMapping{config: _q.config} + nodes = append(nodes, node) + return node.assignValues(columns, values) + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + return nodes, nil +} + +func (_q *EpicGvgDefenseAttackMappingQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique + } + return sqlgraph.CountNodes(ctx, _q.driver, _spec) +} + +func (_q *EpicGvgDefenseAttackMappingQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(epicgvgdefenseattackmapping.Table, epicgvgdefenseattackmapping.Columns, sqlgraph.NewFieldSpec(epicgvgdefenseattackmapping.FieldID, field.TypeInt64)) + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if _q.path != nil { + _spec.Unique = true + } + if fields := _q.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, epicgvgdefenseattackmapping.FieldID) + for i := range fields { + if fields[i] != epicgvgdefenseattackmapping.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := _q.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := _q.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := _q.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := _q.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (_q *EpicGvgDefenseAttackMappingQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(epicgvgdefenseattackmapping.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = epicgvgdefenseattackmapping.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if _q.sql != nil { + selector = _q.sql + selector.Select(selector.Columns(columns...)...) + } + if _q.ctx.Unique != nil && *_q.ctx.Unique { + selector.Distinct() + } + for _, p := range _q.predicates { + p(selector) + } + for _, p := range _q.order { + p(selector) + } + if offset := _q.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := _q.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// EpicGvgDefenseAttackMappingGroupBy is the group-by builder for EpicGvgDefenseAttackMapping entities. +type EpicGvgDefenseAttackMappingGroupBy struct { + selector + build *EpicGvgDefenseAttackMappingQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *EpicGvgDefenseAttackMappingGroupBy) Aggregate(fns ...AggregateFunc) *EpicGvgDefenseAttackMappingGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *EpicGvgDefenseAttackMappingGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*EpicGvgDefenseAttackMappingQuery, *EpicGvgDefenseAttackMappingGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *EpicGvgDefenseAttackMappingGroupBy) sqlScan(ctx context.Context, root *EpicGvgDefenseAttackMappingQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*_g.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// EpicGvgDefenseAttackMappingSelect is the builder for selecting fields of EpicGvgDefenseAttackMapping entities. +type EpicGvgDefenseAttackMappingSelect struct { + *EpicGvgDefenseAttackMappingQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *EpicGvgDefenseAttackMappingSelect) Aggregate(fns ...AggregateFunc) *EpicGvgDefenseAttackMappingSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *EpicGvgDefenseAttackMappingSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*EpicGvgDefenseAttackMappingQuery, *EpicGvgDefenseAttackMappingSelect](ctx, _s.EpicGvgDefenseAttackMappingQuery, _s, _s.inters, v) +} + +func (_s *EpicGvgDefenseAttackMappingSelect) sqlScan(ctx context.Context, root *EpicGvgDefenseAttackMappingQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/internal/ent/epicgvgdefenseattackmapping_update.go b/internal/ent/epicgvgdefenseattackmapping_update.go new file mode 100644 index 0000000..8fd70a1 --- /dev/null +++ b/internal/ent/epicgvgdefenseattackmapping_update.go @@ -0,0 +1,746 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "epic-ent/internal/ent/epicgvgdefenseattackmapping" + "epic-ent/internal/ent/predicate" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// EpicGvgDefenseAttackMappingUpdate is the builder for updating EpicGvgDefenseAttackMapping entities. +type EpicGvgDefenseAttackMappingUpdate struct { + config + hooks []Hook + mutation *EpicGvgDefenseAttackMappingMutation +} + +// Where appends a list predicates to the EpicGvgDefenseAttackMappingUpdate builder. +func (_u *EpicGvgDefenseAttackMappingUpdate) Where(ps ...predicate.EpicGvgDefenseAttackMapping) *EpicGvgDefenseAttackMappingUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetDefenseID sets the "defense_id" field. +func (_u *EpicGvgDefenseAttackMappingUpdate) SetDefenseID(v int64) *EpicGvgDefenseAttackMappingUpdate { + _u.mutation.ResetDefenseID() + _u.mutation.SetDefenseID(v) + return _u +} + +// SetNillableDefenseID sets the "defense_id" field if the given value is not nil. +func (_u *EpicGvgDefenseAttackMappingUpdate) SetNillableDefenseID(v *int64) *EpicGvgDefenseAttackMappingUpdate { + if v != nil { + _u.SetDefenseID(*v) + } + return _u +} + +// AddDefenseID adds value to the "defense_id" field. +func (_u *EpicGvgDefenseAttackMappingUpdate) AddDefenseID(v int64) *EpicGvgDefenseAttackMappingUpdate { + _u.mutation.AddDefenseID(v) + return _u +} + +// SetAttackID sets the "attack_id" field. +func (_u *EpicGvgDefenseAttackMappingUpdate) SetAttackID(v int64) *EpicGvgDefenseAttackMappingUpdate { + _u.mutation.ResetAttackID() + _u.mutation.SetAttackID(v) + return _u +} + +// SetNillableAttackID sets the "attack_id" field if the given value is not nil. +func (_u *EpicGvgDefenseAttackMappingUpdate) SetNillableAttackID(v *int64) *EpicGvgDefenseAttackMappingUpdate { + if v != nil { + _u.SetAttackID(*v) + } + return _u +} + +// AddAttackID adds value to the "attack_id" field. +func (_u *EpicGvgDefenseAttackMappingUpdate) AddAttackID(v int64) *EpicGvgDefenseAttackMappingUpdate { + _u.mutation.AddAttackID(v) + return _u +} + +// SetEquipmentInfo sets the "equipment_info" field. +func (_u *EpicGvgDefenseAttackMappingUpdate) SetEquipmentInfo(v string) *EpicGvgDefenseAttackMappingUpdate { + _u.mutation.SetEquipmentInfo(v) + return _u +} + +// SetNillableEquipmentInfo sets the "equipment_info" field if the given value is not nil. +func (_u *EpicGvgDefenseAttackMappingUpdate) SetNillableEquipmentInfo(v *string) *EpicGvgDefenseAttackMappingUpdate { + if v != nil { + _u.SetEquipmentInfo(*v) + } + return _u +} + +// SetArtifacts sets the "artifacts" field. +func (_u *EpicGvgDefenseAttackMappingUpdate) SetArtifacts(v string) *EpicGvgDefenseAttackMappingUpdate { + _u.mutation.SetArtifacts(v) + return _u +} + +// SetNillableArtifacts sets the "artifacts" field if the given value is not nil. +func (_u *EpicGvgDefenseAttackMappingUpdate) SetNillableArtifacts(v *string) *EpicGvgDefenseAttackMappingUpdate { + if v != nil { + _u.SetArtifacts(*v) + } + return _u +} + +// SetBattleStrategy sets the "battle_strategy" field. +func (_u *EpicGvgDefenseAttackMappingUpdate) SetBattleStrategy(v string) *EpicGvgDefenseAttackMappingUpdate { + _u.mutation.SetBattleStrategy(v) + return _u +} + +// SetNillableBattleStrategy sets the "battle_strategy" field if the given value is not nil. +func (_u *EpicGvgDefenseAttackMappingUpdate) SetNillableBattleStrategy(v *string) *EpicGvgDefenseAttackMappingUpdate { + if v != nil { + _u.SetBattleStrategy(*v) + } + return _u +} + +// SetPrerequisites sets the "prerequisites" field. +func (_u *EpicGvgDefenseAttackMappingUpdate) SetPrerequisites(v string) *EpicGvgDefenseAttackMappingUpdate { + _u.mutation.SetPrerequisites(v) + return _u +} + +// SetNillablePrerequisites sets the "prerequisites" field if the given value is not nil. +func (_u *EpicGvgDefenseAttackMappingUpdate) SetNillablePrerequisites(v *string) *EpicGvgDefenseAttackMappingUpdate { + if v != nil { + _u.SetPrerequisites(*v) + } + return _u +} + +// SetImportantNotes sets the "important_notes" field. +func (_u *EpicGvgDefenseAttackMappingUpdate) SetImportantNotes(v string) *EpicGvgDefenseAttackMappingUpdate { + _u.mutation.SetImportantNotes(v) + return _u +} + +// SetNillableImportantNotes sets the "important_notes" field if the given value is not nil. +func (_u *EpicGvgDefenseAttackMappingUpdate) SetNillableImportantNotes(v *string) *EpicGvgDefenseAttackMappingUpdate { + if v != nil { + _u.SetImportantNotes(*v) + } + return _u +} + +// SetCreator sets the "creator" field. +func (_u *EpicGvgDefenseAttackMappingUpdate) SetCreator(v string) *EpicGvgDefenseAttackMappingUpdate { + _u.mutation.SetCreator(v) + return _u +} + +// SetNillableCreator sets the "creator" field if the given value is not nil. +func (_u *EpicGvgDefenseAttackMappingUpdate) SetNillableCreator(v *string) *EpicGvgDefenseAttackMappingUpdate { + if v != nil { + _u.SetCreator(*v) + } + return _u +} + +// SetCreateTime sets the "create_time" field. +func (_u *EpicGvgDefenseAttackMappingUpdate) SetCreateTime(v time.Time) *EpicGvgDefenseAttackMappingUpdate { + _u.mutation.SetCreateTime(v) + return _u +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (_u *EpicGvgDefenseAttackMappingUpdate) SetNillableCreateTime(v *time.Time) *EpicGvgDefenseAttackMappingUpdate { + if v != nil { + _u.SetCreateTime(*v) + } + return _u +} + +// ClearCreateTime clears the value of the "create_time" field. +func (_u *EpicGvgDefenseAttackMappingUpdate) ClearCreateTime() *EpicGvgDefenseAttackMappingUpdate { + _u.mutation.ClearCreateTime() + return _u +} + +// SetUpdater sets the "updater" field. +func (_u *EpicGvgDefenseAttackMappingUpdate) SetUpdater(v string) *EpicGvgDefenseAttackMappingUpdate { + _u.mutation.SetUpdater(v) + return _u +} + +// SetNillableUpdater sets the "updater" field if the given value is not nil. +func (_u *EpicGvgDefenseAttackMappingUpdate) SetNillableUpdater(v *string) *EpicGvgDefenseAttackMappingUpdate { + if v != nil { + _u.SetUpdater(*v) + } + return _u +} + +// SetUpdateTime sets the "update_time" field. +func (_u *EpicGvgDefenseAttackMappingUpdate) SetUpdateTime(v time.Time) *EpicGvgDefenseAttackMappingUpdate { + _u.mutation.SetUpdateTime(v) + return _u +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (_u *EpicGvgDefenseAttackMappingUpdate) SetNillableUpdateTime(v *time.Time) *EpicGvgDefenseAttackMappingUpdate { + if v != nil { + _u.SetUpdateTime(*v) + } + return _u +} + +// ClearUpdateTime clears the value of the "update_time" field. +func (_u *EpicGvgDefenseAttackMappingUpdate) ClearUpdateTime() *EpicGvgDefenseAttackMappingUpdate { + _u.mutation.ClearUpdateTime() + return _u +} + +// SetDeleted sets the "deleted" field. +func (_u *EpicGvgDefenseAttackMappingUpdate) SetDeleted(v bool) *EpicGvgDefenseAttackMappingUpdate { + _u.mutation.SetDeleted(v) + return _u +} + +// SetNillableDeleted sets the "deleted" field if the given value is not nil. +func (_u *EpicGvgDefenseAttackMappingUpdate) SetNillableDeleted(v *bool) *EpicGvgDefenseAttackMappingUpdate { + if v != nil { + _u.SetDeleted(*v) + } + return _u +} + +// Mutation returns the EpicGvgDefenseAttackMappingMutation object of the builder. +func (_u *EpicGvgDefenseAttackMappingUpdate) Mutation() *EpicGvgDefenseAttackMappingMutation { + return _u.mutation +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *EpicGvgDefenseAttackMappingUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *EpicGvgDefenseAttackMappingUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *EpicGvgDefenseAttackMappingUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *EpicGvgDefenseAttackMappingUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *EpicGvgDefenseAttackMappingUpdate) check() error { + if v, ok := _u.mutation.EquipmentInfo(); ok { + if err := epicgvgdefenseattackmapping.EquipmentInfoValidator(v); err != nil { + return &ValidationError{Name: "equipment_info", err: fmt.Errorf(`ent: validator failed for field "EpicGvgDefenseAttackMapping.equipment_info": %w`, err)} + } + } + if v, ok := _u.mutation.Artifacts(); ok { + if err := epicgvgdefenseattackmapping.ArtifactsValidator(v); err != nil { + return &ValidationError{Name: "artifacts", err: fmt.Errorf(`ent: validator failed for field "EpicGvgDefenseAttackMapping.artifacts": %w`, err)} + } + } + if v, ok := _u.mutation.BattleStrategy(); ok { + if err := epicgvgdefenseattackmapping.BattleStrategyValidator(v); err != nil { + return &ValidationError{Name: "battle_strategy", err: fmt.Errorf(`ent: validator failed for field "EpicGvgDefenseAttackMapping.battle_strategy": %w`, err)} + } + } + if v, ok := _u.mutation.Prerequisites(); ok { + if err := epicgvgdefenseattackmapping.PrerequisitesValidator(v); err != nil { + return &ValidationError{Name: "prerequisites", err: fmt.Errorf(`ent: validator failed for field "EpicGvgDefenseAttackMapping.prerequisites": %w`, err)} + } + } + if v, ok := _u.mutation.ImportantNotes(); ok { + if err := epicgvgdefenseattackmapping.ImportantNotesValidator(v); err != nil { + return &ValidationError{Name: "important_notes", err: fmt.Errorf(`ent: validator failed for field "EpicGvgDefenseAttackMapping.important_notes": %w`, err)} + } + } + if v, ok := _u.mutation.Creator(); ok { + if err := epicgvgdefenseattackmapping.CreatorValidator(v); err != nil { + return &ValidationError{Name: "creator", err: fmt.Errorf(`ent: validator failed for field "EpicGvgDefenseAttackMapping.creator": %w`, err)} + } + } + if v, ok := _u.mutation.Updater(); ok { + if err := epicgvgdefenseattackmapping.UpdaterValidator(v); err != nil { + return &ValidationError{Name: "updater", err: fmt.Errorf(`ent: validator failed for field "EpicGvgDefenseAttackMapping.updater": %w`, err)} + } + } + return nil +} + +func (_u *EpicGvgDefenseAttackMappingUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(epicgvgdefenseattackmapping.Table, epicgvgdefenseattackmapping.Columns, sqlgraph.NewFieldSpec(epicgvgdefenseattackmapping.FieldID, field.TypeInt64)) + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.DefenseID(); ok { + _spec.SetField(epicgvgdefenseattackmapping.FieldDefenseID, field.TypeInt64, value) + } + if value, ok := _u.mutation.AddedDefenseID(); ok { + _spec.AddField(epicgvgdefenseattackmapping.FieldDefenseID, field.TypeInt64, value) + } + if value, ok := _u.mutation.AttackID(); ok { + _spec.SetField(epicgvgdefenseattackmapping.FieldAttackID, field.TypeInt64, value) + } + if value, ok := _u.mutation.AddedAttackID(); ok { + _spec.AddField(epicgvgdefenseattackmapping.FieldAttackID, field.TypeInt64, value) + } + if value, ok := _u.mutation.EquipmentInfo(); ok { + _spec.SetField(epicgvgdefenseattackmapping.FieldEquipmentInfo, field.TypeString, value) + } + if value, ok := _u.mutation.Artifacts(); ok { + _spec.SetField(epicgvgdefenseattackmapping.FieldArtifacts, field.TypeString, value) + } + if value, ok := _u.mutation.BattleStrategy(); ok { + _spec.SetField(epicgvgdefenseattackmapping.FieldBattleStrategy, field.TypeString, value) + } + if value, ok := _u.mutation.Prerequisites(); ok { + _spec.SetField(epicgvgdefenseattackmapping.FieldPrerequisites, field.TypeString, value) + } + if value, ok := _u.mutation.ImportantNotes(); ok { + _spec.SetField(epicgvgdefenseattackmapping.FieldImportantNotes, field.TypeString, value) + } + if value, ok := _u.mutation.Creator(); ok { + _spec.SetField(epicgvgdefenseattackmapping.FieldCreator, field.TypeString, value) + } + if value, ok := _u.mutation.CreateTime(); ok { + _spec.SetField(epicgvgdefenseattackmapping.FieldCreateTime, field.TypeTime, value) + } + if _u.mutation.CreateTimeCleared() { + _spec.ClearField(epicgvgdefenseattackmapping.FieldCreateTime, field.TypeTime) + } + if value, ok := _u.mutation.Updater(); ok { + _spec.SetField(epicgvgdefenseattackmapping.FieldUpdater, field.TypeString, value) + } + if value, ok := _u.mutation.UpdateTime(); ok { + _spec.SetField(epicgvgdefenseattackmapping.FieldUpdateTime, field.TypeTime, value) + } + if _u.mutation.UpdateTimeCleared() { + _spec.ClearField(epicgvgdefenseattackmapping.FieldUpdateTime, field.TypeTime) + } + if value, ok := _u.mutation.Deleted(); ok { + _spec.SetField(epicgvgdefenseattackmapping.FieldDeleted, field.TypeBool, value) + } + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{epicgvgdefenseattackmapping.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// EpicGvgDefenseAttackMappingUpdateOne is the builder for updating a single EpicGvgDefenseAttackMapping entity. +type EpicGvgDefenseAttackMappingUpdateOne struct { + config + fields []string + hooks []Hook + mutation *EpicGvgDefenseAttackMappingMutation +} + +// SetDefenseID sets the "defense_id" field. +func (_u *EpicGvgDefenseAttackMappingUpdateOne) SetDefenseID(v int64) *EpicGvgDefenseAttackMappingUpdateOne { + _u.mutation.ResetDefenseID() + _u.mutation.SetDefenseID(v) + return _u +} + +// SetNillableDefenseID sets the "defense_id" field if the given value is not nil. +func (_u *EpicGvgDefenseAttackMappingUpdateOne) SetNillableDefenseID(v *int64) *EpicGvgDefenseAttackMappingUpdateOne { + if v != nil { + _u.SetDefenseID(*v) + } + return _u +} + +// AddDefenseID adds value to the "defense_id" field. +func (_u *EpicGvgDefenseAttackMappingUpdateOne) AddDefenseID(v int64) *EpicGvgDefenseAttackMappingUpdateOne { + _u.mutation.AddDefenseID(v) + return _u +} + +// SetAttackID sets the "attack_id" field. +func (_u *EpicGvgDefenseAttackMappingUpdateOne) SetAttackID(v int64) *EpicGvgDefenseAttackMappingUpdateOne { + _u.mutation.ResetAttackID() + _u.mutation.SetAttackID(v) + return _u +} + +// SetNillableAttackID sets the "attack_id" field if the given value is not nil. +func (_u *EpicGvgDefenseAttackMappingUpdateOne) SetNillableAttackID(v *int64) *EpicGvgDefenseAttackMappingUpdateOne { + if v != nil { + _u.SetAttackID(*v) + } + return _u +} + +// AddAttackID adds value to the "attack_id" field. +func (_u *EpicGvgDefenseAttackMappingUpdateOne) AddAttackID(v int64) *EpicGvgDefenseAttackMappingUpdateOne { + _u.mutation.AddAttackID(v) + return _u +} + +// SetEquipmentInfo sets the "equipment_info" field. +func (_u *EpicGvgDefenseAttackMappingUpdateOne) SetEquipmentInfo(v string) *EpicGvgDefenseAttackMappingUpdateOne { + _u.mutation.SetEquipmentInfo(v) + return _u +} + +// SetNillableEquipmentInfo sets the "equipment_info" field if the given value is not nil. +func (_u *EpicGvgDefenseAttackMappingUpdateOne) SetNillableEquipmentInfo(v *string) *EpicGvgDefenseAttackMappingUpdateOne { + if v != nil { + _u.SetEquipmentInfo(*v) + } + return _u +} + +// SetArtifacts sets the "artifacts" field. +func (_u *EpicGvgDefenseAttackMappingUpdateOne) SetArtifacts(v string) *EpicGvgDefenseAttackMappingUpdateOne { + _u.mutation.SetArtifacts(v) + return _u +} + +// SetNillableArtifacts sets the "artifacts" field if the given value is not nil. +func (_u *EpicGvgDefenseAttackMappingUpdateOne) SetNillableArtifacts(v *string) *EpicGvgDefenseAttackMappingUpdateOne { + if v != nil { + _u.SetArtifacts(*v) + } + return _u +} + +// SetBattleStrategy sets the "battle_strategy" field. +func (_u *EpicGvgDefenseAttackMappingUpdateOne) SetBattleStrategy(v string) *EpicGvgDefenseAttackMappingUpdateOne { + _u.mutation.SetBattleStrategy(v) + return _u +} + +// SetNillableBattleStrategy sets the "battle_strategy" field if the given value is not nil. +func (_u *EpicGvgDefenseAttackMappingUpdateOne) SetNillableBattleStrategy(v *string) *EpicGvgDefenseAttackMappingUpdateOne { + if v != nil { + _u.SetBattleStrategy(*v) + } + return _u +} + +// SetPrerequisites sets the "prerequisites" field. +func (_u *EpicGvgDefenseAttackMappingUpdateOne) SetPrerequisites(v string) *EpicGvgDefenseAttackMappingUpdateOne { + _u.mutation.SetPrerequisites(v) + return _u +} + +// SetNillablePrerequisites sets the "prerequisites" field if the given value is not nil. +func (_u *EpicGvgDefenseAttackMappingUpdateOne) SetNillablePrerequisites(v *string) *EpicGvgDefenseAttackMappingUpdateOne { + if v != nil { + _u.SetPrerequisites(*v) + } + return _u +} + +// SetImportantNotes sets the "important_notes" field. +func (_u *EpicGvgDefenseAttackMappingUpdateOne) SetImportantNotes(v string) *EpicGvgDefenseAttackMappingUpdateOne { + _u.mutation.SetImportantNotes(v) + return _u +} + +// SetNillableImportantNotes sets the "important_notes" field if the given value is not nil. +func (_u *EpicGvgDefenseAttackMappingUpdateOne) SetNillableImportantNotes(v *string) *EpicGvgDefenseAttackMappingUpdateOne { + if v != nil { + _u.SetImportantNotes(*v) + } + return _u +} + +// SetCreator sets the "creator" field. +func (_u *EpicGvgDefenseAttackMappingUpdateOne) SetCreator(v string) *EpicGvgDefenseAttackMappingUpdateOne { + _u.mutation.SetCreator(v) + return _u +} + +// SetNillableCreator sets the "creator" field if the given value is not nil. +func (_u *EpicGvgDefenseAttackMappingUpdateOne) SetNillableCreator(v *string) *EpicGvgDefenseAttackMappingUpdateOne { + if v != nil { + _u.SetCreator(*v) + } + return _u +} + +// SetCreateTime sets the "create_time" field. +func (_u *EpicGvgDefenseAttackMappingUpdateOne) SetCreateTime(v time.Time) *EpicGvgDefenseAttackMappingUpdateOne { + _u.mutation.SetCreateTime(v) + return _u +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (_u *EpicGvgDefenseAttackMappingUpdateOne) SetNillableCreateTime(v *time.Time) *EpicGvgDefenseAttackMappingUpdateOne { + if v != nil { + _u.SetCreateTime(*v) + } + return _u +} + +// ClearCreateTime clears the value of the "create_time" field. +func (_u *EpicGvgDefenseAttackMappingUpdateOne) ClearCreateTime() *EpicGvgDefenseAttackMappingUpdateOne { + _u.mutation.ClearCreateTime() + return _u +} + +// SetUpdater sets the "updater" field. +func (_u *EpicGvgDefenseAttackMappingUpdateOne) SetUpdater(v string) *EpicGvgDefenseAttackMappingUpdateOne { + _u.mutation.SetUpdater(v) + return _u +} + +// SetNillableUpdater sets the "updater" field if the given value is not nil. +func (_u *EpicGvgDefenseAttackMappingUpdateOne) SetNillableUpdater(v *string) *EpicGvgDefenseAttackMappingUpdateOne { + if v != nil { + _u.SetUpdater(*v) + } + return _u +} + +// SetUpdateTime sets the "update_time" field. +func (_u *EpicGvgDefenseAttackMappingUpdateOne) SetUpdateTime(v time.Time) *EpicGvgDefenseAttackMappingUpdateOne { + _u.mutation.SetUpdateTime(v) + return _u +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (_u *EpicGvgDefenseAttackMappingUpdateOne) SetNillableUpdateTime(v *time.Time) *EpicGvgDefenseAttackMappingUpdateOne { + if v != nil { + _u.SetUpdateTime(*v) + } + return _u +} + +// ClearUpdateTime clears the value of the "update_time" field. +func (_u *EpicGvgDefenseAttackMappingUpdateOne) ClearUpdateTime() *EpicGvgDefenseAttackMappingUpdateOne { + _u.mutation.ClearUpdateTime() + return _u +} + +// SetDeleted sets the "deleted" field. +func (_u *EpicGvgDefenseAttackMappingUpdateOne) SetDeleted(v bool) *EpicGvgDefenseAttackMappingUpdateOne { + _u.mutation.SetDeleted(v) + return _u +} + +// SetNillableDeleted sets the "deleted" field if the given value is not nil. +func (_u *EpicGvgDefenseAttackMappingUpdateOne) SetNillableDeleted(v *bool) *EpicGvgDefenseAttackMappingUpdateOne { + if v != nil { + _u.SetDeleted(*v) + } + return _u +} + +// Mutation returns the EpicGvgDefenseAttackMappingMutation object of the builder. +func (_u *EpicGvgDefenseAttackMappingUpdateOne) Mutation() *EpicGvgDefenseAttackMappingMutation { + return _u.mutation +} + +// Where appends a list predicates to the EpicGvgDefenseAttackMappingUpdate builder. +func (_u *EpicGvgDefenseAttackMappingUpdateOne) Where(ps ...predicate.EpicGvgDefenseAttackMapping) *EpicGvgDefenseAttackMappingUpdateOne { + _u.mutation.Where(ps...) + return _u +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (_u *EpicGvgDefenseAttackMappingUpdateOne) Select(field string, fields ...string) *EpicGvgDefenseAttackMappingUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated EpicGvgDefenseAttackMapping entity. +func (_u *EpicGvgDefenseAttackMappingUpdateOne) Save(ctx context.Context) (*EpicGvgDefenseAttackMapping, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *EpicGvgDefenseAttackMappingUpdateOne) SaveX(ctx context.Context) *EpicGvgDefenseAttackMapping { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *EpicGvgDefenseAttackMappingUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *EpicGvgDefenseAttackMappingUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *EpicGvgDefenseAttackMappingUpdateOne) check() error { + if v, ok := _u.mutation.EquipmentInfo(); ok { + if err := epicgvgdefenseattackmapping.EquipmentInfoValidator(v); err != nil { + return &ValidationError{Name: "equipment_info", err: fmt.Errorf(`ent: validator failed for field "EpicGvgDefenseAttackMapping.equipment_info": %w`, err)} + } + } + if v, ok := _u.mutation.Artifacts(); ok { + if err := epicgvgdefenseattackmapping.ArtifactsValidator(v); err != nil { + return &ValidationError{Name: "artifacts", err: fmt.Errorf(`ent: validator failed for field "EpicGvgDefenseAttackMapping.artifacts": %w`, err)} + } + } + if v, ok := _u.mutation.BattleStrategy(); ok { + if err := epicgvgdefenseattackmapping.BattleStrategyValidator(v); err != nil { + return &ValidationError{Name: "battle_strategy", err: fmt.Errorf(`ent: validator failed for field "EpicGvgDefenseAttackMapping.battle_strategy": %w`, err)} + } + } + if v, ok := _u.mutation.Prerequisites(); ok { + if err := epicgvgdefenseattackmapping.PrerequisitesValidator(v); err != nil { + return &ValidationError{Name: "prerequisites", err: fmt.Errorf(`ent: validator failed for field "EpicGvgDefenseAttackMapping.prerequisites": %w`, err)} + } + } + if v, ok := _u.mutation.ImportantNotes(); ok { + if err := epicgvgdefenseattackmapping.ImportantNotesValidator(v); err != nil { + return &ValidationError{Name: "important_notes", err: fmt.Errorf(`ent: validator failed for field "EpicGvgDefenseAttackMapping.important_notes": %w`, err)} + } + } + if v, ok := _u.mutation.Creator(); ok { + if err := epicgvgdefenseattackmapping.CreatorValidator(v); err != nil { + return &ValidationError{Name: "creator", err: fmt.Errorf(`ent: validator failed for field "EpicGvgDefenseAttackMapping.creator": %w`, err)} + } + } + if v, ok := _u.mutation.Updater(); ok { + if err := epicgvgdefenseattackmapping.UpdaterValidator(v); err != nil { + return &ValidationError{Name: "updater", err: fmt.Errorf(`ent: validator failed for field "EpicGvgDefenseAttackMapping.updater": %w`, err)} + } + } + return nil +} + +func (_u *EpicGvgDefenseAttackMappingUpdateOne) sqlSave(ctx context.Context) (_node *EpicGvgDefenseAttackMapping, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(epicgvgdefenseattackmapping.Table, epicgvgdefenseattackmapping.Columns, sqlgraph.NewFieldSpec(epicgvgdefenseattackmapping.FieldID, field.TypeInt64)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "EpicGvgDefenseAttackMapping.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := _u.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, epicgvgdefenseattackmapping.FieldID) + for _, f := range fields { + if !epicgvgdefenseattackmapping.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != epicgvgdefenseattackmapping.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.DefenseID(); ok { + _spec.SetField(epicgvgdefenseattackmapping.FieldDefenseID, field.TypeInt64, value) + } + if value, ok := _u.mutation.AddedDefenseID(); ok { + _spec.AddField(epicgvgdefenseattackmapping.FieldDefenseID, field.TypeInt64, value) + } + if value, ok := _u.mutation.AttackID(); ok { + _spec.SetField(epicgvgdefenseattackmapping.FieldAttackID, field.TypeInt64, value) + } + if value, ok := _u.mutation.AddedAttackID(); ok { + _spec.AddField(epicgvgdefenseattackmapping.FieldAttackID, field.TypeInt64, value) + } + if value, ok := _u.mutation.EquipmentInfo(); ok { + _spec.SetField(epicgvgdefenseattackmapping.FieldEquipmentInfo, field.TypeString, value) + } + if value, ok := _u.mutation.Artifacts(); ok { + _spec.SetField(epicgvgdefenseattackmapping.FieldArtifacts, field.TypeString, value) + } + if value, ok := _u.mutation.BattleStrategy(); ok { + _spec.SetField(epicgvgdefenseattackmapping.FieldBattleStrategy, field.TypeString, value) + } + if value, ok := _u.mutation.Prerequisites(); ok { + _spec.SetField(epicgvgdefenseattackmapping.FieldPrerequisites, field.TypeString, value) + } + if value, ok := _u.mutation.ImportantNotes(); ok { + _spec.SetField(epicgvgdefenseattackmapping.FieldImportantNotes, field.TypeString, value) + } + if value, ok := _u.mutation.Creator(); ok { + _spec.SetField(epicgvgdefenseattackmapping.FieldCreator, field.TypeString, value) + } + if value, ok := _u.mutation.CreateTime(); ok { + _spec.SetField(epicgvgdefenseattackmapping.FieldCreateTime, field.TypeTime, value) + } + if _u.mutation.CreateTimeCleared() { + _spec.ClearField(epicgvgdefenseattackmapping.FieldCreateTime, field.TypeTime) + } + if value, ok := _u.mutation.Updater(); ok { + _spec.SetField(epicgvgdefenseattackmapping.FieldUpdater, field.TypeString, value) + } + if value, ok := _u.mutation.UpdateTime(); ok { + _spec.SetField(epicgvgdefenseattackmapping.FieldUpdateTime, field.TypeTime, value) + } + if _u.mutation.UpdateTimeCleared() { + _spec.ClearField(epicgvgdefenseattackmapping.FieldUpdateTime, field.TypeTime) + } + if value, ok := _u.mutation.Deleted(); ok { + _spec.SetField(epicgvgdefenseattackmapping.FieldDeleted, field.TypeBool, value) + } + _node = &EpicGvgDefenseAttackMapping{config: _u.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{epicgvgdefenseattackmapping.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} diff --git a/internal/ent/epicgvgdefenseteams.go b/internal/ent/epicgvgdefenseteams.go new file mode 100644 index 0000000..749717d --- /dev/null +++ b/internal/ent/epicgvgdefenseteams.go @@ -0,0 +1,169 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "epic-ent/internal/ent/epicgvgdefenseteams" + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// EpicGvgDefenseTeams is the model entity for the EpicGvgDefenseTeams schema. +type EpicGvgDefenseTeams struct { + config `json:"-"` + // ID of the ent. + ID int64 `json:"id,omitempty"` + // DefenseHeroes holds the value of the "defense_heroes" field. + DefenseHeroes string `json:"defense_heroes,omitempty"` + // Creator holds the value of the "creator" field. + Creator string `json:"creator,omitempty"` + // CreateTime holds the value of the "create_time" field. + CreateTime *time.Time `json:"create_time,omitempty"` + // Updater holds the value of the "updater" field. + Updater string `json:"updater,omitempty"` + // UpdateTime holds the value of the "update_time" field. + UpdateTime *time.Time `json:"update_time,omitempty"` + // Deleted holds the value of the "deleted" field. + Deleted bool `json:"deleted,omitempty"` + selectValues sql.SelectValues +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*EpicGvgDefenseTeams) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case epicgvgdefenseteams.FieldDeleted: + values[i] = new(sql.NullBool) + case epicgvgdefenseteams.FieldID: + values[i] = new(sql.NullInt64) + case epicgvgdefenseteams.FieldDefenseHeroes, epicgvgdefenseteams.FieldCreator, epicgvgdefenseteams.FieldUpdater: + values[i] = new(sql.NullString) + case epicgvgdefenseteams.FieldCreateTime, epicgvgdefenseteams.FieldUpdateTime: + values[i] = new(sql.NullTime) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the EpicGvgDefenseTeams fields. +func (_m *EpicGvgDefenseTeams) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case epicgvgdefenseteams.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + _m.ID = int64(value.Int64) + case epicgvgdefenseteams.FieldDefenseHeroes: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field defense_heroes", values[i]) + } else if value.Valid { + _m.DefenseHeroes = value.String + } + case epicgvgdefenseteams.FieldCreator: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field creator", values[i]) + } else if value.Valid { + _m.Creator = value.String + } + case epicgvgdefenseteams.FieldCreateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field create_time", values[i]) + } else if value.Valid { + _m.CreateTime = new(time.Time) + *_m.CreateTime = value.Time + } + case epicgvgdefenseteams.FieldUpdater: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field updater", values[i]) + } else if value.Valid { + _m.Updater = value.String + } + case epicgvgdefenseteams.FieldUpdateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field update_time", values[i]) + } else if value.Valid { + _m.UpdateTime = new(time.Time) + *_m.UpdateTime = value.Time + } + case epicgvgdefenseteams.FieldDeleted: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field deleted", values[i]) + } else if value.Valid { + _m.Deleted = value.Bool + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the EpicGvgDefenseTeams. +// This includes values selected through modifiers, order, etc. +func (_m *EpicGvgDefenseTeams) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// Update returns a builder for updating this EpicGvgDefenseTeams. +// Note that you need to call EpicGvgDefenseTeams.Unwrap() before calling this method if this EpicGvgDefenseTeams +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *EpicGvgDefenseTeams) Update() *EpicGvgDefenseTeamsUpdateOne { + return NewEpicGvgDefenseTeamsClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the EpicGvgDefenseTeams entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (_m *EpicGvgDefenseTeams) Unwrap() *EpicGvgDefenseTeams { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("ent: EpicGvgDefenseTeams is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *EpicGvgDefenseTeams) String() string { + var builder strings.Builder + builder.WriteString("EpicGvgDefenseTeams(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("defense_heroes=") + builder.WriteString(_m.DefenseHeroes) + builder.WriteString(", ") + builder.WriteString("creator=") + builder.WriteString(_m.Creator) + builder.WriteString(", ") + if v := _m.CreateTime; v != nil { + builder.WriteString("create_time=") + builder.WriteString(v.Format(time.ANSIC)) + } + builder.WriteString(", ") + builder.WriteString("updater=") + builder.WriteString(_m.Updater) + builder.WriteString(", ") + if v := _m.UpdateTime; v != nil { + builder.WriteString("update_time=") + builder.WriteString(v.Format(time.ANSIC)) + } + builder.WriteString(", ") + builder.WriteString("deleted=") + builder.WriteString(fmt.Sprintf("%v", _m.Deleted)) + builder.WriteByte(')') + return builder.String() +} + +// EpicGvgDefenseTeamsSlice is a parsable slice of EpicGvgDefenseTeams. +type EpicGvgDefenseTeamsSlice []*EpicGvgDefenseTeams diff --git a/internal/ent/epicgvgdefenseteams/epicgvgdefenseteams.go b/internal/ent/epicgvgdefenseteams/epicgvgdefenseteams.go new file mode 100644 index 0000000..f9bed47 --- /dev/null +++ b/internal/ent/epicgvgdefenseteams/epicgvgdefenseteams.go @@ -0,0 +1,96 @@ +// Code generated by ent, DO NOT EDIT. + +package epicgvgdefenseteams + +import ( + "entgo.io/ent/dialect/sql" +) + +const ( + // Label holds the string label denoting the epicgvgdefenseteams type in the database. + Label = "epic_gvg_defense_teams" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldDefenseHeroes holds the string denoting the defense_heroes field in the database. + FieldDefenseHeroes = "defense_heroes" + // FieldCreator holds the string denoting the creator field in the database. + FieldCreator = "creator" + // FieldCreateTime holds the string denoting the create_time field in the database. + FieldCreateTime = "create_time" + // FieldUpdater holds the string denoting the updater field in the database. + FieldUpdater = "updater" + // FieldUpdateTime holds the string denoting the update_time field in the database. + FieldUpdateTime = "update_time" + // FieldDeleted holds the string denoting the deleted field in the database. + FieldDeleted = "deleted" + // Table holds the table name of the epicgvgdefenseteams in the database. + Table = "epic_gvg_defense_teams" +) + +// Columns holds all SQL columns for epicgvgdefenseteams fields. +var Columns = []string{ + FieldID, + FieldDefenseHeroes, + FieldCreator, + FieldCreateTime, + FieldUpdater, + FieldUpdateTime, + FieldDeleted, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // DefenseHeroesValidator is a validator for the "defense_heroes" field. It is called by the builders before save. + DefenseHeroesValidator func(string) error + // CreatorValidator is a validator for the "creator" field. It is called by the builders before save. + CreatorValidator func(string) error + // UpdaterValidator is a validator for the "updater" field. It is called by the builders before save. + UpdaterValidator func(string) error +) + +// OrderOption defines the ordering options for the EpicGvgDefenseTeams queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByDefenseHeroes orders the results by the defense_heroes field. +func ByDefenseHeroes(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDefenseHeroes, opts...).ToFunc() +} + +// ByCreator orders the results by the creator field. +func ByCreator(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreator, opts...).ToFunc() +} + +// ByCreateTime orders the results by the create_time field. +func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateTime, opts...).ToFunc() +} + +// ByUpdater orders the results by the updater field. +func ByUpdater(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdater, opts...).ToFunc() +} + +// ByUpdateTime orders the results by the update_time field. +func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() +} + +// ByDeleted orders the results by the deleted field. +func ByDeleted(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeleted, opts...).ToFunc() +} diff --git a/internal/ent/epicgvgdefenseteams/where.go b/internal/ent/epicgvgdefenseteams/where.go new file mode 100644 index 0000000..11aae7d --- /dev/null +++ b/internal/ent/epicgvgdefenseteams/where.go @@ -0,0 +1,405 @@ +// Code generated by ent, DO NOT EDIT. + +package epicgvgdefenseteams + +import ( + "epic-ent/internal/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" +) + +// ID filters vertices based on their ID field. +func ID(id int64) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int64) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int64) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int64) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int64) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int64) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int64) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int64) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int64) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldLTE(FieldID, id)) +} + +// DefenseHeroes applies equality check predicate on the "defense_heroes" field. It's identical to DefenseHeroesEQ. +func DefenseHeroes(v string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldEQ(FieldDefenseHeroes, v)) +} + +// Creator applies equality check predicate on the "creator" field. It's identical to CreatorEQ. +func Creator(v string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldEQ(FieldCreator, v)) +} + +// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. +func CreateTime(v time.Time) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldEQ(FieldCreateTime, v)) +} + +// Updater applies equality check predicate on the "updater" field. It's identical to UpdaterEQ. +func Updater(v string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldEQ(FieldUpdater, v)) +} + +// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. +func UpdateTime(v time.Time) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldEQ(FieldUpdateTime, v)) +} + +// Deleted applies equality check predicate on the "deleted" field. It's identical to DeletedEQ. +func Deleted(v bool) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldEQ(FieldDeleted, v)) +} + +// DefenseHeroesEQ applies the EQ predicate on the "defense_heroes" field. +func DefenseHeroesEQ(v string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldEQ(FieldDefenseHeroes, v)) +} + +// DefenseHeroesNEQ applies the NEQ predicate on the "defense_heroes" field. +func DefenseHeroesNEQ(v string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldNEQ(FieldDefenseHeroes, v)) +} + +// DefenseHeroesIn applies the In predicate on the "defense_heroes" field. +func DefenseHeroesIn(vs ...string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldIn(FieldDefenseHeroes, vs...)) +} + +// DefenseHeroesNotIn applies the NotIn predicate on the "defense_heroes" field. +func DefenseHeroesNotIn(vs ...string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldNotIn(FieldDefenseHeroes, vs...)) +} + +// DefenseHeroesGT applies the GT predicate on the "defense_heroes" field. +func DefenseHeroesGT(v string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldGT(FieldDefenseHeroes, v)) +} + +// DefenseHeroesGTE applies the GTE predicate on the "defense_heroes" field. +func DefenseHeroesGTE(v string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldGTE(FieldDefenseHeroes, v)) +} + +// DefenseHeroesLT applies the LT predicate on the "defense_heroes" field. +func DefenseHeroesLT(v string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldLT(FieldDefenseHeroes, v)) +} + +// DefenseHeroesLTE applies the LTE predicate on the "defense_heroes" field. +func DefenseHeroesLTE(v string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldLTE(FieldDefenseHeroes, v)) +} + +// DefenseHeroesContains applies the Contains predicate on the "defense_heroes" field. +func DefenseHeroesContains(v string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldContains(FieldDefenseHeroes, v)) +} + +// DefenseHeroesHasPrefix applies the HasPrefix predicate on the "defense_heroes" field. +func DefenseHeroesHasPrefix(v string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldHasPrefix(FieldDefenseHeroes, v)) +} + +// DefenseHeroesHasSuffix applies the HasSuffix predicate on the "defense_heroes" field. +func DefenseHeroesHasSuffix(v string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldHasSuffix(FieldDefenseHeroes, v)) +} + +// DefenseHeroesEqualFold applies the EqualFold predicate on the "defense_heroes" field. +func DefenseHeroesEqualFold(v string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldEqualFold(FieldDefenseHeroes, v)) +} + +// DefenseHeroesContainsFold applies the ContainsFold predicate on the "defense_heroes" field. +func DefenseHeroesContainsFold(v string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldContainsFold(FieldDefenseHeroes, v)) +} + +// CreatorEQ applies the EQ predicate on the "creator" field. +func CreatorEQ(v string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldEQ(FieldCreator, v)) +} + +// CreatorNEQ applies the NEQ predicate on the "creator" field. +func CreatorNEQ(v string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldNEQ(FieldCreator, v)) +} + +// CreatorIn applies the In predicate on the "creator" field. +func CreatorIn(vs ...string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldIn(FieldCreator, vs...)) +} + +// CreatorNotIn applies the NotIn predicate on the "creator" field. +func CreatorNotIn(vs ...string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldNotIn(FieldCreator, vs...)) +} + +// CreatorGT applies the GT predicate on the "creator" field. +func CreatorGT(v string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldGT(FieldCreator, v)) +} + +// CreatorGTE applies the GTE predicate on the "creator" field. +func CreatorGTE(v string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldGTE(FieldCreator, v)) +} + +// CreatorLT applies the LT predicate on the "creator" field. +func CreatorLT(v string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldLT(FieldCreator, v)) +} + +// CreatorLTE applies the LTE predicate on the "creator" field. +func CreatorLTE(v string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldLTE(FieldCreator, v)) +} + +// CreatorContains applies the Contains predicate on the "creator" field. +func CreatorContains(v string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldContains(FieldCreator, v)) +} + +// CreatorHasPrefix applies the HasPrefix predicate on the "creator" field. +func CreatorHasPrefix(v string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldHasPrefix(FieldCreator, v)) +} + +// CreatorHasSuffix applies the HasSuffix predicate on the "creator" field. +func CreatorHasSuffix(v string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldHasSuffix(FieldCreator, v)) +} + +// CreatorEqualFold applies the EqualFold predicate on the "creator" field. +func CreatorEqualFold(v string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldEqualFold(FieldCreator, v)) +} + +// CreatorContainsFold applies the ContainsFold predicate on the "creator" field. +func CreatorContainsFold(v string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldContainsFold(FieldCreator, v)) +} + +// CreateTimeEQ applies the EQ predicate on the "create_time" field. +func CreateTimeEQ(v time.Time) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldEQ(FieldCreateTime, v)) +} + +// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. +func CreateTimeNEQ(v time.Time) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldNEQ(FieldCreateTime, v)) +} + +// CreateTimeIn applies the In predicate on the "create_time" field. +func CreateTimeIn(vs ...time.Time) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldIn(FieldCreateTime, vs...)) +} + +// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. +func CreateTimeNotIn(vs ...time.Time) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldNotIn(FieldCreateTime, vs...)) +} + +// CreateTimeGT applies the GT predicate on the "create_time" field. +func CreateTimeGT(v time.Time) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldGT(FieldCreateTime, v)) +} + +// CreateTimeGTE applies the GTE predicate on the "create_time" field. +func CreateTimeGTE(v time.Time) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldGTE(FieldCreateTime, v)) +} + +// CreateTimeLT applies the LT predicate on the "create_time" field. +func CreateTimeLT(v time.Time) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldLT(FieldCreateTime, v)) +} + +// CreateTimeLTE applies the LTE predicate on the "create_time" field. +func CreateTimeLTE(v time.Time) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldLTE(FieldCreateTime, v)) +} + +// CreateTimeIsNil applies the IsNil predicate on the "create_time" field. +func CreateTimeIsNil() predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldIsNull(FieldCreateTime)) +} + +// CreateTimeNotNil applies the NotNil predicate on the "create_time" field. +func CreateTimeNotNil() predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldNotNull(FieldCreateTime)) +} + +// UpdaterEQ applies the EQ predicate on the "updater" field. +func UpdaterEQ(v string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldEQ(FieldUpdater, v)) +} + +// UpdaterNEQ applies the NEQ predicate on the "updater" field. +func UpdaterNEQ(v string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldNEQ(FieldUpdater, v)) +} + +// UpdaterIn applies the In predicate on the "updater" field. +func UpdaterIn(vs ...string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldIn(FieldUpdater, vs...)) +} + +// UpdaterNotIn applies the NotIn predicate on the "updater" field. +func UpdaterNotIn(vs ...string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldNotIn(FieldUpdater, vs...)) +} + +// UpdaterGT applies the GT predicate on the "updater" field. +func UpdaterGT(v string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldGT(FieldUpdater, v)) +} + +// UpdaterGTE applies the GTE predicate on the "updater" field. +func UpdaterGTE(v string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldGTE(FieldUpdater, v)) +} + +// UpdaterLT applies the LT predicate on the "updater" field. +func UpdaterLT(v string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldLT(FieldUpdater, v)) +} + +// UpdaterLTE applies the LTE predicate on the "updater" field. +func UpdaterLTE(v string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldLTE(FieldUpdater, v)) +} + +// UpdaterContains applies the Contains predicate on the "updater" field. +func UpdaterContains(v string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldContains(FieldUpdater, v)) +} + +// UpdaterHasPrefix applies the HasPrefix predicate on the "updater" field. +func UpdaterHasPrefix(v string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldHasPrefix(FieldUpdater, v)) +} + +// UpdaterHasSuffix applies the HasSuffix predicate on the "updater" field. +func UpdaterHasSuffix(v string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldHasSuffix(FieldUpdater, v)) +} + +// UpdaterEqualFold applies the EqualFold predicate on the "updater" field. +func UpdaterEqualFold(v string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldEqualFold(FieldUpdater, v)) +} + +// UpdaterContainsFold applies the ContainsFold predicate on the "updater" field. +func UpdaterContainsFold(v string) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldContainsFold(FieldUpdater, v)) +} + +// UpdateTimeEQ applies the EQ predicate on the "update_time" field. +func UpdateTimeEQ(v time.Time) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldEQ(FieldUpdateTime, v)) +} + +// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. +func UpdateTimeNEQ(v time.Time) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldNEQ(FieldUpdateTime, v)) +} + +// UpdateTimeIn applies the In predicate on the "update_time" field. +func UpdateTimeIn(vs ...time.Time) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. +func UpdateTimeNotIn(vs ...time.Time) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldNotIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeGT applies the GT predicate on the "update_time" field. +func UpdateTimeGT(v time.Time) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldGT(FieldUpdateTime, v)) +} + +// UpdateTimeGTE applies the GTE predicate on the "update_time" field. +func UpdateTimeGTE(v time.Time) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldGTE(FieldUpdateTime, v)) +} + +// UpdateTimeLT applies the LT predicate on the "update_time" field. +func UpdateTimeLT(v time.Time) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldLT(FieldUpdateTime, v)) +} + +// UpdateTimeLTE applies the LTE predicate on the "update_time" field. +func UpdateTimeLTE(v time.Time) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldLTE(FieldUpdateTime, v)) +} + +// UpdateTimeIsNil applies the IsNil predicate on the "update_time" field. +func UpdateTimeIsNil() predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldIsNull(FieldUpdateTime)) +} + +// UpdateTimeNotNil applies the NotNil predicate on the "update_time" field. +func UpdateTimeNotNil() predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldNotNull(FieldUpdateTime)) +} + +// DeletedEQ applies the EQ predicate on the "deleted" field. +func DeletedEQ(v bool) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldEQ(FieldDeleted, v)) +} + +// DeletedNEQ applies the NEQ predicate on the "deleted" field. +func DeletedNEQ(v bool) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.FieldNEQ(FieldDeleted, v)) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.EpicGvgDefenseTeams) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.EpicGvgDefenseTeams) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.EpicGvgDefenseTeams) predicate.EpicGvgDefenseTeams { + return predicate.EpicGvgDefenseTeams(sql.NotPredicates(p)) +} diff --git a/internal/ent/epicgvgdefenseteams_create.go b/internal/ent/epicgvgdefenseteams_create.go new file mode 100644 index 0000000..7a9779a --- /dev/null +++ b/internal/ent/epicgvgdefenseteams_create.go @@ -0,0 +1,286 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "epic-ent/internal/ent/epicgvgdefenseteams" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// EpicGvgDefenseTeamsCreate is the builder for creating a EpicGvgDefenseTeams entity. +type EpicGvgDefenseTeamsCreate struct { + config + mutation *EpicGvgDefenseTeamsMutation + hooks []Hook +} + +// SetDefenseHeroes sets the "defense_heroes" field. +func (_c *EpicGvgDefenseTeamsCreate) SetDefenseHeroes(v string) *EpicGvgDefenseTeamsCreate { + _c.mutation.SetDefenseHeroes(v) + return _c +} + +// SetCreator sets the "creator" field. +func (_c *EpicGvgDefenseTeamsCreate) SetCreator(v string) *EpicGvgDefenseTeamsCreate { + _c.mutation.SetCreator(v) + return _c +} + +// SetCreateTime sets the "create_time" field. +func (_c *EpicGvgDefenseTeamsCreate) SetCreateTime(v time.Time) *EpicGvgDefenseTeamsCreate { + _c.mutation.SetCreateTime(v) + return _c +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (_c *EpicGvgDefenseTeamsCreate) SetNillableCreateTime(v *time.Time) *EpicGvgDefenseTeamsCreate { + if v != nil { + _c.SetCreateTime(*v) + } + return _c +} + +// SetUpdater sets the "updater" field. +func (_c *EpicGvgDefenseTeamsCreate) SetUpdater(v string) *EpicGvgDefenseTeamsCreate { + _c.mutation.SetUpdater(v) + return _c +} + +// SetUpdateTime sets the "update_time" field. +func (_c *EpicGvgDefenseTeamsCreate) SetUpdateTime(v time.Time) *EpicGvgDefenseTeamsCreate { + _c.mutation.SetUpdateTime(v) + return _c +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (_c *EpicGvgDefenseTeamsCreate) SetNillableUpdateTime(v *time.Time) *EpicGvgDefenseTeamsCreate { + if v != nil { + _c.SetUpdateTime(*v) + } + return _c +} + +// SetDeleted sets the "deleted" field. +func (_c *EpicGvgDefenseTeamsCreate) SetDeleted(v bool) *EpicGvgDefenseTeamsCreate { + _c.mutation.SetDeleted(v) + return _c +} + +// SetID sets the "id" field. +func (_c *EpicGvgDefenseTeamsCreate) SetID(v int64) *EpicGvgDefenseTeamsCreate { + _c.mutation.SetID(v) + return _c +} + +// Mutation returns the EpicGvgDefenseTeamsMutation object of the builder. +func (_c *EpicGvgDefenseTeamsCreate) Mutation() *EpicGvgDefenseTeamsMutation { + return _c.mutation +} + +// Save creates the EpicGvgDefenseTeams in the database. +func (_c *EpicGvgDefenseTeamsCreate) Save(ctx context.Context) (*EpicGvgDefenseTeams, error) { + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *EpicGvgDefenseTeamsCreate) SaveX(ctx context.Context) *EpicGvgDefenseTeams { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *EpicGvgDefenseTeamsCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *EpicGvgDefenseTeamsCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *EpicGvgDefenseTeamsCreate) check() error { + if _, ok := _c.mutation.DefenseHeroes(); !ok { + return &ValidationError{Name: "defense_heroes", err: errors.New(`ent: missing required field "EpicGvgDefenseTeams.defense_heroes"`)} + } + if v, ok := _c.mutation.DefenseHeroes(); ok { + if err := epicgvgdefenseteams.DefenseHeroesValidator(v); err != nil { + return &ValidationError{Name: "defense_heroes", err: fmt.Errorf(`ent: validator failed for field "EpicGvgDefenseTeams.defense_heroes": %w`, err)} + } + } + if _, ok := _c.mutation.Creator(); !ok { + return &ValidationError{Name: "creator", err: errors.New(`ent: missing required field "EpicGvgDefenseTeams.creator"`)} + } + if v, ok := _c.mutation.Creator(); ok { + if err := epicgvgdefenseteams.CreatorValidator(v); err != nil { + return &ValidationError{Name: "creator", err: fmt.Errorf(`ent: validator failed for field "EpicGvgDefenseTeams.creator": %w`, err)} + } + } + if _, ok := _c.mutation.Updater(); !ok { + return &ValidationError{Name: "updater", err: errors.New(`ent: missing required field "EpicGvgDefenseTeams.updater"`)} + } + if v, ok := _c.mutation.Updater(); ok { + if err := epicgvgdefenseteams.UpdaterValidator(v); err != nil { + return &ValidationError{Name: "updater", err: fmt.Errorf(`ent: validator failed for field "EpicGvgDefenseTeams.updater": %w`, err)} + } + } + if _, ok := _c.mutation.Deleted(); !ok { + return &ValidationError{Name: "deleted", err: errors.New(`ent: missing required field "EpicGvgDefenseTeams.deleted"`)} + } + return nil +} + +func (_c *EpicGvgDefenseTeamsCreate) sqlSave(ctx context.Context) (*EpicGvgDefenseTeams, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != _node.ID { + id := _spec.ID.Value.(int64) + _node.ID = int64(id) + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *EpicGvgDefenseTeamsCreate) createSpec() (*EpicGvgDefenseTeams, *sqlgraph.CreateSpec) { + var ( + _node = &EpicGvgDefenseTeams{config: _c.config} + _spec = sqlgraph.NewCreateSpec(epicgvgdefenseteams.Table, sqlgraph.NewFieldSpec(epicgvgdefenseteams.FieldID, field.TypeInt64)) + ) + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := _c.mutation.DefenseHeroes(); ok { + _spec.SetField(epicgvgdefenseteams.FieldDefenseHeroes, field.TypeString, value) + _node.DefenseHeroes = value + } + if value, ok := _c.mutation.Creator(); ok { + _spec.SetField(epicgvgdefenseteams.FieldCreator, field.TypeString, value) + _node.Creator = value + } + if value, ok := _c.mutation.CreateTime(); ok { + _spec.SetField(epicgvgdefenseteams.FieldCreateTime, field.TypeTime, value) + _node.CreateTime = &value + } + if value, ok := _c.mutation.Updater(); ok { + _spec.SetField(epicgvgdefenseteams.FieldUpdater, field.TypeString, value) + _node.Updater = value + } + if value, ok := _c.mutation.UpdateTime(); ok { + _spec.SetField(epicgvgdefenseteams.FieldUpdateTime, field.TypeTime, value) + _node.UpdateTime = &value + } + if value, ok := _c.mutation.Deleted(); ok { + _spec.SetField(epicgvgdefenseteams.FieldDeleted, field.TypeBool, value) + _node.Deleted = value + } + return _node, _spec +} + +// EpicGvgDefenseTeamsCreateBulk is the builder for creating many EpicGvgDefenseTeams entities in bulk. +type EpicGvgDefenseTeamsCreateBulk struct { + config + err error + builders []*EpicGvgDefenseTeamsCreate +} + +// Save creates the EpicGvgDefenseTeams entities in the database. +func (_c *EpicGvgDefenseTeamsCreateBulk) Save(ctx context.Context) ([]*EpicGvgDefenseTeams, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*EpicGvgDefenseTeams, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*EpicGvgDefenseTeamsMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil && nodes[i].ID == 0 { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int64(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *EpicGvgDefenseTeamsCreateBulk) SaveX(ctx context.Context) []*EpicGvgDefenseTeams { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *EpicGvgDefenseTeamsCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *EpicGvgDefenseTeamsCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/ent/epicgvgdefenseteams_delete.go b/internal/ent/epicgvgdefenseteams_delete.go new file mode 100644 index 0000000..41144ad --- /dev/null +++ b/internal/ent/epicgvgdefenseteams_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "epic-ent/internal/ent/epicgvgdefenseteams" + "epic-ent/internal/ent/predicate" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// EpicGvgDefenseTeamsDelete is the builder for deleting a EpicGvgDefenseTeams entity. +type EpicGvgDefenseTeamsDelete struct { + config + hooks []Hook + mutation *EpicGvgDefenseTeamsMutation +} + +// Where appends a list predicates to the EpicGvgDefenseTeamsDelete builder. +func (_d *EpicGvgDefenseTeamsDelete) Where(ps ...predicate.EpicGvgDefenseTeams) *EpicGvgDefenseTeamsDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *EpicGvgDefenseTeamsDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *EpicGvgDefenseTeamsDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *EpicGvgDefenseTeamsDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(epicgvgdefenseteams.Table, sqlgraph.NewFieldSpec(epicgvgdefenseteams.FieldID, field.TypeInt64)) + if ps := _d.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + _d.mutation.done = true + return affected, err +} + +// EpicGvgDefenseTeamsDeleteOne is the builder for deleting a single EpicGvgDefenseTeams entity. +type EpicGvgDefenseTeamsDeleteOne struct { + _d *EpicGvgDefenseTeamsDelete +} + +// Where appends a list predicates to the EpicGvgDefenseTeamsDelete builder. +func (_d *EpicGvgDefenseTeamsDeleteOne) Where(ps ...predicate.EpicGvgDefenseTeams) *EpicGvgDefenseTeamsDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *EpicGvgDefenseTeamsDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{epicgvgdefenseteams.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *EpicGvgDefenseTeamsDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/ent/epicgvgdefenseteams_query.go b/internal/ent/epicgvgdefenseteams_query.go new file mode 100644 index 0000000..27f984a --- /dev/null +++ b/internal/ent/epicgvgdefenseteams_query.go @@ -0,0 +1,527 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "epic-ent/internal/ent/epicgvgdefenseteams" + "epic-ent/internal/ent/predicate" + "fmt" + "math" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// EpicGvgDefenseTeamsQuery is the builder for querying EpicGvgDefenseTeams entities. +type EpicGvgDefenseTeamsQuery struct { + config + ctx *QueryContext + order []epicgvgdefenseteams.OrderOption + inters []Interceptor + predicates []predicate.EpicGvgDefenseTeams + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the EpicGvgDefenseTeamsQuery builder. +func (_q *EpicGvgDefenseTeamsQuery) Where(ps ...predicate.EpicGvgDefenseTeams) *EpicGvgDefenseTeamsQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *EpicGvgDefenseTeamsQuery) Limit(limit int) *EpicGvgDefenseTeamsQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *EpicGvgDefenseTeamsQuery) Offset(offset int) *EpicGvgDefenseTeamsQuery { + _q.ctx.Offset = &offset + return _q +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (_q *EpicGvgDefenseTeamsQuery) Unique(unique bool) *EpicGvgDefenseTeamsQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *EpicGvgDefenseTeamsQuery) Order(o ...epicgvgdefenseteams.OrderOption) *EpicGvgDefenseTeamsQuery { + _q.order = append(_q.order, o...) + return _q +} + +// First returns the first EpicGvgDefenseTeams entity from the query. +// Returns a *NotFoundError when no EpicGvgDefenseTeams was found. +func (_q *EpicGvgDefenseTeamsQuery) First(ctx context.Context) (*EpicGvgDefenseTeams, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{epicgvgdefenseteams.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *EpicGvgDefenseTeamsQuery) FirstX(ctx context.Context) *EpicGvgDefenseTeams { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first EpicGvgDefenseTeams ID from the query. +// Returns a *NotFoundError when no EpicGvgDefenseTeams ID was found. +func (_q *EpicGvgDefenseTeamsQuery) FirstID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{epicgvgdefenseteams.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *EpicGvgDefenseTeamsQuery) FirstIDX(ctx context.Context) int64 { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single EpicGvgDefenseTeams entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one EpicGvgDefenseTeams entity is found. +// Returns a *NotFoundError when no EpicGvgDefenseTeams entities are found. +func (_q *EpicGvgDefenseTeamsQuery) Only(ctx context.Context) (*EpicGvgDefenseTeams, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{epicgvgdefenseteams.Label} + default: + return nil, &NotSingularError{epicgvgdefenseteams.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *EpicGvgDefenseTeamsQuery) OnlyX(ctx context.Context) *EpicGvgDefenseTeams { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only EpicGvgDefenseTeams ID in the query. +// Returns a *NotSingularError when more than one EpicGvgDefenseTeams ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *EpicGvgDefenseTeamsQuery) OnlyID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{epicgvgdefenseteams.Label} + default: + err = &NotSingularError{epicgvgdefenseteams.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *EpicGvgDefenseTeamsQuery) OnlyIDX(ctx context.Context) int64 { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of EpicGvgDefenseTeamsSlice. +func (_q *EpicGvgDefenseTeamsQuery) All(ctx context.Context) ([]*EpicGvgDefenseTeams, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*EpicGvgDefenseTeams, *EpicGvgDefenseTeamsQuery]() + return withInterceptors[[]*EpicGvgDefenseTeams](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *EpicGvgDefenseTeamsQuery) AllX(ctx context.Context) []*EpicGvgDefenseTeams { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of EpicGvgDefenseTeams IDs. +func (_q *EpicGvgDefenseTeamsQuery) IDs(ctx context.Context) (ids []int64, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(epicgvgdefenseteams.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *EpicGvgDefenseTeamsQuery) IDsX(ctx context.Context) []int64 { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *EpicGvgDefenseTeamsQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, _q, querierCount[*EpicGvgDefenseTeamsQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *EpicGvgDefenseTeamsQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (_q *EpicGvgDefenseTeamsQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *EpicGvgDefenseTeamsQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the EpicGvgDefenseTeamsQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (_q *EpicGvgDefenseTeamsQuery) Clone() *EpicGvgDefenseTeamsQuery { + if _q == nil { + return nil + } + return &EpicGvgDefenseTeamsQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]epicgvgdefenseteams.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.EpicGvgDefenseTeams{}, _q.predicates...), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + } +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// DefenseHeroes string `json:"defense_heroes,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.EpicGvgDefenseTeams.Query(). +// GroupBy(epicgvgdefenseteams.FieldDefenseHeroes). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *EpicGvgDefenseTeamsQuery) GroupBy(field string, fields ...string) *EpicGvgDefenseTeamsGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &EpicGvgDefenseTeamsGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = epicgvgdefenseteams.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// DefenseHeroes string `json:"defense_heroes,omitempty"` +// } +// +// client.EpicGvgDefenseTeams.Query(). +// Select(epicgvgdefenseteams.FieldDefenseHeroes). +// Scan(ctx, &v) +func (_q *EpicGvgDefenseTeamsQuery) Select(fields ...string) *EpicGvgDefenseTeamsSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &EpicGvgDefenseTeamsSelect{EpicGvgDefenseTeamsQuery: _q} + sbuild.label = epicgvgdefenseteams.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a EpicGvgDefenseTeamsSelect configured with the given aggregations. +func (_q *EpicGvgDefenseTeamsQuery) Aggregate(fns ...AggregateFunc) *EpicGvgDefenseTeamsSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *EpicGvgDefenseTeamsQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !epicgvgdefenseteams.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if _q.path != nil { + prev, err := _q.path(ctx) + if err != nil { + return err + } + _q.sql = prev + } + return nil +} + +func (_q *EpicGvgDefenseTeamsQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*EpicGvgDefenseTeams, error) { + var ( + nodes = []*EpicGvgDefenseTeams{} + _spec = _q.querySpec() + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*EpicGvgDefenseTeams).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &EpicGvgDefenseTeams{config: _q.config} + nodes = append(nodes, node) + return node.assignValues(columns, values) + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + return nodes, nil +} + +func (_q *EpicGvgDefenseTeamsQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique + } + return sqlgraph.CountNodes(ctx, _q.driver, _spec) +} + +func (_q *EpicGvgDefenseTeamsQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(epicgvgdefenseteams.Table, epicgvgdefenseteams.Columns, sqlgraph.NewFieldSpec(epicgvgdefenseteams.FieldID, field.TypeInt64)) + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if _q.path != nil { + _spec.Unique = true + } + if fields := _q.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, epicgvgdefenseteams.FieldID) + for i := range fields { + if fields[i] != epicgvgdefenseteams.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := _q.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := _q.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := _q.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := _q.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (_q *EpicGvgDefenseTeamsQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(epicgvgdefenseteams.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = epicgvgdefenseteams.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if _q.sql != nil { + selector = _q.sql + selector.Select(selector.Columns(columns...)...) + } + if _q.ctx.Unique != nil && *_q.ctx.Unique { + selector.Distinct() + } + for _, p := range _q.predicates { + p(selector) + } + for _, p := range _q.order { + p(selector) + } + if offset := _q.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := _q.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// EpicGvgDefenseTeamsGroupBy is the group-by builder for EpicGvgDefenseTeams entities. +type EpicGvgDefenseTeamsGroupBy struct { + selector + build *EpicGvgDefenseTeamsQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *EpicGvgDefenseTeamsGroupBy) Aggregate(fns ...AggregateFunc) *EpicGvgDefenseTeamsGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *EpicGvgDefenseTeamsGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*EpicGvgDefenseTeamsQuery, *EpicGvgDefenseTeamsGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *EpicGvgDefenseTeamsGroupBy) sqlScan(ctx context.Context, root *EpicGvgDefenseTeamsQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*_g.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// EpicGvgDefenseTeamsSelect is the builder for selecting fields of EpicGvgDefenseTeams entities. +type EpicGvgDefenseTeamsSelect struct { + *EpicGvgDefenseTeamsQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *EpicGvgDefenseTeamsSelect) Aggregate(fns ...AggregateFunc) *EpicGvgDefenseTeamsSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *EpicGvgDefenseTeamsSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*EpicGvgDefenseTeamsQuery, *EpicGvgDefenseTeamsSelect](ctx, _s.EpicGvgDefenseTeamsQuery, _s, _s.inters, v) +} + +func (_s *EpicGvgDefenseTeamsSelect) sqlScan(ctx context.Context, root *EpicGvgDefenseTeamsQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/internal/ent/epicgvgdefenseteams_update.go b/internal/ent/epicgvgdefenseteams_update.go new file mode 100644 index 0000000..12983d0 --- /dev/null +++ b/internal/ent/epicgvgdefenseteams_update.go @@ -0,0 +1,462 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "epic-ent/internal/ent/epicgvgdefenseteams" + "epic-ent/internal/ent/predicate" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// EpicGvgDefenseTeamsUpdate is the builder for updating EpicGvgDefenseTeams entities. +type EpicGvgDefenseTeamsUpdate struct { + config + hooks []Hook + mutation *EpicGvgDefenseTeamsMutation +} + +// Where appends a list predicates to the EpicGvgDefenseTeamsUpdate builder. +func (_u *EpicGvgDefenseTeamsUpdate) Where(ps ...predicate.EpicGvgDefenseTeams) *EpicGvgDefenseTeamsUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetDefenseHeroes sets the "defense_heroes" field. +func (_u *EpicGvgDefenseTeamsUpdate) SetDefenseHeroes(v string) *EpicGvgDefenseTeamsUpdate { + _u.mutation.SetDefenseHeroes(v) + return _u +} + +// SetNillableDefenseHeroes sets the "defense_heroes" field if the given value is not nil. +func (_u *EpicGvgDefenseTeamsUpdate) SetNillableDefenseHeroes(v *string) *EpicGvgDefenseTeamsUpdate { + if v != nil { + _u.SetDefenseHeroes(*v) + } + return _u +} + +// SetCreator sets the "creator" field. +func (_u *EpicGvgDefenseTeamsUpdate) SetCreator(v string) *EpicGvgDefenseTeamsUpdate { + _u.mutation.SetCreator(v) + return _u +} + +// SetNillableCreator sets the "creator" field if the given value is not nil. +func (_u *EpicGvgDefenseTeamsUpdate) SetNillableCreator(v *string) *EpicGvgDefenseTeamsUpdate { + if v != nil { + _u.SetCreator(*v) + } + return _u +} + +// SetCreateTime sets the "create_time" field. +func (_u *EpicGvgDefenseTeamsUpdate) SetCreateTime(v time.Time) *EpicGvgDefenseTeamsUpdate { + _u.mutation.SetCreateTime(v) + return _u +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (_u *EpicGvgDefenseTeamsUpdate) SetNillableCreateTime(v *time.Time) *EpicGvgDefenseTeamsUpdate { + if v != nil { + _u.SetCreateTime(*v) + } + return _u +} + +// ClearCreateTime clears the value of the "create_time" field. +func (_u *EpicGvgDefenseTeamsUpdate) ClearCreateTime() *EpicGvgDefenseTeamsUpdate { + _u.mutation.ClearCreateTime() + return _u +} + +// SetUpdater sets the "updater" field. +func (_u *EpicGvgDefenseTeamsUpdate) SetUpdater(v string) *EpicGvgDefenseTeamsUpdate { + _u.mutation.SetUpdater(v) + return _u +} + +// SetNillableUpdater sets the "updater" field if the given value is not nil. +func (_u *EpicGvgDefenseTeamsUpdate) SetNillableUpdater(v *string) *EpicGvgDefenseTeamsUpdate { + if v != nil { + _u.SetUpdater(*v) + } + return _u +} + +// SetUpdateTime sets the "update_time" field. +func (_u *EpicGvgDefenseTeamsUpdate) SetUpdateTime(v time.Time) *EpicGvgDefenseTeamsUpdate { + _u.mutation.SetUpdateTime(v) + return _u +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (_u *EpicGvgDefenseTeamsUpdate) SetNillableUpdateTime(v *time.Time) *EpicGvgDefenseTeamsUpdate { + if v != nil { + _u.SetUpdateTime(*v) + } + return _u +} + +// ClearUpdateTime clears the value of the "update_time" field. +func (_u *EpicGvgDefenseTeamsUpdate) ClearUpdateTime() *EpicGvgDefenseTeamsUpdate { + _u.mutation.ClearUpdateTime() + return _u +} + +// SetDeleted sets the "deleted" field. +func (_u *EpicGvgDefenseTeamsUpdate) SetDeleted(v bool) *EpicGvgDefenseTeamsUpdate { + _u.mutation.SetDeleted(v) + return _u +} + +// SetNillableDeleted sets the "deleted" field if the given value is not nil. +func (_u *EpicGvgDefenseTeamsUpdate) SetNillableDeleted(v *bool) *EpicGvgDefenseTeamsUpdate { + if v != nil { + _u.SetDeleted(*v) + } + return _u +} + +// Mutation returns the EpicGvgDefenseTeamsMutation object of the builder. +func (_u *EpicGvgDefenseTeamsUpdate) Mutation() *EpicGvgDefenseTeamsMutation { + return _u.mutation +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *EpicGvgDefenseTeamsUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *EpicGvgDefenseTeamsUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *EpicGvgDefenseTeamsUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *EpicGvgDefenseTeamsUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *EpicGvgDefenseTeamsUpdate) check() error { + if v, ok := _u.mutation.DefenseHeroes(); ok { + if err := epicgvgdefenseteams.DefenseHeroesValidator(v); err != nil { + return &ValidationError{Name: "defense_heroes", err: fmt.Errorf(`ent: validator failed for field "EpicGvgDefenseTeams.defense_heroes": %w`, err)} + } + } + if v, ok := _u.mutation.Creator(); ok { + if err := epicgvgdefenseteams.CreatorValidator(v); err != nil { + return &ValidationError{Name: "creator", err: fmt.Errorf(`ent: validator failed for field "EpicGvgDefenseTeams.creator": %w`, err)} + } + } + if v, ok := _u.mutation.Updater(); ok { + if err := epicgvgdefenseteams.UpdaterValidator(v); err != nil { + return &ValidationError{Name: "updater", err: fmt.Errorf(`ent: validator failed for field "EpicGvgDefenseTeams.updater": %w`, err)} + } + } + return nil +} + +func (_u *EpicGvgDefenseTeamsUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(epicgvgdefenseteams.Table, epicgvgdefenseteams.Columns, sqlgraph.NewFieldSpec(epicgvgdefenseteams.FieldID, field.TypeInt64)) + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.DefenseHeroes(); ok { + _spec.SetField(epicgvgdefenseteams.FieldDefenseHeroes, field.TypeString, value) + } + if value, ok := _u.mutation.Creator(); ok { + _spec.SetField(epicgvgdefenseteams.FieldCreator, field.TypeString, value) + } + if value, ok := _u.mutation.CreateTime(); ok { + _spec.SetField(epicgvgdefenseteams.FieldCreateTime, field.TypeTime, value) + } + if _u.mutation.CreateTimeCleared() { + _spec.ClearField(epicgvgdefenseteams.FieldCreateTime, field.TypeTime) + } + if value, ok := _u.mutation.Updater(); ok { + _spec.SetField(epicgvgdefenseteams.FieldUpdater, field.TypeString, value) + } + if value, ok := _u.mutation.UpdateTime(); ok { + _spec.SetField(epicgvgdefenseteams.FieldUpdateTime, field.TypeTime, value) + } + if _u.mutation.UpdateTimeCleared() { + _spec.ClearField(epicgvgdefenseteams.FieldUpdateTime, field.TypeTime) + } + if value, ok := _u.mutation.Deleted(); ok { + _spec.SetField(epicgvgdefenseteams.FieldDeleted, field.TypeBool, value) + } + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{epicgvgdefenseteams.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// EpicGvgDefenseTeamsUpdateOne is the builder for updating a single EpicGvgDefenseTeams entity. +type EpicGvgDefenseTeamsUpdateOne struct { + config + fields []string + hooks []Hook + mutation *EpicGvgDefenseTeamsMutation +} + +// SetDefenseHeroes sets the "defense_heroes" field. +func (_u *EpicGvgDefenseTeamsUpdateOne) SetDefenseHeroes(v string) *EpicGvgDefenseTeamsUpdateOne { + _u.mutation.SetDefenseHeroes(v) + return _u +} + +// SetNillableDefenseHeroes sets the "defense_heroes" field if the given value is not nil. +func (_u *EpicGvgDefenseTeamsUpdateOne) SetNillableDefenseHeroes(v *string) *EpicGvgDefenseTeamsUpdateOne { + if v != nil { + _u.SetDefenseHeroes(*v) + } + return _u +} + +// SetCreator sets the "creator" field. +func (_u *EpicGvgDefenseTeamsUpdateOne) SetCreator(v string) *EpicGvgDefenseTeamsUpdateOne { + _u.mutation.SetCreator(v) + return _u +} + +// SetNillableCreator sets the "creator" field if the given value is not nil. +func (_u *EpicGvgDefenseTeamsUpdateOne) SetNillableCreator(v *string) *EpicGvgDefenseTeamsUpdateOne { + if v != nil { + _u.SetCreator(*v) + } + return _u +} + +// SetCreateTime sets the "create_time" field. +func (_u *EpicGvgDefenseTeamsUpdateOne) SetCreateTime(v time.Time) *EpicGvgDefenseTeamsUpdateOne { + _u.mutation.SetCreateTime(v) + return _u +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (_u *EpicGvgDefenseTeamsUpdateOne) SetNillableCreateTime(v *time.Time) *EpicGvgDefenseTeamsUpdateOne { + if v != nil { + _u.SetCreateTime(*v) + } + return _u +} + +// ClearCreateTime clears the value of the "create_time" field. +func (_u *EpicGvgDefenseTeamsUpdateOne) ClearCreateTime() *EpicGvgDefenseTeamsUpdateOne { + _u.mutation.ClearCreateTime() + return _u +} + +// SetUpdater sets the "updater" field. +func (_u *EpicGvgDefenseTeamsUpdateOne) SetUpdater(v string) *EpicGvgDefenseTeamsUpdateOne { + _u.mutation.SetUpdater(v) + return _u +} + +// SetNillableUpdater sets the "updater" field if the given value is not nil. +func (_u *EpicGvgDefenseTeamsUpdateOne) SetNillableUpdater(v *string) *EpicGvgDefenseTeamsUpdateOne { + if v != nil { + _u.SetUpdater(*v) + } + return _u +} + +// SetUpdateTime sets the "update_time" field. +func (_u *EpicGvgDefenseTeamsUpdateOne) SetUpdateTime(v time.Time) *EpicGvgDefenseTeamsUpdateOne { + _u.mutation.SetUpdateTime(v) + return _u +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (_u *EpicGvgDefenseTeamsUpdateOne) SetNillableUpdateTime(v *time.Time) *EpicGvgDefenseTeamsUpdateOne { + if v != nil { + _u.SetUpdateTime(*v) + } + return _u +} + +// ClearUpdateTime clears the value of the "update_time" field. +func (_u *EpicGvgDefenseTeamsUpdateOne) ClearUpdateTime() *EpicGvgDefenseTeamsUpdateOne { + _u.mutation.ClearUpdateTime() + return _u +} + +// SetDeleted sets the "deleted" field. +func (_u *EpicGvgDefenseTeamsUpdateOne) SetDeleted(v bool) *EpicGvgDefenseTeamsUpdateOne { + _u.mutation.SetDeleted(v) + return _u +} + +// SetNillableDeleted sets the "deleted" field if the given value is not nil. +func (_u *EpicGvgDefenseTeamsUpdateOne) SetNillableDeleted(v *bool) *EpicGvgDefenseTeamsUpdateOne { + if v != nil { + _u.SetDeleted(*v) + } + return _u +} + +// Mutation returns the EpicGvgDefenseTeamsMutation object of the builder. +func (_u *EpicGvgDefenseTeamsUpdateOne) Mutation() *EpicGvgDefenseTeamsMutation { + return _u.mutation +} + +// Where appends a list predicates to the EpicGvgDefenseTeamsUpdate builder. +func (_u *EpicGvgDefenseTeamsUpdateOne) Where(ps ...predicate.EpicGvgDefenseTeams) *EpicGvgDefenseTeamsUpdateOne { + _u.mutation.Where(ps...) + return _u +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (_u *EpicGvgDefenseTeamsUpdateOne) Select(field string, fields ...string) *EpicGvgDefenseTeamsUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated EpicGvgDefenseTeams entity. +func (_u *EpicGvgDefenseTeamsUpdateOne) Save(ctx context.Context) (*EpicGvgDefenseTeams, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *EpicGvgDefenseTeamsUpdateOne) SaveX(ctx context.Context) *EpicGvgDefenseTeams { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *EpicGvgDefenseTeamsUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *EpicGvgDefenseTeamsUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *EpicGvgDefenseTeamsUpdateOne) check() error { + if v, ok := _u.mutation.DefenseHeroes(); ok { + if err := epicgvgdefenseteams.DefenseHeroesValidator(v); err != nil { + return &ValidationError{Name: "defense_heroes", err: fmt.Errorf(`ent: validator failed for field "EpicGvgDefenseTeams.defense_heroes": %w`, err)} + } + } + if v, ok := _u.mutation.Creator(); ok { + if err := epicgvgdefenseteams.CreatorValidator(v); err != nil { + return &ValidationError{Name: "creator", err: fmt.Errorf(`ent: validator failed for field "EpicGvgDefenseTeams.creator": %w`, err)} + } + } + if v, ok := _u.mutation.Updater(); ok { + if err := epicgvgdefenseteams.UpdaterValidator(v); err != nil { + return &ValidationError{Name: "updater", err: fmt.Errorf(`ent: validator failed for field "EpicGvgDefenseTeams.updater": %w`, err)} + } + } + return nil +} + +func (_u *EpicGvgDefenseTeamsUpdateOne) sqlSave(ctx context.Context) (_node *EpicGvgDefenseTeams, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(epicgvgdefenseteams.Table, epicgvgdefenseteams.Columns, sqlgraph.NewFieldSpec(epicgvgdefenseteams.FieldID, field.TypeInt64)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "EpicGvgDefenseTeams.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := _u.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, epicgvgdefenseteams.FieldID) + for _, f := range fields { + if !epicgvgdefenseteams.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != epicgvgdefenseteams.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.DefenseHeroes(); ok { + _spec.SetField(epicgvgdefenseteams.FieldDefenseHeroes, field.TypeString, value) + } + if value, ok := _u.mutation.Creator(); ok { + _spec.SetField(epicgvgdefenseteams.FieldCreator, field.TypeString, value) + } + if value, ok := _u.mutation.CreateTime(); ok { + _spec.SetField(epicgvgdefenseteams.FieldCreateTime, field.TypeTime, value) + } + if _u.mutation.CreateTimeCleared() { + _spec.ClearField(epicgvgdefenseteams.FieldCreateTime, field.TypeTime) + } + if value, ok := _u.mutation.Updater(); ok { + _spec.SetField(epicgvgdefenseteams.FieldUpdater, field.TypeString, value) + } + if value, ok := _u.mutation.UpdateTime(); ok { + _spec.SetField(epicgvgdefenseteams.FieldUpdateTime, field.TypeTime, value) + } + if _u.mutation.UpdateTimeCleared() { + _spec.ClearField(epicgvgdefenseteams.FieldUpdateTime, field.TypeTime) + } + if value, ok := _u.mutation.Deleted(); ok { + _spec.SetField(epicgvgdefenseteams.FieldDeleted, field.TypeBool, value) + } + _node = &EpicGvgDefenseTeams{config: _u.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{epicgvgdefenseteams.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} diff --git a/internal/ent/epicheroinfo.go b/internal/ent/epicheroinfo.go new file mode 100644 index 0000000..73d479b --- /dev/null +++ b/internal/ent/epicheroinfo.go @@ -0,0 +1,304 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "epic-ent/internal/ent/epicheroinfo" + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// EpicHeroInfo is the model entity for the EpicHeroInfo schema. +type EpicHeroInfo struct { + config `json:"-"` + // ID of the ent. + ID int64 `json:"id,omitempty"` + // HeroName holds the value of the "hero_name" field. + HeroName string `json:"hero_name,omitempty"` + // HeroCode holds the value of the "hero_code" field. + HeroCode string `json:"hero_code,omitempty"` + // HeroAttrLv60 holds the value of the "hero_attr_lv60" field. + HeroAttrLv60 string `json:"hero_attr_lv60,omitempty"` + // Creator holds the value of the "creator" field. + Creator string `json:"creator,omitempty"` + // CreateTime holds the value of the "create_time" field. + CreateTime *time.Time `json:"create_time,omitempty"` + // Updater holds the value of the "updater" field. + Updater string `json:"updater,omitempty"` + // UpdateTime holds the value of the "update_time" field. + UpdateTime *time.Time `json:"update_time,omitempty"` + // Deleted holds the value of the "deleted" field. + Deleted bool `json:"deleted,omitempty"` + // NickName holds the value of the "nick_name" field. + NickName string `json:"nick_name,omitempty"` + // Rarity holds the value of the "rarity" field. + Rarity string `json:"rarity,omitempty"` + // Role holds the value of the "role" field. + Role string `json:"role,omitempty"` + // Zodiac holds the value of the "zodiac" field. + Zodiac string `json:"zodiac,omitempty"` + // HeadImgURL holds the value of the "head_img_url" field. + HeadImgURL string `json:"head_img_url,omitempty"` + // Attribute holds the value of the "attribute" field. + Attribute string `json:"attribute,omitempty"` + // Remark holds the value of the "remark" field. + Remark string `json:"remark,omitempty"` + // RawJSON holds the value of the "raw_json" field. + RawJSON string `json:"raw_json,omitempty"` + // SetContentJSON holds the value of the "set_content_json" field. + SetContentJSON string `json:"set_content_json,omitempty"` + // SetUpdateTime holds the value of the "set_update_time" field. + SetUpdateTime *time.Time `json:"set_update_time,omitempty"` + selectValues sql.SelectValues +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*EpicHeroInfo) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case epicheroinfo.FieldDeleted: + values[i] = new(sql.NullBool) + case epicheroinfo.FieldID: + values[i] = new(sql.NullInt64) + case epicheroinfo.FieldHeroName, epicheroinfo.FieldHeroCode, epicheroinfo.FieldHeroAttrLv60, epicheroinfo.FieldCreator, epicheroinfo.FieldUpdater, epicheroinfo.FieldNickName, epicheroinfo.FieldRarity, epicheroinfo.FieldRole, epicheroinfo.FieldZodiac, epicheroinfo.FieldHeadImgURL, epicheroinfo.FieldAttribute, epicheroinfo.FieldRemark, epicheroinfo.FieldRawJSON, epicheroinfo.FieldSetContentJSON: + values[i] = new(sql.NullString) + case epicheroinfo.FieldCreateTime, epicheroinfo.FieldUpdateTime, epicheroinfo.FieldSetUpdateTime: + values[i] = new(sql.NullTime) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the EpicHeroInfo fields. +func (_m *EpicHeroInfo) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case epicheroinfo.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + _m.ID = int64(value.Int64) + case epicheroinfo.FieldHeroName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field hero_name", values[i]) + } else if value.Valid { + _m.HeroName = value.String + } + case epicheroinfo.FieldHeroCode: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field hero_code", values[i]) + } else if value.Valid { + _m.HeroCode = value.String + } + case epicheroinfo.FieldHeroAttrLv60: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field hero_attr_lv60", values[i]) + } else if value.Valid { + _m.HeroAttrLv60 = value.String + } + case epicheroinfo.FieldCreator: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field creator", values[i]) + } else if value.Valid { + _m.Creator = value.String + } + case epicheroinfo.FieldCreateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field create_time", values[i]) + } else if value.Valid { + _m.CreateTime = new(time.Time) + *_m.CreateTime = value.Time + } + case epicheroinfo.FieldUpdater: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field updater", values[i]) + } else if value.Valid { + _m.Updater = value.String + } + case epicheroinfo.FieldUpdateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field update_time", values[i]) + } else if value.Valid { + _m.UpdateTime = new(time.Time) + *_m.UpdateTime = value.Time + } + case epicheroinfo.FieldDeleted: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field deleted", values[i]) + } else if value.Valid { + _m.Deleted = value.Bool + } + case epicheroinfo.FieldNickName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field nick_name", values[i]) + } else if value.Valid { + _m.NickName = value.String + } + case epicheroinfo.FieldRarity: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field rarity", values[i]) + } else if value.Valid { + _m.Rarity = value.String + } + case epicheroinfo.FieldRole: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field role", values[i]) + } else if value.Valid { + _m.Role = value.String + } + case epicheroinfo.FieldZodiac: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field zodiac", values[i]) + } else if value.Valid { + _m.Zodiac = value.String + } + case epicheroinfo.FieldHeadImgURL: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field head_img_url", values[i]) + } else if value.Valid { + _m.HeadImgURL = value.String + } + case epicheroinfo.FieldAttribute: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field attribute", values[i]) + } else if value.Valid { + _m.Attribute = value.String + } + case epicheroinfo.FieldRemark: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field remark", values[i]) + } else if value.Valid { + _m.Remark = value.String + } + case epicheroinfo.FieldRawJSON: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field raw_json", values[i]) + } else if value.Valid { + _m.RawJSON = value.String + } + case epicheroinfo.FieldSetContentJSON: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field set_content_json", values[i]) + } else if value.Valid { + _m.SetContentJSON = value.String + } + case epicheroinfo.FieldSetUpdateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field set_update_time", values[i]) + } else if value.Valid { + _m.SetUpdateTime = new(time.Time) + *_m.SetUpdateTime = value.Time + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the EpicHeroInfo. +// This includes values selected through modifiers, order, etc. +func (_m *EpicHeroInfo) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// Update returns a builder for updating this EpicHeroInfo. +// Note that you need to call EpicHeroInfo.Unwrap() before calling this method if this EpicHeroInfo +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *EpicHeroInfo) Update() *EpicHeroInfoUpdateOne { + return NewEpicHeroInfoClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the EpicHeroInfo entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (_m *EpicHeroInfo) Unwrap() *EpicHeroInfo { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("ent: EpicHeroInfo is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *EpicHeroInfo) String() string { + var builder strings.Builder + builder.WriteString("EpicHeroInfo(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("hero_name=") + builder.WriteString(_m.HeroName) + builder.WriteString(", ") + builder.WriteString("hero_code=") + builder.WriteString(_m.HeroCode) + builder.WriteString(", ") + builder.WriteString("hero_attr_lv60=") + builder.WriteString(_m.HeroAttrLv60) + builder.WriteString(", ") + builder.WriteString("creator=") + builder.WriteString(_m.Creator) + builder.WriteString(", ") + if v := _m.CreateTime; v != nil { + builder.WriteString("create_time=") + builder.WriteString(v.Format(time.ANSIC)) + } + builder.WriteString(", ") + builder.WriteString("updater=") + builder.WriteString(_m.Updater) + builder.WriteString(", ") + if v := _m.UpdateTime; v != nil { + builder.WriteString("update_time=") + builder.WriteString(v.Format(time.ANSIC)) + } + builder.WriteString(", ") + builder.WriteString("deleted=") + builder.WriteString(fmt.Sprintf("%v", _m.Deleted)) + builder.WriteString(", ") + builder.WriteString("nick_name=") + builder.WriteString(_m.NickName) + builder.WriteString(", ") + builder.WriteString("rarity=") + builder.WriteString(_m.Rarity) + builder.WriteString(", ") + builder.WriteString("role=") + builder.WriteString(_m.Role) + builder.WriteString(", ") + builder.WriteString("zodiac=") + builder.WriteString(_m.Zodiac) + builder.WriteString(", ") + builder.WriteString("head_img_url=") + builder.WriteString(_m.HeadImgURL) + builder.WriteString(", ") + builder.WriteString("attribute=") + builder.WriteString(_m.Attribute) + builder.WriteString(", ") + builder.WriteString("remark=") + builder.WriteString(_m.Remark) + builder.WriteString(", ") + builder.WriteString("raw_json=") + builder.WriteString(_m.RawJSON) + builder.WriteString(", ") + builder.WriteString("set_content_json=") + builder.WriteString(_m.SetContentJSON) + builder.WriteString(", ") + if v := _m.SetUpdateTime; v != nil { + builder.WriteString("set_update_time=") + builder.WriteString(v.Format(time.ANSIC)) + } + builder.WriteByte(')') + return builder.String() +} + +// EpicHeroInfos is a parsable slice of EpicHeroInfo. +type EpicHeroInfos []*EpicHeroInfo diff --git a/internal/ent/epicheroinfo/epicheroinfo.go b/internal/ent/epicheroinfo/epicheroinfo.go new file mode 100644 index 0000000..045051b --- /dev/null +++ b/internal/ent/epicheroinfo/epicheroinfo.go @@ -0,0 +1,214 @@ +// Code generated by ent, DO NOT EDIT. + +package epicheroinfo + +import ( + "entgo.io/ent/dialect/sql" +) + +const ( + // Label holds the string label denoting the epicheroinfo type in the database. + Label = "epic_hero_info" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldHeroName holds the string denoting the hero_name field in the database. + FieldHeroName = "hero_name" + // FieldHeroCode holds the string denoting the hero_code field in the database. + FieldHeroCode = "hero_code" + // FieldHeroAttrLv60 holds the string denoting the hero_attr_lv60 field in the database. + FieldHeroAttrLv60 = "hero_attr_lv60" + // FieldCreator holds the string denoting the creator field in the database. + FieldCreator = "creator" + // FieldCreateTime holds the string denoting the create_time field in the database. + FieldCreateTime = "create_time" + // FieldUpdater holds the string denoting the updater field in the database. + FieldUpdater = "updater" + // FieldUpdateTime holds the string denoting the update_time field in the database. + FieldUpdateTime = "update_time" + // FieldDeleted holds the string denoting the deleted field in the database. + FieldDeleted = "deleted" + // FieldNickName holds the string denoting the nick_name field in the database. + FieldNickName = "nick_name" + // FieldRarity holds the string denoting the rarity field in the database. + FieldRarity = "rarity" + // FieldRole holds the string denoting the role field in the database. + FieldRole = "role" + // FieldZodiac holds the string denoting the zodiac field in the database. + FieldZodiac = "zodiac" + // FieldHeadImgURL holds the string denoting the head_img_url field in the database. + FieldHeadImgURL = "head_img_url" + // FieldAttribute holds the string denoting the attribute field in the database. + FieldAttribute = "attribute" + // FieldRemark holds the string denoting the remark field in the database. + FieldRemark = "remark" + // FieldRawJSON holds the string denoting the raw_json field in the database. + FieldRawJSON = "raw_json" + // FieldSetContentJSON holds the string denoting the set_content_json field in the database. + FieldSetContentJSON = "set_content_json" + // FieldSetUpdateTime holds the string denoting the set_update_time field in the database. + FieldSetUpdateTime = "set_update_time" + // Table holds the table name of the epicheroinfo in the database. + Table = "epic_hero_infos" +) + +// Columns holds all SQL columns for epicheroinfo fields. +var Columns = []string{ + FieldID, + FieldHeroName, + FieldHeroCode, + FieldHeroAttrLv60, + FieldCreator, + FieldCreateTime, + FieldUpdater, + FieldUpdateTime, + FieldDeleted, + FieldNickName, + FieldRarity, + FieldRole, + FieldZodiac, + FieldHeadImgURL, + FieldAttribute, + FieldRemark, + FieldRawJSON, + FieldSetContentJSON, + FieldSetUpdateTime, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // HeroNameValidator is a validator for the "hero_name" field. It is called by the builders before save. + HeroNameValidator func(string) error + // HeroCodeValidator is a validator for the "hero_code" field. It is called by the builders before save. + HeroCodeValidator func(string) error + // HeroAttrLv60Validator is a validator for the "hero_attr_lv60" field. It is called by the builders before save. + HeroAttrLv60Validator func(string) error + // CreatorValidator is a validator for the "creator" field. It is called by the builders before save. + CreatorValidator func(string) error + // UpdaterValidator is a validator for the "updater" field. It is called by the builders before save. + UpdaterValidator func(string) error + // NickNameValidator is a validator for the "nick_name" field. It is called by the builders before save. + NickNameValidator func(string) error + // RarityValidator is a validator for the "rarity" field. It is called by the builders before save. + RarityValidator func(string) error + // RoleValidator is a validator for the "role" field. It is called by the builders before save. + RoleValidator func(string) error + // ZodiacValidator is a validator for the "zodiac" field. It is called by the builders before save. + ZodiacValidator func(string) error + // HeadImgURLValidator is a validator for the "head_img_url" field. It is called by the builders before save. + HeadImgURLValidator func(string) error + // AttributeValidator is a validator for the "attribute" field. It is called by the builders before save. + AttributeValidator func(string) error + // RemarkValidator is a validator for the "remark" field. It is called by the builders before save. + RemarkValidator func(string) error + // RawJSONValidator is a validator for the "raw_json" field. It is called by the builders before save. + RawJSONValidator func(string) error + // SetContentJSONValidator is a validator for the "set_content_json" field. It is called by the builders before save. + SetContentJSONValidator func(string) error +) + +// OrderOption defines the ordering options for the EpicHeroInfo queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByHeroName orders the results by the hero_name field. +func ByHeroName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldHeroName, opts...).ToFunc() +} + +// ByHeroCode orders the results by the hero_code field. +func ByHeroCode(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldHeroCode, opts...).ToFunc() +} + +// ByHeroAttrLv60 orders the results by the hero_attr_lv60 field. +func ByHeroAttrLv60(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldHeroAttrLv60, opts...).ToFunc() +} + +// ByCreator orders the results by the creator field. +func ByCreator(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreator, opts...).ToFunc() +} + +// ByCreateTime orders the results by the create_time field. +func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateTime, opts...).ToFunc() +} + +// ByUpdater orders the results by the updater field. +func ByUpdater(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdater, opts...).ToFunc() +} + +// ByUpdateTime orders the results by the update_time field. +func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() +} + +// ByDeleted orders the results by the deleted field. +func ByDeleted(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeleted, opts...).ToFunc() +} + +// ByNickName orders the results by the nick_name field. +func ByNickName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldNickName, opts...).ToFunc() +} + +// ByRarity orders the results by the rarity field. +func ByRarity(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldRarity, opts...).ToFunc() +} + +// ByRole orders the results by the role field. +func ByRole(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldRole, opts...).ToFunc() +} + +// ByZodiac orders the results by the zodiac field. +func ByZodiac(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldZodiac, opts...).ToFunc() +} + +// ByHeadImgURL orders the results by the head_img_url field. +func ByHeadImgURL(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldHeadImgURL, opts...).ToFunc() +} + +// ByAttribute orders the results by the attribute field. +func ByAttribute(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldAttribute, opts...).ToFunc() +} + +// ByRemark orders the results by the remark field. +func ByRemark(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldRemark, opts...).ToFunc() +} + +// ByRawJSON orders the results by the raw_json field. +func ByRawJSON(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldRawJSON, opts...).ToFunc() +} + +// BySetContentJSON orders the results by the set_content_json field. +func BySetContentJSON(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSetContentJSON, opts...).ToFunc() +} + +// BySetUpdateTime orders the results by the set_update_time field. +func BySetUpdateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSetUpdateTime, opts...).ToFunc() +} diff --git a/internal/ent/epicheroinfo/where.go b/internal/ent/epicheroinfo/where.go new file mode 100644 index 0000000..6533d20 --- /dev/null +++ b/internal/ent/epicheroinfo/where.go @@ -0,0 +1,1230 @@ +// Code generated by ent, DO NOT EDIT. + +package epicheroinfo + +import ( + "epic-ent/internal/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" +) + +// ID filters vertices based on their ID field. +func ID(id int64) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int64) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int64) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int64) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int64) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int64) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int64) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int64) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int64) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldLTE(FieldID, id)) +} + +// HeroName applies equality check predicate on the "hero_name" field. It's identical to HeroNameEQ. +func HeroName(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEQ(FieldHeroName, v)) +} + +// HeroCode applies equality check predicate on the "hero_code" field. It's identical to HeroCodeEQ. +func HeroCode(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEQ(FieldHeroCode, v)) +} + +// HeroAttrLv60 applies equality check predicate on the "hero_attr_lv60" field. It's identical to HeroAttrLv60EQ. +func HeroAttrLv60(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEQ(FieldHeroAttrLv60, v)) +} + +// Creator applies equality check predicate on the "creator" field. It's identical to CreatorEQ. +func Creator(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEQ(FieldCreator, v)) +} + +// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. +func CreateTime(v time.Time) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEQ(FieldCreateTime, v)) +} + +// Updater applies equality check predicate on the "updater" field. It's identical to UpdaterEQ. +func Updater(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEQ(FieldUpdater, v)) +} + +// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. +func UpdateTime(v time.Time) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEQ(FieldUpdateTime, v)) +} + +// Deleted applies equality check predicate on the "deleted" field. It's identical to DeletedEQ. +func Deleted(v bool) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEQ(FieldDeleted, v)) +} + +// NickName applies equality check predicate on the "nick_name" field. It's identical to NickNameEQ. +func NickName(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEQ(FieldNickName, v)) +} + +// Rarity applies equality check predicate on the "rarity" field. It's identical to RarityEQ. +func Rarity(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEQ(FieldRarity, v)) +} + +// Role applies equality check predicate on the "role" field. It's identical to RoleEQ. +func Role(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEQ(FieldRole, v)) +} + +// Zodiac applies equality check predicate on the "zodiac" field. It's identical to ZodiacEQ. +func Zodiac(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEQ(FieldZodiac, v)) +} + +// HeadImgURL applies equality check predicate on the "head_img_url" field. It's identical to HeadImgURLEQ. +func HeadImgURL(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEQ(FieldHeadImgURL, v)) +} + +// Attribute applies equality check predicate on the "attribute" field. It's identical to AttributeEQ. +func Attribute(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEQ(FieldAttribute, v)) +} + +// Remark applies equality check predicate on the "remark" field. It's identical to RemarkEQ. +func Remark(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEQ(FieldRemark, v)) +} + +// RawJSON applies equality check predicate on the "raw_json" field. It's identical to RawJSONEQ. +func RawJSON(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEQ(FieldRawJSON, v)) +} + +// SetContentJSON applies equality check predicate on the "set_content_json" field. It's identical to SetContentJSONEQ. +func SetContentJSON(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEQ(FieldSetContentJSON, v)) +} + +// SetUpdateTime applies equality check predicate on the "set_update_time" field. It's identical to SetUpdateTimeEQ. +func SetUpdateTime(v time.Time) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEQ(FieldSetUpdateTime, v)) +} + +// HeroNameEQ applies the EQ predicate on the "hero_name" field. +func HeroNameEQ(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEQ(FieldHeroName, v)) +} + +// HeroNameNEQ applies the NEQ predicate on the "hero_name" field. +func HeroNameNEQ(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldNEQ(FieldHeroName, v)) +} + +// HeroNameIn applies the In predicate on the "hero_name" field. +func HeroNameIn(vs ...string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldIn(FieldHeroName, vs...)) +} + +// HeroNameNotIn applies the NotIn predicate on the "hero_name" field. +func HeroNameNotIn(vs ...string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldNotIn(FieldHeroName, vs...)) +} + +// HeroNameGT applies the GT predicate on the "hero_name" field. +func HeroNameGT(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldGT(FieldHeroName, v)) +} + +// HeroNameGTE applies the GTE predicate on the "hero_name" field. +func HeroNameGTE(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldGTE(FieldHeroName, v)) +} + +// HeroNameLT applies the LT predicate on the "hero_name" field. +func HeroNameLT(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldLT(FieldHeroName, v)) +} + +// HeroNameLTE applies the LTE predicate on the "hero_name" field. +func HeroNameLTE(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldLTE(FieldHeroName, v)) +} + +// HeroNameContains applies the Contains predicate on the "hero_name" field. +func HeroNameContains(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldContains(FieldHeroName, v)) +} + +// HeroNameHasPrefix applies the HasPrefix predicate on the "hero_name" field. +func HeroNameHasPrefix(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldHasPrefix(FieldHeroName, v)) +} + +// HeroNameHasSuffix applies the HasSuffix predicate on the "hero_name" field. +func HeroNameHasSuffix(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldHasSuffix(FieldHeroName, v)) +} + +// HeroNameEqualFold applies the EqualFold predicate on the "hero_name" field. +func HeroNameEqualFold(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEqualFold(FieldHeroName, v)) +} + +// HeroNameContainsFold applies the ContainsFold predicate on the "hero_name" field. +func HeroNameContainsFold(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldContainsFold(FieldHeroName, v)) +} + +// HeroCodeEQ applies the EQ predicate on the "hero_code" field. +func HeroCodeEQ(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEQ(FieldHeroCode, v)) +} + +// HeroCodeNEQ applies the NEQ predicate on the "hero_code" field. +func HeroCodeNEQ(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldNEQ(FieldHeroCode, v)) +} + +// HeroCodeIn applies the In predicate on the "hero_code" field. +func HeroCodeIn(vs ...string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldIn(FieldHeroCode, vs...)) +} + +// HeroCodeNotIn applies the NotIn predicate on the "hero_code" field. +func HeroCodeNotIn(vs ...string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldNotIn(FieldHeroCode, vs...)) +} + +// HeroCodeGT applies the GT predicate on the "hero_code" field. +func HeroCodeGT(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldGT(FieldHeroCode, v)) +} + +// HeroCodeGTE applies the GTE predicate on the "hero_code" field. +func HeroCodeGTE(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldGTE(FieldHeroCode, v)) +} + +// HeroCodeLT applies the LT predicate on the "hero_code" field. +func HeroCodeLT(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldLT(FieldHeroCode, v)) +} + +// HeroCodeLTE applies the LTE predicate on the "hero_code" field. +func HeroCodeLTE(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldLTE(FieldHeroCode, v)) +} + +// HeroCodeContains applies the Contains predicate on the "hero_code" field. +func HeroCodeContains(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldContains(FieldHeroCode, v)) +} + +// HeroCodeHasPrefix applies the HasPrefix predicate on the "hero_code" field. +func HeroCodeHasPrefix(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldHasPrefix(FieldHeroCode, v)) +} + +// HeroCodeHasSuffix applies the HasSuffix predicate on the "hero_code" field. +func HeroCodeHasSuffix(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldHasSuffix(FieldHeroCode, v)) +} + +// HeroCodeEqualFold applies the EqualFold predicate on the "hero_code" field. +func HeroCodeEqualFold(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEqualFold(FieldHeroCode, v)) +} + +// HeroCodeContainsFold applies the ContainsFold predicate on the "hero_code" field. +func HeroCodeContainsFold(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldContainsFold(FieldHeroCode, v)) +} + +// HeroAttrLv60EQ applies the EQ predicate on the "hero_attr_lv60" field. +func HeroAttrLv60EQ(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEQ(FieldHeroAttrLv60, v)) +} + +// HeroAttrLv60NEQ applies the NEQ predicate on the "hero_attr_lv60" field. +func HeroAttrLv60NEQ(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldNEQ(FieldHeroAttrLv60, v)) +} + +// HeroAttrLv60In applies the In predicate on the "hero_attr_lv60" field. +func HeroAttrLv60In(vs ...string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldIn(FieldHeroAttrLv60, vs...)) +} + +// HeroAttrLv60NotIn applies the NotIn predicate on the "hero_attr_lv60" field. +func HeroAttrLv60NotIn(vs ...string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldNotIn(FieldHeroAttrLv60, vs...)) +} + +// HeroAttrLv60GT applies the GT predicate on the "hero_attr_lv60" field. +func HeroAttrLv60GT(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldGT(FieldHeroAttrLv60, v)) +} + +// HeroAttrLv60GTE applies the GTE predicate on the "hero_attr_lv60" field. +func HeroAttrLv60GTE(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldGTE(FieldHeroAttrLv60, v)) +} + +// HeroAttrLv60LT applies the LT predicate on the "hero_attr_lv60" field. +func HeroAttrLv60LT(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldLT(FieldHeroAttrLv60, v)) +} + +// HeroAttrLv60LTE applies the LTE predicate on the "hero_attr_lv60" field. +func HeroAttrLv60LTE(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldLTE(FieldHeroAttrLv60, v)) +} + +// HeroAttrLv60Contains applies the Contains predicate on the "hero_attr_lv60" field. +func HeroAttrLv60Contains(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldContains(FieldHeroAttrLv60, v)) +} + +// HeroAttrLv60HasPrefix applies the HasPrefix predicate on the "hero_attr_lv60" field. +func HeroAttrLv60HasPrefix(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldHasPrefix(FieldHeroAttrLv60, v)) +} + +// HeroAttrLv60HasSuffix applies the HasSuffix predicate on the "hero_attr_lv60" field. +func HeroAttrLv60HasSuffix(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldHasSuffix(FieldHeroAttrLv60, v)) +} + +// HeroAttrLv60EqualFold applies the EqualFold predicate on the "hero_attr_lv60" field. +func HeroAttrLv60EqualFold(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEqualFold(FieldHeroAttrLv60, v)) +} + +// HeroAttrLv60ContainsFold applies the ContainsFold predicate on the "hero_attr_lv60" field. +func HeroAttrLv60ContainsFold(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldContainsFold(FieldHeroAttrLv60, v)) +} + +// CreatorEQ applies the EQ predicate on the "creator" field. +func CreatorEQ(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEQ(FieldCreator, v)) +} + +// CreatorNEQ applies the NEQ predicate on the "creator" field. +func CreatorNEQ(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldNEQ(FieldCreator, v)) +} + +// CreatorIn applies the In predicate on the "creator" field. +func CreatorIn(vs ...string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldIn(FieldCreator, vs...)) +} + +// CreatorNotIn applies the NotIn predicate on the "creator" field. +func CreatorNotIn(vs ...string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldNotIn(FieldCreator, vs...)) +} + +// CreatorGT applies the GT predicate on the "creator" field. +func CreatorGT(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldGT(FieldCreator, v)) +} + +// CreatorGTE applies the GTE predicate on the "creator" field. +func CreatorGTE(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldGTE(FieldCreator, v)) +} + +// CreatorLT applies the LT predicate on the "creator" field. +func CreatorLT(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldLT(FieldCreator, v)) +} + +// CreatorLTE applies the LTE predicate on the "creator" field. +func CreatorLTE(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldLTE(FieldCreator, v)) +} + +// CreatorContains applies the Contains predicate on the "creator" field. +func CreatorContains(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldContains(FieldCreator, v)) +} + +// CreatorHasPrefix applies the HasPrefix predicate on the "creator" field. +func CreatorHasPrefix(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldHasPrefix(FieldCreator, v)) +} + +// CreatorHasSuffix applies the HasSuffix predicate on the "creator" field. +func CreatorHasSuffix(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldHasSuffix(FieldCreator, v)) +} + +// CreatorEqualFold applies the EqualFold predicate on the "creator" field. +func CreatorEqualFold(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEqualFold(FieldCreator, v)) +} + +// CreatorContainsFold applies the ContainsFold predicate on the "creator" field. +func CreatorContainsFold(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldContainsFold(FieldCreator, v)) +} + +// CreateTimeEQ applies the EQ predicate on the "create_time" field. +func CreateTimeEQ(v time.Time) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEQ(FieldCreateTime, v)) +} + +// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. +func CreateTimeNEQ(v time.Time) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldNEQ(FieldCreateTime, v)) +} + +// CreateTimeIn applies the In predicate on the "create_time" field. +func CreateTimeIn(vs ...time.Time) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldIn(FieldCreateTime, vs...)) +} + +// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. +func CreateTimeNotIn(vs ...time.Time) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldNotIn(FieldCreateTime, vs...)) +} + +// CreateTimeGT applies the GT predicate on the "create_time" field. +func CreateTimeGT(v time.Time) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldGT(FieldCreateTime, v)) +} + +// CreateTimeGTE applies the GTE predicate on the "create_time" field. +func CreateTimeGTE(v time.Time) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldGTE(FieldCreateTime, v)) +} + +// CreateTimeLT applies the LT predicate on the "create_time" field. +func CreateTimeLT(v time.Time) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldLT(FieldCreateTime, v)) +} + +// CreateTimeLTE applies the LTE predicate on the "create_time" field. +func CreateTimeLTE(v time.Time) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldLTE(FieldCreateTime, v)) +} + +// CreateTimeIsNil applies the IsNil predicate on the "create_time" field. +func CreateTimeIsNil() predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldIsNull(FieldCreateTime)) +} + +// CreateTimeNotNil applies the NotNil predicate on the "create_time" field. +func CreateTimeNotNil() predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldNotNull(FieldCreateTime)) +} + +// UpdaterEQ applies the EQ predicate on the "updater" field. +func UpdaterEQ(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEQ(FieldUpdater, v)) +} + +// UpdaterNEQ applies the NEQ predicate on the "updater" field. +func UpdaterNEQ(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldNEQ(FieldUpdater, v)) +} + +// UpdaterIn applies the In predicate on the "updater" field. +func UpdaterIn(vs ...string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldIn(FieldUpdater, vs...)) +} + +// UpdaterNotIn applies the NotIn predicate on the "updater" field. +func UpdaterNotIn(vs ...string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldNotIn(FieldUpdater, vs...)) +} + +// UpdaterGT applies the GT predicate on the "updater" field. +func UpdaterGT(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldGT(FieldUpdater, v)) +} + +// UpdaterGTE applies the GTE predicate on the "updater" field. +func UpdaterGTE(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldGTE(FieldUpdater, v)) +} + +// UpdaterLT applies the LT predicate on the "updater" field. +func UpdaterLT(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldLT(FieldUpdater, v)) +} + +// UpdaterLTE applies the LTE predicate on the "updater" field. +func UpdaterLTE(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldLTE(FieldUpdater, v)) +} + +// UpdaterContains applies the Contains predicate on the "updater" field. +func UpdaterContains(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldContains(FieldUpdater, v)) +} + +// UpdaterHasPrefix applies the HasPrefix predicate on the "updater" field. +func UpdaterHasPrefix(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldHasPrefix(FieldUpdater, v)) +} + +// UpdaterHasSuffix applies the HasSuffix predicate on the "updater" field. +func UpdaterHasSuffix(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldHasSuffix(FieldUpdater, v)) +} + +// UpdaterEqualFold applies the EqualFold predicate on the "updater" field. +func UpdaterEqualFold(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEqualFold(FieldUpdater, v)) +} + +// UpdaterContainsFold applies the ContainsFold predicate on the "updater" field. +func UpdaterContainsFold(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldContainsFold(FieldUpdater, v)) +} + +// UpdateTimeEQ applies the EQ predicate on the "update_time" field. +func UpdateTimeEQ(v time.Time) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEQ(FieldUpdateTime, v)) +} + +// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. +func UpdateTimeNEQ(v time.Time) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldNEQ(FieldUpdateTime, v)) +} + +// UpdateTimeIn applies the In predicate on the "update_time" field. +func UpdateTimeIn(vs ...time.Time) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. +func UpdateTimeNotIn(vs ...time.Time) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldNotIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeGT applies the GT predicate on the "update_time" field. +func UpdateTimeGT(v time.Time) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldGT(FieldUpdateTime, v)) +} + +// UpdateTimeGTE applies the GTE predicate on the "update_time" field. +func UpdateTimeGTE(v time.Time) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldGTE(FieldUpdateTime, v)) +} + +// UpdateTimeLT applies the LT predicate on the "update_time" field. +func UpdateTimeLT(v time.Time) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldLT(FieldUpdateTime, v)) +} + +// UpdateTimeLTE applies the LTE predicate on the "update_time" field. +func UpdateTimeLTE(v time.Time) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldLTE(FieldUpdateTime, v)) +} + +// UpdateTimeIsNil applies the IsNil predicate on the "update_time" field. +func UpdateTimeIsNil() predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldIsNull(FieldUpdateTime)) +} + +// UpdateTimeNotNil applies the NotNil predicate on the "update_time" field. +func UpdateTimeNotNil() predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldNotNull(FieldUpdateTime)) +} + +// DeletedEQ applies the EQ predicate on the "deleted" field. +func DeletedEQ(v bool) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEQ(FieldDeleted, v)) +} + +// DeletedNEQ applies the NEQ predicate on the "deleted" field. +func DeletedNEQ(v bool) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldNEQ(FieldDeleted, v)) +} + +// NickNameEQ applies the EQ predicate on the "nick_name" field. +func NickNameEQ(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEQ(FieldNickName, v)) +} + +// NickNameNEQ applies the NEQ predicate on the "nick_name" field. +func NickNameNEQ(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldNEQ(FieldNickName, v)) +} + +// NickNameIn applies the In predicate on the "nick_name" field. +func NickNameIn(vs ...string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldIn(FieldNickName, vs...)) +} + +// NickNameNotIn applies the NotIn predicate on the "nick_name" field. +func NickNameNotIn(vs ...string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldNotIn(FieldNickName, vs...)) +} + +// NickNameGT applies the GT predicate on the "nick_name" field. +func NickNameGT(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldGT(FieldNickName, v)) +} + +// NickNameGTE applies the GTE predicate on the "nick_name" field. +func NickNameGTE(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldGTE(FieldNickName, v)) +} + +// NickNameLT applies the LT predicate on the "nick_name" field. +func NickNameLT(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldLT(FieldNickName, v)) +} + +// NickNameLTE applies the LTE predicate on the "nick_name" field. +func NickNameLTE(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldLTE(FieldNickName, v)) +} + +// NickNameContains applies the Contains predicate on the "nick_name" field. +func NickNameContains(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldContains(FieldNickName, v)) +} + +// NickNameHasPrefix applies the HasPrefix predicate on the "nick_name" field. +func NickNameHasPrefix(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldHasPrefix(FieldNickName, v)) +} + +// NickNameHasSuffix applies the HasSuffix predicate on the "nick_name" field. +func NickNameHasSuffix(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldHasSuffix(FieldNickName, v)) +} + +// NickNameEqualFold applies the EqualFold predicate on the "nick_name" field. +func NickNameEqualFold(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEqualFold(FieldNickName, v)) +} + +// NickNameContainsFold applies the ContainsFold predicate on the "nick_name" field. +func NickNameContainsFold(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldContainsFold(FieldNickName, v)) +} + +// RarityEQ applies the EQ predicate on the "rarity" field. +func RarityEQ(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEQ(FieldRarity, v)) +} + +// RarityNEQ applies the NEQ predicate on the "rarity" field. +func RarityNEQ(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldNEQ(FieldRarity, v)) +} + +// RarityIn applies the In predicate on the "rarity" field. +func RarityIn(vs ...string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldIn(FieldRarity, vs...)) +} + +// RarityNotIn applies the NotIn predicate on the "rarity" field. +func RarityNotIn(vs ...string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldNotIn(FieldRarity, vs...)) +} + +// RarityGT applies the GT predicate on the "rarity" field. +func RarityGT(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldGT(FieldRarity, v)) +} + +// RarityGTE applies the GTE predicate on the "rarity" field. +func RarityGTE(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldGTE(FieldRarity, v)) +} + +// RarityLT applies the LT predicate on the "rarity" field. +func RarityLT(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldLT(FieldRarity, v)) +} + +// RarityLTE applies the LTE predicate on the "rarity" field. +func RarityLTE(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldLTE(FieldRarity, v)) +} + +// RarityContains applies the Contains predicate on the "rarity" field. +func RarityContains(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldContains(FieldRarity, v)) +} + +// RarityHasPrefix applies the HasPrefix predicate on the "rarity" field. +func RarityHasPrefix(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldHasPrefix(FieldRarity, v)) +} + +// RarityHasSuffix applies the HasSuffix predicate on the "rarity" field. +func RarityHasSuffix(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldHasSuffix(FieldRarity, v)) +} + +// RarityEqualFold applies the EqualFold predicate on the "rarity" field. +func RarityEqualFold(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEqualFold(FieldRarity, v)) +} + +// RarityContainsFold applies the ContainsFold predicate on the "rarity" field. +func RarityContainsFold(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldContainsFold(FieldRarity, v)) +} + +// RoleEQ applies the EQ predicate on the "role" field. +func RoleEQ(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEQ(FieldRole, v)) +} + +// RoleNEQ applies the NEQ predicate on the "role" field. +func RoleNEQ(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldNEQ(FieldRole, v)) +} + +// RoleIn applies the In predicate on the "role" field. +func RoleIn(vs ...string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldIn(FieldRole, vs...)) +} + +// RoleNotIn applies the NotIn predicate on the "role" field. +func RoleNotIn(vs ...string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldNotIn(FieldRole, vs...)) +} + +// RoleGT applies the GT predicate on the "role" field. +func RoleGT(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldGT(FieldRole, v)) +} + +// RoleGTE applies the GTE predicate on the "role" field. +func RoleGTE(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldGTE(FieldRole, v)) +} + +// RoleLT applies the LT predicate on the "role" field. +func RoleLT(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldLT(FieldRole, v)) +} + +// RoleLTE applies the LTE predicate on the "role" field. +func RoleLTE(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldLTE(FieldRole, v)) +} + +// RoleContains applies the Contains predicate on the "role" field. +func RoleContains(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldContains(FieldRole, v)) +} + +// RoleHasPrefix applies the HasPrefix predicate on the "role" field. +func RoleHasPrefix(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldHasPrefix(FieldRole, v)) +} + +// RoleHasSuffix applies the HasSuffix predicate on the "role" field. +func RoleHasSuffix(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldHasSuffix(FieldRole, v)) +} + +// RoleEqualFold applies the EqualFold predicate on the "role" field. +func RoleEqualFold(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEqualFold(FieldRole, v)) +} + +// RoleContainsFold applies the ContainsFold predicate on the "role" field. +func RoleContainsFold(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldContainsFold(FieldRole, v)) +} + +// ZodiacEQ applies the EQ predicate on the "zodiac" field. +func ZodiacEQ(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEQ(FieldZodiac, v)) +} + +// ZodiacNEQ applies the NEQ predicate on the "zodiac" field. +func ZodiacNEQ(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldNEQ(FieldZodiac, v)) +} + +// ZodiacIn applies the In predicate on the "zodiac" field. +func ZodiacIn(vs ...string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldIn(FieldZodiac, vs...)) +} + +// ZodiacNotIn applies the NotIn predicate on the "zodiac" field. +func ZodiacNotIn(vs ...string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldNotIn(FieldZodiac, vs...)) +} + +// ZodiacGT applies the GT predicate on the "zodiac" field. +func ZodiacGT(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldGT(FieldZodiac, v)) +} + +// ZodiacGTE applies the GTE predicate on the "zodiac" field. +func ZodiacGTE(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldGTE(FieldZodiac, v)) +} + +// ZodiacLT applies the LT predicate on the "zodiac" field. +func ZodiacLT(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldLT(FieldZodiac, v)) +} + +// ZodiacLTE applies the LTE predicate on the "zodiac" field. +func ZodiacLTE(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldLTE(FieldZodiac, v)) +} + +// ZodiacContains applies the Contains predicate on the "zodiac" field. +func ZodiacContains(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldContains(FieldZodiac, v)) +} + +// ZodiacHasPrefix applies the HasPrefix predicate on the "zodiac" field. +func ZodiacHasPrefix(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldHasPrefix(FieldZodiac, v)) +} + +// ZodiacHasSuffix applies the HasSuffix predicate on the "zodiac" field. +func ZodiacHasSuffix(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldHasSuffix(FieldZodiac, v)) +} + +// ZodiacEqualFold applies the EqualFold predicate on the "zodiac" field. +func ZodiacEqualFold(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEqualFold(FieldZodiac, v)) +} + +// ZodiacContainsFold applies the ContainsFold predicate on the "zodiac" field. +func ZodiacContainsFold(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldContainsFold(FieldZodiac, v)) +} + +// HeadImgURLEQ applies the EQ predicate on the "head_img_url" field. +func HeadImgURLEQ(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEQ(FieldHeadImgURL, v)) +} + +// HeadImgURLNEQ applies the NEQ predicate on the "head_img_url" field. +func HeadImgURLNEQ(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldNEQ(FieldHeadImgURL, v)) +} + +// HeadImgURLIn applies the In predicate on the "head_img_url" field. +func HeadImgURLIn(vs ...string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldIn(FieldHeadImgURL, vs...)) +} + +// HeadImgURLNotIn applies the NotIn predicate on the "head_img_url" field. +func HeadImgURLNotIn(vs ...string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldNotIn(FieldHeadImgURL, vs...)) +} + +// HeadImgURLGT applies the GT predicate on the "head_img_url" field. +func HeadImgURLGT(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldGT(FieldHeadImgURL, v)) +} + +// HeadImgURLGTE applies the GTE predicate on the "head_img_url" field. +func HeadImgURLGTE(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldGTE(FieldHeadImgURL, v)) +} + +// HeadImgURLLT applies the LT predicate on the "head_img_url" field. +func HeadImgURLLT(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldLT(FieldHeadImgURL, v)) +} + +// HeadImgURLLTE applies the LTE predicate on the "head_img_url" field. +func HeadImgURLLTE(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldLTE(FieldHeadImgURL, v)) +} + +// HeadImgURLContains applies the Contains predicate on the "head_img_url" field. +func HeadImgURLContains(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldContains(FieldHeadImgURL, v)) +} + +// HeadImgURLHasPrefix applies the HasPrefix predicate on the "head_img_url" field. +func HeadImgURLHasPrefix(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldHasPrefix(FieldHeadImgURL, v)) +} + +// HeadImgURLHasSuffix applies the HasSuffix predicate on the "head_img_url" field. +func HeadImgURLHasSuffix(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldHasSuffix(FieldHeadImgURL, v)) +} + +// HeadImgURLEqualFold applies the EqualFold predicate on the "head_img_url" field. +func HeadImgURLEqualFold(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEqualFold(FieldHeadImgURL, v)) +} + +// HeadImgURLContainsFold applies the ContainsFold predicate on the "head_img_url" field. +func HeadImgURLContainsFold(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldContainsFold(FieldHeadImgURL, v)) +} + +// AttributeEQ applies the EQ predicate on the "attribute" field. +func AttributeEQ(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEQ(FieldAttribute, v)) +} + +// AttributeNEQ applies the NEQ predicate on the "attribute" field. +func AttributeNEQ(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldNEQ(FieldAttribute, v)) +} + +// AttributeIn applies the In predicate on the "attribute" field. +func AttributeIn(vs ...string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldIn(FieldAttribute, vs...)) +} + +// AttributeNotIn applies the NotIn predicate on the "attribute" field. +func AttributeNotIn(vs ...string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldNotIn(FieldAttribute, vs...)) +} + +// AttributeGT applies the GT predicate on the "attribute" field. +func AttributeGT(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldGT(FieldAttribute, v)) +} + +// AttributeGTE applies the GTE predicate on the "attribute" field. +func AttributeGTE(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldGTE(FieldAttribute, v)) +} + +// AttributeLT applies the LT predicate on the "attribute" field. +func AttributeLT(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldLT(FieldAttribute, v)) +} + +// AttributeLTE applies the LTE predicate on the "attribute" field. +func AttributeLTE(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldLTE(FieldAttribute, v)) +} + +// AttributeContains applies the Contains predicate on the "attribute" field. +func AttributeContains(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldContains(FieldAttribute, v)) +} + +// AttributeHasPrefix applies the HasPrefix predicate on the "attribute" field. +func AttributeHasPrefix(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldHasPrefix(FieldAttribute, v)) +} + +// AttributeHasSuffix applies the HasSuffix predicate on the "attribute" field. +func AttributeHasSuffix(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldHasSuffix(FieldAttribute, v)) +} + +// AttributeEqualFold applies the EqualFold predicate on the "attribute" field. +func AttributeEqualFold(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEqualFold(FieldAttribute, v)) +} + +// AttributeContainsFold applies the ContainsFold predicate on the "attribute" field. +func AttributeContainsFold(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldContainsFold(FieldAttribute, v)) +} + +// RemarkEQ applies the EQ predicate on the "remark" field. +func RemarkEQ(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEQ(FieldRemark, v)) +} + +// RemarkNEQ applies the NEQ predicate on the "remark" field. +func RemarkNEQ(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldNEQ(FieldRemark, v)) +} + +// RemarkIn applies the In predicate on the "remark" field. +func RemarkIn(vs ...string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldIn(FieldRemark, vs...)) +} + +// RemarkNotIn applies the NotIn predicate on the "remark" field. +func RemarkNotIn(vs ...string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldNotIn(FieldRemark, vs...)) +} + +// RemarkGT applies the GT predicate on the "remark" field. +func RemarkGT(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldGT(FieldRemark, v)) +} + +// RemarkGTE applies the GTE predicate on the "remark" field. +func RemarkGTE(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldGTE(FieldRemark, v)) +} + +// RemarkLT applies the LT predicate on the "remark" field. +func RemarkLT(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldLT(FieldRemark, v)) +} + +// RemarkLTE applies the LTE predicate on the "remark" field. +func RemarkLTE(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldLTE(FieldRemark, v)) +} + +// RemarkContains applies the Contains predicate on the "remark" field. +func RemarkContains(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldContains(FieldRemark, v)) +} + +// RemarkHasPrefix applies the HasPrefix predicate on the "remark" field. +func RemarkHasPrefix(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldHasPrefix(FieldRemark, v)) +} + +// RemarkHasSuffix applies the HasSuffix predicate on the "remark" field. +func RemarkHasSuffix(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldHasSuffix(FieldRemark, v)) +} + +// RemarkEqualFold applies the EqualFold predicate on the "remark" field. +func RemarkEqualFold(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEqualFold(FieldRemark, v)) +} + +// RemarkContainsFold applies the ContainsFold predicate on the "remark" field. +func RemarkContainsFold(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldContainsFold(FieldRemark, v)) +} + +// RawJSONEQ applies the EQ predicate on the "raw_json" field. +func RawJSONEQ(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEQ(FieldRawJSON, v)) +} + +// RawJSONNEQ applies the NEQ predicate on the "raw_json" field. +func RawJSONNEQ(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldNEQ(FieldRawJSON, v)) +} + +// RawJSONIn applies the In predicate on the "raw_json" field. +func RawJSONIn(vs ...string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldIn(FieldRawJSON, vs...)) +} + +// RawJSONNotIn applies the NotIn predicate on the "raw_json" field. +func RawJSONNotIn(vs ...string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldNotIn(FieldRawJSON, vs...)) +} + +// RawJSONGT applies the GT predicate on the "raw_json" field. +func RawJSONGT(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldGT(FieldRawJSON, v)) +} + +// RawJSONGTE applies the GTE predicate on the "raw_json" field. +func RawJSONGTE(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldGTE(FieldRawJSON, v)) +} + +// RawJSONLT applies the LT predicate on the "raw_json" field. +func RawJSONLT(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldLT(FieldRawJSON, v)) +} + +// RawJSONLTE applies the LTE predicate on the "raw_json" field. +func RawJSONLTE(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldLTE(FieldRawJSON, v)) +} + +// RawJSONContains applies the Contains predicate on the "raw_json" field. +func RawJSONContains(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldContains(FieldRawJSON, v)) +} + +// RawJSONHasPrefix applies the HasPrefix predicate on the "raw_json" field. +func RawJSONHasPrefix(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldHasPrefix(FieldRawJSON, v)) +} + +// RawJSONHasSuffix applies the HasSuffix predicate on the "raw_json" field. +func RawJSONHasSuffix(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldHasSuffix(FieldRawJSON, v)) +} + +// RawJSONEqualFold applies the EqualFold predicate on the "raw_json" field. +func RawJSONEqualFold(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEqualFold(FieldRawJSON, v)) +} + +// RawJSONContainsFold applies the ContainsFold predicate on the "raw_json" field. +func RawJSONContainsFold(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldContainsFold(FieldRawJSON, v)) +} + +// SetContentJSONEQ applies the EQ predicate on the "set_content_json" field. +func SetContentJSONEQ(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEQ(FieldSetContentJSON, v)) +} + +// SetContentJSONNEQ applies the NEQ predicate on the "set_content_json" field. +func SetContentJSONNEQ(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldNEQ(FieldSetContentJSON, v)) +} + +// SetContentJSONIn applies the In predicate on the "set_content_json" field. +func SetContentJSONIn(vs ...string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldIn(FieldSetContentJSON, vs...)) +} + +// SetContentJSONNotIn applies the NotIn predicate on the "set_content_json" field. +func SetContentJSONNotIn(vs ...string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldNotIn(FieldSetContentJSON, vs...)) +} + +// SetContentJSONGT applies the GT predicate on the "set_content_json" field. +func SetContentJSONGT(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldGT(FieldSetContentJSON, v)) +} + +// SetContentJSONGTE applies the GTE predicate on the "set_content_json" field. +func SetContentJSONGTE(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldGTE(FieldSetContentJSON, v)) +} + +// SetContentJSONLT applies the LT predicate on the "set_content_json" field. +func SetContentJSONLT(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldLT(FieldSetContentJSON, v)) +} + +// SetContentJSONLTE applies the LTE predicate on the "set_content_json" field. +func SetContentJSONLTE(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldLTE(FieldSetContentJSON, v)) +} + +// SetContentJSONContains applies the Contains predicate on the "set_content_json" field. +func SetContentJSONContains(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldContains(FieldSetContentJSON, v)) +} + +// SetContentJSONHasPrefix applies the HasPrefix predicate on the "set_content_json" field. +func SetContentJSONHasPrefix(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldHasPrefix(FieldSetContentJSON, v)) +} + +// SetContentJSONHasSuffix applies the HasSuffix predicate on the "set_content_json" field. +func SetContentJSONHasSuffix(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldHasSuffix(FieldSetContentJSON, v)) +} + +// SetContentJSONEqualFold applies the EqualFold predicate on the "set_content_json" field. +func SetContentJSONEqualFold(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEqualFold(FieldSetContentJSON, v)) +} + +// SetContentJSONContainsFold applies the ContainsFold predicate on the "set_content_json" field. +func SetContentJSONContainsFold(v string) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldContainsFold(FieldSetContentJSON, v)) +} + +// SetUpdateTimeEQ applies the EQ predicate on the "set_update_time" field. +func SetUpdateTimeEQ(v time.Time) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldEQ(FieldSetUpdateTime, v)) +} + +// SetUpdateTimeNEQ applies the NEQ predicate on the "set_update_time" field. +func SetUpdateTimeNEQ(v time.Time) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldNEQ(FieldSetUpdateTime, v)) +} + +// SetUpdateTimeIn applies the In predicate on the "set_update_time" field. +func SetUpdateTimeIn(vs ...time.Time) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldIn(FieldSetUpdateTime, vs...)) +} + +// SetUpdateTimeNotIn applies the NotIn predicate on the "set_update_time" field. +func SetUpdateTimeNotIn(vs ...time.Time) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldNotIn(FieldSetUpdateTime, vs...)) +} + +// SetUpdateTimeGT applies the GT predicate on the "set_update_time" field. +func SetUpdateTimeGT(v time.Time) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldGT(FieldSetUpdateTime, v)) +} + +// SetUpdateTimeGTE applies the GTE predicate on the "set_update_time" field. +func SetUpdateTimeGTE(v time.Time) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldGTE(FieldSetUpdateTime, v)) +} + +// SetUpdateTimeLT applies the LT predicate on the "set_update_time" field. +func SetUpdateTimeLT(v time.Time) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldLT(FieldSetUpdateTime, v)) +} + +// SetUpdateTimeLTE applies the LTE predicate on the "set_update_time" field. +func SetUpdateTimeLTE(v time.Time) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldLTE(FieldSetUpdateTime, v)) +} + +// SetUpdateTimeIsNil applies the IsNil predicate on the "set_update_time" field. +func SetUpdateTimeIsNil() predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldIsNull(FieldSetUpdateTime)) +} + +// SetUpdateTimeNotNil applies the NotNil predicate on the "set_update_time" field. +func SetUpdateTimeNotNil() predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.FieldNotNull(FieldSetUpdateTime)) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.EpicHeroInfo) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.EpicHeroInfo) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.EpicHeroInfo) predicate.EpicHeroInfo { + return predicate.EpicHeroInfo(sql.NotPredicates(p)) +} diff --git a/internal/ent/epicheroinfo_create.go b/internal/ent/epicheroinfo_create.go new file mode 100644 index 0000000..8fc410b --- /dev/null +++ b/internal/ent/epicheroinfo_create.go @@ -0,0 +1,502 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "epic-ent/internal/ent/epicheroinfo" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// EpicHeroInfoCreate is the builder for creating a EpicHeroInfo entity. +type EpicHeroInfoCreate struct { + config + mutation *EpicHeroInfoMutation + hooks []Hook +} + +// SetHeroName sets the "hero_name" field. +func (_c *EpicHeroInfoCreate) SetHeroName(v string) *EpicHeroInfoCreate { + _c.mutation.SetHeroName(v) + return _c +} + +// SetHeroCode sets the "hero_code" field. +func (_c *EpicHeroInfoCreate) SetHeroCode(v string) *EpicHeroInfoCreate { + _c.mutation.SetHeroCode(v) + return _c +} + +// SetHeroAttrLv60 sets the "hero_attr_lv60" field. +func (_c *EpicHeroInfoCreate) SetHeroAttrLv60(v string) *EpicHeroInfoCreate { + _c.mutation.SetHeroAttrLv60(v) + return _c +} + +// SetCreator sets the "creator" field. +func (_c *EpicHeroInfoCreate) SetCreator(v string) *EpicHeroInfoCreate { + _c.mutation.SetCreator(v) + return _c +} + +// SetCreateTime sets the "create_time" field. +func (_c *EpicHeroInfoCreate) SetCreateTime(v time.Time) *EpicHeroInfoCreate { + _c.mutation.SetCreateTime(v) + return _c +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (_c *EpicHeroInfoCreate) SetNillableCreateTime(v *time.Time) *EpicHeroInfoCreate { + if v != nil { + _c.SetCreateTime(*v) + } + return _c +} + +// SetUpdater sets the "updater" field. +func (_c *EpicHeroInfoCreate) SetUpdater(v string) *EpicHeroInfoCreate { + _c.mutation.SetUpdater(v) + return _c +} + +// SetUpdateTime sets the "update_time" field. +func (_c *EpicHeroInfoCreate) SetUpdateTime(v time.Time) *EpicHeroInfoCreate { + _c.mutation.SetUpdateTime(v) + return _c +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (_c *EpicHeroInfoCreate) SetNillableUpdateTime(v *time.Time) *EpicHeroInfoCreate { + if v != nil { + _c.SetUpdateTime(*v) + } + return _c +} + +// SetDeleted sets the "deleted" field. +func (_c *EpicHeroInfoCreate) SetDeleted(v bool) *EpicHeroInfoCreate { + _c.mutation.SetDeleted(v) + return _c +} + +// SetNickName sets the "nick_name" field. +func (_c *EpicHeroInfoCreate) SetNickName(v string) *EpicHeroInfoCreate { + _c.mutation.SetNickName(v) + return _c +} + +// SetRarity sets the "rarity" field. +func (_c *EpicHeroInfoCreate) SetRarity(v string) *EpicHeroInfoCreate { + _c.mutation.SetRarity(v) + return _c +} + +// SetRole sets the "role" field. +func (_c *EpicHeroInfoCreate) SetRole(v string) *EpicHeroInfoCreate { + _c.mutation.SetRole(v) + return _c +} + +// SetZodiac sets the "zodiac" field. +func (_c *EpicHeroInfoCreate) SetZodiac(v string) *EpicHeroInfoCreate { + _c.mutation.SetZodiac(v) + return _c +} + +// SetHeadImgURL sets the "head_img_url" field. +func (_c *EpicHeroInfoCreate) SetHeadImgURL(v string) *EpicHeroInfoCreate { + _c.mutation.SetHeadImgURL(v) + return _c +} + +// SetAttribute sets the "attribute" field. +func (_c *EpicHeroInfoCreate) SetAttribute(v string) *EpicHeroInfoCreate { + _c.mutation.SetAttribute(v) + return _c +} + +// SetRemark sets the "remark" field. +func (_c *EpicHeroInfoCreate) SetRemark(v string) *EpicHeroInfoCreate { + _c.mutation.SetRemark(v) + return _c +} + +// SetRawJSON sets the "raw_json" field. +func (_c *EpicHeroInfoCreate) SetRawJSON(v string) *EpicHeroInfoCreate { + _c.mutation.SetRawJSON(v) + return _c +} + +// SetSetContentJSON sets the "set_content_json" field. +func (_c *EpicHeroInfoCreate) SetSetContentJSON(v string) *EpicHeroInfoCreate { + _c.mutation.SetSetContentJSON(v) + return _c +} + +// SetSetUpdateTime sets the "set_update_time" field. +func (_c *EpicHeroInfoCreate) SetSetUpdateTime(v time.Time) *EpicHeroInfoCreate { + _c.mutation.SetSetUpdateTime(v) + return _c +} + +// SetNillableSetUpdateTime sets the "set_update_time" field if the given value is not nil. +func (_c *EpicHeroInfoCreate) SetNillableSetUpdateTime(v *time.Time) *EpicHeroInfoCreate { + if v != nil { + _c.SetSetUpdateTime(*v) + } + return _c +} + +// SetID sets the "id" field. +func (_c *EpicHeroInfoCreate) SetID(v int64) *EpicHeroInfoCreate { + _c.mutation.SetID(v) + return _c +} + +// Mutation returns the EpicHeroInfoMutation object of the builder. +func (_c *EpicHeroInfoCreate) Mutation() *EpicHeroInfoMutation { + return _c.mutation +} + +// Save creates the EpicHeroInfo in the database. +func (_c *EpicHeroInfoCreate) Save(ctx context.Context) (*EpicHeroInfo, error) { + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *EpicHeroInfoCreate) SaveX(ctx context.Context) *EpicHeroInfo { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *EpicHeroInfoCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *EpicHeroInfoCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *EpicHeroInfoCreate) check() error { + if _, ok := _c.mutation.HeroName(); !ok { + return &ValidationError{Name: "hero_name", err: errors.New(`ent: missing required field "EpicHeroInfo.hero_name"`)} + } + if v, ok := _c.mutation.HeroName(); ok { + if err := epicheroinfo.HeroNameValidator(v); err != nil { + return &ValidationError{Name: "hero_name", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.hero_name": %w`, err)} + } + } + if _, ok := _c.mutation.HeroCode(); !ok { + return &ValidationError{Name: "hero_code", err: errors.New(`ent: missing required field "EpicHeroInfo.hero_code"`)} + } + if v, ok := _c.mutation.HeroCode(); ok { + if err := epicheroinfo.HeroCodeValidator(v); err != nil { + return &ValidationError{Name: "hero_code", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.hero_code": %w`, err)} + } + } + if _, ok := _c.mutation.HeroAttrLv60(); !ok { + return &ValidationError{Name: "hero_attr_lv60", err: errors.New(`ent: missing required field "EpicHeroInfo.hero_attr_lv60"`)} + } + if v, ok := _c.mutation.HeroAttrLv60(); ok { + if err := epicheroinfo.HeroAttrLv60Validator(v); err != nil { + return &ValidationError{Name: "hero_attr_lv60", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.hero_attr_lv60": %w`, err)} + } + } + if _, ok := _c.mutation.Creator(); !ok { + return &ValidationError{Name: "creator", err: errors.New(`ent: missing required field "EpicHeroInfo.creator"`)} + } + if v, ok := _c.mutation.Creator(); ok { + if err := epicheroinfo.CreatorValidator(v); err != nil { + return &ValidationError{Name: "creator", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.creator": %w`, err)} + } + } + if _, ok := _c.mutation.Updater(); !ok { + return &ValidationError{Name: "updater", err: errors.New(`ent: missing required field "EpicHeroInfo.updater"`)} + } + if v, ok := _c.mutation.Updater(); ok { + if err := epicheroinfo.UpdaterValidator(v); err != nil { + return &ValidationError{Name: "updater", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.updater": %w`, err)} + } + } + if _, ok := _c.mutation.Deleted(); !ok { + return &ValidationError{Name: "deleted", err: errors.New(`ent: missing required field "EpicHeroInfo.deleted"`)} + } + if _, ok := _c.mutation.NickName(); !ok { + return &ValidationError{Name: "nick_name", err: errors.New(`ent: missing required field "EpicHeroInfo.nick_name"`)} + } + if v, ok := _c.mutation.NickName(); ok { + if err := epicheroinfo.NickNameValidator(v); err != nil { + return &ValidationError{Name: "nick_name", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.nick_name": %w`, err)} + } + } + if _, ok := _c.mutation.Rarity(); !ok { + return &ValidationError{Name: "rarity", err: errors.New(`ent: missing required field "EpicHeroInfo.rarity"`)} + } + if v, ok := _c.mutation.Rarity(); ok { + if err := epicheroinfo.RarityValidator(v); err != nil { + return &ValidationError{Name: "rarity", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.rarity": %w`, err)} + } + } + if _, ok := _c.mutation.Role(); !ok { + return &ValidationError{Name: "role", err: errors.New(`ent: missing required field "EpicHeroInfo.role"`)} + } + if v, ok := _c.mutation.Role(); ok { + if err := epicheroinfo.RoleValidator(v); err != nil { + return &ValidationError{Name: "role", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.role": %w`, err)} + } + } + if _, ok := _c.mutation.Zodiac(); !ok { + return &ValidationError{Name: "zodiac", err: errors.New(`ent: missing required field "EpicHeroInfo.zodiac"`)} + } + if v, ok := _c.mutation.Zodiac(); ok { + if err := epicheroinfo.ZodiacValidator(v); err != nil { + return &ValidationError{Name: "zodiac", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.zodiac": %w`, err)} + } + } + if _, ok := _c.mutation.HeadImgURL(); !ok { + return &ValidationError{Name: "head_img_url", err: errors.New(`ent: missing required field "EpicHeroInfo.head_img_url"`)} + } + if v, ok := _c.mutation.HeadImgURL(); ok { + if err := epicheroinfo.HeadImgURLValidator(v); err != nil { + return &ValidationError{Name: "head_img_url", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.head_img_url": %w`, err)} + } + } + if _, ok := _c.mutation.Attribute(); !ok { + return &ValidationError{Name: "attribute", err: errors.New(`ent: missing required field "EpicHeroInfo.attribute"`)} + } + if v, ok := _c.mutation.Attribute(); ok { + if err := epicheroinfo.AttributeValidator(v); err != nil { + return &ValidationError{Name: "attribute", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.attribute": %w`, err)} + } + } + if _, ok := _c.mutation.Remark(); !ok { + return &ValidationError{Name: "remark", err: errors.New(`ent: missing required field "EpicHeroInfo.remark"`)} + } + if v, ok := _c.mutation.Remark(); ok { + if err := epicheroinfo.RemarkValidator(v); err != nil { + return &ValidationError{Name: "remark", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.remark": %w`, err)} + } + } + if _, ok := _c.mutation.RawJSON(); !ok { + return &ValidationError{Name: "raw_json", err: errors.New(`ent: missing required field "EpicHeroInfo.raw_json"`)} + } + if v, ok := _c.mutation.RawJSON(); ok { + if err := epicheroinfo.RawJSONValidator(v); err != nil { + return &ValidationError{Name: "raw_json", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.raw_json": %w`, err)} + } + } + if _, ok := _c.mutation.SetContentJSON(); !ok { + return &ValidationError{Name: "set_content_json", err: errors.New(`ent: missing required field "EpicHeroInfo.set_content_json"`)} + } + if v, ok := _c.mutation.SetContentJSON(); ok { + if err := epicheroinfo.SetContentJSONValidator(v); err != nil { + return &ValidationError{Name: "set_content_json", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.set_content_json": %w`, err)} + } + } + return nil +} + +func (_c *EpicHeroInfoCreate) sqlSave(ctx context.Context) (*EpicHeroInfo, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != _node.ID { + id := _spec.ID.Value.(int64) + _node.ID = int64(id) + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *EpicHeroInfoCreate) createSpec() (*EpicHeroInfo, *sqlgraph.CreateSpec) { + var ( + _node = &EpicHeroInfo{config: _c.config} + _spec = sqlgraph.NewCreateSpec(epicheroinfo.Table, sqlgraph.NewFieldSpec(epicheroinfo.FieldID, field.TypeInt64)) + ) + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := _c.mutation.HeroName(); ok { + _spec.SetField(epicheroinfo.FieldHeroName, field.TypeString, value) + _node.HeroName = value + } + if value, ok := _c.mutation.HeroCode(); ok { + _spec.SetField(epicheroinfo.FieldHeroCode, field.TypeString, value) + _node.HeroCode = value + } + if value, ok := _c.mutation.HeroAttrLv60(); ok { + _spec.SetField(epicheroinfo.FieldHeroAttrLv60, field.TypeString, value) + _node.HeroAttrLv60 = value + } + if value, ok := _c.mutation.Creator(); ok { + _spec.SetField(epicheroinfo.FieldCreator, field.TypeString, value) + _node.Creator = value + } + if value, ok := _c.mutation.CreateTime(); ok { + _spec.SetField(epicheroinfo.FieldCreateTime, field.TypeTime, value) + _node.CreateTime = &value + } + if value, ok := _c.mutation.Updater(); ok { + _spec.SetField(epicheroinfo.FieldUpdater, field.TypeString, value) + _node.Updater = value + } + if value, ok := _c.mutation.UpdateTime(); ok { + _spec.SetField(epicheroinfo.FieldUpdateTime, field.TypeTime, value) + _node.UpdateTime = &value + } + if value, ok := _c.mutation.Deleted(); ok { + _spec.SetField(epicheroinfo.FieldDeleted, field.TypeBool, value) + _node.Deleted = value + } + if value, ok := _c.mutation.NickName(); ok { + _spec.SetField(epicheroinfo.FieldNickName, field.TypeString, value) + _node.NickName = value + } + if value, ok := _c.mutation.Rarity(); ok { + _spec.SetField(epicheroinfo.FieldRarity, field.TypeString, value) + _node.Rarity = value + } + if value, ok := _c.mutation.Role(); ok { + _spec.SetField(epicheroinfo.FieldRole, field.TypeString, value) + _node.Role = value + } + if value, ok := _c.mutation.Zodiac(); ok { + _spec.SetField(epicheroinfo.FieldZodiac, field.TypeString, value) + _node.Zodiac = value + } + if value, ok := _c.mutation.HeadImgURL(); ok { + _spec.SetField(epicheroinfo.FieldHeadImgURL, field.TypeString, value) + _node.HeadImgURL = value + } + if value, ok := _c.mutation.Attribute(); ok { + _spec.SetField(epicheroinfo.FieldAttribute, field.TypeString, value) + _node.Attribute = value + } + if value, ok := _c.mutation.Remark(); ok { + _spec.SetField(epicheroinfo.FieldRemark, field.TypeString, value) + _node.Remark = value + } + if value, ok := _c.mutation.RawJSON(); ok { + _spec.SetField(epicheroinfo.FieldRawJSON, field.TypeString, value) + _node.RawJSON = value + } + if value, ok := _c.mutation.SetContentJSON(); ok { + _spec.SetField(epicheroinfo.FieldSetContentJSON, field.TypeString, value) + _node.SetContentJSON = value + } + if value, ok := _c.mutation.SetUpdateTime(); ok { + _spec.SetField(epicheroinfo.FieldSetUpdateTime, field.TypeTime, value) + _node.SetUpdateTime = &value + } + return _node, _spec +} + +// EpicHeroInfoCreateBulk is the builder for creating many EpicHeroInfo entities in bulk. +type EpicHeroInfoCreateBulk struct { + config + err error + builders []*EpicHeroInfoCreate +} + +// Save creates the EpicHeroInfo entities in the database. +func (_c *EpicHeroInfoCreateBulk) Save(ctx context.Context) ([]*EpicHeroInfo, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*EpicHeroInfo, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*EpicHeroInfoMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil && nodes[i].ID == 0 { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int64(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *EpicHeroInfoCreateBulk) SaveX(ctx context.Context) []*EpicHeroInfo { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *EpicHeroInfoCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *EpicHeroInfoCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/ent/epicheroinfo_delete.go b/internal/ent/epicheroinfo_delete.go new file mode 100644 index 0000000..97da135 --- /dev/null +++ b/internal/ent/epicheroinfo_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "epic-ent/internal/ent/epicheroinfo" + "epic-ent/internal/ent/predicate" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// EpicHeroInfoDelete is the builder for deleting a EpicHeroInfo entity. +type EpicHeroInfoDelete struct { + config + hooks []Hook + mutation *EpicHeroInfoMutation +} + +// Where appends a list predicates to the EpicHeroInfoDelete builder. +func (_d *EpicHeroInfoDelete) Where(ps ...predicate.EpicHeroInfo) *EpicHeroInfoDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *EpicHeroInfoDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *EpicHeroInfoDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *EpicHeroInfoDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(epicheroinfo.Table, sqlgraph.NewFieldSpec(epicheroinfo.FieldID, field.TypeInt64)) + if ps := _d.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + _d.mutation.done = true + return affected, err +} + +// EpicHeroInfoDeleteOne is the builder for deleting a single EpicHeroInfo entity. +type EpicHeroInfoDeleteOne struct { + _d *EpicHeroInfoDelete +} + +// Where appends a list predicates to the EpicHeroInfoDelete builder. +func (_d *EpicHeroInfoDeleteOne) Where(ps ...predicate.EpicHeroInfo) *EpicHeroInfoDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *EpicHeroInfoDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{epicheroinfo.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *EpicHeroInfoDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/ent/epicheroinfo_query.go b/internal/ent/epicheroinfo_query.go new file mode 100644 index 0000000..396d83f --- /dev/null +++ b/internal/ent/epicheroinfo_query.go @@ -0,0 +1,527 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "epic-ent/internal/ent/epicheroinfo" + "epic-ent/internal/ent/predicate" + "fmt" + "math" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// EpicHeroInfoQuery is the builder for querying EpicHeroInfo entities. +type EpicHeroInfoQuery struct { + config + ctx *QueryContext + order []epicheroinfo.OrderOption + inters []Interceptor + predicates []predicate.EpicHeroInfo + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the EpicHeroInfoQuery builder. +func (_q *EpicHeroInfoQuery) Where(ps ...predicate.EpicHeroInfo) *EpicHeroInfoQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *EpicHeroInfoQuery) Limit(limit int) *EpicHeroInfoQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *EpicHeroInfoQuery) Offset(offset int) *EpicHeroInfoQuery { + _q.ctx.Offset = &offset + return _q +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (_q *EpicHeroInfoQuery) Unique(unique bool) *EpicHeroInfoQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *EpicHeroInfoQuery) Order(o ...epicheroinfo.OrderOption) *EpicHeroInfoQuery { + _q.order = append(_q.order, o...) + return _q +} + +// First returns the first EpicHeroInfo entity from the query. +// Returns a *NotFoundError when no EpicHeroInfo was found. +func (_q *EpicHeroInfoQuery) First(ctx context.Context) (*EpicHeroInfo, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{epicheroinfo.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *EpicHeroInfoQuery) FirstX(ctx context.Context) *EpicHeroInfo { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first EpicHeroInfo ID from the query. +// Returns a *NotFoundError when no EpicHeroInfo ID was found. +func (_q *EpicHeroInfoQuery) FirstID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{epicheroinfo.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *EpicHeroInfoQuery) FirstIDX(ctx context.Context) int64 { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single EpicHeroInfo entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one EpicHeroInfo entity is found. +// Returns a *NotFoundError when no EpicHeroInfo entities are found. +func (_q *EpicHeroInfoQuery) Only(ctx context.Context) (*EpicHeroInfo, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{epicheroinfo.Label} + default: + return nil, &NotSingularError{epicheroinfo.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *EpicHeroInfoQuery) OnlyX(ctx context.Context) *EpicHeroInfo { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only EpicHeroInfo ID in the query. +// Returns a *NotSingularError when more than one EpicHeroInfo ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *EpicHeroInfoQuery) OnlyID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{epicheroinfo.Label} + default: + err = &NotSingularError{epicheroinfo.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *EpicHeroInfoQuery) OnlyIDX(ctx context.Context) int64 { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of EpicHeroInfos. +func (_q *EpicHeroInfoQuery) All(ctx context.Context) ([]*EpicHeroInfo, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*EpicHeroInfo, *EpicHeroInfoQuery]() + return withInterceptors[[]*EpicHeroInfo](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *EpicHeroInfoQuery) AllX(ctx context.Context) []*EpicHeroInfo { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of EpicHeroInfo IDs. +func (_q *EpicHeroInfoQuery) IDs(ctx context.Context) (ids []int64, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(epicheroinfo.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *EpicHeroInfoQuery) IDsX(ctx context.Context) []int64 { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *EpicHeroInfoQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, _q, querierCount[*EpicHeroInfoQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *EpicHeroInfoQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (_q *EpicHeroInfoQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *EpicHeroInfoQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the EpicHeroInfoQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (_q *EpicHeroInfoQuery) Clone() *EpicHeroInfoQuery { + if _q == nil { + return nil + } + return &EpicHeroInfoQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]epicheroinfo.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.EpicHeroInfo{}, _q.predicates...), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + } +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// HeroName string `json:"hero_name,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.EpicHeroInfo.Query(). +// GroupBy(epicheroinfo.FieldHeroName). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *EpicHeroInfoQuery) GroupBy(field string, fields ...string) *EpicHeroInfoGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &EpicHeroInfoGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = epicheroinfo.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// HeroName string `json:"hero_name,omitempty"` +// } +// +// client.EpicHeroInfo.Query(). +// Select(epicheroinfo.FieldHeroName). +// Scan(ctx, &v) +func (_q *EpicHeroInfoQuery) Select(fields ...string) *EpicHeroInfoSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &EpicHeroInfoSelect{EpicHeroInfoQuery: _q} + sbuild.label = epicheroinfo.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a EpicHeroInfoSelect configured with the given aggregations. +func (_q *EpicHeroInfoQuery) Aggregate(fns ...AggregateFunc) *EpicHeroInfoSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *EpicHeroInfoQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !epicheroinfo.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if _q.path != nil { + prev, err := _q.path(ctx) + if err != nil { + return err + } + _q.sql = prev + } + return nil +} + +func (_q *EpicHeroInfoQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*EpicHeroInfo, error) { + var ( + nodes = []*EpicHeroInfo{} + _spec = _q.querySpec() + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*EpicHeroInfo).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &EpicHeroInfo{config: _q.config} + nodes = append(nodes, node) + return node.assignValues(columns, values) + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + return nodes, nil +} + +func (_q *EpicHeroInfoQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique + } + return sqlgraph.CountNodes(ctx, _q.driver, _spec) +} + +func (_q *EpicHeroInfoQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(epicheroinfo.Table, epicheroinfo.Columns, sqlgraph.NewFieldSpec(epicheroinfo.FieldID, field.TypeInt64)) + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if _q.path != nil { + _spec.Unique = true + } + if fields := _q.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, epicheroinfo.FieldID) + for i := range fields { + if fields[i] != epicheroinfo.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := _q.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := _q.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := _q.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := _q.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (_q *EpicHeroInfoQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(epicheroinfo.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = epicheroinfo.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if _q.sql != nil { + selector = _q.sql + selector.Select(selector.Columns(columns...)...) + } + if _q.ctx.Unique != nil && *_q.ctx.Unique { + selector.Distinct() + } + for _, p := range _q.predicates { + p(selector) + } + for _, p := range _q.order { + p(selector) + } + if offset := _q.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := _q.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// EpicHeroInfoGroupBy is the group-by builder for EpicHeroInfo entities. +type EpicHeroInfoGroupBy struct { + selector + build *EpicHeroInfoQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *EpicHeroInfoGroupBy) Aggregate(fns ...AggregateFunc) *EpicHeroInfoGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *EpicHeroInfoGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*EpicHeroInfoQuery, *EpicHeroInfoGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *EpicHeroInfoGroupBy) sqlScan(ctx context.Context, root *EpicHeroInfoQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*_g.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// EpicHeroInfoSelect is the builder for selecting fields of EpicHeroInfo entities. +type EpicHeroInfoSelect struct { + *EpicHeroInfoQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *EpicHeroInfoSelect) Aggregate(fns ...AggregateFunc) *EpicHeroInfoSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *EpicHeroInfoSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*EpicHeroInfoQuery, *EpicHeroInfoSelect](ctx, _s.EpicHeroInfoQuery, _s, _s.inters, v) +} + +func (_s *EpicHeroInfoSelect) sqlScan(ctx context.Context, root *EpicHeroInfoQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/internal/ent/epicheroinfo_update.go b/internal/ent/epicheroinfo_update.go new file mode 100644 index 0000000..702b411 --- /dev/null +++ b/internal/ent/epicheroinfo_update.go @@ -0,0 +1,998 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "epic-ent/internal/ent/epicheroinfo" + "epic-ent/internal/ent/predicate" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// EpicHeroInfoUpdate is the builder for updating EpicHeroInfo entities. +type EpicHeroInfoUpdate struct { + config + hooks []Hook + mutation *EpicHeroInfoMutation +} + +// Where appends a list predicates to the EpicHeroInfoUpdate builder. +func (_u *EpicHeroInfoUpdate) Where(ps ...predicate.EpicHeroInfo) *EpicHeroInfoUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetHeroName sets the "hero_name" field. +func (_u *EpicHeroInfoUpdate) SetHeroName(v string) *EpicHeroInfoUpdate { + _u.mutation.SetHeroName(v) + return _u +} + +// SetNillableHeroName sets the "hero_name" field if the given value is not nil. +func (_u *EpicHeroInfoUpdate) SetNillableHeroName(v *string) *EpicHeroInfoUpdate { + if v != nil { + _u.SetHeroName(*v) + } + return _u +} + +// SetHeroCode sets the "hero_code" field. +func (_u *EpicHeroInfoUpdate) SetHeroCode(v string) *EpicHeroInfoUpdate { + _u.mutation.SetHeroCode(v) + return _u +} + +// SetNillableHeroCode sets the "hero_code" field if the given value is not nil. +func (_u *EpicHeroInfoUpdate) SetNillableHeroCode(v *string) *EpicHeroInfoUpdate { + if v != nil { + _u.SetHeroCode(*v) + } + return _u +} + +// SetHeroAttrLv60 sets the "hero_attr_lv60" field. +func (_u *EpicHeroInfoUpdate) SetHeroAttrLv60(v string) *EpicHeroInfoUpdate { + _u.mutation.SetHeroAttrLv60(v) + return _u +} + +// SetNillableHeroAttrLv60 sets the "hero_attr_lv60" field if the given value is not nil. +func (_u *EpicHeroInfoUpdate) SetNillableHeroAttrLv60(v *string) *EpicHeroInfoUpdate { + if v != nil { + _u.SetHeroAttrLv60(*v) + } + return _u +} + +// SetCreator sets the "creator" field. +func (_u *EpicHeroInfoUpdate) SetCreator(v string) *EpicHeroInfoUpdate { + _u.mutation.SetCreator(v) + return _u +} + +// SetNillableCreator sets the "creator" field if the given value is not nil. +func (_u *EpicHeroInfoUpdate) SetNillableCreator(v *string) *EpicHeroInfoUpdate { + if v != nil { + _u.SetCreator(*v) + } + return _u +} + +// SetCreateTime sets the "create_time" field. +func (_u *EpicHeroInfoUpdate) SetCreateTime(v time.Time) *EpicHeroInfoUpdate { + _u.mutation.SetCreateTime(v) + return _u +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (_u *EpicHeroInfoUpdate) SetNillableCreateTime(v *time.Time) *EpicHeroInfoUpdate { + if v != nil { + _u.SetCreateTime(*v) + } + return _u +} + +// ClearCreateTime clears the value of the "create_time" field. +func (_u *EpicHeroInfoUpdate) ClearCreateTime() *EpicHeroInfoUpdate { + _u.mutation.ClearCreateTime() + return _u +} + +// SetUpdater sets the "updater" field. +func (_u *EpicHeroInfoUpdate) SetUpdater(v string) *EpicHeroInfoUpdate { + _u.mutation.SetUpdater(v) + return _u +} + +// SetNillableUpdater sets the "updater" field if the given value is not nil. +func (_u *EpicHeroInfoUpdate) SetNillableUpdater(v *string) *EpicHeroInfoUpdate { + if v != nil { + _u.SetUpdater(*v) + } + return _u +} + +// SetUpdateTime sets the "update_time" field. +func (_u *EpicHeroInfoUpdate) SetUpdateTime(v time.Time) *EpicHeroInfoUpdate { + _u.mutation.SetUpdateTime(v) + return _u +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (_u *EpicHeroInfoUpdate) SetNillableUpdateTime(v *time.Time) *EpicHeroInfoUpdate { + if v != nil { + _u.SetUpdateTime(*v) + } + return _u +} + +// ClearUpdateTime clears the value of the "update_time" field. +func (_u *EpicHeroInfoUpdate) ClearUpdateTime() *EpicHeroInfoUpdate { + _u.mutation.ClearUpdateTime() + return _u +} + +// SetDeleted sets the "deleted" field. +func (_u *EpicHeroInfoUpdate) SetDeleted(v bool) *EpicHeroInfoUpdate { + _u.mutation.SetDeleted(v) + return _u +} + +// SetNillableDeleted sets the "deleted" field if the given value is not nil. +func (_u *EpicHeroInfoUpdate) SetNillableDeleted(v *bool) *EpicHeroInfoUpdate { + if v != nil { + _u.SetDeleted(*v) + } + return _u +} + +// SetNickName sets the "nick_name" field. +func (_u *EpicHeroInfoUpdate) SetNickName(v string) *EpicHeroInfoUpdate { + _u.mutation.SetNickName(v) + return _u +} + +// SetNillableNickName sets the "nick_name" field if the given value is not nil. +func (_u *EpicHeroInfoUpdate) SetNillableNickName(v *string) *EpicHeroInfoUpdate { + if v != nil { + _u.SetNickName(*v) + } + return _u +} + +// SetRarity sets the "rarity" field. +func (_u *EpicHeroInfoUpdate) SetRarity(v string) *EpicHeroInfoUpdate { + _u.mutation.SetRarity(v) + return _u +} + +// SetNillableRarity sets the "rarity" field if the given value is not nil. +func (_u *EpicHeroInfoUpdate) SetNillableRarity(v *string) *EpicHeroInfoUpdate { + if v != nil { + _u.SetRarity(*v) + } + return _u +} + +// SetRole sets the "role" field. +func (_u *EpicHeroInfoUpdate) SetRole(v string) *EpicHeroInfoUpdate { + _u.mutation.SetRole(v) + return _u +} + +// SetNillableRole sets the "role" field if the given value is not nil. +func (_u *EpicHeroInfoUpdate) SetNillableRole(v *string) *EpicHeroInfoUpdate { + if v != nil { + _u.SetRole(*v) + } + return _u +} + +// SetZodiac sets the "zodiac" field. +func (_u *EpicHeroInfoUpdate) SetZodiac(v string) *EpicHeroInfoUpdate { + _u.mutation.SetZodiac(v) + return _u +} + +// SetNillableZodiac sets the "zodiac" field if the given value is not nil. +func (_u *EpicHeroInfoUpdate) SetNillableZodiac(v *string) *EpicHeroInfoUpdate { + if v != nil { + _u.SetZodiac(*v) + } + return _u +} + +// SetHeadImgURL sets the "head_img_url" field. +func (_u *EpicHeroInfoUpdate) SetHeadImgURL(v string) *EpicHeroInfoUpdate { + _u.mutation.SetHeadImgURL(v) + return _u +} + +// SetNillableHeadImgURL sets the "head_img_url" field if the given value is not nil. +func (_u *EpicHeroInfoUpdate) SetNillableHeadImgURL(v *string) *EpicHeroInfoUpdate { + if v != nil { + _u.SetHeadImgURL(*v) + } + return _u +} + +// SetAttribute sets the "attribute" field. +func (_u *EpicHeroInfoUpdate) SetAttribute(v string) *EpicHeroInfoUpdate { + _u.mutation.SetAttribute(v) + return _u +} + +// SetNillableAttribute sets the "attribute" field if the given value is not nil. +func (_u *EpicHeroInfoUpdate) SetNillableAttribute(v *string) *EpicHeroInfoUpdate { + if v != nil { + _u.SetAttribute(*v) + } + return _u +} + +// SetRemark sets the "remark" field. +func (_u *EpicHeroInfoUpdate) SetRemark(v string) *EpicHeroInfoUpdate { + _u.mutation.SetRemark(v) + return _u +} + +// SetNillableRemark sets the "remark" field if the given value is not nil. +func (_u *EpicHeroInfoUpdate) SetNillableRemark(v *string) *EpicHeroInfoUpdate { + if v != nil { + _u.SetRemark(*v) + } + return _u +} + +// SetRawJSON sets the "raw_json" field. +func (_u *EpicHeroInfoUpdate) SetRawJSON(v string) *EpicHeroInfoUpdate { + _u.mutation.SetRawJSON(v) + return _u +} + +// SetNillableRawJSON sets the "raw_json" field if the given value is not nil. +func (_u *EpicHeroInfoUpdate) SetNillableRawJSON(v *string) *EpicHeroInfoUpdate { + if v != nil { + _u.SetRawJSON(*v) + } + return _u +} + +// SetSetContentJSON sets the "set_content_json" field. +func (_u *EpicHeroInfoUpdate) SetSetContentJSON(v string) *EpicHeroInfoUpdate { + _u.mutation.SetSetContentJSON(v) + return _u +} + +// SetNillableSetContentJSON sets the "set_content_json" field if the given value is not nil. +func (_u *EpicHeroInfoUpdate) SetNillableSetContentJSON(v *string) *EpicHeroInfoUpdate { + if v != nil { + _u.SetSetContentJSON(*v) + } + return _u +} + +// SetSetUpdateTime sets the "set_update_time" field. +func (_u *EpicHeroInfoUpdate) SetSetUpdateTime(v time.Time) *EpicHeroInfoUpdate { + _u.mutation.SetSetUpdateTime(v) + return _u +} + +// SetNillableSetUpdateTime sets the "set_update_time" field if the given value is not nil. +func (_u *EpicHeroInfoUpdate) SetNillableSetUpdateTime(v *time.Time) *EpicHeroInfoUpdate { + if v != nil { + _u.SetSetUpdateTime(*v) + } + return _u +} + +// ClearSetUpdateTime clears the value of the "set_update_time" field. +func (_u *EpicHeroInfoUpdate) ClearSetUpdateTime() *EpicHeroInfoUpdate { + _u.mutation.ClearSetUpdateTime() + return _u +} + +// Mutation returns the EpicHeroInfoMutation object of the builder. +func (_u *EpicHeroInfoUpdate) Mutation() *EpicHeroInfoMutation { + return _u.mutation +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *EpicHeroInfoUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *EpicHeroInfoUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *EpicHeroInfoUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *EpicHeroInfoUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *EpicHeroInfoUpdate) check() error { + if v, ok := _u.mutation.HeroName(); ok { + if err := epicheroinfo.HeroNameValidator(v); err != nil { + return &ValidationError{Name: "hero_name", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.hero_name": %w`, err)} + } + } + if v, ok := _u.mutation.HeroCode(); ok { + if err := epicheroinfo.HeroCodeValidator(v); err != nil { + return &ValidationError{Name: "hero_code", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.hero_code": %w`, err)} + } + } + if v, ok := _u.mutation.HeroAttrLv60(); ok { + if err := epicheroinfo.HeroAttrLv60Validator(v); err != nil { + return &ValidationError{Name: "hero_attr_lv60", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.hero_attr_lv60": %w`, err)} + } + } + if v, ok := _u.mutation.Creator(); ok { + if err := epicheroinfo.CreatorValidator(v); err != nil { + return &ValidationError{Name: "creator", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.creator": %w`, err)} + } + } + if v, ok := _u.mutation.Updater(); ok { + if err := epicheroinfo.UpdaterValidator(v); err != nil { + return &ValidationError{Name: "updater", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.updater": %w`, err)} + } + } + if v, ok := _u.mutation.NickName(); ok { + if err := epicheroinfo.NickNameValidator(v); err != nil { + return &ValidationError{Name: "nick_name", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.nick_name": %w`, err)} + } + } + if v, ok := _u.mutation.Rarity(); ok { + if err := epicheroinfo.RarityValidator(v); err != nil { + return &ValidationError{Name: "rarity", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.rarity": %w`, err)} + } + } + if v, ok := _u.mutation.Role(); ok { + if err := epicheroinfo.RoleValidator(v); err != nil { + return &ValidationError{Name: "role", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.role": %w`, err)} + } + } + if v, ok := _u.mutation.Zodiac(); ok { + if err := epicheroinfo.ZodiacValidator(v); err != nil { + return &ValidationError{Name: "zodiac", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.zodiac": %w`, err)} + } + } + if v, ok := _u.mutation.HeadImgURL(); ok { + if err := epicheroinfo.HeadImgURLValidator(v); err != nil { + return &ValidationError{Name: "head_img_url", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.head_img_url": %w`, err)} + } + } + if v, ok := _u.mutation.Attribute(); ok { + if err := epicheroinfo.AttributeValidator(v); err != nil { + return &ValidationError{Name: "attribute", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.attribute": %w`, err)} + } + } + if v, ok := _u.mutation.Remark(); ok { + if err := epicheroinfo.RemarkValidator(v); err != nil { + return &ValidationError{Name: "remark", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.remark": %w`, err)} + } + } + if v, ok := _u.mutation.RawJSON(); ok { + if err := epicheroinfo.RawJSONValidator(v); err != nil { + return &ValidationError{Name: "raw_json", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.raw_json": %w`, err)} + } + } + if v, ok := _u.mutation.SetContentJSON(); ok { + if err := epicheroinfo.SetContentJSONValidator(v); err != nil { + return &ValidationError{Name: "set_content_json", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.set_content_json": %w`, err)} + } + } + return nil +} + +func (_u *EpicHeroInfoUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(epicheroinfo.Table, epicheroinfo.Columns, sqlgraph.NewFieldSpec(epicheroinfo.FieldID, field.TypeInt64)) + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.HeroName(); ok { + _spec.SetField(epicheroinfo.FieldHeroName, field.TypeString, value) + } + if value, ok := _u.mutation.HeroCode(); ok { + _spec.SetField(epicheroinfo.FieldHeroCode, field.TypeString, value) + } + if value, ok := _u.mutation.HeroAttrLv60(); ok { + _spec.SetField(epicheroinfo.FieldHeroAttrLv60, field.TypeString, value) + } + if value, ok := _u.mutation.Creator(); ok { + _spec.SetField(epicheroinfo.FieldCreator, field.TypeString, value) + } + if value, ok := _u.mutation.CreateTime(); ok { + _spec.SetField(epicheroinfo.FieldCreateTime, field.TypeTime, value) + } + if _u.mutation.CreateTimeCleared() { + _spec.ClearField(epicheroinfo.FieldCreateTime, field.TypeTime) + } + if value, ok := _u.mutation.Updater(); ok { + _spec.SetField(epicheroinfo.FieldUpdater, field.TypeString, value) + } + if value, ok := _u.mutation.UpdateTime(); ok { + _spec.SetField(epicheroinfo.FieldUpdateTime, field.TypeTime, value) + } + if _u.mutation.UpdateTimeCleared() { + _spec.ClearField(epicheroinfo.FieldUpdateTime, field.TypeTime) + } + if value, ok := _u.mutation.Deleted(); ok { + _spec.SetField(epicheroinfo.FieldDeleted, field.TypeBool, value) + } + if value, ok := _u.mutation.NickName(); ok { + _spec.SetField(epicheroinfo.FieldNickName, field.TypeString, value) + } + if value, ok := _u.mutation.Rarity(); ok { + _spec.SetField(epicheroinfo.FieldRarity, field.TypeString, value) + } + if value, ok := _u.mutation.Role(); ok { + _spec.SetField(epicheroinfo.FieldRole, field.TypeString, value) + } + if value, ok := _u.mutation.Zodiac(); ok { + _spec.SetField(epicheroinfo.FieldZodiac, field.TypeString, value) + } + if value, ok := _u.mutation.HeadImgURL(); ok { + _spec.SetField(epicheroinfo.FieldHeadImgURL, field.TypeString, value) + } + if value, ok := _u.mutation.Attribute(); ok { + _spec.SetField(epicheroinfo.FieldAttribute, field.TypeString, value) + } + if value, ok := _u.mutation.Remark(); ok { + _spec.SetField(epicheroinfo.FieldRemark, field.TypeString, value) + } + if value, ok := _u.mutation.RawJSON(); ok { + _spec.SetField(epicheroinfo.FieldRawJSON, field.TypeString, value) + } + if value, ok := _u.mutation.SetContentJSON(); ok { + _spec.SetField(epicheroinfo.FieldSetContentJSON, field.TypeString, value) + } + if value, ok := _u.mutation.SetUpdateTime(); ok { + _spec.SetField(epicheroinfo.FieldSetUpdateTime, field.TypeTime, value) + } + if _u.mutation.SetUpdateTimeCleared() { + _spec.ClearField(epicheroinfo.FieldSetUpdateTime, field.TypeTime) + } + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{epicheroinfo.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// EpicHeroInfoUpdateOne is the builder for updating a single EpicHeroInfo entity. +type EpicHeroInfoUpdateOne struct { + config + fields []string + hooks []Hook + mutation *EpicHeroInfoMutation +} + +// SetHeroName sets the "hero_name" field. +func (_u *EpicHeroInfoUpdateOne) SetHeroName(v string) *EpicHeroInfoUpdateOne { + _u.mutation.SetHeroName(v) + return _u +} + +// SetNillableHeroName sets the "hero_name" field if the given value is not nil. +func (_u *EpicHeroInfoUpdateOne) SetNillableHeroName(v *string) *EpicHeroInfoUpdateOne { + if v != nil { + _u.SetHeroName(*v) + } + return _u +} + +// SetHeroCode sets the "hero_code" field. +func (_u *EpicHeroInfoUpdateOne) SetHeroCode(v string) *EpicHeroInfoUpdateOne { + _u.mutation.SetHeroCode(v) + return _u +} + +// SetNillableHeroCode sets the "hero_code" field if the given value is not nil. +func (_u *EpicHeroInfoUpdateOne) SetNillableHeroCode(v *string) *EpicHeroInfoUpdateOne { + if v != nil { + _u.SetHeroCode(*v) + } + return _u +} + +// SetHeroAttrLv60 sets the "hero_attr_lv60" field. +func (_u *EpicHeroInfoUpdateOne) SetHeroAttrLv60(v string) *EpicHeroInfoUpdateOne { + _u.mutation.SetHeroAttrLv60(v) + return _u +} + +// SetNillableHeroAttrLv60 sets the "hero_attr_lv60" field if the given value is not nil. +func (_u *EpicHeroInfoUpdateOne) SetNillableHeroAttrLv60(v *string) *EpicHeroInfoUpdateOne { + if v != nil { + _u.SetHeroAttrLv60(*v) + } + return _u +} + +// SetCreator sets the "creator" field. +func (_u *EpicHeroInfoUpdateOne) SetCreator(v string) *EpicHeroInfoUpdateOne { + _u.mutation.SetCreator(v) + return _u +} + +// SetNillableCreator sets the "creator" field if the given value is not nil. +func (_u *EpicHeroInfoUpdateOne) SetNillableCreator(v *string) *EpicHeroInfoUpdateOne { + if v != nil { + _u.SetCreator(*v) + } + return _u +} + +// SetCreateTime sets the "create_time" field. +func (_u *EpicHeroInfoUpdateOne) SetCreateTime(v time.Time) *EpicHeroInfoUpdateOne { + _u.mutation.SetCreateTime(v) + return _u +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (_u *EpicHeroInfoUpdateOne) SetNillableCreateTime(v *time.Time) *EpicHeroInfoUpdateOne { + if v != nil { + _u.SetCreateTime(*v) + } + return _u +} + +// ClearCreateTime clears the value of the "create_time" field. +func (_u *EpicHeroInfoUpdateOne) ClearCreateTime() *EpicHeroInfoUpdateOne { + _u.mutation.ClearCreateTime() + return _u +} + +// SetUpdater sets the "updater" field. +func (_u *EpicHeroInfoUpdateOne) SetUpdater(v string) *EpicHeroInfoUpdateOne { + _u.mutation.SetUpdater(v) + return _u +} + +// SetNillableUpdater sets the "updater" field if the given value is not nil. +func (_u *EpicHeroInfoUpdateOne) SetNillableUpdater(v *string) *EpicHeroInfoUpdateOne { + if v != nil { + _u.SetUpdater(*v) + } + return _u +} + +// SetUpdateTime sets the "update_time" field. +func (_u *EpicHeroInfoUpdateOne) SetUpdateTime(v time.Time) *EpicHeroInfoUpdateOne { + _u.mutation.SetUpdateTime(v) + return _u +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (_u *EpicHeroInfoUpdateOne) SetNillableUpdateTime(v *time.Time) *EpicHeroInfoUpdateOne { + if v != nil { + _u.SetUpdateTime(*v) + } + return _u +} + +// ClearUpdateTime clears the value of the "update_time" field. +func (_u *EpicHeroInfoUpdateOne) ClearUpdateTime() *EpicHeroInfoUpdateOne { + _u.mutation.ClearUpdateTime() + return _u +} + +// SetDeleted sets the "deleted" field. +func (_u *EpicHeroInfoUpdateOne) SetDeleted(v bool) *EpicHeroInfoUpdateOne { + _u.mutation.SetDeleted(v) + return _u +} + +// SetNillableDeleted sets the "deleted" field if the given value is not nil. +func (_u *EpicHeroInfoUpdateOne) SetNillableDeleted(v *bool) *EpicHeroInfoUpdateOne { + if v != nil { + _u.SetDeleted(*v) + } + return _u +} + +// SetNickName sets the "nick_name" field. +func (_u *EpicHeroInfoUpdateOne) SetNickName(v string) *EpicHeroInfoUpdateOne { + _u.mutation.SetNickName(v) + return _u +} + +// SetNillableNickName sets the "nick_name" field if the given value is not nil. +func (_u *EpicHeroInfoUpdateOne) SetNillableNickName(v *string) *EpicHeroInfoUpdateOne { + if v != nil { + _u.SetNickName(*v) + } + return _u +} + +// SetRarity sets the "rarity" field. +func (_u *EpicHeroInfoUpdateOne) SetRarity(v string) *EpicHeroInfoUpdateOne { + _u.mutation.SetRarity(v) + return _u +} + +// SetNillableRarity sets the "rarity" field if the given value is not nil. +func (_u *EpicHeroInfoUpdateOne) SetNillableRarity(v *string) *EpicHeroInfoUpdateOne { + if v != nil { + _u.SetRarity(*v) + } + return _u +} + +// SetRole sets the "role" field. +func (_u *EpicHeroInfoUpdateOne) SetRole(v string) *EpicHeroInfoUpdateOne { + _u.mutation.SetRole(v) + return _u +} + +// SetNillableRole sets the "role" field if the given value is not nil. +func (_u *EpicHeroInfoUpdateOne) SetNillableRole(v *string) *EpicHeroInfoUpdateOne { + if v != nil { + _u.SetRole(*v) + } + return _u +} + +// SetZodiac sets the "zodiac" field. +func (_u *EpicHeroInfoUpdateOne) SetZodiac(v string) *EpicHeroInfoUpdateOne { + _u.mutation.SetZodiac(v) + return _u +} + +// SetNillableZodiac sets the "zodiac" field if the given value is not nil. +func (_u *EpicHeroInfoUpdateOne) SetNillableZodiac(v *string) *EpicHeroInfoUpdateOne { + if v != nil { + _u.SetZodiac(*v) + } + return _u +} + +// SetHeadImgURL sets the "head_img_url" field. +func (_u *EpicHeroInfoUpdateOne) SetHeadImgURL(v string) *EpicHeroInfoUpdateOne { + _u.mutation.SetHeadImgURL(v) + return _u +} + +// SetNillableHeadImgURL sets the "head_img_url" field if the given value is not nil. +func (_u *EpicHeroInfoUpdateOne) SetNillableHeadImgURL(v *string) *EpicHeroInfoUpdateOne { + if v != nil { + _u.SetHeadImgURL(*v) + } + return _u +} + +// SetAttribute sets the "attribute" field. +func (_u *EpicHeroInfoUpdateOne) SetAttribute(v string) *EpicHeroInfoUpdateOne { + _u.mutation.SetAttribute(v) + return _u +} + +// SetNillableAttribute sets the "attribute" field if the given value is not nil. +func (_u *EpicHeroInfoUpdateOne) SetNillableAttribute(v *string) *EpicHeroInfoUpdateOne { + if v != nil { + _u.SetAttribute(*v) + } + return _u +} + +// SetRemark sets the "remark" field. +func (_u *EpicHeroInfoUpdateOne) SetRemark(v string) *EpicHeroInfoUpdateOne { + _u.mutation.SetRemark(v) + return _u +} + +// SetNillableRemark sets the "remark" field if the given value is not nil. +func (_u *EpicHeroInfoUpdateOne) SetNillableRemark(v *string) *EpicHeroInfoUpdateOne { + if v != nil { + _u.SetRemark(*v) + } + return _u +} + +// SetRawJSON sets the "raw_json" field. +func (_u *EpicHeroInfoUpdateOne) SetRawJSON(v string) *EpicHeroInfoUpdateOne { + _u.mutation.SetRawJSON(v) + return _u +} + +// SetNillableRawJSON sets the "raw_json" field if the given value is not nil. +func (_u *EpicHeroInfoUpdateOne) SetNillableRawJSON(v *string) *EpicHeroInfoUpdateOne { + if v != nil { + _u.SetRawJSON(*v) + } + return _u +} + +// SetSetContentJSON sets the "set_content_json" field. +func (_u *EpicHeroInfoUpdateOne) SetSetContentJSON(v string) *EpicHeroInfoUpdateOne { + _u.mutation.SetSetContentJSON(v) + return _u +} + +// SetNillableSetContentJSON sets the "set_content_json" field if the given value is not nil. +func (_u *EpicHeroInfoUpdateOne) SetNillableSetContentJSON(v *string) *EpicHeroInfoUpdateOne { + if v != nil { + _u.SetSetContentJSON(*v) + } + return _u +} + +// SetSetUpdateTime sets the "set_update_time" field. +func (_u *EpicHeroInfoUpdateOne) SetSetUpdateTime(v time.Time) *EpicHeroInfoUpdateOne { + _u.mutation.SetSetUpdateTime(v) + return _u +} + +// SetNillableSetUpdateTime sets the "set_update_time" field if the given value is not nil. +func (_u *EpicHeroInfoUpdateOne) SetNillableSetUpdateTime(v *time.Time) *EpicHeroInfoUpdateOne { + if v != nil { + _u.SetSetUpdateTime(*v) + } + return _u +} + +// ClearSetUpdateTime clears the value of the "set_update_time" field. +func (_u *EpicHeroInfoUpdateOne) ClearSetUpdateTime() *EpicHeroInfoUpdateOne { + _u.mutation.ClearSetUpdateTime() + return _u +} + +// Mutation returns the EpicHeroInfoMutation object of the builder. +func (_u *EpicHeroInfoUpdateOne) Mutation() *EpicHeroInfoMutation { + return _u.mutation +} + +// Where appends a list predicates to the EpicHeroInfoUpdate builder. +func (_u *EpicHeroInfoUpdateOne) Where(ps ...predicate.EpicHeroInfo) *EpicHeroInfoUpdateOne { + _u.mutation.Where(ps...) + return _u +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (_u *EpicHeroInfoUpdateOne) Select(field string, fields ...string) *EpicHeroInfoUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated EpicHeroInfo entity. +func (_u *EpicHeroInfoUpdateOne) Save(ctx context.Context) (*EpicHeroInfo, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *EpicHeroInfoUpdateOne) SaveX(ctx context.Context) *EpicHeroInfo { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *EpicHeroInfoUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *EpicHeroInfoUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *EpicHeroInfoUpdateOne) check() error { + if v, ok := _u.mutation.HeroName(); ok { + if err := epicheroinfo.HeroNameValidator(v); err != nil { + return &ValidationError{Name: "hero_name", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.hero_name": %w`, err)} + } + } + if v, ok := _u.mutation.HeroCode(); ok { + if err := epicheroinfo.HeroCodeValidator(v); err != nil { + return &ValidationError{Name: "hero_code", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.hero_code": %w`, err)} + } + } + if v, ok := _u.mutation.HeroAttrLv60(); ok { + if err := epicheroinfo.HeroAttrLv60Validator(v); err != nil { + return &ValidationError{Name: "hero_attr_lv60", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.hero_attr_lv60": %w`, err)} + } + } + if v, ok := _u.mutation.Creator(); ok { + if err := epicheroinfo.CreatorValidator(v); err != nil { + return &ValidationError{Name: "creator", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.creator": %w`, err)} + } + } + if v, ok := _u.mutation.Updater(); ok { + if err := epicheroinfo.UpdaterValidator(v); err != nil { + return &ValidationError{Name: "updater", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.updater": %w`, err)} + } + } + if v, ok := _u.mutation.NickName(); ok { + if err := epicheroinfo.NickNameValidator(v); err != nil { + return &ValidationError{Name: "nick_name", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.nick_name": %w`, err)} + } + } + if v, ok := _u.mutation.Rarity(); ok { + if err := epicheroinfo.RarityValidator(v); err != nil { + return &ValidationError{Name: "rarity", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.rarity": %w`, err)} + } + } + if v, ok := _u.mutation.Role(); ok { + if err := epicheroinfo.RoleValidator(v); err != nil { + return &ValidationError{Name: "role", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.role": %w`, err)} + } + } + if v, ok := _u.mutation.Zodiac(); ok { + if err := epicheroinfo.ZodiacValidator(v); err != nil { + return &ValidationError{Name: "zodiac", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.zodiac": %w`, err)} + } + } + if v, ok := _u.mutation.HeadImgURL(); ok { + if err := epicheroinfo.HeadImgURLValidator(v); err != nil { + return &ValidationError{Name: "head_img_url", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.head_img_url": %w`, err)} + } + } + if v, ok := _u.mutation.Attribute(); ok { + if err := epicheroinfo.AttributeValidator(v); err != nil { + return &ValidationError{Name: "attribute", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.attribute": %w`, err)} + } + } + if v, ok := _u.mutation.Remark(); ok { + if err := epicheroinfo.RemarkValidator(v); err != nil { + return &ValidationError{Name: "remark", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.remark": %w`, err)} + } + } + if v, ok := _u.mutation.RawJSON(); ok { + if err := epicheroinfo.RawJSONValidator(v); err != nil { + return &ValidationError{Name: "raw_json", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.raw_json": %w`, err)} + } + } + if v, ok := _u.mutation.SetContentJSON(); ok { + if err := epicheroinfo.SetContentJSONValidator(v); err != nil { + return &ValidationError{Name: "set_content_json", err: fmt.Errorf(`ent: validator failed for field "EpicHeroInfo.set_content_json": %w`, err)} + } + } + return nil +} + +func (_u *EpicHeroInfoUpdateOne) sqlSave(ctx context.Context) (_node *EpicHeroInfo, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(epicheroinfo.Table, epicheroinfo.Columns, sqlgraph.NewFieldSpec(epicheroinfo.FieldID, field.TypeInt64)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "EpicHeroInfo.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := _u.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, epicheroinfo.FieldID) + for _, f := range fields { + if !epicheroinfo.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != epicheroinfo.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.HeroName(); ok { + _spec.SetField(epicheroinfo.FieldHeroName, field.TypeString, value) + } + if value, ok := _u.mutation.HeroCode(); ok { + _spec.SetField(epicheroinfo.FieldHeroCode, field.TypeString, value) + } + if value, ok := _u.mutation.HeroAttrLv60(); ok { + _spec.SetField(epicheroinfo.FieldHeroAttrLv60, field.TypeString, value) + } + if value, ok := _u.mutation.Creator(); ok { + _spec.SetField(epicheroinfo.FieldCreator, field.TypeString, value) + } + if value, ok := _u.mutation.CreateTime(); ok { + _spec.SetField(epicheroinfo.FieldCreateTime, field.TypeTime, value) + } + if _u.mutation.CreateTimeCleared() { + _spec.ClearField(epicheroinfo.FieldCreateTime, field.TypeTime) + } + if value, ok := _u.mutation.Updater(); ok { + _spec.SetField(epicheroinfo.FieldUpdater, field.TypeString, value) + } + if value, ok := _u.mutation.UpdateTime(); ok { + _spec.SetField(epicheroinfo.FieldUpdateTime, field.TypeTime, value) + } + if _u.mutation.UpdateTimeCleared() { + _spec.ClearField(epicheroinfo.FieldUpdateTime, field.TypeTime) + } + if value, ok := _u.mutation.Deleted(); ok { + _spec.SetField(epicheroinfo.FieldDeleted, field.TypeBool, value) + } + if value, ok := _u.mutation.NickName(); ok { + _spec.SetField(epicheroinfo.FieldNickName, field.TypeString, value) + } + if value, ok := _u.mutation.Rarity(); ok { + _spec.SetField(epicheroinfo.FieldRarity, field.TypeString, value) + } + if value, ok := _u.mutation.Role(); ok { + _spec.SetField(epicheroinfo.FieldRole, field.TypeString, value) + } + if value, ok := _u.mutation.Zodiac(); ok { + _spec.SetField(epicheroinfo.FieldZodiac, field.TypeString, value) + } + if value, ok := _u.mutation.HeadImgURL(); ok { + _spec.SetField(epicheroinfo.FieldHeadImgURL, field.TypeString, value) + } + if value, ok := _u.mutation.Attribute(); ok { + _spec.SetField(epicheroinfo.FieldAttribute, field.TypeString, value) + } + if value, ok := _u.mutation.Remark(); ok { + _spec.SetField(epicheroinfo.FieldRemark, field.TypeString, value) + } + if value, ok := _u.mutation.RawJSON(); ok { + _spec.SetField(epicheroinfo.FieldRawJSON, field.TypeString, value) + } + if value, ok := _u.mutation.SetContentJSON(); ok { + _spec.SetField(epicheroinfo.FieldSetContentJSON, field.TypeString, value) + } + if value, ok := _u.mutation.SetUpdateTime(); ok { + _spec.SetField(epicheroinfo.FieldSetUpdateTime, field.TypeTime, value) + } + if _u.mutation.SetUpdateTimeCleared() { + _spec.ClearField(epicheroinfo.FieldSetUpdateTime, field.TypeTime) + } + _node = &EpicHeroInfo{config: _u.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{epicheroinfo.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} diff --git a/internal/ent/epicherouserbuild.go b/internal/ent/epicherouserbuild.go new file mode 100644 index 0000000..54abf29 --- /dev/null +++ b/internal/ent/epicherouserbuild.go @@ -0,0 +1,215 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "epic-ent/internal/ent/epicherouserbuild" + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// EpicHeroUserBuild is the model entity for the EpicHeroUserBuild schema. +type EpicHeroUserBuild struct { + config `json:"-"` + // ID of the ent. + ID int64 `json:"id,omitempty"` + // ArtifactCode holds the value of the "artifact_code" field. + ArtifactCode string `json:"artifact_code,omitempty"` + // HeroCode holds the value of the "hero_code" field. + HeroCode string `json:"hero_code,omitempty"` + // HeroHeathBuild holds the value of the "hero_heath_build" field. + HeroHeathBuild float64 `json:"hero_heath_build,omitempty"` + // HeroAttackBuild holds the value of the "hero_attack_build" field. + HeroAttackBuild float64 `json:"hero_attack_build,omitempty"` + // HeroDefBuild holds the value of the "hero_def_build" field. + HeroDefBuild float64 `json:"hero_def_build,omitempty"` + // Creator holds the value of the "creator" field. + Creator string `json:"creator,omitempty"` + // CreateTime holds the value of the "create_time" field. + CreateTime *time.Time `json:"create_time,omitempty"` + // Updater holds the value of the "updater" field. + Updater string `json:"updater,omitempty"` + // UpdateTime holds the value of the "update_time" field. + UpdateTime *time.Time `json:"update_time,omitempty"` + // Deleted holds the value of the "deleted" field. + Deleted bool `json:"deleted,omitempty"` + selectValues sql.SelectValues +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*EpicHeroUserBuild) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case epicherouserbuild.FieldDeleted: + values[i] = new(sql.NullBool) + case epicherouserbuild.FieldHeroHeathBuild, epicherouserbuild.FieldHeroAttackBuild, epicherouserbuild.FieldHeroDefBuild: + values[i] = new(sql.NullFloat64) + case epicherouserbuild.FieldID: + values[i] = new(sql.NullInt64) + case epicherouserbuild.FieldArtifactCode, epicherouserbuild.FieldHeroCode, epicherouserbuild.FieldCreator, epicherouserbuild.FieldUpdater: + values[i] = new(sql.NullString) + case epicherouserbuild.FieldCreateTime, epicherouserbuild.FieldUpdateTime: + values[i] = new(sql.NullTime) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the EpicHeroUserBuild fields. +func (_m *EpicHeroUserBuild) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case epicherouserbuild.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + _m.ID = int64(value.Int64) + case epicherouserbuild.FieldArtifactCode: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field artifact_code", values[i]) + } else if value.Valid { + _m.ArtifactCode = value.String + } + case epicherouserbuild.FieldHeroCode: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field hero_code", values[i]) + } else if value.Valid { + _m.HeroCode = value.String + } + case epicherouserbuild.FieldHeroHeathBuild: + if value, ok := values[i].(*sql.NullFloat64); !ok { + return fmt.Errorf("unexpected type %T for field hero_heath_build", values[i]) + } else if value.Valid { + _m.HeroHeathBuild = value.Float64 + } + case epicherouserbuild.FieldHeroAttackBuild: + if value, ok := values[i].(*sql.NullFloat64); !ok { + return fmt.Errorf("unexpected type %T for field hero_attack_build", values[i]) + } else if value.Valid { + _m.HeroAttackBuild = value.Float64 + } + case epicherouserbuild.FieldHeroDefBuild: + if value, ok := values[i].(*sql.NullFloat64); !ok { + return fmt.Errorf("unexpected type %T for field hero_def_build", values[i]) + } else if value.Valid { + _m.HeroDefBuild = value.Float64 + } + case epicherouserbuild.FieldCreator: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field creator", values[i]) + } else if value.Valid { + _m.Creator = value.String + } + case epicherouserbuild.FieldCreateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field create_time", values[i]) + } else if value.Valid { + _m.CreateTime = new(time.Time) + *_m.CreateTime = value.Time + } + case epicherouserbuild.FieldUpdater: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field updater", values[i]) + } else if value.Valid { + _m.Updater = value.String + } + case epicherouserbuild.FieldUpdateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field update_time", values[i]) + } else if value.Valid { + _m.UpdateTime = new(time.Time) + *_m.UpdateTime = value.Time + } + case epicherouserbuild.FieldDeleted: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field deleted", values[i]) + } else if value.Valid { + _m.Deleted = value.Bool + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the EpicHeroUserBuild. +// This includes values selected through modifiers, order, etc. +func (_m *EpicHeroUserBuild) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// Update returns a builder for updating this EpicHeroUserBuild. +// Note that you need to call EpicHeroUserBuild.Unwrap() before calling this method if this EpicHeroUserBuild +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *EpicHeroUserBuild) Update() *EpicHeroUserBuildUpdateOne { + return NewEpicHeroUserBuildClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the EpicHeroUserBuild entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (_m *EpicHeroUserBuild) Unwrap() *EpicHeroUserBuild { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("ent: EpicHeroUserBuild is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *EpicHeroUserBuild) String() string { + var builder strings.Builder + builder.WriteString("EpicHeroUserBuild(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("artifact_code=") + builder.WriteString(_m.ArtifactCode) + builder.WriteString(", ") + builder.WriteString("hero_code=") + builder.WriteString(_m.HeroCode) + builder.WriteString(", ") + builder.WriteString("hero_heath_build=") + builder.WriteString(fmt.Sprintf("%v", _m.HeroHeathBuild)) + builder.WriteString(", ") + builder.WriteString("hero_attack_build=") + builder.WriteString(fmt.Sprintf("%v", _m.HeroAttackBuild)) + builder.WriteString(", ") + builder.WriteString("hero_def_build=") + builder.WriteString(fmt.Sprintf("%v", _m.HeroDefBuild)) + builder.WriteString(", ") + builder.WriteString("creator=") + builder.WriteString(_m.Creator) + builder.WriteString(", ") + if v := _m.CreateTime; v != nil { + builder.WriteString("create_time=") + builder.WriteString(v.Format(time.ANSIC)) + } + builder.WriteString(", ") + builder.WriteString("updater=") + builder.WriteString(_m.Updater) + builder.WriteString(", ") + if v := _m.UpdateTime; v != nil { + builder.WriteString("update_time=") + builder.WriteString(v.Format(time.ANSIC)) + } + builder.WriteString(", ") + builder.WriteString("deleted=") + builder.WriteString(fmt.Sprintf("%v", _m.Deleted)) + builder.WriteByte(')') + return builder.String() +} + +// EpicHeroUserBuilds is a parsable slice of EpicHeroUserBuild. +type EpicHeroUserBuilds []*EpicHeroUserBuild diff --git a/internal/ent/epicherouserbuild/epicherouserbuild.go b/internal/ent/epicherouserbuild/epicherouserbuild.go new file mode 100644 index 0000000..ce11526 --- /dev/null +++ b/internal/ent/epicherouserbuild/epicherouserbuild.go @@ -0,0 +1,130 @@ +// Code generated by ent, DO NOT EDIT. + +package epicherouserbuild + +import ( + "entgo.io/ent/dialect/sql" +) + +const ( + // Label holds the string label denoting the epicherouserbuild type in the database. + Label = "epic_hero_user_build" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldArtifactCode holds the string denoting the artifact_code field in the database. + FieldArtifactCode = "artifact_code" + // FieldHeroCode holds the string denoting the hero_code field in the database. + FieldHeroCode = "hero_code" + // FieldHeroHeathBuild holds the string denoting the hero_heath_build field in the database. + FieldHeroHeathBuild = "hero_heath_build" + // FieldHeroAttackBuild holds the string denoting the hero_attack_build field in the database. + FieldHeroAttackBuild = "hero_attack_build" + // FieldHeroDefBuild holds the string denoting the hero_def_build field in the database. + FieldHeroDefBuild = "hero_def_build" + // FieldCreator holds the string denoting the creator field in the database. + FieldCreator = "creator" + // FieldCreateTime holds the string denoting the create_time field in the database. + FieldCreateTime = "create_time" + // FieldUpdater holds the string denoting the updater field in the database. + FieldUpdater = "updater" + // FieldUpdateTime holds the string denoting the update_time field in the database. + FieldUpdateTime = "update_time" + // FieldDeleted holds the string denoting the deleted field in the database. + FieldDeleted = "deleted" + // Table holds the table name of the epicherouserbuild in the database. + Table = "epic_hero_user_builds" +) + +// Columns holds all SQL columns for epicherouserbuild fields. +var Columns = []string{ + FieldID, + FieldArtifactCode, + FieldHeroCode, + FieldHeroHeathBuild, + FieldHeroAttackBuild, + FieldHeroDefBuild, + FieldCreator, + FieldCreateTime, + FieldUpdater, + FieldUpdateTime, + FieldDeleted, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // ArtifactCodeValidator is a validator for the "artifact_code" field. It is called by the builders before save. + ArtifactCodeValidator func(string) error + // HeroCodeValidator is a validator for the "hero_code" field. It is called by the builders before save. + HeroCodeValidator func(string) error + // CreatorValidator is a validator for the "creator" field. It is called by the builders before save. + CreatorValidator func(string) error + // UpdaterValidator is a validator for the "updater" field. It is called by the builders before save. + UpdaterValidator func(string) error +) + +// OrderOption defines the ordering options for the EpicHeroUserBuild queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByArtifactCode orders the results by the artifact_code field. +func ByArtifactCode(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldArtifactCode, opts...).ToFunc() +} + +// ByHeroCode orders the results by the hero_code field. +func ByHeroCode(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldHeroCode, opts...).ToFunc() +} + +// ByHeroHeathBuild orders the results by the hero_heath_build field. +func ByHeroHeathBuild(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldHeroHeathBuild, opts...).ToFunc() +} + +// ByHeroAttackBuild orders the results by the hero_attack_build field. +func ByHeroAttackBuild(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldHeroAttackBuild, opts...).ToFunc() +} + +// ByHeroDefBuild orders the results by the hero_def_build field. +func ByHeroDefBuild(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldHeroDefBuild, opts...).ToFunc() +} + +// ByCreator orders the results by the creator field. +func ByCreator(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreator, opts...).ToFunc() +} + +// ByCreateTime orders the results by the create_time field. +func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateTime, opts...).ToFunc() +} + +// ByUpdater orders the results by the updater field. +func ByUpdater(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdater, opts...).ToFunc() +} + +// ByUpdateTime orders the results by the update_time field. +func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() +} + +// ByDeleted orders the results by the deleted field. +func ByDeleted(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeleted, opts...).ToFunc() +} diff --git a/internal/ent/epicherouserbuild/where.go b/internal/ent/epicherouserbuild/where.go new file mode 100644 index 0000000..1aa615e --- /dev/null +++ b/internal/ent/epicherouserbuild/where.go @@ -0,0 +1,610 @@ +// Code generated by ent, DO NOT EDIT. + +package epicherouserbuild + +import ( + "epic-ent/internal/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" +) + +// ID filters vertices based on their ID field. +func ID(id int64) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int64) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int64) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int64) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int64) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int64) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int64) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int64) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int64) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldLTE(FieldID, id)) +} + +// ArtifactCode applies equality check predicate on the "artifact_code" field. It's identical to ArtifactCodeEQ. +func ArtifactCode(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldEQ(FieldArtifactCode, v)) +} + +// HeroCode applies equality check predicate on the "hero_code" field. It's identical to HeroCodeEQ. +func HeroCode(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldEQ(FieldHeroCode, v)) +} + +// HeroHeathBuild applies equality check predicate on the "hero_heath_build" field. It's identical to HeroHeathBuildEQ. +func HeroHeathBuild(v float64) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldEQ(FieldHeroHeathBuild, v)) +} + +// HeroAttackBuild applies equality check predicate on the "hero_attack_build" field. It's identical to HeroAttackBuildEQ. +func HeroAttackBuild(v float64) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldEQ(FieldHeroAttackBuild, v)) +} + +// HeroDefBuild applies equality check predicate on the "hero_def_build" field. It's identical to HeroDefBuildEQ. +func HeroDefBuild(v float64) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldEQ(FieldHeroDefBuild, v)) +} + +// Creator applies equality check predicate on the "creator" field. It's identical to CreatorEQ. +func Creator(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldEQ(FieldCreator, v)) +} + +// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. +func CreateTime(v time.Time) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldEQ(FieldCreateTime, v)) +} + +// Updater applies equality check predicate on the "updater" field. It's identical to UpdaterEQ. +func Updater(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldEQ(FieldUpdater, v)) +} + +// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. +func UpdateTime(v time.Time) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldEQ(FieldUpdateTime, v)) +} + +// Deleted applies equality check predicate on the "deleted" field. It's identical to DeletedEQ. +func Deleted(v bool) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldEQ(FieldDeleted, v)) +} + +// ArtifactCodeEQ applies the EQ predicate on the "artifact_code" field. +func ArtifactCodeEQ(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldEQ(FieldArtifactCode, v)) +} + +// ArtifactCodeNEQ applies the NEQ predicate on the "artifact_code" field. +func ArtifactCodeNEQ(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldNEQ(FieldArtifactCode, v)) +} + +// ArtifactCodeIn applies the In predicate on the "artifact_code" field. +func ArtifactCodeIn(vs ...string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldIn(FieldArtifactCode, vs...)) +} + +// ArtifactCodeNotIn applies the NotIn predicate on the "artifact_code" field. +func ArtifactCodeNotIn(vs ...string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldNotIn(FieldArtifactCode, vs...)) +} + +// ArtifactCodeGT applies the GT predicate on the "artifact_code" field. +func ArtifactCodeGT(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldGT(FieldArtifactCode, v)) +} + +// ArtifactCodeGTE applies the GTE predicate on the "artifact_code" field. +func ArtifactCodeGTE(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldGTE(FieldArtifactCode, v)) +} + +// ArtifactCodeLT applies the LT predicate on the "artifact_code" field. +func ArtifactCodeLT(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldLT(FieldArtifactCode, v)) +} + +// ArtifactCodeLTE applies the LTE predicate on the "artifact_code" field. +func ArtifactCodeLTE(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldLTE(FieldArtifactCode, v)) +} + +// ArtifactCodeContains applies the Contains predicate on the "artifact_code" field. +func ArtifactCodeContains(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldContains(FieldArtifactCode, v)) +} + +// ArtifactCodeHasPrefix applies the HasPrefix predicate on the "artifact_code" field. +func ArtifactCodeHasPrefix(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldHasPrefix(FieldArtifactCode, v)) +} + +// ArtifactCodeHasSuffix applies the HasSuffix predicate on the "artifact_code" field. +func ArtifactCodeHasSuffix(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldHasSuffix(FieldArtifactCode, v)) +} + +// ArtifactCodeEqualFold applies the EqualFold predicate on the "artifact_code" field. +func ArtifactCodeEqualFold(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldEqualFold(FieldArtifactCode, v)) +} + +// ArtifactCodeContainsFold applies the ContainsFold predicate on the "artifact_code" field. +func ArtifactCodeContainsFold(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldContainsFold(FieldArtifactCode, v)) +} + +// HeroCodeEQ applies the EQ predicate on the "hero_code" field. +func HeroCodeEQ(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldEQ(FieldHeroCode, v)) +} + +// HeroCodeNEQ applies the NEQ predicate on the "hero_code" field. +func HeroCodeNEQ(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldNEQ(FieldHeroCode, v)) +} + +// HeroCodeIn applies the In predicate on the "hero_code" field. +func HeroCodeIn(vs ...string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldIn(FieldHeroCode, vs...)) +} + +// HeroCodeNotIn applies the NotIn predicate on the "hero_code" field. +func HeroCodeNotIn(vs ...string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldNotIn(FieldHeroCode, vs...)) +} + +// HeroCodeGT applies the GT predicate on the "hero_code" field. +func HeroCodeGT(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldGT(FieldHeroCode, v)) +} + +// HeroCodeGTE applies the GTE predicate on the "hero_code" field. +func HeroCodeGTE(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldGTE(FieldHeroCode, v)) +} + +// HeroCodeLT applies the LT predicate on the "hero_code" field. +func HeroCodeLT(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldLT(FieldHeroCode, v)) +} + +// HeroCodeLTE applies the LTE predicate on the "hero_code" field. +func HeroCodeLTE(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldLTE(FieldHeroCode, v)) +} + +// HeroCodeContains applies the Contains predicate on the "hero_code" field. +func HeroCodeContains(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldContains(FieldHeroCode, v)) +} + +// HeroCodeHasPrefix applies the HasPrefix predicate on the "hero_code" field. +func HeroCodeHasPrefix(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldHasPrefix(FieldHeroCode, v)) +} + +// HeroCodeHasSuffix applies the HasSuffix predicate on the "hero_code" field. +func HeroCodeHasSuffix(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldHasSuffix(FieldHeroCode, v)) +} + +// HeroCodeEqualFold applies the EqualFold predicate on the "hero_code" field. +func HeroCodeEqualFold(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldEqualFold(FieldHeroCode, v)) +} + +// HeroCodeContainsFold applies the ContainsFold predicate on the "hero_code" field. +func HeroCodeContainsFold(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldContainsFold(FieldHeroCode, v)) +} + +// HeroHeathBuildEQ applies the EQ predicate on the "hero_heath_build" field. +func HeroHeathBuildEQ(v float64) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldEQ(FieldHeroHeathBuild, v)) +} + +// HeroHeathBuildNEQ applies the NEQ predicate on the "hero_heath_build" field. +func HeroHeathBuildNEQ(v float64) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldNEQ(FieldHeroHeathBuild, v)) +} + +// HeroHeathBuildIn applies the In predicate on the "hero_heath_build" field. +func HeroHeathBuildIn(vs ...float64) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldIn(FieldHeroHeathBuild, vs...)) +} + +// HeroHeathBuildNotIn applies the NotIn predicate on the "hero_heath_build" field. +func HeroHeathBuildNotIn(vs ...float64) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldNotIn(FieldHeroHeathBuild, vs...)) +} + +// HeroHeathBuildGT applies the GT predicate on the "hero_heath_build" field. +func HeroHeathBuildGT(v float64) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldGT(FieldHeroHeathBuild, v)) +} + +// HeroHeathBuildGTE applies the GTE predicate on the "hero_heath_build" field. +func HeroHeathBuildGTE(v float64) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldGTE(FieldHeroHeathBuild, v)) +} + +// HeroHeathBuildLT applies the LT predicate on the "hero_heath_build" field. +func HeroHeathBuildLT(v float64) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldLT(FieldHeroHeathBuild, v)) +} + +// HeroHeathBuildLTE applies the LTE predicate on the "hero_heath_build" field. +func HeroHeathBuildLTE(v float64) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldLTE(FieldHeroHeathBuild, v)) +} + +// HeroAttackBuildEQ applies the EQ predicate on the "hero_attack_build" field. +func HeroAttackBuildEQ(v float64) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldEQ(FieldHeroAttackBuild, v)) +} + +// HeroAttackBuildNEQ applies the NEQ predicate on the "hero_attack_build" field. +func HeroAttackBuildNEQ(v float64) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldNEQ(FieldHeroAttackBuild, v)) +} + +// HeroAttackBuildIn applies the In predicate on the "hero_attack_build" field. +func HeroAttackBuildIn(vs ...float64) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldIn(FieldHeroAttackBuild, vs...)) +} + +// HeroAttackBuildNotIn applies the NotIn predicate on the "hero_attack_build" field. +func HeroAttackBuildNotIn(vs ...float64) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldNotIn(FieldHeroAttackBuild, vs...)) +} + +// HeroAttackBuildGT applies the GT predicate on the "hero_attack_build" field. +func HeroAttackBuildGT(v float64) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldGT(FieldHeroAttackBuild, v)) +} + +// HeroAttackBuildGTE applies the GTE predicate on the "hero_attack_build" field. +func HeroAttackBuildGTE(v float64) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldGTE(FieldHeroAttackBuild, v)) +} + +// HeroAttackBuildLT applies the LT predicate on the "hero_attack_build" field. +func HeroAttackBuildLT(v float64) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldLT(FieldHeroAttackBuild, v)) +} + +// HeroAttackBuildLTE applies the LTE predicate on the "hero_attack_build" field. +func HeroAttackBuildLTE(v float64) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldLTE(FieldHeroAttackBuild, v)) +} + +// HeroDefBuildEQ applies the EQ predicate on the "hero_def_build" field. +func HeroDefBuildEQ(v float64) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldEQ(FieldHeroDefBuild, v)) +} + +// HeroDefBuildNEQ applies the NEQ predicate on the "hero_def_build" field. +func HeroDefBuildNEQ(v float64) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldNEQ(FieldHeroDefBuild, v)) +} + +// HeroDefBuildIn applies the In predicate on the "hero_def_build" field. +func HeroDefBuildIn(vs ...float64) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldIn(FieldHeroDefBuild, vs...)) +} + +// HeroDefBuildNotIn applies the NotIn predicate on the "hero_def_build" field. +func HeroDefBuildNotIn(vs ...float64) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldNotIn(FieldHeroDefBuild, vs...)) +} + +// HeroDefBuildGT applies the GT predicate on the "hero_def_build" field. +func HeroDefBuildGT(v float64) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldGT(FieldHeroDefBuild, v)) +} + +// HeroDefBuildGTE applies the GTE predicate on the "hero_def_build" field. +func HeroDefBuildGTE(v float64) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldGTE(FieldHeroDefBuild, v)) +} + +// HeroDefBuildLT applies the LT predicate on the "hero_def_build" field. +func HeroDefBuildLT(v float64) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldLT(FieldHeroDefBuild, v)) +} + +// HeroDefBuildLTE applies the LTE predicate on the "hero_def_build" field. +func HeroDefBuildLTE(v float64) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldLTE(FieldHeroDefBuild, v)) +} + +// CreatorEQ applies the EQ predicate on the "creator" field. +func CreatorEQ(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldEQ(FieldCreator, v)) +} + +// CreatorNEQ applies the NEQ predicate on the "creator" field. +func CreatorNEQ(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldNEQ(FieldCreator, v)) +} + +// CreatorIn applies the In predicate on the "creator" field. +func CreatorIn(vs ...string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldIn(FieldCreator, vs...)) +} + +// CreatorNotIn applies the NotIn predicate on the "creator" field. +func CreatorNotIn(vs ...string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldNotIn(FieldCreator, vs...)) +} + +// CreatorGT applies the GT predicate on the "creator" field. +func CreatorGT(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldGT(FieldCreator, v)) +} + +// CreatorGTE applies the GTE predicate on the "creator" field. +func CreatorGTE(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldGTE(FieldCreator, v)) +} + +// CreatorLT applies the LT predicate on the "creator" field. +func CreatorLT(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldLT(FieldCreator, v)) +} + +// CreatorLTE applies the LTE predicate on the "creator" field. +func CreatorLTE(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldLTE(FieldCreator, v)) +} + +// CreatorContains applies the Contains predicate on the "creator" field. +func CreatorContains(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldContains(FieldCreator, v)) +} + +// CreatorHasPrefix applies the HasPrefix predicate on the "creator" field. +func CreatorHasPrefix(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldHasPrefix(FieldCreator, v)) +} + +// CreatorHasSuffix applies the HasSuffix predicate on the "creator" field. +func CreatorHasSuffix(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldHasSuffix(FieldCreator, v)) +} + +// CreatorEqualFold applies the EqualFold predicate on the "creator" field. +func CreatorEqualFold(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldEqualFold(FieldCreator, v)) +} + +// CreatorContainsFold applies the ContainsFold predicate on the "creator" field. +func CreatorContainsFold(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldContainsFold(FieldCreator, v)) +} + +// CreateTimeEQ applies the EQ predicate on the "create_time" field. +func CreateTimeEQ(v time.Time) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldEQ(FieldCreateTime, v)) +} + +// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. +func CreateTimeNEQ(v time.Time) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldNEQ(FieldCreateTime, v)) +} + +// CreateTimeIn applies the In predicate on the "create_time" field. +func CreateTimeIn(vs ...time.Time) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldIn(FieldCreateTime, vs...)) +} + +// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. +func CreateTimeNotIn(vs ...time.Time) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldNotIn(FieldCreateTime, vs...)) +} + +// CreateTimeGT applies the GT predicate on the "create_time" field. +func CreateTimeGT(v time.Time) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldGT(FieldCreateTime, v)) +} + +// CreateTimeGTE applies the GTE predicate on the "create_time" field. +func CreateTimeGTE(v time.Time) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldGTE(FieldCreateTime, v)) +} + +// CreateTimeLT applies the LT predicate on the "create_time" field. +func CreateTimeLT(v time.Time) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldLT(FieldCreateTime, v)) +} + +// CreateTimeLTE applies the LTE predicate on the "create_time" field. +func CreateTimeLTE(v time.Time) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldLTE(FieldCreateTime, v)) +} + +// CreateTimeIsNil applies the IsNil predicate on the "create_time" field. +func CreateTimeIsNil() predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldIsNull(FieldCreateTime)) +} + +// CreateTimeNotNil applies the NotNil predicate on the "create_time" field. +func CreateTimeNotNil() predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldNotNull(FieldCreateTime)) +} + +// UpdaterEQ applies the EQ predicate on the "updater" field. +func UpdaterEQ(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldEQ(FieldUpdater, v)) +} + +// UpdaterNEQ applies the NEQ predicate on the "updater" field. +func UpdaterNEQ(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldNEQ(FieldUpdater, v)) +} + +// UpdaterIn applies the In predicate on the "updater" field. +func UpdaterIn(vs ...string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldIn(FieldUpdater, vs...)) +} + +// UpdaterNotIn applies the NotIn predicate on the "updater" field. +func UpdaterNotIn(vs ...string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldNotIn(FieldUpdater, vs...)) +} + +// UpdaterGT applies the GT predicate on the "updater" field. +func UpdaterGT(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldGT(FieldUpdater, v)) +} + +// UpdaterGTE applies the GTE predicate on the "updater" field. +func UpdaterGTE(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldGTE(FieldUpdater, v)) +} + +// UpdaterLT applies the LT predicate on the "updater" field. +func UpdaterLT(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldLT(FieldUpdater, v)) +} + +// UpdaterLTE applies the LTE predicate on the "updater" field. +func UpdaterLTE(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldLTE(FieldUpdater, v)) +} + +// UpdaterContains applies the Contains predicate on the "updater" field. +func UpdaterContains(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldContains(FieldUpdater, v)) +} + +// UpdaterHasPrefix applies the HasPrefix predicate on the "updater" field. +func UpdaterHasPrefix(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldHasPrefix(FieldUpdater, v)) +} + +// UpdaterHasSuffix applies the HasSuffix predicate on the "updater" field. +func UpdaterHasSuffix(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldHasSuffix(FieldUpdater, v)) +} + +// UpdaterEqualFold applies the EqualFold predicate on the "updater" field. +func UpdaterEqualFold(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldEqualFold(FieldUpdater, v)) +} + +// UpdaterContainsFold applies the ContainsFold predicate on the "updater" field. +func UpdaterContainsFold(v string) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldContainsFold(FieldUpdater, v)) +} + +// UpdateTimeEQ applies the EQ predicate on the "update_time" field. +func UpdateTimeEQ(v time.Time) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldEQ(FieldUpdateTime, v)) +} + +// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. +func UpdateTimeNEQ(v time.Time) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldNEQ(FieldUpdateTime, v)) +} + +// UpdateTimeIn applies the In predicate on the "update_time" field. +func UpdateTimeIn(vs ...time.Time) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. +func UpdateTimeNotIn(vs ...time.Time) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldNotIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeGT applies the GT predicate on the "update_time" field. +func UpdateTimeGT(v time.Time) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldGT(FieldUpdateTime, v)) +} + +// UpdateTimeGTE applies the GTE predicate on the "update_time" field. +func UpdateTimeGTE(v time.Time) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldGTE(FieldUpdateTime, v)) +} + +// UpdateTimeLT applies the LT predicate on the "update_time" field. +func UpdateTimeLT(v time.Time) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldLT(FieldUpdateTime, v)) +} + +// UpdateTimeLTE applies the LTE predicate on the "update_time" field. +func UpdateTimeLTE(v time.Time) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldLTE(FieldUpdateTime, v)) +} + +// UpdateTimeIsNil applies the IsNil predicate on the "update_time" field. +func UpdateTimeIsNil() predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldIsNull(FieldUpdateTime)) +} + +// UpdateTimeNotNil applies the NotNil predicate on the "update_time" field. +func UpdateTimeNotNil() predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldNotNull(FieldUpdateTime)) +} + +// DeletedEQ applies the EQ predicate on the "deleted" field. +func DeletedEQ(v bool) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldEQ(FieldDeleted, v)) +} + +// DeletedNEQ applies the NEQ predicate on the "deleted" field. +func DeletedNEQ(v bool) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.FieldNEQ(FieldDeleted, v)) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.EpicHeroUserBuild) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.EpicHeroUserBuild) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.EpicHeroUserBuild) predicate.EpicHeroUserBuild { + return predicate.EpicHeroUserBuild(sql.NotPredicates(p)) +} diff --git a/internal/ent/epicherouserbuild_create.go b/internal/ent/epicherouserbuild_create.go new file mode 100644 index 0000000..ec88356 --- /dev/null +++ b/internal/ent/epicherouserbuild_create.go @@ -0,0 +1,343 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "epic-ent/internal/ent/epicherouserbuild" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// EpicHeroUserBuildCreate is the builder for creating a EpicHeroUserBuild entity. +type EpicHeroUserBuildCreate struct { + config + mutation *EpicHeroUserBuildMutation + hooks []Hook +} + +// SetArtifactCode sets the "artifact_code" field. +func (_c *EpicHeroUserBuildCreate) SetArtifactCode(v string) *EpicHeroUserBuildCreate { + _c.mutation.SetArtifactCode(v) + return _c +} + +// SetHeroCode sets the "hero_code" field. +func (_c *EpicHeroUserBuildCreate) SetHeroCode(v string) *EpicHeroUserBuildCreate { + _c.mutation.SetHeroCode(v) + return _c +} + +// SetHeroHeathBuild sets the "hero_heath_build" field. +func (_c *EpicHeroUserBuildCreate) SetHeroHeathBuild(v float64) *EpicHeroUserBuildCreate { + _c.mutation.SetHeroHeathBuild(v) + return _c +} + +// SetHeroAttackBuild sets the "hero_attack_build" field. +func (_c *EpicHeroUserBuildCreate) SetHeroAttackBuild(v float64) *EpicHeroUserBuildCreate { + _c.mutation.SetHeroAttackBuild(v) + return _c +} + +// SetHeroDefBuild sets the "hero_def_build" field. +func (_c *EpicHeroUserBuildCreate) SetHeroDefBuild(v float64) *EpicHeroUserBuildCreate { + _c.mutation.SetHeroDefBuild(v) + return _c +} + +// SetCreator sets the "creator" field. +func (_c *EpicHeroUserBuildCreate) SetCreator(v string) *EpicHeroUserBuildCreate { + _c.mutation.SetCreator(v) + return _c +} + +// SetCreateTime sets the "create_time" field. +func (_c *EpicHeroUserBuildCreate) SetCreateTime(v time.Time) *EpicHeroUserBuildCreate { + _c.mutation.SetCreateTime(v) + return _c +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (_c *EpicHeroUserBuildCreate) SetNillableCreateTime(v *time.Time) *EpicHeroUserBuildCreate { + if v != nil { + _c.SetCreateTime(*v) + } + return _c +} + +// SetUpdater sets the "updater" field. +func (_c *EpicHeroUserBuildCreate) SetUpdater(v string) *EpicHeroUserBuildCreate { + _c.mutation.SetUpdater(v) + return _c +} + +// SetUpdateTime sets the "update_time" field. +func (_c *EpicHeroUserBuildCreate) SetUpdateTime(v time.Time) *EpicHeroUserBuildCreate { + _c.mutation.SetUpdateTime(v) + return _c +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (_c *EpicHeroUserBuildCreate) SetNillableUpdateTime(v *time.Time) *EpicHeroUserBuildCreate { + if v != nil { + _c.SetUpdateTime(*v) + } + return _c +} + +// SetDeleted sets the "deleted" field. +func (_c *EpicHeroUserBuildCreate) SetDeleted(v bool) *EpicHeroUserBuildCreate { + _c.mutation.SetDeleted(v) + return _c +} + +// SetID sets the "id" field. +func (_c *EpicHeroUserBuildCreate) SetID(v int64) *EpicHeroUserBuildCreate { + _c.mutation.SetID(v) + return _c +} + +// Mutation returns the EpicHeroUserBuildMutation object of the builder. +func (_c *EpicHeroUserBuildCreate) Mutation() *EpicHeroUserBuildMutation { + return _c.mutation +} + +// Save creates the EpicHeroUserBuild in the database. +func (_c *EpicHeroUserBuildCreate) Save(ctx context.Context) (*EpicHeroUserBuild, error) { + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *EpicHeroUserBuildCreate) SaveX(ctx context.Context) *EpicHeroUserBuild { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *EpicHeroUserBuildCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *EpicHeroUserBuildCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *EpicHeroUserBuildCreate) check() error { + if _, ok := _c.mutation.ArtifactCode(); !ok { + return &ValidationError{Name: "artifact_code", err: errors.New(`ent: missing required field "EpicHeroUserBuild.artifact_code"`)} + } + if v, ok := _c.mutation.ArtifactCode(); ok { + if err := epicherouserbuild.ArtifactCodeValidator(v); err != nil { + return &ValidationError{Name: "artifact_code", err: fmt.Errorf(`ent: validator failed for field "EpicHeroUserBuild.artifact_code": %w`, err)} + } + } + if _, ok := _c.mutation.HeroCode(); !ok { + return &ValidationError{Name: "hero_code", err: errors.New(`ent: missing required field "EpicHeroUserBuild.hero_code"`)} + } + if v, ok := _c.mutation.HeroCode(); ok { + if err := epicherouserbuild.HeroCodeValidator(v); err != nil { + return &ValidationError{Name: "hero_code", err: fmt.Errorf(`ent: validator failed for field "EpicHeroUserBuild.hero_code": %w`, err)} + } + } + if _, ok := _c.mutation.HeroHeathBuild(); !ok { + return &ValidationError{Name: "hero_heath_build", err: errors.New(`ent: missing required field "EpicHeroUserBuild.hero_heath_build"`)} + } + if _, ok := _c.mutation.HeroAttackBuild(); !ok { + return &ValidationError{Name: "hero_attack_build", err: errors.New(`ent: missing required field "EpicHeroUserBuild.hero_attack_build"`)} + } + if _, ok := _c.mutation.HeroDefBuild(); !ok { + return &ValidationError{Name: "hero_def_build", err: errors.New(`ent: missing required field "EpicHeroUserBuild.hero_def_build"`)} + } + if _, ok := _c.mutation.Creator(); !ok { + return &ValidationError{Name: "creator", err: errors.New(`ent: missing required field "EpicHeroUserBuild.creator"`)} + } + if v, ok := _c.mutation.Creator(); ok { + if err := epicherouserbuild.CreatorValidator(v); err != nil { + return &ValidationError{Name: "creator", err: fmt.Errorf(`ent: validator failed for field "EpicHeroUserBuild.creator": %w`, err)} + } + } + if _, ok := _c.mutation.Updater(); !ok { + return &ValidationError{Name: "updater", err: errors.New(`ent: missing required field "EpicHeroUserBuild.updater"`)} + } + if v, ok := _c.mutation.Updater(); ok { + if err := epicherouserbuild.UpdaterValidator(v); err != nil { + return &ValidationError{Name: "updater", err: fmt.Errorf(`ent: validator failed for field "EpicHeroUserBuild.updater": %w`, err)} + } + } + if _, ok := _c.mutation.Deleted(); !ok { + return &ValidationError{Name: "deleted", err: errors.New(`ent: missing required field "EpicHeroUserBuild.deleted"`)} + } + return nil +} + +func (_c *EpicHeroUserBuildCreate) sqlSave(ctx context.Context) (*EpicHeroUserBuild, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != _node.ID { + id := _spec.ID.Value.(int64) + _node.ID = int64(id) + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *EpicHeroUserBuildCreate) createSpec() (*EpicHeroUserBuild, *sqlgraph.CreateSpec) { + var ( + _node = &EpicHeroUserBuild{config: _c.config} + _spec = sqlgraph.NewCreateSpec(epicherouserbuild.Table, sqlgraph.NewFieldSpec(epicherouserbuild.FieldID, field.TypeInt64)) + ) + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := _c.mutation.ArtifactCode(); ok { + _spec.SetField(epicherouserbuild.FieldArtifactCode, field.TypeString, value) + _node.ArtifactCode = value + } + if value, ok := _c.mutation.HeroCode(); ok { + _spec.SetField(epicherouserbuild.FieldHeroCode, field.TypeString, value) + _node.HeroCode = value + } + if value, ok := _c.mutation.HeroHeathBuild(); ok { + _spec.SetField(epicherouserbuild.FieldHeroHeathBuild, field.TypeFloat64, value) + _node.HeroHeathBuild = value + } + if value, ok := _c.mutation.HeroAttackBuild(); ok { + _spec.SetField(epicherouserbuild.FieldHeroAttackBuild, field.TypeFloat64, value) + _node.HeroAttackBuild = value + } + if value, ok := _c.mutation.HeroDefBuild(); ok { + _spec.SetField(epicherouserbuild.FieldHeroDefBuild, field.TypeFloat64, value) + _node.HeroDefBuild = value + } + if value, ok := _c.mutation.Creator(); ok { + _spec.SetField(epicherouserbuild.FieldCreator, field.TypeString, value) + _node.Creator = value + } + if value, ok := _c.mutation.CreateTime(); ok { + _spec.SetField(epicherouserbuild.FieldCreateTime, field.TypeTime, value) + _node.CreateTime = &value + } + if value, ok := _c.mutation.Updater(); ok { + _spec.SetField(epicherouserbuild.FieldUpdater, field.TypeString, value) + _node.Updater = value + } + if value, ok := _c.mutation.UpdateTime(); ok { + _spec.SetField(epicherouserbuild.FieldUpdateTime, field.TypeTime, value) + _node.UpdateTime = &value + } + if value, ok := _c.mutation.Deleted(); ok { + _spec.SetField(epicherouserbuild.FieldDeleted, field.TypeBool, value) + _node.Deleted = value + } + return _node, _spec +} + +// EpicHeroUserBuildCreateBulk is the builder for creating many EpicHeroUserBuild entities in bulk. +type EpicHeroUserBuildCreateBulk struct { + config + err error + builders []*EpicHeroUserBuildCreate +} + +// Save creates the EpicHeroUserBuild entities in the database. +func (_c *EpicHeroUserBuildCreateBulk) Save(ctx context.Context) ([]*EpicHeroUserBuild, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*EpicHeroUserBuild, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*EpicHeroUserBuildMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil && nodes[i].ID == 0 { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int64(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *EpicHeroUserBuildCreateBulk) SaveX(ctx context.Context) []*EpicHeroUserBuild { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *EpicHeroUserBuildCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *EpicHeroUserBuildCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/ent/epicherouserbuild_delete.go b/internal/ent/epicherouserbuild_delete.go new file mode 100644 index 0000000..4af5b24 --- /dev/null +++ b/internal/ent/epicherouserbuild_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "epic-ent/internal/ent/epicherouserbuild" + "epic-ent/internal/ent/predicate" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// EpicHeroUserBuildDelete is the builder for deleting a EpicHeroUserBuild entity. +type EpicHeroUserBuildDelete struct { + config + hooks []Hook + mutation *EpicHeroUserBuildMutation +} + +// Where appends a list predicates to the EpicHeroUserBuildDelete builder. +func (_d *EpicHeroUserBuildDelete) Where(ps ...predicate.EpicHeroUserBuild) *EpicHeroUserBuildDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *EpicHeroUserBuildDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *EpicHeroUserBuildDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *EpicHeroUserBuildDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(epicherouserbuild.Table, sqlgraph.NewFieldSpec(epicherouserbuild.FieldID, field.TypeInt64)) + if ps := _d.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + _d.mutation.done = true + return affected, err +} + +// EpicHeroUserBuildDeleteOne is the builder for deleting a single EpicHeroUserBuild entity. +type EpicHeroUserBuildDeleteOne struct { + _d *EpicHeroUserBuildDelete +} + +// Where appends a list predicates to the EpicHeroUserBuildDelete builder. +func (_d *EpicHeroUserBuildDeleteOne) Where(ps ...predicate.EpicHeroUserBuild) *EpicHeroUserBuildDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *EpicHeroUserBuildDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{epicherouserbuild.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *EpicHeroUserBuildDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/ent/epicherouserbuild_query.go b/internal/ent/epicherouserbuild_query.go new file mode 100644 index 0000000..d92d6f8 --- /dev/null +++ b/internal/ent/epicherouserbuild_query.go @@ -0,0 +1,527 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "epic-ent/internal/ent/epicherouserbuild" + "epic-ent/internal/ent/predicate" + "fmt" + "math" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// EpicHeroUserBuildQuery is the builder for querying EpicHeroUserBuild entities. +type EpicHeroUserBuildQuery struct { + config + ctx *QueryContext + order []epicherouserbuild.OrderOption + inters []Interceptor + predicates []predicate.EpicHeroUserBuild + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the EpicHeroUserBuildQuery builder. +func (_q *EpicHeroUserBuildQuery) Where(ps ...predicate.EpicHeroUserBuild) *EpicHeroUserBuildQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *EpicHeroUserBuildQuery) Limit(limit int) *EpicHeroUserBuildQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *EpicHeroUserBuildQuery) Offset(offset int) *EpicHeroUserBuildQuery { + _q.ctx.Offset = &offset + return _q +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (_q *EpicHeroUserBuildQuery) Unique(unique bool) *EpicHeroUserBuildQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *EpicHeroUserBuildQuery) Order(o ...epicherouserbuild.OrderOption) *EpicHeroUserBuildQuery { + _q.order = append(_q.order, o...) + return _q +} + +// First returns the first EpicHeroUserBuild entity from the query. +// Returns a *NotFoundError when no EpicHeroUserBuild was found. +func (_q *EpicHeroUserBuildQuery) First(ctx context.Context) (*EpicHeroUserBuild, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{epicherouserbuild.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *EpicHeroUserBuildQuery) FirstX(ctx context.Context) *EpicHeroUserBuild { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first EpicHeroUserBuild ID from the query. +// Returns a *NotFoundError when no EpicHeroUserBuild ID was found. +func (_q *EpicHeroUserBuildQuery) FirstID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{epicherouserbuild.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *EpicHeroUserBuildQuery) FirstIDX(ctx context.Context) int64 { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single EpicHeroUserBuild entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one EpicHeroUserBuild entity is found. +// Returns a *NotFoundError when no EpicHeroUserBuild entities are found. +func (_q *EpicHeroUserBuildQuery) Only(ctx context.Context) (*EpicHeroUserBuild, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{epicherouserbuild.Label} + default: + return nil, &NotSingularError{epicherouserbuild.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *EpicHeroUserBuildQuery) OnlyX(ctx context.Context) *EpicHeroUserBuild { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only EpicHeroUserBuild ID in the query. +// Returns a *NotSingularError when more than one EpicHeroUserBuild ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *EpicHeroUserBuildQuery) OnlyID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{epicherouserbuild.Label} + default: + err = &NotSingularError{epicherouserbuild.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *EpicHeroUserBuildQuery) OnlyIDX(ctx context.Context) int64 { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of EpicHeroUserBuilds. +func (_q *EpicHeroUserBuildQuery) All(ctx context.Context) ([]*EpicHeroUserBuild, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*EpicHeroUserBuild, *EpicHeroUserBuildQuery]() + return withInterceptors[[]*EpicHeroUserBuild](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *EpicHeroUserBuildQuery) AllX(ctx context.Context) []*EpicHeroUserBuild { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of EpicHeroUserBuild IDs. +func (_q *EpicHeroUserBuildQuery) IDs(ctx context.Context) (ids []int64, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(epicherouserbuild.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *EpicHeroUserBuildQuery) IDsX(ctx context.Context) []int64 { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *EpicHeroUserBuildQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, _q, querierCount[*EpicHeroUserBuildQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *EpicHeroUserBuildQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (_q *EpicHeroUserBuildQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *EpicHeroUserBuildQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the EpicHeroUserBuildQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (_q *EpicHeroUserBuildQuery) Clone() *EpicHeroUserBuildQuery { + if _q == nil { + return nil + } + return &EpicHeroUserBuildQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]epicherouserbuild.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.EpicHeroUserBuild{}, _q.predicates...), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + } +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// ArtifactCode string `json:"artifact_code,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.EpicHeroUserBuild.Query(). +// GroupBy(epicherouserbuild.FieldArtifactCode). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *EpicHeroUserBuildQuery) GroupBy(field string, fields ...string) *EpicHeroUserBuildGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &EpicHeroUserBuildGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = epicherouserbuild.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// ArtifactCode string `json:"artifact_code,omitempty"` +// } +// +// client.EpicHeroUserBuild.Query(). +// Select(epicherouserbuild.FieldArtifactCode). +// Scan(ctx, &v) +func (_q *EpicHeroUserBuildQuery) Select(fields ...string) *EpicHeroUserBuildSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &EpicHeroUserBuildSelect{EpicHeroUserBuildQuery: _q} + sbuild.label = epicherouserbuild.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a EpicHeroUserBuildSelect configured with the given aggregations. +func (_q *EpicHeroUserBuildQuery) Aggregate(fns ...AggregateFunc) *EpicHeroUserBuildSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *EpicHeroUserBuildQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !epicherouserbuild.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if _q.path != nil { + prev, err := _q.path(ctx) + if err != nil { + return err + } + _q.sql = prev + } + return nil +} + +func (_q *EpicHeroUserBuildQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*EpicHeroUserBuild, error) { + var ( + nodes = []*EpicHeroUserBuild{} + _spec = _q.querySpec() + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*EpicHeroUserBuild).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &EpicHeroUserBuild{config: _q.config} + nodes = append(nodes, node) + return node.assignValues(columns, values) + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + return nodes, nil +} + +func (_q *EpicHeroUserBuildQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique + } + return sqlgraph.CountNodes(ctx, _q.driver, _spec) +} + +func (_q *EpicHeroUserBuildQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(epicherouserbuild.Table, epicherouserbuild.Columns, sqlgraph.NewFieldSpec(epicherouserbuild.FieldID, field.TypeInt64)) + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if _q.path != nil { + _spec.Unique = true + } + if fields := _q.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, epicherouserbuild.FieldID) + for i := range fields { + if fields[i] != epicherouserbuild.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := _q.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := _q.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := _q.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := _q.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (_q *EpicHeroUserBuildQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(epicherouserbuild.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = epicherouserbuild.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if _q.sql != nil { + selector = _q.sql + selector.Select(selector.Columns(columns...)...) + } + if _q.ctx.Unique != nil && *_q.ctx.Unique { + selector.Distinct() + } + for _, p := range _q.predicates { + p(selector) + } + for _, p := range _q.order { + p(selector) + } + if offset := _q.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := _q.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// EpicHeroUserBuildGroupBy is the group-by builder for EpicHeroUserBuild entities. +type EpicHeroUserBuildGroupBy struct { + selector + build *EpicHeroUserBuildQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *EpicHeroUserBuildGroupBy) Aggregate(fns ...AggregateFunc) *EpicHeroUserBuildGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *EpicHeroUserBuildGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*EpicHeroUserBuildQuery, *EpicHeroUserBuildGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *EpicHeroUserBuildGroupBy) sqlScan(ctx context.Context, root *EpicHeroUserBuildQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*_g.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// EpicHeroUserBuildSelect is the builder for selecting fields of EpicHeroUserBuild entities. +type EpicHeroUserBuildSelect struct { + *EpicHeroUserBuildQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *EpicHeroUserBuildSelect) Aggregate(fns ...AggregateFunc) *EpicHeroUserBuildSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *EpicHeroUserBuildSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*EpicHeroUserBuildQuery, *EpicHeroUserBuildSelect](ctx, _s.EpicHeroUserBuildQuery, _s, _s.inters, v) +} + +func (_s *EpicHeroUserBuildSelect) sqlScan(ctx context.Context, root *EpicHeroUserBuildQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/internal/ent/epicherouserbuild_update.go b/internal/ent/epicherouserbuild_update.go new file mode 100644 index 0000000..77631da --- /dev/null +++ b/internal/ent/epicherouserbuild_update.go @@ -0,0 +1,668 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "epic-ent/internal/ent/epicherouserbuild" + "epic-ent/internal/ent/predicate" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// EpicHeroUserBuildUpdate is the builder for updating EpicHeroUserBuild entities. +type EpicHeroUserBuildUpdate struct { + config + hooks []Hook + mutation *EpicHeroUserBuildMutation +} + +// Where appends a list predicates to the EpicHeroUserBuildUpdate builder. +func (_u *EpicHeroUserBuildUpdate) Where(ps ...predicate.EpicHeroUserBuild) *EpicHeroUserBuildUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetArtifactCode sets the "artifact_code" field. +func (_u *EpicHeroUserBuildUpdate) SetArtifactCode(v string) *EpicHeroUserBuildUpdate { + _u.mutation.SetArtifactCode(v) + return _u +} + +// SetNillableArtifactCode sets the "artifact_code" field if the given value is not nil. +func (_u *EpicHeroUserBuildUpdate) SetNillableArtifactCode(v *string) *EpicHeroUserBuildUpdate { + if v != nil { + _u.SetArtifactCode(*v) + } + return _u +} + +// SetHeroCode sets the "hero_code" field. +func (_u *EpicHeroUserBuildUpdate) SetHeroCode(v string) *EpicHeroUserBuildUpdate { + _u.mutation.SetHeroCode(v) + return _u +} + +// SetNillableHeroCode sets the "hero_code" field if the given value is not nil. +func (_u *EpicHeroUserBuildUpdate) SetNillableHeroCode(v *string) *EpicHeroUserBuildUpdate { + if v != nil { + _u.SetHeroCode(*v) + } + return _u +} + +// SetHeroHeathBuild sets the "hero_heath_build" field. +func (_u *EpicHeroUserBuildUpdate) SetHeroHeathBuild(v float64) *EpicHeroUserBuildUpdate { + _u.mutation.ResetHeroHeathBuild() + _u.mutation.SetHeroHeathBuild(v) + return _u +} + +// SetNillableHeroHeathBuild sets the "hero_heath_build" field if the given value is not nil. +func (_u *EpicHeroUserBuildUpdate) SetNillableHeroHeathBuild(v *float64) *EpicHeroUserBuildUpdate { + if v != nil { + _u.SetHeroHeathBuild(*v) + } + return _u +} + +// AddHeroHeathBuild adds value to the "hero_heath_build" field. +func (_u *EpicHeroUserBuildUpdate) AddHeroHeathBuild(v float64) *EpicHeroUserBuildUpdate { + _u.mutation.AddHeroHeathBuild(v) + return _u +} + +// SetHeroAttackBuild sets the "hero_attack_build" field. +func (_u *EpicHeroUserBuildUpdate) SetHeroAttackBuild(v float64) *EpicHeroUserBuildUpdate { + _u.mutation.ResetHeroAttackBuild() + _u.mutation.SetHeroAttackBuild(v) + return _u +} + +// SetNillableHeroAttackBuild sets the "hero_attack_build" field if the given value is not nil. +func (_u *EpicHeroUserBuildUpdate) SetNillableHeroAttackBuild(v *float64) *EpicHeroUserBuildUpdate { + if v != nil { + _u.SetHeroAttackBuild(*v) + } + return _u +} + +// AddHeroAttackBuild adds value to the "hero_attack_build" field. +func (_u *EpicHeroUserBuildUpdate) AddHeroAttackBuild(v float64) *EpicHeroUserBuildUpdate { + _u.mutation.AddHeroAttackBuild(v) + return _u +} + +// SetHeroDefBuild sets the "hero_def_build" field. +func (_u *EpicHeroUserBuildUpdate) SetHeroDefBuild(v float64) *EpicHeroUserBuildUpdate { + _u.mutation.ResetHeroDefBuild() + _u.mutation.SetHeroDefBuild(v) + return _u +} + +// SetNillableHeroDefBuild sets the "hero_def_build" field if the given value is not nil. +func (_u *EpicHeroUserBuildUpdate) SetNillableHeroDefBuild(v *float64) *EpicHeroUserBuildUpdate { + if v != nil { + _u.SetHeroDefBuild(*v) + } + return _u +} + +// AddHeroDefBuild adds value to the "hero_def_build" field. +func (_u *EpicHeroUserBuildUpdate) AddHeroDefBuild(v float64) *EpicHeroUserBuildUpdate { + _u.mutation.AddHeroDefBuild(v) + return _u +} + +// SetCreator sets the "creator" field. +func (_u *EpicHeroUserBuildUpdate) SetCreator(v string) *EpicHeroUserBuildUpdate { + _u.mutation.SetCreator(v) + return _u +} + +// SetNillableCreator sets the "creator" field if the given value is not nil. +func (_u *EpicHeroUserBuildUpdate) SetNillableCreator(v *string) *EpicHeroUserBuildUpdate { + if v != nil { + _u.SetCreator(*v) + } + return _u +} + +// SetCreateTime sets the "create_time" field. +func (_u *EpicHeroUserBuildUpdate) SetCreateTime(v time.Time) *EpicHeroUserBuildUpdate { + _u.mutation.SetCreateTime(v) + return _u +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (_u *EpicHeroUserBuildUpdate) SetNillableCreateTime(v *time.Time) *EpicHeroUserBuildUpdate { + if v != nil { + _u.SetCreateTime(*v) + } + return _u +} + +// ClearCreateTime clears the value of the "create_time" field. +func (_u *EpicHeroUserBuildUpdate) ClearCreateTime() *EpicHeroUserBuildUpdate { + _u.mutation.ClearCreateTime() + return _u +} + +// SetUpdater sets the "updater" field. +func (_u *EpicHeroUserBuildUpdate) SetUpdater(v string) *EpicHeroUserBuildUpdate { + _u.mutation.SetUpdater(v) + return _u +} + +// SetNillableUpdater sets the "updater" field if the given value is not nil. +func (_u *EpicHeroUserBuildUpdate) SetNillableUpdater(v *string) *EpicHeroUserBuildUpdate { + if v != nil { + _u.SetUpdater(*v) + } + return _u +} + +// SetUpdateTime sets the "update_time" field. +func (_u *EpicHeroUserBuildUpdate) SetUpdateTime(v time.Time) *EpicHeroUserBuildUpdate { + _u.mutation.SetUpdateTime(v) + return _u +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (_u *EpicHeroUserBuildUpdate) SetNillableUpdateTime(v *time.Time) *EpicHeroUserBuildUpdate { + if v != nil { + _u.SetUpdateTime(*v) + } + return _u +} + +// ClearUpdateTime clears the value of the "update_time" field. +func (_u *EpicHeroUserBuildUpdate) ClearUpdateTime() *EpicHeroUserBuildUpdate { + _u.mutation.ClearUpdateTime() + return _u +} + +// SetDeleted sets the "deleted" field. +func (_u *EpicHeroUserBuildUpdate) SetDeleted(v bool) *EpicHeroUserBuildUpdate { + _u.mutation.SetDeleted(v) + return _u +} + +// SetNillableDeleted sets the "deleted" field if the given value is not nil. +func (_u *EpicHeroUserBuildUpdate) SetNillableDeleted(v *bool) *EpicHeroUserBuildUpdate { + if v != nil { + _u.SetDeleted(*v) + } + return _u +} + +// Mutation returns the EpicHeroUserBuildMutation object of the builder. +func (_u *EpicHeroUserBuildUpdate) Mutation() *EpicHeroUserBuildMutation { + return _u.mutation +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *EpicHeroUserBuildUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *EpicHeroUserBuildUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *EpicHeroUserBuildUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *EpicHeroUserBuildUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *EpicHeroUserBuildUpdate) check() error { + if v, ok := _u.mutation.ArtifactCode(); ok { + if err := epicherouserbuild.ArtifactCodeValidator(v); err != nil { + return &ValidationError{Name: "artifact_code", err: fmt.Errorf(`ent: validator failed for field "EpicHeroUserBuild.artifact_code": %w`, err)} + } + } + if v, ok := _u.mutation.HeroCode(); ok { + if err := epicherouserbuild.HeroCodeValidator(v); err != nil { + return &ValidationError{Name: "hero_code", err: fmt.Errorf(`ent: validator failed for field "EpicHeroUserBuild.hero_code": %w`, err)} + } + } + if v, ok := _u.mutation.Creator(); ok { + if err := epicherouserbuild.CreatorValidator(v); err != nil { + return &ValidationError{Name: "creator", err: fmt.Errorf(`ent: validator failed for field "EpicHeroUserBuild.creator": %w`, err)} + } + } + if v, ok := _u.mutation.Updater(); ok { + if err := epicherouserbuild.UpdaterValidator(v); err != nil { + return &ValidationError{Name: "updater", err: fmt.Errorf(`ent: validator failed for field "EpicHeroUserBuild.updater": %w`, err)} + } + } + return nil +} + +func (_u *EpicHeroUserBuildUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(epicherouserbuild.Table, epicherouserbuild.Columns, sqlgraph.NewFieldSpec(epicherouserbuild.FieldID, field.TypeInt64)) + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.ArtifactCode(); ok { + _spec.SetField(epicherouserbuild.FieldArtifactCode, field.TypeString, value) + } + if value, ok := _u.mutation.HeroCode(); ok { + _spec.SetField(epicherouserbuild.FieldHeroCode, field.TypeString, value) + } + if value, ok := _u.mutation.HeroHeathBuild(); ok { + _spec.SetField(epicherouserbuild.FieldHeroHeathBuild, field.TypeFloat64, value) + } + if value, ok := _u.mutation.AddedHeroHeathBuild(); ok { + _spec.AddField(epicherouserbuild.FieldHeroHeathBuild, field.TypeFloat64, value) + } + if value, ok := _u.mutation.HeroAttackBuild(); ok { + _spec.SetField(epicherouserbuild.FieldHeroAttackBuild, field.TypeFloat64, value) + } + if value, ok := _u.mutation.AddedHeroAttackBuild(); ok { + _spec.AddField(epicherouserbuild.FieldHeroAttackBuild, field.TypeFloat64, value) + } + if value, ok := _u.mutation.HeroDefBuild(); ok { + _spec.SetField(epicherouserbuild.FieldHeroDefBuild, field.TypeFloat64, value) + } + if value, ok := _u.mutation.AddedHeroDefBuild(); ok { + _spec.AddField(epicherouserbuild.FieldHeroDefBuild, field.TypeFloat64, value) + } + if value, ok := _u.mutation.Creator(); ok { + _spec.SetField(epicherouserbuild.FieldCreator, field.TypeString, value) + } + if value, ok := _u.mutation.CreateTime(); ok { + _spec.SetField(epicherouserbuild.FieldCreateTime, field.TypeTime, value) + } + if _u.mutation.CreateTimeCleared() { + _spec.ClearField(epicherouserbuild.FieldCreateTime, field.TypeTime) + } + if value, ok := _u.mutation.Updater(); ok { + _spec.SetField(epicherouserbuild.FieldUpdater, field.TypeString, value) + } + if value, ok := _u.mutation.UpdateTime(); ok { + _spec.SetField(epicherouserbuild.FieldUpdateTime, field.TypeTime, value) + } + if _u.mutation.UpdateTimeCleared() { + _spec.ClearField(epicherouserbuild.FieldUpdateTime, field.TypeTime) + } + if value, ok := _u.mutation.Deleted(); ok { + _spec.SetField(epicherouserbuild.FieldDeleted, field.TypeBool, value) + } + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{epicherouserbuild.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// EpicHeroUserBuildUpdateOne is the builder for updating a single EpicHeroUserBuild entity. +type EpicHeroUserBuildUpdateOne struct { + config + fields []string + hooks []Hook + mutation *EpicHeroUserBuildMutation +} + +// SetArtifactCode sets the "artifact_code" field. +func (_u *EpicHeroUserBuildUpdateOne) SetArtifactCode(v string) *EpicHeroUserBuildUpdateOne { + _u.mutation.SetArtifactCode(v) + return _u +} + +// SetNillableArtifactCode sets the "artifact_code" field if the given value is not nil. +func (_u *EpicHeroUserBuildUpdateOne) SetNillableArtifactCode(v *string) *EpicHeroUserBuildUpdateOne { + if v != nil { + _u.SetArtifactCode(*v) + } + return _u +} + +// SetHeroCode sets the "hero_code" field. +func (_u *EpicHeroUserBuildUpdateOne) SetHeroCode(v string) *EpicHeroUserBuildUpdateOne { + _u.mutation.SetHeroCode(v) + return _u +} + +// SetNillableHeroCode sets the "hero_code" field if the given value is not nil. +func (_u *EpicHeroUserBuildUpdateOne) SetNillableHeroCode(v *string) *EpicHeroUserBuildUpdateOne { + if v != nil { + _u.SetHeroCode(*v) + } + return _u +} + +// SetHeroHeathBuild sets the "hero_heath_build" field. +func (_u *EpicHeroUserBuildUpdateOne) SetHeroHeathBuild(v float64) *EpicHeroUserBuildUpdateOne { + _u.mutation.ResetHeroHeathBuild() + _u.mutation.SetHeroHeathBuild(v) + return _u +} + +// SetNillableHeroHeathBuild sets the "hero_heath_build" field if the given value is not nil. +func (_u *EpicHeroUserBuildUpdateOne) SetNillableHeroHeathBuild(v *float64) *EpicHeroUserBuildUpdateOne { + if v != nil { + _u.SetHeroHeathBuild(*v) + } + return _u +} + +// AddHeroHeathBuild adds value to the "hero_heath_build" field. +func (_u *EpicHeroUserBuildUpdateOne) AddHeroHeathBuild(v float64) *EpicHeroUserBuildUpdateOne { + _u.mutation.AddHeroHeathBuild(v) + return _u +} + +// SetHeroAttackBuild sets the "hero_attack_build" field. +func (_u *EpicHeroUserBuildUpdateOne) SetHeroAttackBuild(v float64) *EpicHeroUserBuildUpdateOne { + _u.mutation.ResetHeroAttackBuild() + _u.mutation.SetHeroAttackBuild(v) + return _u +} + +// SetNillableHeroAttackBuild sets the "hero_attack_build" field if the given value is not nil. +func (_u *EpicHeroUserBuildUpdateOne) SetNillableHeroAttackBuild(v *float64) *EpicHeroUserBuildUpdateOne { + if v != nil { + _u.SetHeroAttackBuild(*v) + } + return _u +} + +// AddHeroAttackBuild adds value to the "hero_attack_build" field. +func (_u *EpicHeroUserBuildUpdateOne) AddHeroAttackBuild(v float64) *EpicHeroUserBuildUpdateOne { + _u.mutation.AddHeroAttackBuild(v) + return _u +} + +// SetHeroDefBuild sets the "hero_def_build" field. +func (_u *EpicHeroUserBuildUpdateOne) SetHeroDefBuild(v float64) *EpicHeroUserBuildUpdateOne { + _u.mutation.ResetHeroDefBuild() + _u.mutation.SetHeroDefBuild(v) + return _u +} + +// SetNillableHeroDefBuild sets the "hero_def_build" field if the given value is not nil. +func (_u *EpicHeroUserBuildUpdateOne) SetNillableHeroDefBuild(v *float64) *EpicHeroUserBuildUpdateOne { + if v != nil { + _u.SetHeroDefBuild(*v) + } + return _u +} + +// AddHeroDefBuild adds value to the "hero_def_build" field. +func (_u *EpicHeroUserBuildUpdateOne) AddHeroDefBuild(v float64) *EpicHeroUserBuildUpdateOne { + _u.mutation.AddHeroDefBuild(v) + return _u +} + +// SetCreator sets the "creator" field. +func (_u *EpicHeroUserBuildUpdateOne) SetCreator(v string) *EpicHeroUserBuildUpdateOne { + _u.mutation.SetCreator(v) + return _u +} + +// SetNillableCreator sets the "creator" field if the given value is not nil. +func (_u *EpicHeroUserBuildUpdateOne) SetNillableCreator(v *string) *EpicHeroUserBuildUpdateOne { + if v != nil { + _u.SetCreator(*v) + } + return _u +} + +// SetCreateTime sets the "create_time" field. +func (_u *EpicHeroUserBuildUpdateOne) SetCreateTime(v time.Time) *EpicHeroUserBuildUpdateOne { + _u.mutation.SetCreateTime(v) + return _u +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (_u *EpicHeroUserBuildUpdateOne) SetNillableCreateTime(v *time.Time) *EpicHeroUserBuildUpdateOne { + if v != nil { + _u.SetCreateTime(*v) + } + return _u +} + +// ClearCreateTime clears the value of the "create_time" field. +func (_u *EpicHeroUserBuildUpdateOne) ClearCreateTime() *EpicHeroUserBuildUpdateOne { + _u.mutation.ClearCreateTime() + return _u +} + +// SetUpdater sets the "updater" field. +func (_u *EpicHeroUserBuildUpdateOne) SetUpdater(v string) *EpicHeroUserBuildUpdateOne { + _u.mutation.SetUpdater(v) + return _u +} + +// SetNillableUpdater sets the "updater" field if the given value is not nil. +func (_u *EpicHeroUserBuildUpdateOne) SetNillableUpdater(v *string) *EpicHeroUserBuildUpdateOne { + if v != nil { + _u.SetUpdater(*v) + } + return _u +} + +// SetUpdateTime sets the "update_time" field. +func (_u *EpicHeroUserBuildUpdateOne) SetUpdateTime(v time.Time) *EpicHeroUserBuildUpdateOne { + _u.mutation.SetUpdateTime(v) + return _u +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (_u *EpicHeroUserBuildUpdateOne) SetNillableUpdateTime(v *time.Time) *EpicHeroUserBuildUpdateOne { + if v != nil { + _u.SetUpdateTime(*v) + } + return _u +} + +// ClearUpdateTime clears the value of the "update_time" field. +func (_u *EpicHeroUserBuildUpdateOne) ClearUpdateTime() *EpicHeroUserBuildUpdateOne { + _u.mutation.ClearUpdateTime() + return _u +} + +// SetDeleted sets the "deleted" field. +func (_u *EpicHeroUserBuildUpdateOne) SetDeleted(v bool) *EpicHeroUserBuildUpdateOne { + _u.mutation.SetDeleted(v) + return _u +} + +// SetNillableDeleted sets the "deleted" field if the given value is not nil. +func (_u *EpicHeroUserBuildUpdateOne) SetNillableDeleted(v *bool) *EpicHeroUserBuildUpdateOne { + if v != nil { + _u.SetDeleted(*v) + } + return _u +} + +// Mutation returns the EpicHeroUserBuildMutation object of the builder. +func (_u *EpicHeroUserBuildUpdateOne) Mutation() *EpicHeroUserBuildMutation { + return _u.mutation +} + +// Where appends a list predicates to the EpicHeroUserBuildUpdate builder. +func (_u *EpicHeroUserBuildUpdateOne) Where(ps ...predicate.EpicHeroUserBuild) *EpicHeroUserBuildUpdateOne { + _u.mutation.Where(ps...) + return _u +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (_u *EpicHeroUserBuildUpdateOne) Select(field string, fields ...string) *EpicHeroUserBuildUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated EpicHeroUserBuild entity. +func (_u *EpicHeroUserBuildUpdateOne) Save(ctx context.Context) (*EpicHeroUserBuild, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *EpicHeroUserBuildUpdateOne) SaveX(ctx context.Context) *EpicHeroUserBuild { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *EpicHeroUserBuildUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *EpicHeroUserBuildUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *EpicHeroUserBuildUpdateOne) check() error { + if v, ok := _u.mutation.ArtifactCode(); ok { + if err := epicherouserbuild.ArtifactCodeValidator(v); err != nil { + return &ValidationError{Name: "artifact_code", err: fmt.Errorf(`ent: validator failed for field "EpicHeroUserBuild.artifact_code": %w`, err)} + } + } + if v, ok := _u.mutation.HeroCode(); ok { + if err := epicherouserbuild.HeroCodeValidator(v); err != nil { + return &ValidationError{Name: "hero_code", err: fmt.Errorf(`ent: validator failed for field "EpicHeroUserBuild.hero_code": %w`, err)} + } + } + if v, ok := _u.mutation.Creator(); ok { + if err := epicherouserbuild.CreatorValidator(v); err != nil { + return &ValidationError{Name: "creator", err: fmt.Errorf(`ent: validator failed for field "EpicHeroUserBuild.creator": %w`, err)} + } + } + if v, ok := _u.mutation.Updater(); ok { + if err := epicherouserbuild.UpdaterValidator(v); err != nil { + return &ValidationError{Name: "updater", err: fmt.Errorf(`ent: validator failed for field "EpicHeroUserBuild.updater": %w`, err)} + } + } + return nil +} + +func (_u *EpicHeroUserBuildUpdateOne) sqlSave(ctx context.Context) (_node *EpicHeroUserBuild, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(epicherouserbuild.Table, epicherouserbuild.Columns, sqlgraph.NewFieldSpec(epicherouserbuild.FieldID, field.TypeInt64)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "EpicHeroUserBuild.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := _u.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, epicherouserbuild.FieldID) + for _, f := range fields { + if !epicherouserbuild.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != epicherouserbuild.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.ArtifactCode(); ok { + _spec.SetField(epicherouserbuild.FieldArtifactCode, field.TypeString, value) + } + if value, ok := _u.mutation.HeroCode(); ok { + _spec.SetField(epicherouserbuild.FieldHeroCode, field.TypeString, value) + } + if value, ok := _u.mutation.HeroHeathBuild(); ok { + _spec.SetField(epicherouserbuild.FieldHeroHeathBuild, field.TypeFloat64, value) + } + if value, ok := _u.mutation.AddedHeroHeathBuild(); ok { + _spec.AddField(epicherouserbuild.FieldHeroHeathBuild, field.TypeFloat64, value) + } + if value, ok := _u.mutation.HeroAttackBuild(); ok { + _spec.SetField(epicherouserbuild.FieldHeroAttackBuild, field.TypeFloat64, value) + } + if value, ok := _u.mutation.AddedHeroAttackBuild(); ok { + _spec.AddField(epicherouserbuild.FieldHeroAttackBuild, field.TypeFloat64, value) + } + if value, ok := _u.mutation.HeroDefBuild(); ok { + _spec.SetField(epicherouserbuild.FieldHeroDefBuild, field.TypeFloat64, value) + } + if value, ok := _u.mutation.AddedHeroDefBuild(); ok { + _spec.AddField(epicherouserbuild.FieldHeroDefBuild, field.TypeFloat64, value) + } + if value, ok := _u.mutation.Creator(); ok { + _spec.SetField(epicherouserbuild.FieldCreator, field.TypeString, value) + } + if value, ok := _u.mutation.CreateTime(); ok { + _spec.SetField(epicherouserbuild.FieldCreateTime, field.TypeTime, value) + } + if _u.mutation.CreateTimeCleared() { + _spec.ClearField(epicherouserbuild.FieldCreateTime, field.TypeTime) + } + if value, ok := _u.mutation.Updater(); ok { + _spec.SetField(epicherouserbuild.FieldUpdater, field.TypeString, value) + } + if value, ok := _u.mutation.UpdateTime(); ok { + _spec.SetField(epicherouserbuild.FieldUpdateTime, field.TypeTime, value) + } + if _u.mutation.UpdateTimeCleared() { + _spec.ClearField(epicherouserbuild.FieldUpdateTime, field.TypeTime) + } + if value, ok := _u.mutation.Deleted(); ok { + _spec.SetField(epicherouserbuild.FieldDeleted, field.TypeBool, value) + } + _node = &EpicHeroUserBuild{config: _u.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{epicherouserbuild.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} diff --git a/internal/ent/epici18nmappings.go b/internal/ent/epici18nmappings.go new file mode 100644 index 0000000..5757d3c --- /dev/null +++ b/internal/ent/epici18nmappings.go @@ -0,0 +1,222 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "epic-ent/internal/ent/epici18nmappings" + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// EpicI18NMappings is the model entity for the EpicI18NMappings schema. +type EpicI18NMappings struct { + config `json:"-"` + // ID of the ent. + ID int64 `json:"id,omitempty"` + // KeyName holds the value of the "key_name" field. + KeyName string `json:"key_name,omitempty"` + // Language holds the value of the "language" field. + Language string `json:"language,omitempty"` + // Value holds the value of the "value" field. + Value string `json:"value,omitempty"` + // Category holds the value of the "category" field. + Category string `json:"category,omitempty"` + // Status holds the value of the "status" field. + Status int `json:"status,omitempty"` + // Creator holds the value of the "creator" field. + Creator string `json:"creator,omitempty"` + // CreateTime holds the value of the "create_time" field. + CreateTime *time.Time `json:"create_time,omitempty"` + // Updater holds the value of the "updater" field. + Updater string `json:"updater,omitempty"` + // UpdateTime holds the value of the "update_time" field. + UpdateTime *time.Time `json:"update_time,omitempty"` + // Deleted holds the value of the "deleted" field. + Deleted int `json:"deleted,omitempty"` + // Code holds the value of the "code" field. + Code string `json:"code,omitempty"` + selectValues sql.SelectValues +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*EpicI18NMappings) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case epici18nmappings.FieldID, epici18nmappings.FieldStatus, epici18nmappings.FieldDeleted: + values[i] = new(sql.NullInt64) + case epici18nmappings.FieldKeyName, epici18nmappings.FieldLanguage, epici18nmappings.FieldValue, epici18nmappings.FieldCategory, epici18nmappings.FieldCreator, epici18nmappings.FieldUpdater, epici18nmappings.FieldCode: + values[i] = new(sql.NullString) + case epici18nmappings.FieldCreateTime, epici18nmappings.FieldUpdateTime: + values[i] = new(sql.NullTime) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the EpicI18NMappings fields. +func (_m *EpicI18NMappings) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case epici18nmappings.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + _m.ID = int64(value.Int64) + case epici18nmappings.FieldKeyName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field key_name", values[i]) + } else if value.Valid { + _m.KeyName = value.String + } + case epici18nmappings.FieldLanguage: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field language", values[i]) + } else if value.Valid { + _m.Language = value.String + } + case epici18nmappings.FieldValue: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field value", values[i]) + } else if value.Valid { + _m.Value = value.String + } + case epici18nmappings.FieldCategory: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field category", values[i]) + } else if value.Valid { + _m.Category = value.String + } + case epici18nmappings.FieldStatus: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field status", values[i]) + } else if value.Valid { + _m.Status = int(value.Int64) + } + case epici18nmappings.FieldCreator: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field creator", values[i]) + } else if value.Valid { + _m.Creator = value.String + } + case epici18nmappings.FieldCreateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field create_time", values[i]) + } else if value.Valid { + _m.CreateTime = new(time.Time) + *_m.CreateTime = value.Time + } + case epici18nmappings.FieldUpdater: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field updater", values[i]) + } else if value.Valid { + _m.Updater = value.String + } + case epici18nmappings.FieldUpdateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field update_time", values[i]) + } else if value.Valid { + _m.UpdateTime = new(time.Time) + *_m.UpdateTime = value.Time + } + case epici18nmappings.FieldDeleted: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field deleted", values[i]) + } else if value.Valid { + _m.Deleted = int(value.Int64) + } + case epici18nmappings.FieldCode: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field code", values[i]) + } else if value.Valid { + _m.Code = value.String + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// GetValue returns the ent.Value that was dynamically selected and assigned to the EpicI18NMappings. +// This includes values selected through modifiers, order, etc. +func (_m *EpicI18NMappings) GetValue(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// Update returns a builder for updating this EpicI18NMappings. +// Note that you need to call EpicI18NMappings.Unwrap() before calling this method if this EpicI18NMappings +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *EpicI18NMappings) Update() *EpicI18NMappingsUpdateOne { + return NewEpicI18NMappingsClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the EpicI18NMappings entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (_m *EpicI18NMappings) Unwrap() *EpicI18NMappings { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("ent: EpicI18NMappings is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *EpicI18NMappings) String() string { + var builder strings.Builder + builder.WriteString("EpicI18NMappings(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("key_name=") + builder.WriteString(_m.KeyName) + builder.WriteString(", ") + builder.WriteString("language=") + builder.WriteString(_m.Language) + builder.WriteString(", ") + builder.WriteString("value=") + builder.WriteString(_m.Value) + builder.WriteString(", ") + builder.WriteString("category=") + builder.WriteString(_m.Category) + builder.WriteString(", ") + builder.WriteString("status=") + builder.WriteString(fmt.Sprintf("%v", _m.Status)) + builder.WriteString(", ") + builder.WriteString("creator=") + builder.WriteString(_m.Creator) + builder.WriteString(", ") + if v := _m.CreateTime; v != nil { + builder.WriteString("create_time=") + builder.WriteString(v.Format(time.ANSIC)) + } + builder.WriteString(", ") + builder.WriteString("updater=") + builder.WriteString(_m.Updater) + builder.WriteString(", ") + if v := _m.UpdateTime; v != nil { + builder.WriteString("update_time=") + builder.WriteString(v.Format(time.ANSIC)) + } + builder.WriteString(", ") + builder.WriteString("deleted=") + builder.WriteString(fmt.Sprintf("%v", _m.Deleted)) + builder.WriteString(", ") + builder.WriteString("code=") + builder.WriteString(_m.Code) + builder.WriteByte(')') + return builder.String() +} + +// EpicI18NMappingsSlice is a parsable slice of EpicI18NMappings. +type EpicI18NMappingsSlice []*EpicI18NMappings diff --git a/internal/ent/epici18nmappings/epici18nmappings.go b/internal/ent/epici18nmappings/epici18nmappings.go new file mode 100644 index 0000000..d05649d --- /dev/null +++ b/internal/ent/epici18nmappings/epici18nmappings.go @@ -0,0 +1,144 @@ +// Code generated by ent, DO NOT EDIT. + +package epici18nmappings + +import ( + "entgo.io/ent/dialect/sql" +) + +const ( + // Label holds the string label denoting the epici18nmappings type in the database. + Label = "epic_i18n_mappings" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldKeyName holds the string denoting the key_name field in the database. + FieldKeyName = "key_name" + // FieldLanguage holds the string denoting the language field in the database. + FieldLanguage = "language" + // FieldValue holds the string denoting the value field in the database. + FieldValue = "value" + // FieldCategory holds the string denoting the category field in the database. + FieldCategory = "category" + // FieldStatus holds the string denoting the status field in the database. + FieldStatus = "status" + // FieldCreator holds the string denoting the creator field in the database. + FieldCreator = "creator" + // FieldCreateTime holds the string denoting the create_time field in the database. + FieldCreateTime = "create_time" + // FieldUpdater holds the string denoting the updater field in the database. + FieldUpdater = "updater" + // FieldUpdateTime holds the string denoting the update_time field in the database. + FieldUpdateTime = "update_time" + // FieldDeleted holds the string denoting the deleted field in the database. + FieldDeleted = "deleted" + // FieldCode holds the string denoting the code field in the database. + FieldCode = "code" + // Table holds the table name of the epici18nmappings in the database. + Table = "epic_i18n_mappings" +) + +// Columns holds all SQL columns for epici18nmappings fields. +var Columns = []string{ + FieldID, + FieldKeyName, + FieldLanguage, + FieldValue, + FieldCategory, + FieldStatus, + FieldCreator, + FieldCreateTime, + FieldUpdater, + FieldUpdateTime, + FieldDeleted, + FieldCode, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // KeyNameValidator is a validator for the "key_name" field. It is called by the builders before save. + KeyNameValidator func(string) error + // LanguageValidator is a validator for the "language" field. It is called by the builders before save. + LanguageValidator func(string) error + // ValueValidator is a validator for the "value" field. It is called by the builders before save. + ValueValidator func(string) error + // CategoryValidator is a validator for the "category" field. It is called by the builders before save. + CategoryValidator func(string) error + // CreatorValidator is a validator for the "creator" field. It is called by the builders before save. + CreatorValidator func(string) error + // UpdaterValidator is a validator for the "updater" field. It is called by the builders before save. + UpdaterValidator func(string) error + // CodeValidator is a validator for the "code" field. It is called by the builders before save. + CodeValidator func(string) error +) + +// OrderOption defines the ordering options for the EpicI18NMappings queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByKeyName orders the results by the key_name field. +func ByKeyName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldKeyName, opts...).ToFunc() +} + +// ByLanguage orders the results by the language field. +func ByLanguage(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLanguage, opts...).ToFunc() +} + +// ByValue orders the results by the value field. +func ByValue(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldValue, opts...).ToFunc() +} + +// ByCategory orders the results by the category field. +func ByCategory(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCategory, opts...).ToFunc() +} + +// ByStatus orders the results by the status field. +func ByStatus(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStatus, opts...).ToFunc() +} + +// ByCreator orders the results by the creator field. +func ByCreator(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreator, opts...).ToFunc() +} + +// ByCreateTime orders the results by the create_time field. +func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateTime, opts...).ToFunc() +} + +// ByUpdater orders the results by the updater field. +func ByUpdater(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdater, opts...).ToFunc() +} + +// ByUpdateTime orders the results by the update_time field. +func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() +} + +// ByDeleted orders the results by the deleted field. +func ByDeleted(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeleted, opts...).ToFunc() +} + +// ByCode orders the results by the code field. +func ByCode(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCode, opts...).ToFunc() +} diff --git a/internal/ent/epici18nmappings/where.go b/internal/ent/epici18nmappings/where.go new file mode 100644 index 0000000..1b43066 --- /dev/null +++ b/internal/ent/epici18nmappings/where.go @@ -0,0 +1,760 @@ +// Code generated by ent, DO NOT EDIT. + +package epici18nmappings + +import ( + "epic-ent/internal/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" +) + +// ID filters vertices based on their ID field. +func ID(id int64) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int64) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int64) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int64) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int64) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int64) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int64) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int64) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int64) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldLTE(FieldID, id)) +} + +// KeyName applies equality check predicate on the "key_name" field. It's identical to KeyNameEQ. +func KeyName(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldEQ(FieldKeyName, v)) +} + +// Language applies equality check predicate on the "language" field. It's identical to LanguageEQ. +func Language(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldEQ(FieldLanguage, v)) +} + +// Value applies equality check predicate on the "value" field. It's identical to ValueEQ. +func Value(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldEQ(FieldValue, v)) +} + +// Category applies equality check predicate on the "category" field. It's identical to CategoryEQ. +func Category(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldEQ(FieldCategory, v)) +} + +// Status applies equality check predicate on the "status" field. It's identical to StatusEQ. +func Status(v int) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldEQ(FieldStatus, v)) +} + +// Creator applies equality check predicate on the "creator" field. It's identical to CreatorEQ. +func Creator(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldEQ(FieldCreator, v)) +} + +// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. +func CreateTime(v time.Time) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldEQ(FieldCreateTime, v)) +} + +// Updater applies equality check predicate on the "updater" field. It's identical to UpdaterEQ. +func Updater(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldEQ(FieldUpdater, v)) +} + +// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. +func UpdateTime(v time.Time) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldEQ(FieldUpdateTime, v)) +} + +// Deleted applies equality check predicate on the "deleted" field. It's identical to DeletedEQ. +func Deleted(v int) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldEQ(FieldDeleted, v)) +} + +// Code applies equality check predicate on the "code" field. It's identical to CodeEQ. +func Code(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldEQ(FieldCode, v)) +} + +// KeyNameEQ applies the EQ predicate on the "key_name" field. +func KeyNameEQ(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldEQ(FieldKeyName, v)) +} + +// KeyNameNEQ applies the NEQ predicate on the "key_name" field. +func KeyNameNEQ(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldNEQ(FieldKeyName, v)) +} + +// KeyNameIn applies the In predicate on the "key_name" field. +func KeyNameIn(vs ...string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldIn(FieldKeyName, vs...)) +} + +// KeyNameNotIn applies the NotIn predicate on the "key_name" field. +func KeyNameNotIn(vs ...string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldNotIn(FieldKeyName, vs...)) +} + +// KeyNameGT applies the GT predicate on the "key_name" field. +func KeyNameGT(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldGT(FieldKeyName, v)) +} + +// KeyNameGTE applies the GTE predicate on the "key_name" field. +func KeyNameGTE(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldGTE(FieldKeyName, v)) +} + +// KeyNameLT applies the LT predicate on the "key_name" field. +func KeyNameLT(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldLT(FieldKeyName, v)) +} + +// KeyNameLTE applies the LTE predicate on the "key_name" field. +func KeyNameLTE(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldLTE(FieldKeyName, v)) +} + +// KeyNameContains applies the Contains predicate on the "key_name" field. +func KeyNameContains(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldContains(FieldKeyName, v)) +} + +// KeyNameHasPrefix applies the HasPrefix predicate on the "key_name" field. +func KeyNameHasPrefix(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldHasPrefix(FieldKeyName, v)) +} + +// KeyNameHasSuffix applies the HasSuffix predicate on the "key_name" field. +func KeyNameHasSuffix(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldHasSuffix(FieldKeyName, v)) +} + +// KeyNameEqualFold applies the EqualFold predicate on the "key_name" field. +func KeyNameEqualFold(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldEqualFold(FieldKeyName, v)) +} + +// KeyNameContainsFold applies the ContainsFold predicate on the "key_name" field. +func KeyNameContainsFold(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldContainsFold(FieldKeyName, v)) +} + +// LanguageEQ applies the EQ predicate on the "language" field. +func LanguageEQ(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldEQ(FieldLanguage, v)) +} + +// LanguageNEQ applies the NEQ predicate on the "language" field. +func LanguageNEQ(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldNEQ(FieldLanguage, v)) +} + +// LanguageIn applies the In predicate on the "language" field. +func LanguageIn(vs ...string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldIn(FieldLanguage, vs...)) +} + +// LanguageNotIn applies the NotIn predicate on the "language" field. +func LanguageNotIn(vs ...string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldNotIn(FieldLanguage, vs...)) +} + +// LanguageGT applies the GT predicate on the "language" field. +func LanguageGT(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldGT(FieldLanguage, v)) +} + +// LanguageGTE applies the GTE predicate on the "language" field. +func LanguageGTE(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldGTE(FieldLanguage, v)) +} + +// LanguageLT applies the LT predicate on the "language" field. +func LanguageLT(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldLT(FieldLanguage, v)) +} + +// LanguageLTE applies the LTE predicate on the "language" field. +func LanguageLTE(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldLTE(FieldLanguage, v)) +} + +// LanguageContains applies the Contains predicate on the "language" field. +func LanguageContains(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldContains(FieldLanguage, v)) +} + +// LanguageHasPrefix applies the HasPrefix predicate on the "language" field. +func LanguageHasPrefix(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldHasPrefix(FieldLanguage, v)) +} + +// LanguageHasSuffix applies the HasSuffix predicate on the "language" field. +func LanguageHasSuffix(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldHasSuffix(FieldLanguage, v)) +} + +// LanguageEqualFold applies the EqualFold predicate on the "language" field. +func LanguageEqualFold(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldEqualFold(FieldLanguage, v)) +} + +// LanguageContainsFold applies the ContainsFold predicate on the "language" field. +func LanguageContainsFold(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldContainsFold(FieldLanguage, v)) +} + +// ValueEQ applies the EQ predicate on the "value" field. +func ValueEQ(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldEQ(FieldValue, v)) +} + +// ValueNEQ applies the NEQ predicate on the "value" field. +func ValueNEQ(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldNEQ(FieldValue, v)) +} + +// ValueIn applies the In predicate on the "value" field. +func ValueIn(vs ...string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldIn(FieldValue, vs...)) +} + +// ValueNotIn applies the NotIn predicate on the "value" field. +func ValueNotIn(vs ...string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldNotIn(FieldValue, vs...)) +} + +// ValueGT applies the GT predicate on the "value" field. +func ValueGT(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldGT(FieldValue, v)) +} + +// ValueGTE applies the GTE predicate on the "value" field. +func ValueGTE(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldGTE(FieldValue, v)) +} + +// ValueLT applies the LT predicate on the "value" field. +func ValueLT(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldLT(FieldValue, v)) +} + +// ValueLTE applies the LTE predicate on the "value" field. +func ValueLTE(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldLTE(FieldValue, v)) +} + +// ValueContains applies the Contains predicate on the "value" field. +func ValueContains(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldContains(FieldValue, v)) +} + +// ValueHasPrefix applies the HasPrefix predicate on the "value" field. +func ValueHasPrefix(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldHasPrefix(FieldValue, v)) +} + +// ValueHasSuffix applies the HasSuffix predicate on the "value" field. +func ValueHasSuffix(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldHasSuffix(FieldValue, v)) +} + +// ValueEqualFold applies the EqualFold predicate on the "value" field. +func ValueEqualFold(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldEqualFold(FieldValue, v)) +} + +// ValueContainsFold applies the ContainsFold predicate on the "value" field. +func ValueContainsFold(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldContainsFold(FieldValue, v)) +} + +// CategoryEQ applies the EQ predicate on the "category" field. +func CategoryEQ(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldEQ(FieldCategory, v)) +} + +// CategoryNEQ applies the NEQ predicate on the "category" field. +func CategoryNEQ(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldNEQ(FieldCategory, v)) +} + +// CategoryIn applies the In predicate on the "category" field. +func CategoryIn(vs ...string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldIn(FieldCategory, vs...)) +} + +// CategoryNotIn applies the NotIn predicate on the "category" field. +func CategoryNotIn(vs ...string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldNotIn(FieldCategory, vs...)) +} + +// CategoryGT applies the GT predicate on the "category" field. +func CategoryGT(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldGT(FieldCategory, v)) +} + +// CategoryGTE applies the GTE predicate on the "category" field. +func CategoryGTE(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldGTE(FieldCategory, v)) +} + +// CategoryLT applies the LT predicate on the "category" field. +func CategoryLT(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldLT(FieldCategory, v)) +} + +// CategoryLTE applies the LTE predicate on the "category" field. +func CategoryLTE(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldLTE(FieldCategory, v)) +} + +// CategoryContains applies the Contains predicate on the "category" field. +func CategoryContains(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldContains(FieldCategory, v)) +} + +// CategoryHasPrefix applies the HasPrefix predicate on the "category" field. +func CategoryHasPrefix(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldHasPrefix(FieldCategory, v)) +} + +// CategoryHasSuffix applies the HasSuffix predicate on the "category" field. +func CategoryHasSuffix(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldHasSuffix(FieldCategory, v)) +} + +// CategoryEqualFold applies the EqualFold predicate on the "category" field. +func CategoryEqualFold(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldEqualFold(FieldCategory, v)) +} + +// CategoryContainsFold applies the ContainsFold predicate on the "category" field. +func CategoryContainsFold(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldContainsFold(FieldCategory, v)) +} + +// StatusEQ applies the EQ predicate on the "status" field. +func StatusEQ(v int) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldEQ(FieldStatus, v)) +} + +// StatusNEQ applies the NEQ predicate on the "status" field. +func StatusNEQ(v int) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldNEQ(FieldStatus, v)) +} + +// StatusIn applies the In predicate on the "status" field. +func StatusIn(vs ...int) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldIn(FieldStatus, vs...)) +} + +// StatusNotIn applies the NotIn predicate on the "status" field. +func StatusNotIn(vs ...int) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldNotIn(FieldStatus, vs...)) +} + +// StatusGT applies the GT predicate on the "status" field. +func StatusGT(v int) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldGT(FieldStatus, v)) +} + +// StatusGTE applies the GTE predicate on the "status" field. +func StatusGTE(v int) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldGTE(FieldStatus, v)) +} + +// StatusLT applies the LT predicate on the "status" field. +func StatusLT(v int) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldLT(FieldStatus, v)) +} + +// StatusLTE applies the LTE predicate on the "status" field. +func StatusLTE(v int) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldLTE(FieldStatus, v)) +} + +// CreatorEQ applies the EQ predicate on the "creator" field. +func CreatorEQ(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldEQ(FieldCreator, v)) +} + +// CreatorNEQ applies the NEQ predicate on the "creator" field. +func CreatorNEQ(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldNEQ(FieldCreator, v)) +} + +// CreatorIn applies the In predicate on the "creator" field. +func CreatorIn(vs ...string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldIn(FieldCreator, vs...)) +} + +// CreatorNotIn applies the NotIn predicate on the "creator" field. +func CreatorNotIn(vs ...string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldNotIn(FieldCreator, vs...)) +} + +// CreatorGT applies the GT predicate on the "creator" field. +func CreatorGT(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldGT(FieldCreator, v)) +} + +// CreatorGTE applies the GTE predicate on the "creator" field. +func CreatorGTE(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldGTE(FieldCreator, v)) +} + +// CreatorLT applies the LT predicate on the "creator" field. +func CreatorLT(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldLT(FieldCreator, v)) +} + +// CreatorLTE applies the LTE predicate on the "creator" field. +func CreatorLTE(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldLTE(FieldCreator, v)) +} + +// CreatorContains applies the Contains predicate on the "creator" field. +func CreatorContains(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldContains(FieldCreator, v)) +} + +// CreatorHasPrefix applies the HasPrefix predicate on the "creator" field. +func CreatorHasPrefix(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldHasPrefix(FieldCreator, v)) +} + +// CreatorHasSuffix applies the HasSuffix predicate on the "creator" field. +func CreatorHasSuffix(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldHasSuffix(FieldCreator, v)) +} + +// CreatorEqualFold applies the EqualFold predicate on the "creator" field. +func CreatorEqualFold(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldEqualFold(FieldCreator, v)) +} + +// CreatorContainsFold applies the ContainsFold predicate on the "creator" field. +func CreatorContainsFold(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldContainsFold(FieldCreator, v)) +} + +// CreateTimeEQ applies the EQ predicate on the "create_time" field. +func CreateTimeEQ(v time.Time) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldEQ(FieldCreateTime, v)) +} + +// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. +func CreateTimeNEQ(v time.Time) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldNEQ(FieldCreateTime, v)) +} + +// CreateTimeIn applies the In predicate on the "create_time" field. +func CreateTimeIn(vs ...time.Time) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldIn(FieldCreateTime, vs...)) +} + +// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. +func CreateTimeNotIn(vs ...time.Time) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldNotIn(FieldCreateTime, vs...)) +} + +// CreateTimeGT applies the GT predicate on the "create_time" field. +func CreateTimeGT(v time.Time) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldGT(FieldCreateTime, v)) +} + +// CreateTimeGTE applies the GTE predicate on the "create_time" field. +func CreateTimeGTE(v time.Time) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldGTE(FieldCreateTime, v)) +} + +// CreateTimeLT applies the LT predicate on the "create_time" field. +func CreateTimeLT(v time.Time) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldLT(FieldCreateTime, v)) +} + +// CreateTimeLTE applies the LTE predicate on the "create_time" field. +func CreateTimeLTE(v time.Time) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldLTE(FieldCreateTime, v)) +} + +// CreateTimeIsNil applies the IsNil predicate on the "create_time" field. +func CreateTimeIsNil() predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldIsNull(FieldCreateTime)) +} + +// CreateTimeNotNil applies the NotNil predicate on the "create_time" field. +func CreateTimeNotNil() predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldNotNull(FieldCreateTime)) +} + +// UpdaterEQ applies the EQ predicate on the "updater" field. +func UpdaterEQ(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldEQ(FieldUpdater, v)) +} + +// UpdaterNEQ applies the NEQ predicate on the "updater" field. +func UpdaterNEQ(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldNEQ(FieldUpdater, v)) +} + +// UpdaterIn applies the In predicate on the "updater" field. +func UpdaterIn(vs ...string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldIn(FieldUpdater, vs...)) +} + +// UpdaterNotIn applies the NotIn predicate on the "updater" field. +func UpdaterNotIn(vs ...string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldNotIn(FieldUpdater, vs...)) +} + +// UpdaterGT applies the GT predicate on the "updater" field. +func UpdaterGT(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldGT(FieldUpdater, v)) +} + +// UpdaterGTE applies the GTE predicate on the "updater" field. +func UpdaterGTE(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldGTE(FieldUpdater, v)) +} + +// UpdaterLT applies the LT predicate on the "updater" field. +func UpdaterLT(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldLT(FieldUpdater, v)) +} + +// UpdaterLTE applies the LTE predicate on the "updater" field. +func UpdaterLTE(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldLTE(FieldUpdater, v)) +} + +// UpdaterContains applies the Contains predicate on the "updater" field. +func UpdaterContains(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldContains(FieldUpdater, v)) +} + +// UpdaterHasPrefix applies the HasPrefix predicate on the "updater" field. +func UpdaterHasPrefix(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldHasPrefix(FieldUpdater, v)) +} + +// UpdaterHasSuffix applies the HasSuffix predicate on the "updater" field. +func UpdaterHasSuffix(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldHasSuffix(FieldUpdater, v)) +} + +// UpdaterEqualFold applies the EqualFold predicate on the "updater" field. +func UpdaterEqualFold(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldEqualFold(FieldUpdater, v)) +} + +// UpdaterContainsFold applies the ContainsFold predicate on the "updater" field. +func UpdaterContainsFold(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldContainsFold(FieldUpdater, v)) +} + +// UpdateTimeEQ applies the EQ predicate on the "update_time" field. +func UpdateTimeEQ(v time.Time) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldEQ(FieldUpdateTime, v)) +} + +// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. +func UpdateTimeNEQ(v time.Time) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldNEQ(FieldUpdateTime, v)) +} + +// UpdateTimeIn applies the In predicate on the "update_time" field. +func UpdateTimeIn(vs ...time.Time) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. +func UpdateTimeNotIn(vs ...time.Time) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldNotIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeGT applies the GT predicate on the "update_time" field. +func UpdateTimeGT(v time.Time) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldGT(FieldUpdateTime, v)) +} + +// UpdateTimeGTE applies the GTE predicate on the "update_time" field. +func UpdateTimeGTE(v time.Time) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldGTE(FieldUpdateTime, v)) +} + +// UpdateTimeLT applies the LT predicate on the "update_time" field. +func UpdateTimeLT(v time.Time) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldLT(FieldUpdateTime, v)) +} + +// UpdateTimeLTE applies the LTE predicate on the "update_time" field. +func UpdateTimeLTE(v time.Time) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldLTE(FieldUpdateTime, v)) +} + +// UpdateTimeIsNil applies the IsNil predicate on the "update_time" field. +func UpdateTimeIsNil() predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldIsNull(FieldUpdateTime)) +} + +// UpdateTimeNotNil applies the NotNil predicate on the "update_time" field. +func UpdateTimeNotNil() predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldNotNull(FieldUpdateTime)) +} + +// DeletedEQ applies the EQ predicate on the "deleted" field. +func DeletedEQ(v int) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldEQ(FieldDeleted, v)) +} + +// DeletedNEQ applies the NEQ predicate on the "deleted" field. +func DeletedNEQ(v int) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldNEQ(FieldDeleted, v)) +} + +// DeletedIn applies the In predicate on the "deleted" field. +func DeletedIn(vs ...int) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldIn(FieldDeleted, vs...)) +} + +// DeletedNotIn applies the NotIn predicate on the "deleted" field. +func DeletedNotIn(vs ...int) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldNotIn(FieldDeleted, vs...)) +} + +// DeletedGT applies the GT predicate on the "deleted" field. +func DeletedGT(v int) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldGT(FieldDeleted, v)) +} + +// DeletedGTE applies the GTE predicate on the "deleted" field. +func DeletedGTE(v int) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldGTE(FieldDeleted, v)) +} + +// DeletedLT applies the LT predicate on the "deleted" field. +func DeletedLT(v int) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldLT(FieldDeleted, v)) +} + +// DeletedLTE applies the LTE predicate on the "deleted" field. +func DeletedLTE(v int) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldLTE(FieldDeleted, v)) +} + +// CodeEQ applies the EQ predicate on the "code" field. +func CodeEQ(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldEQ(FieldCode, v)) +} + +// CodeNEQ applies the NEQ predicate on the "code" field. +func CodeNEQ(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldNEQ(FieldCode, v)) +} + +// CodeIn applies the In predicate on the "code" field. +func CodeIn(vs ...string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldIn(FieldCode, vs...)) +} + +// CodeNotIn applies the NotIn predicate on the "code" field. +func CodeNotIn(vs ...string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldNotIn(FieldCode, vs...)) +} + +// CodeGT applies the GT predicate on the "code" field. +func CodeGT(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldGT(FieldCode, v)) +} + +// CodeGTE applies the GTE predicate on the "code" field. +func CodeGTE(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldGTE(FieldCode, v)) +} + +// CodeLT applies the LT predicate on the "code" field. +func CodeLT(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldLT(FieldCode, v)) +} + +// CodeLTE applies the LTE predicate on the "code" field. +func CodeLTE(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldLTE(FieldCode, v)) +} + +// CodeContains applies the Contains predicate on the "code" field. +func CodeContains(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldContains(FieldCode, v)) +} + +// CodeHasPrefix applies the HasPrefix predicate on the "code" field. +func CodeHasPrefix(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldHasPrefix(FieldCode, v)) +} + +// CodeHasSuffix applies the HasSuffix predicate on the "code" field. +func CodeHasSuffix(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldHasSuffix(FieldCode, v)) +} + +// CodeEqualFold applies the EqualFold predicate on the "code" field. +func CodeEqualFold(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldEqualFold(FieldCode, v)) +} + +// CodeContainsFold applies the ContainsFold predicate on the "code" field. +func CodeContainsFold(v string) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.FieldContainsFold(FieldCode, v)) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.EpicI18NMappings) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.EpicI18NMappings) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.EpicI18NMappings) predicate.EpicI18NMappings { + return predicate.EpicI18NMappings(sql.NotPredicates(p)) +} diff --git a/internal/ent/epici18nmappings_create.go b/internal/ent/epici18nmappings_create.go new file mode 100644 index 0000000..b3a4de5 --- /dev/null +++ b/internal/ent/epici18nmappings_create.go @@ -0,0 +1,371 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "epic-ent/internal/ent/epici18nmappings" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// EpicI18NMappingsCreate is the builder for creating a EpicI18NMappings entity. +type EpicI18NMappingsCreate struct { + config + mutation *EpicI18NMappingsMutation + hooks []Hook +} + +// SetKeyName sets the "key_name" field. +func (_c *EpicI18NMappingsCreate) SetKeyName(v string) *EpicI18NMappingsCreate { + _c.mutation.SetKeyName(v) + return _c +} + +// SetLanguage sets the "language" field. +func (_c *EpicI18NMappingsCreate) SetLanguage(v string) *EpicI18NMappingsCreate { + _c.mutation.SetLanguage(v) + return _c +} + +// SetValue sets the "value" field. +func (_c *EpicI18NMappingsCreate) SetValue(v string) *EpicI18NMappingsCreate { + _c.mutation.SetValue(v) + return _c +} + +// SetCategory sets the "category" field. +func (_c *EpicI18NMappingsCreate) SetCategory(v string) *EpicI18NMappingsCreate { + _c.mutation.SetCategory(v) + return _c +} + +// SetStatus sets the "status" field. +func (_c *EpicI18NMappingsCreate) SetStatus(v int) *EpicI18NMappingsCreate { + _c.mutation.SetStatus(v) + return _c +} + +// SetCreator sets the "creator" field. +func (_c *EpicI18NMappingsCreate) SetCreator(v string) *EpicI18NMappingsCreate { + _c.mutation.SetCreator(v) + return _c +} + +// SetCreateTime sets the "create_time" field. +func (_c *EpicI18NMappingsCreate) SetCreateTime(v time.Time) *EpicI18NMappingsCreate { + _c.mutation.SetCreateTime(v) + return _c +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (_c *EpicI18NMappingsCreate) SetNillableCreateTime(v *time.Time) *EpicI18NMappingsCreate { + if v != nil { + _c.SetCreateTime(*v) + } + return _c +} + +// SetUpdater sets the "updater" field. +func (_c *EpicI18NMappingsCreate) SetUpdater(v string) *EpicI18NMappingsCreate { + _c.mutation.SetUpdater(v) + return _c +} + +// SetUpdateTime sets the "update_time" field. +func (_c *EpicI18NMappingsCreate) SetUpdateTime(v time.Time) *EpicI18NMappingsCreate { + _c.mutation.SetUpdateTime(v) + return _c +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (_c *EpicI18NMappingsCreate) SetNillableUpdateTime(v *time.Time) *EpicI18NMappingsCreate { + if v != nil { + _c.SetUpdateTime(*v) + } + return _c +} + +// SetDeleted sets the "deleted" field. +func (_c *EpicI18NMappingsCreate) SetDeleted(v int) *EpicI18NMappingsCreate { + _c.mutation.SetDeleted(v) + return _c +} + +// SetCode sets the "code" field. +func (_c *EpicI18NMappingsCreate) SetCode(v string) *EpicI18NMappingsCreate { + _c.mutation.SetCode(v) + return _c +} + +// SetID sets the "id" field. +func (_c *EpicI18NMappingsCreate) SetID(v int64) *EpicI18NMappingsCreate { + _c.mutation.SetID(v) + return _c +} + +// Mutation returns the EpicI18NMappingsMutation object of the builder. +func (_c *EpicI18NMappingsCreate) Mutation() *EpicI18NMappingsMutation { + return _c.mutation +} + +// Save creates the EpicI18NMappings in the database. +func (_c *EpicI18NMappingsCreate) Save(ctx context.Context) (*EpicI18NMappings, error) { + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *EpicI18NMappingsCreate) SaveX(ctx context.Context) *EpicI18NMappings { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *EpicI18NMappingsCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *EpicI18NMappingsCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *EpicI18NMappingsCreate) check() error { + if _, ok := _c.mutation.KeyName(); !ok { + return &ValidationError{Name: "key_name", err: errors.New(`ent: missing required field "EpicI18NMappings.key_name"`)} + } + if v, ok := _c.mutation.KeyName(); ok { + if err := epici18nmappings.KeyNameValidator(v); err != nil { + return &ValidationError{Name: "key_name", err: fmt.Errorf(`ent: validator failed for field "EpicI18NMappings.key_name": %w`, err)} + } + } + if _, ok := _c.mutation.Language(); !ok { + return &ValidationError{Name: "language", err: errors.New(`ent: missing required field "EpicI18NMappings.language"`)} + } + if v, ok := _c.mutation.Language(); ok { + if err := epici18nmappings.LanguageValidator(v); err != nil { + return &ValidationError{Name: "language", err: fmt.Errorf(`ent: validator failed for field "EpicI18NMappings.language": %w`, err)} + } + } + if _, ok := _c.mutation.Value(); !ok { + return &ValidationError{Name: "value", err: errors.New(`ent: missing required field "EpicI18NMappings.value"`)} + } + if v, ok := _c.mutation.Value(); ok { + if err := epici18nmappings.ValueValidator(v); err != nil { + return &ValidationError{Name: "value", err: fmt.Errorf(`ent: validator failed for field "EpicI18NMappings.value": %w`, err)} + } + } + if _, ok := _c.mutation.Category(); !ok { + return &ValidationError{Name: "category", err: errors.New(`ent: missing required field "EpicI18NMappings.category"`)} + } + if v, ok := _c.mutation.Category(); ok { + if err := epici18nmappings.CategoryValidator(v); err != nil { + return &ValidationError{Name: "category", err: fmt.Errorf(`ent: validator failed for field "EpicI18NMappings.category": %w`, err)} + } + } + if _, ok := _c.mutation.Status(); !ok { + return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "EpicI18NMappings.status"`)} + } + if _, ok := _c.mutation.Creator(); !ok { + return &ValidationError{Name: "creator", err: errors.New(`ent: missing required field "EpicI18NMappings.creator"`)} + } + if v, ok := _c.mutation.Creator(); ok { + if err := epici18nmappings.CreatorValidator(v); err != nil { + return &ValidationError{Name: "creator", err: fmt.Errorf(`ent: validator failed for field "EpicI18NMappings.creator": %w`, err)} + } + } + if _, ok := _c.mutation.Updater(); !ok { + return &ValidationError{Name: "updater", err: errors.New(`ent: missing required field "EpicI18NMappings.updater"`)} + } + if v, ok := _c.mutation.Updater(); ok { + if err := epici18nmappings.UpdaterValidator(v); err != nil { + return &ValidationError{Name: "updater", err: fmt.Errorf(`ent: validator failed for field "EpicI18NMappings.updater": %w`, err)} + } + } + if _, ok := _c.mutation.Deleted(); !ok { + return &ValidationError{Name: "deleted", err: errors.New(`ent: missing required field "EpicI18NMappings.deleted"`)} + } + if _, ok := _c.mutation.Code(); !ok { + return &ValidationError{Name: "code", err: errors.New(`ent: missing required field "EpicI18NMappings.code"`)} + } + if v, ok := _c.mutation.Code(); ok { + if err := epici18nmappings.CodeValidator(v); err != nil { + return &ValidationError{Name: "code", err: fmt.Errorf(`ent: validator failed for field "EpicI18NMappings.code": %w`, err)} + } + } + return nil +} + +func (_c *EpicI18NMappingsCreate) sqlSave(ctx context.Context) (*EpicI18NMappings, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != _node.ID { + id := _spec.ID.Value.(int64) + _node.ID = int64(id) + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *EpicI18NMappingsCreate) createSpec() (*EpicI18NMappings, *sqlgraph.CreateSpec) { + var ( + _node = &EpicI18NMappings{config: _c.config} + _spec = sqlgraph.NewCreateSpec(epici18nmappings.Table, sqlgraph.NewFieldSpec(epici18nmappings.FieldID, field.TypeInt64)) + ) + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := _c.mutation.KeyName(); ok { + _spec.SetField(epici18nmappings.FieldKeyName, field.TypeString, value) + _node.KeyName = value + } + if value, ok := _c.mutation.Language(); ok { + _spec.SetField(epici18nmappings.FieldLanguage, field.TypeString, value) + _node.Language = value + } + if value, ok := _c.mutation.Value(); ok { + _spec.SetField(epici18nmappings.FieldValue, field.TypeString, value) + _node.Value = value + } + if value, ok := _c.mutation.Category(); ok { + _spec.SetField(epici18nmappings.FieldCategory, field.TypeString, value) + _node.Category = value + } + if value, ok := _c.mutation.Status(); ok { + _spec.SetField(epici18nmappings.FieldStatus, field.TypeInt, value) + _node.Status = value + } + if value, ok := _c.mutation.Creator(); ok { + _spec.SetField(epici18nmappings.FieldCreator, field.TypeString, value) + _node.Creator = value + } + if value, ok := _c.mutation.CreateTime(); ok { + _spec.SetField(epici18nmappings.FieldCreateTime, field.TypeTime, value) + _node.CreateTime = &value + } + if value, ok := _c.mutation.Updater(); ok { + _spec.SetField(epici18nmappings.FieldUpdater, field.TypeString, value) + _node.Updater = value + } + if value, ok := _c.mutation.UpdateTime(); ok { + _spec.SetField(epici18nmappings.FieldUpdateTime, field.TypeTime, value) + _node.UpdateTime = &value + } + if value, ok := _c.mutation.Deleted(); ok { + _spec.SetField(epici18nmappings.FieldDeleted, field.TypeInt, value) + _node.Deleted = value + } + if value, ok := _c.mutation.Code(); ok { + _spec.SetField(epici18nmappings.FieldCode, field.TypeString, value) + _node.Code = value + } + return _node, _spec +} + +// EpicI18NMappingsCreateBulk is the builder for creating many EpicI18NMappings entities in bulk. +type EpicI18NMappingsCreateBulk struct { + config + err error + builders []*EpicI18NMappingsCreate +} + +// Save creates the EpicI18NMappings entities in the database. +func (_c *EpicI18NMappingsCreateBulk) Save(ctx context.Context) ([]*EpicI18NMappings, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*EpicI18NMappings, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*EpicI18NMappingsMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil && nodes[i].ID == 0 { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int64(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *EpicI18NMappingsCreateBulk) SaveX(ctx context.Context) []*EpicI18NMappings { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *EpicI18NMappingsCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *EpicI18NMappingsCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/ent/epici18nmappings_delete.go b/internal/ent/epici18nmappings_delete.go new file mode 100644 index 0000000..1eabbdf --- /dev/null +++ b/internal/ent/epici18nmappings_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "epic-ent/internal/ent/epici18nmappings" + "epic-ent/internal/ent/predicate" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// EpicI18NMappingsDelete is the builder for deleting a EpicI18NMappings entity. +type EpicI18NMappingsDelete struct { + config + hooks []Hook + mutation *EpicI18NMappingsMutation +} + +// Where appends a list predicates to the EpicI18NMappingsDelete builder. +func (_d *EpicI18NMappingsDelete) Where(ps ...predicate.EpicI18NMappings) *EpicI18NMappingsDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *EpicI18NMappingsDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *EpicI18NMappingsDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *EpicI18NMappingsDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(epici18nmappings.Table, sqlgraph.NewFieldSpec(epici18nmappings.FieldID, field.TypeInt64)) + if ps := _d.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + _d.mutation.done = true + return affected, err +} + +// EpicI18NMappingsDeleteOne is the builder for deleting a single EpicI18NMappings entity. +type EpicI18NMappingsDeleteOne struct { + _d *EpicI18NMappingsDelete +} + +// Where appends a list predicates to the EpicI18NMappingsDelete builder. +func (_d *EpicI18NMappingsDeleteOne) Where(ps ...predicate.EpicI18NMappings) *EpicI18NMappingsDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *EpicI18NMappingsDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{epici18nmappings.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *EpicI18NMappingsDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/ent/epici18nmappings_query.go b/internal/ent/epici18nmappings_query.go new file mode 100644 index 0000000..303af3c --- /dev/null +++ b/internal/ent/epici18nmappings_query.go @@ -0,0 +1,527 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "epic-ent/internal/ent/epici18nmappings" + "epic-ent/internal/ent/predicate" + "fmt" + "math" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// EpicI18NMappingsQuery is the builder for querying EpicI18NMappings entities. +type EpicI18NMappingsQuery struct { + config + ctx *QueryContext + order []epici18nmappings.OrderOption + inters []Interceptor + predicates []predicate.EpicI18NMappings + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the EpicI18NMappingsQuery builder. +func (_q *EpicI18NMappingsQuery) Where(ps ...predicate.EpicI18NMappings) *EpicI18NMappingsQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *EpicI18NMappingsQuery) Limit(limit int) *EpicI18NMappingsQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *EpicI18NMappingsQuery) Offset(offset int) *EpicI18NMappingsQuery { + _q.ctx.Offset = &offset + return _q +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (_q *EpicI18NMappingsQuery) Unique(unique bool) *EpicI18NMappingsQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *EpicI18NMappingsQuery) Order(o ...epici18nmappings.OrderOption) *EpicI18NMappingsQuery { + _q.order = append(_q.order, o...) + return _q +} + +// First returns the first EpicI18NMappings entity from the query. +// Returns a *NotFoundError when no EpicI18NMappings was found. +func (_q *EpicI18NMappingsQuery) First(ctx context.Context) (*EpicI18NMappings, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{epici18nmappings.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *EpicI18NMappingsQuery) FirstX(ctx context.Context) *EpicI18NMappings { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first EpicI18NMappings ID from the query. +// Returns a *NotFoundError when no EpicI18NMappings ID was found. +func (_q *EpicI18NMappingsQuery) FirstID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{epici18nmappings.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *EpicI18NMappingsQuery) FirstIDX(ctx context.Context) int64 { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single EpicI18NMappings entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one EpicI18NMappings entity is found. +// Returns a *NotFoundError when no EpicI18NMappings entities are found. +func (_q *EpicI18NMappingsQuery) Only(ctx context.Context) (*EpicI18NMappings, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{epici18nmappings.Label} + default: + return nil, &NotSingularError{epici18nmappings.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *EpicI18NMappingsQuery) OnlyX(ctx context.Context) *EpicI18NMappings { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only EpicI18NMappings ID in the query. +// Returns a *NotSingularError when more than one EpicI18NMappings ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *EpicI18NMappingsQuery) OnlyID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{epici18nmappings.Label} + default: + err = &NotSingularError{epici18nmappings.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *EpicI18NMappingsQuery) OnlyIDX(ctx context.Context) int64 { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of EpicI18NMappingsSlice. +func (_q *EpicI18NMappingsQuery) All(ctx context.Context) ([]*EpicI18NMappings, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*EpicI18NMappings, *EpicI18NMappingsQuery]() + return withInterceptors[[]*EpicI18NMappings](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *EpicI18NMappingsQuery) AllX(ctx context.Context) []*EpicI18NMappings { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of EpicI18NMappings IDs. +func (_q *EpicI18NMappingsQuery) IDs(ctx context.Context) (ids []int64, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(epici18nmappings.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *EpicI18NMappingsQuery) IDsX(ctx context.Context) []int64 { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *EpicI18NMappingsQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, _q, querierCount[*EpicI18NMappingsQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *EpicI18NMappingsQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (_q *EpicI18NMappingsQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *EpicI18NMappingsQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the EpicI18NMappingsQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (_q *EpicI18NMappingsQuery) Clone() *EpicI18NMappingsQuery { + if _q == nil { + return nil + } + return &EpicI18NMappingsQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]epici18nmappings.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.EpicI18NMappings{}, _q.predicates...), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + } +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// KeyName string `json:"key_name,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.EpicI18NMappings.Query(). +// GroupBy(epici18nmappings.FieldKeyName). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *EpicI18NMappingsQuery) GroupBy(field string, fields ...string) *EpicI18NMappingsGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &EpicI18NMappingsGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = epici18nmappings.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// KeyName string `json:"key_name,omitempty"` +// } +// +// client.EpicI18NMappings.Query(). +// Select(epici18nmappings.FieldKeyName). +// Scan(ctx, &v) +func (_q *EpicI18NMappingsQuery) Select(fields ...string) *EpicI18NMappingsSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &EpicI18NMappingsSelect{EpicI18NMappingsQuery: _q} + sbuild.label = epici18nmappings.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a EpicI18NMappingsSelect configured with the given aggregations. +func (_q *EpicI18NMappingsQuery) Aggregate(fns ...AggregateFunc) *EpicI18NMappingsSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *EpicI18NMappingsQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !epici18nmappings.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if _q.path != nil { + prev, err := _q.path(ctx) + if err != nil { + return err + } + _q.sql = prev + } + return nil +} + +func (_q *EpicI18NMappingsQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*EpicI18NMappings, error) { + var ( + nodes = []*EpicI18NMappings{} + _spec = _q.querySpec() + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*EpicI18NMappings).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &EpicI18NMappings{config: _q.config} + nodes = append(nodes, node) + return node.assignValues(columns, values) + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + return nodes, nil +} + +func (_q *EpicI18NMappingsQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique + } + return sqlgraph.CountNodes(ctx, _q.driver, _spec) +} + +func (_q *EpicI18NMappingsQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(epici18nmappings.Table, epici18nmappings.Columns, sqlgraph.NewFieldSpec(epici18nmappings.FieldID, field.TypeInt64)) + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if _q.path != nil { + _spec.Unique = true + } + if fields := _q.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, epici18nmappings.FieldID) + for i := range fields { + if fields[i] != epici18nmappings.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := _q.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := _q.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := _q.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := _q.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (_q *EpicI18NMappingsQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(epici18nmappings.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = epici18nmappings.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if _q.sql != nil { + selector = _q.sql + selector.Select(selector.Columns(columns...)...) + } + if _q.ctx.Unique != nil && *_q.ctx.Unique { + selector.Distinct() + } + for _, p := range _q.predicates { + p(selector) + } + for _, p := range _q.order { + p(selector) + } + if offset := _q.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := _q.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// EpicI18NMappingsGroupBy is the group-by builder for EpicI18NMappings entities. +type EpicI18NMappingsGroupBy struct { + selector + build *EpicI18NMappingsQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *EpicI18NMappingsGroupBy) Aggregate(fns ...AggregateFunc) *EpicI18NMappingsGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *EpicI18NMappingsGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*EpicI18NMappingsQuery, *EpicI18NMappingsGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *EpicI18NMappingsGroupBy) sqlScan(ctx context.Context, root *EpicI18NMappingsQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*_g.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// EpicI18NMappingsSelect is the builder for selecting fields of EpicI18NMappings entities. +type EpicI18NMappingsSelect struct { + *EpicI18NMappingsQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *EpicI18NMappingsSelect) Aggregate(fns ...AggregateFunc) *EpicI18NMappingsSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *EpicI18NMappingsSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*EpicI18NMappingsQuery, *EpicI18NMappingsSelect](ctx, _s.EpicI18NMappingsQuery, _s, _s.inters, v) +} + +func (_s *EpicI18NMappingsSelect) sqlScan(ctx context.Context, root *EpicI18NMappingsQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/internal/ent/epici18nmappings_update.go b/internal/ent/epici18nmappings_update.go new file mode 100644 index 0000000..75d83eb --- /dev/null +++ b/internal/ent/epici18nmappings_update.go @@ -0,0 +1,712 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "epic-ent/internal/ent/epici18nmappings" + "epic-ent/internal/ent/predicate" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// EpicI18NMappingsUpdate is the builder for updating EpicI18NMappings entities. +type EpicI18NMappingsUpdate struct { + config + hooks []Hook + mutation *EpicI18NMappingsMutation +} + +// Where appends a list predicates to the EpicI18NMappingsUpdate builder. +func (_u *EpicI18NMappingsUpdate) Where(ps ...predicate.EpicI18NMappings) *EpicI18NMappingsUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetKeyName sets the "key_name" field. +func (_u *EpicI18NMappingsUpdate) SetKeyName(v string) *EpicI18NMappingsUpdate { + _u.mutation.SetKeyName(v) + return _u +} + +// SetNillableKeyName sets the "key_name" field if the given value is not nil. +func (_u *EpicI18NMappingsUpdate) SetNillableKeyName(v *string) *EpicI18NMappingsUpdate { + if v != nil { + _u.SetKeyName(*v) + } + return _u +} + +// SetLanguage sets the "language" field. +func (_u *EpicI18NMappingsUpdate) SetLanguage(v string) *EpicI18NMappingsUpdate { + _u.mutation.SetLanguage(v) + return _u +} + +// SetNillableLanguage sets the "language" field if the given value is not nil. +func (_u *EpicI18NMappingsUpdate) SetNillableLanguage(v *string) *EpicI18NMappingsUpdate { + if v != nil { + _u.SetLanguage(*v) + } + return _u +} + +// SetValue sets the "value" field. +func (_u *EpicI18NMappingsUpdate) SetValue(v string) *EpicI18NMappingsUpdate { + _u.mutation.SetValue(v) + return _u +} + +// SetNillableValue sets the "value" field if the given value is not nil. +func (_u *EpicI18NMappingsUpdate) SetNillableValue(v *string) *EpicI18NMappingsUpdate { + if v != nil { + _u.SetValue(*v) + } + return _u +} + +// SetCategory sets the "category" field. +func (_u *EpicI18NMappingsUpdate) SetCategory(v string) *EpicI18NMappingsUpdate { + _u.mutation.SetCategory(v) + return _u +} + +// SetNillableCategory sets the "category" field if the given value is not nil. +func (_u *EpicI18NMappingsUpdate) SetNillableCategory(v *string) *EpicI18NMappingsUpdate { + if v != nil { + _u.SetCategory(*v) + } + return _u +} + +// SetStatus sets the "status" field. +func (_u *EpicI18NMappingsUpdate) SetStatus(v int) *EpicI18NMappingsUpdate { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_u *EpicI18NMappingsUpdate) SetNillableStatus(v *int) *EpicI18NMappingsUpdate { + if v != nil { + _u.SetStatus(*v) + } + return _u +} + +// AddStatus adds value to the "status" field. +func (_u *EpicI18NMappingsUpdate) AddStatus(v int) *EpicI18NMappingsUpdate { + _u.mutation.AddStatus(v) + return _u +} + +// SetCreator sets the "creator" field. +func (_u *EpicI18NMappingsUpdate) SetCreator(v string) *EpicI18NMappingsUpdate { + _u.mutation.SetCreator(v) + return _u +} + +// SetNillableCreator sets the "creator" field if the given value is not nil. +func (_u *EpicI18NMappingsUpdate) SetNillableCreator(v *string) *EpicI18NMappingsUpdate { + if v != nil { + _u.SetCreator(*v) + } + return _u +} + +// SetCreateTime sets the "create_time" field. +func (_u *EpicI18NMappingsUpdate) SetCreateTime(v time.Time) *EpicI18NMappingsUpdate { + _u.mutation.SetCreateTime(v) + return _u +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (_u *EpicI18NMappingsUpdate) SetNillableCreateTime(v *time.Time) *EpicI18NMappingsUpdate { + if v != nil { + _u.SetCreateTime(*v) + } + return _u +} + +// ClearCreateTime clears the value of the "create_time" field. +func (_u *EpicI18NMappingsUpdate) ClearCreateTime() *EpicI18NMappingsUpdate { + _u.mutation.ClearCreateTime() + return _u +} + +// SetUpdater sets the "updater" field. +func (_u *EpicI18NMappingsUpdate) SetUpdater(v string) *EpicI18NMappingsUpdate { + _u.mutation.SetUpdater(v) + return _u +} + +// SetNillableUpdater sets the "updater" field if the given value is not nil. +func (_u *EpicI18NMappingsUpdate) SetNillableUpdater(v *string) *EpicI18NMappingsUpdate { + if v != nil { + _u.SetUpdater(*v) + } + return _u +} + +// SetUpdateTime sets the "update_time" field. +func (_u *EpicI18NMappingsUpdate) SetUpdateTime(v time.Time) *EpicI18NMappingsUpdate { + _u.mutation.SetUpdateTime(v) + return _u +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (_u *EpicI18NMappingsUpdate) SetNillableUpdateTime(v *time.Time) *EpicI18NMappingsUpdate { + if v != nil { + _u.SetUpdateTime(*v) + } + return _u +} + +// ClearUpdateTime clears the value of the "update_time" field. +func (_u *EpicI18NMappingsUpdate) ClearUpdateTime() *EpicI18NMappingsUpdate { + _u.mutation.ClearUpdateTime() + return _u +} + +// SetDeleted sets the "deleted" field. +func (_u *EpicI18NMappingsUpdate) SetDeleted(v int) *EpicI18NMappingsUpdate { + _u.mutation.ResetDeleted() + _u.mutation.SetDeleted(v) + return _u +} + +// SetNillableDeleted sets the "deleted" field if the given value is not nil. +func (_u *EpicI18NMappingsUpdate) SetNillableDeleted(v *int) *EpicI18NMappingsUpdate { + if v != nil { + _u.SetDeleted(*v) + } + return _u +} + +// AddDeleted adds value to the "deleted" field. +func (_u *EpicI18NMappingsUpdate) AddDeleted(v int) *EpicI18NMappingsUpdate { + _u.mutation.AddDeleted(v) + return _u +} + +// SetCode sets the "code" field. +func (_u *EpicI18NMappingsUpdate) SetCode(v string) *EpicI18NMappingsUpdate { + _u.mutation.SetCode(v) + return _u +} + +// SetNillableCode sets the "code" field if the given value is not nil. +func (_u *EpicI18NMappingsUpdate) SetNillableCode(v *string) *EpicI18NMappingsUpdate { + if v != nil { + _u.SetCode(*v) + } + return _u +} + +// Mutation returns the EpicI18NMappingsMutation object of the builder. +func (_u *EpicI18NMappingsUpdate) Mutation() *EpicI18NMappingsMutation { + return _u.mutation +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *EpicI18NMappingsUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *EpicI18NMappingsUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *EpicI18NMappingsUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *EpicI18NMappingsUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *EpicI18NMappingsUpdate) check() error { + if v, ok := _u.mutation.KeyName(); ok { + if err := epici18nmappings.KeyNameValidator(v); err != nil { + return &ValidationError{Name: "key_name", err: fmt.Errorf(`ent: validator failed for field "EpicI18NMappings.key_name": %w`, err)} + } + } + if v, ok := _u.mutation.Language(); ok { + if err := epici18nmappings.LanguageValidator(v); err != nil { + return &ValidationError{Name: "language", err: fmt.Errorf(`ent: validator failed for field "EpicI18NMappings.language": %w`, err)} + } + } + if v, ok := _u.mutation.Value(); ok { + if err := epici18nmappings.ValueValidator(v); err != nil { + return &ValidationError{Name: "value", err: fmt.Errorf(`ent: validator failed for field "EpicI18NMappings.value": %w`, err)} + } + } + if v, ok := _u.mutation.Category(); ok { + if err := epici18nmappings.CategoryValidator(v); err != nil { + return &ValidationError{Name: "category", err: fmt.Errorf(`ent: validator failed for field "EpicI18NMappings.category": %w`, err)} + } + } + if v, ok := _u.mutation.Creator(); ok { + if err := epici18nmappings.CreatorValidator(v); err != nil { + return &ValidationError{Name: "creator", err: fmt.Errorf(`ent: validator failed for field "EpicI18NMappings.creator": %w`, err)} + } + } + if v, ok := _u.mutation.Updater(); ok { + if err := epici18nmappings.UpdaterValidator(v); err != nil { + return &ValidationError{Name: "updater", err: fmt.Errorf(`ent: validator failed for field "EpicI18NMappings.updater": %w`, err)} + } + } + if v, ok := _u.mutation.Code(); ok { + if err := epici18nmappings.CodeValidator(v); err != nil { + return &ValidationError{Name: "code", err: fmt.Errorf(`ent: validator failed for field "EpicI18NMappings.code": %w`, err)} + } + } + return nil +} + +func (_u *EpicI18NMappingsUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(epici18nmappings.Table, epici18nmappings.Columns, sqlgraph.NewFieldSpec(epici18nmappings.FieldID, field.TypeInt64)) + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.KeyName(); ok { + _spec.SetField(epici18nmappings.FieldKeyName, field.TypeString, value) + } + if value, ok := _u.mutation.Language(); ok { + _spec.SetField(epici18nmappings.FieldLanguage, field.TypeString, value) + } + if value, ok := _u.mutation.Value(); ok { + _spec.SetField(epici18nmappings.FieldValue, field.TypeString, value) + } + if value, ok := _u.mutation.Category(); ok { + _spec.SetField(epici18nmappings.FieldCategory, field.TypeString, value) + } + if value, ok := _u.mutation.Status(); ok { + _spec.SetField(epici18nmappings.FieldStatus, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedStatus(); ok { + _spec.AddField(epici18nmappings.FieldStatus, field.TypeInt, value) + } + if value, ok := _u.mutation.Creator(); ok { + _spec.SetField(epici18nmappings.FieldCreator, field.TypeString, value) + } + if value, ok := _u.mutation.CreateTime(); ok { + _spec.SetField(epici18nmappings.FieldCreateTime, field.TypeTime, value) + } + if _u.mutation.CreateTimeCleared() { + _spec.ClearField(epici18nmappings.FieldCreateTime, field.TypeTime) + } + if value, ok := _u.mutation.Updater(); ok { + _spec.SetField(epici18nmappings.FieldUpdater, field.TypeString, value) + } + if value, ok := _u.mutation.UpdateTime(); ok { + _spec.SetField(epici18nmappings.FieldUpdateTime, field.TypeTime, value) + } + if _u.mutation.UpdateTimeCleared() { + _spec.ClearField(epici18nmappings.FieldUpdateTime, field.TypeTime) + } + if value, ok := _u.mutation.Deleted(); ok { + _spec.SetField(epici18nmappings.FieldDeleted, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedDeleted(); ok { + _spec.AddField(epici18nmappings.FieldDeleted, field.TypeInt, value) + } + if value, ok := _u.mutation.Code(); ok { + _spec.SetField(epici18nmappings.FieldCode, field.TypeString, value) + } + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{epici18nmappings.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// EpicI18NMappingsUpdateOne is the builder for updating a single EpicI18NMappings entity. +type EpicI18NMappingsUpdateOne struct { + config + fields []string + hooks []Hook + mutation *EpicI18NMappingsMutation +} + +// SetKeyName sets the "key_name" field. +func (_u *EpicI18NMappingsUpdateOne) SetKeyName(v string) *EpicI18NMappingsUpdateOne { + _u.mutation.SetKeyName(v) + return _u +} + +// SetNillableKeyName sets the "key_name" field if the given value is not nil. +func (_u *EpicI18NMappingsUpdateOne) SetNillableKeyName(v *string) *EpicI18NMappingsUpdateOne { + if v != nil { + _u.SetKeyName(*v) + } + return _u +} + +// SetLanguage sets the "language" field. +func (_u *EpicI18NMappingsUpdateOne) SetLanguage(v string) *EpicI18NMappingsUpdateOne { + _u.mutation.SetLanguage(v) + return _u +} + +// SetNillableLanguage sets the "language" field if the given value is not nil. +func (_u *EpicI18NMappingsUpdateOne) SetNillableLanguage(v *string) *EpicI18NMappingsUpdateOne { + if v != nil { + _u.SetLanguage(*v) + } + return _u +} + +// SetValue sets the "value" field. +func (_u *EpicI18NMappingsUpdateOne) SetValue(v string) *EpicI18NMappingsUpdateOne { + _u.mutation.SetValue(v) + return _u +} + +// SetNillableValue sets the "value" field if the given value is not nil. +func (_u *EpicI18NMappingsUpdateOne) SetNillableValue(v *string) *EpicI18NMappingsUpdateOne { + if v != nil { + _u.SetValue(*v) + } + return _u +} + +// SetCategory sets the "category" field. +func (_u *EpicI18NMappingsUpdateOne) SetCategory(v string) *EpicI18NMappingsUpdateOne { + _u.mutation.SetCategory(v) + return _u +} + +// SetNillableCategory sets the "category" field if the given value is not nil. +func (_u *EpicI18NMappingsUpdateOne) SetNillableCategory(v *string) *EpicI18NMappingsUpdateOne { + if v != nil { + _u.SetCategory(*v) + } + return _u +} + +// SetStatus sets the "status" field. +func (_u *EpicI18NMappingsUpdateOne) SetStatus(v int) *EpicI18NMappingsUpdateOne { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_u *EpicI18NMappingsUpdateOne) SetNillableStatus(v *int) *EpicI18NMappingsUpdateOne { + if v != nil { + _u.SetStatus(*v) + } + return _u +} + +// AddStatus adds value to the "status" field. +func (_u *EpicI18NMappingsUpdateOne) AddStatus(v int) *EpicI18NMappingsUpdateOne { + _u.mutation.AddStatus(v) + return _u +} + +// SetCreator sets the "creator" field. +func (_u *EpicI18NMappingsUpdateOne) SetCreator(v string) *EpicI18NMappingsUpdateOne { + _u.mutation.SetCreator(v) + return _u +} + +// SetNillableCreator sets the "creator" field if the given value is not nil. +func (_u *EpicI18NMappingsUpdateOne) SetNillableCreator(v *string) *EpicI18NMappingsUpdateOne { + if v != nil { + _u.SetCreator(*v) + } + return _u +} + +// SetCreateTime sets the "create_time" field. +func (_u *EpicI18NMappingsUpdateOne) SetCreateTime(v time.Time) *EpicI18NMappingsUpdateOne { + _u.mutation.SetCreateTime(v) + return _u +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (_u *EpicI18NMappingsUpdateOne) SetNillableCreateTime(v *time.Time) *EpicI18NMappingsUpdateOne { + if v != nil { + _u.SetCreateTime(*v) + } + return _u +} + +// ClearCreateTime clears the value of the "create_time" field. +func (_u *EpicI18NMappingsUpdateOne) ClearCreateTime() *EpicI18NMappingsUpdateOne { + _u.mutation.ClearCreateTime() + return _u +} + +// SetUpdater sets the "updater" field. +func (_u *EpicI18NMappingsUpdateOne) SetUpdater(v string) *EpicI18NMappingsUpdateOne { + _u.mutation.SetUpdater(v) + return _u +} + +// SetNillableUpdater sets the "updater" field if the given value is not nil. +func (_u *EpicI18NMappingsUpdateOne) SetNillableUpdater(v *string) *EpicI18NMappingsUpdateOne { + if v != nil { + _u.SetUpdater(*v) + } + return _u +} + +// SetUpdateTime sets the "update_time" field. +func (_u *EpicI18NMappingsUpdateOne) SetUpdateTime(v time.Time) *EpicI18NMappingsUpdateOne { + _u.mutation.SetUpdateTime(v) + return _u +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (_u *EpicI18NMappingsUpdateOne) SetNillableUpdateTime(v *time.Time) *EpicI18NMappingsUpdateOne { + if v != nil { + _u.SetUpdateTime(*v) + } + return _u +} + +// ClearUpdateTime clears the value of the "update_time" field. +func (_u *EpicI18NMappingsUpdateOne) ClearUpdateTime() *EpicI18NMappingsUpdateOne { + _u.mutation.ClearUpdateTime() + return _u +} + +// SetDeleted sets the "deleted" field. +func (_u *EpicI18NMappingsUpdateOne) SetDeleted(v int) *EpicI18NMappingsUpdateOne { + _u.mutation.ResetDeleted() + _u.mutation.SetDeleted(v) + return _u +} + +// SetNillableDeleted sets the "deleted" field if the given value is not nil. +func (_u *EpicI18NMappingsUpdateOne) SetNillableDeleted(v *int) *EpicI18NMappingsUpdateOne { + if v != nil { + _u.SetDeleted(*v) + } + return _u +} + +// AddDeleted adds value to the "deleted" field. +func (_u *EpicI18NMappingsUpdateOne) AddDeleted(v int) *EpicI18NMappingsUpdateOne { + _u.mutation.AddDeleted(v) + return _u +} + +// SetCode sets the "code" field. +func (_u *EpicI18NMappingsUpdateOne) SetCode(v string) *EpicI18NMappingsUpdateOne { + _u.mutation.SetCode(v) + return _u +} + +// SetNillableCode sets the "code" field if the given value is not nil. +func (_u *EpicI18NMappingsUpdateOne) SetNillableCode(v *string) *EpicI18NMappingsUpdateOne { + if v != nil { + _u.SetCode(*v) + } + return _u +} + +// Mutation returns the EpicI18NMappingsMutation object of the builder. +func (_u *EpicI18NMappingsUpdateOne) Mutation() *EpicI18NMappingsMutation { + return _u.mutation +} + +// Where appends a list predicates to the EpicI18NMappingsUpdate builder. +func (_u *EpicI18NMappingsUpdateOne) Where(ps ...predicate.EpicI18NMappings) *EpicI18NMappingsUpdateOne { + _u.mutation.Where(ps...) + return _u +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (_u *EpicI18NMappingsUpdateOne) Select(field string, fields ...string) *EpicI18NMappingsUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated EpicI18NMappings entity. +func (_u *EpicI18NMappingsUpdateOne) Save(ctx context.Context) (*EpicI18NMappings, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *EpicI18NMappingsUpdateOne) SaveX(ctx context.Context) *EpicI18NMappings { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *EpicI18NMappingsUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *EpicI18NMappingsUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *EpicI18NMappingsUpdateOne) check() error { + if v, ok := _u.mutation.KeyName(); ok { + if err := epici18nmappings.KeyNameValidator(v); err != nil { + return &ValidationError{Name: "key_name", err: fmt.Errorf(`ent: validator failed for field "EpicI18NMappings.key_name": %w`, err)} + } + } + if v, ok := _u.mutation.Language(); ok { + if err := epici18nmappings.LanguageValidator(v); err != nil { + return &ValidationError{Name: "language", err: fmt.Errorf(`ent: validator failed for field "EpicI18NMappings.language": %w`, err)} + } + } + if v, ok := _u.mutation.Value(); ok { + if err := epici18nmappings.ValueValidator(v); err != nil { + return &ValidationError{Name: "value", err: fmt.Errorf(`ent: validator failed for field "EpicI18NMappings.value": %w`, err)} + } + } + if v, ok := _u.mutation.Category(); ok { + if err := epici18nmappings.CategoryValidator(v); err != nil { + return &ValidationError{Name: "category", err: fmt.Errorf(`ent: validator failed for field "EpicI18NMappings.category": %w`, err)} + } + } + if v, ok := _u.mutation.Creator(); ok { + if err := epici18nmappings.CreatorValidator(v); err != nil { + return &ValidationError{Name: "creator", err: fmt.Errorf(`ent: validator failed for field "EpicI18NMappings.creator": %w`, err)} + } + } + if v, ok := _u.mutation.Updater(); ok { + if err := epici18nmappings.UpdaterValidator(v); err != nil { + return &ValidationError{Name: "updater", err: fmt.Errorf(`ent: validator failed for field "EpicI18NMappings.updater": %w`, err)} + } + } + if v, ok := _u.mutation.Code(); ok { + if err := epici18nmappings.CodeValidator(v); err != nil { + return &ValidationError{Name: "code", err: fmt.Errorf(`ent: validator failed for field "EpicI18NMappings.code": %w`, err)} + } + } + return nil +} + +func (_u *EpicI18NMappingsUpdateOne) sqlSave(ctx context.Context) (_node *EpicI18NMappings, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(epici18nmappings.Table, epici18nmappings.Columns, sqlgraph.NewFieldSpec(epici18nmappings.FieldID, field.TypeInt64)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "EpicI18NMappings.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := _u.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, epici18nmappings.FieldID) + for _, f := range fields { + if !epici18nmappings.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != epici18nmappings.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.KeyName(); ok { + _spec.SetField(epici18nmappings.FieldKeyName, field.TypeString, value) + } + if value, ok := _u.mutation.Language(); ok { + _spec.SetField(epici18nmappings.FieldLanguage, field.TypeString, value) + } + if value, ok := _u.mutation.Value(); ok { + _spec.SetField(epici18nmappings.FieldValue, field.TypeString, value) + } + if value, ok := _u.mutation.Category(); ok { + _spec.SetField(epici18nmappings.FieldCategory, field.TypeString, value) + } + if value, ok := _u.mutation.Status(); ok { + _spec.SetField(epici18nmappings.FieldStatus, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedStatus(); ok { + _spec.AddField(epici18nmappings.FieldStatus, field.TypeInt, value) + } + if value, ok := _u.mutation.Creator(); ok { + _spec.SetField(epici18nmappings.FieldCreator, field.TypeString, value) + } + if value, ok := _u.mutation.CreateTime(); ok { + _spec.SetField(epici18nmappings.FieldCreateTime, field.TypeTime, value) + } + if _u.mutation.CreateTimeCleared() { + _spec.ClearField(epici18nmappings.FieldCreateTime, field.TypeTime) + } + if value, ok := _u.mutation.Updater(); ok { + _spec.SetField(epici18nmappings.FieldUpdater, field.TypeString, value) + } + if value, ok := _u.mutation.UpdateTime(); ok { + _spec.SetField(epici18nmappings.FieldUpdateTime, field.TypeTime, value) + } + if _u.mutation.UpdateTimeCleared() { + _spec.ClearField(epici18nmappings.FieldUpdateTime, field.TypeTime) + } + if value, ok := _u.mutation.Deleted(); ok { + _spec.SetField(epici18nmappings.FieldDeleted, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedDeleted(); ok { + _spec.AddField(epici18nmappings.FieldDeleted, field.TypeInt, value) + } + if value, ok := _u.mutation.Code(); ok { + _spec.SetField(epici18nmappings.FieldCode, field.TypeString, value) + } + _node = &EpicI18NMappings{config: _u.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{epici18nmappings.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} diff --git a/internal/ent/fribbleheroset.go b/internal/ent/fribbleheroset.go new file mode 100644 index 0000000..86d4431 --- /dev/null +++ b/internal/ent/fribbleheroset.go @@ -0,0 +1,202 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "epic-ent/internal/ent/fribbleheroset" + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// FribbleHeroSet is the model entity for the FribbleHeroSet schema. +type FribbleHeroSet struct { + config `json:"-"` + // ID of the ent. + ID int64 `json:"id,omitempty"` + // HeroCode holds the value of the "hero_code" field. + HeroCode string `json:"hero_code,omitempty"` + // JSONContent holds the value of the "json_content" field. + JSONContent string `json:"json_content,omitempty"` + // HeroName holds the value of the "hero_name" field. + HeroName string `json:"hero_name,omitempty"` + // Creator holds the value of the "creator" field. + Creator string `json:"creator,omitempty"` + // CreateTime holds the value of the "create_time" field. + CreateTime *time.Time `json:"create_time,omitempty"` + // Updater holds the value of the "updater" field. + Updater string `json:"updater,omitempty"` + // UpdateTime holds the value of the "update_time" field. + UpdateTime *time.Time `json:"update_time,omitempty"` + // Deleted holds the value of the "deleted" field. + Deleted bool `json:"deleted,omitempty"` + // SuccessGet holds the value of the "success_get" field. + SuccessGet int `json:"success_get,omitempty"` + selectValues sql.SelectValues +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*FribbleHeroSet) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case fribbleheroset.FieldDeleted: + values[i] = new(sql.NullBool) + case fribbleheroset.FieldID, fribbleheroset.FieldSuccessGet: + values[i] = new(sql.NullInt64) + case fribbleheroset.FieldHeroCode, fribbleheroset.FieldJSONContent, fribbleheroset.FieldHeroName, fribbleheroset.FieldCreator, fribbleheroset.FieldUpdater: + values[i] = new(sql.NullString) + case fribbleheroset.FieldCreateTime, fribbleheroset.FieldUpdateTime: + values[i] = new(sql.NullTime) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the FribbleHeroSet fields. +func (_m *FribbleHeroSet) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case fribbleheroset.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + _m.ID = int64(value.Int64) + case fribbleheroset.FieldHeroCode: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field hero_code", values[i]) + } else if value.Valid { + _m.HeroCode = value.String + } + case fribbleheroset.FieldJSONContent: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field json_content", values[i]) + } else if value.Valid { + _m.JSONContent = value.String + } + case fribbleheroset.FieldHeroName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field hero_name", values[i]) + } else if value.Valid { + _m.HeroName = value.String + } + case fribbleheroset.FieldCreator: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field creator", values[i]) + } else if value.Valid { + _m.Creator = value.String + } + case fribbleheroset.FieldCreateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field create_time", values[i]) + } else if value.Valid { + _m.CreateTime = new(time.Time) + *_m.CreateTime = value.Time + } + case fribbleheroset.FieldUpdater: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field updater", values[i]) + } else if value.Valid { + _m.Updater = value.String + } + case fribbleheroset.FieldUpdateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field update_time", values[i]) + } else if value.Valid { + _m.UpdateTime = new(time.Time) + *_m.UpdateTime = value.Time + } + case fribbleheroset.FieldDeleted: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field deleted", values[i]) + } else if value.Valid { + _m.Deleted = value.Bool + } + case fribbleheroset.FieldSuccessGet: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field success_get", values[i]) + } else if value.Valid { + _m.SuccessGet = int(value.Int64) + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the FribbleHeroSet. +// This includes values selected through modifiers, order, etc. +func (_m *FribbleHeroSet) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// Update returns a builder for updating this FribbleHeroSet. +// Note that you need to call FribbleHeroSet.Unwrap() before calling this method if this FribbleHeroSet +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *FribbleHeroSet) Update() *FribbleHeroSetUpdateOne { + return NewFribbleHeroSetClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the FribbleHeroSet entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (_m *FribbleHeroSet) Unwrap() *FribbleHeroSet { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("ent: FribbleHeroSet is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *FribbleHeroSet) String() string { + var builder strings.Builder + builder.WriteString("FribbleHeroSet(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("hero_code=") + builder.WriteString(_m.HeroCode) + builder.WriteString(", ") + builder.WriteString("json_content=") + builder.WriteString(_m.JSONContent) + builder.WriteString(", ") + builder.WriteString("hero_name=") + builder.WriteString(_m.HeroName) + builder.WriteString(", ") + builder.WriteString("creator=") + builder.WriteString(_m.Creator) + builder.WriteString(", ") + if v := _m.CreateTime; v != nil { + builder.WriteString("create_time=") + builder.WriteString(v.Format(time.ANSIC)) + } + builder.WriteString(", ") + builder.WriteString("updater=") + builder.WriteString(_m.Updater) + builder.WriteString(", ") + if v := _m.UpdateTime; v != nil { + builder.WriteString("update_time=") + builder.WriteString(v.Format(time.ANSIC)) + } + builder.WriteString(", ") + builder.WriteString("deleted=") + builder.WriteString(fmt.Sprintf("%v", _m.Deleted)) + builder.WriteString(", ") + builder.WriteString("success_get=") + builder.WriteString(fmt.Sprintf("%v", _m.SuccessGet)) + builder.WriteByte(')') + return builder.String() +} + +// FribbleHeroSets is a parsable slice of FribbleHeroSet. +type FribbleHeroSets []*FribbleHeroSet diff --git a/internal/ent/fribbleheroset/fribbleheroset.go b/internal/ent/fribbleheroset/fribbleheroset.go new file mode 100644 index 0000000..4e5de04 --- /dev/null +++ b/internal/ent/fribbleheroset/fribbleheroset.go @@ -0,0 +1,124 @@ +// Code generated by ent, DO NOT EDIT. + +package fribbleheroset + +import ( + "entgo.io/ent/dialect/sql" +) + +const ( + // Label holds the string label denoting the fribbleheroset type in the database. + Label = "fribble_hero_set" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldHeroCode holds the string denoting the hero_code field in the database. + FieldHeroCode = "hero_code" + // FieldJSONContent holds the string denoting the json_content field in the database. + FieldJSONContent = "json_content" + // FieldHeroName holds the string denoting the hero_name field in the database. + FieldHeroName = "hero_name" + // FieldCreator holds the string denoting the creator field in the database. + FieldCreator = "creator" + // FieldCreateTime holds the string denoting the create_time field in the database. + FieldCreateTime = "create_time" + // FieldUpdater holds the string denoting the updater field in the database. + FieldUpdater = "updater" + // FieldUpdateTime holds the string denoting the update_time field in the database. + FieldUpdateTime = "update_time" + // FieldDeleted holds the string denoting the deleted field in the database. + FieldDeleted = "deleted" + // FieldSuccessGet holds the string denoting the success_get field in the database. + FieldSuccessGet = "success_get" + // Table holds the table name of the fribbleheroset in the database. + Table = "fribble_hero_sets" +) + +// Columns holds all SQL columns for fribbleheroset fields. +var Columns = []string{ + FieldID, + FieldHeroCode, + FieldJSONContent, + FieldHeroName, + FieldCreator, + FieldCreateTime, + FieldUpdater, + FieldUpdateTime, + FieldDeleted, + FieldSuccessGet, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // HeroCodeValidator is a validator for the "hero_code" field. It is called by the builders before save. + HeroCodeValidator func(string) error + // JSONContentValidator is a validator for the "json_content" field. It is called by the builders before save. + JSONContentValidator func(string) error + // HeroNameValidator is a validator for the "hero_name" field. It is called by the builders before save. + HeroNameValidator func(string) error + // CreatorValidator is a validator for the "creator" field. It is called by the builders before save. + CreatorValidator func(string) error + // UpdaterValidator is a validator for the "updater" field. It is called by the builders before save. + UpdaterValidator func(string) error +) + +// OrderOption defines the ordering options for the FribbleHeroSet queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByHeroCode orders the results by the hero_code field. +func ByHeroCode(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldHeroCode, opts...).ToFunc() +} + +// ByJSONContent orders the results by the json_content field. +func ByJSONContent(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldJSONContent, opts...).ToFunc() +} + +// ByHeroName orders the results by the hero_name field. +func ByHeroName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldHeroName, opts...).ToFunc() +} + +// ByCreator orders the results by the creator field. +func ByCreator(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreator, opts...).ToFunc() +} + +// ByCreateTime orders the results by the create_time field. +func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateTime, opts...).ToFunc() +} + +// ByUpdater orders the results by the updater field. +func ByUpdater(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdater, opts...).ToFunc() +} + +// ByUpdateTime orders the results by the update_time field. +func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() +} + +// ByDeleted orders the results by the deleted field. +func ByDeleted(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeleted, opts...).ToFunc() +} + +// BySuccessGet orders the results by the success_get field. +func BySuccessGet(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSuccessGet, opts...).ToFunc() +} diff --git a/internal/ent/fribbleheroset/where.go b/internal/ent/fribbleheroset/where.go new file mode 100644 index 0000000..dcda11e --- /dev/null +++ b/internal/ent/fribbleheroset/where.go @@ -0,0 +1,590 @@ +// Code generated by ent, DO NOT EDIT. + +package fribbleheroset + +import ( + "epic-ent/internal/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" +) + +// ID filters vertices based on their ID field. +func ID(id int64) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int64) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int64) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int64) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int64) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int64) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int64) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int64) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int64) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldLTE(FieldID, id)) +} + +// HeroCode applies equality check predicate on the "hero_code" field. It's identical to HeroCodeEQ. +func HeroCode(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldEQ(FieldHeroCode, v)) +} + +// JSONContent applies equality check predicate on the "json_content" field. It's identical to JSONContentEQ. +func JSONContent(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldEQ(FieldJSONContent, v)) +} + +// HeroName applies equality check predicate on the "hero_name" field. It's identical to HeroNameEQ. +func HeroName(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldEQ(FieldHeroName, v)) +} + +// Creator applies equality check predicate on the "creator" field. It's identical to CreatorEQ. +func Creator(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldEQ(FieldCreator, v)) +} + +// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. +func CreateTime(v time.Time) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldEQ(FieldCreateTime, v)) +} + +// Updater applies equality check predicate on the "updater" field. It's identical to UpdaterEQ. +func Updater(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldEQ(FieldUpdater, v)) +} + +// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. +func UpdateTime(v time.Time) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldEQ(FieldUpdateTime, v)) +} + +// Deleted applies equality check predicate on the "deleted" field. It's identical to DeletedEQ. +func Deleted(v bool) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldEQ(FieldDeleted, v)) +} + +// SuccessGet applies equality check predicate on the "success_get" field. It's identical to SuccessGetEQ. +func SuccessGet(v int) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldEQ(FieldSuccessGet, v)) +} + +// HeroCodeEQ applies the EQ predicate on the "hero_code" field. +func HeroCodeEQ(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldEQ(FieldHeroCode, v)) +} + +// HeroCodeNEQ applies the NEQ predicate on the "hero_code" field. +func HeroCodeNEQ(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldNEQ(FieldHeroCode, v)) +} + +// HeroCodeIn applies the In predicate on the "hero_code" field. +func HeroCodeIn(vs ...string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldIn(FieldHeroCode, vs...)) +} + +// HeroCodeNotIn applies the NotIn predicate on the "hero_code" field. +func HeroCodeNotIn(vs ...string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldNotIn(FieldHeroCode, vs...)) +} + +// HeroCodeGT applies the GT predicate on the "hero_code" field. +func HeroCodeGT(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldGT(FieldHeroCode, v)) +} + +// HeroCodeGTE applies the GTE predicate on the "hero_code" field. +func HeroCodeGTE(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldGTE(FieldHeroCode, v)) +} + +// HeroCodeLT applies the LT predicate on the "hero_code" field. +func HeroCodeLT(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldLT(FieldHeroCode, v)) +} + +// HeroCodeLTE applies the LTE predicate on the "hero_code" field. +func HeroCodeLTE(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldLTE(FieldHeroCode, v)) +} + +// HeroCodeContains applies the Contains predicate on the "hero_code" field. +func HeroCodeContains(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldContains(FieldHeroCode, v)) +} + +// HeroCodeHasPrefix applies the HasPrefix predicate on the "hero_code" field. +func HeroCodeHasPrefix(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldHasPrefix(FieldHeroCode, v)) +} + +// HeroCodeHasSuffix applies the HasSuffix predicate on the "hero_code" field. +func HeroCodeHasSuffix(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldHasSuffix(FieldHeroCode, v)) +} + +// HeroCodeEqualFold applies the EqualFold predicate on the "hero_code" field. +func HeroCodeEqualFold(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldEqualFold(FieldHeroCode, v)) +} + +// HeroCodeContainsFold applies the ContainsFold predicate on the "hero_code" field. +func HeroCodeContainsFold(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldContainsFold(FieldHeroCode, v)) +} + +// JSONContentEQ applies the EQ predicate on the "json_content" field. +func JSONContentEQ(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldEQ(FieldJSONContent, v)) +} + +// JSONContentNEQ applies the NEQ predicate on the "json_content" field. +func JSONContentNEQ(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldNEQ(FieldJSONContent, v)) +} + +// JSONContentIn applies the In predicate on the "json_content" field. +func JSONContentIn(vs ...string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldIn(FieldJSONContent, vs...)) +} + +// JSONContentNotIn applies the NotIn predicate on the "json_content" field. +func JSONContentNotIn(vs ...string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldNotIn(FieldJSONContent, vs...)) +} + +// JSONContentGT applies the GT predicate on the "json_content" field. +func JSONContentGT(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldGT(FieldJSONContent, v)) +} + +// JSONContentGTE applies the GTE predicate on the "json_content" field. +func JSONContentGTE(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldGTE(FieldJSONContent, v)) +} + +// JSONContentLT applies the LT predicate on the "json_content" field. +func JSONContentLT(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldLT(FieldJSONContent, v)) +} + +// JSONContentLTE applies the LTE predicate on the "json_content" field. +func JSONContentLTE(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldLTE(FieldJSONContent, v)) +} + +// JSONContentContains applies the Contains predicate on the "json_content" field. +func JSONContentContains(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldContains(FieldJSONContent, v)) +} + +// JSONContentHasPrefix applies the HasPrefix predicate on the "json_content" field. +func JSONContentHasPrefix(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldHasPrefix(FieldJSONContent, v)) +} + +// JSONContentHasSuffix applies the HasSuffix predicate on the "json_content" field. +func JSONContentHasSuffix(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldHasSuffix(FieldJSONContent, v)) +} + +// JSONContentEqualFold applies the EqualFold predicate on the "json_content" field. +func JSONContentEqualFold(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldEqualFold(FieldJSONContent, v)) +} + +// JSONContentContainsFold applies the ContainsFold predicate on the "json_content" field. +func JSONContentContainsFold(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldContainsFold(FieldJSONContent, v)) +} + +// HeroNameEQ applies the EQ predicate on the "hero_name" field. +func HeroNameEQ(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldEQ(FieldHeroName, v)) +} + +// HeroNameNEQ applies the NEQ predicate on the "hero_name" field. +func HeroNameNEQ(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldNEQ(FieldHeroName, v)) +} + +// HeroNameIn applies the In predicate on the "hero_name" field. +func HeroNameIn(vs ...string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldIn(FieldHeroName, vs...)) +} + +// HeroNameNotIn applies the NotIn predicate on the "hero_name" field. +func HeroNameNotIn(vs ...string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldNotIn(FieldHeroName, vs...)) +} + +// HeroNameGT applies the GT predicate on the "hero_name" field. +func HeroNameGT(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldGT(FieldHeroName, v)) +} + +// HeroNameGTE applies the GTE predicate on the "hero_name" field. +func HeroNameGTE(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldGTE(FieldHeroName, v)) +} + +// HeroNameLT applies the LT predicate on the "hero_name" field. +func HeroNameLT(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldLT(FieldHeroName, v)) +} + +// HeroNameLTE applies the LTE predicate on the "hero_name" field. +func HeroNameLTE(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldLTE(FieldHeroName, v)) +} + +// HeroNameContains applies the Contains predicate on the "hero_name" field. +func HeroNameContains(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldContains(FieldHeroName, v)) +} + +// HeroNameHasPrefix applies the HasPrefix predicate on the "hero_name" field. +func HeroNameHasPrefix(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldHasPrefix(FieldHeroName, v)) +} + +// HeroNameHasSuffix applies the HasSuffix predicate on the "hero_name" field. +func HeroNameHasSuffix(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldHasSuffix(FieldHeroName, v)) +} + +// HeroNameEqualFold applies the EqualFold predicate on the "hero_name" field. +func HeroNameEqualFold(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldEqualFold(FieldHeroName, v)) +} + +// HeroNameContainsFold applies the ContainsFold predicate on the "hero_name" field. +func HeroNameContainsFold(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldContainsFold(FieldHeroName, v)) +} + +// CreatorEQ applies the EQ predicate on the "creator" field. +func CreatorEQ(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldEQ(FieldCreator, v)) +} + +// CreatorNEQ applies the NEQ predicate on the "creator" field. +func CreatorNEQ(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldNEQ(FieldCreator, v)) +} + +// CreatorIn applies the In predicate on the "creator" field. +func CreatorIn(vs ...string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldIn(FieldCreator, vs...)) +} + +// CreatorNotIn applies the NotIn predicate on the "creator" field. +func CreatorNotIn(vs ...string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldNotIn(FieldCreator, vs...)) +} + +// CreatorGT applies the GT predicate on the "creator" field. +func CreatorGT(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldGT(FieldCreator, v)) +} + +// CreatorGTE applies the GTE predicate on the "creator" field. +func CreatorGTE(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldGTE(FieldCreator, v)) +} + +// CreatorLT applies the LT predicate on the "creator" field. +func CreatorLT(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldLT(FieldCreator, v)) +} + +// CreatorLTE applies the LTE predicate on the "creator" field. +func CreatorLTE(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldLTE(FieldCreator, v)) +} + +// CreatorContains applies the Contains predicate on the "creator" field. +func CreatorContains(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldContains(FieldCreator, v)) +} + +// CreatorHasPrefix applies the HasPrefix predicate on the "creator" field. +func CreatorHasPrefix(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldHasPrefix(FieldCreator, v)) +} + +// CreatorHasSuffix applies the HasSuffix predicate on the "creator" field. +func CreatorHasSuffix(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldHasSuffix(FieldCreator, v)) +} + +// CreatorEqualFold applies the EqualFold predicate on the "creator" field. +func CreatorEqualFold(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldEqualFold(FieldCreator, v)) +} + +// CreatorContainsFold applies the ContainsFold predicate on the "creator" field. +func CreatorContainsFold(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldContainsFold(FieldCreator, v)) +} + +// CreateTimeEQ applies the EQ predicate on the "create_time" field. +func CreateTimeEQ(v time.Time) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldEQ(FieldCreateTime, v)) +} + +// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. +func CreateTimeNEQ(v time.Time) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldNEQ(FieldCreateTime, v)) +} + +// CreateTimeIn applies the In predicate on the "create_time" field. +func CreateTimeIn(vs ...time.Time) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldIn(FieldCreateTime, vs...)) +} + +// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. +func CreateTimeNotIn(vs ...time.Time) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldNotIn(FieldCreateTime, vs...)) +} + +// CreateTimeGT applies the GT predicate on the "create_time" field. +func CreateTimeGT(v time.Time) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldGT(FieldCreateTime, v)) +} + +// CreateTimeGTE applies the GTE predicate on the "create_time" field. +func CreateTimeGTE(v time.Time) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldGTE(FieldCreateTime, v)) +} + +// CreateTimeLT applies the LT predicate on the "create_time" field. +func CreateTimeLT(v time.Time) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldLT(FieldCreateTime, v)) +} + +// CreateTimeLTE applies the LTE predicate on the "create_time" field. +func CreateTimeLTE(v time.Time) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldLTE(FieldCreateTime, v)) +} + +// CreateTimeIsNil applies the IsNil predicate on the "create_time" field. +func CreateTimeIsNil() predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldIsNull(FieldCreateTime)) +} + +// CreateTimeNotNil applies the NotNil predicate on the "create_time" field. +func CreateTimeNotNil() predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldNotNull(FieldCreateTime)) +} + +// UpdaterEQ applies the EQ predicate on the "updater" field. +func UpdaterEQ(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldEQ(FieldUpdater, v)) +} + +// UpdaterNEQ applies the NEQ predicate on the "updater" field. +func UpdaterNEQ(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldNEQ(FieldUpdater, v)) +} + +// UpdaterIn applies the In predicate on the "updater" field. +func UpdaterIn(vs ...string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldIn(FieldUpdater, vs...)) +} + +// UpdaterNotIn applies the NotIn predicate on the "updater" field. +func UpdaterNotIn(vs ...string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldNotIn(FieldUpdater, vs...)) +} + +// UpdaterGT applies the GT predicate on the "updater" field. +func UpdaterGT(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldGT(FieldUpdater, v)) +} + +// UpdaterGTE applies the GTE predicate on the "updater" field. +func UpdaterGTE(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldGTE(FieldUpdater, v)) +} + +// UpdaterLT applies the LT predicate on the "updater" field. +func UpdaterLT(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldLT(FieldUpdater, v)) +} + +// UpdaterLTE applies the LTE predicate on the "updater" field. +func UpdaterLTE(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldLTE(FieldUpdater, v)) +} + +// UpdaterContains applies the Contains predicate on the "updater" field. +func UpdaterContains(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldContains(FieldUpdater, v)) +} + +// UpdaterHasPrefix applies the HasPrefix predicate on the "updater" field. +func UpdaterHasPrefix(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldHasPrefix(FieldUpdater, v)) +} + +// UpdaterHasSuffix applies the HasSuffix predicate on the "updater" field. +func UpdaterHasSuffix(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldHasSuffix(FieldUpdater, v)) +} + +// UpdaterEqualFold applies the EqualFold predicate on the "updater" field. +func UpdaterEqualFold(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldEqualFold(FieldUpdater, v)) +} + +// UpdaterContainsFold applies the ContainsFold predicate on the "updater" field. +func UpdaterContainsFold(v string) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldContainsFold(FieldUpdater, v)) +} + +// UpdateTimeEQ applies the EQ predicate on the "update_time" field. +func UpdateTimeEQ(v time.Time) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldEQ(FieldUpdateTime, v)) +} + +// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. +func UpdateTimeNEQ(v time.Time) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldNEQ(FieldUpdateTime, v)) +} + +// UpdateTimeIn applies the In predicate on the "update_time" field. +func UpdateTimeIn(vs ...time.Time) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. +func UpdateTimeNotIn(vs ...time.Time) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldNotIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeGT applies the GT predicate on the "update_time" field. +func UpdateTimeGT(v time.Time) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldGT(FieldUpdateTime, v)) +} + +// UpdateTimeGTE applies the GTE predicate on the "update_time" field. +func UpdateTimeGTE(v time.Time) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldGTE(FieldUpdateTime, v)) +} + +// UpdateTimeLT applies the LT predicate on the "update_time" field. +func UpdateTimeLT(v time.Time) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldLT(FieldUpdateTime, v)) +} + +// UpdateTimeLTE applies the LTE predicate on the "update_time" field. +func UpdateTimeLTE(v time.Time) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldLTE(FieldUpdateTime, v)) +} + +// UpdateTimeIsNil applies the IsNil predicate on the "update_time" field. +func UpdateTimeIsNil() predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldIsNull(FieldUpdateTime)) +} + +// UpdateTimeNotNil applies the NotNil predicate on the "update_time" field. +func UpdateTimeNotNil() predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldNotNull(FieldUpdateTime)) +} + +// DeletedEQ applies the EQ predicate on the "deleted" field. +func DeletedEQ(v bool) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldEQ(FieldDeleted, v)) +} + +// DeletedNEQ applies the NEQ predicate on the "deleted" field. +func DeletedNEQ(v bool) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldNEQ(FieldDeleted, v)) +} + +// SuccessGetEQ applies the EQ predicate on the "success_get" field. +func SuccessGetEQ(v int) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldEQ(FieldSuccessGet, v)) +} + +// SuccessGetNEQ applies the NEQ predicate on the "success_get" field. +func SuccessGetNEQ(v int) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldNEQ(FieldSuccessGet, v)) +} + +// SuccessGetIn applies the In predicate on the "success_get" field. +func SuccessGetIn(vs ...int) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldIn(FieldSuccessGet, vs...)) +} + +// SuccessGetNotIn applies the NotIn predicate on the "success_get" field. +func SuccessGetNotIn(vs ...int) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldNotIn(FieldSuccessGet, vs...)) +} + +// SuccessGetGT applies the GT predicate on the "success_get" field. +func SuccessGetGT(v int) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldGT(FieldSuccessGet, v)) +} + +// SuccessGetGTE applies the GTE predicate on the "success_get" field. +func SuccessGetGTE(v int) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldGTE(FieldSuccessGet, v)) +} + +// SuccessGetLT applies the LT predicate on the "success_get" field. +func SuccessGetLT(v int) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldLT(FieldSuccessGet, v)) +} + +// SuccessGetLTE applies the LTE predicate on the "success_get" field. +func SuccessGetLTE(v int) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.FieldLTE(FieldSuccessGet, v)) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.FribbleHeroSet) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.FribbleHeroSet) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.FribbleHeroSet) predicate.FribbleHeroSet { + return predicate.FribbleHeroSet(sql.NotPredicates(p)) +} diff --git a/internal/ent/fribbleheroset_create.go b/internal/ent/fribbleheroset_create.go new file mode 100644 index 0000000..e97c040 --- /dev/null +++ b/internal/ent/fribbleheroset_create.go @@ -0,0 +1,335 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "epic-ent/internal/ent/fribbleheroset" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// FribbleHeroSetCreate is the builder for creating a FribbleHeroSet entity. +type FribbleHeroSetCreate struct { + config + mutation *FribbleHeroSetMutation + hooks []Hook +} + +// SetHeroCode sets the "hero_code" field. +func (_c *FribbleHeroSetCreate) SetHeroCode(v string) *FribbleHeroSetCreate { + _c.mutation.SetHeroCode(v) + return _c +} + +// SetJSONContent sets the "json_content" field. +func (_c *FribbleHeroSetCreate) SetJSONContent(v string) *FribbleHeroSetCreate { + _c.mutation.SetJSONContent(v) + return _c +} + +// SetHeroName sets the "hero_name" field. +func (_c *FribbleHeroSetCreate) SetHeroName(v string) *FribbleHeroSetCreate { + _c.mutation.SetHeroName(v) + return _c +} + +// SetCreator sets the "creator" field. +func (_c *FribbleHeroSetCreate) SetCreator(v string) *FribbleHeroSetCreate { + _c.mutation.SetCreator(v) + return _c +} + +// SetCreateTime sets the "create_time" field. +func (_c *FribbleHeroSetCreate) SetCreateTime(v time.Time) *FribbleHeroSetCreate { + _c.mutation.SetCreateTime(v) + return _c +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (_c *FribbleHeroSetCreate) SetNillableCreateTime(v *time.Time) *FribbleHeroSetCreate { + if v != nil { + _c.SetCreateTime(*v) + } + return _c +} + +// SetUpdater sets the "updater" field. +func (_c *FribbleHeroSetCreate) SetUpdater(v string) *FribbleHeroSetCreate { + _c.mutation.SetUpdater(v) + return _c +} + +// SetUpdateTime sets the "update_time" field. +func (_c *FribbleHeroSetCreate) SetUpdateTime(v time.Time) *FribbleHeroSetCreate { + _c.mutation.SetUpdateTime(v) + return _c +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (_c *FribbleHeroSetCreate) SetNillableUpdateTime(v *time.Time) *FribbleHeroSetCreate { + if v != nil { + _c.SetUpdateTime(*v) + } + return _c +} + +// SetDeleted sets the "deleted" field. +func (_c *FribbleHeroSetCreate) SetDeleted(v bool) *FribbleHeroSetCreate { + _c.mutation.SetDeleted(v) + return _c +} + +// SetSuccessGet sets the "success_get" field. +func (_c *FribbleHeroSetCreate) SetSuccessGet(v int) *FribbleHeroSetCreate { + _c.mutation.SetSuccessGet(v) + return _c +} + +// SetID sets the "id" field. +func (_c *FribbleHeroSetCreate) SetID(v int64) *FribbleHeroSetCreate { + _c.mutation.SetID(v) + return _c +} + +// Mutation returns the FribbleHeroSetMutation object of the builder. +func (_c *FribbleHeroSetCreate) Mutation() *FribbleHeroSetMutation { + return _c.mutation +} + +// Save creates the FribbleHeroSet in the database. +func (_c *FribbleHeroSetCreate) Save(ctx context.Context) (*FribbleHeroSet, error) { + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *FribbleHeroSetCreate) SaveX(ctx context.Context) *FribbleHeroSet { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *FribbleHeroSetCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *FribbleHeroSetCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *FribbleHeroSetCreate) check() error { + if _, ok := _c.mutation.HeroCode(); !ok { + return &ValidationError{Name: "hero_code", err: errors.New(`ent: missing required field "FribbleHeroSet.hero_code"`)} + } + if v, ok := _c.mutation.HeroCode(); ok { + if err := fribbleheroset.HeroCodeValidator(v); err != nil { + return &ValidationError{Name: "hero_code", err: fmt.Errorf(`ent: validator failed for field "FribbleHeroSet.hero_code": %w`, err)} + } + } + if _, ok := _c.mutation.JSONContent(); !ok { + return &ValidationError{Name: "json_content", err: errors.New(`ent: missing required field "FribbleHeroSet.json_content"`)} + } + if v, ok := _c.mutation.JSONContent(); ok { + if err := fribbleheroset.JSONContentValidator(v); err != nil { + return &ValidationError{Name: "json_content", err: fmt.Errorf(`ent: validator failed for field "FribbleHeroSet.json_content": %w`, err)} + } + } + if _, ok := _c.mutation.HeroName(); !ok { + return &ValidationError{Name: "hero_name", err: errors.New(`ent: missing required field "FribbleHeroSet.hero_name"`)} + } + if v, ok := _c.mutation.HeroName(); ok { + if err := fribbleheroset.HeroNameValidator(v); err != nil { + return &ValidationError{Name: "hero_name", err: fmt.Errorf(`ent: validator failed for field "FribbleHeroSet.hero_name": %w`, err)} + } + } + if _, ok := _c.mutation.Creator(); !ok { + return &ValidationError{Name: "creator", err: errors.New(`ent: missing required field "FribbleHeroSet.creator"`)} + } + if v, ok := _c.mutation.Creator(); ok { + if err := fribbleheroset.CreatorValidator(v); err != nil { + return &ValidationError{Name: "creator", err: fmt.Errorf(`ent: validator failed for field "FribbleHeroSet.creator": %w`, err)} + } + } + if _, ok := _c.mutation.Updater(); !ok { + return &ValidationError{Name: "updater", err: errors.New(`ent: missing required field "FribbleHeroSet.updater"`)} + } + if v, ok := _c.mutation.Updater(); ok { + if err := fribbleheroset.UpdaterValidator(v); err != nil { + return &ValidationError{Name: "updater", err: fmt.Errorf(`ent: validator failed for field "FribbleHeroSet.updater": %w`, err)} + } + } + if _, ok := _c.mutation.Deleted(); !ok { + return &ValidationError{Name: "deleted", err: errors.New(`ent: missing required field "FribbleHeroSet.deleted"`)} + } + if _, ok := _c.mutation.SuccessGet(); !ok { + return &ValidationError{Name: "success_get", err: errors.New(`ent: missing required field "FribbleHeroSet.success_get"`)} + } + return nil +} + +func (_c *FribbleHeroSetCreate) sqlSave(ctx context.Context) (*FribbleHeroSet, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != _node.ID { + id := _spec.ID.Value.(int64) + _node.ID = int64(id) + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *FribbleHeroSetCreate) createSpec() (*FribbleHeroSet, *sqlgraph.CreateSpec) { + var ( + _node = &FribbleHeroSet{config: _c.config} + _spec = sqlgraph.NewCreateSpec(fribbleheroset.Table, sqlgraph.NewFieldSpec(fribbleheroset.FieldID, field.TypeInt64)) + ) + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := _c.mutation.HeroCode(); ok { + _spec.SetField(fribbleheroset.FieldHeroCode, field.TypeString, value) + _node.HeroCode = value + } + if value, ok := _c.mutation.JSONContent(); ok { + _spec.SetField(fribbleheroset.FieldJSONContent, field.TypeString, value) + _node.JSONContent = value + } + if value, ok := _c.mutation.HeroName(); ok { + _spec.SetField(fribbleheroset.FieldHeroName, field.TypeString, value) + _node.HeroName = value + } + if value, ok := _c.mutation.Creator(); ok { + _spec.SetField(fribbleheroset.FieldCreator, field.TypeString, value) + _node.Creator = value + } + if value, ok := _c.mutation.CreateTime(); ok { + _spec.SetField(fribbleheroset.FieldCreateTime, field.TypeTime, value) + _node.CreateTime = &value + } + if value, ok := _c.mutation.Updater(); ok { + _spec.SetField(fribbleheroset.FieldUpdater, field.TypeString, value) + _node.Updater = value + } + if value, ok := _c.mutation.UpdateTime(); ok { + _spec.SetField(fribbleheroset.FieldUpdateTime, field.TypeTime, value) + _node.UpdateTime = &value + } + if value, ok := _c.mutation.Deleted(); ok { + _spec.SetField(fribbleheroset.FieldDeleted, field.TypeBool, value) + _node.Deleted = value + } + if value, ok := _c.mutation.SuccessGet(); ok { + _spec.SetField(fribbleheroset.FieldSuccessGet, field.TypeInt, value) + _node.SuccessGet = value + } + return _node, _spec +} + +// FribbleHeroSetCreateBulk is the builder for creating many FribbleHeroSet entities in bulk. +type FribbleHeroSetCreateBulk struct { + config + err error + builders []*FribbleHeroSetCreate +} + +// Save creates the FribbleHeroSet entities in the database. +func (_c *FribbleHeroSetCreateBulk) Save(ctx context.Context) ([]*FribbleHeroSet, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*FribbleHeroSet, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*FribbleHeroSetMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil && nodes[i].ID == 0 { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int64(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *FribbleHeroSetCreateBulk) SaveX(ctx context.Context) []*FribbleHeroSet { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *FribbleHeroSetCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *FribbleHeroSetCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/ent/fribbleheroset_delete.go b/internal/ent/fribbleheroset_delete.go new file mode 100644 index 0000000..7a31fa6 --- /dev/null +++ b/internal/ent/fribbleheroset_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "epic-ent/internal/ent/fribbleheroset" + "epic-ent/internal/ent/predicate" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// FribbleHeroSetDelete is the builder for deleting a FribbleHeroSet entity. +type FribbleHeroSetDelete struct { + config + hooks []Hook + mutation *FribbleHeroSetMutation +} + +// Where appends a list predicates to the FribbleHeroSetDelete builder. +func (_d *FribbleHeroSetDelete) Where(ps ...predicate.FribbleHeroSet) *FribbleHeroSetDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *FribbleHeroSetDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *FribbleHeroSetDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *FribbleHeroSetDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(fribbleheroset.Table, sqlgraph.NewFieldSpec(fribbleheroset.FieldID, field.TypeInt64)) + if ps := _d.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + _d.mutation.done = true + return affected, err +} + +// FribbleHeroSetDeleteOne is the builder for deleting a single FribbleHeroSet entity. +type FribbleHeroSetDeleteOne struct { + _d *FribbleHeroSetDelete +} + +// Where appends a list predicates to the FribbleHeroSetDelete builder. +func (_d *FribbleHeroSetDeleteOne) Where(ps ...predicate.FribbleHeroSet) *FribbleHeroSetDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *FribbleHeroSetDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{fribbleheroset.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *FribbleHeroSetDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/ent/fribbleheroset_query.go b/internal/ent/fribbleheroset_query.go new file mode 100644 index 0000000..7465f49 --- /dev/null +++ b/internal/ent/fribbleheroset_query.go @@ -0,0 +1,527 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "epic-ent/internal/ent/fribbleheroset" + "epic-ent/internal/ent/predicate" + "fmt" + "math" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// FribbleHeroSetQuery is the builder for querying FribbleHeroSet entities. +type FribbleHeroSetQuery struct { + config + ctx *QueryContext + order []fribbleheroset.OrderOption + inters []Interceptor + predicates []predicate.FribbleHeroSet + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the FribbleHeroSetQuery builder. +func (_q *FribbleHeroSetQuery) Where(ps ...predicate.FribbleHeroSet) *FribbleHeroSetQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *FribbleHeroSetQuery) Limit(limit int) *FribbleHeroSetQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *FribbleHeroSetQuery) Offset(offset int) *FribbleHeroSetQuery { + _q.ctx.Offset = &offset + return _q +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (_q *FribbleHeroSetQuery) Unique(unique bool) *FribbleHeroSetQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *FribbleHeroSetQuery) Order(o ...fribbleheroset.OrderOption) *FribbleHeroSetQuery { + _q.order = append(_q.order, o...) + return _q +} + +// First returns the first FribbleHeroSet entity from the query. +// Returns a *NotFoundError when no FribbleHeroSet was found. +func (_q *FribbleHeroSetQuery) First(ctx context.Context) (*FribbleHeroSet, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{fribbleheroset.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *FribbleHeroSetQuery) FirstX(ctx context.Context) *FribbleHeroSet { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first FribbleHeroSet ID from the query. +// Returns a *NotFoundError when no FribbleHeroSet ID was found. +func (_q *FribbleHeroSetQuery) FirstID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{fribbleheroset.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *FribbleHeroSetQuery) FirstIDX(ctx context.Context) int64 { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single FribbleHeroSet entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one FribbleHeroSet entity is found. +// Returns a *NotFoundError when no FribbleHeroSet entities are found. +func (_q *FribbleHeroSetQuery) Only(ctx context.Context) (*FribbleHeroSet, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{fribbleheroset.Label} + default: + return nil, &NotSingularError{fribbleheroset.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *FribbleHeroSetQuery) OnlyX(ctx context.Context) *FribbleHeroSet { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only FribbleHeroSet ID in the query. +// Returns a *NotSingularError when more than one FribbleHeroSet ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *FribbleHeroSetQuery) OnlyID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{fribbleheroset.Label} + default: + err = &NotSingularError{fribbleheroset.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *FribbleHeroSetQuery) OnlyIDX(ctx context.Context) int64 { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of FribbleHeroSets. +func (_q *FribbleHeroSetQuery) All(ctx context.Context) ([]*FribbleHeroSet, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*FribbleHeroSet, *FribbleHeroSetQuery]() + return withInterceptors[[]*FribbleHeroSet](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *FribbleHeroSetQuery) AllX(ctx context.Context) []*FribbleHeroSet { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of FribbleHeroSet IDs. +func (_q *FribbleHeroSetQuery) IDs(ctx context.Context) (ids []int64, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(fribbleheroset.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *FribbleHeroSetQuery) IDsX(ctx context.Context) []int64 { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *FribbleHeroSetQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, _q, querierCount[*FribbleHeroSetQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *FribbleHeroSetQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (_q *FribbleHeroSetQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *FribbleHeroSetQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the FribbleHeroSetQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (_q *FribbleHeroSetQuery) Clone() *FribbleHeroSetQuery { + if _q == nil { + return nil + } + return &FribbleHeroSetQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]fribbleheroset.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.FribbleHeroSet{}, _q.predicates...), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + } +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// HeroCode string `json:"hero_code,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.FribbleHeroSet.Query(). +// GroupBy(fribbleheroset.FieldHeroCode). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *FribbleHeroSetQuery) GroupBy(field string, fields ...string) *FribbleHeroSetGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &FribbleHeroSetGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = fribbleheroset.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// HeroCode string `json:"hero_code,omitempty"` +// } +// +// client.FribbleHeroSet.Query(). +// Select(fribbleheroset.FieldHeroCode). +// Scan(ctx, &v) +func (_q *FribbleHeroSetQuery) Select(fields ...string) *FribbleHeroSetSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &FribbleHeroSetSelect{FribbleHeroSetQuery: _q} + sbuild.label = fribbleheroset.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a FribbleHeroSetSelect configured with the given aggregations. +func (_q *FribbleHeroSetQuery) Aggregate(fns ...AggregateFunc) *FribbleHeroSetSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *FribbleHeroSetQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !fribbleheroset.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if _q.path != nil { + prev, err := _q.path(ctx) + if err != nil { + return err + } + _q.sql = prev + } + return nil +} + +func (_q *FribbleHeroSetQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*FribbleHeroSet, error) { + var ( + nodes = []*FribbleHeroSet{} + _spec = _q.querySpec() + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*FribbleHeroSet).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &FribbleHeroSet{config: _q.config} + nodes = append(nodes, node) + return node.assignValues(columns, values) + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + return nodes, nil +} + +func (_q *FribbleHeroSetQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique + } + return sqlgraph.CountNodes(ctx, _q.driver, _spec) +} + +func (_q *FribbleHeroSetQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(fribbleheroset.Table, fribbleheroset.Columns, sqlgraph.NewFieldSpec(fribbleheroset.FieldID, field.TypeInt64)) + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if _q.path != nil { + _spec.Unique = true + } + if fields := _q.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, fribbleheroset.FieldID) + for i := range fields { + if fields[i] != fribbleheroset.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := _q.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := _q.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := _q.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := _q.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (_q *FribbleHeroSetQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(fribbleheroset.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = fribbleheroset.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if _q.sql != nil { + selector = _q.sql + selector.Select(selector.Columns(columns...)...) + } + if _q.ctx.Unique != nil && *_q.ctx.Unique { + selector.Distinct() + } + for _, p := range _q.predicates { + p(selector) + } + for _, p := range _q.order { + p(selector) + } + if offset := _q.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := _q.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// FribbleHeroSetGroupBy is the group-by builder for FribbleHeroSet entities. +type FribbleHeroSetGroupBy struct { + selector + build *FribbleHeroSetQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *FribbleHeroSetGroupBy) Aggregate(fns ...AggregateFunc) *FribbleHeroSetGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *FribbleHeroSetGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*FribbleHeroSetQuery, *FribbleHeroSetGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *FribbleHeroSetGroupBy) sqlScan(ctx context.Context, root *FribbleHeroSetQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*_g.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// FribbleHeroSetSelect is the builder for selecting fields of FribbleHeroSet entities. +type FribbleHeroSetSelect struct { + *FribbleHeroSetQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *FribbleHeroSetSelect) Aggregate(fns ...AggregateFunc) *FribbleHeroSetSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *FribbleHeroSetSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*FribbleHeroSetQuery, *FribbleHeroSetSelect](ctx, _s.FribbleHeroSetQuery, _s, _s.inters, v) +} + +func (_s *FribbleHeroSetSelect) sqlScan(ctx context.Context, root *FribbleHeroSetQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/internal/ent/fribbleheroset_update.go b/internal/ent/fribbleheroset_update.go new file mode 100644 index 0000000..2d9cce9 --- /dev/null +++ b/internal/ent/fribbleheroset_update.go @@ -0,0 +1,604 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "epic-ent/internal/ent/fribbleheroset" + "epic-ent/internal/ent/predicate" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// FribbleHeroSetUpdate is the builder for updating FribbleHeroSet entities. +type FribbleHeroSetUpdate struct { + config + hooks []Hook + mutation *FribbleHeroSetMutation +} + +// Where appends a list predicates to the FribbleHeroSetUpdate builder. +func (_u *FribbleHeroSetUpdate) Where(ps ...predicate.FribbleHeroSet) *FribbleHeroSetUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetHeroCode sets the "hero_code" field. +func (_u *FribbleHeroSetUpdate) SetHeroCode(v string) *FribbleHeroSetUpdate { + _u.mutation.SetHeroCode(v) + return _u +} + +// SetNillableHeroCode sets the "hero_code" field if the given value is not nil. +func (_u *FribbleHeroSetUpdate) SetNillableHeroCode(v *string) *FribbleHeroSetUpdate { + if v != nil { + _u.SetHeroCode(*v) + } + return _u +} + +// SetJSONContent sets the "json_content" field. +func (_u *FribbleHeroSetUpdate) SetJSONContent(v string) *FribbleHeroSetUpdate { + _u.mutation.SetJSONContent(v) + return _u +} + +// SetNillableJSONContent sets the "json_content" field if the given value is not nil. +func (_u *FribbleHeroSetUpdate) SetNillableJSONContent(v *string) *FribbleHeroSetUpdate { + if v != nil { + _u.SetJSONContent(*v) + } + return _u +} + +// SetHeroName sets the "hero_name" field. +func (_u *FribbleHeroSetUpdate) SetHeroName(v string) *FribbleHeroSetUpdate { + _u.mutation.SetHeroName(v) + return _u +} + +// SetNillableHeroName sets the "hero_name" field if the given value is not nil. +func (_u *FribbleHeroSetUpdate) SetNillableHeroName(v *string) *FribbleHeroSetUpdate { + if v != nil { + _u.SetHeroName(*v) + } + return _u +} + +// SetCreator sets the "creator" field. +func (_u *FribbleHeroSetUpdate) SetCreator(v string) *FribbleHeroSetUpdate { + _u.mutation.SetCreator(v) + return _u +} + +// SetNillableCreator sets the "creator" field if the given value is not nil. +func (_u *FribbleHeroSetUpdate) SetNillableCreator(v *string) *FribbleHeroSetUpdate { + if v != nil { + _u.SetCreator(*v) + } + return _u +} + +// SetCreateTime sets the "create_time" field. +func (_u *FribbleHeroSetUpdate) SetCreateTime(v time.Time) *FribbleHeroSetUpdate { + _u.mutation.SetCreateTime(v) + return _u +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (_u *FribbleHeroSetUpdate) SetNillableCreateTime(v *time.Time) *FribbleHeroSetUpdate { + if v != nil { + _u.SetCreateTime(*v) + } + return _u +} + +// ClearCreateTime clears the value of the "create_time" field. +func (_u *FribbleHeroSetUpdate) ClearCreateTime() *FribbleHeroSetUpdate { + _u.mutation.ClearCreateTime() + return _u +} + +// SetUpdater sets the "updater" field. +func (_u *FribbleHeroSetUpdate) SetUpdater(v string) *FribbleHeroSetUpdate { + _u.mutation.SetUpdater(v) + return _u +} + +// SetNillableUpdater sets the "updater" field if the given value is not nil. +func (_u *FribbleHeroSetUpdate) SetNillableUpdater(v *string) *FribbleHeroSetUpdate { + if v != nil { + _u.SetUpdater(*v) + } + return _u +} + +// SetUpdateTime sets the "update_time" field. +func (_u *FribbleHeroSetUpdate) SetUpdateTime(v time.Time) *FribbleHeroSetUpdate { + _u.mutation.SetUpdateTime(v) + return _u +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (_u *FribbleHeroSetUpdate) SetNillableUpdateTime(v *time.Time) *FribbleHeroSetUpdate { + if v != nil { + _u.SetUpdateTime(*v) + } + return _u +} + +// ClearUpdateTime clears the value of the "update_time" field. +func (_u *FribbleHeroSetUpdate) ClearUpdateTime() *FribbleHeroSetUpdate { + _u.mutation.ClearUpdateTime() + return _u +} + +// SetDeleted sets the "deleted" field. +func (_u *FribbleHeroSetUpdate) SetDeleted(v bool) *FribbleHeroSetUpdate { + _u.mutation.SetDeleted(v) + return _u +} + +// SetNillableDeleted sets the "deleted" field if the given value is not nil. +func (_u *FribbleHeroSetUpdate) SetNillableDeleted(v *bool) *FribbleHeroSetUpdate { + if v != nil { + _u.SetDeleted(*v) + } + return _u +} + +// SetSuccessGet sets the "success_get" field. +func (_u *FribbleHeroSetUpdate) SetSuccessGet(v int) *FribbleHeroSetUpdate { + _u.mutation.ResetSuccessGet() + _u.mutation.SetSuccessGet(v) + return _u +} + +// SetNillableSuccessGet sets the "success_get" field if the given value is not nil. +func (_u *FribbleHeroSetUpdate) SetNillableSuccessGet(v *int) *FribbleHeroSetUpdate { + if v != nil { + _u.SetSuccessGet(*v) + } + return _u +} + +// AddSuccessGet adds value to the "success_get" field. +func (_u *FribbleHeroSetUpdate) AddSuccessGet(v int) *FribbleHeroSetUpdate { + _u.mutation.AddSuccessGet(v) + return _u +} + +// Mutation returns the FribbleHeroSetMutation object of the builder. +func (_u *FribbleHeroSetUpdate) Mutation() *FribbleHeroSetMutation { + return _u.mutation +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *FribbleHeroSetUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *FribbleHeroSetUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *FribbleHeroSetUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *FribbleHeroSetUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *FribbleHeroSetUpdate) check() error { + if v, ok := _u.mutation.HeroCode(); ok { + if err := fribbleheroset.HeroCodeValidator(v); err != nil { + return &ValidationError{Name: "hero_code", err: fmt.Errorf(`ent: validator failed for field "FribbleHeroSet.hero_code": %w`, err)} + } + } + if v, ok := _u.mutation.JSONContent(); ok { + if err := fribbleheroset.JSONContentValidator(v); err != nil { + return &ValidationError{Name: "json_content", err: fmt.Errorf(`ent: validator failed for field "FribbleHeroSet.json_content": %w`, err)} + } + } + if v, ok := _u.mutation.HeroName(); ok { + if err := fribbleheroset.HeroNameValidator(v); err != nil { + return &ValidationError{Name: "hero_name", err: fmt.Errorf(`ent: validator failed for field "FribbleHeroSet.hero_name": %w`, err)} + } + } + if v, ok := _u.mutation.Creator(); ok { + if err := fribbleheroset.CreatorValidator(v); err != nil { + return &ValidationError{Name: "creator", err: fmt.Errorf(`ent: validator failed for field "FribbleHeroSet.creator": %w`, err)} + } + } + if v, ok := _u.mutation.Updater(); ok { + if err := fribbleheroset.UpdaterValidator(v); err != nil { + return &ValidationError{Name: "updater", err: fmt.Errorf(`ent: validator failed for field "FribbleHeroSet.updater": %w`, err)} + } + } + return nil +} + +func (_u *FribbleHeroSetUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(fribbleheroset.Table, fribbleheroset.Columns, sqlgraph.NewFieldSpec(fribbleheroset.FieldID, field.TypeInt64)) + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.HeroCode(); ok { + _spec.SetField(fribbleheroset.FieldHeroCode, field.TypeString, value) + } + if value, ok := _u.mutation.JSONContent(); ok { + _spec.SetField(fribbleheroset.FieldJSONContent, field.TypeString, value) + } + if value, ok := _u.mutation.HeroName(); ok { + _spec.SetField(fribbleheroset.FieldHeroName, field.TypeString, value) + } + if value, ok := _u.mutation.Creator(); ok { + _spec.SetField(fribbleheroset.FieldCreator, field.TypeString, value) + } + if value, ok := _u.mutation.CreateTime(); ok { + _spec.SetField(fribbleheroset.FieldCreateTime, field.TypeTime, value) + } + if _u.mutation.CreateTimeCleared() { + _spec.ClearField(fribbleheroset.FieldCreateTime, field.TypeTime) + } + if value, ok := _u.mutation.Updater(); ok { + _spec.SetField(fribbleheroset.FieldUpdater, field.TypeString, value) + } + if value, ok := _u.mutation.UpdateTime(); ok { + _spec.SetField(fribbleheroset.FieldUpdateTime, field.TypeTime, value) + } + if _u.mutation.UpdateTimeCleared() { + _spec.ClearField(fribbleheroset.FieldUpdateTime, field.TypeTime) + } + if value, ok := _u.mutation.Deleted(); ok { + _spec.SetField(fribbleheroset.FieldDeleted, field.TypeBool, value) + } + if value, ok := _u.mutation.SuccessGet(); ok { + _spec.SetField(fribbleheroset.FieldSuccessGet, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedSuccessGet(); ok { + _spec.AddField(fribbleheroset.FieldSuccessGet, field.TypeInt, value) + } + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{fribbleheroset.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// FribbleHeroSetUpdateOne is the builder for updating a single FribbleHeroSet entity. +type FribbleHeroSetUpdateOne struct { + config + fields []string + hooks []Hook + mutation *FribbleHeroSetMutation +} + +// SetHeroCode sets the "hero_code" field. +func (_u *FribbleHeroSetUpdateOne) SetHeroCode(v string) *FribbleHeroSetUpdateOne { + _u.mutation.SetHeroCode(v) + return _u +} + +// SetNillableHeroCode sets the "hero_code" field if the given value is not nil. +func (_u *FribbleHeroSetUpdateOne) SetNillableHeroCode(v *string) *FribbleHeroSetUpdateOne { + if v != nil { + _u.SetHeroCode(*v) + } + return _u +} + +// SetJSONContent sets the "json_content" field. +func (_u *FribbleHeroSetUpdateOne) SetJSONContent(v string) *FribbleHeroSetUpdateOne { + _u.mutation.SetJSONContent(v) + return _u +} + +// SetNillableJSONContent sets the "json_content" field if the given value is not nil. +func (_u *FribbleHeroSetUpdateOne) SetNillableJSONContent(v *string) *FribbleHeroSetUpdateOne { + if v != nil { + _u.SetJSONContent(*v) + } + return _u +} + +// SetHeroName sets the "hero_name" field. +func (_u *FribbleHeroSetUpdateOne) SetHeroName(v string) *FribbleHeroSetUpdateOne { + _u.mutation.SetHeroName(v) + return _u +} + +// SetNillableHeroName sets the "hero_name" field if the given value is not nil. +func (_u *FribbleHeroSetUpdateOne) SetNillableHeroName(v *string) *FribbleHeroSetUpdateOne { + if v != nil { + _u.SetHeroName(*v) + } + return _u +} + +// SetCreator sets the "creator" field. +func (_u *FribbleHeroSetUpdateOne) SetCreator(v string) *FribbleHeroSetUpdateOne { + _u.mutation.SetCreator(v) + return _u +} + +// SetNillableCreator sets the "creator" field if the given value is not nil. +func (_u *FribbleHeroSetUpdateOne) SetNillableCreator(v *string) *FribbleHeroSetUpdateOne { + if v != nil { + _u.SetCreator(*v) + } + return _u +} + +// SetCreateTime sets the "create_time" field. +func (_u *FribbleHeroSetUpdateOne) SetCreateTime(v time.Time) *FribbleHeroSetUpdateOne { + _u.mutation.SetCreateTime(v) + return _u +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (_u *FribbleHeroSetUpdateOne) SetNillableCreateTime(v *time.Time) *FribbleHeroSetUpdateOne { + if v != nil { + _u.SetCreateTime(*v) + } + return _u +} + +// ClearCreateTime clears the value of the "create_time" field. +func (_u *FribbleHeroSetUpdateOne) ClearCreateTime() *FribbleHeroSetUpdateOne { + _u.mutation.ClearCreateTime() + return _u +} + +// SetUpdater sets the "updater" field. +func (_u *FribbleHeroSetUpdateOne) SetUpdater(v string) *FribbleHeroSetUpdateOne { + _u.mutation.SetUpdater(v) + return _u +} + +// SetNillableUpdater sets the "updater" field if the given value is not nil. +func (_u *FribbleHeroSetUpdateOne) SetNillableUpdater(v *string) *FribbleHeroSetUpdateOne { + if v != nil { + _u.SetUpdater(*v) + } + return _u +} + +// SetUpdateTime sets the "update_time" field. +func (_u *FribbleHeroSetUpdateOne) SetUpdateTime(v time.Time) *FribbleHeroSetUpdateOne { + _u.mutation.SetUpdateTime(v) + return _u +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (_u *FribbleHeroSetUpdateOne) SetNillableUpdateTime(v *time.Time) *FribbleHeroSetUpdateOne { + if v != nil { + _u.SetUpdateTime(*v) + } + return _u +} + +// ClearUpdateTime clears the value of the "update_time" field. +func (_u *FribbleHeroSetUpdateOne) ClearUpdateTime() *FribbleHeroSetUpdateOne { + _u.mutation.ClearUpdateTime() + return _u +} + +// SetDeleted sets the "deleted" field. +func (_u *FribbleHeroSetUpdateOne) SetDeleted(v bool) *FribbleHeroSetUpdateOne { + _u.mutation.SetDeleted(v) + return _u +} + +// SetNillableDeleted sets the "deleted" field if the given value is not nil. +func (_u *FribbleHeroSetUpdateOne) SetNillableDeleted(v *bool) *FribbleHeroSetUpdateOne { + if v != nil { + _u.SetDeleted(*v) + } + return _u +} + +// SetSuccessGet sets the "success_get" field. +func (_u *FribbleHeroSetUpdateOne) SetSuccessGet(v int) *FribbleHeroSetUpdateOne { + _u.mutation.ResetSuccessGet() + _u.mutation.SetSuccessGet(v) + return _u +} + +// SetNillableSuccessGet sets the "success_get" field if the given value is not nil. +func (_u *FribbleHeroSetUpdateOne) SetNillableSuccessGet(v *int) *FribbleHeroSetUpdateOne { + if v != nil { + _u.SetSuccessGet(*v) + } + return _u +} + +// AddSuccessGet adds value to the "success_get" field. +func (_u *FribbleHeroSetUpdateOne) AddSuccessGet(v int) *FribbleHeroSetUpdateOne { + _u.mutation.AddSuccessGet(v) + return _u +} + +// Mutation returns the FribbleHeroSetMutation object of the builder. +func (_u *FribbleHeroSetUpdateOne) Mutation() *FribbleHeroSetMutation { + return _u.mutation +} + +// Where appends a list predicates to the FribbleHeroSetUpdate builder. +func (_u *FribbleHeroSetUpdateOne) Where(ps ...predicate.FribbleHeroSet) *FribbleHeroSetUpdateOne { + _u.mutation.Where(ps...) + return _u +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (_u *FribbleHeroSetUpdateOne) Select(field string, fields ...string) *FribbleHeroSetUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated FribbleHeroSet entity. +func (_u *FribbleHeroSetUpdateOne) Save(ctx context.Context) (*FribbleHeroSet, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *FribbleHeroSetUpdateOne) SaveX(ctx context.Context) *FribbleHeroSet { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *FribbleHeroSetUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *FribbleHeroSetUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *FribbleHeroSetUpdateOne) check() error { + if v, ok := _u.mutation.HeroCode(); ok { + if err := fribbleheroset.HeroCodeValidator(v); err != nil { + return &ValidationError{Name: "hero_code", err: fmt.Errorf(`ent: validator failed for field "FribbleHeroSet.hero_code": %w`, err)} + } + } + if v, ok := _u.mutation.JSONContent(); ok { + if err := fribbleheroset.JSONContentValidator(v); err != nil { + return &ValidationError{Name: "json_content", err: fmt.Errorf(`ent: validator failed for field "FribbleHeroSet.json_content": %w`, err)} + } + } + if v, ok := _u.mutation.HeroName(); ok { + if err := fribbleheroset.HeroNameValidator(v); err != nil { + return &ValidationError{Name: "hero_name", err: fmt.Errorf(`ent: validator failed for field "FribbleHeroSet.hero_name": %w`, err)} + } + } + if v, ok := _u.mutation.Creator(); ok { + if err := fribbleheroset.CreatorValidator(v); err != nil { + return &ValidationError{Name: "creator", err: fmt.Errorf(`ent: validator failed for field "FribbleHeroSet.creator": %w`, err)} + } + } + if v, ok := _u.mutation.Updater(); ok { + if err := fribbleheroset.UpdaterValidator(v); err != nil { + return &ValidationError{Name: "updater", err: fmt.Errorf(`ent: validator failed for field "FribbleHeroSet.updater": %w`, err)} + } + } + return nil +} + +func (_u *FribbleHeroSetUpdateOne) sqlSave(ctx context.Context) (_node *FribbleHeroSet, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(fribbleheroset.Table, fribbleheroset.Columns, sqlgraph.NewFieldSpec(fribbleheroset.FieldID, field.TypeInt64)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "FribbleHeroSet.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := _u.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, fribbleheroset.FieldID) + for _, f := range fields { + if !fribbleheroset.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != fribbleheroset.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.HeroCode(); ok { + _spec.SetField(fribbleheroset.FieldHeroCode, field.TypeString, value) + } + if value, ok := _u.mutation.JSONContent(); ok { + _spec.SetField(fribbleheroset.FieldJSONContent, field.TypeString, value) + } + if value, ok := _u.mutation.HeroName(); ok { + _spec.SetField(fribbleheroset.FieldHeroName, field.TypeString, value) + } + if value, ok := _u.mutation.Creator(); ok { + _spec.SetField(fribbleheroset.FieldCreator, field.TypeString, value) + } + if value, ok := _u.mutation.CreateTime(); ok { + _spec.SetField(fribbleheroset.FieldCreateTime, field.TypeTime, value) + } + if _u.mutation.CreateTimeCleared() { + _spec.ClearField(fribbleheroset.FieldCreateTime, field.TypeTime) + } + if value, ok := _u.mutation.Updater(); ok { + _spec.SetField(fribbleheroset.FieldUpdater, field.TypeString, value) + } + if value, ok := _u.mutation.UpdateTime(); ok { + _spec.SetField(fribbleheroset.FieldUpdateTime, field.TypeTime, value) + } + if _u.mutation.UpdateTimeCleared() { + _spec.ClearField(fribbleheroset.FieldUpdateTime, field.TypeTime) + } + if value, ok := _u.mutation.Deleted(); ok { + _spec.SetField(fribbleheroset.FieldDeleted, field.TypeBool, value) + } + if value, ok := _u.mutation.SuccessGet(); ok { + _spec.SetField(fribbleheroset.FieldSuccessGet, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedSuccessGet(); ok { + _spec.AddField(fribbleheroset.FieldSuccessGet, field.TypeInt, value) + } + _node = &FribbleHeroSet{config: _u.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{fribbleheroset.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} diff --git a/internal/ent/gearsetinfo.go b/internal/ent/gearsetinfo.go new file mode 100644 index 0000000..4fb75ab --- /dev/null +++ b/internal/ent/gearsetinfo.go @@ -0,0 +1,345 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "epic-ent/internal/ent/gearsetinfo" + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// GearSetInfo is the model entity for the GearSetInfo schema. +type GearSetInfo struct { + config `json:"-"` + // ID of the ent. + ID int64 `json:"id,omitempty"` + // Level holds the value of the "level" field. + Level int `json:"level,omitempty"` + // GearID holds the value of the "gear_id" field. + GearID int64 `json:"gear_id,omitempty"` + // Enhance holds the value of the "enhance" field. + Enhance int `json:"enhance,omitempty"` + // GearType holds the value of the "gear_type" field. + GearType string `json:"gear_type,omitempty"` + // GearSetType holds the value of the "gear_set_type" field. + GearSetType string `json:"gear_set_type,omitempty"` + // MainStatType holds the value of the "main_stat_type" field. + MainStatType string `json:"main_stat_type,omitempty"` + // MainStatValue holds the value of the "main_stat_value" field. + MainStatValue int `json:"main_stat_value,omitempty"` + // SubStatOneType holds the value of the "sub_stat_one_type" field. + SubStatOneType string `json:"sub_stat_one_type,omitempty"` + // SubStatOneValue holds the value of the "sub_stat_one_value" field. + SubStatOneValue int `json:"sub_stat_one_value,omitempty"` + // SubStatTwoType holds the value of the "sub_stat_two_type" field. + SubStatTwoType string `json:"sub_stat_two_type,omitempty"` + // SubStatTwoValue holds the value of the "sub_stat_two_value" field. + SubStatTwoValue int `json:"sub_stat_two_value,omitempty"` + // SubStatThreeType holds the value of the "sub_stat_three_type" field. + SubStatThreeType string `json:"sub_stat_three_type,omitempty"` + // SubStatThreeValue holds the value of the "sub_stat_three_value" field. + SubStatThreeValue int `json:"sub_stat_three_value,omitempty"` + // SubStatFourType holds the value of the "sub_stat_four_type" field. + SubStatFourType string `json:"sub_stat_four_type,omitempty"` + // SubStatFourValue holds the value of the "sub_stat_four_value" field. + SubStatFourValue int `json:"sub_stat_four_value,omitempty"` + // AccountCode holds the value of the "account_code" field. + AccountCode string `json:"account_code,omitempty"` + // Creator holds the value of the "creator" field. + Creator string `json:"creator,omitempty"` + // CreateTime holds the value of the "create_time" field. + CreateTime *time.Time `json:"create_time,omitempty"` + // Updater holds the value of the "updater" field. + Updater string `json:"updater,omitempty"` + // UpdateTime holds the value of the "update_time" field. + UpdateTime *time.Time `json:"update_time,omitempty"` + // Deleted holds the value of the "deleted" field. + Deleted bool `json:"deleted,omitempty"` + // TenantID holds the value of the "tenant_id" field. + TenantID int64 `json:"tenant_id,omitempty"` + selectValues sql.SelectValues +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*GearSetInfo) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case gearsetinfo.FieldDeleted: + values[i] = new(sql.NullBool) + case gearsetinfo.FieldID, gearsetinfo.FieldLevel, gearsetinfo.FieldGearID, gearsetinfo.FieldEnhance, gearsetinfo.FieldMainStatValue, gearsetinfo.FieldSubStatOneValue, gearsetinfo.FieldSubStatTwoValue, gearsetinfo.FieldSubStatThreeValue, gearsetinfo.FieldSubStatFourValue, gearsetinfo.FieldTenantID: + values[i] = new(sql.NullInt64) + case gearsetinfo.FieldGearType, gearsetinfo.FieldGearSetType, gearsetinfo.FieldMainStatType, gearsetinfo.FieldSubStatOneType, gearsetinfo.FieldSubStatTwoType, gearsetinfo.FieldSubStatThreeType, gearsetinfo.FieldSubStatFourType, gearsetinfo.FieldAccountCode, gearsetinfo.FieldCreator, gearsetinfo.FieldUpdater: + values[i] = new(sql.NullString) + case gearsetinfo.FieldCreateTime, gearsetinfo.FieldUpdateTime: + values[i] = new(sql.NullTime) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the GearSetInfo fields. +func (_m *GearSetInfo) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case gearsetinfo.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + _m.ID = int64(value.Int64) + case gearsetinfo.FieldLevel: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field level", values[i]) + } else if value.Valid { + _m.Level = int(value.Int64) + } + case gearsetinfo.FieldGearID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field gear_id", values[i]) + } else if value.Valid { + _m.GearID = value.Int64 + } + case gearsetinfo.FieldEnhance: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field enhance", values[i]) + } else if value.Valid { + _m.Enhance = int(value.Int64) + } + case gearsetinfo.FieldGearType: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field gear_type", values[i]) + } else if value.Valid { + _m.GearType = value.String + } + case gearsetinfo.FieldGearSetType: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field gear_set_type", values[i]) + } else if value.Valid { + _m.GearSetType = value.String + } + case gearsetinfo.FieldMainStatType: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field main_stat_type", values[i]) + } else if value.Valid { + _m.MainStatType = value.String + } + case gearsetinfo.FieldMainStatValue: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field main_stat_value", values[i]) + } else if value.Valid { + _m.MainStatValue = int(value.Int64) + } + case gearsetinfo.FieldSubStatOneType: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field sub_stat_one_type", values[i]) + } else if value.Valid { + _m.SubStatOneType = value.String + } + case gearsetinfo.FieldSubStatOneValue: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field sub_stat_one_value", values[i]) + } else if value.Valid { + _m.SubStatOneValue = int(value.Int64) + } + case gearsetinfo.FieldSubStatTwoType: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field sub_stat_two_type", values[i]) + } else if value.Valid { + _m.SubStatTwoType = value.String + } + case gearsetinfo.FieldSubStatTwoValue: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field sub_stat_two_value", values[i]) + } else if value.Valid { + _m.SubStatTwoValue = int(value.Int64) + } + case gearsetinfo.FieldSubStatThreeType: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field sub_stat_three_type", values[i]) + } else if value.Valid { + _m.SubStatThreeType = value.String + } + case gearsetinfo.FieldSubStatThreeValue: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field sub_stat_three_value", values[i]) + } else if value.Valid { + _m.SubStatThreeValue = int(value.Int64) + } + case gearsetinfo.FieldSubStatFourType: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field sub_stat_four_type", values[i]) + } else if value.Valid { + _m.SubStatFourType = value.String + } + case gearsetinfo.FieldSubStatFourValue: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field sub_stat_four_value", values[i]) + } else if value.Valid { + _m.SubStatFourValue = int(value.Int64) + } + case gearsetinfo.FieldAccountCode: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field account_code", values[i]) + } else if value.Valid { + _m.AccountCode = value.String + } + case gearsetinfo.FieldCreator: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field creator", values[i]) + } else if value.Valid { + _m.Creator = value.String + } + case gearsetinfo.FieldCreateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field create_time", values[i]) + } else if value.Valid { + _m.CreateTime = new(time.Time) + *_m.CreateTime = value.Time + } + case gearsetinfo.FieldUpdater: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field updater", values[i]) + } else if value.Valid { + _m.Updater = value.String + } + case gearsetinfo.FieldUpdateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field update_time", values[i]) + } else if value.Valid { + _m.UpdateTime = new(time.Time) + *_m.UpdateTime = value.Time + } + case gearsetinfo.FieldDeleted: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field deleted", values[i]) + } else if value.Valid { + _m.Deleted = value.Bool + } + case gearsetinfo.FieldTenantID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field tenant_id", values[i]) + } else if value.Valid { + _m.TenantID = value.Int64 + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the GearSetInfo. +// This includes values selected through modifiers, order, etc. +func (_m *GearSetInfo) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// Update returns a builder for updating this GearSetInfo. +// Note that you need to call GearSetInfo.Unwrap() before calling this method if this GearSetInfo +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *GearSetInfo) Update() *GearSetInfoUpdateOne { + return NewGearSetInfoClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the GearSetInfo entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (_m *GearSetInfo) Unwrap() *GearSetInfo { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("ent: GearSetInfo is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *GearSetInfo) String() string { + var builder strings.Builder + builder.WriteString("GearSetInfo(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("level=") + builder.WriteString(fmt.Sprintf("%v", _m.Level)) + builder.WriteString(", ") + builder.WriteString("gear_id=") + builder.WriteString(fmt.Sprintf("%v", _m.GearID)) + builder.WriteString(", ") + builder.WriteString("enhance=") + builder.WriteString(fmt.Sprintf("%v", _m.Enhance)) + builder.WriteString(", ") + builder.WriteString("gear_type=") + builder.WriteString(_m.GearType) + builder.WriteString(", ") + builder.WriteString("gear_set_type=") + builder.WriteString(_m.GearSetType) + builder.WriteString(", ") + builder.WriteString("main_stat_type=") + builder.WriteString(_m.MainStatType) + builder.WriteString(", ") + builder.WriteString("main_stat_value=") + builder.WriteString(fmt.Sprintf("%v", _m.MainStatValue)) + builder.WriteString(", ") + builder.WriteString("sub_stat_one_type=") + builder.WriteString(_m.SubStatOneType) + builder.WriteString(", ") + builder.WriteString("sub_stat_one_value=") + builder.WriteString(fmt.Sprintf("%v", _m.SubStatOneValue)) + builder.WriteString(", ") + builder.WriteString("sub_stat_two_type=") + builder.WriteString(_m.SubStatTwoType) + builder.WriteString(", ") + builder.WriteString("sub_stat_two_value=") + builder.WriteString(fmt.Sprintf("%v", _m.SubStatTwoValue)) + builder.WriteString(", ") + builder.WriteString("sub_stat_three_type=") + builder.WriteString(_m.SubStatThreeType) + builder.WriteString(", ") + builder.WriteString("sub_stat_three_value=") + builder.WriteString(fmt.Sprintf("%v", _m.SubStatThreeValue)) + builder.WriteString(", ") + builder.WriteString("sub_stat_four_type=") + builder.WriteString(_m.SubStatFourType) + builder.WriteString(", ") + builder.WriteString("sub_stat_four_value=") + builder.WriteString(fmt.Sprintf("%v", _m.SubStatFourValue)) + builder.WriteString(", ") + builder.WriteString("account_code=") + builder.WriteString(_m.AccountCode) + builder.WriteString(", ") + builder.WriteString("creator=") + builder.WriteString(_m.Creator) + builder.WriteString(", ") + if v := _m.CreateTime; v != nil { + builder.WriteString("create_time=") + builder.WriteString(v.Format(time.ANSIC)) + } + builder.WriteString(", ") + builder.WriteString("updater=") + builder.WriteString(_m.Updater) + builder.WriteString(", ") + if v := _m.UpdateTime; v != nil { + builder.WriteString("update_time=") + builder.WriteString(v.Format(time.ANSIC)) + } + builder.WriteString(", ") + builder.WriteString("deleted=") + builder.WriteString(fmt.Sprintf("%v", _m.Deleted)) + builder.WriteString(", ") + builder.WriteString("tenant_id=") + builder.WriteString(fmt.Sprintf("%v", _m.TenantID)) + builder.WriteByte(')') + return builder.String() +} + +// GearSetInfos is a parsable slice of GearSetInfo. +type GearSetInfos []*GearSetInfo diff --git a/internal/ent/gearsetinfo/gearsetinfo.go b/internal/ent/gearsetinfo/gearsetinfo.go new file mode 100644 index 0000000..53daff2 --- /dev/null +++ b/internal/ent/gearsetinfo/gearsetinfo.go @@ -0,0 +1,238 @@ +// Code generated by ent, DO NOT EDIT. + +package gearsetinfo + +import ( + "entgo.io/ent/dialect/sql" +) + +const ( + // Label holds the string label denoting the gearsetinfo type in the database. + Label = "gear_set_info" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldLevel holds the string denoting the level field in the database. + FieldLevel = "level" + // FieldGearID holds the string denoting the gear_id field in the database. + FieldGearID = "gear_id" + // FieldEnhance holds the string denoting the enhance field in the database. + FieldEnhance = "enhance" + // FieldGearType holds the string denoting the gear_type field in the database. + FieldGearType = "gear_type" + // FieldGearSetType holds the string denoting the gear_set_type field in the database. + FieldGearSetType = "gear_set_type" + // FieldMainStatType holds the string denoting the main_stat_type field in the database. + FieldMainStatType = "main_stat_type" + // FieldMainStatValue holds the string denoting the main_stat_value field in the database. + FieldMainStatValue = "main_stat_value" + // FieldSubStatOneType holds the string denoting the sub_stat_one_type field in the database. + FieldSubStatOneType = "sub_stat_one_type" + // FieldSubStatOneValue holds the string denoting the sub_stat_one_value field in the database. + FieldSubStatOneValue = "sub_stat_one_value" + // FieldSubStatTwoType holds the string denoting the sub_stat_two_type field in the database. + FieldSubStatTwoType = "sub_stat_two_type" + // FieldSubStatTwoValue holds the string denoting the sub_stat_two_value field in the database. + FieldSubStatTwoValue = "sub_stat_two_value" + // FieldSubStatThreeType holds the string denoting the sub_stat_three_type field in the database. + FieldSubStatThreeType = "sub_stat_three_type" + // FieldSubStatThreeValue holds the string denoting the sub_stat_three_value field in the database. + FieldSubStatThreeValue = "sub_stat_three_value" + // FieldSubStatFourType holds the string denoting the sub_stat_four_type field in the database. + FieldSubStatFourType = "sub_stat_four_type" + // FieldSubStatFourValue holds the string denoting the sub_stat_four_value field in the database. + FieldSubStatFourValue = "sub_stat_four_value" + // FieldAccountCode holds the string denoting the account_code field in the database. + FieldAccountCode = "account_code" + // FieldCreator holds the string denoting the creator field in the database. + FieldCreator = "creator" + // FieldCreateTime holds the string denoting the create_time field in the database. + FieldCreateTime = "create_time" + // FieldUpdater holds the string denoting the updater field in the database. + FieldUpdater = "updater" + // FieldUpdateTime holds the string denoting the update_time field in the database. + FieldUpdateTime = "update_time" + // FieldDeleted holds the string denoting the deleted field in the database. + FieldDeleted = "deleted" + // FieldTenantID holds the string denoting the tenant_id field in the database. + FieldTenantID = "tenant_id" + // Table holds the table name of the gearsetinfo in the database. + Table = "gear_set_infos" +) + +// Columns holds all SQL columns for gearsetinfo fields. +var Columns = []string{ + FieldID, + FieldLevel, + FieldGearID, + FieldEnhance, + FieldGearType, + FieldGearSetType, + FieldMainStatType, + FieldMainStatValue, + FieldSubStatOneType, + FieldSubStatOneValue, + FieldSubStatTwoType, + FieldSubStatTwoValue, + FieldSubStatThreeType, + FieldSubStatThreeValue, + FieldSubStatFourType, + FieldSubStatFourValue, + FieldAccountCode, + FieldCreator, + FieldCreateTime, + FieldUpdater, + FieldUpdateTime, + FieldDeleted, + FieldTenantID, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // GearTypeValidator is a validator for the "gear_type" field. It is called by the builders before save. + GearTypeValidator func(string) error + // GearSetTypeValidator is a validator for the "gear_set_type" field. It is called by the builders before save. + GearSetTypeValidator func(string) error + // MainStatTypeValidator is a validator for the "main_stat_type" field. It is called by the builders before save. + MainStatTypeValidator func(string) error + // SubStatOneTypeValidator is a validator for the "sub_stat_one_type" field. It is called by the builders before save. + SubStatOneTypeValidator func(string) error + // SubStatTwoTypeValidator is a validator for the "sub_stat_two_type" field. It is called by the builders before save. + SubStatTwoTypeValidator func(string) error + // SubStatThreeTypeValidator is a validator for the "sub_stat_three_type" field. It is called by the builders before save. + SubStatThreeTypeValidator func(string) error + // SubStatFourTypeValidator is a validator for the "sub_stat_four_type" field. It is called by the builders before save. + SubStatFourTypeValidator func(string) error + // AccountCodeValidator is a validator for the "account_code" field. It is called by the builders before save. + AccountCodeValidator func(string) error + // CreatorValidator is a validator for the "creator" field. It is called by the builders before save. + CreatorValidator func(string) error + // UpdaterValidator is a validator for the "updater" field. It is called by the builders before save. + UpdaterValidator func(string) error +) + +// OrderOption defines the ordering options for the GearSetInfo queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByLevel orders the results by the level field. +func ByLevel(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLevel, opts...).ToFunc() +} + +// ByGearID orders the results by the gear_id field. +func ByGearID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldGearID, opts...).ToFunc() +} + +// ByEnhance orders the results by the enhance field. +func ByEnhance(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldEnhance, opts...).ToFunc() +} + +// ByGearType orders the results by the gear_type field. +func ByGearType(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldGearType, opts...).ToFunc() +} + +// ByGearSetType orders the results by the gear_set_type field. +func ByGearSetType(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldGearSetType, opts...).ToFunc() +} + +// ByMainStatType orders the results by the main_stat_type field. +func ByMainStatType(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldMainStatType, opts...).ToFunc() +} + +// ByMainStatValue orders the results by the main_stat_value field. +func ByMainStatValue(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldMainStatValue, opts...).ToFunc() +} + +// BySubStatOneType orders the results by the sub_stat_one_type field. +func BySubStatOneType(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSubStatOneType, opts...).ToFunc() +} + +// BySubStatOneValue orders the results by the sub_stat_one_value field. +func BySubStatOneValue(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSubStatOneValue, opts...).ToFunc() +} + +// BySubStatTwoType orders the results by the sub_stat_two_type field. +func BySubStatTwoType(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSubStatTwoType, opts...).ToFunc() +} + +// BySubStatTwoValue orders the results by the sub_stat_two_value field. +func BySubStatTwoValue(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSubStatTwoValue, opts...).ToFunc() +} + +// BySubStatThreeType orders the results by the sub_stat_three_type field. +func BySubStatThreeType(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSubStatThreeType, opts...).ToFunc() +} + +// BySubStatThreeValue orders the results by the sub_stat_three_value field. +func BySubStatThreeValue(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSubStatThreeValue, opts...).ToFunc() +} + +// BySubStatFourType orders the results by the sub_stat_four_type field. +func BySubStatFourType(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSubStatFourType, opts...).ToFunc() +} + +// BySubStatFourValue orders the results by the sub_stat_four_value field. +func BySubStatFourValue(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSubStatFourValue, opts...).ToFunc() +} + +// ByAccountCode orders the results by the account_code field. +func ByAccountCode(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldAccountCode, opts...).ToFunc() +} + +// ByCreator orders the results by the creator field. +func ByCreator(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreator, opts...).ToFunc() +} + +// ByCreateTime orders the results by the create_time field. +func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateTime, opts...).ToFunc() +} + +// ByUpdater orders the results by the updater field. +func ByUpdater(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdater, opts...).ToFunc() +} + +// ByUpdateTime orders the results by the update_time field. +func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() +} + +// ByDeleted orders the results by the deleted field. +func ByDeleted(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeleted, opts...).ToFunc() +} + +// ByTenantID orders the results by the tenant_id field. +func ByTenantID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldTenantID, opts...).ToFunc() +} diff --git a/internal/ent/gearsetinfo/where.go b/internal/ent/gearsetinfo/where.go new file mode 100644 index 0000000..13ba14f --- /dev/null +++ b/internal/ent/gearsetinfo/where.go @@ -0,0 +1,1300 @@ +// Code generated by ent, DO NOT EDIT. + +package gearsetinfo + +import ( + "epic-ent/internal/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" +) + +// ID filters vertices based on their ID field. +func ID(id int64) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int64) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int64) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int64) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int64) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int64) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int64) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int64) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int64) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLTE(FieldID, id)) +} + +// Level applies equality check predicate on the "level" field. It's identical to LevelEQ. +func Level(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldLevel, v)) +} + +// GearID applies equality check predicate on the "gear_id" field. It's identical to GearIDEQ. +func GearID(v int64) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldGearID, v)) +} + +// Enhance applies equality check predicate on the "enhance" field. It's identical to EnhanceEQ. +func Enhance(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldEnhance, v)) +} + +// GearType applies equality check predicate on the "gear_type" field. It's identical to GearTypeEQ. +func GearType(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldGearType, v)) +} + +// GearSetType applies equality check predicate on the "gear_set_type" field. It's identical to GearSetTypeEQ. +func GearSetType(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldGearSetType, v)) +} + +// MainStatType applies equality check predicate on the "main_stat_type" field. It's identical to MainStatTypeEQ. +func MainStatType(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldMainStatType, v)) +} + +// MainStatValue applies equality check predicate on the "main_stat_value" field. It's identical to MainStatValueEQ. +func MainStatValue(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldMainStatValue, v)) +} + +// SubStatOneType applies equality check predicate on the "sub_stat_one_type" field. It's identical to SubStatOneTypeEQ. +func SubStatOneType(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldSubStatOneType, v)) +} + +// SubStatOneValue applies equality check predicate on the "sub_stat_one_value" field. It's identical to SubStatOneValueEQ. +func SubStatOneValue(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldSubStatOneValue, v)) +} + +// SubStatTwoType applies equality check predicate on the "sub_stat_two_type" field. It's identical to SubStatTwoTypeEQ. +func SubStatTwoType(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldSubStatTwoType, v)) +} + +// SubStatTwoValue applies equality check predicate on the "sub_stat_two_value" field. It's identical to SubStatTwoValueEQ. +func SubStatTwoValue(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldSubStatTwoValue, v)) +} + +// SubStatThreeType applies equality check predicate on the "sub_stat_three_type" field. It's identical to SubStatThreeTypeEQ. +func SubStatThreeType(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldSubStatThreeType, v)) +} + +// SubStatThreeValue applies equality check predicate on the "sub_stat_three_value" field. It's identical to SubStatThreeValueEQ. +func SubStatThreeValue(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldSubStatThreeValue, v)) +} + +// SubStatFourType applies equality check predicate on the "sub_stat_four_type" field. It's identical to SubStatFourTypeEQ. +func SubStatFourType(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldSubStatFourType, v)) +} + +// SubStatFourValue applies equality check predicate on the "sub_stat_four_value" field. It's identical to SubStatFourValueEQ. +func SubStatFourValue(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldSubStatFourValue, v)) +} + +// AccountCode applies equality check predicate on the "account_code" field. It's identical to AccountCodeEQ. +func AccountCode(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldAccountCode, v)) +} + +// Creator applies equality check predicate on the "creator" field. It's identical to CreatorEQ. +func Creator(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldCreator, v)) +} + +// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. +func CreateTime(v time.Time) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldCreateTime, v)) +} + +// Updater applies equality check predicate on the "updater" field. It's identical to UpdaterEQ. +func Updater(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldUpdater, v)) +} + +// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. +func UpdateTime(v time.Time) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldUpdateTime, v)) +} + +// Deleted applies equality check predicate on the "deleted" field. It's identical to DeletedEQ. +func Deleted(v bool) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldDeleted, v)) +} + +// TenantID applies equality check predicate on the "tenant_id" field. It's identical to TenantIDEQ. +func TenantID(v int64) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldTenantID, v)) +} + +// LevelEQ applies the EQ predicate on the "level" field. +func LevelEQ(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldLevel, v)) +} + +// LevelNEQ applies the NEQ predicate on the "level" field. +func LevelNEQ(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNEQ(FieldLevel, v)) +} + +// LevelIn applies the In predicate on the "level" field. +func LevelIn(vs ...int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldIn(FieldLevel, vs...)) +} + +// LevelNotIn applies the NotIn predicate on the "level" field. +func LevelNotIn(vs ...int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNotIn(FieldLevel, vs...)) +} + +// LevelGT applies the GT predicate on the "level" field. +func LevelGT(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGT(FieldLevel, v)) +} + +// LevelGTE applies the GTE predicate on the "level" field. +func LevelGTE(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGTE(FieldLevel, v)) +} + +// LevelLT applies the LT predicate on the "level" field. +func LevelLT(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLT(FieldLevel, v)) +} + +// LevelLTE applies the LTE predicate on the "level" field. +func LevelLTE(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLTE(FieldLevel, v)) +} + +// GearIDEQ applies the EQ predicate on the "gear_id" field. +func GearIDEQ(v int64) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldGearID, v)) +} + +// GearIDNEQ applies the NEQ predicate on the "gear_id" field. +func GearIDNEQ(v int64) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNEQ(FieldGearID, v)) +} + +// GearIDIn applies the In predicate on the "gear_id" field. +func GearIDIn(vs ...int64) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldIn(FieldGearID, vs...)) +} + +// GearIDNotIn applies the NotIn predicate on the "gear_id" field. +func GearIDNotIn(vs ...int64) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNotIn(FieldGearID, vs...)) +} + +// GearIDGT applies the GT predicate on the "gear_id" field. +func GearIDGT(v int64) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGT(FieldGearID, v)) +} + +// GearIDGTE applies the GTE predicate on the "gear_id" field. +func GearIDGTE(v int64) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGTE(FieldGearID, v)) +} + +// GearIDLT applies the LT predicate on the "gear_id" field. +func GearIDLT(v int64) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLT(FieldGearID, v)) +} + +// GearIDLTE applies the LTE predicate on the "gear_id" field. +func GearIDLTE(v int64) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLTE(FieldGearID, v)) +} + +// EnhanceEQ applies the EQ predicate on the "enhance" field. +func EnhanceEQ(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldEnhance, v)) +} + +// EnhanceNEQ applies the NEQ predicate on the "enhance" field. +func EnhanceNEQ(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNEQ(FieldEnhance, v)) +} + +// EnhanceIn applies the In predicate on the "enhance" field. +func EnhanceIn(vs ...int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldIn(FieldEnhance, vs...)) +} + +// EnhanceNotIn applies the NotIn predicate on the "enhance" field. +func EnhanceNotIn(vs ...int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNotIn(FieldEnhance, vs...)) +} + +// EnhanceGT applies the GT predicate on the "enhance" field. +func EnhanceGT(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGT(FieldEnhance, v)) +} + +// EnhanceGTE applies the GTE predicate on the "enhance" field. +func EnhanceGTE(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGTE(FieldEnhance, v)) +} + +// EnhanceLT applies the LT predicate on the "enhance" field. +func EnhanceLT(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLT(FieldEnhance, v)) +} + +// EnhanceLTE applies the LTE predicate on the "enhance" field. +func EnhanceLTE(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLTE(FieldEnhance, v)) +} + +// GearTypeEQ applies the EQ predicate on the "gear_type" field. +func GearTypeEQ(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldGearType, v)) +} + +// GearTypeNEQ applies the NEQ predicate on the "gear_type" field. +func GearTypeNEQ(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNEQ(FieldGearType, v)) +} + +// GearTypeIn applies the In predicate on the "gear_type" field. +func GearTypeIn(vs ...string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldIn(FieldGearType, vs...)) +} + +// GearTypeNotIn applies the NotIn predicate on the "gear_type" field. +func GearTypeNotIn(vs ...string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNotIn(FieldGearType, vs...)) +} + +// GearTypeGT applies the GT predicate on the "gear_type" field. +func GearTypeGT(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGT(FieldGearType, v)) +} + +// GearTypeGTE applies the GTE predicate on the "gear_type" field. +func GearTypeGTE(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGTE(FieldGearType, v)) +} + +// GearTypeLT applies the LT predicate on the "gear_type" field. +func GearTypeLT(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLT(FieldGearType, v)) +} + +// GearTypeLTE applies the LTE predicate on the "gear_type" field. +func GearTypeLTE(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLTE(FieldGearType, v)) +} + +// GearTypeContains applies the Contains predicate on the "gear_type" field. +func GearTypeContains(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldContains(FieldGearType, v)) +} + +// GearTypeHasPrefix applies the HasPrefix predicate on the "gear_type" field. +func GearTypeHasPrefix(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldHasPrefix(FieldGearType, v)) +} + +// GearTypeHasSuffix applies the HasSuffix predicate on the "gear_type" field. +func GearTypeHasSuffix(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldHasSuffix(FieldGearType, v)) +} + +// GearTypeEqualFold applies the EqualFold predicate on the "gear_type" field. +func GearTypeEqualFold(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEqualFold(FieldGearType, v)) +} + +// GearTypeContainsFold applies the ContainsFold predicate on the "gear_type" field. +func GearTypeContainsFold(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldContainsFold(FieldGearType, v)) +} + +// GearSetTypeEQ applies the EQ predicate on the "gear_set_type" field. +func GearSetTypeEQ(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldGearSetType, v)) +} + +// GearSetTypeNEQ applies the NEQ predicate on the "gear_set_type" field. +func GearSetTypeNEQ(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNEQ(FieldGearSetType, v)) +} + +// GearSetTypeIn applies the In predicate on the "gear_set_type" field. +func GearSetTypeIn(vs ...string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldIn(FieldGearSetType, vs...)) +} + +// GearSetTypeNotIn applies the NotIn predicate on the "gear_set_type" field. +func GearSetTypeNotIn(vs ...string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNotIn(FieldGearSetType, vs...)) +} + +// GearSetTypeGT applies the GT predicate on the "gear_set_type" field. +func GearSetTypeGT(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGT(FieldGearSetType, v)) +} + +// GearSetTypeGTE applies the GTE predicate on the "gear_set_type" field. +func GearSetTypeGTE(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGTE(FieldGearSetType, v)) +} + +// GearSetTypeLT applies the LT predicate on the "gear_set_type" field. +func GearSetTypeLT(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLT(FieldGearSetType, v)) +} + +// GearSetTypeLTE applies the LTE predicate on the "gear_set_type" field. +func GearSetTypeLTE(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLTE(FieldGearSetType, v)) +} + +// GearSetTypeContains applies the Contains predicate on the "gear_set_type" field. +func GearSetTypeContains(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldContains(FieldGearSetType, v)) +} + +// GearSetTypeHasPrefix applies the HasPrefix predicate on the "gear_set_type" field. +func GearSetTypeHasPrefix(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldHasPrefix(FieldGearSetType, v)) +} + +// GearSetTypeHasSuffix applies the HasSuffix predicate on the "gear_set_type" field. +func GearSetTypeHasSuffix(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldHasSuffix(FieldGearSetType, v)) +} + +// GearSetTypeEqualFold applies the EqualFold predicate on the "gear_set_type" field. +func GearSetTypeEqualFold(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEqualFold(FieldGearSetType, v)) +} + +// GearSetTypeContainsFold applies the ContainsFold predicate on the "gear_set_type" field. +func GearSetTypeContainsFold(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldContainsFold(FieldGearSetType, v)) +} + +// MainStatTypeEQ applies the EQ predicate on the "main_stat_type" field. +func MainStatTypeEQ(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldMainStatType, v)) +} + +// MainStatTypeNEQ applies the NEQ predicate on the "main_stat_type" field. +func MainStatTypeNEQ(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNEQ(FieldMainStatType, v)) +} + +// MainStatTypeIn applies the In predicate on the "main_stat_type" field. +func MainStatTypeIn(vs ...string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldIn(FieldMainStatType, vs...)) +} + +// MainStatTypeNotIn applies the NotIn predicate on the "main_stat_type" field. +func MainStatTypeNotIn(vs ...string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNotIn(FieldMainStatType, vs...)) +} + +// MainStatTypeGT applies the GT predicate on the "main_stat_type" field. +func MainStatTypeGT(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGT(FieldMainStatType, v)) +} + +// MainStatTypeGTE applies the GTE predicate on the "main_stat_type" field. +func MainStatTypeGTE(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGTE(FieldMainStatType, v)) +} + +// MainStatTypeLT applies the LT predicate on the "main_stat_type" field. +func MainStatTypeLT(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLT(FieldMainStatType, v)) +} + +// MainStatTypeLTE applies the LTE predicate on the "main_stat_type" field. +func MainStatTypeLTE(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLTE(FieldMainStatType, v)) +} + +// MainStatTypeContains applies the Contains predicate on the "main_stat_type" field. +func MainStatTypeContains(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldContains(FieldMainStatType, v)) +} + +// MainStatTypeHasPrefix applies the HasPrefix predicate on the "main_stat_type" field. +func MainStatTypeHasPrefix(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldHasPrefix(FieldMainStatType, v)) +} + +// MainStatTypeHasSuffix applies the HasSuffix predicate on the "main_stat_type" field. +func MainStatTypeHasSuffix(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldHasSuffix(FieldMainStatType, v)) +} + +// MainStatTypeEqualFold applies the EqualFold predicate on the "main_stat_type" field. +func MainStatTypeEqualFold(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEqualFold(FieldMainStatType, v)) +} + +// MainStatTypeContainsFold applies the ContainsFold predicate on the "main_stat_type" field. +func MainStatTypeContainsFold(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldContainsFold(FieldMainStatType, v)) +} + +// MainStatValueEQ applies the EQ predicate on the "main_stat_value" field. +func MainStatValueEQ(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldMainStatValue, v)) +} + +// MainStatValueNEQ applies the NEQ predicate on the "main_stat_value" field. +func MainStatValueNEQ(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNEQ(FieldMainStatValue, v)) +} + +// MainStatValueIn applies the In predicate on the "main_stat_value" field. +func MainStatValueIn(vs ...int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldIn(FieldMainStatValue, vs...)) +} + +// MainStatValueNotIn applies the NotIn predicate on the "main_stat_value" field. +func MainStatValueNotIn(vs ...int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNotIn(FieldMainStatValue, vs...)) +} + +// MainStatValueGT applies the GT predicate on the "main_stat_value" field. +func MainStatValueGT(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGT(FieldMainStatValue, v)) +} + +// MainStatValueGTE applies the GTE predicate on the "main_stat_value" field. +func MainStatValueGTE(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGTE(FieldMainStatValue, v)) +} + +// MainStatValueLT applies the LT predicate on the "main_stat_value" field. +func MainStatValueLT(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLT(FieldMainStatValue, v)) +} + +// MainStatValueLTE applies the LTE predicate on the "main_stat_value" field. +func MainStatValueLTE(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLTE(FieldMainStatValue, v)) +} + +// SubStatOneTypeEQ applies the EQ predicate on the "sub_stat_one_type" field. +func SubStatOneTypeEQ(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldSubStatOneType, v)) +} + +// SubStatOneTypeNEQ applies the NEQ predicate on the "sub_stat_one_type" field. +func SubStatOneTypeNEQ(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNEQ(FieldSubStatOneType, v)) +} + +// SubStatOneTypeIn applies the In predicate on the "sub_stat_one_type" field. +func SubStatOneTypeIn(vs ...string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldIn(FieldSubStatOneType, vs...)) +} + +// SubStatOneTypeNotIn applies the NotIn predicate on the "sub_stat_one_type" field. +func SubStatOneTypeNotIn(vs ...string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNotIn(FieldSubStatOneType, vs...)) +} + +// SubStatOneTypeGT applies the GT predicate on the "sub_stat_one_type" field. +func SubStatOneTypeGT(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGT(FieldSubStatOneType, v)) +} + +// SubStatOneTypeGTE applies the GTE predicate on the "sub_stat_one_type" field. +func SubStatOneTypeGTE(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGTE(FieldSubStatOneType, v)) +} + +// SubStatOneTypeLT applies the LT predicate on the "sub_stat_one_type" field. +func SubStatOneTypeLT(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLT(FieldSubStatOneType, v)) +} + +// SubStatOneTypeLTE applies the LTE predicate on the "sub_stat_one_type" field. +func SubStatOneTypeLTE(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLTE(FieldSubStatOneType, v)) +} + +// SubStatOneTypeContains applies the Contains predicate on the "sub_stat_one_type" field. +func SubStatOneTypeContains(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldContains(FieldSubStatOneType, v)) +} + +// SubStatOneTypeHasPrefix applies the HasPrefix predicate on the "sub_stat_one_type" field. +func SubStatOneTypeHasPrefix(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldHasPrefix(FieldSubStatOneType, v)) +} + +// SubStatOneTypeHasSuffix applies the HasSuffix predicate on the "sub_stat_one_type" field. +func SubStatOneTypeHasSuffix(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldHasSuffix(FieldSubStatOneType, v)) +} + +// SubStatOneTypeEqualFold applies the EqualFold predicate on the "sub_stat_one_type" field. +func SubStatOneTypeEqualFold(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEqualFold(FieldSubStatOneType, v)) +} + +// SubStatOneTypeContainsFold applies the ContainsFold predicate on the "sub_stat_one_type" field. +func SubStatOneTypeContainsFold(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldContainsFold(FieldSubStatOneType, v)) +} + +// SubStatOneValueEQ applies the EQ predicate on the "sub_stat_one_value" field. +func SubStatOneValueEQ(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldSubStatOneValue, v)) +} + +// SubStatOneValueNEQ applies the NEQ predicate on the "sub_stat_one_value" field. +func SubStatOneValueNEQ(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNEQ(FieldSubStatOneValue, v)) +} + +// SubStatOneValueIn applies the In predicate on the "sub_stat_one_value" field. +func SubStatOneValueIn(vs ...int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldIn(FieldSubStatOneValue, vs...)) +} + +// SubStatOneValueNotIn applies the NotIn predicate on the "sub_stat_one_value" field. +func SubStatOneValueNotIn(vs ...int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNotIn(FieldSubStatOneValue, vs...)) +} + +// SubStatOneValueGT applies the GT predicate on the "sub_stat_one_value" field. +func SubStatOneValueGT(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGT(FieldSubStatOneValue, v)) +} + +// SubStatOneValueGTE applies the GTE predicate on the "sub_stat_one_value" field. +func SubStatOneValueGTE(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGTE(FieldSubStatOneValue, v)) +} + +// SubStatOneValueLT applies the LT predicate on the "sub_stat_one_value" field. +func SubStatOneValueLT(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLT(FieldSubStatOneValue, v)) +} + +// SubStatOneValueLTE applies the LTE predicate on the "sub_stat_one_value" field. +func SubStatOneValueLTE(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLTE(FieldSubStatOneValue, v)) +} + +// SubStatTwoTypeEQ applies the EQ predicate on the "sub_stat_two_type" field. +func SubStatTwoTypeEQ(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldSubStatTwoType, v)) +} + +// SubStatTwoTypeNEQ applies the NEQ predicate on the "sub_stat_two_type" field. +func SubStatTwoTypeNEQ(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNEQ(FieldSubStatTwoType, v)) +} + +// SubStatTwoTypeIn applies the In predicate on the "sub_stat_two_type" field. +func SubStatTwoTypeIn(vs ...string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldIn(FieldSubStatTwoType, vs...)) +} + +// SubStatTwoTypeNotIn applies the NotIn predicate on the "sub_stat_two_type" field. +func SubStatTwoTypeNotIn(vs ...string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNotIn(FieldSubStatTwoType, vs...)) +} + +// SubStatTwoTypeGT applies the GT predicate on the "sub_stat_two_type" field. +func SubStatTwoTypeGT(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGT(FieldSubStatTwoType, v)) +} + +// SubStatTwoTypeGTE applies the GTE predicate on the "sub_stat_two_type" field. +func SubStatTwoTypeGTE(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGTE(FieldSubStatTwoType, v)) +} + +// SubStatTwoTypeLT applies the LT predicate on the "sub_stat_two_type" field. +func SubStatTwoTypeLT(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLT(FieldSubStatTwoType, v)) +} + +// SubStatTwoTypeLTE applies the LTE predicate on the "sub_stat_two_type" field. +func SubStatTwoTypeLTE(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLTE(FieldSubStatTwoType, v)) +} + +// SubStatTwoTypeContains applies the Contains predicate on the "sub_stat_two_type" field. +func SubStatTwoTypeContains(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldContains(FieldSubStatTwoType, v)) +} + +// SubStatTwoTypeHasPrefix applies the HasPrefix predicate on the "sub_stat_two_type" field. +func SubStatTwoTypeHasPrefix(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldHasPrefix(FieldSubStatTwoType, v)) +} + +// SubStatTwoTypeHasSuffix applies the HasSuffix predicate on the "sub_stat_two_type" field. +func SubStatTwoTypeHasSuffix(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldHasSuffix(FieldSubStatTwoType, v)) +} + +// SubStatTwoTypeEqualFold applies the EqualFold predicate on the "sub_stat_two_type" field. +func SubStatTwoTypeEqualFold(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEqualFold(FieldSubStatTwoType, v)) +} + +// SubStatTwoTypeContainsFold applies the ContainsFold predicate on the "sub_stat_two_type" field. +func SubStatTwoTypeContainsFold(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldContainsFold(FieldSubStatTwoType, v)) +} + +// SubStatTwoValueEQ applies the EQ predicate on the "sub_stat_two_value" field. +func SubStatTwoValueEQ(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldSubStatTwoValue, v)) +} + +// SubStatTwoValueNEQ applies the NEQ predicate on the "sub_stat_two_value" field. +func SubStatTwoValueNEQ(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNEQ(FieldSubStatTwoValue, v)) +} + +// SubStatTwoValueIn applies the In predicate on the "sub_stat_two_value" field. +func SubStatTwoValueIn(vs ...int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldIn(FieldSubStatTwoValue, vs...)) +} + +// SubStatTwoValueNotIn applies the NotIn predicate on the "sub_stat_two_value" field. +func SubStatTwoValueNotIn(vs ...int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNotIn(FieldSubStatTwoValue, vs...)) +} + +// SubStatTwoValueGT applies the GT predicate on the "sub_stat_two_value" field. +func SubStatTwoValueGT(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGT(FieldSubStatTwoValue, v)) +} + +// SubStatTwoValueGTE applies the GTE predicate on the "sub_stat_two_value" field. +func SubStatTwoValueGTE(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGTE(FieldSubStatTwoValue, v)) +} + +// SubStatTwoValueLT applies the LT predicate on the "sub_stat_two_value" field. +func SubStatTwoValueLT(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLT(FieldSubStatTwoValue, v)) +} + +// SubStatTwoValueLTE applies the LTE predicate on the "sub_stat_two_value" field. +func SubStatTwoValueLTE(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLTE(FieldSubStatTwoValue, v)) +} + +// SubStatThreeTypeEQ applies the EQ predicate on the "sub_stat_three_type" field. +func SubStatThreeTypeEQ(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldSubStatThreeType, v)) +} + +// SubStatThreeTypeNEQ applies the NEQ predicate on the "sub_stat_three_type" field. +func SubStatThreeTypeNEQ(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNEQ(FieldSubStatThreeType, v)) +} + +// SubStatThreeTypeIn applies the In predicate on the "sub_stat_three_type" field. +func SubStatThreeTypeIn(vs ...string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldIn(FieldSubStatThreeType, vs...)) +} + +// SubStatThreeTypeNotIn applies the NotIn predicate on the "sub_stat_three_type" field. +func SubStatThreeTypeNotIn(vs ...string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNotIn(FieldSubStatThreeType, vs...)) +} + +// SubStatThreeTypeGT applies the GT predicate on the "sub_stat_three_type" field. +func SubStatThreeTypeGT(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGT(FieldSubStatThreeType, v)) +} + +// SubStatThreeTypeGTE applies the GTE predicate on the "sub_stat_three_type" field. +func SubStatThreeTypeGTE(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGTE(FieldSubStatThreeType, v)) +} + +// SubStatThreeTypeLT applies the LT predicate on the "sub_stat_three_type" field. +func SubStatThreeTypeLT(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLT(FieldSubStatThreeType, v)) +} + +// SubStatThreeTypeLTE applies the LTE predicate on the "sub_stat_three_type" field. +func SubStatThreeTypeLTE(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLTE(FieldSubStatThreeType, v)) +} + +// SubStatThreeTypeContains applies the Contains predicate on the "sub_stat_three_type" field. +func SubStatThreeTypeContains(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldContains(FieldSubStatThreeType, v)) +} + +// SubStatThreeTypeHasPrefix applies the HasPrefix predicate on the "sub_stat_three_type" field. +func SubStatThreeTypeHasPrefix(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldHasPrefix(FieldSubStatThreeType, v)) +} + +// SubStatThreeTypeHasSuffix applies the HasSuffix predicate on the "sub_stat_three_type" field. +func SubStatThreeTypeHasSuffix(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldHasSuffix(FieldSubStatThreeType, v)) +} + +// SubStatThreeTypeEqualFold applies the EqualFold predicate on the "sub_stat_three_type" field. +func SubStatThreeTypeEqualFold(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEqualFold(FieldSubStatThreeType, v)) +} + +// SubStatThreeTypeContainsFold applies the ContainsFold predicate on the "sub_stat_three_type" field. +func SubStatThreeTypeContainsFold(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldContainsFold(FieldSubStatThreeType, v)) +} + +// SubStatThreeValueEQ applies the EQ predicate on the "sub_stat_three_value" field. +func SubStatThreeValueEQ(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldSubStatThreeValue, v)) +} + +// SubStatThreeValueNEQ applies the NEQ predicate on the "sub_stat_three_value" field. +func SubStatThreeValueNEQ(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNEQ(FieldSubStatThreeValue, v)) +} + +// SubStatThreeValueIn applies the In predicate on the "sub_stat_three_value" field. +func SubStatThreeValueIn(vs ...int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldIn(FieldSubStatThreeValue, vs...)) +} + +// SubStatThreeValueNotIn applies the NotIn predicate on the "sub_stat_three_value" field. +func SubStatThreeValueNotIn(vs ...int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNotIn(FieldSubStatThreeValue, vs...)) +} + +// SubStatThreeValueGT applies the GT predicate on the "sub_stat_three_value" field. +func SubStatThreeValueGT(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGT(FieldSubStatThreeValue, v)) +} + +// SubStatThreeValueGTE applies the GTE predicate on the "sub_stat_three_value" field. +func SubStatThreeValueGTE(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGTE(FieldSubStatThreeValue, v)) +} + +// SubStatThreeValueLT applies the LT predicate on the "sub_stat_three_value" field. +func SubStatThreeValueLT(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLT(FieldSubStatThreeValue, v)) +} + +// SubStatThreeValueLTE applies the LTE predicate on the "sub_stat_three_value" field. +func SubStatThreeValueLTE(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLTE(FieldSubStatThreeValue, v)) +} + +// SubStatFourTypeEQ applies the EQ predicate on the "sub_stat_four_type" field. +func SubStatFourTypeEQ(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldSubStatFourType, v)) +} + +// SubStatFourTypeNEQ applies the NEQ predicate on the "sub_stat_four_type" field. +func SubStatFourTypeNEQ(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNEQ(FieldSubStatFourType, v)) +} + +// SubStatFourTypeIn applies the In predicate on the "sub_stat_four_type" field. +func SubStatFourTypeIn(vs ...string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldIn(FieldSubStatFourType, vs...)) +} + +// SubStatFourTypeNotIn applies the NotIn predicate on the "sub_stat_four_type" field. +func SubStatFourTypeNotIn(vs ...string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNotIn(FieldSubStatFourType, vs...)) +} + +// SubStatFourTypeGT applies the GT predicate on the "sub_stat_four_type" field. +func SubStatFourTypeGT(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGT(FieldSubStatFourType, v)) +} + +// SubStatFourTypeGTE applies the GTE predicate on the "sub_stat_four_type" field. +func SubStatFourTypeGTE(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGTE(FieldSubStatFourType, v)) +} + +// SubStatFourTypeLT applies the LT predicate on the "sub_stat_four_type" field. +func SubStatFourTypeLT(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLT(FieldSubStatFourType, v)) +} + +// SubStatFourTypeLTE applies the LTE predicate on the "sub_stat_four_type" field. +func SubStatFourTypeLTE(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLTE(FieldSubStatFourType, v)) +} + +// SubStatFourTypeContains applies the Contains predicate on the "sub_stat_four_type" field. +func SubStatFourTypeContains(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldContains(FieldSubStatFourType, v)) +} + +// SubStatFourTypeHasPrefix applies the HasPrefix predicate on the "sub_stat_four_type" field. +func SubStatFourTypeHasPrefix(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldHasPrefix(FieldSubStatFourType, v)) +} + +// SubStatFourTypeHasSuffix applies the HasSuffix predicate on the "sub_stat_four_type" field. +func SubStatFourTypeHasSuffix(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldHasSuffix(FieldSubStatFourType, v)) +} + +// SubStatFourTypeEqualFold applies the EqualFold predicate on the "sub_stat_four_type" field. +func SubStatFourTypeEqualFold(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEqualFold(FieldSubStatFourType, v)) +} + +// SubStatFourTypeContainsFold applies the ContainsFold predicate on the "sub_stat_four_type" field. +func SubStatFourTypeContainsFold(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldContainsFold(FieldSubStatFourType, v)) +} + +// SubStatFourValueEQ applies the EQ predicate on the "sub_stat_four_value" field. +func SubStatFourValueEQ(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldSubStatFourValue, v)) +} + +// SubStatFourValueNEQ applies the NEQ predicate on the "sub_stat_four_value" field. +func SubStatFourValueNEQ(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNEQ(FieldSubStatFourValue, v)) +} + +// SubStatFourValueIn applies the In predicate on the "sub_stat_four_value" field. +func SubStatFourValueIn(vs ...int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldIn(FieldSubStatFourValue, vs...)) +} + +// SubStatFourValueNotIn applies the NotIn predicate on the "sub_stat_four_value" field. +func SubStatFourValueNotIn(vs ...int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNotIn(FieldSubStatFourValue, vs...)) +} + +// SubStatFourValueGT applies the GT predicate on the "sub_stat_four_value" field. +func SubStatFourValueGT(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGT(FieldSubStatFourValue, v)) +} + +// SubStatFourValueGTE applies the GTE predicate on the "sub_stat_four_value" field. +func SubStatFourValueGTE(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGTE(FieldSubStatFourValue, v)) +} + +// SubStatFourValueLT applies the LT predicate on the "sub_stat_four_value" field. +func SubStatFourValueLT(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLT(FieldSubStatFourValue, v)) +} + +// SubStatFourValueLTE applies the LTE predicate on the "sub_stat_four_value" field. +func SubStatFourValueLTE(v int) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLTE(FieldSubStatFourValue, v)) +} + +// AccountCodeEQ applies the EQ predicate on the "account_code" field. +func AccountCodeEQ(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldAccountCode, v)) +} + +// AccountCodeNEQ applies the NEQ predicate on the "account_code" field. +func AccountCodeNEQ(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNEQ(FieldAccountCode, v)) +} + +// AccountCodeIn applies the In predicate on the "account_code" field. +func AccountCodeIn(vs ...string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldIn(FieldAccountCode, vs...)) +} + +// AccountCodeNotIn applies the NotIn predicate on the "account_code" field. +func AccountCodeNotIn(vs ...string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNotIn(FieldAccountCode, vs...)) +} + +// AccountCodeGT applies the GT predicate on the "account_code" field. +func AccountCodeGT(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGT(FieldAccountCode, v)) +} + +// AccountCodeGTE applies the GTE predicate on the "account_code" field. +func AccountCodeGTE(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGTE(FieldAccountCode, v)) +} + +// AccountCodeLT applies the LT predicate on the "account_code" field. +func AccountCodeLT(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLT(FieldAccountCode, v)) +} + +// AccountCodeLTE applies the LTE predicate on the "account_code" field. +func AccountCodeLTE(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLTE(FieldAccountCode, v)) +} + +// AccountCodeContains applies the Contains predicate on the "account_code" field. +func AccountCodeContains(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldContains(FieldAccountCode, v)) +} + +// AccountCodeHasPrefix applies the HasPrefix predicate on the "account_code" field. +func AccountCodeHasPrefix(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldHasPrefix(FieldAccountCode, v)) +} + +// AccountCodeHasSuffix applies the HasSuffix predicate on the "account_code" field. +func AccountCodeHasSuffix(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldHasSuffix(FieldAccountCode, v)) +} + +// AccountCodeEqualFold applies the EqualFold predicate on the "account_code" field. +func AccountCodeEqualFold(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEqualFold(FieldAccountCode, v)) +} + +// AccountCodeContainsFold applies the ContainsFold predicate on the "account_code" field. +func AccountCodeContainsFold(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldContainsFold(FieldAccountCode, v)) +} + +// CreatorEQ applies the EQ predicate on the "creator" field. +func CreatorEQ(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldCreator, v)) +} + +// CreatorNEQ applies the NEQ predicate on the "creator" field. +func CreatorNEQ(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNEQ(FieldCreator, v)) +} + +// CreatorIn applies the In predicate on the "creator" field. +func CreatorIn(vs ...string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldIn(FieldCreator, vs...)) +} + +// CreatorNotIn applies the NotIn predicate on the "creator" field. +func CreatorNotIn(vs ...string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNotIn(FieldCreator, vs...)) +} + +// CreatorGT applies the GT predicate on the "creator" field. +func CreatorGT(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGT(FieldCreator, v)) +} + +// CreatorGTE applies the GTE predicate on the "creator" field. +func CreatorGTE(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGTE(FieldCreator, v)) +} + +// CreatorLT applies the LT predicate on the "creator" field. +func CreatorLT(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLT(FieldCreator, v)) +} + +// CreatorLTE applies the LTE predicate on the "creator" field. +func CreatorLTE(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLTE(FieldCreator, v)) +} + +// CreatorContains applies the Contains predicate on the "creator" field. +func CreatorContains(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldContains(FieldCreator, v)) +} + +// CreatorHasPrefix applies the HasPrefix predicate on the "creator" field. +func CreatorHasPrefix(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldHasPrefix(FieldCreator, v)) +} + +// CreatorHasSuffix applies the HasSuffix predicate on the "creator" field. +func CreatorHasSuffix(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldHasSuffix(FieldCreator, v)) +} + +// CreatorEqualFold applies the EqualFold predicate on the "creator" field. +func CreatorEqualFold(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEqualFold(FieldCreator, v)) +} + +// CreatorContainsFold applies the ContainsFold predicate on the "creator" field. +func CreatorContainsFold(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldContainsFold(FieldCreator, v)) +} + +// CreateTimeEQ applies the EQ predicate on the "create_time" field. +func CreateTimeEQ(v time.Time) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldCreateTime, v)) +} + +// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. +func CreateTimeNEQ(v time.Time) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNEQ(FieldCreateTime, v)) +} + +// CreateTimeIn applies the In predicate on the "create_time" field. +func CreateTimeIn(vs ...time.Time) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldIn(FieldCreateTime, vs...)) +} + +// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. +func CreateTimeNotIn(vs ...time.Time) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNotIn(FieldCreateTime, vs...)) +} + +// CreateTimeGT applies the GT predicate on the "create_time" field. +func CreateTimeGT(v time.Time) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGT(FieldCreateTime, v)) +} + +// CreateTimeGTE applies the GTE predicate on the "create_time" field. +func CreateTimeGTE(v time.Time) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGTE(FieldCreateTime, v)) +} + +// CreateTimeLT applies the LT predicate on the "create_time" field. +func CreateTimeLT(v time.Time) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLT(FieldCreateTime, v)) +} + +// CreateTimeLTE applies the LTE predicate on the "create_time" field. +func CreateTimeLTE(v time.Time) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLTE(FieldCreateTime, v)) +} + +// CreateTimeIsNil applies the IsNil predicate on the "create_time" field. +func CreateTimeIsNil() predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldIsNull(FieldCreateTime)) +} + +// CreateTimeNotNil applies the NotNil predicate on the "create_time" field. +func CreateTimeNotNil() predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNotNull(FieldCreateTime)) +} + +// UpdaterEQ applies the EQ predicate on the "updater" field. +func UpdaterEQ(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldUpdater, v)) +} + +// UpdaterNEQ applies the NEQ predicate on the "updater" field. +func UpdaterNEQ(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNEQ(FieldUpdater, v)) +} + +// UpdaterIn applies the In predicate on the "updater" field. +func UpdaterIn(vs ...string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldIn(FieldUpdater, vs...)) +} + +// UpdaterNotIn applies the NotIn predicate on the "updater" field. +func UpdaterNotIn(vs ...string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNotIn(FieldUpdater, vs...)) +} + +// UpdaterGT applies the GT predicate on the "updater" field. +func UpdaterGT(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGT(FieldUpdater, v)) +} + +// UpdaterGTE applies the GTE predicate on the "updater" field. +func UpdaterGTE(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGTE(FieldUpdater, v)) +} + +// UpdaterLT applies the LT predicate on the "updater" field. +func UpdaterLT(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLT(FieldUpdater, v)) +} + +// UpdaterLTE applies the LTE predicate on the "updater" field. +func UpdaterLTE(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLTE(FieldUpdater, v)) +} + +// UpdaterContains applies the Contains predicate on the "updater" field. +func UpdaterContains(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldContains(FieldUpdater, v)) +} + +// UpdaterHasPrefix applies the HasPrefix predicate on the "updater" field. +func UpdaterHasPrefix(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldHasPrefix(FieldUpdater, v)) +} + +// UpdaterHasSuffix applies the HasSuffix predicate on the "updater" field. +func UpdaterHasSuffix(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldHasSuffix(FieldUpdater, v)) +} + +// UpdaterEqualFold applies the EqualFold predicate on the "updater" field. +func UpdaterEqualFold(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEqualFold(FieldUpdater, v)) +} + +// UpdaterContainsFold applies the ContainsFold predicate on the "updater" field. +func UpdaterContainsFold(v string) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldContainsFold(FieldUpdater, v)) +} + +// UpdateTimeEQ applies the EQ predicate on the "update_time" field. +func UpdateTimeEQ(v time.Time) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldUpdateTime, v)) +} + +// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. +func UpdateTimeNEQ(v time.Time) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNEQ(FieldUpdateTime, v)) +} + +// UpdateTimeIn applies the In predicate on the "update_time" field. +func UpdateTimeIn(vs ...time.Time) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. +func UpdateTimeNotIn(vs ...time.Time) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNotIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeGT applies the GT predicate on the "update_time" field. +func UpdateTimeGT(v time.Time) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGT(FieldUpdateTime, v)) +} + +// UpdateTimeGTE applies the GTE predicate on the "update_time" field. +func UpdateTimeGTE(v time.Time) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGTE(FieldUpdateTime, v)) +} + +// UpdateTimeLT applies the LT predicate on the "update_time" field. +func UpdateTimeLT(v time.Time) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLT(FieldUpdateTime, v)) +} + +// UpdateTimeLTE applies the LTE predicate on the "update_time" field. +func UpdateTimeLTE(v time.Time) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLTE(FieldUpdateTime, v)) +} + +// UpdateTimeIsNil applies the IsNil predicate on the "update_time" field. +func UpdateTimeIsNil() predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldIsNull(FieldUpdateTime)) +} + +// UpdateTimeNotNil applies the NotNil predicate on the "update_time" field. +func UpdateTimeNotNil() predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNotNull(FieldUpdateTime)) +} + +// DeletedEQ applies the EQ predicate on the "deleted" field. +func DeletedEQ(v bool) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldDeleted, v)) +} + +// DeletedNEQ applies the NEQ predicate on the "deleted" field. +func DeletedNEQ(v bool) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNEQ(FieldDeleted, v)) +} + +// TenantIDEQ applies the EQ predicate on the "tenant_id" field. +func TenantIDEQ(v int64) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldEQ(FieldTenantID, v)) +} + +// TenantIDNEQ applies the NEQ predicate on the "tenant_id" field. +func TenantIDNEQ(v int64) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNEQ(FieldTenantID, v)) +} + +// TenantIDIn applies the In predicate on the "tenant_id" field. +func TenantIDIn(vs ...int64) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldIn(FieldTenantID, vs...)) +} + +// TenantIDNotIn applies the NotIn predicate on the "tenant_id" field. +func TenantIDNotIn(vs ...int64) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldNotIn(FieldTenantID, vs...)) +} + +// TenantIDGT applies the GT predicate on the "tenant_id" field. +func TenantIDGT(v int64) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGT(FieldTenantID, v)) +} + +// TenantIDGTE applies the GTE predicate on the "tenant_id" field. +func TenantIDGTE(v int64) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldGTE(FieldTenantID, v)) +} + +// TenantIDLT applies the LT predicate on the "tenant_id" field. +func TenantIDLT(v int64) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLT(FieldTenantID, v)) +} + +// TenantIDLTE applies the LTE predicate on the "tenant_id" field. +func TenantIDLTE(v int64) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.FieldLTE(FieldTenantID, v)) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.GearSetInfo) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.GearSetInfo) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.GearSetInfo) predicate.GearSetInfo { + return predicate.GearSetInfo(sql.NotPredicates(p)) +} diff --git a/internal/ent/gearsetinfo_create.go b/internal/ent/gearsetinfo_create.go new file mode 100644 index 0000000..c328f47 --- /dev/null +++ b/internal/ent/gearsetinfo_create.go @@ -0,0 +1,529 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "epic-ent/internal/ent/gearsetinfo" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// GearSetInfoCreate is the builder for creating a GearSetInfo entity. +type GearSetInfoCreate struct { + config + mutation *GearSetInfoMutation + hooks []Hook +} + +// SetLevel sets the "level" field. +func (_c *GearSetInfoCreate) SetLevel(v int) *GearSetInfoCreate { + _c.mutation.SetLevel(v) + return _c +} + +// SetGearID sets the "gear_id" field. +func (_c *GearSetInfoCreate) SetGearID(v int64) *GearSetInfoCreate { + _c.mutation.SetGearID(v) + return _c +} + +// SetEnhance sets the "enhance" field. +func (_c *GearSetInfoCreate) SetEnhance(v int) *GearSetInfoCreate { + _c.mutation.SetEnhance(v) + return _c +} + +// SetGearType sets the "gear_type" field. +func (_c *GearSetInfoCreate) SetGearType(v string) *GearSetInfoCreate { + _c.mutation.SetGearType(v) + return _c +} + +// SetGearSetType sets the "gear_set_type" field. +func (_c *GearSetInfoCreate) SetGearSetType(v string) *GearSetInfoCreate { + _c.mutation.SetGearSetType(v) + return _c +} + +// SetMainStatType sets the "main_stat_type" field. +func (_c *GearSetInfoCreate) SetMainStatType(v string) *GearSetInfoCreate { + _c.mutation.SetMainStatType(v) + return _c +} + +// SetMainStatValue sets the "main_stat_value" field. +func (_c *GearSetInfoCreate) SetMainStatValue(v int) *GearSetInfoCreate { + _c.mutation.SetMainStatValue(v) + return _c +} + +// SetSubStatOneType sets the "sub_stat_one_type" field. +func (_c *GearSetInfoCreate) SetSubStatOneType(v string) *GearSetInfoCreate { + _c.mutation.SetSubStatOneType(v) + return _c +} + +// SetSubStatOneValue sets the "sub_stat_one_value" field. +func (_c *GearSetInfoCreate) SetSubStatOneValue(v int) *GearSetInfoCreate { + _c.mutation.SetSubStatOneValue(v) + return _c +} + +// SetSubStatTwoType sets the "sub_stat_two_type" field. +func (_c *GearSetInfoCreate) SetSubStatTwoType(v string) *GearSetInfoCreate { + _c.mutation.SetSubStatTwoType(v) + return _c +} + +// SetSubStatTwoValue sets the "sub_stat_two_value" field. +func (_c *GearSetInfoCreate) SetSubStatTwoValue(v int) *GearSetInfoCreate { + _c.mutation.SetSubStatTwoValue(v) + return _c +} + +// SetSubStatThreeType sets the "sub_stat_three_type" field. +func (_c *GearSetInfoCreate) SetSubStatThreeType(v string) *GearSetInfoCreate { + _c.mutation.SetSubStatThreeType(v) + return _c +} + +// SetSubStatThreeValue sets the "sub_stat_three_value" field. +func (_c *GearSetInfoCreate) SetSubStatThreeValue(v int) *GearSetInfoCreate { + _c.mutation.SetSubStatThreeValue(v) + return _c +} + +// SetSubStatFourType sets the "sub_stat_four_type" field. +func (_c *GearSetInfoCreate) SetSubStatFourType(v string) *GearSetInfoCreate { + _c.mutation.SetSubStatFourType(v) + return _c +} + +// SetSubStatFourValue sets the "sub_stat_four_value" field. +func (_c *GearSetInfoCreate) SetSubStatFourValue(v int) *GearSetInfoCreate { + _c.mutation.SetSubStatFourValue(v) + return _c +} + +// SetAccountCode sets the "account_code" field. +func (_c *GearSetInfoCreate) SetAccountCode(v string) *GearSetInfoCreate { + _c.mutation.SetAccountCode(v) + return _c +} + +// SetCreator sets the "creator" field. +func (_c *GearSetInfoCreate) SetCreator(v string) *GearSetInfoCreate { + _c.mutation.SetCreator(v) + return _c +} + +// SetCreateTime sets the "create_time" field. +func (_c *GearSetInfoCreate) SetCreateTime(v time.Time) *GearSetInfoCreate { + _c.mutation.SetCreateTime(v) + return _c +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (_c *GearSetInfoCreate) SetNillableCreateTime(v *time.Time) *GearSetInfoCreate { + if v != nil { + _c.SetCreateTime(*v) + } + return _c +} + +// SetUpdater sets the "updater" field. +func (_c *GearSetInfoCreate) SetUpdater(v string) *GearSetInfoCreate { + _c.mutation.SetUpdater(v) + return _c +} + +// SetUpdateTime sets the "update_time" field. +func (_c *GearSetInfoCreate) SetUpdateTime(v time.Time) *GearSetInfoCreate { + _c.mutation.SetUpdateTime(v) + return _c +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (_c *GearSetInfoCreate) SetNillableUpdateTime(v *time.Time) *GearSetInfoCreate { + if v != nil { + _c.SetUpdateTime(*v) + } + return _c +} + +// SetDeleted sets the "deleted" field. +func (_c *GearSetInfoCreate) SetDeleted(v bool) *GearSetInfoCreate { + _c.mutation.SetDeleted(v) + return _c +} + +// SetTenantID sets the "tenant_id" field. +func (_c *GearSetInfoCreate) SetTenantID(v int64) *GearSetInfoCreate { + _c.mutation.SetTenantID(v) + return _c +} + +// SetID sets the "id" field. +func (_c *GearSetInfoCreate) SetID(v int64) *GearSetInfoCreate { + _c.mutation.SetID(v) + return _c +} + +// Mutation returns the GearSetInfoMutation object of the builder. +func (_c *GearSetInfoCreate) Mutation() *GearSetInfoMutation { + return _c.mutation +} + +// Save creates the GearSetInfo in the database. +func (_c *GearSetInfoCreate) Save(ctx context.Context) (*GearSetInfo, error) { + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *GearSetInfoCreate) SaveX(ctx context.Context) *GearSetInfo { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *GearSetInfoCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *GearSetInfoCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *GearSetInfoCreate) check() error { + if _, ok := _c.mutation.Level(); !ok { + return &ValidationError{Name: "level", err: errors.New(`ent: missing required field "GearSetInfo.level"`)} + } + if _, ok := _c.mutation.GearID(); !ok { + return &ValidationError{Name: "gear_id", err: errors.New(`ent: missing required field "GearSetInfo.gear_id"`)} + } + if _, ok := _c.mutation.Enhance(); !ok { + return &ValidationError{Name: "enhance", err: errors.New(`ent: missing required field "GearSetInfo.enhance"`)} + } + if _, ok := _c.mutation.GearType(); !ok { + return &ValidationError{Name: "gear_type", err: errors.New(`ent: missing required field "GearSetInfo.gear_type"`)} + } + if v, ok := _c.mutation.GearType(); ok { + if err := gearsetinfo.GearTypeValidator(v); err != nil { + return &ValidationError{Name: "gear_type", err: fmt.Errorf(`ent: validator failed for field "GearSetInfo.gear_type": %w`, err)} + } + } + if _, ok := _c.mutation.GearSetType(); !ok { + return &ValidationError{Name: "gear_set_type", err: errors.New(`ent: missing required field "GearSetInfo.gear_set_type"`)} + } + if v, ok := _c.mutation.GearSetType(); ok { + if err := gearsetinfo.GearSetTypeValidator(v); err != nil { + return &ValidationError{Name: "gear_set_type", err: fmt.Errorf(`ent: validator failed for field "GearSetInfo.gear_set_type": %w`, err)} + } + } + if _, ok := _c.mutation.MainStatType(); !ok { + return &ValidationError{Name: "main_stat_type", err: errors.New(`ent: missing required field "GearSetInfo.main_stat_type"`)} + } + if v, ok := _c.mutation.MainStatType(); ok { + if err := gearsetinfo.MainStatTypeValidator(v); err != nil { + return &ValidationError{Name: "main_stat_type", err: fmt.Errorf(`ent: validator failed for field "GearSetInfo.main_stat_type": %w`, err)} + } + } + if _, ok := _c.mutation.MainStatValue(); !ok { + return &ValidationError{Name: "main_stat_value", err: errors.New(`ent: missing required field "GearSetInfo.main_stat_value"`)} + } + if _, ok := _c.mutation.SubStatOneType(); !ok { + return &ValidationError{Name: "sub_stat_one_type", err: errors.New(`ent: missing required field "GearSetInfo.sub_stat_one_type"`)} + } + if v, ok := _c.mutation.SubStatOneType(); ok { + if err := gearsetinfo.SubStatOneTypeValidator(v); err != nil { + return &ValidationError{Name: "sub_stat_one_type", err: fmt.Errorf(`ent: validator failed for field "GearSetInfo.sub_stat_one_type": %w`, err)} + } + } + if _, ok := _c.mutation.SubStatOneValue(); !ok { + return &ValidationError{Name: "sub_stat_one_value", err: errors.New(`ent: missing required field "GearSetInfo.sub_stat_one_value"`)} + } + if _, ok := _c.mutation.SubStatTwoType(); !ok { + return &ValidationError{Name: "sub_stat_two_type", err: errors.New(`ent: missing required field "GearSetInfo.sub_stat_two_type"`)} + } + if v, ok := _c.mutation.SubStatTwoType(); ok { + if err := gearsetinfo.SubStatTwoTypeValidator(v); err != nil { + return &ValidationError{Name: "sub_stat_two_type", err: fmt.Errorf(`ent: validator failed for field "GearSetInfo.sub_stat_two_type": %w`, err)} + } + } + if _, ok := _c.mutation.SubStatTwoValue(); !ok { + return &ValidationError{Name: "sub_stat_two_value", err: errors.New(`ent: missing required field "GearSetInfo.sub_stat_two_value"`)} + } + if _, ok := _c.mutation.SubStatThreeType(); !ok { + return &ValidationError{Name: "sub_stat_three_type", err: errors.New(`ent: missing required field "GearSetInfo.sub_stat_three_type"`)} + } + if v, ok := _c.mutation.SubStatThreeType(); ok { + if err := gearsetinfo.SubStatThreeTypeValidator(v); err != nil { + return &ValidationError{Name: "sub_stat_three_type", err: fmt.Errorf(`ent: validator failed for field "GearSetInfo.sub_stat_three_type": %w`, err)} + } + } + if _, ok := _c.mutation.SubStatThreeValue(); !ok { + return &ValidationError{Name: "sub_stat_three_value", err: errors.New(`ent: missing required field "GearSetInfo.sub_stat_three_value"`)} + } + if _, ok := _c.mutation.SubStatFourType(); !ok { + return &ValidationError{Name: "sub_stat_four_type", err: errors.New(`ent: missing required field "GearSetInfo.sub_stat_four_type"`)} + } + if v, ok := _c.mutation.SubStatFourType(); ok { + if err := gearsetinfo.SubStatFourTypeValidator(v); err != nil { + return &ValidationError{Name: "sub_stat_four_type", err: fmt.Errorf(`ent: validator failed for field "GearSetInfo.sub_stat_four_type": %w`, err)} + } + } + if _, ok := _c.mutation.SubStatFourValue(); !ok { + return &ValidationError{Name: "sub_stat_four_value", err: errors.New(`ent: missing required field "GearSetInfo.sub_stat_four_value"`)} + } + if _, ok := _c.mutation.AccountCode(); !ok { + return &ValidationError{Name: "account_code", err: errors.New(`ent: missing required field "GearSetInfo.account_code"`)} + } + if v, ok := _c.mutation.AccountCode(); ok { + if err := gearsetinfo.AccountCodeValidator(v); err != nil { + return &ValidationError{Name: "account_code", err: fmt.Errorf(`ent: validator failed for field "GearSetInfo.account_code": %w`, err)} + } + } + if _, ok := _c.mutation.Creator(); !ok { + return &ValidationError{Name: "creator", err: errors.New(`ent: missing required field "GearSetInfo.creator"`)} + } + if v, ok := _c.mutation.Creator(); ok { + if err := gearsetinfo.CreatorValidator(v); err != nil { + return &ValidationError{Name: "creator", err: fmt.Errorf(`ent: validator failed for field "GearSetInfo.creator": %w`, err)} + } + } + if _, ok := _c.mutation.Updater(); !ok { + return &ValidationError{Name: "updater", err: errors.New(`ent: missing required field "GearSetInfo.updater"`)} + } + if v, ok := _c.mutation.Updater(); ok { + if err := gearsetinfo.UpdaterValidator(v); err != nil { + return &ValidationError{Name: "updater", err: fmt.Errorf(`ent: validator failed for field "GearSetInfo.updater": %w`, err)} + } + } + if _, ok := _c.mutation.Deleted(); !ok { + return &ValidationError{Name: "deleted", err: errors.New(`ent: missing required field "GearSetInfo.deleted"`)} + } + if _, ok := _c.mutation.TenantID(); !ok { + return &ValidationError{Name: "tenant_id", err: errors.New(`ent: missing required field "GearSetInfo.tenant_id"`)} + } + return nil +} + +func (_c *GearSetInfoCreate) sqlSave(ctx context.Context) (*GearSetInfo, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != _node.ID { + id := _spec.ID.Value.(int64) + _node.ID = int64(id) + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *GearSetInfoCreate) createSpec() (*GearSetInfo, *sqlgraph.CreateSpec) { + var ( + _node = &GearSetInfo{config: _c.config} + _spec = sqlgraph.NewCreateSpec(gearsetinfo.Table, sqlgraph.NewFieldSpec(gearsetinfo.FieldID, field.TypeInt64)) + ) + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := _c.mutation.Level(); ok { + _spec.SetField(gearsetinfo.FieldLevel, field.TypeInt, value) + _node.Level = value + } + if value, ok := _c.mutation.GearID(); ok { + _spec.SetField(gearsetinfo.FieldGearID, field.TypeInt64, value) + _node.GearID = value + } + if value, ok := _c.mutation.Enhance(); ok { + _spec.SetField(gearsetinfo.FieldEnhance, field.TypeInt, value) + _node.Enhance = value + } + if value, ok := _c.mutation.GearType(); ok { + _spec.SetField(gearsetinfo.FieldGearType, field.TypeString, value) + _node.GearType = value + } + if value, ok := _c.mutation.GearSetType(); ok { + _spec.SetField(gearsetinfo.FieldGearSetType, field.TypeString, value) + _node.GearSetType = value + } + if value, ok := _c.mutation.MainStatType(); ok { + _spec.SetField(gearsetinfo.FieldMainStatType, field.TypeString, value) + _node.MainStatType = value + } + if value, ok := _c.mutation.MainStatValue(); ok { + _spec.SetField(gearsetinfo.FieldMainStatValue, field.TypeInt, value) + _node.MainStatValue = value + } + if value, ok := _c.mutation.SubStatOneType(); ok { + _spec.SetField(gearsetinfo.FieldSubStatOneType, field.TypeString, value) + _node.SubStatOneType = value + } + if value, ok := _c.mutation.SubStatOneValue(); ok { + _spec.SetField(gearsetinfo.FieldSubStatOneValue, field.TypeInt, value) + _node.SubStatOneValue = value + } + if value, ok := _c.mutation.SubStatTwoType(); ok { + _spec.SetField(gearsetinfo.FieldSubStatTwoType, field.TypeString, value) + _node.SubStatTwoType = value + } + if value, ok := _c.mutation.SubStatTwoValue(); ok { + _spec.SetField(gearsetinfo.FieldSubStatTwoValue, field.TypeInt, value) + _node.SubStatTwoValue = value + } + if value, ok := _c.mutation.SubStatThreeType(); ok { + _spec.SetField(gearsetinfo.FieldSubStatThreeType, field.TypeString, value) + _node.SubStatThreeType = value + } + if value, ok := _c.mutation.SubStatThreeValue(); ok { + _spec.SetField(gearsetinfo.FieldSubStatThreeValue, field.TypeInt, value) + _node.SubStatThreeValue = value + } + if value, ok := _c.mutation.SubStatFourType(); ok { + _spec.SetField(gearsetinfo.FieldSubStatFourType, field.TypeString, value) + _node.SubStatFourType = value + } + if value, ok := _c.mutation.SubStatFourValue(); ok { + _spec.SetField(gearsetinfo.FieldSubStatFourValue, field.TypeInt, value) + _node.SubStatFourValue = value + } + if value, ok := _c.mutation.AccountCode(); ok { + _spec.SetField(gearsetinfo.FieldAccountCode, field.TypeString, value) + _node.AccountCode = value + } + if value, ok := _c.mutation.Creator(); ok { + _spec.SetField(gearsetinfo.FieldCreator, field.TypeString, value) + _node.Creator = value + } + if value, ok := _c.mutation.CreateTime(); ok { + _spec.SetField(gearsetinfo.FieldCreateTime, field.TypeTime, value) + _node.CreateTime = &value + } + if value, ok := _c.mutation.Updater(); ok { + _spec.SetField(gearsetinfo.FieldUpdater, field.TypeString, value) + _node.Updater = value + } + if value, ok := _c.mutation.UpdateTime(); ok { + _spec.SetField(gearsetinfo.FieldUpdateTime, field.TypeTime, value) + _node.UpdateTime = &value + } + if value, ok := _c.mutation.Deleted(); ok { + _spec.SetField(gearsetinfo.FieldDeleted, field.TypeBool, value) + _node.Deleted = value + } + if value, ok := _c.mutation.TenantID(); ok { + _spec.SetField(gearsetinfo.FieldTenantID, field.TypeInt64, value) + _node.TenantID = value + } + return _node, _spec +} + +// GearSetInfoCreateBulk is the builder for creating many GearSetInfo entities in bulk. +type GearSetInfoCreateBulk struct { + config + err error + builders []*GearSetInfoCreate +} + +// Save creates the GearSetInfo entities in the database. +func (_c *GearSetInfoCreateBulk) Save(ctx context.Context) ([]*GearSetInfo, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*GearSetInfo, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*GearSetInfoMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil && nodes[i].ID == 0 { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int64(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *GearSetInfoCreateBulk) SaveX(ctx context.Context) []*GearSetInfo { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *GearSetInfoCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *GearSetInfoCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/ent/gearsetinfo_delete.go b/internal/ent/gearsetinfo_delete.go new file mode 100644 index 0000000..2d4aeaf --- /dev/null +++ b/internal/ent/gearsetinfo_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "epic-ent/internal/ent/gearsetinfo" + "epic-ent/internal/ent/predicate" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// GearSetInfoDelete is the builder for deleting a GearSetInfo entity. +type GearSetInfoDelete struct { + config + hooks []Hook + mutation *GearSetInfoMutation +} + +// Where appends a list predicates to the GearSetInfoDelete builder. +func (_d *GearSetInfoDelete) Where(ps ...predicate.GearSetInfo) *GearSetInfoDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *GearSetInfoDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *GearSetInfoDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *GearSetInfoDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(gearsetinfo.Table, sqlgraph.NewFieldSpec(gearsetinfo.FieldID, field.TypeInt64)) + if ps := _d.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + _d.mutation.done = true + return affected, err +} + +// GearSetInfoDeleteOne is the builder for deleting a single GearSetInfo entity. +type GearSetInfoDeleteOne struct { + _d *GearSetInfoDelete +} + +// Where appends a list predicates to the GearSetInfoDelete builder. +func (_d *GearSetInfoDeleteOne) Where(ps ...predicate.GearSetInfo) *GearSetInfoDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *GearSetInfoDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{gearsetinfo.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *GearSetInfoDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/ent/gearsetinfo_query.go b/internal/ent/gearsetinfo_query.go new file mode 100644 index 0000000..a481d3f --- /dev/null +++ b/internal/ent/gearsetinfo_query.go @@ -0,0 +1,527 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "epic-ent/internal/ent/gearsetinfo" + "epic-ent/internal/ent/predicate" + "fmt" + "math" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// GearSetInfoQuery is the builder for querying GearSetInfo entities. +type GearSetInfoQuery struct { + config + ctx *QueryContext + order []gearsetinfo.OrderOption + inters []Interceptor + predicates []predicate.GearSetInfo + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the GearSetInfoQuery builder. +func (_q *GearSetInfoQuery) Where(ps ...predicate.GearSetInfo) *GearSetInfoQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *GearSetInfoQuery) Limit(limit int) *GearSetInfoQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *GearSetInfoQuery) Offset(offset int) *GearSetInfoQuery { + _q.ctx.Offset = &offset + return _q +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (_q *GearSetInfoQuery) Unique(unique bool) *GearSetInfoQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *GearSetInfoQuery) Order(o ...gearsetinfo.OrderOption) *GearSetInfoQuery { + _q.order = append(_q.order, o...) + return _q +} + +// First returns the first GearSetInfo entity from the query. +// Returns a *NotFoundError when no GearSetInfo was found. +func (_q *GearSetInfoQuery) First(ctx context.Context) (*GearSetInfo, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{gearsetinfo.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *GearSetInfoQuery) FirstX(ctx context.Context) *GearSetInfo { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first GearSetInfo ID from the query. +// Returns a *NotFoundError when no GearSetInfo ID was found. +func (_q *GearSetInfoQuery) FirstID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{gearsetinfo.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *GearSetInfoQuery) FirstIDX(ctx context.Context) int64 { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single GearSetInfo entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one GearSetInfo entity is found. +// Returns a *NotFoundError when no GearSetInfo entities are found. +func (_q *GearSetInfoQuery) Only(ctx context.Context) (*GearSetInfo, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{gearsetinfo.Label} + default: + return nil, &NotSingularError{gearsetinfo.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *GearSetInfoQuery) OnlyX(ctx context.Context) *GearSetInfo { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only GearSetInfo ID in the query. +// Returns a *NotSingularError when more than one GearSetInfo ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *GearSetInfoQuery) OnlyID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{gearsetinfo.Label} + default: + err = &NotSingularError{gearsetinfo.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *GearSetInfoQuery) OnlyIDX(ctx context.Context) int64 { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of GearSetInfos. +func (_q *GearSetInfoQuery) All(ctx context.Context) ([]*GearSetInfo, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*GearSetInfo, *GearSetInfoQuery]() + return withInterceptors[[]*GearSetInfo](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *GearSetInfoQuery) AllX(ctx context.Context) []*GearSetInfo { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of GearSetInfo IDs. +func (_q *GearSetInfoQuery) IDs(ctx context.Context) (ids []int64, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(gearsetinfo.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *GearSetInfoQuery) IDsX(ctx context.Context) []int64 { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *GearSetInfoQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, _q, querierCount[*GearSetInfoQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *GearSetInfoQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (_q *GearSetInfoQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *GearSetInfoQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the GearSetInfoQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (_q *GearSetInfoQuery) Clone() *GearSetInfoQuery { + if _q == nil { + return nil + } + return &GearSetInfoQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]gearsetinfo.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.GearSetInfo{}, _q.predicates...), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + } +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// Level int `json:"level,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.GearSetInfo.Query(). +// GroupBy(gearsetinfo.FieldLevel). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *GearSetInfoQuery) GroupBy(field string, fields ...string) *GearSetInfoGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &GearSetInfoGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = gearsetinfo.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// Level int `json:"level,omitempty"` +// } +// +// client.GearSetInfo.Query(). +// Select(gearsetinfo.FieldLevel). +// Scan(ctx, &v) +func (_q *GearSetInfoQuery) Select(fields ...string) *GearSetInfoSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &GearSetInfoSelect{GearSetInfoQuery: _q} + sbuild.label = gearsetinfo.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a GearSetInfoSelect configured with the given aggregations. +func (_q *GearSetInfoQuery) Aggregate(fns ...AggregateFunc) *GearSetInfoSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *GearSetInfoQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !gearsetinfo.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if _q.path != nil { + prev, err := _q.path(ctx) + if err != nil { + return err + } + _q.sql = prev + } + return nil +} + +func (_q *GearSetInfoQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*GearSetInfo, error) { + var ( + nodes = []*GearSetInfo{} + _spec = _q.querySpec() + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*GearSetInfo).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &GearSetInfo{config: _q.config} + nodes = append(nodes, node) + return node.assignValues(columns, values) + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + return nodes, nil +} + +func (_q *GearSetInfoQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique + } + return sqlgraph.CountNodes(ctx, _q.driver, _spec) +} + +func (_q *GearSetInfoQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(gearsetinfo.Table, gearsetinfo.Columns, sqlgraph.NewFieldSpec(gearsetinfo.FieldID, field.TypeInt64)) + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if _q.path != nil { + _spec.Unique = true + } + if fields := _q.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, gearsetinfo.FieldID) + for i := range fields { + if fields[i] != gearsetinfo.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := _q.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := _q.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := _q.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := _q.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (_q *GearSetInfoQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(gearsetinfo.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = gearsetinfo.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if _q.sql != nil { + selector = _q.sql + selector.Select(selector.Columns(columns...)...) + } + if _q.ctx.Unique != nil && *_q.ctx.Unique { + selector.Distinct() + } + for _, p := range _q.predicates { + p(selector) + } + for _, p := range _q.order { + p(selector) + } + if offset := _q.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := _q.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// GearSetInfoGroupBy is the group-by builder for GearSetInfo entities. +type GearSetInfoGroupBy struct { + selector + build *GearSetInfoQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *GearSetInfoGroupBy) Aggregate(fns ...AggregateFunc) *GearSetInfoGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *GearSetInfoGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*GearSetInfoQuery, *GearSetInfoGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *GearSetInfoGroupBy) sqlScan(ctx context.Context, root *GearSetInfoQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*_g.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// GearSetInfoSelect is the builder for selecting fields of GearSetInfo entities. +type GearSetInfoSelect struct { + *GearSetInfoQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *GearSetInfoSelect) Aggregate(fns ...AggregateFunc) *GearSetInfoSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *GearSetInfoSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*GearSetInfoQuery, *GearSetInfoSelect](ctx, _s.GearSetInfoQuery, _s, _s.inters, v) +} + +func (_s *GearSetInfoSelect) sqlScan(ctx context.Context, root *GearSetInfoQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/internal/ent/gearsetinfo_update.go b/internal/ent/gearsetinfo_update.go new file mode 100644 index 0000000..28d254b --- /dev/null +++ b/internal/ent/gearsetinfo_update.go @@ -0,0 +1,1256 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "epic-ent/internal/ent/gearsetinfo" + "epic-ent/internal/ent/predicate" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// GearSetInfoUpdate is the builder for updating GearSetInfo entities. +type GearSetInfoUpdate struct { + config + hooks []Hook + mutation *GearSetInfoMutation +} + +// Where appends a list predicates to the GearSetInfoUpdate builder. +func (_u *GearSetInfoUpdate) Where(ps ...predicate.GearSetInfo) *GearSetInfoUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetLevel sets the "level" field. +func (_u *GearSetInfoUpdate) SetLevel(v int) *GearSetInfoUpdate { + _u.mutation.ResetLevel() + _u.mutation.SetLevel(v) + return _u +} + +// SetNillableLevel sets the "level" field if the given value is not nil. +func (_u *GearSetInfoUpdate) SetNillableLevel(v *int) *GearSetInfoUpdate { + if v != nil { + _u.SetLevel(*v) + } + return _u +} + +// AddLevel adds value to the "level" field. +func (_u *GearSetInfoUpdate) AddLevel(v int) *GearSetInfoUpdate { + _u.mutation.AddLevel(v) + return _u +} + +// SetGearID sets the "gear_id" field. +func (_u *GearSetInfoUpdate) SetGearID(v int64) *GearSetInfoUpdate { + _u.mutation.ResetGearID() + _u.mutation.SetGearID(v) + return _u +} + +// SetNillableGearID sets the "gear_id" field if the given value is not nil. +func (_u *GearSetInfoUpdate) SetNillableGearID(v *int64) *GearSetInfoUpdate { + if v != nil { + _u.SetGearID(*v) + } + return _u +} + +// AddGearID adds value to the "gear_id" field. +func (_u *GearSetInfoUpdate) AddGearID(v int64) *GearSetInfoUpdate { + _u.mutation.AddGearID(v) + return _u +} + +// SetEnhance sets the "enhance" field. +func (_u *GearSetInfoUpdate) SetEnhance(v int) *GearSetInfoUpdate { + _u.mutation.ResetEnhance() + _u.mutation.SetEnhance(v) + return _u +} + +// SetNillableEnhance sets the "enhance" field if the given value is not nil. +func (_u *GearSetInfoUpdate) SetNillableEnhance(v *int) *GearSetInfoUpdate { + if v != nil { + _u.SetEnhance(*v) + } + return _u +} + +// AddEnhance adds value to the "enhance" field. +func (_u *GearSetInfoUpdate) AddEnhance(v int) *GearSetInfoUpdate { + _u.mutation.AddEnhance(v) + return _u +} + +// SetGearType sets the "gear_type" field. +func (_u *GearSetInfoUpdate) SetGearType(v string) *GearSetInfoUpdate { + _u.mutation.SetGearType(v) + return _u +} + +// SetNillableGearType sets the "gear_type" field if the given value is not nil. +func (_u *GearSetInfoUpdate) SetNillableGearType(v *string) *GearSetInfoUpdate { + if v != nil { + _u.SetGearType(*v) + } + return _u +} + +// SetGearSetType sets the "gear_set_type" field. +func (_u *GearSetInfoUpdate) SetGearSetType(v string) *GearSetInfoUpdate { + _u.mutation.SetGearSetType(v) + return _u +} + +// SetNillableGearSetType sets the "gear_set_type" field if the given value is not nil. +func (_u *GearSetInfoUpdate) SetNillableGearSetType(v *string) *GearSetInfoUpdate { + if v != nil { + _u.SetGearSetType(*v) + } + return _u +} + +// SetMainStatType sets the "main_stat_type" field. +func (_u *GearSetInfoUpdate) SetMainStatType(v string) *GearSetInfoUpdate { + _u.mutation.SetMainStatType(v) + return _u +} + +// SetNillableMainStatType sets the "main_stat_type" field if the given value is not nil. +func (_u *GearSetInfoUpdate) SetNillableMainStatType(v *string) *GearSetInfoUpdate { + if v != nil { + _u.SetMainStatType(*v) + } + return _u +} + +// SetMainStatValue sets the "main_stat_value" field. +func (_u *GearSetInfoUpdate) SetMainStatValue(v int) *GearSetInfoUpdate { + _u.mutation.ResetMainStatValue() + _u.mutation.SetMainStatValue(v) + return _u +} + +// SetNillableMainStatValue sets the "main_stat_value" field if the given value is not nil. +func (_u *GearSetInfoUpdate) SetNillableMainStatValue(v *int) *GearSetInfoUpdate { + if v != nil { + _u.SetMainStatValue(*v) + } + return _u +} + +// AddMainStatValue adds value to the "main_stat_value" field. +func (_u *GearSetInfoUpdate) AddMainStatValue(v int) *GearSetInfoUpdate { + _u.mutation.AddMainStatValue(v) + return _u +} + +// SetSubStatOneType sets the "sub_stat_one_type" field. +func (_u *GearSetInfoUpdate) SetSubStatOneType(v string) *GearSetInfoUpdate { + _u.mutation.SetSubStatOneType(v) + return _u +} + +// SetNillableSubStatOneType sets the "sub_stat_one_type" field if the given value is not nil. +func (_u *GearSetInfoUpdate) SetNillableSubStatOneType(v *string) *GearSetInfoUpdate { + if v != nil { + _u.SetSubStatOneType(*v) + } + return _u +} + +// SetSubStatOneValue sets the "sub_stat_one_value" field. +func (_u *GearSetInfoUpdate) SetSubStatOneValue(v int) *GearSetInfoUpdate { + _u.mutation.ResetSubStatOneValue() + _u.mutation.SetSubStatOneValue(v) + return _u +} + +// SetNillableSubStatOneValue sets the "sub_stat_one_value" field if the given value is not nil. +func (_u *GearSetInfoUpdate) SetNillableSubStatOneValue(v *int) *GearSetInfoUpdate { + if v != nil { + _u.SetSubStatOneValue(*v) + } + return _u +} + +// AddSubStatOneValue adds value to the "sub_stat_one_value" field. +func (_u *GearSetInfoUpdate) AddSubStatOneValue(v int) *GearSetInfoUpdate { + _u.mutation.AddSubStatOneValue(v) + return _u +} + +// SetSubStatTwoType sets the "sub_stat_two_type" field. +func (_u *GearSetInfoUpdate) SetSubStatTwoType(v string) *GearSetInfoUpdate { + _u.mutation.SetSubStatTwoType(v) + return _u +} + +// SetNillableSubStatTwoType sets the "sub_stat_two_type" field if the given value is not nil. +func (_u *GearSetInfoUpdate) SetNillableSubStatTwoType(v *string) *GearSetInfoUpdate { + if v != nil { + _u.SetSubStatTwoType(*v) + } + return _u +} + +// SetSubStatTwoValue sets the "sub_stat_two_value" field. +func (_u *GearSetInfoUpdate) SetSubStatTwoValue(v int) *GearSetInfoUpdate { + _u.mutation.ResetSubStatTwoValue() + _u.mutation.SetSubStatTwoValue(v) + return _u +} + +// SetNillableSubStatTwoValue sets the "sub_stat_two_value" field if the given value is not nil. +func (_u *GearSetInfoUpdate) SetNillableSubStatTwoValue(v *int) *GearSetInfoUpdate { + if v != nil { + _u.SetSubStatTwoValue(*v) + } + return _u +} + +// AddSubStatTwoValue adds value to the "sub_stat_two_value" field. +func (_u *GearSetInfoUpdate) AddSubStatTwoValue(v int) *GearSetInfoUpdate { + _u.mutation.AddSubStatTwoValue(v) + return _u +} + +// SetSubStatThreeType sets the "sub_stat_three_type" field. +func (_u *GearSetInfoUpdate) SetSubStatThreeType(v string) *GearSetInfoUpdate { + _u.mutation.SetSubStatThreeType(v) + return _u +} + +// SetNillableSubStatThreeType sets the "sub_stat_three_type" field if the given value is not nil. +func (_u *GearSetInfoUpdate) SetNillableSubStatThreeType(v *string) *GearSetInfoUpdate { + if v != nil { + _u.SetSubStatThreeType(*v) + } + return _u +} + +// SetSubStatThreeValue sets the "sub_stat_three_value" field. +func (_u *GearSetInfoUpdate) SetSubStatThreeValue(v int) *GearSetInfoUpdate { + _u.mutation.ResetSubStatThreeValue() + _u.mutation.SetSubStatThreeValue(v) + return _u +} + +// SetNillableSubStatThreeValue sets the "sub_stat_three_value" field if the given value is not nil. +func (_u *GearSetInfoUpdate) SetNillableSubStatThreeValue(v *int) *GearSetInfoUpdate { + if v != nil { + _u.SetSubStatThreeValue(*v) + } + return _u +} + +// AddSubStatThreeValue adds value to the "sub_stat_three_value" field. +func (_u *GearSetInfoUpdate) AddSubStatThreeValue(v int) *GearSetInfoUpdate { + _u.mutation.AddSubStatThreeValue(v) + return _u +} + +// SetSubStatFourType sets the "sub_stat_four_type" field. +func (_u *GearSetInfoUpdate) SetSubStatFourType(v string) *GearSetInfoUpdate { + _u.mutation.SetSubStatFourType(v) + return _u +} + +// SetNillableSubStatFourType sets the "sub_stat_four_type" field if the given value is not nil. +func (_u *GearSetInfoUpdate) SetNillableSubStatFourType(v *string) *GearSetInfoUpdate { + if v != nil { + _u.SetSubStatFourType(*v) + } + return _u +} + +// SetSubStatFourValue sets the "sub_stat_four_value" field. +func (_u *GearSetInfoUpdate) SetSubStatFourValue(v int) *GearSetInfoUpdate { + _u.mutation.ResetSubStatFourValue() + _u.mutation.SetSubStatFourValue(v) + return _u +} + +// SetNillableSubStatFourValue sets the "sub_stat_four_value" field if the given value is not nil. +func (_u *GearSetInfoUpdate) SetNillableSubStatFourValue(v *int) *GearSetInfoUpdate { + if v != nil { + _u.SetSubStatFourValue(*v) + } + return _u +} + +// AddSubStatFourValue adds value to the "sub_stat_four_value" field. +func (_u *GearSetInfoUpdate) AddSubStatFourValue(v int) *GearSetInfoUpdate { + _u.mutation.AddSubStatFourValue(v) + return _u +} + +// SetAccountCode sets the "account_code" field. +func (_u *GearSetInfoUpdate) SetAccountCode(v string) *GearSetInfoUpdate { + _u.mutation.SetAccountCode(v) + return _u +} + +// SetNillableAccountCode sets the "account_code" field if the given value is not nil. +func (_u *GearSetInfoUpdate) SetNillableAccountCode(v *string) *GearSetInfoUpdate { + if v != nil { + _u.SetAccountCode(*v) + } + return _u +} + +// SetCreator sets the "creator" field. +func (_u *GearSetInfoUpdate) SetCreator(v string) *GearSetInfoUpdate { + _u.mutation.SetCreator(v) + return _u +} + +// SetNillableCreator sets the "creator" field if the given value is not nil. +func (_u *GearSetInfoUpdate) SetNillableCreator(v *string) *GearSetInfoUpdate { + if v != nil { + _u.SetCreator(*v) + } + return _u +} + +// SetCreateTime sets the "create_time" field. +func (_u *GearSetInfoUpdate) SetCreateTime(v time.Time) *GearSetInfoUpdate { + _u.mutation.SetCreateTime(v) + return _u +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (_u *GearSetInfoUpdate) SetNillableCreateTime(v *time.Time) *GearSetInfoUpdate { + if v != nil { + _u.SetCreateTime(*v) + } + return _u +} + +// ClearCreateTime clears the value of the "create_time" field. +func (_u *GearSetInfoUpdate) ClearCreateTime() *GearSetInfoUpdate { + _u.mutation.ClearCreateTime() + return _u +} + +// SetUpdater sets the "updater" field. +func (_u *GearSetInfoUpdate) SetUpdater(v string) *GearSetInfoUpdate { + _u.mutation.SetUpdater(v) + return _u +} + +// SetNillableUpdater sets the "updater" field if the given value is not nil. +func (_u *GearSetInfoUpdate) SetNillableUpdater(v *string) *GearSetInfoUpdate { + if v != nil { + _u.SetUpdater(*v) + } + return _u +} + +// SetUpdateTime sets the "update_time" field. +func (_u *GearSetInfoUpdate) SetUpdateTime(v time.Time) *GearSetInfoUpdate { + _u.mutation.SetUpdateTime(v) + return _u +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (_u *GearSetInfoUpdate) SetNillableUpdateTime(v *time.Time) *GearSetInfoUpdate { + if v != nil { + _u.SetUpdateTime(*v) + } + return _u +} + +// ClearUpdateTime clears the value of the "update_time" field. +func (_u *GearSetInfoUpdate) ClearUpdateTime() *GearSetInfoUpdate { + _u.mutation.ClearUpdateTime() + return _u +} + +// SetDeleted sets the "deleted" field. +func (_u *GearSetInfoUpdate) SetDeleted(v bool) *GearSetInfoUpdate { + _u.mutation.SetDeleted(v) + return _u +} + +// SetNillableDeleted sets the "deleted" field if the given value is not nil. +func (_u *GearSetInfoUpdate) SetNillableDeleted(v *bool) *GearSetInfoUpdate { + if v != nil { + _u.SetDeleted(*v) + } + return _u +} + +// SetTenantID sets the "tenant_id" field. +func (_u *GearSetInfoUpdate) SetTenantID(v int64) *GearSetInfoUpdate { + _u.mutation.ResetTenantID() + _u.mutation.SetTenantID(v) + return _u +} + +// SetNillableTenantID sets the "tenant_id" field if the given value is not nil. +func (_u *GearSetInfoUpdate) SetNillableTenantID(v *int64) *GearSetInfoUpdate { + if v != nil { + _u.SetTenantID(*v) + } + return _u +} + +// AddTenantID adds value to the "tenant_id" field. +func (_u *GearSetInfoUpdate) AddTenantID(v int64) *GearSetInfoUpdate { + _u.mutation.AddTenantID(v) + return _u +} + +// Mutation returns the GearSetInfoMutation object of the builder. +func (_u *GearSetInfoUpdate) Mutation() *GearSetInfoMutation { + return _u.mutation +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *GearSetInfoUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *GearSetInfoUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *GearSetInfoUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *GearSetInfoUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *GearSetInfoUpdate) check() error { + if v, ok := _u.mutation.GearType(); ok { + if err := gearsetinfo.GearTypeValidator(v); err != nil { + return &ValidationError{Name: "gear_type", err: fmt.Errorf(`ent: validator failed for field "GearSetInfo.gear_type": %w`, err)} + } + } + if v, ok := _u.mutation.GearSetType(); ok { + if err := gearsetinfo.GearSetTypeValidator(v); err != nil { + return &ValidationError{Name: "gear_set_type", err: fmt.Errorf(`ent: validator failed for field "GearSetInfo.gear_set_type": %w`, err)} + } + } + if v, ok := _u.mutation.MainStatType(); ok { + if err := gearsetinfo.MainStatTypeValidator(v); err != nil { + return &ValidationError{Name: "main_stat_type", err: fmt.Errorf(`ent: validator failed for field "GearSetInfo.main_stat_type": %w`, err)} + } + } + if v, ok := _u.mutation.SubStatOneType(); ok { + if err := gearsetinfo.SubStatOneTypeValidator(v); err != nil { + return &ValidationError{Name: "sub_stat_one_type", err: fmt.Errorf(`ent: validator failed for field "GearSetInfo.sub_stat_one_type": %w`, err)} + } + } + if v, ok := _u.mutation.SubStatTwoType(); ok { + if err := gearsetinfo.SubStatTwoTypeValidator(v); err != nil { + return &ValidationError{Name: "sub_stat_two_type", err: fmt.Errorf(`ent: validator failed for field "GearSetInfo.sub_stat_two_type": %w`, err)} + } + } + if v, ok := _u.mutation.SubStatThreeType(); ok { + if err := gearsetinfo.SubStatThreeTypeValidator(v); err != nil { + return &ValidationError{Name: "sub_stat_three_type", err: fmt.Errorf(`ent: validator failed for field "GearSetInfo.sub_stat_three_type": %w`, err)} + } + } + if v, ok := _u.mutation.SubStatFourType(); ok { + if err := gearsetinfo.SubStatFourTypeValidator(v); err != nil { + return &ValidationError{Name: "sub_stat_four_type", err: fmt.Errorf(`ent: validator failed for field "GearSetInfo.sub_stat_four_type": %w`, err)} + } + } + if v, ok := _u.mutation.AccountCode(); ok { + if err := gearsetinfo.AccountCodeValidator(v); err != nil { + return &ValidationError{Name: "account_code", err: fmt.Errorf(`ent: validator failed for field "GearSetInfo.account_code": %w`, err)} + } + } + if v, ok := _u.mutation.Creator(); ok { + if err := gearsetinfo.CreatorValidator(v); err != nil { + return &ValidationError{Name: "creator", err: fmt.Errorf(`ent: validator failed for field "GearSetInfo.creator": %w`, err)} + } + } + if v, ok := _u.mutation.Updater(); ok { + if err := gearsetinfo.UpdaterValidator(v); err != nil { + return &ValidationError{Name: "updater", err: fmt.Errorf(`ent: validator failed for field "GearSetInfo.updater": %w`, err)} + } + } + return nil +} + +func (_u *GearSetInfoUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(gearsetinfo.Table, gearsetinfo.Columns, sqlgraph.NewFieldSpec(gearsetinfo.FieldID, field.TypeInt64)) + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.Level(); ok { + _spec.SetField(gearsetinfo.FieldLevel, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedLevel(); ok { + _spec.AddField(gearsetinfo.FieldLevel, field.TypeInt, value) + } + if value, ok := _u.mutation.GearID(); ok { + _spec.SetField(gearsetinfo.FieldGearID, field.TypeInt64, value) + } + if value, ok := _u.mutation.AddedGearID(); ok { + _spec.AddField(gearsetinfo.FieldGearID, field.TypeInt64, value) + } + if value, ok := _u.mutation.Enhance(); ok { + _spec.SetField(gearsetinfo.FieldEnhance, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedEnhance(); ok { + _spec.AddField(gearsetinfo.FieldEnhance, field.TypeInt, value) + } + if value, ok := _u.mutation.GearType(); ok { + _spec.SetField(gearsetinfo.FieldGearType, field.TypeString, value) + } + if value, ok := _u.mutation.GearSetType(); ok { + _spec.SetField(gearsetinfo.FieldGearSetType, field.TypeString, value) + } + if value, ok := _u.mutation.MainStatType(); ok { + _spec.SetField(gearsetinfo.FieldMainStatType, field.TypeString, value) + } + if value, ok := _u.mutation.MainStatValue(); ok { + _spec.SetField(gearsetinfo.FieldMainStatValue, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedMainStatValue(); ok { + _spec.AddField(gearsetinfo.FieldMainStatValue, field.TypeInt, value) + } + if value, ok := _u.mutation.SubStatOneType(); ok { + _spec.SetField(gearsetinfo.FieldSubStatOneType, field.TypeString, value) + } + if value, ok := _u.mutation.SubStatOneValue(); ok { + _spec.SetField(gearsetinfo.FieldSubStatOneValue, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedSubStatOneValue(); ok { + _spec.AddField(gearsetinfo.FieldSubStatOneValue, field.TypeInt, value) + } + if value, ok := _u.mutation.SubStatTwoType(); ok { + _spec.SetField(gearsetinfo.FieldSubStatTwoType, field.TypeString, value) + } + if value, ok := _u.mutation.SubStatTwoValue(); ok { + _spec.SetField(gearsetinfo.FieldSubStatTwoValue, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedSubStatTwoValue(); ok { + _spec.AddField(gearsetinfo.FieldSubStatTwoValue, field.TypeInt, value) + } + if value, ok := _u.mutation.SubStatThreeType(); ok { + _spec.SetField(gearsetinfo.FieldSubStatThreeType, field.TypeString, value) + } + if value, ok := _u.mutation.SubStatThreeValue(); ok { + _spec.SetField(gearsetinfo.FieldSubStatThreeValue, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedSubStatThreeValue(); ok { + _spec.AddField(gearsetinfo.FieldSubStatThreeValue, field.TypeInt, value) + } + if value, ok := _u.mutation.SubStatFourType(); ok { + _spec.SetField(gearsetinfo.FieldSubStatFourType, field.TypeString, value) + } + if value, ok := _u.mutation.SubStatFourValue(); ok { + _spec.SetField(gearsetinfo.FieldSubStatFourValue, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedSubStatFourValue(); ok { + _spec.AddField(gearsetinfo.FieldSubStatFourValue, field.TypeInt, value) + } + if value, ok := _u.mutation.AccountCode(); ok { + _spec.SetField(gearsetinfo.FieldAccountCode, field.TypeString, value) + } + if value, ok := _u.mutation.Creator(); ok { + _spec.SetField(gearsetinfo.FieldCreator, field.TypeString, value) + } + if value, ok := _u.mutation.CreateTime(); ok { + _spec.SetField(gearsetinfo.FieldCreateTime, field.TypeTime, value) + } + if _u.mutation.CreateTimeCleared() { + _spec.ClearField(gearsetinfo.FieldCreateTime, field.TypeTime) + } + if value, ok := _u.mutation.Updater(); ok { + _spec.SetField(gearsetinfo.FieldUpdater, field.TypeString, value) + } + if value, ok := _u.mutation.UpdateTime(); ok { + _spec.SetField(gearsetinfo.FieldUpdateTime, field.TypeTime, value) + } + if _u.mutation.UpdateTimeCleared() { + _spec.ClearField(gearsetinfo.FieldUpdateTime, field.TypeTime) + } + if value, ok := _u.mutation.Deleted(); ok { + _spec.SetField(gearsetinfo.FieldDeleted, field.TypeBool, value) + } + if value, ok := _u.mutation.TenantID(); ok { + _spec.SetField(gearsetinfo.FieldTenantID, field.TypeInt64, value) + } + if value, ok := _u.mutation.AddedTenantID(); ok { + _spec.AddField(gearsetinfo.FieldTenantID, field.TypeInt64, value) + } + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{gearsetinfo.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// GearSetInfoUpdateOne is the builder for updating a single GearSetInfo entity. +type GearSetInfoUpdateOne struct { + config + fields []string + hooks []Hook + mutation *GearSetInfoMutation +} + +// SetLevel sets the "level" field. +func (_u *GearSetInfoUpdateOne) SetLevel(v int) *GearSetInfoUpdateOne { + _u.mutation.ResetLevel() + _u.mutation.SetLevel(v) + return _u +} + +// SetNillableLevel sets the "level" field if the given value is not nil. +func (_u *GearSetInfoUpdateOne) SetNillableLevel(v *int) *GearSetInfoUpdateOne { + if v != nil { + _u.SetLevel(*v) + } + return _u +} + +// AddLevel adds value to the "level" field. +func (_u *GearSetInfoUpdateOne) AddLevel(v int) *GearSetInfoUpdateOne { + _u.mutation.AddLevel(v) + return _u +} + +// SetGearID sets the "gear_id" field. +func (_u *GearSetInfoUpdateOne) SetGearID(v int64) *GearSetInfoUpdateOne { + _u.mutation.ResetGearID() + _u.mutation.SetGearID(v) + return _u +} + +// SetNillableGearID sets the "gear_id" field if the given value is not nil. +func (_u *GearSetInfoUpdateOne) SetNillableGearID(v *int64) *GearSetInfoUpdateOne { + if v != nil { + _u.SetGearID(*v) + } + return _u +} + +// AddGearID adds value to the "gear_id" field. +func (_u *GearSetInfoUpdateOne) AddGearID(v int64) *GearSetInfoUpdateOne { + _u.mutation.AddGearID(v) + return _u +} + +// SetEnhance sets the "enhance" field. +func (_u *GearSetInfoUpdateOne) SetEnhance(v int) *GearSetInfoUpdateOne { + _u.mutation.ResetEnhance() + _u.mutation.SetEnhance(v) + return _u +} + +// SetNillableEnhance sets the "enhance" field if the given value is not nil. +func (_u *GearSetInfoUpdateOne) SetNillableEnhance(v *int) *GearSetInfoUpdateOne { + if v != nil { + _u.SetEnhance(*v) + } + return _u +} + +// AddEnhance adds value to the "enhance" field. +func (_u *GearSetInfoUpdateOne) AddEnhance(v int) *GearSetInfoUpdateOne { + _u.mutation.AddEnhance(v) + return _u +} + +// SetGearType sets the "gear_type" field. +func (_u *GearSetInfoUpdateOne) SetGearType(v string) *GearSetInfoUpdateOne { + _u.mutation.SetGearType(v) + return _u +} + +// SetNillableGearType sets the "gear_type" field if the given value is not nil. +func (_u *GearSetInfoUpdateOne) SetNillableGearType(v *string) *GearSetInfoUpdateOne { + if v != nil { + _u.SetGearType(*v) + } + return _u +} + +// SetGearSetType sets the "gear_set_type" field. +func (_u *GearSetInfoUpdateOne) SetGearSetType(v string) *GearSetInfoUpdateOne { + _u.mutation.SetGearSetType(v) + return _u +} + +// SetNillableGearSetType sets the "gear_set_type" field if the given value is not nil. +func (_u *GearSetInfoUpdateOne) SetNillableGearSetType(v *string) *GearSetInfoUpdateOne { + if v != nil { + _u.SetGearSetType(*v) + } + return _u +} + +// SetMainStatType sets the "main_stat_type" field. +func (_u *GearSetInfoUpdateOne) SetMainStatType(v string) *GearSetInfoUpdateOne { + _u.mutation.SetMainStatType(v) + return _u +} + +// SetNillableMainStatType sets the "main_stat_type" field if the given value is not nil. +func (_u *GearSetInfoUpdateOne) SetNillableMainStatType(v *string) *GearSetInfoUpdateOne { + if v != nil { + _u.SetMainStatType(*v) + } + return _u +} + +// SetMainStatValue sets the "main_stat_value" field. +func (_u *GearSetInfoUpdateOne) SetMainStatValue(v int) *GearSetInfoUpdateOne { + _u.mutation.ResetMainStatValue() + _u.mutation.SetMainStatValue(v) + return _u +} + +// SetNillableMainStatValue sets the "main_stat_value" field if the given value is not nil. +func (_u *GearSetInfoUpdateOne) SetNillableMainStatValue(v *int) *GearSetInfoUpdateOne { + if v != nil { + _u.SetMainStatValue(*v) + } + return _u +} + +// AddMainStatValue adds value to the "main_stat_value" field. +func (_u *GearSetInfoUpdateOne) AddMainStatValue(v int) *GearSetInfoUpdateOne { + _u.mutation.AddMainStatValue(v) + return _u +} + +// SetSubStatOneType sets the "sub_stat_one_type" field. +func (_u *GearSetInfoUpdateOne) SetSubStatOneType(v string) *GearSetInfoUpdateOne { + _u.mutation.SetSubStatOneType(v) + return _u +} + +// SetNillableSubStatOneType sets the "sub_stat_one_type" field if the given value is not nil. +func (_u *GearSetInfoUpdateOne) SetNillableSubStatOneType(v *string) *GearSetInfoUpdateOne { + if v != nil { + _u.SetSubStatOneType(*v) + } + return _u +} + +// SetSubStatOneValue sets the "sub_stat_one_value" field. +func (_u *GearSetInfoUpdateOne) SetSubStatOneValue(v int) *GearSetInfoUpdateOne { + _u.mutation.ResetSubStatOneValue() + _u.mutation.SetSubStatOneValue(v) + return _u +} + +// SetNillableSubStatOneValue sets the "sub_stat_one_value" field if the given value is not nil. +func (_u *GearSetInfoUpdateOne) SetNillableSubStatOneValue(v *int) *GearSetInfoUpdateOne { + if v != nil { + _u.SetSubStatOneValue(*v) + } + return _u +} + +// AddSubStatOneValue adds value to the "sub_stat_one_value" field. +func (_u *GearSetInfoUpdateOne) AddSubStatOneValue(v int) *GearSetInfoUpdateOne { + _u.mutation.AddSubStatOneValue(v) + return _u +} + +// SetSubStatTwoType sets the "sub_stat_two_type" field. +func (_u *GearSetInfoUpdateOne) SetSubStatTwoType(v string) *GearSetInfoUpdateOne { + _u.mutation.SetSubStatTwoType(v) + return _u +} + +// SetNillableSubStatTwoType sets the "sub_stat_two_type" field if the given value is not nil. +func (_u *GearSetInfoUpdateOne) SetNillableSubStatTwoType(v *string) *GearSetInfoUpdateOne { + if v != nil { + _u.SetSubStatTwoType(*v) + } + return _u +} + +// SetSubStatTwoValue sets the "sub_stat_two_value" field. +func (_u *GearSetInfoUpdateOne) SetSubStatTwoValue(v int) *GearSetInfoUpdateOne { + _u.mutation.ResetSubStatTwoValue() + _u.mutation.SetSubStatTwoValue(v) + return _u +} + +// SetNillableSubStatTwoValue sets the "sub_stat_two_value" field if the given value is not nil. +func (_u *GearSetInfoUpdateOne) SetNillableSubStatTwoValue(v *int) *GearSetInfoUpdateOne { + if v != nil { + _u.SetSubStatTwoValue(*v) + } + return _u +} + +// AddSubStatTwoValue adds value to the "sub_stat_two_value" field. +func (_u *GearSetInfoUpdateOne) AddSubStatTwoValue(v int) *GearSetInfoUpdateOne { + _u.mutation.AddSubStatTwoValue(v) + return _u +} + +// SetSubStatThreeType sets the "sub_stat_three_type" field. +func (_u *GearSetInfoUpdateOne) SetSubStatThreeType(v string) *GearSetInfoUpdateOne { + _u.mutation.SetSubStatThreeType(v) + return _u +} + +// SetNillableSubStatThreeType sets the "sub_stat_three_type" field if the given value is not nil. +func (_u *GearSetInfoUpdateOne) SetNillableSubStatThreeType(v *string) *GearSetInfoUpdateOne { + if v != nil { + _u.SetSubStatThreeType(*v) + } + return _u +} + +// SetSubStatThreeValue sets the "sub_stat_three_value" field. +func (_u *GearSetInfoUpdateOne) SetSubStatThreeValue(v int) *GearSetInfoUpdateOne { + _u.mutation.ResetSubStatThreeValue() + _u.mutation.SetSubStatThreeValue(v) + return _u +} + +// SetNillableSubStatThreeValue sets the "sub_stat_three_value" field if the given value is not nil. +func (_u *GearSetInfoUpdateOne) SetNillableSubStatThreeValue(v *int) *GearSetInfoUpdateOne { + if v != nil { + _u.SetSubStatThreeValue(*v) + } + return _u +} + +// AddSubStatThreeValue adds value to the "sub_stat_three_value" field. +func (_u *GearSetInfoUpdateOne) AddSubStatThreeValue(v int) *GearSetInfoUpdateOne { + _u.mutation.AddSubStatThreeValue(v) + return _u +} + +// SetSubStatFourType sets the "sub_stat_four_type" field. +func (_u *GearSetInfoUpdateOne) SetSubStatFourType(v string) *GearSetInfoUpdateOne { + _u.mutation.SetSubStatFourType(v) + return _u +} + +// SetNillableSubStatFourType sets the "sub_stat_four_type" field if the given value is not nil. +func (_u *GearSetInfoUpdateOne) SetNillableSubStatFourType(v *string) *GearSetInfoUpdateOne { + if v != nil { + _u.SetSubStatFourType(*v) + } + return _u +} + +// SetSubStatFourValue sets the "sub_stat_four_value" field. +func (_u *GearSetInfoUpdateOne) SetSubStatFourValue(v int) *GearSetInfoUpdateOne { + _u.mutation.ResetSubStatFourValue() + _u.mutation.SetSubStatFourValue(v) + return _u +} + +// SetNillableSubStatFourValue sets the "sub_stat_four_value" field if the given value is not nil. +func (_u *GearSetInfoUpdateOne) SetNillableSubStatFourValue(v *int) *GearSetInfoUpdateOne { + if v != nil { + _u.SetSubStatFourValue(*v) + } + return _u +} + +// AddSubStatFourValue adds value to the "sub_stat_four_value" field. +func (_u *GearSetInfoUpdateOne) AddSubStatFourValue(v int) *GearSetInfoUpdateOne { + _u.mutation.AddSubStatFourValue(v) + return _u +} + +// SetAccountCode sets the "account_code" field. +func (_u *GearSetInfoUpdateOne) SetAccountCode(v string) *GearSetInfoUpdateOne { + _u.mutation.SetAccountCode(v) + return _u +} + +// SetNillableAccountCode sets the "account_code" field if the given value is not nil. +func (_u *GearSetInfoUpdateOne) SetNillableAccountCode(v *string) *GearSetInfoUpdateOne { + if v != nil { + _u.SetAccountCode(*v) + } + return _u +} + +// SetCreator sets the "creator" field. +func (_u *GearSetInfoUpdateOne) SetCreator(v string) *GearSetInfoUpdateOne { + _u.mutation.SetCreator(v) + return _u +} + +// SetNillableCreator sets the "creator" field if the given value is not nil. +func (_u *GearSetInfoUpdateOne) SetNillableCreator(v *string) *GearSetInfoUpdateOne { + if v != nil { + _u.SetCreator(*v) + } + return _u +} + +// SetCreateTime sets the "create_time" field. +func (_u *GearSetInfoUpdateOne) SetCreateTime(v time.Time) *GearSetInfoUpdateOne { + _u.mutation.SetCreateTime(v) + return _u +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (_u *GearSetInfoUpdateOne) SetNillableCreateTime(v *time.Time) *GearSetInfoUpdateOne { + if v != nil { + _u.SetCreateTime(*v) + } + return _u +} + +// ClearCreateTime clears the value of the "create_time" field. +func (_u *GearSetInfoUpdateOne) ClearCreateTime() *GearSetInfoUpdateOne { + _u.mutation.ClearCreateTime() + return _u +} + +// SetUpdater sets the "updater" field. +func (_u *GearSetInfoUpdateOne) SetUpdater(v string) *GearSetInfoUpdateOne { + _u.mutation.SetUpdater(v) + return _u +} + +// SetNillableUpdater sets the "updater" field if the given value is not nil. +func (_u *GearSetInfoUpdateOne) SetNillableUpdater(v *string) *GearSetInfoUpdateOne { + if v != nil { + _u.SetUpdater(*v) + } + return _u +} + +// SetUpdateTime sets the "update_time" field. +func (_u *GearSetInfoUpdateOne) SetUpdateTime(v time.Time) *GearSetInfoUpdateOne { + _u.mutation.SetUpdateTime(v) + return _u +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (_u *GearSetInfoUpdateOne) SetNillableUpdateTime(v *time.Time) *GearSetInfoUpdateOne { + if v != nil { + _u.SetUpdateTime(*v) + } + return _u +} + +// ClearUpdateTime clears the value of the "update_time" field. +func (_u *GearSetInfoUpdateOne) ClearUpdateTime() *GearSetInfoUpdateOne { + _u.mutation.ClearUpdateTime() + return _u +} + +// SetDeleted sets the "deleted" field. +func (_u *GearSetInfoUpdateOne) SetDeleted(v bool) *GearSetInfoUpdateOne { + _u.mutation.SetDeleted(v) + return _u +} + +// SetNillableDeleted sets the "deleted" field if the given value is not nil. +func (_u *GearSetInfoUpdateOne) SetNillableDeleted(v *bool) *GearSetInfoUpdateOne { + if v != nil { + _u.SetDeleted(*v) + } + return _u +} + +// SetTenantID sets the "tenant_id" field. +func (_u *GearSetInfoUpdateOne) SetTenantID(v int64) *GearSetInfoUpdateOne { + _u.mutation.ResetTenantID() + _u.mutation.SetTenantID(v) + return _u +} + +// SetNillableTenantID sets the "tenant_id" field if the given value is not nil. +func (_u *GearSetInfoUpdateOne) SetNillableTenantID(v *int64) *GearSetInfoUpdateOne { + if v != nil { + _u.SetTenantID(*v) + } + return _u +} + +// AddTenantID adds value to the "tenant_id" field. +func (_u *GearSetInfoUpdateOne) AddTenantID(v int64) *GearSetInfoUpdateOne { + _u.mutation.AddTenantID(v) + return _u +} + +// Mutation returns the GearSetInfoMutation object of the builder. +func (_u *GearSetInfoUpdateOne) Mutation() *GearSetInfoMutation { + return _u.mutation +} + +// Where appends a list predicates to the GearSetInfoUpdate builder. +func (_u *GearSetInfoUpdateOne) Where(ps ...predicate.GearSetInfo) *GearSetInfoUpdateOne { + _u.mutation.Where(ps...) + return _u +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (_u *GearSetInfoUpdateOne) Select(field string, fields ...string) *GearSetInfoUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated GearSetInfo entity. +func (_u *GearSetInfoUpdateOne) Save(ctx context.Context) (*GearSetInfo, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *GearSetInfoUpdateOne) SaveX(ctx context.Context) *GearSetInfo { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *GearSetInfoUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *GearSetInfoUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *GearSetInfoUpdateOne) check() error { + if v, ok := _u.mutation.GearType(); ok { + if err := gearsetinfo.GearTypeValidator(v); err != nil { + return &ValidationError{Name: "gear_type", err: fmt.Errorf(`ent: validator failed for field "GearSetInfo.gear_type": %w`, err)} + } + } + if v, ok := _u.mutation.GearSetType(); ok { + if err := gearsetinfo.GearSetTypeValidator(v); err != nil { + return &ValidationError{Name: "gear_set_type", err: fmt.Errorf(`ent: validator failed for field "GearSetInfo.gear_set_type": %w`, err)} + } + } + if v, ok := _u.mutation.MainStatType(); ok { + if err := gearsetinfo.MainStatTypeValidator(v); err != nil { + return &ValidationError{Name: "main_stat_type", err: fmt.Errorf(`ent: validator failed for field "GearSetInfo.main_stat_type": %w`, err)} + } + } + if v, ok := _u.mutation.SubStatOneType(); ok { + if err := gearsetinfo.SubStatOneTypeValidator(v); err != nil { + return &ValidationError{Name: "sub_stat_one_type", err: fmt.Errorf(`ent: validator failed for field "GearSetInfo.sub_stat_one_type": %w`, err)} + } + } + if v, ok := _u.mutation.SubStatTwoType(); ok { + if err := gearsetinfo.SubStatTwoTypeValidator(v); err != nil { + return &ValidationError{Name: "sub_stat_two_type", err: fmt.Errorf(`ent: validator failed for field "GearSetInfo.sub_stat_two_type": %w`, err)} + } + } + if v, ok := _u.mutation.SubStatThreeType(); ok { + if err := gearsetinfo.SubStatThreeTypeValidator(v); err != nil { + return &ValidationError{Name: "sub_stat_three_type", err: fmt.Errorf(`ent: validator failed for field "GearSetInfo.sub_stat_three_type": %w`, err)} + } + } + if v, ok := _u.mutation.SubStatFourType(); ok { + if err := gearsetinfo.SubStatFourTypeValidator(v); err != nil { + return &ValidationError{Name: "sub_stat_four_type", err: fmt.Errorf(`ent: validator failed for field "GearSetInfo.sub_stat_four_type": %w`, err)} + } + } + if v, ok := _u.mutation.AccountCode(); ok { + if err := gearsetinfo.AccountCodeValidator(v); err != nil { + return &ValidationError{Name: "account_code", err: fmt.Errorf(`ent: validator failed for field "GearSetInfo.account_code": %w`, err)} + } + } + if v, ok := _u.mutation.Creator(); ok { + if err := gearsetinfo.CreatorValidator(v); err != nil { + return &ValidationError{Name: "creator", err: fmt.Errorf(`ent: validator failed for field "GearSetInfo.creator": %w`, err)} + } + } + if v, ok := _u.mutation.Updater(); ok { + if err := gearsetinfo.UpdaterValidator(v); err != nil { + return &ValidationError{Name: "updater", err: fmt.Errorf(`ent: validator failed for field "GearSetInfo.updater": %w`, err)} + } + } + return nil +} + +func (_u *GearSetInfoUpdateOne) sqlSave(ctx context.Context) (_node *GearSetInfo, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(gearsetinfo.Table, gearsetinfo.Columns, sqlgraph.NewFieldSpec(gearsetinfo.FieldID, field.TypeInt64)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "GearSetInfo.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := _u.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, gearsetinfo.FieldID) + for _, f := range fields { + if !gearsetinfo.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != gearsetinfo.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.Level(); ok { + _spec.SetField(gearsetinfo.FieldLevel, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedLevel(); ok { + _spec.AddField(gearsetinfo.FieldLevel, field.TypeInt, value) + } + if value, ok := _u.mutation.GearID(); ok { + _spec.SetField(gearsetinfo.FieldGearID, field.TypeInt64, value) + } + if value, ok := _u.mutation.AddedGearID(); ok { + _spec.AddField(gearsetinfo.FieldGearID, field.TypeInt64, value) + } + if value, ok := _u.mutation.Enhance(); ok { + _spec.SetField(gearsetinfo.FieldEnhance, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedEnhance(); ok { + _spec.AddField(gearsetinfo.FieldEnhance, field.TypeInt, value) + } + if value, ok := _u.mutation.GearType(); ok { + _spec.SetField(gearsetinfo.FieldGearType, field.TypeString, value) + } + if value, ok := _u.mutation.GearSetType(); ok { + _spec.SetField(gearsetinfo.FieldGearSetType, field.TypeString, value) + } + if value, ok := _u.mutation.MainStatType(); ok { + _spec.SetField(gearsetinfo.FieldMainStatType, field.TypeString, value) + } + if value, ok := _u.mutation.MainStatValue(); ok { + _spec.SetField(gearsetinfo.FieldMainStatValue, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedMainStatValue(); ok { + _spec.AddField(gearsetinfo.FieldMainStatValue, field.TypeInt, value) + } + if value, ok := _u.mutation.SubStatOneType(); ok { + _spec.SetField(gearsetinfo.FieldSubStatOneType, field.TypeString, value) + } + if value, ok := _u.mutation.SubStatOneValue(); ok { + _spec.SetField(gearsetinfo.FieldSubStatOneValue, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedSubStatOneValue(); ok { + _spec.AddField(gearsetinfo.FieldSubStatOneValue, field.TypeInt, value) + } + if value, ok := _u.mutation.SubStatTwoType(); ok { + _spec.SetField(gearsetinfo.FieldSubStatTwoType, field.TypeString, value) + } + if value, ok := _u.mutation.SubStatTwoValue(); ok { + _spec.SetField(gearsetinfo.FieldSubStatTwoValue, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedSubStatTwoValue(); ok { + _spec.AddField(gearsetinfo.FieldSubStatTwoValue, field.TypeInt, value) + } + if value, ok := _u.mutation.SubStatThreeType(); ok { + _spec.SetField(gearsetinfo.FieldSubStatThreeType, field.TypeString, value) + } + if value, ok := _u.mutation.SubStatThreeValue(); ok { + _spec.SetField(gearsetinfo.FieldSubStatThreeValue, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedSubStatThreeValue(); ok { + _spec.AddField(gearsetinfo.FieldSubStatThreeValue, field.TypeInt, value) + } + if value, ok := _u.mutation.SubStatFourType(); ok { + _spec.SetField(gearsetinfo.FieldSubStatFourType, field.TypeString, value) + } + if value, ok := _u.mutation.SubStatFourValue(); ok { + _spec.SetField(gearsetinfo.FieldSubStatFourValue, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedSubStatFourValue(); ok { + _spec.AddField(gearsetinfo.FieldSubStatFourValue, field.TypeInt, value) + } + if value, ok := _u.mutation.AccountCode(); ok { + _spec.SetField(gearsetinfo.FieldAccountCode, field.TypeString, value) + } + if value, ok := _u.mutation.Creator(); ok { + _spec.SetField(gearsetinfo.FieldCreator, field.TypeString, value) + } + if value, ok := _u.mutation.CreateTime(); ok { + _spec.SetField(gearsetinfo.FieldCreateTime, field.TypeTime, value) + } + if _u.mutation.CreateTimeCleared() { + _spec.ClearField(gearsetinfo.FieldCreateTime, field.TypeTime) + } + if value, ok := _u.mutation.Updater(); ok { + _spec.SetField(gearsetinfo.FieldUpdater, field.TypeString, value) + } + if value, ok := _u.mutation.UpdateTime(); ok { + _spec.SetField(gearsetinfo.FieldUpdateTime, field.TypeTime, value) + } + if _u.mutation.UpdateTimeCleared() { + _spec.ClearField(gearsetinfo.FieldUpdateTime, field.TypeTime) + } + if value, ok := _u.mutation.Deleted(); ok { + _spec.SetField(gearsetinfo.FieldDeleted, field.TypeBool, value) + } + if value, ok := _u.mutation.TenantID(); ok { + _spec.SetField(gearsetinfo.FieldTenantID, field.TypeInt64, value) + } + if value, ok := _u.mutation.AddedTenantID(); ok { + _spec.AddField(gearsetinfo.FieldTenantID, field.TypeInt64, value) + } + _node = &GearSetInfo{config: _u.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{gearsetinfo.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} diff --git a/internal/ent/hook/hook.go b/internal/ent/hook/hook.go new file mode 100644 index 0000000..cde922a --- /dev/null +++ b/internal/ent/hook/hook.go @@ -0,0 +1,294 @@ +// Code generated by ent, DO NOT EDIT. + +package hook + +import ( + "context" + "epic-ent/internal/ent" + "fmt" +) + +// The EpicArtifactInfoFunc type is an adapter to allow the use of ordinary +// function as EpicArtifactInfo mutator. +type EpicArtifactInfoFunc func(context.Context, *ent.EpicArtifactInfoMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f EpicArtifactInfoFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.EpicArtifactInfoMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.EpicArtifactInfoMutation", m) +} + +// The EpicGvgAttackTeamsFunc type is an adapter to allow the use of ordinary +// function as EpicGvgAttackTeams mutator. +type EpicGvgAttackTeamsFunc func(context.Context, *ent.EpicGvgAttackTeamsMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f EpicGvgAttackTeamsFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.EpicGvgAttackTeamsMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.EpicGvgAttackTeamsMutation", m) +} + +// The EpicGvgDefenseAttackMappingFunc type is an adapter to allow the use of ordinary +// function as EpicGvgDefenseAttackMapping mutator. +type EpicGvgDefenseAttackMappingFunc func(context.Context, *ent.EpicGvgDefenseAttackMappingMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f EpicGvgDefenseAttackMappingFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.EpicGvgDefenseAttackMappingMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.EpicGvgDefenseAttackMappingMutation", m) +} + +// The EpicGvgDefenseTeamsFunc type is an adapter to allow the use of ordinary +// function as EpicGvgDefenseTeams mutator. +type EpicGvgDefenseTeamsFunc func(context.Context, *ent.EpicGvgDefenseTeamsMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f EpicGvgDefenseTeamsFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.EpicGvgDefenseTeamsMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.EpicGvgDefenseTeamsMutation", m) +} + +// The EpicHeroInfoFunc type is an adapter to allow the use of ordinary +// function as EpicHeroInfo mutator. +type EpicHeroInfoFunc func(context.Context, *ent.EpicHeroInfoMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f EpicHeroInfoFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.EpicHeroInfoMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.EpicHeroInfoMutation", m) +} + +// The EpicHeroUserBuildFunc type is an adapter to allow the use of ordinary +// function as EpicHeroUserBuild mutator. +type EpicHeroUserBuildFunc func(context.Context, *ent.EpicHeroUserBuildMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f EpicHeroUserBuildFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.EpicHeroUserBuildMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.EpicHeroUserBuildMutation", m) +} + +// The EpicI18NMappingsFunc type is an adapter to allow the use of ordinary +// function as EpicI18NMappings mutator. +type EpicI18NMappingsFunc func(context.Context, *ent.EpicI18NMappingsMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f EpicI18NMappingsFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.EpicI18NMappingsMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.EpicI18NMappingsMutation", m) +} + +// The FribbleHeroSetFunc type is an adapter to allow the use of ordinary +// function as FribbleHeroSet mutator. +type FribbleHeroSetFunc func(context.Context, *ent.FribbleHeroSetMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f FribbleHeroSetFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.FribbleHeroSetMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.FribbleHeroSetMutation", m) +} + +// The GearSetInfoFunc type is an adapter to allow the use of ordinary +// function as GearSetInfo mutator. +type GearSetInfoFunc func(context.Context, *ent.GearSetInfoMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f GearSetInfoFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.GearSetInfoMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.GearSetInfoMutation", m) +} + +// Condition is a hook condition function. +type Condition func(context.Context, ent.Mutation) bool + +// And groups conditions with the AND operator. +func And(first, second Condition, rest ...Condition) Condition { + return func(ctx context.Context, m ent.Mutation) bool { + if !first(ctx, m) || !second(ctx, m) { + return false + } + for _, cond := range rest { + if !cond(ctx, m) { + return false + } + } + return true + } +} + +// Or groups conditions with the OR operator. +func Or(first, second Condition, rest ...Condition) Condition { + return func(ctx context.Context, m ent.Mutation) bool { + if first(ctx, m) || second(ctx, m) { + return true + } + for _, cond := range rest { + if cond(ctx, m) { + return true + } + } + return false + } +} + +// Not negates a given condition. +func Not(cond Condition) Condition { + return func(ctx context.Context, m ent.Mutation) bool { + return !cond(ctx, m) + } +} + +// HasOp is a condition testing mutation operation. +func HasOp(op ent.Op) Condition { + return func(_ context.Context, m ent.Mutation) bool { + return m.Op().Is(op) + } +} + +// HasAddedFields is a condition validating `.AddedField` on fields. +func HasAddedFields(field string, fields ...string) Condition { + return func(_ context.Context, m ent.Mutation) bool { + if _, exists := m.AddedField(field); !exists { + return false + } + for _, field := range fields { + if _, exists := m.AddedField(field); !exists { + return false + } + } + return true + } +} + +// HasClearedFields is a condition validating `.FieldCleared` on fields. +func HasClearedFields(field string, fields ...string) Condition { + return func(_ context.Context, m ent.Mutation) bool { + if exists := m.FieldCleared(field); !exists { + return false + } + for _, field := range fields { + if exists := m.FieldCleared(field); !exists { + return false + } + } + return true + } +} + +// HasFields is a condition validating `.Field` on fields. +func HasFields(field string, fields ...string) Condition { + return func(_ context.Context, m ent.Mutation) bool { + if _, exists := m.Field(field); !exists { + return false + } + for _, field := range fields { + if _, exists := m.Field(field); !exists { + return false + } + } + return true + } +} + +// If executes the given hook under condition. +// +// hook.If(ComputeAverage, And(HasFields(...), HasAddedFields(...))) +func If(hk ent.Hook, cond Condition) ent.Hook { + return func(next ent.Mutator) ent.Mutator { + return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if cond(ctx, m) { + return hk(next).Mutate(ctx, m) + } + return next.Mutate(ctx, m) + }) + } +} + +// On executes the given hook only for the given operation. +// +// hook.On(Log, ent.Delete|ent.Create) +func On(hk ent.Hook, op ent.Op) ent.Hook { + return If(hk, HasOp(op)) +} + +// Unless skips the given hook only for the given operation. +// +// hook.Unless(Log, ent.Update|ent.UpdateOne) +func Unless(hk ent.Hook, op ent.Op) ent.Hook { + return If(hk, Not(HasOp(op))) +} + +// FixedError is a hook returning a fixed error. +func FixedError(err error) ent.Hook { + return func(ent.Mutator) ent.Mutator { + return ent.MutateFunc(func(context.Context, ent.Mutation) (ent.Value, error) { + return nil, err + }) + } +} + +// Reject returns a hook that rejects all operations that match op. +// +// func (T) Hooks() []ent.Hook { +// return []ent.Hook{ +// Reject(ent.Delete|ent.Update), +// } +// } +func Reject(op ent.Op) ent.Hook { + hk := FixedError(fmt.Errorf("%s operation is not allowed", op)) + return On(hk, op) +} + +// Chain acts as a list of hooks and is effectively immutable. +// Once created, it will always hold the same set of hooks in the same order. +type Chain struct { + hooks []ent.Hook +} + +// NewChain creates a new chain of hooks. +func NewChain(hooks ...ent.Hook) Chain { + return Chain{append([]ent.Hook(nil), hooks...)} +} + +// Hook chains the list of hooks and returns the final hook. +func (c Chain) Hook() ent.Hook { + return func(mutator ent.Mutator) ent.Mutator { + for i := len(c.hooks) - 1; i >= 0; i-- { + mutator = c.hooks[i](mutator) + } + return mutator + } +} + +// Append extends a chain, adding the specified hook +// as the last ones in the mutation flow. +func (c Chain) Append(hooks ...ent.Hook) Chain { + newHooks := make([]ent.Hook, 0, len(c.hooks)+len(hooks)) + newHooks = append(newHooks, c.hooks...) + newHooks = append(newHooks, hooks...) + return Chain{newHooks} +} + +// Extend extends a chain, adding the specified chain +// as the last ones in the mutation flow. +func (c Chain) Extend(chain Chain) Chain { + return c.Append(chain.hooks...) +} diff --git a/internal/ent/migrate/migrate.go b/internal/ent/migrate/migrate.go new file mode 100644 index 0000000..1956a6b --- /dev/null +++ b/internal/ent/migrate/migrate.go @@ -0,0 +1,64 @@ +// Code generated by ent, DO NOT EDIT. + +package migrate + +import ( + "context" + "fmt" + "io" + + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql/schema" +) + +var ( + // WithGlobalUniqueID sets the universal ids options to the migration. + // If this option is enabled, ent migration will allocate a 1<<32 range + // for the ids of each entity (table). + // Note that this option cannot be applied on tables that already exist. + WithGlobalUniqueID = schema.WithGlobalUniqueID + // WithDropColumn sets the drop column option to the migration. + // If this option is enabled, ent migration will drop old columns + // that were used for both fields and edges. This defaults to false. + WithDropColumn = schema.WithDropColumn + // WithDropIndex sets the drop index option to the migration. + // If this option is enabled, ent migration will drop old indexes + // that were defined in the schema. This defaults to false. + // Note that unique constraints are defined using `UNIQUE INDEX`, + // and therefore, it's recommended to enable this option to get more + // flexibility in the schema changes. + WithDropIndex = schema.WithDropIndex + // WithForeignKeys enables creating foreign-key in schema DDL. This defaults to true. + WithForeignKeys = schema.WithForeignKeys +) + +// Schema is the API for creating, migrating and dropping a schema. +type Schema struct { + drv dialect.Driver +} + +// NewSchema creates a new schema client. +func NewSchema(drv dialect.Driver) *Schema { return &Schema{drv: drv} } + +// Create creates all schema resources. +func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error { + return Create(ctx, s, Tables, opts...) +} + +// Create creates all table resources using the given schema driver. +func Create(ctx context.Context, s *Schema, tables []*schema.Table, opts ...schema.MigrateOption) error { + migrate, err := schema.NewMigrate(s.drv, opts...) + if err != nil { + return fmt.Errorf("ent/migrate: %w", err) + } + return migrate.Create(ctx, tables...) +} + +// WriteTo writes the schema changes to w instead of running them against the database. +// +// if err := client.Schema.WriteTo(context.Background(), os.Stdout); err != nil { +// log.Fatal(err) +// } +func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error { + return Create(ctx, &Schema{drv: &schema.WriteDriver{Writer: w, Driver: s.drv}}, Tables, opts...) +} diff --git a/internal/ent/migrate/schema.go b/internal/ent/migrate/schema.go new file mode 100644 index 0000000..0e80fe5 --- /dev/null +++ b/internal/ent/migrate/schema.go @@ -0,0 +1,224 @@ +// Code generated by ent, DO NOT EDIT. + +package migrate + +import ( + "entgo.io/ent/dialect/sql/schema" + "entgo.io/ent/schema/field" +) + +var ( + // EpicArtifactInfosColumns holds the columns for the "epic_artifact_infos" table. + EpicArtifactInfosColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt64, Increment: true}, + {Name: "artifact_name", Type: field.TypeString, Size: 255}, + {Name: "artifact_code", Type: field.TypeString, Size: 255}, + {Name: "creator", Type: field.TypeString, Size: 255}, + {Name: "create_time", Type: field.TypeTime, Nullable: true}, + {Name: "updater", Type: field.TypeString, Size: 255}, + {Name: "update_time", Type: field.TypeTime, Nullable: true}, + {Name: "deleted", Type: field.TypeBool}, + {Name: "stats_health", Type: field.TypeInt}, + {Name: "stats_attack", Type: field.TypeInt}, + {Name: "stats_defense", Type: field.TypeInt}, + {Name: "rarity", Type: field.TypeString, Size: 255}, + {Name: "role", Type: field.TypeString, Size: 255}, + {Name: "artifact_name_en", Type: field.TypeString, Size: 255}, + {Name: "image_url", Type: field.TypeString, Size: 255}, + } + // EpicArtifactInfosTable holds the schema information for the "epic_artifact_infos" table. + EpicArtifactInfosTable = &schema.Table{ + Name: "epic_artifact_infos", + Columns: EpicArtifactInfosColumns, + PrimaryKey: []*schema.Column{EpicArtifactInfosColumns[0]}, + } + // EpicGvgAttackTeamsColumns holds the columns for the "epic_gvg_attack_teams" table. + EpicGvgAttackTeamsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt64, Increment: true}, + {Name: "attack_heroes", Type: field.TypeString, Size: 255}, + {Name: "creator", Type: field.TypeString, Size: 255}, + {Name: "create_time", Type: field.TypeTime, Nullable: true}, + {Name: "updater", Type: field.TypeString, Size: 255}, + {Name: "update_time", Type: field.TypeTime, Nullable: true}, + {Name: "deleted", Type: field.TypeBool}, + } + // EpicGvgAttackTeamsTable holds the schema information for the "epic_gvg_attack_teams" table. + EpicGvgAttackTeamsTable = &schema.Table{ + Name: "epic_gvg_attack_teams", + Columns: EpicGvgAttackTeamsColumns, + PrimaryKey: []*schema.Column{EpicGvgAttackTeamsColumns[0]}, + } + // EpicGvgDefenseAttackMappingsColumns holds the columns for the "epic_gvg_defense_attack_mappings" table. + EpicGvgDefenseAttackMappingsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt64, Increment: true}, + {Name: "defense_id", Type: field.TypeInt64}, + {Name: "attack_id", Type: field.TypeInt64}, + {Name: "equipment_info", Type: field.TypeString, Size: 255}, + {Name: "artifacts", Type: field.TypeString, Size: 255}, + {Name: "battle_strategy", Type: field.TypeString, Size: 255}, + {Name: "prerequisites", Type: field.TypeString, Size: 255}, + {Name: "important_notes", Type: field.TypeString, Size: 255}, + {Name: "creator", Type: field.TypeString, Size: 255}, + {Name: "create_time", Type: field.TypeTime, Nullable: true}, + {Name: "updater", Type: field.TypeString, Size: 255}, + {Name: "update_time", Type: field.TypeTime, Nullable: true}, + {Name: "deleted", Type: field.TypeBool}, + } + // EpicGvgDefenseAttackMappingsTable holds the schema information for the "epic_gvg_defense_attack_mappings" table. + EpicGvgDefenseAttackMappingsTable = &schema.Table{ + Name: "epic_gvg_defense_attack_mappings", + Columns: EpicGvgDefenseAttackMappingsColumns, + PrimaryKey: []*schema.Column{EpicGvgDefenseAttackMappingsColumns[0]}, + } + // EpicGvgDefenseTeamsColumns holds the columns for the "epic_gvg_defense_teams" table. + EpicGvgDefenseTeamsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt64, Increment: true}, + {Name: "defense_heroes", Type: field.TypeString, Size: 255}, + {Name: "creator", Type: field.TypeString, Size: 255}, + {Name: "create_time", Type: field.TypeTime, Nullable: true}, + {Name: "updater", Type: field.TypeString, Size: 255}, + {Name: "update_time", Type: field.TypeTime, Nullable: true}, + {Name: "deleted", Type: field.TypeBool}, + } + // EpicGvgDefenseTeamsTable holds the schema information for the "epic_gvg_defense_teams" table. + EpicGvgDefenseTeamsTable = &schema.Table{ + Name: "epic_gvg_defense_teams", + Columns: EpicGvgDefenseTeamsColumns, + PrimaryKey: []*schema.Column{EpicGvgDefenseTeamsColumns[0]}, + } + // EpicHeroInfosColumns holds the columns for the "epic_hero_infos" table. + EpicHeroInfosColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt64, Increment: true}, + {Name: "hero_name", Type: field.TypeString, Size: 255}, + {Name: "hero_code", Type: field.TypeString, Size: 255}, + {Name: "hero_attr_lv60", Type: field.TypeString, Size: 255}, + {Name: "creator", Type: field.TypeString, Size: 255}, + {Name: "create_time", Type: field.TypeTime, Nullable: true}, + {Name: "updater", Type: field.TypeString, Size: 255}, + {Name: "update_time", Type: field.TypeTime, Nullable: true}, + {Name: "deleted", Type: field.TypeBool}, + {Name: "nick_name", Type: field.TypeString, Size: 255}, + {Name: "rarity", Type: field.TypeString, Size: 255}, + {Name: "role", Type: field.TypeString, Size: 255}, + {Name: "zodiac", Type: field.TypeString, Size: 255}, + {Name: "head_img_url", Type: field.TypeString, Size: 255}, + {Name: "attribute", Type: field.TypeString, Size: 255}, + {Name: "remark", Type: field.TypeString, Size: 255}, + {Name: "raw_json", Type: field.TypeString, Size: 255}, + {Name: "set_content_json", Type: field.TypeString, Size: 255}, + {Name: "set_update_time", Type: field.TypeTime, Nullable: true}, + } + // EpicHeroInfosTable holds the schema information for the "epic_hero_infos" table. + EpicHeroInfosTable = &schema.Table{ + Name: "epic_hero_infos", + Columns: EpicHeroInfosColumns, + PrimaryKey: []*schema.Column{EpicHeroInfosColumns[0]}, + } + // EpicHeroUserBuildsColumns holds the columns for the "epic_hero_user_builds" table. + EpicHeroUserBuildsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt64, Increment: true}, + {Name: "artifact_code", Type: field.TypeString, Size: 255}, + {Name: "hero_code", Type: field.TypeString, Size: 255}, + {Name: "hero_heath_build", Type: field.TypeFloat64}, + {Name: "hero_attack_build", Type: field.TypeFloat64}, + {Name: "hero_def_build", Type: field.TypeFloat64}, + {Name: "creator", Type: field.TypeString, Size: 255}, + {Name: "create_time", Type: field.TypeTime, Nullable: true}, + {Name: "updater", Type: field.TypeString, Size: 255}, + {Name: "update_time", Type: field.TypeTime, Nullable: true}, + {Name: "deleted", Type: field.TypeBool}, + } + // EpicHeroUserBuildsTable holds the schema information for the "epic_hero_user_builds" table. + EpicHeroUserBuildsTable = &schema.Table{ + Name: "epic_hero_user_builds", + Columns: EpicHeroUserBuildsColumns, + PrimaryKey: []*schema.Column{EpicHeroUserBuildsColumns[0]}, + } + // EpicI18nMappingsColumns holds the columns for the "epic_i18n_mappings" table. + EpicI18nMappingsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt64, Increment: true}, + {Name: "key_name", Type: field.TypeString, Size: 255}, + {Name: "language", Type: field.TypeString, Size: 255}, + {Name: "value", Type: field.TypeString, Size: 255}, + {Name: "category", Type: field.TypeString, Size: 255}, + {Name: "status", Type: field.TypeInt}, + {Name: "creator", Type: field.TypeString, Size: 255}, + {Name: "create_time", Type: field.TypeTime, Nullable: true}, + {Name: "updater", Type: field.TypeString, Size: 255}, + {Name: "update_time", Type: field.TypeTime, Nullable: true}, + {Name: "deleted", Type: field.TypeInt}, + {Name: "code", Type: field.TypeString, Size: 255}, + } + // EpicI18nMappingsTable holds the schema information for the "epic_i18n_mappings" table. + EpicI18nMappingsTable = &schema.Table{ + Name: "epic_i18n_mappings", + Columns: EpicI18nMappingsColumns, + PrimaryKey: []*schema.Column{EpicI18nMappingsColumns[0]}, + } + // FribbleHeroSetsColumns holds the columns for the "fribble_hero_sets" table. + FribbleHeroSetsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt64, Increment: true}, + {Name: "hero_code", Type: field.TypeString, Size: 255}, + {Name: "json_content", Type: field.TypeString, Size: 255}, + {Name: "hero_name", Type: field.TypeString, Size: 255}, + {Name: "creator", Type: field.TypeString, Size: 255}, + {Name: "create_time", Type: field.TypeTime, Nullable: true}, + {Name: "updater", Type: field.TypeString, Size: 255}, + {Name: "update_time", Type: field.TypeTime, Nullable: true}, + {Name: "deleted", Type: field.TypeBool}, + {Name: "success_get", Type: field.TypeInt}, + } + // FribbleHeroSetsTable holds the schema information for the "fribble_hero_sets" table. + FribbleHeroSetsTable = &schema.Table{ + Name: "fribble_hero_sets", + Columns: FribbleHeroSetsColumns, + PrimaryKey: []*schema.Column{FribbleHeroSetsColumns[0]}, + } + // GearSetInfosColumns holds the columns for the "gear_set_infos" table. + GearSetInfosColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt64, Increment: true}, + {Name: "level", Type: field.TypeInt}, + {Name: "gear_id", Type: field.TypeInt64}, + {Name: "enhance", Type: field.TypeInt}, + {Name: "gear_type", Type: field.TypeString, Size: 255}, + {Name: "gear_set_type", Type: field.TypeString, Size: 255}, + {Name: "main_stat_type", Type: field.TypeString, Size: 255}, + {Name: "main_stat_value", Type: field.TypeInt}, + {Name: "sub_stat_one_type", Type: field.TypeString, Size: 255}, + {Name: "sub_stat_one_value", Type: field.TypeInt}, + {Name: "sub_stat_two_type", Type: field.TypeString, Size: 255}, + {Name: "sub_stat_two_value", Type: field.TypeInt}, + {Name: "sub_stat_three_type", Type: field.TypeString, Size: 255}, + {Name: "sub_stat_three_value", Type: field.TypeInt}, + {Name: "sub_stat_four_type", Type: field.TypeString, Size: 255}, + {Name: "sub_stat_four_value", Type: field.TypeInt}, + {Name: "account_code", Type: field.TypeString, Size: 255}, + {Name: "creator", Type: field.TypeString, Size: 255}, + {Name: "create_time", Type: field.TypeTime, Nullable: true}, + {Name: "updater", Type: field.TypeString, Size: 255}, + {Name: "update_time", Type: field.TypeTime, Nullable: true}, + {Name: "deleted", Type: field.TypeBool}, + {Name: "tenant_id", Type: field.TypeInt64}, + } + // GearSetInfosTable holds the schema information for the "gear_set_infos" table. + GearSetInfosTable = &schema.Table{ + Name: "gear_set_infos", + Columns: GearSetInfosColumns, + PrimaryKey: []*schema.Column{GearSetInfosColumns[0]}, + } + // Tables holds all the tables in the schema. + Tables = []*schema.Table{ + EpicArtifactInfosTable, + EpicGvgAttackTeamsTable, + EpicGvgDefenseAttackMappingsTable, + EpicGvgDefenseTeamsTable, + EpicHeroInfosTable, + EpicHeroUserBuildsTable, + EpicI18nMappingsTable, + FribbleHeroSetsTable, + GearSetInfosTable, + } +) + +func init() { +} diff --git a/internal/ent/mutation.go b/internal/ent/mutation.go new file mode 100644 index 0000000..f64787f --- /dev/null +++ b/internal/ent/mutation.go @@ -0,0 +1,9444 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "epic-ent/internal/ent/epicartifactinfo" + "epic-ent/internal/ent/epicgvgattackteams" + "epic-ent/internal/ent/epicgvgdefenseattackmapping" + "epic-ent/internal/ent/epicgvgdefenseteams" + "epic-ent/internal/ent/epicheroinfo" + "epic-ent/internal/ent/epicherouserbuild" + "epic-ent/internal/ent/epici18nmappings" + "epic-ent/internal/ent/fribbleheroset" + "epic-ent/internal/ent/gearsetinfo" + "epic-ent/internal/ent/predicate" + "errors" + "fmt" + "sync" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +const ( + // Operation types. + OpCreate = ent.OpCreate + OpDelete = ent.OpDelete + OpDeleteOne = ent.OpDeleteOne + OpUpdate = ent.OpUpdate + OpUpdateOne = ent.OpUpdateOne + + // Node types. + TypeEpicArtifactInfo = "EpicArtifactInfo" + TypeEpicGvgAttackTeams = "EpicGvgAttackTeams" + TypeEpicGvgDefenseAttackMapping = "EpicGvgDefenseAttackMapping" + TypeEpicGvgDefenseTeams = "EpicGvgDefenseTeams" + TypeEpicHeroInfo = "EpicHeroInfo" + TypeEpicHeroUserBuild = "EpicHeroUserBuild" + TypeEpicI18NMappings = "EpicI18NMappings" + TypeFribbleHeroSet = "FribbleHeroSet" + TypeGearSetInfo = "GearSetInfo" +) + +// EpicArtifactInfoMutation represents an operation that mutates the EpicArtifactInfo nodes in the graph. +type EpicArtifactInfoMutation struct { + config + op Op + typ string + id *int64 + artifact_name *string + artifact_code *string + creator *string + create_time *time.Time + updater *string + update_time *time.Time + deleted *bool + stats_health *int + addstats_health *int + stats_attack *int + addstats_attack *int + stats_defense *int + addstats_defense *int + rarity *string + role *string + artifact_name_en *string + image_url *string + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*EpicArtifactInfo, error) + predicates []predicate.EpicArtifactInfo +} + +var _ ent.Mutation = (*EpicArtifactInfoMutation)(nil) + +// epicartifactinfoOption allows management of the mutation configuration using functional options. +type epicartifactinfoOption func(*EpicArtifactInfoMutation) + +// newEpicArtifactInfoMutation creates new mutation for the EpicArtifactInfo entity. +func newEpicArtifactInfoMutation(c config, op Op, opts ...epicartifactinfoOption) *EpicArtifactInfoMutation { + m := &EpicArtifactInfoMutation{ + config: c, + op: op, + typ: TypeEpicArtifactInfo, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withEpicArtifactInfoID sets the ID field of the mutation. +func withEpicArtifactInfoID(id int64) epicartifactinfoOption { + return func(m *EpicArtifactInfoMutation) { + var ( + err error + once sync.Once + value *EpicArtifactInfo + ) + m.oldValue = func(ctx context.Context) (*EpicArtifactInfo, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().EpicArtifactInfo.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withEpicArtifactInfo sets the old EpicArtifactInfo of the mutation. +func withEpicArtifactInfo(node *EpicArtifactInfo) epicartifactinfoOption { + return func(m *EpicArtifactInfoMutation) { + m.oldValue = func(context.Context) (*EpicArtifactInfo, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m EpicArtifactInfoMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m EpicArtifactInfoMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of EpicArtifactInfo entities. +func (m *EpicArtifactInfoMutation) SetID(id int64) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *EpicArtifactInfoMutation) ID() (id int64, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *EpicArtifactInfoMutation) IDs(ctx context.Context) ([]int64, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int64{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().EpicArtifactInfo.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetArtifactName sets the "artifact_name" field. +func (m *EpicArtifactInfoMutation) SetArtifactName(s string) { + m.artifact_name = &s +} + +// ArtifactName returns the value of the "artifact_name" field in the mutation. +func (m *EpicArtifactInfoMutation) ArtifactName() (r string, exists bool) { + v := m.artifact_name + if v == nil { + return + } + return *v, true +} + +// OldArtifactName returns the old "artifact_name" field's value of the EpicArtifactInfo entity. +// If the EpicArtifactInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicArtifactInfoMutation) OldArtifactName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldArtifactName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldArtifactName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldArtifactName: %w", err) + } + return oldValue.ArtifactName, nil +} + +// ResetArtifactName resets all changes to the "artifact_name" field. +func (m *EpicArtifactInfoMutation) ResetArtifactName() { + m.artifact_name = nil +} + +// SetArtifactCode sets the "artifact_code" field. +func (m *EpicArtifactInfoMutation) SetArtifactCode(s string) { + m.artifact_code = &s +} + +// ArtifactCode returns the value of the "artifact_code" field in the mutation. +func (m *EpicArtifactInfoMutation) ArtifactCode() (r string, exists bool) { + v := m.artifact_code + if v == nil { + return + } + return *v, true +} + +// OldArtifactCode returns the old "artifact_code" field's value of the EpicArtifactInfo entity. +// If the EpicArtifactInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicArtifactInfoMutation) OldArtifactCode(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldArtifactCode is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldArtifactCode requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldArtifactCode: %w", err) + } + return oldValue.ArtifactCode, nil +} + +// ResetArtifactCode resets all changes to the "artifact_code" field. +func (m *EpicArtifactInfoMutation) ResetArtifactCode() { + m.artifact_code = nil +} + +// SetCreator sets the "creator" field. +func (m *EpicArtifactInfoMutation) SetCreator(s string) { + m.creator = &s +} + +// Creator returns the value of the "creator" field in the mutation. +func (m *EpicArtifactInfoMutation) Creator() (r string, exists bool) { + v := m.creator + if v == nil { + return + } + return *v, true +} + +// OldCreator returns the old "creator" field's value of the EpicArtifactInfo entity. +// If the EpicArtifactInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicArtifactInfoMutation) OldCreator(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreator is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreator requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreator: %w", err) + } + return oldValue.Creator, nil +} + +// ResetCreator resets all changes to the "creator" field. +func (m *EpicArtifactInfoMutation) ResetCreator() { + m.creator = nil +} + +// SetCreateTime sets the "create_time" field. +func (m *EpicArtifactInfoMutation) SetCreateTime(t time.Time) { + m.create_time = &t +} + +// CreateTime returns the value of the "create_time" field in the mutation. +func (m *EpicArtifactInfoMutation) CreateTime() (r time.Time, exists bool) { + v := m.create_time + if v == nil { + return + } + return *v, true +} + +// OldCreateTime returns the old "create_time" field's value of the EpicArtifactInfo entity. +// If the EpicArtifactInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicArtifactInfoMutation) OldCreateTime(ctx context.Context) (v *time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) + } + return oldValue.CreateTime, nil +} + +// ClearCreateTime clears the value of the "create_time" field. +func (m *EpicArtifactInfoMutation) ClearCreateTime() { + m.create_time = nil + m.clearedFields[epicartifactinfo.FieldCreateTime] = struct{}{} +} + +// CreateTimeCleared returns if the "create_time" field was cleared in this mutation. +func (m *EpicArtifactInfoMutation) CreateTimeCleared() bool { + _, ok := m.clearedFields[epicartifactinfo.FieldCreateTime] + return ok +} + +// ResetCreateTime resets all changes to the "create_time" field. +func (m *EpicArtifactInfoMutation) ResetCreateTime() { + m.create_time = nil + delete(m.clearedFields, epicartifactinfo.FieldCreateTime) +} + +// SetUpdater sets the "updater" field. +func (m *EpicArtifactInfoMutation) SetUpdater(s string) { + m.updater = &s +} + +// Updater returns the value of the "updater" field in the mutation. +func (m *EpicArtifactInfoMutation) Updater() (r string, exists bool) { + v := m.updater + if v == nil { + return + } + return *v, true +} + +// OldUpdater returns the old "updater" field's value of the EpicArtifactInfo entity. +// If the EpicArtifactInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicArtifactInfoMutation) OldUpdater(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdater is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdater requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdater: %w", err) + } + return oldValue.Updater, nil +} + +// ResetUpdater resets all changes to the "updater" field. +func (m *EpicArtifactInfoMutation) ResetUpdater() { + m.updater = nil +} + +// SetUpdateTime sets the "update_time" field. +func (m *EpicArtifactInfoMutation) SetUpdateTime(t time.Time) { + m.update_time = &t +} + +// UpdateTime returns the value of the "update_time" field in the mutation. +func (m *EpicArtifactInfoMutation) UpdateTime() (r time.Time, exists bool) { + v := m.update_time + if v == nil { + return + } + return *v, true +} + +// OldUpdateTime returns the old "update_time" field's value of the EpicArtifactInfo entity. +// If the EpicArtifactInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicArtifactInfoMutation) OldUpdateTime(ctx context.Context) (v *time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err) + } + return oldValue.UpdateTime, nil +} + +// ClearUpdateTime clears the value of the "update_time" field. +func (m *EpicArtifactInfoMutation) ClearUpdateTime() { + m.update_time = nil + m.clearedFields[epicartifactinfo.FieldUpdateTime] = struct{}{} +} + +// UpdateTimeCleared returns if the "update_time" field was cleared in this mutation. +func (m *EpicArtifactInfoMutation) UpdateTimeCleared() bool { + _, ok := m.clearedFields[epicartifactinfo.FieldUpdateTime] + return ok +} + +// ResetUpdateTime resets all changes to the "update_time" field. +func (m *EpicArtifactInfoMutation) ResetUpdateTime() { + m.update_time = nil + delete(m.clearedFields, epicartifactinfo.FieldUpdateTime) +} + +// SetDeleted sets the "deleted" field. +func (m *EpicArtifactInfoMutation) SetDeleted(b bool) { + m.deleted = &b +} + +// Deleted returns the value of the "deleted" field in the mutation. +func (m *EpicArtifactInfoMutation) Deleted() (r bool, exists bool) { + v := m.deleted + if v == nil { + return + } + return *v, true +} + +// OldDeleted returns the old "deleted" field's value of the EpicArtifactInfo entity. +// If the EpicArtifactInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicArtifactInfoMutation) OldDeleted(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeleted is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeleted requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeleted: %w", err) + } + return oldValue.Deleted, nil +} + +// ResetDeleted resets all changes to the "deleted" field. +func (m *EpicArtifactInfoMutation) ResetDeleted() { + m.deleted = nil +} + +// SetStatsHealth sets the "stats_health" field. +func (m *EpicArtifactInfoMutation) SetStatsHealth(i int) { + m.stats_health = &i + m.addstats_health = nil +} + +// StatsHealth returns the value of the "stats_health" field in the mutation. +func (m *EpicArtifactInfoMutation) StatsHealth() (r int, exists bool) { + v := m.stats_health + if v == nil { + return + } + return *v, true +} + +// OldStatsHealth returns the old "stats_health" field's value of the EpicArtifactInfo entity. +// If the EpicArtifactInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicArtifactInfoMutation) OldStatsHealth(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldStatsHealth is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldStatsHealth requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldStatsHealth: %w", err) + } + return oldValue.StatsHealth, nil +} + +// AddStatsHealth adds i to the "stats_health" field. +func (m *EpicArtifactInfoMutation) AddStatsHealth(i int) { + if m.addstats_health != nil { + *m.addstats_health += i + } else { + m.addstats_health = &i + } +} + +// AddedStatsHealth returns the value that was added to the "stats_health" field in this mutation. +func (m *EpicArtifactInfoMutation) AddedStatsHealth() (r int, exists bool) { + v := m.addstats_health + if v == nil { + return + } + return *v, true +} + +// ResetStatsHealth resets all changes to the "stats_health" field. +func (m *EpicArtifactInfoMutation) ResetStatsHealth() { + m.stats_health = nil + m.addstats_health = nil +} + +// SetStatsAttack sets the "stats_attack" field. +func (m *EpicArtifactInfoMutation) SetStatsAttack(i int) { + m.stats_attack = &i + m.addstats_attack = nil +} + +// StatsAttack returns the value of the "stats_attack" field in the mutation. +func (m *EpicArtifactInfoMutation) StatsAttack() (r int, exists bool) { + v := m.stats_attack + if v == nil { + return + } + return *v, true +} + +// OldStatsAttack returns the old "stats_attack" field's value of the EpicArtifactInfo entity. +// If the EpicArtifactInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicArtifactInfoMutation) OldStatsAttack(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldStatsAttack is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldStatsAttack requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldStatsAttack: %w", err) + } + return oldValue.StatsAttack, nil +} + +// AddStatsAttack adds i to the "stats_attack" field. +func (m *EpicArtifactInfoMutation) AddStatsAttack(i int) { + if m.addstats_attack != nil { + *m.addstats_attack += i + } else { + m.addstats_attack = &i + } +} + +// AddedStatsAttack returns the value that was added to the "stats_attack" field in this mutation. +func (m *EpicArtifactInfoMutation) AddedStatsAttack() (r int, exists bool) { + v := m.addstats_attack + if v == nil { + return + } + return *v, true +} + +// ResetStatsAttack resets all changes to the "stats_attack" field. +func (m *EpicArtifactInfoMutation) ResetStatsAttack() { + m.stats_attack = nil + m.addstats_attack = nil +} + +// SetStatsDefense sets the "stats_defense" field. +func (m *EpicArtifactInfoMutation) SetStatsDefense(i int) { + m.stats_defense = &i + m.addstats_defense = nil +} + +// StatsDefense returns the value of the "stats_defense" field in the mutation. +func (m *EpicArtifactInfoMutation) StatsDefense() (r int, exists bool) { + v := m.stats_defense + if v == nil { + return + } + return *v, true +} + +// OldStatsDefense returns the old "stats_defense" field's value of the EpicArtifactInfo entity. +// If the EpicArtifactInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicArtifactInfoMutation) OldStatsDefense(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldStatsDefense is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldStatsDefense requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldStatsDefense: %w", err) + } + return oldValue.StatsDefense, nil +} + +// AddStatsDefense adds i to the "stats_defense" field. +func (m *EpicArtifactInfoMutation) AddStatsDefense(i int) { + if m.addstats_defense != nil { + *m.addstats_defense += i + } else { + m.addstats_defense = &i + } +} + +// AddedStatsDefense returns the value that was added to the "stats_defense" field in this mutation. +func (m *EpicArtifactInfoMutation) AddedStatsDefense() (r int, exists bool) { + v := m.addstats_defense + if v == nil { + return + } + return *v, true +} + +// ResetStatsDefense resets all changes to the "stats_defense" field. +func (m *EpicArtifactInfoMutation) ResetStatsDefense() { + m.stats_defense = nil + m.addstats_defense = nil +} + +// SetRarity sets the "rarity" field. +func (m *EpicArtifactInfoMutation) SetRarity(s string) { + m.rarity = &s +} + +// Rarity returns the value of the "rarity" field in the mutation. +func (m *EpicArtifactInfoMutation) Rarity() (r string, exists bool) { + v := m.rarity + if v == nil { + return + } + return *v, true +} + +// OldRarity returns the old "rarity" field's value of the EpicArtifactInfo entity. +// If the EpicArtifactInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicArtifactInfoMutation) OldRarity(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRarity is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRarity requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRarity: %w", err) + } + return oldValue.Rarity, nil +} + +// ResetRarity resets all changes to the "rarity" field. +func (m *EpicArtifactInfoMutation) ResetRarity() { + m.rarity = nil +} + +// SetRole sets the "role" field. +func (m *EpicArtifactInfoMutation) SetRole(s string) { + m.role = &s +} + +// Role returns the value of the "role" field in the mutation. +func (m *EpicArtifactInfoMutation) Role() (r string, exists bool) { + v := m.role + if v == nil { + return + } + return *v, true +} + +// OldRole returns the old "role" field's value of the EpicArtifactInfo entity. +// If the EpicArtifactInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicArtifactInfoMutation) OldRole(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRole is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRole requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRole: %w", err) + } + return oldValue.Role, nil +} + +// ResetRole resets all changes to the "role" field. +func (m *EpicArtifactInfoMutation) ResetRole() { + m.role = nil +} + +// SetArtifactNameEn sets the "artifact_name_en" field. +func (m *EpicArtifactInfoMutation) SetArtifactNameEn(s string) { + m.artifact_name_en = &s +} + +// ArtifactNameEn returns the value of the "artifact_name_en" field in the mutation. +func (m *EpicArtifactInfoMutation) ArtifactNameEn() (r string, exists bool) { + v := m.artifact_name_en + if v == nil { + return + } + return *v, true +} + +// OldArtifactNameEn returns the old "artifact_name_en" field's value of the EpicArtifactInfo entity. +// If the EpicArtifactInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicArtifactInfoMutation) OldArtifactNameEn(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldArtifactNameEn is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldArtifactNameEn requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldArtifactNameEn: %w", err) + } + return oldValue.ArtifactNameEn, nil +} + +// ResetArtifactNameEn resets all changes to the "artifact_name_en" field. +func (m *EpicArtifactInfoMutation) ResetArtifactNameEn() { + m.artifact_name_en = nil +} + +// SetImageURL sets the "image_url" field. +func (m *EpicArtifactInfoMutation) SetImageURL(s string) { + m.image_url = &s +} + +// ImageURL returns the value of the "image_url" field in the mutation. +func (m *EpicArtifactInfoMutation) ImageURL() (r string, exists bool) { + v := m.image_url + if v == nil { + return + } + return *v, true +} + +// OldImageURL returns the old "image_url" field's value of the EpicArtifactInfo entity. +// If the EpicArtifactInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicArtifactInfoMutation) OldImageURL(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldImageURL is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldImageURL requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldImageURL: %w", err) + } + return oldValue.ImageURL, nil +} + +// ResetImageURL resets all changes to the "image_url" field. +func (m *EpicArtifactInfoMutation) ResetImageURL() { + m.image_url = nil +} + +// Where appends a list predicates to the EpicArtifactInfoMutation builder. +func (m *EpicArtifactInfoMutation) Where(ps ...predicate.EpicArtifactInfo) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the EpicArtifactInfoMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *EpicArtifactInfoMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.EpicArtifactInfo, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *EpicArtifactInfoMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *EpicArtifactInfoMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (EpicArtifactInfo). +func (m *EpicArtifactInfoMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *EpicArtifactInfoMutation) Fields() []string { + fields := make([]string, 0, 14) + if m.artifact_name != nil { + fields = append(fields, epicartifactinfo.FieldArtifactName) + } + if m.artifact_code != nil { + fields = append(fields, epicartifactinfo.FieldArtifactCode) + } + if m.creator != nil { + fields = append(fields, epicartifactinfo.FieldCreator) + } + if m.create_time != nil { + fields = append(fields, epicartifactinfo.FieldCreateTime) + } + if m.updater != nil { + fields = append(fields, epicartifactinfo.FieldUpdater) + } + if m.update_time != nil { + fields = append(fields, epicartifactinfo.FieldUpdateTime) + } + if m.deleted != nil { + fields = append(fields, epicartifactinfo.FieldDeleted) + } + if m.stats_health != nil { + fields = append(fields, epicartifactinfo.FieldStatsHealth) + } + if m.stats_attack != nil { + fields = append(fields, epicartifactinfo.FieldStatsAttack) + } + if m.stats_defense != nil { + fields = append(fields, epicartifactinfo.FieldStatsDefense) + } + if m.rarity != nil { + fields = append(fields, epicartifactinfo.FieldRarity) + } + if m.role != nil { + fields = append(fields, epicartifactinfo.FieldRole) + } + if m.artifact_name_en != nil { + fields = append(fields, epicartifactinfo.FieldArtifactNameEn) + } + if m.image_url != nil { + fields = append(fields, epicartifactinfo.FieldImageURL) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *EpicArtifactInfoMutation) Field(name string) (ent.Value, bool) { + switch name { + case epicartifactinfo.FieldArtifactName: + return m.ArtifactName() + case epicartifactinfo.FieldArtifactCode: + return m.ArtifactCode() + case epicartifactinfo.FieldCreator: + return m.Creator() + case epicartifactinfo.FieldCreateTime: + return m.CreateTime() + case epicartifactinfo.FieldUpdater: + return m.Updater() + case epicartifactinfo.FieldUpdateTime: + return m.UpdateTime() + case epicartifactinfo.FieldDeleted: + return m.Deleted() + case epicartifactinfo.FieldStatsHealth: + return m.StatsHealth() + case epicartifactinfo.FieldStatsAttack: + return m.StatsAttack() + case epicartifactinfo.FieldStatsDefense: + return m.StatsDefense() + case epicartifactinfo.FieldRarity: + return m.Rarity() + case epicartifactinfo.FieldRole: + return m.Role() + case epicartifactinfo.FieldArtifactNameEn: + return m.ArtifactNameEn() + case epicartifactinfo.FieldImageURL: + return m.ImageURL() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *EpicArtifactInfoMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case epicartifactinfo.FieldArtifactName: + return m.OldArtifactName(ctx) + case epicartifactinfo.FieldArtifactCode: + return m.OldArtifactCode(ctx) + case epicartifactinfo.FieldCreator: + return m.OldCreator(ctx) + case epicartifactinfo.FieldCreateTime: + return m.OldCreateTime(ctx) + case epicartifactinfo.FieldUpdater: + return m.OldUpdater(ctx) + case epicartifactinfo.FieldUpdateTime: + return m.OldUpdateTime(ctx) + case epicartifactinfo.FieldDeleted: + return m.OldDeleted(ctx) + case epicartifactinfo.FieldStatsHealth: + return m.OldStatsHealth(ctx) + case epicartifactinfo.FieldStatsAttack: + return m.OldStatsAttack(ctx) + case epicartifactinfo.FieldStatsDefense: + return m.OldStatsDefense(ctx) + case epicartifactinfo.FieldRarity: + return m.OldRarity(ctx) + case epicartifactinfo.FieldRole: + return m.OldRole(ctx) + case epicartifactinfo.FieldArtifactNameEn: + return m.OldArtifactNameEn(ctx) + case epicartifactinfo.FieldImageURL: + return m.OldImageURL(ctx) + } + return nil, fmt.Errorf("unknown EpicArtifactInfo field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *EpicArtifactInfoMutation) SetField(name string, value ent.Value) error { + switch name { + case epicartifactinfo.FieldArtifactName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetArtifactName(v) + return nil + case epicartifactinfo.FieldArtifactCode: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetArtifactCode(v) + return nil + case epicartifactinfo.FieldCreator: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreator(v) + return nil + case epicartifactinfo.FieldCreateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreateTime(v) + return nil + case epicartifactinfo.FieldUpdater: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdater(v) + return nil + case epicartifactinfo.FieldUpdateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdateTime(v) + return nil + case epicartifactinfo.FieldDeleted: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeleted(v) + return nil + case epicartifactinfo.FieldStatsHealth: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStatsHealth(v) + return nil + case epicartifactinfo.FieldStatsAttack: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStatsAttack(v) + return nil + case epicartifactinfo.FieldStatsDefense: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStatsDefense(v) + return nil + case epicartifactinfo.FieldRarity: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRarity(v) + return nil + case epicartifactinfo.FieldRole: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRole(v) + return nil + case epicartifactinfo.FieldArtifactNameEn: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetArtifactNameEn(v) + return nil + case epicartifactinfo.FieldImageURL: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetImageURL(v) + return nil + } + return fmt.Errorf("unknown EpicArtifactInfo field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *EpicArtifactInfoMutation) AddedFields() []string { + var fields []string + if m.addstats_health != nil { + fields = append(fields, epicartifactinfo.FieldStatsHealth) + } + if m.addstats_attack != nil { + fields = append(fields, epicartifactinfo.FieldStatsAttack) + } + if m.addstats_defense != nil { + fields = append(fields, epicartifactinfo.FieldStatsDefense) + } + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *EpicArtifactInfoMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case epicartifactinfo.FieldStatsHealth: + return m.AddedStatsHealth() + case epicartifactinfo.FieldStatsAttack: + return m.AddedStatsAttack() + case epicartifactinfo.FieldStatsDefense: + return m.AddedStatsDefense() + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *EpicArtifactInfoMutation) AddField(name string, value ent.Value) error { + switch name { + case epicartifactinfo.FieldStatsHealth: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddStatsHealth(v) + return nil + case epicartifactinfo.FieldStatsAttack: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddStatsAttack(v) + return nil + case epicartifactinfo.FieldStatsDefense: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddStatsDefense(v) + return nil + } + return fmt.Errorf("unknown EpicArtifactInfo numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *EpicArtifactInfoMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(epicartifactinfo.FieldCreateTime) { + fields = append(fields, epicartifactinfo.FieldCreateTime) + } + if m.FieldCleared(epicartifactinfo.FieldUpdateTime) { + fields = append(fields, epicartifactinfo.FieldUpdateTime) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *EpicArtifactInfoMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *EpicArtifactInfoMutation) ClearField(name string) error { + switch name { + case epicartifactinfo.FieldCreateTime: + m.ClearCreateTime() + return nil + case epicartifactinfo.FieldUpdateTime: + m.ClearUpdateTime() + return nil + } + return fmt.Errorf("unknown EpicArtifactInfo nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *EpicArtifactInfoMutation) ResetField(name string) error { + switch name { + case epicartifactinfo.FieldArtifactName: + m.ResetArtifactName() + return nil + case epicartifactinfo.FieldArtifactCode: + m.ResetArtifactCode() + return nil + case epicartifactinfo.FieldCreator: + m.ResetCreator() + return nil + case epicartifactinfo.FieldCreateTime: + m.ResetCreateTime() + return nil + case epicartifactinfo.FieldUpdater: + m.ResetUpdater() + return nil + case epicartifactinfo.FieldUpdateTime: + m.ResetUpdateTime() + return nil + case epicartifactinfo.FieldDeleted: + m.ResetDeleted() + return nil + case epicartifactinfo.FieldStatsHealth: + m.ResetStatsHealth() + return nil + case epicartifactinfo.FieldStatsAttack: + m.ResetStatsAttack() + return nil + case epicartifactinfo.FieldStatsDefense: + m.ResetStatsDefense() + return nil + case epicartifactinfo.FieldRarity: + m.ResetRarity() + return nil + case epicartifactinfo.FieldRole: + m.ResetRole() + return nil + case epicartifactinfo.FieldArtifactNameEn: + m.ResetArtifactNameEn() + return nil + case epicartifactinfo.FieldImageURL: + m.ResetImageURL() + return nil + } + return fmt.Errorf("unknown EpicArtifactInfo field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *EpicArtifactInfoMutation) AddedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *EpicArtifactInfoMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *EpicArtifactInfoMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *EpicArtifactInfoMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *EpicArtifactInfoMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *EpicArtifactInfoMutation) EdgeCleared(name string) bool { + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *EpicArtifactInfoMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown EpicArtifactInfo unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *EpicArtifactInfoMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown EpicArtifactInfo edge %s", name) +} + +// EpicGvgAttackTeamsMutation represents an operation that mutates the EpicGvgAttackTeams nodes in the graph. +type EpicGvgAttackTeamsMutation struct { + config + op Op + typ string + id *int64 + attack_heroes *string + creator *string + create_time *time.Time + updater *string + update_time *time.Time + deleted *bool + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*EpicGvgAttackTeams, error) + predicates []predicate.EpicGvgAttackTeams +} + +var _ ent.Mutation = (*EpicGvgAttackTeamsMutation)(nil) + +// epicgvgattackteamsOption allows management of the mutation configuration using functional options. +type epicgvgattackteamsOption func(*EpicGvgAttackTeamsMutation) + +// newEpicGvgAttackTeamsMutation creates new mutation for the EpicGvgAttackTeams entity. +func newEpicGvgAttackTeamsMutation(c config, op Op, opts ...epicgvgattackteamsOption) *EpicGvgAttackTeamsMutation { + m := &EpicGvgAttackTeamsMutation{ + config: c, + op: op, + typ: TypeEpicGvgAttackTeams, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withEpicGvgAttackTeamsID sets the ID field of the mutation. +func withEpicGvgAttackTeamsID(id int64) epicgvgattackteamsOption { + return func(m *EpicGvgAttackTeamsMutation) { + var ( + err error + once sync.Once + value *EpicGvgAttackTeams + ) + m.oldValue = func(ctx context.Context) (*EpicGvgAttackTeams, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().EpicGvgAttackTeams.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withEpicGvgAttackTeams sets the old EpicGvgAttackTeams of the mutation. +func withEpicGvgAttackTeams(node *EpicGvgAttackTeams) epicgvgattackteamsOption { + return func(m *EpicGvgAttackTeamsMutation) { + m.oldValue = func(context.Context) (*EpicGvgAttackTeams, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m EpicGvgAttackTeamsMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m EpicGvgAttackTeamsMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of EpicGvgAttackTeams entities. +func (m *EpicGvgAttackTeamsMutation) SetID(id int64) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *EpicGvgAttackTeamsMutation) ID() (id int64, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *EpicGvgAttackTeamsMutation) IDs(ctx context.Context) ([]int64, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int64{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().EpicGvgAttackTeams.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetAttackHeroes sets the "attack_heroes" field. +func (m *EpicGvgAttackTeamsMutation) SetAttackHeroes(s string) { + m.attack_heroes = &s +} + +// AttackHeroes returns the value of the "attack_heroes" field in the mutation. +func (m *EpicGvgAttackTeamsMutation) AttackHeroes() (r string, exists bool) { + v := m.attack_heroes + if v == nil { + return + } + return *v, true +} + +// OldAttackHeroes returns the old "attack_heroes" field's value of the EpicGvgAttackTeams entity. +// If the EpicGvgAttackTeams object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicGvgAttackTeamsMutation) OldAttackHeroes(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAttackHeroes is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAttackHeroes requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAttackHeroes: %w", err) + } + return oldValue.AttackHeroes, nil +} + +// ResetAttackHeroes resets all changes to the "attack_heroes" field. +func (m *EpicGvgAttackTeamsMutation) ResetAttackHeroes() { + m.attack_heroes = nil +} + +// SetCreator sets the "creator" field. +func (m *EpicGvgAttackTeamsMutation) SetCreator(s string) { + m.creator = &s +} + +// Creator returns the value of the "creator" field in the mutation. +func (m *EpicGvgAttackTeamsMutation) Creator() (r string, exists bool) { + v := m.creator + if v == nil { + return + } + return *v, true +} + +// OldCreator returns the old "creator" field's value of the EpicGvgAttackTeams entity. +// If the EpicGvgAttackTeams object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicGvgAttackTeamsMutation) OldCreator(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreator is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreator requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreator: %w", err) + } + return oldValue.Creator, nil +} + +// ResetCreator resets all changes to the "creator" field. +func (m *EpicGvgAttackTeamsMutation) ResetCreator() { + m.creator = nil +} + +// SetCreateTime sets the "create_time" field. +func (m *EpicGvgAttackTeamsMutation) SetCreateTime(t time.Time) { + m.create_time = &t +} + +// CreateTime returns the value of the "create_time" field in the mutation. +func (m *EpicGvgAttackTeamsMutation) CreateTime() (r time.Time, exists bool) { + v := m.create_time + if v == nil { + return + } + return *v, true +} + +// OldCreateTime returns the old "create_time" field's value of the EpicGvgAttackTeams entity. +// If the EpicGvgAttackTeams object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicGvgAttackTeamsMutation) OldCreateTime(ctx context.Context) (v *time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) + } + return oldValue.CreateTime, nil +} + +// ClearCreateTime clears the value of the "create_time" field. +func (m *EpicGvgAttackTeamsMutation) ClearCreateTime() { + m.create_time = nil + m.clearedFields[epicgvgattackteams.FieldCreateTime] = struct{}{} +} + +// CreateTimeCleared returns if the "create_time" field was cleared in this mutation. +func (m *EpicGvgAttackTeamsMutation) CreateTimeCleared() bool { + _, ok := m.clearedFields[epicgvgattackteams.FieldCreateTime] + return ok +} + +// ResetCreateTime resets all changes to the "create_time" field. +func (m *EpicGvgAttackTeamsMutation) ResetCreateTime() { + m.create_time = nil + delete(m.clearedFields, epicgvgattackteams.FieldCreateTime) +} + +// SetUpdater sets the "updater" field. +func (m *EpicGvgAttackTeamsMutation) SetUpdater(s string) { + m.updater = &s +} + +// Updater returns the value of the "updater" field in the mutation. +func (m *EpicGvgAttackTeamsMutation) Updater() (r string, exists bool) { + v := m.updater + if v == nil { + return + } + return *v, true +} + +// OldUpdater returns the old "updater" field's value of the EpicGvgAttackTeams entity. +// If the EpicGvgAttackTeams object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicGvgAttackTeamsMutation) OldUpdater(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdater is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdater requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdater: %w", err) + } + return oldValue.Updater, nil +} + +// ResetUpdater resets all changes to the "updater" field. +func (m *EpicGvgAttackTeamsMutation) ResetUpdater() { + m.updater = nil +} + +// SetUpdateTime sets the "update_time" field. +func (m *EpicGvgAttackTeamsMutation) SetUpdateTime(t time.Time) { + m.update_time = &t +} + +// UpdateTime returns the value of the "update_time" field in the mutation. +func (m *EpicGvgAttackTeamsMutation) UpdateTime() (r time.Time, exists bool) { + v := m.update_time + if v == nil { + return + } + return *v, true +} + +// OldUpdateTime returns the old "update_time" field's value of the EpicGvgAttackTeams entity. +// If the EpicGvgAttackTeams object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicGvgAttackTeamsMutation) OldUpdateTime(ctx context.Context) (v *time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err) + } + return oldValue.UpdateTime, nil +} + +// ClearUpdateTime clears the value of the "update_time" field. +func (m *EpicGvgAttackTeamsMutation) ClearUpdateTime() { + m.update_time = nil + m.clearedFields[epicgvgattackteams.FieldUpdateTime] = struct{}{} +} + +// UpdateTimeCleared returns if the "update_time" field was cleared in this mutation. +func (m *EpicGvgAttackTeamsMutation) UpdateTimeCleared() bool { + _, ok := m.clearedFields[epicgvgattackteams.FieldUpdateTime] + return ok +} + +// ResetUpdateTime resets all changes to the "update_time" field. +func (m *EpicGvgAttackTeamsMutation) ResetUpdateTime() { + m.update_time = nil + delete(m.clearedFields, epicgvgattackteams.FieldUpdateTime) +} + +// SetDeleted sets the "deleted" field. +func (m *EpicGvgAttackTeamsMutation) SetDeleted(b bool) { + m.deleted = &b +} + +// Deleted returns the value of the "deleted" field in the mutation. +func (m *EpicGvgAttackTeamsMutation) Deleted() (r bool, exists bool) { + v := m.deleted + if v == nil { + return + } + return *v, true +} + +// OldDeleted returns the old "deleted" field's value of the EpicGvgAttackTeams entity. +// If the EpicGvgAttackTeams object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicGvgAttackTeamsMutation) OldDeleted(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeleted is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeleted requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeleted: %w", err) + } + return oldValue.Deleted, nil +} + +// ResetDeleted resets all changes to the "deleted" field. +func (m *EpicGvgAttackTeamsMutation) ResetDeleted() { + m.deleted = nil +} + +// Where appends a list predicates to the EpicGvgAttackTeamsMutation builder. +func (m *EpicGvgAttackTeamsMutation) Where(ps ...predicate.EpicGvgAttackTeams) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the EpicGvgAttackTeamsMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *EpicGvgAttackTeamsMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.EpicGvgAttackTeams, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *EpicGvgAttackTeamsMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *EpicGvgAttackTeamsMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (EpicGvgAttackTeams). +func (m *EpicGvgAttackTeamsMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *EpicGvgAttackTeamsMutation) Fields() []string { + fields := make([]string, 0, 6) + if m.attack_heroes != nil { + fields = append(fields, epicgvgattackteams.FieldAttackHeroes) + } + if m.creator != nil { + fields = append(fields, epicgvgattackteams.FieldCreator) + } + if m.create_time != nil { + fields = append(fields, epicgvgattackteams.FieldCreateTime) + } + if m.updater != nil { + fields = append(fields, epicgvgattackteams.FieldUpdater) + } + if m.update_time != nil { + fields = append(fields, epicgvgattackteams.FieldUpdateTime) + } + if m.deleted != nil { + fields = append(fields, epicgvgattackteams.FieldDeleted) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *EpicGvgAttackTeamsMutation) Field(name string) (ent.Value, bool) { + switch name { + case epicgvgattackteams.FieldAttackHeroes: + return m.AttackHeroes() + case epicgvgattackteams.FieldCreator: + return m.Creator() + case epicgvgattackteams.FieldCreateTime: + return m.CreateTime() + case epicgvgattackteams.FieldUpdater: + return m.Updater() + case epicgvgattackteams.FieldUpdateTime: + return m.UpdateTime() + case epicgvgattackteams.FieldDeleted: + return m.Deleted() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *EpicGvgAttackTeamsMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case epicgvgattackteams.FieldAttackHeroes: + return m.OldAttackHeroes(ctx) + case epicgvgattackteams.FieldCreator: + return m.OldCreator(ctx) + case epicgvgattackteams.FieldCreateTime: + return m.OldCreateTime(ctx) + case epicgvgattackteams.FieldUpdater: + return m.OldUpdater(ctx) + case epicgvgattackteams.FieldUpdateTime: + return m.OldUpdateTime(ctx) + case epicgvgattackteams.FieldDeleted: + return m.OldDeleted(ctx) + } + return nil, fmt.Errorf("unknown EpicGvgAttackTeams field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *EpicGvgAttackTeamsMutation) SetField(name string, value ent.Value) error { + switch name { + case epicgvgattackteams.FieldAttackHeroes: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAttackHeroes(v) + return nil + case epicgvgattackteams.FieldCreator: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreator(v) + return nil + case epicgvgattackteams.FieldCreateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreateTime(v) + return nil + case epicgvgattackteams.FieldUpdater: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdater(v) + return nil + case epicgvgattackteams.FieldUpdateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdateTime(v) + return nil + case epicgvgattackteams.FieldDeleted: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeleted(v) + return nil + } + return fmt.Errorf("unknown EpicGvgAttackTeams field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *EpicGvgAttackTeamsMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *EpicGvgAttackTeamsMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *EpicGvgAttackTeamsMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown EpicGvgAttackTeams numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *EpicGvgAttackTeamsMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(epicgvgattackteams.FieldCreateTime) { + fields = append(fields, epicgvgattackteams.FieldCreateTime) + } + if m.FieldCleared(epicgvgattackteams.FieldUpdateTime) { + fields = append(fields, epicgvgattackteams.FieldUpdateTime) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *EpicGvgAttackTeamsMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *EpicGvgAttackTeamsMutation) ClearField(name string) error { + switch name { + case epicgvgattackteams.FieldCreateTime: + m.ClearCreateTime() + return nil + case epicgvgattackteams.FieldUpdateTime: + m.ClearUpdateTime() + return nil + } + return fmt.Errorf("unknown EpicGvgAttackTeams nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *EpicGvgAttackTeamsMutation) ResetField(name string) error { + switch name { + case epicgvgattackteams.FieldAttackHeroes: + m.ResetAttackHeroes() + return nil + case epicgvgattackteams.FieldCreator: + m.ResetCreator() + return nil + case epicgvgattackteams.FieldCreateTime: + m.ResetCreateTime() + return nil + case epicgvgattackteams.FieldUpdater: + m.ResetUpdater() + return nil + case epicgvgattackteams.FieldUpdateTime: + m.ResetUpdateTime() + return nil + case epicgvgattackteams.FieldDeleted: + m.ResetDeleted() + return nil + } + return fmt.Errorf("unknown EpicGvgAttackTeams field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *EpicGvgAttackTeamsMutation) AddedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *EpicGvgAttackTeamsMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *EpicGvgAttackTeamsMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *EpicGvgAttackTeamsMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *EpicGvgAttackTeamsMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *EpicGvgAttackTeamsMutation) EdgeCleared(name string) bool { + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *EpicGvgAttackTeamsMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown EpicGvgAttackTeams unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *EpicGvgAttackTeamsMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown EpicGvgAttackTeams edge %s", name) +} + +// EpicGvgDefenseAttackMappingMutation represents an operation that mutates the EpicGvgDefenseAttackMapping nodes in the graph. +type EpicGvgDefenseAttackMappingMutation struct { + config + op Op + typ string + id *int64 + defense_id *int64 + adddefense_id *int64 + attack_id *int64 + addattack_id *int64 + equipment_info *string + artifacts *string + battle_strategy *string + prerequisites *string + important_notes *string + creator *string + create_time *time.Time + updater *string + update_time *time.Time + deleted *bool + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*EpicGvgDefenseAttackMapping, error) + predicates []predicate.EpicGvgDefenseAttackMapping +} + +var _ ent.Mutation = (*EpicGvgDefenseAttackMappingMutation)(nil) + +// epicgvgdefenseattackmappingOption allows management of the mutation configuration using functional options. +type epicgvgdefenseattackmappingOption func(*EpicGvgDefenseAttackMappingMutation) + +// newEpicGvgDefenseAttackMappingMutation creates new mutation for the EpicGvgDefenseAttackMapping entity. +func newEpicGvgDefenseAttackMappingMutation(c config, op Op, opts ...epicgvgdefenseattackmappingOption) *EpicGvgDefenseAttackMappingMutation { + m := &EpicGvgDefenseAttackMappingMutation{ + config: c, + op: op, + typ: TypeEpicGvgDefenseAttackMapping, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withEpicGvgDefenseAttackMappingID sets the ID field of the mutation. +func withEpicGvgDefenseAttackMappingID(id int64) epicgvgdefenseattackmappingOption { + return func(m *EpicGvgDefenseAttackMappingMutation) { + var ( + err error + once sync.Once + value *EpicGvgDefenseAttackMapping + ) + m.oldValue = func(ctx context.Context) (*EpicGvgDefenseAttackMapping, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().EpicGvgDefenseAttackMapping.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withEpicGvgDefenseAttackMapping sets the old EpicGvgDefenseAttackMapping of the mutation. +func withEpicGvgDefenseAttackMapping(node *EpicGvgDefenseAttackMapping) epicgvgdefenseattackmappingOption { + return func(m *EpicGvgDefenseAttackMappingMutation) { + m.oldValue = func(context.Context) (*EpicGvgDefenseAttackMapping, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m EpicGvgDefenseAttackMappingMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m EpicGvgDefenseAttackMappingMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of EpicGvgDefenseAttackMapping entities. +func (m *EpicGvgDefenseAttackMappingMutation) SetID(id int64) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *EpicGvgDefenseAttackMappingMutation) ID() (id int64, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *EpicGvgDefenseAttackMappingMutation) IDs(ctx context.Context) ([]int64, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int64{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().EpicGvgDefenseAttackMapping.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetDefenseID sets the "defense_id" field. +func (m *EpicGvgDefenseAttackMappingMutation) SetDefenseID(i int64) { + m.defense_id = &i + m.adddefense_id = nil +} + +// DefenseID returns the value of the "defense_id" field in the mutation. +func (m *EpicGvgDefenseAttackMappingMutation) DefenseID() (r int64, exists bool) { + v := m.defense_id + if v == nil { + return + } + return *v, true +} + +// OldDefenseID returns the old "defense_id" field's value of the EpicGvgDefenseAttackMapping entity. +// If the EpicGvgDefenseAttackMapping object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicGvgDefenseAttackMappingMutation) OldDefenseID(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDefenseID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDefenseID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDefenseID: %w", err) + } + return oldValue.DefenseID, nil +} + +// AddDefenseID adds i to the "defense_id" field. +func (m *EpicGvgDefenseAttackMappingMutation) AddDefenseID(i int64) { + if m.adddefense_id != nil { + *m.adddefense_id += i + } else { + m.adddefense_id = &i + } +} + +// AddedDefenseID returns the value that was added to the "defense_id" field in this mutation. +func (m *EpicGvgDefenseAttackMappingMutation) AddedDefenseID() (r int64, exists bool) { + v := m.adddefense_id + if v == nil { + return + } + return *v, true +} + +// ResetDefenseID resets all changes to the "defense_id" field. +func (m *EpicGvgDefenseAttackMappingMutation) ResetDefenseID() { + m.defense_id = nil + m.adddefense_id = nil +} + +// SetAttackID sets the "attack_id" field. +func (m *EpicGvgDefenseAttackMappingMutation) SetAttackID(i int64) { + m.attack_id = &i + m.addattack_id = nil +} + +// AttackID returns the value of the "attack_id" field in the mutation. +func (m *EpicGvgDefenseAttackMappingMutation) AttackID() (r int64, exists bool) { + v := m.attack_id + if v == nil { + return + } + return *v, true +} + +// OldAttackID returns the old "attack_id" field's value of the EpicGvgDefenseAttackMapping entity. +// If the EpicGvgDefenseAttackMapping object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicGvgDefenseAttackMappingMutation) OldAttackID(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAttackID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAttackID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAttackID: %w", err) + } + return oldValue.AttackID, nil +} + +// AddAttackID adds i to the "attack_id" field. +func (m *EpicGvgDefenseAttackMappingMutation) AddAttackID(i int64) { + if m.addattack_id != nil { + *m.addattack_id += i + } else { + m.addattack_id = &i + } +} + +// AddedAttackID returns the value that was added to the "attack_id" field in this mutation. +func (m *EpicGvgDefenseAttackMappingMutation) AddedAttackID() (r int64, exists bool) { + v := m.addattack_id + if v == nil { + return + } + return *v, true +} + +// ResetAttackID resets all changes to the "attack_id" field. +func (m *EpicGvgDefenseAttackMappingMutation) ResetAttackID() { + m.attack_id = nil + m.addattack_id = nil +} + +// SetEquipmentInfo sets the "equipment_info" field. +func (m *EpicGvgDefenseAttackMappingMutation) SetEquipmentInfo(s string) { + m.equipment_info = &s +} + +// EquipmentInfo returns the value of the "equipment_info" field in the mutation. +func (m *EpicGvgDefenseAttackMappingMutation) EquipmentInfo() (r string, exists bool) { + v := m.equipment_info + if v == nil { + return + } + return *v, true +} + +// OldEquipmentInfo returns the old "equipment_info" field's value of the EpicGvgDefenseAttackMapping entity. +// If the EpicGvgDefenseAttackMapping object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicGvgDefenseAttackMappingMutation) OldEquipmentInfo(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldEquipmentInfo is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldEquipmentInfo requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldEquipmentInfo: %w", err) + } + return oldValue.EquipmentInfo, nil +} + +// ResetEquipmentInfo resets all changes to the "equipment_info" field. +func (m *EpicGvgDefenseAttackMappingMutation) ResetEquipmentInfo() { + m.equipment_info = nil +} + +// SetArtifacts sets the "artifacts" field. +func (m *EpicGvgDefenseAttackMappingMutation) SetArtifacts(s string) { + m.artifacts = &s +} + +// Artifacts returns the value of the "artifacts" field in the mutation. +func (m *EpicGvgDefenseAttackMappingMutation) Artifacts() (r string, exists bool) { + v := m.artifacts + if v == nil { + return + } + return *v, true +} + +// OldArtifacts returns the old "artifacts" field's value of the EpicGvgDefenseAttackMapping entity. +// If the EpicGvgDefenseAttackMapping object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicGvgDefenseAttackMappingMutation) OldArtifacts(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldArtifacts is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldArtifacts requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldArtifacts: %w", err) + } + return oldValue.Artifacts, nil +} + +// ResetArtifacts resets all changes to the "artifacts" field. +func (m *EpicGvgDefenseAttackMappingMutation) ResetArtifacts() { + m.artifacts = nil +} + +// SetBattleStrategy sets the "battle_strategy" field. +func (m *EpicGvgDefenseAttackMappingMutation) SetBattleStrategy(s string) { + m.battle_strategy = &s +} + +// BattleStrategy returns the value of the "battle_strategy" field in the mutation. +func (m *EpicGvgDefenseAttackMappingMutation) BattleStrategy() (r string, exists bool) { + v := m.battle_strategy + if v == nil { + return + } + return *v, true +} + +// OldBattleStrategy returns the old "battle_strategy" field's value of the EpicGvgDefenseAttackMapping entity. +// If the EpicGvgDefenseAttackMapping object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicGvgDefenseAttackMappingMutation) OldBattleStrategy(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldBattleStrategy is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldBattleStrategy requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldBattleStrategy: %w", err) + } + return oldValue.BattleStrategy, nil +} + +// ResetBattleStrategy resets all changes to the "battle_strategy" field. +func (m *EpicGvgDefenseAttackMappingMutation) ResetBattleStrategy() { + m.battle_strategy = nil +} + +// SetPrerequisites sets the "prerequisites" field. +func (m *EpicGvgDefenseAttackMappingMutation) SetPrerequisites(s string) { + m.prerequisites = &s +} + +// Prerequisites returns the value of the "prerequisites" field in the mutation. +func (m *EpicGvgDefenseAttackMappingMutation) Prerequisites() (r string, exists bool) { + v := m.prerequisites + if v == nil { + return + } + return *v, true +} + +// OldPrerequisites returns the old "prerequisites" field's value of the EpicGvgDefenseAttackMapping entity. +// If the EpicGvgDefenseAttackMapping object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicGvgDefenseAttackMappingMutation) OldPrerequisites(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPrerequisites is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPrerequisites requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPrerequisites: %w", err) + } + return oldValue.Prerequisites, nil +} + +// ResetPrerequisites resets all changes to the "prerequisites" field. +func (m *EpicGvgDefenseAttackMappingMutation) ResetPrerequisites() { + m.prerequisites = nil +} + +// SetImportantNotes sets the "important_notes" field. +func (m *EpicGvgDefenseAttackMappingMutation) SetImportantNotes(s string) { + m.important_notes = &s +} + +// ImportantNotes returns the value of the "important_notes" field in the mutation. +func (m *EpicGvgDefenseAttackMappingMutation) ImportantNotes() (r string, exists bool) { + v := m.important_notes + if v == nil { + return + } + return *v, true +} + +// OldImportantNotes returns the old "important_notes" field's value of the EpicGvgDefenseAttackMapping entity. +// If the EpicGvgDefenseAttackMapping object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicGvgDefenseAttackMappingMutation) OldImportantNotes(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldImportantNotes is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldImportantNotes requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldImportantNotes: %w", err) + } + return oldValue.ImportantNotes, nil +} + +// ResetImportantNotes resets all changes to the "important_notes" field. +func (m *EpicGvgDefenseAttackMappingMutation) ResetImportantNotes() { + m.important_notes = nil +} + +// SetCreator sets the "creator" field. +func (m *EpicGvgDefenseAttackMappingMutation) SetCreator(s string) { + m.creator = &s +} + +// Creator returns the value of the "creator" field in the mutation. +func (m *EpicGvgDefenseAttackMappingMutation) Creator() (r string, exists bool) { + v := m.creator + if v == nil { + return + } + return *v, true +} + +// OldCreator returns the old "creator" field's value of the EpicGvgDefenseAttackMapping entity. +// If the EpicGvgDefenseAttackMapping object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicGvgDefenseAttackMappingMutation) OldCreator(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreator is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreator requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreator: %w", err) + } + return oldValue.Creator, nil +} + +// ResetCreator resets all changes to the "creator" field. +func (m *EpicGvgDefenseAttackMappingMutation) ResetCreator() { + m.creator = nil +} + +// SetCreateTime sets the "create_time" field. +func (m *EpicGvgDefenseAttackMappingMutation) SetCreateTime(t time.Time) { + m.create_time = &t +} + +// CreateTime returns the value of the "create_time" field in the mutation. +func (m *EpicGvgDefenseAttackMappingMutation) CreateTime() (r time.Time, exists bool) { + v := m.create_time + if v == nil { + return + } + return *v, true +} + +// OldCreateTime returns the old "create_time" field's value of the EpicGvgDefenseAttackMapping entity. +// If the EpicGvgDefenseAttackMapping object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicGvgDefenseAttackMappingMutation) OldCreateTime(ctx context.Context) (v *time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) + } + return oldValue.CreateTime, nil +} + +// ClearCreateTime clears the value of the "create_time" field. +func (m *EpicGvgDefenseAttackMappingMutation) ClearCreateTime() { + m.create_time = nil + m.clearedFields[epicgvgdefenseattackmapping.FieldCreateTime] = struct{}{} +} + +// CreateTimeCleared returns if the "create_time" field was cleared in this mutation. +func (m *EpicGvgDefenseAttackMappingMutation) CreateTimeCleared() bool { + _, ok := m.clearedFields[epicgvgdefenseattackmapping.FieldCreateTime] + return ok +} + +// ResetCreateTime resets all changes to the "create_time" field. +func (m *EpicGvgDefenseAttackMappingMutation) ResetCreateTime() { + m.create_time = nil + delete(m.clearedFields, epicgvgdefenseattackmapping.FieldCreateTime) +} + +// SetUpdater sets the "updater" field. +func (m *EpicGvgDefenseAttackMappingMutation) SetUpdater(s string) { + m.updater = &s +} + +// Updater returns the value of the "updater" field in the mutation. +func (m *EpicGvgDefenseAttackMappingMutation) Updater() (r string, exists bool) { + v := m.updater + if v == nil { + return + } + return *v, true +} + +// OldUpdater returns the old "updater" field's value of the EpicGvgDefenseAttackMapping entity. +// If the EpicGvgDefenseAttackMapping object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicGvgDefenseAttackMappingMutation) OldUpdater(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdater is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdater requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdater: %w", err) + } + return oldValue.Updater, nil +} + +// ResetUpdater resets all changes to the "updater" field. +func (m *EpicGvgDefenseAttackMappingMutation) ResetUpdater() { + m.updater = nil +} + +// SetUpdateTime sets the "update_time" field. +func (m *EpicGvgDefenseAttackMappingMutation) SetUpdateTime(t time.Time) { + m.update_time = &t +} + +// UpdateTime returns the value of the "update_time" field in the mutation. +func (m *EpicGvgDefenseAttackMappingMutation) UpdateTime() (r time.Time, exists bool) { + v := m.update_time + if v == nil { + return + } + return *v, true +} + +// OldUpdateTime returns the old "update_time" field's value of the EpicGvgDefenseAttackMapping entity. +// If the EpicGvgDefenseAttackMapping object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicGvgDefenseAttackMappingMutation) OldUpdateTime(ctx context.Context) (v *time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err) + } + return oldValue.UpdateTime, nil +} + +// ClearUpdateTime clears the value of the "update_time" field. +func (m *EpicGvgDefenseAttackMappingMutation) ClearUpdateTime() { + m.update_time = nil + m.clearedFields[epicgvgdefenseattackmapping.FieldUpdateTime] = struct{}{} +} + +// UpdateTimeCleared returns if the "update_time" field was cleared in this mutation. +func (m *EpicGvgDefenseAttackMappingMutation) UpdateTimeCleared() bool { + _, ok := m.clearedFields[epicgvgdefenseattackmapping.FieldUpdateTime] + return ok +} + +// ResetUpdateTime resets all changes to the "update_time" field. +func (m *EpicGvgDefenseAttackMappingMutation) ResetUpdateTime() { + m.update_time = nil + delete(m.clearedFields, epicgvgdefenseattackmapping.FieldUpdateTime) +} + +// SetDeleted sets the "deleted" field. +func (m *EpicGvgDefenseAttackMappingMutation) SetDeleted(b bool) { + m.deleted = &b +} + +// Deleted returns the value of the "deleted" field in the mutation. +func (m *EpicGvgDefenseAttackMappingMutation) Deleted() (r bool, exists bool) { + v := m.deleted + if v == nil { + return + } + return *v, true +} + +// OldDeleted returns the old "deleted" field's value of the EpicGvgDefenseAttackMapping entity. +// If the EpicGvgDefenseAttackMapping object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicGvgDefenseAttackMappingMutation) OldDeleted(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeleted is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeleted requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeleted: %w", err) + } + return oldValue.Deleted, nil +} + +// ResetDeleted resets all changes to the "deleted" field. +func (m *EpicGvgDefenseAttackMappingMutation) ResetDeleted() { + m.deleted = nil +} + +// Where appends a list predicates to the EpicGvgDefenseAttackMappingMutation builder. +func (m *EpicGvgDefenseAttackMappingMutation) Where(ps ...predicate.EpicGvgDefenseAttackMapping) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the EpicGvgDefenseAttackMappingMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *EpicGvgDefenseAttackMappingMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.EpicGvgDefenseAttackMapping, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *EpicGvgDefenseAttackMappingMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *EpicGvgDefenseAttackMappingMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (EpicGvgDefenseAttackMapping). +func (m *EpicGvgDefenseAttackMappingMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *EpicGvgDefenseAttackMappingMutation) Fields() []string { + fields := make([]string, 0, 12) + if m.defense_id != nil { + fields = append(fields, epicgvgdefenseattackmapping.FieldDefenseID) + } + if m.attack_id != nil { + fields = append(fields, epicgvgdefenseattackmapping.FieldAttackID) + } + if m.equipment_info != nil { + fields = append(fields, epicgvgdefenseattackmapping.FieldEquipmentInfo) + } + if m.artifacts != nil { + fields = append(fields, epicgvgdefenseattackmapping.FieldArtifacts) + } + if m.battle_strategy != nil { + fields = append(fields, epicgvgdefenseattackmapping.FieldBattleStrategy) + } + if m.prerequisites != nil { + fields = append(fields, epicgvgdefenseattackmapping.FieldPrerequisites) + } + if m.important_notes != nil { + fields = append(fields, epicgvgdefenseattackmapping.FieldImportantNotes) + } + if m.creator != nil { + fields = append(fields, epicgvgdefenseattackmapping.FieldCreator) + } + if m.create_time != nil { + fields = append(fields, epicgvgdefenseattackmapping.FieldCreateTime) + } + if m.updater != nil { + fields = append(fields, epicgvgdefenseattackmapping.FieldUpdater) + } + if m.update_time != nil { + fields = append(fields, epicgvgdefenseattackmapping.FieldUpdateTime) + } + if m.deleted != nil { + fields = append(fields, epicgvgdefenseattackmapping.FieldDeleted) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *EpicGvgDefenseAttackMappingMutation) Field(name string) (ent.Value, bool) { + switch name { + case epicgvgdefenseattackmapping.FieldDefenseID: + return m.DefenseID() + case epicgvgdefenseattackmapping.FieldAttackID: + return m.AttackID() + case epicgvgdefenseattackmapping.FieldEquipmentInfo: + return m.EquipmentInfo() + case epicgvgdefenseattackmapping.FieldArtifacts: + return m.Artifacts() + case epicgvgdefenseattackmapping.FieldBattleStrategy: + return m.BattleStrategy() + case epicgvgdefenseattackmapping.FieldPrerequisites: + return m.Prerequisites() + case epicgvgdefenseattackmapping.FieldImportantNotes: + return m.ImportantNotes() + case epicgvgdefenseattackmapping.FieldCreator: + return m.Creator() + case epicgvgdefenseattackmapping.FieldCreateTime: + return m.CreateTime() + case epicgvgdefenseattackmapping.FieldUpdater: + return m.Updater() + case epicgvgdefenseattackmapping.FieldUpdateTime: + return m.UpdateTime() + case epicgvgdefenseattackmapping.FieldDeleted: + return m.Deleted() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *EpicGvgDefenseAttackMappingMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case epicgvgdefenseattackmapping.FieldDefenseID: + return m.OldDefenseID(ctx) + case epicgvgdefenseattackmapping.FieldAttackID: + return m.OldAttackID(ctx) + case epicgvgdefenseattackmapping.FieldEquipmentInfo: + return m.OldEquipmentInfo(ctx) + case epicgvgdefenseattackmapping.FieldArtifacts: + return m.OldArtifacts(ctx) + case epicgvgdefenseattackmapping.FieldBattleStrategy: + return m.OldBattleStrategy(ctx) + case epicgvgdefenseattackmapping.FieldPrerequisites: + return m.OldPrerequisites(ctx) + case epicgvgdefenseattackmapping.FieldImportantNotes: + return m.OldImportantNotes(ctx) + case epicgvgdefenseattackmapping.FieldCreator: + return m.OldCreator(ctx) + case epicgvgdefenseattackmapping.FieldCreateTime: + return m.OldCreateTime(ctx) + case epicgvgdefenseattackmapping.FieldUpdater: + return m.OldUpdater(ctx) + case epicgvgdefenseattackmapping.FieldUpdateTime: + return m.OldUpdateTime(ctx) + case epicgvgdefenseattackmapping.FieldDeleted: + return m.OldDeleted(ctx) + } + return nil, fmt.Errorf("unknown EpicGvgDefenseAttackMapping field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *EpicGvgDefenseAttackMappingMutation) SetField(name string, value ent.Value) error { + switch name { + case epicgvgdefenseattackmapping.FieldDefenseID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDefenseID(v) + return nil + case epicgvgdefenseattackmapping.FieldAttackID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAttackID(v) + return nil + case epicgvgdefenseattackmapping.FieldEquipmentInfo: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetEquipmentInfo(v) + return nil + case epicgvgdefenseattackmapping.FieldArtifacts: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetArtifacts(v) + return nil + case epicgvgdefenseattackmapping.FieldBattleStrategy: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetBattleStrategy(v) + return nil + case epicgvgdefenseattackmapping.FieldPrerequisites: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPrerequisites(v) + return nil + case epicgvgdefenseattackmapping.FieldImportantNotes: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetImportantNotes(v) + return nil + case epicgvgdefenseattackmapping.FieldCreator: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreator(v) + return nil + case epicgvgdefenseattackmapping.FieldCreateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreateTime(v) + return nil + case epicgvgdefenseattackmapping.FieldUpdater: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdater(v) + return nil + case epicgvgdefenseattackmapping.FieldUpdateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdateTime(v) + return nil + case epicgvgdefenseattackmapping.FieldDeleted: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeleted(v) + return nil + } + return fmt.Errorf("unknown EpicGvgDefenseAttackMapping field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *EpicGvgDefenseAttackMappingMutation) AddedFields() []string { + var fields []string + if m.adddefense_id != nil { + fields = append(fields, epicgvgdefenseattackmapping.FieldDefenseID) + } + if m.addattack_id != nil { + fields = append(fields, epicgvgdefenseattackmapping.FieldAttackID) + } + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *EpicGvgDefenseAttackMappingMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case epicgvgdefenseattackmapping.FieldDefenseID: + return m.AddedDefenseID() + case epicgvgdefenseattackmapping.FieldAttackID: + return m.AddedAttackID() + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *EpicGvgDefenseAttackMappingMutation) AddField(name string, value ent.Value) error { + switch name { + case epicgvgdefenseattackmapping.FieldDefenseID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddDefenseID(v) + return nil + case epicgvgdefenseattackmapping.FieldAttackID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddAttackID(v) + return nil + } + return fmt.Errorf("unknown EpicGvgDefenseAttackMapping numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *EpicGvgDefenseAttackMappingMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(epicgvgdefenseattackmapping.FieldCreateTime) { + fields = append(fields, epicgvgdefenseattackmapping.FieldCreateTime) + } + if m.FieldCleared(epicgvgdefenseattackmapping.FieldUpdateTime) { + fields = append(fields, epicgvgdefenseattackmapping.FieldUpdateTime) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *EpicGvgDefenseAttackMappingMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *EpicGvgDefenseAttackMappingMutation) ClearField(name string) error { + switch name { + case epicgvgdefenseattackmapping.FieldCreateTime: + m.ClearCreateTime() + return nil + case epicgvgdefenseattackmapping.FieldUpdateTime: + m.ClearUpdateTime() + return nil + } + return fmt.Errorf("unknown EpicGvgDefenseAttackMapping nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *EpicGvgDefenseAttackMappingMutation) ResetField(name string) error { + switch name { + case epicgvgdefenseattackmapping.FieldDefenseID: + m.ResetDefenseID() + return nil + case epicgvgdefenseattackmapping.FieldAttackID: + m.ResetAttackID() + return nil + case epicgvgdefenseattackmapping.FieldEquipmentInfo: + m.ResetEquipmentInfo() + return nil + case epicgvgdefenseattackmapping.FieldArtifacts: + m.ResetArtifacts() + return nil + case epicgvgdefenseattackmapping.FieldBattleStrategy: + m.ResetBattleStrategy() + return nil + case epicgvgdefenseattackmapping.FieldPrerequisites: + m.ResetPrerequisites() + return nil + case epicgvgdefenseattackmapping.FieldImportantNotes: + m.ResetImportantNotes() + return nil + case epicgvgdefenseattackmapping.FieldCreator: + m.ResetCreator() + return nil + case epicgvgdefenseattackmapping.FieldCreateTime: + m.ResetCreateTime() + return nil + case epicgvgdefenseattackmapping.FieldUpdater: + m.ResetUpdater() + return nil + case epicgvgdefenseattackmapping.FieldUpdateTime: + m.ResetUpdateTime() + return nil + case epicgvgdefenseattackmapping.FieldDeleted: + m.ResetDeleted() + return nil + } + return fmt.Errorf("unknown EpicGvgDefenseAttackMapping field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *EpicGvgDefenseAttackMappingMutation) AddedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *EpicGvgDefenseAttackMappingMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *EpicGvgDefenseAttackMappingMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *EpicGvgDefenseAttackMappingMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *EpicGvgDefenseAttackMappingMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *EpicGvgDefenseAttackMappingMutation) EdgeCleared(name string) bool { + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *EpicGvgDefenseAttackMappingMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown EpicGvgDefenseAttackMapping unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *EpicGvgDefenseAttackMappingMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown EpicGvgDefenseAttackMapping edge %s", name) +} + +// EpicGvgDefenseTeamsMutation represents an operation that mutates the EpicGvgDefenseTeams nodes in the graph. +type EpicGvgDefenseTeamsMutation struct { + config + op Op + typ string + id *int64 + defense_heroes *string + creator *string + create_time *time.Time + updater *string + update_time *time.Time + deleted *bool + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*EpicGvgDefenseTeams, error) + predicates []predicate.EpicGvgDefenseTeams +} + +var _ ent.Mutation = (*EpicGvgDefenseTeamsMutation)(nil) + +// epicgvgdefenseteamsOption allows management of the mutation configuration using functional options. +type epicgvgdefenseteamsOption func(*EpicGvgDefenseTeamsMutation) + +// newEpicGvgDefenseTeamsMutation creates new mutation for the EpicGvgDefenseTeams entity. +func newEpicGvgDefenseTeamsMutation(c config, op Op, opts ...epicgvgdefenseteamsOption) *EpicGvgDefenseTeamsMutation { + m := &EpicGvgDefenseTeamsMutation{ + config: c, + op: op, + typ: TypeEpicGvgDefenseTeams, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withEpicGvgDefenseTeamsID sets the ID field of the mutation. +func withEpicGvgDefenseTeamsID(id int64) epicgvgdefenseteamsOption { + return func(m *EpicGvgDefenseTeamsMutation) { + var ( + err error + once sync.Once + value *EpicGvgDefenseTeams + ) + m.oldValue = func(ctx context.Context) (*EpicGvgDefenseTeams, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().EpicGvgDefenseTeams.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withEpicGvgDefenseTeams sets the old EpicGvgDefenseTeams of the mutation. +func withEpicGvgDefenseTeams(node *EpicGvgDefenseTeams) epicgvgdefenseteamsOption { + return func(m *EpicGvgDefenseTeamsMutation) { + m.oldValue = func(context.Context) (*EpicGvgDefenseTeams, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m EpicGvgDefenseTeamsMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m EpicGvgDefenseTeamsMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of EpicGvgDefenseTeams entities. +func (m *EpicGvgDefenseTeamsMutation) SetID(id int64) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *EpicGvgDefenseTeamsMutation) ID() (id int64, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *EpicGvgDefenseTeamsMutation) IDs(ctx context.Context) ([]int64, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int64{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().EpicGvgDefenseTeams.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetDefenseHeroes sets the "defense_heroes" field. +func (m *EpicGvgDefenseTeamsMutation) SetDefenseHeroes(s string) { + m.defense_heroes = &s +} + +// DefenseHeroes returns the value of the "defense_heroes" field in the mutation. +func (m *EpicGvgDefenseTeamsMutation) DefenseHeroes() (r string, exists bool) { + v := m.defense_heroes + if v == nil { + return + } + return *v, true +} + +// OldDefenseHeroes returns the old "defense_heroes" field's value of the EpicGvgDefenseTeams entity. +// If the EpicGvgDefenseTeams object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicGvgDefenseTeamsMutation) OldDefenseHeroes(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDefenseHeroes is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDefenseHeroes requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDefenseHeroes: %w", err) + } + return oldValue.DefenseHeroes, nil +} + +// ResetDefenseHeroes resets all changes to the "defense_heroes" field. +func (m *EpicGvgDefenseTeamsMutation) ResetDefenseHeroes() { + m.defense_heroes = nil +} + +// SetCreator sets the "creator" field. +func (m *EpicGvgDefenseTeamsMutation) SetCreator(s string) { + m.creator = &s +} + +// Creator returns the value of the "creator" field in the mutation. +func (m *EpicGvgDefenseTeamsMutation) Creator() (r string, exists bool) { + v := m.creator + if v == nil { + return + } + return *v, true +} + +// OldCreator returns the old "creator" field's value of the EpicGvgDefenseTeams entity. +// If the EpicGvgDefenseTeams object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicGvgDefenseTeamsMutation) OldCreator(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreator is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreator requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreator: %w", err) + } + return oldValue.Creator, nil +} + +// ResetCreator resets all changes to the "creator" field. +func (m *EpicGvgDefenseTeamsMutation) ResetCreator() { + m.creator = nil +} + +// SetCreateTime sets the "create_time" field. +func (m *EpicGvgDefenseTeamsMutation) SetCreateTime(t time.Time) { + m.create_time = &t +} + +// CreateTime returns the value of the "create_time" field in the mutation. +func (m *EpicGvgDefenseTeamsMutation) CreateTime() (r time.Time, exists bool) { + v := m.create_time + if v == nil { + return + } + return *v, true +} + +// OldCreateTime returns the old "create_time" field's value of the EpicGvgDefenseTeams entity. +// If the EpicGvgDefenseTeams object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicGvgDefenseTeamsMutation) OldCreateTime(ctx context.Context) (v *time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) + } + return oldValue.CreateTime, nil +} + +// ClearCreateTime clears the value of the "create_time" field. +func (m *EpicGvgDefenseTeamsMutation) ClearCreateTime() { + m.create_time = nil + m.clearedFields[epicgvgdefenseteams.FieldCreateTime] = struct{}{} +} + +// CreateTimeCleared returns if the "create_time" field was cleared in this mutation. +func (m *EpicGvgDefenseTeamsMutation) CreateTimeCleared() bool { + _, ok := m.clearedFields[epicgvgdefenseteams.FieldCreateTime] + return ok +} + +// ResetCreateTime resets all changes to the "create_time" field. +func (m *EpicGvgDefenseTeamsMutation) ResetCreateTime() { + m.create_time = nil + delete(m.clearedFields, epicgvgdefenseteams.FieldCreateTime) +} + +// SetUpdater sets the "updater" field. +func (m *EpicGvgDefenseTeamsMutation) SetUpdater(s string) { + m.updater = &s +} + +// Updater returns the value of the "updater" field in the mutation. +func (m *EpicGvgDefenseTeamsMutation) Updater() (r string, exists bool) { + v := m.updater + if v == nil { + return + } + return *v, true +} + +// OldUpdater returns the old "updater" field's value of the EpicGvgDefenseTeams entity. +// If the EpicGvgDefenseTeams object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicGvgDefenseTeamsMutation) OldUpdater(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdater is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdater requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdater: %w", err) + } + return oldValue.Updater, nil +} + +// ResetUpdater resets all changes to the "updater" field. +func (m *EpicGvgDefenseTeamsMutation) ResetUpdater() { + m.updater = nil +} + +// SetUpdateTime sets the "update_time" field. +func (m *EpicGvgDefenseTeamsMutation) SetUpdateTime(t time.Time) { + m.update_time = &t +} + +// UpdateTime returns the value of the "update_time" field in the mutation. +func (m *EpicGvgDefenseTeamsMutation) UpdateTime() (r time.Time, exists bool) { + v := m.update_time + if v == nil { + return + } + return *v, true +} + +// OldUpdateTime returns the old "update_time" field's value of the EpicGvgDefenseTeams entity. +// If the EpicGvgDefenseTeams object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicGvgDefenseTeamsMutation) OldUpdateTime(ctx context.Context) (v *time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err) + } + return oldValue.UpdateTime, nil +} + +// ClearUpdateTime clears the value of the "update_time" field. +func (m *EpicGvgDefenseTeamsMutation) ClearUpdateTime() { + m.update_time = nil + m.clearedFields[epicgvgdefenseteams.FieldUpdateTime] = struct{}{} +} + +// UpdateTimeCleared returns if the "update_time" field was cleared in this mutation. +func (m *EpicGvgDefenseTeamsMutation) UpdateTimeCleared() bool { + _, ok := m.clearedFields[epicgvgdefenseteams.FieldUpdateTime] + return ok +} + +// ResetUpdateTime resets all changes to the "update_time" field. +func (m *EpicGvgDefenseTeamsMutation) ResetUpdateTime() { + m.update_time = nil + delete(m.clearedFields, epicgvgdefenseteams.FieldUpdateTime) +} + +// SetDeleted sets the "deleted" field. +func (m *EpicGvgDefenseTeamsMutation) SetDeleted(b bool) { + m.deleted = &b +} + +// Deleted returns the value of the "deleted" field in the mutation. +func (m *EpicGvgDefenseTeamsMutation) Deleted() (r bool, exists bool) { + v := m.deleted + if v == nil { + return + } + return *v, true +} + +// OldDeleted returns the old "deleted" field's value of the EpicGvgDefenseTeams entity. +// If the EpicGvgDefenseTeams object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicGvgDefenseTeamsMutation) OldDeleted(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeleted is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeleted requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeleted: %w", err) + } + return oldValue.Deleted, nil +} + +// ResetDeleted resets all changes to the "deleted" field. +func (m *EpicGvgDefenseTeamsMutation) ResetDeleted() { + m.deleted = nil +} + +// Where appends a list predicates to the EpicGvgDefenseTeamsMutation builder. +func (m *EpicGvgDefenseTeamsMutation) Where(ps ...predicate.EpicGvgDefenseTeams) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the EpicGvgDefenseTeamsMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *EpicGvgDefenseTeamsMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.EpicGvgDefenseTeams, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *EpicGvgDefenseTeamsMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *EpicGvgDefenseTeamsMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (EpicGvgDefenseTeams). +func (m *EpicGvgDefenseTeamsMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *EpicGvgDefenseTeamsMutation) Fields() []string { + fields := make([]string, 0, 6) + if m.defense_heroes != nil { + fields = append(fields, epicgvgdefenseteams.FieldDefenseHeroes) + } + if m.creator != nil { + fields = append(fields, epicgvgdefenseteams.FieldCreator) + } + if m.create_time != nil { + fields = append(fields, epicgvgdefenseteams.FieldCreateTime) + } + if m.updater != nil { + fields = append(fields, epicgvgdefenseteams.FieldUpdater) + } + if m.update_time != nil { + fields = append(fields, epicgvgdefenseteams.FieldUpdateTime) + } + if m.deleted != nil { + fields = append(fields, epicgvgdefenseteams.FieldDeleted) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *EpicGvgDefenseTeamsMutation) Field(name string) (ent.Value, bool) { + switch name { + case epicgvgdefenseteams.FieldDefenseHeroes: + return m.DefenseHeroes() + case epicgvgdefenseteams.FieldCreator: + return m.Creator() + case epicgvgdefenseteams.FieldCreateTime: + return m.CreateTime() + case epicgvgdefenseteams.FieldUpdater: + return m.Updater() + case epicgvgdefenseteams.FieldUpdateTime: + return m.UpdateTime() + case epicgvgdefenseteams.FieldDeleted: + return m.Deleted() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *EpicGvgDefenseTeamsMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case epicgvgdefenseteams.FieldDefenseHeroes: + return m.OldDefenseHeroes(ctx) + case epicgvgdefenseteams.FieldCreator: + return m.OldCreator(ctx) + case epicgvgdefenseteams.FieldCreateTime: + return m.OldCreateTime(ctx) + case epicgvgdefenseteams.FieldUpdater: + return m.OldUpdater(ctx) + case epicgvgdefenseteams.FieldUpdateTime: + return m.OldUpdateTime(ctx) + case epicgvgdefenseteams.FieldDeleted: + return m.OldDeleted(ctx) + } + return nil, fmt.Errorf("unknown EpicGvgDefenseTeams field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *EpicGvgDefenseTeamsMutation) SetField(name string, value ent.Value) error { + switch name { + case epicgvgdefenseteams.FieldDefenseHeroes: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDefenseHeroes(v) + return nil + case epicgvgdefenseteams.FieldCreator: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreator(v) + return nil + case epicgvgdefenseteams.FieldCreateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreateTime(v) + return nil + case epicgvgdefenseteams.FieldUpdater: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdater(v) + return nil + case epicgvgdefenseteams.FieldUpdateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdateTime(v) + return nil + case epicgvgdefenseteams.FieldDeleted: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeleted(v) + return nil + } + return fmt.Errorf("unknown EpicGvgDefenseTeams field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *EpicGvgDefenseTeamsMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *EpicGvgDefenseTeamsMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *EpicGvgDefenseTeamsMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown EpicGvgDefenseTeams numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *EpicGvgDefenseTeamsMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(epicgvgdefenseteams.FieldCreateTime) { + fields = append(fields, epicgvgdefenseteams.FieldCreateTime) + } + if m.FieldCleared(epicgvgdefenseteams.FieldUpdateTime) { + fields = append(fields, epicgvgdefenseteams.FieldUpdateTime) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *EpicGvgDefenseTeamsMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *EpicGvgDefenseTeamsMutation) ClearField(name string) error { + switch name { + case epicgvgdefenseteams.FieldCreateTime: + m.ClearCreateTime() + return nil + case epicgvgdefenseteams.FieldUpdateTime: + m.ClearUpdateTime() + return nil + } + return fmt.Errorf("unknown EpicGvgDefenseTeams nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *EpicGvgDefenseTeamsMutation) ResetField(name string) error { + switch name { + case epicgvgdefenseteams.FieldDefenseHeroes: + m.ResetDefenseHeroes() + return nil + case epicgvgdefenseteams.FieldCreator: + m.ResetCreator() + return nil + case epicgvgdefenseteams.FieldCreateTime: + m.ResetCreateTime() + return nil + case epicgvgdefenseteams.FieldUpdater: + m.ResetUpdater() + return nil + case epicgvgdefenseteams.FieldUpdateTime: + m.ResetUpdateTime() + return nil + case epicgvgdefenseteams.FieldDeleted: + m.ResetDeleted() + return nil + } + return fmt.Errorf("unknown EpicGvgDefenseTeams field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *EpicGvgDefenseTeamsMutation) AddedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *EpicGvgDefenseTeamsMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *EpicGvgDefenseTeamsMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *EpicGvgDefenseTeamsMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *EpicGvgDefenseTeamsMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *EpicGvgDefenseTeamsMutation) EdgeCleared(name string) bool { + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *EpicGvgDefenseTeamsMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown EpicGvgDefenseTeams unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *EpicGvgDefenseTeamsMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown EpicGvgDefenseTeams edge %s", name) +} + +// EpicHeroInfoMutation represents an operation that mutates the EpicHeroInfo nodes in the graph. +type EpicHeroInfoMutation struct { + config + op Op + typ string + id *int64 + hero_name *string + hero_code *string + hero_attr_lv60 *string + creator *string + create_time *time.Time + updater *string + update_time *time.Time + deleted *bool + nick_name *string + rarity *string + role *string + zodiac *string + head_img_url *string + attribute *string + remark *string + raw_json *string + set_content_json *string + set_update_time *time.Time + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*EpicHeroInfo, error) + predicates []predicate.EpicHeroInfo +} + +var _ ent.Mutation = (*EpicHeroInfoMutation)(nil) + +// epicheroinfoOption allows management of the mutation configuration using functional options. +type epicheroinfoOption func(*EpicHeroInfoMutation) + +// newEpicHeroInfoMutation creates new mutation for the EpicHeroInfo entity. +func newEpicHeroInfoMutation(c config, op Op, opts ...epicheroinfoOption) *EpicHeroInfoMutation { + m := &EpicHeroInfoMutation{ + config: c, + op: op, + typ: TypeEpicHeroInfo, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withEpicHeroInfoID sets the ID field of the mutation. +func withEpicHeroInfoID(id int64) epicheroinfoOption { + return func(m *EpicHeroInfoMutation) { + var ( + err error + once sync.Once + value *EpicHeroInfo + ) + m.oldValue = func(ctx context.Context) (*EpicHeroInfo, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().EpicHeroInfo.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withEpicHeroInfo sets the old EpicHeroInfo of the mutation. +func withEpicHeroInfo(node *EpicHeroInfo) epicheroinfoOption { + return func(m *EpicHeroInfoMutation) { + m.oldValue = func(context.Context) (*EpicHeroInfo, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m EpicHeroInfoMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m EpicHeroInfoMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of EpicHeroInfo entities. +func (m *EpicHeroInfoMutation) SetID(id int64) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *EpicHeroInfoMutation) ID() (id int64, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *EpicHeroInfoMutation) IDs(ctx context.Context) ([]int64, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int64{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().EpicHeroInfo.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetHeroName sets the "hero_name" field. +func (m *EpicHeroInfoMutation) SetHeroName(s string) { + m.hero_name = &s +} + +// HeroName returns the value of the "hero_name" field in the mutation. +func (m *EpicHeroInfoMutation) HeroName() (r string, exists bool) { + v := m.hero_name + if v == nil { + return + } + return *v, true +} + +// OldHeroName returns the old "hero_name" field's value of the EpicHeroInfo entity. +// If the EpicHeroInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicHeroInfoMutation) OldHeroName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldHeroName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldHeroName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldHeroName: %w", err) + } + return oldValue.HeroName, nil +} + +// ResetHeroName resets all changes to the "hero_name" field. +func (m *EpicHeroInfoMutation) ResetHeroName() { + m.hero_name = nil +} + +// SetHeroCode sets the "hero_code" field. +func (m *EpicHeroInfoMutation) SetHeroCode(s string) { + m.hero_code = &s +} + +// HeroCode returns the value of the "hero_code" field in the mutation. +func (m *EpicHeroInfoMutation) HeroCode() (r string, exists bool) { + v := m.hero_code + if v == nil { + return + } + return *v, true +} + +// OldHeroCode returns the old "hero_code" field's value of the EpicHeroInfo entity. +// If the EpicHeroInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicHeroInfoMutation) OldHeroCode(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldHeroCode is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldHeroCode requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldHeroCode: %w", err) + } + return oldValue.HeroCode, nil +} + +// ResetHeroCode resets all changes to the "hero_code" field. +func (m *EpicHeroInfoMutation) ResetHeroCode() { + m.hero_code = nil +} + +// SetHeroAttrLv60 sets the "hero_attr_lv60" field. +func (m *EpicHeroInfoMutation) SetHeroAttrLv60(s string) { + m.hero_attr_lv60 = &s +} + +// HeroAttrLv60 returns the value of the "hero_attr_lv60" field in the mutation. +func (m *EpicHeroInfoMutation) HeroAttrLv60() (r string, exists bool) { + v := m.hero_attr_lv60 + if v == nil { + return + } + return *v, true +} + +// OldHeroAttrLv60 returns the old "hero_attr_lv60" field's value of the EpicHeroInfo entity. +// If the EpicHeroInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicHeroInfoMutation) OldHeroAttrLv60(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldHeroAttrLv60 is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldHeroAttrLv60 requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldHeroAttrLv60: %w", err) + } + return oldValue.HeroAttrLv60, nil +} + +// ResetHeroAttrLv60 resets all changes to the "hero_attr_lv60" field. +func (m *EpicHeroInfoMutation) ResetHeroAttrLv60() { + m.hero_attr_lv60 = nil +} + +// SetCreator sets the "creator" field. +func (m *EpicHeroInfoMutation) SetCreator(s string) { + m.creator = &s +} + +// Creator returns the value of the "creator" field in the mutation. +func (m *EpicHeroInfoMutation) Creator() (r string, exists bool) { + v := m.creator + if v == nil { + return + } + return *v, true +} + +// OldCreator returns the old "creator" field's value of the EpicHeroInfo entity. +// If the EpicHeroInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicHeroInfoMutation) OldCreator(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreator is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreator requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreator: %w", err) + } + return oldValue.Creator, nil +} + +// ResetCreator resets all changes to the "creator" field. +func (m *EpicHeroInfoMutation) ResetCreator() { + m.creator = nil +} + +// SetCreateTime sets the "create_time" field. +func (m *EpicHeroInfoMutation) SetCreateTime(t time.Time) { + m.create_time = &t +} + +// CreateTime returns the value of the "create_time" field in the mutation. +func (m *EpicHeroInfoMutation) CreateTime() (r time.Time, exists bool) { + v := m.create_time + if v == nil { + return + } + return *v, true +} + +// OldCreateTime returns the old "create_time" field's value of the EpicHeroInfo entity. +// If the EpicHeroInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicHeroInfoMutation) OldCreateTime(ctx context.Context) (v *time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) + } + return oldValue.CreateTime, nil +} + +// ClearCreateTime clears the value of the "create_time" field. +func (m *EpicHeroInfoMutation) ClearCreateTime() { + m.create_time = nil + m.clearedFields[epicheroinfo.FieldCreateTime] = struct{}{} +} + +// CreateTimeCleared returns if the "create_time" field was cleared in this mutation. +func (m *EpicHeroInfoMutation) CreateTimeCleared() bool { + _, ok := m.clearedFields[epicheroinfo.FieldCreateTime] + return ok +} + +// ResetCreateTime resets all changes to the "create_time" field. +func (m *EpicHeroInfoMutation) ResetCreateTime() { + m.create_time = nil + delete(m.clearedFields, epicheroinfo.FieldCreateTime) +} + +// SetUpdater sets the "updater" field. +func (m *EpicHeroInfoMutation) SetUpdater(s string) { + m.updater = &s +} + +// Updater returns the value of the "updater" field in the mutation. +func (m *EpicHeroInfoMutation) Updater() (r string, exists bool) { + v := m.updater + if v == nil { + return + } + return *v, true +} + +// OldUpdater returns the old "updater" field's value of the EpicHeroInfo entity. +// If the EpicHeroInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicHeroInfoMutation) OldUpdater(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdater is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdater requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdater: %w", err) + } + return oldValue.Updater, nil +} + +// ResetUpdater resets all changes to the "updater" field. +func (m *EpicHeroInfoMutation) ResetUpdater() { + m.updater = nil +} + +// SetUpdateTime sets the "update_time" field. +func (m *EpicHeroInfoMutation) SetUpdateTime(t time.Time) { + m.update_time = &t +} + +// UpdateTime returns the value of the "update_time" field in the mutation. +func (m *EpicHeroInfoMutation) UpdateTime() (r time.Time, exists bool) { + v := m.update_time + if v == nil { + return + } + return *v, true +} + +// OldUpdateTime returns the old "update_time" field's value of the EpicHeroInfo entity. +// If the EpicHeroInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicHeroInfoMutation) OldUpdateTime(ctx context.Context) (v *time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err) + } + return oldValue.UpdateTime, nil +} + +// ClearUpdateTime clears the value of the "update_time" field. +func (m *EpicHeroInfoMutation) ClearUpdateTime() { + m.update_time = nil + m.clearedFields[epicheroinfo.FieldUpdateTime] = struct{}{} +} + +// UpdateTimeCleared returns if the "update_time" field was cleared in this mutation. +func (m *EpicHeroInfoMutation) UpdateTimeCleared() bool { + _, ok := m.clearedFields[epicheroinfo.FieldUpdateTime] + return ok +} + +// ResetUpdateTime resets all changes to the "update_time" field. +func (m *EpicHeroInfoMutation) ResetUpdateTime() { + m.update_time = nil + delete(m.clearedFields, epicheroinfo.FieldUpdateTime) +} + +// SetDeleted sets the "deleted" field. +func (m *EpicHeroInfoMutation) SetDeleted(b bool) { + m.deleted = &b +} + +// Deleted returns the value of the "deleted" field in the mutation. +func (m *EpicHeroInfoMutation) Deleted() (r bool, exists bool) { + v := m.deleted + if v == nil { + return + } + return *v, true +} + +// OldDeleted returns the old "deleted" field's value of the EpicHeroInfo entity. +// If the EpicHeroInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicHeroInfoMutation) OldDeleted(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeleted is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeleted requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeleted: %w", err) + } + return oldValue.Deleted, nil +} + +// ResetDeleted resets all changes to the "deleted" field. +func (m *EpicHeroInfoMutation) ResetDeleted() { + m.deleted = nil +} + +// SetNickName sets the "nick_name" field. +func (m *EpicHeroInfoMutation) SetNickName(s string) { + m.nick_name = &s +} + +// NickName returns the value of the "nick_name" field in the mutation. +func (m *EpicHeroInfoMutation) NickName() (r string, exists bool) { + v := m.nick_name + if v == nil { + return + } + return *v, true +} + +// OldNickName returns the old "nick_name" field's value of the EpicHeroInfo entity. +// If the EpicHeroInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicHeroInfoMutation) OldNickName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldNickName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldNickName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldNickName: %w", err) + } + return oldValue.NickName, nil +} + +// ResetNickName resets all changes to the "nick_name" field. +func (m *EpicHeroInfoMutation) ResetNickName() { + m.nick_name = nil +} + +// SetRarity sets the "rarity" field. +func (m *EpicHeroInfoMutation) SetRarity(s string) { + m.rarity = &s +} + +// Rarity returns the value of the "rarity" field in the mutation. +func (m *EpicHeroInfoMutation) Rarity() (r string, exists bool) { + v := m.rarity + if v == nil { + return + } + return *v, true +} + +// OldRarity returns the old "rarity" field's value of the EpicHeroInfo entity. +// If the EpicHeroInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicHeroInfoMutation) OldRarity(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRarity is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRarity requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRarity: %w", err) + } + return oldValue.Rarity, nil +} + +// ResetRarity resets all changes to the "rarity" field. +func (m *EpicHeroInfoMutation) ResetRarity() { + m.rarity = nil +} + +// SetRole sets the "role" field. +func (m *EpicHeroInfoMutation) SetRole(s string) { + m.role = &s +} + +// Role returns the value of the "role" field in the mutation. +func (m *EpicHeroInfoMutation) Role() (r string, exists bool) { + v := m.role + if v == nil { + return + } + return *v, true +} + +// OldRole returns the old "role" field's value of the EpicHeroInfo entity. +// If the EpicHeroInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicHeroInfoMutation) OldRole(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRole is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRole requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRole: %w", err) + } + return oldValue.Role, nil +} + +// ResetRole resets all changes to the "role" field. +func (m *EpicHeroInfoMutation) ResetRole() { + m.role = nil +} + +// SetZodiac sets the "zodiac" field. +func (m *EpicHeroInfoMutation) SetZodiac(s string) { + m.zodiac = &s +} + +// Zodiac returns the value of the "zodiac" field in the mutation. +func (m *EpicHeroInfoMutation) Zodiac() (r string, exists bool) { + v := m.zodiac + if v == nil { + return + } + return *v, true +} + +// OldZodiac returns the old "zodiac" field's value of the EpicHeroInfo entity. +// If the EpicHeroInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicHeroInfoMutation) OldZodiac(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldZodiac is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldZodiac requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldZodiac: %w", err) + } + return oldValue.Zodiac, nil +} + +// ResetZodiac resets all changes to the "zodiac" field. +func (m *EpicHeroInfoMutation) ResetZodiac() { + m.zodiac = nil +} + +// SetHeadImgURL sets the "head_img_url" field. +func (m *EpicHeroInfoMutation) SetHeadImgURL(s string) { + m.head_img_url = &s +} + +// HeadImgURL returns the value of the "head_img_url" field in the mutation. +func (m *EpicHeroInfoMutation) HeadImgURL() (r string, exists bool) { + v := m.head_img_url + if v == nil { + return + } + return *v, true +} + +// OldHeadImgURL returns the old "head_img_url" field's value of the EpicHeroInfo entity. +// If the EpicHeroInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicHeroInfoMutation) OldHeadImgURL(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldHeadImgURL is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldHeadImgURL requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldHeadImgURL: %w", err) + } + return oldValue.HeadImgURL, nil +} + +// ResetHeadImgURL resets all changes to the "head_img_url" field. +func (m *EpicHeroInfoMutation) ResetHeadImgURL() { + m.head_img_url = nil +} + +// SetAttribute sets the "attribute" field. +func (m *EpicHeroInfoMutation) SetAttribute(s string) { + m.attribute = &s +} + +// Attribute returns the value of the "attribute" field in the mutation. +func (m *EpicHeroInfoMutation) Attribute() (r string, exists bool) { + v := m.attribute + if v == nil { + return + } + return *v, true +} + +// OldAttribute returns the old "attribute" field's value of the EpicHeroInfo entity. +// If the EpicHeroInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicHeroInfoMutation) OldAttribute(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAttribute is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAttribute requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAttribute: %w", err) + } + return oldValue.Attribute, nil +} + +// ResetAttribute resets all changes to the "attribute" field. +func (m *EpicHeroInfoMutation) ResetAttribute() { + m.attribute = nil +} + +// SetRemark sets the "remark" field. +func (m *EpicHeroInfoMutation) SetRemark(s string) { + m.remark = &s +} + +// Remark returns the value of the "remark" field in the mutation. +func (m *EpicHeroInfoMutation) Remark() (r string, exists bool) { + v := m.remark + if v == nil { + return + } + return *v, true +} + +// OldRemark returns the old "remark" field's value of the EpicHeroInfo entity. +// If the EpicHeroInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicHeroInfoMutation) OldRemark(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRemark is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRemark requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRemark: %w", err) + } + return oldValue.Remark, nil +} + +// ResetRemark resets all changes to the "remark" field. +func (m *EpicHeroInfoMutation) ResetRemark() { + m.remark = nil +} + +// SetRawJSON sets the "raw_json" field. +func (m *EpicHeroInfoMutation) SetRawJSON(s string) { + m.raw_json = &s +} + +// RawJSON returns the value of the "raw_json" field in the mutation. +func (m *EpicHeroInfoMutation) RawJSON() (r string, exists bool) { + v := m.raw_json + if v == nil { + return + } + return *v, true +} + +// OldRawJSON returns the old "raw_json" field's value of the EpicHeroInfo entity. +// If the EpicHeroInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicHeroInfoMutation) OldRawJSON(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRawJSON is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRawJSON requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRawJSON: %w", err) + } + return oldValue.RawJSON, nil +} + +// ResetRawJSON resets all changes to the "raw_json" field. +func (m *EpicHeroInfoMutation) ResetRawJSON() { + m.raw_json = nil +} + +// SetSetContentJSON sets the "set_content_json" field. +func (m *EpicHeroInfoMutation) SetSetContentJSON(s string) { + m.set_content_json = &s +} + +// SetContentJSON returns the value of the "set_content_json" field in the mutation. +func (m *EpicHeroInfoMutation) SetContentJSON() (r string, exists bool) { + v := m.set_content_json + if v == nil { + return + } + return *v, true +} + +// OldSetContentJSON returns the old "set_content_json" field's value of the EpicHeroInfo entity. +// If the EpicHeroInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicHeroInfoMutation) OldSetContentJSON(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSetContentJSON is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSetContentJSON requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSetContentJSON: %w", err) + } + return oldValue.SetContentJSON, nil +} + +// ResetSetContentJSON resets all changes to the "set_content_json" field. +func (m *EpicHeroInfoMutation) ResetSetContentJSON() { + m.set_content_json = nil +} + +// SetSetUpdateTime sets the "set_update_time" field. +func (m *EpicHeroInfoMutation) SetSetUpdateTime(t time.Time) { + m.set_update_time = &t +} + +// SetUpdateTime returns the value of the "set_update_time" field in the mutation. +func (m *EpicHeroInfoMutation) SetUpdateTime() (r time.Time, exists bool) { + v := m.set_update_time + if v == nil { + return + } + return *v, true +} + +// OldSetUpdateTime returns the old "set_update_time" field's value of the EpicHeroInfo entity. +// If the EpicHeroInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicHeroInfoMutation) OldSetUpdateTime(ctx context.Context) (v *time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSetUpdateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSetUpdateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSetUpdateTime: %w", err) + } + return oldValue.SetUpdateTime, nil +} + +// ClearSetUpdateTime clears the value of the "set_update_time" field. +func (m *EpicHeroInfoMutation) ClearSetUpdateTime() { + m.set_update_time = nil + m.clearedFields[epicheroinfo.FieldSetUpdateTime] = struct{}{} +} + +// SetUpdateTimeCleared returns if the "set_update_time" field was cleared in this mutation. +func (m *EpicHeroInfoMutation) SetUpdateTimeCleared() bool { + _, ok := m.clearedFields[epicheroinfo.FieldSetUpdateTime] + return ok +} + +// ResetSetUpdateTime resets all changes to the "set_update_time" field. +func (m *EpicHeroInfoMutation) ResetSetUpdateTime() { + m.set_update_time = nil + delete(m.clearedFields, epicheroinfo.FieldSetUpdateTime) +} + +// Where appends a list predicates to the EpicHeroInfoMutation builder. +func (m *EpicHeroInfoMutation) Where(ps ...predicate.EpicHeroInfo) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the EpicHeroInfoMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *EpicHeroInfoMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.EpicHeroInfo, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *EpicHeroInfoMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *EpicHeroInfoMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (EpicHeroInfo). +func (m *EpicHeroInfoMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *EpicHeroInfoMutation) Fields() []string { + fields := make([]string, 0, 18) + if m.hero_name != nil { + fields = append(fields, epicheroinfo.FieldHeroName) + } + if m.hero_code != nil { + fields = append(fields, epicheroinfo.FieldHeroCode) + } + if m.hero_attr_lv60 != nil { + fields = append(fields, epicheroinfo.FieldHeroAttrLv60) + } + if m.creator != nil { + fields = append(fields, epicheroinfo.FieldCreator) + } + if m.create_time != nil { + fields = append(fields, epicheroinfo.FieldCreateTime) + } + if m.updater != nil { + fields = append(fields, epicheroinfo.FieldUpdater) + } + if m.update_time != nil { + fields = append(fields, epicheroinfo.FieldUpdateTime) + } + if m.deleted != nil { + fields = append(fields, epicheroinfo.FieldDeleted) + } + if m.nick_name != nil { + fields = append(fields, epicheroinfo.FieldNickName) + } + if m.rarity != nil { + fields = append(fields, epicheroinfo.FieldRarity) + } + if m.role != nil { + fields = append(fields, epicheroinfo.FieldRole) + } + if m.zodiac != nil { + fields = append(fields, epicheroinfo.FieldZodiac) + } + if m.head_img_url != nil { + fields = append(fields, epicheroinfo.FieldHeadImgURL) + } + if m.attribute != nil { + fields = append(fields, epicheroinfo.FieldAttribute) + } + if m.remark != nil { + fields = append(fields, epicheroinfo.FieldRemark) + } + if m.raw_json != nil { + fields = append(fields, epicheroinfo.FieldRawJSON) + } + if m.set_content_json != nil { + fields = append(fields, epicheroinfo.FieldSetContentJSON) + } + if m.set_update_time != nil { + fields = append(fields, epicheroinfo.FieldSetUpdateTime) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *EpicHeroInfoMutation) Field(name string) (ent.Value, bool) { + switch name { + case epicheroinfo.FieldHeroName: + return m.HeroName() + case epicheroinfo.FieldHeroCode: + return m.HeroCode() + case epicheroinfo.FieldHeroAttrLv60: + return m.HeroAttrLv60() + case epicheroinfo.FieldCreator: + return m.Creator() + case epicheroinfo.FieldCreateTime: + return m.CreateTime() + case epicheroinfo.FieldUpdater: + return m.Updater() + case epicheroinfo.FieldUpdateTime: + return m.UpdateTime() + case epicheroinfo.FieldDeleted: + return m.Deleted() + case epicheroinfo.FieldNickName: + return m.NickName() + case epicheroinfo.FieldRarity: + return m.Rarity() + case epicheroinfo.FieldRole: + return m.Role() + case epicheroinfo.FieldZodiac: + return m.Zodiac() + case epicheroinfo.FieldHeadImgURL: + return m.HeadImgURL() + case epicheroinfo.FieldAttribute: + return m.Attribute() + case epicheroinfo.FieldRemark: + return m.Remark() + case epicheroinfo.FieldRawJSON: + return m.RawJSON() + case epicheroinfo.FieldSetContentJSON: + return m.SetContentJSON() + case epicheroinfo.FieldSetUpdateTime: + return m.SetUpdateTime() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *EpicHeroInfoMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case epicheroinfo.FieldHeroName: + return m.OldHeroName(ctx) + case epicheroinfo.FieldHeroCode: + return m.OldHeroCode(ctx) + case epicheroinfo.FieldHeroAttrLv60: + return m.OldHeroAttrLv60(ctx) + case epicheroinfo.FieldCreator: + return m.OldCreator(ctx) + case epicheroinfo.FieldCreateTime: + return m.OldCreateTime(ctx) + case epicheroinfo.FieldUpdater: + return m.OldUpdater(ctx) + case epicheroinfo.FieldUpdateTime: + return m.OldUpdateTime(ctx) + case epicheroinfo.FieldDeleted: + return m.OldDeleted(ctx) + case epicheroinfo.FieldNickName: + return m.OldNickName(ctx) + case epicheroinfo.FieldRarity: + return m.OldRarity(ctx) + case epicheroinfo.FieldRole: + return m.OldRole(ctx) + case epicheroinfo.FieldZodiac: + return m.OldZodiac(ctx) + case epicheroinfo.FieldHeadImgURL: + return m.OldHeadImgURL(ctx) + case epicheroinfo.FieldAttribute: + return m.OldAttribute(ctx) + case epicheroinfo.FieldRemark: + return m.OldRemark(ctx) + case epicheroinfo.FieldRawJSON: + return m.OldRawJSON(ctx) + case epicheroinfo.FieldSetContentJSON: + return m.OldSetContentJSON(ctx) + case epicheroinfo.FieldSetUpdateTime: + return m.OldSetUpdateTime(ctx) + } + return nil, fmt.Errorf("unknown EpicHeroInfo field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *EpicHeroInfoMutation) SetField(name string, value ent.Value) error { + switch name { + case epicheroinfo.FieldHeroName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHeroName(v) + return nil + case epicheroinfo.FieldHeroCode: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHeroCode(v) + return nil + case epicheroinfo.FieldHeroAttrLv60: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHeroAttrLv60(v) + return nil + case epicheroinfo.FieldCreator: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreator(v) + return nil + case epicheroinfo.FieldCreateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreateTime(v) + return nil + case epicheroinfo.FieldUpdater: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdater(v) + return nil + case epicheroinfo.FieldUpdateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdateTime(v) + return nil + case epicheroinfo.FieldDeleted: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeleted(v) + return nil + case epicheroinfo.FieldNickName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetNickName(v) + return nil + case epicheroinfo.FieldRarity: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRarity(v) + return nil + case epicheroinfo.FieldRole: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRole(v) + return nil + case epicheroinfo.FieldZodiac: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetZodiac(v) + return nil + case epicheroinfo.FieldHeadImgURL: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHeadImgURL(v) + return nil + case epicheroinfo.FieldAttribute: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAttribute(v) + return nil + case epicheroinfo.FieldRemark: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRemark(v) + return nil + case epicheroinfo.FieldRawJSON: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRawJSON(v) + return nil + case epicheroinfo.FieldSetContentJSON: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSetContentJSON(v) + return nil + case epicheroinfo.FieldSetUpdateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSetUpdateTime(v) + return nil + } + return fmt.Errorf("unknown EpicHeroInfo field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *EpicHeroInfoMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *EpicHeroInfoMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *EpicHeroInfoMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown EpicHeroInfo numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *EpicHeroInfoMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(epicheroinfo.FieldCreateTime) { + fields = append(fields, epicheroinfo.FieldCreateTime) + } + if m.FieldCleared(epicheroinfo.FieldUpdateTime) { + fields = append(fields, epicheroinfo.FieldUpdateTime) + } + if m.FieldCleared(epicheroinfo.FieldSetUpdateTime) { + fields = append(fields, epicheroinfo.FieldSetUpdateTime) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *EpicHeroInfoMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *EpicHeroInfoMutation) ClearField(name string) error { + switch name { + case epicheroinfo.FieldCreateTime: + m.ClearCreateTime() + return nil + case epicheroinfo.FieldUpdateTime: + m.ClearUpdateTime() + return nil + case epicheroinfo.FieldSetUpdateTime: + m.ClearSetUpdateTime() + return nil + } + return fmt.Errorf("unknown EpicHeroInfo nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *EpicHeroInfoMutation) ResetField(name string) error { + switch name { + case epicheroinfo.FieldHeroName: + m.ResetHeroName() + return nil + case epicheroinfo.FieldHeroCode: + m.ResetHeroCode() + return nil + case epicheroinfo.FieldHeroAttrLv60: + m.ResetHeroAttrLv60() + return nil + case epicheroinfo.FieldCreator: + m.ResetCreator() + return nil + case epicheroinfo.FieldCreateTime: + m.ResetCreateTime() + return nil + case epicheroinfo.FieldUpdater: + m.ResetUpdater() + return nil + case epicheroinfo.FieldUpdateTime: + m.ResetUpdateTime() + return nil + case epicheroinfo.FieldDeleted: + m.ResetDeleted() + return nil + case epicheroinfo.FieldNickName: + m.ResetNickName() + return nil + case epicheroinfo.FieldRarity: + m.ResetRarity() + return nil + case epicheroinfo.FieldRole: + m.ResetRole() + return nil + case epicheroinfo.FieldZodiac: + m.ResetZodiac() + return nil + case epicheroinfo.FieldHeadImgURL: + m.ResetHeadImgURL() + return nil + case epicheroinfo.FieldAttribute: + m.ResetAttribute() + return nil + case epicheroinfo.FieldRemark: + m.ResetRemark() + return nil + case epicheroinfo.FieldRawJSON: + m.ResetRawJSON() + return nil + case epicheroinfo.FieldSetContentJSON: + m.ResetSetContentJSON() + return nil + case epicheroinfo.FieldSetUpdateTime: + m.ResetSetUpdateTime() + return nil + } + return fmt.Errorf("unknown EpicHeroInfo field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *EpicHeroInfoMutation) AddedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *EpicHeroInfoMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *EpicHeroInfoMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *EpicHeroInfoMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *EpicHeroInfoMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *EpicHeroInfoMutation) EdgeCleared(name string) bool { + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *EpicHeroInfoMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown EpicHeroInfo unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *EpicHeroInfoMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown EpicHeroInfo edge %s", name) +} + +// EpicHeroUserBuildMutation represents an operation that mutates the EpicHeroUserBuild nodes in the graph. +type EpicHeroUserBuildMutation struct { + config + op Op + typ string + id *int64 + artifact_code *string + hero_code *string + hero_heath_build *float64 + addhero_heath_build *float64 + hero_attack_build *float64 + addhero_attack_build *float64 + hero_def_build *float64 + addhero_def_build *float64 + creator *string + create_time *time.Time + updater *string + update_time *time.Time + deleted *bool + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*EpicHeroUserBuild, error) + predicates []predicate.EpicHeroUserBuild +} + +var _ ent.Mutation = (*EpicHeroUserBuildMutation)(nil) + +// epicherouserbuildOption allows management of the mutation configuration using functional options. +type epicherouserbuildOption func(*EpicHeroUserBuildMutation) + +// newEpicHeroUserBuildMutation creates new mutation for the EpicHeroUserBuild entity. +func newEpicHeroUserBuildMutation(c config, op Op, opts ...epicherouserbuildOption) *EpicHeroUserBuildMutation { + m := &EpicHeroUserBuildMutation{ + config: c, + op: op, + typ: TypeEpicHeroUserBuild, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withEpicHeroUserBuildID sets the ID field of the mutation. +func withEpicHeroUserBuildID(id int64) epicherouserbuildOption { + return func(m *EpicHeroUserBuildMutation) { + var ( + err error + once sync.Once + value *EpicHeroUserBuild + ) + m.oldValue = func(ctx context.Context) (*EpicHeroUserBuild, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().EpicHeroUserBuild.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withEpicHeroUserBuild sets the old EpicHeroUserBuild of the mutation. +func withEpicHeroUserBuild(node *EpicHeroUserBuild) epicherouserbuildOption { + return func(m *EpicHeroUserBuildMutation) { + m.oldValue = func(context.Context) (*EpicHeroUserBuild, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m EpicHeroUserBuildMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m EpicHeroUserBuildMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of EpicHeroUserBuild entities. +func (m *EpicHeroUserBuildMutation) SetID(id int64) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *EpicHeroUserBuildMutation) ID() (id int64, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *EpicHeroUserBuildMutation) IDs(ctx context.Context) ([]int64, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int64{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().EpicHeroUserBuild.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetArtifactCode sets the "artifact_code" field. +func (m *EpicHeroUserBuildMutation) SetArtifactCode(s string) { + m.artifact_code = &s +} + +// ArtifactCode returns the value of the "artifact_code" field in the mutation. +func (m *EpicHeroUserBuildMutation) ArtifactCode() (r string, exists bool) { + v := m.artifact_code + if v == nil { + return + } + return *v, true +} + +// OldArtifactCode returns the old "artifact_code" field's value of the EpicHeroUserBuild entity. +// If the EpicHeroUserBuild object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicHeroUserBuildMutation) OldArtifactCode(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldArtifactCode is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldArtifactCode requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldArtifactCode: %w", err) + } + return oldValue.ArtifactCode, nil +} + +// ResetArtifactCode resets all changes to the "artifact_code" field. +func (m *EpicHeroUserBuildMutation) ResetArtifactCode() { + m.artifact_code = nil +} + +// SetHeroCode sets the "hero_code" field. +func (m *EpicHeroUserBuildMutation) SetHeroCode(s string) { + m.hero_code = &s +} + +// HeroCode returns the value of the "hero_code" field in the mutation. +func (m *EpicHeroUserBuildMutation) HeroCode() (r string, exists bool) { + v := m.hero_code + if v == nil { + return + } + return *v, true +} + +// OldHeroCode returns the old "hero_code" field's value of the EpicHeroUserBuild entity. +// If the EpicHeroUserBuild object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicHeroUserBuildMutation) OldHeroCode(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldHeroCode is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldHeroCode requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldHeroCode: %w", err) + } + return oldValue.HeroCode, nil +} + +// ResetHeroCode resets all changes to the "hero_code" field. +func (m *EpicHeroUserBuildMutation) ResetHeroCode() { + m.hero_code = nil +} + +// SetHeroHeathBuild sets the "hero_heath_build" field. +func (m *EpicHeroUserBuildMutation) SetHeroHeathBuild(f float64) { + m.hero_heath_build = &f + m.addhero_heath_build = nil +} + +// HeroHeathBuild returns the value of the "hero_heath_build" field in the mutation. +func (m *EpicHeroUserBuildMutation) HeroHeathBuild() (r float64, exists bool) { + v := m.hero_heath_build + if v == nil { + return + } + return *v, true +} + +// OldHeroHeathBuild returns the old "hero_heath_build" field's value of the EpicHeroUserBuild entity. +// If the EpicHeroUserBuild object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicHeroUserBuildMutation) OldHeroHeathBuild(ctx context.Context) (v float64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldHeroHeathBuild is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldHeroHeathBuild requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldHeroHeathBuild: %w", err) + } + return oldValue.HeroHeathBuild, nil +} + +// AddHeroHeathBuild adds f to the "hero_heath_build" field. +func (m *EpicHeroUserBuildMutation) AddHeroHeathBuild(f float64) { + if m.addhero_heath_build != nil { + *m.addhero_heath_build += f + } else { + m.addhero_heath_build = &f + } +} + +// AddedHeroHeathBuild returns the value that was added to the "hero_heath_build" field in this mutation. +func (m *EpicHeroUserBuildMutation) AddedHeroHeathBuild() (r float64, exists bool) { + v := m.addhero_heath_build + if v == nil { + return + } + return *v, true +} + +// ResetHeroHeathBuild resets all changes to the "hero_heath_build" field. +func (m *EpicHeroUserBuildMutation) ResetHeroHeathBuild() { + m.hero_heath_build = nil + m.addhero_heath_build = nil +} + +// SetHeroAttackBuild sets the "hero_attack_build" field. +func (m *EpicHeroUserBuildMutation) SetHeroAttackBuild(f float64) { + m.hero_attack_build = &f + m.addhero_attack_build = nil +} + +// HeroAttackBuild returns the value of the "hero_attack_build" field in the mutation. +func (m *EpicHeroUserBuildMutation) HeroAttackBuild() (r float64, exists bool) { + v := m.hero_attack_build + if v == nil { + return + } + return *v, true +} + +// OldHeroAttackBuild returns the old "hero_attack_build" field's value of the EpicHeroUserBuild entity. +// If the EpicHeroUserBuild object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicHeroUserBuildMutation) OldHeroAttackBuild(ctx context.Context) (v float64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldHeroAttackBuild is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldHeroAttackBuild requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldHeroAttackBuild: %w", err) + } + return oldValue.HeroAttackBuild, nil +} + +// AddHeroAttackBuild adds f to the "hero_attack_build" field. +func (m *EpicHeroUserBuildMutation) AddHeroAttackBuild(f float64) { + if m.addhero_attack_build != nil { + *m.addhero_attack_build += f + } else { + m.addhero_attack_build = &f + } +} + +// AddedHeroAttackBuild returns the value that was added to the "hero_attack_build" field in this mutation. +func (m *EpicHeroUserBuildMutation) AddedHeroAttackBuild() (r float64, exists bool) { + v := m.addhero_attack_build + if v == nil { + return + } + return *v, true +} + +// ResetHeroAttackBuild resets all changes to the "hero_attack_build" field. +func (m *EpicHeroUserBuildMutation) ResetHeroAttackBuild() { + m.hero_attack_build = nil + m.addhero_attack_build = nil +} + +// SetHeroDefBuild sets the "hero_def_build" field. +func (m *EpicHeroUserBuildMutation) SetHeroDefBuild(f float64) { + m.hero_def_build = &f + m.addhero_def_build = nil +} + +// HeroDefBuild returns the value of the "hero_def_build" field in the mutation. +func (m *EpicHeroUserBuildMutation) HeroDefBuild() (r float64, exists bool) { + v := m.hero_def_build + if v == nil { + return + } + return *v, true +} + +// OldHeroDefBuild returns the old "hero_def_build" field's value of the EpicHeroUserBuild entity. +// If the EpicHeroUserBuild object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicHeroUserBuildMutation) OldHeroDefBuild(ctx context.Context) (v float64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldHeroDefBuild is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldHeroDefBuild requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldHeroDefBuild: %w", err) + } + return oldValue.HeroDefBuild, nil +} + +// AddHeroDefBuild adds f to the "hero_def_build" field. +func (m *EpicHeroUserBuildMutation) AddHeroDefBuild(f float64) { + if m.addhero_def_build != nil { + *m.addhero_def_build += f + } else { + m.addhero_def_build = &f + } +} + +// AddedHeroDefBuild returns the value that was added to the "hero_def_build" field in this mutation. +func (m *EpicHeroUserBuildMutation) AddedHeroDefBuild() (r float64, exists bool) { + v := m.addhero_def_build + if v == nil { + return + } + return *v, true +} + +// ResetHeroDefBuild resets all changes to the "hero_def_build" field. +func (m *EpicHeroUserBuildMutation) ResetHeroDefBuild() { + m.hero_def_build = nil + m.addhero_def_build = nil +} + +// SetCreator sets the "creator" field. +func (m *EpicHeroUserBuildMutation) SetCreator(s string) { + m.creator = &s +} + +// Creator returns the value of the "creator" field in the mutation. +func (m *EpicHeroUserBuildMutation) Creator() (r string, exists bool) { + v := m.creator + if v == nil { + return + } + return *v, true +} + +// OldCreator returns the old "creator" field's value of the EpicHeroUserBuild entity. +// If the EpicHeroUserBuild object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicHeroUserBuildMutation) OldCreator(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreator is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreator requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreator: %w", err) + } + return oldValue.Creator, nil +} + +// ResetCreator resets all changes to the "creator" field. +func (m *EpicHeroUserBuildMutation) ResetCreator() { + m.creator = nil +} + +// SetCreateTime sets the "create_time" field. +func (m *EpicHeroUserBuildMutation) SetCreateTime(t time.Time) { + m.create_time = &t +} + +// CreateTime returns the value of the "create_time" field in the mutation. +func (m *EpicHeroUserBuildMutation) CreateTime() (r time.Time, exists bool) { + v := m.create_time + if v == nil { + return + } + return *v, true +} + +// OldCreateTime returns the old "create_time" field's value of the EpicHeroUserBuild entity. +// If the EpicHeroUserBuild object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicHeroUserBuildMutation) OldCreateTime(ctx context.Context) (v *time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) + } + return oldValue.CreateTime, nil +} + +// ClearCreateTime clears the value of the "create_time" field. +func (m *EpicHeroUserBuildMutation) ClearCreateTime() { + m.create_time = nil + m.clearedFields[epicherouserbuild.FieldCreateTime] = struct{}{} +} + +// CreateTimeCleared returns if the "create_time" field was cleared in this mutation. +func (m *EpicHeroUserBuildMutation) CreateTimeCleared() bool { + _, ok := m.clearedFields[epicherouserbuild.FieldCreateTime] + return ok +} + +// ResetCreateTime resets all changes to the "create_time" field. +func (m *EpicHeroUserBuildMutation) ResetCreateTime() { + m.create_time = nil + delete(m.clearedFields, epicherouserbuild.FieldCreateTime) +} + +// SetUpdater sets the "updater" field. +func (m *EpicHeroUserBuildMutation) SetUpdater(s string) { + m.updater = &s +} + +// Updater returns the value of the "updater" field in the mutation. +func (m *EpicHeroUserBuildMutation) Updater() (r string, exists bool) { + v := m.updater + if v == nil { + return + } + return *v, true +} + +// OldUpdater returns the old "updater" field's value of the EpicHeroUserBuild entity. +// If the EpicHeroUserBuild object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicHeroUserBuildMutation) OldUpdater(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdater is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdater requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdater: %w", err) + } + return oldValue.Updater, nil +} + +// ResetUpdater resets all changes to the "updater" field. +func (m *EpicHeroUserBuildMutation) ResetUpdater() { + m.updater = nil +} + +// SetUpdateTime sets the "update_time" field. +func (m *EpicHeroUserBuildMutation) SetUpdateTime(t time.Time) { + m.update_time = &t +} + +// UpdateTime returns the value of the "update_time" field in the mutation. +func (m *EpicHeroUserBuildMutation) UpdateTime() (r time.Time, exists bool) { + v := m.update_time + if v == nil { + return + } + return *v, true +} + +// OldUpdateTime returns the old "update_time" field's value of the EpicHeroUserBuild entity. +// If the EpicHeroUserBuild object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicHeroUserBuildMutation) OldUpdateTime(ctx context.Context) (v *time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err) + } + return oldValue.UpdateTime, nil +} + +// ClearUpdateTime clears the value of the "update_time" field. +func (m *EpicHeroUserBuildMutation) ClearUpdateTime() { + m.update_time = nil + m.clearedFields[epicherouserbuild.FieldUpdateTime] = struct{}{} +} + +// UpdateTimeCleared returns if the "update_time" field was cleared in this mutation. +func (m *EpicHeroUserBuildMutation) UpdateTimeCleared() bool { + _, ok := m.clearedFields[epicherouserbuild.FieldUpdateTime] + return ok +} + +// ResetUpdateTime resets all changes to the "update_time" field. +func (m *EpicHeroUserBuildMutation) ResetUpdateTime() { + m.update_time = nil + delete(m.clearedFields, epicherouserbuild.FieldUpdateTime) +} + +// SetDeleted sets the "deleted" field. +func (m *EpicHeroUserBuildMutation) SetDeleted(b bool) { + m.deleted = &b +} + +// Deleted returns the value of the "deleted" field in the mutation. +func (m *EpicHeroUserBuildMutation) Deleted() (r bool, exists bool) { + v := m.deleted + if v == nil { + return + } + return *v, true +} + +// OldDeleted returns the old "deleted" field's value of the EpicHeroUserBuild entity. +// If the EpicHeroUserBuild object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicHeroUserBuildMutation) OldDeleted(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeleted is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeleted requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeleted: %w", err) + } + return oldValue.Deleted, nil +} + +// ResetDeleted resets all changes to the "deleted" field. +func (m *EpicHeroUserBuildMutation) ResetDeleted() { + m.deleted = nil +} + +// Where appends a list predicates to the EpicHeroUserBuildMutation builder. +func (m *EpicHeroUserBuildMutation) Where(ps ...predicate.EpicHeroUserBuild) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the EpicHeroUserBuildMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *EpicHeroUserBuildMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.EpicHeroUserBuild, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *EpicHeroUserBuildMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *EpicHeroUserBuildMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (EpicHeroUserBuild). +func (m *EpicHeroUserBuildMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *EpicHeroUserBuildMutation) Fields() []string { + fields := make([]string, 0, 10) + if m.artifact_code != nil { + fields = append(fields, epicherouserbuild.FieldArtifactCode) + } + if m.hero_code != nil { + fields = append(fields, epicherouserbuild.FieldHeroCode) + } + if m.hero_heath_build != nil { + fields = append(fields, epicherouserbuild.FieldHeroHeathBuild) + } + if m.hero_attack_build != nil { + fields = append(fields, epicherouserbuild.FieldHeroAttackBuild) + } + if m.hero_def_build != nil { + fields = append(fields, epicherouserbuild.FieldHeroDefBuild) + } + if m.creator != nil { + fields = append(fields, epicherouserbuild.FieldCreator) + } + if m.create_time != nil { + fields = append(fields, epicherouserbuild.FieldCreateTime) + } + if m.updater != nil { + fields = append(fields, epicherouserbuild.FieldUpdater) + } + if m.update_time != nil { + fields = append(fields, epicherouserbuild.FieldUpdateTime) + } + if m.deleted != nil { + fields = append(fields, epicherouserbuild.FieldDeleted) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *EpicHeroUserBuildMutation) Field(name string) (ent.Value, bool) { + switch name { + case epicherouserbuild.FieldArtifactCode: + return m.ArtifactCode() + case epicherouserbuild.FieldHeroCode: + return m.HeroCode() + case epicherouserbuild.FieldHeroHeathBuild: + return m.HeroHeathBuild() + case epicherouserbuild.FieldHeroAttackBuild: + return m.HeroAttackBuild() + case epicherouserbuild.FieldHeroDefBuild: + return m.HeroDefBuild() + case epicherouserbuild.FieldCreator: + return m.Creator() + case epicherouserbuild.FieldCreateTime: + return m.CreateTime() + case epicherouserbuild.FieldUpdater: + return m.Updater() + case epicherouserbuild.FieldUpdateTime: + return m.UpdateTime() + case epicherouserbuild.FieldDeleted: + return m.Deleted() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *EpicHeroUserBuildMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case epicherouserbuild.FieldArtifactCode: + return m.OldArtifactCode(ctx) + case epicherouserbuild.FieldHeroCode: + return m.OldHeroCode(ctx) + case epicherouserbuild.FieldHeroHeathBuild: + return m.OldHeroHeathBuild(ctx) + case epicherouserbuild.FieldHeroAttackBuild: + return m.OldHeroAttackBuild(ctx) + case epicherouserbuild.FieldHeroDefBuild: + return m.OldHeroDefBuild(ctx) + case epicherouserbuild.FieldCreator: + return m.OldCreator(ctx) + case epicherouserbuild.FieldCreateTime: + return m.OldCreateTime(ctx) + case epicherouserbuild.FieldUpdater: + return m.OldUpdater(ctx) + case epicherouserbuild.FieldUpdateTime: + return m.OldUpdateTime(ctx) + case epicherouserbuild.FieldDeleted: + return m.OldDeleted(ctx) + } + return nil, fmt.Errorf("unknown EpicHeroUserBuild field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *EpicHeroUserBuildMutation) SetField(name string, value ent.Value) error { + switch name { + case epicherouserbuild.FieldArtifactCode: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetArtifactCode(v) + return nil + case epicherouserbuild.FieldHeroCode: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHeroCode(v) + return nil + case epicherouserbuild.FieldHeroHeathBuild: + v, ok := value.(float64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHeroHeathBuild(v) + return nil + case epicherouserbuild.FieldHeroAttackBuild: + v, ok := value.(float64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHeroAttackBuild(v) + return nil + case epicherouserbuild.FieldHeroDefBuild: + v, ok := value.(float64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHeroDefBuild(v) + return nil + case epicherouserbuild.FieldCreator: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreator(v) + return nil + case epicherouserbuild.FieldCreateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreateTime(v) + return nil + case epicherouserbuild.FieldUpdater: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdater(v) + return nil + case epicherouserbuild.FieldUpdateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdateTime(v) + return nil + case epicherouserbuild.FieldDeleted: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeleted(v) + return nil + } + return fmt.Errorf("unknown EpicHeroUserBuild field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *EpicHeroUserBuildMutation) AddedFields() []string { + var fields []string + if m.addhero_heath_build != nil { + fields = append(fields, epicherouserbuild.FieldHeroHeathBuild) + } + if m.addhero_attack_build != nil { + fields = append(fields, epicherouserbuild.FieldHeroAttackBuild) + } + if m.addhero_def_build != nil { + fields = append(fields, epicherouserbuild.FieldHeroDefBuild) + } + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *EpicHeroUserBuildMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case epicherouserbuild.FieldHeroHeathBuild: + return m.AddedHeroHeathBuild() + case epicherouserbuild.FieldHeroAttackBuild: + return m.AddedHeroAttackBuild() + case epicherouserbuild.FieldHeroDefBuild: + return m.AddedHeroDefBuild() + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *EpicHeroUserBuildMutation) AddField(name string, value ent.Value) error { + switch name { + case epicherouserbuild.FieldHeroHeathBuild: + v, ok := value.(float64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddHeroHeathBuild(v) + return nil + case epicherouserbuild.FieldHeroAttackBuild: + v, ok := value.(float64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddHeroAttackBuild(v) + return nil + case epicherouserbuild.FieldHeroDefBuild: + v, ok := value.(float64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddHeroDefBuild(v) + return nil + } + return fmt.Errorf("unknown EpicHeroUserBuild numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *EpicHeroUserBuildMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(epicherouserbuild.FieldCreateTime) { + fields = append(fields, epicherouserbuild.FieldCreateTime) + } + if m.FieldCleared(epicherouserbuild.FieldUpdateTime) { + fields = append(fields, epicherouserbuild.FieldUpdateTime) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *EpicHeroUserBuildMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *EpicHeroUserBuildMutation) ClearField(name string) error { + switch name { + case epicherouserbuild.FieldCreateTime: + m.ClearCreateTime() + return nil + case epicherouserbuild.FieldUpdateTime: + m.ClearUpdateTime() + return nil + } + return fmt.Errorf("unknown EpicHeroUserBuild nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *EpicHeroUserBuildMutation) ResetField(name string) error { + switch name { + case epicherouserbuild.FieldArtifactCode: + m.ResetArtifactCode() + return nil + case epicherouserbuild.FieldHeroCode: + m.ResetHeroCode() + return nil + case epicherouserbuild.FieldHeroHeathBuild: + m.ResetHeroHeathBuild() + return nil + case epicherouserbuild.FieldHeroAttackBuild: + m.ResetHeroAttackBuild() + return nil + case epicherouserbuild.FieldHeroDefBuild: + m.ResetHeroDefBuild() + return nil + case epicherouserbuild.FieldCreator: + m.ResetCreator() + return nil + case epicherouserbuild.FieldCreateTime: + m.ResetCreateTime() + return nil + case epicherouserbuild.FieldUpdater: + m.ResetUpdater() + return nil + case epicherouserbuild.FieldUpdateTime: + m.ResetUpdateTime() + return nil + case epicherouserbuild.FieldDeleted: + m.ResetDeleted() + return nil + } + return fmt.Errorf("unknown EpicHeroUserBuild field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *EpicHeroUserBuildMutation) AddedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *EpicHeroUserBuildMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *EpicHeroUserBuildMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *EpicHeroUserBuildMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *EpicHeroUserBuildMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *EpicHeroUserBuildMutation) EdgeCleared(name string) bool { + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *EpicHeroUserBuildMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown EpicHeroUserBuild unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *EpicHeroUserBuildMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown EpicHeroUserBuild edge %s", name) +} + +// EpicI18NMappingsMutation represents an operation that mutates the EpicI18NMappings nodes in the graph. +type EpicI18NMappingsMutation struct { + config + op Op + typ string + id *int64 + key_name *string + language *string + value *string + category *string + status *int + addstatus *int + creator *string + create_time *time.Time + updater *string + update_time *time.Time + deleted *int + adddeleted *int + code *string + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*EpicI18NMappings, error) + predicates []predicate.EpicI18NMappings +} + +var _ ent.Mutation = (*EpicI18NMappingsMutation)(nil) + +// epici18nmappingsOption allows management of the mutation configuration using functional options. +type epici18nmappingsOption func(*EpicI18NMappingsMutation) + +// newEpicI18NMappingsMutation creates new mutation for the EpicI18NMappings entity. +func newEpicI18NMappingsMutation(c config, op Op, opts ...epici18nmappingsOption) *EpicI18NMappingsMutation { + m := &EpicI18NMappingsMutation{ + config: c, + op: op, + typ: TypeEpicI18NMappings, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withEpicI18NMappingsID sets the ID field of the mutation. +func withEpicI18NMappingsID(id int64) epici18nmappingsOption { + return func(m *EpicI18NMappingsMutation) { + var ( + err error + once sync.Once + value *EpicI18NMappings + ) + m.oldValue = func(ctx context.Context) (*EpicI18NMappings, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().EpicI18NMappings.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withEpicI18NMappings sets the old EpicI18NMappings of the mutation. +func withEpicI18NMappings(node *EpicI18NMappings) epici18nmappingsOption { + return func(m *EpicI18NMappingsMutation) { + m.oldValue = func(context.Context) (*EpicI18NMappings, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m EpicI18NMappingsMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m EpicI18NMappingsMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of EpicI18NMappings entities. +func (m *EpicI18NMappingsMutation) SetID(id int64) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *EpicI18NMappingsMutation) ID() (id int64, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *EpicI18NMappingsMutation) IDs(ctx context.Context) ([]int64, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int64{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().EpicI18NMappings.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetKeyName sets the "key_name" field. +func (m *EpicI18NMappingsMutation) SetKeyName(s string) { + m.key_name = &s +} + +// KeyName returns the value of the "key_name" field in the mutation. +func (m *EpicI18NMappingsMutation) KeyName() (r string, exists bool) { + v := m.key_name + if v == nil { + return + } + return *v, true +} + +// OldKeyName returns the old "key_name" field's value of the EpicI18NMappings entity. +// If the EpicI18NMappings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicI18NMappingsMutation) OldKeyName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldKeyName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldKeyName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldKeyName: %w", err) + } + return oldValue.KeyName, nil +} + +// ResetKeyName resets all changes to the "key_name" field. +func (m *EpicI18NMappingsMutation) ResetKeyName() { + m.key_name = nil +} + +// SetLanguage sets the "language" field. +func (m *EpicI18NMappingsMutation) SetLanguage(s string) { + m.language = &s +} + +// Language returns the value of the "language" field in the mutation. +func (m *EpicI18NMappingsMutation) Language() (r string, exists bool) { + v := m.language + if v == nil { + return + } + return *v, true +} + +// OldLanguage returns the old "language" field's value of the EpicI18NMappings entity. +// If the EpicI18NMappings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicI18NMappingsMutation) OldLanguage(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLanguage is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLanguage requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLanguage: %w", err) + } + return oldValue.Language, nil +} + +// ResetLanguage resets all changes to the "language" field. +func (m *EpicI18NMappingsMutation) ResetLanguage() { + m.language = nil +} + +// SetValue sets the "value" field. +func (m *EpicI18NMappingsMutation) SetValue(s string) { + m.value = &s +} + +// Value returns the value of the "value" field in the mutation. +func (m *EpicI18NMappingsMutation) Value() (r string, exists bool) { + v := m.value + if v == nil { + return + } + return *v, true +} + +// OldValue returns the old "value" field's value of the EpicI18NMappings entity. +// If the EpicI18NMappings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicI18NMappingsMutation) OldValue(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldValue is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldValue requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldValue: %w", err) + } + return oldValue.Value, nil +} + +// ResetValue resets all changes to the "value" field. +func (m *EpicI18NMappingsMutation) ResetValue() { + m.value = nil +} + +// SetCategory sets the "category" field. +func (m *EpicI18NMappingsMutation) SetCategory(s string) { + m.category = &s +} + +// Category returns the value of the "category" field in the mutation. +func (m *EpicI18NMappingsMutation) Category() (r string, exists bool) { + v := m.category + if v == nil { + return + } + return *v, true +} + +// OldCategory returns the old "category" field's value of the EpicI18NMappings entity. +// If the EpicI18NMappings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicI18NMappingsMutation) OldCategory(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCategory is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCategory requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCategory: %w", err) + } + return oldValue.Category, nil +} + +// ResetCategory resets all changes to the "category" field. +func (m *EpicI18NMappingsMutation) ResetCategory() { + m.category = nil +} + +// SetStatus sets the "status" field. +func (m *EpicI18NMappingsMutation) SetStatus(i int) { + m.status = &i + m.addstatus = nil +} + +// Status returns the value of the "status" field in the mutation. +func (m *EpicI18NMappingsMutation) Status() (r int, exists bool) { + v := m.status + if v == nil { + return + } + return *v, true +} + +// OldStatus returns the old "status" field's value of the EpicI18NMappings entity. +// If the EpicI18NMappings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicI18NMappingsMutation) OldStatus(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldStatus is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldStatus requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldStatus: %w", err) + } + return oldValue.Status, nil +} + +// AddStatus adds i to the "status" field. +func (m *EpicI18NMappingsMutation) AddStatus(i int) { + if m.addstatus != nil { + *m.addstatus += i + } else { + m.addstatus = &i + } +} + +// AddedStatus returns the value that was added to the "status" field in this mutation. +func (m *EpicI18NMappingsMutation) AddedStatus() (r int, exists bool) { + v := m.addstatus + if v == nil { + return + } + return *v, true +} + +// ResetStatus resets all changes to the "status" field. +func (m *EpicI18NMappingsMutation) ResetStatus() { + m.status = nil + m.addstatus = nil +} + +// SetCreator sets the "creator" field. +func (m *EpicI18NMappingsMutation) SetCreator(s string) { + m.creator = &s +} + +// Creator returns the value of the "creator" field in the mutation. +func (m *EpicI18NMappingsMutation) Creator() (r string, exists bool) { + v := m.creator + if v == nil { + return + } + return *v, true +} + +// OldCreator returns the old "creator" field's value of the EpicI18NMappings entity. +// If the EpicI18NMappings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicI18NMappingsMutation) OldCreator(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreator is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreator requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreator: %w", err) + } + return oldValue.Creator, nil +} + +// ResetCreator resets all changes to the "creator" field. +func (m *EpicI18NMappingsMutation) ResetCreator() { + m.creator = nil +} + +// SetCreateTime sets the "create_time" field. +func (m *EpicI18NMappingsMutation) SetCreateTime(t time.Time) { + m.create_time = &t +} + +// CreateTime returns the value of the "create_time" field in the mutation. +func (m *EpicI18NMappingsMutation) CreateTime() (r time.Time, exists bool) { + v := m.create_time + if v == nil { + return + } + return *v, true +} + +// OldCreateTime returns the old "create_time" field's value of the EpicI18NMappings entity. +// If the EpicI18NMappings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicI18NMappingsMutation) OldCreateTime(ctx context.Context) (v *time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) + } + return oldValue.CreateTime, nil +} + +// ClearCreateTime clears the value of the "create_time" field. +func (m *EpicI18NMappingsMutation) ClearCreateTime() { + m.create_time = nil + m.clearedFields[epici18nmappings.FieldCreateTime] = struct{}{} +} + +// CreateTimeCleared returns if the "create_time" field was cleared in this mutation. +func (m *EpicI18NMappingsMutation) CreateTimeCleared() bool { + _, ok := m.clearedFields[epici18nmappings.FieldCreateTime] + return ok +} + +// ResetCreateTime resets all changes to the "create_time" field. +func (m *EpicI18NMappingsMutation) ResetCreateTime() { + m.create_time = nil + delete(m.clearedFields, epici18nmappings.FieldCreateTime) +} + +// SetUpdater sets the "updater" field. +func (m *EpicI18NMappingsMutation) SetUpdater(s string) { + m.updater = &s +} + +// Updater returns the value of the "updater" field in the mutation. +func (m *EpicI18NMappingsMutation) Updater() (r string, exists bool) { + v := m.updater + if v == nil { + return + } + return *v, true +} + +// OldUpdater returns the old "updater" field's value of the EpicI18NMappings entity. +// If the EpicI18NMappings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicI18NMappingsMutation) OldUpdater(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdater is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdater requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdater: %w", err) + } + return oldValue.Updater, nil +} + +// ResetUpdater resets all changes to the "updater" field. +func (m *EpicI18NMappingsMutation) ResetUpdater() { + m.updater = nil +} + +// SetUpdateTime sets the "update_time" field. +func (m *EpicI18NMappingsMutation) SetUpdateTime(t time.Time) { + m.update_time = &t +} + +// UpdateTime returns the value of the "update_time" field in the mutation. +func (m *EpicI18NMappingsMutation) UpdateTime() (r time.Time, exists bool) { + v := m.update_time + if v == nil { + return + } + return *v, true +} + +// OldUpdateTime returns the old "update_time" field's value of the EpicI18NMappings entity. +// If the EpicI18NMappings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicI18NMappingsMutation) OldUpdateTime(ctx context.Context) (v *time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err) + } + return oldValue.UpdateTime, nil +} + +// ClearUpdateTime clears the value of the "update_time" field. +func (m *EpicI18NMappingsMutation) ClearUpdateTime() { + m.update_time = nil + m.clearedFields[epici18nmappings.FieldUpdateTime] = struct{}{} +} + +// UpdateTimeCleared returns if the "update_time" field was cleared in this mutation. +func (m *EpicI18NMappingsMutation) UpdateTimeCleared() bool { + _, ok := m.clearedFields[epici18nmappings.FieldUpdateTime] + return ok +} + +// ResetUpdateTime resets all changes to the "update_time" field. +func (m *EpicI18NMappingsMutation) ResetUpdateTime() { + m.update_time = nil + delete(m.clearedFields, epici18nmappings.FieldUpdateTime) +} + +// SetDeleted sets the "deleted" field. +func (m *EpicI18NMappingsMutation) SetDeleted(i int) { + m.deleted = &i + m.adddeleted = nil +} + +// Deleted returns the value of the "deleted" field in the mutation. +func (m *EpicI18NMappingsMutation) Deleted() (r int, exists bool) { + v := m.deleted + if v == nil { + return + } + return *v, true +} + +// OldDeleted returns the old "deleted" field's value of the EpicI18NMappings entity. +// If the EpicI18NMappings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicI18NMappingsMutation) OldDeleted(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeleted is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeleted requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeleted: %w", err) + } + return oldValue.Deleted, nil +} + +// AddDeleted adds i to the "deleted" field. +func (m *EpicI18NMappingsMutation) AddDeleted(i int) { + if m.adddeleted != nil { + *m.adddeleted += i + } else { + m.adddeleted = &i + } +} + +// AddedDeleted returns the value that was added to the "deleted" field in this mutation. +func (m *EpicI18NMappingsMutation) AddedDeleted() (r int, exists bool) { + v := m.adddeleted + if v == nil { + return + } + return *v, true +} + +// ResetDeleted resets all changes to the "deleted" field. +func (m *EpicI18NMappingsMutation) ResetDeleted() { + m.deleted = nil + m.adddeleted = nil +} + +// SetCode sets the "code" field. +func (m *EpicI18NMappingsMutation) SetCode(s string) { + m.code = &s +} + +// Code returns the value of the "code" field in the mutation. +func (m *EpicI18NMappingsMutation) Code() (r string, exists bool) { + v := m.code + if v == nil { + return + } + return *v, true +} + +// OldCode returns the old "code" field's value of the EpicI18NMappings entity. +// If the EpicI18NMappings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EpicI18NMappingsMutation) OldCode(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCode is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCode requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCode: %w", err) + } + return oldValue.Code, nil +} + +// ResetCode resets all changes to the "code" field. +func (m *EpicI18NMappingsMutation) ResetCode() { + m.code = nil +} + +// Where appends a list predicates to the EpicI18NMappingsMutation builder. +func (m *EpicI18NMappingsMutation) Where(ps ...predicate.EpicI18NMappings) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the EpicI18NMappingsMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *EpicI18NMappingsMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.EpicI18NMappings, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *EpicI18NMappingsMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *EpicI18NMappingsMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (EpicI18NMappings). +func (m *EpicI18NMappingsMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *EpicI18NMappingsMutation) Fields() []string { + fields := make([]string, 0, 11) + if m.key_name != nil { + fields = append(fields, epici18nmappings.FieldKeyName) + } + if m.language != nil { + fields = append(fields, epici18nmappings.FieldLanguage) + } + if m.value != nil { + fields = append(fields, epici18nmappings.FieldValue) + } + if m.category != nil { + fields = append(fields, epici18nmappings.FieldCategory) + } + if m.status != nil { + fields = append(fields, epici18nmappings.FieldStatus) + } + if m.creator != nil { + fields = append(fields, epici18nmappings.FieldCreator) + } + if m.create_time != nil { + fields = append(fields, epici18nmappings.FieldCreateTime) + } + if m.updater != nil { + fields = append(fields, epici18nmappings.FieldUpdater) + } + if m.update_time != nil { + fields = append(fields, epici18nmappings.FieldUpdateTime) + } + if m.deleted != nil { + fields = append(fields, epici18nmappings.FieldDeleted) + } + if m.code != nil { + fields = append(fields, epici18nmappings.FieldCode) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *EpicI18NMappingsMutation) Field(name string) (ent.Value, bool) { + switch name { + case epici18nmappings.FieldKeyName: + return m.KeyName() + case epici18nmappings.FieldLanguage: + return m.Language() + case epici18nmappings.FieldValue: + return m.Value() + case epici18nmappings.FieldCategory: + return m.Category() + case epici18nmappings.FieldStatus: + return m.Status() + case epici18nmappings.FieldCreator: + return m.Creator() + case epici18nmappings.FieldCreateTime: + return m.CreateTime() + case epici18nmappings.FieldUpdater: + return m.Updater() + case epici18nmappings.FieldUpdateTime: + return m.UpdateTime() + case epici18nmappings.FieldDeleted: + return m.Deleted() + case epici18nmappings.FieldCode: + return m.Code() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *EpicI18NMappingsMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case epici18nmappings.FieldKeyName: + return m.OldKeyName(ctx) + case epici18nmappings.FieldLanguage: + return m.OldLanguage(ctx) + case epici18nmappings.FieldValue: + return m.OldValue(ctx) + case epici18nmappings.FieldCategory: + return m.OldCategory(ctx) + case epici18nmappings.FieldStatus: + return m.OldStatus(ctx) + case epici18nmappings.FieldCreator: + return m.OldCreator(ctx) + case epici18nmappings.FieldCreateTime: + return m.OldCreateTime(ctx) + case epici18nmappings.FieldUpdater: + return m.OldUpdater(ctx) + case epici18nmappings.FieldUpdateTime: + return m.OldUpdateTime(ctx) + case epici18nmappings.FieldDeleted: + return m.OldDeleted(ctx) + case epici18nmappings.FieldCode: + return m.OldCode(ctx) + } + return nil, fmt.Errorf("unknown EpicI18NMappings field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *EpicI18NMappingsMutation) SetField(name string, value ent.Value) error { + switch name { + case epici18nmappings.FieldKeyName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetKeyName(v) + return nil + case epici18nmappings.FieldLanguage: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLanguage(v) + return nil + case epici18nmappings.FieldValue: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetValue(v) + return nil + case epici18nmappings.FieldCategory: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCategory(v) + return nil + case epici18nmappings.FieldStatus: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStatus(v) + return nil + case epici18nmappings.FieldCreator: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreator(v) + return nil + case epici18nmappings.FieldCreateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreateTime(v) + return nil + case epici18nmappings.FieldUpdater: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdater(v) + return nil + case epici18nmappings.FieldUpdateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdateTime(v) + return nil + case epici18nmappings.FieldDeleted: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeleted(v) + return nil + case epici18nmappings.FieldCode: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCode(v) + return nil + } + return fmt.Errorf("unknown EpicI18NMappings field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *EpicI18NMappingsMutation) AddedFields() []string { + var fields []string + if m.addstatus != nil { + fields = append(fields, epici18nmappings.FieldStatus) + } + if m.adddeleted != nil { + fields = append(fields, epici18nmappings.FieldDeleted) + } + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *EpicI18NMappingsMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case epici18nmappings.FieldStatus: + return m.AddedStatus() + case epici18nmappings.FieldDeleted: + return m.AddedDeleted() + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *EpicI18NMappingsMutation) AddField(name string, value ent.Value) error { + switch name { + case epici18nmappings.FieldStatus: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddStatus(v) + return nil + case epici18nmappings.FieldDeleted: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddDeleted(v) + return nil + } + return fmt.Errorf("unknown EpicI18NMappings numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *EpicI18NMappingsMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(epici18nmappings.FieldCreateTime) { + fields = append(fields, epici18nmappings.FieldCreateTime) + } + if m.FieldCleared(epici18nmappings.FieldUpdateTime) { + fields = append(fields, epici18nmappings.FieldUpdateTime) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *EpicI18NMappingsMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *EpicI18NMappingsMutation) ClearField(name string) error { + switch name { + case epici18nmappings.FieldCreateTime: + m.ClearCreateTime() + return nil + case epici18nmappings.FieldUpdateTime: + m.ClearUpdateTime() + return nil + } + return fmt.Errorf("unknown EpicI18NMappings nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *EpicI18NMappingsMutation) ResetField(name string) error { + switch name { + case epici18nmappings.FieldKeyName: + m.ResetKeyName() + return nil + case epici18nmappings.FieldLanguage: + m.ResetLanguage() + return nil + case epici18nmappings.FieldValue: + m.ResetValue() + return nil + case epici18nmappings.FieldCategory: + m.ResetCategory() + return nil + case epici18nmappings.FieldStatus: + m.ResetStatus() + return nil + case epici18nmappings.FieldCreator: + m.ResetCreator() + return nil + case epici18nmappings.FieldCreateTime: + m.ResetCreateTime() + return nil + case epici18nmappings.FieldUpdater: + m.ResetUpdater() + return nil + case epici18nmappings.FieldUpdateTime: + m.ResetUpdateTime() + return nil + case epici18nmappings.FieldDeleted: + m.ResetDeleted() + return nil + case epici18nmappings.FieldCode: + m.ResetCode() + return nil + } + return fmt.Errorf("unknown EpicI18NMappings field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *EpicI18NMappingsMutation) AddedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *EpicI18NMappingsMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *EpicI18NMappingsMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *EpicI18NMappingsMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *EpicI18NMappingsMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *EpicI18NMappingsMutation) EdgeCleared(name string) bool { + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *EpicI18NMappingsMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown EpicI18NMappings unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *EpicI18NMappingsMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown EpicI18NMappings edge %s", name) +} + +// FribbleHeroSetMutation represents an operation that mutates the FribbleHeroSet nodes in the graph. +type FribbleHeroSetMutation struct { + config + op Op + typ string + id *int64 + hero_code *string + json_content *string + hero_name *string + creator *string + create_time *time.Time + updater *string + update_time *time.Time + deleted *bool + success_get *int + addsuccess_get *int + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*FribbleHeroSet, error) + predicates []predicate.FribbleHeroSet +} + +var _ ent.Mutation = (*FribbleHeroSetMutation)(nil) + +// fribbleherosetOption allows management of the mutation configuration using functional options. +type fribbleherosetOption func(*FribbleHeroSetMutation) + +// newFribbleHeroSetMutation creates new mutation for the FribbleHeroSet entity. +func newFribbleHeroSetMutation(c config, op Op, opts ...fribbleherosetOption) *FribbleHeroSetMutation { + m := &FribbleHeroSetMutation{ + config: c, + op: op, + typ: TypeFribbleHeroSet, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withFribbleHeroSetID sets the ID field of the mutation. +func withFribbleHeroSetID(id int64) fribbleherosetOption { + return func(m *FribbleHeroSetMutation) { + var ( + err error + once sync.Once + value *FribbleHeroSet + ) + m.oldValue = func(ctx context.Context) (*FribbleHeroSet, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().FribbleHeroSet.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withFribbleHeroSet sets the old FribbleHeroSet of the mutation. +func withFribbleHeroSet(node *FribbleHeroSet) fribbleherosetOption { + return func(m *FribbleHeroSetMutation) { + m.oldValue = func(context.Context) (*FribbleHeroSet, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m FribbleHeroSetMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m FribbleHeroSetMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of FribbleHeroSet entities. +func (m *FribbleHeroSetMutation) SetID(id int64) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *FribbleHeroSetMutation) ID() (id int64, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *FribbleHeroSetMutation) IDs(ctx context.Context) ([]int64, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int64{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().FribbleHeroSet.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetHeroCode sets the "hero_code" field. +func (m *FribbleHeroSetMutation) SetHeroCode(s string) { + m.hero_code = &s +} + +// HeroCode returns the value of the "hero_code" field in the mutation. +func (m *FribbleHeroSetMutation) HeroCode() (r string, exists bool) { + v := m.hero_code + if v == nil { + return + } + return *v, true +} + +// OldHeroCode returns the old "hero_code" field's value of the FribbleHeroSet entity. +// If the FribbleHeroSet object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *FribbleHeroSetMutation) OldHeroCode(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldHeroCode is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldHeroCode requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldHeroCode: %w", err) + } + return oldValue.HeroCode, nil +} + +// ResetHeroCode resets all changes to the "hero_code" field. +func (m *FribbleHeroSetMutation) ResetHeroCode() { + m.hero_code = nil +} + +// SetJSONContent sets the "json_content" field. +func (m *FribbleHeroSetMutation) SetJSONContent(s string) { + m.json_content = &s +} + +// JSONContent returns the value of the "json_content" field in the mutation. +func (m *FribbleHeroSetMutation) JSONContent() (r string, exists bool) { + v := m.json_content + if v == nil { + return + } + return *v, true +} + +// OldJSONContent returns the old "json_content" field's value of the FribbleHeroSet entity. +// If the FribbleHeroSet object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *FribbleHeroSetMutation) OldJSONContent(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldJSONContent is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldJSONContent requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldJSONContent: %w", err) + } + return oldValue.JSONContent, nil +} + +// ResetJSONContent resets all changes to the "json_content" field. +func (m *FribbleHeroSetMutation) ResetJSONContent() { + m.json_content = nil +} + +// SetHeroName sets the "hero_name" field. +func (m *FribbleHeroSetMutation) SetHeroName(s string) { + m.hero_name = &s +} + +// HeroName returns the value of the "hero_name" field in the mutation. +func (m *FribbleHeroSetMutation) HeroName() (r string, exists bool) { + v := m.hero_name + if v == nil { + return + } + return *v, true +} + +// OldHeroName returns the old "hero_name" field's value of the FribbleHeroSet entity. +// If the FribbleHeroSet object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *FribbleHeroSetMutation) OldHeroName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldHeroName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldHeroName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldHeroName: %w", err) + } + return oldValue.HeroName, nil +} + +// ResetHeroName resets all changes to the "hero_name" field. +func (m *FribbleHeroSetMutation) ResetHeroName() { + m.hero_name = nil +} + +// SetCreator sets the "creator" field. +func (m *FribbleHeroSetMutation) SetCreator(s string) { + m.creator = &s +} + +// Creator returns the value of the "creator" field in the mutation. +func (m *FribbleHeroSetMutation) Creator() (r string, exists bool) { + v := m.creator + if v == nil { + return + } + return *v, true +} + +// OldCreator returns the old "creator" field's value of the FribbleHeroSet entity. +// If the FribbleHeroSet object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *FribbleHeroSetMutation) OldCreator(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreator is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreator requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreator: %w", err) + } + return oldValue.Creator, nil +} + +// ResetCreator resets all changes to the "creator" field. +func (m *FribbleHeroSetMutation) ResetCreator() { + m.creator = nil +} + +// SetCreateTime sets the "create_time" field. +func (m *FribbleHeroSetMutation) SetCreateTime(t time.Time) { + m.create_time = &t +} + +// CreateTime returns the value of the "create_time" field in the mutation. +func (m *FribbleHeroSetMutation) CreateTime() (r time.Time, exists bool) { + v := m.create_time + if v == nil { + return + } + return *v, true +} + +// OldCreateTime returns the old "create_time" field's value of the FribbleHeroSet entity. +// If the FribbleHeroSet object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *FribbleHeroSetMutation) OldCreateTime(ctx context.Context) (v *time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) + } + return oldValue.CreateTime, nil +} + +// ClearCreateTime clears the value of the "create_time" field. +func (m *FribbleHeroSetMutation) ClearCreateTime() { + m.create_time = nil + m.clearedFields[fribbleheroset.FieldCreateTime] = struct{}{} +} + +// CreateTimeCleared returns if the "create_time" field was cleared in this mutation. +func (m *FribbleHeroSetMutation) CreateTimeCleared() bool { + _, ok := m.clearedFields[fribbleheroset.FieldCreateTime] + return ok +} + +// ResetCreateTime resets all changes to the "create_time" field. +func (m *FribbleHeroSetMutation) ResetCreateTime() { + m.create_time = nil + delete(m.clearedFields, fribbleheroset.FieldCreateTime) +} + +// SetUpdater sets the "updater" field. +func (m *FribbleHeroSetMutation) SetUpdater(s string) { + m.updater = &s +} + +// Updater returns the value of the "updater" field in the mutation. +func (m *FribbleHeroSetMutation) Updater() (r string, exists bool) { + v := m.updater + if v == nil { + return + } + return *v, true +} + +// OldUpdater returns the old "updater" field's value of the FribbleHeroSet entity. +// If the FribbleHeroSet object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *FribbleHeroSetMutation) OldUpdater(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdater is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdater requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdater: %w", err) + } + return oldValue.Updater, nil +} + +// ResetUpdater resets all changes to the "updater" field. +func (m *FribbleHeroSetMutation) ResetUpdater() { + m.updater = nil +} + +// SetUpdateTime sets the "update_time" field. +func (m *FribbleHeroSetMutation) SetUpdateTime(t time.Time) { + m.update_time = &t +} + +// UpdateTime returns the value of the "update_time" field in the mutation. +func (m *FribbleHeroSetMutation) UpdateTime() (r time.Time, exists bool) { + v := m.update_time + if v == nil { + return + } + return *v, true +} + +// OldUpdateTime returns the old "update_time" field's value of the FribbleHeroSet entity. +// If the FribbleHeroSet object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *FribbleHeroSetMutation) OldUpdateTime(ctx context.Context) (v *time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err) + } + return oldValue.UpdateTime, nil +} + +// ClearUpdateTime clears the value of the "update_time" field. +func (m *FribbleHeroSetMutation) ClearUpdateTime() { + m.update_time = nil + m.clearedFields[fribbleheroset.FieldUpdateTime] = struct{}{} +} + +// UpdateTimeCleared returns if the "update_time" field was cleared in this mutation. +func (m *FribbleHeroSetMutation) UpdateTimeCleared() bool { + _, ok := m.clearedFields[fribbleheroset.FieldUpdateTime] + return ok +} + +// ResetUpdateTime resets all changes to the "update_time" field. +func (m *FribbleHeroSetMutation) ResetUpdateTime() { + m.update_time = nil + delete(m.clearedFields, fribbleheroset.FieldUpdateTime) +} + +// SetDeleted sets the "deleted" field. +func (m *FribbleHeroSetMutation) SetDeleted(b bool) { + m.deleted = &b +} + +// Deleted returns the value of the "deleted" field in the mutation. +func (m *FribbleHeroSetMutation) Deleted() (r bool, exists bool) { + v := m.deleted + if v == nil { + return + } + return *v, true +} + +// OldDeleted returns the old "deleted" field's value of the FribbleHeroSet entity. +// If the FribbleHeroSet object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *FribbleHeroSetMutation) OldDeleted(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeleted is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeleted requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeleted: %w", err) + } + return oldValue.Deleted, nil +} + +// ResetDeleted resets all changes to the "deleted" field. +func (m *FribbleHeroSetMutation) ResetDeleted() { + m.deleted = nil +} + +// SetSuccessGet sets the "success_get" field. +func (m *FribbleHeroSetMutation) SetSuccessGet(i int) { + m.success_get = &i + m.addsuccess_get = nil +} + +// SuccessGet returns the value of the "success_get" field in the mutation. +func (m *FribbleHeroSetMutation) SuccessGet() (r int, exists bool) { + v := m.success_get + if v == nil { + return + } + return *v, true +} + +// OldSuccessGet returns the old "success_get" field's value of the FribbleHeroSet entity. +// If the FribbleHeroSet object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *FribbleHeroSetMutation) OldSuccessGet(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSuccessGet is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSuccessGet requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSuccessGet: %w", err) + } + return oldValue.SuccessGet, nil +} + +// AddSuccessGet adds i to the "success_get" field. +func (m *FribbleHeroSetMutation) AddSuccessGet(i int) { + if m.addsuccess_get != nil { + *m.addsuccess_get += i + } else { + m.addsuccess_get = &i + } +} + +// AddedSuccessGet returns the value that was added to the "success_get" field in this mutation. +func (m *FribbleHeroSetMutation) AddedSuccessGet() (r int, exists bool) { + v := m.addsuccess_get + if v == nil { + return + } + return *v, true +} + +// ResetSuccessGet resets all changes to the "success_get" field. +func (m *FribbleHeroSetMutation) ResetSuccessGet() { + m.success_get = nil + m.addsuccess_get = nil +} + +// Where appends a list predicates to the FribbleHeroSetMutation builder. +func (m *FribbleHeroSetMutation) Where(ps ...predicate.FribbleHeroSet) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the FribbleHeroSetMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *FribbleHeroSetMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.FribbleHeroSet, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *FribbleHeroSetMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *FribbleHeroSetMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (FribbleHeroSet). +func (m *FribbleHeroSetMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *FribbleHeroSetMutation) Fields() []string { + fields := make([]string, 0, 9) + if m.hero_code != nil { + fields = append(fields, fribbleheroset.FieldHeroCode) + } + if m.json_content != nil { + fields = append(fields, fribbleheroset.FieldJSONContent) + } + if m.hero_name != nil { + fields = append(fields, fribbleheroset.FieldHeroName) + } + if m.creator != nil { + fields = append(fields, fribbleheroset.FieldCreator) + } + if m.create_time != nil { + fields = append(fields, fribbleheroset.FieldCreateTime) + } + if m.updater != nil { + fields = append(fields, fribbleheroset.FieldUpdater) + } + if m.update_time != nil { + fields = append(fields, fribbleheroset.FieldUpdateTime) + } + if m.deleted != nil { + fields = append(fields, fribbleheroset.FieldDeleted) + } + if m.success_get != nil { + fields = append(fields, fribbleheroset.FieldSuccessGet) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *FribbleHeroSetMutation) Field(name string) (ent.Value, bool) { + switch name { + case fribbleheroset.FieldHeroCode: + return m.HeroCode() + case fribbleheroset.FieldJSONContent: + return m.JSONContent() + case fribbleheroset.FieldHeroName: + return m.HeroName() + case fribbleheroset.FieldCreator: + return m.Creator() + case fribbleheroset.FieldCreateTime: + return m.CreateTime() + case fribbleheroset.FieldUpdater: + return m.Updater() + case fribbleheroset.FieldUpdateTime: + return m.UpdateTime() + case fribbleheroset.FieldDeleted: + return m.Deleted() + case fribbleheroset.FieldSuccessGet: + return m.SuccessGet() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *FribbleHeroSetMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case fribbleheroset.FieldHeroCode: + return m.OldHeroCode(ctx) + case fribbleheroset.FieldJSONContent: + return m.OldJSONContent(ctx) + case fribbleheroset.FieldHeroName: + return m.OldHeroName(ctx) + case fribbleheroset.FieldCreator: + return m.OldCreator(ctx) + case fribbleheroset.FieldCreateTime: + return m.OldCreateTime(ctx) + case fribbleheroset.FieldUpdater: + return m.OldUpdater(ctx) + case fribbleheroset.FieldUpdateTime: + return m.OldUpdateTime(ctx) + case fribbleheroset.FieldDeleted: + return m.OldDeleted(ctx) + case fribbleheroset.FieldSuccessGet: + return m.OldSuccessGet(ctx) + } + return nil, fmt.Errorf("unknown FribbleHeroSet field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *FribbleHeroSetMutation) SetField(name string, value ent.Value) error { + switch name { + case fribbleheroset.FieldHeroCode: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHeroCode(v) + return nil + case fribbleheroset.FieldJSONContent: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetJSONContent(v) + return nil + case fribbleheroset.FieldHeroName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHeroName(v) + return nil + case fribbleheroset.FieldCreator: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreator(v) + return nil + case fribbleheroset.FieldCreateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreateTime(v) + return nil + case fribbleheroset.FieldUpdater: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdater(v) + return nil + case fribbleheroset.FieldUpdateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdateTime(v) + return nil + case fribbleheroset.FieldDeleted: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeleted(v) + return nil + case fribbleheroset.FieldSuccessGet: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSuccessGet(v) + return nil + } + return fmt.Errorf("unknown FribbleHeroSet field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *FribbleHeroSetMutation) AddedFields() []string { + var fields []string + if m.addsuccess_get != nil { + fields = append(fields, fribbleheroset.FieldSuccessGet) + } + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *FribbleHeroSetMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case fribbleheroset.FieldSuccessGet: + return m.AddedSuccessGet() + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *FribbleHeroSetMutation) AddField(name string, value ent.Value) error { + switch name { + case fribbleheroset.FieldSuccessGet: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddSuccessGet(v) + return nil + } + return fmt.Errorf("unknown FribbleHeroSet numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *FribbleHeroSetMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(fribbleheroset.FieldCreateTime) { + fields = append(fields, fribbleheroset.FieldCreateTime) + } + if m.FieldCleared(fribbleheroset.FieldUpdateTime) { + fields = append(fields, fribbleheroset.FieldUpdateTime) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *FribbleHeroSetMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *FribbleHeroSetMutation) ClearField(name string) error { + switch name { + case fribbleheroset.FieldCreateTime: + m.ClearCreateTime() + return nil + case fribbleheroset.FieldUpdateTime: + m.ClearUpdateTime() + return nil + } + return fmt.Errorf("unknown FribbleHeroSet nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *FribbleHeroSetMutation) ResetField(name string) error { + switch name { + case fribbleheroset.FieldHeroCode: + m.ResetHeroCode() + return nil + case fribbleheroset.FieldJSONContent: + m.ResetJSONContent() + return nil + case fribbleheroset.FieldHeroName: + m.ResetHeroName() + return nil + case fribbleheroset.FieldCreator: + m.ResetCreator() + return nil + case fribbleheroset.FieldCreateTime: + m.ResetCreateTime() + return nil + case fribbleheroset.FieldUpdater: + m.ResetUpdater() + return nil + case fribbleheroset.FieldUpdateTime: + m.ResetUpdateTime() + return nil + case fribbleheroset.FieldDeleted: + m.ResetDeleted() + return nil + case fribbleheroset.FieldSuccessGet: + m.ResetSuccessGet() + return nil + } + return fmt.Errorf("unknown FribbleHeroSet field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *FribbleHeroSetMutation) AddedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *FribbleHeroSetMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *FribbleHeroSetMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *FribbleHeroSetMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *FribbleHeroSetMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *FribbleHeroSetMutation) EdgeCleared(name string) bool { + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *FribbleHeroSetMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown FribbleHeroSet unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *FribbleHeroSetMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown FribbleHeroSet edge %s", name) +} + +// GearSetInfoMutation represents an operation that mutates the GearSetInfo nodes in the graph. +type GearSetInfoMutation struct { + config + op Op + typ string + id *int64 + level *int + addlevel *int + gear_id *int64 + addgear_id *int64 + enhance *int + addenhance *int + gear_type *string + gear_set_type *string + main_stat_type *string + main_stat_value *int + addmain_stat_value *int + sub_stat_one_type *string + sub_stat_one_value *int + addsub_stat_one_value *int + sub_stat_two_type *string + sub_stat_two_value *int + addsub_stat_two_value *int + sub_stat_three_type *string + sub_stat_three_value *int + addsub_stat_three_value *int + sub_stat_four_type *string + sub_stat_four_value *int + addsub_stat_four_value *int + account_code *string + creator *string + create_time *time.Time + updater *string + update_time *time.Time + deleted *bool + tenant_id *int64 + addtenant_id *int64 + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*GearSetInfo, error) + predicates []predicate.GearSetInfo +} + +var _ ent.Mutation = (*GearSetInfoMutation)(nil) + +// gearsetinfoOption allows management of the mutation configuration using functional options. +type gearsetinfoOption func(*GearSetInfoMutation) + +// newGearSetInfoMutation creates new mutation for the GearSetInfo entity. +func newGearSetInfoMutation(c config, op Op, opts ...gearsetinfoOption) *GearSetInfoMutation { + m := &GearSetInfoMutation{ + config: c, + op: op, + typ: TypeGearSetInfo, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withGearSetInfoID sets the ID field of the mutation. +func withGearSetInfoID(id int64) gearsetinfoOption { + return func(m *GearSetInfoMutation) { + var ( + err error + once sync.Once + value *GearSetInfo + ) + m.oldValue = func(ctx context.Context) (*GearSetInfo, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().GearSetInfo.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withGearSetInfo sets the old GearSetInfo of the mutation. +func withGearSetInfo(node *GearSetInfo) gearsetinfoOption { + return func(m *GearSetInfoMutation) { + m.oldValue = func(context.Context) (*GearSetInfo, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m GearSetInfoMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m GearSetInfoMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of GearSetInfo entities. +func (m *GearSetInfoMutation) SetID(id int64) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *GearSetInfoMutation) ID() (id int64, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *GearSetInfoMutation) IDs(ctx context.Context) ([]int64, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int64{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().GearSetInfo.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetLevel sets the "level" field. +func (m *GearSetInfoMutation) SetLevel(i int) { + m.level = &i + m.addlevel = nil +} + +// Level returns the value of the "level" field in the mutation. +func (m *GearSetInfoMutation) Level() (r int, exists bool) { + v := m.level + if v == nil { + return + } + return *v, true +} + +// OldLevel returns the old "level" field's value of the GearSetInfo entity. +// If the GearSetInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *GearSetInfoMutation) OldLevel(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLevel is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLevel requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLevel: %w", err) + } + return oldValue.Level, nil +} + +// AddLevel adds i to the "level" field. +func (m *GearSetInfoMutation) AddLevel(i int) { + if m.addlevel != nil { + *m.addlevel += i + } else { + m.addlevel = &i + } +} + +// AddedLevel returns the value that was added to the "level" field in this mutation. +func (m *GearSetInfoMutation) AddedLevel() (r int, exists bool) { + v := m.addlevel + if v == nil { + return + } + return *v, true +} + +// ResetLevel resets all changes to the "level" field. +func (m *GearSetInfoMutation) ResetLevel() { + m.level = nil + m.addlevel = nil +} + +// SetGearID sets the "gear_id" field. +func (m *GearSetInfoMutation) SetGearID(i int64) { + m.gear_id = &i + m.addgear_id = nil +} + +// GearID returns the value of the "gear_id" field in the mutation. +func (m *GearSetInfoMutation) GearID() (r int64, exists bool) { + v := m.gear_id + if v == nil { + return + } + return *v, true +} + +// OldGearID returns the old "gear_id" field's value of the GearSetInfo entity. +// If the GearSetInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *GearSetInfoMutation) OldGearID(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldGearID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldGearID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldGearID: %w", err) + } + return oldValue.GearID, nil +} + +// AddGearID adds i to the "gear_id" field. +func (m *GearSetInfoMutation) AddGearID(i int64) { + if m.addgear_id != nil { + *m.addgear_id += i + } else { + m.addgear_id = &i + } +} + +// AddedGearID returns the value that was added to the "gear_id" field in this mutation. +func (m *GearSetInfoMutation) AddedGearID() (r int64, exists bool) { + v := m.addgear_id + if v == nil { + return + } + return *v, true +} + +// ResetGearID resets all changes to the "gear_id" field. +func (m *GearSetInfoMutation) ResetGearID() { + m.gear_id = nil + m.addgear_id = nil +} + +// SetEnhance sets the "enhance" field. +func (m *GearSetInfoMutation) SetEnhance(i int) { + m.enhance = &i + m.addenhance = nil +} + +// Enhance returns the value of the "enhance" field in the mutation. +func (m *GearSetInfoMutation) Enhance() (r int, exists bool) { + v := m.enhance + if v == nil { + return + } + return *v, true +} + +// OldEnhance returns the old "enhance" field's value of the GearSetInfo entity. +// If the GearSetInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *GearSetInfoMutation) OldEnhance(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldEnhance is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldEnhance requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldEnhance: %w", err) + } + return oldValue.Enhance, nil +} + +// AddEnhance adds i to the "enhance" field. +func (m *GearSetInfoMutation) AddEnhance(i int) { + if m.addenhance != nil { + *m.addenhance += i + } else { + m.addenhance = &i + } +} + +// AddedEnhance returns the value that was added to the "enhance" field in this mutation. +func (m *GearSetInfoMutation) AddedEnhance() (r int, exists bool) { + v := m.addenhance + if v == nil { + return + } + return *v, true +} + +// ResetEnhance resets all changes to the "enhance" field. +func (m *GearSetInfoMutation) ResetEnhance() { + m.enhance = nil + m.addenhance = nil +} + +// SetGearType sets the "gear_type" field. +func (m *GearSetInfoMutation) SetGearType(s string) { + m.gear_type = &s +} + +// GearType returns the value of the "gear_type" field in the mutation. +func (m *GearSetInfoMutation) GearType() (r string, exists bool) { + v := m.gear_type + if v == nil { + return + } + return *v, true +} + +// OldGearType returns the old "gear_type" field's value of the GearSetInfo entity. +// If the GearSetInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *GearSetInfoMutation) OldGearType(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldGearType is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldGearType requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldGearType: %w", err) + } + return oldValue.GearType, nil +} + +// ResetGearType resets all changes to the "gear_type" field. +func (m *GearSetInfoMutation) ResetGearType() { + m.gear_type = nil +} + +// SetGearSetType sets the "gear_set_type" field. +func (m *GearSetInfoMutation) SetGearSetType(s string) { + m.gear_set_type = &s +} + +// GearSetType returns the value of the "gear_set_type" field in the mutation. +func (m *GearSetInfoMutation) GearSetType() (r string, exists bool) { + v := m.gear_set_type + if v == nil { + return + } + return *v, true +} + +// OldGearSetType returns the old "gear_set_type" field's value of the GearSetInfo entity. +// If the GearSetInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *GearSetInfoMutation) OldGearSetType(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldGearSetType is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldGearSetType requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldGearSetType: %w", err) + } + return oldValue.GearSetType, nil +} + +// ResetGearSetType resets all changes to the "gear_set_type" field. +func (m *GearSetInfoMutation) ResetGearSetType() { + m.gear_set_type = nil +} + +// SetMainStatType sets the "main_stat_type" field. +func (m *GearSetInfoMutation) SetMainStatType(s string) { + m.main_stat_type = &s +} + +// MainStatType returns the value of the "main_stat_type" field in the mutation. +func (m *GearSetInfoMutation) MainStatType() (r string, exists bool) { + v := m.main_stat_type + if v == nil { + return + } + return *v, true +} + +// OldMainStatType returns the old "main_stat_type" field's value of the GearSetInfo entity. +// If the GearSetInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *GearSetInfoMutation) OldMainStatType(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldMainStatType is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldMainStatType requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldMainStatType: %w", err) + } + return oldValue.MainStatType, nil +} + +// ResetMainStatType resets all changes to the "main_stat_type" field. +func (m *GearSetInfoMutation) ResetMainStatType() { + m.main_stat_type = nil +} + +// SetMainStatValue sets the "main_stat_value" field. +func (m *GearSetInfoMutation) SetMainStatValue(i int) { + m.main_stat_value = &i + m.addmain_stat_value = nil +} + +// MainStatValue returns the value of the "main_stat_value" field in the mutation. +func (m *GearSetInfoMutation) MainStatValue() (r int, exists bool) { + v := m.main_stat_value + if v == nil { + return + } + return *v, true +} + +// OldMainStatValue returns the old "main_stat_value" field's value of the GearSetInfo entity. +// If the GearSetInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *GearSetInfoMutation) OldMainStatValue(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldMainStatValue is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldMainStatValue requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldMainStatValue: %w", err) + } + return oldValue.MainStatValue, nil +} + +// AddMainStatValue adds i to the "main_stat_value" field. +func (m *GearSetInfoMutation) AddMainStatValue(i int) { + if m.addmain_stat_value != nil { + *m.addmain_stat_value += i + } else { + m.addmain_stat_value = &i + } +} + +// AddedMainStatValue returns the value that was added to the "main_stat_value" field in this mutation. +func (m *GearSetInfoMutation) AddedMainStatValue() (r int, exists bool) { + v := m.addmain_stat_value + if v == nil { + return + } + return *v, true +} + +// ResetMainStatValue resets all changes to the "main_stat_value" field. +func (m *GearSetInfoMutation) ResetMainStatValue() { + m.main_stat_value = nil + m.addmain_stat_value = nil +} + +// SetSubStatOneType sets the "sub_stat_one_type" field. +func (m *GearSetInfoMutation) SetSubStatOneType(s string) { + m.sub_stat_one_type = &s +} + +// SubStatOneType returns the value of the "sub_stat_one_type" field in the mutation. +func (m *GearSetInfoMutation) SubStatOneType() (r string, exists bool) { + v := m.sub_stat_one_type + if v == nil { + return + } + return *v, true +} + +// OldSubStatOneType returns the old "sub_stat_one_type" field's value of the GearSetInfo entity. +// If the GearSetInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *GearSetInfoMutation) OldSubStatOneType(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSubStatOneType is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSubStatOneType requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSubStatOneType: %w", err) + } + return oldValue.SubStatOneType, nil +} + +// ResetSubStatOneType resets all changes to the "sub_stat_one_type" field. +func (m *GearSetInfoMutation) ResetSubStatOneType() { + m.sub_stat_one_type = nil +} + +// SetSubStatOneValue sets the "sub_stat_one_value" field. +func (m *GearSetInfoMutation) SetSubStatOneValue(i int) { + m.sub_stat_one_value = &i + m.addsub_stat_one_value = nil +} + +// SubStatOneValue returns the value of the "sub_stat_one_value" field in the mutation. +func (m *GearSetInfoMutation) SubStatOneValue() (r int, exists bool) { + v := m.sub_stat_one_value + if v == nil { + return + } + return *v, true +} + +// OldSubStatOneValue returns the old "sub_stat_one_value" field's value of the GearSetInfo entity. +// If the GearSetInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *GearSetInfoMutation) OldSubStatOneValue(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSubStatOneValue is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSubStatOneValue requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSubStatOneValue: %w", err) + } + return oldValue.SubStatOneValue, nil +} + +// AddSubStatOneValue adds i to the "sub_stat_one_value" field. +func (m *GearSetInfoMutation) AddSubStatOneValue(i int) { + if m.addsub_stat_one_value != nil { + *m.addsub_stat_one_value += i + } else { + m.addsub_stat_one_value = &i + } +} + +// AddedSubStatOneValue returns the value that was added to the "sub_stat_one_value" field in this mutation. +func (m *GearSetInfoMutation) AddedSubStatOneValue() (r int, exists bool) { + v := m.addsub_stat_one_value + if v == nil { + return + } + return *v, true +} + +// ResetSubStatOneValue resets all changes to the "sub_stat_one_value" field. +func (m *GearSetInfoMutation) ResetSubStatOneValue() { + m.sub_stat_one_value = nil + m.addsub_stat_one_value = nil +} + +// SetSubStatTwoType sets the "sub_stat_two_type" field. +func (m *GearSetInfoMutation) SetSubStatTwoType(s string) { + m.sub_stat_two_type = &s +} + +// SubStatTwoType returns the value of the "sub_stat_two_type" field in the mutation. +func (m *GearSetInfoMutation) SubStatTwoType() (r string, exists bool) { + v := m.sub_stat_two_type + if v == nil { + return + } + return *v, true +} + +// OldSubStatTwoType returns the old "sub_stat_two_type" field's value of the GearSetInfo entity. +// If the GearSetInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *GearSetInfoMutation) OldSubStatTwoType(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSubStatTwoType is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSubStatTwoType requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSubStatTwoType: %w", err) + } + return oldValue.SubStatTwoType, nil +} + +// ResetSubStatTwoType resets all changes to the "sub_stat_two_type" field. +func (m *GearSetInfoMutation) ResetSubStatTwoType() { + m.sub_stat_two_type = nil +} + +// SetSubStatTwoValue sets the "sub_stat_two_value" field. +func (m *GearSetInfoMutation) SetSubStatTwoValue(i int) { + m.sub_stat_two_value = &i + m.addsub_stat_two_value = nil +} + +// SubStatTwoValue returns the value of the "sub_stat_two_value" field in the mutation. +func (m *GearSetInfoMutation) SubStatTwoValue() (r int, exists bool) { + v := m.sub_stat_two_value + if v == nil { + return + } + return *v, true +} + +// OldSubStatTwoValue returns the old "sub_stat_two_value" field's value of the GearSetInfo entity. +// If the GearSetInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *GearSetInfoMutation) OldSubStatTwoValue(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSubStatTwoValue is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSubStatTwoValue requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSubStatTwoValue: %w", err) + } + return oldValue.SubStatTwoValue, nil +} + +// AddSubStatTwoValue adds i to the "sub_stat_two_value" field. +func (m *GearSetInfoMutation) AddSubStatTwoValue(i int) { + if m.addsub_stat_two_value != nil { + *m.addsub_stat_two_value += i + } else { + m.addsub_stat_two_value = &i + } +} + +// AddedSubStatTwoValue returns the value that was added to the "sub_stat_two_value" field in this mutation. +func (m *GearSetInfoMutation) AddedSubStatTwoValue() (r int, exists bool) { + v := m.addsub_stat_two_value + if v == nil { + return + } + return *v, true +} + +// ResetSubStatTwoValue resets all changes to the "sub_stat_two_value" field. +func (m *GearSetInfoMutation) ResetSubStatTwoValue() { + m.sub_stat_two_value = nil + m.addsub_stat_two_value = nil +} + +// SetSubStatThreeType sets the "sub_stat_three_type" field. +func (m *GearSetInfoMutation) SetSubStatThreeType(s string) { + m.sub_stat_three_type = &s +} + +// SubStatThreeType returns the value of the "sub_stat_three_type" field in the mutation. +func (m *GearSetInfoMutation) SubStatThreeType() (r string, exists bool) { + v := m.sub_stat_three_type + if v == nil { + return + } + return *v, true +} + +// OldSubStatThreeType returns the old "sub_stat_three_type" field's value of the GearSetInfo entity. +// If the GearSetInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *GearSetInfoMutation) OldSubStatThreeType(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSubStatThreeType is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSubStatThreeType requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSubStatThreeType: %w", err) + } + return oldValue.SubStatThreeType, nil +} + +// ResetSubStatThreeType resets all changes to the "sub_stat_three_type" field. +func (m *GearSetInfoMutation) ResetSubStatThreeType() { + m.sub_stat_three_type = nil +} + +// SetSubStatThreeValue sets the "sub_stat_three_value" field. +func (m *GearSetInfoMutation) SetSubStatThreeValue(i int) { + m.sub_stat_three_value = &i + m.addsub_stat_three_value = nil +} + +// SubStatThreeValue returns the value of the "sub_stat_three_value" field in the mutation. +func (m *GearSetInfoMutation) SubStatThreeValue() (r int, exists bool) { + v := m.sub_stat_three_value + if v == nil { + return + } + return *v, true +} + +// OldSubStatThreeValue returns the old "sub_stat_three_value" field's value of the GearSetInfo entity. +// If the GearSetInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *GearSetInfoMutation) OldSubStatThreeValue(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSubStatThreeValue is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSubStatThreeValue requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSubStatThreeValue: %w", err) + } + return oldValue.SubStatThreeValue, nil +} + +// AddSubStatThreeValue adds i to the "sub_stat_three_value" field. +func (m *GearSetInfoMutation) AddSubStatThreeValue(i int) { + if m.addsub_stat_three_value != nil { + *m.addsub_stat_three_value += i + } else { + m.addsub_stat_three_value = &i + } +} + +// AddedSubStatThreeValue returns the value that was added to the "sub_stat_three_value" field in this mutation. +func (m *GearSetInfoMutation) AddedSubStatThreeValue() (r int, exists bool) { + v := m.addsub_stat_three_value + if v == nil { + return + } + return *v, true +} + +// ResetSubStatThreeValue resets all changes to the "sub_stat_three_value" field. +func (m *GearSetInfoMutation) ResetSubStatThreeValue() { + m.sub_stat_three_value = nil + m.addsub_stat_three_value = nil +} + +// SetSubStatFourType sets the "sub_stat_four_type" field. +func (m *GearSetInfoMutation) SetSubStatFourType(s string) { + m.sub_stat_four_type = &s +} + +// SubStatFourType returns the value of the "sub_stat_four_type" field in the mutation. +func (m *GearSetInfoMutation) SubStatFourType() (r string, exists bool) { + v := m.sub_stat_four_type + if v == nil { + return + } + return *v, true +} + +// OldSubStatFourType returns the old "sub_stat_four_type" field's value of the GearSetInfo entity. +// If the GearSetInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *GearSetInfoMutation) OldSubStatFourType(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSubStatFourType is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSubStatFourType requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSubStatFourType: %w", err) + } + return oldValue.SubStatFourType, nil +} + +// ResetSubStatFourType resets all changes to the "sub_stat_four_type" field. +func (m *GearSetInfoMutation) ResetSubStatFourType() { + m.sub_stat_four_type = nil +} + +// SetSubStatFourValue sets the "sub_stat_four_value" field. +func (m *GearSetInfoMutation) SetSubStatFourValue(i int) { + m.sub_stat_four_value = &i + m.addsub_stat_four_value = nil +} + +// SubStatFourValue returns the value of the "sub_stat_four_value" field in the mutation. +func (m *GearSetInfoMutation) SubStatFourValue() (r int, exists bool) { + v := m.sub_stat_four_value + if v == nil { + return + } + return *v, true +} + +// OldSubStatFourValue returns the old "sub_stat_four_value" field's value of the GearSetInfo entity. +// If the GearSetInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *GearSetInfoMutation) OldSubStatFourValue(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSubStatFourValue is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSubStatFourValue requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSubStatFourValue: %w", err) + } + return oldValue.SubStatFourValue, nil +} + +// AddSubStatFourValue adds i to the "sub_stat_four_value" field. +func (m *GearSetInfoMutation) AddSubStatFourValue(i int) { + if m.addsub_stat_four_value != nil { + *m.addsub_stat_four_value += i + } else { + m.addsub_stat_four_value = &i + } +} + +// AddedSubStatFourValue returns the value that was added to the "sub_stat_four_value" field in this mutation. +func (m *GearSetInfoMutation) AddedSubStatFourValue() (r int, exists bool) { + v := m.addsub_stat_four_value + if v == nil { + return + } + return *v, true +} + +// ResetSubStatFourValue resets all changes to the "sub_stat_four_value" field. +func (m *GearSetInfoMutation) ResetSubStatFourValue() { + m.sub_stat_four_value = nil + m.addsub_stat_four_value = nil +} + +// SetAccountCode sets the "account_code" field. +func (m *GearSetInfoMutation) SetAccountCode(s string) { + m.account_code = &s +} + +// AccountCode returns the value of the "account_code" field in the mutation. +func (m *GearSetInfoMutation) AccountCode() (r string, exists bool) { + v := m.account_code + if v == nil { + return + } + return *v, true +} + +// OldAccountCode returns the old "account_code" field's value of the GearSetInfo entity. +// If the GearSetInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *GearSetInfoMutation) OldAccountCode(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAccountCode is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAccountCode requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAccountCode: %w", err) + } + return oldValue.AccountCode, nil +} + +// ResetAccountCode resets all changes to the "account_code" field. +func (m *GearSetInfoMutation) ResetAccountCode() { + m.account_code = nil +} + +// SetCreator sets the "creator" field. +func (m *GearSetInfoMutation) SetCreator(s string) { + m.creator = &s +} + +// Creator returns the value of the "creator" field in the mutation. +func (m *GearSetInfoMutation) Creator() (r string, exists bool) { + v := m.creator + if v == nil { + return + } + return *v, true +} + +// OldCreator returns the old "creator" field's value of the GearSetInfo entity. +// If the GearSetInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *GearSetInfoMutation) OldCreator(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreator is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreator requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreator: %w", err) + } + return oldValue.Creator, nil +} + +// ResetCreator resets all changes to the "creator" field. +func (m *GearSetInfoMutation) ResetCreator() { + m.creator = nil +} + +// SetCreateTime sets the "create_time" field. +func (m *GearSetInfoMutation) SetCreateTime(t time.Time) { + m.create_time = &t +} + +// CreateTime returns the value of the "create_time" field in the mutation. +func (m *GearSetInfoMutation) CreateTime() (r time.Time, exists bool) { + v := m.create_time + if v == nil { + return + } + return *v, true +} + +// OldCreateTime returns the old "create_time" field's value of the GearSetInfo entity. +// If the GearSetInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *GearSetInfoMutation) OldCreateTime(ctx context.Context) (v *time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) + } + return oldValue.CreateTime, nil +} + +// ClearCreateTime clears the value of the "create_time" field. +func (m *GearSetInfoMutation) ClearCreateTime() { + m.create_time = nil + m.clearedFields[gearsetinfo.FieldCreateTime] = struct{}{} +} + +// CreateTimeCleared returns if the "create_time" field was cleared in this mutation. +func (m *GearSetInfoMutation) CreateTimeCleared() bool { + _, ok := m.clearedFields[gearsetinfo.FieldCreateTime] + return ok +} + +// ResetCreateTime resets all changes to the "create_time" field. +func (m *GearSetInfoMutation) ResetCreateTime() { + m.create_time = nil + delete(m.clearedFields, gearsetinfo.FieldCreateTime) +} + +// SetUpdater sets the "updater" field. +func (m *GearSetInfoMutation) SetUpdater(s string) { + m.updater = &s +} + +// Updater returns the value of the "updater" field in the mutation. +func (m *GearSetInfoMutation) Updater() (r string, exists bool) { + v := m.updater + if v == nil { + return + } + return *v, true +} + +// OldUpdater returns the old "updater" field's value of the GearSetInfo entity. +// If the GearSetInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *GearSetInfoMutation) OldUpdater(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdater is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdater requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdater: %w", err) + } + return oldValue.Updater, nil +} + +// ResetUpdater resets all changes to the "updater" field. +func (m *GearSetInfoMutation) ResetUpdater() { + m.updater = nil +} + +// SetUpdateTime sets the "update_time" field. +func (m *GearSetInfoMutation) SetUpdateTime(t time.Time) { + m.update_time = &t +} + +// UpdateTime returns the value of the "update_time" field in the mutation. +func (m *GearSetInfoMutation) UpdateTime() (r time.Time, exists bool) { + v := m.update_time + if v == nil { + return + } + return *v, true +} + +// OldUpdateTime returns the old "update_time" field's value of the GearSetInfo entity. +// If the GearSetInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *GearSetInfoMutation) OldUpdateTime(ctx context.Context) (v *time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err) + } + return oldValue.UpdateTime, nil +} + +// ClearUpdateTime clears the value of the "update_time" field. +func (m *GearSetInfoMutation) ClearUpdateTime() { + m.update_time = nil + m.clearedFields[gearsetinfo.FieldUpdateTime] = struct{}{} +} + +// UpdateTimeCleared returns if the "update_time" field was cleared in this mutation. +func (m *GearSetInfoMutation) UpdateTimeCleared() bool { + _, ok := m.clearedFields[gearsetinfo.FieldUpdateTime] + return ok +} + +// ResetUpdateTime resets all changes to the "update_time" field. +func (m *GearSetInfoMutation) ResetUpdateTime() { + m.update_time = nil + delete(m.clearedFields, gearsetinfo.FieldUpdateTime) +} + +// SetDeleted sets the "deleted" field. +func (m *GearSetInfoMutation) SetDeleted(b bool) { + m.deleted = &b +} + +// Deleted returns the value of the "deleted" field in the mutation. +func (m *GearSetInfoMutation) Deleted() (r bool, exists bool) { + v := m.deleted + if v == nil { + return + } + return *v, true +} + +// OldDeleted returns the old "deleted" field's value of the GearSetInfo entity. +// If the GearSetInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *GearSetInfoMutation) OldDeleted(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeleted is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeleted requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeleted: %w", err) + } + return oldValue.Deleted, nil +} + +// ResetDeleted resets all changes to the "deleted" field. +func (m *GearSetInfoMutation) ResetDeleted() { + m.deleted = nil +} + +// SetTenantID sets the "tenant_id" field. +func (m *GearSetInfoMutation) SetTenantID(i int64) { + m.tenant_id = &i + m.addtenant_id = nil +} + +// TenantID returns the value of the "tenant_id" field in the mutation. +func (m *GearSetInfoMutation) TenantID() (r int64, exists bool) { + v := m.tenant_id + if v == nil { + return + } + return *v, true +} + +// OldTenantID returns the old "tenant_id" field's value of the GearSetInfo entity. +// If the GearSetInfo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *GearSetInfoMutation) OldTenantID(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTenantID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTenantID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTenantID: %w", err) + } + return oldValue.TenantID, nil +} + +// AddTenantID adds i to the "tenant_id" field. +func (m *GearSetInfoMutation) AddTenantID(i int64) { + if m.addtenant_id != nil { + *m.addtenant_id += i + } else { + m.addtenant_id = &i + } +} + +// AddedTenantID returns the value that was added to the "tenant_id" field in this mutation. +func (m *GearSetInfoMutation) AddedTenantID() (r int64, exists bool) { + v := m.addtenant_id + if v == nil { + return + } + return *v, true +} + +// ResetTenantID resets all changes to the "tenant_id" field. +func (m *GearSetInfoMutation) ResetTenantID() { + m.tenant_id = nil + m.addtenant_id = nil +} + +// Where appends a list predicates to the GearSetInfoMutation builder. +func (m *GearSetInfoMutation) Where(ps ...predicate.GearSetInfo) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the GearSetInfoMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *GearSetInfoMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.GearSetInfo, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *GearSetInfoMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *GearSetInfoMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (GearSetInfo). +func (m *GearSetInfoMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *GearSetInfoMutation) Fields() []string { + fields := make([]string, 0, 22) + if m.level != nil { + fields = append(fields, gearsetinfo.FieldLevel) + } + if m.gear_id != nil { + fields = append(fields, gearsetinfo.FieldGearID) + } + if m.enhance != nil { + fields = append(fields, gearsetinfo.FieldEnhance) + } + if m.gear_type != nil { + fields = append(fields, gearsetinfo.FieldGearType) + } + if m.gear_set_type != nil { + fields = append(fields, gearsetinfo.FieldGearSetType) + } + if m.main_stat_type != nil { + fields = append(fields, gearsetinfo.FieldMainStatType) + } + if m.main_stat_value != nil { + fields = append(fields, gearsetinfo.FieldMainStatValue) + } + if m.sub_stat_one_type != nil { + fields = append(fields, gearsetinfo.FieldSubStatOneType) + } + if m.sub_stat_one_value != nil { + fields = append(fields, gearsetinfo.FieldSubStatOneValue) + } + if m.sub_stat_two_type != nil { + fields = append(fields, gearsetinfo.FieldSubStatTwoType) + } + if m.sub_stat_two_value != nil { + fields = append(fields, gearsetinfo.FieldSubStatTwoValue) + } + if m.sub_stat_three_type != nil { + fields = append(fields, gearsetinfo.FieldSubStatThreeType) + } + if m.sub_stat_three_value != nil { + fields = append(fields, gearsetinfo.FieldSubStatThreeValue) + } + if m.sub_stat_four_type != nil { + fields = append(fields, gearsetinfo.FieldSubStatFourType) + } + if m.sub_stat_four_value != nil { + fields = append(fields, gearsetinfo.FieldSubStatFourValue) + } + if m.account_code != nil { + fields = append(fields, gearsetinfo.FieldAccountCode) + } + if m.creator != nil { + fields = append(fields, gearsetinfo.FieldCreator) + } + if m.create_time != nil { + fields = append(fields, gearsetinfo.FieldCreateTime) + } + if m.updater != nil { + fields = append(fields, gearsetinfo.FieldUpdater) + } + if m.update_time != nil { + fields = append(fields, gearsetinfo.FieldUpdateTime) + } + if m.deleted != nil { + fields = append(fields, gearsetinfo.FieldDeleted) + } + if m.tenant_id != nil { + fields = append(fields, gearsetinfo.FieldTenantID) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *GearSetInfoMutation) Field(name string) (ent.Value, bool) { + switch name { + case gearsetinfo.FieldLevel: + return m.Level() + case gearsetinfo.FieldGearID: + return m.GearID() + case gearsetinfo.FieldEnhance: + return m.Enhance() + case gearsetinfo.FieldGearType: + return m.GearType() + case gearsetinfo.FieldGearSetType: + return m.GearSetType() + case gearsetinfo.FieldMainStatType: + return m.MainStatType() + case gearsetinfo.FieldMainStatValue: + return m.MainStatValue() + case gearsetinfo.FieldSubStatOneType: + return m.SubStatOneType() + case gearsetinfo.FieldSubStatOneValue: + return m.SubStatOneValue() + case gearsetinfo.FieldSubStatTwoType: + return m.SubStatTwoType() + case gearsetinfo.FieldSubStatTwoValue: + return m.SubStatTwoValue() + case gearsetinfo.FieldSubStatThreeType: + return m.SubStatThreeType() + case gearsetinfo.FieldSubStatThreeValue: + return m.SubStatThreeValue() + case gearsetinfo.FieldSubStatFourType: + return m.SubStatFourType() + case gearsetinfo.FieldSubStatFourValue: + return m.SubStatFourValue() + case gearsetinfo.FieldAccountCode: + return m.AccountCode() + case gearsetinfo.FieldCreator: + return m.Creator() + case gearsetinfo.FieldCreateTime: + return m.CreateTime() + case gearsetinfo.FieldUpdater: + return m.Updater() + case gearsetinfo.FieldUpdateTime: + return m.UpdateTime() + case gearsetinfo.FieldDeleted: + return m.Deleted() + case gearsetinfo.FieldTenantID: + return m.TenantID() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *GearSetInfoMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case gearsetinfo.FieldLevel: + return m.OldLevel(ctx) + case gearsetinfo.FieldGearID: + return m.OldGearID(ctx) + case gearsetinfo.FieldEnhance: + return m.OldEnhance(ctx) + case gearsetinfo.FieldGearType: + return m.OldGearType(ctx) + case gearsetinfo.FieldGearSetType: + return m.OldGearSetType(ctx) + case gearsetinfo.FieldMainStatType: + return m.OldMainStatType(ctx) + case gearsetinfo.FieldMainStatValue: + return m.OldMainStatValue(ctx) + case gearsetinfo.FieldSubStatOneType: + return m.OldSubStatOneType(ctx) + case gearsetinfo.FieldSubStatOneValue: + return m.OldSubStatOneValue(ctx) + case gearsetinfo.FieldSubStatTwoType: + return m.OldSubStatTwoType(ctx) + case gearsetinfo.FieldSubStatTwoValue: + return m.OldSubStatTwoValue(ctx) + case gearsetinfo.FieldSubStatThreeType: + return m.OldSubStatThreeType(ctx) + case gearsetinfo.FieldSubStatThreeValue: + return m.OldSubStatThreeValue(ctx) + case gearsetinfo.FieldSubStatFourType: + return m.OldSubStatFourType(ctx) + case gearsetinfo.FieldSubStatFourValue: + return m.OldSubStatFourValue(ctx) + case gearsetinfo.FieldAccountCode: + return m.OldAccountCode(ctx) + case gearsetinfo.FieldCreator: + return m.OldCreator(ctx) + case gearsetinfo.FieldCreateTime: + return m.OldCreateTime(ctx) + case gearsetinfo.FieldUpdater: + return m.OldUpdater(ctx) + case gearsetinfo.FieldUpdateTime: + return m.OldUpdateTime(ctx) + case gearsetinfo.FieldDeleted: + return m.OldDeleted(ctx) + case gearsetinfo.FieldTenantID: + return m.OldTenantID(ctx) + } + return nil, fmt.Errorf("unknown GearSetInfo field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *GearSetInfoMutation) SetField(name string, value ent.Value) error { + switch name { + case gearsetinfo.FieldLevel: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLevel(v) + return nil + case gearsetinfo.FieldGearID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetGearID(v) + return nil + case gearsetinfo.FieldEnhance: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetEnhance(v) + return nil + case gearsetinfo.FieldGearType: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetGearType(v) + return nil + case gearsetinfo.FieldGearSetType: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetGearSetType(v) + return nil + case gearsetinfo.FieldMainStatType: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMainStatType(v) + return nil + case gearsetinfo.FieldMainStatValue: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMainStatValue(v) + return nil + case gearsetinfo.FieldSubStatOneType: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSubStatOneType(v) + return nil + case gearsetinfo.FieldSubStatOneValue: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSubStatOneValue(v) + return nil + case gearsetinfo.FieldSubStatTwoType: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSubStatTwoType(v) + return nil + case gearsetinfo.FieldSubStatTwoValue: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSubStatTwoValue(v) + return nil + case gearsetinfo.FieldSubStatThreeType: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSubStatThreeType(v) + return nil + case gearsetinfo.FieldSubStatThreeValue: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSubStatThreeValue(v) + return nil + case gearsetinfo.FieldSubStatFourType: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSubStatFourType(v) + return nil + case gearsetinfo.FieldSubStatFourValue: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSubStatFourValue(v) + return nil + case gearsetinfo.FieldAccountCode: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAccountCode(v) + return nil + case gearsetinfo.FieldCreator: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreator(v) + return nil + case gearsetinfo.FieldCreateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreateTime(v) + return nil + case gearsetinfo.FieldUpdater: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdater(v) + return nil + case gearsetinfo.FieldUpdateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdateTime(v) + return nil + case gearsetinfo.FieldDeleted: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeleted(v) + return nil + case gearsetinfo.FieldTenantID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTenantID(v) + return nil + } + return fmt.Errorf("unknown GearSetInfo field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *GearSetInfoMutation) AddedFields() []string { + var fields []string + if m.addlevel != nil { + fields = append(fields, gearsetinfo.FieldLevel) + } + if m.addgear_id != nil { + fields = append(fields, gearsetinfo.FieldGearID) + } + if m.addenhance != nil { + fields = append(fields, gearsetinfo.FieldEnhance) + } + if m.addmain_stat_value != nil { + fields = append(fields, gearsetinfo.FieldMainStatValue) + } + if m.addsub_stat_one_value != nil { + fields = append(fields, gearsetinfo.FieldSubStatOneValue) + } + if m.addsub_stat_two_value != nil { + fields = append(fields, gearsetinfo.FieldSubStatTwoValue) + } + if m.addsub_stat_three_value != nil { + fields = append(fields, gearsetinfo.FieldSubStatThreeValue) + } + if m.addsub_stat_four_value != nil { + fields = append(fields, gearsetinfo.FieldSubStatFourValue) + } + if m.addtenant_id != nil { + fields = append(fields, gearsetinfo.FieldTenantID) + } + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *GearSetInfoMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case gearsetinfo.FieldLevel: + return m.AddedLevel() + case gearsetinfo.FieldGearID: + return m.AddedGearID() + case gearsetinfo.FieldEnhance: + return m.AddedEnhance() + case gearsetinfo.FieldMainStatValue: + return m.AddedMainStatValue() + case gearsetinfo.FieldSubStatOneValue: + return m.AddedSubStatOneValue() + case gearsetinfo.FieldSubStatTwoValue: + return m.AddedSubStatTwoValue() + case gearsetinfo.FieldSubStatThreeValue: + return m.AddedSubStatThreeValue() + case gearsetinfo.FieldSubStatFourValue: + return m.AddedSubStatFourValue() + case gearsetinfo.FieldTenantID: + return m.AddedTenantID() + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *GearSetInfoMutation) AddField(name string, value ent.Value) error { + switch name { + case gearsetinfo.FieldLevel: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddLevel(v) + return nil + case gearsetinfo.FieldGearID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddGearID(v) + return nil + case gearsetinfo.FieldEnhance: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddEnhance(v) + return nil + case gearsetinfo.FieldMainStatValue: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddMainStatValue(v) + return nil + case gearsetinfo.FieldSubStatOneValue: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddSubStatOneValue(v) + return nil + case gearsetinfo.FieldSubStatTwoValue: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddSubStatTwoValue(v) + return nil + case gearsetinfo.FieldSubStatThreeValue: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddSubStatThreeValue(v) + return nil + case gearsetinfo.FieldSubStatFourValue: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddSubStatFourValue(v) + return nil + case gearsetinfo.FieldTenantID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddTenantID(v) + return nil + } + return fmt.Errorf("unknown GearSetInfo numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *GearSetInfoMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(gearsetinfo.FieldCreateTime) { + fields = append(fields, gearsetinfo.FieldCreateTime) + } + if m.FieldCleared(gearsetinfo.FieldUpdateTime) { + fields = append(fields, gearsetinfo.FieldUpdateTime) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *GearSetInfoMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *GearSetInfoMutation) ClearField(name string) error { + switch name { + case gearsetinfo.FieldCreateTime: + m.ClearCreateTime() + return nil + case gearsetinfo.FieldUpdateTime: + m.ClearUpdateTime() + return nil + } + return fmt.Errorf("unknown GearSetInfo nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *GearSetInfoMutation) ResetField(name string) error { + switch name { + case gearsetinfo.FieldLevel: + m.ResetLevel() + return nil + case gearsetinfo.FieldGearID: + m.ResetGearID() + return nil + case gearsetinfo.FieldEnhance: + m.ResetEnhance() + return nil + case gearsetinfo.FieldGearType: + m.ResetGearType() + return nil + case gearsetinfo.FieldGearSetType: + m.ResetGearSetType() + return nil + case gearsetinfo.FieldMainStatType: + m.ResetMainStatType() + return nil + case gearsetinfo.FieldMainStatValue: + m.ResetMainStatValue() + return nil + case gearsetinfo.FieldSubStatOneType: + m.ResetSubStatOneType() + return nil + case gearsetinfo.FieldSubStatOneValue: + m.ResetSubStatOneValue() + return nil + case gearsetinfo.FieldSubStatTwoType: + m.ResetSubStatTwoType() + return nil + case gearsetinfo.FieldSubStatTwoValue: + m.ResetSubStatTwoValue() + return nil + case gearsetinfo.FieldSubStatThreeType: + m.ResetSubStatThreeType() + return nil + case gearsetinfo.FieldSubStatThreeValue: + m.ResetSubStatThreeValue() + return nil + case gearsetinfo.FieldSubStatFourType: + m.ResetSubStatFourType() + return nil + case gearsetinfo.FieldSubStatFourValue: + m.ResetSubStatFourValue() + return nil + case gearsetinfo.FieldAccountCode: + m.ResetAccountCode() + return nil + case gearsetinfo.FieldCreator: + m.ResetCreator() + return nil + case gearsetinfo.FieldCreateTime: + m.ResetCreateTime() + return nil + case gearsetinfo.FieldUpdater: + m.ResetUpdater() + return nil + case gearsetinfo.FieldUpdateTime: + m.ResetUpdateTime() + return nil + case gearsetinfo.FieldDeleted: + m.ResetDeleted() + return nil + case gearsetinfo.FieldTenantID: + m.ResetTenantID() + return nil + } + return fmt.Errorf("unknown GearSetInfo field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *GearSetInfoMutation) AddedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *GearSetInfoMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *GearSetInfoMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *GearSetInfoMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *GearSetInfoMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *GearSetInfoMutation) EdgeCleared(name string) bool { + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *GearSetInfoMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown GearSetInfo unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *GearSetInfoMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown GearSetInfo edge %s", name) +} diff --git a/internal/ent/predicate/predicate.go b/internal/ent/predicate/predicate.go new file mode 100644 index 0000000..8cb60c2 --- /dev/null +++ b/internal/ent/predicate/predicate.go @@ -0,0 +1,34 @@ +// Code generated by ent, DO NOT EDIT. + +package predicate + +import ( + "entgo.io/ent/dialect/sql" +) + +// EpicArtifactInfo is the predicate function for epicartifactinfo builders. +type EpicArtifactInfo func(*sql.Selector) + +// EpicGvgAttackTeams is the predicate function for epicgvgattackteams builders. +type EpicGvgAttackTeams func(*sql.Selector) + +// EpicGvgDefenseAttackMapping is the predicate function for epicgvgdefenseattackmapping builders. +type EpicGvgDefenseAttackMapping func(*sql.Selector) + +// EpicGvgDefenseTeams is the predicate function for epicgvgdefenseteams builders. +type EpicGvgDefenseTeams func(*sql.Selector) + +// EpicHeroInfo is the predicate function for epicheroinfo builders. +type EpicHeroInfo func(*sql.Selector) + +// EpicHeroUserBuild is the predicate function for epicherouserbuild builders. +type EpicHeroUserBuild func(*sql.Selector) + +// EpicI18NMappings is the predicate function for epici18nmappings builders. +type EpicI18NMappings func(*sql.Selector) + +// FribbleHeroSet is the predicate function for fribbleheroset builders. +type FribbleHeroSet func(*sql.Selector) + +// GearSetInfo is the predicate function for gearsetinfo builders. +type GearSetInfo func(*sql.Selector) diff --git a/internal/ent/runtime.go b/internal/ent/runtime.go new file mode 100644 index 0000000..9e53fc7 --- /dev/null +++ b/internal/ent/runtime.go @@ -0,0 +1,284 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "epic-ent/internal/domain/entity" + "epic-ent/internal/ent/epicartifactinfo" + "epic-ent/internal/ent/epicgvgattackteams" + "epic-ent/internal/ent/epicgvgdefenseattackmapping" + "epic-ent/internal/ent/epicgvgdefenseteams" + "epic-ent/internal/ent/epicheroinfo" + "epic-ent/internal/ent/epicherouserbuild" + "epic-ent/internal/ent/epici18nmappings" + "epic-ent/internal/ent/fribbleheroset" + "epic-ent/internal/ent/gearsetinfo" +) + +// The init function reads all schema descriptors with runtime code +// (default values, validators, hooks and policies) and stitches it +// to their package variables. +func init() { + epicartifactinfoFields := entity.EpicArtifactInfo{}.Fields() + _ = epicartifactinfoFields + // epicartifactinfoDescArtifactName is the schema descriptor for artifact_name field. + epicartifactinfoDescArtifactName := epicartifactinfoFields[1].Descriptor() + // epicartifactinfo.ArtifactNameValidator is a validator for the "artifact_name" field. It is called by the builders before save. + epicartifactinfo.ArtifactNameValidator = epicartifactinfoDescArtifactName.Validators[0].(func(string) error) + // epicartifactinfoDescArtifactCode is the schema descriptor for artifact_code field. + epicartifactinfoDescArtifactCode := epicartifactinfoFields[2].Descriptor() + // epicartifactinfo.ArtifactCodeValidator is a validator for the "artifact_code" field. It is called by the builders before save. + epicartifactinfo.ArtifactCodeValidator = epicartifactinfoDescArtifactCode.Validators[0].(func(string) error) + // epicartifactinfoDescCreator is the schema descriptor for creator field. + epicartifactinfoDescCreator := epicartifactinfoFields[3].Descriptor() + // epicartifactinfo.CreatorValidator is a validator for the "creator" field. It is called by the builders before save. + epicartifactinfo.CreatorValidator = epicartifactinfoDescCreator.Validators[0].(func(string) error) + // epicartifactinfoDescUpdater is the schema descriptor for updater field. + epicartifactinfoDescUpdater := epicartifactinfoFields[5].Descriptor() + // epicartifactinfo.UpdaterValidator is a validator for the "updater" field. It is called by the builders before save. + epicartifactinfo.UpdaterValidator = epicartifactinfoDescUpdater.Validators[0].(func(string) error) + // epicartifactinfoDescRarity is the schema descriptor for rarity field. + epicartifactinfoDescRarity := epicartifactinfoFields[11].Descriptor() + // epicartifactinfo.RarityValidator is a validator for the "rarity" field. It is called by the builders before save. + epicartifactinfo.RarityValidator = epicartifactinfoDescRarity.Validators[0].(func(string) error) + // epicartifactinfoDescRole is the schema descriptor for role field. + epicartifactinfoDescRole := epicartifactinfoFields[12].Descriptor() + // epicartifactinfo.RoleValidator is a validator for the "role" field. It is called by the builders before save. + epicartifactinfo.RoleValidator = epicartifactinfoDescRole.Validators[0].(func(string) error) + // epicartifactinfoDescArtifactNameEn is the schema descriptor for artifact_name_en field. + epicartifactinfoDescArtifactNameEn := epicartifactinfoFields[13].Descriptor() + // epicartifactinfo.ArtifactNameEnValidator is a validator for the "artifact_name_en" field. It is called by the builders before save. + epicartifactinfo.ArtifactNameEnValidator = epicartifactinfoDescArtifactNameEn.Validators[0].(func(string) error) + // epicartifactinfoDescImageURL is the schema descriptor for image_url field. + epicartifactinfoDescImageURL := epicartifactinfoFields[14].Descriptor() + // epicartifactinfo.ImageURLValidator is a validator for the "image_url" field. It is called by the builders before save. + epicartifactinfo.ImageURLValidator = epicartifactinfoDescImageURL.Validators[0].(func(string) error) + epicgvgattackteamsFields := entity.EpicGvgAttackTeams{}.Fields() + _ = epicgvgattackteamsFields + // epicgvgattackteamsDescAttackHeroes is the schema descriptor for attack_heroes field. + epicgvgattackteamsDescAttackHeroes := epicgvgattackteamsFields[1].Descriptor() + // epicgvgattackteams.AttackHeroesValidator is a validator for the "attack_heroes" field. It is called by the builders before save. + epicgvgattackteams.AttackHeroesValidator = epicgvgattackteamsDescAttackHeroes.Validators[0].(func(string) error) + // epicgvgattackteamsDescCreator is the schema descriptor for creator field. + epicgvgattackteamsDescCreator := epicgvgattackteamsFields[2].Descriptor() + // epicgvgattackteams.CreatorValidator is a validator for the "creator" field. It is called by the builders before save. + epicgvgattackteams.CreatorValidator = epicgvgattackteamsDescCreator.Validators[0].(func(string) error) + // epicgvgattackteamsDescUpdater is the schema descriptor for updater field. + epicgvgattackteamsDescUpdater := epicgvgattackteamsFields[4].Descriptor() + // epicgvgattackteams.UpdaterValidator is a validator for the "updater" field. It is called by the builders before save. + epicgvgattackteams.UpdaterValidator = epicgvgattackteamsDescUpdater.Validators[0].(func(string) error) + epicgvgdefenseattackmappingFields := entity.EpicGvgDefenseAttackMapping{}.Fields() + _ = epicgvgdefenseattackmappingFields + // epicgvgdefenseattackmappingDescEquipmentInfo is the schema descriptor for equipment_info field. + epicgvgdefenseattackmappingDescEquipmentInfo := epicgvgdefenseattackmappingFields[3].Descriptor() + // epicgvgdefenseattackmapping.EquipmentInfoValidator is a validator for the "equipment_info" field. It is called by the builders before save. + epicgvgdefenseattackmapping.EquipmentInfoValidator = epicgvgdefenseattackmappingDescEquipmentInfo.Validators[0].(func(string) error) + // epicgvgdefenseattackmappingDescArtifacts is the schema descriptor for artifacts field. + epicgvgdefenseattackmappingDescArtifacts := epicgvgdefenseattackmappingFields[4].Descriptor() + // epicgvgdefenseattackmapping.ArtifactsValidator is a validator for the "artifacts" field. It is called by the builders before save. + epicgvgdefenseattackmapping.ArtifactsValidator = epicgvgdefenseattackmappingDescArtifacts.Validators[0].(func(string) error) + // epicgvgdefenseattackmappingDescBattleStrategy is the schema descriptor for battle_strategy field. + epicgvgdefenseattackmappingDescBattleStrategy := epicgvgdefenseattackmappingFields[5].Descriptor() + // epicgvgdefenseattackmapping.BattleStrategyValidator is a validator for the "battle_strategy" field. It is called by the builders before save. + epicgvgdefenseattackmapping.BattleStrategyValidator = epicgvgdefenseattackmappingDescBattleStrategy.Validators[0].(func(string) error) + // epicgvgdefenseattackmappingDescPrerequisites is the schema descriptor for prerequisites field. + epicgvgdefenseattackmappingDescPrerequisites := epicgvgdefenseattackmappingFields[6].Descriptor() + // epicgvgdefenseattackmapping.PrerequisitesValidator is a validator for the "prerequisites" field. It is called by the builders before save. + epicgvgdefenseattackmapping.PrerequisitesValidator = epicgvgdefenseattackmappingDescPrerequisites.Validators[0].(func(string) error) + // epicgvgdefenseattackmappingDescImportantNotes is the schema descriptor for important_notes field. + epicgvgdefenseattackmappingDescImportantNotes := epicgvgdefenseattackmappingFields[7].Descriptor() + // epicgvgdefenseattackmapping.ImportantNotesValidator is a validator for the "important_notes" field. It is called by the builders before save. + epicgvgdefenseattackmapping.ImportantNotesValidator = epicgvgdefenseattackmappingDescImportantNotes.Validators[0].(func(string) error) + // epicgvgdefenseattackmappingDescCreator is the schema descriptor for creator field. + epicgvgdefenseattackmappingDescCreator := epicgvgdefenseattackmappingFields[8].Descriptor() + // epicgvgdefenseattackmapping.CreatorValidator is a validator for the "creator" field. It is called by the builders before save. + epicgvgdefenseattackmapping.CreatorValidator = epicgvgdefenseattackmappingDescCreator.Validators[0].(func(string) error) + // epicgvgdefenseattackmappingDescUpdater is the schema descriptor for updater field. + epicgvgdefenseattackmappingDescUpdater := epicgvgdefenseattackmappingFields[10].Descriptor() + // epicgvgdefenseattackmapping.UpdaterValidator is a validator for the "updater" field. It is called by the builders before save. + epicgvgdefenseattackmapping.UpdaterValidator = epicgvgdefenseattackmappingDescUpdater.Validators[0].(func(string) error) + epicgvgdefenseteamsFields := entity.EpicGvgDefenseTeams{}.Fields() + _ = epicgvgdefenseteamsFields + // epicgvgdefenseteamsDescDefenseHeroes is the schema descriptor for defense_heroes field. + epicgvgdefenseteamsDescDefenseHeroes := epicgvgdefenseteamsFields[1].Descriptor() + // epicgvgdefenseteams.DefenseHeroesValidator is a validator for the "defense_heroes" field. It is called by the builders before save. + epicgvgdefenseteams.DefenseHeroesValidator = epicgvgdefenseteamsDescDefenseHeroes.Validators[0].(func(string) error) + // epicgvgdefenseteamsDescCreator is the schema descriptor for creator field. + epicgvgdefenseteamsDescCreator := epicgvgdefenseteamsFields[2].Descriptor() + // epicgvgdefenseteams.CreatorValidator is a validator for the "creator" field. It is called by the builders before save. + epicgvgdefenseteams.CreatorValidator = epicgvgdefenseteamsDescCreator.Validators[0].(func(string) error) + // epicgvgdefenseteamsDescUpdater is the schema descriptor for updater field. + epicgvgdefenseteamsDescUpdater := epicgvgdefenseteamsFields[4].Descriptor() + // epicgvgdefenseteams.UpdaterValidator is a validator for the "updater" field. It is called by the builders before save. + epicgvgdefenseteams.UpdaterValidator = epicgvgdefenseteamsDescUpdater.Validators[0].(func(string) error) + epicheroinfoFields := entity.EpicHeroInfo{}.Fields() + _ = epicheroinfoFields + // epicheroinfoDescHeroName is the schema descriptor for hero_name field. + epicheroinfoDescHeroName := epicheroinfoFields[1].Descriptor() + // epicheroinfo.HeroNameValidator is a validator for the "hero_name" field. It is called by the builders before save. + epicheroinfo.HeroNameValidator = epicheroinfoDescHeroName.Validators[0].(func(string) error) + // epicheroinfoDescHeroCode is the schema descriptor for hero_code field. + epicheroinfoDescHeroCode := epicheroinfoFields[2].Descriptor() + // epicheroinfo.HeroCodeValidator is a validator for the "hero_code" field. It is called by the builders before save. + epicheroinfo.HeroCodeValidator = epicheroinfoDescHeroCode.Validators[0].(func(string) error) + // epicheroinfoDescHeroAttrLv60 is the schema descriptor for hero_attr_lv60 field. + epicheroinfoDescHeroAttrLv60 := epicheroinfoFields[3].Descriptor() + // epicheroinfo.HeroAttrLv60Validator is a validator for the "hero_attr_lv60" field. It is called by the builders before save. + epicheroinfo.HeroAttrLv60Validator = epicheroinfoDescHeroAttrLv60.Validators[0].(func(string) error) + // epicheroinfoDescCreator is the schema descriptor for creator field. + epicheroinfoDescCreator := epicheroinfoFields[4].Descriptor() + // epicheroinfo.CreatorValidator is a validator for the "creator" field. It is called by the builders before save. + epicheroinfo.CreatorValidator = epicheroinfoDescCreator.Validators[0].(func(string) error) + // epicheroinfoDescUpdater is the schema descriptor for updater field. + epicheroinfoDescUpdater := epicheroinfoFields[6].Descriptor() + // epicheroinfo.UpdaterValidator is a validator for the "updater" field. It is called by the builders before save. + epicheroinfo.UpdaterValidator = epicheroinfoDescUpdater.Validators[0].(func(string) error) + // epicheroinfoDescNickName is the schema descriptor for nick_name field. + epicheroinfoDescNickName := epicheroinfoFields[9].Descriptor() + // epicheroinfo.NickNameValidator is a validator for the "nick_name" field. It is called by the builders before save. + epicheroinfo.NickNameValidator = epicheroinfoDescNickName.Validators[0].(func(string) error) + // epicheroinfoDescRarity is the schema descriptor for rarity field. + epicheroinfoDescRarity := epicheroinfoFields[10].Descriptor() + // epicheroinfo.RarityValidator is a validator for the "rarity" field. It is called by the builders before save. + epicheroinfo.RarityValidator = epicheroinfoDescRarity.Validators[0].(func(string) error) + // epicheroinfoDescRole is the schema descriptor for role field. + epicheroinfoDescRole := epicheroinfoFields[11].Descriptor() + // epicheroinfo.RoleValidator is a validator for the "role" field. It is called by the builders before save. + epicheroinfo.RoleValidator = epicheroinfoDescRole.Validators[0].(func(string) error) + // epicheroinfoDescZodiac is the schema descriptor for zodiac field. + epicheroinfoDescZodiac := epicheroinfoFields[12].Descriptor() + // epicheroinfo.ZodiacValidator is a validator for the "zodiac" field. It is called by the builders before save. + epicheroinfo.ZodiacValidator = epicheroinfoDescZodiac.Validators[0].(func(string) error) + // epicheroinfoDescHeadImgURL is the schema descriptor for head_img_url field. + epicheroinfoDescHeadImgURL := epicheroinfoFields[13].Descriptor() + // epicheroinfo.HeadImgURLValidator is a validator for the "head_img_url" field. It is called by the builders before save. + epicheroinfo.HeadImgURLValidator = epicheroinfoDescHeadImgURL.Validators[0].(func(string) error) + // epicheroinfoDescAttribute is the schema descriptor for attribute field. + epicheroinfoDescAttribute := epicheroinfoFields[14].Descriptor() + // epicheroinfo.AttributeValidator is a validator for the "attribute" field. It is called by the builders before save. + epicheroinfo.AttributeValidator = epicheroinfoDescAttribute.Validators[0].(func(string) error) + // epicheroinfoDescRemark is the schema descriptor for remark field. + epicheroinfoDescRemark := epicheroinfoFields[15].Descriptor() + // epicheroinfo.RemarkValidator is a validator for the "remark" field. It is called by the builders before save. + epicheroinfo.RemarkValidator = epicheroinfoDescRemark.Validators[0].(func(string) error) + // epicheroinfoDescRawJSON is the schema descriptor for raw_json field. + epicheroinfoDescRawJSON := epicheroinfoFields[16].Descriptor() + // epicheroinfo.RawJSONValidator is a validator for the "raw_json" field. It is called by the builders before save. + epicheroinfo.RawJSONValidator = epicheroinfoDescRawJSON.Validators[0].(func(string) error) + // epicheroinfoDescSetContentJSON is the schema descriptor for set_content_json field. + epicheroinfoDescSetContentJSON := epicheroinfoFields[17].Descriptor() + // epicheroinfo.SetContentJSONValidator is a validator for the "set_content_json" field. It is called by the builders before save. + epicheroinfo.SetContentJSONValidator = epicheroinfoDescSetContentJSON.Validators[0].(func(string) error) + epicherouserbuildFields := entity.EpicHeroUserBuild{}.Fields() + _ = epicherouserbuildFields + // epicherouserbuildDescArtifactCode is the schema descriptor for artifact_code field. + epicherouserbuildDescArtifactCode := epicherouserbuildFields[1].Descriptor() + // epicherouserbuild.ArtifactCodeValidator is a validator for the "artifact_code" field. It is called by the builders before save. + epicherouserbuild.ArtifactCodeValidator = epicherouserbuildDescArtifactCode.Validators[0].(func(string) error) + // epicherouserbuildDescHeroCode is the schema descriptor for hero_code field. + epicherouserbuildDescHeroCode := epicherouserbuildFields[2].Descriptor() + // epicherouserbuild.HeroCodeValidator is a validator for the "hero_code" field. It is called by the builders before save. + epicherouserbuild.HeroCodeValidator = epicherouserbuildDescHeroCode.Validators[0].(func(string) error) + // epicherouserbuildDescCreator is the schema descriptor for creator field. + epicherouserbuildDescCreator := epicherouserbuildFields[6].Descriptor() + // epicherouserbuild.CreatorValidator is a validator for the "creator" field. It is called by the builders before save. + epicherouserbuild.CreatorValidator = epicherouserbuildDescCreator.Validators[0].(func(string) error) + // epicherouserbuildDescUpdater is the schema descriptor for updater field. + epicherouserbuildDescUpdater := epicherouserbuildFields[8].Descriptor() + // epicherouserbuild.UpdaterValidator is a validator for the "updater" field. It is called by the builders before save. + epicherouserbuild.UpdaterValidator = epicherouserbuildDescUpdater.Validators[0].(func(string) error) + epici18nmappingsFields := entity.EpicI18NMappings{}.Fields() + _ = epici18nmappingsFields + // epici18nmappingsDescKeyName is the schema descriptor for key_name field. + epici18nmappingsDescKeyName := epici18nmappingsFields[1].Descriptor() + // epici18nmappings.KeyNameValidator is a validator for the "key_name" field. It is called by the builders before save. + epici18nmappings.KeyNameValidator = epici18nmappingsDescKeyName.Validators[0].(func(string) error) + // epici18nmappingsDescLanguage is the schema descriptor for language field. + epici18nmappingsDescLanguage := epici18nmappingsFields[2].Descriptor() + // epici18nmappings.LanguageValidator is a validator for the "language" field. It is called by the builders before save. + epici18nmappings.LanguageValidator = epici18nmappingsDescLanguage.Validators[0].(func(string) error) + // epici18nmappingsDescValue is the schema descriptor for value field. + epici18nmappingsDescValue := epici18nmappingsFields[3].Descriptor() + // epici18nmappings.ValueValidator is a validator for the "value" field. It is called by the builders before save. + epici18nmappings.ValueValidator = epici18nmappingsDescValue.Validators[0].(func(string) error) + // epici18nmappingsDescCategory is the schema descriptor for category field. + epici18nmappingsDescCategory := epici18nmappingsFields[4].Descriptor() + // epici18nmappings.CategoryValidator is a validator for the "category" field. It is called by the builders before save. + epici18nmappings.CategoryValidator = epici18nmappingsDescCategory.Validators[0].(func(string) error) + // epici18nmappingsDescCreator is the schema descriptor for creator field. + epici18nmappingsDescCreator := epici18nmappingsFields[6].Descriptor() + // epici18nmappings.CreatorValidator is a validator for the "creator" field. It is called by the builders before save. + epici18nmappings.CreatorValidator = epici18nmappingsDescCreator.Validators[0].(func(string) error) + // epici18nmappingsDescUpdater is the schema descriptor for updater field. + epici18nmappingsDescUpdater := epici18nmappingsFields[8].Descriptor() + // epici18nmappings.UpdaterValidator is a validator for the "updater" field. It is called by the builders before save. + epici18nmappings.UpdaterValidator = epici18nmappingsDescUpdater.Validators[0].(func(string) error) + // epici18nmappingsDescCode is the schema descriptor for code field. + epici18nmappingsDescCode := epici18nmappingsFields[11].Descriptor() + // epici18nmappings.CodeValidator is a validator for the "code" field. It is called by the builders before save. + epici18nmappings.CodeValidator = epici18nmappingsDescCode.Validators[0].(func(string) error) + fribbleherosetFields := entity.FribbleHeroSet{}.Fields() + _ = fribbleherosetFields + // fribbleherosetDescHeroCode is the schema descriptor for hero_code field. + fribbleherosetDescHeroCode := fribbleherosetFields[1].Descriptor() + // fribbleheroset.HeroCodeValidator is a validator for the "hero_code" field. It is called by the builders before save. + fribbleheroset.HeroCodeValidator = fribbleherosetDescHeroCode.Validators[0].(func(string) error) + // fribbleherosetDescJSONContent is the schema descriptor for json_content field. + fribbleherosetDescJSONContent := fribbleherosetFields[2].Descriptor() + // fribbleheroset.JSONContentValidator is a validator for the "json_content" field. It is called by the builders before save. + fribbleheroset.JSONContentValidator = fribbleherosetDescJSONContent.Validators[0].(func(string) error) + // fribbleherosetDescHeroName is the schema descriptor for hero_name field. + fribbleherosetDescHeroName := fribbleherosetFields[3].Descriptor() + // fribbleheroset.HeroNameValidator is a validator for the "hero_name" field. It is called by the builders before save. + fribbleheroset.HeroNameValidator = fribbleherosetDescHeroName.Validators[0].(func(string) error) + // fribbleherosetDescCreator is the schema descriptor for creator field. + fribbleherosetDescCreator := fribbleherosetFields[4].Descriptor() + // fribbleheroset.CreatorValidator is a validator for the "creator" field. It is called by the builders before save. + fribbleheroset.CreatorValidator = fribbleherosetDescCreator.Validators[0].(func(string) error) + // fribbleherosetDescUpdater is the schema descriptor for updater field. + fribbleherosetDescUpdater := fribbleherosetFields[6].Descriptor() + // fribbleheroset.UpdaterValidator is a validator for the "updater" field. It is called by the builders before save. + fribbleheroset.UpdaterValidator = fribbleherosetDescUpdater.Validators[0].(func(string) error) + gearsetinfoFields := entity.GearSetInfo{}.Fields() + _ = gearsetinfoFields + // gearsetinfoDescGearType is the schema descriptor for gear_type field. + gearsetinfoDescGearType := gearsetinfoFields[4].Descriptor() + // gearsetinfo.GearTypeValidator is a validator for the "gear_type" field. It is called by the builders before save. + gearsetinfo.GearTypeValidator = gearsetinfoDescGearType.Validators[0].(func(string) error) + // gearsetinfoDescGearSetType is the schema descriptor for gear_set_type field. + gearsetinfoDescGearSetType := gearsetinfoFields[5].Descriptor() + // gearsetinfo.GearSetTypeValidator is a validator for the "gear_set_type" field. It is called by the builders before save. + gearsetinfo.GearSetTypeValidator = gearsetinfoDescGearSetType.Validators[0].(func(string) error) + // gearsetinfoDescMainStatType is the schema descriptor for main_stat_type field. + gearsetinfoDescMainStatType := gearsetinfoFields[6].Descriptor() + // gearsetinfo.MainStatTypeValidator is a validator for the "main_stat_type" field. It is called by the builders before save. + gearsetinfo.MainStatTypeValidator = gearsetinfoDescMainStatType.Validators[0].(func(string) error) + // gearsetinfoDescSubStatOneType is the schema descriptor for sub_stat_one_type field. + gearsetinfoDescSubStatOneType := gearsetinfoFields[8].Descriptor() + // gearsetinfo.SubStatOneTypeValidator is a validator for the "sub_stat_one_type" field. It is called by the builders before save. + gearsetinfo.SubStatOneTypeValidator = gearsetinfoDescSubStatOneType.Validators[0].(func(string) error) + // gearsetinfoDescSubStatTwoType is the schema descriptor for sub_stat_two_type field. + gearsetinfoDescSubStatTwoType := gearsetinfoFields[10].Descriptor() + // gearsetinfo.SubStatTwoTypeValidator is a validator for the "sub_stat_two_type" field. It is called by the builders before save. + gearsetinfo.SubStatTwoTypeValidator = gearsetinfoDescSubStatTwoType.Validators[0].(func(string) error) + // gearsetinfoDescSubStatThreeType is the schema descriptor for sub_stat_three_type field. + gearsetinfoDescSubStatThreeType := gearsetinfoFields[12].Descriptor() + // gearsetinfo.SubStatThreeTypeValidator is a validator for the "sub_stat_three_type" field. It is called by the builders before save. + gearsetinfo.SubStatThreeTypeValidator = gearsetinfoDescSubStatThreeType.Validators[0].(func(string) error) + // gearsetinfoDescSubStatFourType is the schema descriptor for sub_stat_four_type field. + gearsetinfoDescSubStatFourType := gearsetinfoFields[14].Descriptor() + // gearsetinfo.SubStatFourTypeValidator is a validator for the "sub_stat_four_type" field. It is called by the builders before save. + gearsetinfo.SubStatFourTypeValidator = gearsetinfoDescSubStatFourType.Validators[0].(func(string) error) + // gearsetinfoDescAccountCode is the schema descriptor for account_code field. + gearsetinfoDescAccountCode := gearsetinfoFields[16].Descriptor() + // gearsetinfo.AccountCodeValidator is a validator for the "account_code" field. It is called by the builders before save. + gearsetinfo.AccountCodeValidator = gearsetinfoDescAccountCode.Validators[0].(func(string) error) + // gearsetinfoDescCreator is the schema descriptor for creator field. + gearsetinfoDescCreator := gearsetinfoFields[17].Descriptor() + // gearsetinfo.CreatorValidator is a validator for the "creator" field. It is called by the builders before save. + gearsetinfo.CreatorValidator = gearsetinfoDescCreator.Validators[0].(func(string) error) + // gearsetinfoDescUpdater is the schema descriptor for updater field. + gearsetinfoDescUpdater := gearsetinfoFields[19].Descriptor() + // gearsetinfo.UpdaterValidator is a validator for the "updater" field. It is called by the builders before save. + gearsetinfo.UpdaterValidator = gearsetinfoDescUpdater.Validators[0].(func(string) error) +} diff --git a/internal/ent/runtime/runtime.go b/internal/ent/runtime/runtime.go new file mode 100644 index 0000000..2ab79cb --- /dev/null +++ b/internal/ent/runtime/runtime.go @@ -0,0 +1,10 @@ +// Code generated by ent, DO NOT EDIT. + +package runtime + +// The schema-stitching logic is generated in epic-ent/internal/ent/runtime.go + +const ( + Version = "v0.14.5" // Version of ent codegen. + Sum = "h1:Rj2WOYJtCkWyFo6a+5wB3EfBRP0rnx1fMk6gGA0UUe4=" // Sum of ent codegen. +) diff --git a/internal/ent/tx.go b/internal/ent/tx.go new file mode 100644 index 0000000..45914e9 --- /dev/null +++ b/internal/ent/tx.go @@ -0,0 +1,234 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "sync" + + "entgo.io/ent/dialect" +) + +// Tx is a transactional client that is created by calling Client.Tx(). +type Tx struct { + config + // EpicArtifactInfo is the client for interacting with the EpicArtifactInfo builders. + EpicArtifactInfo *EpicArtifactInfoClient + // EpicGvgAttackTeams is the client for interacting with the EpicGvgAttackTeams builders. + EpicGvgAttackTeams *EpicGvgAttackTeamsClient + // EpicGvgDefenseAttackMapping is the client for interacting with the EpicGvgDefenseAttackMapping builders. + EpicGvgDefenseAttackMapping *EpicGvgDefenseAttackMappingClient + // EpicGvgDefenseTeams is the client for interacting with the EpicGvgDefenseTeams builders. + EpicGvgDefenseTeams *EpicGvgDefenseTeamsClient + // EpicHeroInfo is the client for interacting with the EpicHeroInfo builders. + EpicHeroInfo *EpicHeroInfoClient + // EpicHeroUserBuild is the client for interacting with the EpicHeroUserBuild builders. + EpicHeroUserBuild *EpicHeroUserBuildClient + // EpicI18NMappings is the client for interacting with the EpicI18NMappings builders. + EpicI18NMappings *EpicI18NMappingsClient + // FribbleHeroSet is the client for interacting with the FribbleHeroSet builders. + FribbleHeroSet *FribbleHeroSetClient + // GearSetInfo is the client for interacting with the GearSetInfo builders. + GearSetInfo *GearSetInfoClient + + // lazily loaded. + client *Client + clientOnce sync.Once + // ctx lives for the life of the transaction. It is + // the same context used by the underlying connection. + ctx context.Context +} + +type ( + // Committer is the interface that wraps the Commit method. + Committer interface { + Commit(context.Context, *Tx) error + } + + // The CommitFunc type is an adapter to allow the use of ordinary + // function as a Committer. If f is a function with the appropriate + // signature, CommitFunc(f) is a Committer that calls f. + CommitFunc func(context.Context, *Tx) error + + // CommitHook defines the "commit middleware". A function that gets a Committer + // and returns a Committer. For example: + // + // hook := func(next ent.Committer) ent.Committer { + // return ent.CommitFunc(func(ctx context.Context, tx *ent.Tx) error { + // // Do some stuff before. + // if err := next.Commit(ctx, tx); err != nil { + // return err + // } + // // Do some stuff after. + // return nil + // }) + // } + // + CommitHook func(Committer) Committer +) + +// Commit calls f(ctx, m). +func (f CommitFunc) Commit(ctx context.Context, tx *Tx) error { + return f(ctx, tx) +} + +// Commit commits the transaction. +func (tx *Tx) Commit() error { + txDriver := tx.config.driver.(*txDriver) + var fn Committer = CommitFunc(func(context.Context, *Tx) error { + return txDriver.tx.Commit() + }) + txDriver.mu.Lock() + hooks := append([]CommitHook(nil), txDriver.onCommit...) + txDriver.mu.Unlock() + for i := len(hooks) - 1; i >= 0; i-- { + fn = hooks[i](fn) + } + return fn.Commit(tx.ctx, tx) +} + +// OnCommit adds a hook to call on commit. +func (tx *Tx) OnCommit(f CommitHook) { + txDriver := tx.config.driver.(*txDriver) + txDriver.mu.Lock() + txDriver.onCommit = append(txDriver.onCommit, f) + txDriver.mu.Unlock() +} + +type ( + // Rollbacker is the interface that wraps the Rollback method. + Rollbacker interface { + Rollback(context.Context, *Tx) error + } + + // The RollbackFunc type is an adapter to allow the use of ordinary + // function as a Rollbacker. If f is a function with the appropriate + // signature, RollbackFunc(f) is a Rollbacker that calls f. + RollbackFunc func(context.Context, *Tx) error + + // RollbackHook defines the "rollback middleware". A function that gets a Rollbacker + // and returns a Rollbacker. For example: + // + // hook := func(next ent.Rollbacker) ent.Rollbacker { + // return ent.RollbackFunc(func(ctx context.Context, tx *ent.Tx) error { + // // Do some stuff before. + // if err := next.Rollback(ctx, tx); err != nil { + // return err + // } + // // Do some stuff after. + // return nil + // }) + // } + // + RollbackHook func(Rollbacker) Rollbacker +) + +// Rollback calls f(ctx, m). +func (f RollbackFunc) Rollback(ctx context.Context, tx *Tx) error { + return f(ctx, tx) +} + +// Rollback rollbacks the transaction. +func (tx *Tx) Rollback() error { + txDriver := tx.config.driver.(*txDriver) + var fn Rollbacker = RollbackFunc(func(context.Context, *Tx) error { + return txDriver.tx.Rollback() + }) + txDriver.mu.Lock() + hooks := append([]RollbackHook(nil), txDriver.onRollback...) + txDriver.mu.Unlock() + for i := len(hooks) - 1; i >= 0; i-- { + fn = hooks[i](fn) + } + return fn.Rollback(tx.ctx, tx) +} + +// OnRollback adds a hook to call on rollback. +func (tx *Tx) OnRollback(f RollbackHook) { + txDriver := tx.config.driver.(*txDriver) + txDriver.mu.Lock() + txDriver.onRollback = append(txDriver.onRollback, f) + txDriver.mu.Unlock() +} + +// Client returns a Client that binds to current transaction. +func (tx *Tx) Client() *Client { + tx.clientOnce.Do(func() { + tx.client = &Client{config: tx.config} + tx.client.init() + }) + return tx.client +} + +func (tx *Tx) init() { + tx.EpicArtifactInfo = NewEpicArtifactInfoClient(tx.config) + tx.EpicGvgAttackTeams = NewEpicGvgAttackTeamsClient(tx.config) + tx.EpicGvgDefenseAttackMapping = NewEpicGvgDefenseAttackMappingClient(tx.config) + tx.EpicGvgDefenseTeams = NewEpicGvgDefenseTeamsClient(tx.config) + tx.EpicHeroInfo = NewEpicHeroInfoClient(tx.config) + tx.EpicHeroUserBuild = NewEpicHeroUserBuildClient(tx.config) + tx.EpicI18NMappings = NewEpicI18NMappingsClient(tx.config) + tx.FribbleHeroSet = NewFribbleHeroSetClient(tx.config) + tx.GearSetInfo = NewGearSetInfoClient(tx.config) +} + +// txDriver wraps the given dialect.Tx with a nop dialect.Driver implementation. +// The idea is to support transactions without adding any extra code to the builders. +// When a builder calls to driver.Tx(), it gets the same dialect.Tx instance. +// Commit and Rollback are nop for the internal builders and the user must call one +// of them in order to commit or rollback the transaction. +// +// If a closed transaction is embedded in one of the generated entities, and the entity +// applies a query, for example: EpicArtifactInfo.QueryXXX(), the query will be executed +// through the driver which created this transaction. +// +// Note that txDriver is not goroutine safe. +type txDriver struct { + // the driver we started the transaction from. + drv dialect.Driver + // tx is the underlying transaction. + tx dialect.Tx + // completion hooks. + mu sync.Mutex + onCommit []CommitHook + onRollback []RollbackHook +} + +// newTx creates a new transactional driver. +func newTx(ctx context.Context, drv dialect.Driver) (*txDriver, error) { + tx, err := drv.Tx(ctx) + if err != nil { + return nil, err + } + return &txDriver{tx: tx, drv: drv}, nil +} + +// Tx returns the transaction wrapper (txDriver) to avoid Commit or Rollback calls +// from the internal builders. Should be called only by the internal builders. +func (tx *txDriver) Tx(context.Context) (dialect.Tx, error) { return tx, nil } + +// Dialect returns the dialect of the driver we started the transaction from. +func (tx *txDriver) Dialect() string { return tx.drv.Dialect() } + +// Close is a nop close. +func (*txDriver) Close() error { return nil } + +// Commit is a nop commit for the internal builders. +// User must call `Tx.Commit` in order to commit the transaction. +func (*txDriver) Commit() error { return nil } + +// Rollback is a nop rollback for the internal builders. +// User must call `Tx.Rollback` in order to rollback the transaction. +func (*txDriver) Rollback() error { return nil } + +// Exec calls tx.Exec. +func (tx *txDriver) Exec(ctx context.Context, query string, args, v any) error { + return tx.tx.Exec(ctx, query, args, v) +} + +// Query calls tx.Query. +func (tx *txDriver) Query(ctx context.Context, query string, args, v any) error { + return tx.tx.Query(ctx, query, args, v) +} + +var _ dialect.Driver = (*txDriver)(nil) diff --git a/internal/exception/handler.go b/internal/exception/handler.go index 9635f14..1ce6ce7 100644 --- a/internal/exception/handler.go +++ b/internal/exception/handler.go @@ -1,14 +1,24 @@ package exception import ( + "net/http" + "github.com/labstack/echo/v4" + + "epic-ent/internal/domain/vo" ) func RegisterErrorHandler(e *echo.Echo) { e.HTTPErrorHandler = func(err error, c echo.Context) { - _ = c.JSON(500, map[string]any{ - "code": "INTERNAL_ERROR", - "message": err.Error(), - }) + code := http.StatusInternalServerError + msg := err.Error() + if he, ok := err.(*echo.HTTPError); ok { + code = he.Code + if he.Message != nil { + msg = he.Message.(string) + } + } + + _ = c.JSON(code, vo.Error(msg)) } } diff --git a/internal/infra/db/ent.go b/internal/infra/db/ent.go new file mode 100644 index 0000000..ed6da95 --- /dev/null +++ b/internal/infra/db/ent.go @@ -0,0 +1,25 @@ +package db + +import ( + "context" + + "go.uber.org/fx" + + "epic-ent/internal/config" + "epic-ent/internal/ent" +) + +func NewEntClient(lc fx.Lifecycle, cfg *config.Config) (*ent.Client, error) { + client, err := ent.Open("mysql", cfg.MySQL.DSN) + if err != nil { + return nil, err + } + + lc.Append(fx.Hook{ + OnStop: func(ctx context.Context) error { + return client.Close() + }, + }) + + return client, nil +} diff --git a/internal/infra/module.go b/internal/infra/module.go index a4a8d78..b4c1d75 100644 --- a/internal/infra/module.go +++ b/internal/infra/module.go @@ -14,6 +14,7 @@ var Module = fx.Options( fx.Provide( infraLog.NewLogger, db.NewMySQL, + db.NewEntClient, cache.NewRedis, http.NewEcho, ), diff --git a/internal/repository/hero_repo.go b/internal/repository/hero_repo.go new file mode 100644 index 0000000..0ca2adf --- /dev/null +++ b/internal/repository/hero_repo.go @@ -0,0 +1,218 @@ +package repository + +import ( + "context" + "database/sql" + "time" + + "epic-ent/internal/domain/dto" + "epic-ent/internal/domain/vo" + "epic-ent/internal/ent" + "epic-ent/internal/ent/epicheroinfo" +) + +type HeroRepository struct { + client *ent.Client +} + +func NewHeroRepository(client *ent.Client) *HeroRepository { + return &HeroRepository{client: client} +} + +func (r *HeroRepository) Create(ctx context.Context, req dto.HeroCreateRequest) (vo.Hero, error) { + create := r.client.EpicHeroInfo.Create(). + SetHeroName(valueOrEmpty(req.HeroName)). + SetHeroCode(valueOrEmpty(req.HeroCode)). + SetHeroAttrLv60(valueOrEmpty(req.HeroAttrLv60)). + SetCreator(valueOrEmpty(req.Creator)). + SetUpdater(valueOrEmpty(req.Updater)). + SetDeleted(valueOrFalse(req.Deleted)). + SetNickName(valueOrEmpty(req.NickName)). + SetRarity(valueOrEmpty(req.Rarity)). + SetRole(valueOrEmpty(req.Role)). + SetZodiac(valueOrEmpty(req.Zodiac)). + SetHeadImgURL(valueOrEmpty(req.HeadImgURL)). + SetAttribute(valueOrEmpty(req.Attribute)). + SetRemark(valueOrEmpty(req.Remark)). + SetRawJSON(valueOrEmpty(req.RawJSON)). + SetSetContentJSON(valueOrEmpty(req.SetContentJSON)) + + if req.CreateTime != nil { + create.SetCreateTime(*req.CreateTime) + } + if req.UpdateTime != nil { + create.SetUpdateTime(*req.UpdateTime) + } + if req.SetUpdateTime != nil { + create.SetSetUpdateTime(*req.SetUpdateTime) + } + + hero, err := create.Save(ctx) + if err != nil { + return vo.Hero{}, err + } + + return toVO(hero), nil +} + +func (r *HeroRepository) GetByID(ctx context.Context, id int64) (vo.Hero, error) { + hero, err := r.client.EpicHeroInfo.Query(). + Where( + epicheroinfo.IDEQ(id), + epicheroinfo.DeletedEQ(false), + ). + Only(ctx) + if err != nil { + return vo.Hero{}, err + } + + return toVO(hero), nil +} + +func (r *HeroRepository) Update(ctx context.Context, id int64, req dto.HeroUpdateRequest) (vo.Hero, error) { + updated := false + update := r.client.EpicHeroInfo.Update(). + Where( + epicheroinfo.IDEQ(id), + epicheroinfo.DeletedEQ(false), + ) + if req.HeroName != nil { + update.SetHeroName(*req.HeroName) + updated = true + } + if req.HeroCode != nil { + update.SetHeroCode(*req.HeroCode) + updated = true + } + if req.HeroAttrLv60 != nil { + update.SetHeroAttrLv60(*req.HeroAttrLv60) + updated = true + } + if req.Updater != nil { + update.SetUpdater(*req.Updater) + updated = true + } + if req.UpdateTime != nil { + update.SetUpdateTime(*req.UpdateTime) + updated = true + } + if req.Deleted != nil { + update.SetDeleted(*req.Deleted) + updated = true + } + if req.NickName != nil { + update.SetNickName(*req.NickName) + updated = true + } + if req.Rarity != nil { + update.SetRarity(*req.Rarity) + updated = true + } + if req.Role != nil { + update.SetRole(*req.Role) + updated = true + } + if req.Zodiac != nil { + update.SetZodiac(*req.Zodiac) + updated = true + } + if req.HeadImgURL != nil { + update.SetHeadImgURL(*req.HeadImgURL) + updated = true + } + if req.Attribute != nil { + update.SetAttribute(*req.Attribute) + updated = true + } + if req.Remark != nil { + update.SetRemark(*req.Remark) + updated = true + } + if req.RawJSON != nil { + update.SetRawJSON(*req.RawJSON) + updated = true + } + if req.SetContentJSON != nil { + update.SetSetContentJSON(*req.SetContentJSON) + updated = true + } + if req.SetUpdateTime != nil { + update.SetSetUpdateTime(*req.SetUpdateTime) + updated = true + } + + if !updated { + return r.GetByID(ctx, id) + } + + if req.UpdateTime == nil { + update.SetUpdateTime(time.Now()) + } + + affected, err := update.Save(ctx) + if err != nil { + return vo.Hero{}, err + } + if affected == 0 { + return vo.Hero{}, sql.ErrNoRows + } + + return r.GetByID(ctx, id) +} + +func (r *HeroRepository) Delete(ctx context.Context, id int64) error { + affected, err := r.client.EpicHeroInfo.Update(). + Where( + epicheroinfo.IDEQ(id), + epicheroinfo.DeletedEQ(false), + ). + SetDeleted(true). + SetUpdateTime(time.Now()). + Save(ctx) + if err != nil { + return err + } + if affected == 0 { + return sql.ErrNoRows + } + + return nil +} + +func toVO(hero *ent.EpicHeroInfo) vo.Hero { + return vo.Hero{ + ID: hero.ID, + HeroName: hero.HeroName, + HeroCode: hero.HeroCode, + HeroAttrLv60: hero.HeroAttrLv60, + Creator: hero.Creator, + CreateTime: hero.CreateTime, + Updater: hero.Updater, + UpdateTime: hero.UpdateTime, + Deleted: hero.Deleted, + NickName: hero.NickName, + Rarity: hero.Rarity, + Role: hero.Role, + Zodiac: hero.Zodiac, + HeadImgURL: hero.HeadImgURL, + Attribute: hero.Attribute, + Remark: hero.Remark, + RawJSON: hero.RawJSON, + SetContentJSON: hero.SetContentJSON, + SetUpdateTime: hero.SetUpdateTime, + } +} + +func valueOrEmpty(v *string) string { + if v == nil { + return "" + } + return *v +} + +func valueOrFalse(v *bool) bool { + if v == nil { + return false + } + return *v +} diff --git a/internal/repository/module.go b/internal/repository/module.go index e6ff95f..0c01e12 100644 --- a/internal/repository/module.go +++ b/internal/repository/module.go @@ -5,5 +5,6 @@ import "go.uber.org/fx" var Module = fx.Options( fx.Provide( NewHealthRepository, + NewHeroRepository, ), ) diff --git a/internal/service/health_service.go b/internal/service/health_service.go deleted file mode 100644 index 185b7b8..0000000 --- a/internal/service/health_service.go +++ /dev/null @@ -1,18 +0,0 @@ -package service - -import ( - "epic-ent/internal/domain/vo" - "epic-ent/internal/repository" -) - -type HealthService struct { - repo *repository.HealthRepository -} - -func NewHealthService(repo *repository.HealthRepository) *HealthService { - return &HealthService{repo: repo} -} - -func (s *HealthService) Check() vo.HealthStatus { - return s.repo.Check() -} diff --git a/internal/service/hero_service.go b/internal/service/hero_service.go new file mode 100644 index 0000000..970eb2a --- /dev/null +++ b/internal/service/hero_service.go @@ -0,0 +1,49 @@ +package service + +import ( + "context" + "time" + + "epic-ent/internal/domain/dto" + "epic-ent/internal/domain/vo" + "epic-ent/internal/repository" +) + +type HeroService struct { + repo *repository.HeroRepository +} + +func NewHeroService(repo *repository.HeroRepository) *HeroService { + return &HeroService{repo: repo} +} + +func (s *HeroService) Create(ctx context.Context, req dto.HeroCreateRequest) (vo.Hero, error) { + now := time.Now() + if req.CreateTime == nil { + req.CreateTime = &now + } + if req.UpdateTime == nil { + req.UpdateTime = &now + } + if req.Deleted == nil { + req.Deleted = boolPtr(false) + } + + return s.repo.Create(ctx, req) +} + +func (s *HeroService) GetByID(ctx context.Context, id int64) (vo.Hero, error) { + return s.repo.GetByID(ctx, id) +} + +func (s *HeroService) Update(ctx context.Context, id int64, req dto.HeroUpdateRequest) (vo.Hero, error) { + return s.repo.Update(ctx, id, req) +} + +func (s *HeroService) Delete(ctx context.Context, id int64) error { + return s.repo.Delete(ctx, id) +} + +func boolPtr(v bool) *bool { + return &v +} diff --git a/internal/service/module.go b/internal/service/module.go index 7c1a38c..258ddf5 100644 --- a/internal/service/module.go +++ b/internal/service/module.go @@ -4,6 +4,6 @@ import "go.uber.org/fx" var Module = fx.Options( fx.Provide( - NewHealthService, + NewHeroService, ), )