From 97ca3fc7b0d2d5a1e5c4872e7bd18d05c0fa78c7 Mon Sep 17 00:00:00 2001 From: landaiqing <3517283258@qq.com> Date: Tue, 12 Nov 2024 17:00:16 +0800 Subject: [PATCH] :tada: init --- .gitignore | 106 + .idea/.gitignore | 8 + .idea/GOHCache.xml | 1576 +++++ .idea/modules.xml | 8 + .../schisandra-album-cloud-microservices.iml | 9 + .idea/vcs.xml | 6 + README.md | 0 app/auth/auth.api | 69 + app/auth/auth.go | 37 + app/auth/etc/auth.yaml | 5 + app/auth/internal/config/config.go | 10 + app/auth/internal/handler/routes.go | 43 + .../handler/user/account_login_handler.go | 28 + .../handler/user/phone_login_handler.go | 28 + .../handler/user/reset_password_handler.go | 28 + .../logic/user/account_login_logic.go | 30 + .../internal/logic/user/phone_login_logic.go | 30 + .../logic/user/reset_password_logic.go | 30 + .../internal/middleware/i18n_middleware.go | 19 + .../middleware/securityheaders_middleware.go | 21 + app/auth/internal/svc/service_context.go | 26 + app/auth/internal/types/types.go | 34 + common/core/mysql.go | 32 + common/ent/client.go | 1012 ++++ common/ent/ent.go | 616 ++ common/ent/enttest/enttest.go | 85 + common/ent/generate.go | 3 + common/ent/hook/hook.go | 246 + common/ent/migrate/migrate.go | 64 + common/ent/migrate/schema.go | 184 + common/ent/mutation.go | 5300 +++++++++++++++++ common/ent/predicate/predicate.go | 22 + common/ent/runtime.go | 229 + common/ent/runtime/runtime.go | 10 + common/ent/scaauthpermissionrule.go | 229 + .../scaauthpermissionrule.go | 147 + common/ent/scaauthpermissionrule/where.go | 623 ++ common/ent/scaauthpermissionrule_create.go | 365 ++ common/ent/scaauthpermissionrule_delete.go | 88 + common/ent/scaauthpermissionrule_query.go | 614 ++ common/ent/scaauthpermissionrule_update.go | 680 +++ common/ent/scaauthrole.go | 177 + common/ent/scaauthrole/scaauthrole.go | 127 + common/ent/scaauthrole/where.go | 369 ++ common/ent/scaauthrole_create.go | 332 ++ common/ent/scaauthrole_delete.go | 88 + common/ent/scaauthrole_query.go | 609 ++ common/ent/scaauthrole_update.go | 533 ++ common/ent/scaauthuser.go | 325 + common/ent/scaauthuser/scaauthuser.go | 265 + common/ent/scaauthuser/where.go | 1267 ++++ common/ent/scaauthuser_create.go | 613 ++ common/ent/scaauthuser_delete.go | 88 + common/ent/scaauthuser_query.go | 686 +++ common/ent/scaauthuser_update.go | 1414 +++++ common/ent/scaauthuserdevice.go | 314 + .../scaauthuserdevice/scaauthuserdevice.go | 237 + common/ent/scaauthuserdevice/where.go | 1099 ++++ common/ent/scaauthuserdevice_create.go | 522 ++ common/ent/scaauthuserdevice_delete.go | 88 + common/ent/scaauthuserdevice_query.go | 614 ++ common/ent/scaauthuserdevice_update.go | 989 +++ common/ent/scaauthusersocial.go | 215 + .../scaauthusersocial/scaauthusersocial.go | 151 + common/ent/scaauthusersocial/where.go | 494 ++ common/ent/scaauthusersocial_create.go | 377 ++ common/ent/scaauthusersocial_delete.go | 88 + common/ent/scaauthusersocial_query.go | 614 ++ common/ent/scaauthusersocial_update.go | 595 ++ common/ent/schema/sca_auth_permission_rule.go | 58 + common/ent/schema/sca_auth_role.go | 55 + common/ent/schema/sca_auth_user.go | 115 + common/ent/schema/sca_auth_user_device.go | 94 + common/ent/schema/sca_auth_user_social.go | 69 + common/ent/tx.go | 222 + common/middleware/i18n_middleware.go | 7 + .../middleware/security_headers_middleware.go | 13 + common/response/response.go | 1 + go.mod | 62 + go.sum | 191 + 80 files changed, 26877 insertions(+) create mode 100644 .gitignore create mode 100644 .idea/.gitignore create mode 100644 .idea/GOHCache.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/schisandra-album-cloud-microservices.iml create mode 100644 .idea/vcs.xml create mode 100644 README.md create mode 100644 app/auth/auth.api create mode 100644 app/auth/auth.go create mode 100644 app/auth/etc/auth.yaml create mode 100644 app/auth/internal/config/config.go create mode 100644 app/auth/internal/handler/routes.go create mode 100644 app/auth/internal/handler/user/account_login_handler.go create mode 100644 app/auth/internal/handler/user/phone_login_handler.go create mode 100644 app/auth/internal/handler/user/reset_password_handler.go create mode 100644 app/auth/internal/logic/user/account_login_logic.go create mode 100644 app/auth/internal/logic/user/phone_login_logic.go create mode 100644 app/auth/internal/logic/user/reset_password_logic.go create mode 100644 app/auth/internal/middleware/i18n_middleware.go create mode 100644 app/auth/internal/middleware/securityheaders_middleware.go create mode 100644 app/auth/internal/svc/service_context.go create mode 100644 app/auth/internal/types/types.go create mode 100644 common/core/mysql.go create mode 100644 common/ent/client.go create mode 100644 common/ent/ent.go create mode 100644 common/ent/enttest/enttest.go create mode 100644 common/ent/generate.go create mode 100644 common/ent/hook/hook.go create mode 100644 common/ent/migrate/migrate.go create mode 100644 common/ent/migrate/schema.go create mode 100644 common/ent/mutation.go create mode 100644 common/ent/predicate/predicate.go create mode 100644 common/ent/runtime.go create mode 100644 common/ent/runtime/runtime.go create mode 100644 common/ent/scaauthpermissionrule.go create mode 100644 common/ent/scaauthpermissionrule/scaauthpermissionrule.go create mode 100644 common/ent/scaauthpermissionrule/where.go create mode 100644 common/ent/scaauthpermissionrule_create.go create mode 100644 common/ent/scaauthpermissionrule_delete.go create mode 100644 common/ent/scaauthpermissionrule_query.go create mode 100644 common/ent/scaauthpermissionrule_update.go create mode 100644 common/ent/scaauthrole.go create mode 100644 common/ent/scaauthrole/scaauthrole.go create mode 100644 common/ent/scaauthrole/where.go create mode 100644 common/ent/scaauthrole_create.go create mode 100644 common/ent/scaauthrole_delete.go create mode 100644 common/ent/scaauthrole_query.go create mode 100644 common/ent/scaauthrole_update.go create mode 100644 common/ent/scaauthuser.go create mode 100644 common/ent/scaauthuser/scaauthuser.go create mode 100644 common/ent/scaauthuser/where.go create mode 100644 common/ent/scaauthuser_create.go create mode 100644 common/ent/scaauthuser_delete.go create mode 100644 common/ent/scaauthuser_query.go create mode 100644 common/ent/scaauthuser_update.go create mode 100644 common/ent/scaauthuserdevice.go create mode 100644 common/ent/scaauthuserdevice/scaauthuserdevice.go create mode 100644 common/ent/scaauthuserdevice/where.go create mode 100644 common/ent/scaauthuserdevice_create.go create mode 100644 common/ent/scaauthuserdevice_delete.go create mode 100644 common/ent/scaauthuserdevice_query.go create mode 100644 common/ent/scaauthuserdevice_update.go create mode 100644 common/ent/scaauthusersocial.go create mode 100644 common/ent/scaauthusersocial/scaauthusersocial.go create mode 100644 common/ent/scaauthusersocial/where.go create mode 100644 common/ent/scaauthusersocial_create.go create mode 100644 common/ent/scaauthusersocial_delete.go create mode 100644 common/ent/scaauthusersocial_query.go create mode 100644 common/ent/scaauthusersocial_update.go create mode 100644 common/ent/schema/sca_auth_permission_rule.go create mode 100644 common/ent/schema/sca_auth_role.go create mode 100644 common/ent/schema/sca_auth_user.go create mode 100644 common/ent/schema/sca_auth_user_device.go create mode 100644 common/ent/schema/sca_auth_user_social.go create mode 100644 common/ent/tx.go create mode 100644 common/middleware/i18n_middleware.go create mode 100644 common/middleware/security_headers_middleware.go create mode 100644 common/response/response.go create mode 100644 go.mod create mode 100644 go.sum diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8273639 --- /dev/null +++ b/.gitignore @@ -0,0 +1,106 @@ +### GoLand+all template +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### Go template +# If you prefer the allow list template instead of the deny list, see community template: +# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore +# +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, built with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Dependency directories (remove the comment below to include it) +# vendor/ + +# Go workspace file +go.work +go.work.sum + +# env file +.env + diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/GOHCache.xml b/.idea/GOHCache.xml new file mode 100644 index 0000000..76fffff --- /dev/null +++ b/.idea/GOHCache.xml @@ -0,0 +1,1576 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..e3067f3 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/schisandra-album-cloud-microservices.iml b/.idea/schisandra-album-cloud-microservices.iml new file mode 100644 index 0000000..5e764c4 --- /dev/null +++ b/.idea/schisandra-album-cloud-microservices.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/app/auth/auth.api b/app/auth/auth.api new file mode 100644 index 0000000..7e22f75 --- /dev/null +++ b/app/auth/auth.api @@ -0,0 +1,69 @@ +syntax = "v1" + +info ( + title: "鉴权微服务" + desc: "鉴权微服务" + author: "landaiqing" + email: "landaiqing@126.com" + version: "v1.0.0" +) + +// 登录请求参数 +type ( + // 账户登录请求参数 + AccountLoginRequest { + Account string `json:"account"` + Password string `json:"password"` + AutoLogin bool `json:"auto_login"` + Angle int64 `json:"angle"` + Key string `json:"key"` + } + // 手机号登录请求参数 + PhoneLoginRequest { + Phone string `json:"phone"` + Captcha string `json:"captcha"` + AutoLogin bool `json:"auto_login"` + } + // 重置密码请求参数 + ResetPasswordRequest { + Phone string `json:"phone"` + Captcha string `json:"captcha"` + Password string `json:"password"` + Repassword string `json:"repassword"` + } + // 登录响应参数 + LoginResponse { + AccessToken string `json:"access_token"` + UID string `json:"uid"` + Username string `json:"username,optional"` + Nickname string `json:"nickname"` + Avatar string `json:"avatar"` + Status int64 `json:"status"` + } +) + +// 用户服务 +@server ( + group: user // 微服务分组 + prefix: /api/auth/user // 微服务前缀 + timeout: 10s // 超时时间 + maxBytes: 1048576 // 最大请求大小 + signature: true // 是否开启签名验证 + middleware: I18nMiddleware,SecurityHeadersMiddleware // 注册中间件 + MaxConns: true // 是否开启最大连接数限制 + Recover: true // 是否开启自动恢复 +) +service auth { + // 账户登录 + @handler accountLogin + post /login (AccountLoginRequest) returns (LoginResponse) + + // 手机号登录 + @handler phoneLogin + post /phone_login (PhoneLoginRequest) returns (LoginResponse) + + // 重置密码 + @handler resetPassword + post /reset_password (ResetPasswordRequest) returns (string) +} + diff --git a/app/auth/auth.go b/app/auth/auth.go new file mode 100644 index 0000000..f89a08d --- /dev/null +++ b/app/auth/auth.go @@ -0,0 +1,37 @@ +package main + +import ( + "flag" + "fmt" + "net/http" + + "schisandra-album-cloud-microservices/app/auth/internal/config" + "schisandra-album-cloud-microservices/app/auth/internal/handler" + "schisandra-album-cloud-microservices/app/auth/internal/svc" + + "github.com/zeromicro/go-zero/core/conf" + "github.com/zeromicro/go-zero/rest" +) + +var configFile = flag.String("f", "etc/auth.yaml", "the config file") + +func main() { + flag.Parse() + + var c config.Config + conf.MustLoad(*configFile, &c) + + server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(func(header http.Header) { + header.Set("Access-Control-Allow-Origin", "*") + header.Add("Access-Control-Allow-Headers", "UserHeader1, UserHeader2") + header.Set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS, PATCH") + header.Set("Access-Control-Expose-Headers", "Content-Length, Content-Type") + }, nil, "*")) + defer server.Stop() + + ctx := svc.NewServiceContext(c) + handler.RegisterHandlers(server, ctx) + + fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port) + server.Start() +} diff --git a/app/auth/etc/auth.yaml b/app/auth/etc/auth.yaml new file mode 100644 index 0000000..a3a3011 --- /dev/null +++ b/app/auth/etc/auth.yaml @@ -0,0 +1,5 @@ +Name: auth +Host: 0.0.0.0 +Port: 8888 +Mysql: + Dsn: root:1611@tcp(localhost:3306)/schisandra-cloud-album?charset=utf8mb4&parseTime=True&loc=Local \ No newline at end of file diff --git a/app/auth/internal/config/config.go b/app/auth/internal/config/config.go new file mode 100644 index 0000000..66adb19 --- /dev/null +++ b/app/auth/internal/config/config.go @@ -0,0 +1,10 @@ +package config + +import "github.com/zeromicro/go-zero/rest" + +type Config struct { + rest.RestConf + Mysql struct { + Dsn string + } +} diff --git a/app/auth/internal/handler/routes.go b/app/auth/internal/handler/routes.go new file mode 100644 index 0000000..5feba97 --- /dev/null +++ b/app/auth/internal/handler/routes.go @@ -0,0 +1,43 @@ +// Code generated by goctl. DO NOT EDIT. +// goctl 1.7.3 + +package handler + +import ( + "net/http" + "time" + + user "schisandra-album-cloud-microservices/app/auth/internal/handler/user" + "schisandra-album-cloud-microservices/app/auth/internal/svc" + + "github.com/zeromicro/go-zero/rest" +) + +func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { + server.AddRoutes( + rest.WithMiddlewares( + []rest.Middleware{serverCtx.I18nMiddleware, serverCtx.SecurityHeadersMiddleware}, + []rest.Route{ + { + Method: http.MethodPost, + Path: "/login", + Handler: user.AccountLoginHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/phone_login", + Handler: user.PhoneLoginHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/reset_password", + Handler: user.ResetPasswordHandler(serverCtx), + }, + }..., + ), + rest.WithSignature(serverCtx.Config.Signature), + rest.WithPrefix("/api/auth/user"), + rest.WithTimeout(10000*time.Millisecond), + rest.WithMaxBytes(1048576), + ) +} diff --git a/app/auth/internal/handler/user/account_login_handler.go b/app/auth/internal/handler/user/account_login_handler.go new file mode 100644 index 0000000..941180a --- /dev/null +++ b/app/auth/internal/handler/user/account_login_handler.go @@ -0,0 +1,28 @@ +package user + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "schisandra-album-cloud-microservices/app/auth/internal/logic/user" + "schisandra-album-cloud-microservices/app/auth/internal/svc" + "schisandra-album-cloud-microservices/app/auth/internal/types" +) + +func AccountLoginHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.AccountLoginRequest + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := user.NewAccountLoginLogic(r.Context(), svcCtx) + resp, err := l.AccountLogin(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/app/auth/internal/handler/user/phone_login_handler.go b/app/auth/internal/handler/user/phone_login_handler.go new file mode 100644 index 0000000..17cc682 --- /dev/null +++ b/app/auth/internal/handler/user/phone_login_handler.go @@ -0,0 +1,28 @@ +package user + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "schisandra-album-cloud-microservices/app/auth/internal/logic/user" + "schisandra-album-cloud-microservices/app/auth/internal/svc" + "schisandra-album-cloud-microservices/app/auth/internal/types" +) + +func PhoneLoginHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.PhoneLoginRequest + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := user.NewPhoneLoginLogic(r.Context(), svcCtx) + resp, err := l.PhoneLogin(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/app/auth/internal/handler/user/reset_password_handler.go b/app/auth/internal/handler/user/reset_password_handler.go new file mode 100644 index 0000000..44fb435 --- /dev/null +++ b/app/auth/internal/handler/user/reset_password_handler.go @@ -0,0 +1,28 @@ +package user + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "schisandra-album-cloud-microservices/app/auth/internal/logic/user" + "schisandra-album-cloud-microservices/app/auth/internal/svc" + "schisandra-album-cloud-microservices/app/auth/internal/types" +) + +func ResetPasswordHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ResetPasswordRequest + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := user.NewResetPasswordLogic(r.Context(), svcCtx) + resp, err := l.ResetPassword(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/app/auth/internal/logic/user/account_login_logic.go b/app/auth/internal/logic/user/account_login_logic.go new file mode 100644 index 0000000..cf05b27 --- /dev/null +++ b/app/auth/internal/logic/user/account_login_logic.go @@ -0,0 +1,30 @@ +package user + +import ( + "context" + + "schisandra-album-cloud-microservices/app/auth/internal/svc" + "schisandra-album-cloud-microservices/app/auth/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type AccountLoginLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewAccountLoginLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AccountLoginLogic { + return &AccountLoginLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *AccountLoginLogic) AccountLogin(req *types.AccountLoginRequest) (resp *types.LoginResponse, err error) { + // todo: add your logic here and delete this line + + return +} diff --git a/app/auth/internal/logic/user/phone_login_logic.go b/app/auth/internal/logic/user/phone_login_logic.go new file mode 100644 index 0000000..1ec33d6 --- /dev/null +++ b/app/auth/internal/logic/user/phone_login_logic.go @@ -0,0 +1,30 @@ +package user + +import ( + "context" + + "schisandra-album-cloud-microservices/app/auth/internal/svc" + "schisandra-album-cloud-microservices/app/auth/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type PhoneLoginLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewPhoneLoginLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PhoneLoginLogic { + return &PhoneLoginLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *PhoneLoginLogic) PhoneLogin(req *types.PhoneLoginRequest) (resp *types.LoginResponse, err error) { + // todo: add your logic here and delete this line + + return +} diff --git a/app/auth/internal/logic/user/reset_password_logic.go b/app/auth/internal/logic/user/reset_password_logic.go new file mode 100644 index 0000000..5ea6963 --- /dev/null +++ b/app/auth/internal/logic/user/reset_password_logic.go @@ -0,0 +1,30 @@ +package user + +import ( + "context" + + "schisandra-album-cloud-microservices/app/auth/internal/svc" + "schisandra-album-cloud-microservices/app/auth/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ResetPasswordLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewResetPasswordLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ResetPasswordLogic { + return &ResetPasswordLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ResetPasswordLogic) ResetPassword(req *types.ResetPasswordRequest) (resp string, err error) { + // todo: add your logic here and delete this line + + return +} diff --git a/app/auth/internal/middleware/i18n_middleware.go b/app/auth/internal/middleware/i18n_middleware.go new file mode 100644 index 0000000..5c1db7d --- /dev/null +++ b/app/auth/internal/middleware/i18n_middleware.go @@ -0,0 +1,19 @@ +package middleware + +import "net/http" + +type I18nMiddleware struct { +} + +func NewI18nMiddleware() *I18nMiddleware { + return &I18nMiddleware{} +} + +func (m *I18nMiddleware) Handle(next http.HandlerFunc) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + // TODO generate middleware implement function, delete after code implementation + + // Passthrough to next handler if need + next(w, r) + } +} diff --git a/app/auth/internal/middleware/securityheaders_middleware.go b/app/auth/internal/middleware/securityheaders_middleware.go new file mode 100644 index 0000000..a4a1a72 --- /dev/null +++ b/app/auth/internal/middleware/securityheaders_middleware.go @@ -0,0 +1,21 @@ +package middleware + +import ( + "net/http" + + "schisandra-album-cloud-microservices/common/middleware" +) + +type SecurityHeadersMiddleware struct { +} + +func NewSecurityHeadersMiddleware() *SecurityHeadersMiddleware { + return &SecurityHeadersMiddleware{} +} + +func (m *SecurityHeadersMiddleware) Handle(next http.HandlerFunc) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + middleware.SecurityHeadersMiddleware(w, r) + next(w, r) + } +} diff --git a/app/auth/internal/svc/service_context.go b/app/auth/internal/svc/service_context.go new file mode 100644 index 0000000..43e47d2 --- /dev/null +++ b/app/auth/internal/svc/service_context.go @@ -0,0 +1,26 @@ +package svc + +import ( + "github.com/zeromicro/go-zero/rest" + + "schisandra-album-cloud-microservices/app/auth/internal/config" + "schisandra-album-cloud-microservices/app/auth/internal/middleware" + "schisandra-album-cloud-microservices/common/core" + "schisandra-album-cloud-microservices/common/ent/gen/entschema" +) + +type ServiceContext struct { + Config config.Config + I18nMiddleware rest.Middleware + SecurityHeadersMiddleware rest.Middleware + DB *entschema.Client +} + +func NewServiceContext(c config.Config) *ServiceContext { + return &ServiceContext{ + Config: c, + I18nMiddleware: middleware.NewI18nMiddleware().Handle, + SecurityHeadersMiddleware: middleware.NewSecurityHeadersMiddleware().Handle, + DB: core.InitMySQL(c.Mysql.Dsn), + } +} diff --git a/app/auth/internal/types/types.go b/app/auth/internal/types/types.go new file mode 100644 index 0000000..fe27b71 --- /dev/null +++ b/app/auth/internal/types/types.go @@ -0,0 +1,34 @@ +// Code generated by goctl. DO NOT EDIT. +// goctl 1.7.3 + +package types + +type AccountLoginRequest struct { + Account string `json:"account"` + Password string `json:"password"` + AutoLogin bool `json:"auto_login"` + Angle int64 `json:"angle"` + Key string `json:"key"` +} + +type LoginResponse struct { + AccessToken string `json:"access_token"` + UID string `json:"uid"` + Username string `json:"username,optional"` + Nickname string `json:"nickname"` + Avatar string `json:"avatar"` + Status int64 `json:"status"` +} + +type PhoneLoginRequest struct { + Phone string `json:"phone"` + Captcha string `json:"captcha"` + AutoLogin bool `json:"auto_login"` +} + +type ResetPasswordRequest struct { + Phone string `json:"phone"` + Captcha string `json:"captcha"` + Password string `json:"password"` + Repassword string `json:"repassword"` +} diff --git a/common/core/mysql.go b/common/core/mysql.go new file mode 100644 index 0000000..80b157f --- /dev/null +++ b/common/core/mysql.go @@ -0,0 +1,32 @@ +package core + +import ( + "context" + "database/sql" + "log" + + entsql "entgo.io/ent/dialect/sql" + _ "github.com/go-sql-driver/mysql" + + "schisandra-album-cloud-microservices/common/ent" +) + +func InitMySQL(url string) *ent.Client { + var db *sql.DB + db, err := sql.Open("mysql", url) + + if err != nil { + return nil + } + db.SetMaxOpenConns(100) + db.SetMaxIdleConns(50) + drv := entsql.OpenDB("mysql", db) + client := ent.NewClient(ent.Driver(drv)) + + defer client.Close() + + if err = client.Schema.Create(context.Background()); err != nil { + log.Fatalf("failed creating schema resources: %v", err) + } + return client +} diff --git a/common/ent/client.go b/common/ent/client.go new file mode 100644 index 0000000..0b303da --- /dev/null +++ b/common/ent/client.go @@ -0,0 +1,1012 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "log" + "reflect" + + "schisandra-album-cloud-microservices/common/ent/migrate" + + "schisandra-album-cloud-microservices/common/ent/scaauthpermissionrule" + "schisandra-album-cloud-microservices/common/ent/scaauthrole" + "schisandra-album-cloud-microservices/common/ent/scaauthuser" + "schisandra-album-cloud-microservices/common/ent/scaauthuserdevice" + "schisandra-album-cloud-microservices/common/ent/scaauthusersocial" + + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// 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 + // ScaAuthPermissionRule is the client for interacting with the ScaAuthPermissionRule builders. + ScaAuthPermissionRule *ScaAuthPermissionRuleClient + // ScaAuthRole is the client for interacting with the ScaAuthRole builders. + ScaAuthRole *ScaAuthRoleClient + // ScaAuthUser is the client for interacting with the ScaAuthUser builders. + ScaAuthUser *ScaAuthUserClient + // ScaAuthUserDevice is the client for interacting with the ScaAuthUserDevice builders. + ScaAuthUserDevice *ScaAuthUserDeviceClient + // ScaAuthUserSocial is the client for interacting with the ScaAuthUserSocial builders. + ScaAuthUserSocial *ScaAuthUserSocialClient +} + +// 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.ScaAuthPermissionRule = NewScaAuthPermissionRuleClient(c.config) + c.ScaAuthRole = NewScaAuthRoleClient(c.config) + c.ScaAuthUser = NewScaAuthUserClient(c.config) + c.ScaAuthUserDevice = NewScaAuthUserDeviceClient(c.config) + c.ScaAuthUserSocial = NewScaAuthUserSocialClient(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, + ScaAuthPermissionRule: NewScaAuthPermissionRuleClient(cfg), + ScaAuthRole: NewScaAuthRoleClient(cfg), + ScaAuthUser: NewScaAuthUserClient(cfg), + ScaAuthUserDevice: NewScaAuthUserDeviceClient(cfg), + ScaAuthUserSocial: NewScaAuthUserSocialClient(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, + ScaAuthPermissionRule: NewScaAuthPermissionRuleClient(cfg), + ScaAuthRole: NewScaAuthRoleClient(cfg), + ScaAuthUser: NewScaAuthUserClient(cfg), + ScaAuthUserDevice: NewScaAuthUserDeviceClient(cfg), + ScaAuthUserSocial: NewScaAuthUserSocialClient(cfg), + }, nil +} + +// Debug returns a new debug-client. It's used to get verbose logging on specific operations. +// +// client.Debug(). +// ScaAuthPermissionRule. +// 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) { + c.ScaAuthPermissionRule.Use(hooks...) + c.ScaAuthRole.Use(hooks...) + c.ScaAuthUser.Use(hooks...) + c.ScaAuthUserDevice.Use(hooks...) + c.ScaAuthUserSocial.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) { + c.ScaAuthPermissionRule.Intercept(interceptors...) + c.ScaAuthRole.Intercept(interceptors...) + c.ScaAuthUser.Intercept(interceptors...) + c.ScaAuthUserDevice.Intercept(interceptors...) + c.ScaAuthUserSocial.Intercept(interceptors...) +} + +// Mutate implements the ent.Mutator interface. +func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { + switch m := m.(type) { + case *ScaAuthPermissionRuleMutation: + return c.ScaAuthPermissionRule.mutate(ctx, m) + case *ScaAuthRoleMutation: + return c.ScaAuthRole.mutate(ctx, m) + case *ScaAuthUserMutation: + return c.ScaAuthUser.mutate(ctx, m) + case *ScaAuthUserDeviceMutation: + return c.ScaAuthUserDevice.mutate(ctx, m) + case *ScaAuthUserSocialMutation: + return c.ScaAuthUserSocial.mutate(ctx, m) + default: + return nil, fmt.Errorf("ent: unknown mutation type %T", m) + } +} + +// ScaAuthPermissionRuleClient is a client for the ScaAuthPermissionRule schema. +type ScaAuthPermissionRuleClient struct { + config +} + +// NewScaAuthPermissionRuleClient returns a client for the ScaAuthPermissionRule from the given config. +func NewScaAuthPermissionRuleClient(c config) *ScaAuthPermissionRuleClient { + return &ScaAuthPermissionRuleClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `scaauthpermissionrule.Hooks(f(g(h())))`. +func (c *ScaAuthPermissionRuleClient) Use(hooks ...Hook) { + c.hooks.ScaAuthPermissionRule = append(c.hooks.ScaAuthPermissionRule, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `scaauthpermissionrule.Intercept(f(g(h())))`. +func (c *ScaAuthPermissionRuleClient) Intercept(interceptors ...Interceptor) { + c.inters.ScaAuthPermissionRule = append(c.inters.ScaAuthPermissionRule, interceptors...) +} + +// Create returns a builder for creating a ScaAuthPermissionRule entity. +func (c *ScaAuthPermissionRuleClient) Create() *ScaAuthPermissionRuleCreate { + mutation := newScaAuthPermissionRuleMutation(c.config, OpCreate) + return &ScaAuthPermissionRuleCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of ScaAuthPermissionRule entities. +func (c *ScaAuthPermissionRuleClient) CreateBulk(builders ...*ScaAuthPermissionRuleCreate) *ScaAuthPermissionRuleCreateBulk { + return &ScaAuthPermissionRuleCreateBulk{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 *ScaAuthPermissionRuleClient) MapCreateBulk(slice any, setFunc func(*ScaAuthPermissionRuleCreate, int)) *ScaAuthPermissionRuleCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &ScaAuthPermissionRuleCreateBulk{err: fmt.Errorf("calling to ScaAuthPermissionRuleClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*ScaAuthPermissionRuleCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &ScaAuthPermissionRuleCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for ScaAuthPermissionRule. +func (c *ScaAuthPermissionRuleClient) Update() *ScaAuthPermissionRuleUpdate { + mutation := newScaAuthPermissionRuleMutation(c.config, OpUpdate) + return &ScaAuthPermissionRuleUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *ScaAuthPermissionRuleClient) UpdateOne(sapr *ScaAuthPermissionRule) *ScaAuthPermissionRuleUpdateOne { + mutation := newScaAuthPermissionRuleMutation(c.config, OpUpdateOne, withScaAuthPermissionRule(sapr)) + return &ScaAuthPermissionRuleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *ScaAuthPermissionRuleClient) UpdateOneID(id int64) *ScaAuthPermissionRuleUpdateOne { + mutation := newScaAuthPermissionRuleMutation(c.config, OpUpdateOne, withScaAuthPermissionRuleID(id)) + return &ScaAuthPermissionRuleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for ScaAuthPermissionRule. +func (c *ScaAuthPermissionRuleClient) Delete() *ScaAuthPermissionRuleDelete { + mutation := newScaAuthPermissionRuleMutation(c.config, OpDelete) + return &ScaAuthPermissionRuleDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *ScaAuthPermissionRuleClient) DeleteOne(sapr *ScaAuthPermissionRule) *ScaAuthPermissionRuleDeleteOne { + return c.DeleteOneID(sapr.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *ScaAuthPermissionRuleClient) DeleteOneID(id int64) *ScaAuthPermissionRuleDeleteOne { + builder := c.Delete().Where(scaauthpermissionrule.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &ScaAuthPermissionRuleDeleteOne{builder} +} + +// Query returns a query builder for ScaAuthPermissionRule. +func (c *ScaAuthPermissionRuleClient) Query() *ScaAuthPermissionRuleQuery { + return &ScaAuthPermissionRuleQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeScaAuthPermissionRule}, + inters: c.Interceptors(), + } +} + +// Get returns a ScaAuthPermissionRule entity by its id. +func (c *ScaAuthPermissionRuleClient) Get(ctx context.Context, id int64) (*ScaAuthPermissionRule, error) { + return c.Query().Where(scaauthpermissionrule.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *ScaAuthPermissionRuleClient) GetX(ctx context.Context, id int64) *ScaAuthPermissionRule { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryScaAuthRole queries the sca_auth_role edge of a ScaAuthPermissionRule. +func (c *ScaAuthPermissionRuleClient) QueryScaAuthRole(sapr *ScaAuthPermissionRule) *ScaAuthRoleQuery { + query := (&ScaAuthRoleClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := sapr.ID + step := sqlgraph.NewStep( + sqlgraph.From(scaauthpermissionrule.Table, scaauthpermissionrule.FieldID, id), + sqlgraph.To(scaauthrole.Table, scaauthrole.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, scaauthpermissionrule.ScaAuthRoleTable, scaauthpermissionrule.ScaAuthRoleColumn), + ) + fromV = sqlgraph.Neighbors(sapr.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *ScaAuthPermissionRuleClient) Hooks() []Hook { + return c.hooks.ScaAuthPermissionRule +} + +// Interceptors returns the client interceptors. +func (c *ScaAuthPermissionRuleClient) Interceptors() []Interceptor { + return c.inters.ScaAuthPermissionRule +} + +func (c *ScaAuthPermissionRuleClient) mutate(ctx context.Context, m *ScaAuthPermissionRuleMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&ScaAuthPermissionRuleCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&ScaAuthPermissionRuleUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&ScaAuthPermissionRuleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&ScaAuthPermissionRuleDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown ScaAuthPermissionRule mutation op: %q", m.Op()) + } +} + +// ScaAuthRoleClient is a client for the ScaAuthRole schema. +type ScaAuthRoleClient struct { + config +} + +// NewScaAuthRoleClient returns a client for the ScaAuthRole from the given config. +func NewScaAuthRoleClient(c config) *ScaAuthRoleClient { + return &ScaAuthRoleClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `scaauthrole.Hooks(f(g(h())))`. +func (c *ScaAuthRoleClient) Use(hooks ...Hook) { + c.hooks.ScaAuthRole = append(c.hooks.ScaAuthRole, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `scaauthrole.Intercept(f(g(h())))`. +func (c *ScaAuthRoleClient) Intercept(interceptors ...Interceptor) { + c.inters.ScaAuthRole = append(c.inters.ScaAuthRole, interceptors...) +} + +// Create returns a builder for creating a ScaAuthRole entity. +func (c *ScaAuthRoleClient) Create() *ScaAuthRoleCreate { + mutation := newScaAuthRoleMutation(c.config, OpCreate) + return &ScaAuthRoleCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of ScaAuthRole entities. +func (c *ScaAuthRoleClient) CreateBulk(builders ...*ScaAuthRoleCreate) *ScaAuthRoleCreateBulk { + return &ScaAuthRoleCreateBulk{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 *ScaAuthRoleClient) MapCreateBulk(slice any, setFunc func(*ScaAuthRoleCreate, int)) *ScaAuthRoleCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &ScaAuthRoleCreateBulk{err: fmt.Errorf("calling to ScaAuthRoleClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*ScaAuthRoleCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &ScaAuthRoleCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for ScaAuthRole. +func (c *ScaAuthRoleClient) Update() *ScaAuthRoleUpdate { + mutation := newScaAuthRoleMutation(c.config, OpUpdate) + return &ScaAuthRoleUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *ScaAuthRoleClient) UpdateOne(sar *ScaAuthRole) *ScaAuthRoleUpdateOne { + mutation := newScaAuthRoleMutation(c.config, OpUpdateOne, withScaAuthRole(sar)) + return &ScaAuthRoleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *ScaAuthRoleClient) UpdateOneID(id int64) *ScaAuthRoleUpdateOne { + mutation := newScaAuthRoleMutation(c.config, OpUpdateOne, withScaAuthRoleID(id)) + return &ScaAuthRoleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for ScaAuthRole. +func (c *ScaAuthRoleClient) Delete() *ScaAuthRoleDelete { + mutation := newScaAuthRoleMutation(c.config, OpDelete) + return &ScaAuthRoleDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *ScaAuthRoleClient) DeleteOne(sar *ScaAuthRole) *ScaAuthRoleDeleteOne { + return c.DeleteOneID(sar.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *ScaAuthRoleClient) DeleteOneID(id int64) *ScaAuthRoleDeleteOne { + builder := c.Delete().Where(scaauthrole.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &ScaAuthRoleDeleteOne{builder} +} + +// Query returns a query builder for ScaAuthRole. +func (c *ScaAuthRoleClient) Query() *ScaAuthRoleQuery { + return &ScaAuthRoleQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeScaAuthRole}, + inters: c.Interceptors(), + } +} + +// Get returns a ScaAuthRole entity by its id. +func (c *ScaAuthRoleClient) Get(ctx context.Context, id int64) (*ScaAuthRole, error) { + return c.Query().Where(scaauthrole.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *ScaAuthRoleClient) GetX(ctx context.Context, id int64) *ScaAuthRole { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryScaAuthPermissionRule queries the sca_auth_permission_rule edge of a ScaAuthRole. +func (c *ScaAuthRoleClient) QueryScaAuthPermissionRule(sar *ScaAuthRole) *ScaAuthPermissionRuleQuery { + query := (&ScaAuthPermissionRuleClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := sar.ID + step := sqlgraph.NewStep( + sqlgraph.From(scaauthrole.Table, scaauthrole.FieldID, id), + sqlgraph.To(scaauthpermissionrule.Table, scaauthpermissionrule.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, scaauthrole.ScaAuthPermissionRuleTable, scaauthrole.ScaAuthPermissionRuleColumn), + ) + fromV = sqlgraph.Neighbors(sar.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *ScaAuthRoleClient) Hooks() []Hook { + return c.hooks.ScaAuthRole +} + +// Interceptors returns the client interceptors. +func (c *ScaAuthRoleClient) Interceptors() []Interceptor { + return c.inters.ScaAuthRole +} + +func (c *ScaAuthRoleClient) mutate(ctx context.Context, m *ScaAuthRoleMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&ScaAuthRoleCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&ScaAuthRoleUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&ScaAuthRoleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&ScaAuthRoleDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown ScaAuthRole mutation op: %q", m.Op()) + } +} + +// ScaAuthUserClient is a client for the ScaAuthUser schema. +type ScaAuthUserClient struct { + config +} + +// NewScaAuthUserClient returns a client for the ScaAuthUser from the given config. +func NewScaAuthUserClient(c config) *ScaAuthUserClient { + return &ScaAuthUserClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `scaauthuser.Hooks(f(g(h())))`. +func (c *ScaAuthUserClient) Use(hooks ...Hook) { + c.hooks.ScaAuthUser = append(c.hooks.ScaAuthUser, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `scaauthuser.Intercept(f(g(h())))`. +func (c *ScaAuthUserClient) Intercept(interceptors ...Interceptor) { + c.inters.ScaAuthUser = append(c.inters.ScaAuthUser, interceptors...) +} + +// Create returns a builder for creating a ScaAuthUser entity. +func (c *ScaAuthUserClient) Create() *ScaAuthUserCreate { + mutation := newScaAuthUserMutation(c.config, OpCreate) + return &ScaAuthUserCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of ScaAuthUser entities. +func (c *ScaAuthUserClient) CreateBulk(builders ...*ScaAuthUserCreate) *ScaAuthUserCreateBulk { + return &ScaAuthUserCreateBulk{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 *ScaAuthUserClient) MapCreateBulk(slice any, setFunc func(*ScaAuthUserCreate, int)) *ScaAuthUserCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &ScaAuthUserCreateBulk{err: fmt.Errorf("calling to ScaAuthUserClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*ScaAuthUserCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &ScaAuthUserCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for ScaAuthUser. +func (c *ScaAuthUserClient) Update() *ScaAuthUserUpdate { + mutation := newScaAuthUserMutation(c.config, OpUpdate) + return &ScaAuthUserUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *ScaAuthUserClient) UpdateOne(sau *ScaAuthUser) *ScaAuthUserUpdateOne { + mutation := newScaAuthUserMutation(c.config, OpUpdateOne, withScaAuthUser(sau)) + return &ScaAuthUserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *ScaAuthUserClient) UpdateOneID(id int64) *ScaAuthUserUpdateOne { + mutation := newScaAuthUserMutation(c.config, OpUpdateOne, withScaAuthUserID(id)) + return &ScaAuthUserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for ScaAuthUser. +func (c *ScaAuthUserClient) Delete() *ScaAuthUserDelete { + mutation := newScaAuthUserMutation(c.config, OpDelete) + return &ScaAuthUserDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *ScaAuthUserClient) DeleteOne(sau *ScaAuthUser) *ScaAuthUserDeleteOne { + return c.DeleteOneID(sau.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *ScaAuthUserClient) DeleteOneID(id int64) *ScaAuthUserDeleteOne { + builder := c.Delete().Where(scaauthuser.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &ScaAuthUserDeleteOne{builder} +} + +// Query returns a query builder for ScaAuthUser. +func (c *ScaAuthUserClient) Query() *ScaAuthUserQuery { + return &ScaAuthUserQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeScaAuthUser}, + inters: c.Interceptors(), + } +} + +// Get returns a ScaAuthUser entity by its id. +func (c *ScaAuthUserClient) Get(ctx context.Context, id int64) (*ScaAuthUser, error) { + return c.Query().Where(scaauthuser.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *ScaAuthUserClient) GetX(ctx context.Context, id int64) *ScaAuthUser { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryScaAuthUserSocial queries the sca_auth_user_social edge of a ScaAuthUser. +func (c *ScaAuthUserClient) QueryScaAuthUserSocial(sau *ScaAuthUser) *ScaAuthUserSocialQuery { + query := (&ScaAuthUserSocialClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := sau.ID + step := sqlgraph.NewStep( + sqlgraph.From(scaauthuser.Table, scaauthuser.FieldID, id), + sqlgraph.To(scaauthusersocial.Table, scaauthusersocial.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, scaauthuser.ScaAuthUserSocialTable, scaauthuser.ScaAuthUserSocialColumn), + ) + fromV = sqlgraph.Neighbors(sau.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryScaAuthUserDevice queries the sca_auth_user_device edge of a ScaAuthUser. +func (c *ScaAuthUserClient) QueryScaAuthUserDevice(sau *ScaAuthUser) *ScaAuthUserDeviceQuery { + query := (&ScaAuthUserDeviceClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := sau.ID + step := sqlgraph.NewStep( + sqlgraph.From(scaauthuser.Table, scaauthuser.FieldID, id), + sqlgraph.To(scaauthuserdevice.Table, scaauthuserdevice.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, scaauthuser.ScaAuthUserDeviceTable, scaauthuser.ScaAuthUserDeviceColumn), + ) + fromV = sqlgraph.Neighbors(sau.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *ScaAuthUserClient) Hooks() []Hook { + return c.hooks.ScaAuthUser +} + +// Interceptors returns the client interceptors. +func (c *ScaAuthUserClient) Interceptors() []Interceptor { + return c.inters.ScaAuthUser +} + +func (c *ScaAuthUserClient) mutate(ctx context.Context, m *ScaAuthUserMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&ScaAuthUserCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&ScaAuthUserUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&ScaAuthUserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&ScaAuthUserDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown ScaAuthUser mutation op: %q", m.Op()) + } +} + +// ScaAuthUserDeviceClient is a client for the ScaAuthUserDevice schema. +type ScaAuthUserDeviceClient struct { + config +} + +// NewScaAuthUserDeviceClient returns a client for the ScaAuthUserDevice from the given config. +func NewScaAuthUserDeviceClient(c config) *ScaAuthUserDeviceClient { + return &ScaAuthUserDeviceClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `scaauthuserdevice.Hooks(f(g(h())))`. +func (c *ScaAuthUserDeviceClient) Use(hooks ...Hook) { + c.hooks.ScaAuthUserDevice = append(c.hooks.ScaAuthUserDevice, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `scaauthuserdevice.Intercept(f(g(h())))`. +func (c *ScaAuthUserDeviceClient) Intercept(interceptors ...Interceptor) { + c.inters.ScaAuthUserDevice = append(c.inters.ScaAuthUserDevice, interceptors...) +} + +// Create returns a builder for creating a ScaAuthUserDevice entity. +func (c *ScaAuthUserDeviceClient) Create() *ScaAuthUserDeviceCreate { + mutation := newScaAuthUserDeviceMutation(c.config, OpCreate) + return &ScaAuthUserDeviceCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of ScaAuthUserDevice entities. +func (c *ScaAuthUserDeviceClient) CreateBulk(builders ...*ScaAuthUserDeviceCreate) *ScaAuthUserDeviceCreateBulk { + return &ScaAuthUserDeviceCreateBulk{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 *ScaAuthUserDeviceClient) MapCreateBulk(slice any, setFunc func(*ScaAuthUserDeviceCreate, int)) *ScaAuthUserDeviceCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &ScaAuthUserDeviceCreateBulk{err: fmt.Errorf("calling to ScaAuthUserDeviceClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*ScaAuthUserDeviceCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &ScaAuthUserDeviceCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for ScaAuthUserDevice. +func (c *ScaAuthUserDeviceClient) Update() *ScaAuthUserDeviceUpdate { + mutation := newScaAuthUserDeviceMutation(c.config, OpUpdate) + return &ScaAuthUserDeviceUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *ScaAuthUserDeviceClient) UpdateOne(saud *ScaAuthUserDevice) *ScaAuthUserDeviceUpdateOne { + mutation := newScaAuthUserDeviceMutation(c.config, OpUpdateOne, withScaAuthUserDevice(saud)) + return &ScaAuthUserDeviceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *ScaAuthUserDeviceClient) UpdateOneID(id int64) *ScaAuthUserDeviceUpdateOne { + mutation := newScaAuthUserDeviceMutation(c.config, OpUpdateOne, withScaAuthUserDeviceID(id)) + return &ScaAuthUserDeviceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for ScaAuthUserDevice. +func (c *ScaAuthUserDeviceClient) Delete() *ScaAuthUserDeviceDelete { + mutation := newScaAuthUserDeviceMutation(c.config, OpDelete) + return &ScaAuthUserDeviceDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *ScaAuthUserDeviceClient) DeleteOne(saud *ScaAuthUserDevice) *ScaAuthUserDeviceDeleteOne { + return c.DeleteOneID(saud.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *ScaAuthUserDeviceClient) DeleteOneID(id int64) *ScaAuthUserDeviceDeleteOne { + builder := c.Delete().Where(scaauthuserdevice.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &ScaAuthUserDeviceDeleteOne{builder} +} + +// Query returns a query builder for ScaAuthUserDevice. +func (c *ScaAuthUserDeviceClient) Query() *ScaAuthUserDeviceQuery { + return &ScaAuthUserDeviceQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeScaAuthUserDevice}, + inters: c.Interceptors(), + } +} + +// Get returns a ScaAuthUserDevice entity by its id. +func (c *ScaAuthUserDeviceClient) Get(ctx context.Context, id int64) (*ScaAuthUserDevice, error) { + return c.Query().Where(scaauthuserdevice.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *ScaAuthUserDeviceClient) GetX(ctx context.Context, id int64) *ScaAuthUserDevice { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryScaAuthUser queries the sca_auth_user edge of a ScaAuthUserDevice. +func (c *ScaAuthUserDeviceClient) QueryScaAuthUser(saud *ScaAuthUserDevice) *ScaAuthUserQuery { + query := (&ScaAuthUserClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := saud.ID + step := sqlgraph.NewStep( + sqlgraph.From(scaauthuserdevice.Table, scaauthuserdevice.FieldID, id), + sqlgraph.To(scaauthuser.Table, scaauthuser.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, scaauthuserdevice.ScaAuthUserTable, scaauthuserdevice.ScaAuthUserColumn), + ) + fromV = sqlgraph.Neighbors(saud.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *ScaAuthUserDeviceClient) Hooks() []Hook { + return c.hooks.ScaAuthUserDevice +} + +// Interceptors returns the client interceptors. +func (c *ScaAuthUserDeviceClient) Interceptors() []Interceptor { + return c.inters.ScaAuthUserDevice +} + +func (c *ScaAuthUserDeviceClient) mutate(ctx context.Context, m *ScaAuthUserDeviceMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&ScaAuthUserDeviceCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&ScaAuthUserDeviceUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&ScaAuthUserDeviceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&ScaAuthUserDeviceDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown ScaAuthUserDevice mutation op: %q", m.Op()) + } +} + +// ScaAuthUserSocialClient is a client for the ScaAuthUserSocial schema. +type ScaAuthUserSocialClient struct { + config +} + +// NewScaAuthUserSocialClient returns a client for the ScaAuthUserSocial from the given config. +func NewScaAuthUserSocialClient(c config) *ScaAuthUserSocialClient { + return &ScaAuthUserSocialClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `scaauthusersocial.Hooks(f(g(h())))`. +func (c *ScaAuthUserSocialClient) Use(hooks ...Hook) { + c.hooks.ScaAuthUserSocial = append(c.hooks.ScaAuthUserSocial, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `scaauthusersocial.Intercept(f(g(h())))`. +func (c *ScaAuthUserSocialClient) Intercept(interceptors ...Interceptor) { + c.inters.ScaAuthUserSocial = append(c.inters.ScaAuthUserSocial, interceptors...) +} + +// Create returns a builder for creating a ScaAuthUserSocial entity. +func (c *ScaAuthUserSocialClient) Create() *ScaAuthUserSocialCreate { + mutation := newScaAuthUserSocialMutation(c.config, OpCreate) + return &ScaAuthUserSocialCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of ScaAuthUserSocial entities. +func (c *ScaAuthUserSocialClient) CreateBulk(builders ...*ScaAuthUserSocialCreate) *ScaAuthUserSocialCreateBulk { + return &ScaAuthUserSocialCreateBulk{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 *ScaAuthUserSocialClient) MapCreateBulk(slice any, setFunc func(*ScaAuthUserSocialCreate, int)) *ScaAuthUserSocialCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &ScaAuthUserSocialCreateBulk{err: fmt.Errorf("calling to ScaAuthUserSocialClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*ScaAuthUserSocialCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &ScaAuthUserSocialCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for ScaAuthUserSocial. +func (c *ScaAuthUserSocialClient) Update() *ScaAuthUserSocialUpdate { + mutation := newScaAuthUserSocialMutation(c.config, OpUpdate) + return &ScaAuthUserSocialUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *ScaAuthUserSocialClient) UpdateOne(saus *ScaAuthUserSocial) *ScaAuthUserSocialUpdateOne { + mutation := newScaAuthUserSocialMutation(c.config, OpUpdateOne, withScaAuthUserSocial(saus)) + return &ScaAuthUserSocialUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *ScaAuthUserSocialClient) UpdateOneID(id int64) *ScaAuthUserSocialUpdateOne { + mutation := newScaAuthUserSocialMutation(c.config, OpUpdateOne, withScaAuthUserSocialID(id)) + return &ScaAuthUserSocialUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for ScaAuthUserSocial. +func (c *ScaAuthUserSocialClient) Delete() *ScaAuthUserSocialDelete { + mutation := newScaAuthUserSocialMutation(c.config, OpDelete) + return &ScaAuthUserSocialDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *ScaAuthUserSocialClient) DeleteOne(saus *ScaAuthUserSocial) *ScaAuthUserSocialDeleteOne { + return c.DeleteOneID(saus.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *ScaAuthUserSocialClient) DeleteOneID(id int64) *ScaAuthUserSocialDeleteOne { + builder := c.Delete().Where(scaauthusersocial.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &ScaAuthUserSocialDeleteOne{builder} +} + +// Query returns a query builder for ScaAuthUserSocial. +func (c *ScaAuthUserSocialClient) Query() *ScaAuthUserSocialQuery { + return &ScaAuthUserSocialQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeScaAuthUserSocial}, + inters: c.Interceptors(), + } +} + +// Get returns a ScaAuthUserSocial entity by its id. +func (c *ScaAuthUserSocialClient) Get(ctx context.Context, id int64) (*ScaAuthUserSocial, error) { + return c.Query().Where(scaauthusersocial.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *ScaAuthUserSocialClient) GetX(ctx context.Context, id int64) *ScaAuthUserSocial { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryScaAuthUser queries the sca_auth_user edge of a ScaAuthUserSocial. +func (c *ScaAuthUserSocialClient) QueryScaAuthUser(saus *ScaAuthUserSocial) *ScaAuthUserQuery { + query := (&ScaAuthUserClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := saus.ID + step := sqlgraph.NewStep( + sqlgraph.From(scaauthusersocial.Table, scaauthusersocial.FieldID, id), + sqlgraph.To(scaauthuser.Table, scaauthuser.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, scaauthusersocial.ScaAuthUserTable, scaauthusersocial.ScaAuthUserColumn), + ) + fromV = sqlgraph.Neighbors(saus.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *ScaAuthUserSocialClient) Hooks() []Hook { + return c.hooks.ScaAuthUserSocial +} + +// Interceptors returns the client interceptors. +func (c *ScaAuthUserSocialClient) Interceptors() []Interceptor { + return c.inters.ScaAuthUserSocial +} + +func (c *ScaAuthUserSocialClient) mutate(ctx context.Context, m *ScaAuthUserSocialMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&ScaAuthUserSocialCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&ScaAuthUserSocialUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&ScaAuthUserSocialUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&ScaAuthUserSocialDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown ScaAuthUserSocial mutation op: %q", m.Op()) + } +} + +// hooks and interceptors per client, for fast access. +type ( + hooks struct { + ScaAuthPermissionRule, ScaAuthRole, ScaAuthUser, ScaAuthUserDevice, + ScaAuthUserSocial []ent.Hook + } + inters struct { + ScaAuthPermissionRule, ScaAuthRole, ScaAuthUser, ScaAuthUserDevice, + ScaAuthUserSocial []ent.Interceptor + } +) diff --git a/common/ent/ent.go b/common/ent/ent.go new file mode 100644 index 0000000..7d942c4 --- /dev/null +++ b/common/ent/ent.go @@ -0,0 +1,616 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "reflect" + "schisandra-album-cloud-microservices/common/ent/scaauthpermissionrule" + "schisandra-album-cloud-microservices/common/ent/scaauthrole" + "schisandra-album-cloud-microservices/common/ent/scaauthuser" + "schisandra-album-cloud-microservices/common/ent/scaauthuserdevice" + "schisandra-album-cloud-microservices/common/ent/scaauthusersocial" + "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(table, column string) error { + initCheck.Do(func() { + columnCheck = sql.NewColumnCheck(map[string]func(string) bool{ + scaauthpermissionrule.Table: scaauthpermissionrule.ValidColumn, + scaauthrole.Table: scaauthrole.ValidColumn, + scaauthuser.Table: scaauthuser.ValidColumn, + scaauthuserdevice.Table: scaauthuserdevice.ValidColumn, + scaauthusersocial.Table: scaauthusersocial.ValidColumn, + }) + }) + return columnCheck(table, column) +} + +// 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/common/ent/enttest/enttest.go b/common/ent/enttest/enttest.go new file mode 100644 index 0000000..6783921 --- /dev/null +++ b/common/ent/enttest/enttest.go @@ -0,0 +1,85 @@ +// Code generated by ent, DO NOT EDIT. + +package enttest + +import ( + "context" + + "schisandra-album-cloud-microservices/common/ent" + // required by schema hooks. + _ "schisandra-album-cloud-microservices/common/ent/runtime" + + "schisandra-album-cloud-microservices/common/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/common/ent/generate.go b/common/ent/generate.go new file mode 100644 index 0000000..8d3fdfd --- /dev/null +++ b/common/ent/generate.go @@ -0,0 +1,3 @@ +package ent + +//go:generate go run -mod=mod entgo.io/ent/cmd/ent generate ./schema diff --git a/common/ent/hook/hook.go b/common/ent/hook/hook.go new file mode 100644 index 0000000..8c8fb07 --- /dev/null +++ b/common/ent/hook/hook.go @@ -0,0 +1,246 @@ +// Code generated by ent, DO NOT EDIT. + +package hook + +import ( + "context" + "fmt" + "schisandra-album-cloud-microservices/common/ent" +) + +// The ScaAuthPermissionRuleFunc type is an adapter to allow the use of ordinary +// function as ScaAuthPermissionRule mutator. +type ScaAuthPermissionRuleFunc func(context.Context, *ent.ScaAuthPermissionRuleMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f ScaAuthPermissionRuleFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.ScaAuthPermissionRuleMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ScaAuthPermissionRuleMutation", m) +} + +// The ScaAuthRoleFunc type is an adapter to allow the use of ordinary +// function as ScaAuthRole mutator. +type ScaAuthRoleFunc func(context.Context, *ent.ScaAuthRoleMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f ScaAuthRoleFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.ScaAuthRoleMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ScaAuthRoleMutation", m) +} + +// The ScaAuthUserFunc type is an adapter to allow the use of ordinary +// function as ScaAuthUser mutator. +type ScaAuthUserFunc func(context.Context, *ent.ScaAuthUserMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f ScaAuthUserFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.ScaAuthUserMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ScaAuthUserMutation", m) +} + +// The ScaAuthUserDeviceFunc type is an adapter to allow the use of ordinary +// function as ScaAuthUserDevice mutator. +type ScaAuthUserDeviceFunc func(context.Context, *ent.ScaAuthUserDeviceMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f ScaAuthUserDeviceFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.ScaAuthUserDeviceMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ScaAuthUserDeviceMutation", m) +} + +// The ScaAuthUserSocialFunc type is an adapter to allow the use of ordinary +// function as ScaAuthUserSocial mutator. +type ScaAuthUserSocialFunc func(context.Context, *ent.ScaAuthUserSocialMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f ScaAuthUserSocialFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.ScaAuthUserSocialMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ScaAuthUserSocialMutation", 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/common/ent/migrate/migrate.go b/common/ent/migrate/migrate.go new file mode 100644 index 0000000..1956a6b --- /dev/null +++ b/common/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/common/ent/migrate/schema.go b/common/ent/migrate/schema.go new file mode 100644 index 0000000..3499fa9 --- /dev/null +++ b/common/ent/migrate/schema.go @@ -0,0 +1,184 @@ +// Code generated by ent, DO NOT EDIT. + +package migrate + +import ( + "entgo.io/ent/dialect/sql/schema" + "entgo.io/ent/schema/field" +) + +var ( + // ScaAuthPermissionRulesColumns holds the columns for the "sca_auth_permission_rules" table. + ScaAuthPermissionRulesColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt64, Increment: true, SchemaType: map[string]string{"mysql": "bigint(20) unsigned"}}, + {Name: "ptype", Type: field.TypeString, Size: 100}, + {Name: "v0", Type: field.TypeString, Size: 100}, + {Name: "v1", Type: field.TypeString, Size: 100}, + {Name: "v2", Type: field.TypeString, Nullable: true, Size: 100}, + {Name: "v3", Type: field.TypeString, Nullable: true, Size: 100}, + {Name: "v4", Type: field.TypeString, Nullable: true, Size: 100}, + {Name: "v5", Type: field.TypeString, Nullable: true, Size: 100}, + {Name: "sca_auth_role_sca_auth_permission_rule", Type: field.TypeInt64, Nullable: true, SchemaType: map[string]string{"mysql": "bigint(20)"}}, + } + // ScaAuthPermissionRulesTable holds the schema information for the "sca_auth_permission_rules" table. + ScaAuthPermissionRulesTable = &schema.Table{ + Name: "sca_auth_permission_rules", + Columns: ScaAuthPermissionRulesColumns, + PrimaryKey: []*schema.Column{ScaAuthPermissionRulesColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "sca_auth_permission_rules_sca_auth_roles_sca_auth_permission_rule", + Columns: []*schema.Column{ScaAuthPermissionRulesColumns[8]}, + RefColumns: []*schema.Column{ScaAuthRolesColumns[0]}, + OnDelete: schema.SetNull, + }, + }, + } + // ScaAuthRolesColumns holds the columns for the "sca_auth_roles" table. + ScaAuthRolesColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt64, Increment: true, SchemaType: map[string]string{"mysql": "bigint(20)"}}, + {Name: "role_name", Type: field.TypeString, Size: 32}, + {Name: "role_key", Type: field.TypeString, Size: 64}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "update_at", Type: field.TypeTime}, + {Name: "deleted", Type: field.TypeInt, Default: 0}, + } + // ScaAuthRolesTable holds the schema information for the "sca_auth_roles" table. + ScaAuthRolesTable = &schema.Table{ + Name: "sca_auth_roles", + Columns: ScaAuthRolesColumns, + PrimaryKey: []*schema.Column{ScaAuthRolesColumns[0]}, + } + // ScaAuthUsersColumns holds the columns for the "sca_auth_users" table. + ScaAuthUsersColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt64, Increment: true, SchemaType: map[string]string{"mysql": "bigint(20)"}}, + {Name: "uid", Type: field.TypeString, Unique: true, Size: 20}, + {Name: "username", Type: field.TypeString, Nullable: true, Size: 32}, + {Name: "nickname", Type: field.TypeString, Nullable: true, Size: 32}, + {Name: "email", Type: field.TypeString, Nullable: true, Size: 32}, + {Name: "phone", Type: field.TypeString, Nullable: true, Size: 32}, + {Name: "password", Type: field.TypeString, Nullable: true, Size: 64}, + {Name: "gender", Type: field.TypeString, Nullable: true, Size: 32}, + {Name: "avatar", Type: field.TypeString, Nullable: true}, + {Name: "status", Type: field.TypeInt8, Nullable: true, Default: 0}, + {Name: "introduce", Type: field.TypeString, Nullable: true, Size: 255}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "update_at", Type: field.TypeTime, Nullable: true}, + {Name: "deleted", Type: field.TypeInt8, Default: 0}, + {Name: "blog", Type: field.TypeString, Nullable: true, Size: 30}, + {Name: "location", Type: field.TypeString, Nullable: true, Size: 50}, + {Name: "company", Type: field.TypeString, Nullable: true, Size: 50}, + } + // ScaAuthUsersTable holds the schema information for the "sca_auth_users" table. + ScaAuthUsersTable = &schema.Table{ + Name: "sca_auth_users", + Columns: ScaAuthUsersColumns, + PrimaryKey: []*schema.Column{ScaAuthUsersColumns[0]}, + Indexes: []*schema.Index{ + { + Name: "scaauthuser_id", + Unique: true, + Columns: []*schema.Column{ScaAuthUsersColumns[0]}, + }, + { + Name: "scaauthuser_uid", + Unique: true, + Columns: []*schema.Column{ScaAuthUsersColumns[1]}, + }, + { + Name: "scaauthuser_phone", + Unique: true, + Columns: []*schema.Column{ScaAuthUsersColumns[5]}, + }, + }, + } + // ScaAuthUserDevicesColumns holds the columns for the "sca_auth_user_devices" table. + ScaAuthUserDevicesColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt64, Increment: true, SchemaType: map[string]string{"mysql": "bigint(20)"}}, + {Name: "user_id", Type: field.TypeString, Size: 20}, + {Name: "ip", Type: field.TypeString, Size: 20}, + {Name: "location", Type: field.TypeString, Size: 20}, + {Name: "agent", Type: field.TypeString, Size: 255}, + {Name: "created_at", Type: field.TypeTime, Nullable: true}, + {Name: "update_at", Type: field.TypeTime}, + {Name: "deleted", Type: field.TypeInt, Default: 0}, + {Name: "browser", Type: field.TypeString, Size: 20}, + {Name: "operating_system", Type: field.TypeString, Size: 20}, + {Name: "browser_version", Type: field.TypeString, Size: 20}, + {Name: "mobile", Type: field.TypeInt}, + {Name: "bot", Type: field.TypeInt}, + {Name: "mozilla", Type: field.TypeString, Size: 10}, + {Name: "platform", Type: field.TypeString, Size: 20}, + {Name: "engine_name", Type: field.TypeString, Size: 20}, + {Name: "engine_version", Type: field.TypeString, Size: 20}, + {Name: "sca_auth_user_sca_auth_user_device", Type: field.TypeInt64, Nullable: true, SchemaType: map[string]string{"mysql": "bigint(20)"}}, + } + // ScaAuthUserDevicesTable holds the schema information for the "sca_auth_user_devices" table. + ScaAuthUserDevicesTable = &schema.Table{ + Name: "sca_auth_user_devices", + Columns: ScaAuthUserDevicesColumns, + PrimaryKey: []*schema.Column{ScaAuthUserDevicesColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "sca_auth_user_devices_sca_auth_users_sca_auth_user_device", + Columns: []*schema.Column{ScaAuthUserDevicesColumns[17]}, + RefColumns: []*schema.Column{ScaAuthUsersColumns[0]}, + OnDelete: schema.SetNull, + }, + }, + Indexes: []*schema.Index{ + { + Name: "scaauthuserdevice_id", + Unique: true, + Columns: []*schema.Column{ScaAuthUserDevicesColumns[0]}, + }, + }, + } + // ScaAuthUserSocialsColumns holds the columns for the "sca_auth_user_socials" table. + ScaAuthUserSocialsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt64, Increment: true, SchemaType: map[string]string{"mysql": "bigint(20)"}}, + {Name: "user_id", Type: field.TypeString, Size: 20}, + {Name: "open_id", Type: field.TypeString, Size: 50}, + {Name: "source", Type: field.TypeString, Size: 10}, + {Name: "status", Type: field.TypeInt, Default: 0}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "update_at", Type: field.TypeTime, Nullable: true}, + {Name: "deleted", Type: field.TypeInt, Default: 0}, + {Name: "sca_auth_user_sca_auth_user_social", Type: field.TypeInt64, Nullable: true, SchemaType: map[string]string{"mysql": "bigint(20)"}}, + } + // ScaAuthUserSocialsTable holds the schema information for the "sca_auth_user_socials" table. + ScaAuthUserSocialsTable = &schema.Table{ + Name: "sca_auth_user_socials", + Columns: ScaAuthUserSocialsColumns, + PrimaryKey: []*schema.Column{ScaAuthUserSocialsColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "sca_auth_user_socials_sca_auth_users_sca_auth_user_social", + Columns: []*schema.Column{ScaAuthUserSocialsColumns[8]}, + RefColumns: []*schema.Column{ScaAuthUsersColumns[0]}, + OnDelete: schema.SetNull, + }, + }, + Indexes: []*schema.Index{ + { + Name: "scaauthusersocial_id_user_id_open_id", + Unique: true, + Columns: []*schema.Column{ScaAuthUserSocialsColumns[0], ScaAuthUserSocialsColumns[1], ScaAuthUserSocialsColumns[2]}, + }, + }, + } + // Tables holds all the tables in the schema. + Tables = []*schema.Table{ + ScaAuthPermissionRulesTable, + ScaAuthRolesTable, + ScaAuthUsersTable, + ScaAuthUserDevicesTable, + ScaAuthUserSocialsTable, + } +) + +func init() { + ScaAuthPermissionRulesTable.ForeignKeys[0].RefTable = ScaAuthRolesTable + ScaAuthUserDevicesTable.ForeignKeys[0].RefTable = ScaAuthUsersTable + ScaAuthUserSocialsTable.ForeignKeys[0].RefTable = ScaAuthUsersTable +} diff --git a/common/ent/mutation.go b/common/ent/mutation.go new file mode 100644 index 0000000..7f34748 --- /dev/null +++ b/common/ent/mutation.go @@ -0,0 +1,5300 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "schisandra-album-cloud-microservices/common/ent/predicate" + "schisandra-album-cloud-microservices/common/ent/scaauthpermissionrule" + "schisandra-album-cloud-microservices/common/ent/scaauthrole" + "schisandra-album-cloud-microservices/common/ent/scaauthuser" + "schisandra-album-cloud-microservices/common/ent/scaauthuserdevice" + "schisandra-album-cloud-microservices/common/ent/scaauthusersocial" + "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. + TypeScaAuthPermissionRule = "ScaAuthPermissionRule" + TypeScaAuthRole = "ScaAuthRole" + TypeScaAuthUser = "ScaAuthUser" + TypeScaAuthUserDevice = "ScaAuthUserDevice" + TypeScaAuthUserSocial = "ScaAuthUserSocial" +) + +// ScaAuthPermissionRuleMutation represents an operation that mutates the ScaAuthPermissionRule nodes in the graph. +type ScaAuthPermissionRuleMutation struct { + config + op Op + typ string + id *int64 + ptype *string + v0 *string + v1 *string + v2 *string + v3 *string + v4 *string + v5 *string + clearedFields map[string]struct{} + sca_auth_role *int64 + clearedsca_auth_role bool + done bool + oldValue func(context.Context) (*ScaAuthPermissionRule, error) + predicates []predicate.ScaAuthPermissionRule +} + +var _ ent.Mutation = (*ScaAuthPermissionRuleMutation)(nil) + +// scaauthpermissionruleOption allows management of the mutation configuration using functional options. +type scaauthpermissionruleOption func(*ScaAuthPermissionRuleMutation) + +// newScaAuthPermissionRuleMutation creates new mutation for the ScaAuthPermissionRule entity. +func newScaAuthPermissionRuleMutation(c config, op Op, opts ...scaauthpermissionruleOption) *ScaAuthPermissionRuleMutation { + m := &ScaAuthPermissionRuleMutation{ + config: c, + op: op, + typ: TypeScaAuthPermissionRule, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withScaAuthPermissionRuleID sets the ID field of the mutation. +func withScaAuthPermissionRuleID(id int64) scaauthpermissionruleOption { + return func(m *ScaAuthPermissionRuleMutation) { + var ( + err error + once sync.Once + value *ScaAuthPermissionRule + ) + m.oldValue = func(ctx context.Context) (*ScaAuthPermissionRule, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().ScaAuthPermissionRule.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withScaAuthPermissionRule sets the old ScaAuthPermissionRule of the mutation. +func withScaAuthPermissionRule(node *ScaAuthPermissionRule) scaauthpermissionruleOption { + return func(m *ScaAuthPermissionRuleMutation) { + m.oldValue = func(context.Context) (*ScaAuthPermissionRule, 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 ScaAuthPermissionRuleMutation) 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 ScaAuthPermissionRuleMutation) 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 ScaAuthPermissionRule entities. +func (m *ScaAuthPermissionRuleMutation) 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 *ScaAuthPermissionRuleMutation) 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 *ScaAuthPermissionRuleMutation) 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().ScaAuthPermissionRule.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetPtype sets the "ptype" field. +func (m *ScaAuthPermissionRuleMutation) SetPtype(s string) { + m.ptype = &s +} + +// Ptype returns the value of the "ptype" field in the mutation. +func (m *ScaAuthPermissionRuleMutation) Ptype() (r string, exists bool) { + v := m.ptype + if v == nil { + return + } + return *v, true +} + +// OldPtype returns the old "ptype" field's value of the ScaAuthPermissionRule entity. +// If the ScaAuthPermissionRule 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 *ScaAuthPermissionRuleMutation) OldPtype(ctx context.Context) (v *string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPtype is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPtype requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPtype: %w", err) + } + return oldValue.Ptype, nil +} + +// ResetPtype resets all changes to the "ptype" field. +func (m *ScaAuthPermissionRuleMutation) ResetPtype() { + m.ptype = nil +} + +// SetV0 sets the "v0" field. +func (m *ScaAuthPermissionRuleMutation) SetV0(s string) { + m.v0 = &s +} + +// V0 returns the value of the "v0" field in the mutation. +func (m *ScaAuthPermissionRuleMutation) V0() (r string, exists bool) { + v := m.v0 + if v == nil { + return + } + return *v, true +} + +// OldV0 returns the old "v0" field's value of the ScaAuthPermissionRule entity. +// If the ScaAuthPermissionRule 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 *ScaAuthPermissionRuleMutation) OldV0(ctx context.Context) (v *string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldV0 is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldV0 requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldV0: %w", err) + } + return oldValue.V0, nil +} + +// ResetV0 resets all changes to the "v0" field. +func (m *ScaAuthPermissionRuleMutation) ResetV0() { + m.v0 = nil +} + +// SetV1 sets the "v1" field. +func (m *ScaAuthPermissionRuleMutation) SetV1(s string) { + m.v1 = &s +} + +// V1 returns the value of the "v1" field in the mutation. +func (m *ScaAuthPermissionRuleMutation) V1() (r string, exists bool) { + v := m.v1 + if v == nil { + return + } + return *v, true +} + +// OldV1 returns the old "v1" field's value of the ScaAuthPermissionRule entity. +// If the ScaAuthPermissionRule 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 *ScaAuthPermissionRuleMutation) OldV1(ctx context.Context) (v *string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldV1 is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldV1 requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldV1: %w", err) + } + return oldValue.V1, nil +} + +// ResetV1 resets all changes to the "v1" field. +func (m *ScaAuthPermissionRuleMutation) ResetV1() { + m.v1 = nil +} + +// SetV2 sets the "v2" field. +func (m *ScaAuthPermissionRuleMutation) SetV2(s string) { + m.v2 = &s +} + +// V2 returns the value of the "v2" field in the mutation. +func (m *ScaAuthPermissionRuleMutation) V2() (r string, exists bool) { + v := m.v2 + if v == nil { + return + } + return *v, true +} + +// OldV2 returns the old "v2" field's value of the ScaAuthPermissionRule entity. +// If the ScaAuthPermissionRule 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 *ScaAuthPermissionRuleMutation) OldV2(ctx context.Context) (v *string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldV2 is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldV2 requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldV2: %w", err) + } + return oldValue.V2, nil +} + +// ClearV2 clears the value of the "v2" field. +func (m *ScaAuthPermissionRuleMutation) ClearV2() { + m.v2 = nil + m.clearedFields[scaauthpermissionrule.FieldV2] = struct{}{} +} + +// V2Cleared returns if the "v2" field was cleared in this mutation. +func (m *ScaAuthPermissionRuleMutation) V2Cleared() bool { + _, ok := m.clearedFields[scaauthpermissionrule.FieldV2] + return ok +} + +// ResetV2 resets all changes to the "v2" field. +func (m *ScaAuthPermissionRuleMutation) ResetV2() { + m.v2 = nil + delete(m.clearedFields, scaauthpermissionrule.FieldV2) +} + +// SetV3 sets the "v3" field. +func (m *ScaAuthPermissionRuleMutation) SetV3(s string) { + m.v3 = &s +} + +// V3 returns the value of the "v3" field in the mutation. +func (m *ScaAuthPermissionRuleMutation) V3() (r string, exists bool) { + v := m.v3 + if v == nil { + return + } + return *v, true +} + +// OldV3 returns the old "v3" field's value of the ScaAuthPermissionRule entity. +// If the ScaAuthPermissionRule 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 *ScaAuthPermissionRuleMutation) OldV3(ctx context.Context) (v *string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldV3 is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldV3 requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldV3: %w", err) + } + return oldValue.V3, nil +} + +// ClearV3 clears the value of the "v3" field. +func (m *ScaAuthPermissionRuleMutation) ClearV3() { + m.v3 = nil + m.clearedFields[scaauthpermissionrule.FieldV3] = struct{}{} +} + +// V3Cleared returns if the "v3" field was cleared in this mutation. +func (m *ScaAuthPermissionRuleMutation) V3Cleared() bool { + _, ok := m.clearedFields[scaauthpermissionrule.FieldV3] + return ok +} + +// ResetV3 resets all changes to the "v3" field. +func (m *ScaAuthPermissionRuleMutation) ResetV3() { + m.v3 = nil + delete(m.clearedFields, scaauthpermissionrule.FieldV3) +} + +// SetV4 sets the "v4" field. +func (m *ScaAuthPermissionRuleMutation) SetV4(s string) { + m.v4 = &s +} + +// V4 returns the value of the "v4" field in the mutation. +func (m *ScaAuthPermissionRuleMutation) V4() (r string, exists bool) { + v := m.v4 + if v == nil { + return + } + return *v, true +} + +// OldV4 returns the old "v4" field's value of the ScaAuthPermissionRule entity. +// If the ScaAuthPermissionRule 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 *ScaAuthPermissionRuleMutation) OldV4(ctx context.Context) (v *string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldV4 is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldV4 requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldV4: %w", err) + } + return oldValue.V4, nil +} + +// ClearV4 clears the value of the "v4" field. +func (m *ScaAuthPermissionRuleMutation) ClearV4() { + m.v4 = nil + m.clearedFields[scaauthpermissionrule.FieldV4] = struct{}{} +} + +// V4Cleared returns if the "v4" field was cleared in this mutation. +func (m *ScaAuthPermissionRuleMutation) V4Cleared() bool { + _, ok := m.clearedFields[scaauthpermissionrule.FieldV4] + return ok +} + +// ResetV4 resets all changes to the "v4" field. +func (m *ScaAuthPermissionRuleMutation) ResetV4() { + m.v4 = nil + delete(m.clearedFields, scaauthpermissionrule.FieldV4) +} + +// SetV5 sets the "v5" field. +func (m *ScaAuthPermissionRuleMutation) SetV5(s string) { + m.v5 = &s +} + +// V5 returns the value of the "v5" field in the mutation. +func (m *ScaAuthPermissionRuleMutation) V5() (r string, exists bool) { + v := m.v5 + if v == nil { + return + } + return *v, true +} + +// OldV5 returns the old "v5" field's value of the ScaAuthPermissionRule entity. +// If the ScaAuthPermissionRule 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 *ScaAuthPermissionRuleMutation) OldV5(ctx context.Context) (v *string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldV5 is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldV5 requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldV5: %w", err) + } + return oldValue.V5, nil +} + +// ClearV5 clears the value of the "v5" field. +func (m *ScaAuthPermissionRuleMutation) ClearV5() { + m.v5 = nil + m.clearedFields[scaauthpermissionrule.FieldV5] = struct{}{} +} + +// V5Cleared returns if the "v5" field was cleared in this mutation. +func (m *ScaAuthPermissionRuleMutation) V5Cleared() bool { + _, ok := m.clearedFields[scaauthpermissionrule.FieldV5] + return ok +} + +// ResetV5 resets all changes to the "v5" field. +func (m *ScaAuthPermissionRuleMutation) ResetV5() { + m.v5 = nil + delete(m.clearedFields, scaauthpermissionrule.FieldV5) +} + +// SetScaAuthRoleID sets the "sca_auth_role" edge to the ScaAuthRole entity by id. +func (m *ScaAuthPermissionRuleMutation) SetScaAuthRoleID(id int64) { + m.sca_auth_role = &id +} + +// ClearScaAuthRole clears the "sca_auth_role" edge to the ScaAuthRole entity. +func (m *ScaAuthPermissionRuleMutation) ClearScaAuthRole() { + m.clearedsca_auth_role = true +} + +// ScaAuthRoleCleared reports if the "sca_auth_role" edge to the ScaAuthRole entity was cleared. +func (m *ScaAuthPermissionRuleMutation) ScaAuthRoleCleared() bool { + return m.clearedsca_auth_role +} + +// ScaAuthRoleID returns the "sca_auth_role" edge ID in the mutation. +func (m *ScaAuthPermissionRuleMutation) ScaAuthRoleID() (id int64, exists bool) { + if m.sca_auth_role != nil { + return *m.sca_auth_role, true + } + return +} + +// ScaAuthRoleIDs returns the "sca_auth_role" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// ScaAuthRoleID instead. It exists only for internal usage by the builders. +func (m *ScaAuthPermissionRuleMutation) ScaAuthRoleIDs() (ids []int64) { + if id := m.sca_auth_role; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetScaAuthRole resets all changes to the "sca_auth_role" edge. +func (m *ScaAuthPermissionRuleMutation) ResetScaAuthRole() { + m.sca_auth_role = nil + m.clearedsca_auth_role = false +} + +// Where appends a list predicates to the ScaAuthPermissionRuleMutation builder. +func (m *ScaAuthPermissionRuleMutation) Where(ps ...predicate.ScaAuthPermissionRule) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the ScaAuthPermissionRuleMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *ScaAuthPermissionRuleMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.ScaAuthPermissionRule, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *ScaAuthPermissionRuleMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *ScaAuthPermissionRuleMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (ScaAuthPermissionRule). +func (m *ScaAuthPermissionRuleMutation) 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 *ScaAuthPermissionRuleMutation) Fields() []string { + fields := make([]string, 0, 7) + if m.ptype != nil { + fields = append(fields, scaauthpermissionrule.FieldPtype) + } + if m.v0 != nil { + fields = append(fields, scaauthpermissionrule.FieldV0) + } + if m.v1 != nil { + fields = append(fields, scaauthpermissionrule.FieldV1) + } + if m.v2 != nil { + fields = append(fields, scaauthpermissionrule.FieldV2) + } + if m.v3 != nil { + fields = append(fields, scaauthpermissionrule.FieldV3) + } + if m.v4 != nil { + fields = append(fields, scaauthpermissionrule.FieldV4) + } + if m.v5 != nil { + fields = append(fields, scaauthpermissionrule.FieldV5) + } + 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 *ScaAuthPermissionRuleMutation) Field(name string) (ent.Value, bool) { + switch name { + case scaauthpermissionrule.FieldPtype: + return m.Ptype() + case scaauthpermissionrule.FieldV0: + return m.V0() + case scaauthpermissionrule.FieldV1: + return m.V1() + case scaauthpermissionrule.FieldV2: + return m.V2() + case scaauthpermissionrule.FieldV3: + return m.V3() + case scaauthpermissionrule.FieldV4: + return m.V4() + case scaauthpermissionrule.FieldV5: + return m.V5() + } + 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 *ScaAuthPermissionRuleMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case scaauthpermissionrule.FieldPtype: + return m.OldPtype(ctx) + case scaauthpermissionrule.FieldV0: + return m.OldV0(ctx) + case scaauthpermissionrule.FieldV1: + return m.OldV1(ctx) + case scaauthpermissionrule.FieldV2: + return m.OldV2(ctx) + case scaauthpermissionrule.FieldV3: + return m.OldV3(ctx) + case scaauthpermissionrule.FieldV4: + return m.OldV4(ctx) + case scaauthpermissionrule.FieldV5: + return m.OldV5(ctx) + } + return nil, fmt.Errorf("unknown ScaAuthPermissionRule 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 *ScaAuthPermissionRuleMutation) SetField(name string, value ent.Value) error { + switch name { + case scaauthpermissionrule.FieldPtype: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPtype(v) + return nil + case scaauthpermissionrule.FieldV0: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetV0(v) + return nil + case scaauthpermissionrule.FieldV1: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetV1(v) + return nil + case scaauthpermissionrule.FieldV2: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetV2(v) + return nil + case scaauthpermissionrule.FieldV3: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetV3(v) + return nil + case scaauthpermissionrule.FieldV4: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetV4(v) + return nil + case scaauthpermissionrule.FieldV5: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetV5(v) + return nil + } + return fmt.Errorf("unknown ScaAuthPermissionRule field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *ScaAuthPermissionRuleMutation) 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 *ScaAuthPermissionRuleMutation) 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 *ScaAuthPermissionRuleMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown ScaAuthPermissionRule numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *ScaAuthPermissionRuleMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(scaauthpermissionrule.FieldV2) { + fields = append(fields, scaauthpermissionrule.FieldV2) + } + if m.FieldCleared(scaauthpermissionrule.FieldV3) { + fields = append(fields, scaauthpermissionrule.FieldV3) + } + if m.FieldCleared(scaauthpermissionrule.FieldV4) { + fields = append(fields, scaauthpermissionrule.FieldV4) + } + if m.FieldCleared(scaauthpermissionrule.FieldV5) { + fields = append(fields, scaauthpermissionrule.FieldV5) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *ScaAuthPermissionRuleMutation) 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 *ScaAuthPermissionRuleMutation) ClearField(name string) error { + switch name { + case scaauthpermissionrule.FieldV2: + m.ClearV2() + return nil + case scaauthpermissionrule.FieldV3: + m.ClearV3() + return nil + case scaauthpermissionrule.FieldV4: + m.ClearV4() + return nil + case scaauthpermissionrule.FieldV5: + m.ClearV5() + return nil + } + return fmt.Errorf("unknown ScaAuthPermissionRule 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 *ScaAuthPermissionRuleMutation) ResetField(name string) error { + switch name { + case scaauthpermissionrule.FieldPtype: + m.ResetPtype() + return nil + case scaauthpermissionrule.FieldV0: + m.ResetV0() + return nil + case scaauthpermissionrule.FieldV1: + m.ResetV1() + return nil + case scaauthpermissionrule.FieldV2: + m.ResetV2() + return nil + case scaauthpermissionrule.FieldV3: + m.ResetV3() + return nil + case scaauthpermissionrule.FieldV4: + m.ResetV4() + return nil + case scaauthpermissionrule.FieldV5: + m.ResetV5() + return nil + } + return fmt.Errorf("unknown ScaAuthPermissionRule field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *ScaAuthPermissionRuleMutation) AddedEdges() []string { + edges := make([]string, 0, 1) + if m.sca_auth_role != nil { + edges = append(edges, scaauthpermissionrule.EdgeScaAuthRole) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *ScaAuthPermissionRuleMutation) AddedIDs(name string) []ent.Value { + switch name { + case scaauthpermissionrule.EdgeScaAuthRole: + if id := m.sca_auth_role; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *ScaAuthPermissionRuleMutation) RemovedEdges() []string { + edges := make([]string, 0, 1) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *ScaAuthPermissionRuleMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *ScaAuthPermissionRuleMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) + if m.clearedsca_auth_role { + edges = append(edges, scaauthpermissionrule.EdgeScaAuthRole) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *ScaAuthPermissionRuleMutation) EdgeCleared(name string) bool { + switch name { + case scaauthpermissionrule.EdgeScaAuthRole: + return m.clearedsca_auth_role + } + 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 *ScaAuthPermissionRuleMutation) ClearEdge(name string) error { + switch name { + case scaauthpermissionrule.EdgeScaAuthRole: + m.ClearScaAuthRole() + return nil + } + return fmt.Errorf("unknown ScaAuthPermissionRule 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 *ScaAuthPermissionRuleMutation) ResetEdge(name string) error { + switch name { + case scaauthpermissionrule.EdgeScaAuthRole: + m.ResetScaAuthRole() + return nil + } + return fmt.Errorf("unknown ScaAuthPermissionRule edge %s", name) +} + +// ScaAuthRoleMutation represents an operation that mutates the ScaAuthRole nodes in the graph. +type ScaAuthRoleMutation struct { + config + op Op + typ string + id *int64 + role_name *string + role_key *string + created_at *time.Time + update_at *time.Time + deleted *int + adddeleted *int + clearedFields map[string]struct{} + sca_auth_permission_rule map[int64]struct{} + removedsca_auth_permission_rule map[int64]struct{} + clearedsca_auth_permission_rule bool + done bool + oldValue func(context.Context) (*ScaAuthRole, error) + predicates []predicate.ScaAuthRole +} + +var _ ent.Mutation = (*ScaAuthRoleMutation)(nil) + +// scaauthroleOption allows management of the mutation configuration using functional options. +type scaauthroleOption func(*ScaAuthRoleMutation) + +// newScaAuthRoleMutation creates new mutation for the ScaAuthRole entity. +func newScaAuthRoleMutation(c config, op Op, opts ...scaauthroleOption) *ScaAuthRoleMutation { + m := &ScaAuthRoleMutation{ + config: c, + op: op, + typ: TypeScaAuthRole, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withScaAuthRoleID sets the ID field of the mutation. +func withScaAuthRoleID(id int64) scaauthroleOption { + return func(m *ScaAuthRoleMutation) { + var ( + err error + once sync.Once + value *ScaAuthRole + ) + m.oldValue = func(ctx context.Context) (*ScaAuthRole, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().ScaAuthRole.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withScaAuthRole sets the old ScaAuthRole of the mutation. +func withScaAuthRole(node *ScaAuthRole) scaauthroleOption { + return func(m *ScaAuthRoleMutation) { + m.oldValue = func(context.Context) (*ScaAuthRole, 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 ScaAuthRoleMutation) 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 ScaAuthRoleMutation) 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 ScaAuthRole entities. +func (m *ScaAuthRoleMutation) 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 *ScaAuthRoleMutation) 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 *ScaAuthRoleMutation) 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().ScaAuthRole.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetRoleName sets the "role_name" field. +func (m *ScaAuthRoleMutation) SetRoleName(s string) { + m.role_name = &s +} + +// RoleName returns the value of the "role_name" field in the mutation. +func (m *ScaAuthRoleMutation) RoleName() (r string, exists bool) { + v := m.role_name + if v == nil { + return + } + return *v, true +} + +// OldRoleName returns the old "role_name" field's value of the ScaAuthRole entity. +// If the ScaAuthRole 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 *ScaAuthRoleMutation) OldRoleName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRoleName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRoleName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRoleName: %w", err) + } + return oldValue.RoleName, nil +} + +// ResetRoleName resets all changes to the "role_name" field. +func (m *ScaAuthRoleMutation) ResetRoleName() { + m.role_name = nil +} + +// SetRoleKey sets the "role_key" field. +func (m *ScaAuthRoleMutation) SetRoleKey(s string) { + m.role_key = &s +} + +// RoleKey returns the value of the "role_key" field in the mutation. +func (m *ScaAuthRoleMutation) RoleKey() (r string, exists bool) { + v := m.role_key + if v == nil { + return + } + return *v, true +} + +// OldRoleKey returns the old "role_key" field's value of the ScaAuthRole entity. +// If the ScaAuthRole 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 *ScaAuthRoleMutation) OldRoleKey(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRoleKey is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRoleKey requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRoleKey: %w", err) + } + return oldValue.RoleKey, nil +} + +// ResetRoleKey resets all changes to the "role_key" field. +func (m *ScaAuthRoleMutation) ResetRoleKey() { + m.role_key = nil +} + +// SetCreatedAt sets the "created_at" field. +func (m *ScaAuthRoleMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *ScaAuthRoleMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "created_at" field's value of the ScaAuthRole entity. +// If the ScaAuthRole 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 *ScaAuthRoleMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *ScaAuthRoleMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdateAt sets the "update_at" field. +func (m *ScaAuthRoleMutation) SetUpdateAt(t time.Time) { + m.update_at = &t +} + +// UpdateAt returns the value of the "update_at" field in the mutation. +func (m *ScaAuthRoleMutation) UpdateAt() (r time.Time, exists bool) { + v := m.update_at + if v == nil { + return + } + return *v, true +} + +// OldUpdateAt returns the old "update_at" field's value of the ScaAuthRole entity. +// If the ScaAuthRole 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 *ScaAuthRoleMutation) OldUpdateAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateAt: %w", err) + } + return oldValue.UpdateAt, nil +} + +// ResetUpdateAt resets all changes to the "update_at" field. +func (m *ScaAuthRoleMutation) ResetUpdateAt() { + m.update_at = nil +} + +// SetDeleted sets the "deleted" field. +func (m *ScaAuthRoleMutation) SetDeleted(i int) { + m.deleted = &i + m.adddeleted = nil +} + +// Deleted returns the value of the "deleted" field in the mutation. +func (m *ScaAuthRoleMutation) 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 ScaAuthRole entity. +// If the ScaAuthRole 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 *ScaAuthRoleMutation) 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 *ScaAuthRoleMutation) 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 *ScaAuthRoleMutation) 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 *ScaAuthRoleMutation) ResetDeleted() { + m.deleted = nil + m.adddeleted = nil +} + +// AddScaAuthPermissionRuleIDs adds the "sca_auth_permission_rule" edge to the ScaAuthPermissionRule entity by ids. +func (m *ScaAuthRoleMutation) AddScaAuthPermissionRuleIDs(ids ...int64) { + if m.sca_auth_permission_rule == nil { + m.sca_auth_permission_rule = make(map[int64]struct{}) + } + for i := range ids { + m.sca_auth_permission_rule[ids[i]] = struct{}{} + } +} + +// ClearScaAuthPermissionRule clears the "sca_auth_permission_rule" edge to the ScaAuthPermissionRule entity. +func (m *ScaAuthRoleMutation) ClearScaAuthPermissionRule() { + m.clearedsca_auth_permission_rule = true +} + +// ScaAuthPermissionRuleCleared reports if the "sca_auth_permission_rule" edge to the ScaAuthPermissionRule entity was cleared. +func (m *ScaAuthRoleMutation) ScaAuthPermissionRuleCleared() bool { + return m.clearedsca_auth_permission_rule +} + +// RemoveScaAuthPermissionRuleIDs removes the "sca_auth_permission_rule" edge to the ScaAuthPermissionRule entity by IDs. +func (m *ScaAuthRoleMutation) RemoveScaAuthPermissionRuleIDs(ids ...int64) { + if m.removedsca_auth_permission_rule == nil { + m.removedsca_auth_permission_rule = make(map[int64]struct{}) + } + for i := range ids { + delete(m.sca_auth_permission_rule, ids[i]) + m.removedsca_auth_permission_rule[ids[i]] = struct{}{} + } +} + +// RemovedScaAuthPermissionRule returns the removed IDs of the "sca_auth_permission_rule" edge to the ScaAuthPermissionRule entity. +func (m *ScaAuthRoleMutation) RemovedScaAuthPermissionRuleIDs() (ids []int64) { + for id := range m.removedsca_auth_permission_rule { + ids = append(ids, id) + } + return +} + +// ScaAuthPermissionRuleIDs returns the "sca_auth_permission_rule" edge IDs in the mutation. +func (m *ScaAuthRoleMutation) ScaAuthPermissionRuleIDs() (ids []int64) { + for id := range m.sca_auth_permission_rule { + ids = append(ids, id) + } + return +} + +// ResetScaAuthPermissionRule resets all changes to the "sca_auth_permission_rule" edge. +func (m *ScaAuthRoleMutation) ResetScaAuthPermissionRule() { + m.sca_auth_permission_rule = nil + m.clearedsca_auth_permission_rule = false + m.removedsca_auth_permission_rule = nil +} + +// Where appends a list predicates to the ScaAuthRoleMutation builder. +func (m *ScaAuthRoleMutation) Where(ps ...predicate.ScaAuthRole) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the ScaAuthRoleMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *ScaAuthRoleMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.ScaAuthRole, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *ScaAuthRoleMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *ScaAuthRoleMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (ScaAuthRole). +func (m *ScaAuthRoleMutation) 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 *ScaAuthRoleMutation) Fields() []string { + fields := make([]string, 0, 5) + if m.role_name != nil { + fields = append(fields, scaauthrole.FieldRoleName) + } + if m.role_key != nil { + fields = append(fields, scaauthrole.FieldRoleKey) + } + if m.created_at != nil { + fields = append(fields, scaauthrole.FieldCreatedAt) + } + if m.update_at != nil { + fields = append(fields, scaauthrole.FieldUpdateAt) + } + if m.deleted != nil { + fields = append(fields, scaauthrole.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 *ScaAuthRoleMutation) Field(name string) (ent.Value, bool) { + switch name { + case scaauthrole.FieldRoleName: + return m.RoleName() + case scaauthrole.FieldRoleKey: + return m.RoleKey() + case scaauthrole.FieldCreatedAt: + return m.CreatedAt() + case scaauthrole.FieldUpdateAt: + return m.UpdateAt() + case scaauthrole.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 *ScaAuthRoleMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case scaauthrole.FieldRoleName: + return m.OldRoleName(ctx) + case scaauthrole.FieldRoleKey: + return m.OldRoleKey(ctx) + case scaauthrole.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case scaauthrole.FieldUpdateAt: + return m.OldUpdateAt(ctx) + case scaauthrole.FieldDeleted: + return m.OldDeleted(ctx) + } + return nil, fmt.Errorf("unknown ScaAuthRole 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 *ScaAuthRoleMutation) SetField(name string, value ent.Value) error { + switch name { + case scaauthrole.FieldRoleName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRoleName(v) + return nil + case scaauthrole.FieldRoleKey: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRoleKey(v) + return nil + case scaauthrole.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + case scaauthrole.FieldUpdateAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdateAt(v) + return nil + case scaauthrole.FieldDeleted: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeleted(v) + return nil + } + return fmt.Errorf("unknown ScaAuthRole field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *ScaAuthRoleMutation) AddedFields() []string { + var fields []string + if m.adddeleted != nil { + fields = append(fields, scaauthrole.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 *ScaAuthRoleMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case scaauthrole.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 *ScaAuthRoleMutation) AddField(name string, value ent.Value) error { + switch name { + case scaauthrole.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 ScaAuthRole numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *ScaAuthRoleMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *ScaAuthRoleMutation) 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 *ScaAuthRoleMutation) ClearField(name string) error { + return fmt.Errorf("unknown ScaAuthRole 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 *ScaAuthRoleMutation) ResetField(name string) error { + switch name { + case scaauthrole.FieldRoleName: + m.ResetRoleName() + return nil + case scaauthrole.FieldRoleKey: + m.ResetRoleKey() + return nil + case scaauthrole.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case scaauthrole.FieldUpdateAt: + m.ResetUpdateAt() + return nil + case scaauthrole.FieldDeleted: + m.ResetDeleted() + return nil + } + return fmt.Errorf("unknown ScaAuthRole field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *ScaAuthRoleMutation) AddedEdges() []string { + edges := make([]string, 0, 1) + if m.sca_auth_permission_rule != nil { + edges = append(edges, scaauthrole.EdgeScaAuthPermissionRule) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *ScaAuthRoleMutation) AddedIDs(name string) []ent.Value { + switch name { + case scaauthrole.EdgeScaAuthPermissionRule: + ids := make([]ent.Value, 0, len(m.sca_auth_permission_rule)) + for id := range m.sca_auth_permission_rule { + ids = append(ids, id) + } + return ids + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *ScaAuthRoleMutation) RemovedEdges() []string { + edges := make([]string, 0, 1) + if m.removedsca_auth_permission_rule != nil { + edges = append(edges, scaauthrole.EdgeScaAuthPermissionRule) + } + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *ScaAuthRoleMutation) RemovedIDs(name string) []ent.Value { + switch name { + case scaauthrole.EdgeScaAuthPermissionRule: + ids := make([]ent.Value, 0, len(m.removedsca_auth_permission_rule)) + for id := range m.removedsca_auth_permission_rule { + ids = append(ids, id) + } + return ids + } + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *ScaAuthRoleMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) + if m.clearedsca_auth_permission_rule { + edges = append(edges, scaauthrole.EdgeScaAuthPermissionRule) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *ScaAuthRoleMutation) EdgeCleared(name string) bool { + switch name { + case scaauthrole.EdgeScaAuthPermissionRule: + return m.clearedsca_auth_permission_rule + } + 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 *ScaAuthRoleMutation) ClearEdge(name string) error { + switch name { + } + return fmt.Errorf("unknown ScaAuthRole 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 *ScaAuthRoleMutation) ResetEdge(name string) error { + switch name { + case scaauthrole.EdgeScaAuthPermissionRule: + m.ResetScaAuthPermissionRule() + return nil + } + return fmt.Errorf("unknown ScaAuthRole edge %s", name) +} + +// ScaAuthUserMutation represents an operation that mutates the ScaAuthUser nodes in the graph. +type ScaAuthUserMutation struct { + config + op Op + typ string + id *int64 + uid *string + username *string + nickname *string + email *string + phone *string + password *string + gender *string + avatar *string + status *int8 + addstatus *int8 + introduce *string + created_at *time.Time + update_at *time.Time + deleted *int8 + adddeleted *int8 + blog *string + location *string + company *string + clearedFields map[string]struct{} + sca_auth_user_social map[int64]struct{} + removedsca_auth_user_social map[int64]struct{} + clearedsca_auth_user_social bool + sca_auth_user_device map[int64]struct{} + removedsca_auth_user_device map[int64]struct{} + clearedsca_auth_user_device bool + done bool + oldValue func(context.Context) (*ScaAuthUser, error) + predicates []predicate.ScaAuthUser +} + +var _ ent.Mutation = (*ScaAuthUserMutation)(nil) + +// scaauthuserOption allows management of the mutation configuration using functional options. +type scaauthuserOption func(*ScaAuthUserMutation) + +// newScaAuthUserMutation creates new mutation for the ScaAuthUser entity. +func newScaAuthUserMutation(c config, op Op, opts ...scaauthuserOption) *ScaAuthUserMutation { + m := &ScaAuthUserMutation{ + config: c, + op: op, + typ: TypeScaAuthUser, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withScaAuthUserID sets the ID field of the mutation. +func withScaAuthUserID(id int64) scaauthuserOption { + return func(m *ScaAuthUserMutation) { + var ( + err error + once sync.Once + value *ScaAuthUser + ) + m.oldValue = func(ctx context.Context) (*ScaAuthUser, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().ScaAuthUser.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withScaAuthUser sets the old ScaAuthUser of the mutation. +func withScaAuthUser(node *ScaAuthUser) scaauthuserOption { + return func(m *ScaAuthUserMutation) { + m.oldValue = func(context.Context) (*ScaAuthUser, 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 ScaAuthUserMutation) 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 ScaAuthUserMutation) 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 ScaAuthUser entities. +func (m *ScaAuthUserMutation) 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 *ScaAuthUserMutation) 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 *ScaAuthUserMutation) 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().ScaAuthUser.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetUID sets the "uid" field. +func (m *ScaAuthUserMutation) SetUID(s string) { + m.uid = &s +} + +// UID returns the value of the "uid" field in the mutation. +func (m *ScaAuthUserMutation) UID() (r string, exists bool) { + v := m.uid + if v == nil { + return + } + return *v, true +} + +// OldUID returns the old "uid" field's value of the ScaAuthUser entity. +// If the ScaAuthUser 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 *ScaAuthUserMutation) OldUID(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUID: %w", err) + } + return oldValue.UID, nil +} + +// ResetUID resets all changes to the "uid" field. +func (m *ScaAuthUserMutation) ResetUID() { + m.uid = nil +} + +// SetUsername sets the "username" field. +func (m *ScaAuthUserMutation) SetUsername(s string) { + m.username = &s +} + +// Username returns the value of the "username" field in the mutation. +func (m *ScaAuthUserMutation) Username() (r string, exists bool) { + v := m.username + if v == nil { + return + } + return *v, true +} + +// OldUsername returns the old "username" field's value of the ScaAuthUser entity. +// If the ScaAuthUser 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 *ScaAuthUserMutation) OldUsername(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUsername is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUsername requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUsername: %w", err) + } + return oldValue.Username, nil +} + +// ClearUsername clears the value of the "username" field. +func (m *ScaAuthUserMutation) ClearUsername() { + m.username = nil + m.clearedFields[scaauthuser.FieldUsername] = struct{}{} +} + +// UsernameCleared returns if the "username" field was cleared in this mutation. +func (m *ScaAuthUserMutation) UsernameCleared() bool { + _, ok := m.clearedFields[scaauthuser.FieldUsername] + return ok +} + +// ResetUsername resets all changes to the "username" field. +func (m *ScaAuthUserMutation) ResetUsername() { + m.username = nil + delete(m.clearedFields, scaauthuser.FieldUsername) +} + +// SetNickname sets the "nickname" field. +func (m *ScaAuthUserMutation) SetNickname(s string) { + m.nickname = &s +} + +// Nickname returns the value of the "nickname" field in the mutation. +func (m *ScaAuthUserMutation) Nickname() (r string, exists bool) { + v := m.nickname + if v == nil { + return + } + return *v, true +} + +// OldNickname returns the old "nickname" field's value of the ScaAuthUser entity. +// If the ScaAuthUser 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 *ScaAuthUserMutation) 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 +} + +// ClearNickname clears the value of the "nickname" field. +func (m *ScaAuthUserMutation) ClearNickname() { + m.nickname = nil + m.clearedFields[scaauthuser.FieldNickname] = struct{}{} +} + +// NicknameCleared returns if the "nickname" field was cleared in this mutation. +func (m *ScaAuthUserMutation) NicknameCleared() bool { + _, ok := m.clearedFields[scaauthuser.FieldNickname] + return ok +} + +// ResetNickname resets all changes to the "nickname" field. +func (m *ScaAuthUserMutation) ResetNickname() { + m.nickname = nil + delete(m.clearedFields, scaauthuser.FieldNickname) +} + +// SetEmail sets the "email" field. +func (m *ScaAuthUserMutation) SetEmail(s string) { + m.email = &s +} + +// Email returns the value of the "email" field in the mutation. +func (m *ScaAuthUserMutation) Email() (r string, exists bool) { + v := m.email + if v == nil { + return + } + return *v, true +} + +// OldEmail returns the old "email" field's value of the ScaAuthUser entity. +// If the ScaAuthUser 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 *ScaAuthUserMutation) OldEmail(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldEmail is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldEmail requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldEmail: %w", err) + } + return oldValue.Email, nil +} + +// ClearEmail clears the value of the "email" field. +func (m *ScaAuthUserMutation) ClearEmail() { + m.email = nil + m.clearedFields[scaauthuser.FieldEmail] = struct{}{} +} + +// EmailCleared returns if the "email" field was cleared in this mutation. +func (m *ScaAuthUserMutation) EmailCleared() bool { + _, ok := m.clearedFields[scaauthuser.FieldEmail] + return ok +} + +// ResetEmail resets all changes to the "email" field. +func (m *ScaAuthUserMutation) ResetEmail() { + m.email = nil + delete(m.clearedFields, scaauthuser.FieldEmail) +} + +// SetPhone sets the "phone" field. +func (m *ScaAuthUserMutation) SetPhone(s string) { + m.phone = &s +} + +// Phone returns the value of the "phone" field in the mutation. +func (m *ScaAuthUserMutation) Phone() (r string, exists bool) { + v := m.phone + if v == nil { + return + } + return *v, true +} + +// OldPhone returns the old "phone" field's value of the ScaAuthUser entity. +// If the ScaAuthUser 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 *ScaAuthUserMutation) OldPhone(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPhone is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPhone requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPhone: %w", err) + } + return oldValue.Phone, nil +} + +// ClearPhone clears the value of the "phone" field. +func (m *ScaAuthUserMutation) ClearPhone() { + m.phone = nil + m.clearedFields[scaauthuser.FieldPhone] = struct{}{} +} + +// PhoneCleared returns if the "phone" field was cleared in this mutation. +func (m *ScaAuthUserMutation) PhoneCleared() bool { + _, ok := m.clearedFields[scaauthuser.FieldPhone] + return ok +} + +// ResetPhone resets all changes to the "phone" field. +func (m *ScaAuthUserMutation) ResetPhone() { + m.phone = nil + delete(m.clearedFields, scaauthuser.FieldPhone) +} + +// SetPassword sets the "password" field. +func (m *ScaAuthUserMutation) SetPassword(s string) { + m.password = &s +} + +// Password returns the value of the "password" field in the mutation. +func (m *ScaAuthUserMutation) Password() (r string, exists bool) { + v := m.password + if v == nil { + return + } + return *v, true +} + +// OldPassword returns the old "password" field's value of the ScaAuthUser entity. +// If the ScaAuthUser 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 *ScaAuthUserMutation) OldPassword(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPassword is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPassword requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPassword: %w", err) + } + return oldValue.Password, nil +} + +// ClearPassword clears the value of the "password" field. +func (m *ScaAuthUserMutation) ClearPassword() { + m.password = nil + m.clearedFields[scaauthuser.FieldPassword] = struct{}{} +} + +// PasswordCleared returns if the "password" field was cleared in this mutation. +func (m *ScaAuthUserMutation) PasswordCleared() bool { + _, ok := m.clearedFields[scaauthuser.FieldPassword] + return ok +} + +// ResetPassword resets all changes to the "password" field. +func (m *ScaAuthUserMutation) ResetPassword() { + m.password = nil + delete(m.clearedFields, scaauthuser.FieldPassword) +} + +// SetGender sets the "gender" field. +func (m *ScaAuthUserMutation) SetGender(s string) { + m.gender = &s +} + +// Gender returns the value of the "gender" field in the mutation. +func (m *ScaAuthUserMutation) Gender() (r string, exists bool) { + v := m.gender + if v == nil { + return + } + return *v, true +} + +// OldGender returns the old "gender" field's value of the ScaAuthUser entity. +// If the ScaAuthUser 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 *ScaAuthUserMutation) OldGender(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldGender is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldGender requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldGender: %w", err) + } + return oldValue.Gender, nil +} + +// ClearGender clears the value of the "gender" field. +func (m *ScaAuthUserMutation) ClearGender() { + m.gender = nil + m.clearedFields[scaauthuser.FieldGender] = struct{}{} +} + +// GenderCleared returns if the "gender" field was cleared in this mutation. +func (m *ScaAuthUserMutation) GenderCleared() bool { + _, ok := m.clearedFields[scaauthuser.FieldGender] + return ok +} + +// ResetGender resets all changes to the "gender" field. +func (m *ScaAuthUserMutation) ResetGender() { + m.gender = nil + delete(m.clearedFields, scaauthuser.FieldGender) +} + +// SetAvatar sets the "avatar" field. +func (m *ScaAuthUserMutation) SetAvatar(s string) { + m.avatar = &s +} + +// Avatar returns the value of the "avatar" field in the mutation. +func (m *ScaAuthUserMutation) Avatar() (r string, exists bool) { + v := m.avatar + if v == nil { + return + } + return *v, true +} + +// OldAvatar returns the old "avatar" field's value of the ScaAuthUser entity. +// If the ScaAuthUser 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 *ScaAuthUserMutation) OldAvatar(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAvatar is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAvatar requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAvatar: %w", err) + } + return oldValue.Avatar, nil +} + +// ClearAvatar clears the value of the "avatar" field. +func (m *ScaAuthUserMutation) ClearAvatar() { + m.avatar = nil + m.clearedFields[scaauthuser.FieldAvatar] = struct{}{} +} + +// AvatarCleared returns if the "avatar" field was cleared in this mutation. +func (m *ScaAuthUserMutation) AvatarCleared() bool { + _, ok := m.clearedFields[scaauthuser.FieldAvatar] + return ok +} + +// ResetAvatar resets all changes to the "avatar" field. +func (m *ScaAuthUserMutation) ResetAvatar() { + m.avatar = nil + delete(m.clearedFields, scaauthuser.FieldAvatar) +} + +// SetStatus sets the "status" field. +func (m *ScaAuthUserMutation) SetStatus(i int8) { + m.status = &i + m.addstatus = nil +} + +// Status returns the value of the "status" field in the mutation. +func (m *ScaAuthUserMutation) Status() (r int8, exists bool) { + v := m.status + if v == nil { + return + } + return *v, true +} + +// OldStatus returns the old "status" field's value of the ScaAuthUser entity. +// If the ScaAuthUser 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 *ScaAuthUserMutation) OldStatus(ctx context.Context) (v int8, 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 *ScaAuthUserMutation) AddStatus(i int8) { + 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 *ScaAuthUserMutation) AddedStatus() (r int8, exists bool) { + v := m.addstatus + if v == nil { + return + } + return *v, true +} + +// ClearStatus clears the value of the "status" field. +func (m *ScaAuthUserMutation) ClearStatus() { + m.status = nil + m.addstatus = nil + m.clearedFields[scaauthuser.FieldStatus] = struct{}{} +} + +// StatusCleared returns if the "status" field was cleared in this mutation. +func (m *ScaAuthUserMutation) StatusCleared() bool { + _, ok := m.clearedFields[scaauthuser.FieldStatus] + return ok +} + +// ResetStatus resets all changes to the "status" field. +func (m *ScaAuthUserMutation) ResetStatus() { + m.status = nil + m.addstatus = nil + delete(m.clearedFields, scaauthuser.FieldStatus) +} + +// SetIntroduce sets the "introduce" field. +func (m *ScaAuthUserMutation) SetIntroduce(s string) { + m.introduce = &s +} + +// Introduce returns the value of the "introduce" field in the mutation. +func (m *ScaAuthUserMutation) Introduce() (r string, exists bool) { + v := m.introduce + if v == nil { + return + } + return *v, true +} + +// OldIntroduce returns the old "introduce" field's value of the ScaAuthUser entity. +// If the ScaAuthUser 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 *ScaAuthUserMutation) OldIntroduce(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldIntroduce is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldIntroduce requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldIntroduce: %w", err) + } + return oldValue.Introduce, nil +} + +// ClearIntroduce clears the value of the "introduce" field. +func (m *ScaAuthUserMutation) ClearIntroduce() { + m.introduce = nil + m.clearedFields[scaauthuser.FieldIntroduce] = struct{}{} +} + +// IntroduceCleared returns if the "introduce" field was cleared in this mutation. +func (m *ScaAuthUserMutation) IntroduceCleared() bool { + _, ok := m.clearedFields[scaauthuser.FieldIntroduce] + return ok +} + +// ResetIntroduce resets all changes to the "introduce" field. +func (m *ScaAuthUserMutation) ResetIntroduce() { + m.introduce = nil + delete(m.clearedFields, scaauthuser.FieldIntroduce) +} + +// SetCreatedAt sets the "created_at" field. +func (m *ScaAuthUserMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *ScaAuthUserMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "created_at" field's value of the ScaAuthUser entity. +// If the ScaAuthUser 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 *ScaAuthUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *ScaAuthUserMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdateAt sets the "update_at" field. +func (m *ScaAuthUserMutation) SetUpdateAt(t time.Time) { + m.update_at = &t +} + +// UpdateAt returns the value of the "update_at" field in the mutation. +func (m *ScaAuthUserMutation) UpdateAt() (r time.Time, exists bool) { + v := m.update_at + if v == nil { + return + } + return *v, true +} + +// OldUpdateAt returns the old "update_at" field's value of the ScaAuthUser entity. +// If the ScaAuthUser 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 *ScaAuthUserMutation) OldUpdateAt(ctx context.Context) (v *time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateAt: %w", err) + } + return oldValue.UpdateAt, nil +} + +// ClearUpdateAt clears the value of the "update_at" field. +func (m *ScaAuthUserMutation) ClearUpdateAt() { + m.update_at = nil + m.clearedFields[scaauthuser.FieldUpdateAt] = struct{}{} +} + +// UpdateAtCleared returns if the "update_at" field was cleared in this mutation. +func (m *ScaAuthUserMutation) UpdateAtCleared() bool { + _, ok := m.clearedFields[scaauthuser.FieldUpdateAt] + return ok +} + +// ResetUpdateAt resets all changes to the "update_at" field. +func (m *ScaAuthUserMutation) ResetUpdateAt() { + m.update_at = nil + delete(m.clearedFields, scaauthuser.FieldUpdateAt) +} + +// SetDeleted sets the "deleted" field. +func (m *ScaAuthUserMutation) SetDeleted(i int8) { + m.deleted = &i + m.adddeleted = nil +} + +// Deleted returns the value of the "deleted" field in the mutation. +func (m *ScaAuthUserMutation) Deleted() (r int8, exists bool) { + v := m.deleted + if v == nil { + return + } + return *v, true +} + +// OldDeleted returns the old "deleted" field's value of the ScaAuthUser entity. +// If the ScaAuthUser 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 *ScaAuthUserMutation) OldDeleted(ctx context.Context) (v int8, 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 *ScaAuthUserMutation) AddDeleted(i int8) { + 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 *ScaAuthUserMutation) AddedDeleted() (r int8, exists bool) { + v := m.adddeleted + if v == nil { + return + } + return *v, true +} + +// ResetDeleted resets all changes to the "deleted" field. +func (m *ScaAuthUserMutation) ResetDeleted() { + m.deleted = nil + m.adddeleted = nil +} + +// SetBlog sets the "blog" field. +func (m *ScaAuthUserMutation) SetBlog(s string) { + m.blog = &s +} + +// Blog returns the value of the "blog" field in the mutation. +func (m *ScaAuthUserMutation) Blog() (r string, exists bool) { + v := m.blog + if v == nil { + return + } + return *v, true +} + +// OldBlog returns the old "blog" field's value of the ScaAuthUser entity. +// If the ScaAuthUser 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 *ScaAuthUserMutation) OldBlog(ctx context.Context) (v *string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldBlog is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldBlog requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldBlog: %w", err) + } + return oldValue.Blog, nil +} + +// ClearBlog clears the value of the "blog" field. +func (m *ScaAuthUserMutation) ClearBlog() { + m.blog = nil + m.clearedFields[scaauthuser.FieldBlog] = struct{}{} +} + +// BlogCleared returns if the "blog" field was cleared in this mutation. +func (m *ScaAuthUserMutation) BlogCleared() bool { + _, ok := m.clearedFields[scaauthuser.FieldBlog] + return ok +} + +// ResetBlog resets all changes to the "blog" field. +func (m *ScaAuthUserMutation) ResetBlog() { + m.blog = nil + delete(m.clearedFields, scaauthuser.FieldBlog) +} + +// SetLocation sets the "location" field. +func (m *ScaAuthUserMutation) SetLocation(s string) { + m.location = &s +} + +// Location returns the value of the "location" field in the mutation. +func (m *ScaAuthUserMutation) Location() (r string, exists bool) { + v := m.location + if v == nil { + return + } + return *v, true +} + +// OldLocation returns the old "location" field's value of the ScaAuthUser entity. +// If the ScaAuthUser 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 *ScaAuthUserMutation) OldLocation(ctx context.Context) (v *string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLocation is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLocation requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLocation: %w", err) + } + return oldValue.Location, nil +} + +// ClearLocation clears the value of the "location" field. +func (m *ScaAuthUserMutation) ClearLocation() { + m.location = nil + m.clearedFields[scaauthuser.FieldLocation] = struct{}{} +} + +// LocationCleared returns if the "location" field was cleared in this mutation. +func (m *ScaAuthUserMutation) LocationCleared() bool { + _, ok := m.clearedFields[scaauthuser.FieldLocation] + return ok +} + +// ResetLocation resets all changes to the "location" field. +func (m *ScaAuthUserMutation) ResetLocation() { + m.location = nil + delete(m.clearedFields, scaauthuser.FieldLocation) +} + +// SetCompany sets the "company" field. +func (m *ScaAuthUserMutation) SetCompany(s string) { + m.company = &s +} + +// Company returns the value of the "company" field in the mutation. +func (m *ScaAuthUserMutation) Company() (r string, exists bool) { + v := m.company + if v == nil { + return + } + return *v, true +} + +// OldCompany returns the old "company" field's value of the ScaAuthUser entity. +// If the ScaAuthUser 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 *ScaAuthUserMutation) OldCompany(ctx context.Context) (v *string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCompany is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCompany requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCompany: %w", err) + } + return oldValue.Company, nil +} + +// ClearCompany clears the value of the "company" field. +func (m *ScaAuthUserMutation) ClearCompany() { + m.company = nil + m.clearedFields[scaauthuser.FieldCompany] = struct{}{} +} + +// CompanyCleared returns if the "company" field was cleared in this mutation. +func (m *ScaAuthUserMutation) CompanyCleared() bool { + _, ok := m.clearedFields[scaauthuser.FieldCompany] + return ok +} + +// ResetCompany resets all changes to the "company" field. +func (m *ScaAuthUserMutation) ResetCompany() { + m.company = nil + delete(m.clearedFields, scaauthuser.FieldCompany) +} + +// AddScaAuthUserSocialIDs adds the "sca_auth_user_social" edge to the ScaAuthUserSocial entity by ids. +func (m *ScaAuthUserMutation) AddScaAuthUserSocialIDs(ids ...int64) { + if m.sca_auth_user_social == nil { + m.sca_auth_user_social = make(map[int64]struct{}) + } + for i := range ids { + m.sca_auth_user_social[ids[i]] = struct{}{} + } +} + +// ClearScaAuthUserSocial clears the "sca_auth_user_social" edge to the ScaAuthUserSocial entity. +func (m *ScaAuthUserMutation) ClearScaAuthUserSocial() { + m.clearedsca_auth_user_social = true +} + +// ScaAuthUserSocialCleared reports if the "sca_auth_user_social" edge to the ScaAuthUserSocial entity was cleared. +func (m *ScaAuthUserMutation) ScaAuthUserSocialCleared() bool { + return m.clearedsca_auth_user_social +} + +// RemoveScaAuthUserSocialIDs removes the "sca_auth_user_social" edge to the ScaAuthUserSocial entity by IDs. +func (m *ScaAuthUserMutation) RemoveScaAuthUserSocialIDs(ids ...int64) { + if m.removedsca_auth_user_social == nil { + m.removedsca_auth_user_social = make(map[int64]struct{}) + } + for i := range ids { + delete(m.sca_auth_user_social, ids[i]) + m.removedsca_auth_user_social[ids[i]] = struct{}{} + } +} + +// RemovedScaAuthUserSocial returns the removed IDs of the "sca_auth_user_social" edge to the ScaAuthUserSocial entity. +func (m *ScaAuthUserMutation) RemovedScaAuthUserSocialIDs() (ids []int64) { + for id := range m.removedsca_auth_user_social { + ids = append(ids, id) + } + return +} + +// ScaAuthUserSocialIDs returns the "sca_auth_user_social" edge IDs in the mutation. +func (m *ScaAuthUserMutation) ScaAuthUserSocialIDs() (ids []int64) { + for id := range m.sca_auth_user_social { + ids = append(ids, id) + } + return +} + +// ResetScaAuthUserSocial resets all changes to the "sca_auth_user_social" edge. +func (m *ScaAuthUserMutation) ResetScaAuthUserSocial() { + m.sca_auth_user_social = nil + m.clearedsca_auth_user_social = false + m.removedsca_auth_user_social = nil +} + +// AddScaAuthUserDeviceIDs adds the "sca_auth_user_device" edge to the ScaAuthUserDevice entity by ids. +func (m *ScaAuthUserMutation) AddScaAuthUserDeviceIDs(ids ...int64) { + if m.sca_auth_user_device == nil { + m.sca_auth_user_device = make(map[int64]struct{}) + } + for i := range ids { + m.sca_auth_user_device[ids[i]] = struct{}{} + } +} + +// ClearScaAuthUserDevice clears the "sca_auth_user_device" edge to the ScaAuthUserDevice entity. +func (m *ScaAuthUserMutation) ClearScaAuthUserDevice() { + m.clearedsca_auth_user_device = true +} + +// ScaAuthUserDeviceCleared reports if the "sca_auth_user_device" edge to the ScaAuthUserDevice entity was cleared. +func (m *ScaAuthUserMutation) ScaAuthUserDeviceCleared() bool { + return m.clearedsca_auth_user_device +} + +// RemoveScaAuthUserDeviceIDs removes the "sca_auth_user_device" edge to the ScaAuthUserDevice entity by IDs. +func (m *ScaAuthUserMutation) RemoveScaAuthUserDeviceIDs(ids ...int64) { + if m.removedsca_auth_user_device == nil { + m.removedsca_auth_user_device = make(map[int64]struct{}) + } + for i := range ids { + delete(m.sca_auth_user_device, ids[i]) + m.removedsca_auth_user_device[ids[i]] = struct{}{} + } +} + +// RemovedScaAuthUserDevice returns the removed IDs of the "sca_auth_user_device" edge to the ScaAuthUserDevice entity. +func (m *ScaAuthUserMutation) RemovedScaAuthUserDeviceIDs() (ids []int64) { + for id := range m.removedsca_auth_user_device { + ids = append(ids, id) + } + return +} + +// ScaAuthUserDeviceIDs returns the "sca_auth_user_device" edge IDs in the mutation. +func (m *ScaAuthUserMutation) ScaAuthUserDeviceIDs() (ids []int64) { + for id := range m.sca_auth_user_device { + ids = append(ids, id) + } + return +} + +// ResetScaAuthUserDevice resets all changes to the "sca_auth_user_device" edge. +func (m *ScaAuthUserMutation) ResetScaAuthUserDevice() { + m.sca_auth_user_device = nil + m.clearedsca_auth_user_device = false + m.removedsca_auth_user_device = nil +} + +// Where appends a list predicates to the ScaAuthUserMutation builder. +func (m *ScaAuthUserMutation) Where(ps ...predicate.ScaAuthUser) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the ScaAuthUserMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *ScaAuthUserMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.ScaAuthUser, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *ScaAuthUserMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *ScaAuthUserMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (ScaAuthUser). +func (m *ScaAuthUserMutation) 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 *ScaAuthUserMutation) Fields() []string { + fields := make([]string, 0, 16) + if m.uid != nil { + fields = append(fields, scaauthuser.FieldUID) + } + if m.username != nil { + fields = append(fields, scaauthuser.FieldUsername) + } + if m.nickname != nil { + fields = append(fields, scaauthuser.FieldNickname) + } + if m.email != nil { + fields = append(fields, scaauthuser.FieldEmail) + } + if m.phone != nil { + fields = append(fields, scaauthuser.FieldPhone) + } + if m.password != nil { + fields = append(fields, scaauthuser.FieldPassword) + } + if m.gender != nil { + fields = append(fields, scaauthuser.FieldGender) + } + if m.avatar != nil { + fields = append(fields, scaauthuser.FieldAvatar) + } + if m.status != nil { + fields = append(fields, scaauthuser.FieldStatus) + } + if m.introduce != nil { + fields = append(fields, scaauthuser.FieldIntroduce) + } + if m.created_at != nil { + fields = append(fields, scaauthuser.FieldCreatedAt) + } + if m.update_at != nil { + fields = append(fields, scaauthuser.FieldUpdateAt) + } + if m.deleted != nil { + fields = append(fields, scaauthuser.FieldDeleted) + } + if m.blog != nil { + fields = append(fields, scaauthuser.FieldBlog) + } + if m.location != nil { + fields = append(fields, scaauthuser.FieldLocation) + } + if m.company != nil { + fields = append(fields, scaauthuser.FieldCompany) + } + 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 *ScaAuthUserMutation) Field(name string) (ent.Value, bool) { + switch name { + case scaauthuser.FieldUID: + return m.UID() + case scaauthuser.FieldUsername: + return m.Username() + case scaauthuser.FieldNickname: + return m.Nickname() + case scaauthuser.FieldEmail: + return m.Email() + case scaauthuser.FieldPhone: + return m.Phone() + case scaauthuser.FieldPassword: + return m.Password() + case scaauthuser.FieldGender: + return m.Gender() + case scaauthuser.FieldAvatar: + return m.Avatar() + case scaauthuser.FieldStatus: + return m.Status() + case scaauthuser.FieldIntroduce: + return m.Introduce() + case scaauthuser.FieldCreatedAt: + return m.CreatedAt() + case scaauthuser.FieldUpdateAt: + return m.UpdateAt() + case scaauthuser.FieldDeleted: + return m.Deleted() + case scaauthuser.FieldBlog: + return m.Blog() + case scaauthuser.FieldLocation: + return m.Location() + case scaauthuser.FieldCompany: + return m.Company() + } + 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 *ScaAuthUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case scaauthuser.FieldUID: + return m.OldUID(ctx) + case scaauthuser.FieldUsername: + return m.OldUsername(ctx) + case scaauthuser.FieldNickname: + return m.OldNickname(ctx) + case scaauthuser.FieldEmail: + return m.OldEmail(ctx) + case scaauthuser.FieldPhone: + return m.OldPhone(ctx) + case scaauthuser.FieldPassword: + return m.OldPassword(ctx) + case scaauthuser.FieldGender: + return m.OldGender(ctx) + case scaauthuser.FieldAvatar: + return m.OldAvatar(ctx) + case scaauthuser.FieldStatus: + return m.OldStatus(ctx) + case scaauthuser.FieldIntroduce: + return m.OldIntroduce(ctx) + case scaauthuser.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case scaauthuser.FieldUpdateAt: + return m.OldUpdateAt(ctx) + case scaauthuser.FieldDeleted: + return m.OldDeleted(ctx) + case scaauthuser.FieldBlog: + return m.OldBlog(ctx) + case scaauthuser.FieldLocation: + return m.OldLocation(ctx) + case scaauthuser.FieldCompany: + return m.OldCompany(ctx) + } + return nil, fmt.Errorf("unknown ScaAuthUser 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 *ScaAuthUserMutation) SetField(name string, value ent.Value) error { + switch name { + case scaauthuser.FieldUID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUID(v) + return nil + case scaauthuser.FieldUsername: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUsername(v) + return nil + case scaauthuser.FieldNickname: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetNickname(v) + return nil + case scaauthuser.FieldEmail: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetEmail(v) + return nil + case scaauthuser.FieldPhone: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPhone(v) + return nil + case scaauthuser.FieldPassword: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPassword(v) + return nil + case scaauthuser.FieldGender: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetGender(v) + return nil + case scaauthuser.FieldAvatar: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAvatar(v) + return nil + case scaauthuser.FieldStatus: + v, ok := value.(int8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStatus(v) + return nil + case scaauthuser.FieldIntroduce: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetIntroduce(v) + return nil + case scaauthuser.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + case scaauthuser.FieldUpdateAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdateAt(v) + return nil + case scaauthuser.FieldDeleted: + v, ok := value.(int8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeleted(v) + return nil + case scaauthuser.FieldBlog: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetBlog(v) + return nil + case scaauthuser.FieldLocation: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocation(v) + return nil + case scaauthuser.FieldCompany: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCompany(v) + return nil + } + return fmt.Errorf("unknown ScaAuthUser field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *ScaAuthUserMutation) AddedFields() []string { + var fields []string + if m.addstatus != nil { + fields = append(fields, scaauthuser.FieldStatus) + } + if m.adddeleted != nil { + fields = append(fields, scaauthuser.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 *ScaAuthUserMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case scaauthuser.FieldStatus: + return m.AddedStatus() + case scaauthuser.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 *ScaAuthUserMutation) AddField(name string, value ent.Value) error { + switch name { + case scaauthuser.FieldStatus: + v, ok := value.(int8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddStatus(v) + return nil + case scaauthuser.FieldDeleted: + v, ok := value.(int8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddDeleted(v) + return nil + } + return fmt.Errorf("unknown ScaAuthUser numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *ScaAuthUserMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(scaauthuser.FieldUsername) { + fields = append(fields, scaauthuser.FieldUsername) + } + if m.FieldCleared(scaauthuser.FieldNickname) { + fields = append(fields, scaauthuser.FieldNickname) + } + if m.FieldCleared(scaauthuser.FieldEmail) { + fields = append(fields, scaauthuser.FieldEmail) + } + if m.FieldCleared(scaauthuser.FieldPhone) { + fields = append(fields, scaauthuser.FieldPhone) + } + if m.FieldCleared(scaauthuser.FieldPassword) { + fields = append(fields, scaauthuser.FieldPassword) + } + if m.FieldCleared(scaauthuser.FieldGender) { + fields = append(fields, scaauthuser.FieldGender) + } + if m.FieldCleared(scaauthuser.FieldAvatar) { + fields = append(fields, scaauthuser.FieldAvatar) + } + if m.FieldCleared(scaauthuser.FieldStatus) { + fields = append(fields, scaauthuser.FieldStatus) + } + if m.FieldCleared(scaauthuser.FieldIntroduce) { + fields = append(fields, scaauthuser.FieldIntroduce) + } + if m.FieldCleared(scaauthuser.FieldUpdateAt) { + fields = append(fields, scaauthuser.FieldUpdateAt) + } + if m.FieldCleared(scaauthuser.FieldBlog) { + fields = append(fields, scaauthuser.FieldBlog) + } + if m.FieldCleared(scaauthuser.FieldLocation) { + fields = append(fields, scaauthuser.FieldLocation) + } + if m.FieldCleared(scaauthuser.FieldCompany) { + fields = append(fields, scaauthuser.FieldCompany) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *ScaAuthUserMutation) 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 *ScaAuthUserMutation) ClearField(name string) error { + switch name { + case scaauthuser.FieldUsername: + m.ClearUsername() + return nil + case scaauthuser.FieldNickname: + m.ClearNickname() + return nil + case scaauthuser.FieldEmail: + m.ClearEmail() + return nil + case scaauthuser.FieldPhone: + m.ClearPhone() + return nil + case scaauthuser.FieldPassword: + m.ClearPassword() + return nil + case scaauthuser.FieldGender: + m.ClearGender() + return nil + case scaauthuser.FieldAvatar: + m.ClearAvatar() + return nil + case scaauthuser.FieldStatus: + m.ClearStatus() + return nil + case scaauthuser.FieldIntroduce: + m.ClearIntroduce() + return nil + case scaauthuser.FieldUpdateAt: + m.ClearUpdateAt() + return nil + case scaauthuser.FieldBlog: + m.ClearBlog() + return nil + case scaauthuser.FieldLocation: + m.ClearLocation() + return nil + case scaauthuser.FieldCompany: + m.ClearCompany() + return nil + } + return fmt.Errorf("unknown ScaAuthUser 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 *ScaAuthUserMutation) ResetField(name string) error { + switch name { + case scaauthuser.FieldUID: + m.ResetUID() + return nil + case scaauthuser.FieldUsername: + m.ResetUsername() + return nil + case scaauthuser.FieldNickname: + m.ResetNickname() + return nil + case scaauthuser.FieldEmail: + m.ResetEmail() + return nil + case scaauthuser.FieldPhone: + m.ResetPhone() + return nil + case scaauthuser.FieldPassword: + m.ResetPassword() + return nil + case scaauthuser.FieldGender: + m.ResetGender() + return nil + case scaauthuser.FieldAvatar: + m.ResetAvatar() + return nil + case scaauthuser.FieldStatus: + m.ResetStatus() + return nil + case scaauthuser.FieldIntroduce: + m.ResetIntroduce() + return nil + case scaauthuser.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case scaauthuser.FieldUpdateAt: + m.ResetUpdateAt() + return nil + case scaauthuser.FieldDeleted: + m.ResetDeleted() + return nil + case scaauthuser.FieldBlog: + m.ResetBlog() + return nil + case scaauthuser.FieldLocation: + m.ResetLocation() + return nil + case scaauthuser.FieldCompany: + m.ResetCompany() + return nil + } + return fmt.Errorf("unknown ScaAuthUser field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *ScaAuthUserMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.sca_auth_user_social != nil { + edges = append(edges, scaauthuser.EdgeScaAuthUserSocial) + } + if m.sca_auth_user_device != nil { + edges = append(edges, scaauthuser.EdgeScaAuthUserDevice) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *ScaAuthUserMutation) AddedIDs(name string) []ent.Value { + switch name { + case scaauthuser.EdgeScaAuthUserSocial: + ids := make([]ent.Value, 0, len(m.sca_auth_user_social)) + for id := range m.sca_auth_user_social { + ids = append(ids, id) + } + return ids + case scaauthuser.EdgeScaAuthUserDevice: + ids := make([]ent.Value, 0, len(m.sca_auth_user_device)) + for id := range m.sca_auth_user_device { + ids = append(ids, id) + } + return ids + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *ScaAuthUserMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) + if m.removedsca_auth_user_social != nil { + edges = append(edges, scaauthuser.EdgeScaAuthUserSocial) + } + if m.removedsca_auth_user_device != nil { + edges = append(edges, scaauthuser.EdgeScaAuthUserDevice) + } + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *ScaAuthUserMutation) RemovedIDs(name string) []ent.Value { + switch name { + case scaauthuser.EdgeScaAuthUserSocial: + ids := make([]ent.Value, 0, len(m.removedsca_auth_user_social)) + for id := range m.removedsca_auth_user_social { + ids = append(ids, id) + } + return ids + case scaauthuser.EdgeScaAuthUserDevice: + ids := make([]ent.Value, 0, len(m.removedsca_auth_user_device)) + for id := range m.removedsca_auth_user_device { + ids = append(ids, id) + } + return ids + } + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *ScaAuthUserMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.clearedsca_auth_user_social { + edges = append(edges, scaauthuser.EdgeScaAuthUserSocial) + } + if m.clearedsca_auth_user_device { + edges = append(edges, scaauthuser.EdgeScaAuthUserDevice) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *ScaAuthUserMutation) EdgeCleared(name string) bool { + switch name { + case scaauthuser.EdgeScaAuthUserSocial: + return m.clearedsca_auth_user_social + case scaauthuser.EdgeScaAuthUserDevice: + return m.clearedsca_auth_user_device + } + 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 *ScaAuthUserMutation) ClearEdge(name string) error { + switch name { + } + return fmt.Errorf("unknown ScaAuthUser 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 *ScaAuthUserMutation) ResetEdge(name string) error { + switch name { + case scaauthuser.EdgeScaAuthUserSocial: + m.ResetScaAuthUserSocial() + return nil + case scaauthuser.EdgeScaAuthUserDevice: + m.ResetScaAuthUserDevice() + return nil + } + return fmt.Errorf("unknown ScaAuthUser edge %s", name) +} + +// ScaAuthUserDeviceMutation represents an operation that mutates the ScaAuthUserDevice nodes in the graph. +type ScaAuthUserDeviceMutation struct { + config + op Op + typ string + id *int64 + user_id *string + ip *string + location *string + agent *string + created_at *time.Time + update_at *time.Time + deleted *int + adddeleted *int + browser *string + operating_system *string + browser_version *string + mobile *int + addmobile *int + bot *int + addbot *int + mozilla *string + platform *string + engine_name *string + engine_version *string + clearedFields map[string]struct{} + sca_auth_user *int64 + clearedsca_auth_user bool + done bool + oldValue func(context.Context) (*ScaAuthUserDevice, error) + predicates []predicate.ScaAuthUserDevice +} + +var _ ent.Mutation = (*ScaAuthUserDeviceMutation)(nil) + +// scaauthuserdeviceOption allows management of the mutation configuration using functional options. +type scaauthuserdeviceOption func(*ScaAuthUserDeviceMutation) + +// newScaAuthUserDeviceMutation creates new mutation for the ScaAuthUserDevice entity. +func newScaAuthUserDeviceMutation(c config, op Op, opts ...scaauthuserdeviceOption) *ScaAuthUserDeviceMutation { + m := &ScaAuthUserDeviceMutation{ + config: c, + op: op, + typ: TypeScaAuthUserDevice, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withScaAuthUserDeviceID sets the ID field of the mutation. +func withScaAuthUserDeviceID(id int64) scaauthuserdeviceOption { + return func(m *ScaAuthUserDeviceMutation) { + var ( + err error + once sync.Once + value *ScaAuthUserDevice + ) + m.oldValue = func(ctx context.Context) (*ScaAuthUserDevice, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().ScaAuthUserDevice.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withScaAuthUserDevice sets the old ScaAuthUserDevice of the mutation. +func withScaAuthUserDevice(node *ScaAuthUserDevice) scaauthuserdeviceOption { + return func(m *ScaAuthUserDeviceMutation) { + m.oldValue = func(context.Context) (*ScaAuthUserDevice, 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 ScaAuthUserDeviceMutation) 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 ScaAuthUserDeviceMutation) 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 ScaAuthUserDevice entities. +func (m *ScaAuthUserDeviceMutation) 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 *ScaAuthUserDeviceMutation) 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 *ScaAuthUserDeviceMutation) 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().ScaAuthUserDevice.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetUserID sets the "user_id" field. +func (m *ScaAuthUserDeviceMutation) SetUserID(s string) { + m.user_id = &s +} + +// UserID returns the value of the "user_id" field in the mutation. +func (m *ScaAuthUserDeviceMutation) UserID() (r string, exists bool) { + v := m.user_id + if v == nil { + return + } + return *v, true +} + +// OldUserID returns the old "user_id" field's value of the ScaAuthUserDevice entity. +// If the ScaAuthUserDevice 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 *ScaAuthUserDeviceMutation) OldUserID(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUserID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUserID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUserID: %w", err) + } + return oldValue.UserID, nil +} + +// ResetUserID resets all changes to the "user_id" field. +func (m *ScaAuthUserDeviceMutation) ResetUserID() { + m.user_id = nil +} + +// SetIP sets the "ip" field. +func (m *ScaAuthUserDeviceMutation) SetIP(s string) { + m.ip = &s +} + +// IP returns the value of the "ip" field in the mutation. +func (m *ScaAuthUserDeviceMutation) IP() (r string, exists bool) { + v := m.ip + if v == nil { + return + } + return *v, true +} + +// OldIP returns the old "ip" field's value of the ScaAuthUserDevice entity. +// If the ScaAuthUserDevice 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 *ScaAuthUserDeviceMutation) OldIP(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldIP is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldIP requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldIP: %w", err) + } + return oldValue.IP, nil +} + +// ResetIP resets all changes to the "ip" field. +func (m *ScaAuthUserDeviceMutation) ResetIP() { + m.ip = nil +} + +// SetLocation sets the "location" field. +func (m *ScaAuthUserDeviceMutation) SetLocation(s string) { + m.location = &s +} + +// Location returns the value of the "location" field in the mutation. +func (m *ScaAuthUserDeviceMutation) Location() (r string, exists bool) { + v := m.location + if v == nil { + return + } + return *v, true +} + +// OldLocation returns the old "location" field's value of the ScaAuthUserDevice entity. +// If the ScaAuthUserDevice 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 *ScaAuthUserDeviceMutation) OldLocation(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLocation is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLocation requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLocation: %w", err) + } + return oldValue.Location, nil +} + +// ResetLocation resets all changes to the "location" field. +func (m *ScaAuthUserDeviceMutation) ResetLocation() { + m.location = nil +} + +// SetAgent sets the "agent" field. +func (m *ScaAuthUserDeviceMutation) SetAgent(s string) { + m.agent = &s +} + +// Agent returns the value of the "agent" field in the mutation. +func (m *ScaAuthUserDeviceMutation) Agent() (r string, exists bool) { + v := m.agent + if v == nil { + return + } + return *v, true +} + +// OldAgent returns the old "agent" field's value of the ScaAuthUserDevice entity. +// If the ScaAuthUserDevice 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 *ScaAuthUserDeviceMutation) OldAgent(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAgent is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAgent requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAgent: %w", err) + } + return oldValue.Agent, nil +} + +// ResetAgent resets all changes to the "agent" field. +func (m *ScaAuthUserDeviceMutation) ResetAgent() { + m.agent = nil +} + +// SetCreatedAt sets the "created_at" field. +func (m *ScaAuthUserDeviceMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *ScaAuthUserDeviceMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "created_at" field's value of the ScaAuthUserDevice entity. +// If the ScaAuthUserDevice 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 *ScaAuthUserDeviceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ClearCreatedAt clears the value of the "created_at" field. +func (m *ScaAuthUserDeviceMutation) ClearCreatedAt() { + m.created_at = nil + m.clearedFields[scaauthuserdevice.FieldCreatedAt] = struct{}{} +} + +// CreatedAtCleared returns if the "created_at" field was cleared in this mutation. +func (m *ScaAuthUserDeviceMutation) CreatedAtCleared() bool { + _, ok := m.clearedFields[scaauthuserdevice.FieldCreatedAt] + return ok +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *ScaAuthUserDeviceMutation) ResetCreatedAt() { + m.created_at = nil + delete(m.clearedFields, scaauthuserdevice.FieldCreatedAt) +} + +// SetUpdateAt sets the "update_at" field. +func (m *ScaAuthUserDeviceMutation) SetUpdateAt(t time.Time) { + m.update_at = &t +} + +// UpdateAt returns the value of the "update_at" field in the mutation. +func (m *ScaAuthUserDeviceMutation) UpdateAt() (r time.Time, exists bool) { + v := m.update_at + if v == nil { + return + } + return *v, true +} + +// OldUpdateAt returns the old "update_at" field's value of the ScaAuthUserDevice entity. +// If the ScaAuthUserDevice 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 *ScaAuthUserDeviceMutation) OldUpdateAt(ctx context.Context) (v *time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateAt: %w", err) + } + return oldValue.UpdateAt, nil +} + +// ResetUpdateAt resets all changes to the "update_at" field. +func (m *ScaAuthUserDeviceMutation) ResetUpdateAt() { + m.update_at = nil +} + +// SetDeleted sets the "deleted" field. +func (m *ScaAuthUserDeviceMutation) SetDeleted(i int) { + m.deleted = &i + m.adddeleted = nil +} + +// Deleted returns the value of the "deleted" field in the mutation. +func (m *ScaAuthUserDeviceMutation) 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 ScaAuthUserDevice entity. +// If the ScaAuthUserDevice 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 *ScaAuthUserDeviceMutation) 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 *ScaAuthUserDeviceMutation) 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 *ScaAuthUserDeviceMutation) 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 *ScaAuthUserDeviceMutation) ResetDeleted() { + m.deleted = nil + m.adddeleted = nil +} + +// SetBrowser sets the "browser" field. +func (m *ScaAuthUserDeviceMutation) SetBrowser(s string) { + m.browser = &s +} + +// Browser returns the value of the "browser" field in the mutation. +func (m *ScaAuthUserDeviceMutation) Browser() (r string, exists bool) { + v := m.browser + if v == nil { + return + } + return *v, true +} + +// OldBrowser returns the old "browser" field's value of the ScaAuthUserDevice entity. +// If the ScaAuthUserDevice 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 *ScaAuthUserDeviceMutation) OldBrowser(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldBrowser is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldBrowser requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldBrowser: %w", err) + } + return oldValue.Browser, nil +} + +// ResetBrowser resets all changes to the "browser" field. +func (m *ScaAuthUserDeviceMutation) ResetBrowser() { + m.browser = nil +} + +// SetOperatingSystem sets the "operating_system" field. +func (m *ScaAuthUserDeviceMutation) SetOperatingSystem(s string) { + m.operating_system = &s +} + +// OperatingSystem returns the value of the "operating_system" field in the mutation. +func (m *ScaAuthUserDeviceMutation) OperatingSystem() (r string, exists bool) { + v := m.operating_system + if v == nil { + return + } + return *v, true +} + +// OldOperatingSystem returns the old "operating_system" field's value of the ScaAuthUserDevice entity. +// If the ScaAuthUserDevice 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 *ScaAuthUserDeviceMutation) OldOperatingSystem(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldOperatingSystem is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldOperatingSystem requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldOperatingSystem: %w", err) + } + return oldValue.OperatingSystem, nil +} + +// ResetOperatingSystem resets all changes to the "operating_system" field. +func (m *ScaAuthUserDeviceMutation) ResetOperatingSystem() { + m.operating_system = nil +} + +// SetBrowserVersion sets the "browser_version" field. +func (m *ScaAuthUserDeviceMutation) SetBrowserVersion(s string) { + m.browser_version = &s +} + +// BrowserVersion returns the value of the "browser_version" field in the mutation. +func (m *ScaAuthUserDeviceMutation) BrowserVersion() (r string, exists bool) { + v := m.browser_version + if v == nil { + return + } + return *v, true +} + +// OldBrowserVersion returns the old "browser_version" field's value of the ScaAuthUserDevice entity. +// If the ScaAuthUserDevice 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 *ScaAuthUserDeviceMutation) OldBrowserVersion(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldBrowserVersion is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldBrowserVersion requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldBrowserVersion: %w", err) + } + return oldValue.BrowserVersion, nil +} + +// ResetBrowserVersion resets all changes to the "browser_version" field. +func (m *ScaAuthUserDeviceMutation) ResetBrowserVersion() { + m.browser_version = nil +} + +// SetMobile sets the "mobile" field. +func (m *ScaAuthUserDeviceMutation) SetMobile(i int) { + m.mobile = &i + m.addmobile = nil +} + +// Mobile returns the value of the "mobile" field in the mutation. +func (m *ScaAuthUserDeviceMutation) Mobile() (r int, exists bool) { + v := m.mobile + if v == nil { + return + } + return *v, true +} + +// OldMobile returns the old "mobile" field's value of the ScaAuthUserDevice entity. +// If the ScaAuthUserDevice 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 *ScaAuthUserDeviceMutation) OldMobile(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldMobile is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldMobile requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldMobile: %w", err) + } + return oldValue.Mobile, nil +} + +// AddMobile adds i to the "mobile" field. +func (m *ScaAuthUserDeviceMutation) AddMobile(i int) { + if m.addmobile != nil { + *m.addmobile += i + } else { + m.addmobile = &i + } +} + +// AddedMobile returns the value that was added to the "mobile" field in this mutation. +func (m *ScaAuthUserDeviceMutation) AddedMobile() (r int, exists bool) { + v := m.addmobile + if v == nil { + return + } + return *v, true +} + +// ResetMobile resets all changes to the "mobile" field. +func (m *ScaAuthUserDeviceMutation) ResetMobile() { + m.mobile = nil + m.addmobile = nil +} + +// SetBot sets the "bot" field. +func (m *ScaAuthUserDeviceMutation) SetBot(i int) { + m.bot = &i + m.addbot = nil +} + +// Bot returns the value of the "bot" field in the mutation. +func (m *ScaAuthUserDeviceMutation) Bot() (r int, exists bool) { + v := m.bot + if v == nil { + return + } + return *v, true +} + +// OldBot returns the old "bot" field's value of the ScaAuthUserDevice entity. +// If the ScaAuthUserDevice 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 *ScaAuthUserDeviceMutation) OldBot(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldBot is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldBot requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldBot: %w", err) + } + return oldValue.Bot, nil +} + +// AddBot adds i to the "bot" field. +func (m *ScaAuthUserDeviceMutation) AddBot(i int) { + if m.addbot != nil { + *m.addbot += i + } else { + m.addbot = &i + } +} + +// AddedBot returns the value that was added to the "bot" field in this mutation. +func (m *ScaAuthUserDeviceMutation) AddedBot() (r int, exists bool) { + v := m.addbot + if v == nil { + return + } + return *v, true +} + +// ResetBot resets all changes to the "bot" field. +func (m *ScaAuthUserDeviceMutation) ResetBot() { + m.bot = nil + m.addbot = nil +} + +// SetMozilla sets the "mozilla" field. +func (m *ScaAuthUserDeviceMutation) SetMozilla(s string) { + m.mozilla = &s +} + +// Mozilla returns the value of the "mozilla" field in the mutation. +func (m *ScaAuthUserDeviceMutation) Mozilla() (r string, exists bool) { + v := m.mozilla + if v == nil { + return + } + return *v, true +} + +// OldMozilla returns the old "mozilla" field's value of the ScaAuthUserDevice entity. +// If the ScaAuthUserDevice 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 *ScaAuthUserDeviceMutation) OldMozilla(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldMozilla is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldMozilla requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldMozilla: %w", err) + } + return oldValue.Mozilla, nil +} + +// ResetMozilla resets all changes to the "mozilla" field. +func (m *ScaAuthUserDeviceMutation) ResetMozilla() { + m.mozilla = nil +} + +// SetPlatform sets the "platform" field. +func (m *ScaAuthUserDeviceMutation) SetPlatform(s string) { + m.platform = &s +} + +// Platform returns the value of the "platform" field in the mutation. +func (m *ScaAuthUserDeviceMutation) Platform() (r string, exists bool) { + v := m.platform + if v == nil { + return + } + return *v, true +} + +// OldPlatform returns the old "platform" field's value of the ScaAuthUserDevice entity. +// If the ScaAuthUserDevice 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 *ScaAuthUserDeviceMutation) OldPlatform(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPlatform is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPlatform requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPlatform: %w", err) + } + return oldValue.Platform, nil +} + +// ResetPlatform resets all changes to the "platform" field. +func (m *ScaAuthUserDeviceMutation) ResetPlatform() { + m.platform = nil +} + +// SetEngineName sets the "engine_name" field. +func (m *ScaAuthUserDeviceMutation) SetEngineName(s string) { + m.engine_name = &s +} + +// EngineName returns the value of the "engine_name" field in the mutation. +func (m *ScaAuthUserDeviceMutation) EngineName() (r string, exists bool) { + v := m.engine_name + if v == nil { + return + } + return *v, true +} + +// OldEngineName returns the old "engine_name" field's value of the ScaAuthUserDevice entity. +// If the ScaAuthUserDevice 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 *ScaAuthUserDeviceMutation) OldEngineName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldEngineName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldEngineName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldEngineName: %w", err) + } + return oldValue.EngineName, nil +} + +// ResetEngineName resets all changes to the "engine_name" field. +func (m *ScaAuthUserDeviceMutation) ResetEngineName() { + m.engine_name = nil +} + +// SetEngineVersion sets the "engine_version" field. +func (m *ScaAuthUserDeviceMutation) SetEngineVersion(s string) { + m.engine_version = &s +} + +// EngineVersion returns the value of the "engine_version" field in the mutation. +func (m *ScaAuthUserDeviceMutation) EngineVersion() (r string, exists bool) { + v := m.engine_version + if v == nil { + return + } + return *v, true +} + +// OldEngineVersion returns the old "engine_version" field's value of the ScaAuthUserDevice entity. +// If the ScaAuthUserDevice 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 *ScaAuthUserDeviceMutation) OldEngineVersion(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldEngineVersion is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldEngineVersion requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldEngineVersion: %w", err) + } + return oldValue.EngineVersion, nil +} + +// ResetEngineVersion resets all changes to the "engine_version" field. +func (m *ScaAuthUserDeviceMutation) ResetEngineVersion() { + m.engine_version = nil +} + +// SetScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by id. +func (m *ScaAuthUserDeviceMutation) SetScaAuthUserID(id int64) { + m.sca_auth_user = &id +} + +// ClearScaAuthUser clears the "sca_auth_user" edge to the ScaAuthUser entity. +func (m *ScaAuthUserDeviceMutation) ClearScaAuthUser() { + m.clearedsca_auth_user = true +} + +// ScaAuthUserCleared reports if the "sca_auth_user" edge to the ScaAuthUser entity was cleared. +func (m *ScaAuthUserDeviceMutation) ScaAuthUserCleared() bool { + return m.clearedsca_auth_user +} + +// ScaAuthUserID returns the "sca_auth_user" edge ID in the mutation. +func (m *ScaAuthUserDeviceMutation) ScaAuthUserID() (id int64, exists bool) { + if m.sca_auth_user != nil { + return *m.sca_auth_user, true + } + return +} + +// ScaAuthUserIDs returns the "sca_auth_user" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// ScaAuthUserID instead. It exists only for internal usage by the builders. +func (m *ScaAuthUserDeviceMutation) ScaAuthUserIDs() (ids []int64) { + if id := m.sca_auth_user; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetScaAuthUser resets all changes to the "sca_auth_user" edge. +func (m *ScaAuthUserDeviceMutation) ResetScaAuthUser() { + m.sca_auth_user = nil + m.clearedsca_auth_user = false +} + +// Where appends a list predicates to the ScaAuthUserDeviceMutation builder. +func (m *ScaAuthUserDeviceMutation) Where(ps ...predicate.ScaAuthUserDevice) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the ScaAuthUserDeviceMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *ScaAuthUserDeviceMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.ScaAuthUserDevice, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *ScaAuthUserDeviceMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *ScaAuthUserDeviceMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (ScaAuthUserDevice). +func (m *ScaAuthUserDeviceMutation) 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 *ScaAuthUserDeviceMutation) Fields() []string { + fields := make([]string, 0, 16) + if m.user_id != nil { + fields = append(fields, scaauthuserdevice.FieldUserID) + } + if m.ip != nil { + fields = append(fields, scaauthuserdevice.FieldIP) + } + if m.location != nil { + fields = append(fields, scaauthuserdevice.FieldLocation) + } + if m.agent != nil { + fields = append(fields, scaauthuserdevice.FieldAgent) + } + if m.created_at != nil { + fields = append(fields, scaauthuserdevice.FieldCreatedAt) + } + if m.update_at != nil { + fields = append(fields, scaauthuserdevice.FieldUpdateAt) + } + if m.deleted != nil { + fields = append(fields, scaauthuserdevice.FieldDeleted) + } + if m.browser != nil { + fields = append(fields, scaauthuserdevice.FieldBrowser) + } + if m.operating_system != nil { + fields = append(fields, scaauthuserdevice.FieldOperatingSystem) + } + if m.browser_version != nil { + fields = append(fields, scaauthuserdevice.FieldBrowserVersion) + } + if m.mobile != nil { + fields = append(fields, scaauthuserdevice.FieldMobile) + } + if m.bot != nil { + fields = append(fields, scaauthuserdevice.FieldBot) + } + if m.mozilla != nil { + fields = append(fields, scaauthuserdevice.FieldMozilla) + } + if m.platform != nil { + fields = append(fields, scaauthuserdevice.FieldPlatform) + } + if m.engine_name != nil { + fields = append(fields, scaauthuserdevice.FieldEngineName) + } + if m.engine_version != nil { + fields = append(fields, scaauthuserdevice.FieldEngineVersion) + } + 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 *ScaAuthUserDeviceMutation) Field(name string) (ent.Value, bool) { + switch name { + case scaauthuserdevice.FieldUserID: + return m.UserID() + case scaauthuserdevice.FieldIP: + return m.IP() + case scaauthuserdevice.FieldLocation: + return m.Location() + case scaauthuserdevice.FieldAgent: + return m.Agent() + case scaauthuserdevice.FieldCreatedAt: + return m.CreatedAt() + case scaauthuserdevice.FieldUpdateAt: + return m.UpdateAt() + case scaauthuserdevice.FieldDeleted: + return m.Deleted() + case scaauthuserdevice.FieldBrowser: + return m.Browser() + case scaauthuserdevice.FieldOperatingSystem: + return m.OperatingSystem() + case scaauthuserdevice.FieldBrowserVersion: + return m.BrowserVersion() + case scaauthuserdevice.FieldMobile: + return m.Mobile() + case scaauthuserdevice.FieldBot: + return m.Bot() + case scaauthuserdevice.FieldMozilla: + return m.Mozilla() + case scaauthuserdevice.FieldPlatform: + return m.Platform() + case scaauthuserdevice.FieldEngineName: + return m.EngineName() + case scaauthuserdevice.FieldEngineVersion: + return m.EngineVersion() + } + 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 *ScaAuthUserDeviceMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case scaauthuserdevice.FieldUserID: + return m.OldUserID(ctx) + case scaauthuserdevice.FieldIP: + return m.OldIP(ctx) + case scaauthuserdevice.FieldLocation: + return m.OldLocation(ctx) + case scaauthuserdevice.FieldAgent: + return m.OldAgent(ctx) + case scaauthuserdevice.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case scaauthuserdevice.FieldUpdateAt: + return m.OldUpdateAt(ctx) + case scaauthuserdevice.FieldDeleted: + return m.OldDeleted(ctx) + case scaauthuserdevice.FieldBrowser: + return m.OldBrowser(ctx) + case scaauthuserdevice.FieldOperatingSystem: + return m.OldOperatingSystem(ctx) + case scaauthuserdevice.FieldBrowserVersion: + return m.OldBrowserVersion(ctx) + case scaauthuserdevice.FieldMobile: + return m.OldMobile(ctx) + case scaauthuserdevice.FieldBot: + return m.OldBot(ctx) + case scaauthuserdevice.FieldMozilla: + return m.OldMozilla(ctx) + case scaauthuserdevice.FieldPlatform: + return m.OldPlatform(ctx) + case scaauthuserdevice.FieldEngineName: + return m.OldEngineName(ctx) + case scaauthuserdevice.FieldEngineVersion: + return m.OldEngineVersion(ctx) + } + return nil, fmt.Errorf("unknown ScaAuthUserDevice 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 *ScaAuthUserDeviceMutation) SetField(name string, value ent.Value) error { + switch name { + case scaauthuserdevice.FieldUserID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUserID(v) + return nil + case scaauthuserdevice.FieldIP: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetIP(v) + return nil + case scaauthuserdevice.FieldLocation: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocation(v) + return nil + case scaauthuserdevice.FieldAgent: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAgent(v) + return nil + case scaauthuserdevice.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + case scaauthuserdevice.FieldUpdateAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdateAt(v) + return nil + case scaauthuserdevice.FieldDeleted: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeleted(v) + return nil + case scaauthuserdevice.FieldBrowser: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetBrowser(v) + return nil + case scaauthuserdevice.FieldOperatingSystem: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetOperatingSystem(v) + return nil + case scaauthuserdevice.FieldBrowserVersion: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetBrowserVersion(v) + return nil + case scaauthuserdevice.FieldMobile: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMobile(v) + return nil + case scaauthuserdevice.FieldBot: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetBot(v) + return nil + case scaauthuserdevice.FieldMozilla: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMozilla(v) + return nil + case scaauthuserdevice.FieldPlatform: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPlatform(v) + return nil + case scaauthuserdevice.FieldEngineName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetEngineName(v) + return nil + case scaauthuserdevice.FieldEngineVersion: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetEngineVersion(v) + return nil + } + return fmt.Errorf("unknown ScaAuthUserDevice field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *ScaAuthUserDeviceMutation) AddedFields() []string { + var fields []string + if m.adddeleted != nil { + fields = append(fields, scaauthuserdevice.FieldDeleted) + } + if m.addmobile != nil { + fields = append(fields, scaauthuserdevice.FieldMobile) + } + if m.addbot != nil { + fields = append(fields, scaauthuserdevice.FieldBot) + } + 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 *ScaAuthUserDeviceMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case scaauthuserdevice.FieldDeleted: + return m.AddedDeleted() + case scaauthuserdevice.FieldMobile: + return m.AddedMobile() + case scaauthuserdevice.FieldBot: + return m.AddedBot() + } + 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 *ScaAuthUserDeviceMutation) AddField(name string, value ent.Value) error { + switch name { + case scaauthuserdevice.FieldDeleted: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddDeleted(v) + return nil + case scaauthuserdevice.FieldMobile: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddMobile(v) + return nil + case scaauthuserdevice.FieldBot: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddBot(v) + return nil + } + return fmt.Errorf("unknown ScaAuthUserDevice numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *ScaAuthUserDeviceMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(scaauthuserdevice.FieldCreatedAt) { + fields = append(fields, scaauthuserdevice.FieldCreatedAt) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *ScaAuthUserDeviceMutation) 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 *ScaAuthUserDeviceMutation) ClearField(name string) error { + switch name { + case scaauthuserdevice.FieldCreatedAt: + m.ClearCreatedAt() + return nil + } + return fmt.Errorf("unknown ScaAuthUserDevice 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 *ScaAuthUserDeviceMutation) ResetField(name string) error { + switch name { + case scaauthuserdevice.FieldUserID: + m.ResetUserID() + return nil + case scaauthuserdevice.FieldIP: + m.ResetIP() + return nil + case scaauthuserdevice.FieldLocation: + m.ResetLocation() + return nil + case scaauthuserdevice.FieldAgent: + m.ResetAgent() + return nil + case scaauthuserdevice.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case scaauthuserdevice.FieldUpdateAt: + m.ResetUpdateAt() + return nil + case scaauthuserdevice.FieldDeleted: + m.ResetDeleted() + return nil + case scaauthuserdevice.FieldBrowser: + m.ResetBrowser() + return nil + case scaauthuserdevice.FieldOperatingSystem: + m.ResetOperatingSystem() + return nil + case scaauthuserdevice.FieldBrowserVersion: + m.ResetBrowserVersion() + return nil + case scaauthuserdevice.FieldMobile: + m.ResetMobile() + return nil + case scaauthuserdevice.FieldBot: + m.ResetBot() + return nil + case scaauthuserdevice.FieldMozilla: + m.ResetMozilla() + return nil + case scaauthuserdevice.FieldPlatform: + m.ResetPlatform() + return nil + case scaauthuserdevice.FieldEngineName: + m.ResetEngineName() + return nil + case scaauthuserdevice.FieldEngineVersion: + m.ResetEngineVersion() + return nil + } + return fmt.Errorf("unknown ScaAuthUserDevice field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *ScaAuthUserDeviceMutation) AddedEdges() []string { + edges := make([]string, 0, 1) + if m.sca_auth_user != nil { + edges = append(edges, scaauthuserdevice.EdgeScaAuthUser) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *ScaAuthUserDeviceMutation) AddedIDs(name string) []ent.Value { + switch name { + case scaauthuserdevice.EdgeScaAuthUser: + if id := m.sca_auth_user; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *ScaAuthUserDeviceMutation) RemovedEdges() []string { + edges := make([]string, 0, 1) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *ScaAuthUserDeviceMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *ScaAuthUserDeviceMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) + if m.clearedsca_auth_user { + edges = append(edges, scaauthuserdevice.EdgeScaAuthUser) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *ScaAuthUserDeviceMutation) EdgeCleared(name string) bool { + switch name { + case scaauthuserdevice.EdgeScaAuthUser: + return m.clearedsca_auth_user + } + 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 *ScaAuthUserDeviceMutation) ClearEdge(name string) error { + switch name { + case scaauthuserdevice.EdgeScaAuthUser: + m.ClearScaAuthUser() + return nil + } + return fmt.Errorf("unknown ScaAuthUserDevice 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 *ScaAuthUserDeviceMutation) ResetEdge(name string) error { + switch name { + case scaauthuserdevice.EdgeScaAuthUser: + m.ResetScaAuthUser() + return nil + } + return fmt.Errorf("unknown ScaAuthUserDevice edge %s", name) +} + +// ScaAuthUserSocialMutation represents an operation that mutates the ScaAuthUserSocial nodes in the graph. +type ScaAuthUserSocialMutation struct { + config + op Op + typ string + id *int64 + user_id *string + open_id *string + source *string + status *int + addstatus *int + created_at *time.Time + update_at *time.Time + deleted *int + adddeleted *int + clearedFields map[string]struct{} + sca_auth_user *int64 + clearedsca_auth_user bool + done bool + oldValue func(context.Context) (*ScaAuthUserSocial, error) + predicates []predicate.ScaAuthUserSocial +} + +var _ ent.Mutation = (*ScaAuthUserSocialMutation)(nil) + +// scaauthusersocialOption allows management of the mutation configuration using functional options. +type scaauthusersocialOption func(*ScaAuthUserSocialMutation) + +// newScaAuthUserSocialMutation creates new mutation for the ScaAuthUserSocial entity. +func newScaAuthUserSocialMutation(c config, op Op, opts ...scaauthusersocialOption) *ScaAuthUserSocialMutation { + m := &ScaAuthUserSocialMutation{ + config: c, + op: op, + typ: TypeScaAuthUserSocial, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withScaAuthUserSocialID sets the ID field of the mutation. +func withScaAuthUserSocialID(id int64) scaauthusersocialOption { + return func(m *ScaAuthUserSocialMutation) { + var ( + err error + once sync.Once + value *ScaAuthUserSocial + ) + m.oldValue = func(ctx context.Context) (*ScaAuthUserSocial, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().ScaAuthUserSocial.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withScaAuthUserSocial sets the old ScaAuthUserSocial of the mutation. +func withScaAuthUserSocial(node *ScaAuthUserSocial) scaauthusersocialOption { + return func(m *ScaAuthUserSocialMutation) { + m.oldValue = func(context.Context) (*ScaAuthUserSocial, 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 ScaAuthUserSocialMutation) 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 ScaAuthUserSocialMutation) 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 ScaAuthUserSocial entities. +func (m *ScaAuthUserSocialMutation) 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 *ScaAuthUserSocialMutation) 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 *ScaAuthUserSocialMutation) 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().ScaAuthUserSocial.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetUserID sets the "user_id" field. +func (m *ScaAuthUserSocialMutation) SetUserID(s string) { + m.user_id = &s +} + +// UserID returns the value of the "user_id" field in the mutation. +func (m *ScaAuthUserSocialMutation) UserID() (r string, exists bool) { + v := m.user_id + if v == nil { + return + } + return *v, true +} + +// OldUserID returns the old "user_id" field's value of the ScaAuthUserSocial entity. +// If the ScaAuthUserSocial 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 *ScaAuthUserSocialMutation) OldUserID(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUserID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUserID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUserID: %w", err) + } + return oldValue.UserID, nil +} + +// ResetUserID resets all changes to the "user_id" field. +func (m *ScaAuthUserSocialMutation) ResetUserID() { + m.user_id = nil +} + +// SetOpenID sets the "open_id" field. +func (m *ScaAuthUserSocialMutation) SetOpenID(s string) { + m.open_id = &s +} + +// OpenID returns the value of the "open_id" field in the mutation. +func (m *ScaAuthUserSocialMutation) OpenID() (r string, exists bool) { + v := m.open_id + if v == nil { + return + } + return *v, true +} + +// OldOpenID returns the old "open_id" field's value of the ScaAuthUserSocial entity. +// If the ScaAuthUserSocial 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 *ScaAuthUserSocialMutation) OldOpenID(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldOpenID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldOpenID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldOpenID: %w", err) + } + return oldValue.OpenID, nil +} + +// ResetOpenID resets all changes to the "open_id" field. +func (m *ScaAuthUserSocialMutation) ResetOpenID() { + m.open_id = nil +} + +// SetSource sets the "source" field. +func (m *ScaAuthUserSocialMutation) SetSource(s string) { + m.source = &s +} + +// Source returns the value of the "source" field in the mutation. +func (m *ScaAuthUserSocialMutation) Source() (r string, exists bool) { + v := m.source + if v == nil { + return + } + return *v, true +} + +// OldSource returns the old "source" field's value of the ScaAuthUserSocial entity. +// If the ScaAuthUserSocial 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 *ScaAuthUserSocialMutation) OldSource(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSource is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSource requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSource: %w", err) + } + return oldValue.Source, nil +} + +// ResetSource resets all changes to the "source" field. +func (m *ScaAuthUserSocialMutation) ResetSource() { + m.source = nil +} + +// SetStatus sets the "status" field. +func (m *ScaAuthUserSocialMutation) SetStatus(i int) { + m.status = &i + m.addstatus = nil +} + +// Status returns the value of the "status" field in the mutation. +func (m *ScaAuthUserSocialMutation) 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 ScaAuthUserSocial entity. +// If the ScaAuthUserSocial 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 *ScaAuthUserSocialMutation) 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 *ScaAuthUserSocialMutation) 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 *ScaAuthUserSocialMutation) 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 *ScaAuthUserSocialMutation) ResetStatus() { + m.status = nil + m.addstatus = nil +} + +// SetCreatedAt sets the "created_at" field. +func (m *ScaAuthUserSocialMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *ScaAuthUserSocialMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "created_at" field's value of the ScaAuthUserSocial entity. +// If the ScaAuthUserSocial 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 *ScaAuthUserSocialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *ScaAuthUserSocialMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdateAt sets the "update_at" field. +func (m *ScaAuthUserSocialMutation) SetUpdateAt(t time.Time) { + m.update_at = &t +} + +// UpdateAt returns the value of the "update_at" field in the mutation. +func (m *ScaAuthUserSocialMutation) UpdateAt() (r time.Time, exists bool) { + v := m.update_at + if v == nil { + return + } + return *v, true +} + +// OldUpdateAt returns the old "update_at" field's value of the ScaAuthUserSocial entity. +// If the ScaAuthUserSocial 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 *ScaAuthUserSocialMutation) OldUpdateAt(ctx context.Context) (v *time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateAt: %w", err) + } + return oldValue.UpdateAt, nil +} + +// ClearUpdateAt clears the value of the "update_at" field. +func (m *ScaAuthUserSocialMutation) ClearUpdateAt() { + m.update_at = nil + m.clearedFields[scaauthusersocial.FieldUpdateAt] = struct{}{} +} + +// UpdateAtCleared returns if the "update_at" field was cleared in this mutation. +func (m *ScaAuthUserSocialMutation) UpdateAtCleared() bool { + _, ok := m.clearedFields[scaauthusersocial.FieldUpdateAt] + return ok +} + +// ResetUpdateAt resets all changes to the "update_at" field. +func (m *ScaAuthUserSocialMutation) ResetUpdateAt() { + m.update_at = nil + delete(m.clearedFields, scaauthusersocial.FieldUpdateAt) +} + +// SetDeleted sets the "deleted" field. +func (m *ScaAuthUserSocialMutation) SetDeleted(i int) { + m.deleted = &i + m.adddeleted = nil +} + +// Deleted returns the value of the "deleted" field in the mutation. +func (m *ScaAuthUserSocialMutation) 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 ScaAuthUserSocial entity. +// If the ScaAuthUserSocial 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 *ScaAuthUserSocialMutation) 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 *ScaAuthUserSocialMutation) 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 *ScaAuthUserSocialMutation) 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 *ScaAuthUserSocialMutation) ResetDeleted() { + m.deleted = nil + m.adddeleted = nil +} + +// SetScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by id. +func (m *ScaAuthUserSocialMutation) SetScaAuthUserID(id int64) { + m.sca_auth_user = &id +} + +// ClearScaAuthUser clears the "sca_auth_user" edge to the ScaAuthUser entity. +func (m *ScaAuthUserSocialMutation) ClearScaAuthUser() { + m.clearedsca_auth_user = true +} + +// ScaAuthUserCleared reports if the "sca_auth_user" edge to the ScaAuthUser entity was cleared. +func (m *ScaAuthUserSocialMutation) ScaAuthUserCleared() bool { + return m.clearedsca_auth_user +} + +// ScaAuthUserID returns the "sca_auth_user" edge ID in the mutation. +func (m *ScaAuthUserSocialMutation) ScaAuthUserID() (id int64, exists bool) { + if m.sca_auth_user != nil { + return *m.sca_auth_user, true + } + return +} + +// ScaAuthUserIDs returns the "sca_auth_user" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// ScaAuthUserID instead. It exists only for internal usage by the builders. +func (m *ScaAuthUserSocialMutation) ScaAuthUserIDs() (ids []int64) { + if id := m.sca_auth_user; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetScaAuthUser resets all changes to the "sca_auth_user" edge. +func (m *ScaAuthUserSocialMutation) ResetScaAuthUser() { + m.sca_auth_user = nil + m.clearedsca_auth_user = false +} + +// Where appends a list predicates to the ScaAuthUserSocialMutation builder. +func (m *ScaAuthUserSocialMutation) Where(ps ...predicate.ScaAuthUserSocial) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the ScaAuthUserSocialMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *ScaAuthUserSocialMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.ScaAuthUserSocial, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *ScaAuthUserSocialMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *ScaAuthUserSocialMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (ScaAuthUserSocial). +func (m *ScaAuthUserSocialMutation) 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 *ScaAuthUserSocialMutation) Fields() []string { + fields := make([]string, 0, 7) + if m.user_id != nil { + fields = append(fields, scaauthusersocial.FieldUserID) + } + if m.open_id != nil { + fields = append(fields, scaauthusersocial.FieldOpenID) + } + if m.source != nil { + fields = append(fields, scaauthusersocial.FieldSource) + } + if m.status != nil { + fields = append(fields, scaauthusersocial.FieldStatus) + } + if m.created_at != nil { + fields = append(fields, scaauthusersocial.FieldCreatedAt) + } + if m.update_at != nil { + fields = append(fields, scaauthusersocial.FieldUpdateAt) + } + if m.deleted != nil { + fields = append(fields, scaauthusersocial.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 *ScaAuthUserSocialMutation) Field(name string) (ent.Value, bool) { + switch name { + case scaauthusersocial.FieldUserID: + return m.UserID() + case scaauthusersocial.FieldOpenID: + return m.OpenID() + case scaauthusersocial.FieldSource: + return m.Source() + case scaauthusersocial.FieldStatus: + return m.Status() + case scaauthusersocial.FieldCreatedAt: + return m.CreatedAt() + case scaauthusersocial.FieldUpdateAt: + return m.UpdateAt() + case scaauthusersocial.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 *ScaAuthUserSocialMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case scaauthusersocial.FieldUserID: + return m.OldUserID(ctx) + case scaauthusersocial.FieldOpenID: + return m.OldOpenID(ctx) + case scaauthusersocial.FieldSource: + return m.OldSource(ctx) + case scaauthusersocial.FieldStatus: + return m.OldStatus(ctx) + case scaauthusersocial.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case scaauthusersocial.FieldUpdateAt: + return m.OldUpdateAt(ctx) + case scaauthusersocial.FieldDeleted: + return m.OldDeleted(ctx) + } + return nil, fmt.Errorf("unknown ScaAuthUserSocial 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 *ScaAuthUserSocialMutation) SetField(name string, value ent.Value) error { + switch name { + case scaauthusersocial.FieldUserID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUserID(v) + return nil + case scaauthusersocial.FieldOpenID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetOpenID(v) + return nil + case scaauthusersocial.FieldSource: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSource(v) + return nil + case scaauthusersocial.FieldStatus: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStatus(v) + return nil + case scaauthusersocial.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + case scaauthusersocial.FieldUpdateAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdateAt(v) + return nil + case scaauthusersocial.FieldDeleted: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeleted(v) + return nil + } + return fmt.Errorf("unknown ScaAuthUserSocial field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *ScaAuthUserSocialMutation) AddedFields() []string { + var fields []string + if m.addstatus != nil { + fields = append(fields, scaauthusersocial.FieldStatus) + } + if m.adddeleted != nil { + fields = append(fields, scaauthusersocial.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 *ScaAuthUserSocialMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case scaauthusersocial.FieldStatus: + return m.AddedStatus() + case scaauthusersocial.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 *ScaAuthUserSocialMutation) AddField(name string, value ent.Value) error { + switch name { + case scaauthusersocial.FieldStatus: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddStatus(v) + return nil + case scaauthusersocial.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 ScaAuthUserSocial numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *ScaAuthUserSocialMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(scaauthusersocial.FieldUpdateAt) { + fields = append(fields, scaauthusersocial.FieldUpdateAt) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *ScaAuthUserSocialMutation) 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 *ScaAuthUserSocialMutation) ClearField(name string) error { + switch name { + case scaauthusersocial.FieldUpdateAt: + m.ClearUpdateAt() + return nil + } + return fmt.Errorf("unknown ScaAuthUserSocial 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 *ScaAuthUserSocialMutation) ResetField(name string) error { + switch name { + case scaauthusersocial.FieldUserID: + m.ResetUserID() + return nil + case scaauthusersocial.FieldOpenID: + m.ResetOpenID() + return nil + case scaauthusersocial.FieldSource: + m.ResetSource() + return nil + case scaauthusersocial.FieldStatus: + m.ResetStatus() + return nil + case scaauthusersocial.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case scaauthusersocial.FieldUpdateAt: + m.ResetUpdateAt() + return nil + case scaauthusersocial.FieldDeleted: + m.ResetDeleted() + return nil + } + return fmt.Errorf("unknown ScaAuthUserSocial field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *ScaAuthUserSocialMutation) AddedEdges() []string { + edges := make([]string, 0, 1) + if m.sca_auth_user != nil { + edges = append(edges, scaauthusersocial.EdgeScaAuthUser) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *ScaAuthUserSocialMutation) AddedIDs(name string) []ent.Value { + switch name { + case scaauthusersocial.EdgeScaAuthUser: + if id := m.sca_auth_user; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *ScaAuthUserSocialMutation) RemovedEdges() []string { + edges := make([]string, 0, 1) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *ScaAuthUserSocialMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *ScaAuthUserSocialMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) + if m.clearedsca_auth_user { + edges = append(edges, scaauthusersocial.EdgeScaAuthUser) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *ScaAuthUserSocialMutation) EdgeCleared(name string) bool { + switch name { + case scaauthusersocial.EdgeScaAuthUser: + return m.clearedsca_auth_user + } + 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 *ScaAuthUserSocialMutation) ClearEdge(name string) error { + switch name { + case scaauthusersocial.EdgeScaAuthUser: + m.ClearScaAuthUser() + return nil + } + return fmt.Errorf("unknown ScaAuthUserSocial 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 *ScaAuthUserSocialMutation) ResetEdge(name string) error { + switch name { + case scaauthusersocial.EdgeScaAuthUser: + m.ResetScaAuthUser() + return nil + } + return fmt.Errorf("unknown ScaAuthUserSocial edge %s", name) +} diff --git a/common/ent/predicate/predicate.go b/common/ent/predicate/predicate.go new file mode 100644 index 0000000..5c09475 --- /dev/null +++ b/common/ent/predicate/predicate.go @@ -0,0 +1,22 @@ +// Code generated by ent, DO NOT EDIT. + +package predicate + +import ( + "entgo.io/ent/dialect/sql" +) + +// ScaAuthPermissionRule is the predicate function for scaauthpermissionrule builders. +type ScaAuthPermissionRule func(*sql.Selector) + +// ScaAuthRole is the predicate function for scaauthrole builders. +type ScaAuthRole func(*sql.Selector) + +// ScaAuthUser is the predicate function for scaauthuser builders. +type ScaAuthUser func(*sql.Selector) + +// ScaAuthUserDevice is the predicate function for scaauthuserdevice builders. +type ScaAuthUserDevice func(*sql.Selector) + +// ScaAuthUserSocial is the predicate function for scaauthusersocial builders. +type ScaAuthUserSocial func(*sql.Selector) diff --git a/common/ent/runtime.go b/common/ent/runtime.go new file mode 100644 index 0000000..8ffb7e2 --- /dev/null +++ b/common/ent/runtime.go @@ -0,0 +1,229 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "schisandra-album-cloud-microservices/common/ent/scaauthpermissionrule" + "schisandra-album-cloud-microservices/common/ent/scaauthrole" + "schisandra-album-cloud-microservices/common/ent/scaauthuser" + "schisandra-album-cloud-microservices/common/ent/scaauthuserdevice" + "schisandra-album-cloud-microservices/common/ent/scaauthusersocial" + "schisandra-album-cloud-microservices/common/ent/schema" + "time" +) + +// 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() { + scaauthpermissionruleFields := schema.ScaAuthPermissionRule{}.Fields() + _ = scaauthpermissionruleFields + // scaauthpermissionruleDescPtype is the schema descriptor for ptype field. + scaauthpermissionruleDescPtype := scaauthpermissionruleFields[1].Descriptor() + // scaauthpermissionrule.PtypeValidator is a validator for the "ptype" field. It is called by the builders before save. + scaauthpermissionrule.PtypeValidator = scaauthpermissionruleDescPtype.Validators[0].(func(string) error) + // scaauthpermissionruleDescV0 is the schema descriptor for v0 field. + scaauthpermissionruleDescV0 := scaauthpermissionruleFields[2].Descriptor() + // scaauthpermissionrule.V0Validator is a validator for the "v0" field. It is called by the builders before save. + scaauthpermissionrule.V0Validator = scaauthpermissionruleDescV0.Validators[0].(func(string) error) + // scaauthpermissionruleDescV1 is the schema descriptor for v1 field. + scaauthpermissionruleDescV1 := scaauthpermissionruleFields[3].Descriptor() + // scaauthpermissionrule.V1Validator is a validator for the "v1" field. It is called by the builders before save. + scaauthpermissionrule.V1Validator = scaauthpermissionruleDescV1.Validators[0].(func(string) error) + // scaauthpermissionruleDescV2 is the schema descriptor for v2 field. + scaauthpermissionruleDescV2 := scaauthpermissionruleFields[4].Descriptor() + // scaauthpermissionrule.V2Validator is a validator for the "v2" field. It is called by the builders before save. + scaauthpermissionrule.V2Validator = scaauthpermissionruleDescV2.Validators[0].(func(string) error) + // scaauthpermissionruleDescV3 is the schema descriptor for v3 field. + scaauthpermissionruleDescV3 := scaauthpermissionruleFields[5].Descriptor() + // scaauthpermissionrule.V3Validator is a validator for the "v3" field. It is called by the builders before save. + scaauthpermissionrule.V3Validator = scaauthpermissionruleDescV3.Validators[0].(func(string) error) + // scaauthpermissionruleDescV4 is the schema descriptor for v4 field. + scaauthpermissionruleDescV4 := scaauthpermissionruleFields[6].Descriptor() + // scaauthpermissionrule.V4Validator is a validator for the "v4" field. It is called by the builders before save. + scaauthpermissionrule.V4Validator = scaauthpermissionruleDescV4.Validators[0].(func(string) error) + // scaauthpermissionruleDescV5 is the schema descriptor for v5 field. + scaauthpermissionruleDescV5 := scaauthpermissionruleFields[7].Descriptor() + // scaauthpermissionrule.V5Validator is a validator for the "v5" field. It is called by the builders before save. + scaauthpermissionrule.V5Validator = scaauthpermissionruleDescV5.Validators[0].(func(string) error) + scaauthroleFields := schema.ScaAuthRole{}.Fields() + _ = scaauthroleFields + // scaauthroleDescRoleName is the schema descriptor for role_name field. + scaauthroleDescRoleName := scaauthroleFields[1].Descriptor() + // scaauthrole.RoleNameValidator is a validator for the "role_name" field. It is called by the builders before save. + scaauthrole.RoleNameValidator = scaauthroleDescRoleName.Validators[0].(func(string) error) + // scaauthroleDescRoleKey is the schema descriptor for role_key field. + scaauthroleDescRoleKey := scaauthroleFields[2].Descriptor() + // scaauthrole.RoleKeyValidator is a validator for the "role_key" field. It is called by the builders before save. + scaauthrole.RoleKeyValidator = scaauthroleDescRoleKey.Validators[0].(func(string) error) + // scaauthroleDescCreatedAt is the schema descriptor for created_at field. + scaauthroleDescCreatedAt := scaauthroleFields[3].Descriptor() + // scaauthrole.DefaultCreatedAt holds the default value on creation for the created_at field. + scaauthrole.DefaultCreatedAt = scaauthroleDescCreatedAt.Default.(func() time.Time) + // scaauthroleDescUpdateAt is the schema descriptor for update_at field. + scaauthroleDescUpdateAt := scaauthroleFields[4].Descriptor() + // scaauthrole.DefaultUpdateAt holds the default value on creation for the update_at field. + scaauthrole.DefaultUpdateAt = scaauthroleDescUpdateAt.Default.(func() time.Time) + // scaauthrole.UpdateDefaultUpdateAt holds the default value on update for the update_at field. + scaauthrole.UpdateDefaultUpdateAt = scaauthroleDescUpdateAt.UpdateDefault.(func() time.Time) + // scaauthroleDescDeleted is the schema descriptor for deleted field. + scaauthroleDescDeleted := scaauthroleFields[5].Descriptor() + // scaauthrole.DefaultDeleted holds the default value on creation for the deleted field. + scaauthrole.DefaultDeleted = scaauthroleDescDeleted.Default.(int) + scaauthuserFields := schema.ScaAuthUser{}.Fields() + _ = scaauthuserFields + // scaauthuserDescUID is the schema descriptor for uid field. + scaauthuserDescUID := scaauthuserFields[1].Descriptor() + // scaauthuser.UIDValidator is a validator for the "uid" field. It is called by the builders before save. + scaauthuser.UIDValidator = scaauthuserDescUID.Validators[0].(func(string) error) + // scaauthuserDescUsername is the schema descriptor for username field. + scaauthuserDescUsername := scaauthuserFields[2].Descriptor() + // scaauthuser.UsernameValidator is a validator for the "username" field. It is called by the builders before save. + scaauthuser.UsernameValidator = scaauthuserDescUsername.Validators[0].(func(string) error) + // scaauthuserDescNickname is the schema descriptor for nickname field. + scaauthuserDescNickname := scaauthuserFields[3].Descriptor() + // scaauthuser.NicknameValidator is a validator for the "nickname" field. It is called by the builders before save. + scaauthuser.NicknameValidator = scaauthuserDescNickname.Validators[0].(func(string) error) + // scaauthuserDescEmail is the schema descriptor for email field. + scaauthuserDescEmail := scaauthuserFields[4].Descriptor() + // scaauthuser.EmailValidator is a validator for the "email" field. It is called by the builders before save. + scaauthuser.EmailValidator = scaauthuserDescEmail.Validators[0].(func(string) error) + // scaauthuserDescPhone is the schema descriptor for phone field. + scaauthuserDescPhone := scaauthuserFields[5].Descriptor() + // scaauthuser.PhoneValidator is a validator for the "phone" field. It is called by the builders before save. + scaauthuser.PhoneValidator = scaauthuserDescPhone.Validators[0].(func(string) error) + // scaauthuserDescPassword is the schema descriptor for password field. + scaauthuserDescPassword := scaauthuserFields[6].Descriptor() + // scaauthuser.PasswordValidator is a validator for the "password" field. It is called by the builders before save. + scaauthuser.PasswordValidator = scaauthuserDescPassword.Validators[0].(func(string) error) + // scaauthuserDescGender is the schema descriptor for gender field. + scaauthuserDescGender := scaauthuserFields[7].Descriptor() + // scaauthuser.GenderValidator is a validator for the "gender" field. It is called by the builders before save. + scaauthuser.GenderValidator = scaauthuserDescGender.Validators[0].(func(string) error) + // scaauthuserDescStatus is the schema descriptor for status field. + scaauthuserDescStatus := scaauthuserFields[9].Descriptor() + // scaauthuser.DefaultStatus holds the default value on creation for the status field. + scaauthuser.DefaultStatus = scaauthuserDescStatus.Default.(int8) + // scaauthuserDescIntroduce is the schema descriptor for introduce field. + scaauthuserDescIntroduce := scaauthuserFields[10].Descriptor() + // scaauthuser.IntroduceValidator is a validator for the "introduce" field. It is called by the builders before save. + scaauthuser.IntroduceValidator = scaauthuserDescIntroduce.Validators[0].(func(string) error) + // scaauthuserDescCreatedAt is the schema descriptor for created_at field. + scaauthuserDescCreatedAt := scaauthuserFields[11].Descriptor() + // scaauthuser.DefaultCreatedAt holds the default value on creation for the created_at field. + scaauthuser.DefaultCreatedAt = scaauthuserDescCreatedAt.Default.(func() time.Time) + // scaauthuserDescUpdateAt is the schema descriptor for update_at field. + scaauthuserDescUpdateAt := scaauthuserFields[12].Descriptor() + // scaauthuser.DefaultUpdateAt holds the default value on creation for the update_at field. + scaauthuser.DefaultUpdateAt = scaauthuserDescUpdateAt.Default.(func() time.Time) + // scaauthuser.UpdateDefaultUpdateAt holds the default value on update for the update_at field. + scaauthuser.UpdateDefaultUpdateAt = scaauthuserDescUpdateAt.UpdateDefault.(func() time.Time) + // scaauthuserDescDeleted is the schema descriptor for deleted field. + scaauthuserDescDeleted := scaauthuserFields[13].Descriptor() + // scaauthuser.DefaultDeleted holds the default value on creation for the deleted field. + scaauthuser.DefaultDeleted = scaauthuserDescDeleted.Default.(int8) + // scaauthuserDescBlog is the schema descriptor for blog field. + scaauthuserDescBlog := scaauthuserFields[14].Descriptor() + // scaauthuser.BlogValidator is a validator for the "blog" field. It is called by the builders before save. + scaauthuser.BlogValidator = scaauthuserDescBlog.Validators[0].(func(string) error) + // scaauthuserDescLocation is the schema descriptor for location field. + scaauthuserDescLocation := scaauthuserFields[15].Descriptor() + // scaauthuser.LocationValidator is a validator for the "location" field. It is called by the builders before save. + scaauthuser.LocationValidator = scaauthuserDescLocation.Validators[0].(func(string) error) + // scaauthuserDescCompany is the schema descriptor for company field. + scaauthuserDescCompany := scaauthuserFields[16].Descriptor() + // scaauthuser.CompanyValidator is a validator for the "company" field. It is called by the builders before save. + scaauthuser.CompanyValidator = scaauthuserDescCompany.Validators[0].(func(string) error) + scaauthuserdeviceFields := schema.ScaAuthUserDevice{}.Fields() + _ = scaauthuserdeviceFields + // scaauthuserdeviceDescUserID is the schema descriptor for user_id field. + scaauthuserdeviceDescUserID := scaauthuserdeviceFields[1].Descriptor() + // scaauthuserdevice.UserIDValidator is a validator for the "user_id" field. It is called by the builders before save. + scaauthuserdevice.UserIDValidator = scaauthuserdeviceDescUserID.Validators[0].(func(string) error) + // scaauthuserdeviceDescIP is the schema descriptor for ip field. + scaauthuserdeviceDescIP := scaauthuserdeviceFields[2].Descriptor() + // scaauthuserdevice.IPValidator is a validator for the "ip" field. It is called by the builders before save. + scaauthuserdevice.IPValidator = scaauthuserdeviceDescIP.Validators[0].(func(string) error) + // scaauthuserdeviceDescLocation is the schema descriptor for location field. + scaauthuserdeviceDescLocation := scaauthuserdeviceFields[3].Descriptor() + // scaauthuserdevice.LocationValidator is a validator for the "location" field. It is called by the builders before save. + scaauthuserdevice.LocationValidator = scaauthuserdeviceDescLocation.Validators[0].(func(string) error) + // scaauthuserdeviceDescAgent is the schema descriptor for agent field. + scaauthuserdeviceDescAgent := scaauthuserdeviceFields[4].Descriptor() + // scaauthuserdevice.AgentValidator is a validator for the "agent" field. It is called by the builders before save. + scaauthuserdevice.AgentValidator = scaauthuserdeviceDescAgent.Validators[0].(func(string) error) + // scaauthuserdeviceDescCreatedAt is the schema descriptor for created_at field. + scaauthuserdeviceDescCreatedAt := scaauthuserdeviceFields[5].Descriptor() + // scaauthuserdevice.DefaultCreatedAt holds the default value on creation for the created_at field. + scaauthuserdevice.DefaultCreatedAt = scaauthuserdeviceDescCreatedAt.Default.(func() time.Time) + // scaauthuserdeviceDescUpdateAt is the schema descriptor for update_at field. + scaauthuserdeviceDescUpdateAt := scaauthuserdeviceFields[6].Descriptor() + // scaauthuserdevice.DefaultUpdateAt holds the default value on creation for the update_at field. + scaauthuserdevice.DefaultUpdateAt = scaauthuserdeviceDescUpdateAt.Default.(func() time.Time) + // scaauthuserdevice.UpdateDefaultUpdateAt holds the default value on update for the update_at field. + scaauthuserdevice.UpdateDefaultUpdateAt = scaauthuserdeviceDescUpdateAt.UpdateDefault.(func() time.Time) + // scaauthuserdeviceDescDeleted is the schema descriptor for deleted field. + scaauthuserdeviceDescDeleted := scaauthuserdeviceFields[7].Descriptor() + // scaauthuserdevice.DefaultDeleted holds the default value on creation for the deleted field. + scaauthuserdevice.DefaultDeleted = scaauthuserdeviceDescDeleted.Default.(int) + // scaauthuserdeviceDescBrowser is the schema descriptor for browser field. + scaauthuserdeviceDescBrowser := scaauthuserdeviceFields[8].Descriptor() + // scaauthuserdevice.BrowserValidator is a validator for the "browser" field. It is called by the builders before save. + scaauthuserdevice.BrowserValidator = scaauthuserdeviceDescBrowser.Validators[0].(func(string) error) + // scaauthuserdeviceDescOperatingSystem is the schema descriptor for operating_system field. + scaauthuserdeviceDescOperatingSystem := scaauthuserdeviceFields[9].Descriptor() + // scaauthuserdevice.OperatingSystemValidator is a validator for the "operating_system" field. It is called by the builders before save. + scaauthuserdevice.OperatingSystemValidator = scaauthuserdeviceDescOperatingSystem.Validators[0].(func(string) error) + // scaauthuserdeviceDescBrowserVersion is the schema descriptor for browser_version field. + scaauthuserdeviceDescBrowserVersion := scaauthuserdeviceFields[10].Descriptor() + // scaauthuserdevice.BrowserVersionValidator is a validator for the "browser_version" field. It is called by the builders before save. + scaauthuserdevice.BrowserVersionValidator = scaauthuserdeviceDescBrowserVersion.Validators[0].(func(string) error) + // scaauthuserdeviceDescMozilla is the schema descriptor for mozilla field. + scaauthuserdeviceDescMozilla := scaauthuserdeviceFields[13].Descriptor() + // scaauthuserdevice.MozillaValidator is a validator for the "mozilla" field. It is called by the builders before save. + scaauthuserdevice.MozillaValidator = scaauthuserdeviceDescMozilla.Validators[0].(func(string) error) + // scaauthuserdeviceDescPlatform is the schema descriptor for platform field. + scaauthuserdeviceDescPlatform := scaauthuserdeviceFields[14].Descriptor() + // scaauthuserdevice.PlatformValidator is a validator for the "platform" field. It is called by the builders before save. + scaauthuserdevice.PlatformValidator = scaauthuserdeviceDescPlatform.Validators[0].(func(string) error) + // scaauthuserdeviceDescEngineName is the schema descriptor for engine_name field. + scaauthuserdeviceDescEngineName := scaauthuserdeviceFields[15].Descriptor() + // scaauthuserdevice.EngineNameValidator is a validator for the "engine_name" field. It is called by the builders before save. + scaauthuserdevice.EngineNameValidator = scaauthuserdeviceDescEngineName.Validators[0].(func(string) error) + // scaauthuserdeviceDescEngineVersion is the schema descriptor for engine_version field. + scaauthuserdeviceDescEngineVersion := scaauthuserdeviceFields[16].Descriptor() + // scaauthuserdevice.EngineVersionValidator is a validator for the "engine_version" field. It is called by the builders before save. + scaauthuserdevice.EngineVersionValidator = scaauthuserdeviceDescEngineVersion.Validators[0].(func(string) error) + scaauthusersocialFields := schema.ScaAuthUserSocial{}.Fields() + _ = scaauthusersocialFields + // scaauthusersocialDescUserID is the schema descriptor for user_id field. + scaauthusersocialDescUserID := scaauthusersocialFields[1].Descriptor() + // scaauthusersocial.UserIDValidator is a validator for the "user_id" field. It is called by the builders before save. + scaauthusersocial.UserIDValidator = scaauthusersocialDescUserID.Validators[0].(func(string) error) + // scaauthusersocialDescOpenID is the schema descriptor for open_id field. + scaauthusersocialDescOpenID := scaauthusersocialFields[2].Descriptor() + // scaauthusersocial.OpenIDValidator is a validator for the "open_id" field. It is called by the builders before save. + scaauthusersocial.OpenIDValidator = scaauthusersocialDescOpenID.Validators[0].(func(string) error) + // scaauthusersocialDescSource is the schema descriptor for source field. + scaauthusersocialDescSource := scaauthusersocialFields[3].Descriptor() + // scaauthusersocial.SourceValidator is a validator for the "source" field. It is called by the builders before save. + scaauthusersocial.SourceValidator = scaauthusersocialDescSource.Validators[0].(func(string) error) + // scaauthusersocialDescStatus is the schema descriptor for status field. + scaauthusersocialDescStatus := scaauthusersocialFields[4].Descriptor() + // scaauthusersocial.DefaultStatus holds the default value on creation for the status field. + scaauthusersocial.DefaultStatus = scaauthusersocialDescStatus.Default.(int) + // scaauthusersocialDescCreatedAt is the schema descriptor for created_at field. + scaauthusersocialDescCreatedAt := scaauthusersocialFields[5].Descriptor() + // scaauthusersocial.DefaultCreatedAt holds the default value on creation for the created_at field. + scaauthusersocial.DefaultCreatedAt = scaauthusersocialDescCreatedAt.Default.(func() time.Time) + // scaauthusersocialDescUpdateAt is the schema descriptor for update_at field. + scaauthusersocialDescUpdateAt := scaauthusersocialFields[6].Descriptor() + // scaauthusersocial.DefaultUpdateAt holds the default value on creation for the update_at field. + scaauthusersocial.DefaultUpdateAt = scaauthusersocialDescUpdateAt.Default.(func() time.Time) + // scaauthusersocial.UpdateDefaultUpdateAt holds the default value on update for the update_at field. + scaauthusersocial.UpdateDefaultUpdateAt = scaauthusersocialDescUpdateAt.UpdateDefault.(func() time.Time) + // scaauthusersocialDescDeleted is the schema descriptor for deleted field. + scaauthusersocialDescDeleted := scaauthusersocialFields[7].Descriptor() + // scaauthusersocial.DefaultDeleted holds the default value on creation for the deleted field. + scaauthusersocial.DefaultDeleted = scaauthusersocialDescDeleted.Default.(int) +} diff --git a/common/ent/runtime/runtime.go b/common/ent/runtime/runtime.go new file mode 100644 index 0000000..5f5d79d --- /dev/null +++ b/common/ent/runtime/runtime.go @@ -0,0 +1,10 @@ +// Code generated by ent, DO NOT EDIT. + +package runtime + +// The schema-stitching logic is generated in schisandra-album-cloud-microservices/common/ent/runtime.go + +const ( + Version = "v0.14.1" // Version of ent codegen. + Sum = "h1:fUERL506Pqr92EPHJqr8EYxbPioflJo6PudkrEA8a/s=" // Sum of ent codegen. +) diff --git a/common/ent/scaauthpermissionrule.go b/common/ent/scaauthpermissionrule.go new file mode 100644 index 0000000..ed0af86 --- /dev/null +++ b/common/ent/scaauthpermissionrule.go @@ -0,0 +1,229 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "schisandra-album-cloud-microservices/common/ent/scaauthpermissionrule" + "schisandra-album-cloud-microservices/common/ent/scaauthrole" + "strings" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// ScaAuthPermissionRule is the model entity for the ScaAuthPermissionRule schema. +type ScaAuthPermissionRule struct { + config `json:"-"` + // ID of the ent. + ID int64 `json:"id,omitempty"` + // Ptype holds the value of the "ptype" field. + Ptype *string `json:"ptype,omitempty"` + // V0 holds the value of the "v0" field. + V0 *string `json:"v0,omitempty"` + // V1 holds the value of the "v1" field. + V1 *string `json:"v1,omitempty"` + // V2 holds the value of the "v2" field. + V2 *string `json:"v2,omitempty"` + // V3 holds the value of the "v3" field. + V3 *string `json:"v3,omitempty"` + // V4 holds the value of the "v4" field. + V4 *string `json:"v4,omitempty"` + // V5 holds the value of the "v5" field. + V5 *string `json:"v5,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the ScaAuthPermissionRuleQuery when eager-loading is set. + Edges ScaAuthPermissionRuleEdges `json:"edges"` + sca_auth_role_sca_auth_permission_rule *int64 + selectValues sql.SelectValues +} + +// ScaAuthPermissionRuleEdges holds the relations/edges for other nodes in the graph. +type ScaAuthPermissionRuleEdges struct { + // ScaAuthRole holds the value of the sca_auth_role edge. + ScaAuthRole *ScaAuthRole `json:"sca_auth_role,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [1]bool +} + +// ScaAuthRoleOrErr returns the ScaAuthRole value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e ScaAuthPermissionRuleEdges) ScaAuthRoleOrErr() (*ScaAuthRole, error) { + if e.ScaAuthRole != nil { + return e.ScaAuthRole, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: scaauthrole.Label} + } + return nil, &NotLoadedError{edge: "sca_auth_role"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*ScaAuthPermissionRule) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case scaauthpermissionrule.FieldID: + values[i] = new(sql.NullInt64) + case scaauthpermissionrule.FieldPtype, scaauthpermissionrule.FieldV0, scaauthpermissionrule.FieldV1, scaauthpermissionrule.FieldV2, scaauthpermissionrule.FieldV3, scaauthpermissionrule.FieldV4, scaauthpermissionrule.FieldV5: + values[i] = new(sql.NullString) + case scaauthpermissionrule.ForeignKeys[0]: // sca_auth_role_sca_auth_permission_rule + values[i] = new(sql.NullInt64) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the ScaAuthPermissionRule fields. +func (sapr *ScaAuthPermissionRule) 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 scaauthpermissionrule.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + sapr.ID = int64(value.Int64) + case scaauthpermissionrule.FieldPtype: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field ptype", values[i]) + } else if value.Valid { + sapr.Ptype = new(string) + *sapr.Ptype = value.String + } + case scaauthpermissionrule.FieldV0: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field v0", values[i]) + } else if value.Valid { + sapr.V0 = new(string) + *sapr.V0 = value.String + } + case scaauthpermissionrule.FieldV1: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field v1", values[i]) + } else if value.Valid { + sapr.V1 = new(string) + *sapr.V1 = value.String + } + case scaauthpermissionrule.FieldV2: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field v2", values[i]) + } else if value.Valid { + sapr.V2 = new(string) + *sapr.V2 = value.String + } + case scaauthpermissionrule.FieldV3: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field v3", values[i]) + } else if value.Valid { + sapr.V3 = new(string) + *sapr.V3 = value.String + } + case scaauthpermissionrule.FieldV4: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field v4", values[i]) + } else if value.Valid { + sapr.V4 = new(string) + *sapr.V4 = value.String + } + case scaauthpermissionrule.FieldV5: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field v5", values[i]) + } else if value.Valid { + sapr.V5 = new(string) + *sapr.V5 = value.String + } + case scaauthpermissionrule.ForeignKeys[0]: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for edge-field sca_auth_role_sca_auth_permission_rule", value) + } else if value.Valid { + sapr.sca_auth_role_sca_auth_permission_rule = new(int64) + *sapr.sca_auth_role_sca_auth_permission_rule = int64(value.Int64) + } + default: + sapr.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the ScaAuthPermissionRule. +// This includes values selected through modifiers, order, etc. +func (sapr *ScaAuthPermissionRule) Value(name string) (ent.Value, error) { + return sapr.selectValues.Get(name) +} + +// QueryScaAuthRole queries the "sca_auth_role" edge of the ScaAuthPermissionRule entity. +func (sapr *ScaAuthPermissionRule) QueryScaAuthRole() *ScaAuthRoleQuery { + return NewScaAuthPermissionRuleClient(sapr.config).QueryScaAuthRole(sapr) +} + +// Update returns a builder for updating this ScaAuthPermissionRule. +// Note that you need to call ScaAuthPermissionRule.Unwrap() before calling this method if this ScaAuthPermissionRule +// was returned from a transaction, and the transaction was committed or rolled back. +func (sapr *ScaAuthPermissionRule) Update() *ScaAuthPermissionRuleUpdateOne { + return NewScaAuthPermissionRuleClient(sapr.config).UpdateOne(sapr) +} + +// Unwrap unwraps the ScaAuthPermissionRule 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 (sapr *ScaAuthPermissionRule) Unwrap() *ScaAuthPermissionRule { + _tx, ok := sapr.config.driver.(*txDriver) + if !ok { + panic("ent: ScaAuthPermissionRule is not a transactional entity") + } + sapr.config.driver = _tx.drv + return sapr +} + +// String implements the fmt.Stringer. +func (sapr *ScaAuthPermissionRule) String() string { + var builder strings.Builder + builder.WriteString("ScaAuthPermissionRule(") + builder.WriteString(fmt.Sprintf("id=%v, ", sapr.ID)) + if v := sapr.Ptype; v != nil { + builder.WriteString("ptype=") + builder.WriteString(*v) + } + builder.WriteString(", ") + if v := sapr.V0; v != nil { + builder.WriteString("v0=") + builder.WriteString(*v) + } + builder.WriteString(", ") + if v := sapr.V1; v != nil { + builder.WriteString("v1=") + builder.WriteString(*v) + } + builder.WriteString(", ") + if v := sapr.V2; v != nil { + builder.WriteString("v2=") + builder.WriteString(*v) + } + builder.WriteString(", ") + if v := sapr.V3; v != nil { + builder.WriteString("v3=") + builder.WriteString(*v) + } + builder.WriteString(", ") + if v := sapr.V4; v != nil { + builder.WriteString("v4=") + builder.WriteString(*v) + } + builder.WriteString(", ") + if v := sapr.V5; v != nil { + builder.WriteString("v5=") + builder.WriteString(*v) + } + builder.WriteByte(')') + return builder.String() +} + +// ScaAuthPermissionRules is a parsable slice of ScaAuthPermissionRule. +type ScaAuthPermissionRules []*ScaAuthPermissionRule diff --git a/common/ent/scaauthpermissionrule/scaauthpermissionrule.go b/common/ent/scaauthpermissionrule/scaauthpermissionrule.go new file mode 100644 index 0000000..30c2bc4 --- /dev/null +++ b/common/ent/scaauthpermissionrule/scaauthpermissionrule.go @@ -0,0 +1,147 @@ +// Code generated by ent, DO NOT EDIT. + +package scaauthpermissionrule + +import ( + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the scaauthpermissionrule type in the database. + Label = "sca_auth_permission_rule" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldPtype holds the string denoting the ptype field in the database. + FieldPtype = "ptype" + // FieldV0 holds the string denoting the v0 field in the database. + FieldV0 = "v0" + // FieldV1 holds the string denoting the v1 field in the database. + FieldV1 = "v1" + // FieldV2 holds the string denoting the v2 field in the database. + FieldV2 = "v2" + // FieldV3 holds the string denoting the v3 field in the database. + FieldV3 = "v3" + // FieldV4 holds the string denoting the v4 field in the database. + FieldV4 = "v4" + // FieldV5 holds the string denoting the v5 field in the database. + FieldV5 = "v5" + // EdgeScaAuthRole holds the string denoting the sca_auth_role edge name in mutations. + EdgeScaAuthRole = "sca_auth_role" + // Table holds the table name of the scaauthpermissionrule in the database. + Table = "sca_auth_permission_rules" + // ScaAuthRoleTable is the table that holds the sca_auth_role relation/edge. + ScaAuthRoleTable = "sca_auth_permission_rules" + // ScaAuthRoleInverseTable is the table name for the ScaAuthRole entity. + // It exists in this package in order to avoid circular dependency with the "scaauthrole" package. + ScaAuthRoleInverseTable = "sca_auth_roles" + // ScaAuthRoleColumn is the table column denoting the sca_auth_role relation/edge. + ScaAuthRoleColumn = "sca_auth_role_sca_auth_permission_rule" +) + +// Columns holds all SQL columns for scaauthpermissionrule fields. +var Columns = []string{ + FieldID, + FieldPtype, + FieldV0, + FieldV1, + FieldV2, + FieldV3, + FieldV4, + FieldV5, +} + +// ForeignKeys holds the SQL foreign-keys that are owned by the "sca_auth_permission_rules" +// table and are not defined as standalone fields in the schema. +var ForeignKeys = []string{ + "sca_auth_role_sca_auth_permission_rule", +} + +// 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 + } + } + for i := range ForeignKeys { + if column == ForeignKeys[i] { + return true + } + } + return false +} + +var ( + // PtypeValidator is a validator for the "ptype" field. It is called by the builders before save. + PtypeValidator func(string) error + // V0Validator is a validator for the "v0" field. It is called by the builders before save. + V0Validator func(string) error + // V1Validator is a validator for the "v1" field. It is called by the builders before save. + V1Validator func(string) error + // V2Validator is a validator for the "v2" field. It is called by the builders before save. + V2Validator func(string) error + // V3Validator is a validator for the "v3" field. It is called by the builders before save. + V3Validator func(string) error + // V4Validator is a validator for the "v4" field. It is called by the builders before save. + V4Validator func(string) error + // V5Validator is a validator for the "v5" field. It is called by the builders before save. + V5Validator func(string) error +) + +// OrderOption defines the ordering options for the ScaAuthPermissionRule 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() +} + +// ByPtype orders the results by the ptype field. +func ByPtype(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPtype, opts...).ToFunc() +} + +// ByV0 orders the results by the v0 field. +func ByV0(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldV0, opts...).ToFunc() +} + +// ByV1 orders the results by the v1 field. +func ByV1(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldV1, opts...).ToFunc() +} + +// ByV2 orders the results by the v2 field. +func ByV2(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldV2, opts...).ToFunc() +} + +// ByV3 orders the results by the v3 field. +func ByV3(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldV3, opts...).ToFunc() +} + +// ByV4 orders the results by the v4 field. +func ByV4(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldV4, opts...).ToFunc() +} + +// ByV5 orders the results by the v5 field. +func ByV5(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldV5, opts...).ToFunc() +} + +// ByScaAuthRoleField orders the results by sca_auth_role field. +func ByScaAuthRoleField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newScaAuthRoleStep(), sql.OrderByField(field, opts...)) + } +} +func newScaAuthRoleStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ScaAuthRoleInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, ScaAuthRoleTable, ScaAuthRoleColumn), + ) +} diff --git a/common/ent/scaauthpermissionrule/where.go b/common/ent/scaauthpermissionrule/where.go new file mode 100644 index 0000000..2c50e83 --- /dev/null +++ b/common/ent/scaauthpermissionrule/where.go @@ -0,0 +1,623 @@ +// Code generated by ent, DO NOT EDIT. + +package scaauthpermissionrule + +import ( + "schisandra-album-cloud-microservices/common/ent/predicate" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id int64) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int64) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int64) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int64) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int64) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int64) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int64) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int64) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int64) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldLTE(FieldID, id)) +} + +// Ptype applies equality check predicate on the "ptype" field. It's identical to PtypeEQ. +func Ptype(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldPtype, v)) +} + +// V0 applies equality check predicate on the "v0" field. It's identical to V0EQ. +func V0(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldV0, v)) +} + +// V1 applies equality check predicate on the "v1" field. It's identical to V1EQ. +func V1(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldV1, v)) +} + +// V2 applies equality check predicate on the "v2" field. It's identical to V2EQ. +func V2(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldV2, v)) +} + +// V3 applies equality check predicate on the "v3" field. It's identical to V3EQ. +func V3(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldV3, v)) +} + +// V4 applies equality check predicate on the "v4" field. It's identical to V4EQ. +func V4(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldV4, v)) +} + +// V5 applies equality check predicate on the "v5" field. It's identical to V5EQ. +func V5(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldV5, v)) +} + +// PtypeEQ applies the EQ predicate on the "ptype" field. +func PtypeEQ(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldPtype, v)) +} + +// PtypeNEQ applies the NEQ predicate on the "ptype" field. +func PtypeNEQ(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldNEQ(FieldPtype, v)) +} + +// PtypeIn applies the In predicate on the "ptype" field. +func PtypeIn(vs ...string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldIn(FieldPtype, vs...)) +} + +// PtypeNotIn applies the NotIn predicate on the "ptype" field. +func PtypeNotIn(vs ...string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldNotIn(FieldPtype, vs...)) +} + +// PtypeGT applies the GT predicate on the "ptype" field. +func PtypeGT(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldGT(FieldPtype, v)) +} + +// PtypeGTE applies the GTE predicate on the "ptype" field. +func PtypeGTE(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldGTE(FieldPtype, v)) +} + +// PtypeLT applies the LT predicate on the "ptype" field. +func PtypeLT(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldLT(FieldPtype, v)) +} + +// PtypeLTE applies the LTE predicate on the "ptype" field. +func PtypeLTE(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldLTE(FieldPtype, v)) +} + +// PtypeContains applies the Contains predicate on the "ptype" field. +func PtypeContains(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldContains(FieldPtype, v)) +} + +// PtypeHasPrefix applies the HasPrefix predicate on the "ptype" field. +func PtypeHasPrefix(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldHasPrefix(FieldPtype, v)) +} + +// PtypeHasSuffix applies the HasSuffix predicate on the "ptype" field. +func PtypeHasSuffix(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldHasSuffix(FieldPtype, v)) +} + +// PtypeEqualFold applies the EqualFold predicate on the "ptype" field. +func PtypeEqualFold(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldEqualFold(FieldPtype, v)) +} + +// PtypeContainsFold applies the ContainsFold predicate on the "ptype" field. +func PtypeContainsFold(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldContainsFold(FieldPtype, v)) +} + +// V0EQ applies the EQ predicate on the "v0" field. +func V0EQ(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldV0, v)) +} + +// V0NEQ applies the NEQ predicate on the "v0" field. +func V0NEQ(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldNEQ(FieldV0, v)) +} + +// V0In applies the In predicate on the "v0" field. +func V0In(vs ...string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldIn(FieldV0, vs...)) +} + +// V0NotIn applies the NotIn predicate on the "v0" field. +func V0NotIn(vs ...string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldNotIn(FieldV0, vs...)) +} + +// V0GT applies the GT predicate on the "v0" field. +func V0GT(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldGT(FieldV0, v)) +} + +// V0GTE applies the GTE predicate on the "v0" field. +func V0GTE(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldGTE(FieldV0, v)) +} + +// V0LT applies the LT predicate on the "v0" field. +func V0LT(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldLT(FieldV0, v)) +} + +// V0LTE applies the LTE predicate on the "v0" field. +func V0LTE(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldLTE(FieldV0, v)) +} + +// V0Contains applies the Contains predicate on the "v0" field. +func V0Contains(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldContains(FieldV0, v)) +} + +// V0HasPrefix applies the HasPrefix predicate on the "v0" field. +func V0HasPrefix(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldHasPrefix(FieldV0, v)) +} + +// V0HasSuffix applies the HasSuffix predicate on the "v0" field. +func V0HasSuffix(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldHasSuffix(FieldV0, v)) +} + +// V0EqualFold applies the EqualFold predicate on the "v0" field. +func V0EqualFold(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldEqualFold(FieldV0, v)) +} + +// V0ContainsFold applies the ContainsFold predicate on the "v0" field. +func V0ContainsFold(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldContainsFold(FieldV0, v)) +} + +// V1EQ applies the EQ predicate on the "v1" field. +func V1EQ(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldV1, v)) +} + +// V1NEQ applies the NEQ predicate on the "v1" field. +func V1NEQ(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldNEQ(FieldV1, v)) +} + +// V1In applies the In predicate on the "v1" field. +func V1In(vs ...string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldIn(FieldV1, vs...)) +} + +// V1NotIn applies the NotIn predicate on the "v1" field. +func V1NotIn(vs ...string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldNotIn(FieldV1, vs...)) +} + +// V1GT applies the GT predicate on the "v1" field. +func V1GT(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldGT(FieldV1, v)) +} + +// V1GTE applies the GTE predicate on the "v1" field. +func V1GTE(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldGTE(FieldV1, v)) +} + +// V1LT applies the LT predicate on the "v1" field. +func V1LT(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldLT(FieldV1, v)) +} + +// V1LTE applies the LTE predicate on the "v1" field. +func V1LTE(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldLTE(FieldV1, v)) +} + +// V1Contains applies the Contains predicate on the "v1" field. +func V1Contains(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldContains(FieldV1, v)) +} + +// V1HasPrefix applies the HasPrefix predicate on the "v1" field. +func V1HasPrefix(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldHasPrefix(FieldV1, v)) +} + +// V1HasSuffix applies the HasSuffix predicate on the "v1" field. +func V1HasSuffix(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldHasSuffix(FieldV1, v)) +} + +// V1EqualFold applies the EqualFold predicate on the "v1" field. +func V1EqualFold(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldEqualFold(FieldV1, v)) +} + +// V1ContainsFold applies the ContainsFold predicate on the "v1" field. +func V1ContainsFold(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldContainsFold(FieldV1, v)) +} + +// V2EQ applies the EQ predicate on the "v2" field. +func V2EQ(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldV2, v)) +} + +// V2NEQ applies the NEQ predicate on the "v2" field. +func V2NEQ(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldNEQ(FieldV2, v)) +} + +// V2In applies the In predicate on the "v2" field. +func V2In(vs ...string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldIn(FieldV2, vs...)) +} + +// V2NotIn applies the NotIn predicate on the "v2" field. +func V2NotIn(vs ...string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldNotIn(FieldV2, vs...)) +} + +// V2GT applies the GT predicate on the "v2" field. +func V2GT(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldGT(FieldV2, v)) +} + +// V2GTE applies the GTE predicate on the "v2" field. +func V2GTE(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldGTE(FieldV2, v)) +} + +// V2LT applies the LT predicate on the "v2" field. +func V2LT(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldLT(FieldV2, v)) +} + +// V2LTE applies the LTE predicate on the "v2" field. +func V2LTE(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldLTE(FieldV2, v)) +} + +// V2Contains applies the Contains predicate on the "v2" field. +func V2Contains(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldContains(FieldV2, v)) +} + +// V2HasPrefix applies the HasPrefix predicate on the "v2" field. +func V2HasPrefix(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldHasPrefix(FieldV2, v)) +} + +// V2HasSuffix applies the HasSuffix predicate on the "v2" field. +func V2HasSuffix(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldHasSuffix(FieldV2, v)) +} + +// V2IsNil applies the IsNil predicate on the "v2" field. +func V2IsNil() predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldIsNull(FieldV2)) +} + +// V2NotNil applies the NotNil predicate on the "v2" field. +func V2NotNil() predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldNotNull(FieldV2)) +} + +// V2EqualFold applies the EqualFold predicate on the "v2" field. +func V2EqualFold(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldEqualFold(FieldV2, v)) +} + +// V2ContainsFold applies the ContainsFold predicate on the "v2" field. +func V2ContainsFold(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldContainsFold(FieldV2, v)) +} + +// V3EQ applies the EQ predicate on the "v3" field. +func V3EQ(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldV3, v)) +} + +// V3NEQ applies the NEQ predicate on the "v3" field. +func V3NEQ(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldNEQ(FieldV3, v)) +} + +// V3In applies the In predicate on the "v3" field. +func V3In(vs ...string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldIn(FieldV3, vs...)) +} + +// V3NotIn applies the NotIn predicate on the "v3" field. +func V3NotIn(vs ...string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldNotIn(FieldV3, vs...)) +} + +// V3GT applies the GT predicate on the "v3" field. +func V3GT(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldGT(FieldV3, v)) +} + +// V3GTE applies the GTE predicate on the "v3" field. +func V3GTE(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldGTE(FieldV3, v)) +} + +// V3LT applies the LT predicate on the "v3" field. +func V3LT(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldLT(FieldV3, v)) +} + +// V3LTE applies the LTE predicate on the "v3" field. +func V3LTE(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldLTE(FieldV3, v)) +} + +// V3Contains applies the Contains predicate on the "v3" field. +func V3Contains(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldContains(FieldV3, v)) +} + +// V3HasPrefix applies the HasPrefix predicate on the "v3" field. +func V3HasPrefix(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldHasPrefix(FieldV3, v)) +} + +// V3HasSuffix applies the HasSuffix predicate on the "v3" field. +func V3HasSuffix(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldHasSuffix(FieldV3, v)) +} + +// V3IsNil applies the IsNil predicate on the "v3" field. +func V3IsNil() predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldIsNull(FieldV3)) +} + +// V3NotNil applies the NotNil predicate on the "v3" field. +func V3NotNil() predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldNotNull(FieldV3)) +} + +// V3EqualFold applies the EqualFold predicate on the "v3" field. +func V3EqualFold(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldEqualFold(FieldV3, v)) +} + +// V3ContainsFold applies the ContainsFold predicate on the "v3" field. +func V3ContainsFold(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldContainsFold(FieldV3, v)) +} + +// V4EQ applies the EQ predicate on the "v4" field. +func V4EQ(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldV4, v)) +} + +// V4NEQ applies the NEQ predicate on the "v4" field. +func V4NEQ(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldNEQ(FieldV4, v)) +} + +// V4In applies the In predicate on the "v4" field. +func V4In(vs ...string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldIn(FieldV4, vs...)) +} + +// V4NotIn applies the NotIn predicate on the "v4" field. +func V4NotIn(vs ...string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldNotIn(FieldV4, vs...)) +} + +// V4GT applies the GT predicate on the "v4" field. +func V4GT(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldGT(FieldV4, v)) +} + +// V4GTE applies the GTE predicate on the "v4" field. +func V4GTE(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldGTE(FieldV4, v)) +} + +// V4LT applies the LT predicate on the "v4" field. +func V4LT(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldLT(FieldV4, v)) +} + +// V4LTE applies the LTE predicate on the "v4" field. +func V4LTE(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldLTE(FieldV4, v)) +} + +// V4Contains applies the Contains predicate on the "v4" field. +func V4Contains(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldContains(FieldV4, v)) +} + +// V4HasPrefix applies the HasPrefix predicate on the "v4" field. +func V4HasPrefix(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldHasPrefix(FieldV4, v)) +} + +// V4HasSuffix applies the HasSuffix predicate on the "v4" field. +func V4HasSuffix(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldHasSuffix(FieldV4, v)) +} + +// V4IsNil applies the IsNil predicate on the "v4" field. +func V4IsNil() predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldIsNull(FieldV4)) +} + +// V4NotNil applies the NotNil predicate on the "v4" field. +func V4NotNil() predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldNotNull(FieldV4)) +} + +// V4EqualFold applies the EqualFold predicate on the "v4" field. +func V4EqualFold(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldEqualFold(FieldV4, v)) +} + +// V4ContainsFold applies the ContainsFold predicate on the "v4" field. +func V4ContainsFold(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldContainsFold(FieldV4, v)) +} + +// V5EQ applies the EQ predicate on the "v5" field. +func V5EQ(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldV5, v)) +} + +// V5NEQ applies the NEQ predicate on the "v5" field. +func V5NEQ(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldNEQ(FieldV5, v)) +} + +// V5In applies the In predicate on the "v5" field. +func V5In(vs ...string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldIn(FieldV5, vs...)) +} + +// V5NotIn applies the NotIn predicate on the "v5" field. +func V5NotIn(vs ...string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldNotIn(FieldV5, vs...)) +} + +// V5GT applies the GT predicate on the "v5" field. +func V5GT(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldGT(FieldV5, v)) +} + +// V5GTE applies the GTE predicate on the "v5" field. +func V5GTE(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldGTE(FieldV5, v)) +} + +// V5LT applies the LT predicate on the "v5" field. +func V5LT(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldLT(FieldV5, v)) +} + +// V5LTE applies the LTE predicate on the "v5" field. +func V5LTE(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldLTE(FieldV5, v)) +} + +// V5Contains applies the Contains predicate on the "v5" field. +func V5Contains(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldContains(FieldV5, v)) +} + +// V5HasPrefix applies the HasPrefix predicate on the "v5" field. +func V5HasPrefix(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldHasPrefix(FieldV5, v)) +} + +// V5HasSuffix applies the HasSuffix predicate on the "v5" field. +func V5HasSuffix(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldHasSuffix(FieldV5, v)) +} + +// V5IsNil applies the IsNil predicate on the "v5" field. +func V5IsNil() predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldIsNull(FieldV5)) +} + +// V5NotNil applies the NotNil predicate on the "v5" field. +func V5NotNil() predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldNotNull(FieldV5)) +} + +// V5EqualFold applies the EqualFold predicate on the "v5" field. +func V5EqualFold(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldEqualFold(FieldV5, v)) +} + +// V5ContainsFold applies the ContainsFold predicate on the "v5" field. +func V5ContainsFold(v string) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.FieldContainsFold(FieldV5, v)) +} + +// HasScaAuthRole applies the HasEdge predicate on the "sca_auth_role" edge. +func HasScaAuthRole() predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, ScaAuthRoleTable, ScaAuthRoleColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasScaAuthRoleWith applies the HasEdge predicate on the "sca_auth_role" edge with a given conditions (other predicates). +func HasScaAuthRoleWith(preds ...predicate.ScaAuthRole) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(func(s *sql.Selector) { + step := newScaAuthRoleStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.ScaAuthPermissionRule) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.ScaAuthPermissionRule) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.ScaAuthPermissionRule) predicate.ScaAuthPermissionRule { + return predicate.ScaAuthPermissionRule(sql.NotPredicates(p)) +} diff --git a/common/ent/scaauthpermissionrule_create.go b/common/ent/scaauthpermissionrule_create.go new file mode 100644 index 0000000..50646ba --- /dev/null +++ b/common/ent/scaauthpermissionrule_create.go @@ -0,0 +1,365 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "schisandra-album-cloud-microservices/common/ent/scaauthpermissionrule" + "schisandra-album-cloud-microservices/common/ent/scaauthrole" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ScaAuthPermissionRuleCreate is the builder for creating a ScaAuthPermissionRule entity. +type ScaAuthPermissionRuleCreate struct { + config + mutation *ScaAuthPermissionRuleMutation + hooks []Hook +} + +// SetPtype sets the "ptype" field. +func (saprc *ScaAuthPermissionRuleCreate) SetPtype(s string) *ScaAuthPermissionRuleCreate { + saprc.mutation.SetPtype(s) + return saprc +} + +// SetV0 sets the "v0" field. +func (saprc *ScaAuthPermissionRuleCreate) SetV0(s string) *ScaAuthPermissionRuleCreate { + saprc.mutation.SetV0(s) + return saprc +} + +// SetV1 sets the "v1" field. +func (saprc *ScaAuthPermissionRuleCreate) SetV1(s string) *ScaAuthPermissionRuleCreate { + saprc.mutation.SetV1(s) + return saprc +} + +// SetV2 sets the "v2" field. +func (saprc *ScaAuthPermissionRuleCreate) SetV2(s string) *ScaAuthPermissionRuleCreate { + saprc.mutation.SetV2(s) + return saprc +} + +// SetNillableV2 sets the "v2" field if the given value is not nil. +func (saprc *ScaAuthPermissionRuleCreate) SetNillableV2(s *string) *ScaAuthPermissionRuleCreate { + if s != nil { + saprc.SetV2(*s) + } + return saprc +} + +// SetV3 sets the "v3" field. +func (saprc *ScaAuthPermissionRuleCreate) SetV3(s string) *ScaAuthPermissionRuleCreate { + saprc.mutation.SetV3(s) + return saprc +} + +// SetNillableV3 sets the "v3" field if the given value is not nil. +func (saprc *ScaAuthPermissionRuleCreate) SetNillableV3(s *string) *ScaAuthPermissionRuleCreate { + if s != nil { + saprc.SetV3(*s) + } + return saprc +} + +// SetV4 sets the "v4" field. +func (saprc *ScaAuthPermissionRuleCreate) SetV4(s string) *ScaAuthPermissionRuleCreate { + saprc.mutation.SetV4(s) + return saprc +} + +// SetNillableV4 sets the "v4" field if the given value is not nil. +func (saprc *ScaAuthPermissionRuleCreate) SetNillableV4(s *string) *ScaAuthPermissionRuleCreate { + if s != nil { + saprc.SetV4(*s) + } + return saprc +} + +// SetV5 sets the "v5" field. +func (saprc *ScaAuthPermissionRuleCreate) SetV5(s string) *ScaAuthPermissionRuleCreate { + saprc.mutation.SetV5(s) + return saprc +} + +// SetNillableV5 sets the "v5" field if the given value is not nil. +func (saprc *ScaAuthPermissionRuleCreate) SetNillableV5(s *string) *ScaAuthPermissionRuleCreate { + if s != nil { + saprc.SetV5(*s) + } + return saprc +} + +// SetID sets the "id" field. +func (saprc *ScaAuthPermissionRuleCreate) SetID(i int64) *ScaAuthPermissionRuleCreate { + saprc.mutation.SetID(i) + return saprc +} + +// SetScaAuthRoleID sets the "sca_auth_role" edge to the ScaAuthRole entity by ID. +func (saprc *ScaAuthPermissionRuleCreate) SetScaAuthRoleID(id int64) *ScaAuthPermissionRuleCreate { + saprc.mutation.SetScaAuthRoleID(id) + return saprc +} + +// SetNillableScaAuthRoleID sets the "sca_auth_role" edge to the ScaAuthRole entity by ID if the given value is not nil. +func (saprc *ScaAuthPermissionRuleCreate) SetNillableScaAuthRoleID(id *int64) *ScaAuthPermissionRuleCreate { + if id != nil { + saprc = saprc.SetScaAuthRoleID(*id) + } + return saprc +} + +// SetScaAuthRole sets the "sca_auth_role" edge to the ScaAuthRole entity. +func (saprc *ScaAuthPermissionRuleCreate) SetScaAuthRole(s *ScaAuthRole) *ScaAuthPermissionRuleCreate { + return saprc.SetScaAuthRoleID(s.ID) +} + +// Mutation returns the ScaAuthPermissionRuleMutation object of the builder. +func (saprc *ScaAuthPermissionRuleCreate) Mutation() *ScaAuthPermissionRuleMutation { + return saprc.mutation +} + +// Save creates the ScaAuthPermissionRule in the database. +func (saprc *ScaAuthPermissionRuleCreate) Save(ctx context.Context) (*ScaAuthPermissionRule, error) { + return withHooks(ctx, saprc.sqlSave, saprc.mutation, saprc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (saprc *ScaAuthPermissionRuleCreate) SaveX(ctx context.Context) *ScaAuthPermissionRule { + v, err := saprc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (saprc *ScaAuthPermissionRuleCreate) Exec(ctx context.Context) error { + _, err := saprc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (saprc *ScaAuthPermissionRuleCreate) ExecX(ctx context.Context) { + if err := saprc.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (saprc *ScaAuthPermissionRuleCreate) check() error { + if _, ok := saprc.mutation.Ptype(); !ok { + return &ValidationError{Name: "ptype", err: errors.New(`ent: missing required field "ScaAuthPermissionRule.ptype"`)} + } + if v, ok := saprc.mutation.Ptype(); ok { + if err := scaauthpermissionrule.PtypeValidator(v); err != nil { + return &ValidationError{Name: "ptype", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.ptype": %w`, err)} + } + } + if _, ok := saprc.mutation.V0(); !ok { + return &ValidationError{Name: "v0", err: errors.New(`ent: missing required field "ScaAuthPermissionRule.v0"`)} + } + if v, ok := saprc.mutation.V0(); ok { + if err := scaauthpermissionrule.V0Validator(v); err != nil { + return &ValidationError{Name: "v0", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v0": %w`, err)} + } + } + if _, ok := saprc.mutation.V1(); !ok { + return &ValidationError{Name: "v1", err: errors.New(`ent: missing required field "ScaAuthPermissionRule.v1"`)} + } + if v, ok := saprc.mutation.V1(); ok { + if err := scaauthpermissionrule.V1Validator(v); err != nil { + return &ValidationError{Name: "v1", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v1": %w`, err)} + } + } + if v, ok := saprc.mutation.V2(); ok { + if err := scaauthpermissionrule.V2Validator(v); err != nil { + return &ValidationError{Name: "v2", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v2": %w`, err)} + } + } + if v, ok := saprc.mutation.V3(); ok { + if err := scaauthpermissionrule.V3Validator(v); err != nil { + return &ValidationError{Name: "v3", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v3": %w`, err)} + } + } + if v, ok := saprc.mutation.V4(); ok { + if err := scaauthpermissionrule.V4Validator(v); err != nil { + return &ValidationError{Name: "v4", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v4": %w`, err)} + } + } + if v, ok := saprc.mutation.V5(); ok { + if err := scaauthpermissionrule.V5Validator(v); err != nil { + return &ValidationError{Name: "v5", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v5": %w`, err)} + } + } + return nil +} + +func (saprc *ScaAuthPermissionRuleCreate) sqlSave(ctx context.Context) (*ScaAuthPermissionRule, error) { + if err := saprc.check(); err != nil { + return nil, err + } + _node, _spec := saprc.createSpec() + if err := sqlgraph.CreateNode(ctx, saprc.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) + } + saprc.mutation.id = &_node.ID + saprc.mutation.done = true + return _node, nil +} + +func (saprc *ScaAuthPermissionRuleCreate) createSpec() (*ScaAuthPermissionRule, *sqlgraph.CreateSpec) { + var ( + _node = &ScaAuthPermissionRule{config: saprc.config} + _spec = sqlgraph.NewCreateSpec(scaauthpermissionrule.Table, sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64)) + ) + if id, ok := saprc.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := saprc.mutation.Ptype(); ok { + _spec.SetField(scaauthpermissionrule.FieldPtype, field.TypeString, value) + _node.Ptype = &value + } + if value, ok := saprc.mutation.V0(); ok { + _spec.SetField(scaauthpermissionrule.FieldV0, field.TypeString, value) + _node.V0 = &value + } + if value, ok := saprc.mutation.V1(); ok { + _spec.SetField(scaauthpermissionrule.FieldV1, field.TypeString, value) + _node.V1 = &value + } + if value, ok := saprc.mutation.V2(); ok { + _spec.SetField(scaauthpermissionrule.FieldV2, field.TypeString, value) + _node.V2 = &value + } + if value, ok := saprc.mutation.V3(); ok { + _spec.SetField(scaauthpermissionrule.FieldV3, field.TypeString, value) + _node.V3 = &value + } + if value, ok := saprc.mutation.V4(); ok { + _spec.SetField(scaauthpermissionrule.FieldV4, field.TypeString, value) + _node.V4 = &value + } + if value, ok := saprc.mutation.V5(); ok { + _spec.SetField(scaauthpermissionrule.FieldV5, field.TypeString, value) + _node.V5 = &value + } + if nodes := saprc.mutation.ScaAuthRoleIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: scaauthpermissionrule.ScaAuthRoleTable, + Columns: []string{scaauthpermissionrule.ScaAuthRoleColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(scaauthrole.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.sca_auth_role_sca_auth_permission_rule = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// ScaAuthPermissionRuleCreateBulk is the builder for creating many ScaAuthPermissionRule entities in bulk. +type ScaAuthPermissionRuleCreateBulk struct { + config + err error + builders []*ScaAuthPermissionRuleCreate +} + +// Save creates the ScaAuthPermissionRule entities in the database. +func (saprcb *ScaAuthPermissionRuleCreateBulk) Save(ctx context.Context) ([]*ScaAuthPermissionRule, error) { + if saprcb.err != nil { + return nil, saprcb.err + } + specs := make([]*sqlgraph.CreateSpec, len(saprcb.builders)) + nodes := make([]*ScaAuthPermissionRule, len(saprcb.builders)) + mutators := make([]Mutator, len(saprcb.builders)) + for i := range saprcb.builders { + func(i int, root context.Context) { + builder := saprcb.builders[i] + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*ScaAuthPermissionRuleMutation) + 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, saprcb.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, saprcb.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, saprcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (saprcb *ScaAuthPermissionRuleCreateBulk) SaveX(ctx context.Context) []*ScaAuthPermissionRule { + v, err := saprcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (saprcb *ScaAuthPermissionRuleCreateBulk) Exec(ctx context.Context) error { + _, err := saprcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (saprcb *ScaAuthPermissionRuleCreateBulk) ExecX(ctx context.Context) { + if err := saprcb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/common/ent/scaauthpermissionrule_delete.go b/common/ent/scaauthpermissionrule_delete.go new file mode 100644 index 0000000..659dcdf --- /dev/null +++ b/common/ent/scaauthpermissionrule_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "schisandra-album-cloud-microservices/common/ent/predicate" + "schisandra-album-cloud-microservices/common/ent/scaauthpermissionrule" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ScaAuthPermissionRuleDelete is the builder for deleting a ScaAuthPermissionRule entity. +type ScaAuthPermissionRuleDelete struct { + config + hooks []Hook + mutation *ScaAuthPermissionRuleMutation +} + +// Where appends a list predicates to the ScaAuthPermissionRuleDelete builder. +func (saprd *ScaAuthPermissionRuleDelete) Where(ps ...predicate.ScaAuthPermissionRule) *ScaAuthPermissionRuleDelete { + saprd.mutation.Where(ps...) + return saprd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (saprd *ScaAuthPermissionRuleDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, saprd.sqlExec, saprd.mutation, saprd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (saprd *ScaAuthPermissionRuleDelete) ExecX(ctx context.Context) int { + n, err := saprd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (saprd *ScaAuthPermissionRuleDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(scaauthpermissionrule.Table, sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64)) + if ps := saprd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, saprd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + saprd.mutation.done = true + return affected, err +} + +// ScaAuthPermissionRuleDeleteOne is the builder for deleting a single ScaAuthPermissionRule entity. +type ScaAuthPermissionRuleDeleteOne struct { + saprd *ScaAuthPermissionRuleDelete +} + +// Where appends a list predicates to the ScaAuthPermissionRuleDelete builder. +func (saprdo *ScaAuthPermissionRuleDeleteOne) Where(ps ...predicate.ScaAuthPermissionRule) *ScaAuthPermissionRuleDeleteOne { + saprdo.saprd.mutation.Where(ps...) + return saprdo +} + +// Exec executes the deletion query. +func (saprdo *ScaAuthPermissionRuleDeleteOne) Exec(ctx context.Context) error { + n, err := saprdo.saprd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{scaauthpermissionrule.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (saprdo *ScaAuthPermissionRuleDeleteOne) ExecX(ctx context.Context) { + if err := saprdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/common/ent/scaauthpermissionrule_query.go b/common/ent/scaauthpermissionrule_query.go new file mode 100644 index 0000000..6059e68 --- /dev/null +++ b/common/ent/scaauthpermissionrule_query.go @@ -0,0 +1,614 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + "schisandra-album-cloud-microservices/common/ent/predicate" + "schisandra-album-cloud-microservices/common/ent/scaauthpermissionrule" + "schisandra-album-cloud-microservices/common/ent/scaauthrole" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ScaAuthPermissionRuleQuery is the builder for querying ScaAuthPermissionRule entities. +type ScaAuthPermissionRuleQuery struct { + config + ctx *QueryContext + order []scaauthpermissionrule.OrderOption + inters []Interceptor + predicates []predicate.ScaAuthPermissionRule + withScaAuthRole *ScaAuthRoleQuery + withFKs bool + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the ScaAuthPermissionRuleQuery builder. +func (saprq *ScaAuthPermissionRuleQuery) Where(ps ...predicate.ScaAuthPermissionRule) *ScaAuthPermissionRuleQuery { + saprq.predicates = append(saprq.predicates, ps...) + return saprq +} + +// Limit the number of records to be returned by this query. +func (saprq *ScaAuthPermissionRuleQuery) Limit(limit int) *ScaAuthPermissionRuleQuery { + saprq.ctx.Limit = &limit + return saprq +} + +// Offset to start from. +func (saprq *ScaAuthPermissionRuleQuery) Offset(offset int) *ScaAuthPermissionRuleQuery { + saprq.ctx.Offset = &offset + return saprq +} + +// 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 (saprq *ScaAuthPermissionRuleQuery) Unique(unique bool) *ScaAuthPermissionRuleQuery { + saprq.ctx.Unique = &unique + return saprq +} + +// Order specifies how the records should be ordered. +func (saprq *ScaAuthPermissionRuleQuery) Order(o ...scaauthpermissionrule.OrderOption) *ScaAuthPermissionRuleQuery { + saprq.order = append(saprq.order, o...) + return saprq +} + +// QueryScaAuthRole chains the current query on the "sca_auth_role" edge. +func (saprq *ScaAuthPermissionRuleQuery) QueryScaAuthRole() *ScaAuthRoleQuery { + query := (&ScaAuthRoleClient{config: saprq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := saprq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := saprq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(scaauthpermissionrule.Table, scaauthpermissionrule.FieldID, selector), + sqlgraph.To(scaauthrole.Table, scaauthrole.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, scaauthpermissionrule.ScaAuthRoleTable, scaauthpermissionrule.ScaAuthRoleColumn), + ) + fromU = sqlgraph.SetNeighbors(saprq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first ScaAuthPermissionRule entity from the query. +// Returns a *NotFoundError when no ScaAuthPermissionRule was found. +func (saprq *ScaAuthPermissionRuleQuery) First(ctx context.Context) (*ScaAuthPermissionRule, error) { + nodes, err := saprq.Limit(1).All(setContextOp(ctx, saprq.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{scaauthpermissionrule.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (saprq *ScaAuthPermissionRuleQuery) FirstX(ctx context.Context) *ScaAuthPermissionRule { + node, err := saprq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first ScaAuthPermissionRule ID from the query. +// Returns a *NotFoundError when no ScaAuthPermissionRule ID was found. +func (saprq *ScaAuthPermissionRuleQuery) FirstID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = saprq.Limit(1).IDs(setContextOp(ctx, saprq.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{scaauthpermissionrule.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (saprq *ScaAuthPermissionRuleQuery) FirstIDX(ctx context.Context) int64 { + id, err := saprq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single ScaAuthPermissionRule entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one ScaAuthPermissionRule entity is found. +// Returns a *NotFoundError when no ScaAuthPermissionRule entities are found. +func (saprq *ScaAuthPermissionRuleQuery) Only(ctx context.Context) (*ScaAuthPermissionRule, error) { + nodes, err := saprq.Limit(2).All(setContextOp(ctx, saprq.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{scaauthpermissionrule.Label} + default: + return nil, &NotSingularError{scaauthpermissionrule.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (saprq *ScaAuthPermissionRuleQuery) OnlyX(ctx context.Context) *ScaAuthPermissionRule { + node, err := saprq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only ScaAuthPermissionRule ID in the query. +// Returns a *NotSingularError when more than one ScaAuthPermissionRule ID is found. +// Returns a *NotFoundError when no entities are found. +func (saprq *ScaAuthPermissionRuleQuery) OnlyID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = saprq.Limit(2).IDs(setContextOp(ctx, saprq.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{scaauthpermissionrule.Label} + default: + err = &NotSingularError{scaauthpermissionrule.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (saprq *ScaAuthPermissionRuleQuery) OnlyIDX(ctx context.Context) int64 { + id, err := saprq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of ScaAuthPermissionRules. +func (saprq *ScaAuthPermissionRuleQuery) All(ctx context.Context) ([]*ScaAuthPermissionRule, error) { + ctx = setContextOp(ctx, saprq.ctx, ent.OpQueryAll) + if err := saprq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*ScaAuthPermissionRule, *ScaAuthPermissionRuleQuery]() + return withInterceptors[[]*ScaAuthPermissionRule](ctx, saprq, qr, saprq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (saprq *ScaAuthPermissionRuleQuery) AllX(ctx context.Context) []*ScaAuthPermissionRule { + nodes, err := saprq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of ScaAuthPermissionRule IDs. +func (saprq *ScaAuthPermissionRuleQuery) IDs(ctx context.Context) (ids []int64, err error) { + if saprq.ctx.Unique == nil && saprq.path != nil { + saprq.Unique(true) + } + ctx = setContextOp(ctx, saprq.ctx, ent.OpQueryIDs) + if err = saprq.Select(scaauthpermissionrule.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (saprq *ScaAuthPermissionRuleQuery) IDsX(ctx context.Context) []int64 { + ids, err := saprq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (saprq *ScaAuthPermissionRuleQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, saprq.ctx, ent.OpQueryCount) + if err := saprq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, saprq, querierCount[*ScaAuthPermissionRuleQuery](), saprq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (saprq *ScaAuthPermissionRuleQuery) CountX(ctx context.Context) int { + count, err := saprq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (saprq *ScaAuthPermissionRuleQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, saprq.ctx, ent.OpQueryExist) + switch _, err := saprq.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 (saprq *ScaAuthPermissionRuleQuery) ExistX(ctx context.Context) bool { + exist, err := saprq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the ScaAuthPermissionRuleQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (saprq *ScaAuthPermissionRuleQuery) Clone() *ScaAuthPermissionRuleQuery { + if saprq == nil { + return nil + } + return &ScaAuthPermissionRuleQuery{ + config: saprq.config, + ctx: saprq.ctx.Clone(), + order: append([]scaauthpermissionrule.OrderOption{}, saprq.order...), + inters: append([]Interceptor{}, saprq.inters...), + predicates: append([]predicate.ScaAuthPermissionRule{}, saprq.predicates...), + withScaAuthRole: saprq.withScaAuthRole.Clone(), + // clone intermediate query. + sql: saprq.sql.Clone(), + path: saprq.path, + } +} + +// WithScaAuthRole tells the query-builder to eager-load the nodes that are connected to +// the "sca_auth_role" edge. The optional arguments are used to configure the query builder of the edge. +func (saprq *ScaAuthPermissionRuleQuery) WithScaAuthRole(opts ...func(*ScaAuthRoleQuery)) *ScaAuthPermissionRuleQuery { + query := (&ScaAuthRoleClient{config: saprq.config}).Query() + for _, opt := range opts { + opt(query) + } + saprq.withScaAuthRole = query + return saprq +} + +// 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 { +// Ptype string `json:"ptype,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.ScaAuthPermissionRule.Query(). +// GroupBy(scaauthpermissionrule.FieldPtype). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (saprq *ScaAuthPermissionRuleQuery) GroupBy(field string, fields ...string) *ScaAuthPermissionRuleGroupBy { + saprq.ctx.Fields = append([]string{field}, fields...) + grbuild := &ScaAuthPermissionRuleGroupBy{build: saprq} + grbuild.flds = &saprq.ctx.Fields + grbuild.label = scaauthpermissionrule.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 { +// Ptype string `json:"ptype,omitempty"` +// } +// +// client.ScaAuthPermissionRule.Query(). +// Select(scaauthpermissionrule.FieldPtype). +// Scan(ctx, &v) +func (saprq *ScaAuthPermissionRuleQuery) Select(fields ...string) *ScaAuthPermissionRuleSelect { + saprq.ctx.Fields = append(saprq.ctx.Fields, fields...) + sbuild := &ScaAuthPermissionRuleSelect{ScaAuthPermissionRuleQuery: saprq} + sbuild.label = scaauthpermissionrule.Label + sbuild.flds, sbuild.scan = &saprq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a ScaAuthPermissionRuleSelect configured with the given aggregations. +func (saprq *ScaAuthPermissionRuleQuery) Aggregate(fns ...AggregateFunc) *ScaAuthPermissionRuleSelect { + return saprq.Select().Aggregate(fns...) +} + +func (saprq *ScaAuthPermissionRuleQuery) prepareQuery(ctx context.Context) error { + for _, inter := range saprq.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, saprq); err != nil { + return err + } + } + } + for _, f := range saprq.ctx.Fields { + if !scaauthpermissionrule.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if saprq.path != nil { + prev, err := saprq.path(ctx) + if err != nil { + return err + } + saprq.sql = prev + } + return nil +} + +func (saprq *ScaAuthPermissionRuleQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ScaAuthPermissionRule, error) { + var ( + nodes = []*ScaAuthPermissionRule{} + withFKs = saprq.withFKs + _spec = saprq.querySpec() + loadedTypes = [1]bool{ + saprq.withScaAuthRole != nil, + } + ) + if saprq.withScaAuthRole != nil { + withFKs = true + } + if withFKs { + _spec.Node.Columns = append(_spec.Node.Columns, scaauthpermissionrule.ForeignKeys...) + } + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*ScaAuthPermissionRule).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &ScaAuthPermissionRule{config: saprq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, saprq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := saprq.withScaAuthRole; query != nil { + if err := saprq.loadScaAuthRole(ctx, query, nodes, nil, + func(n *ScaAuthPermissionRule, e *ScaAuthRole) { n.Edges.ScaAuthRole = e }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (saprq *ScaAuthPermissionRuleQuery) loadScaAuthRole(ctx context.Context, query *ScaAuthRoleQuery, nodes []*ScaAuthPermissionRule, init func(*ScaAuthPermissionRule), assign func(*ScaAuthPermissionRule, *ScaAuthRole)) error { + ids := make([]int64, 0, len(nodes)) + nodeids := make(map[int64][]*ScaAuthPermissionRule) + for i := range nodes { + if nodes[i].sca_auth_role_sca_auth_permission_rule == nil { + continue + } + fk := *nodes[i].sca_auth_role_sca_auth_permission_rule + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(scaauthrole.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "sca_auth_role_sca_auth_permission_rule" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + +func (saprq *ScaAuthPermissionRuleQuery) sqlCount(ctx context.Context) (int, error) { + _spec := saprq.querySpec() + _spec.Node.Columns = saprq.ctx.Fields + if len(saprq.ctx.Fields) > 0 { + _spec.Unique = saprq.ctx.Unique != nil && *saprq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, saprq.driver, _spec) +} + +func (saprq *ScaAuthPermissionRuleQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(scaauthpermissionrule.Table, scaauthpermissionrule.Columns, sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64)) + _spec.From = saprq.sql + if unique := saprq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if saprq.path != nil { + _spec.Unique = true + } + if fields := saprq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, scaauthpermissionrule.FieldID) + for i := range fields { + if fields[i] != scaauthpermissionrule.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := saprq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := saprq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := saprq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := saprq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (saprq *ScaAuthPermissionRuleQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(saprq.driver.Dialect()) + t1 := builder.Table(scaauthpermissionrule.Table) + columns := saprq.ctx.Fields + if len(columns) == 0 { + columns = scaauthpermissionrule.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if saprq.sql != nil { + selector = saprq.sql + selector.Select(selector.Columns(columns...)...) + } + if saprq.ctx.Unique != nil && *saprq.ctx.Unique { + selector.Distinct() + } + for _, p := range saprq.predicates { + p(selector) + } + for _, p := range saprq.order { + p(selector) + } + if offset := saprq.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 := saprq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// ScaAuthPermissionRuleGroupBy is the group-by builder for ScaAuthPermissionRule entities. +type ScaAuthPermissionRuleGroupBy struct { + selector + build *ScaAuthPermissionRuleQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (saprgb *ScaAuthPermissionRuleGroupBy) Aggregate(fns ...AggregateFunc) *ScaAuthPermissionRuleGroupBy { + saprgb.fns = append(saprgb.fns, fns...) + return saprgb +} + +// Scan applies the selector query and scans the result into the given value. +func (saprgb *ScaAuthPermissionRuleGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, saprgb.build.ctx, ent.OpQueryGroupBy) + if err := saprgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ScaAuthPermissionRuleQuery, *ScaAuthPermissionRuleGroupBy](ctx, saprgb.build, saprgb, saprgb.build.inters, v) +} + +func (saprgb *ScaAuthPermissionRuleGroupBy) sqlScan(ctx context.Context, root *ScaAuthPermissionRuleQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(saprgb.fns)) + for _, fn := range saprgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*saprgb.flds)+len(saprgb.fns)) + for _, f := range *saprgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*saprgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := saprgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// ScaAuthPermissionRuleSelect is the builder for selecting fields of ScaAuthPermissionRule entities. +type ScaAuthPermissionRuleSelect struct { + *ScaAuthPermissionRuleQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (saprs *ScaAuthPermissionRuleSelect) Aggregate(fns ...AggregateFunc) *ScaAuthPermissionRuleSelect { + saprs.fns = append(saprs.fns, fns...) + return saprs +} + +// Scan applies the selector query and scans the result into the given value. +func (saprs *ScaAuthPermissionRuleSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, saprs.ctx, ent.OpQuerySelect) + if err := saprs.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ScaAuthPermissionRuleQuery, *ScaAuthPermissionRuleSelect](ctx, saprs.ScaAuthPermissionRuleQuery, saprs, saprs.inters, v) +} + +func (saprs *ScaAuthPermissionRuleSelect) sqlScan(ctx context.Context, root *ScaAuthPermissionRuleQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(saprs.fns)) + for _, fn := range saprs.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*saprs.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 := saprs.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/common/ent/scaauthpermissionrule_update.go b/common/ent/scaauthpermissionrule_update.go new file mode 100644 index 0000000..4290284 --- /dev/null +++ b/common/ent/scaauthpermissionrule_update.go @@ -0,0 +1,680 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "schisandra-album-cloud-microservices/common/ent/predicate" + "schisandra-album-cloud-microservices/common/ent/scaauthpermissionrule" + "schisandra-album-cloud-microservices/common/ent/scaauthrole" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ScaAuthPermissionRuleUpdate is the builder for updating ScaAuthPermissionRule entities. +type ScaAuthPermissionRuleUpdate struct { + config + hooks []Hook + mutation *ScaAuthPermissionRuleMutation +} + +// Where appends a list predicates to the ScaAuthPermissionRuleUpdate builder. +func (sapru *ScaAuthPermissionRuleUpdate) Where(ps ...predicate.ScaAuthPermissionRule) *ScaAuthPermissionRuleUpdate { + sapru.mutation.Where(ps...) + return sapru +} + +// SetPtype sets the "ptype" field. +func (sapru *ScaAuthPermissionRuleUpdate) SetPtype(s string) *ScaAuthPermissionRuleUpdate { + sapru.mutation.SetPtype(s) + return sapru +} + +// SetNillablePtype sets the "ptype" field if the given value is not nil. +func (sapru *ScaAuthPermissionRuleUpdate) SetNillablePtype(s *string) *ScaAuthPermissionRuleUpdate { + if s != nil { + sapru.SetPtype(*s) + } + return sapru +} + +// SetV0 sets the "v0" field. +func (sapru *ScaAuthPermissionRuleUpdate) SetV0(s string) *ScaAuthPermissionRuleUpdate { + sapru.mutation.SetV0(s) + return sapru +} + +// SetNillableV0 sets the "v0" field if the given value is not nil. +func (sapru *ScaAuthPermissionRuleUpdate) SetNillableV0(s *string) *ScaAuthPermissionRuleUpdate { + if s != nil { + sapru.SetV0(*s) + } + return sapru +} + +// SetV1 sets the "v1" field. +func (sapru *ScaAuthPermissionRuleUpdate) SetV1(s string) *ScaAuthPermissionRuleUpdate { + sapru.mutation.SetV1(s) + return sapru +} + +// SetNillableV1 sets the "v1" field if the given value is not nil. +func (sapru *ScaAuthPermissionRuleUpdate) SetNillableV1(s *string) *ScaAuthPermissionRuleUpdate { + if s != nil { + sapru.SetV1(*s) + } + return sapru +} + +// SetV2 sets the "v2" field. +func (sapru *ScaAuthPermissionRuleUpdate) SetV2(s string) *ScaAuthPermissionRuleUpdate { + sapru.mutation.SetV2(s) + return sapru +} + +// SetNillableV2 sets the "v2" field if the given value is not nil. +func (sapru *ScaAuthPermissionRuleUpdate) SetNillableV2(s *string) *ScaAuthPermissionRuleUpdate { + if s != nil { + sapru.SetV2(*s) + } + return sapru +} + +// ClearV2 clears the value of the "v2" field. +func (sapru *ScaAuthPermissionRuleUpdate) ClearV2() *ScaAuthPermissionRuleUpdate { + sapru.mutation.ClearV2() + return sapru +} + +// SetV3 sets the "v3" field. +func (sapru *ScaAuthPermissionRuleUpdate) SetV3(s string) *ScaAuthPermissionRuleUpdate { + sapru.mutation.SetV3(s) + return sapru +} + +// SetNillableV3 sets the "v3" field if the given value is not nil. +func (sapru *ScaAuthPermissionRuleUpdate) SetNillableV3(s *string) *ScaAuthPermissionRuleUpdate { + if s != nil { + sapru.SetV3(*s) + } + return sapru +} + +// ClearV3 clears the value of the "v3" field. +func (sapru *ScaAuthPermissionRuleUpdate) ClearV3() *ScaAuthPermissionRuleUpdate { + sapru.mutation.ClearV3() + return sapru +} + +// SetV4 sets the "v4" field. +func (sapru *ScaAuthPermissionRuleUpdate) SetV4(s string) *ScaAuthPermissionRuleUpdate { + sapru.mutation.SetV4(s) + return sapru +} + +// SetNillableV4 sets the "v4" field if the given value is not nil. +func (sapru *ScaAuthPermissionRuleUpdate) SetNillableV4(s *string) *ScaAuthPermissionRuleUpdate { + if s != nil { + sapru.SetV4(*s) + } + return sapru +} + +// ClearV4 clears the value of the "v4" field. +func (sapru *ScaAuthPermissionRuleUpdate) ClearV4() *ScaAuthPermissionRuleUpdate { + sapru.mutation.ClearV4() + return sapru +} + +// SetV5 sets the "v5" field. +func (sapru *ScaAuthPermissionRuleUpdate) SetV5(s string) *ScaAuthPermissionRuleUpdate { + sapru.mutation.SetV5(s) + return sapru +} + +// SetNillableV5 sets the "v5" field if the given value is not nil. +func (sapru *ScaAuthPermissionRuleUpdate) SetNillableV5(s *string) *ScaAuthPermissionRuleUpdate { + if s != nil { + sapru.SetV5(*s) + } + return sapru +} + +// ClearV5 clears the value of the "v5" field. +func (sapru *ScaAuthPermissionRuleUpdate) ClearV5() *ScaAuthPermissionRuleUpdate { + sapru.mutation.ClearV5() + return sapru +} + +// SetScaAuthRoleID sets the "sca_auth_role" edge to the ScaAuthRole entity by ID. +func (sapru *ScaAuthPermissionRuleUpdate) SetScaAuthRoleID(id int64) *ScaAuthPermissionRuleUpdate { + sapru.mutation.SetScaAuthRoleID(id) + return sapru +} + +// SetNillableScaAuthRoleID sets the "sca_auth_role" edge to the ScaAuthRole entity by ID if the given value is not nil. +func (sapru *ScaAuthPermissionRuleUpdate) SetNillableScaAuthRoleID(id *int64) *ScaAuthPermissionRuleUpdate { + if id != nil { + sapru = sapru.SetScaAuthRoleID(*id) + } + return sapru +} + +// SetScaAuthRole sets the "sca_auth_role" edge to the ScaAuthRole entity. +func (sapru *ScaAuthPermissionRuleUpdate) SetScaAuthRole(s *ScaAuthRole) *ScaAuthPermissionRuleUpdate { + return sapru.SetScaAuthRoleID(s.ID) +} + +// Mutation returns the ScaAuthPermissionRuleMutation object of the builder. +func (sapru *ScaAuthPermissionRuleUpdate) Mutation() *ScaAuthPermissionRuleMutation { + return sapru.mutation +} + +// ClearScaAuthRole clears the "sca_auth_role" edge to the ScaAuthRole entity. +func (sapru *ScaAuthPermissionRuleUpdate) ClearScaAuthRole() *ScaAuthPermissionRuleUpdate { + sapru.mutation.ClearScaAuthRole() + return sapru +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (sapru *ScaAuthPermissionRuleUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, sapru.sqlSave, sapru.mutation, sapru.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (sapru *ScaAuthPermissionRuleUpdate) SaveX(ctx context.Context) int { + affected, err := sapru.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (sapru *ScaAuthPermissionRuleUpdate) Exec(ctx context.Context) error { + _, err := sapru.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (sapru *ScaAuthPermissionRuleUpdate) ExecX(ctx context.Context) { + if err := sapru.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (sapru *ScaAuthPermissionRuleUpdate) check() error { + if v, ok := sapru.mutation.Ptype(); ok { + if err := scaauthpermissionrule.PtypeValidator(v); err != nil { + return &ValidationError{Name: "ptype", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.ptype": %w`, err)} + } + } + if v, ok := sapru.mutation.V0(); ok { + if err := scaauthpermissionrule.V0Validator(v); err != nil { + return &ValidationError{Name: "v0", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v0": %w`, err)} + } + } + if v, ok := sapru.mutation.V1(); ok { + if err := scaauthpermissionrule.V1Validator(v); err != nil { + return &ValidationError{Name: "v1", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v1": %w`, err)} + } + } + if v, ok := sapru.mutation.V2(); ok { + if err := scaauthpermissionrule.V2Validator(v); err != nil { + return &ValidationError{Name: "v2", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v2": %w`, err)} + } + } + if v, ok := sapru.mutation.V3(); ok { + if err := scaauthpermissionrule.V3Validator(v); err != nil { + return &ValidationError{Name: "v3", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v3": %w`, err)} + } + } + if v, ok := sapru.mutation.V4(); ok { + if err := scaauthpermissionrule.V4Validator(v); err != nil { + return &ValidationError{Name: "v4", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v4": %w`, err)} + } + } + if v, ok := sapru.mutation.V5(); ok { + if err := scaauthpermissionrule.V5Validator(v); err != nil { + return &ValidationError{Name: "v5", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v5": %w`, err)} + } + } + return nil +} + +func (sapru *ScaAuthPermissionRuleUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := sapru.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(scaauthpermissionrule.Table, scaauthpermissionrule.Columns, sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64)) + if ps := sapru.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := sapru.mutation.Ptype(); ok { + _spec.SetField(scaauthpermissionrule.FieldPtype, field.TypeString, value) + } + if value, ok := sapru.mutation.V0(); ok { + _spec.SetField(scaauthpermissionrule.FieldV0, field.TypeString, value) + } + if value, ok := sapru.mutation.V1(); ok { + _spec.SetField(scaauthpermissionrule.FieldV1, field.TypeString, value) + } + if value, ok := sapru.mutation.V2(); ok { + _spec.SetField(scaauthpermissionrule.FieldV2, field.TypeString, value) + } + if sapru.mutation.V2Cleared() { + _spec.ClearField(scaauthpermissionrule.FieldV2, field.TypeString) + } + if value, ok := sapru.mutation.V3(); ok { + _spec.SetField(scaauthpermissionrule.FieldV3, field.TypeString, value) + } + if sapru.mutation.V3Cleared() { + _spec.ClearField(scaauthpermissionrule.FieldV3, field.TypeString) + } + if value, ok := sapru.mutation.V4(); ok { + _spec.SetField(scaauthpermissionrule.FieldV4, field.TypeString, value) + } + if sapru.mutation.V4Cleared() { + _spec.ClearField(scaauthpermissionrule.FieldV4, field.TypeString) + } + if value, ok := sapru.mutation.V5(); ok { + _spec.SetField(scaauthpermissionrule.FieldV5, field.TypeString, value) + } + if sapru.mutation.V5Cleared() { + _spec.ClearField(scaauthpermissionrule.FieldV5, field.TypeString) + } + if sapru.mutation.ScaAuthRoleCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: scaauthpermissionrule.ScaAuthRoleTable, + Columns: []string{scaauthpermissionrule.ScaAuthRoleColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(scaauthrole.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := sapru.mutation.ScaAuthRoleIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: scaauthpermissionrule.ScaAuthRoleTable, + Columns: []string{scaauthpermissionrule.ScaAuthRoleColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(scaauthrole.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if n, err = sqlgraph.UpdateNodes(ctx, sapru.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{scaauthpermissionrule.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + sapru.mutation.done = true + return n, nil +} + +// ScaAuthPermissionRuleUpdateOne is the builder for updating a single ScaAuthPermissionRule entity. +type ScaAuthPermissionRuleUpdateOne struct { + config + fields []string + hooks []Hook + mutation *ScaAuthPermissionRuleMutation +} + +// SetPtype sets the "ptype" field. +func (sapruo *ScaAuthPermissionRuleUpdateOne) SetPtype(s string) *ScaAuthPermissionRuleUpdateOne { + sapruo.mutation.SetPtype(s) + return sapruo +} + +// SetNillablePtype sets the "ptype" field if the given value is not nil. +func (sapruo *ScaAuthPermissionRuleUpdateOne) SetNillablePtype(s *string) *ScaAuthPermissionRuleUpdateOne { + if s != nil { + sapruo.SetPtype(*s) + } + return sapruo +} + +// SetV0 sets the "v0" field. +func (sapruo *ScaAuthPermissionRuleUpdateOne) SetV0(s string) *ScaAuthPermissionRuleUpdateOne { + sapruo.mutation.SetV0(s) + return sapruo +} + +// SetNillableV0 sets the "v0" field if the given value is not nil. +func (sapruo *ScaAuthPermissionRuleUpdateOne) SetNillableV0(s *string) *ScaAuthPermissionRuleUpdateOne { + if s != nil { + sapruo.SetV0(*s) + } + return sapruo +} + +// SetV1 sets the "v1" field. +func (sapruo *ScaAuthPermissionRuleUpdateOne) SetV1(s string) *ScaAuthPermissionRuleUpdateOne { + sapruo.mutation.SetV1(s) + return sapruo +} + +// SetNillableV1 sets the "v1" field if the given value is not nil. +func (sapruo *ScaAuthPermissionRuleUpdateOne) SetNillableV1(s *string) *ScaAuthPermissionRuleUpdateOne { + if s != nil { + sapruo.SetV1(*s) + } + return sapruo +} + +// SetV2 sets the "v2" field. +func (sapruo *ScaAuthPermissionRuleUpdateOne) SetV2(s string) *ScaAuthPermissionRuleUpdateOne { + sapruo.mutation.SetV2(s) + return sapruo +} + +// SetNillableV2 sets the "v2" field if the given value is not nil. +func (sapruo *ScaAuthPermissionRuleUpdateOne) SetNillableV2(s *string) *ScaAuthPermissionRuleUpdateOne { + if s != nil { + sapruo.SetV2(*s) + } + return sapruo +} + +// ClearV2 clears the value of the "v2" field. +func (sapruo *ScaAuthPermissionRuleUpdateOne) ClearV2() *ScaAuthPermissionRuleUpdateOne { + sapruo.mutation.ClearV2() + return sapruo +} + +// SetV3 sets the "v3" field. +func (sapruo *ScaAuthPermissionRuleUpdateOne) SetV3(s string) *ScaAuthPermissionRuleUpdateOne { + sapruo.mutation.SetV3(s) + return sapruo +} + +// SetNillableV3 sets the "v3" field if the given value is not nil. +func (sapruo *ScaAuthPermissionRuleUpdateOne) SetNillableV3(s *string) *ScaAuthPermissionRuleUpdateOne { + if s != nil { + sapruo.SetV3(*s) + } + return sapruo +} + +// ClearV3 clears the value of the "v3" field. +func (sapruo *ScaAuthPermissionRuleUpdateOne) ClearV3() *ScaAuthPermissionRuleUpdateOne { + sapruo.mutation.ClearV3() + return sapruo +} + +// SetV4 sets the "v4" field. +func (sapruo *ScaAuthPermissionRuleUpdateOne) SetV4(s string) *ScaAuthPermissionRuleUpdateOne { + sapruo.mutation.SetV4(s) + return sapruo +} + +// SetNillableV4 sets the "v4" field if the given value is not nil. +func (sapruo *ScaAuthPermissionRuleUpdateOne) SetNillableV4(s *string) *ScaAuthPermissionRuleUpdateOne { + if s != nil { + sapruo.SetV4(*s) + } + return sapruo +} + +// ClearV4 clears the value of the "v4" field. +func (sapruo *ScaAuthPermissionRuleUpdateOne) ClearV4() *ScaAuthPermissionRuleUpdateOne { + sapruo.mutation.ClearV4() + return sapruo +} + +// SetV5 sets the "v5" field. +func (sapruo *ScaAuthPermissionRuleUpdateOne) SetV5(s string) *ScaAuthPermissionRuleUpdateOne { + sapruo.mutation.SetV5(s) + return sapruo +} + +// SetNillableV5 sets the "v5" field if the given value is not nil. +func (sapruo *ScaAuthPermissionRuleUpdateOne) SetNillableV5(s *string) *ScaAuthPermissionRuleUpdateOne { + if s != nil { + sapruo.SetV5(*s) + } + return sapruo +} + +// ClearV5 clears the value of the "v5" field. +func (sapruo *ScaAuthPermissionRuleUpdateOne) ClearV5() *ScaAuthPermissionRuleUpdateOne { + sapruo.mutation.ClearV5() + return sapruo +} + +// SetScaAuthRoleID sets the "sca_auth_role" edge to the ScaAuthRole entity by ID. +func (sapruo *ScaAuthPermissionRuleUpdateOne) SetScaAuthRoleID(id int64) *ScaAuthPermissionRuleUpdateOne { + sapruo.mutation.SetScaAuthRoleID(id) + return sapruo +} + +// SetNillableScaAuthRoleID sets the "sca_auth_role" edge to the ScaAuthRole entity by ID if the given value is not nil. +func (sapruo *ScaAuthPermissionRuleUpdateOne) SetNillableScaAuthRoleID(id *int64) *ScaAuthPermissionRuleUpdateOne { + if id != nil { + sapruo = sapruo.SetScaAuthRoleID(*id) + } + return sapruo +} + +// SetScaAuthRole sets the "sca_auth_role" edge to the ScaAuthRole entity. +func (sapruo *ScaAuthPermissionRuleUpdateOne) SetScaAuthRole(s *ScaAuthRole) *ScaAuthPermissionRuleUpdateOne { + return sapruo.SetScaAuthRoleID(s.ID) +} + +// Mutation returns the ScaAuthPermissionRuleMutation object of the builder. +func (sapruo *ScaAuthPermissionRuleUpdateOne) Mutation() *ScaAuthPermissionRuleMutation { + return sapruo.mutation +} + +// ClearScaAuthRole clears the "sca_auth_role" edge to the ScaAuthRole entity. +func (sapruo *ScaAuthPermissionRuleUpdateOne) ClearScaAuthRole() *ScaAuthPermissionRuleUpdateOne { + sapruo.mutation.ClearScaAuthRole() + return sapruo +} + +// Where appends a list predicates to the ScaAuthPermissionRuleUpdate builder. +func (sapruo *ScaAuthPermissionRuleUpdateOne) Where(ps ...predicate.ScaAuthPermissionRule) *ScaAuthPermissionRuleUpdateOne { + sapruo.mutation.Where(ps...) + return sapruo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (sapruo *ScaAuthPermissionRuleUpdateOne) Select(field string, fields ...string) *ScaAuthPermissionRuleUpdateOne { + sapruo.fields = append([]string{field}, fields...) + return sapruo +} + +// Save executes the query and returns the updated ScaAuthPermissionRule entity. +func (sapruo *ScaAuthPermissionRuleUpdateOne) Save(ctx context.Context) (*ScaAuthPermissionRule, error) { + return withHooks(ctx, sapruo.sqlSave, sapruo.mutation, sapruo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (sapruo *ScaAuthPermissionRuleUpdateOne) SaveX(ctx context.Context) *ScaAuthPermissionRule { + node, err := sapruo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (sapruo *ScaAuthPermissionRuleUpdateOne) Exec(ctx context.Context) error { + _, err := sapruo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (sapruo *ScaAuthPermissionRuleUpdateOne) ExecX(ctx context.Context) { + if err := sapruo.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (sapruo *ScaAuthPermissionRuleUpdateOne) check() error { + if v, ok := sapruo.mutation.Ptype(); ok { + if err := scaauthpermissionrule.PtypeValidator(v); err != nil { + return &ValidationError{Name: "ptype", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.ptype": %w`, err)} + } + } + if v, ok := sapruo.mutation.V0(); ok { + if err := scaauthpermissionrule.V0Validator(v); err != nil { + return &ValidationError{Name: "v0", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v0": %w`, err)} + } + } + if v, ok := sapruo.mutation.V1(); ok { + if err := scaauthpermissionrule.V1Validator(v); err != nil { + return &ValidationError{Name: "v1", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v1": %w`, err)} + } + } + if v, ok := sapruo.mutation.V2(); ok { + if err := scaauthpermissionrule.V2Validator(v); err != nil { + return &ValidationError{Name: "v2", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v2": %w`, err)} + } + } + if v, ok := sapruo.mutation.V3(); ok { + if err := scaauthpermissionrule.V3Validator(v); err != nil { + return &ValidationError{Name: "v3", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v3": %w`, err)} + } + } + if v, ok := sapruo.mutation.V4(); ok { + if err := scaauthpermissionrule.V4Validator(v); err != nil { + return &ValidationError{Name: "v4", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v4": %w`, err)} + } + } + if v, ok := sapruo.mutation.V5(); ok { + if err := scaauthpermissionrule.V5Validator(v); err != nil { + return &ValidationError{Name: "v5", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v5": %w`, err)} + } + } + return nil +} + +func (sapruo *ScaAuthPermissionRuleUpdateOne) sqlSave(ctx context.Context) (_node *ScaAuthPermissionRule, err error) { + if err := sapruo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(scaauthpermissionrule.Table, scaauthpermissionrule.Columns, sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64)) + id, ok := sapruo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ScaAuthPermissionRule.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := sapruo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, scaauthpermissionrule.FieldID) + for _, f := range fields { + if !scaauthpermissionrule.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != scaauthpermissionrule.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := sapruo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := sapruo.mutation.Ptype(); ok { + _spec.SetField(scaauthpermissionrule.FieldPtype, field.TypeString, value) + } + if value, ok := sapruo.mutation.V0(); ok { + _spec.SetField(scaauthpermissionrule.FieldV0, field.TypeString, value) + } + if value, ok := sapruo.mutation.V1(); ok { + _spec.SetField(scaauthpermissionrule.FieldV1, field.TypeString, value) + } + if value, ok := sapruo.mutation.V2(); ok { + _spec.SetField(scaauthpermissionrule.FieldV2, field.TypeString, value) + } + if sapruo.mutation.V2Cleared() { + _spec.ClearField(scaauthpermissionrule.FieldV2, field.TypeString) + } + if value, ok := sapruo.mutation.V3(); ok { + _spec.SetField(scaauthpermissionrule.FieldV3, field.TypeString, value) + } + if sapruo.mutation.V3Cleared() { + _spec.ClearField(scaauthpermissionrule.FieldV3, field.TypeString) + } + if value, ok := sapruo.mutation.V4(); ok { + _spec.SetField(scaauthpermissionrule.FieldV4, field.TypeString, value) + } + if sapruo.mutation.V4Cleared() { + _spec.ClearField(scaauthpermissionrule.FieldV4, field.TypeString) + } + if value, ok := sapruo.mutation.V5(); ok { + _spec.SetField(scaauthpermissionrule.FieldV5, field.TypeString, value) + } + if sapruo.mutation.V5Cleared() { + _spec.ClearField(scaauthpermissionrule.FieldV5, field.TypeString) + } + if sapruo.mutation.ScaAuthRoleCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: scaauthpermissionrule.ScaAuthRoleTable, + Columns: []string{scaauthpermissionrule.ScaAuthRoleColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(scaauthrole.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := sapruo.mutation.ScaAuthRoleIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: scaauthpermissionrule.ScaAuthRoleTable, + Columns: []string{scaauthpermissionrule.ScaAuthRoleColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(scaauthrole.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _node = &ScaAuthPermissionRule{config: sapruo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, sapruo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{scaauthpermissionrule.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + sapruo.mutation.done = true + return _node, nil +} diff --git a/common/ent/scaauthrole.go b/common/ent/scaauthrole.go new file mode 100644 index 0000000..a3a8128 --- /dev/null +++ b/common/ent/scaauthrole.go @@ -0,0 +1,177 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "schisandra-album-cloud-microservices/common/ent/scaauthrole" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// ScaAuthRole is the model entity for the ScaAuthRole schema. +type ScaAuthRole struct { + config `json:"-"` + // ID of the ent. + // 主键ID + ID int64 `json:"id,omitempty"` + // 角色名称 + RoleName string `json:"role_name,omitempty"` + // 角色关键字 + RoleKey string `json:"role_key,omitempty"` + // 创建时间 + CreatedAt time.Time `json:"created_at,omitempty"` + // 更新时间 + UpdateAt time.Time `json:"update_at,omitempty"` + // 是否删除 0 未删除 1已删除 + Deleted int `json:"deleted,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the ScaAuthRoleQuery when eager-loading is set. + Edges ScaAuthRoleEdges `json:"edges"` + selectValues sql.SelectValues +} + +// ScaAuthRoleEdges holds the relations/edges for other nodes in the graph. +type ScaAuthRoleEdges struct { + // ScaAuthPermissionRule holds the value of the sca_auth_permission_rule edge. + ScaAuthPermissionRule []*ScaAuthPermissionRule `json:"sca_auth_permission_rule,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [1]bool +} + +// ScaAuthPermissionRuleOrErr returns the ScaAuthPermissionRule value or an error if the edge +// was not loaded in eager-loading. +func (e ScaAuthRoleEdges) ScaAuthPermissionRuleOrErr() ([]*ScaAuthPermissionRule, error) { + if e.loadedTypes[0] { + return e.ScaAuthPermissionRule, nil + } + return nil, &NotLoadedError{edge: "sca_auth_permission_rule"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*ScaAuthRole) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case scaauthrole.FieldID, scaauthrole.FieldDeleted: + values[i] = new(sql.NullInt64) + case scaauthrole.FieldRoleName, scaauthrole.FieldRoleKey: + values[i] = new(sql.NullString) + case scaauthrole.FieldCreatedAt, scaauthrole.FieldUpdateAt: + 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 ScaAuthRole fields. +func (sar *ScaAuthRole) 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 scaauthrole.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + sar.ID = int64(value.Int64) + case scaauthrole.FieldRoleName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field role_name", values[i]) + } else if value.Valid { + sar.RoleName = value.String + } + case scaauthrole.FieldRoleKey: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field role_key", values[i]) + } else if value.Valid { + sar.RoleKey = value.String + } + case scaauthrole.FieldCreatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field created_at", values[i]) + } else if value.Valid { + sar.CreatedAt = value.Time + } + case scaauthrole.FieldUpdateAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field update_at", values[i]) + } else if value.Valid { + sar.UpdateAt = value.Time + } + case scaauthrole.FieldDeleted: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field deleted", values[i]) + } else if value.Valid { + sar.Deleted = int(value.Int64) + } + default: + sar.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the ScaAuthRole. +// This includes values selected through modifiers, order, etc. +func (sar *ScaAuthRole) Value(name string) (ent.Value, error) { + return sar.selectValues.Get(name) +} + +// QueryScaAuthPermissionRule queries the "sca_auth_permission_rule" edge of the ScaAuthRole entity. +func (sar *ScaAuthRole) QueryScaAuthPermissionRule() *ScaAuthPermissionRuleQuery { + return NewScaAuthRoleClient(sar.config).QueryScaAuthPermissionRule(sar) +} + +// Update returns a builder for updating this ScaAuthRole. +// Note that you need to call ScaAuthRole.Unwrap() before calling this method if this ScaAuthRole +// was returned from a transaction, and the transaction was committed or rolled back. +func (sar *ScaAuthRole) Update() *ScaAuthRoleUpdateOne { + return NewScaAuthRoleClient(sar.config).UpdateOne(sar) +} + +// Unwrap unwraps the ScaAuthRole 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 (sar *ScaAuthRole) Unwrap() *ScaAuthRole { + _tx, ok := sar.config.driver.(*txDriver) + if !ok { + panic("ent: ScaAuthRole is not a transactional entity") + } + sar.config.driver = _tx.drv + return sar +} + +// String implements the fmt.Stringer. +func (sar *ScaAuthRole) String() string { + var builder strings.Builder + builder.WriteString("ScaAuthRole(") + builder.WriteString(fmt.Sprintf("id=%v, ", sar.ID)) + builder.WriteString("role_name=") + builder.WriteString(sar.RoleName) + builder.WriteString(", ") + builder.WriteString("role_key=") + builder.WriteString(sar.RoleKey) + builder.WriteString(", ") + builder.WriteString("created_at=") + builder.WriteString(sar.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("update_at=") + builder.WriteString(sar.UpdateAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("deleted=") + builder.WriteString(fmt.Sprintf("%v", sar.Deleted)) + builder.WriteByte(')') + return builder.String() +} + +// ScaAuthRoles is a parsable slice of ScaAuthRole. +type ScaAuthRoles []*ScaAuthRole diff --git a/common/ent/scaauthrole/scaauthrole.go b/common/ent/scaauthrole/scaauthrole.go new file mode 100644 index 0000000..e31bdbf --- /dev/null +++ b/common/ent/scaauthrole/scaauthrole.go @@ -0,0 +1,127 @@ +// Code generated by ent, DO NOT EDIT. + +package scaauthrole + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the scaauthrole type in the database. + Label = "sca_auth_role" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldRoleName holds the string denoting the role_name field in the database. + FieldRoleName = "role_name" + // FieldRoleKey holds the string denoting the role_key field in the database. + FieldRoleKey = "role_key" + // FieldCreatedAt holds the string denoting the created_at field in the database. + FieldCreatedAt = "created_at" + // FieldUpdateAt holds the string denoting the update_at field in the database. + FieldUpdateAt = "update_at" + // FieldDeleted holds the string denoting the deleted field in the database. + FieldDeleted = "deleted" + // EdgeScaAuthPermissionRule holds the string denoting the sca_auth_permission_rule edge name in mutations. + EdgeScaAuthPermissionRule = "sca_auth_permission_rule" + // Table holds the table name of the scaauthrole in the database. + Table = "sca_auth_roles" + // ScaAuthPermissionRuleTable is the table that holds the sca_auth_permission_rule relation/edge. + ScaAuthPermissionRuleTable = "sca_auth_permission_rules" + // ScaAuthPermissionRuleInverseTable is the table name for the ScaAuthPermissionRule entity. + // It exists in this package in order to avoid circular dependency with the "scaauthpermissionrule" package. + ScaAuthPermissionRuleInverseTable = "sca_auth_permission_rules" + // ScaAuthPermissionRuleColumn is the table column denoting the sca_auth_permission_rule relation/edge. + ScaAuthPermissionRuleColumn = "sca_auth_role_sca_auth_permission_rule" +) + +// Columns holds all SQL columns for scaauthrole fields. +var Columns = []string{ + FieldID, + FieldRoleName, + FieldRoleKey, + FieldCreatedAt, + FieldUpdateAt, + 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 ( + // RoleNameValidator is a validator for the "role_name" field. It is called by the builders before save. + RoleNameValidator func(string) error + // RoleKeyValidator is a validator for the "role_key" field. It is called by the builders before save. + RoleKeyValidator func(string) error + // DefaultCreatedAt holds the default value on creation for the "created_at" field. + DefaultCreatedAt func() time.Time + // DefaultUpdateAt holds the default value on creation for the "update_at" field. + DefaultUpdateAt func() time.Time + // UpdateDefaultUpdateAt holds the default value on update for the "update_at" field. + UpdateDefaultUpdateAt func() time.Time + // DefaultDeleted holds the default value on creation for the "deleted" field. + DefaultDeleted int +) + +// OrderOption defines the ordering options for the ScaAuthRole 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() +} + +// ByRoleName orders the results by the role_name field. +func ByRoleName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldRoleName, opts...).ToFunc() +} + +// ByRoleKey orders the results by the role_key field. +func ByRoleKey(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldRoleKey, opts...).ToFunc() +} + +// ByCreatedAt orders the results by the created_at field. +func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() +} + +// ByUpdateAt orders the results by the update_at field. +func ByUpdateAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateAt, opts...).ToFunc() +} + +// ByDeleted orders the results by the deleted field. +func ByDeleted(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeleted, opts...).ToFunc() +} + +// ByScaAuthPermissionRuleCount orders the results by sca_auth_permission_rule count. +func ByScaAuthPermissionRuleCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newScaAuthPermissionRuleStep(), opts...) + } +} + +// ByScaAuthPermissionRule orders the results by sca_auth_permission_rule terms. +func ByScaAuthPermissionRule(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newScaAuthPermissionRuleStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} +func newScaAuthPermissionRuleStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ScaAuthPermissionRuleInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, ScaAuthPermissionRuleTable, ScaAuthPermissionRuleColumn), + ) +} diff --git a/common/ent/scaauthrole/where.go b/common/ent/scaauthrole/where.go new file mode 100644 index 0000000..a77b8d3 --- /dev/null +++ b/common/ent/scaauthrole/where.go @@ -0,0 +1,369 @@ +// Code generated by ent, DO NOT EDIT. + +package scaauthrole + +import ( + "schisandra-album-cloud-microservices/common/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id int64) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int64) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int64) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int64) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int64) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int64) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int64) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int64) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int64) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldLTE(FieldID, id)) +} + +// RoleName applies equality check predicate on the "role_name" field. It's identical to RoleNameEQ. +func RoleName(v string) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldEQ(FieldRoleName, v)) +} + +// RoleKey applies equality check predicate on the "role_key" field. It's identical to RoleKeyEQ. +func RoleKey(v string) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldEQ(FieldRoleKey, v)) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldEQ(FieldCreatedAt, v)) +} + +// UpdateAt applies equality check predicate on the "update_at" field. It's identical to UpdateAtEQ. +func UpdateAt(v time.Time) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldEQ(FieldUpdateAt, v)) +} + +// Deleted applies equality check predicate on the "deleted" field. It's identical to DeletedEQ. +func Deleted(v int) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldEQ(FieldDeleted, v)) +} + +// RoleNameEQ applies the EQ predicate on the "role_name" field. +func RoleNameEQ(v string) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldEQ(FieldRoleName, v)) +} + +// RoleNameNEQ applies the NEQ predicate on the "role_name" field. +func RoleNameNEQ(v string) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldNEQ(FieldRoleName, v)) +} + +// RoleNameIn applies the In predicate on the "role_name" field. +func RoleNameIn(vs ...string) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldIn(FieldRoleName, vs...)) +} + +// RoleNameNotIn applies the NotIn predicate on the "role_name" field. +func RoleNameNotIn(vs ...string) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldNotIn(FieldRoleName, vs...)) +} + +// RoleNameGT applies the GT predicate on the "role_name" field. +func RoleNameGT(v string) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldGT(FieldRoleName, v)) +} + +// RoleNameGTE applies the GTE predicate on the "role_name" field. +func RoleNameGTE(v string) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldGTE(FieldRoleName, v)) +} + +// RoleNameLT applies the LT predicate on the "role_name" field. +func RoleNameLT(v string) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldLT(FieldRoleName, v)) +} + +// RoleNameLTE applies the LTE predicate on the "role_name" field. +func RoleNameLTE(v string) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldLTE(FieldRoleName, v)) +} + +// RoleNameContains applies the Contains predicate on the "role_name" field. +func RoleNameContains(v string) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldContains(FieldRoleName, v)) +} + +// RoleNameHasPrefix applies the HasPrefix predicate on the "role_name" field. +func RoleNameHasPrefix(v string) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldHasPrefix(FieldRoleName, v)) +} + +// RoleNameHasSuffix applies the HasSuffix predicate on the "role_name" field. +func RoleNameHasSuffix(v string) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldHasSuffix(FieldRoleName, v)) +} + +// RoleNameEqualFold applies the EqualFold predicate on the "role_name" field. +func RoleNameEqualFold(v string) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldEqualFold(FieldRoleName, v)) +} + +// RoleNameContainsFold applies the ContainsFold predicate on the "role_name" field. +func RoleNameContainsFold(v string) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldContainsFold(FieldRoleName, v)) +} + +// RoleKeyEQ applies the EQ predicate on the "role_key" field. +func RoleKeyEQ(v string) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldEQ(FieldRoleKey, v)) +} + +// RoleKeyNEQ applies the NEQ predicate on the "role_key" field. +func RoleKeyNEQ(v string) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldNEQ(FieldRoleKey, v)) +} + +// RoleKeyIn applies the In predicate on the "role_key" field. +func RoleKeyIn(vs ...string) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldIn(FieldRoleKey, vs...)) +} + +// RoleKeyNotIn applies the NotIn predicate on the "role_key" field. +func RoleKeyNotIn(vs ...string) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldNotIn(FieldRoleKey, vs...)) +} + +// RoleKeyGT applies the GT predicate on the "role_key" field. +func RoleKeyGT(v string) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldGT(FieldRoleKey, v)) +} + +// RoleKeyGTE applies the GTE predicate on the "role_key" field. +func RoleKeyGTE(v string) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldGTE(FieldRoleKey, v)) +} + +// RoleKeyLT applies the LT predicate on the "role_key" field. +func RoleKeyLT(v string) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldLT(FieldRoleKey, v)) +} + +// RoleKeyLTE applies the LTE predicate on the "role_key" field. +func RoleKeyLTE(v string) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldLTE(FieldRoleKey, v)) +} + +// RoleKeyContains applies the Contains predicate on the "role_key" field. +func RoleKeyContains(v string) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldContains(FieldRoleKey, v)) +} + +// RoleKeyHasPrefix applies the HasPrefix predicate on the "role_key" field. +func RoleKeyHasPrefix(v string) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldHasPrefix(FieldRoleKey, v)) +} + +// RoleKeyHasSuffix applies the HasSuffix predicate on the "role_key" field. +func RoleKeyHasSuffix(v string) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldHasSuffix(FieldRoleKey, v)) +} + +// RoleKeyEqualFold applies the EqualFold predicate on the "role_key" field. +func RoleKeyEqualFold(v string) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldEqualFold(FieldRoleKey, v)) +} + +// RoleKeyContainsFold applies the ContainsFold predicate on the "role_key" field. +func RoleKeyContainsFold(v string) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldContainsFold(FieldRoleKey, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldLTE(FieldCreatedAt, v)) +} + +// UpdateAtEQ applies the EQ predicate on the "update_at" field. +func UpdateAtEQ(v time.Time) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldEQ(FieldUpdateAt, v)) +} + +// UpdateAtNEQ applies the NEQ predicate on the "update_at" field. +func UpdateAtNEQ(v time.Time) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldNEQ(FieldUpdateAt, v)) +} + +// UpdateAtIn applies the In predicate on the "update_at" field. +func UpdateAtIn(vs ...time.Time) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldIn(FieldUpdateAt, vs...)) +} + +// UpdateAtNotIn applies the NotIn predicate on the "update_at" field. +func UpdateAtNotIn(vs ...time.Time) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldNotIn(FieldUpdateAt, vs...)) +} + +// UpdateAtGT applies the GT predicate on the "update_at" field. +func UpdateAtGT(v time.Time) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldGT(FieldUpdateAt, v)) +} + +// UpdateAtGTE applies the GTE predicate on the "update_at" field. +func UpdateAtGTE(v time.Time) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldGTE(FieldUpdateAt, v)) +} + +// UpdateAtLT applies the LT predicate on the "update_at" field. +func UpdateAtLT(v time.Time) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldLT(FieldUpdateAt, v)) +} + +// UpdateAtLTE applies the LTE predicate on the "update_at" field. +func UpdateAtLTE(v time.Time) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldLTE(FieldUpdateAt, v)) +} + +// DeletedEQ applies the EQ predicate on the "deleted" field. +func DeletedEQ(v int) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldEQ(FieldDeleted, v)) +} + +// DeletedNEQ applies the NEQ predicate on the "deleted" field. +func DeletedNEQ(v int) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldNEQ(FieldDeleted, v)) +} + +// DeletedIn applies the In predicate on the "deleted" field. +func DeletedIn(vs ...int) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldIn(FieldDeleted, vs...)) +} + +// DeletedNotIn applies the NotIn predicate on the "deleted" field. +func DeletedNotIn(vs ...int) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldNotIn(FieldDeleted, vs...)) +} + +// DeletedGT applies the GT predicate on the "deleted" field. +func DeletedGT(v int) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldGT(FieldDeleted, v)) +} + +// DeletedGTE applies the GTE predicate on the "deleted" field. +func DeletedGTE(v int) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldGTE(FieldDeleted, v)) +} + +// DeletedLT applies the LT predicate on the "deleted" field. +func DeletedLT(v int) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldLT(FieldDeleted, v)) +} + +// DeletedLTE applies the LTE predicate on the "deleted" field. +func DeletedLTE(v int) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.FieldLTE(FieldDeleted, v)) +} + +// HasScaAuthPermissionRule applies the HasEdge predicate on the "sca_auth_permission_rule" edge. +func HasScaAuthPermissionRule() predicate.ScaAuthRole { + return predicate.ScaAuthRole(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, ScaAuthPermissionRuleTable, ScaAuthPermissionRuleColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasScaAuthPermissionRuleWith applies the HasEdge predicate on the "sca_auth_permission_rule" edge with a given conditions (other predicates). +func HasScaAuthPermissionRuleWith(preds ...predicate.ScaAuthPermissionRule) predicate.ScaAuthRole { + return predicate.ScaAuthRole(func(s *sql.Selector) { + step := newScaAuthPermissionRuleStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.ScaAuthRole) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.ScaAuthRole) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.ScaAuthRole) predicate.ScaAuthRole { + return predicate.ScaAuthRole(sql.NotPredicates(p)) +} diff --git a/common/ent/scaauthrole_create.go b/common/ent/scaauthrole_create.go new file mode 100644 index 0000000..8c04601 --- /dev/null +++ b/common/ent/scaauthrole_create.go @@ -0,0 +1,332 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "schisandra-album-cloud-microservices/common/ent/scaauthpermissionrule" + "schisandra-album-cloud-microservices/common/ent/scaauthrole" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ScaAuthRoleCreate is the builder for creating a ScaAuthRole entity. +type ScaAuthRoleCreate struct { + config + mutation *ScaAuthRoleMutation + hooks []Hook +} + +// SetRoleName sets the "role_name" field. +func (sarc *ScaAuthRoleCreate) SetRoleName(s string) *ScaAuthRoleCreate { + sarc.mutation.SetRoleName(s) + return sarc +} + +// SetRoleKey sets the "role_key" field. +func (sarc *ScaAuthRoleCreate) SetRoleKey(s string) *ScaAuthRoleCreate { + sarc.mutation.SetRoleKey(s) + return sarc +} + +// SetCreatedAt sets the "created_at" field. +func (sarc *ScaAuthRoleCreate) SetCreatedAt(t time.Time) *ScaAuthRoleCreate { + sarc.mutation.SetCreatedAt(t) + return sarc +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (sarc *ScaAuthRoleCreate) SetNillableCreatedAt(t *time.Time) *ScaAuthRoleCreate { + if t != nil { + sarc.SetCreatedAt(*t) + } + return sarc +} + +// SetUpdateAt sets the "update_at" field. +func (sarc *ScaAuthRoleCreate) SetUpdateAt(t time.Time) *ScaAuthRoleCreate { + sarc.mutation.SetUpdateAt(t) + return sarc +} + +// SetNillableUpdateAt sets the "update_at" field if the given value is not nil. +func (sarc *ScaAuthRoleCreate) SetNillableUpdateAt(t *time.Time) *ScaAuthRoleCreate { + if t != nil { + sarc.SetUpdateAt(*t) + } + return sarc +} + +// SetDeleted sets the "deleted" field. +func (sarc *ScaAuthRoleCreate) SetDeleted(i int) *ScaAuthRoleCreate { + sarc.mutation.SetDeleted(i) + return sarc +} + +// SetNillableDeleted sets the "deleted" field if the given value is not nil. +func (sarc *ScaAuthRoleCreate) SetNillableDeleted(i *int) *ScaAuthRoleCreate { + if i != nil { + sarc.SetDeleted(*i) + } + return sarc +} + +// SetID sets the "id" field. +func (sarc *ScaAuthRoleCreate) SetID(i int64) *ScaAuthRoleCreate { + sarc.mutation.SetID(i) + return sarc +} + +// AddScaAuthPermissionRuleIDs adds the "sca_auth_permission_rule" edge to the ScaAuthPermissionRule entity by IDs. +func (sarc *ScaAuthRoleCreate) AddScaAuthPermissionRuleIDs(ids ...int64) *ScaAuthRoleCreate { + sarc.mutation.AddScaAuthPermissionRuleIDs(ids...) + return sarc +} + +// AddScaAuthPermissionRule adds the "sca_auth_permission_rule" edges to the ScaAuthPermissionRule entity. +func (sarc *ScaAuthRoleCreate) AddScaAuthPermissionRule(s ...*ScaAuthPermissionRule) *ScaAuthRoleCreate { + ids := make([]int64, len(s)) + for i := range s { + ids[i] = s[i].ID + } + return sarc.AddScaAuthPermissionRuleIDs(ids...) +} + +// Mutation returns the ScaAuthRoleMutation object of the builder. +func (sarc *ScaAuthRoleCreate) Mutation() *ScaAuthRoleMutation { + return sarc.mutation +} + +// Save creates the ScaAuthRole in the database. +func (sarc *ScaAuthRoleCreate) Save(ctx context.Context) (*ScaAuthRole, error) { + sarc.defaults() + return withHooks(ctx, sarc.sqlSave, sarc.mutation, sarc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (sarc *ScaAuthRoleCreate) SaveX(ctx context.Context) *ScaAuthRole { + v, err := sarc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (sarc *ScaAuthRoleCreate) Exec(ctx context.Context) error { + _, err := sarc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (sarc *ScaAuthRoleCreate) ExecX(ctx context.Context) { + if err := sarc.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (sarc *ScaAuthRoleCreate) defaults() { + if _, ok := sarc.mutation.CreatedAt(); !ok { + v := scaauthrole.DefaultCreatedAt() + sarc.mutation.SetCreatedAt(v) + } + if _, ok := sarc.mutation.UpdateAt(); !ok { + v := scaauthrole.DefaultUpdateAt() + sarc.mutation.SetUpdateAt(v) + } + if _, ok := sarc.mutation.Deleted(); !ok { + v := scaauthrole.DefaultDeleted + sarc.mutation.SetDeleted(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (sarc *ScaAuthRoleCreate) check() error { + if _, ok := sarc.mutation.RoleName(); !ok { + return &ValidationError{Name: "role_name", err: errors.New(`ent: missing required field "ScaAuthRole.role_name"`)} + } + if v, ok := sarc.mutation.RoleName(); ok { + if err := scaauthrole.RoleNameValidator(v); err != nil { + return &ValidationError{Name: "role_name", err: fmt.Errorf(`ent: validator failed for field "ScaAuthRole.role_name": %w`, err)} + } + } + if _, ok := sarc.mutation.RoleKey(); !ok { + return &ValidationError{Name: "role_key", err: errors.New(`ent: missing required field "ScaAuthRole.role_key"`)} + } + if v, ok := sarc.mutation.RoleKey(); ok { + if err := scaauthrole.RoleKeyValidator(v); err != nil { + return &ValidationError{Name: "role_key", err: fmt.Errorf(`ent: validator failed for field "ScaAuthRole.role_key": %w`, err)} + } + } + if _, ok := sarc.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "ScaAuthRole.created_at"`)} + } + if _, ok := sarc.mutation.UpdateAt(); !ok { + return &ValidationError{Name: "update_at", err: errors.New(`ent: missing required field "ScaAuthRole.update_at"`)} + } + if _, ok := sarc.mutation.Deleted(); !ok { + return &ValidationError{Name: "deleted", err: errors.New(`ent: missing required field "ScaAuthRole.deleted"`)} + } + return nil +} + +func (sarc *ScaAuthRoleCreate) sqlSave(ctx context.Context) (*ScaAuthRole, error) { + if err := sarc.check(); err != nil { + return nil, err + } + _node, _spec := sarc.createSpec() + if err := sqlgraph.CreateNode(ctx, sarc.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) + } + sarc.mutation.id = &_node.ID + sarc.mutation.done = true + return _node, nil +} + +func (sarc *ScaAuthRoleCreate) createSpec() (*ScaAuthRole, *sqlgraph.CreateSpec) { + var ( + _node = &ScaAuthRole{config: sarc.config} + _spec = sqlgraph.NewCreateSpec(scaauthrole.Table, sqlgraph.NewFieldSpec(scaauthrole.FieldID, field.TypeInt64)) + ) + if id, ok := sarc.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := sarc.mutation.RoleName(); ok { + _spec.SetField(scaauthrole.FieldRoleName, field.TypeString, value) + _node.RoleName = value + } + if value, ok := sarc.mutation.RoleKey(); ok { + _spec.SetField(scaauthrole.FieldRoleKey, field.TypeString, value) + _node.RoleKey = value + } + if value, ok := sarc.mutation.CreatedAt(); ok { + _spec.SetField(scaauthrole.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := sarc.mutation.UpdateAt(); ok { + _spec.SetField(scaauthrole.FieldUpdateAt, field.TypeTime, value) + _node.UpdateAt = value + } + if value, ok := sarc.mutation.Deleted(); ok { + _spec.SetField(scaauthrole.FieldDeleted, field.TypeInt, value) + _node.Deleted = value + } + if nodes := sarc.mutation.ScaAuthPermissionRuleIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: scaauthrole.ScaAuthPermissionRuleTable, + Columns: []string{scaauthrole.ScaAuthPermissionRuleColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// ScaAuthRoleCreateBulk is the builder for creating many ScaAuthRole entities in bulk. +type ScaAuthRoleCreateBulk struct { + config + err error + builders []*ScaAuthRoleCreate +} + +// Save creates the ScaAuthRole entities in the database. +func (sarcb *ScaAuthRoleCreateBulk) Save(ctx context.Context) ([]*ScaAuthRole, error) { + if sarcb.err != nil { + return nil, sarcb.err + } + specs := make([]*sqlgraph.CreateSpec, len(sarcb.builders)) + nodes := make([]*ScaAuthRole, len(sarcb.builders)) + mutators := make([]Mutator, len(sarcb.builders)) + for i := range sarcb.builders { + func(i int, root context.Context) { + builder := sarcb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*ScaAuthRoleMutation) + 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, sarcb.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, sarcb.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, sarcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (sarcb *ScaAuthRoleCreateBulk) SaveX(ctx context.Context) []*ScaAuthRole { + v, err := sarcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (sarcb *ScaAuthRoleCreateBulk) Exec(ctx context.Context) error { + _, err := sarcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (sarcb *ScaAuthRoleCreateBulk) ExecX(ctx context.Context) { + if err := sarcb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/common/ent/scaauthrole_delete.go b/common/ent/scaauthrole_delete.go new file mode 100644 index 0000000..fac2237 --- /dev/null +++ b/common/ent/scaauthrole_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "schisandra-album-cloud-microservices/common/ent/predicate" + "schisandra-album-cloud-microservices/common/ent/scaauthrole" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ScaAuthRoleDelete is the builder for deleting a ScaAuthRole entity. +type ScaAuthRoleDelete struct { + config + hooks []Hook + mutation *ScaAuthRoleMutation +} + +// Where appends a list predicates to the ScaAuthRoleDelete builder. +func (sard *ScaAuthRoleDelete) Where(ps ...predicate.ScaAuthRole) *ScaAuthRoleDelete { + sard.mutation.Where(ps...) + return sard +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (sard *ScaAuthRoleDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, sard.sqlExec, sard.mutation, sard.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (sard *ScaAuthRoleDelete) ExecX(ctx context.Context) int { + n, err := sard.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (sard *ScaAuthRoleDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(scaauthrole.Table, sqlgraph.NewFieldSpec(scaauthrole.FieldID, field.TypeInt64)) + if ps := sard.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, sard.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + sard.mutation.done = true + return affected, err +} + +// ScaAuthRoleDeleteOne is the builder for deleting a single ScaAuthRole entity. +type ScaAuthRoleDeleteOne struct { + sard *ScaAuthRoleDelete +} + +// Where appends a list predicates to the ScaAuthRoleDelete builder. +func (sardo *ScaAuthRoleDeleteOne) Where(ps ...predicate.ScaAuthRole) *ScaAuthRoleDeleteOne { + sardo.sard.mutation.Where(ps...) + return sardo +} + +// Exec executes the deletion query. +func (sardo *ScaAuthRoleDeleteOne) Exec(ctx context.Context) error { + n, err := sardo.sard.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{scaauthrole.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (sardo *ScaAuthRoleDeleteOne) ExecX(ctx context.Context) { + if err := sardo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/common/ent/scaauthrole_query.go b/common/ent/scaauthrole_query.go new file mode 100644 index 0000000..358a4f2 --- /dev/null +++ b/common/ent/scaauthrole_query.go @@ -0,0 +1,609 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "database/sql/driver" + "fmt" + "math" + "schisandra-album-cloud-microservices/common/ent/predicate" + "schisandra-album-cloud-microservices/common/ent/scaauthpermissionrule" + "schisandra-album-cloud-microservices/common/ent/scaauthrole" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ScaAuthRoleQuery is the builder for querying ScaAuthRole entities. +type ScaAuthRoleQuery struct { + config + ctx *QueryContext + order []scaauthrole.OrderOption + inters []Interceptor + predicates []predicate.ScaAuthRole + withScaAuthPermissionRule *ScaAuthPermissionRuleQuery + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the ScaAuthRoleQuery builder. +func (sarq *ScaAuthRoleQuery) Where(ps ...predicate.ScaAuthRole) *ScaAuthRoleQuery { + sarq.predicates = append(sarq.predicates, ps...) + return sarq +} + +// Limit the number of records to be returned by this query. +func (sarq *ScaAuthRoleQuery) Limit(limit int) *ScaAuthRoleQuery { + sarq.ctx.Limit = &limit + return sarq +} + +// Offset to start from. +func (sarq *ScaAuthRoleQuery) Offset(offset int) *ScaAuthRoleQuery { + sarq.ctx.Offset = &offset + return sarq +} + +// 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 (sarq *ScaAuthRoleQuery) Unique(unique bool) *ScaAuthRoleQuery { + sarq.ctx.Unique = &unique + return sarq +} + +// Order specifies how the records should be ordered. +func (sarq *ScaAuthRoleQuery) Order(o ...scaauthrole.OrderOption) *ScaAuthRoleQuery { + sarq.order = append(sarq.order, o...) + return sarq +} + +// QueryScaAuthPermissionRule chains the current query on the "sca_auth_permission_rule" edge. +func (sarq *ScaAuthRoleQuery) QueryScaAuthPermissionRule() *ScaAuthPermissionRuleQuery { + query := (&ScaAuthPermissionRuleClient{config: sarq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := sarq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := sarq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(scaauthrole.Table, scaauthrole.FieldID, selector), + sqlgraph.To(scaauthpermissionrule.Table, scaauthpermissionrule.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, scaauthrole.ScaAuthPermissionRuleTable, scaauthrole.ScaAuthPermissionRuleColumn), + ) + fromU = sqlgraph.SetNeighbors(sarq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first ScaAuthRole entity from the query. +// Returns a *NotFoundError when no ScaAuthRole was found. +func (sarq *ScaAuthRoleQuery) First(ctx context.Context) (*ScaAuthRole, error) { + nodes, err := sarq.Limit(1).All(setContextOp(ctx, sarq.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{scaauthrole.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (sarq *ScaAuthRoleQuery) FirstX(ctx context.Context) *ScaAuthRole { + node, err := sarq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first ScaAuthRole ID from the query. +// Returns a *NotFoundError when no ScaAuthRole ID was found. +func (sarq *ScaAuthRoleQuery) FirstID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = sarq.Limit(1).IDs(setContextOp(ctx, sarq.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{scaauthrole.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (sarq *ScaAuthRoleQuery) FirstIDX(ctx context.Context) int64 { + id, err := sarq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single ScaAuthRole entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one ScaAuthRole entity is found. +// Returns a *NotFoundError when no ScaAuthRole entities are found. +func (sarq *ScaAuthRoleQuery) Only(ctx context.Context) (*ScaAuthRole, error) { + nodes, err := sarq.Limit(2).All(setContextOp(ctx, sarq.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{scaauthrole.Label} + default: + return nil, &NotSingularError{scaauthrole.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (sarq *ScaAuthRoleQuery) OnlyX(ctx context.Context) *ScaAuthRole { + node, err := sarq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only ScaAuthRole ID in the query. +// Returns a *NotSingularError when more than one ScaAuthRole ID is found. +// Returns a *NotFoundError when no entities are found. +func (sarq *ScaAuthRoleQuery) OnlyID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = sarq.Limit(2).IDs(setContextOp(ctx, sarq.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{scaauthrole.Label} + default: + err = &NotSingularError{scaauthrole.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (sarq *ScaAuthRoleQuery) OnlyIDX(ctx context.Context) int64 { + id, err := sarq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of ScaAuthRoles. +func (sarq *ScaAuthRoleQuery) All(ctx context.Context) ([]*ScaAuthRole, error) { + ctx = setContextOp(ctx, sarq.ctx, ent.OpQueryAll) + if err := sarq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*ScaAuthRole, *ScaAuthRoleQuery]() + return withInterceptors[[]*ScaAuthRole](ctx, sarq, qr, sarq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (sarq *ScaAuthRoleQuery) AllX(ctx context.Context) []*ScaAuthRole { + nodes, err := sarq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of ScaAuthRole IDs. +func (sarq *ScaAuthRoleQuery) IDs(ctx context.Context) (ids []int64, err error) { + if sarq.ctx.Unique == nil && sarq.path != nil { + sarq.Unique(true) + } + ctx = setContextOp(ctx, sarq.ctx, ent.OpQueryIDs) + if err = sarq.Select(scaauthrole.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (sarq *ScaAuthRoleQuery) IDsX(ctx context.Context) []int64 { + ids, err := sarq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (sarq *ScaAuthRoleQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, sarq.ctx, ent.OpQueryCount) + if err := sarq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, sarq, querierCount[*ScaAuthRoleQuery](), sarq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (sarq *ScaAuthRoleQuery) CountX(ctx context.Context) int { + count, err := sarq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (sarq *ScaAuthRoleQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, sarq.ctx, ent.OpQueryExist) + switch _, err := sarq.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 (sarq *ScaAuthRoleQuery) ExistX(ctx context.Context) bool { + exist, err := sarq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the ScaAuthRoleQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (sarq *ScaAuthRoleQuery) Clone() *ScaAuthRoleQuery { + if sarq == nil { + return nil + } + return &ScaAuthRoleQuery{ + config: sarq.config, + ctx: sarq.ctx.Clone(), + order: append([]scaauthrole.OrderOption{}, sarq.order...), + inters: append([]Interceptor{}, sarq.inters...), + predicates: append([]predicate.ScaAuthRole{}, sarq.predicates...), + withScaAuthPermissionRule: sarq.withScaAuthPermissionRule.Clone(), + // clone intermediate query. + sql: sarq.sql.Clone(), + path: sarq.path, + } +} + +// WithScaAuthPermissionRule tells the query-builder to eager-load the nodes that are connected to +// the "sca_auth_permission_rule" edge. The optional arguments are used to configure the query builder of the edge. +func (sarq *ScaAuthRoleQuery) WithScaAuthPermissionRule(opts ...func(*ScaAuthPermissionRuleQuery)) *ScaAuthRoleQuery { + query := (&ScaAuthPermissionRuleClient{config: sarq.config}).Query() + for _, opt := range opts { + opt(query) + } + sarq.withScaAuthPermissionRule = query + return sarq +} + +// 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 { +// RoleName string `json:"role_name,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.ScaAuthRole.Query(). +// GroupBy(scaauthrole.FieldRoleName). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (sarq *ScaAuthRoleQuery) GroupBy(field string, fields ...string) *ScaAuthRoleGroupBy { + sarq.ctx.Fields = append([]string{field}, fields...) + grbuild := &ScaAuthRoleGroupBy{build: sarq} + grbuild.flds = &sarq.ctx.Fields + grbuild.label = scaauthrole.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 { +// RoleName string `json:"role_name,omitempty"` +// } +// +// client.ScaAuthRole.Query(). +// Select(scaauthrole.FieldRoleName). +// Scan(ctx, &v) +func (sarq *ScaAuthRoleQuery) Select(fields ...string) *ScaAuthRoleSelect { + sarq.ctx.Fields = append(sarq.ctx.Fields, fields...) + sbuild := &ScaAuthRoleSelect{ScaAuthRoleQuery: sarq} + sbuild.label = scaauthrole.Label + sbuild.flds, sbuild.scan = &sarq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a ScaAuthRoleSelect configured with the given aggregations. +func (sarq *ScaAuthRoleQuery) Aggregate(fns ...AggregateFunc) *ScaAuthRoleSelect { + return sarq.Select().Aggregate(fns...) +} + +func (sarq *ScaAuthRoleQuery) prepareQuery(ctx context.Context) error { + for _, inter := range sarq.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, sarq); err != nil { + return err + } + } + } + for _, f := range sarq.ctx.Fields { + if !scaauthrole.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if sarq.path != nil { + prev, err := sarq.path(ctx) + if err != nil { + return err + } + sarq.sql = prev + } + return nil +} + +func (sarq *ScaAuthRoleQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ScaAuthRole, error) { + var ( + nodes = []*ScaAuthRole{} + _spec = sarq.querySpec() + loadedTypes = [1]bool{ + sarq.withScaAuthPermissionRule != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*ScaAuthRole).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &ScaAuthRole{config: sarq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, sarq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := sarq.withScaAuthPermissionRule; query != nil { + if err := sarq.loadScaAuthPermissionRule(ctx, query, nodes, + func(n *ScaAuthRole) { n.Edges.ScaAuthPermissionRule = []*ScaAuthPermissionRule{} }, + func(n *ScaAuthRole, e *ScaAuthPermissionRule) { + n.Edges.ScaAuthPermissionRule = append(n.Edges.ScaAuthPermissionRule, e) + }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (sarq *ScaAuthRoleQuery) loadScaAuthPermissionRule(ctx context.Context, query *ScaAuthPermissionRuleQuery, nodes []*ScaAuthRole, init func(*ScaAuthRole), assign func(*ScaAuthRole, *ScaAuthPermissionRule)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[int64]*ScaAuthRole) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + query.withFKs = true + query.Where(predicate.ScaAuthPermissionRule(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(scaauthrole.ScaAuthPermissionRuleColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.sca_auth_role_sca_auth_permission_rule + if fk == nil { + return fmt.Errorf(`foreign-key "sca_auth_role_sca_auth_permission_rule" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "sca_auth_role_sca_auth_permission_rule" returned %v for node %v`, *fk, n.ID) + } + assign(node, n) + } + return nil +} + +func (sarq *ScaAuthRoleQuery) sqlCount(ctx context.Context) (int, error) { + _spec := sarq.querySpec() + _spec.Node.Columns = sarq.ctx.Fields + if len(sarq.ctx.Fields) > 0 { + _spec.Unique = sarq.ctx.Unique != nil && *sarq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, sarq.driver, _spec) +} + +func (sarq *ScaAuthRoleQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(scaauthrole.Table, scaauthrole.Columns, sqlgraph.NewFieldSpec(scaauthrole.FieldID, field.TypeInt64)) + _spec.From = sarq.sql + if unique := sarq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if sarq.path != nil { + _spec.Unique = true + } + if fields := sarq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, scaauthrole.FieldID) + for i := range fields { + if fields[i] != scaauthrole.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := sarq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := sarq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := sarq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := sarq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (sarq *ScaAuthRoleQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(sarq.driver.Dialect()) + t1 := builder.Table(scaauthrole.Table) + columns := sarq.ctx.Fields + if len(columns) == 0 { + columns = scaauthrole.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if sarq.sql != nil { + selector = sarq.sql + selector.Select(selector.Columns(columns...)...) + } + if sarq.ctx.Unique != nil && *sarq.ctx.Unique { + selector.Distinct() + } + for _, p := range sarq.predicates { + p(selector) + } + for _, p := range sarq.order { + p(selector) + } + if offset := sarq.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 := sarq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// ScaAuthRoleGroupBy is the group-by builder for ScaAuthRole entities. +type ScaAuthRoleGroupBy struct { + selector + build *ScaAuthRoleQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (sargb *ScaAuthRoleGroupBy) Aggregate(fns ...AggregateFunc) *ScaAuthRoleGroupBy { + sargb.fns = append(sargb.fns, fns...) + return sargb +} + +// Scan applies the selector query and scans the result into the given value. +func (sargb *ScaAuthRoleGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, sargb.build.ctx, ent.OpQueryGroupBy) + if err := sargb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ScaAuthRoleQuery, *ScaAuthRoleGroupBy](ctx, sargb.build, sargb, sargb.build.inters, v) +} + +func (sargb *ScaAuthRoleGroupBy) sqlScan(ctx context.Context, root *ScaAuthRoleQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(sargb.fns)) + for _, fn := range sargb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*sargb.flds)+len(sargb.fns)) + for _, f := range *sargb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*sargb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := sargb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// ScaAuthRoleSelect is the builder for selecting fields of ScaAuthRole entities. +type ScaAuthRoleSelect struct { + *ScaAuthRoleQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (sars *ScaAuthRoleSelect) Aggregate(fns ...AggregateFunc) *ScaAuthRoleSelect { + sars.fns = append(sars.fns, fns...) + return sars +} + +// Scan applies the selector query and scans the result into the given value. +func (sars *ScaAuthRoleSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, sars.ctx, ent.OpQuerySelect) + if err := sars.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ScaAuthRoleQuery, *ScaAuthRoleSelect](ctx, sars.ScaAuthRoleQuery, sars, sars.inters, v) +} + +func (sars *ScaAuthRoleSelect) sqlScan(ctx context.Context, root *ScaAuthRoleQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(sars.fns)) + for _, fn := range sars.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*sars.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 := sars.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/common/ent/scaauthrole_update.go b/common/ent/scaauthrole_update.go new file mode 100644 index 0000000..ab06068 --- /dev/null +++ b/common/ent/scaauthrole_update.go @@ -0,0 +1,533 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "schisandra-album-cloud-microservices/common/ent/predicate" + "schisandra-album-cloud-microservices/common/ent/scaauthpermissionrule" + "schisandra-album-cloud-microservices/common/ent/scaauthrole" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ScaAuthRoleUpdate is the builder for updating ScaAuthRole entities. +type ScaAuthRoleUpdate struct { + config + hooks []Hook + mutation *ScaAuthRoleMutation +} + +// Where appends a list predicates to the ScaAuthRoleUpdate builder. +func (saru *ScaAuthRoleUpdate) Where(ps ...predicate.ScaAuthRole) *ScaAuthRoleUpdate { + saru.mutation.Where(ps...) + return saru +} + +// SetRoleName sets the "role_name" field. +func (saru *ScaAuthRoleUpdate) SetRoleName(s string) *ScaAuthRoleUpdate { + saru.mutation.SetRoleName(s) + return saru +} + +// SetNillableRoleName sets the "role_name" field if the given value is not nil. +func (saru *ScaAuthRoleUpdate) SetNillableRoleName(s *string) *ScaAuthRoleUpdate { + if s != nil { + saru.SetRoleName(*s) + } + return saru +} + +// SetRoleKey sets the "role_key" field. +func (saru *ScaAuthRoleUpdate) SetRoleKey(s string) *ScaAuthRoleUpdate { + saru.mutation.SetRoleKey(s) + return saru +} + +// SetNillableRoleKey sets the "role_key" field if the given value is not nil. +func (saru *ScaAuthRoleUpdate) SetNillableRoleKey(s *string) *ScaAuthRoleUpdate { + if s != nil { + saru.SetRoleKey(*s) + } + return saru +} + +// SetUpdateAt sets the "update_at" field. +func (saru *ScaAuthRoleUpdate) SetUpdateAt(t time.Time) *ScaAuthRoleUpdate { + saru.mutation.SetUpdateAt(t) + return saru +} + +// SetDeleted sets the "deleted" field. +func (saru *ScaAuthRoleUpdate) SetDeleted(i int) *ScaAuthRoleUpdate { + saru.mutation.ResetDeleted() + saru.mutation.SetDeleted(i) + return saru +} + +// SetNillableDeleted sets the "deleted" field if the given value is not nil. +func (saru *ScaAuthRoleUpdate) SetNillableDeleted(i *int) *ScaAuthRoleUpdate { + if i != nil { + saru.SetDeleted(*i) + } + return saru +} + +// AddDeleted adds i to the "deleted" field. +func (saru *ScaAuthRoleUpdate) AddDeleted(i int) *ScaAuthRoleUpdate { + saru.mutation.AddDeleted(i) + return saru +} + +// AddScaAuthPermissionRuleIDs adds the "sca_auth_permission_rule" edge to the ScaAuthPermissionRule entity by IDs. +func (saru *ScaAuthRoleUpdate) AddScaAuthPermissionRuleIDs(ids ...int64) *ScaAuthRoleUpdate { + saru.mutation.AddScaAuthPermissionRuleIDs(ids...) + return saru +} + +// AddScaAuthPermissionRule adds the "sca_auth_permission_rule" edges to the ScaAuthPermissionRule entity. +func (saru *ScaAuthRoleUpdate) AddScaAuthPermissionRule(s ...*ScaAuthPermissionRule) *ScaAuthRoleUpdate { + ids := make([]int64, len(s)) + for i := range s { + ids[i] = s[i].ID + } + return saru.AddScaAuthPermissionRuleIDs(ids...) +} + +// Mutation returns the ScaAuthRoleMutation object of the builder. +func (saru *ScaAuthRoleUpdate) Mutation() *ScaAuthRoleMutation { + return saru.mutation +} + +// ClearScaAuthPermissionRule clears all "sca_auth_permission_rule" edges to the ScaAuthPermissionRule entity. +func (saru *ScaAuthRoleUpdate) ClearScaAuthPermissionRule() *ScaAuthRoleUpdate { + saru.mutation.ClearScaAuthPermissionRule() + return saru +} + +// RemoveScaAuthPermissionRuleIDs removes the "sca_auth_permission_rule" edge to ScaAuthPermissionRule entities by IDs. +func (saru *ScaAuthRoleUpdate) RemoveScaAuthPermissionRuleIDs(ids ...int64) *ScaAuthRoleUpdate { + saru.mutation.RemoveScaAuthPermissionRuleIDs(ids...) + return saru +} + +// RemoveScaAuthPermissionRule removes "sca_auth_permission_rule" edges to ScaAuthPermissionRule entities. +func (saru *ScaAuthRoleUpdate) RemoveScaAuthPermissionRule(s ...*ScaAuthPermissionRule) *ScaAuthRoleUpdate { + ids := make([]int64, len(s)) + for i := range s { + ids[i] = s[i].ID + } + return saru.RemoveScaAuthPermissionRuleIDs(ids...) +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (saru *ScaAuthRoleUpdate) Save(ctx context.Context) (int, error) { + saru.defaults() + return withHooks(ctx, saru.sqlSave, saru.mutation, saru.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (saru *ScaAuthRoleUpdate) SaveX(ctx context.Context) int { + affected, err := saru.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (saru *ScaAuthRoleUpdate) Exec(ctx context.Context) error { + _, err := saru.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (saru *ScaAuthRoleUpdate) ExecX(ctx context.Context) { + if err := saru.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (saru *ScaAuthRoleUpdate) defaults() { + if _, ok := saru.mutation.UpdateAt(); !ok { + v := scaauthrole.UpdateDefaultUpdateAt() + saru.mutation.SetUpdateAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (saru *ScaAuthRoleUpdate) check() error { + if v, ok := saru.mutation.RoleName(); ok { + if err := scaauthrole.RoleNameValidator(v); err != nil { + return &ValidationError{Name: "role_name", err: fmt.Errorf(`ent: validator failed for field "ScaAuthRole.role_name": %w`, err)} + } + } + if v, ok := saru.mutation.RoleKey(); ok { + if err := scaauthrole.RoleKeyValidator(v); err != nil { + return &ValidationError{Name: "role_key", err: fmt.Errorf(`ent: validator failed for field "ScaAuthRole.role_key": %w`, err)} + } + } + return nil +} + +func (saru *ScaAuthRoleUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := saru.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(scaauthrole.Table, scaauthrole.Columns, sqlgraph.NewFieldSpec(scaauthrole.FieldID, field.TypeInt64)) + if ps := saru.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := saru.mutation.RoleName(); ok { + _spec.SetField(scaauthrole.FieldRoleName, field.TypeString, value) + } + if value, ok := saru.mutation.RoleKey(); ok { + _spec.SetField(scaauthrole.FieldRoleKey, field.TypeString, value) + } + if value, ok := saru.mutation.UpdateAt(); ok { + _spec.SetField(scaauthrole.FieldUpdateAt, field.TypeTime, value) + } + if value, ok := saru.mutation.Deleted(); ok { + _spec.SetField(scaauthrole.FieldDeleted, field.TypeInt, value) + } + if value, ok := saru.mutation.AddedDeleted(); ok { + _spec.AddField(scaauthrole.FieldDeleted, field.TypeInt, value) + } + if saru.mutation.ScaAuthPermissionRuleCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: scaauthrole.ScaAuthPermissionRuleTable, + Columns: []string{scaauthrole.ScaAuthPermissionRuleColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := saru.mutation.RemovedScaAuthPermissionRuleIDs(); len(nodes) > 0 && !saru.mutation.ScaAuthPermissionRuleCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: scaauthrole.ScaAuthPermissionRuleTable, + Columns: []string{scaauthrole.ScaAuthPermissionRuleColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := saru.mutation.ScaAuthPermissionRuleIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: scaauthrole.ScaAuthPermissionRuleTable, + Columns: []string{scaauthrole.ScaAuthPermissionRuleColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if n, err = sqlgraph.UpdateNodes(ctx, saru.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{scaauthrole.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + saru.mutation.done = true + return n, nil +} + +// ScaAuthRoleUpdateOne is the builder for updating a single ScaAuthRole entity. +type ScaAuthRoleUpdateOne struct { + config + fields []string + hooks []Hook + mutation *ScaAuthRoleMutation +} + +// SetRoleName sets the "role_name" field. +func (saruo *ScaAuthRoleUpdateOne) SetRoleName(s string) *ScaAuthRoleUpdateOne { + saruo.mutation.SetRoleName(s) + return saruo +} + +// SetNillableRoleName sets the "role_name" field if the given value is not nil. +func (saruo *ScaAuthRoleUpdateOne) SetNillableRoleName(s *string) *ScaAuthRoleUpdateOne { + if s != nil { + saruo.SetRoleName(*s) + } + return saruo +} + +// SetRoleKey sets the "role_key" field. +func (saruo *ScaAuthRoleUpdateOne) SetRoleKey(s string) *ScaAuthRoleUpdateOne { + saruo.mutation.SetRoleKey(s) + return saruo +} + +// SetNillableRoleKey sets the "role_key" field if the given value is not nil. +func (saruo *ScaAuthRoleUpdateOne) SetNillableRoleKey(s *string) *ScaAuthRoleUpdateOne { + if s != nil { + saruo.SetRoleKey(*s) + } + return saruo +} + +// SetUpdateAt sets the "update_at" field. +func (saruo *ScaAuthRoleUpdateOne) SetUpdateAt(t time.Time) *ScaAuthRoleUpdateOne { + saruo.mutation.SetUpdateAt(t) + return saruo +} + +// SetDeleted sets the "deleted" field. +func (saruo *ScaAuthRoleUpdateOne) SetDeleted(i int) *ScaAuthRoleUpdateOne { + saruo.mutation.ResetDeleted() + saruo.mutation.SetDeleted(i) + return saruo +} + +// SetNillableDeleted sets the "deleted" field if the given value is not nil. +func (saruo *ScaAuthRoleUpdateOne) SetNillableDeleted(i *int) *ScaAuthRoleUpdateOne { + if i != nil { + saruo.SetDeleted(*i) + } + return saruo +} + +// AddDeleted adds i to the "deleted" field. +func (saruo *ScaAuthRoleUpdateOne) AddDeleted(i int) *ScaAuthRoleUpdateOne { + saruo.mutation.AddDeleted(i) + return saruo +} + +// AddScaAuthPermissionRuleIDs adds the "sca_auth_permission_rule" edge to the ScaAuthPermissionRule entity by IDs. +func (saruo *ScaAuthRoleUpdateOne) AddScaAuthPermissionRuleIDs(ids ...int64) *ScaAuthRoleUpdateOne { + saruo.mutation.AddScaAuthPermissionRuleIDs(ids...) + return saruo +} + +// AddScaAuthPermissionRule adds the "sca_auth_permission_rule" edges to the ScaAuthPermissionRule entity. +func (saruo *ScaAuthRoleUpdateOne) AddScaAuthPermissionRule(s ...*ScaAuthPermissionRule) *ScaAuthRoleUpdateOne { + ids := make([]int64, len(s)) + for i := range s { + ids[i] = s[i].ID + } + return saruo.AddScaAuthPermissionRuleIDs(ids...) +} + +// Mutation returns the ScaAuthRoleMutation object of the builder. +func (saruo *ScaAuthRoleUpdateOne) Mutation() *ScaAuthRoleMutation { + return saruo.mutation +} + +// ClearScaAuthPermissionRule clears all "sca_auth_permission_rule" edges to the ScaAuthPermissionRule entity. +func (saruo *ScaAuthRoleUpdateOne) ClearScaAuthPermissionRule() *ScaAuthRoleUpdateOne { + saruo.mutation.ClearScaAuthPermissionRule() + return saruo +} + +// RemoveScaAuthPermissionRuleIDs removes the "sca_auth_permission_rule" edge to ScaAuthPermissionRule entities by IDs. +func (saruo *ScaAuthRoleUpdateOne) RemoveScaAuthPermissionRuleIDs(ids ...int64) *ScaAuthRoleUpdateOne { + saruo.mutation.RemoveScaAuthPermissionRuleIDs(ids...) + return saruo +} + +// RemoveScaAuthPermissionRule removes "sca_auth_permission_rule" edges to ScaAuthPermissionRule entities. +func (saruo *ScaAuthRoleUpdateOne) RemoveScaAuthPermissionRule(s ...*ScaAuthPermissionRule) *ScaAuthRoleUpdateOne { + ids := make([]int64, len(s)) + for i := range s { + ids[i] = s[i].ID + } + return saruo.RemoveScaAuthPermissionRuleIDs(ids...) +} + +// Where appends a list predicates to the ScaAuthRoleUpdate builder. +func (saruo *ScaAuthRoleUpdateOne) Where(ps ...predicate.ScaAuthRole) *ScaAuthRoleUpdateOne { + saruo.mutation.Where(ps...) + return saruo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (saruo *ScaAuthRoleUpdateOne) Select(field string, fields ...string) *ScaAuthRoleUpdateOne { + saruo.fields = append([]string{field}, fields...) + return saruo +} + +// Save executes the query and returns the updated ScaAuthRole entity. +func (saruo *ScaAuthRoleUpdateOne) Save(ctx context.Context) (*ScaAuthRole, error) { + saruo.defaults() + return withHooks(ctx, saruo.sqlSave, saruo.mutation, saruo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (saruo *ScaAuthRoleUpdateOne) SaveX(ctx context.Context) *ScaAuthRole { + node, err := saruo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (saruo *ScaAuthRoleUpdateOne) Exec(ctx context.Context) error { + _, err := saruo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (saruo *ScaAuthRoleUpdateOne) ExecX(ctx context.Context) { + if err := saruo.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (saruo *ScaAuthRoleUpdateOne) defaults() { + if _, ok := saruo.mutation.UpdateAt(); !ok { + v := scaauthrole.UpdateDefaultUpdateAt() + saruo.mutation.SetUpdateAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (saruo *ScaAuthRoleUpdateOne) check() error { + if v, ok := saruo.mutation.RoleName(); ok { + if err := scaauthrole.RoleNameValidator(v); err != nil { + return &ValidationError{Name: "role_name", err: fmt.Errorf(`ent: validator failed for field "ScaAuthRole.role_name": %w`, err)} + } + } + if v, ok := saruo.mutation.RoleKey(); ok { + if err := scaauthrole.RoleKeyValidator(v); err != nil { + return &ValidationError{Name: "role_key", err: fmt.Errorf(`ent: validator failed for field "ScaAuthRole.role_key": %w`, err)} + } + } + return nil +} + +func (saruo *ScaAuthRoleUpdateOne) sqlSave(ctx context.Context) (_node *ScaAuthRole, err error) { + if err := saruo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(scaauthrole.Table, scaauthrole.Columns, sqlgraph.NewFieldSpec(scaauthrole.FieldID, field.TypeInt64)) + id, ok := saruo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ScaAuthRole.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := saruo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, scaauthrole.FieldID) + for _, f := range fields { + if !scaauthrole.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != scaauthrole.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := saruo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := saruo.mutation.RoleName(); ok { + _spec.SetField(scaauthrole.FieldRoleName, field.TypeString, value) + } + if value, ok := saruo.mutation.RoleKey(); ok { + _spec.SetField(scaauthrole.FieldRoleKey, field.TypeString, value) + } + if value, ok := saruo.mutation.UpdateAt(); ok { + _spec.SetField(scaauthrole.FieldUpdateAt, field.TypeTime, value) + } + if value, ok := saruo.mutation.Deleted(); ok { + _spec.SetField(scaauthrole.FieldDeleted, field.TypeInt, value) + } + if value, ok := saruo.mutation.AddedDeleted(); ok { + _spec.AddField(scaauthrole.FieldDeleted, field.TypeInt, value) + } + if saruo.mutation.ScaAuthPermissionRuleCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: scaauthrole.ScaAuthPermissionRuleTable, + Columns: []string{scaauthrole.ScaAuthPermissionRuleColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := saruo.mutation.RemovedScaAuthPermissionRuleIDs(); len(nodes) > 0 && !saruo.mutation.ScaAuthPermissionRuleCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: scaauthrole.ScaAuthPermissionRuleTable, + Columns: []string{scaauthrole.ScaAuthPermissionRuleColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := saruo.mutation.ScaAuthPermissionRuleIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: scaauthrole.ScaAuthPermissionRuleTable, + Columns: []string{scaauthrole.ScaAuthPermissionRuleColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _node = &ScaAuthRole{config: saruo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, saruo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{scaauthrole.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + saruo.mutation.done = true + return _node, nil +} diff --git a/common/ent/scaauthuser.go b/common/ent/scaauthuser.go new file mode 100644 index 0000000..90b5a8c --- /dev/null +++ b/common/ent/scaauthuser.go @@ -0,0 +1,325 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "schisandra-album-cloud-microservices/common/ent/scaauthuser" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// ScaAuthUser is the model entity for the ScaAuthUser schema. +type ScaAuthUser struct { + config `json:"-"` + // ID of the ent. + // 自增ID + ID int64 `json:"id,omitempty"` + // 唯一ID + UID string `json:"uid,omitempty"` + // 用户名 + Username string `json:"username,omitempty"` + // 昵称 + Nickname string `json:"nickname,omitempty"` + // 邮箱 + Email string `json:"email,omitempty"` + // 电话 + Phone string `json:"phone,omitempty"` + // 密码 + Password string `json:"-"` + // 性别 + Gender string `json:"gender,omitempty"` + // 头像 + Avatar string `json:"avatar,omitempty"` + // 状态 0 正常 1 封禁 + Status int8 `json:"status,omitempty"` + // 介绍 + Introduce string `json:"introduce,omitempty"` + // 创建时间 + CreatedAt time.Time `json:"created_at,omitempty"` + // 更新时间 + UpdateAt *time.Time `json:"update_at,omitempty"` + // 是否删除 0 未删除 1 已删除 + Deleted int8 `json:"deleted,omitempty"` + // 博客 + Blog *string `json:"blog,omitempty"` + // 地址 + Location *string `json:"location,omitempty"` + // 公司 + Company *string `json:"company,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the ScaAuthUserQuery when eager-loading is set. + Edges ScaAuthUserEdges `json:"edges"` + selectValues sql.SelectValues +} + +// ScaAuthUserEdges holds the relations/edges for other nodes in the graph. +type ScaAuthUserEdges struct { + // ScaAuthUserSocial holds the value of the sca_auth_user_social edge. + ScaAuthUserSocial []*ScaAuthUserSocial `json:"sca_auth_user_social,omitempty"` + // ScaAuthUserDevice holds the value of the sca_auth_user_device edge. + ScaAuthUserDevice []*ScaAuthUserDevice `json:"sca_auth_user_device,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [2]bool +} + +// ScaAuthUserSocialOrErr returns the ScaAuthUserSocial value or an error if the edge +// was not loaded in eager-loading. +func (e ScaAuthUserEdges) ScaAuthUserSocialOrErr() ([]*ScaAuthUserSocial, error) { + if e.loadedTypes[0] { + return e.ScaAuthUserSocial, nil + } + return nil, &NotLoadedError{edge: "sca_auth_user_social"} +} + +// ScaAuthUserDeviceOrErr returns the ScaAuthUserDevice value or an error if the edge +// was not loaded in eager-loading. +func (e ScaAuthUserEdges) ScaAuthUserDeviceOrErr() ([]*ScaAuthUserDevice, error) { + if e.loadedTypes[1] { + return e.ScaAuthUserDevice, nil + } + return nil, &NotLoadedError{edge: "sca_auth_user_device"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*ScaAuthUser) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case scaauthuser.FieldID, scaauthuser.FieldStatus, scaauthuser.FieldDeleted: + values[i] = new(sql.NullInt64) + case scaauthuser.FieldUID, scaauthuser.FieldUsername, scaauthuser.FieldNickname, scaauthuser.FieldEmail, scaauthuser.FieldPhone, scaauthuser.FieldPassword, scaauthuser.FieldGender, scaauthuser.FieldAvatar, scaauthuser.FieldIntroduce, scaauthuser.FieldBlog, scaauthuser.FieldLocation, scaauthuser.FieldCompany: + values[i] = new(sql.NullString) + case scaauthuser.FieldCreatedAt, scaauthuser.FieldUpdateAt: + 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 ScaAuthUser fields. +func (sau *ScaAuthUser) 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 scaauthuser.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + sau.ID = int64(value.Int64) + case scaauthuser.FieldUID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field uid", values[i]) + } else if value.Valid { + sau.UID = value.String + } + case scaauthuser.FieldUsername: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field username", values[i]) + } else if value.Valid { + sau.Username = value.String + } + case scaauthuser.FieldNickname: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field nickname", values[i]) + } else if value.Valid { + sau.Nickname = value.String + } + case scaauthuser.FieldEmail: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field email", values[i]) + } else if value.Valid { + sau.Email = value.String + } + case scaauthuser.FieldPhone: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field phone", values[i]) + } else if value.Valid { + sau.Phone = value.String + } + case scaauthuser.FieldPassword: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field password", values[i]) + } else if value.Valid { + sau.Password = value.String + } + case scaauthuser.FieldGender: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field gender", values[i]) + } else if value.Valid { + sau.Gender = value.String + } + case scaauthuser.FieldAvatar: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field avatar", values[i]) + } else if value.Valid { + sau.Avatar = value.String + } + case scaauthuser.FieldStatus: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field status", values[i]) + } else if value.Valid { + sau.Status = int8(value.Int64) + } + case scaauthuser.FieldIntroduce: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field introduce", values[i]) + } else if value.Valid { + sau.Introduce = value.String + } + case scaauthuser.FieldCreatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field created_at", values[i]) + } else if value.Valid { + sau.CreatedAt = value.Time + } + case scaauthuser.FieldUpdateAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field update_at", values[i]) + } else if value.Valid { + sau.UpdateAt = new(time.Time) + *sau.UpdateAt = value.Time + } + case scaauthuser.FieldDeleted: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field deleted", values[i]) + } else if value.Valid { + sau.Deleted = int8(value.Int64) + } + case scaauthuser.FieldBlog: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field blog", values[i]) + } else if value.Valid { + sau.Blog = new(string) + *sau.Blog = value.String + } + case scaauthuser.FieldLocation: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field location", values[i]) + } else if value.Valid { + sau.Location = new(string) + *sau.Location = value.String + } + case scaauthuser.FieldCompany: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field company", values[i]) + } else if value.Valid { + sau.Company = new(string) + *sau.Company = value.String + } + default: + sau.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the ScaAuthUser. +// This includes values selected through modifiers, order, etc. +func (sau *ScaAuthUser) Value(name string) (ent.Value, error) { + return sau.selectValues.Get(name) +} + +// QueryScaAuthUserSocial queries the "sca_auth_user_social" edge of the ScaAuthUser entity. +func (sau *ScaAuthUser) QueryScaAuthUserSocial() *ScaAuthUserSocialQuery { + return NewScaAuthUserClient(sau.config).QueryScaAuthUserSocial(sau) +} + +// QueryScaAuthUserDevice queries the "sca_auth_user_device" edge of the ScaAuthUser entity. +func (sau *ScaAuthUser) QueryScaAuthUserDevice() *ScaAuthUserDeviceQuery { + return NewScaAuthUserClient(sau.config).QueryScaAuthUserDevice(sau) +} + +// Update returns a builder for updating this ScaAuthUser. +// Note that you need to call ScaAuthUser.Unwrap() before calling this method if this ScaAuthUser +// was returned from a transaction, and the transaction was committed or rolled back. +func (sau *ScaAuthUser) Update() *ScaAuthUserUpdateOne { + return NewScaAuthUserClient(sau.config).UpdateOne(sau) +} + +// Unwrap unwraps the ScaAuthUser 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 (sau *ScaAuthUser) Unwrap() *ScaAuthUser { + _tx, ok := sau.config.driver.(*txDriver) + if !ok { + panic("ent: ScaAuthUser is not a transactional entity") + } + sau.config.driver = _tx.drv + return sau +} + +// String implements the fmt.Stringer. +func (sau *ScaAuthUser) String() string { + var builder strings.Builder + builder.WriteString("ScaAuthUser(") + builder.WriteString(fmt.Sprintf("id=%v, ", sau.ID)) + builder.WriteString("uid=") + builder.WriteString(sau.UID) + builder.WriteString(", ") + builder.WriteString("username=") + builder.WriteString(sau.Username) + builder.WriteString(", ") + builder.WriteString("nickname=") + builder.WriteString(sau.Nickname) + builder.WriteString(", ") + builder.WriteString("email=") + builder.WriteString(sau.Email) + builder.WriteString(", ") + builder.WriteString("phone=") + builder.WriteString(sau.Phone) + builder.WriteString(", ") + builder.WriteString("password=") + builder.WriteString(", ") + builder.WriteString("gender=") + builder.WriteString(sau.Gender) + builder.WriteString(", ") + builder.WriteString("avatar=") + builder.WriteString(sau.Avatar) + builder.WriteString(", ") + builder.WriteString("status=") + builder.WriteString(fmt.Sprintf("%v", sau.Status)) + builder.WriteString(", ") + builder.WriteString("introduce=") + builder.WriteString(sau.Introduce) + builder.WriteString(", ") + builder.WriteString("created_at=") + builder.WriteString(sau.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + if v := sau.UpdateAt; v != nil { + builder.WriteString("update_at=") + builder.WriteString(v.Format(time.ANSIC)) + } + builder.WriteString(", ") + builder.WriteString("deleted=") + builder.WriteString(fmt.Sprintf("%v", sau.Deleted)) + builder.WriteString(", ") + if v := sau.Blog; v != nil { + builder.WriteString("blog=") + builder.WriteString(*v) + } + builder.WriteString(", ") + if v := sau.Location; v != nil { + builder.WriteString("location=") + builder.WriteString(*v) + } + builder.WriteString(", ") + if v := sau.Company; v != nil { + builder.WriteString("company=") + builder.WriteString(*v) + } + builder.WriteByte(')') + return builder.String() +} + +// ScaAuthUsers is a parsable slice of ScaAuthUser. +type ScaAuthUsers []*ScaAuthUser diff --git a/common/ent/scaauthuser/scaauthuser.go b/common/ent/scaauthuser/scaauthuser.go new file mode 100644 index 0000000..d21746e --- /dev/null +++ b/common/ent/scaauthuser/scaauthuser.go @@ -0,0 +1,265 @@ +// Code generated by ent, DO NOT EDIT. + +package scaauthuser + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the scaauthuser type in the database. + Label = "sca_auth_user" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldUID holds the string denoting the uid field in the database. + FieldUID = "uid" + // FieldUsername holds the string denoting the username field in the database. + FieldUsername = "username" + // FieldNickname holds the string denoting the nickname field in the database. + FieldNickname = "nickname" + // FieldEmail holds the string denoting the email field in the database. + FieldEmail = "email" + // FieldPhone holds the string denoting the phone field in the database. + FieldPhone = "phone" + // FieldPassword holds the string denoting the password field in the database. + FieldPassword = "password" + // FieldGender holds the string denoting the gender field in the database. + FieldGender = "gender" + // FieldAvatar holds the string denoting the avatar field in the database. + FieldAvatar = "avatar" + // FieldStatus holds the string denoting the status field in the database. + FieldStatus = "status" + // FieldIntroduce holds the string denoting the introduce field in the database. + FieldIntroduce = "introduce" + // FieldCreatedAt holds the string denoting the created_at field in the database. + FieldCreatedAt = "created_at" + // FieldUpdateAt holds the string denoting the update_at field in the database. + FieldUpdateAt = "update_at" + // FieldDeleted holds the string denoting the deleted field in the database. + FieldDeleted = "deleted" + // FieldBlog holds the string denoting the blog field in the database. + FieldBlog = "blog" + // FieldLocation holds the string denoting the location field in the database. + FieldLocation = "location" + // FieldCompany holds the string denoting the company field in the database. + FieldCompany = "company" + // EdgeScaAuthUserSocial holds the string denoting the sca_auth_user_social edge name in mutations. + EdgeScaAuthUserSocial = "sca_auth_user_social" + // EdgeScaAuthUserDevice holds the string denoting the sca_auth_user_device edge name in mutations. + EdgeScaAuthUserDevice = "sca_auth_user_device" + // Table holds the table name of the scaauthuser in the database. + Table = "sca_auth_users" + // ScaAuthUserSocialTable is the table that holds the sca_auth_user_social relation/edge. + ScaAuthUserSocialTable = "sca_auth_user_socials" + // ScaAuthUserSocialInverseTable is the table name for the ScaAuthUserSocial entity. + // It exists in this package in order to avoid circular dependency with the "scaauthusersocial" package. + ScaAuthUserSocialInverseTable = "sca_auth_user_socials" + // ScaAuthUserSocialColumn is the table column denoting the sca_auth_user_social relation/edge. + ScaAuthUserSocialColumn = "sca_auth_user_sca_auth_user_social" + // ScaAuthUserDeviceTable is the table that holds the sca_auth_user_device relation/edge. + ScaAuthUserDeviceTable = "sca_auth_user_devices" + // ScaAuthUserDeviceInverseTable is the table name for the ScaAuthUserDevice entity. + // It exists in this package in order to avoid circular dependency with the "scaauthuserdevice" package. + ScaAuthUserDeviceInverseTable = "sca_auth_user_devices" + // ScaAuthUserDeviceColumn is the table column denoting the sca_auth_user_device relation/edge. + ScaAuthUserDeviceColumn = "sca_auth_user_sca_auth_user_device" +) + +// Columns holds all SQL columns for scaauthuser fields. +var Columns = []string{ + FieldID, + FieldUID, + FieldUsername, + FieldNickname, + FieldEmail, + FieldPhone, + FieldPassword, + FieldGender, + FieldAvatar, + FieldStatus, + FieldIntroduce, + FieldCreatedAt, + FieldUpdateAt, + FieldDeleted, + FieldBlog, + FieldLocation, + FieldCompany, +} + +// 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 ( + // UIDValidator is a validator for the "uid" field. It is called by the builders before save. + UIDValidator func(string) error + // UsernameValidator is a validator for the "username" field. It is called by the builders before save. + UsernameValidator func(string) error + // NicknameValidator is a validator for the "nickname" field. It is called by the builders before save. + NicknameValidator func(string) error + // EmailValidator is a validator for the "email" field. It is called by the builders before save. + EmailValidator func(string) error + // PhoneValidator is a validator for the "phone" field. It is called by the builders before save. + PhoneValidator func(string) error + // PasswordValidator is a validator for the "password" field. It is called by the builders before save. + PasswordValidator func(string) error + // GenderValidator is a validator for the "gender" field. It is called by the builders before save. + GenderValidator func(string) error + // DefaultStatus holds the default value on creation for the "status" field. + DefaultStatus int8 + // IntroduceValidator is a validator for the "introduce" field. It is called by the builders before save. + IntroduceValidator func(string) error + // DefaultCreatedAt holds the default value on creation for the "created_at" field. + DefaultCreatedAt func() time.Time + // DefaultUpdateAt holds the default value on creation for the "update_at" field. + DefaultUpdateAt func() time.Time + // UpdateDefaultUpdateAt holds the default value on update for the "update_at" field. + UpdateDefaultUpdateAt func() time.Time + // DefaultDeleted holds the default value on creation for the "deleted" field. + DefaultDeleted int8 + // BlogValidator is a validator for the "blog" field. It is called by the builders before save. + BlogValidator func(string) error + // LocationValidator is a validator for the "location" field. It is called by the builders before save. + LocationValidator func(string) error + // CompanyValidator is a validator for the "company" field. It is called by the builders before save. + CompanyValidator func(string) error +) + +// OrderOption defines the ordering options for the ScaAuthUser 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() +} + +// ByUID orders the results by the uid field. +func ByUID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUID, opts...).ToFunc() +} + +// ByUsername orders the results by the username field. +func ByUsername(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUsername, opts...).ToFunc() +} + +// ByNickname orders the results by the nickname field. +func ByNickname(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldNickname, opts...).ToFunc() +} + +// ByEmail orders the results by the email field. +func ByEmail(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldEmail, opts...).ToFunc() +} + +// ByPhone orders the results by the phone field. +func ByPhone(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPhone, opts...).ToFunc() +} + +// ByPassword orders the results by the password field. +func ByPassword(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPassword, opts...).ToFunc() +} + +// ByGender orders the results by the gender field. +func ByGender(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldGender, opts...).ToFunc() +} + +// ByAvatar orders the results by the avatar field. +func ByAvatar(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldAvatar, opts...).ToFunc() +} + +// ByStatus orders the results by the status field. +func ByStatus(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStatus, opts...).ToFunc() +} + +// ByIntroduce orders the results by the introduce field. +func ByIntroduce(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldIntroduce, opts...).ToFunc() +} + +// ByCreatedAt orders the results by the created_at field. +func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() +} + +// ByUpdateAt orders the results by the update_at field. +func ByUpdateAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateAt, opts...).ToFunc() +} + +// ByDeleted orders the results by the deleted field. +func ByDeleted(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeleted, opts...).ToFunc() +} + +// ByBlog orders the results by the blog field. +func ByBlog(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldBlog, opts...).ToFunc() +} + +// ByLocation orders the results by the location field. +func ByLocation(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLocation, opts...).ToFunc() +} + +// ByCompany orders the results by the company field. +func ByCompany(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCompany, opts...).ToFunc() +} + +// ByScaAuthUserSocialCount orders the results by sca_auth_user_social count. +func ByScaAuthUserSocialCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newScaAuthUserSocialStep(), opts...) + } +} + +// ByScaAuthUserSocial orders the results by sca_auth_user_social terms. +func ByScaAuthUserSocial(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newScaAuthUserSocialStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByScaAuthUserDeviceCount orders the results by sca_auth_user_device count. +func ByScaAuthUserDeviceCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newScaAuthUserDeviceStep(), opts...) + } +} + +// ByScaAuthUserDevice orders the results by sca_auth_user_device terms. +func ByScaAuthUserDevice(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newScaAuthUserDeviceStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} +func newScaAuthUserSocialStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ScaAuthUserSocialInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, ScaAuthUserSocialTable, ScaAuthUserSocialColumn), + ) +} +func newScaAuthUserDeviceStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ScaAuthUserDeviceInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, ScaAuthUserDeviceTable, ScaAuthUserDeviceColumn), + ) +} diff --git a/common/ent/scaauthuser/where.go b/common/ent/scaauthuser/where.go new file mode 100644 index 0000000..1ac7280 --- /dev/null +++ b/common/ent/scaauthuser/where.go @@ -0,0 +1,1267 @@ +// Code generated by ent, DO NOT EDIT. + +package scaauthuser + +import ( + "schisandra-album-cloud-microservices/common/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id int64) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int64) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int64) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int64) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int64) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int64) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int64) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int64) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int64) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldLTE(FieldID, id)) +} + +// UID applies equality check predicate on the "uid" field. It's identical to UIDEQ. +func UID(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEQ(FieldUID, v)) +} + +// Username applies equality check predicate on the "username" field. It's identical to UsernameEQ. +func Username(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEQ(FieldUsername, v)) +} + +// Nickname applies equality check predicate on the "nickname" field. It's identical to NicknameEQ. +func Nickname(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEQ(FieldNickname, v)) +} + +// Email applies equality check predicate on the "email" field. It's identical to EmailEQ. +func Email(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEQ(FieldEmail, v)) +} + +// Phone applies equality check predicate on the "phone" field. It's identical to PhoneEQ. +func Phone(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEQ(FieldPhone, v)) +} + +// Password applies equality check predicate on the "password" field. It's identical to PasswordEQ. +func Password(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEQ(FieldPassword, v)) +} + +// Gender applies equality check predicate on the "gender" field. It's identical to GenderEQ. +func Gender(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEQ(FieldGender, v)) +} + +// Avatar applies equality check predicate on the "avatar" field. It's identical to AvatarEQ. +func Avatar(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEQ(FieldAvatar, v)) +} + +// Status applies equality check predicate on the "status" field. It's identical to StatusEQ. +func Status(v int8) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEQ(FieldStatus, v)) +} + +// Introduce applies equality check predicate on the "introduce" field. It's identical to IntroduceEQ. +func Introduce(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEQ(FieldIntroduce, v)) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEQ(FieldCreatedAt, v)) +} + +// UpdateAt applies equality check predicate on the "update_at" field. It's identical to UpdateAtEQ. +func UpdateAt(v time.Time) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEQ(FieldUpdateAt, v)) +} + +// Deleted applies equality check predicate on the "deleted" field. It's identical to DeletedEQ. +func Deleted(v int8) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEQ(FieldDeleted, v)) +} + +// Blog applies equality check predicate on the "blog" field. It's identical to BlogEQ. +func Blog(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEQ(FieldBlog, v)) +} + +// Location applies equality check predicate on the "location" field. It's identical to LocationEQ. +func Location(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEQ(FieldLocation, v)) +} + +// Company applies equality check predicate on the "company" field. It's identical to CompanyEQ. +func Company(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEQ(FieldCompany, v)) +} + +// UIDEQ applies the EQ predicate on the "uid" field. +func UIDEQ(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEQ(FieldUID, v)) +} + +// UIDNEQ applies the NEQ predicate on the "uid" field. +func UIDNEQ(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNEQ(FieldUID, v)) +} + +// UIDIn applies the In predicate on the "uid" field. +func UIDIn(vs ...string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldIn(FieldUID, vs...)) +} + +// UIDNotIn applies the NotIn predicate on the "uid" field. +func UIDNotIn(vs ...string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNotIn(FieldUID, vs...)) +} + +// UIDGT applies the GT predicate on the "uid" field. +func UIDGT(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldGT(FieldUID, v)) +} + +// UIDGTE applies the GTE predicate on the "uid" field. +func UIDGTE(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldGTE(FieldUID, v)) +} + +// UIDLT applies the LT predicate on the "uid" field. +func UIDLT(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldLT(FieldUID, v)) +} + +// UIDLTE applies the LTE predicate on the "uid" field. +func UIDLTE(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldLTE(FieldUID, v)) +} + +// UIDContains applies the Contains predicate on the "uid" field. +func UIDContains(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldContains(FieldUID, v)) +} + +// UIDHasPrefix applies the HasPrefix predicate on the "uid" field. +func UIDHasPrefix(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldHasPrefix(FieldUID, v)) +} + +// UIDHasSuffix applies the HasSuffix predicate on the "uid" field. +func UIDHasSuffix(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldHasSuffix(FieldUID, v)) +} + +// UIDEqualFold applies the EqualFold predicate on the "uid" field. +func UIDEqualFold(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEqualFold(FieldUID, v)) +} + +// UIDContainsFold applies the ContainsFold predicate on the "uid" field. +func UIDContainsFold(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldContainsFold(FieldUID, v)) +} + +// UsernameEQ applies the EQ predicate on the "username" field. +func UsernameEQ(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEQ(FieldUsername, v)) +} + +// UsernameNEQ applies the NEQ predicate on the "username" field. +func UsernameNEQ(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNEQ(FieldUsername, v)) +} + +// UsernameIn applies the In predicate on the "username" field. +func UsernameIn(vs ...string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldIn(FieldUsername, vs...)) +} + +// UsernameNotIn applies the NotIn predicate on the "username" field. +func UsernameNotIn(vs ...string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNotIn(FieldUsername, vs...)) +} + +// UsernameGT applies the GT predicate on the "username" field. +func UsernameGT(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldGT(FieldUsername, v)) +} + +// UsernameGTE applies the GTE predicate on the "username" field. +func UsernameGTE(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldGTE(FieldUsername, v)) +} + +// UsernameLT applies the LT predicate on the "username" field. +func UsernameLT(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldLT(FieldUsername, v)) +} + +// UsernameLTE applies the LTE predicate on the "username" field. +func UsernameLTE(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldLTE(FieldUsername, v)) +} + +// UsernameContains applies the Contains predicate on the "username" field. +func UsernameContains(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldContains(FieldUsername, v)) +} + +// UsernameHasPrefix applies the HasPrefix predicate on the "username" field. +func UsernameHasPrefix(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldHasPrefix(FieldUsername, v)) +} + +// UsernameHasSuffix applies the HasSuffix predicate on the "username" field. +func UsernameHasSuffix(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldHasSuffix(FieldUsername, v)) +} + +// UsernameIsNil applies the IsNil predicate on the "username" field. +func UsernameIsNil() predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldIsNull(FieldUsername)) +} + +// UsernameNotNil applies the NotNil predicate on the "username" field. +func UsernameNotNil() predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNotNull(FieldUsername)) +} + +// UsernameEqualFold applies the EqualFold predicate on the "username" field. +func UsernameEqualFold(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEqualFold(FieldUsername, v)) +} + +// UsernameContainsFold applies the ContainsFold predicate on the "username" field. +func UsernameContainsFold(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldContainsFold(FieldUsername, v)) +} + +// NicknameEQ applies the EQ predicate on the "nickname" field. +func NicknameEQ(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEQ(FieldNickname, v)) +} + +// NicknameNEQ applies the NEQ predicate on the "nickname" field. +func NicknameNEQ(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNEQ(FieldNickname, v)) +} + +// NicknameIn applies the In predicate on the "nickname" field. +func NicknameIn(vs ...string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldIn(FieldNickname, vs...)) +} + +// NicknameNotIn applies the NotIn predicate on the "nickname" field. +func NicknameNotIn(vs ...string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNotIn(FieldNickname, vs...)) +} + +// NicknameGT applies the GT predicate on the "nickname" field. +func NicknameGT(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldGT(FieldNickname, v)) +} + +// NicknameGTE applies the GTE predicate on the "nickname" field. +func NicknameGTE(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldGTE(FieldNickname, v)) +} + +// NicknameLT applies the LT predicate on the "nickname" field. +func NicknameLT(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldLT(FieldNickname, v)) +} + +// NicknameLTE applies the LTE predicate on the "nickname" field. +func NicknameLTE(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldLTE(FieldNickname, v)) +} + +// NicknameContains applies the Contains predicate on the "nickname" field. +func NicknameContains(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldContains(FieldNickname, v)) +} + +// NicknameHasPrefix applies the HasPrefix predicate on the "nickname" field. +func NicknameHasPrefix(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldHasPrefix(FieldNickname, v)) +} + +// NicknameHasSuffix applies the HasSuffix predicate on the "nickname" field. +func NicknameHasSuffix(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldHasSuffix(FieldNickname, v)) +} + +// NicknameIsNil applies the IsNil predicate on the "nickname" field. +func NicknameIsNil() predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldIsNull(FieldNickname)) +} + +// NicknameNotNil applies the NotNil predicate on the "nickname" field. +func NicknameNotNil() predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNotNull(FieldNickname)) +} + +// NicknameEqualFold applies the EqualFold predicate on the "nickname" field. +func NicknameEqualFold(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEqualFold(FieldNickname, v)) +} + +// NicknameContainsFold applies the ContainsFold predicate on the "nickname" field. +func NicknameContainsFold(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldContainsFold(FieldNickname, v)) +} + +// EmailEQ applies the EQ predicate on the "email" field. +func EmailEQ(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEQ(FieldEmail, v)) +} + +// EmailNEQ applies the NEQ predicate on the "email" field. +func EmailNEQ(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNEQ(FieldEmail, v)) +} + +// EmailIn applies the In predicate on the "email" field. +func EmailIn(vs ...string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldIn(FieldEmail, vs...)) +} + +// EmailNotIn applies the NotIn predicate on the "email" field. +func EmailNotIn(vs ...string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNotIn(FieldEmail, vs...)) +} + +// EmailGT applies the GT predicate on the "email" field. +func EmailGT(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldGT(FieldEmail, v)) +} + +// EmailGTE applies the GTE predicate on the "email" field. +func EmailGTE(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldGTE(FieldEmail, v)) +} + +// EmailLT applies the LT predicate on the "email" field. +func EmailLT(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldLT(FieldEmail, v)) +} + +// EmailLTE applies the LTE predicate on the "email" field. +func EmailLTE(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldLTE(FieldEmail, v)) +} + +// EmailContains applies the Contains predicate on the "email" field. +func EmailContains(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldContains(FieldEmail, v)) +} + +// EmailHasPrefix applies the HasPrefix predicate on the "email" field. +func EmailHasPrefix(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldHasPrefix(FieldEmail, v)) +} + +// EmailHasSuffix applies the HasSuffix predicate on the "email" field. +func EmailHasSuffix(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldHasSuffix(FieldEmail, v)) +} + +// EmailIsNil applies the IsNil predicate on the "email" field. +func EmailIsNil() predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldIsNull(FieldEmail)) +} + +// EmailNotNil applies the NotNil predicate on the "email" field. +func EmailNotNil() predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNotNull(FieldEmail)) +} + +// EmailEqualFold applies the EqualFold predicate on the "email" field. +func EmailEqualFold(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEqualFold(FieldEmail, v)) +} + +// EmailContainsFold applies the ContainsFold predicate on the "email" field. +func EmailContainsFold(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldContainsFold(FieldEmail, v)) +} + +// PhoneEQ applies the EQ predicate on the "phone" field. +func PhoneEQ(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEQ(FieldPhone, v)) +} + +// PhoneNEQ applies the NEQ predicate on the "phone" field. +func PhoneNEQ(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNEQ(FieldPhone, v)) +} + +// PhoneIn applies the In predicate on the "phone" field. +func PhoneIn(vs ...string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldIn(FieldPhone, vs...)) +} + +// PhoneNotIn applies the NotIn predicate on the "phone" field. +func PhoneNotIn(vs ...string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNotIn(FieldPhone, vs...)) +} + +// PhoneGT applies the GT predicate on the "phone" field. +func PhoneGT(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldGT(FieldPhone, v)) +} + +// PhoneGTE applies the GTE predicate on the "phone" field. +func PhoneGTE(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldGTE(FieldPhone, v)) +} + +// PhoneLT applies the LT predicate on the "phone" field. +func PhoneLT(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldLT(FieldPhone, v)) +} + +// PhoneLTE applies the LTE predicate on the "phone" field. +func PhoneLTE(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldLTE(FieldPhone, v)) +} + +// PhoneContains applies the Contains predicate on the "phone" field. +func PhoneContains(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldContains(FieldPhone, v)) +} + +// PhoneHasPrefix applies the HasPrefix predicate on the "phone" field. +func PhoneHasPrefix(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldHasPrefix(FieldPhone, v)) +} + +// PhoneHasSuffix applies the HasSuffix predicate on the "phone" field. +func PhoneHasSuffix(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldHasSuffix(FieldPhone, v)) +} + +// PhoneIsNil applies the IsNil predicate on the "phone" field. +func PhoneIsNil() predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldIsNull(FieldPhone)) +} + +// PhoneNotNil applies the NotNil predicate on the "phone" field. +func PhoneNotNil() predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNotNull(FieldPhone)) +} + +// PhoneEqualFold applies the EqualFold predicate on the "phone" field. +func PhoneEqualFold(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEqualFold(FieldPhone, v)) +} + +// PhoneContainsFold applies the ContainsFold predicate on the "phone" field. +func PhoneContainsFold(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldContainsFold(FieldPhone, v)) +} + +// PasswordEQ applies the EQ predicate on the "password" field. +func PasswordEQ(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEQ(FieldPassword, v)) +} + +// PasswordNEQ applies the NEQ predicate on the "password" field. +func PasswordNEQ(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNEQ(FieldPassword, v)) +} + +// PasswordIn applies the In predicate on the "password" field. +func PasswordIn(vs ...string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldIn(FieldPassword, vs...)) +} + +// PasswordNotIn applies the NotIn predicate on the "password" field. +func PasswordNotIn(vs ...string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNotIn(FieldPassword, vs...)) +} + +// PasswordGT applies the GT predicate on the "password" field. +func PasswordGT(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldGT(FieldPassword, v)) +} + +// PasswordGTE applies the GTE predicate on the "password" field. +func PasswordGTE(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldGTE(FieldPassword, v)) +} + +// PasswordLT applies the LT predicate on the "password" field. +func PasswordLT(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldLT(FieldPassword, v)) +} + +// PasswordLTE applies the LTE predicate on the "password" field. +func PasswordLTE(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldLTE(FieldPassword, v)) +} + +// PasswordContains applies the Contains predicate on the "password" field. +func PasswordContains(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldContains(FieldPassword, v)) +} + +// PasswordHasPrefix applies the HasPrefix predicate on the "password" field. +func PasswordHasPrefix(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldHasPrefix(FieldPassword, v)) +} + +// PasswordHasSuffix applies the HasSuffix predicate on the "password" field. +func PasswordHasSuffix(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldHasSuffix(FieldPassword, v)) +} + +// PasswordIsNil applies the IsNil predicate on the "password" field. +func PasswordIsNil() predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldIsNull(FieldPassword)) +} + +// PasswordNotNil applies the NotNil predicate on the "password" field. +func PasswordNotNil() predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNotNull(FieldPassword)) +} + +// PasswordEqualFold applies the EqualFold predicate on the "password" field. +func PasswordEqualFold(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEqualFold(FieldPassword, v)) +} + +// PasswordContainsFold applies the ContainsFold predicate on the "password" field. +func PasswordContainsFold(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldContainsFold(FieldPassword, v)) +} + +// GenderEQ applies the EQ predicate on the "gender" field. +func GenderEQ(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEQ(FieldGender, v)) +} + +// GenderNEQ applies the NEQ predicate on the "gender" field. +func GenderNEQ(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNEQ(FieldGender, v)) +} + +// GenderIn applies the In predicate on the "gender" field. +func GenderIn(vs ...string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldIn(FieldGender, vs...)) +} + +// GenderNotIn applies the NotIn predicate on the "gender" field. +func GenderNotIn(vs ...string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNotIn(FieldGender, vs...)) +} + +// GenderGT applies the GT predicate on the "gender" field. +func GenderGT(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldGT(FieldGender, v)) +} + +// GenderGTE applies the GTE predicate on the "gender" field. +func GenderGTE(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldGTE(FieldGender, v)) +} + +// GenderLT applies the LT predicate on the "gender" field. +func GenderLT(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldLT(FieldGender, v)) +} + +// GenderLTE applies the LTE predicate on the "gender" field. +func GenderLTE(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldLTE(FieldGender, v)) +} + +// GenderContains applies the Contains predicate on the "gender" field. +func GenderContains(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldContains(FieldGender, v)) +} + +// GenderHasPrefix applies the HasPrefix predicate on the "gender" field. +func GenderHasPrefix(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldHasPrefix(FieldGender, v)) +} + +// GenderHasSuffix applies the HasSuffix predicate on the "gender" field. +func GenderHasSuffix(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldHasSuffix(FieldGender, v)) +} + +// GenderIsNil applies the IsNil predicate on the "gender" field. +func GenderIsNil() predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldIsNull(FieldGender)) +} + +// GenderNotNil applies the NotNil predicate on the "gender" field. +func GenderNotNil() predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNotNull(FieldGender)) +} + +// GenderEqualFold applies the EqualFold predicate on the "gender" field. +func GenderEqualFold(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEqualFold(FieldGender, v)) +} + +// GenderContainsFold applies the ContainsFold predicate on the "gender" field. +func GenderContainsFold(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldContainsFold(FieldGender, v)) +} + +// AvatarEQ applies the EQ predicate on the "avatar" field. +func AvatarEQ(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEQ(FieldAvatar, v)) +} + +// AvatarNEQ applies the NEQ predicate on the "avatar" field. +func AvatarNEQ(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNEQ(FieldAvatar, v)) +} + +// AvatarIn applies the In predicate on the "avatar" field. +func AvatarIn(vs ...string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldIn(FieldAvatar, vs...)) +} + +// AvatarNotIn applies the NotIn predicate on the "avatar" field. +func AvatarNotIn(vs ...string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNotIn(FieldAvatar, vs...)) +} + +// AvatarGT applies the GT predicate on the "avatar" field. +func AvatarGT(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldGT(FieldAvatar, v)) +} + +// AvatarGTE applies the GTE predicate on the "avatar" field. +func AvatarGTE(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldGTE(FieldAvatar, v)) +} + +// AvatarLT applies the LT predicate on the "avatar" field. +func AvatarLT(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldLT(FieldAvatar, v)) +} + +// AvatarLTE applies the LTE predicate on the "avatar" field. +func AvatarLTE(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldLTE(FieldAvatar, v)) +} + +// AvatarContains applies the Contains predicate on the "avatar" field. +func AvatarContains(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldContains(FieldAvatar, v)) +} + +// AvatarHasPrefix applies the HasPrefix predicate on the "avatar" field. +func AvatarHasPrefix(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldHasPrefix(FieldAvatar, v)) +} + +// AvatarHasSuffix applies the HasSuffix predicate on the "avatar" field. +func AvatarHasSuffix(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldHasSuffix(FieldAvatar, v)) +} + +// AvatarIsNil applies the IsNil predicate on the "avatar" field. +func AvatarIsNil() predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldIsNull(FieldAvatar)) +} + +// AvatarNotNil applies the NotNil predicate on the "avatar" field. +func AvatarNotNil() predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNotNull(FieldAvatar)) +} + +// AvatarEqualFold applies the EqualFold predicate on the "avatar" field. +func AvatarEqualFold(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEqualFold(FieldAvatar, v)) +} + +// AvatarContainsFold applies the ContainsFold predicate on the "avatar" field. +func AvatarContainsFold(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldContainsFold(FieldAvatar, v)) +} + +// StatusEQ applies the EQ predicate on the "status" field. +func StatusEQ(v int8) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEQ(FieldStatus, v)) +} + +// StatusNEQ applies the NEQ predicate on the "status" field. +func StatusNEQ(v int8) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNEQ(FieldStatus, v)) +} + +// StatusIn applies the In predicate on the "status" field. +func StatusIn(vs ...int8) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldIn(FieldStatus, vs...)) +} + +// StatusNotIn applies the NotIn predicate on the "status" field. +func StatusNotIn(vs ...int8) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNotIn(FieldStatus, vs...)) +} + +// StatusGT applies the GT predicate on the "status" field. +func StatusGT(v int8) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldGT(FieldStatus, v)) +} + +// StatusGTE applies the GTE predicate on the "status" field. +func StatusGTE(v int8) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldGTE(FieldStatus, v)) +} + +// StatusLT applies the LT predicate on the "status" field. +func StatusLT(v int8) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldLT(FieldStatus, v)) +} + +// StatusLTE applies the LTE predicate on the "status" field. +func StatusLTE(v int8) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldLTE(FieldStatus, v)) +} + +// StatusIsNil applies the IsNil predicate on the "status" field. +func StatusIsNil() predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldIsNull(FieldStatus)) +} + +// StatusNotNil applies the NotNil predicate on the "status" field. +func StatusNotNil() predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNotNull(FieldStatus)) +} + +// IntroduceEQ applies the EQ predicate on the "introduce" field. +func IntroduceEQ(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEQ(FieldIntroduce, v)) +} + +// IntroduceNEQ applies the NEQ predicate on the "introduce" field. +func IntroduceNEQ(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNEQ(FieldIntroduce, v)) +} + +// IntroduceIn applies the In predicate on the "introduce" field. +func IntroduceIn(vs ...string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldIn(FieldIntroduce, vs...)) +} + +// IntroduceNotIn applies the NotIn predicate on the "introduce" field. +func IntroduceNotIn(vs ...string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNotIn(FieldIntroduce, vs...)) +} + +// IntroduceGT applies the GT predicate on the "introduce" field. +func IntroduceGT(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldGT(FieldIntroduce, v)) +} + +// IntroduceGTE applies the GTE predicate on the "introduce" field. +func IntroduceGTE(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldGTE(FieldIntroduce, v)) +} + +// IntroduceLT applies the LT predicate on the "introduce" field. +func IntroduceLT(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldLT(FieldIntroduce, v)) +} + +// IntroduceLTE applies the LTE predicate on the "introduce" field. +func IntroduceLTE(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldLTE(FieldIntroduce, v)) +} + +// IntroduceContains applies the Contains predicate on the "introduce" field. +func IntroduceContains(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldContains(FieldIntroduce, v)) +} + +// IntroduceHasPrefix applies the HasPrefix predicate on the "introduce" field. +func IntroduceHasPrefix(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldHasPrefix(FieldIntroduce, v)) +} + +// IntroduceHasSuffix applies the HasSuffix predicate on the "introduce" field. +func IntroduceHasSuffix(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldHasSuffix(FieldIntroduce, v)) +} + +// IntroduceIsNil applies the IsNil predicate on the "introduce" field. +func IntroduceIsNil() predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldIsNull(FieldIntroduce)) +} + +// IntroduceNotNil applies the NotNil predicate on the "introduce" field. +func IntroduceNotNil() predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNotNull(FieldIntroduce)) +} + +// IntroduceEqualFold applies the EqualFold predicate on the "introduce" field. +func IntroduceEqualFold(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEqualFold(FieldIntroduce, v)) +} + +// IntroduceContainsFold applies the ContainsFold predicate on the "introduce" field. +func IntroduceContainsFold(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldContainsFold(FieldIntroduce, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldLTE(FieldCreatedAt, v)) +} + +// UpdateAtEQ applies the EQ predicate on the "update_at" field. +func UpdateAtEQ(v time.Time) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEQ(FieldUpdateAt, v)) +} + +// UpdateAtNEQ applies the NEQ predicate on the "update_at" field. +func UpdateAtNEQ(v time.Time) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNEQ(FieldUpdateAt, v)) +} + +// UpdateAtIn applies the In predicate on the "update_at" field. +func UpdateAtIn(vs ...time.Time) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldIn(FieldUpdateAt, vs...)) +} + +// UpdateAtNotIn applies the NotIn predicate on the "update_at" field. +func UpdateAtNotIn(vs ...time.Time) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNotIn(FieldUpdateAt, vs...)) +} + +// UpdateAtGT applies the GT predicate on the "update_at" field. +func UpdateAtGT(v time.Time) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldGT(FieldUpdateAt, v)) +} + +// UpdateAtGTE applies the GTE predicate on the "update_at" field. +func UpdateAtGTE(v time.Time) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldGTE(FieldUpdateAt, v)) +} + +// UpdateAtLT applies the LT predicate on the "update_at" field. +func UpdateAtLT(v time.Time) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldLT(FieldUpdateAt, v)) +} + +// UpdateAtLTE applies the LTE predicate on the "update_at" field. +func UpdateAtLTE(v time.Time) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldLTE(FieldUpdateAt, v)) +} + +// UpdateAtIsNil applies the IsNil predicate on the "update_at" field. +func UpdateAtIsNil() predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldIsNull(FieldUpdateAt)) +} + +// UpdateAtNotNil applies the NotNil predicate on the "update_at" field. +func UpdateAtNotNil() predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNotNull(FieldUpdateAt)) +} + +// DeletedEQ applies the EQ predicate on the "deleted" field. +func DeletedEQ(v int8) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEQ(FieldDeleted, v)) +} + +// DeletedNEQ applies the NEQ predicate on the "deleted" field. +func DeletedNEQ(v int8) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNEQ(FieldDeleted, v)) +} + +// DeletedIn applies the In predicate on the "deleted" field. +func DeletedIn(vs ...int8) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldIn(FieldDeleted, vs...)) +} + +// DeletedNotIn applies the NotIn predicate on the "deleted" field. +func DeletedNotIn(vs ...int8) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNotIn(FieldDeleted, vs...)) +} + +// DeletedGT applies the GT predicate on the "deleted" field. +func DeletedGT(v int8) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldGT(FieldDeleted, v)) +} + +// DeletedGTE applies the GTE predicate on the "deleted" field. +func DeletedGTE(v int8) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldGTE(FieldDeleted, v)) +} + +// DeletedLT applies the LT predicate on the "deleted" field. +func DeletedLT(v int8) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldLT(FieldDeleted, v)) +} + +// DeletedLTE applies the LTE predicate on the "deleted" field. +func DeletedLTE(v int8) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldLTE(FieldDeleted, v)) +} + +// BlogEQ applies the EQ predicate on the "blog" field. +func BlogEQ(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEQ(FieldBlog, v)) +} + +// BlogNEQ applies the NEQ predicate on the "blog" field. +func BlogNEQ(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNEQ(FieldBlog, v)) +} + +// BlogIn applies the In predicate on the "blog" field. +func BlogIn(vs ...string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldIn(FieldBlog, vs...)) +} + +// BlogNotIn applies the NotIn predicate on the "blog" field. +func BlogNotIn(vs ...string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNotIn(FieldBlog, vs...)) +} + +// BlogGT applies the GT predicate on the "blog" field. +func BlogGT(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldGT(FieldBlog, v)) +} + +// BlogGTE applies the GTE predicate on the "blog" field. +func BlogGTE(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldGTE(FieldBlog, v)) +} + +// BlogLT applies the LT predicate on the "blog" field. +func BlogLT(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldLT(FieldBlog, v)) +} + +// BlogLTE applies the LTE predicate on the "blog" field. +func BlogLTE(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldLTE(FieldBlog, v)) +} + +// BlogContains applies the Contains predicate on the "blog" field. +func BlogContains(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldContains(FieldBlog, v)) +} + +// BlogHasPrefix applies the HasPrefix predicate on the "blog" field. +func BlogHasPrefix(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldHasPrefix(FieldBlog, v)) +} + +// BlogHasSuffix applies the HasSuffix predicate on the "blog" field. +func BlogHasSuffix(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldHasSuffix(FieldBlog, v)) +} + +// BlogIsNil applies the IsNil predicate on the "blog" field. +func BlogIsNil() predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldIsNull(FieldBlog)) +} + +// BlogNotNil applies the NotNil predicate on the "blog" field. +func BlogNotNil() predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNotNull(FieldBlog)) +} + +// BlogEqualFold applies the EqualFold predicate on the "blog" field. +func BlogEqualFold(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEqualFold(FieldBlog, v)) +} + +// BlogContainsFold applies the ContainsFold predicate on the "blog" field. +func BlogContainsFold(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldContainsFold(FieldBlog, v)) +} + +// LocationEQ applies the EQ predicate on the "location" field. +func LocationEQ(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEQ(FieldLocation, v)) +} + +// LocationNEQ applies the NEQ predicate on the "location" field. +func LocationNEQ(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNEQ(FieldLocation, v)) +} + +// LocationIn applies the In predicate on the "location" field. +func LocationIn(vs ...string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldIn(FieldLocation, vs...)) +} + +// LocationNotIn applies the NotIn predicate on the "location" field. +func LocationNotIn(vs ...string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNotIn(FieldLocation, vs...)) +} + +// LocationGT applies the GT predicate on the "location" field. +func LocationGT(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldGT(FieldLocation, v)) +} + +// LocationGTE applies the GTE predicate on the "location" field. +func LocationGTE(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldGTE(FieldLocation, v)) +} + +// LocationLT applies the LT predicate on the "location" field. +func LocationLT(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldLT(FieldLocation, v)) +} + +// LocationLTE applies the LTE predicate on the "location" field. +func LocationLTE(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldLTE(FieldLocation, v)) +} + +// LocationContains applies the Contains predicate on the "location" field. +func LocationContains(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldContains(FieldLocation, v)) +} + +// LocationHasPrefix applies the HasPrefix predicate on the "location" field. +func LocationHasPrefix(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldHasPrefix(FieldLocation, v)) +} + +// LocationHasSuffix applies the HasSuffix predicate on the "location" field. +func LocationHasSuffix(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldHasSuffix(FieldLocation, v)) +} + +// LocationIsNil applies the IsNil predicate on the "location" field. +func LocationIsNil() predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldIsNull(FieldLocation)) +} + +// LocationNotNil applies the NotNil predicate on the "location" field. +func LocationNotNil() predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNotNull(FieldLocation)) +} + +// LocationEqualFold applies the EqualFold predicate on the "location" field. +func LocationEqualFold(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEqualFold(FieldLocation, v)) +} + +// LocationContainsFold applies the ContainsFold predicate on the "location" field. +func LocationContainsFold(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldContainsFold(FieldLocation, v)) +} + +// CompanyEQ applies the EQ predicate on the "company" field. +func CompanyEQ(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEQ(FieldCompany, v)) +} + +// CompanyNEQ applies the NEQ predicate on the "company" field. +func CompanyNEQ(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNEQ(FieldCompany, v)) +} + +// CompanyIn applies the In predicate on the "company" field. +func CompanyIn(vs ...string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldIn(FieldCompany, vs...)) +} + +// CompanyNotIn applies the NotIn predicate on the "company" field. +func CompanyNotIn(vs ...string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNotIn(FieldCompany, vs...)) +} + +// CompanyGT applies the GT predicate on the "company" field. +func CompanyGT(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldGT(FieldCompany, v)) +} + +// CompanyGTE applies the GTE predicate on the "company" field. +func CompanyGTE(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldGTE(FieldCompany, v)) +} + +// CompanyLT applies the LT predicate on the "company" field. +func CompanyLT(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldLT(FieldCompany, v)) +} + +// CompanyLTE applies the LTE predicate on the "company" field. +func CompanyLTE(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldLTE(FieldCompany, v)) +} + +// CompanyContains applies the Contains predicate on the "company" field. +func CompanyContains(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldContains(FieldCompany, v)) +} + +// CompanyHasPrefix applies the HasPrefix predicate on the "company" field. +func CompanyHasPrefix(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldHasPrefix(FieldCompany, v)) +} + +// CompanyHasSuffix applies the HasSuffix predicate on the "company" field. +func CompanyHasSuffix(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldHasSuffix(FieldCompany, v)) +} + +// CompanyIsNil applies the IsNil predicate on the "company" field. +func CompanyIsNil() predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldIsNull(FieldCompany)) +} + +// CompanyNotNil applies the NotNil predicate on the "company" field. +func CompanyNotNil() predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldNotNull(FieldCompany)) +} + +// CompanyEqualFold applies the EqualFold predicate on the "company" field. +func CompanyEqualFold(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldEqualFold(FieldCompany, v)) +} + +// CompanyContainsFold applies the ContainsFold predicate on the "company" field. +func CompanyContainsFold(v string) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.FieldContainsFold(FieldCompany, v)) +} + +// HasScaAuthUserSocial applies the HasEdge predicate on the "sca_auth_user_social" edge. +func HasScaAuthUserSocial() predicate.ScaAuthUser { + return predicate.ScaAuthUser(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, ScaAuthUserSocialTable, ScaAuthUserSocialColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasScaAuthUserSocialWith applies the HasEdge predicate on the "sca_auth_user_social" edge with a given conditions (other predicates). +func HasScaAuthUserSocialWith(preds ...predicate.ScaAuthUserSocial) predicate.ScaAuthUser { + return predicate.ScaAuthUser(func(s *sql.Selector) { + step := newScaAuthUserSocialStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasScaAuthUserDevice applies the HasEdge predicate on the "sca_auth_user_device" edge. +func HasScaAuthUserDevice() predicate.ScaAuthUser { + return predicate.ScaAuthUser(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, ScaAuthUserDeviceTable, ScaAuthUserDeviceColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasScaAuthUserDeviceWith applies the HasEdge predicate on the "sca_auth_user_device" edge with a given conditions (other predicates). +func HasScaAuthUserDeviceWith(preds ...predicate.ScaAuthUserDevice) predicate.ScaAuthUser { + return predicate.ScaAuthUser(func(s *sql.Selector) { + step := newScaAuthUserDeviceStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.ScaAuthUser) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.ScaAuthUser) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.ScaAuthUser) predicate.ScaAuthUser { + return predicate.ScaAuthUser(sql.NotPredicates(p)) +} diff --git a/common/ent/scaauthuser_create.go b/common/ent/scaauthuser_create.go new file mode 100644 index 0000000..3a23cf1 --- /dev/null +++ b/common/ent/scaauthuser_create.go @@ -0,0 +1,613 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "schisandra-album-cloud-microservices/common/ent/scaauthuser" + "schisandra-album-cloud-microservices/common/ent/scaauthuserdevice" + "schisandra-album-cloud-microservices/common/ent/scaauthusersocial" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ScaAuthUserCreate is the builder for creating a ScaAuthUser entity. +type ScaAuthUserCreate struct { + config + mutation *ScaAuthUserMutation + hooks []Hook +} + +// SetUID sets the "uid" field. +func (sauc *ScaAuthUserCreate) SetUID(s string) *ScaAuthUserCreate { + sauc.mutation.SetUID(s) + return sauc +} + +// SetUsername sets the "username" field. +func (sauc *ScaAuthUserCreate) SetUsername(s string) *ScaAuthUserCreate { + sauc.mutation.SetUsername(s) + return sauc +} + +// SetNillableUsername sets the "username" field if the given value is not nil. +func (sauc *ScaAuthUserCreate) SetNillableUsername(s *string) *ScaAuthUserCreate { + if s != nil { + sauc.SetUsername(*s) + } + return sauc +} + +// SetNickname sets the "nickname" field. +func (sauc *ScaAuthUserCreate) SetNickname(s string) *ScaAuthUserCreate { + sauc.mutation.SetNickname(s) + return sauc +} + +// SetNillableNickname sets the "nickname" field if the given value is not nil. +func (sauc *ScaAuthUserCreate) SetNillableNickname(s *string) *ScaAuthUserCreate { + if s != nil { + sauc.SetNickname(*s) + } + return sauc +} + +// SetEmail sets the "email" field. +func (sauc *ScaAuthUserCreate) SetEmail(s string) *ScaAuthUserCreate { + sauc.mutation.SetEmail(s) + return sauc +} + +// SetNillableEmail sets the "email" field if the given value is not nil. +func (sauc *ScaAuthUserCreate) SetNillableEmail(s *string) *ScaAuthUserCreate { + if s != nil { + sauc.SetEmail(*s) + } + return sauc +} + +// SetPhone sets the "phone" field. +func (sauc *ScaAuthUserCreate) SetPhone(s string) *ScaAuthUserCreate { + sauc.mutation.SetPhone(s) + return sauc +} + +// SetNillablePhone sets the "phone" field if the given value is not nil. +func (sauc *ScaAuthUserCreate) SetNillablePhone(s *string) *ScaAuthUserCreate { + if s != nil { + sauc.SetPhone(*s) + } + return sauc +} + +// SetPassword sets the "password" field. +func (sauc *ScaAuthUserCreate) SetPassword(s string) *ScaAuthUserCreate { + sauc.mutation.SetPassword(s) + return sauc +} + +// SetNillablePassword sets the "password" field if the given value is not nil. +func (sauc *ScaAuthUserCreate) SetNillablePassword(s *string) *ScaAuthUserCreate { + if s != nil { + sauc.SetPassword(*s) + } + return sauc +} + +// SetGender sets the "gender" field. +func (sauc *ScaAuthUserCreate) SetGender(s string) *ScaAuthUserCreate { + sauc.mutation.SetGender(s) + return sauc +} + +// SetNillableGender sets the "gender" field if the given value is not nil. +func (sauc *ScaAuthUserCreate) SetNillableGender(s *string) *ScaAuthUserCreate { + if s != nil { + sauc.SetGender(*s) + } + return sauc +} + +// SetAvatar sets the "avatar" field. +func (sauc *ScaAuthUserCreate) SetAvatar(s string) *ScaAuthUserCreate { + sauc.mutation.SetAvatar(s) + return sauc +} + +// SetNillableAvatar sets the "avatar" field if the given value is not nil. +func (sauc *ScaAuthUserCreate) SetNillableAvatar(s *string) *ScaAuthUserCreate { + if s != nil { + sauc.SetAvatar(*s) + } + return sauc +} + +// SetStatus sets the "status" field. +func (sauc *ScaAuthUserCreate) SetStatus(i int8) *ScaAuthUserCreate { + sauc.mutation.SetStatus(i) + return sauc +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (sauc *ScaAuthUserCreate) SetNillableStatus(i *int8) *ScaAuthUserCreate { + if i != nil { + sauc.SetStatus(*i) + } + return sauc +} + +// SetIntroduce sets the "introduce" field. +func (sauc *ScaAuthUserCreate) SetIntroduce(s string) *ScaAuthUserCreate { + sauc.mutation.SetIntroduce(s) + return sauc +} + +// SetNillableIntroduce sets the "introduce" field if the given value is not nil. +func (sauc *ScaAuthUserCreate) SetNillableIntroduce(s *string) *ScaAuthUserCreate { + if s != nil { + sauc.SetIntroduce(*s) + } + return sauc +} + +// SetCreatedAt sets the "created_at" field. +func (sauc *ScaAuthUserCreate) SetCreatedAt(t time.Time) *ScaAuthUserCreate { + sauc.mutation.SetCreatedAt(t) + return sauc +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (sauc *ScaAuthUserCreate) SetNillableCreatedAt(t *time.Time) *ScaAuthUserCreate { + if t != nil { + sauc.SetCreatedAt(*t) + } + return sauc +} + +// SetUpdateAt sets the "update_at" field. +func (sauc *ScaAuthUserCreate) SetUpdateAt(t time.Time) *ScaAuthUserCreate { + sauc.mutation.SetUpdateAt(t) + return sauc +} + +// SetNillableUpdateAt sets the "update_at" field if the given value is not nil. +func (sauc *ScaAuthUserCreate) SetNillableUpdateAt(t *time.Time) *ScaAuthUserCreate { + if t != nil { + sauc.SetUpdateAt(*t) + } + return sauc +} + +// SetDeleted sets the "deleted" field. +func (sauc *ScaAuthUserCreate) SetDeleted(i int8) *ScaAuthUserCreate { + sauc.mutation.SetDeleted(i) + return sauc +} + +// SetNillableDeleted sets the "deleted" field if the given value is not nil. +func (sauc *ScaAuthUserCreate) SetNillableDeleted(i *int8) *ScaAuthUserCreate { + if i != nil { + sauc.SetDeleted(*i) + } + return sauc +} + +// SetBlog sets the "blog" field. +func (sauc *ScaAuthUserCreate) SetBlog(s string) *ScaAuthUserCreate { + sauc.mutation.SetBlog(s) + return sauc +} + +// SetNillableBlog sets the "blog" field if the given value is not nil. +func (sauc *ScaAuthUserCreate) SetNillableBlog(s *string) *ScaAuthUserCreate { + if s != nil { + sauc.SetBlog(*s) + } + return sauc +} + +// SetLocation sets the "location" field. +func (sauc *ScaAuthUserCreate) SetLocation(s string) *ScaAuthUserCreate { + sauc.mutation.SetLocation(s) + return sauc +} + +// SetNillableLocation sets the "location" field if the given value is not nil. +func (sauc *ScaAuthUserCreate) SetNillableLocation(s *string) *ScaAuthUserCreate { + if s != nil { + sauc.SetLocation(*s) + } + return sauc +} + +// SetCompany sets the "company" field. +func (sauc *ScaAuthUserCreate) SetCompany(s string) *ScaAuthUserCreate { + sauc.mutation.SetCompany(s) + return sauc +} + +// SetNillableCompany sets the "company" field if the given value is not nil. +func (sauc *ScaAuthUserCreate) SetNillableCompany(s *string) *ScaAuthUserCreate { + if s != nil { + sauc.SetCompany(*s) + } + return sauc +} + +// SetID sets the "id" field. +func (sauc *ScaAuthUserCreate) SetID(i int64) *ScaAuthUserCreate { + sauc.mutation.SetID(i) + return sauc +} + +// AddScaAuthUserSocialIDs adds the "sca_auth_user_social" edge to the ScaAuthUserSocial entity by IDs. +func (sauc *ScaAuthUserCreate) AddScaAuthUserSocialIDs(ids ...int64) *ScaAuthUserCreate { + sauc.mutation.AddScaAuthUserSocialIDs(ids...) + return sauc +} + +// AddScaAuthUserSocial adds the "sca_auth_user_social" edges to the ScaAuthUserSocial entity. +func (sauc *ScaAuthUserCreate) AddScaAuthUserSocial(s ...*ScaAuthUserSocial) *ScaAuthUserCreate { + ids := make([]int64, len(s)) + for i := range s { + ids[i] = s[i].ID + } + return sauc.AddScaAuthUserSocialIDs(ids...) +} + +// AddScaAuthUserDeviceIDs adds the "sca_auth_user_device" edge to the ScaAuthUserDevice entity by IDs. +func (sauc *ScaAuthUserCreate) AddScaAuthUserDeviceIDs(ids ...int64) *ScaAuthUserCreate { + sauc.mutation.AddScaAuthUserDeviceIDs(ids...) + return sauc +} + +// AddScaAuthUserDevice adds the "sca_auth_user_device" edges to the ScaAuthUserDevice entity. +func (sauc *ScaAuthUserCreate) AddScaAuthUserDevice(s ...*ScaAuthUserDevice) *ScaAuthUserCreate { + ids := make([]int64, len(s)) + for i := range s { + ids[i] = s[i].ID + } + return sauc.AddScaAuthUserDeviceIDs(ids...) +} + +// Mutation returns the ScaAuthUserMutation object of the builder. +func (sauc *ScaAuthUserCreate) Mutation() *ScaAuthUserMutation { + return sauc.mutation +} + +// Save creates the ScaAuthUser in the database. +func (sauc *ScaAuthUserCreate) Save(ctx context.Context) (*ScaAuthUser, error) { + sauc.defaults() + return withHooks(ctx, sauc.sqlSave, sauc.mutation, sauc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (sauc *ScaAuthUserCreate) SaveX(ctx context.Context) *ScaAuthUser { + v, err := sauc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (sauc *ScaAuthUserCreate) Exec(ctx context.Context) error { + _, err := sauc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (sauc *ScaAuthUserCreate) ExecX(ctx context.Context) { + if err := sauc.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (sauc *ScaAuthUserCreate) defaults() { + if _, ok := sauc.mutation.Status(); !ok { + v := scaauthuser.DefaultStatus + sauc.mutation.SetStatus(v) + } + if _, ok := sauc.mutation.CreatedAt(); !ok { + v := scaauthuser.DefaultCreatedAt() + sauc.mutation.SetCreatedAt(v) + } + if _, ok := sauc.mutation.UpdateAt(); !ok { + v := scaauthuser.DefaultUpdateAt() + sauc.mutation.SetUpdateAt(v) + } + if _, ok := sauc.mutation.Deleted(); !ok { + v := scaauthuser.DefaultDeleted + sauc.mutation.SetDeleted(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (sauc *ScaAuthUserCreate) check() error { + if _, ok := sauc.mutation.UID(); !ok { + return &ValidationError{Name: "uid", err: errors.New(`ent: missing required field "ScaAuthUser.uid"`)} + } + if v, ok := sauc.mutation.UID(); ok { + if err := scaauthuser.UIDValidator(v); err != nil { + return &ValidationError{Name: "uid", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.uid": %w`, err)} + } + } + if v, ok := sauc.mutation.Username(); ok { + if err := scaauthuser.UsernameValidator(v); err != nil { + return &ValidationError{Name: "username", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.username": %w`, err)} + } + } + if v, ok := sauc.mutation.Nickname(); ok { + if err := scaauthuser.NicknameValidator(v); err != nil { + return &ValidationError{Name: "nickname", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.nickname": %w`, err)} + } + } + if v, ok := sauc.mutation.Email(); ok { + if err := scaauthuser.EmailValidator(v); err != nil { + return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.email": %w`, err)} + } + } + if v, ok := sauc.mutation.Phone(); ok { + if err := scaauthuser.PhoneValidator(v); err != nil { + return &ValidationError{Name: "phone", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.phone": %w`, err)} + } + } + if v, ok := sauc.mutation.Password(); ok { + if err := scaauthuser.PasswordValidator(v); err != nil { + return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.password": %w`, err)} + } + } + if v, ok := sauc.mutation.Gender(); ok { + if err := scaauthuser.GenderValidator(v); err != nil { + return &ValidationError{Name: "gender", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.gender": %w`, err)} + } + } + if v, ok := sauc.mutation.Introduce(); ok { + if err := scaauthuser.IntroduceValidator(v); err != nil { + return &ValidationError{Name: "introduce", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.introduce": %w`, err)} + } + } + if _, ok := sauc.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "ScaAuthUser.created_at"`)} + } + if _, ok := sauc.mutation.Deleted(); !ok { + return &ValidationError{Name: "deleted", err: errors.New(`ent: missing required field "ScaAuthUser.deleted"`)} + } + if v, ok := sauc.mutation.Blog(); ok { + if err := scaauthuser.BlogValidator(v); err != nil { + return &ValidationError{Name: "blog", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.blog": %w`, err)} + } + } + if v, ok := sauc.mutation.Location(); ok { + if err := scaauthuser.LocationValidator(v); err != nil { + return &ValidationError{Name: "location", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.location": %w`, err)} + } + } + if v, ok := sauc.mutation.Company(); ok { + if err := scaauthuser.CompanyValidator(v); err != nil { + return &ValidationError{Name: "company", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.company": %w`, err)} + } + } + return nil +} + +func (sauc *ScaAuthUserCreate) sqlSave(ctx context.Context) (*ScaAuthUser, error) { + if err := sauc.check(); err != nil { + return nil, err + } + _node, _spec := sauc.createSpec() + if err := sqlgraph.CreateNode(ctx, sauc.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) + } + sauc.mutation.id = &_node.ID + sauc.mutation.done = true + return _node, nil +} + +func (sauc *ScaAuthUserCreate) createSpec() (*ScaAuthUser, *sqlgraph.CreateSpec) { + var ( + _node = &ScaAuthUser{config: sauc.config} + _spec = sqlgraph.NewCreateSpec(scaauthuser.Table, sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64)) + ) + if id, ok := sauc.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := sauc.mutation.UID(); ok { + _spec.SetField(scaauthuser.FieldUID, field.TypeString, value) + _node.UID = value + } + if value, ok := sauc.mutation.Username(); ok { + _spec.SetField(scaauthuser.FieldUsername, field.TypeString, value) + _node.Username = value + } + if value, ok := sauc.mutation.Nickname(); ok { + _spec.SetField(scaauthuser.FieldNickname, field.TypeString, value) + _node.Nickname = value + } + if value, ok := sauc.mutation.Email(); ok { + _spec.SetField(scaauthuser.FieldEmail, field.TypeString, value) + _node.Email = value + } + if value, ok := sauc.mutation.Phone(); ok { + _spec.SetField(scaauthuser.FieldPhone, field.TypeString, value) + _node.Phone = value + } + if value, ok := sauc.mutation.Password(); ok { + _spec.SetField(scaauthuser.FieldPassword, field.TypeString, value) + _node.Password = value + } + if value, ok := sauc.mutation.Gender(); ok { + _spec.SetField(scaauthuser.FieldGender, field.TypeString, value) + _node.Gender = value + } + if value, ok := sauc.mutation.Avatar(); ok { + _spec.SetField(scaauthuser.FieldAvatar, field.TypeString, value) + _node.Avatar = value + } + if value, ok := sauc.mutation.Status(); ok { + _spec.SetField(scaauthuser.FieldStatus, field.TypeInt8, value) + _node.Status = value + } + if value, ok := sauc.mutation.Introduce(); ok { + _spec.SetField(scaauthuser.FieldIntroduce, field.TypeString, value) + _node.Introduce = value + } + if value, ok := sauc.mutation.CreatedAt(); ok { + _spec.SetField(scaauthuser.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := sauc.mutation.UpdateAt(); ok { + _spec.SetField(scaauthuser.FieldUpdateAt, field.TypeTime, value) + _node.UpdateAt = &value + } + if value, ok := sauc.mutation.Deleted(); ok { + _spec.SetField(scaauthuser.FieldDeleted, field.TypeInt8, value) + _node.Deleted = value + } + if value, ok := sauc.mutation.Blog(); ok { + _spec.SetField(scaauthuser.FieldBlog, field.TypeString, value) + _node.Blog = &value + } + if value, ok := sauc.mutation.Location(); ok { + _spec.SetField(scaauthuser.FieldLocation, field.TypeString, value) + _node.Location = &value + } + if value, ok := sauc.mutation.Company(); ok { + _spec.SetField(scaauthuser.FieldCompany, field.TypeString, value) + _node.Company = &value + } + if nodes := sauc.mutation.ScaAuthUserSocialIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: scaauthuser.ScaAuthUserSocialTable, + Columns: []string{scaauthuser.ScaAuthUserSocialColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := sauc.mutation.ScaAuthUserDeviceIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: scaauthuser.ScaAuthUserDeviceTable, + Columns: []string{scaauthuser.ScaAuthUserDeviceColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(scaauthuserdevice.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// ScaAuthUserCreateBulk is the builder for creating many ScaAuthUser entities in bulk. +type ScaAuthUserCreateBulk struct { + config + err error + builders []*ScaAuthUserCreate +} + +// Save creates the ScaAuthUser entities in the database. +func (saucb *ScaAuthUserCreateBulk) Save(ctx context.Context) ([]*ScaAuthUser, error) { + if saucb.err != nil { + return nil, saucb.err + } + specs := make([]*sqlgraph.CreateSpec, len(saucb.builders)) + nodes := make([]*ScaAuthUser, len(saucb.builders)) + mutators := make([]Mutator, len(saucb.builders)) + for i := range saucb.builders { + func(i int, root context.Context) { + builder := saucb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*ScaAuthUserMutation) + 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, saucb.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, saucb.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, saucb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (saucb *ScaAuthUserCreateBulk) SaveX(ctx context.Context) []*ScaAuthUser { + v, err := saucb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (saucb *ScaAuthUserCreateBulk) Exec(ctx context.Context) error { + _, err := saucb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (saucb *ScaAuthUserCreateBulk) ExecX(ctx context.Context) { + if err := saucb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/common/ent/scaauthuser_delete.go b/common/ent/scaauthuser_delete.go new file mode 100644 index 0000000..857d525 --- /dev/null +++ b/common/ent/scaauthuser_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "schisandra-album-cloud-microservices/common/ent/predicate" + "schisandra-album-cloud-microservices/common/ent/scaauthuser" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ScaAuthUserDelete is the builder for deleting a ScaAuthUser entity. +type ScaAuthUserDelete struct { + config + hooks []Hook + mutation *ScaAuthUserMutation +} + +// Where appends a list predicates to the ScaAuthUserDelete builder. +func (saud *ScaAuthUserDelete) Where(ps ...predicate.ScaAuthUser) *ScaAuthUserDelete { + saud.mutation.Where(ps...) + return saud +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (saud *ScaAuthUserDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, saud.sqlExec, saud.mutation, saud.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (saud *ScaAuthUserDelete) ExecX(ctx context.Context) int { + n, err := saud.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (saud *ScaAuthUserDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(scaauthuser.Table, sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64)) + if ps := saud.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, saud.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + saud.mutation.done = true + return affected, err +} + +// ScaAuthUserDeleteOne is the builder for deleting a single ScaAuthUser entity. +type ScaAuthUserDeleteOne struct { + saud *ScaAuthUserDelete +} + +// Where appends a list predicates to the ScaAuthUserDelete builder. +func (saudo *ScaAuthUserDeleteOne) Where(ps ...predicate.ScaAuthUser) *ScaAuthUserDeleteOne { + saudo.saud.mutation.Where(ps...) + return saudo +} + +// Exec executes the deletion query. +func (saudo *ScaAuthUserDeleteOne) Exec(ctx context.Context) error { + n, err := saudo.saud.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{scaauthuser.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (saudo *ScaAuthUserDeleteOne) ExecX(ctx context.Context) { + if err := saudo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/common/ent/scaauthuser_query.go b/common/ent/scaauthuser_query.go new file mode 100644 index 0000000..0b88bff --- /dev/null +++ b/common/ent/scaauthuser_query.go @@ -0,0 +1,686 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "database/sql/driver" + "fmt" + "math" + "schisandra-album-cloud-microservices/common/ent/predicate" + "schisandra-album-cloud-microservices/common/ent/scaauthuser" + "schisandra-album-cloud-microservices/common/ent/scaauthuserdevice" + "schisandra-album-cloud-microservices/common/ent/scaauthusersocial" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ScaAuthUserQuery is the builder for querying ScaAuthUser entities. +type ScaAuthUserQuery struct { + config + ctx *QueryContext + order []scaauthuser.OrderOption + inters []Interceptor + predicates []predicate.ScaAuthUser + withScaAuthUserSocial *ScaAuthUserSocialQuery + withScaAuthUserDevice *ScaAuthUserDeviceQuery + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the ScaAuthUserQuery builder. +func (sauq *ScaAuthUserQuery) Where(ps ...predicate.ScaAuthUser) *ScaAuthUserQuery { + sauq.predicates = append(sauq.predicates, ps...) + return sauq +} + +// Limit the number of records to be returned by this query. +func (sauq *ScaAuthUserQuery) Limit(limit int) *ScaAuthUserQuery { + sauq.ctx.Limit = &limit + return sauq +} + +// Offset to start from. +func (sauq *ScaAuthUserQuery) Offset(offset int) *ScaAuthUserQuery { + sauq.ctx.Offset = &offset + return sauq +} + +// 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 (sauq *ScaAuthUserQuery) Unique(unique bool) *ScaAuthUserQuery { + sauq.ctx.Unique = &unique + return sauq +} + +// Order specifies how the records should be ordered. +func (sauq *ScaAuthUserQuery) Order(o ...scaauthuser.OrderOption) *ScaAuthUserQuery { + sauq.order = append(sauq.order, o...) + return sauq +} + +// QueryScaAuthUserSocial chains the current query on the "sca_auth_user_social" edge. +func (sauq *ScaAuthUserQuery) QueryScaAuthUserSocial() *ScaAuthUserSocialQuery { + query := (&ScaAuthUserSocialClient{config: sauq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := sauq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := sauq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(scaauthuser.Table, scaauthuser.FieldID, selector), + sqlgraph.To(scaauthusersocial.Table, scaauthusersocial.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, scaauthuser.ScaAuthUserSocialTable, scaauthuser.ScaAuthUserSocialColumn), + ) + fromU = sqlgraph.SetNeighbors(sauq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryScaAuthUserDevice chains the current query on the "sca_auth_user_device" edge. +func (sauq *ScaAuthUserQuery) QueryScaAuthUserDevice() *ScaAuthUserDeviceQuery { + query := (&ScaAuthUserDeviceClient{config: sauq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := sauq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := sauq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(scaauthuser.Table, scaauthuser.FieldID, selector), + sqlgraph.To(scaauthuserdevice.Table, scaauthuserdevice.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, scaauthuser.ScaAuthUserDeviceTable, scaauthuser.ScaAuthUserDeviceColumn), + ) + fromU = sqlgraph.SetNeighbors(sauq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first ScaAuthUser entity from the query. +// Returns a *NotFoundError when no ScaAuthUser was found. +func (sauq *ScaAuthUserQuery) First(ctx context.Context) (*ScaAuthUser, error) { + nodes, err := sauq.Limit(1).All(setContextOp(ctx, sauq.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{scaauthuser.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (sauq *ScaAuthUserQuery) FirstX(ctx context.Context) *ScaAuthUser { + node, err := sauq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first ScaAuthUser ID from the query. +// Returns a *NotFoundError when no ScaAuthUser ID was found. +func (sauq *ScaAuthUserQuery) FirstID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = sauq.Limit(1).IDs(setContextOp(ctx, sauq.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{scaauthuser.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (sauq *ScaAuthUserQuery) FirstIDX(ctx context.Context) int64 { + id, err := sauq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single ScaAuthUser entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one ScaAuthUser entity is found. +// Returns a *NotFoundError when no ScaAuthUser entities are found. +func (sauq *ScaAuthUserQuery) Only(ctx context.Context) (*ScaAuthUser, error) { + nodes, err := sauq.Limit(2).All(setContextOp(ctx, sauq.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{scaauthuser.Label} + default: + return nil, &NotSingularError{scaauthuser.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (sauq *ScaAuthUserQuery) OnlyX(ctx context.Context) *ScaAuthUser { + node, err := sauq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only ScaAuthUser ID in the query. +// Returns a *NotSingularError when more than one ScaAuthUser ID is found. +// Returns a *NotFoundError when no entities are found. +func (sauq *ScaAuthUserQuery) OnlyID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = sauq.Limit(2).IDs(setContextOp(ctx, sauq.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{scaauthuser.Label} + default: + err = &NotSingularError{scaauthuser.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (sauq *ScaAuthUserQuery) OnlyIDX(ctx context.Context) int64 { + id, err := sauq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of ScaAuthUsers. +func (sauq *ScaAuthUserQuery) All(ctx context.Context) ([]*ScaAuthUser, error) { + ctx = setContextOp(ctx, sauq.ctx, ent.OpQueryAll) + if err := sauq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*ScaAuthUser, *ScaAuthUserQuery]() + return withInterceptors[[]*ScaAuthUser](ctx, sauq, qr, sauq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (sauq *ScaAuthUserQuery) AllX(ctx context.Context) []*ScaAuthUser { + nodes, err := sauq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of ScaAuthUser IDs. +func (sauq *ScaAuthUserQuery) IDs(ctx context.Context) (ids []int64, err error) { + if sauq.ctx.Unique == nil && sauq.path != nil { + sauq.Unique(true) + } + ctx = setContextOp(ctx, sauq.ctx, ent.OpQueryIDs) + if err = sauq.Select(scaauthuser.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (sauq *ScaAuthUserQuery) IDsX(ctx context.Context) []int64 { + ids, err := sauq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (sauq *ScaAuthUserQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, sauq.ctx, ent.OpQueryCount) + if err := sauq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, sauq, querierCount[*ScaAuthUserQuery](), sauq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (sauq *ScaAuthUserQuery) CountX(ctx context.Context) int { + count, err := sauq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (sauq *ScaAuthUserQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, sauq.ctx, ent.OpQueryExist) + switch _, err := sauq.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 (sauq *ScaAuthUserQuery) ExistX(ctx context.Context) bool { + exist, err := sauq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the ScaAuthUserQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (sauq *ScaAuthUserQuery) Clone() *ScaAuthUserQuery { + if sauq == nil { + return nil + } + return &ScaAuthUserQuery{ + config: sauq.config, + ctx: sauq.ctx.Clone(), + order: append([]scaauthuser.OrderOption{}, sauq.order...), + inters: append([]Interceptor{}, sauq.inters...), + predicates: append([]predicate.ScaAuthUser{}, sauq.predicates...), + withScaAuthUserSocial: sauq.withScaAuthUserSocial.Clone(), + withScaAuthUserDevice: sauq.withScaAuthUserDevice.Clone(), + // clone intermediate query. + sql: sauq.sql.Clone(), + path: sauq.path, + } +} + +// WithScaAuthUserSocial tells the query-builder to eager-load the nodes that are connected to +// the "sca_auth_user_social" edge. The optional arguments are used to configure the query builder of the edge. +func (sauq *ScaAuthUserQuery) WithScaAuthUserSocial(opts ...func(*ScaAuthUserSocialQuery)) *ScaAuthUserQuery { + query := (&ScaAuthUserSocialClient{config: sauq.config}).Query() + for _, opt := range opts { + opt(query) + } + sauq.withScaAuthUserSocial = query + return sauq +} + +// WithScaAuthUserDevice tells the query-builder to eager-load the nodes that are connected to +// the "sca_auth_user_device" edge. The optional arguments are used to configure the query builder of the edge. +func (sauq *ScaAuthUserQuery) WithScaAuthUserDevice(opts ...func(*ScaAuthUserDeviceQuery)) *ScaAuthUserQuery { + query := (&ScaAuthUserDeviceClient{config: sauq.config}).Query() + for _, opt := range opts { + opt(query) + } + sauq.withScaAuthUserDevice = query + return sauq +} + +// 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 { +// UID string `json:"uid,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.ScaAuthUser.Query(). +// GroupBy(scaauthuser.FieldUID). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (sauq *ScaAuthUserQuery) GroupBy(field string, fields ...string) *ScaAuthUserGroupBy { + sauq.ctx.Fields = append([]string{field}, fields...) + grbuild := &ScaAuthUserGroupBy{build: sauq} + grbuild.flds = &sauq.ctx.Fields + grbuild.label = scaauthuser.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 { +// UID string `json:"uid,omitempty"` +// } +// +// client.ScaAuthUser.Query(). +// Select(scaauthuser.FieldUID). +// Scan(ctx, &v) +func (sauq *ScaAuthUserQuery) Select(fields ...string) *ScaAuthUserSelect { + sauq.ctx.Fields = append(sauq.ctx.Fields, fields...) + sbuild := &ScaAuthUserSelect{ScaAuthUserQuery: sauq} + sbuild.label = scaauthuser.Label + sbuild.flds, sbuild.scan = &sauq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a ScaAuthUserSelect configured with the given aggregations. +func (sauq *ScaAuthUserQuery) Aggregate(fns ...AggregateFunc) *ScaAuthUserSelect { + return sauq.Select().Aggregate(fns...) +} + +func (sauq *ScaAuthUserQuery) prepareQuery(ctx context.Context) error { + for _, inter := range sauq.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, sauq); err != nil { + return err + } + } + } + for _, f := range sauq.ctx.Fields { + if !scaauthuser.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if sauq.path != nil { + prev, err := sauq.path(ctx) + if err != nil { + return err + } + sauq.sql = prev + } + return nil +} + +func (sauq *ScaAuthUserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ScaAuthUser, error) { + var ( + nodes = []*ScaAuthUser{} + _spec = sauq.querySpec() + loadedTypes = [2]bool{ + sauq.withScaAuthUserSocial != nil, + sauq.withScaAuthUserDevice != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*ScaAuthUser).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &ScaAuthUser{config: sauq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, sauq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := sauq.withScaAuthUserSocial; query != nil { + if err := sauq.loadScaAuthUserSocial(ctx, query, nodes, + func(n *ScaAuthUser) { n.Edges.ScaAuthUserSocial = []*ScaAuthUserSocial{} }, + func(n *ScaAuthUser, e *ScaAuthUserSocial) { + n.Edges.ScaAuthUserSocial = append(n.Edges.ScaAuthUserSocial, e) + }); err != nil { + return nil, err + } + } + if query := sauq.withScaAuthUserDevice; query != nil { + if err := sauq.loadScaAuthUserDevice(ctx, query, nodes, + func(n *ScaAuthUser) { n.Edges.ScaAuthUserDevice = []*ScaAuthUserDevice{} }, + func(n *ScaAuthUser, e *ScaAuthUserDevice) { + n.Edges.ScaAuthUserDevice = append(n.Edges.ScaAuthUserDevice, e) + }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (sauq *ScaAuthUserQuery) loadScaAuthUserSocial(ctx context.Context, query *ScaAuthUserSocialQuery, nodes []*ScaAuthUser, init func(*ScaAuthUser), assign func(*ScaAuthUser, *ScaAuthUserSocial)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[int64]*ScaAuthUser) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + query.withFKs = true + query.Where(predicate.ScaAuthUserSocial(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(scaauthuser.ScaAuthUserSocialColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.sca_auth_user_sca_auth_user_social + if fk == nil { + return fmt.Errorf(`foreign-key "sca_auth_user_sca_auth_user_social" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "sca_auth_user_sca_auth_user_social" returned %v for node %v`, *fk, n.ID) + } + assign(node, n) + } + return nil +} +func (sauq *ScaAuthUserQuery) loadScaAuthUserDevice(ctx context.Context, query *ScaAuthUserDeviceQuery, nodes []*ScaAuthUser, init func(*ScaAuthUser), assign func(*ScaAuthUser, *ScaAuthUserDevice)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[int64]*ScaAuthUser) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + query.withFKs = true + query.Where(predicate.ScaAuthUserDevice(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(scaauthuser.ScaAuthUserDeviceColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.sca_auth_user_sca_auth_user_device + if fk == nil { + return fmt.Errorf(`foreign-key "sca_auth_user_sca_auth_user_device" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "sca_auth_user_sca_auth_user_device" returned %v for node %v`, *fk, n.ID) + } + assign(node, n) + } + return nil +} + +func (sauq *ScaAuthUserQuery) sqlCount(ctx context.Context) (int, error) { + _spec := sauq.querySpec() + _spec.Node.Columns = sauq.ctx.Fields + if len(sauq.ctx.Fields) > 0 { + _spec.Unique = sauq.ctx.Unique != nil && *sauq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, sauq.driver, _spec) +} + +func (sauq *ScaAuthUserQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(scaauthuser.Table, scaauthuser.Columns, sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64)) + _spec.From = sauq.sql + if unique := sauq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if sauq.path != nil { + _spec.Unique = true + } + if fields := sauq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, scaauthuser.FieldID) + for i := range fields { + if fields[i] != scaauthuser.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := sauq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := sauq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := sauq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := sauq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (sauq *ScaAuthUserQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(sauq.driver.Dialect()) + t1 := builder.Table(scaauthuser.Table) + columns := sauq.ctx.Fields + if len(columns) == 0 { + columns = scaauthuser.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if sauq.sql != nil { + selector = sauq.sql + selector.Select(selector.Columns(columns...)...) + } + if sauq.ctx.Unique != nil && *sauq.ctx.Unique { + selector.Distinct() + } + for _, p := range sauq.predicates { + p(selector) + } + for _, p := range sauq.order { + p(selector) + } + if offset := sauq.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 := sauq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// ScaAuthUserGroupBy is the group-by builder for ScaAuthUser entities. +type ScaAuthUserGroupBy struct { + selector + build *ScaAuthUserQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (saugb *ScaAuthUserGroupBy) Aggregate(fns ...AggregateFunc) *ScaAuthUserGroupBy { + saugb.fns = append(saugb.fns, fns...) + return saugb +} + +// Scan applies the selector query and scans the result into the given value. +func (saugb *ScaAuthUserGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, saugb.build.ctx, ent.OpQueryGroupBy) + if err := saugb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ScaAuthUserQuery, *ScaAuthUserGroupBy](ctx, saugb.build, saugb, saugb.build.inters, v) +} + +func (saugb *ScaAuthUserGroupBy) sqlScan(ctx context.Context, root *ScaAuthUserQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(saugb.fns)) + for _, fn := range saugb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*saugb.flds)+len(saugb.fns)) + for _, f := range *saugb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*saugb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := saugb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// ScaAuthUserSelect is the builder for selecting fields of ScaAuthUser entities. +type ScaAuthUserSelect struct { + *ScaAuthUserQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (saus *ScaAuthUserSelect) Aggregate(fns ...AggregateFunc) *ScaAuthUserSelect { + saus.fns = append(saus.fns, fns...) + return saus +} + +// Scan applies the selector query and scans the result into the given value. +func (saus *ScaAuthUserSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, saus.ctx, ent.OpQuerySelect) + if err := saus.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ScaAuthUserQuery, *ScaAuthUserSelect](ctx, saus.ScaAuthUserQuery, saus, saus.inters, v) +} + +func (saus *ScaAuthUserSelect) sqlScan(ctx context.Context, root *ScaAuthUserQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(saus.fns)) + for _, fn := range saus.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*saus.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 := saus.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/common/ent/scaauthuser_update.go b/common/ent/scaauthuser_update.go new file mode 100644 index 0000000..13065fd --- /dev/null +++ b/common/ent/scaauthuser_update.go @@ -0,0 +1,1414 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "schisandra-album-cloud-microservices/common/ent/predicate" + "schisandra-album-cloud-microservices/common/ent/scaauthuser" + "schisandra-album-cloud-microservices/common/ent/scaauthuserdevice" + "schisandra-album-cloud-microservices/common/ent/scaauthusersocial" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ScaAuthUserUpdate is the builder for updating ScaAuthUser entities. +type ScaAuthUserUpdate struct { + config + hooks []Hook + mutation *ScaAuthUserMutation +} + +// Where appends a list predicates to the ScaAuthUserUpdate builder. +func (sauu *ScaAuthUserUpdate) Where(ps ...predicate.ScaAuthUser) *ScaAuthUserUpdate { + sauu.mutation.Where(ps...) + return sauu +} + +// SetUID sets the "uid" field. +func (sauu *ScaAuthUserUpdate) SetUID(s string) *ScaAuthUserUpdate { + sauu.mutation.SetUID(s) + return sauu +} + +// SetNillableUID sets the "uid" field if the given value is not nil. +func (sauu *ScaAuthUserUpdate) SetNillableUID(s *string) *ScaAuthUserUpdate { + if s != nil { + sauu.SetUID(*s) + } + return sauu +} + +// SetUsername sets the "username" field. +func (sauu *ScaAuthUserUpdate) SetUsername(s string) *ScaAuthUserUpdate { + sauu.mutation.SetUsername(s) + return sauu +} + +// SetNillableUsername sets the "username" field if the given value is not nil. +func (sauu *ScaAuthUserUpdate) SetNillableUsername(s *string) *ScaAuthUserUpdate { + if s != nil { + sauu.SetUsername(*s) + } + return sauu +} + +// ClearUsername clears the value of the "username" field. +func (sauu *ScaAuthUserUpdate) ClearUsername() *ScaAuthUserUpdate { + sauu.mutation.ClearUsername() + return sauu +} + +// SetNickname sets the "nickname" field. +func (sauu *ScaAuthUserUpdate) SetNickname(s string) *ScaAuthUserUpdate { + sauu.mutation.SetNickname(s) + return sauu +} + +// SetNillableNickname sets the "nickname" field if the given value is not nil. +func (sauu *ScaAuthUserUpdate) SetNillableNickname(s *string) *ScaAuthUserUpdate { + if s != nil { + sauu.SetNickname(*s) + } + return sauu +} + +// ClearNickname clears the value of the "nickname" field. +func (sauu *ScaAuthUserUpdate) ClearNickname() *ScaAuthUserUpdate { + sauu.mutation.ClearNickname() + return sauu +} + +// SetEmail sets the "email" field. +func (sauu *ScaAuthUserUpdate) SetEmail(s string) *ScaAuthUserUpdate { + sauu.mutation.SetEmail(s) + return sauu +} + +// SetNillableEmail sets the "email" field if the given value is not nil. +func (sauu *ScaAuthUserUpdate) SetNillableEmail(s *string) *ScaAuthUserUpdate { + if s != nil { + sauu.SetEmail(*s) + } + return sauu +} + +// ClearEmail clears the value of the "email" field. +func (sauu *ScaAuthUserUpdate) ClearEmail() *ScaAuthUserUpdate { + sauu.mutation.ClearEmail() + return sauu +} + +// SetPhone sets the "phone" field. +func (sauu *ScaAuthUserUpdate) SetPhone(s string) *ScaAuthUserUpdate { + sauu.mutation.SetPhone(s) + return sauu +} + +// SetNillablePhone sets the "phone" field if the given value is not nil. +func (sauu *ScaAuthUserUpdate) SetNillablePhone(s *string) *ScaAuthUserUpdate { + if s != nil { + sauu.SetPhone(*s) + } + return sauu +} + +// ClearPhone clears the value of the "phone" field. +func (sauu *ScaAuthUserUpdate) ClearPhone() *ScaAuthUserUpdate { + sauu.mutation.ClearPhone() + return sauu +} + +// SetPassword sets the "password" field. +func (sauu *ScaAuthUserUpdate) SetPassword(s string) *ScaAuthUserUpdate { + sauu.mutation.SetPassword(s) + return sauu +} + +// SetNillablePassword sets the "password" field if the given value is not nil. +func (sauu *ScaAuthUserUpdate) SetNillablePassword(s *string) *ScaAuthUserUpdate { + if s != nil { + sauu.SetPassword(*s) + } + return sauu +} + +// ClearPassword clears the value of the "password" field. +func (sauu *ScaAuthUserUpdate) ClearPassword() *ScaAuthUserUpdate { + sauu.mutation.ClearPassword() + return sauu +} + +// SetGender sets the "gender" field. +func (sauu *ScaAuthUserUpdate) SetGender(s string) *ScaAuthUserUpdate { + sauu.mutation.SetGender(s) + return sauu +} + +// SetNillableGender sets the "gender" field if the given value is not nil. +func (sauu *ScaAuthUserUpdate) SetNillableGender(s *string) *ScaAuthUserUpdate { + if s != nil { + sauu.SetGender(*s) + } + return sauu +} + +// ClearGender clears the value of the "gender" field. +func (sauu *ScaAuthUserUpdate) ClearGender() *ScaAuthUserUpdate { + sauu.mutation.ClearGender() + return sauu +} + +// SetAvatar sets the "avatar" field. +func (sauu *ScaAuthUserUpdate) SetAvatar(s string) *ScaAuthUserUpdate { + sauu.mutation.SetAvatar(s) + return sauu +} + +// SetNillableAvatar sets the "avatar" field if the given value is not nil. +func (sauu *ScaAuthUserUpdate) SetNillableAvatar(s *string) *ScaAuthUserUpdate { + if s != nil { + sauu.SetAvatar(*s) + } + return sauu +} + +// ClearAvatar clears the value of the "avatar" field. +func (sauu *ScaAuthUserUpdate) ClearAvatar() *ScaAuthUserUpdate { + sauu.mutation.ClearAvatar() + return sauu +} + +// SetStatus sets the "status" field. +func (sauu *ScaAuthUserUpdate) SetStatus(i int8) *ScaAuthUserUpdate { + sauu.mutation.ResetStatus() + sauu.mutation.SetStatus(i) + return sauu +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (sauu *ScaAuthUserUpdate) SetNillableStatus(i *int8) *ScaAuthUserUpdate { + if i != nil { + sauu.SetStatus(*i) + } + return sauu +} + +// AddStatus adds i to the "status" field. +func (sauu *ScaAuthUserUpdate) AddStatus(i int8) *ScaAuthUserUpdate { + sauu.mutation.AddStatus(i) + return sauu +} + +// ClearStatus clears the value of the "status" field. +func (sauu *ScaAuthUserUpdate) ClearStatus() *ScaAuthUserUpdate { + sauu.mutation.ClearStatus() + return sauu +} + +// SetIntroduce sets the "introduce" field. +func (sauu *ScaAuthUserUpdate) SetIntroduce(s string) *ScaAuthUserUpdate { + sauu.mutation.SetIntroduce(s) + return sauu +} + +// SetNillableIntroduce sets the "introduce" field if the given value is not nil. +func (sauu *ScaAuthUserUpdate) SetNillableIntroduce(s *string) *ScaAuthUserUpdate { + if s != nil { + sauu.SetIntroduce(*s) + } + return sauu +} + +// ClearIntroduce clears the value of the "introduce" field. +func (sauu *ScaAuthUserUpdate) ClearIntroduce() *ScaAuthUserUpdate { + sauu.mutation.ClearIntroduce() + return sauu +} + +// SetUpdateAt sets the "update_at" field. +func (sauu *ScaAuthUserUpdate) SetUpdateAt(t time.Time) *ScaAuthUserUpdate { + sauu.mutation.SetUpdateAt(t) + return sauu +} + +// ClearUpdateAt clears the value of the "update_at" field. +func (sauu *ScaAuthUserUpdate) ClearUpdateAt() *ScaAuthUserUpdate { + sauu.mutation.ClearUpdateAt() + return sauu +} + +// SetDeleted sets the "deleted" field. +func (sauu *ScaAuthUserUpdate) SetDeleted(i int8) *ScaAuthUserUpdate { + sauu.mutation.ResetDeleted() + sauu.mutation.SetDeleted(i) + return sauu +} + +// SetNillableDeleted sets the "deleted" field if the given value is not nil. +func (sauu *ScaAuthUserUpdate) SetNillableDeleted(i *int8) *ScaAuthUserUpdate { + if i != nil { + sauu.SetDeleted(*i) + } + return sauu +} + +// AddDeleted adds i to the "deleted" field. +func (sauu *ScaAuthUserUpdate) AddDeleted(i int8) *ScaAuthUserUpdate { + sauu.mutation.AddDeleted(i) + return sauu +} + +// SetBlog sets the "blog" field. +func (sauu *ScaAuthUserUpdate) SetBlog(s string) *ScaAuthUserUpdate { + sauu.mutation.SetBlog(s) + return sauu +} + +// SetNillableBlog sets the "blog" field if the given value is not nil. +func (sauu *ScaAuthUserUpdate) SetNillableBlog(s *string) *ScaAuthUserUpdate { + if s != nil { + sauu.SetBlog(*s) + } + return sauu +} + +// ClearBlog clears the value of the "blog" field. +func (sauu *ScaAuthUserUpdate) ClearBlog() *ScaAuthUserUpdate { + sauu.mutation.ClearBlog() + return sauu +} + +// SetLocation sets the "location" field. +func (sauu *ScaAuthUserUpdate) SetLocation(s string) *ScaAuthUserUpdate { + sauu.mutation.SetLocation(s) + return sauu +} + +// SetNillableLocation sets the "location" field if the given value is not nil. +func (sauu *ScaAuthUserUpdate) SetNillableLocation(s *string) *ScaAuthUserUpdate { + if s != nil { + sauu.SetLocation(*s) + } + return sauu +} + +// ClearLocation clears the value of the "location" field. +func (sauu *ScaAuthUserUpdate) ClearLocation() *ScaAuthUserUpdate { + sauu.mutation.ClearLocation() + return sauu +} + +// SetCompany sets the "company" field. +func (sauu *ScaAuthUserUpdate) SetCompany(s string) *ScaAuthUserUpdate { + sauu.mutation.SetCompany(s) + return sauu +} + +// SetNillableCompany sets the "company" field if the given value is not nil. +func (sauu *ScaAuthUserUpdate) SetNillableCompany(s *string) *ScaAuthUserUpdate { + if s != nil { + sauu.SetCompany(*s) + } + return sauu +} + +// ClearCompany clears the value of the "company" field. +func (sauu *ScaAuthUserUpdate) ClearCompany() *ScaAuthUserUpdate { + sauu.mutation.ClearCompany() + return sauu +} + +// AddScaAuthUserSocialIDs adds the "sca_auth_user_social" edge to the ScaAuthUserSocial entity by IDs. +func (sauu *ScaAuthUserUpdate) AddScaAuthUserSocialIDs(ids ...int64) *ScaAuthUserUpdate { + sauu.mutation.AddScaAuthUserSocialIDs(ids...) + return sauu +} + +// AddScaAuthUserSocial adds the "sca_auth_user_social" edges to the ScaAuthUserSocial entity. +func (sauu *ScaAuthUserUpdate) AddScaAuthUserSocial(s ...*ScaAuthUserSocial) *ScaAuthUserUpdate { + ids := make([]int64, len(s)) + for i := range s { + ids[i] = s[i].ID + } + return sauu.AddScaAuthUserSocialIDs(ids...) +} + +// AddScaAuthUserDeviceIDs adds the "sca_auth_user_device" edge to the ScaAuthUserDevice entity by IDs. +func (sauu *ScaAuthUserUpdate) AddScaAuthUserDeviceIDs(ids ...int64) *ScaAuthUserUpdate { + sauu.mutation.AddScaAuthUserDeviceIDs(ids...) + return sauu +} + +// AddScaAuthUserDevice adds the "sca_auth_user_device" edges to the ScaAuthUserDevice entity. +func (sauu *ScaAuthUserUpdate) AddScaAuthUserDevice(s ...*ScaAuthUserDevice) *ScaAuthUserUpdate { + ids := make([]int64, len(s)) + for i := range s { + ids[i] = s[i].ID + } + return sauu.AddScaAuthUserDeviceIDs(ids...) +} + +// Mutation returns the ScaAuthUserMutation object of the builder. +func (sauu *ScaAuthUserUpdate) Mutation() *ScaAuthUserMutation { + return sauu.mutation +} + +// ClearScaAuthUserSocial clears all "sca_auth_user_social" edges to the ScaAuthUserSocial entity. +func (sauu *ScaAuthUserUpdate) ClearScaAuthUserSocial() *ScaAuthUserUpdate { + sauu.mutation.ClearScaAuthUserSocial() + return sauu +} + +// RemoveScaAuthUserSocialIDs removes the "sca_auth_user_social" edge to ScaAuthUserSocial entities by IDs. +func (sauu *ScaAuthUserUpdate) RemoveScaAuthUserSocialIDs(ids ...int64) *ScaAuthUserUpdate { + sauu.mutation.RemoveScaAuthUserSocialIDs(ids...) + return sauu +} + +// RemoveScaAuthUserSocial removes "sca_auth_user_social" edges to ScaAuthUserSocial entities. +func (sauu *ScaAuthUserUpdate) RemoveScaAuthUserSocial(s ...*ScaAuthUserSocial) *ScaAuthUserUpdate { + ids := make([]int64, len(s)) + for i := range s { + ids[i] = s[i].ID + } + return sauu.RemoveScaAuthUserSocialIDs(ids...) +} + +// ClearScaAuthUserDevice clears all "sca_auth_user_device" edges to the ScaAuthUserDevice entity. +func (sauu *ScaAuthUserUpdate) ClearScaAuthUserDevice() *ScaAuthUserUpdate { + sauu.mutation.ClearScaAuthUserDevice() + return sauu +} + +// RemoveScaAuthUserDeviceIDs removes the "sca_auth_user_device" edge to ScaAuthUserDevice entities by IDs. +func (sauu *ScaAuthUserUpdate) RemoveScaAuthUserDeviceIDs(ids ...int64) *ScaAuthUserUpdate { + sauu.mutation.RemoveScaAuthUserDeviceIDs(ids...) + return sauu +} + +// RemoveScaAuthUserDevice removes "sca_auth_user_device" edges to ScaAuthUserDevice entities. +func (sauu *ScaAuthUserUpdate) RemoveScaAuthUserDevice(s ...*ScaAuthUserDevice) *ScaAuthUserUpdate { + ids := make([]int64, len(s)) + for i := range s { + ids[i] = s[i].ID + } + return sauu.RemoveScaAuthUserDeviceIDs(ids...) +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (sauu *ScaAuthUserUpdate) Save(ctx context.Context) (int, error) { + sauu.defaults() + return withHooks(ctx, sauu.sqlSave, sauu.mutation, sauu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (sauu *ScaAuthUserUpdate) SaveX(ctx context.Context) int { + affected, err := sauu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (sauu *ScaAuthUserUpdate) Exec(ctx context.Context) error { + _, err := sauu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (sauu *ScaAuthUserUpdate) ExecX(ctx context.Context) { + if err := sauu.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (sauu *ScaAuthUserUpdate) defaults() { + if _, ok := sauu.mutation.UpdateAt(); !ok && !sauu.mutation.UpdateAtCleared() { + v := scaauthuser.UpdateDefaultUpdateAt() + sauu.mutation.SetUpdateAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (sauu *ScaAuthUserUpdate) check() error { + if v, ok := sauu.mutation.UID(); ok { + if err := scaauthuser.UIDValidator(v); err != nil { + return &ValidationError{Name: "uid", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.uid": %w`, err)} + } + } + if v, ok := sauu.mutation.Username(); ok { + if err := scaauthuser.UsernameValidator(v); err != nil { + return &ValidationError{Name: "username", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.username": %w`, err)} + } + } + if v, ok := sauu.mutation.Nickname(); ok { + if err := scaauthuser.NicknameValidator(v); err != nil { + return &ValidationError{Name: "nickname", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.nickname": %w`, err)} + } + } + if v, ok := sauu.mutation.Email(); ok { + if err := scaauthuser.EmailValidator(v); err != nil { + return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.email": %w`, err)} + } + } + if v, ok := sauu.mutation.Phone(); ok { + if err := scaauthuser.PhoneValidator(v); err != nil { + return &ValidationError{Name: "phone", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.phone": %w`, err)} + } + } + if v, ok := sauu.mutation.Password(); ok { + if err := scaauthuser.PasswordValidator(v); err != nil { + return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.password": %w`, err)} + } + } + if v, ok := sauu.mutation.Gender(); ok { + if err := scaauthuser.GenderValidator(v); err != nil { + return &ValidationError{Name: "gender", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.gender": %w`, err)} + } + } + if v, ok := sauu.mutation.Introduce(); ok { + if err := scaauthuser.IntroduceValidator(v); err != nil { + return &ValidationError{Name: "introduce", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.introduce": %w`, err)} + } + } + if v, ok := sauu.mutation.Blog(); ok { + if err := scaauthuser.BlogValidator(v); err != nil { + return &ValidationError{Name: "blog", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.blog": %w`, err)} + } + } + if v, ok := sauu.mutation.Location(); ok { + if err := scaauthuser.LocationValidator(v); err != nil { + return &ValidationError{Name: "location", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.location": %w`, err)} + } + } + if v, ok := sauu.mutation.Company(); ok { + if err := scaauthuser.CompanyValidator(v); err != nil { + return &ValidationError{Name: "company", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.company": %w`, err)} + } + } + return nil +} + +func (sauu *ScaAuthUserUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := sauu.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(scaauthuser.Table, scaauthuser.Columns, sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64)) + if ps := sauu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := sauu.mutation.UID(); ok { + _spec.SetField(scaauthuser.FieldUID, field.TypeString, value) + } + if value, ok := sauu.mutation.Username(); ok { + _spec.SetField(scaauthuser.FieldUsername, field.TypeString, value) + } + if sauu.mutation.UsernameCleared() { + _spec.ClearField(scaauthuser.FieldUsername, field.TypeString) + } + if value, ok := sauu.mutation.Nickname(); ok { + _spec.SetField(scaauthuser.FieldNickname, field.TypeString, value) + } + if sauu.mutation.NicknameCleared() { + _spec.ClearField(scaauthuser.FieldNickname, field.TypeString) + } + if value, ok := sauu.mutation.Email(); ok { + _spec.SetField(scaauthuser.FieldEmail, field.TypeString, value) + } + if sauu.mutation.EmailCleared() { + _spec.ClearField(scaauthuser.FieldEmail, field.TypeString) + } + if value, ok := sauu.mutation.Phone(); ok { + _spec.SetField(scaauthuser.FieldPhone, field.TypeString, value) + } + if sauu.mutation.PhoneCleared() { + _spec.ClearField(scaauthuser.FieldPhone, field.TypeString) + } + if value, ok := sauu.mutation.Password(); ok { + _spec.SetField(scaauthuser.FieldPassword, field.TypeString, value) + } + if sauu.mutation.PasswordCleared() { + _spec.ClearField(scaauthuser.FieldPassword, field.TypeString) + } + if value, ok := sauu.mutation.Gender(); ok { + _spec.SetField(scaauthuser.FieldGender, field.TypeString, value) + } + if sauu.mutation.GenderCleared() { + _spec.ClearField(scaauthuser.FieldGender, field.TypeString) + } + if value, ok := sauu.mutation.Avatar(); ok { + _spec.SetField(scaauthuser.FieldAvatar, field.TypeString, value) + } + if sauu.mutation.AvatarCleared() { + _spec.ClearField(scaauthuser.FieldAvatar, field.TypeString) + } + if value, ok := sauu.mutation.Status(); ok { + _spec.SetField(scaauthuser.FieldStatus, field.TypeInt8, value) + } + if value, ok := sauu.mutation.AddedStatus(); ok { + _spec.AddField(scaauthuser.FieldStatus, field.TypeInt8, value) + } + if sauu.mutation.StatusCleared() { + _spec.ClearField(scaauthuser.FieldStatus, field.TypeInt8) + } + if value, ok := sauu.mutation.Introduce(); ok { + _spec.SetField(scaauthuser.FieldIntroduce, field.TypeString, value) + } + if sauu.mutation.IntroduceCleared() { + _spec.ClearField(scaauthuser.FieldIntroduce, field.TypeString) + } + if value, ok := sauu.mutation.UpdateAt(); ok { + _spec.SetField(scaauthuser.FieldUpdateAt, field.TypeTime, value) + } + if sauu.mutation.UpdateAtCleared() { + _spec.ClearField(scaauthuser.FieldUpdateAt, field.TypeTime) + } + if value, ok := sauu.mutation.Deleted(); ok { + _spec.SetField(scaauthuser.FieldDeleted, field.TypeInt8, value) + } + if value, ok := sauu.mutation.AddedDeleted(); ok { + _spec.AddField(scaauthuser.FieldDeleted, field.TypeInt8, value) + } + if value, ok := sauu.mutation.Blog(); ok { + _spec.SetField(scaauthuser.FieldBlog, field.TypeString, value) + } + if sauu.mutation.BlogCleared() { + _spec.ClearField(scaauthuser.FieldBlog, field.TypeString) + } + if value, ok := sauu.mutation.Location(); ok { + _spec.SetField(scaauthuser.FieldLocation, field.TypeString, value) + } + if sauu.mutation.LocationCleared() { + _spec.ClearField(scaauthuser.FieldLocation, field.TypeString) + } + if value, ok := sauu.mutation.Company(); ok { + _spec.SetField(scaauthuser.FieldCompany, field.TypeString, value) + } + if sauu.mutation.CompanyCleared() { + _spec.ClearField(scaauthuser.FieldCompany, field.TypeString) + } + if sauu.mutation.ScaAuthUserSocialCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: scaauthuser.ScaAuthUserSocialTable, + Columns: []string{scaauthuser.ScaAuthUserSocialColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := sauu.mutation.RemovedScaAuthUserSocialIDs(); len(nodes) > 0 && !sauu.mutation.ScaAuthUserSocialCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: scaauthuser.ScaAuthUserSocialTable, + Columns: []string{scaauthuser.ScaAuthUserSocialColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := sauu.mutation.ScaAuthUserSocialIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: scaauthuser.ScaAuthUserSocialTable, + Columns: []string{scaauthuser.ScaAuthUserSocialColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if sauu.mutation.ScaAuthUserDeviceCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: scaauthuser.ScaAuthUserDeviceTable, + Columns: []string{scaauthuser.ScaAuthUserDeviceColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(scaauthuserdevice.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := sauu.mutation.RemovedScaAuthUserDeviceIDs(); len(nodes) > 0 && !sauu.mutation.ScaAuthUserDeviceCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: scaauthuser.ScaAuthUserDeviceTable, + Columns: []string{scaauthuser.ScaAuthUserDeviceColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(scaauthuserdevice.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := sauu.mutation.ScaAuthUserDeviceIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: scaauthuser.ScaAuthUserDeviceTable, + Columns: []string{scaauthuser.ScaAuthUserDeviceColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(scaauthuserdevice.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if n, err = sqlgraph.UpdateNodes(ctx, sauu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{scaauthuser.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + sauu.mutation.done = true + return n, nil +} + +// ScaAuthUserUpdateOne is the builder for updating a single ScaAuthUser entity. +type ScaAuthUserUpdateOne struct { + config + fields []string + hooks []Hook + mutation *ScaAuthUserMutation +} + +// SetUID sets the "uid" field. +func (sauuo *ScaAuthUserUpdateOne) SetUID(s string) *ScaAuthUserUpdateOne { + sauuo.mutation.SetUID(s) + return sauuo +} + +// SetNillableUID sets the "uid" field if the given value is not nil. +func (sauuo *ScaAuthUserUpdateOne) SetNillableUID(s *string) *ScaAuthUserUpdateOne { + if s != nil { + sauuo.SetUID(*s) + } + return sauuo +} + +// SetUsername sets the "username" field. +func (sauuo *ScaAuthUserUpdateOne) SetUsername(s string) *ScaAuthUserUpdateOne { + sauuo.mutation.SetUsername(s) + return sauuo +} + +// SetNillableUsername sets the "username" field if the given value is not nil. +func (sauuo *ScaAuthUserUpdateOne) SetNillableUsername(s *string) *ScaAuthUserUpdateOne { + if s != nil { + sauuo.SetUsername(*s) + } + return sauuo +} + +// ClearUsername clears the value of the "username" field. +func (sauuo *ScaAuthUserUpdateOne) ClearUsername() *ScaAuthUserUpdateOne { + sauuo.mutation.ClearUsername() + return sauuo +} + +// SetNickname sets the "nickname" field. +func (sauuo *ScaAuthUserUpdateOne) SetNickname(s string) *ScaAuthUserUpdateOne { + sauuo.mutation.SetNickname(s) + return sauuo +} + +// SetNillableNickname sets the "nickname" field if the given value is not nil. +func (sauuo *ScaAuthUserUpdateOne) SetNillableNickname(s *string) *ScaAuthUserUpdateOne { + if s != nil { + sauuo.SetNickname(*s) + } + return sauuo +} + +// ClearNickname clears the value of the "nickname" field. +func (sauuo *ScaAuthUserUpdateOne) ClearNickname() *ScaAuthUserUpdateOne { + sauuo.mutation.ClearNickname() + return sauuo +} + +// SetEmail sets the "email" field. +func (sauuo *ScaAuthUserUpdateOne) SetEmail(s string) *ScaAuthUserUpdateOne { + sauuo.mutation.SetEmail(s) + return sauuo +} + +// SetNillableEmail sets the "email" field if the given value is not nil. +func (sauuo *ScaAuthUserUpdateOne) SetNillableEmail(s *string) *ScaAuthUserUpdateOne { + if s != nil { + sauuo.SetEmail(*s) + } + return sauuo +} + +// ClearEmail clears the value of the "email" field. +func (sauuo *ScaAuthUserUpdateOne) ClearEmail() *ScaAuthUserUpdateOne { + sauuo.mutation.ClearEmail() + return sauuo +} + +// SetPhone sets the "phone" field. +func (sauuo *ScaAuthUserUpdateOne) SetPhone(s string) *ScaAuthUserUpdateOne { + sauuo.mutation.SetPhone(s) + return sauuo +} + +// SetNillablePhone sets the "phone" field if the given value is not nil. +func (sauuo *ScaAuthUserUpdateOne) SetNillablePhone(s *string) *ScaAuthUserUpdateOne { + if s != nil { + sauuo.SetPhone(*s) + } + return sauuo +} + +// ClearPhone clears the value of the "phone" field. +func (sauuo *ScaAuthUserUpdateOne) ClearPhone() *ScaAuthUserUpdateOne { + sauuo.mutation.ClearPhone() + return sauuo +} + +// SetPassword sets the "password" field. +func (sauuo *ScaAuthUserUpdateOne) SetPassword(s string) *ScaAuthUserUpdateOne { + sauuo.mutation.SetPassword(s) + return sauuo +} + +// SetNillablePassword sets the "password" field if the given value is not nil. +func (sauuo *ScaAuthUserUpdateOne) SetNillablePassword(s *string) *ScaAuthUserUpdateOne { + if s != nil { + sauuo.SetPassword(*s) + } + return sauuo +} + +// ClearPassword clears the value of the "password" field. +func (sauuo *ScaAuthUserUpdateOne) ClearPassword() *ScaAuthUserUpdateOne { + sauuo.mutation.ClearPassword() + return sauuo +} + +// SetGender sets the "gender" field. +func (sauuo *ScaAuthUserUpdateOne) SetGender(s string) *ScaAuthUserUpdateOne { + sauuo.mutation.SetGender(s) + return sauuo +} + +// SetNillableGender sets the "gender" field if the given value is not nil. +func (sauuo *ScaAuthUserUpdateOne) SetNillableGender(s *string) *ScaAuthUserUpdateOne { + if s != nil { + sauuo.SetGender(*s) + } + return sauuo +} + +// ClearGender clears the value of the "gender" field. +func (sauuo *ScaAuthUserUpdateOne) ClearGender() *ScaAuthUserUpdateOne { + sauuo.mutation.ClearGender() + return sauuo +} + +// SetAvatar sets the "avatar" field. +func (sauuo *ScaAuthUserUpdateOne) SetAvatar(s string) *ScaAuthUserUpdateOne { + sauuo.mutation.SetAvatar(s) + return sauuo +} + +// SetNillableAvatar sets the "avatar" field if the given value is not nil. +func (sauuo *ScaAuthUserUpdateOne) SetNillableAvatar(s *string) *ScaAuthUserUpdateOne { + if s != nil { + sauuo.SetAvatar(*s) + } + return sauuo +} + +// ClearAvatar clears the value of the "avatar" field. +func (sauuo *ScaAuthUserUpdateOne) ClearAvatar() *ScaAuthUserUpdateOne { + sauuo.mutation.ClearAvatar() + return sauuo +} + +// SetStatus sets the "status" field. +func (sauuo *ScaAuthUserUpdateOne) SetStatus(i int8) *ScaAuthUserUpdateOne { + sauuo.mutation.ResetStatus() + sauuo.mutation.SetStatus(i) + return sauuo +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (sauuo *ScaAuthUserUpdateOne) SetNillableStatus(i *int8) *ScaAuthUserUpdateOne { + if i != nil { + sauuo.SetStatus(*i) + } + return sauuo +} + +// AddStatus adds i to the "status" field. +func (sauuo *ScaAuthUserUpdateOne) AddStatus(i int8) *ScaAuthUserUpdateOne { + sauuo.mutation.AddStatus(i) + return sauuo +} + +// ClearStatus clears the value of the "status" field. +func (sauuo *ScaAuthUserUpdateOne) ClearStatus() *ScaAuthUserUpdateOne { + sauuo.mutation.ClearStatus() + return sauuo +} + +// SetIntroduce sets the "introduce" field. +func (sauuo *ScaAuthUserUpdateOne) SetIntroduce(s string) *ScaAuthUserUpdateOne { + sauuo.mutation.SetIntroduce(s) + return sauuo +} + +// SetNillableIntroduce sets the "introduce" field if the given value is not nil. +func (sauuo *ScaAuthUserUpdateOne) SetNillableIntroduce(s *string) *ScaAuthUserUpdateOne { + if s != nil { + sauuo.SetIntroduce(*s) + } + return sauuo +} + +// ClearIntroduce clears the value of the "introduce" field. +func (sauuo *ScaAuthUserUpdateOne) ClearIntroduce() *ScaAuthUserUpdateOne { + sauuo.mutation.ClearIntroduce() + return sauuo +} + +// SetUpdateAt sets the "update_at" field. +func (sauuo *ScaAuthUserUpdateOne) SetUpdateAt(t time.Time) *ScaAuthUserUpdateOne { + sauuo.mutation.SetUpdateAt(t) + return sauuo +} + +// ClearUpdateAt clears the value of the "update_at" field. +func (sauuo *ScaAuthUserUpdateOne) ClearUpdateAt() *ScaAuthUserUpdateOne { + sauuo.mutation.ClearUpdateAt() + return sauuo +} + +// SetDeleted sets the "deleted" field. +func (sauuo *ScaAuthUserUpdateOne) SetDeleted(i int8) *ScaAuthUserUpdateOne { + sauuo.mutation.ResetDeleted() + sauuo.mutation.SetDeleted(i) + return sauuo +} + +// SetNillableDeleted sets the "deleted" field if the given value is not nil. +func (sauuo *ScaAuthUserUpdateOne) SetNillableDeleted(i *int8) *ScaAuthUserUpdateOne { + if i != nil { + sauuo.SetDeleted(*i) + } + return sauuo +} + +// AddDeleted adds i to the "deleted" field. +func (sauuo *ScaAuthUserUpdateOne) AddDeleted(i int8) *ScaAuthUserUpdateOne { + sauuo.mutation.AddDeleted(i) + return sauuo +} + +// SetBlog sets the "blog" field. +func (sauuo *ScaAuthUserUpdateOne) SetBlog(s string) *ScaAuthUserUpdateOne { + sauuo.mutation.SetBlog(s) + return sauuo +} + +// SetNillableBlog sets the "blog" field if the given value is not nil. +func (sauuo *ScaAuthUserUpdateOne) SetNillableBlog(s *string) *ScaAuthUserUpdateOne { + if s != nil { + sauuo.SetBlog(*s) + } + return sauuo +} + +// ClearBlog clears the value of the "blog" field. +func (sauuo *ScaAuthUserUpdateOne) ClearBlog() *ScaAuthUserUpdateOne { + sauuo.mutation.ClearBlog() + return sauuo +} + +// SetLocation sets the "location" field. +func (sauuo *ScaAuthUserUpdateOne) SetLocation(s string) *ScaAuthUserUpdateOne { + sauuo.mutation.SetLocation(s) + return sauuo +} + +// SetNillableLocation sets the "location" field if the given value is not nil. +func (sauuo *ScaAuthUserUpdateOne) SetNillableLocation(s *string) *ScaAuthUserUpdateOne { + if s != nil { + sauuo.SetLocation(*s) + } + return sauuo +} + +// ClearLocation clears the value of the "location" field. +func (sauuo *ScaAuthUserUpdateOne) ClearLocation() *ScaAuthUserUpdateOne { + sauuo.mutation.ClearLocation() + return sauuo +} + +// SetCompany sets the "company" field. +func (sauuo *ScaAuthUserUpdateOne) SetCompany(s string) *ScaAuthUserUpdateOne { + sauuo.mutation.SetCompany(s) + return sauuo +} + +// SetNillableCompany sets the "company" field if the given value is not nil. +func (sauuo *ScaAuthUserUpdateOne) SetNillableCompany(s *string) *ScaAuthUserUpdateOne { + if s != nil { + sauuo.SetCompany(*s) + } + return sauuo +} + +// ClearCompany clears the value of the "company" field. +func (sauuo *ScaAuthUserUpdateOne) ClearCompany() *ScaAuthUserUpdateOne { + sauuo.mutation.ClearCompany() + return sauuo +} + +// AddScaAuthUserSocialIDs adds the "sca_auth_user_social" edge to the ScaAuthUserSocial entity by IDs. +func (sauuo *ScaAuthUserUpdateOne) AddScaAuthUserSocialIDs(ids ...int64) *ScaAuthUserUpdateOne { + sauuo.mutation.AddScaAuthUserSocialIDs(ids...) + return sauuo +} + +// AddScaAuthUserSocial adds the "sca_auth_user_social" edges to the ScaAuthUserSocial entity. +func (sauuo *ScaAuthUserUpdateOne) AddScaAuthUserSocial(s ...*ScaAuthUserSocial) *ScaAuthUserUpdateOne { + ids := make([]int64, len(s)) + for i := range s { + ids[i] = s[i].ID + } + return sauuo.AddScaAuthUserSocialIDs(ids...) +} + +// AddScaAuthUserDeviceIDs adds the "sca_auth_user_device" edge to the ScaAuthUserDevice entity by IDs. +func (sauuo *ScaAuthUserUpdateOne) AddScaAuthUserDeviceIDs(ids ...int64) *ScaAuthUserUpdateOne { + sauuo.mutation.AddScaAuthUserDeviceIDs(ids...) + return sauuo +} + +// AddScaAuthUserDevice adds the "sca_auth_user_device" edges to the ScaAuthUserDevice entity. +func (sauuo *ScaAuthUserUpdateOne) AddScaAuthUserDevice(s ...*ScaAuthUserDevice) *ScaAuthUserUpdateOne { + ids := make([]int64, len(s)) + for i := range s { + ids[i] = s[i].ID + } + return sauuo.AddScaAuthUserDeviceIDs(ids...) +} + +// Mutation returns the ScaAuthUserMutation object of the builder. +func (sauuo *ScaAuthUserUpdateOne) Mutation() *ScaAuthUserMutation { + return sauuo.mutation +} + +// ClearScaAuthUserSocial clears all "sca_auth_user_social" edges to the ScaAuthUserSocial entity. +func (sauuo *ScaAuthUserUpdateOne) ClearScaAuthUserSocial() *ScaAuthUserUpdateOne { + sauuo.mutation.ClearScaAuthUserSocial() + return sauuo +} + +// RemoveScaAuthUserSocialIDs removes the "sca_auth_user_social" edge to ScaAuthUserSocial entities by IDs. +func (sauuo *ScaAuthUserUpdateOne) RemoveScaAuthUserSocialIDs(ids ...int64) *ScaAuthUserUpdateOne { + sauuo.mutation.RemoveScaAuthUserSocialIDs(ids...) + return sauuo +} + +// RemoveScaAuthUserSocial removes "sca_auth_user_social" edges to ScaAuthUserSocial entities. +func (sauuo *ScaAuthUserUpdateOne) RemoveScaAuthUserSocial(s ...*ScaAuthUserSocial) *ScaAuthUserUpdateOne { + ids := make([]int64, len(s)) + for i := range s { + ids[i] = s[i].ID + } + return sauuo.RemoveScaAuthUserSocialIDs(ids...) +} + +// ClearScaAuthUserDevice clears all "sca_auth_user_device" edges to the ScaAuthUserDevice entity. +func (sauuo *ScaAuthUserUpdateOne) ClearScaAuthUserDevice() *ScaAuthUserUpdateOne { + sauuo.mutation.ClearScaAuthUserDevice() + return sauuo +} + +// RemoveScaAuthUserDeviceIDs removes the "sca_auth_user_device" edge to ScaAuthUserDevice entities by IDs. +func (sauuo *ScaAuthUserUpdateOne) RemoveScaAuthUserDeviceIDs(ids ...int64) *ScaAuthUserUpdateOne { + sauuo.mutation.RemoveScaAuthUserDeviceIDs(ids...) + return sauuo +} + +// RemoveScaAuthUserDevice removes "sca_auth_user_device" edges to ScaAuthUserDevice entities. +func (sauuo *ScaAuthUserUpdateOne) RemoveScaAuthUserDevice(s ...*ScaAuthUserDevice) *ScaAuthUserUpdateOne { + ids := make([]int64, len(s)) + for i := range s { + ids[i] = s[i].ID + } + return sauuo.RemoveScaAuthUserDeviceIDs(ids...) +} + +// Where appends a list predicates to the ScaAuthUserUpdate builder. +func (sauuo *ScaAuthUserUpdateOne) Where(ps ...predicate.ScaAuthUser) *ScaAuthUserUpdateOne { + sauuo.mutation.Where(ps...) + return sauuo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (sauuo *ScaAuthUserUpdateOne) Select(field string, fields ...string) *ScaAuthUserUpdateOne { + sauuo.fields = append([]string{field}, fields...) + return sauuo +} + +// Save executes the query and returns the updated ScaAuthUser entity. +func (sauuo *ScaAuthUserUpdateOne) Save(ctx context.Context) (*ScaAuthUser, error) { + sauuo.defaults() + return withHooks(ctx, sauuo.sqlSave, sauuo.mutation, sauuo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (sauuo *ScaAuthUserUpdateOne) SaveX(ctx context.Context) *ScaAuthUser { + node, err := sauuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (sauuo *ScaAuthUserUpdateOne) Exec(ctx context.Context) error { + _, err := sauuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (sauuo *ScaAuthUserUpdateOne) ExecX(ctx context.Context) { + if err := sauuo.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (sauuo *ScaAuthUserUpdateOne) defaults() { + if _, ok := sauuo.mutation.UpdateAt(); !ok && !sauuo.mutation.UpdateAtCleared() { + v := scaauthuser.UpdateDefaultUpdateAt() + sauuo.mutation.SetUpdateAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (sauuo *ScaAuthUserUpdateOne) check() error { + if v, ok := sauuo.mutation.UID(); ok { + if err := scaauthuser.UIDValidator(v); err != nil { + return &ValidationError{Name: "uid", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.uid": %w`, err)} + } + } + if v, ok := sauuo.mutation.Username(); ok { + if err := scaauthuser.UsernameValidator(v); err != nil { + return &ValidationError{Name: "username", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.username": %w`, err)} + } + } + if v, ok := sauuo.mutation.Nickname(); ok { + if err := scaauthuser.NicknameValidator(v); err != nil { + return &ValidationError{Name: "nickname", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.nickname": %w`, err)} + } + } + if v, ok := sauuo.mutation.Email(); ok { + if err := scaauthuser.EmailValidator(v); err != nil { + return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.email": %w`, err)} + } + } + if v, ok := sauuo.mutation.Phone(); ok { + if err := scaauthuser.PhoneValidator(v); err != nil { + return &ValidationError{Name: "phone", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.phone": %w`, err)} + } + } + if v, ok := sauuo.mutation.Password(); ok { + if err := scaauthuser.PasswordValidator(v); err != nil { + return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.password": %w`, err)} + } + } + if v, ok := sauuo.mutation.Gender(); ok { + if err := scaauthuser.GenderValidator(v); err != nil { + return &ValidationError{Name: "gender", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.gender": %w`, err)} + } + } + if v, ok := sauuo.mutation.Introduce(); ok { + if err := scaauthuser.IntroduceValidator(v); err != nil { + return &ValidationError{Name: "introduce", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.introduce": %w`, err)} + } + } + if v, ok := sauuo.mutation.Blog(); ok { + if err := scaauthuser.BlogValidator(v); err != nil { + return &ValidationError{Name: "blog", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.blog": %w`, err)} + } + } + if v, ok := sauuo.mutation.Location(); ok { + if err := scaauthuser.LocationValidator(v); err != nil { + return &ValidationError{Name: "location", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.location": %w`, err)} + } + } + if v, ok := sauuo.mutation.Company(); ok { + if err := scaauthuser.CompanyValidator(v); err != nil { + return &ValidationError{Name: "company", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.company": %w`, err)} + } + } + return nil +} + +func (sauuo *ScaAuthUserUpdateOne) sqlSave(ctx context.Context) (_node *ScaAuthUser, err error) { + if err := sauuo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(scaauthuser.Table, scaauthuser.Columns, sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64)) + id, ok := sauuo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ScaAuthUser.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := sauuo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, scaauthuser.FieldID) + for _, f := range fields { + if !scaauthuser.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != scaauthuser.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := sauuo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := sauuo.mutation.UID(); ok { + _spec.SetField(scaauthuser.FieldUID, field.TypeString, value) + } + if value, ok := sauuo.mutation.Username(); ok { + _spec.SetField(scaauthuser.FieldUsername, field.TypeString, value) + } + if sauuo.mutation.UsernameCleared() { + _spec.ClearField(scaauthuser.FieldUsername, field.TypeString) + } + if value, ok := sauuo.mutation.Nickname(); ok { + _spec.SetField(scaauthuser.FieldNickname, field.TypeString, value) + } + if sauuo.mutation.NicknameCleared() { + _spec.ClearField(scaauthuser.FieldNickname, field.TypeString) + } + if value, ok := sauuo.mutation.Email(); ok { + _spec.SetField(scaauthuser.FieldEmail, field.TypeString, value) + } + if sauuo.mutation.EmailCleared() { + _spec.ClearField(scaauthuser.FieldEmail, field.TypeString) + } + if value, ok := sauuo.mutation.Phone(); ok { + _spec.SetField(scaauthuser.FieldPhone, field.TypeString, value) + } + if sauuo.mutation.PhoneCleared() { + _spec.ClearField(scaauthuser.FieldPhone, field.TypeString) + } + if value, ok := sauuo.mutation.Password(); ok { + _spec.SetField(scaauthuser.FieldPassword, field.TypeString, value) + } + if sauuo.mutation.PasswordCleared() { + _spec.ClearField(scaauthuser.FieldPassword, field.TypeString) + } + if value, ok := sauuo.mutation.Gender(); ok { + _spec.SetField(scaauthuser.FieldGender, field.TypeString, value) + } + if sauuo.mutation.GenderCleared() { + _spec.ClearField(scaauthuser.FieldGender, field.TypeString) + } + if value, ok := sauuo.mutation.Avatar(); ok { + _spec.SetField(scaauthuser.FieldAvatar, field.TypeString, value) + } + if sauuo.mutation.AvatarCleared() { + _spec.ClearField(scaauthuser.FieldAvatar, field.TypeString) + } + if value, ok := sauuo.mutation.Status(); ok { + _spec.SetField(scaauthuser.FieldStatus, field.TypeInt8, value) + } + if value, ok := sauuo.mutation.AddedStatus(); ok { + _spec.AddField(scaauthuser.FieldStatus, field.TypeInt8, value) + } + if sauuo.mutation.StatusCleared() { + _spec.ClearField(scaauthuser.FieldStatus, field.TypeInt8) + } + if value, ok := sauuo.mutation.Introduce(); ok { + _spec.SetField(scaauthuser.FieldIntroduce, field.TypeString, value) + } + if sauuo.mutation.IntroduceCleared() { + _spec.ClearField(scaauthuser.FieldIntroduce, field.TypeString) + } + if value, ok := sauuo.mutation.UpdateAt(); ok { + _spec.SetField(scaauthuser.FieldUpdateAt, field.TypeTime, value) + } + if sauuo.mutation.UpdateAtCleared() { + _spec.ClearField(scaauthuser.FieldUpdateAt, field.TypeTime) + } + if value, ok := sauuo.mutation.Deleted(); ok { + _spec.SetField(scaauthuser.FieldDeleted, field.TypeInt8, value) + } + if value, ok := sauuo.mutation.AddedDeleted(); ok { + _spec.AddField(scaauthuser.FieldDeleted, field.TypeInt8, value) + } + if value, ok := sauuo.mutation.Blog(); ok { + _spec.SetField(scaauthuser.FieldBlog, field.TypeString, value) + } + if sauuo.mutation.BlogCleared() { + _spec.ClearField(scaauthuser.FieldBlog, field.TypeString) + } + if value, ok := sauuo.mutation.Location(); ok { + _spec.SetField(scaauthuser.FieldLocation, field.TypeString, value) + } + if sauuo.mutation.LocationCleared() { + _spec.ClearField(scaauthuser.FieldLocation, field.TypeString) + } + if value, ok := sauuo.mutation.Company(); ok { + _spec.SetField(scaauthuser.FieldCompany, field.TypeString, value) + } + if sauuo.mutation.CompanyCleared() { + _spec.ClearField(scaauthuser.FieldCompany, field.TypeString) + } + if sauuo.mutation.ScaAuthUserSocialCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: scaauthuser.ScaAuthUserSocialTable, + Columns: []string{scaauthuser.ScaAuthUserSocialColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := sauuo.mutation.RemovedScaAuthUserSocialIDs(); len(nodes) > 0 && !sauuo.mutation.ScaAuthUserSocialCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: scaauthuser.ScaAuthUserSocialTable, + Columns: []string{scaauthuser.ScaAuthUserSocialColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := sauuo.mutation.ScaAuthUserSocialIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: scaauthuser.ScaAuthUserSocialTable, + Columns: []string{scaauthuser.ScaAuthUserSocialColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if sauuo.mutation.ScaAuthUserDeviceCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: scaauthuser.ScaAuthUserDeviceTable, + Columns: []string{scaauthuser.ScaAuthUserDeviceColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(scaauthuserdevice.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := sauuo.mutation.RemovedScaAuthUserDeviceIDs(); len(nodes) > 0 && !sauuo.mutation.ScaAuthUserDeviceCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: scaauthuser.ScaAuthUserDeviceTable, + Columns: []string{scaauthuser.ScaAuthUserDeviceColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(scaauthuserdevice.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := sauuo.mutation.ScaAuthUserDeviceIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: scaauthuser.ScaAuthUserDeviceTable, + Columns: []string{scaauthuser.ScaAuthUserDeviceColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(scaauthuserdevice.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _node = &ScaAuthUser{config: sauuo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, sauuo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{scaauthuser.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + sauuo.mutation.done = true + return _node, nil +} diff --git a/common/ent/scaauthuserdevice.go b/common/ent/scaauthuserdevice.go new file mode 100644 index 0000000..0cae624 --- /dev/null +++ b/common/ent/scaauthuserdevice.go @@ -0,0 +1,314 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "schisandra-album-cloud-microservices/common/ent/scaauthuser" + "schisandra-album-cloud-microservices/common/ent/scaauthuserdevice" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// ScaAuthUserDevice is the model entity for the ScaAuthUserDevice schema. +type ScaAuthUserDevice struct { + config `json:"-"` + // ID of the ent. + // 主键ID + ID int64 `json:"id,omitempty"` + // 用户ID + UserID string `json:"user_id,omitempty"` + // 登录IP + IP string `json:"ip,omitempty"` + // 地址 + Location string `json:"location,omitempty"` + // 设备信息 + Agent string `json:"agent,omitempty"` + // 创建时间 + CreatedAt time.Time `json:"created_at,omitempty"` + // 更新时间 + UpdateAt *time.Time `json:"update_at,omitempty"` + // 是否删除 + Deleted int `json:"deleted,omitempty"` + // 浏览器 + Browser string `json:"browser,omitempty"` + // 操作系统 + OperatingSystem string `json:"operating_system,omitempty"` + // 浏览器版本 + BrowserVersion string `json:"browser_version,omitempty"` + // 是否为手机 0否1是 + Mobile int `json:"mobile,omitempty"` + // 是否为bot 0否1是 + Bot int `json:"bot,omitempty"` + // 火狐版本 + Mozilla string `json:"mozilla,omitempty"` + // 平台 + Platform string `json:"platform,omitempty"` + // 引擎名称 + EngineName string `json:"engine_name,omitempty"` + // 引擎版本 + EngineVersion string `json:"engine_version,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the ScaAuthUserDeviceQuery when eager-loading is set. + Edges ScaAuthUserDeviceEdges `json:"edges"` + sca_auth_user_sca_auth_user_device *int64 + selectValues sql.SelectValues +} + +// ScaAuthUserDeviceEdges holds the relations/edges for other nodes in the graph. +type ScaAuthUserDeviceEdges struct { + // ScaAuthUser holds the value of the sca_auth_user edge. + ScaAuthUser *ScaAuthUser `json:"sca_auth_user,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [1]bool +} + +// ScaAuthUserOrErr returns the ScaAuthUser value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e ScaAuthUserDeviceEdges) ScaAuthUserOrErr() (*ScaAuthUser, error) { + if e.ScaAuthUser != nil { + return e.ScaAuthUser, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: scaauthuser.Label} + } + return nil, &NotLoadedError{edge: "sca_auth_user"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*ScaAuthUserDevice) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case scaauthuserdevice.FieldID, scaauthuserdevice.FieldDeleted, scaauthuserdevice.FieldMobile, scaauthuserdevice.FieldBot: + values[i] = new(sql.NullInt64) + case scaauthuserdevice.FieldUserID, scaauthuserdevice.FieldIP, scaauthuserdevice.FieldLocation, scaauthuserdevice.FieldAgent, scaauthuserdevice.FieldBrowser, scaauthuserdevice.FieldOperatingSystem, scaauthuserdevice.FieldBrowserVersion, scaauthuserdevice.FieldMozilla, scaauthuserdevice.FieldPlatform, scaauthuserdevice.FieldEngineName, scaauthuserdevice.FieldEngineVersion: + values[i] = new(sql.NullString) + case scaauthuserdevice.FieldCreatedAt, scaauthuserdevice.FieldUpdateAt: + values[i] = new(sql.NullTime) + case scaauthuserdevice.ForeignKeys[0]: // sca_auth_user_sca_auth_user_device + values[i] = new(sql.NullInt64) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the ScaAuthUserDevice fields. +func (saud *ScaAuthUserDevice) 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 scaauthuserdevice.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + saud.ID = int64(value.Int64) + case scaauthuserdevice.FieldUserID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field user_id", values[i]) + } else if value.Valid { + saud.UserID = value.String + } + case scaauthuserdevice.FieldIP: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field ip", values[i]) + } else if value.Valid { + saud.IP = value.String + } + case scaauthuserdevice.FieldLocation: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field location", values[i]) + } else if value.Valid { + saud.Location = value.String + } + case scaauthuserdevice.FieldAgent: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field agent", values[i]) + } else if value.Valid { + saud.Agent = value.String + } + case scaauthuserdevice.FieldCreatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field created_at", values[i]) + } else if value.Valid { + saud.CreatedAt = value.Time + } + case scaauthuserdevice.FieldUpdateAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field update_at", values[i]) + } else if value.Valid { + saud.UpdateAt = new(time.Time) + *saud.UpdateAt = value.Time + } + case scaauthuserdevice.FieldDeleted: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field deleted", values[i]) + } else if value.Valid { + saud.Deleted = int(value.Int64) + } + case scaauthuserdevice.FieldBrowser: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field browser", values[i]) + } else if value.Valid { + saud.Browser = value.String + } + case scaauthuserdevice.FieldOperatingSystem: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field operating_system", values[i]) + } else if value.Valid { + saud.OperatingSystem = value.String + } + case scaauthuserdevice.FieldBrowserVersion: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field browser_version", values[i]) + } else if value.Valid { + saud.BrowserVersion = value.String + } + case scaauthuserdevice.FieldMobile: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field mobile", values[i]) + } else if value.Valid { + saud.Mobile = int(value.Int64) + } + case scaauthuserdevice.FieldBot: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field bot", values[i]) + } else if value.Valid { + saud.Bot = int(value.Int64) + } + case scaauthuserdevice.FieldMozilla: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field mozilla", values[i]) + } else if value.Valid { + saud.Mozilla = value.String + } + case scaauthuserdevice.FieldPlatform: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field platform", values[i]) + } else if value.Valid { + saud.Platform = value.String + } + case scaauthuserdevice.FieldEngineName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field engine_name", values[i]) + } else if value.Valid { + saud.EngineName = value.String + } + case scaauthuserdevice.FieldEngineVersion: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field engine_version", values[i]) + } else if value.Valid { + saud.EngineVersion = value.String + } + case scaauthuserdevice.ForeignKeys[0]: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for edge-field sca_auth_user_sca_auth_user_device", value) + } else if value.Valid { + saud.sca_auth_user_sca_auth_user_device = new(int64) + *saud.sca_auth_user_sca_auth_user_device = int64(value.Int64) + } + default: + saud.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the ScaAuthUserDevice. +// This includes values selected through modifiers, order, etc. +func (saud *ScaAuthUserDevice) Value(name string) (ent.Value, error) { + return saud.selectValues.Get(name) +} + +// QueryScaAuthUser queries the "sca_auth_user" edge of the ScaAuthUserDevice entity. +func (saud *ScaAuthUserDevice) QueryScaAuthUser() *ScaAuthUserQuery { + return NewScaAuthUserDeviceClient(saud.config).QueryScaAuthUser(saud) +} + +// Update returns a builder for updating this ScaAuthUserDevice. +// Note that you need to call ScaAuthUserDevice.Unwrap() before calling this method if this ScaAuthUserDevice +// was returned from a transaction, and the transaction was committed or rolled back. +func (saud *ScaAuthUserDevice) Update() *ScaAuthUserDeviceUpdateOne { + return NewScaAuthUserDeviceClient(saud.config).UpdateOne(saud) +} + +// Unwrap unwraps the ScaAuthUserDevice 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 (saud *ScaAuthUserDevice) Unwrap() *ScaAuthUserDevice { + _tx, ok := saud.config.driver.(*txDriver) + if !ok { + panic("ent: ScaAuthUserDevice is not a transactional entity") + } + saud.config.driver = _tx.drv + return saud +} + +// String implements the fmt.Stringer. +func (saud *ScaAuthUserDevice) String() string { + var builder strings.Builder + builder.WriteString("ScaAuthUserDevice(") + builder.WriteString(fmt.Sprintf("id=%v, ", saud.ID)) + builder.WriteString("user_id=") + builder.WriteString(saud.UserID) + builder.WriteString(", ") + builder.WriteString("ip=") + builder.WriteString(saud.IP) + builder.WriteString(", ") + builder.WriteString("location=") + builder.WriteString(saud.Location) + builder.WriteString(", ") + builder.WriteString("agent=") + builder.WriteString(saud.Agent) + builder.WriteString(", ") + builder.WriteString("created_at=") + builder.WriteString(saud.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + if v := saud.UpdateAt; v != nil { + builder.WriteString("update_at=") + builder.WriteString(v.Format(time.ANSIC)) + } + builder.WriteString(", ") + builder.WriteString("deleted=") + builder.WriteString(fmt.Sprintf("%v", saud.Deleted)) + builder.WriteString(", ") + builder.WriteString("browser=") + builder.WriteString(saud.Browser) + builder.WriteString(", ") + builder.WriteString("operating_system=") + builder.WriteString(saud.OperatingSystem) + builder.WriteString(", ") + builder.WriteString("browser_version=") + builder.WriteString(saud.BrowserVersion) + builder.WriteString(", ") + builder.WriteString("mobile=") + builder.WriteString(fmt.Sprintf("%v", saud.Mobile)) + builder.WriteString(", ") + builder.WriteString("bot=") + builder.WriteString(fmt.Sprintf("%v", saud.Bot)) + builder.WriteString(", ") + builder.WriteString("mozilla=") + builder.WriteString(saud.Mozilla) + builder.WriteString(", ") + builder.WriteString("platform=") + builder.WriteString(saud.Platform) + builder.WriteString(", ") + builder.WriteString("engine_name=") + builder.WriteString(saud.EngineName) + builder.WriteString(", ") + builder.WriteString("engine_version=") + builder.WriteString(saud.EngineVersion) + builder.WriteByte(')') + return builder.String() +} + +// ScaAuthUserDevices is a parsable slice of ScaAuthUserDevice. +type ScaAuthUserDevices []*ScaAuthUserDevice diff --git a/common/ent/scaauthuserdevice/scaauthuserdevice.go b/common/ent/scaauthuserdevice/scaauthuserdevice.go new file mode 100644 index 0000000..b2e2f6d --- /dev/null +++ b/common/ent/scaauthuserdevice/scaauthuserdevice.go @@ -0,0 +1,237 @@ +// Code generated by ent, DO NOT EDIT. + +package scaauthuserdevice + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the scaauthuserdevice type in the database. + Label = "sca_auth_user_device" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldUserID holds the string denoting the user_id field in the database. + FieldUserID = "user_id" + // FieldIP holds the string denoting the ip field in the database. + FieldIP = "ip" + // FieldLocation holds the string denoting the location field in the database. + FieldLocation = "location" + // FieldAgent holds the string denoting the agent field in the database. + FieldAgent = "agent" + // FieldCreatedAt holds the string denoting the created_at field in the database. + FieldCreatedAt = "created_at" + // FieldUpdateAt holds the string denoting the update_at field in the database. + FieldUpdateAt = "update_at" + // FieldDeleted holds the string denoting the deleted field in the database. + FieldDeleted = "deleted" + // FieldBrowser holds the string denoting the browser field in the database. + FieldBrowser = "browser" + // FieldOperatingSystem holds the string denoting the operating_system field in the database. + FieldOperatingSystem = "operating_system" + // FieldBrowserVersion holds the string denoting the browser_version field in the database. + FieldBrowserVersion = "browser_version" + // FieldMobile holds the string denoting the mobile field in the database. + FieldMobile = "mobile" + // FieldBot holds the string denoting the bot field in the database. + FieldBot = "bot" + // FieldMozilla holds the string denoting the mozilla field in the database. + FieldMozilla = "mozilla" + // FieldPlatform holds the string denoting the platform field in the database. + FieldPlatform = "platform" + // FieldEngineName holds the string denoting the engine_name field in the database. + FieldEngineName = "engine_name" + // FieldEngineVersion holds the string denoting the engine_version field in the database. + FieldEngineVersion = "engine_version" + // EdgeScaAuthUser holds the string denoting the sca_auth_user edge name in mutations. + EdgeScaAuthUser = "sca_auth_user" + // Table holds the table name of the scaauthuserdevice in the database. + Table = "sca_auth_user_devices" + // ScaAuthUserTable is the table that holds the sca_auth_user relation/edge. + ScaAuthUserTable = "sca_auth_user_devices" + // ScaAuthUserInverseTable is the table name for the ScaAuthUser entity. + // It exists in this package in order to avoid circular dependency with the "scaauthuser" package. + ScaAuthUserInverseTable = "sca_auth_users" + // ScaAuthUserColumn is the table column denoting the sca_auth_user relation/edge. + ScaAuthUserColumn = "sca_auth_user_sca_auth_user_device" +) + +// Columns holds all SQL columns for scaauthuserdevice fields. +var Columns = []string{ + FieldID, + FieldUserID, + FieldIP, + FieldLocation, + FieldAgent, + FieldCreatedAt, + FieldUpdateAt, + FieldDeleted, + FieldBrowser, + FieldOperatingSystem, + FieldBrowserVersion, + FieldMobile, + FieldBot, + FieldMozilla, + FieldPlatform, + FieldEngineName, + FieldEngineVersion, +} + +// ForeignKeys holds the SQL foreign-keys that are owned by the "sca_auth_user_devices" +// table and are not defined as standalone fields in the schema. +var ForeignKeys = []string{ + "sca_auth_user_sca_auth_user_device", +} + +// 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 + } + } + for i := range ForeignKeys { + if column == ForeignKeys[i] { + return true + } + } + return false +} + +var ( + // UserIDValidator is a validator for the "user_id" field. It is called by the builders before save. + UserIDValidator func(string) error + // IPValidator is a validator for the "ip" field. It is called by the builders before save. + IPValidator func(string) error + // LocationValidator is a validator for the "location" field. It is called by the builders before save. + LocationValidator func(string) error + // AgentValidator is a validator for the "agent" field. It is called by the builders before save. + AgentValidator func(string) error + // DefaultCreatedAt holds the default value on creation for the "created_at" field. + DefaultCreatedAt func() time.Time + // DefaultUpdateAt holds the default value on creation for the "update_at" field. + DefaultUpdateAt func() time.Time + // UpdateDefaultUpdateAt holds the default value on update for the "update_at" field. + UpdateDefaultUpdateAt func() time.Time + // DefaultDeleted holds the default value on creation for the "deleted" field. + DefaultDeleted int + // BrowserValidator is a validator for the "browser" field. It is called by the builders before save. + BrowserValidator func(string) error + // OperatingSystemValidator is a validator for the "operating_system" field. It is called by the builders before save. + OperatingSystemValidator func(string) error + // BrowserVersionValidator is a validator for the "browser_version" field. It is called by the builders before save. + BrowserVersionValidator func(string) error + // MozillaValidator is a validator for the "mozilla" field. It is called by the builders before save. + MozillaValidator func(string) error + // PlatformValidator is a validator for the "platform" field. It is called by the builders before save. + PlatformValidator func(string) error + // EngineNameValidator is a validator for the "engine_name" field. It is called by the builders before save. + EngineNameValidator func(string) error + // EngineVersionValidator is a validator for the "engine_version" field. It is called by the builders before save. + EngineVersionValidator func(string) error +) + +// OrderOption defines the ordering options for the ScaAuthUserDevice 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() +} + +// ByUserID orders the results by the user_id field. +func ByUserID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUserID, opts...).ToFunc() +} + +// ByIP orders the results by the ip field. +func ByIP(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldIP, opts...).ToFunc() +} + +// ByLocation orders the results by the location field. +func ByLocation(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLocation, opts...).ToFunc() +} + +// ByAgent orders the results by the agent field. +func ByAgent(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldAgent, opts...).ToFunc() +} + +// ByCreatedAt orders the results by the created_at field. +func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() +} + +// ByUpdateAt orders the results by the update_at field. +func ByUpdateAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateAt, opts...).ToFunc() +} + +// ByDeleted orders the results by the deleted field. +func ByDeleted(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeleted, opts...).ToFunc() +} + +// ByBrowser orders the results by the browser field. +func ByBrowser(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldBrowser, opts...).ToFunc() +} + +// ByOperatingSystem orders the results by the operating_system field. +func ByOperatingSystem(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldOperatingSystem, opts...).ToFunc() +} + +// ByBrowserVersion orders the results by the browser_version field. +func ByBrowserVersion(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldBrowserVersion, opts...).ToFunc() +} + +// ByMobile orders the results by the mobile field. +func ByMobile(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldMobile, opts...).ToFunc() +} + +// ByBot orders the results by the bot field. +func ByBot(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldBot, opts...).ToFunc() +} + +// ByMozilla orders the results by the mozilla field. +func ByMozilla(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldMozilla, opts...).ToFunc() +} + +// ByPlatform orders the results by the platform field. +func ByPlatform(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPlatform, opts...).ToFunc() +} + +// ByEngineName orders the results by the engine_name field. +func ByEngineName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldEngineName, opts...).ToFunc() +} + +// ByEngineVersion orders the results by the engine_version field. +func ByEngineVersion(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldEngineVersion, opts...).ToFunc() +} + +// ByScaAuthUserField orders the results by sca_auth_user field. +func ByScaAuthUserField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newScaAuthUserStep(), sql.OrderByField(field, opts...)) + } +} +func newScaAuthUserStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ScaAuthUserInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, ScaAuthUserTable, ScaAuthUserColumn), + ) +} diff --git a/common/ent/scaauthuserdevice/where.go b/common/ent/scaauthuserdevice/where.go new file mode 100644 index 0000000..75ace67 --- /dev/null +++ b/common/ent/scaauthuserdevice/where.go @@ -0,0 +1,1099 @@ +// Code generated by ent, DO NOT EDIT. + +package scaauthuserdevice + +import ( + "schisandra-album-cloud-microservices/common/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id int64) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int64) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int64) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int64) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int64) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int64) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int64) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int64) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int64) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldLTE(FieldID, id)) +} + +// UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ. +func UserID(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEQ(FieldUserID, v)) +} + +// IP applies equality check predicate on the "ip" field. It's identical to IPEQ. +func IP(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEQ(FieldIP, v)) +} + +// Location applies equality check predicate on the "location" field. It's identical to LocationEQ. +func Location(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEQ(FieldLocation, v)) +} + +// Agent applies equality check predicate on the "agent" field. It's identical to AgentEQ. +func Agent(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEQ(FieldAgent, v)) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEQ(FieldCreatedAt, v)) +} + +// UpdateAt applies equality check predicate on the "update_at" field. It's identical to UpdateAtEQ. +func UpdateAt(v time.Time) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEQ(FieldUpdateAt, v)) +} + +// Deleted applies equality check predicate on the "deleted" field. It's identical to DeletedEQ. +func Deleted(v int) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEQ(FieldDeleted, v)) +} + +// Browser applies equality check predicate on the "browser" field. It's identical to BrowserEQ. +func Browser(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEQ(FieldBrowser, v)) +} + +// OperatingSystem applies equality check predicate on the "operating_system" field. It's identical to OperatingSystemEQ. +func OperatingSystem(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEQ(FieldOperatingSystem, v)) +} + +// BrowserVersion applies equality check predicate on the "browser_version" field. It's identical to BrowserVersionEQ. +func BrowserVersion(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEQ(FieldBrowserVersion, v)) +} + +// Mobile applies equality check predicate on the "mobile" field. It's identical to MobileEQ. +func Mobile(v int) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEQ(FieldMobile, v)) +} + +// Bot applies equality check predicate on the "bot" field. It's identical to BotEQ. +func Bot(v int) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEQ(FieldBot, v)) +} + +// Mozilla applies equality check predicate on the "mozilla" field. It's identical to MozillaEQ. +func Mozilla(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEQ(FieldMozilla, v)) +} + +// Platform applies equality check predicate on the "platform" field. It's identical to PlatformEQ. +func Platform(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEQ(FieldPlatform, v)) +} + +// EngineName applies equality check predicate on the "engine_name" field. It's identical to EngineNameEQ. +func EngineName(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEQ(FieldEngineName, v)) +} + +// EngineVersion applies equality check predicate on the "engine_version" field. It's identical to EngineVersionEQ. +func EngineVersion(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEQ(FieldEngineVersion, v)) +} + +// UserIDEQ applies the EQ predicate on the "user_id" field. +func UserIDEQ(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEQ(FieldUserID, v)) +} + +// UserIDNEQ applies the NEQ predicate on the "user_id" field. +func UserIDNEQ(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldNEQ(FieldUserID, v)) +} + +// UserIDIn applies the In predicate on the "user_id" field. +func UserIDIn(vs ...string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldIn(FieldUserID, vs...)) +} + +// UserIDNotIn applies the NotIn predicate on the "user_id" field. +func UserIDNotIn(vs ...string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldNotIn(FieldUserID, vs...)) +} + +// UserIDGT applies the GT predicate on the "user_id" field. +func UserIDGT(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldGT(FieldUserID, v)) +} + +// UserIDGTE applies the GTE predicate on the "user_id" field. +func UserIDGTE(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldGTE(FieldUserID, v)) +} + +// UserIDLT applies the LT predicate on the "user_id" field. +func UserIDLT(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldLT(FieldUserID, v)) +} + +// UserIDLTE applies the LTE predicate on the "user_id" field. +func UserIDLTE(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldLTE(FieldUserID, v)) +} + +// UserIDContains applies the Contains predicate on the "user_id" field. +func UserIDContains(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldContains(FieldUserID, v)) +} + +// UserIDHasPrefix applies the HasPrefix predicate on the "user_id" field. +func UserIDHasPrefix(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldHasPrefix(FieldUserID, v)) +} + +// UserIDHasSuffix applies the HasSuffix predicate on the "user_id" field. +func UserIDHasSuffix(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldHasSuffix(FieldUserID, v)) +} + +// UserIDEqualFold applies the EqualFold predicate on the "user_id" field. +func UserIDEqualFold(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEqualFold(FieldUserID, v)) +} + +// UserIDContainsFold applies the ContainsFold predicate on the "user_id" field. +func UserIDContainsFold(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldContainsFold(FieldUserID, v)) +} + +// IPEQ applies the EQ predicate on the "ip" field. +func IPEQ(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEQ(FieldIP, v)) +} + +// IPNEQ applies the NEQ predicate on the "ip" field. +func IPNEQ(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldNEQ(FieldIP, v)) +} + +// IPIn applies the In predicate on the "ip" field. +func IPIn(vs ...string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldIn(FieldIP, vs...)) +} + +// IPNotIn applies the NotIn predicate on the "ip" field. +func IPNotIn(vs ...string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldNotIn(FieldIP, vs...)) +} + +// IPGT applies the GT predicate on the "ip" field. +func IPGT(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldGT(FieldIP, v)) +} + +// IPGTE applies the GTE predicate on the "ip" field. +func IPGTE(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldGTE(FieldIP, v)) +} + +// IPLT applies the LT predicate on the "ip" field. +func IPLT(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldLT(FieldIP, v)) +} + +// IPLTE applies the LTE predicate on the "ip" field. +func IPLTE(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldLTE(FieldIP, v)) +} + +// IPContains applies the Contains predicate on the "ip" field. +func IPContains(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldContains(FieldIP, v)) +} + +// IPHasPrefix applies the HasPrefix predicate on the "ip" field. +func IPHasPrefix(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldHasPrefix(FieldIP, v)) +} + +// IPHasSuffix applies the HasSuffix predicate on the "ip" field. +func IPHasSuffix(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldHasSuffix(FieldIP, v)) +} + +// IPEqualFold applies the EqualFold predicate on the "ip" field. +func IPEqualFold(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEqualFold(FieldIP, v)) +} + +// IPContainsFold applies the ContainsFold predicate on the "ip" field. +func IPContainsFold(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldContainsFold(FieldIP, v)) +} + +// LocationEQ applies the EQ predicate on the "location" field. +func LocationEQ(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEQ(FieldLocation, v)) +} + +// LocationNEQ applies the NEQ predicate on the "location" field. +func LocationNEQ(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldNEQ(FieldLocation, v)) +} + +// LocationIn applies the In predicate on the "location" field. +func LocationIn(vs ...string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldIn(FieldLocation, vs...)) +} + +// LocationNotIn applies the NotIn predicate on the "location" field. +func LocationNotIn(vs ...string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldNotIn(FieldLocation, vs...)) +} + +// LocationGT applies the GT predicate on the "location" field. +func LocationGT(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldGT(FieldLocation, v)) +} + +// LocationGTE applies the GTE predicate on the "location" field. +func LocationGTE(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldGTE(FieldLocation, v)) +} + +// LocationLT applies the LT predicate on the "location" field. +func LocationLT(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldLT(FieldLocation, v)) +} + +// LocationLTE applies the LTE predicate on the "location" field. +func LocationLTE(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldLTE(FieldLocation, v)) +} + +// LocationContains applies the Contains predicate on the "location" field. +func LocationContains(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldContains(FieldLocation, v)) +} + +// LocationHasPrefix applies the HasPrefix predicate on the "location" field. +func LocationHasPrefix(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldHasPrefix(FieldLocation, v)) +} + +// LocationHasSuffix applies the HasSuffix predicate on the "location" field. +func LocationHasSuffix(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldHasSuffix(FieldLocation, v)) +} + +// LocationEqualFold applies the EqualFold predicate on the "location" field. +func LocationEqualFold(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEqualFold(FieldLocation, v)) +} + +// LocationContainsFold applies the ContainsFold predicate on the "location" field. +func LocationContainsFold(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldContainsFold(FieldLocation, v)) +} + +// AgentEQ applies the EQ predicate on the "agent" field. +func AgentEQ(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEQ(FieldAgent, v)) +} + +// AgentNEQ applies the NEQ predicate on the "agent" field. +func AgentNEQ(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldNEQ(FieldAgent, v)) +} + +// AgentIn applies the In predicate on the "agent" field. +func AgentIn(vs ...string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldIn(FieldAgent, vs...)) +} + +// AgentNotIn applies the NotIn predicate on the "agent" field. +func AgentNotIn(vs ...string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldNotIn(FieldAgent, vs...)) +} + +// AgentGT applies the GT predicate on the "agent" field. +func AgentGT(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldGT(FieldAgent, v)) +} + +// AgentGTE applies the GTE predicate on the "agent" field. +func AgentGTE(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldGTE(FieldAgent, v)) +} + +// AgentLT applies the LT predicate on the "agent" field. +func AgentLT(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldLT(FieldAgent, v)) +} + +// AgentLTE applies the LTE predicate on the "agent" field. +func AgentLTE(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldLTE(FieldAgent, v)) +} + +// AgentContains applies the Contains predicate on the "agent" field. +func AgentContains(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldContains(FieldAgent, v)) +} + +// AgentHasPrefix applies the HasPrefix predicate on the "agent" field. +func AgentHasPrefix(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldHasPrefix(FieldAgent, v)) +} + +// AgentHasSuffix applies the HasSuffix predicate on the "agent" field. +func AgentHasSuffix(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldHasSuffix(FieldAgent, v)) +} + +// AgentEqualFold applies the EqualFold predicate on the "agent" field. +func AgentEqualFold(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEqualFold(FieldAgent, v)) +} + +// AgentContainsFold applies the ContainsFold predicate on the "agent" field. +func AgentContainsFold(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldContainsFold(FieldAgent, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldLTE(FieldCreatedAt, v)) +} + +// CreatedAtIsNil applies the IsNil predicate on the "created_at" field. +func CreatedAtIsNil() predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldIsNull(FieldCreatedAt)) +} + +// CreatedAtNotNil applies the NotNil predicate on the "created_at" field. +func CreatedAtNotNil() predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldNotNull(FieldCreatedAt)) +} + +// UpdateAtEQ applies the EQ predicate on the "update_at" field. +func UpdateAtEQ(v time.Time) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEQ(FieldUpdateAt, v)) +} + +// UpdateAtNEQ applies the NEQ predicate on the "update_at" field. +func UpdateAtNEQ(v time.Time) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldNEQ(FieldUpdateAt, v)) +} + +// UpdateAtIn applies the In predicate on the "update_at" field. +func UpdateAtIn(vs ...time.Time) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldIn(FieldUpdateAt, vs...)) +} + +// UpdateAtNotIn applies the NotIn predicate on the "update_at" field. +func UpdateAtNotIn(vs ...time.Time) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldNotIn(FieldUpdateAt, vs...)) +} + +// UpdateAtGT applies the GT predicate on the "update_at" field. +func UpdateAtGT(v time.Time) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldGT(FieldUpdateAt, v)) +} + +// UpdateAtGTE applies the GTE predicate on the "update_at" field. +func UpdateAtGTE(v time.Time) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldGTE(FieldUpdateAt, v)) +} + +// UpdateAtLT applies the LT predicate on the "update_at" field. +func UpdateAtLT(v time.Time) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldLT(FieldUpdateAt, v)) +} + +// UpdateAtLTE applies the LTE predicate on the "update_at" field. +func UpdateAtLTE(v time.Time) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldLTE(FieldUpdateAt, v)) +} + +// DeletedEQ applies the EQ predicate on the "deleted" field. +func DeletedEQ(v int) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEQ(FieldDeleted, v)) +} + +// DeletedNEQ applies the NEQ predicate on the "deleted" field. +func DeletedNEQ(v int) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldNEQ(FieldDeleted, v)) +} + +// DeletedIn applies the In predicate on the "deleted" field. +func DeletedIn(vs ...int) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldIn(FieldDeleted, vs...)) +} + +// DeletedNotIn applies the NotIn predicate on the "deleted" field. +func DeletedNotIn(vs ...int) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldNotIn(FieldDeleted, vs...)) +} + +// DeletedGT applies the GT predicate on the "deleted" field. +func DeletedGT(v int) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldGT(FieldDeleted, v)) +} + +// DeletedGTE applies the GTE predicate on the "deleted" field. +func DeletedGTE(v int) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldGTE(FieldDeleted, v)) +} + +// DeletedLT applies the LT predicate on the "deleted" field. +func DeletedLT(v int) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldLT(FieldDeleted, v)) +} + +// DeletedLTE applies the LTE predicate on the "deleted" field. +func DeletedLTE(v int) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldLTE(FieldDeleted, v)) +} + +// BrowserEQ applies the EQ predicate on the "browser" field. +func BrowserEQ(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEQ(FieldBrowser, v)) +} + +// BrowserNEQ applies the NEQ predicate on the "browser" field. +func BrowserNEQ(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldNEQ(FieldBrowser, v)) +} + +// BrowserIn applies the In predicate on the "browser" field. +func BrowserIn(vs ...string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldIn(FieldBrowser, vs...)) +} + +// BrowserNotIn applies the NotIn predicate on the "browser" field. +func BrowserNotIn(vs ...string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldNotIn(FieldBrowser, vs...)) +} + +// BrowserGT applies the GT predicate on the "browser" field. +func BrowserGT(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldGT(FieldBrowser, v)) +} + +// BrowserGTE applies the GTE predicate on the "browser" field. +func BrowserGTE(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldGTE(FieldBrowser, v)) +} + +// BrowserLT applies the LT predicate on the "browser" field. +func BrowserLT(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldLT(FieldBrowser, v)) +} + +// BrowserLTE applies the LTE predicate on the "browser" field. +func BrowserLTE(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldLTE(FieldBrowser, v)) +} + +// BrowserContains applies the Contains predicate on the "browser" field. +func BrowserContains(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldContains(FieldBrowser, v)) +} + +// BrowserHasPrefix applies the HasPrefix predicate on the "browser" field. +func BrowserHasPrefix(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldHasPrefix(FieldBrowser, v)) +} + +// BrowserHasSuffix applies the HasSuffix predicate on the "browser" field. +func BrowserHasSuffix(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldHasSuffix(FieldBrowser, v)) +} + +// BrowserEqualFold applies the EqualFold predicate on the "browser" field. +func BrowserEqualFold(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEqualFold(FieldBrowser, v)) +} + +// BrowserContainsFold applies the ContainsFold predicate on the "browser" field. +func BrowserContainsFold(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldContainsFold(FieldBrowser, v)) +} + +// OperatingSystemEQ applies the EQ predicate on the "operating_system" field. +func OperatingSystemEQ(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEQ(FieldOperatingSystem, v)) +} + +// OperatingSystemNEQ applies the NEQ predicate on the "operating_system" field. +func OperatingSystemNEQ(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldNEQ(FieldOperatingSystem, v)) +} + +// OperatingSystemIn applies the In predicate on the "operating_system" field. +func OperatingSystemIn(vs ...string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldIn(FieldOperatingSystem, vs...)) +} + +// OperatingSystemNotIn applies the NotIn predicate on the "operating_system" field. +func OperatingSystemNotIn(vs ...string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldNotIn(FieldOperatingSystem, vs...)) +} + +// OperatingSystemGT applies the GT predicate on the "operating_system" field. +func OperatingSystemGT(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldGT(FieldOperatingSystem, v)) +} + +// OperatingSystemGTE applies the GTE predicate on the "operating_system" field. +func OperatingSystemGTE(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldGTE(FieldOperatingSystem, v)) +} + +// OperatingSystemLT applies the LT predicate on the "operating_system" field. +func OperatingSystemLT(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldLT(FieldOperatingSystem, v)) +} + +// OperatingSystemLTE applies the LTE predicate on the "operating_system" field. +func OperatingSystemLTE(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldLTE(FieldOperatingSystem, v)) +} + +// OperatingSystemContains applies the Contains predicate on the "operating_system" field. +func OperatingSystemContains(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldContains(FieldOperatingSystem, v)) +} + +// OperatingSystemHasPrefix applies the HasPrefix predicate on the "operating_system" field. +func OperatingSystemHasPrefix(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldHasPrefix(FieldOperatingSystem, v)) +} + +// OperatingSystemHasSuffix applies the HasSuffix predicate on the "operating_system" field. +func OperatingSystemHasSuffix(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldHasSuffix(FieldOperatingSystem, v)) +} + +// OperatingSystemEqualFold applies the EqualFold predicate on the "operating_system" field. +func OperatingSystemEqualFold(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEqualFold(FieldOperatingSystem, v)) +} + +// OperatingSystemContainsFold applies the ContainsFold predicate on the "operating_system" field. +func OperatingSystemContainsFold(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldContainsFold(FieldOperatingSystem, v)) +} + +// BrowserVersionEQ applies the EQ predicate on the "browser_version" field. +func BrowserVersionEQ(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEQ(FieldBrowserVersion, v)) +} + +// BrowserVersionNEQ applies the NEQ predicate on the "browser_version" field. +func BrowserVersionNEQ(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldNEQ(FieldBrowserVersion, v)) +} + +// BrowserVersionIn applies the In predicate on the "browser_version" field. +func BrowserVersionIn(vs ...string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldIn(FieldBrowserVersion, vs...)) +} + +// BrowserVersionNotIn applies the NotIn predicate on the "browser_version" field. +func BrowserVersionNotIn(vs ...string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldNotIn(FieldBrowserVersion, vs...)) +} + +// BrowserVersionGT applies the GT predicate on the "browser_version" field. +func BrowserVersionGT(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldGT(FieldBrowserVersion, v)) +} + +// BrowserVersionGTE applies the GTE predicate on the "browser_version" field. +func BrowserVersionGTE(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldGTE(FieldBrowserVersion, v)) +} + +// BrowserVersionLT applies the LT predicate on the "browser_version" field. +func BrowserVersionLT(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldLT(FieldBrowserVersion, v)) +} + +// BrowserVersionLTE applies the LTE predicate on the "browser_version" field. +func BrowserVersionLTE(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldLTE(FieldBrowserVersion, v)) +} + +// BrowserVersionContains applies the Contains predicate on the "browser_version" field. +func BrowserVersionContains(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldContains(FieldBrowserVersion, v)) +} + +// BrowserVersionHasPrefix applies the HasPrefix predicate on the "browser_version" field. +func BrowserVersionHasPrefix(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldHasPrefix(FieldBrowserVersion, v)) +} + +// BrowserVersionHasSuffix applies the HasSuffix predicate on the "browser_version" field. +func BrowserVersionHasSuffix(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldHasSuffix(FieldBrowserVersion, v)) +} + +// BrowserVersionEqualFold applies the EqualFold predicate on the "browser_version" field. +func BrowserVersionEqualFold(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEqualFold(FieldBrowserVersion, v)) +} + +// BrowserVersionContainsFold applies the ContainsFold predicate on the "browser_version" field. +func BrowserVersionContainsFold(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldContainsFold(FieldBrowserVersion, v)) +} + +// MobileEQ applies the EQ predicate on the "mobile" field. +func MobileEQ(v int) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEQ(FieldMobile, v)) +} + +// MobileNEQ applies the NEQ predicate on the "mobile" field. +func MobileNEQ(v int) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldNEQ(FieldMobile, v)) +} + +// MobileIn applies the In predicate on the "mobile" field. +func MobileIn(vs ...int) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldIn(FieldMobile, vs...)) +} + +// MobileNotIn applies the NotIn predicate on the "mobile" field. +func MobileNotIn(vs ...int) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldNotIn(FieldMobile, vs...)) +} + +// MobileGT applies the GT predicate on the "mobile" field. +func MobileGT(v int) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldGT(FieldMobile, v)) +} + +// MobileGTE applies the GTE predicate on the "mobile" field. +func MobileGTE(v int) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldGTE(FieldMobile, v)) +} + +// MobileLT applies the LT predicate on the "mobile" field. +func MobileLT(v int) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldLT(FieldMobile, v)) +} + +// MobileLTE applies the LTE predicate on the "mobile" field. +func MobileLTE(v int) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldLTE(FieldMobile, v)) +} + +// BotEQ applies the EQ predicate on the "bot" field. +func BotEQ(v int) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEQ(FieldBot, v)) +} + +// BotNEQ applies the NEQ predicate on the "bot" field. +func BotNEQ(v int) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldNEQ(FieldBot, v)) +} + +// BotIn applies the In predicate on the "bot" field. +func BotIn(vs ...int) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldIn(FieldBot, vs...)) +} + +// BotNotIn applies the NotIn predicate on the "bot" field. +func BotNotIn(vs ...int) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldNotIn(FieldBot, vs...)) +} + +// BotGT applies the GT predicate on the "bot" field. +func BotGT(v int) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldGT(FieldBot, v)) +} + +// BotGTE applies the GTE predicate on the "bot" field. +func BotGTE(v int) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldGTE(FieldBot, v)) +} + +// BotLT applies the LT predicate on the "bot" field. +func BotLT(v int) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldLT(FieldBot, v)) +} + +// BotLTE applies the LTE predicate on the "bot" field. +func BotLTE(v int) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldLTE(FieldBot, v)) +} + +// MozillaEQ applies the EQ predicate on the "mozilla" field. +func MozillaEQ(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEQ(FieldMozilla, v)) +} + +// MozillaNEQ applies the NEQ predicate on the "mozilla" field. +func MozillaNEQ(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldNEQ(FieldMozilla, v)) +} + +// MozillaIn applies the In predicate on the "mozilla" field. +func MozillaIn(vs ...string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldIn(FieldMozilla, vs...)) +} + +// MozillaNotIn applies the NotIn predicate on the "mozilla" field. +func MozillaNotIn(vs ...string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldNotIn(FieldMozilla, vs...)) +} + +// MozillaGT applies the GT predicate on the "mozilla" field. +func MozillaGT(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldGT(FieldMozilla, v)) +} + +// MozillaGTE applies the GTE predicate on the "mozilla" field. +func MozillaGTE(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldGTE(FieldMozilla, v)) +} + +// MozillaLT applies the LT predicate on the "mozilla" field. +func MozillaLT(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldLT(FieldMozilla, v)) +} + +// MozillaLTE applies the LTE predicate on the "mozilla" field. +func MozillaLTE(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldLTE(FieldMozilla, v)) +} + +// MozillaContains applies the Contains predicate on the "mozilla" field. +func MozillaContains(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldContains(FieldMozilla, v)) +} + +// MozillaHasPrefix applies the HasPrefix predicate on the "mozilla" field. +func MozillaHasPrefix(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldHasPrefix(FieldMozilla, v)) +} + +// MozillaHasSuffix applies the HasSuffix predicate on the "mozilla" field. +func MozillaHasSuffix(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldHasSuffix(FieldMozilla, v)) +} + +// MozillaEqualFold applies the EqualFold predicate on the "mozilla" field. +func MozillaEqualFold(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEqualFold(FieldMozilla, v)) +} + +// MozillaContainsFold applies the ContainsFold predicate on the "mozilla" field. +func MozillaContainsFold(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldContainsFold(FieldMozilla, v)) +} + +// PlatformEQ applies the EQ predicate on the "platform" field. +func PlatformEQ(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEQ(FieldPlatform, v)) +} + +// PlatformNEQ applies the NEQ predicate on the "platform" field. +func PlatformNEQ(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldNEQ(FieldPlatform, v)) +} + +// PlatformIn applies the In predicate on the "platform" field. +func PlatformIn(vs ...string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldIn(FieldPlatform, vs...)) +} + +// PlatformNotIn applies the NotIn predicate on the "platform" field. +func PlatformNotIn(vs ...string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldNotIn(FieldPlatform, vs...)) +} + +// PlatformGT applies the GT predicate on the "platform" field. +func PlatformGT(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldGT(FieldPlatform, v)) +} + +// PlatformGTE applies the GTE predicate on the "platform" field. +func PlatformGTE(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldGTE(FieldPlatform, v)) +} + +// PlatformLT applies the LT predicate on the "platform" field. +func PlatformLT(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldLT(FieldPlatform, v)) +} + +// PlatformLTE applies the LTE predicate on the "platform" field. +func PlatformLTE(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldLTE(FieldPlatform, v)) +} + +// PlatformContains applies the Contains predicate on the "platform" field. +func PlatformContains(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldContains(FieldPlatform, v)) +} + +// PlatformHasPrefix applies the HasPrefix predicate on the "platform" field. +func PlatformHasPrefix(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldHasPrefix(FieldPlatform, v)) +} + +// PlatformHasSuffix applies the HasSuffix predicate on the "platform" field. +func PlatformHasSuffix(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldHasSuffix(FieldPlatform, v)) +} + +// PlatformEqualFold applies the EqualFold predicate on the "platform" field. +func PlatformEqualFold(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEqualFold(FieldPlatform, v)) +} + +// PlatformContainsFold applies the ContainsFold predicate on the "platform" field. +func PlatformContainsFold(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldContainsFold(FieldPlatform, v)) +} + +// EngineNameEQ applies the EQ predicate on the "engine_name" field. +func EngineNameEQ(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEQ(FieldEngineName, v)) +} + +// EngineNameNEQ applies the NEQ predicate on the "engine_name" field. +func EngineNameNEQ(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldNEQ(FieldEngineName, v)) +} + +// EngineNameIn applies the In predicate on the "engine_name" field. +func EngineNameIn(vs ...string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldIn(FieldEngineName, vs...)) +} + +// EngineNameNotIn applies the NotIn predicate on the "engine_name" field. +func EngineNameNotIn(vs ...string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldNotIn(FieldEngineName, vs...)) +} + +// EngineNameGT applies the GT predicate on the "engine_name" field. +func EngineNameGT(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldGT(FieldEngineName, v)) +} + +// EngineNameGTE applies the GTE predicate on the "engine_name" field. +func EngineNameGTE(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldGTE(FieldEngineName, v)) +} + +// EngineNameLT applies the LT predicate on the "engine_name" field. +func EngineNameLT(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldLT(FieldEngineName, v)) +} + +// EngineNameLTE applies the LTE predicate on the "engine_name" field. +func EngineNameLTE(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldLTE(FieldEngineName, v)) +} + +// EngineNameContains applies the Contains predicate on the "engine_name" field. +func EngineNameContains(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldContains(FieldEngineName, v)) +} + +// EngineNameHasPrefix applies the HasPrefix predicate on the "engine_name" field. +func EngineNameHasPrefix(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldHasPrefix(FieldEngineName, v)) +} + +// EngineNameHasSuffix applies the HasSuffix predicate on the "engine_name" field. +func EngineNameHasSuffix(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldHasSuffix(FieldEngineName, v)) +} + +// EngineNameEqualFold applies the EqualFold predicate on the "engine_name" field. +func EngineNameEqualFold(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEqualFold(FieldEngineName, v)) +} + +// EngineNameContainsFold applies the ContainsFold predicate on the "engine_name" field. +func EngineNameContainsFold(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldContainsFold(FieldEngineName, v)) +} + +// EngineVersionEQ applies the EQ predicate on the "engine_version" field. +func EngineVersionEQ(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEQ(FieldEngineVersion, v)) +} + +// EngineVersionNEQ applies the NEQ predicate on the "engine_version" field. +func EngineVersionNEQ(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldNEQ(FieldEngineVersion, v)) +} + +// EngineVersionIn applies the In predicate on the "engine_version" field. +func EngineVersionIn(vs ...string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldIn(FieldEngineVersion, vs...)) +} + +// EngineVersionNotIn applies the NotIn predicate on the "engine_version" field. +func EngineVersionNotIn(vs ...string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldNotIn(FieldEngineVersion, vs...)) +} + +// EngineVersionGT applies the GT predicate on the "engine_version" field. +func EngineVersionGT(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldGT(FieldEngineVersion, v)) +} + +// EngineVersionGTE applies the GTE predicate on the "engine_version" field. +func EngineVersionGTE(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldGTE(FieldEngineVersion, v)) +} + +// EngineVersionLT applies the LT predicate on the "engine_version" field. +func EngineVersionLT(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldLT(FieldEngineVersion, v)) +} + +// EngineVersionLTE applies the LTE predicate on the "engine_version" field. +func EngineVersionLTE(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldLTE(FieldEngineVersion, v)) +} + +// EngineVersionContains applies the Contains predicate on the "engine_version" field. +func EngineVersionContains(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldContains(FieldEngineVersion, v)) +} + +// EngineVersionHasPrefix applies the HasPrefix predicate on the "engine_version" field. +func EngineVersionHasPrefix(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldHasPrefix(FieldEngineVersion, v)) +} + +// EngineVersionHasSuffix applies the HasSuffix predicate on the "engine_version" field. +func EngineVersionHasSuffix(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldHasSuffix(FieldEngineVersion, v)) +} + +// EngineVersionEqualFold applies the EqualFold predicate on the "engine_version" field. +func EngineVersionEqualFold(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldEqualFold(FieldEngineVersion, v)) +} + +// EngineVersionContainsFold applies the ContainsFold predicate on the "engine_version" field. +func EngineVersionContainsFold(v string) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.FieldContainsFold(FieldEngineVersion, v)) +} + +// HasScaAuthUser applies the HasEdge predicate on the "sca_auth_user" edge. +func HasScaAuthUser() predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, ScaAuthUserTable, ScaAuthUserColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasScaAuthUserWith applies the HasEdge predicate on the "sca_auth_user" edge with a given conditions (other predicates). +func HasScaAuthUserWith(preds ...predicate.ScaAuthUser) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(func(s *sql.Selector) { + step := newScaAuthUserStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.ScaAuthUserDevice) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.ScaAuthUserDevice) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.ScaAuthUserDevice) predicate.ScaAuthUserDevice { + return predicate.ScaAuthUserDevice(sql.NotPredicates(p)) +} diff --git a/common/ent/scaauthuserdevice_create.go b/common/ent/scaauthuserdevice_create.go new file mode 100644 index 0000000..4aa7140 --- /dev/null +++ b/common/ent/scaauthuserdevice_create.go @@ -0,0 +1,522 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "schisandra-album-cloud-microservices/common/ent/scaauthuser" + "schisandra-album-cloud-microservices/common/ent/scaauthuserdevice" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ScaAuthUserDeviceCreate is the builder for creating a ScaAuthUserDevice entity. +type ScaAuthUserDeviceCreate struct { + config + mutation *ScaAuthUserDeviceMutation + hooks []Hook +} + +// SetUserID sets the "user_id" field. +func (saudc *ScaAuthUserDeviceCreate) SetUserID(s string) *ScaAuthUserDeviceCreate { + saudc.mutation.SetUserID(s) + return saudc +} + +// SetIP sets the "ip" field. +func (saudc *ScaAuthUserDeviceCreate) SetIP(s string) *ScaAuthUserDeviceCreate { + saudc.mutation.SetIP(s) + return saudc +} + +// SetLocation sets the "location" field. +func (saudc *ScaAuthUserDeviceCreate) SetLocation(s string) *ScaAuthUserDeviceCreate { + saudc.mutation.SetLocation(s) + return saudc +} + +// SetAgent sets the "agent" field. +func (saudc *ScaAuthUserDeviceCreate) SetAgent(s string) *ScaAuthUserDeviceCreate { + saudc.mutation.SetAgent(s) + return saudc +} + +// SetCreatedAt sets the "created_at" field. +func (saudc *ScaAuthUserDeviceCreate) SetCreatedAt(t time.Time) *ScaAuthUserDeviceCreate { + saudc.mutation.SetCreatedAt(t) + return saudc +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (saudc *ScaAuthUserDeviceCreate) SetNillableCreatedAt(t *time.Time) *ScaAuthUserDeviceCreate { + if t != nil { + saudc.SetCreatedAt(*t) + } + return saudc +} + +// SetUpdateAt sets the "update_at" field. +func (saudc *ScaAuthUserDeviceCreate) SetUpdateAt(t time.Time) *ScaAuthUserDeviceCreate { + saudc.mutation.SetUpdateAt(t) + return saudc +} + +// SetNillableUpdateAt sets the "update_at" field if the given value is not nil. +func (saudc *ScaAuthUserDeviceCreate) SetNillableUpdateAt(t *time.Time) *ScaAuthUserDeviceCreate { + if t != nil { + saudc.SetUpdateAt(*t) + } + return saudc +} + +// SetDeleted sets the "deleted" field. +func (saudc *ScaAuthUserDeviceCreate) SetDeleted(i int) *ScaAuthUserDeviceCreate { + saudc.mutation.SetDeleted(i) + return saudc +} + +// SetNillableDeleted sets the "deleted" field if the given value is not nil. +func (saudc *ScaAuthUserDeviceCreate) SetNillableDeleted(i *int) *ScaAuthUserDeviceCreate { + if i != nil { + saudc.SetDeleted(*i) + } + return saudc +} + +// SetBrowser sets the "browser" field. +func (saudc *ScaAuthUserDeviceCreate) SetBrowser(s string) *ScaAuthUserDeviceCreate { + saudc.mutation.SetBrowser(s) + return saudc +} + +// SetOperatingSystem sets the "operating_system" field. +func (saudc *ScaAuthUserDeviceCreate) SetOperatingSystem(s string) *ScaAuthUserDeviceCreate { + saudc.mutation.SetOperatingSystem(s) + return saudc +} + +// SetBrowserVersion sets the "browser_version" field. +func (saudc *ScaAuthUserDeviceCreate) SetBrowserVersion(s string) *ScaAuthUserDeviceCreate { + saudc.mutation.SetBrowserVersion(s) + return saudc +} + +// SetMobile sets the "mobile" field. +func (saudc *ScaAuthUserDeviceCreate) SetMobile(i int) *ScaAuthUserDeviceCreate { + saudc.mutation.SetMobile(i) + return saudc +} + +// SetBot sets the "bot" field. +func (saudc *ScaAuthUserDeviceCreate) SetBot(i int) *ScaAuthUserDeviceCreate { + saudc.mutation.SetBot(i) + return saudc +} + +// SetMozilla sets the "mozilla" field. +func (saudc *ScaAuthUserDeviceCreate) SetMozilla(s string) *ScaAuthUserDeviceCreate { + saudc.mutation.SetMozilla(s) + return saudc +} + +// SetPlatform sets the "platform" field. +func (saudc *ScaAuthUserDeviceCreate) SetPlatform(s string) *ScaAuthUserDeviceCreate { + saudc.mutation.SetPlatform(s) + return saudc +} + +// SetEngineName sets the "engine_name" field. +func (saudc *ScaAuthUserDeviceCreate) SetEngineName(s string) *ScaAuthUserDeviceCreate { + saudc.mutation.SetEngineName(s) + return saudc +} + +// SetEngineVersion sets the "engine_version" field. +func (saudc *ScaAuthUserDeviceCreate) SetEngineVersion(s string) *ScaAuthUserDeviceCreate { + saudc.mutation.SetEngineVersion(s) + return saudc +} + +// SetID sets the "id" field. +func (saudc *ScaAuthUserDeviceCreate) SetID(i int64) *ScaAuthUserDeviceCreate { + saudc.mutation.SetID(i) + return saudc +} + +// SetScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by ID. +func (saudc *ScaAuthUserDeviceCreate) SetScaAuthUserID(id int64) *ScaAuthUserDeviceCreate { + saudc.mutation.SetScaAuthUserID(id) + return saudc +} + +// SetNillableScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by ID if the given value is not nil. +func (saudc *ScaAuthUserDeviceCreate) SetNillableScaAuthUserID(id *int64) *ScaAuthUserDeviceCreate { + if id != nil { + saudc = saudc.SetScaAuthUserID(*id) + } + return saudc +} + +// SetScaAuthUser sets the "sca_auth_user" edge to the ScaAuthUser entity. +func (saudc *ScaAuthUserDeviceCreate) SetScaAuthUser(s *ScaAuthUser) *ScaAuthUserDeviceCreate { + return saudc.SetScaAuthUserID(s.ID) +} + +// Mutation returns the ScaAuthUserDeviceMutation object of the builder. +func (saudc *ScaAuthUserDeviceCreate) Mutation() *ScaAuthUserDeviceMutation { + return saudc.mutation +} + +// Save creates the ScaAuthUserDevice in the database. +func (saudc *ScaAuthUserDeviceCreate) Save(ctx context.Context) (*ScaAuthUserDevice, error) { + saudc.defaults() + return withHooks(ctx, saudc.sqlSave, saudc.mutation, saudc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (saudc *ScaAuthUserDeviceCreate) SaveX(ctx context.Context) *ScaAuthUserDevice { + v, err := saudc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (saudc *ScaAuthUserDeviceCreate) Exec(ctx context.Context) error { + _, err := saudc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (saudc *ScaAuthUserDeviceCreate) ExecX(ctx context.Context) { + if err := saudc.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (saudc *ScaAuthUserDeviceCreate) defaults() { + if _, ok := saudc.mutation.CreatedAt(); !ok { + v := scaauthuserdevice.DefaultCreatedAt() + saudc.mutation.SetCreatedAt(v) + } + if _, ok := saudc.mutation.UpdateAt(); !ok { + v := scaauthuserdevice.DefaultUpdateAt() + saudc.mutation.SetUpdateAt(v) + } + if _, ok := saudc.mutation.Deleted(); !ok { + v := scaauthuserdevice.DefaultDeleted + saudc.mutation.SetDeleted(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (saudc *ScaAuthUserDeviceCreate) check() error { + if _, ok := saudc.mutation.UserID(); !ok { + return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "ScaAuthUserDevice.user_id"`)} + } + if v, ok := saudc.mutation.UserID(); ok { + if err := scaauthuserdevice.UserIDValidator(v); err != nil { + return &ValidationError{Name: "user_id", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.user_id": %w`, err)} + } + } + if _, ok := saudc.mutation.IP(); !ok { + return &ValidationError{Name: "ip", err: errors.New(`ent: missing required field "ScaAuthUserDevice.ip"`)} + } + if v, ok := saudc.mutation.IP(); ok { + if err := scaauthuserdevice.IPValidator(v); err != nil { + return &ValidationError{Name: "ip", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.ip": %w`, err)} + } + } + if _, ok := saudc.mutation.Location(); !ok { + return &ValidationError{Name: "location", err: errors.New(`ent: missing required field "ScaAuthUserDevice.location"`)} + } + if v, ok := saudc.mutation.Location(); ok { + if err := scaauthuserdevice.LocationValidator(v); err != nil { + return &ValidationError{Name: "location", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.location": %w`, err)} + } + } + if _, ok := saudc.mutation.Agent(); !ok { + return &ValidationError{Name: "agent", err: errors.New(`ent: missing required field "ScaAuthUserDevice.agent"`)} + } + if v, ok := saudc.mutation.Agent(); ok { + if err := scaauthuserdevice.AgentValidator(v); err != nil { + return &ValidationError{Name: "agent", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.agent": %w`, err)} + } + } + if _, ok := saudc.mutation.UpdateAt(); !ok { + return &ValidationError{Name: "update_at", err: errors.New(`ent: missing required field "ScaAuthUserDevice.update_at"`)} + } + if _, ok := saudc.mutation.Deleted(); !ok { + return &ValidationError{Name: "deleted", err: errors.New(`ent: missing required field "ScaAuthUserDevice.deleted"`)} + } + if _, ok := saudc.mutation.Browser(); !ok { + return &ValidationError{Name: "browser", err: errors.New(`ent: missing required field "ScaAuthUserDevice.browser"`)} + } + if v, ok := saudc.mutation.Browser(); ok { + if err := scaauthuserdevice.BrowserValidator(v); err != nil { + return &ValidationError{Name: "browser", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.browser": %w`, err)} + } + } + if _, ok := saudc.mutation.OperatingSystem(); !ok { + return &ValidationError{Name: "operating_system", err: errors.New(`ent: missing required field "ScaAuthUserDevice.operating_system"`)} + } + if v, ok := saudc.mutation.OperatingSystem(); ok { + if err := scaauthuserdevice.OperatingSystemValidator(v); err != nil { + return &ValidationError{Name: "operating_system", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.operating_system": %w`, err)} + } + } + if _, ok := saudc.mutation.BrowserVersion(); !ok { + return &ValidationError{Name: "browser_version", err: errors.New(`ent: missing required field "ScaAuthUserDevice.browser_version"`)} + } + if v, ok := saudc.mutation.BrowserVersion(); ok { + if err := scaauthuserdevice.BrowserVersionValidator(v); err != nil { + return &ValidationError{Name: "browser_version", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.browser_version": %w`, err)} + } + } + if _, ok := saudc.mutation.Mobile(); !ok { + return &ValidationError{Name: "mobile", err: errors.New(`ent: missing required field "ScaAuthUserDevice.mobile"`)} + } + if _, ok := saudc.mutation.Bot(); !ok { + return &ValidationError{Name: "bot", err: errors.New(`ent: missing required field "ScaAuthUserDevice.bot"`)} + } + if _, ok := saudc.mutation.Mozilla(); !ok { + return &ValidationError{Name: "mozilla", err: errors.New(`ent: missing required field "ScaAuthUserDevice.mozilla"`)} + } + if v, ok := saudc.mutation.Mozilla(); ok { + if err := scaauthuserdevice.MozillaValidator(v); err != nil { + return &ValidationError{Name: "mozilla", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.mozilla": %w`, err)} + } + } + if _, ok := saudc.mutation.Platform(); !ok { + return &ValidationError{Name: "platform", err: errors.New(`ent: missing required field "ScaAuthUserDevice.platform"`)} + } + if v, ok := saudc.mutation.Platform(); ok { + if err := scaauthuserdevice.PlatformValidator(v); err != nil { + return &ValidationError{Name: "platform", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.platform": %w`, err)} + } + } + if _, ok := saudc.mutation.EngineName(); !ok { + return &ValidationError{Name: "engine_name", err: errors.New(`ent: missing required field "ScaAuthUserDevice.engine_name"`)} + } + if v, ok := saudc.mutation.EngineName(); ok { + if err := scaauthuserdevice.EngineNameValidator(v); err != nil { + return &ValidationError{Name: "engine_name", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.engine_name": %w`, err)} + } + } + if _, ok := saudc.mutation.EngineVersion(); !ok { + return &ValidationError{Name: "engine_version", err: errors.New(`ent: missing required field "ScaAuthUserDevice.engine_version"`)} + } + if v, ok := saudc.mutation.EngineVersion(); ok { + if err := scaauthuserdevice.EngineVersionValidator(v); err != nil { + return &ValidationError{Name: "engine_version", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.engine_version": %w`, err)} + } + } + return nil +} + +func (saudc *ScaAuthUserDeviceCreate) sqlSave(ctx context.Context) (*ScaAuthUserDevice, error) { + if err := saudc.check(); err != nil { + return nil, err + } + _node, _spec := saudc.createSpec() + if err := sqlgraph.CreateNode(ctx, saudc.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) + } + saudc.mutation.id = &_node.ID + saudc.mutation.done = true + return _node, nil +} + +func (saudc *ScaAuthUserDeviceCreate) createSpec() (*ScaAuthUserDevice, *sqlgraph.CreateSpec) { + var ( + _node = &ScaAuthUserDevice{config: saudc.config} + _spec = sqlgraph.NewCreateSpec(scaauthuserdevice.Table, sqlgraph.NewFieldSpec(scaauthuserdevice.FieldID, field.TypeInt64)) + ) + if id, ok := saudc.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := saudc.mutation.UserID(); ok { + _spec.SetField(scaauthuserdevice.FieldUserID, field.TypeString, value) + _node.UserID = value + } + if value, ok := saudc.mutation.IP(); ok { + _spec.SetField(scaauthuserdevice.FieldIP, field.TypeString, value) + _node.IP = value + } + if value, ok := saudc.mutation.Location(); ok { + _spec.SetField(scaauthuserdevice.FieldLocation, field.TypeString, value) + _node.Location = value + } + if value, ok := saudc.mutation.Agent(); ok { + _spec.SetField(scaauthuserdevice.FieldAgent, field.TypeString, value) + _node.Agent = value + } + if value, ok := saudc.mutation.CreatedAt(); ok { + _spec.SetField(scaauthuserdevice.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := saudc.mutation.UpdateAt(); ok { + _spec.SetField(scaauthuserdevice.FieldUpdateAt, field.TypeTime, value) + _node.UpdateAt = &value + } + if value, ok := saudc.mutation.Deleted(); ok { + _spec.SetField(scaauthuserdevice.FieldDeleted, field.TypeInt, value) + _node.Deleted = value + } + if value, ok := saudc.mutation.Browser(); ok { + _spec.SetField(scaauthuserdevice.FieldBrowser, field.TypeString, value) + _node.Browser = value + } + if value, ok := saudc.mutation.OperatingSystem(); ok { + _spec.SetField(scaauthuserdevice.FieldOperatingSystem, field.TypeString, value) + _node.OperatingSystem = value + } + if value, ok := saudc.mutation.BrowserVersion(); ok { + _spec.SetField(scaauthuserdevice.FieldBrowserVersion, field.TypeString, value) + _node.BrowserVersion = value + } + if value, ok := saudc.mutation.Mobile(); ok { + _spec.SetField(scaauthuserdevice.FieldMobile, field.TypeInt, value) + _node.Mobile = value + } + if value, ok := saudc.mutation.Bot(); ok { + _spec.SetField(scaauthuserdevice.FieldBot, field.TypeInt, value) + _node.Bot = value + } + if value, ok := saudc.mutation.Mozilla(); ok { + _spec.SetField(scaauthuserdevice.FieldMozilla, field.TypeString, value) + _node.Mozilla = value + } + if value, ok := saudc.mutation.Platform(); ok { + _spec.SetField(scaauthuserdevice.FieldPlatform, field.TypeString, value) + _node.Platform = value + } + if value, ok := saudc.mutation.EngineName(); ok { + _spec.SetField(scaauthuserdevice.FieldEngineName, field.TypeString, value) + _node.EngineName = value + } + if value, ok := saudc.mutation.EngineVersion(); ok { + _spec.SetField(scaauthuserdevice.FieldEngineVersion, field.TypeString, value) + _node.EngineVersion = value + } + if nodes := saudc.mutation.ScaAuthUserIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: scaauthuserdevice.ScaAuthUserTable, + Columns: []string{scaauthuserdevice.ScaAuthUserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.sca_auth_user_sca_auth_user_device = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// ScaAuthUserDeviceCreateBulk is the builder for creating many ScaAuthUserDevice entities in bulk. +type ScaAuthUserDeviceCreateBulk struct { + config + err error + builders []*ScaAuthUserDeviceCreate +} + +// Save creates the ScaAuthUserDevice entities in the database. +func (saudcb *ScaAuthUserDeviceCreateBulk) Save(ctx context.Context) ([]*ScaAuthUserDevice, error) { + if saudcb.err != nil { + return nil, saudcb.err + } + specs := make([]*sqlgraph.CreateSpec, len(saudcb.builders)) + nodes := make([]*ScaAuthUserDevice, len(saudcb.builders)) + mutators := make([]Mutator, len(saudcb.builders)) + for i := range saudcb.builders { + func(i int, root context.Context) { + builder := saudcb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*ScaAuthUserDeviceMutation) + 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, saudcb.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, saudcb.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, saudcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (saudcb *ScaAuthUserDeviceCreateBulk) SaveX(ctx context.Context) []*ScaAuthUserDevice { + v, err := saudcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (saudcb *ScaAuthUserDeviceCreateBulk) Exec(ctx context.Context) error { + _, err := saudcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (saudcb *ScaAuthUserDeviceCreateBulk) ExecX(ctx context.Context) { + if err := saudcb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/common/ent/scaauthuserdevice_delete.go b/common/ent/scaauthuserdevice_delete.go new file mode 100644 index 0000000..f043148 --- /dev/null +++ b/common/ent/scaauthuserdevice_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "schisandra-album-cloud-microservices/common/ent/predicate" + "schisandra-album-cloud-microservices/common/ent/scaauthuserdevice" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ScaAuthUserDeviceDelete is the builder for deleting a ScaAuthUserDevice entity. +type ScaAuthUserDeviceDelete struct { + config + hooks []Hook + mutation *ScaAuthUserDeviceMutation +} + +// Where appends a list predicates to the ScaAuthUserDeviceDelete builder. +func (saudd *ScaAuthUserDeviceDelete) Where(ps ...predicate.ScaAuthUserDevice) *ScaAuthUserDeviceDelete { + saudd.mutation.Where(ps...) + return saudd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (saudd *ScaAuthUserDeviceDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, saudd.sqlExec, saudd.mutation, saudd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (saudd *ScaAuthUserDeviceDelete) ExecX(ctx context.Context) int { + n, err := saudd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (saudd *ScaAuthUserDeviceDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(scaauthuserdevice.Table, sqlgraph.NewFieldSpec(scaauthuserdevice.FieldID, field.TypeInt64)) + if ps := saudd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, saudd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + saudd.mutation.done = true + return affected, err +} + +// ScaAuthUserDeviceDeleteOne is the builder for deleting a single ScaAuthUserDevice entity. +type ScaAuthUserDeviceDeleteOne struct { + saudd *ScaAuthUserDeviceDelete +} + +// Where appends a list predicates to the ScaAuthUserDeviceDelete builder. +func (sauddo *ScaAuthUserDeviceDeleteOne) Where(ps ...predicate.ScaAuthUserDevice) *ScaAuthUserDeviceDeleteOne { + sauddo.saudd.mutation.Where(ps...) + return sauddo +} + +// Exec executes the deletion query. +func (sauddo *ScaAuthUserDeviceDeleteOne) Exec(ctx context.Context) error { + n, err := sauddo.saudd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{scaauthuserdevice.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (sauddo *ScaAuthUserDeviceDeleteOne) ExecX(ctx context.Context) { + if err := sauddo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/common/ent/scaauthuserdevice_query.go b/common/ent/scaauthuserdevice_query.go new file mode 100644 index 0000000..c9fdf54 --- /dev/null +++ b/common/ent/scaauthuserdevice_query.go @@ -0,0 +1,614 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + "schisandra-album-cloud-microservices/common/ent/predicate" + "schisandra-album-cloud-microservices/common/ent/scaauthuser" + "schisandra-album-cloud-microservices/common/ent/scaauthuserdevice" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ScaAuthUserDeviceQuery is the builder for querying ScaAuthUserDevice entities. +type ScaAuthUserDeviceQuery struct { + config + ctx *QueryContext + order []scaauthuserdevice.OrderOption + inters []Interceptor + predicates []predicate.ScaAuthUserDevice + withScaAuthUser *ScaAuthUserQuery + withFKs bool + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the ScaAuthUserDeviceQuery builder. +func (saudq *ScaAuthUserDeviceQuery) Where(ps ...predicate.ScaAuthUserDevice) *ScaAuthUserDeviceQuery { + saudq.predicates = append(saudq.predicates, ps...) + return saudq +} + +// Limit the number of records to be returned by this query. +func (saudq *ScaAuthUserDeviceQuery) Limit(limit int) *ScaAuthUserDeviceQuery { + saudq.ctx.Limit = &limit + return saudq +} + +// Offset to start from. +func (saudq *ScaAuthUserDeviceQuery) Offset(offset int) *ScaAuthUserDeviceQuery { + saudq.ctx.Offset = &offset + return saudq +} + +// 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 (saudq *ScaAuthUserDeviceQuery) Unique(unique bool) *ScaAuthUserDeviceQuery { + saudq.ctx.Unique = &unique + return saudq +} + +// Order specifies how the records should be ordered. +func (saudq *ScaAuthUserDeviceQuery) Order(o ...scaauthuserdevice.OrderOption) *ScaAuthUserDeviceQuery { + saudq.order = append(saudq.order, o...) + return saudq +} + +// QueryScaAuthUser chains the current query on the "sca_auth_user" edge. +func (saudq *ScaAuthUserDeviceQuery) QueryScaAuthUser() *ScaAuthUserQuery { + query := (&ScaAuthUserClient{config: saudq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := saudq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := saudq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(scaauthuserdevice.Table, scaauthuserdevice.FieldID, selector), + sqlgraph.To(scaauthuser.Table, scaauthuser.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, scaauthuserdevice.ScaAuthUserTable, scaauthuserdevice.ScaAuthUserColumn), + ) + fromU = sqlgraph.SetNeighbors(saudq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first ScaAuthUserDevice entity from the query. +// Returns a *NotFoundError when no ScaAuthUserDevice was found. +func (saudq *ScaAuthUserDeviceQuery) First(ctx context.Context) (*ScaAuthUserDevice, error) { + nodes, err := saudq.Limit(1).All(setContextOp(ctx, saudq.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{scaauthuserdevice.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (saudq *ScaAuthUserDeviceQuery) FirstX(ctx context.Context) *ScaAuthUserDevice { + node, err := saudq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first ScaAuthUserDevice ID from the query. +// Returns a *NotFoundError when no ScaAuthUserDevice ID was found. +func (saudq *ScaAuthUserDeviceQuery) FirstID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = saudq.Limit(1).IDs(setContextOp(ctx, saudq.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{scaauthuserdevice.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (saudq *ScaAuthUserDeviceQuery) FirstIDX(ctx context.Context) int64 { + id, err := saudq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single ScaAuthUserDevice entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one ScaAuthUserDevice entity is found. +// Returns a *NotFoundError when no ScaAuthUserDevice entities are found. +func (saudq *ScaAuthUserDeviceQuery) Only(ctx context.Context) (*ScaAuthUserDevice, error) { + nodes, err := saudq.Limit(2).All(setContextOp(ctx, saudq.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{scaauthuserdevice.Label} + default: + return nil, &NotSingularError{scaauthuserdevice.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (saudq *ScaAuthUserDeviceQuery) OnlyX(ctx context.Context) *ScaAuthUserDevice { + node, err := saudq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only ScaAuthUserDevice ID in the query. +// Returns a *NotSingularError when more than one ScaAuthUserDevice ID is found. +// Returns a *NotFoundError when no entities are found. +func (saudq *ScaAuthUserDeviceQuery) OnlyID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = saudq.Limit(2).IDs(setContextOp(ctx, saudq.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{scaauthuserdevice.Label} + default: + err = &NotSingularError{scaauthuserdevice.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (saudq *ScaAuthUserDeviceQuery) OnlyIDX(ctx context.Context) int64 { + id, err := saudq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of ScaAuthUserDevices. +func (saudq *ScaAuthUserDeviceQuery) All(ctx context.Context) ([]*ScaAuthUserDevice, error) { + ctx = setContextOp(ctx, saudq.ctx, ent.OpQueryAll) + if err := saudq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*ScaAuthUserDevice, *ScaAuthUserDeviceQuery]() + return withInterceptors[[]*ScaAuthUserDevice](ctx, saudq, qr, saudq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (saudq *ScaAuthUserDeviceQuery) AllX(ctx context.Context) []*ScaAuthUserDevice { + nodes, err := saudq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of ScaAuthUserDevice IDs. +func (saudq *ScaAuthUserDeviceQuery) IDs(ctx context.Context) (ids []int64, err error) { + if saudq.ctx.Unique == nil && saudq.path != nil { + saudq.Unique(true) + } + ctx = setContextOp(ctx, saudq.ctx, ent.OpQueryIDs) + if err = saudq.Select(scaauthuserdevice.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (saudq *ScaAuthUserDeviceQuery) IDsX(ctx context.Context) []int64 { + ids, err := saudq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (saudq *ScaAuthUserDeviceQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, saudq.ctx, ent.OpQueryCount) + if err := saudq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, saudq, querierCount[*ScaAuthUserDeviceQuery](), saudq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (saudq *ScaAuthUserDeviceQuery) CountX(ctx context.Context) int { + count, err := saudq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (saudq *ScaAuthUserDeviceQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, saudq.ctx, ent.OpQueryExist) + switch _, err := saudq.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 (saudq *ScaAuthUserDeviceQuery) ExistX(ctx context.Context) bool { + exist, err := saudq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the ScaAuthUserDeviceQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (saudq *ScaAuthUserDeviceQuery) Clone() *ScaAuthUserDeviceQuery { + if saudq == nil { + return nil + } + return &ScaAuthUserDeviceQuery{ + config: saudq.config, + ctx: saudq.ctx.Clone(), + order: append([]scaauthuserdevice.OrderOption{}, saudq.order...), + inters: append([]Interceptor{}, saudq.inters...), + predicates: append([]predicate.ScaAuthUserDevice{}, saudq.predicates...), + withScaAuthUser: saudq.withScaAuthUser.Clone(), + // clone intermediate query. + sql: saudq.sql.Clone(), + path: saudq.path, + } +} + +// WithScaAuthUser tells the query-builder to eager-load the nodes that are connected to +// the "sca_auth_user" edge. The optional arguments are used to configure the query builder of the edge. +func (saudq *ScaAuthUserDeviceQuery) WithScaAuthUser(opts ...func(*ScaAuthUserQuery)) *ScaAuthUserDeviceQuery { + query := (&ScaAuthUserClient{config: saudq.config}).Query() + for _, opt := range opts { + opt(query) + } + saudq.withScaAuthUser = query + return saudq +} + +// 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 { +// UserID string `json:"user_id,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.ScaAuthUserDevice.Query(). +// GroupBy(scaauthuserdevice.FieldUserID). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (saudq *ScaAuthUserDeviceQuery) GroupBy(field string, fields ...string) *ScaAuthUserDeviceGroupBy { + saudq.ctx.Fields = append([]string{field}, fields...) + grbuild := &ScaAuthUserDeviceGroupBy{build: saudq} + grbuild.flds = &saudq.ctx.Fields + grbuild.label = scaauthuserdevice.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 { +// UserID string `json:"user_id,omitempty"` +// } +// +// client.ScaAuthUserDevice.Query(). +// Select(scaauthuserdevice.FieldUserID). +// Scan(ctx, &v) +func (saudq *ScaAuthUserDeviceQuery) Select(fields ...string) *ScaAuthUserDeviceSelect { + saudq.ctx.Fields = append(saudq.ctx.Fields, fields...) + sbuild := &ScaAuthUserDeviceSelect{ScaAuthUserDeviceQuery: saudq} + sbuild.label = scaauthuserdevice.Label + sbuild.flds, sbuild.scan = &saudq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a ScaAuthUserDeviceSelect configured with the given aggregations. +func (saudq *ScaAuthUserDeviceQuery) Aggregate(fns ...AggregateFunc) *ScaAuthUserDeviceSelect { + return saudq.Select().Aggregate(fns...) +} + +func (saudq *ScaAuthUserDeviceQuery) prepareQuery(ctx context.Context) error { + for _, inter := range saudq.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, saudq); err != nil { + return err + } + } + } + for _, f := range saudq.ctx.Fields { + if !scaauthuserdevice.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if saudq.path != nil { + prev, err := saudq.path(ctx) + if err != nil { + return err + } + saudq.sql = prev + } + return nil +} + +func (saudq *ScaAuthUserDeviceQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ScaAuthUserDevice, error) { + var ( + nodes = []*ScaAuthUserDevice{} + withFKs = saudq.withFKs + _spec = saudq.querySpec() + loadedTypes = [1]bool{ + saudq.withScaAuthUser != nil, + } + ) + if saudq.withScaAuthUser != nil { + withFKs = true + } + if withFKs { + _spec.Node.Columns = append(_spec.Node.Columns, scaauthuserdevice.ForeignKeys...) + } + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*ScaAuthUserDevice).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &ScaAuthUserDevice{config: saudq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, saudq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := saudq.withScaAuthUser; query != nil { + if err := saudq.loadScaAuthUser(ctx, query, nodes, nil, + func(n *ScaAuthUserDevice, e *ScaAuthUser) { n.Edges.ScaAuthUser = e }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (saudq *ScaAuthUserDeviceQuery) loadScaAuthUser(ctx context.Context, query *ScaAuthUserQuery, nodes []*ScaAuthUserDevice, init func(*ScaAuthUserDevice), assign func(*ScaAuthUserDevice, *ScaAuthUser)) error { + ids := make([]int64, 0, len(nodes)) + nodeids := make(map[int64][]*ScaAuthUserDevice) + for i := range nodes { + if nodes[i].sca_auth_user_sca_auth_user_device == nil { + continue + } + fk := *nodes[i].sca_auth_user_sca_auth_user_device + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(scaauthuser.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "sca_auth_user_sca_auth_user_device" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + +func (saudq *ScaAuthUserDeviceQuery) sqlCount(ctx context.Context) (int, error) { + _spec := saudq.querySpec() + _spec.Node.Columns = saudq.ctx.Fields + if len(saudq.ctx.Fields) > 0 { + _spec.Unique = saudq.ctx.Unique != nil && *saudq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, saudq.driver, _spec) +} + +func (saudq *ScaAuthUserDeviceQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(scaauthuserdevice.Table, scaauthuserdevice.Columns, sqlgraph.NewFieldSpec(scaauthuserdevice.FieldID, field.TypeInt64)) + _spec.From = saudq.sql + if unique := saudq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if saudq.path != nil { + _spec.Unique = true + } + if fields := saudq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, scaauthuserdevice.FieldID) + for i := range fields { + if fields[i] != scaauthuserdevice.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := saudq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := saudq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := saudq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := saudq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (saudq *ScaAuthUserDeviceQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(saudq.driver.Dialect()) + t1 := builder.Table(scaauthuserdevice.Table) + columns := saudq.ctx.Fields + if len(columns) == 0 { + columns = scaauthuserdevice.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if saudq.sql != nil { + selector = saudq.sql + selector.Select(selector.Columns(columns...)...) + } + if saudq.ctx.Unique != nil && *saudq.ctx.Unique { + selector.Distinct() + } + for _, p := range saudq.predicates { + p(selector) + } + for _, p := range saudq.order { + p(selector) + } + if offset := saudq.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 := saudq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// ScaAuthUserDeviceGroupBy is the group-by builder for ScaAuthUserDevice entities. +type ScaAuthUserDeviceGroupBy struct { + selector + build *ScaAuthUserDeviceQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (saudgb *ScaAuthUserDeviceGroupBy) Aggregate(fns ...AggregateFunc) *ScaAuthUserDeviceGroupBy { + saudgb.fns = append(saudgb.fns, fns...) + return saudgb +} + +// Scan applies the selector query and scans the result into the given value. +func (saudgb *ScaAuthUserDeviceGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, saudgb.build.ctx, ent.OpQueryGroupBy) + if err := saudgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ScaAuthUserDeviceQuery, *ScaAuthUserDeviceGroupBy](ctx, saudgb.build, saudgb, saudgb.build.inters, v) +} + +func (saudgb *ScaAuthUserDeviceGroupBy) sqlScan(ctx context.Context, root *ScaAuthUserDeviceQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(saudgb.fns)) + for _, fn := range saudgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*saudgb.flds)+len(saudgb.fns)) + for _, f := range *saudgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*saudgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := saudgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// ScaAuthUserDeviceSelect is the builder for selecting fields of ScaAuthUserDevice entities. +type ScaAuthUserDeviceSelect struct { + *ScaAuthUserDeviceQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (sauds *ScaAuthUserDeviceSelect) Aggregate(fns ...AggregateFunc) *ScaAuthUserDeviceSelect { + sauds.fns = append(sauds.fns, fns...) + return sauds +} + +// Scan applies the selector query and scans the result into the given value. +func (sauds *ScaAuthUserDeviceSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, sauds.ctx, ent.OpQuerySelect) + if err := sauds.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ScaAuthUserDeviceQuery, *ScaAuthUserDeviceSelect](ctx, sauds.ScaAuthUserDeviceQuery, sauds, sauds.inters, v) +} + +func (sauds *ScaAuthUserDeviceSelect) sqlScan(ctx context.Context, root *ScaAuthUserDeviceQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(sauds.fns)) + for _, fn := range sauds.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*sauds.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 := sauds.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/common/ent/scaauthuserdevice_update.go b/common/ent/scaauthuserdevice_update.go new file mode 100644 index 0000000..8521d81 --- /dev/null +++ b/common/ent/scaauthuserdevice_update.go @@ -0,0 +1,989 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "schisandra-album-cloud-microservices/common/ent/predicate" + "schisandra-album-cloud-microservices/common/ent/scaauthuser" + "schisandra-album-cloud-microservices/common/ent/scaauthuserdevice" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ScaAuthUserDeviceUpdate is the builder for updating ScaAuthUserDevice entities. +type ScaAuthUserDeviceUpdate struct { + config + hooks []Hook + mutation *ScaAuthUserDeviceMutation +} + +// Where appends a list predicates to the ScaAuthUserDeviceUpdate builder. +func (saudu *ScaAuthUserDeviceUpdate) Where(ps ...predicate.ScaAuthUserDevice) *ScaAuthUserDeviceUpdate { + saudu.mutation.Where(ps...) + return saudu +} + +// SetUserID sets the "user_id" field. +func (saudu *ScaAuthUserDeviceUpdate) SetUserID(s string) *ScaAuthUserDeviceUpdate { + saudu.mutation.SetUserID(s) + return saudu +} + +// SetNillableUserID sets the "user_id" field if the given value is not nil. +func (saudu *ScaAuthUserDeviceUpdate) SetNillableUserID(s *string) *ScaAuthUserDeviceUpdate { + if s != nil { + saudu.SetUserID(*s) + } + return saudu +} + +// SetIP sets the "ip" field. +func (saudu *ScaAuthUserDeviceUpdate) SetIP(s string) *ScaAuthUserDeviceUpdate { + saudu.mutation.SetIP(s) + return saudu +} + +// SetNillableIP sets the "ip" field if the given value is not nil. +func (saudu *ScaAuthUserDeviceUpdate) SetNillableIP(s *string) *ScaAuthUserDeviceUpdate { + if s != nil { + saudu.SetIP(*s) + } + return saudu +} + +// SetLocation sets the "location" field. +func (saudu *ScaAuthUserDeviceUpdate) SetLocation(s string) *ScaAuthUserDeviceUpdate { + saudu.mutation.SetLocation(s) + return saudu +} + +// SetNillableLocation sets the "location" field if the given value is not nil. +func (saudu *ScaAuthUserDeviceUpdate) SetNillableLocation(s *string) *ScaAuthUserDeviceUpdate { + if s != nil { + saudu.SetLocation(*s) + } + return saudu +} + +// SetAgent sets the "agent" field. +func (saudu *ScaAuthUserDeviceUpdate) SetAgent(s string) *ScaAuthUserDeviceUpdate { + saudu.mutation.SetAgent(s) + return saudu +} + +// SetNillableAgent sets the "agent" field if the given value is not nil. +func (saudu *ScaAuthUserDeviceUpdate) SetNillableAgent(s *string) *ScaAuthUserDeviceUpdate { + if s != nil { + saudu.SetAgent(*s) + } + return saudu +} + +// SetUpdateAt sets the "update_at" field. +func (saudu *ScaAuthUserDeviceUpdate) SetUpdateAt(t time.Time) *ScaAuthUserDeviceUpdate { + saudu.mutation.SetUpdateAt(t) + return saudu +} + +// SetDeleted sets the "deleted" field. +func (saudu *ScaAuthUserDeviceUpdate) SetDeleted(i int) *ScaAuthUserDeviceUpdate { + saudu.mutation.ResetDeleted() + saudu.mutation.SetDeleted(i) + return saudu +} + +// SetNillableDeleted sets the "deleted" field if the given value is not nil. +func (saudu *ScaAuthUserDeviceUpdate) SetNillableDeleted(i *int) *ScaAuthUserDeviceUpdate { + if i != nil { + saudu.SetDeleted(*i) + } + return saudu +} + +// AddDeleted adds i to the "deleted" field. +func (saudu *ScaAuthUserDeviceUpdate) AddDeleted(i int) *ScaAuthUserDeviceUpdate { + saudu.mutation.AddDeleted(i) + return saudu +} + +// SetBrowser sets the "browser" field. +func (saudu *ScaAuthUserDeviceUpdate) SetBrowser(s string) *ScaAuthUserDeviceUpdate { + saudu.mutation.SetBrowser(s) + return saudu +} + +// SetNillableBrowser sets the "browser" field if the given value is not nil. +func (saudu *ScaAuthUserDeviceUpdate) SetNillableBrowser(s *string) *ScaAuthUserDeviceUpdate { + if s != nil { + saudu.SetBrowser(*s) + } + return saudu +} + +// SetOperatingSystem sets the "operating_system" field. +func (saudu *ScaAuthUserDeviceUpdate) SetOperatingSystem(s string) *ScaAuthUserDeviceUpdate { + saudu.mutation.SetOperatingSystem(s) + return saudu +} + +// SetNillableOperatingSystem sets the "operating_system" field if the given value is not nil. +func (saudu *ScaAuthUserDeviceUpdate) SetNillableOperatingSystem(s *string) *ScaAuthUserDeviceUpdate { + if s != nil { + saudu.SetOperatingSystem(*s) + } + return saudu +} + +// SetBrowserVersion sets the "browser_version" field. +func (saudu *ScaAuthUserDeviceUpdate) SetBrowserVersion(s string) *ScaAuthUserDeviceUpdate { + saudu.mutation.SetBrowserVersion(s) + return saudu +} + +// SetNillableBrowserVersion sets the "browser_version" field if the given value is not nil. +func (saudu *ScaAuthUserDeviceUpdate) SetNillableBrowserVersion(s *string) *ScaAuthUserDeviceUpdate { + if s != nil { + saudu.SetBrowserVersion(*s) + } + return saudu +} + +// SetMobile sets the "mobile" field. +func (saudu *ScaAuthUserDeviceUpdate) SetMobile(i int) *ScaAuthUserDeviceUpdate { + saudu.mutation.ResetMobile() + saudu.mutation.SetMobile(i) + return saudu +} + +// SetNillableMobile sets the "mobile" field if the given value is not nil. +func (saudu *ScaAuthUserDeviceUpdate) SetNillableMobile(i *int) *ScaAuthUserDeviceUpdate { + if i != nil { + saudu.SetMobile(*i) + } + return saudu +} + +// AddMobile adds i to the "mobile" field. +func (saudu *ScaAuthUserDeviceUpdate) AddMobile(i int) *ScaAuthUserDeviceUpdate { + saudu.mutation.AddMobile(i) + return saudu +} + +// SetBot sets the "bot" field. +func (saudu *ScaAuthUserDeviceUpdate) SetBot(i int) *ScaAuthUserDeviceUpdate { + saudu.mutation.ResetBot() + saudu.mutation.SetBot(i) + return saudu +} + +// SetNillableBot sets the "bot" field if the given value is not nil. +func (saudu *ScaAuthUserDeviceUpdate) SetNillableBot(i *int) *ScaAuthUserDeviceUpdate { + if i != nil { + saudu.SetBot(*i) + } + return saudu +} + +// AddBot adds i to the "bot" field. +func (saudu *ScaAuthUserDeviceUpdate) AddBot(i int) *ScaAuthUserDeviceUpdate { + saudu.mutation.AddBot(i) + return saudu +} + +// SetMozilla sets the "mozilla" field. +func (saudu *ScaAuthUserDeviceUpdate) SetMozilla(s string) *ScaAuthUserDeviceUpdate { + saudu.mutation.SetMozilla(s) + return saudu +} + +// SetNillableMozilla sets the "mozilla" field if the given value is not nil. +func (saudu *ScaAuthUserDeviceUpdate) SetNillableMozilla(s *string) *ScaAuthUserDeviceUpdate { + if s != nil { + saudu.SetMozilla(*s) + } + return saudu +} + +// SetPlatform sets the "platform" field. +func (saudu *ScaAuthUserDeviceUpdate) SetPlatform(s string) *ScaAuthUserDeviceUpdate { + saudu.mutation.SetPlatform(s) + return saudu +} + +// SetNillablePlatform sets the "platform" field if the given value is not nil. +func (saudu *ScaAuthUserDeviceUpdate) SetNillablePlatform(s *string) *ScaAuthUserDeviceUpdate { + if s != nil { + saudu.SetPlatform(*s) + } + return saudu +} + +// SetEngineName sets the "engine_name" field. +func (saudu *ScaAuthUserDeviceUpdate) SetEngineName(s string) *ScaAuthUserDeviceUpdate { + saudu.mutation.SetEngineName(s) + return saudu +} + +// SetNillableEngineName sets the "engine_name" field if the given value is not nil. +func (saudu *ScaAuthUserDeviceUpdate) SetNillableEngineName(s *string) *ScaAuthUserDeviceUpdate { + if s != nil { + saudu.SetEngineName(*s) + } + return saudu +} + +// SetEngineVersion sets the "engine_version" field. +func (saudu *ScaAuthUserDeviceUpdate) SetEngineVersion(s string) *ScaAuthUserDeviceUpdate { + saudu.mutation.SetEngineVersion(s) + return saudu +} + +// SetNillableEngineVersion sets the "engine_version" field if the given value is not nil. +func (saudu *ScaAuthUserDeviceUpdate) SetNillableEngineVersion(s *string) *ScaAuthUserDeviceUpdate { + if s != nil { + saudu.SetEngineVersion(*s) + } + return saudu +} + +// SetScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by ID. +func (saudu *ScaAuthUserDeviceUpdate) SetScaAuthUserID(id int64) *ScaAuthUserDeviceUpdate { + saudu.mutation.SetScaAuthUserID(id) + return saudu +} + +// SetNillableScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by ID if the given value is not nil. +func (saudu *ScaAuthUserDeviceUpdate) SetNillableScaAuthUserID(id *int64) *ScaAuthUserDeviceUpdate { + if id != nil { + saudu = saudu.SetScaAuthUserID(*id) + } + return saudu +} + +// SetScaAuthUser sets the "sca_auth_user" edge to the ScaAuthUser entity. +func (saudu *ScaAuthUserDeviceUpdate) SetScaAuthUser(s *ScaAuthUser) *ScaAuthUserDeviceUpdate { + return saudu.SetScaAuthUserID(s.ID) +} + +// Mutation returns the ScaAuthUserDeviceMutation object of the builder. +func (saudu *ScaAuthUserDeviceUpdate) Mutation() *ScaAuthUserDeviceMutation { + return saudu.mutation +} + +// ClearScaAuthUser clears the "sca_auth_user" edge to the ScaAuthUser entity. +func (saudu *ScaAuthUserDeviceUpdate) ClearScaAuthUser() *ScaAuthUserDeviceUpdate { + saudu.mutation.ClearScaAuthUser() + return saudu +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (saudu *ScaAuthUserDeviceUpdate) Save(ctx context.Context) (int, error) { + saudu.defaults() + return withHooks(ctx, saudu.sqlSave, saudu.mutation, saudu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (saudu *ScaAuthUserDeviceUpdate) SaveX(ctx context.Context) int { + affected, err := saudu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (saudu *ScaAuthUserDeviceUpdate) Exec(ctx context.Context) error { + _, err := saudu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (saudu *ScaAuthUserDeviceUpdate) ExecX(ctx context.Context) { + if err := saudu.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (saudu *ScaAuthUserDeviceUpdate) defaults() { + if _, ok := saudu.mutation.UpdateAt(); !ok { + v := scaauthuserdevice.UpdateDefaultUpdateAt() + saudu.mutation.SetUpdateAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (saudu *ScaAuthUserDeviceUpdate) check() error { + if v, ok := saudu.mutation.UserID(); ok { + if err := scaauthuserdevice.UserIDValidator(v); err != nil { + return &ValidationError{Name: "user_id", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.user_id": %w`, err)} + } + } + if v, ok := saudu.mutation.IP(); ok { + if err := scaauthuserdevice.IPValidator(v); err != nil { + return &ValidationError{Name: "ip", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.ip": %w`, err)} + } + } + if v, ok := saudu.mutation.Location(); ok { + if err := scaauthuserdevice.LocationValidator(v); err != nil { + return &ValidationError{Name: "location", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.location": %w`, err)} + } + } + if v, ok := saudu.mutation.Agent(); ok { + if err := scaauthuserdevice.AgentValidator(v); err != nil { + return &ValidationError{Name: "agent", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.agent": %w`, err)} + } + } + if v, ok := saudu.mutation.Browser(); ok { + if err := scaauthuserdevice.BrowserValidator(v); err != nil { + return &ValidationError{Name: "browser", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.browser": %w`, err)} + } + } + if v, ok := saudu.mutation.OperatingSystem(); ok { + if err := scaauthuserdevice.OperatingSystemValidator(v); err != nil { + return &ValidationError{Name: "operating_system", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.operating_system": %w`, err)} + } + } + if v, ok := saudu.mutation.BrowserVersion(); ok { + if err := scaauthuserdevice.BrowserVersionValidator(v); err != nil { + return &ValidationError{Name: "browser_version", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.browser_version": %w`, err)} + } + } + if v, ok := saudu.mutation.Mozilla(); ok { + if err := scaauthuserdevice.MozillaValidator(v); err != nil { + return &ValidationError{Name: "mozilla", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.mozilla": %w`, err)} + } + } + if v, ok := saudu.mutation.Platform(); ok { + if err := scaauthuserdevice.PlatformValidator(v); err != nil { + return &ValidationError{Name: "platform", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.platform": %w`, err)} + } + } + if v, ok := saudu.mutation.EngineName(); ok { + if err := scaauthuserdevice.EngineNameValidator(v); err != nil { + return &ValidationError{Name: "engine_name", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.engine_name": %w`, err)} + } + } + if v, ok := saudu.mutation.EngineVersion(); ok { + if err := scaauthuserdevice.EngineVersionValidator(v); err != nil { + return &ValidationError{Name: "engine_version", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.engine_version": %w`, err)} + } + } + return nil +} + +func (saudu *ScaAuthUserDeviceUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := saudu.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(scaauthuserdevice.Table, scaauthuserdevice.Columns, sqlgraph.NewFieldSpec(scaauthuserdevice.FieldID, field.TypeInt64)) + if ps := saudu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := saudu.mutation.UserID(); ok { + _spec.SetField(scaauthuserdevice.FieldUserID, field.TypeString, value) + } + if value, ok := saudu.mutation.IP(); ok { + _spec.SetField(scaauthuserdevice.FieldIP, field.TypeString, value) + } + if value, ok := saudu.mutation.Location(); ok { + _spec.SetField(scaauthuserdevice.FieldLocation, field.TypeString, value) + } + if value, ok := saudu.mutation.Agent(); ok { + _spec.SetField(scaauthuserdevice.FieldAgent, field.TypeString, value) + } + if saudu.mutation.CreatedAtCleared() { + _spec.ClearField(scaauthuserdevice.FieldCreatedAt, field.TypeTime) + } + if value, ok := saudu.mutation.UpdateAt(); ok { + _spec.SetField(scaauthuserdevice.FieldUpdateAt, field.TypeTime, value) + } + if value, ok := saudu.mutation.Deleted(); ok { + _spec.SetField(scaauthuserdevice.FieldDeleted, field.TypeInt, value) + } + if value, ok := saudu.mutation.AddedDeleted(); ok { + _spec.AddField(scaauthuserdevice.FieldDeleted, field.TypeInt, value) + } + if value, ok := saudu.mutation.Browser(); ok { + _spec.SetField(scaauthuserdevice.FieldBrowser, field.TypeString, value) + } + if value, ok := saudu.mutation.OperatingSystem(); ok { + _spec.SetField(scaauthuserdevice.FieldOperatingSystem, field.TypeString, value) + } + if value, ok := saudu.mutation.BrowserVersion(); ok { + _spec.SetField(scaauthuserdevice.FieldBrowserVersion, field.TypeString, value) + } + if value, ok := saudu.mutation.Mobile(); ok { + _spec.SetField(scaauthuserdevice.FieldMobile, field.TypeInt, value) + } + if value, ok := saudu.mutation.AddedMobile(); ok { + _spec.AddField(scaauthuserdevice.FieldMobile, field.TypeInt, value) + } + if value, ok := saudu.mutation.Bot(); ok { + _spec.SetField(scaauthuserdevice.FieldBot, field.TypeInt, value) + } + if value, ok := saudu.mutation.AddedBot(); ok { + _spec.AddField(scaauthuserdevice.FieldBot, field.TypeInt, value) + } + if value, ok := saudu.mutation.Mozilla(); ok { + _spec.SetField(scaauthuserdevice.FieldMozilla, field.TypeString, value) + } + if value, ok := saudu.mutation.Platform(); ok { + _spec.SetField(scaauthuserdevice.FieldPlatform, field.TypeString, value) + } + if value, ok := saudu.mutation.EngineName(); ok { + _spec.SetField(scaauthuserdevice.FieldEngineName, field.TypeString, value) + } + if value, ok := saudu.mutation.EngineVersion(); ok { + _spec.SetField(scaauthuserdevice.FieldEngineVersion, field.TypeString, value) + } + if saudu.mutation.ScaAuthUserCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: scaauthuserdevice.ScaAuthUserTable, + Columns: []string{scaauthuserdevice.ScaAuthUserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := saudu.mutation.ScaAuthUserIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: scaauthuserdevice.ScaAuthUserTable, + Columns: []string{scaauthuserdevice.ScaAuthUserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if n, err = sqlgraph.UpdateNodes(ctx, saudu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{scaauthuserdevice.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + saudu.mutation.done = true + return n, nil +} + +// ScaAuthUserDeviceUpdateOne is the builder for updating a single ScaAuthUserDevice entity. +type ScaAuthUserDeviceUpdateOne struct { + config + fields []string + hooks []Hook + mutation *ScaAuthUserDeviceMutation +} + +// SetUserID sets the "user_id" field. +func (sauduo *ScaAuthUserDeviceUpdateOne) SetUserID(s string) *ScaAuthUserDeviceUpdateOne { + sauduo.mutation.SetUserID(s) + return sauduo +} + +// SetNillableUserID sets the "user_id" field if the given value is not nil. +func (sauduo *ScaAuthUserDeviceUpdateOne) SetNillableUserID(s *string) *ScaAuthUserDeviceUpdateOne { + if s != nil { + sauduo.SetUserID(*s) + } + return sauduo +} + +// SetIP sets the "ip" field. +func (sauduo *ScaAuthUserDeviceUpdateOne) SetIP(s string) *ScaAuthUserDeviceUpdateOne { + sauduo.mutation.SetIP(s) + return sauduo +} + +// SetNillableIP sets the "ip" field if the given value is not nil. +func (sauduo *ScaAuthUserDeviceUpdateOne) SetNillableIP(s *string) *ScaAuthUserDeviceUpdateOne { + if s != nil { + sauduo.SetIP(*s) + } + return sauduo +} + +// SetLocation sets the "location" field. +func (sauduo *ScaAuthUserDeviceUpdateOne) SetLocation(s string) *ScaAuthUserDeviceUpdateOne { + sauduo.mutation.SetLocation(s) + return sauduo +} + +// SetNillableLocation sets the "location" field if the given value is not nil. +func (sauduo *ScaAuthUserDeviceUpdateOne) SetNillableLocation(s *string) *ScaAuthUserDeviceUpdateOne { + if s != nil { + sauduo.SetLocation(*s) + } + return sauduo +} + +// SetAgent sets the "agent" field. +func (sauduo *ScaAuthUserDeviceUpdateOne) SetAgent(s string) *ScaAuthUserDeviceUpdateOne { + sauduo.mutation.SetAgent(s) + return sauduo +} + +// SetNillableAgent sets the "agent" field if the given value is not nil. +func (sauduo *ScaAuthUserDeviceUpdateOne) SetNillableAgent(s *string) *ScaAuthUserDeviceUpdateOne { + if s != nil { + sauduo.SetAgent(*s) + } + return sauduo +} + +// SetUpdateAt sets the "update_at" field. +func (sauduo *ScaAuthUserDeviceUpdateOne) SetUpdateAt(t time.Time) *ScaAuthUserDeviceUpdateOne { + sauduo.mutation.SetUpdateAt(t) + return sauduo +} + +// SetDeleted sets the "deleted" field. +func (sauduo *ScaAuthUserDeviceUpdateOne) SetDeleted(i int) *ScaAuthUserDeviceUpdateOne { + sauduo.mutation.ResetDeleted() + sauduo.mutation.SetDeleted(i) + return sauduo +} + +// SetNillableDeleted sets the "deleted" field if the given value is not nil. +func (sauduo *ScaAuthUserDeviceUpdateOne) SetNillableDeleted(i *int) *ScaAuthUserDeviceUpdateOne { + if i != nil { + sauduo.SetDeleted(*i) + } + return sauduo +} + +// AddDeleted adds i to the "deleted" field. +func (sauduo *ScaAuthUserDeviceUpdateOne) AddDeleted(i int) *ScaAuthUserDeviceUpdateOne { + sauduo.mutation.AddDeleted(i) + return sauduo +} + +// SetBrowser sets the "browser" field. +func (sauduo *ScaAuthUserDeviceUpdateOne) SetBrowser(s string) *ScaAuthUserDeviceUpdateOne { + sauduo.mutation.SetBrowser(s) + return sauduo +} + +// SetNillableBrowser sets the "browser" field if the given value is not nil. +func (sauduo *ScaAuthUserDeviceUpdateOne) SetNillableBrowser(s *string) *ScaAuthUserDeviceUpdateOne { + if s != nil { + sauduo.SetBrowser(*s) + } + return sauduo +} + +// SetOperatingSystem sets the "operating_system" field. +func (sauduo *ScaAuthUserDeviceUpdateOne) SetOperatingSystem(s string) *ScaAuthUserDeviceUpdateOne { + sauduo.mutation.SetOperatingSystem(s) + return sauduo +} + +// SetNillableOperatingSystem sets the "operating_system" field if the given value is not nil. +func (sauduo *ScaAuthUserDeviceUpdateOne) SetNillableOperatingSystem(s *string) *ScaAuthUserDeviceUpdateOne { + if s != nil { + sauduo.SetOperatingSystem(*s) + } + return sauduo +} + +// SetBrowserVersion sets the "browser_version" field. +func (sauduo *ScaAuthUserDeviceUpdateOne) SetBrowserVersion(s string) *ScaAuthUserDeviceUpdateOne { + sauduo.mutation.SetBrowserVersion(s) + return sauduo +} + +// SetNillableBrowserVersion sets the "browser_version" field if the given value is not nil. +func (sauduo *ScaAuthUserDeviceUpdateOne) SetNillableBrowserVersion(s *string) *ScaAuthUserDeviceUpdateOne { + if s != nil { + sauduo.SetBrowserVersion(*s) + } + return sauduo +} + +// SetMobile sets the "mobile" field. +func (sauduo *ScaAuthUserDeviceUpdateOne) SetMobile(i int) *ScaAuthUserDeviceUpdateOne { + sauduo.mutation.ResetMobile() + sauduo.mutation.SetMobile(i) + return sauduo +} + +// SetNillableMobile sets the "mobile" field if the given value is not nil. +func (sauduo *ScaAuthUserDeviceUpdateOne) SetNillableMobile(i *int) *ScaAuthUserDeviceUpdateOne { + if i != nil { + sauduo.SetMobile(*i) + } + return sauduo +} + +// AddMobile adds i to the "mobile" field. +func (sauduo *ScaAuthUserDeviceUpdateOne) AddMobile(i int) *ScaAuthUserDeviceUpdateOne { + sauduo.mutation.AddMobile(i) + return sauduo +} + +// SetBot sets the "bot" field. +func (sauduo *ScaAuthUserDeviceUpdateOne) SetBot(i int) *ScaAuthUserDeviceUpdateOne { + sauduo.mutation.ResetBot() + sauduo.mutation.SetBot(i) + return sauduo +} + +// SetNillableBot sets the "bot" field if the given value is not nil. +func (sauduo *ScaAuthUserDeviceUpdateOne) SetNillableBot(i *int) *ScaAuthUserDeviceUpdateOne { + if i != nil { + sauduo.SetBot(*i) + } + return sauduo +} + +// AddBot adds i to the "bot" field. +func (sauduo *ScaAuthUserDeviceUpdateOne) AddBot(i int) *ScaAuthUserDeviceUpdateOne { + sauduo.mutation.AddBot(i) + return sauduo +} + +// SetMozilla sets the "mozilla" field. +func (sauduo *ScaAuthUserDeviceUpdateOne) SetMozilla(s string) *ScaAuthUserDeviceUpdateOne { + sauduo.mutation.SetMozilla(s) + return sauduo +} + +// SetNillableMozilla sets the "mozilla" field if the given value is not nil. +func (sauduo *ScaAuthUserDeviceUpdateOne) SetNillableMozilla(s *string) *ScaAuthUserDeviceUpdateOne { + if s != nil { + sauduo.SetMozilla(*s) + } + return sauduo +} + +// SetPlatform sets the "platform" field. +func (sauduo *ScaAuthUserDeviceUpdateOne) SetPlatform(s string) *ScaAuthUserDeviceUpdateOne { + sauduo.mutation.SetPlatform(s) + return sauduo +} + +// SetNillablePlatform sets the "platform" field if the given value is not nil. +func (sauduo *ScaAuthUserDeviceUpdateOne) SetNillablePlatform(s *string) *ScaAuthUserDeviceUpdateOne { + if s != nil { + sauduo.SetPlatform(*s) + } + return sauduo +} + +// SetEngineName sets the "engine_name" field. +func (sauduo *ScaAuthUserDeviceUpdateOne) SetEngineName(s string) *ScaAuthUserDeviceUpdateOne { + sauduo.mutation.SetEngineName(s) + return sauduo +} + +// SetNillableEngineName sets the "engine_name" field if the given value is not nil. +func (sauduo *ScaAuthUserDeviceUpdateOne) SetNillableEngineName(s *string) *ScaAuthUserDeviceUpdateOne { + if s != nil { + sauduo.SetEngineName(*s) + } + return sauduo +} + +// SetEngineVersion sets the "engine_version" field. +func (sauduo *ScaAuthUserDeviceUpdateOne) SetEngineVersion(s string) *ScaAuthUserDeviceUpdateOne { + sauduo.mutation.SetEngineVersion(s) + return sauduo +} + +// SetNillableEngineVersion sets the "engine_version" field if the given value is not nil. +func (sauduo *ScaAuthUserDeviceUpdateOne) SetNillableEngineVersion(s *string) *ScaAuthUserDeviceUpdateOne { + if s != nil { + sauduo.SetEngineVersion(*s) + } + return sauduo +} + +// SetScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by ID. +func (sauduo *ScaAuthUserDeviceUpdateOne) SetScaAuthUserID(id int64) *ScaAuthUserDeviceUpdateOne { + sauduo.mutation.SetScaAuthUserID(id) + return sauduo +} + +// SetNillableScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by ID if the given value is not nil. +func (sauduo *ScaAuthUserDeviceUpdateOne) SetNillableScaAuthUserID(id *int64) *ScaAuthUserDeviceUpdateOne { + if id != nil { + sauduo = sauduo.SetScaAuthUserID(*id) + } + return sauduo +} + +// SetScaAuthUser sets the "sca_auth_user" edge to the ScaAuthUser entity. +func (sauduo *ScaAuthUserDeviceUpdateOne) SetScaAuthUser(s *ScaAuthUser) *ScaAuthUserDeviceUpdateOne { + return sauduo.SetScaAuthUserID(s.ID) +} + +// Mutation returns the ScaAuthUserDeviceMutation object of the builder. +func (sauduo *ScaAuthUserDeviceUpdateOne) Mutation() *ScaAuthUserDeviceMutation { + return sauduo.mutation +} + +// ClearScaAuthUser clears the "sca_auth_user" edge to the ScaAuthUser entity. +func (sauduo *ScaAuthUserDeviceUpdateOne) ClearScaAuthUser() *ScaAuthUserDeviceUpdateOne { + sauduo.mutation.ClearScaAuthUser() + return sauduo +} + +// Where appends a list predicates to the ScaAuthUserDeviceUpdate builder. +func (sauduo *ScaAuthUserDeviceUpdateOne) Where(ps ...predicate.ScaAuthUserDevice) *ScaAuthUserDeviceUpdateOne { + sauduo.mutation.Where(ps...) + return sauduo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (sauduo *ScaAuthUserDeviceUpdateOne) Select(field string, fields ...string) *ScaAuthUserDeviceUpdateOne { + sauduo.fields = append([]string{field}, fields...) + return sauduo +} + +// Save executes the query and returns the updated ScaAuthUserDevice entity. +func (sauduo *ScaAuthUserDeviceUpdateOne) Save(ctx context.Context) (*ScaAuthUserDevice, error) { + sauduo.defaults() + return withHooks(ctx, sauduo.sqlSave, sauduo.mutation, sauduo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (sauduo *ScaAuthUserDeviceUpdateOne) SaveX(ctx context.Context) *ScaAuthUserDevice { + node, err := sauduo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (sauduo *ScaAuthUserDeviceUpdateOne) Exec(ctx context.Context) error { + _, err := sauduo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (sauduo *ScaAuthUserDeviceUpdateOne) ExecX(ctx context.Context) { + if err := sauduo.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (sauduo *ScaAuthUserDeviceUpdateOne) defaults() { + if _, ok := sauduo.mutation.UpdateAt(); !ok { + v := scaauthuserdevice.UpdateDefaultUpdateAt() + sauduo.mutation.SetUpdateAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (sauduo *ScaAuthUserDeviceUpdateOne) check() error { + if v, ok := sauduo.mutation.UserID(); ok { + if err := scaauthuserdevice.UserIDValidator(v); err != nil { + return &ValidationError{Name: "user_id", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.user_id": %w`, err)} + } + } + if v, ok := sauduo.mutation.IP(); ok { + if err := scaauthuserdevice.IPValidator(v); err != nil { + return &ValidationError{Name: "ip", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.ip": %w`, err)} + } + } + if v, ok := sauduo.mutation.Location(); ok { + if err := scaauthuserdevice.LocationValidator(v); err != nil { + return &ValidationError{Name: "location", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.location": %w`, err)} + } + } + if v, ok := sauduo.mutation.Agent(); ok { + if err := scaauthuserdevice.AgentValidator(v); err != nil { + return &ValidationError{Name: "agent", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.agent": %w`, err)} + } + } + if v, ok := sauduo.mutation.Browser(); ok { + if err := scaauthuserdevice.BrowserValidator(v); err != nil { + return &ValidationError{Name: "browser", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.browser": %w`, err)} + } + } + if v, ok := sauduo.mutation.OperatingSystem(); ok { + if err := scaauthuserdevice.OperatingSystemValidator(v); err != nil { + return &ValidationError{Name: "operating_system", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.operating_system": %w`, err)} + } + } + if v, ok := sauduo.mutation.BrowserVersion(); ok { + if err := scaauthuserdevice.BrowserVersionValidator(v); err != nil { + return &ValidationError{Name: "browser_version", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.browser_version": %w`, err)} + } + } + if v, ok := sauduo.mutation.Mozilla(); ok { + if err := scaauthuserdevice.MozillaValidator(v); err != nil { + return &ValidationError{Name: "mozilla", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.mozilla": %w`, err)} + } + } + if v, ok := sauduo.mutation.Platform(); ok { + if err := scaauthuserdevice.PlatformValidator(v); err != nil { + return &ValidationError{Name: "platform", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.platform": %w`, err)} + } + } + if v, ok := sauduo.mutation.EngineName(); ok { + if err := scaauthuserdevice.EngineNameValidator(v); err != nil { + return &ValidationError{Name: "engine_name", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.engine_name": %w`, err)} + } + } + if v, ok := sauduo.mutation.EngineVersion(); ok { + if err := scaauthuserdevice.EngineVersionValidator(v); err != nil { + return &ValidationError{Name: "engine_version", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.engine_version": %w`, err)} + } + } + return nil +} + +func (sauduo *ScaAuthUserDeviceUpdateOne) sqlSave(ctx context.Context) (_node *ScaAuthUserDevice, err error) { + if err := sauduo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(scaauthuserdevice.Table, scaauthuserdevice.Columns, sqlgraph.NewFieldSpec(scaauthuserdevice.FieldID, field.TypeInt64)) + id, ok := sauduo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ScaAuthUserDevice.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := sauduo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, scaauthuserdevice.FieldID) + for _, f := range fields { + if !scaauthuserdevice.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != scaauthuserdevice.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := sauduo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := sauduo.mutation.UserID(); ok { + _spec.SetField(scaauthuserdevice.FieldUserID, field.TypeString, value) + } + if value, ok := sauduo.mutation.IP(); ok { + _spec.SetField(scaauthuserdevice.FieldIP, field.TypeString, value) + } + if value, ok := sauduo.mutation.Location(); ok { + _spec.SetField(scaauthuserdevice.FieldLocation, field.TypeString, value) + } + if value, ok := sauduo.mutation.Agent(); ok { + _spec.SetField(scaauthuserdevice.FieldAgent, field.TypeString, value) + } + if sauduo.mutation.CreatedAtCleared() { + _spec.ClearField(scaauthuserdevice.FieldCreatedAt, field.TypeTime) + } + if value, ok := sauduo.mutation.UpdateAt(); ok { + _spec.SetField(scaauthuserdevice.FieldUpdateAt, field.TypeTime, value) + } + if value, ok := sauduo.mutation.Deleted(); ok { + _spec.SetField(scaauthuserdevice.FieldDeleted, field.TypeInt, value) + } + if value, ok := sauduo.mutation.AddedDeleted(); ok { + _spec.AddField(scaauthuserdevice.FieldDeleted, field.TypeInt, value) + } + if value, ok := sauduo.mutation.Browser(); ok { + _spec.SetField(scaauthuserdevice.FieldBrowser, field.TypeString, value) + } + if value, ok := sauduo.mutation.OperatingSystem(); ok { + _spec.SetField(scaauthuserdevice.FieldOperatingSystem, field.TypeString, value) + } + if value, ok := sauduo.mutation.BrowserVersion(); ok { + _spec.SetField(scaauthuserdevice.FieldBrowserVersion, field.TypeString, value) + } + if value, ok := sauduo.mutation.Mobile(); ok { + _spec.SetField(scaauthuserdevice.FieldMobile, field.TypeInt, value) + } + if value, ok := sauduo.mutation.AddedMobile(); ok { + _spec.AddField(scaauthuserdevice.FieldMobile, field.TypeInt, value) + } + if value, ok := sauduo.mutation.Bot(); ok { + _spec.SetField(scaauthuserdevice.FieldBot, field.TypeInt, value) + } + if value, ok := sauduo.mutation.AddedBot(); ok { + _spec.AddField(scaauthuserdevice.FieldBot, field.TypeInt, value) + } + if value, ok := sauduo.mutation.Mozilla(); ok { + _spec.SetField(scaauthuserdevice.FieldMozilla, field.TypeString, value) + } + if value, ok := sauduo.mutation.Platform(); ok { + _spec.SetField(scaauthuserdevice.FieldPlatform, field.TypeString, value) + } + if value, ok := sauduo.mutation.EngineName(); ok { + _spec.SetField(scaauthuserdevice.FieldEngineName, field.TypeString, value) + } + if value, ok := sauduo.mutation.EngineVersion(); ok { + _spec.SetField(scaauthuserdevice.FieldEngineVersion, field.TypeString, value) + } + if sauduo.mutation.ScaAuthUserCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: scaauthuserdevice.ScaAuthUserTable, + Columns: []string{scaauthuserdevice.ScaAuthUserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := sauduo.mutation.ScaAuthUserIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: scaauthuserdevice.ScaAuthUserTable, + Columns: []string{scaauthuserdevice.ScaAuthUserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _node = &ScaAuthUserDevice{config: sauduo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, sauduo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{scaauthuserdevice.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + sauduo.mutation.done = true + return _node, nil +} diff --git a/common/ent/scaauthusersocial.go b/common/ent/scaauthusersocial.go new file mode 100644 index 0000000..c0747bd --- /dev/null +++ b/common/ent/scaauthusersocial.go @@ -0,0 +1,215 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "schisandra-album-cloud-microservices/common/ent/scaauthuser" + "schisandra-album-cloud-microservices/common/ent/scaauthusersocial" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// ScaAuthUserSocial is the model entity for the ScaAuthUserSocial schema. +type ScaAuthUserSocial struct { + config `json:"-"` + // ID of the ent. + // 主键ID + ID int64 `json:"id,omitempty"` + // 用户ID + UserID string `json:"user_id,omitempty"` + // 第三方用户的 open id + OpenID string `json:"open_id,omitempty"` + // 第三方用户来源 + Source string `json:"source,omitempty"` + // 状态 0正常 1 封禁 + Status int `json:"status,omitempty"` + // 创建时间 + CreatedAt time.Time `json:"created_at,omitempty"` + // 更新时间 + UpdateAt *time.Time `json:"update_at,omitempty"` + // 是否删除 + Deleted int `json:"deleted,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the ScaAuthUserSocialQuery when eager-loading is set. + Edges ScaAuthUserSocialEdges `json:"edges"` + sca_auth_user_sca_auth_user_social *int64 + selectValues sql.SelectValues +} + +// ScaAuthUserSocialEdges holds the relations/edges for other nodes in the graph. +type ScaAuthUserSocialEdges struct { + // ScaAuthUser holds the value of the sca_auth_user edge. + ScaAuthUser *ScaAuthUser `json:"sca_auth_user,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [1]bool +} + +// ScaAuthUserOrErr returns the ScaAuthUser value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e ScaAuthUserSocialEdges) ScaAuthUserOrErr() (*ScaAuthUser, error) { + if e.ScaAuthUser != nil { + return e.ScaAuthUser, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: scaauthuser.Label} + } + return nil, &NotLoadedError{edge: "sca_auth_user"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*ScaAuthUserSocial) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case scaauthusersocial.FieldID, scaauthusersocial.FieldStatus, scaauthusersocial.FieldDeleted: + values[i] = new(sql.NullInt64) + case scaauthusersocial.FieldUserID, scaauthusersocial.FieldOpenID, scaauthusersocial.FieldSource: + values[i] = new(sql.NullString) + case scaauthusersocial.FieldCreatedAt, scaauthusersocial.FieldUpdateAt: + values[i] = new(sql.NullTime) + case scaauthusersocial.ForeignKeys[0]: // sca_auth_user_sca_auth_user_social + values[i] = new(sql.NullInt64) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the ScaAuthUserSocial fields. +func (saus *ScaAuthUserSocial) 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 scaauthusersocial.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + saus.ID = int64(value.Int64) + case scaauthusersocial.FieldUserID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field user_id", values[i]) + } else if value.Valid { + saus.UserID = value.String + } + case scaauthusersocial.FieldOpenID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field open_id", values[i]) + } else if value.Valid { + saus.OpenID = value.String + } + case scaauthusersocial.FieldSource: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field source", values[i]) + } else if value.Valid { + saus.Source = value.String + } + case scaauthusersocial.FieldStatus: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field status", values[i]) + } else if value.Valid { + saus.Status = int(value.Int64) + } + case scaauthusersocial.FieldCreatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field created_at", values[i]) + } else if value.Valid { + saus.CreatedAt = value.Time + } + case scaauthusersocial.FieldUpdateAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field update_at", values[i]) + } else if value.Valid { + saus.UpdateAt = new(time.Time) + *saus.UpdateAt = value.Time + } + case scaauthusersocial.FieldDeleted: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field deleted", values[i]) + } else if value.Valid { + saus.Deleted = int(value.Int64) + } + case scaauthusersocial.ForeignKeys[0]: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for edge-field sca_auth_user_sca_auth_user_social", value) + } else if value.Valid { + saus.sca_auth_user_sca_auth_user_social = new(int64) + *saus.sca_auth_user_sca_auth_user_social = int64(value.Int64) + } + default: + saus.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the ScaAuthUserSocial. +// This includes values selected through modifiers, order, etc. +func (saus *ScaAuthUserSocial) Value(name string) (ent.Value, error) { + return saus.selectValues.Get(name) +} + +// QueryScaAuthUser queries the "sca_auth_user" edge of the ScaAuthUserSocial entity. +func (saus *ScaAuthUserSocial) QueryScaAuthUser() *ScaAuthUserQuery { + return NewScaAuthUserSocialClient(saus.config).QueryScaAuthUser(saus) +} + +// Update returns a builder for updating this ScaAuthUserSocial. +// Note that you need to call ScaAuthUserSocial.Unwrap() before calling this method if this ScaAuthUserSocial +// was returned from a transaction, and the transaction was committed or rolled back. +func (saus *ScaAuthUserSocial) Update() *ScaAuthUserSocialUpdateOne { + return NewScaAuthUserSocialClient(saus.config).UpdateOne(saus) +} + +// Unwrap unwraps the ScaAuthUserSocial 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 (saus *ScaAuthUserSocial) Unwrap() *ScaAuthUserSocial { + _tx, ok := saus.config.driver.(*txDriver) + if !ok { + panic("ent: ScaAuthUserSocial is not a transactional entity") + } + saus.config.driver = _tx.drv + return saus +} + +// String implements the fmt.Stringer. +func (saus *ScaAuthUserSocial) String() string { + var builder strings.Builder + builder.WriteString("ScaAuthUserSocial(") + builder.WriteString(fmt.Sprintf("id=%v, ", saus.ID)) + builder.WriteString("user_id=") + builder.WriteString(saus.UserID) + builder.WriteString(", ") + builder.WriteString("open_id=") + builder.WriteString(saus.OpenID) + builder.WriteString(", ") + builder.WriteString("source=") + builder.WriteString(saus.Source) + builder.WriteString(", ") + builder.WriteString("status=") + builder.WriteString(fmt.Sprintf("%v", saus.Status)) + builder.WriteString(", ") + builder.WriteString("created_at=") + builder.WriteString(saus.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + if v := saus.UpdateAt; v != nil { + builder.WriteString("update_at=") + builder.WriteString(v.Format(time.ANSIC)) + } + builder.WriteString(", ") + builder.WriteString("deleted=") + builder.WriteString(fmt.Sprintf("%v", saus.Deleted)) + builder.WriteByte(')') + return builder.String() +} + +// ScaAuthUserSocials is a parsable slice of ScaAuthUserSocial. +type ScaAuthUserSocials []*ScaAuthUserSocial diff --git a/common/ent/scaauthusersocial/scaauthusersocial.go b/common/ent/scaauthusersocial/scaauthusersocial.go new file mode 100644 index 0000000..d9a704f --- /dev/null +++ b/common/ent/scaauthusersocial/scaauthusersocial.go @@ -0,0 +1,151 @@ +// Code generated by ent, DO NOT EDIT. + +package scaauthusersocial + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the scaauthusersocial type in the database. + Label = "sca_auth_user_social" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldUserID holds the string denoting the user_id field in the database. + FieldUserID = "user_id" + // FieldOpenID holds the string denoting the open_id field in the database. + FieldOpenID = "open_id" + // FieldSource holds the string denoting the source field in the database. + FieldSource = "source" + // FieldStatus holds the string denoting the status field in the database. + FieldStatus = "status" + // FieldCreatedAt holds the string denoting the created_at field in the database. + FieldCreatedAt = "created_at" + // FieldUpdateAt holds the string denoting the update_at field in the database. + FieldUpdateAt = "update_at" + // FieldDeleted holds the string denoting the deleted field in the database. + FieldDeleted = "deleted" + // EdgeScaAuthUser holds the string denoting the sca_auth_user edge name in mutations. + EdgeScaAuthUser = "sca_auth_user" + // Table holds the table name of the scaauthusersocial in the database. + Table = "sca_auth_user_socials" + // ScaAuthUserTable is the table that holds the sca_auth_user relation/edge. + ScaAuthUserTable = "sca_auth_user_socials" + // ScaAuthUserInverseTable is the table name for the ScaAuthUser entity. + // It exists in this package in order to avoid circular dependency with the "scaauthuser" package. + ScaAuthUserInverseTable = "sca_auth_users" + // ScaAuthUserColumn is the table column denoting the sca_auth_user relation/edge. + ScaAuthUserColumn = "sca_auth_user_sca_auth_user_social" +) + +// Columns holds all SQL columns for scaauthusersocial fields. +var Columns = []string{ + FieldID, + FieldUserID, + FieldOpenID, + FieldSource, + FieldStatus, + FieldCreatedAt, + FieldUpdateAt, + FieldDeleted, +} + +// ForeignKeys holds the SQL foreign-keys that are owned by the "sca_auth_user_socials" +// table and are not defined as standalone fields in the schema. +var ForeignKeys = []string{ + "sca_auth_user_sca_auth_user_social", +} + +// 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 + } + } + for i := range ForeignKeys { + if column == ForeignKeys[i] { + return true + } + } + return false +} + +var ( + // UserIDValidator is a validator for the "user_id" field. It is called by the builders before save. + UserIDValidator func(string) error + // OpenIDValidator is a validator for the "open_id" field. It is called by the builders before save. + OpenIDValidator func(string) error + // SourceValidator is a validator for the "source" field. It is called by the builders before save. + SourceValidator func(string) error + // DefaultStatus holds the default value on creation for the "status" field. + DefaultStatus int + // DefaultCreatedAt holds the default value on creation for the "created_at" field. + DefaultCreatedAt func() time.Time + // DefaultUpdateAt holds the default value on creation for the "update_at" field. + DefaultUpdateAt func() time.Time + // UpdateDefaultUpdateAt holds the default value on update for the "update_at" field. + UpdateDefaultUpdateAt func() time.Time + // DefaultDeleted holds the default value on creation for the "deleted" field. + DefaultDeleted int +) + +// OrderOption defines the ordering options for the ScaAuthUserSocial 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() +} + +// ByUserID orders the results by the user_id field. +func ByUserID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUserID, opts...).ToFunc() +} + +// ByOpenID orders the results by the open_id field. +func ByOpenID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldOpenID, opts...).ToFunc() +} + +// BySource orders the results by the source field. +func BySource(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSource, opts...).ToFunc() +} + +// ByStatus orders the results by the status field. +func ByStatus(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStatus, opts...).ToFunc() +} + +// ByCreatedAt orders the results by the created_at field. +func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() +} + +// ByUpdateAt orders the results by the update_at field. +func ByUpdateAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateAt, opts...).ToFunc() +} + +// ByDeleted orders the results by the deleted field. +func ByDeleted(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeleted, opts...).ToFunc() +} + +// ByScaAuthUserField orders the results by sca_auth_user field. +func ByScaAuthUserField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newScaAuthUserStep(), sql.OrderByField(field, opts...)) + } +} +func newScaAuthUserStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ScaAuthUserInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, ScaAuthUserTable, ScaAuthUserColumn), + ) +} diff --git a/common/ent/scaauthusersocial/where.go b/common/ent/scaauthusersocial/where.go new file mode 100644 index 0000000..3e5b38e --- /dev/null +++ b/common/ent/scaauthusersocial/where.go @@ -0,0 +1,494 @@ +// Code generated by ent, DO NOT EDIT. + +package scaauthusersocial + +import ( + "schisandra-album-cloud-microservices/common/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id int64) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int64) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int64) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int64) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int64) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int64) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int64) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int64) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int64) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldLTE(FieldID, id)) +} + +// UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ. +func UserID(v string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldUserID, v)) +} + +// OpenID applies equality check predicate on the "open_id" field. It's identical to OpenIDEQ. +func OpenID(v string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldOpenID, v)) +} + +// Source applies equality check predicate on the "source" field. It's identical to SourceEQ. +func Source(v string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldSource, v)) +} + +// Status applies equality check predicate on the "status" field. It's identical to StatusEQ. +func Status(v int) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldStatus, v)) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldCreatedAt, v)) +} + +// UpdateAt applies equality check predicate on the "update_at" field. It's identical to UpdateAtEQ. +func UpdateAt(v time.Time) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldUpdateAt, v)) +} + +// Deleted applies equality check predicate on the "deleted" field. It's identical to DeletedEQ. +func Deleted(v int) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldDeleted, v)) +} + +// UserIDEQ applies the EQ predicate on the "user_id" field. +func UserIDEQ(v string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldUserID, v)) +} + +// UserIDNEQ applies the NEQ predicate on the "user_id" field. +func UserIDNEQ(v string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldNEQ(FieldUserID, v)) +} + +// UserIDIn applies the In predicate on the "user_id" field. +func UserIDIn(vs ...string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldIn(FieldUserID, vs...)) +} + +// UserIDNotIn applies the NotIn predicate on the "user_id" field. +func UserIDNotIn(vs ...string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldNotIn(FieldUserID, vs...)) +} + +// UserIDGT applies the GT predicate on the "user_id" field. +func UserIDGT(v string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldGT(FieldUserID, v)) +} + +// UserIDGTE applies the GTE predicate on the "user_id" field. +func UserIDGTE(v string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldGTE(FieldUserID, v)) +} + +// UserIDLT applies the LT predicate on the "user_id" field. +func UserIDLT(v string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldLT(FieldUserID, v)) +} + +// UserIDLTE applies the LTE predicate on the "user_id" field. +func UserIDLTE(v string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldLTE(FieldUserID, v)) +} + +// UserIDContains applies the Contains predicate on the "user_id" field. +func UserIDContains(v string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldContains(FieldUserID, v)) +} + +// UserIDHasPrefix applies the HasPrefix predicate on the "user_id" field. +func UserIDHasPrefix(v string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldHasPrefix(FieldUserID, v)) +} + +// UserIDHasSuffix applies the HasSuffix predicate on the "user_id" field. +func UserIDHasSuffix(v string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldHasSuffix(FieldUserID, v)) +} + +// UserIDEqualFold applies the EqualFold predicate on the "user_id" field. +func UserIDEqualFold(v string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldEqualFold(FieldUserID, v)) +} + +// UserIDContainsFold applies the ContainsFold predicate on the "user_id" field. +func UserIDContainsFold(v string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldContainsFold(FieldUserID, v)) +} + +// OpenIDEQ applies the EQ predicate on the "open_id" field. +func OpenIDEQ(v string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldOpenID, v)) +} + +// OpenIDNEQ applies the NEQ predicate on the "open_id" field. +func OpenIDNEQ(v string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldNEQ(FieldOpenID, v)) +} + +// OpenIDIn applies the In predicate on the "open_id" field. +func OpenIDIn(vs ...string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldIn(FieldOpenID, vs...)) +} + +// OpenIDNotIn applies the NotIn predicate on the "open_id" field. +func OpenIDNotIn(vs ...string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldNotIn(FieldOpenID, vs...)) +} + +// OpenIDGT applies the GT predicate on the "open_id" field. +func OpenIDGT(v string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldGT(FieldOpenID, v)) +} + +// OpenIDGTE applies the GTE predicate on the "open_id" field. +func OpenIDGTE(v string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldGTE(FieldOpenID, v)) +} + +// OpenIDLT applies the LT predicate on the "open_id" field. +func OpenIDLT(v string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldLT(FieldOpenID, v)) +} + +// OpenIDLTE applies the LTE predicate on the "open_id" field. +func OpenIDLTE(v string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldLTE(FieldOpenID, v)) +} + +// OpenIDContains applies the Contains predicate on the "open_id" field. +func OpenIDContains(v string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldContains(FieldOpenID, v)) +} + +// OpenIDHasPrefix applies the HasPrefix predicate on the "open_id" field. +func OpenIDHasPrefix(v string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldHasPrefix(FieldOpenID, v)) +} + +// OpenIDHasSuffix applies the HasSuffix predicate on the "open_id" field. +func OpenIDHasSuffix(v string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldHasSuffix(FieldOpenID, v)) +} + +// OpenIDEqualFold applies the EqualFold predicate on the "open_id" field. +func OpenIDEqualFold(v string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldEqualFold(FieldOpenID, v)) +} + +// OpenIDContainsFold applies the ContainsFold predicate on the "open_id" field. +func OpenIDContainsFold(v string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldContainsFold(FieldOpenID, v)) +} + +// SourceEQ applies the EQ predicate on the "source" field. +func SourceEQ(v string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldSource, v)) +} + +// SourceNEQ applies the NEQ predicate on the "source" field. +func SourceNEQ(v string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldNEQ(FieldSource, v)) +} + +// SourceIn applies the In predicate on the "source" field. +func SourceIn(vs ...string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldIn(FieldSource, vs...)) +} + +// SourceNotIn applies the NotIn predicate on the "source" field. +func SourceNotIn(vs ...string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldNotIn(FieldSource, vs...)) +} + +// SourceGT applies the GT predicate on the "source" field. +func SourceGT(v string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldGT(FieldSource, v)) +} + +// SourceGTE applies the GTE predicate on the "source" field. +func SourceGTE(v string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldGTE(FieldSource, v)) +} + +// SourceLT applies the LT predicate on the "source" field. +func SourceLT(v string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldLT(FieldSource, v)) +} + +// SourceLTE applies the LTE predicate on the "source" field. +func SourceLTE(v string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldLTE(FieldSource, v)) +} + +// SourceContains applies the Contains predicate on the "source" field. +func SourceContains(v string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldContains(FieldSource, v)) +} + +// SourceHasPrefix applies the HasPrefix predicate on the "source" field. +func SourceHasPrefix(v string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldHasPrefix(FieldSource, v)) +} + +// SourceHasSuffix applies the HasSuffix predicate on the "source" field. +func SourceHasSuffix(v string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldHasSuffix(FieldSource, v)) +} + +// SourceEqualFold applies the EqualFold predicate on the "source" field. +func SourceEqualFold(v string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldEqualFold(FieldSource, v)) +} + +// SourceContainsFold applies the ContainsFold predicate on the "source" field. +func SourceContainsFold(v string) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldContainsFold(FieldSource, v)) +} + +// StatusEQ applies the EQ predicate on the "status" field. +func StatusEQ(v int) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldStatus, v)) +} + +// StatusNEQ applies the NEQ predicate on the "status" field. +func StatusNEQ(v int) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldNEQ(FieldStatus, v)) +} + +// StatusIn applies the In predicate on the "status" field. +func StatusIn(vs ...int) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldIn(FieldStatus, vs...)) +} + +// StatusNotIn applies the NotIn predicate on the "status" field. +func StatusNotIn(vs ...int) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldNotIn(FieldStatus, vs...)) +} + +// StatusGT applies the GT predicate on the "status" field. +func StatusGT(v int) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldGT(FieldStatus, v)) +} + +// StatusGTE applies the GTE predicate on the "status" field. +func StatusGTE(v int) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldGTE(FieldStatus, v)) +} + +// StatusLT applies the LT predicate on the "status" field. +func StatusLT(v int) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldLT(FieldStatus, v)) +} + +// StatusLTE applies the LTE predicate on the "status" field. +func StatusLTE(v int) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldLTE(FieldStatus, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldLTE(FieldCreatedAt, v)) +} + +// UpdateAtEQ applies the EQ predicate on the "update_at" field. +func UpdateAtEQ(v time.Time) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldUpdateAt, v)) +} + +// UpdateAtNEQ applies the NEQ predicate on the "update_at" field. +func UpdateAtNEQ(v time.Time) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldNEQ(FieldUpdateAt, v)) +} + +// UpdateAtIn applies the In predicate on the "update_at" field. +func UpdateAtIn(vs ...time.Time) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldIn(FieldUpdateAt, vs...)) +} + +// UpdateAtNotIn applies the NotIn predicate on the "update_at" field. +func UpdateAtNotIn(vs ...time.Time) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldNotIn(FieldUpdateAt, vs...)) +} + +// UpdateAtGT applies the GT predicate on the "update_at" field. +func UpdateAtGT(v time.Time) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldGT(FieldUpdateAt, v)) +} + +// UpdateAtGTE applies the GTE predicate on the "update_at" field. +func UpdateAtGTE(v time.Time) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldGTE(FieldUpdateAt, v)) +} + +// UpdateAtLT applies the LT predicate on the "update_at" field. +func UpdateAtLT(v time.Time) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldLT(FieldUpdateAt, v)) +} + +// UpdateAtLTE applies the LTE predicate on the "update_at" field. +func UpdateAtLTE(v time.Time) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldLTE(FieldUpdateAt, v)) +} + +// UpdateAtIsNil applies the IsNil predicate on the "update_at" field. +func UpdateAtIsNil() predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldIsNull(FieldUpdateAt)) +} + +// UpdateAtNotNil applies the NotNil predicate on the "update_at" field. +func UpdateAtNotNil() predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldNotNull(FieldUpdateAt)) +} + +// DeletedEQ applies the EQ predicate on the "deleted" field. +func DeletedEQ(v int) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldDeleted, v)) +} + +// DeletedNEQ applies the NEQ predicate on the "deleted" field. +func DeletedNEQ(v int) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldNEQ(FieldDeleted, v)) +} + +// DeletedIn applies the In predicate on the "deleted" field. +func DeletedIn(vs ...int) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldIn(FieldDeleted, vs...)) +} + +// DeletedNotIn applies the NotIn predicate on the "deleted" field. +func DeletedNotIn(vs ...int) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldNotIn(FieldDeleted, vs...)) +} + +// DeletedGT applies the GT predicate on the "deleted" field. +func DeletedGT(v int) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldGT(FieldDeleted, v)) +} + +// DeletedGTE applies the GTE predicate on the "deleted" field. +func DeletedGTE(v int) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldGTE(FieldDeleted, v)) +} + +// DeletedLT applies the LT predicate on the "deleted" field. +func DeletedLT(v int) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldLT(FieldDeleted, v)) +} + +// DeletedLTE applies the LTE predicate on the "deleted" field. +func DeletedLTE(v int) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.FieldLTE(FieldDeleted, v)) +} + +// HasScaAuthUser applies the HasEdge predicate on the "sca_auth_user" edge. +func HasScaAuthUser() predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, ScaAuthUserTable, ScaAuthUserColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasScaAuthUserWith applies the HasEdge predicate on the "sca_auth_user" edge with a given conditions (other predicates). +func HasScaAuthUserWith(preds ...predicate.ScaAuthUser) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(func(s *sql.Selector) { + step := newScaAuthUserStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.ScaAuthUserSocial) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.ScaAuthUserSocial) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.ScaAuthUserSocial) predicate.ScaAuthUserSocial { + return predicate.ScaAuthUserSocial(sql.NotPredicates(p)) +} diff --git a/common/ent/scaauthusersocial_create.go b/common/ent/scaauthusersocial_create.go new file mode 100644 index 0000000..4497046 --- /dev/null +++ b/common/ent/scaauthusersocial_create.go @@ -0,0 +1,377 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "schisandra-album-cloud-microservices/common/ent/scaauthuser" + "schisandra-album-cloud-microservices/common/ent/scaauthusersocial" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ScaAuthUserSocialCreate is the builder for creating a ScaAuthUserSocial entity. +type ScaAuthUserSocialCreate struct { + config + mutation *ScaAuthUserSocialMutation + hooks []Hook +} + +// SetUserID sets the "user_id" field. +func (sausc *ScaAuthUserSocialCreate) SetUserID(s string) *ScaAuthUserSocialCreate { + sausc.mutation.SetUserID(s) + return sausc +} + +// SetOpenID sets the "open_id" field. +func (sausc *ScaAuthUserSocialCreate) SetOpenID(s string) *ScaAuthUserSocialCreate { + sausc.mutation.SetOpenID(s) + return sausc +} + +// SetSource sets the "source" field. +func (sausc *ScaAuthUserSocialCreate) SetSource(s string) *ScaAuthUserSocialCreate { + sausc.mutation.SetSource(s) + return sausc +} + +// SetStatus sets the "status" field. +func (sausc *ScaAuthUserSocialCreate) SetStatus(i int) *ScaAuthUserSocialCreate { + sausc.mutation.SetStatus(i) + return sausc +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (sausc *ScaAuthUserSocialCreate) SetNillableStatus(i *int) *ScaAuthUserSocialCreate { + if i != nil { + sausc.SetStatus(*i) + } + return sausc +} + +// SetCreatedAt sets the "created_at" field. +func (sausc *ScaAuthUserSocialCreate) SetCreatedAt(t time.Time) *ScaAuthUserSocialCreate { + sausc.mutation.SetCreatedAt(t) + return sausc +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (sausc *ScaAuthUserSocialCreate) SetNillableCreatedAt(t *time.Time) *ScaAuthUserSocialCreate { + if t != nil { + sausc.SetCreatedAt(*t) + } + return sausc +} + +// SetUpdateAt sets the "update_at" field. +func (sausc *ScaAuthUserSocialCreate) SetUpdateAt(t time.Time) *ScaAuthUserSocialCreate { + sausc.mutation.SetUpdateAt(t) + return sausc +} + +// SetNillableUpdateAt sets the "update_at" field if the given value is not nil. +func (sausc *ScaAuthUserSocialCreate) SetNillableUpdateAt(t *time.Time) *ScaAuthUserSocialCreate { + if t != nil { + sausc.SetUpdateAt(*t) + } + return sausc +} + +// SetDeleted sets the "deleted" field. +func (sausc *ScaAuthUserSocialCreate) SetDeleted(i int) *ScaAuthUserSocialCreate { + sausc.mutation.SetDeleted(i) + return sausc +} + +// SetNillableDeleted sets the "deleted" field if the given value is not nil. +func (sausc *ScaAuthUserSocialCreate) SetNillableDeleted(i *int) *ScaAuthUserSocialCreate { + if i != nil { + sausc.SetDeleted(*i) + } + return sausc +} + +// SetID sets the "id" field. +func (sausc *ScaAuthUserSocialCreate) SetID(i int64) *ScaAuthUserSocialCreate { + sausc.mutation.SetID(i) + return sausc +} + +// SetScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by ID. +func (sausc *ScaAuthUserSocialCreate) SetScaAuthUserID(id int64) *ScaAuthUserSocialCreate { + sausc.mutation.SetScaAuthUserID(id) + return sausc +} + +// SetNillableScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by ID if the given value is not nil. +func (sausc *ScaAuthUserSocialCreate) SetNillableScaAuthUserID(id *int64) *ScaAuthUserSocialCreate { + if id != nil { + sausc = sausc.SetScaAuthUserID(*id) + } + return sausc +} + +// SetScaAuthUser sets the "sca_auth_user" edge to the ScaAuthUser entity. +func (sausc *ScaAuthUserSocialCreate) SetScaAuthUser(s *ScaAuthUser) *ScaAuthUserSocialCreate { + return sausc.SetScaAuthUserID(s.ID) +} + +// Mutation returns the ScaAuthUserSocialMutation object of the builder. +func (sausc *ScaAuthUserSocialCreate) Mutation() *ScaAuthUserSocialMutation { + return sausc.mutation +} + +// Save creates the ScaAuthUserSocial in the database. +func (sausc *ScaAuthUserSocialCreate) Save(ctx context.Context) (*ScaAuthUserSocial, error) { + sausc.defaults() + return withHooks(ctx, sausc.sqlSave, sausc.mutation, sausc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (sausc *ScaAuthUserSocialCreate) SaveX(ctx context.Context) *ScaAuthUserSocial { + v, err := sausc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (sausc *ScaAuthUserSocialCreate) Exec(ctx context.Context) error { + _, err := sausc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (sausc *ScaAuthUserSocialCreate) ExecX(ctx context.Context) { + if err := sausc.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (sausc *ScaAuthUserSocialCreate) defaults() { + if _, ok := sausc.mutation.Status(); !ok { + v := scaauthusersocial.DefaultStatus + sausc.mutation.SetStatus(v) + } + if _, ok := sausc.mutation.CreatedAt(); !ok { + v := scaauthusersocial.DefaultCreatedAt() + sausc.mutation.SetCreatedAt(v) + } + if _, ok := sausc.mutation.UpdateAt(); !ok { + v := scaauthusersocial.DefaultUpdateAt() + sausc.mutation.SetUpdateAt(v) + } + if _, ok := sausc.mutation.Deleted(); !ok { + v := scaauthusersocial.DefaultDeleted + sausc.mutation.SetDeleted(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (sausc *ScaAuthUserSocialCreate) check() error { + if _, ok := sausc.mutation.UserID(); !ok { + return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "ScaAuthUserSocial.user_id"`)} + } + if v, ok := sausc.mutation.UserID(); ok { + if err := scaauthusersocial.UserIDValidator(v); err != nil { + return &ValidationError{Name: "user_id", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserSocial.user_id": %w`, err)} + } + } + if _, ok := sausc.mutation.OpenID(); !ok { + return &ValidationError{Name: "open_id", err: errors.New(`ent: missing required field "ScaAuthUserSocial.open_id"`)} + } + if v, ok := sausc.mutation.OpenID(); ok { + if err := scaauthusersocial.OpenIDValidator(v); err != nil { + return &ValidationError{Name: "open_id", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserSocial.open_id": %w`, err)} + } + } + if _, ok := sausc.mutation.Source(); !ok { + return &ValidationError{Name: "source", err: errors.New(`ent: missing required field "ScaAuthUserSocial.source"`)} + } + if v, ok := sausc.mutation.Source(); ok { + if err := scaauthusersocial.SourceValidator(v); err != nil { + return &ValidationError{Name: "source", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserSocial.source": %w`, err)} + } + } + if _, ok := sausc.mutation.Status(); !ok { + return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "ScaAuthUserSocial.status"`)} + } + if _, ok := sausc.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "ScaAuthUserSocial.created_at"`)} + } + if _, ok := sausc.mutation.Deleted(); !ok { + return &ValidationError{Name: "deleted", err: errors.New(`ent: missing required field "ScaAuthUserSocial.deleted"`)} + } + return nil +} + +func (sausc *ScaAuthUserSocialCreate) sqlSave(ctx context.Context) (*ScaAuthUserSocial, error) { + if err := sausc.check(); err != nil { + return nil, err + } + _node, _spec := sausc.createSpec() + if err := sqlgraph.CreateNode(ctx, sausc.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) + } + sausc.mutation.id = &_node.ID + sausc.mutation.done = true + return _node, nil +} + +func (sausc *ScaAuthUserSocialCreate) createSpec() (*ScaAuthUserSocial, *sqlgraph.CreateSpec) { + var ( + _node = &ScaAuthUserSocial{config: sausc.config} + _spec = sqlgraph.NewCreateSpec(scaauthusersocial.Table, sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64)) + ) + if id, ok := sausc.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := sausc.mutation.UserID(); ok { + _spec.SetField(scaauthusersocial.FieldUserID, field.TypeString, value) + _node.UserID = value + } + if value, ok := sausc.mutation.OpenID(); ok { + _spec.SetField(scaauthusersocial.FieldOpenID, field.TypeString, value) + _node.OpenID = value + } + if value, ok := sausc.mutation.Source(); ok { + _spec.SetField(scaauthusersocial.FieldSource, field.TypeString, value) + _node.Source = value + } + if value, ok := sausc.mutation.Status(); ok { + _spec.SetField(scaauthusersocial.FieldStatus, field.TypeInt, value) + _node.Status = value + } + if value, ok := sausc.mutation.CreatedAt(); ok { + _spec.SetField(scaauthusersocial.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := sausc.mutation.UpdateAt(); ok { + _spec.SetField(scaauthusersocial.FieldUpdateAt, field.TypeTime, value) + _node.UpdateAt = &value + } + if value, ok := sausc.mutation.Deleted(); ok { + _spec.SetField(scaauthusersocial.FieldDeleted, field.TypeInt, value) + _node.Deleted = value + } + if nodes := sausc.mutation.ScaAuthUserIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: scaauthusersocial.ScaAuthUserTable, + Columns: []string{scaauthusersocial.ScaAuthUserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.sca_auth_user_sca_auth_user_social = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// ScaAuthUserSocialCreateBulk is the builder for creating many ScaAuthUserSocial entities in bulk. +type ScaAuthUserSocialCreateBulk struct { + config + err error + builders []*ScaAuthUserSocialCreate +} + +// Save creates the ScaAuthUserSocial entities in the database. +func (sauscb *ScaAuthUserSocialCreateBulk) Save(ctx context.Context) ([]*ScaAuthUserSocial, error) { + if sauscb.err != nil { + return nil, sauscb.err + } + specs := make([]*sqlgraph.CreateSpec, len(sauscb.builders)) + nodes := make([]*ScaAuthUserSocial, len(sauscb.builders)) + mutators := make([]Mutator, len(sauscb.builders)) + for i := range sauscb.builders { + func(i int, root context.Context) { + builder := sauscb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*ScaAuthUserSocialMutation) + 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, sauscb.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, sauscb.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, sauscb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (sauscb *ScaAuthUserSocialCreateBulk) SaveX(ctx context.Context) []*ScaAuthUserSocial { + v, err := sauscb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (sauscb *ScaAuthUserSocialCreateBulk) Exec(ctx context.Context) error { + _, err := sauscb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (sauscb *ScaAuthUserSocialCreateBulk) ExecX(ctx context.Context) { + if err := sauscb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/common/ent/scaauthusersocial_delete.go b/common/ent/scaauthusersocial_delete.go new file mode 100644 index 0000000..f55ae07 --- /dev/null +++ b/common/ent/scaauthusersocial_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "schisandra-album-cloud-microservices/common/ent/predicate" + "schisandra-album-cloud-microservices/common/ent/scaauthusersocial" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ScaAuthUserSocialDelete is the builder for deleting a ScaAuthUserSocial entity. +type ScaAuthUserSocialDelete struct { + config + hooks []Hook + mutation *ScaAuthUserSocialMutation +} + +// Where appends a list predicates to the ScaAuthUserSocialDelete builder. +func (sausd *ScaAuthUserSocialDelete) Where(ps ...predicate.ScaAuthUserSocial) *ScaAuthUserSocialDelete { + sausd.mutation.Where(ps...) + return sausd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (sausd *ScaAuthUserSocialDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, sausd.sqlExec, sausd.mutation, sausd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (sausd *ScaAuthUserSocialDelete) ExecX(ctx context.Context) int { + n, err := sausd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (sausd *ScaAuthUserSocialDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(scaauthusersocial.Table, sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64)) + if ps := sausd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, sausd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + sausd.mutation.done = true + return affected, err +} + +// ScaAuthUserSocialDeleteOne is the builder for deleting a single ScaAuthUserSocial entity. +type ScaAuthUserSocialDeleteOne struct { + sausd *ScaAuthUserSocialDelete +} + +// Where appends a list predicates to the ScaAuthUserSocialDelete builder. +func (sausdo *ScaAuthUserSocialDeleteOne) Where(ps ...predicate.ScaAuthUserSocial) *ScaAuthUserSocialDeleteOne { + sausdo.sausd.mutation.Where(ps...) + return sausdo +} + +// Exec executes the deletion query. +func (sausdo *ScaAuthUserSocialDeleteOne) Exec(ctx context.Context) error { + n, err := sausdo.sausd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{scaauthusersocial.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (sausdo *ScaAuthUserSocialDeleteOne) ExecX(ctx context.Context) { + if err := sausdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/common/ent/scaauthusersocial_query.go b/common/ent/scaauthusersocial_query.go new file mode 100644 index 0000000..ae67b04 --- /dev/null +++ b/common/ent/scaauthusersocial_query.go @@ -0,0 +1,614 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + "schisandra-album-cloud-microservices/common/ent/predicate" + "schisandra-album-cloud-microservices/common/ent/scaauthuser" + "schisandra-album-cloud-microservices/common/ent/scaauthusersocial" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ScaAuthUserSocialQuery is the builder for querying ScaAuthUserSocial entities. +type ScaAuthUserSocialQuery struct { + config + ctx *QueryContext + order []scaauthusersocial.OrderOption + inters []Interceptor + predicates []predicate.ScaAuthUserSocial + withScaAuthUser *ScaAuthUserQuery + withFKs bool + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the ScaAuthUserSocialQuery builder. +func (sausq *ScaAuthUserSocialQuery) Where(ps ...predicate.ScaAuthUserSocial) *ScaAuthUserSocialQuery { + sausq.predicates = append(sausq.predicates, ps...) + return sausq +} + +// Limit the number of records to be returned by this query. +func (sausq *ScaAuthUserSocialQuery) Limit(limit int) *ScaAuthUserSocialQuery { + sausq.ctx.Limit = &limit + return sausq +} + +// Offset to start from. +func (sausq *ScaAuthUserSocialQuery) Offset(offset int) *ScaAuthUserSocialQuery { + sausq.ctx.Offset = &offset + return sausq +} + +// 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 (sausq *ScaAuthUserSocialQuery) Unique(unique bool) *ScaAuthUserSocialQuery { + sausq.ctx.Unique = &unique + return sausq +} + +// Order specifies how the records should be ordered. +func (sausq *ScaAuthUserSocialQuery) Order(o ...scaauthusersocial.OrderOption) *ScaAuthUserSocialQuery { + sausq.order = append(sausq.order, o...) + return sausq +} + +// QueryScaAuthUser chains the current query on the "sca_auth_user" edge. +func (sausq *ScaAuthUserSocialQuery) QueryScaAuthUser() *ScaAuthUserQuery { + query := (&ScaAuthUserClient{config: sausq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := sausq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := sausq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(scaauthusersocial.Table, scaauthusersocial.FieldID, selector), + sqlgraph.To(scaauthuser.Table, scaauthuser.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, scaauthusersocial.ScaAuthUserTable, scaauthusersocial.ScaAuthUserColumn), + ) + fromU = sqlgraph.SetNeighbors(sausq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first ScaAuthUserSocial entity from the query. +// Returns a *NotFoundError when no ScaAuthUserSocial was found. +func (sausq *ScaAuthUserSocialQuery) First(ctx context.Context) (*ScaAuthUserSocial, error) { + nodes, err := sausq.Limit(1).All(setContextOp(ctx, sausq.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{scaauthusersocial.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (sausq *ScaAuthUserSocialQuery) FirstX(ctx context.Context) *ScaAuthUserSocial { + node, err := sausq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first ScaAuthUserSocial ID from the query. +// Returns a *NotFoundError when no ScaAuthUserSocial ID was found. +func (sausq *ScaAuthUserSocialQuery) FirstID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = sausq.Limit(1).IDs(setContextOp(ctx, sausq.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{scaauthusersocial.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (sausq *ScaAuthUserSocialQuery) FirstIDX(ctx context.Context) int64 { + id, err := sausq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single ScaAuthUserSocial entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one ScaAuthUserSocial entity is found. +// Returns a *NotFoundError when no ScaAuthUserSocial entities are found. +func (sausq *ScaAuthUserSocialQuery) Only(ctx context.Context) (*ScaAuthUserSocial, error) { + nodes, err := sausq.Limit(2).All(setContextOp(ctx, sausq.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{scaauthusersocial.Label} + default: + return nil, &NotSingularError{scaauthusersocial.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (sausq *ScaAuthUserSocialQuery) OnlyX(ctx context.Context) *ScaAuthUserSocial { + node, err := sausq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only ScaAuthUserSocial ID in the query. +// Returns a *NotSingularError when more than one ScaAuthUserSocial ID is found. +// Returns a *NotFoundError when no entities are found. +func (sausq *ScaAuthUserSocialQuery) OnlyID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = sausq.Limit(2).IDs(setContextOp(ctx, sausq.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{scaauthusersocial.Label} + default: + err = &NotSingularError{scaauthusersocial.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (sausq *ScaAuthUserSocialQuery) OnlyIDX(ctx context.Context) int64 { + id, err := sausq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of ScaAuthUserSocials. +func (sausq *ScaAuthUserSocialQuery) All(ctx context.Context) ([]*ScaAuthUserSocial, error) { + ctx = setContextOp(ctx, sausq.ctx, ent.OpQueryAll) + if err := sausq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*ScaAuthUserSocial, *ScaAuthUserSocialQuery]() + return withInterceptors[[]*ScaAuthUserSocial](ctx, sausq, qr, sausq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (sausq *ScaAuthUserSocialQuery) AllX(ctx context.Context) []*ScaAuthUserSocial { + nodes, err := sausq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of ScaAuthUserSocial IDs. +func (sausq *ScaAuthUserSocialQuery) IDs(ctx context.Context) (ids []int64, err error) { + if sausq.ctx.Unique == nil && sausq.path != nil { + sausq.Unique(true) + } + ctx = setContextOp(ctx, sausq.ctx, ent.OpQueryIDs) + if err = sausq.Select(scaauthusersocial.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (sausq *ScaAuthUserSocialQuery) IDsX(ctx context.Context) []int64 { + ids, err := sausq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (sausq *ScaAuthUserSocialQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, sausq.ctx, ent.OpQueryCount) + if err := sausq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, sausq, querierCount[*ScaAuthUserSocialQuery](), sausq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (sausq *ScaAuthUserSocialQuery) CountX(ctx context.Context) int { + count, err := sausq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (sausq *ScaAuthUserSocialQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, sausq.ctx, ent.OpQueryExist) + switch _, err := sausq.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 (sausq *ScaAuthUserSocialQuery) ExistX(ctx context.Context) bool { + exist, err := sausq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the ScaAuthUserSocialQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (sausq *ScaAuthUserSocialQuery) Clone() *ScaAuthUserSocialQuery { + if sausq == nil { + return nil + } + return &ScaAuthUserSocialQuery{ + config: sausq.config, + ctx: sausq.ctx.Clone(), + order: append([]scaauthusersocial.OrderOption{}, sausq.order...), + inters: append([]Interceptor{}, sausq.inters...), + predicates: append([]predicate.ScaAuthUserSocial{}, sausq.predicates...), + withScaAuthUser: sausq.withScaAuthUser.Clone(), + // clone intermediate query. + sql: sausq.sql.Clone(), + path: sausq.path, + } +} + +// WithScaAuthUser tells the query-builder to eager-load the nodes that are connected to +// the "sca_auth_user" edge. The optional arguments are used to configure the query builder of the edge. +func (sausq *ScaAuthUserSocialQuery) WithScaAuthUser(opts ...func(*ScaAuthUserQuery)) *ScaAuthUserSocialQuery { + query := (&ScaAuthUserClient{config: sausq.config}).Query() + for _, opt := range opts { + opt(query) + } + sausq.withScaAuthUser = query + return sausq +} + +// 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 { +// UserID string `json:"user_id,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.ScaAuthUserSocial.Query(). +// GroupBy(scaauthusersocial.FieldUserID). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (sausq *ScaAuthUserSocialQuery) GroupBy(field string, fields ...string) *ScaAuthUserSocialGroupBy { + sausq.ctx.Fields = append([]string{field}, fields...) + grbuild := &ScaAuthUserSocialGroupBy{build: sausq} + grbuild.flds = &sausq.ctx.Fields + grbuild.label = scaauthusersocial.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 { +// UserID string `json:"user_id,omitempty"` +// } +// +// client.ScaAuthUserSocial.Query(). +// Select(scaauthusersocial.FieldUserID). +// Scan(ctx, &v) +func (sausq *ScaAuthUserSocialQuery) Select(fields ...string) *ScaAuthUserSocialSelect { + sausq.ctx.Fields = append(sausq.ctx.Fields, fields...) + sbuild := &ScaAuthUserSocialSelect{ScaAuthUserSocialQuery: sausq} + sbuild.label = scaauthusersocial.Label + sbuild.flds, sbuild.scan = &sausq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a ScaAuthUserSocialSelect configured with the given aggregations. +func (sausq *ScaAuthUserSocialQuery) Aggregate(fns ...AggregateFunc) *ScaAuthUserSocialSelect { + return sausq.Select().Aggregate(fns...) +} + +func (sausq *ScaAuthUserSocialQuery) prepareQuery(ctx context.Context) error { + for _, inter := range sausq.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, sausq); err != nil { + return err + } + } + } + for _, f := range sausq.ctx.Fields { + if !scaauthusersocial.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if sausq.path != nil { + prev, err := sausq.path(ctx) + if err != nil { + return err + } + sausq.sql = prev + } + return nil +} + +func (sausq *ScaAuthUserSocialQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ScaAuthUserSocial, error) { + var ( + nodes = []*ScaAuthUserSocial{} + withFKs = sausq.withFKs + _spec = sausq.querySpec() + loadedTypes = [1]bool{ + sausq.withScaAuthUser != nil, + } + ) + if sausq.withScaAuthUser != nil { + withFKs = true + } + if withFKs { + _spec.Node.Columns = append(_spec.Node.Columns, scaauthusersocial.ForeignKeys...) + } + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*ScaAuthUserSocial).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &ScaAuthUserSocial{config: sausq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, sausq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := sausq.withScaAuthUser; query != nil { + if err := sausq.loadScaAuthUser(ctx, query, nodes, nil, + func(n *ScaAuthUserSocial, e *ScaAuthUser) { n.Edges.ScaAuthUser = e }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (sausq *ScaAuthUserSocialQuery) loadScaAuthUser(ctx context.Context, query *ScaAuthUserQuery, nodes []*ScaAuthUserSocial, init func(*ScaAuthUserSocial), assign func(*ScaAuthUserSocial, *ScaAuthUser)) error { + ids := make([]int64, 0, len(nodes)) + nodeids := make(map[int64][]*ScaAuthUserSocial) + for i := range nodes { + if nodes[i].sca_auth_user_sca_auth_user_social == nil { + continue + } + fk := *nodes[i].sca_auth_user_sca_auth_user_social + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(scaauthuser.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "sca_auth_user_sca_auth_user_social" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + +func (sausq *ScaAuthUserSocialQuery) sqlCount(ctx context.Context) (int, error) { + _spec := sausq.querySpec() + _spec.Node.Columns = sausq.ctx.Fields + if len(sausq.ctx.Fields) > 0 { + _spec.Unique = sausq.ctx.Unique != nil && *sausq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, sausq.driver, _spec) +} + +func (sausq *ScaAuthUserSocialQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(scaauthusersocial.Table, scaauthusersocial.Columns, sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64)) + _spec.From = sausq.sql + if unique := sausq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if sausq.path != nil { + _spec.Unique = true + } + if fields := sausq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, scaauthusersocial.FieldID) + for i := range fields { + if fields[i] != scaauthusersocial.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := sausq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := sausq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := sausq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := sausq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (sausq *ScaAuthUserSocialQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(sausq.driver.Dialect()) + t1 := builder.Table(scaauthusersocial.Table) + columns := sausq.ctx.Fields + if len(columns) == 0 { + columns = scaauthusersocial.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if sausq.sql != nil { + selector = sausq.sql + selector.Select(selector.Columns(columns...)...) + } + if sausq.ctx.Unique != nil && *sausq.ctx.Unique { + selector.Distinct() + } + for _, p := range sausq.predicates { + p(selector) + } + for _, p := range sausq.order { + p(selector) + } + if offset := sausq.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 := sausq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// ScaAuthUserSocialGroupBy is the group-by builder for ScaAuthUserSocial entities. +type ScaAuthUserSocialGroupBy struct { + selector + build *ScaAuthUserSocialQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (sausgb *ScaAuthUserSocialGroupBy) Aggregate(fns ...AggregateFunc) *ScaAuthUserSocialGroupBy { + sausgb.fns = append(sausgb.fns, fns...) + return sausgb +} + +// Scan applies the selector query and scans the result into the given value. +func (sausgb *ScaAuthUserSocialGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, sausgb.build.ctx, ent.OpQueryGroupBy) + if err := sausgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ScaAuthUserSocialQuery, *ScaAuthUserSocialGroupBy](ctx, sausgb.build, sausgb, sausgb.build.inters, v) +} + +func (sausgb *ScaAuthUserSocialGroupBy) sqlScan(ctx context.Context, root *ScaAuthUserSocialQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(sausgb.fns)) + for _, fn := range sausgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*sausgb.flds)+len(sausgb.fns)) + for _, f := range *sausgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*sausgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := sausgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// ScaAuthUserSocialSelect is the builder for selecting fields of ScaAuthUserSocial entities. +type ScaAuthUserSocialSelect struct { + *ScaAuthUserSocialQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (sauss *ScaAuthUserSocialSelect) Aggregate(fns ...AggregateFunc) *ScaAuthUserSocialSelect { + sauss.fns = append(sauss.fns, fns...) + return sauss +} + +// Scan applies the selector query and scans the result into the given value. +func (sauss *ScaAuthUserSocialSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, sauss.ctx, ent.OpQuerySelect) + if err := sauss.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ScaAuthUserSocialQuery, *ScaAuthUserSocialSelect](ctx, sauss.ScaAuthUserSocialQuery, sauss, sauss.inters, v) +} + +func (sauss *ScaAuthUserSocialSelect) sqlScan(ctx context.Context, root *ScaAuthUserSocialQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(sauss.fns)) + for _, fn := range sauss.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*sauss.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 := sauss.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/common/ent/scaauthusersocial_update.go b/common/ent/scaauthusersocial_update.go new file mode 100644 index 0000000..295dec4 --- /dev/null +++ b/common/ent/scaauthusersocial_update.go @@ -0,0 +1,595 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "schisandra-album-cloud-microservices/common/ent/predicate" + "schisandra-album-cloud-microservices/common/ent/scaauthuser" + "schisandra-album-cloud-microservices/common/ent/scaauthusersocial" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ScaAuthUserSocialUpdate is the builder for updating ScaAuthUserSocial entities. +type ScaAuthUserSocialUpdate struct { + config + hooks []Hook + mutation *ScaAuthUserSocialMutation +} + +// Where appends a list predicates to the ScaAuthUserSocialUpdate builder. +func (sausu *ScaAuthUserSocialUpdate) Where(ps ...predicate.ScaAuthUserSocial) *ScaAuthUserSocialUpdate { + sausu.mutation.Where(ps...) + return sausu +} + +// SetUserID sets the "user_id" field. +func (sausu *ScaAuthUserSocialUpdate) SetUserID(s string) *ScaAuthUserSocialUpdate { + sausu.mutation.SetUserID(s) + return sausu +} + +// SetNillableUserID sets the "user_id" field if the given value is not nil. +func (sausu *ScaAuthUserSocialUpdate) SetNillableUserID(s *string) *ScaAuthUserSocialUpdate { + if s != nil { + sausu.SetUserID(*s) + } + return sausu +} + +// SetOpenID sets the "open_id" field. +func (sausu *ScaAuthUserSocialUpdate) SetOpenID(s string) *ScaAuthUserSocialUpdate { + sausu.mutation.SetOpenID(s) + return sausu +} + +// SetNillableOpenID sets the "open_id" field if the given value is not nil. +func (sausu *ScaAuthUserSocialUpdate) SetNillableOpenID(s *string) *ScaAuthUserSocialUpdate { + if s != nil { + sausu.SetOpenID(*s) + } + return sausu +} + +// SetSource sets the "source" field. +func (sausu *ScaAuthUserSocialUpdate) SetSource(s string) *ScaAuthUserSocialUpdate { + sausu.mutation.SetSource(s) + return sausu +} + +// SetNillableSource sets the "source" field if the given value is not nil. +func (sausu *ScaAuthUserSocialUpdate) SetNillableSource(s *string) *ScaAuthUserSocialUpdate { + if s != nil { + sausu.SetSource(*s) + } + return sausu +} + +// SetStatus sets the "status" field. +func (sausu *ScaAuthUserSocialUpdate) SetStatus(i int) *ScaAuthUserSocialUpdate { + sausu.mutation.ResetStatus() + sausu.mutation.SetStatus(i) + return sausu +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (sausu *ScaAuthUserSocialUpdate) SetNillableStatus(i *int) *ScaAuthUserSocialUpdate { + if i != nil { + sausu.SetStatus(*i) + } + return sausu +} + +// AddStatus adds i to the "status" field. +func (sausu *ScaAuthUserSocialUpdate) AddStatus(i int) *ScaAuthUserSocialUpdate { + sausu.mutation.AddStatus(i) + return sausu +} + +// SetUpdateAt sets the "update_at" field. +func (sausu *ScaAuthUserSocialUpdate) SetUpdateAt(t time.Time) *ScaAuthUserSocialUpdate { + sausu.mutation.SetUpdateAt(t) + return sausu +} + +// ClearUpdateAt clears the value of the "update_at" field. +func (sausu *ScaAuthUserSocialUpdate) ClearUpdateAt() *ScaAuthUserSocialUpdate { + sausu.mutation.ClearUpdateAt() + return sausu +} + +// SetDeleted sets the "deleted" field. +func (sausu *ScaAuthUserSocialUpdate) SetDeleted(i int) *ScaAuthUserSocialUpdate { + sausu.mutation.ResetDeleted() + sausu.mutation.SetDeleted(i) + return sausu +} + +// SetNillableDeleted sets the "deleted" field if the given value is not nil. +func (sausu *ScaAuthUserSocialUpdate) SetNillableDeleted(i *int) *ScaAuthUserSocialUpdate { + if i != nil { + sausu.SetDeleted(*i) + } + return sausu +} + +// AddDeleted adds i to the "deleted" field. +func (sausu *ScaAuthUserSocialUpdate) AddDeleted(i int) *ScaAuthUserSocialUpdate { + sausu.mutation.AddDeleted(i) + return sausu +} + +// SetScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by ID. +func (sausu *ScaAuthUserSocialUpdate) SetScaAuthUserID(id int64) *ScaAuthUserSocialUpdate { + sausu.mutation.SetScaAuthUserID(id) + return sausu +} + +// SetNillableScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by ID if the given value is not nil. +func (sausu *ScaAuthUserSocialUpdate) SetNillableScaAuthUserID(id *int64) *ScaAuthUserSocialUpdate { + if id != nil { + sausu = sausu.SetScaAuthUserID(*id) + } + return sausu +} + +// SetScaAuthUser sets the "sca_auth_user" edge to the ScaAuthUser entity. +func (sausu *ScaAuthUserSocialUpdate) SetScaAuthUser(s *ScaAuthUser) *ScaAuthUserSocialUpdate { + return sausu.SetScaAuthUserID(s.ID) +} + +// Mutation returns the ScaAuthUserSocialMutation object of the builder. +func (sausu *ScaAuthUserSocialUpdate) Mutation() *ScaAuthUserSocialMutation { + return sausu.mutation +} + +// ClearScaAuthUser clears the "sca_auth_user" edge to the ScaAuthUser entity. +func (sausu *ScaAuthUserSocialUpdate) ClearScaAuthUser() *ScaAuthUserSocialUpdate { + sausu.mutation.ClearScaAuthUser() + return sausu +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (sausu *ScaAuthUserSocialUpdate) Save(ctx context.Context) (int, error) { + sausu.defaults() + return withHooks(ctx, sausu.sqlSave, sausu.mutation, sausu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (sausu *ScaAuthUserSocialUpdate) SaveX(ctx context.Context) int { + affected, err := sausu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (sausu *ScaAuthUserSocialUpdate) Exec(ctx context.Context) error { + _, err := sausu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (sausu *ScaAuthUserSocialUpdate) ExecX(ctx context.Context) { + if err := sausu.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (sausu *ScaAuthUserSocialUpdate) defaults() { + if _, ok := sausu.mutation.UpdateAt(); !ok && !sausu.mutation.UpdateAtCleared() { + v := scaauthusersocial.UpdateDefaultUpdateAt() + sausu.mutation.SetUpdateAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (sausu *ScaAuthUserSocialUpdate) check() error { + if v, ok := sausu.mutation.UserID(); ok { + if err := scaauthusersocial.UserIDValidator(v); err != nil { + return &ValidationError{Name: "user_id", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserSocial.user_id": %w`, err)} + } + } + if v, ok := sausu.mutation.OpenID(); ok { + if err := scaauthusersocial.OpenIDValidator(v); err != nil { + return &ValidationError{Name: "open_id", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserSocial.open_id": %w`, err)} + } + } + if v, ok := sausu.mutation.Source(); ok { + if err := scaauthusersocial.SourceValidator(v); err != nil { + return &ValidationError{Name: "source", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserSocial.source": %w`, err)} + } + } + return nil +} + +func (sausu *ScaAuthUserSocialUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := sausu.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(scaauthusersocial.Table, scaauthusersocial.Columns, sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64)) + if ps := sausu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := sausu.mutation.UserID(); ok { + _spec.SetField(scaauthusersocial.FieldUserID, field.TypeString, value) + } + if value, ok := sausu.mutation.OpenID(); ok { + _spec.SetField(scaauthusersocial.FieldOpenID, field.TypeString, value) + } + if value, ok := sausu.mutation.Source(); ok { + _spec.SetField(scaauthusersocial.FieldSource, field.TypeString, value) + } + if value, ok := sausu.mutation.Status(); ok { + _spec.SetField(scaauthusersocial.FieldStatus, field.TypeInt, value) + } + if value, ok := sausu.mutation.AddedStatus(); ok { + _spec.AddField(scaauthusersocial.FieldStatus, field.TypeInt, value) + } + if value, ok := sausu.mutation.UpdateAt(); ok { + _spec.SetField(scaauthusersocial.FieldUpdateAt, field.TypeTime, value) + } + if sausu.mutation.UpdateAtCleared() { + _spec.ClearField(scaauthusersocial.FieldUpdateAt, field.TypeTime) + } + if value, ok := sausu.mutation.Deleted(); ok { + _spec.SetField(scaauthusersocial.FieldDeleted, field.TypeInt, value) + } + if value, ok := sausu.mutation.AddedDeleted(); ok { + _spec.AddField(scaauthusersocial.FieldDeleted, field.TypeInt, value) + } + if sausu.mutation.ScaAuthUserCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: scaauthusersocial.ScaAuthUserTable, + Columns: []string{scaauthusersocial.ScaAuthUserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := sausu.mutation.ScaAuthUserIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: scaauthusersocial.ScaAuthUserTable, + Columns: []string{scaauthusersocial.ScaAuthUserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if n, err = sqlgraph.UpdateNodes(ctx, sausu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{scaauthusersocial.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + sausu.mutation.done = true + return n, nil +} + +// ScaAuthUserSocialUpdateOne is the builder for updating a single ScaAuthUserSocial entity. +type ScaAuthUserSocialUpdateOne struct { + config + fields []string + hooks []Hook + mutation *ScaAuthUserSocialMutation +} + +// SetUserID sets the "user_id" field. +func (sausuo *ScaAuthUserSocialUpdateOne) SetUserID(s string) *ScaAuthUserSocialUpdateOne { + sausuo.mutation.SetUserID(s) + return sausuo +} + +// SetNillableUserID sets the "user_id" field if the given value is not nil. +func (sausuo *ScaAuthUserSocialUpdateOne) SetNillableUserID(s *string) *ScaAuthUserSocialUpdateOne { + if s != nil { + sausuo.SetUserID(*s) + } + return sausuo +} + +// SetOpenID sets the "open_id" field. +func (sausuo *ScaAuthUserSocialUpdateOne) SetOpenID(s string) *ScaAuthUserSocialUpdateOne { + sausuo.mutation.SetOpenID(s) + return sausuo +} + +// SetNillableOpenID sets the "open_id" field if the given value is not nil. +func (sausuo *ScaAuthUserSocialUpdateOne) SetNillableOpenID(s *string) *ScaAuthUserSocialUpdateOne { + if s != nil { + sausuo.SetOpenID(*s) + } + return sausuo +} + +// SetSource sets the "source" field. +func (sausuo *ScaAuthUserSocialUpdateOne) SetSource(s string) *ScaAuthUserSocialUpdateOne { + sausuo.mutation.SetSource(s) + return sausuo +} + +// SetNillableSource sets the "source" field if the given value is not nil. +func (sausuo *ScaAuthUserSocialUpdateOne) SetNillableSource(s *string) *ScaAuthUserSocialUpdateOne { + if s != nil { + sausuo.SetSource(*s) + } + return sausuo +} + +// SetStatus sets the "status" field. +func (sausuo *ScaAuthUserSocialUpdateOne) SetStatus(i int) *ScaAuthUserSocialUpdateOne { + sausuo.mutation.ResetStatus() + sausuo.mutation.SetStatus(i) + return sausuo +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (sausuo *ScaAuthUserSocialUpdateOne) SetNillableStatus(i *int) *ScaAuthUserSocialUpdateOne { + if i != nil { + sausuo.SetStatus(*i) + } + return sausuo +} + +// AddStatus adds i to the "status" field. +func (sausuo *ScaAuthUserSocialUpdateOne) AddStatus(i int) *ScaAuthUserSocialUpdateOne { + sausuo.mutation.AddStatus(i) + return sausuo +} + +// SetUpdateAt sets the "update_at" field. +func (sausuo *ScaAuthUserSocialUpdateOne) SetUpdateAt(t time.Time) *ScaAuthUserSocialUpdateOne { + sausuo.mutation.SetUpdateAt(t) + return sausuo +} + +// ClearUpdateAt clears the value of the "update_at" field. +func (sausuo *ScaAuthUserSocialUpdateOne) ClearUpdateAt() *ScaAuthUserSocialUpdateOne { + sausuo.mutation.ClearUpdateAt() + return sausuo +} + +// SetDeleted sets the "deleted" field. +func (sausuo *ScaAuthUserSocialUpdateOne) SetDeleted(i int) *ScaAuthUserSocialUpdateOne { + sausuo.mutation.ResetDeleted() + sausuo.mutation.SetDeleted(i) + return sausuo +} + +// SetNillableDeleted sets the "deleted" field if the given value is not nil. +func (sausuo *ScaAuthUserSocialUpdateOne) SetNillableDeleted(i *int) *ScaAuthUserSocialUpdateOne { + if i != nil { + sausuo.SetDeleted(*i) + } + return sausuo +} + +// AddDeleted adds i to the "deleted" field. +func (sausuo *ScaAuthUserSocialUpdateOne) AddDeleted(i int) *ScaAuthUserSocialUpdateOne { + sausuo.mutation.AddDeleted(i) + return sausuo +} + +// SetScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by ID. +func (sausuo *ScaAuthUserSocialUpdateOne) SetScaAuthUserID(id int64) *ScaAuthUserSocialUpdateOne { + sausuo.mutation.SetScaAuthUserID(id) + return sausuo +} + +// SetNillableScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by ID if the given value is not nil. +func (sausuo *ScaAuthUserSocialUpdateOne) SetNillableScaAuthUserID(id *int64) *ScaAuthUserSocialUpdateOne { + if id != nil { + sausuo = sausuo.SetScaAuthUserID(*id) + } + return sausuo +} + +// SetScaAuthUser sets the "sca_auth_user" edge to the ScaAuthUser entity. +func (sausuo *ScaAuthUserSocialUpdateOne) SetScaAuthUser(s *ScaAuthUser) *ScaAuthUserSocialUpdateOne { + return sausuo.SetScaAuthUserID(s.ID) +} + +// Mutation returns the ScaAuthUserSocialMutation object of the builder. +func (sausuo *ScaAuthUserSocialUpdateOne) Mutation() *ScaAuthUserSocialMutation { + return sausuo.mutation +} + +// ClearScaAuthUser clears the "sca_auth_user" edge to the ScaAuthUser entity. +func (sausuo *ScaAuthUserSocialUpdateOne) ClearScaAuthUser() *ScaAuthUserSocialUpdateOne { + sausuo.mutation.ClearScaAuthUser() + return sausuo +} + +// Where appends a list predicates to the ScaAuthUserSocialUpdate builder. +func (sausuo *ScaAuthUserSocialUpdateOne) Where(ps ...predicate.ScaAuthUserSocial) *ScaAuthUserSocialUpdateOne { + sausuo.mutation.Where(ps...) + return sausuo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (sausuo *ScaAuthUserSocialUpdateOne) Select(field string, fields ...string) *ScaAuthUserSocialUpdateOne { + sausuo.fields = append([]string{field}, fields...) + return sausuo +} + +// Save executes the query and returns the updated ScaAuthUserSocial entity. +func (sausuo *ScaAuthUserSocialUpdateOne) Save(ctx context.Context) (*ScaAuthUserSocial, error) { + sausuo.defaults() + return withHooks(ctx, sausuo.sqlSave, sausuo.mutation, sausuo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (sausuo *ScaAuthUserSocialUpdateOne) SaveX(ctx context.Context) *ScaAuthUserSocial { + node, err := sausuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (sausuo *ScaAuthUserSocialUpdateOne) Exec(ctx context.Context) error { + _, err := sausuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (sausuo *ScaAuthUserSocialUpdateOne) ExecX(ctx context.Context) { + if err := sausuo.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (sausuo *ScaAuthUserSocialUpdateOne) defaults() { + if _, ok := sausuo.mutation.UpdateAt(); !ok && !sausuo.mutation.UpdateAtCleared() { + v := scaauthusersocial.UpdateDefaultUpdateAt() + sausuo.mutation.SetUpdateAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (sausuo *ScaAuthUserSocialUpdateOne) check() error { + if v, ok := sausuo.mutation.UserID(); ok { + if err := scaauthusersocial.UserIDValidator(v); err != nil { + return &ValidationError{Name: "user_id", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserSocial.user_id": %w`, err)} + } + } + if v, ok := sausuo.mutation.OpenID(); ok { + if err := scaauthusersocial.OpenIDValidator(v); err != nil { + return &ValidationError{Name: "open_id", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserSocial.open_id": %w`, err)} + } + } + if v, ok := sausuo.mutation.Source(); ok { + if err := scaauthusersocial.SourceValidator(v); err != nil { + return &ValidationError{Name: "source", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserSocial.source": %w`, err)} + } + } + return nil +} + +func (sausuo *ScaAuthUserSocialUpdateOne) sqlSave(ctx context.Context) (_node *ScaAuthUserSocial, err error) { + if err := sausuo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(scaauthusersocial.Table, scaauthusersocial.Columns, sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64)) + id, ok := sausuo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ScaAuthUserSocial.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := sausuo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, scaauthusersocial.FieldID) + for _, f := range fields { + if !scaauthusersocial.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != scaauthusersocial.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := sausuo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := sausuo.mutation.UserID(); ok { + _spec.SetField(scaauthusersocial.FieldUserID, field.TypeString, value) + } + if value, ok := sausuo.mutation.OpenID(); ok { + _spec.SetField(scaauthusersocial.FieldOpenID, field.TypeString, value) + } + if value, ok := sausuo.mutation.Source(); ok { + _spec.SetField(scaauthusersocial.FieldSource, field.TypeString, value) + } + if value, ok := sausuo.mutation.Status(); ok { + _spec.SetField(scaauthusersocial.FieldStatus, field.TypeInt, value) + } + if value, ok := sausuo.mutation.AddedStatus(); ok { + _spec.AddField(scaauthusersocial.FieldStatus, field.TypeInt, value) + } + if value, ok := sausuo.mutation.UpdateAt(); ok { + _spec.SetField(scaauthusersocial.FieldUpdateAt, field.TypeTime, value) + } + if sausuo.mutation.UpdateAtCleared() { + _spec.ClearField(scaauthusersocial.FieldUpdateAt, field.TypeTime) + } + if value, ok := sausuo.mutation.Deleted(); ok { + _spec.SetField(scaauthusersocial.FieldDeleted, field.TypeInt, value) + } + if value, ok := sausuo.mutation.AddedDeleted(); ok { + _spec.AddField(scaauthusersocial.FieldDeleted, field.TypeInt, value) + } + if sausuo.mutation.ScaAuthUserCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: scaauthusersocial.ScaAuthUserTable, + Columns: []string{scaauthusersocial.ScaAuthUserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := sausuo.mutation.ScaAuthUserIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: scaauthusersocial.ScaAuthUserTable, + Columns: []string{scaauthusersocial.ScaAuthUserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _node = &ScaAuthUserSocial{config: sausuo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, sausuo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{scaauthusersocial.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + sausuo.mutation.done = true + return _node, nil +} diff --git a/common/ent/schema/sca_auth_permission_rule.go b/common/ent/schema/sca_auth_permission_rule.go new file mode 100644 index 0000000..63be6b0 --- /dev/null +++ b/common/ent/schema/sca_auth_permission_rule.go @@ -0,0 +1,58 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" +) + +// ScaAuthPermissionRule holds the schema definition for the ScaAuthPermissionRule entity. +type ScaAuthPermissionRule struct { + ent.Schema +} + +// Fields of the ScaAuthPermissionRule. +func (ScaAuthPermissionRule) Fields() []ent.Field { + return []ent.Field{ + field.Int64("id"). + SchemaType(map[string]string{ + dialect.MySQL: "bigint(20) unsigned", + }). + Unique(), + field.String("ptype"). + MaxLen(100). + Nillable(), + field.String("v0"). + MaxLen(100). + Nillable(), + field.String("v1"). + MaxLen(100). + Nillable(), + field.String("v2"). + MaxLen(100). + Optional(). + Nillable(), + field.String("v3"). + MaxLen(100). + Optional(). + Nillable(), + field.String("v4"). + MaxLen(100). + Optional(). + Nillable(), + field.String("v5"). + MaxLen(100). + Optional(). + Nillable(), + } +} + +// Edges of the ScaAuthPermissionRule. +func (ScaAuthPermissionRule) Edges() []ent.Edge { + return []ent.Edge{ + edge.From("sca_auth_role", ScaAuthRole.Type). + Ref("sca_auth_permission_rule"). + Unique(), + } +} diff --git a/common/ent/schema/sca_auth_role.go b/common/ent/schema/sca_auth_role.go new file mode 100644 index 0000000..e8ee693 --- /dev/null +++ b/common/ent/schema/sca_auth_role.go @@ -0,0 +1,55 @@ +package schema + +import ( + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" +) + +// ScaAuthRole holds the schema definition for the ScaAuthRole entity. +type ScaAuthRole struct { + ent.Schema +} + +// Fields of the ScaAuthRole. +func (ScaAuthRole) Fields() []ent.Field { + return []ent.Field{ + field.Int64("id"). + SchemaType(map[string]string{ + dialect.MySQL: "bigint(20)", + }). + Unique(). + Comment("主键ID"), + field.String("role_name"). + MaxLen(32). + Comment("角色名称"), + field.String("role_key"). + MaxLen(64). + Comment("角色关键字"), + field.Time("created_at"). + Default(time.Now). + Immutable(). + Comment("创建时间"), + field.Time("update_at"). + Default(time.Now).UpdateDefault(time.Now). + Comment("更新时间"), + field.Int("deleted"). + Default(0). + Comment("是否删除 0 未删除 1已删除"), + } +} + +// Edges of the ScaAuthRole. +func (ScaAuthRole) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("sca_auth_permission_rule", ScaAuthPermissionRule.Type), + } +} + +// Indexes of the ScaAuthRole. +func (ScaAuthRole) Indexes() []ent.Index { + return nil +} diff --git a/common/ent/schema/sca_auth_user.go b/common/ent/schema/sca_auth_user.go new file mode 100644 index 0000000..d8af149 --- /dev/null +++ b/common/ent/schema/sca_auth_user.go @@ -0,0 +1,115 @@ +package schema + +import ( + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" +) + +// ScaAuthUser holds the schema definition for the ScaAuthUser entity. +type ScaAuthUser struct { + ent.Schema +} + +// Fields of the ScaAuthUser. +func (ScaAuthUser) Fields() []ent.Field { + return []ent.Field{ + field.Int64("id"). + SchemaType(map[string]string{ + dialect.MySQL: "bigint(20)", + }). + Unique(). + Comment("自增ID"), + field.String("uid"). + MaxLen(20). + Unique(). + Comment("唯一ID"), + field.String("username"). + MaxLen(32). + Optional(). + Comment("用户名"), + field.String("nickname"). + MaxLen(32). + Optional(). + Comment("昵称"), + field.String("email"). + MaxLen(32). + Optional(). + Comment("邮箱"), + field.String("phone"). + MaxLen(32). + Optional(). + Comment("电话"), + field.String("password"). + MaxLen(64). + Optional(). + Sensitive(). + Comment("密码"), + field.String("gender"). + MaxLen(32). + Optional(). + Comment("性别"), + field.String("avatar"). + Optional(). + Comment("头像"), + field.Int8("status"). + Default(0). + Optional(). + Comment("状态 0 正常 1 封禁"), + field.String("introduce"). + MaxLen(255). + Optional(). + Comment("介绍"), + field.Time("created_at"). + Default(time.Now). + Immutable(). + Comment("创建时间"), + field.Time("update_at"). + Default(time.Now).UpdateDefault(time.Now). + Nillable(). + Optional(). + Comment("更新时间"), + field.Int8("deleted"). + Default(0). + Comment("是否删除 0 未删除 1 已删除"), + field.String("blog"). + MaxLen(30). + Nillable(). + Optional(). + Comment("博客"), + field.String("location"). + MaxLen(50). + Nillable(). + Optional(). + Comment("地址"), + field.String("company"). + MaxLen(50). + Nillable(). + Optional(). + Comment("公司"), + } +} + +// Edges of the ScaAuthUser. +func (ScaAuthUser) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("sca_auth_user_social", ScaAuthUserSocial.Type), + edge.To("sca_auth_user_device", ScaAuthUserDevice.Type), + } +} + +// Indexes of the ScaAuthUser. +func (ScaAuthUser) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("id"). + Unique(), + index.Fields("uid"). + Unique(), + index.Fields("phone"). + Unique(), + } +} diff --git a/common/ent/schema/sca_auth_user_device.go b/common/ent/schema/sca_auth_user_device.go new file mode 100644 index 0000000..71fff46 --- /dev/null +++ b/common/ent/schema/sca_auth_user_device.go @@ -0,0 +1,94 @@ +package schema + +import ( + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" +) + +// ScaAuthUserDevice holds the schema definition for the ScaAuthUserDevice entity. +type ScaAuthUserDevice struct { + ent.Schema +} + +// Fields of the ScaAuthUserDevice. +func (ScaAuthUserDevice) Fields() []ent.Field { + return []ent.Field{ + field.Int64("id"). + SchemaType(map[string]string{ + dialect.MySQL: "bigint(20)", + }). + Unique(). + Comment("主键ID"), + field.String("user_id"). + MaxLen(20). + Comment("用户ID"), + field.String("ip"). + MaxLen(20). + Comment("登录IP"), + field.String("location"). + MaxLen(20). + Comment("地址"), + field.String("agent"). + MaxLen(255). + Comment("设备信息"), + field.Time("created_at"). + Default(time.Now). + Optional(). + Immutable(). + Comment("创建时间"), + field.Time("update_at"). + Default(time.Now).UpdateDefault(time.Now). + Nillable(). + Comment("更新时间"), + field.Int("deleted"). + Default(0). + Comment("是否删除"), + field.String("browser"). + MaxLen(20). + Comment("浏览器"), + field.String("operating_system"). + MaxLen(20). + Comment("操作系统"), + field.String("browser_version"). + MaxLen(20). + Comment("浏览器版本"), + field.Int("mobile"). + Comment("是否为手机 0否1是"), + field.Int("bot"). + Comment("是否为bot 0否1是"), + field.String("mozilla"). + MaxLen(10). + Comment("火狐版本"), + field.String("platform"). + MaxLen(20). + Comment("平台"), + field.String("engine_name"). + MaxLen(20). + Comment("引擎名称"), + field.String("engine_version"). + MaxLen(20). + Comment("引擎版本"), + } +} + +// Edges of the ScaAuthUserDevice. +func (ScaAuthUserDevice) Edges() []ent.Edge { + return []ent.Edge{ + edge.From("sca_auth_user", ScaAuthUser.Type). + Ref("sca_auth_user_device"). + Unique(), + } +} + +// Indexes of the ScaAuthUserDevice. +func (ScaAuthUserDevice) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("id"). + Unique(), + } +} diff --git a/common/ent/schema/sca_auth_user_social.go b/common/ent/schema/sca_auth_user_social.go new file mode 100644 index 0000000..42f3ee0 --- /dev/null +++ b/common/ent/schema/sca_auth_user_social.go @@ -0,0 +1,69 @@ +package schema + +import ( + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" +) + +// ScaAuthUserSocial holds the schema definition for the ScaAuthUserSocial entity. +type ScaAuthUserSocial struct { + ent.Schema +} + +// Fields of the ScaAuthUserSocial. +func (ScaAuthUserSocial) Fields() []ent.Field { + return []ent.Field{ + field.Int64("id"). + SchemaType(map[string]string{ + dialect.MySQL: "bigint(20)", + }). + Unique(). + Comment("主键ID"), + field.String("user_id"). + MaxLen(20). + Comment("用户ID"), + field.String("open_id"). + MaxLen(50). + Comment("第三方用户的 open id"), + field.String("source"). + MaxLen(10). + Comment("第三方用户来源"), + field.Int("status"). + Default(0). + Comment("状态 0正常 1 封禁"), + field.Time("created_at"). + Default(time.Now). + Immutable(). + Comment("创建时间"), + field.Time("update_at"). + Default(time.Now).UpdateDefault(time.Now). + Optional(). + Nillable(). + Comment("更新时间"), + field.Int("deleted"). + Default(0). + Comment("是否删除"), + } +} + +// Edges of the ScaAuthUserSocial. +func (ScaAuthUserSocial) Edges() []ent.Edge { + return []ent.Edge{ + edge.From("sca_auth_user", ScaAuthUser.Type). + Ref("sca_auth_user_social"). + Unique(), + } +} + +// Indexes of the ScaAuthUserSocial. +func (ScaAuthUserSocial) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("id", "user_id", "open_id"). + Unique(), + } +} diff --git a/common/ent/tx.go b/common/ent/tx.go new file mode 100644 index 0000000..17d77f2 --- /dev/null +++ b/common/ent/tx.go @@ -0,0 +1,222 @@ +// 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 + // ScaAuthPermissionRule is the client for interacting with the ScaAuthPermissionRule builders. + ScaAuthPermissionRule *ScaAuthPermissionRuleClient + // ScaAuthRole is the client for interacting with the ScaAuthRole builders. + ScaAuthRole *ScaAuthRoleClient + // ScaAuthUser is the client for interacting with the ScaAuthUser builders. + ScaAuthUser *ScaAuthUserClient + // ScaAuthUserDevice is the client for interacting with the ScaAuthUserDevice builders. + ScaAuthUserDevice *ScaAuthUserDeviceClient + // ScaAuthUserSocial is the client for interacting with the ScaAuthUserSocial builders. + ScaAuthUserSocial *ScaAuthUserSocialClient + + // 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.ScaAuthPermissionRule = NewScaAuthPermissionRuleClient(tx.config) + tx.ScaAuthRole = NewScaAuthRoleClient(tx.config) + tx.ScaAuthUser = NewScaAuthUserClient(tx.config) + tx.ScaAuthUserDevice = NewScaAuthUserDeviceClient(tx.config) + tx.ScaAuthUserSocial = NewScaAuthUserSocialClient(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: ScaAuthPermissionRule.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/common/middleware/i18n_middleware.go b/common/middleware/i18n_middleware.go new file mode 100644 index 0000000..7770085 --- /dev/null +++ b/common/middleware/i18n_middleware.go @@ -0,0 +1,7 @@ +package middleware + +import "net/http" + +func I18nMiddleware(w http.ResponseWriter, r *http.Request) { + +} diff --git a/common/middleware/security_headers_middleware.go b/common/middleware/security_headers_middleware.go new file mode 100644 index 0000000..2d9be78 --- /dev/null +++ b/common/middleware/security_headers_middleware.go @@ -0,0 +1,13 @@ +package middleware + +import "net/http" + +func SecurityHeadersMiddleware(w http.ResponseWriter, r *http.Request) { + r.Header.Set("X-Frame-Options", "DENY") + r.Header.Set("Content-Security-Policy", "default-src 'self'; connect-src *; font-src *; script-src-elem * 'unsafe-inline'; img-src * data:; style-src * 'unsafe-inline';") + r.Header.Set("X-XSS-Protection", "1; mode=block") + r.Header.Set("Strict-Transport-Security", "max-age=31536000; includeSubDomains; preload") + r.Header.Set("Referrer-Policy", "strict-origin") + r.Header.Set("X-Content-Type-Options", "nosniff") + r.Header.Set("Permissions-Policy", "geolocation=(),midi=(),sync-xhr=(),microphone=(),camera=(),magnetometer=(),gyroscope=(),fullscreen=(self),payment=()") +} diff --git a/common/response/response.go b/common/response/response.go new file mode 100644 index 0000000..a467149 --- /dev/null +++ b/common/response/response.go @@ -0,0 +1 @@ +package response diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..914f84e --- /dev/null +++ b/go.mod @@ -0,0 +1,62 @@ +module schisandra-album-cloud-microservices + +go 1.23.3 + +require ( + entgo.io/ent v0.14.1 + github.com/go-sql-driver/mysql v1.8.1 + github.com/zeromicro/go-zero v1.7.3 +) + +require ( + ariga.io/atlas v0.19.1-0.20240203083654-5948b60a8e43 // indirect + filippo.io/edwards25519 v1.1.0 // indirect + github.com/agext/levenshtein v1.2.1 // indirect + github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect + github.com/beorn7/perks v1.0.1 // indirect + github.com/cenkalti/backoff/v4 v4.3.0 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect + github.com/fatih/color v1.17.0 // indirect + github.com/go-logr/logr v1.4.2 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + github.com/go-openapi/inflect v0.19.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/google/go-cmp v0.6.0 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect + github.com/hashicorp/hcl/v2 v2.13.0 // indirect + github.com/klauspost/compress v1.17.9 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 // indirect + github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/openzipkin/zipkin-go v0.4.3 // indirect + github.com/pelletier/go-toml/v2 v2.2.2 // indirect + github.com/prometheus/client_golang v1.20.5 // indirect + github.com/prometheus/client_model v0.6.1 // indirect + github.com/prometheus/common v0.55.0 // indirect + github.com/prometheus/procfs v0.15.1 // indirect + github.com/spaolacci/murmur3 v1.1.0 // indirect + github.com/zclconf/go-cty v1.8.0 // indirect + go.opentelemetry.io/otel v1.24.0 // indirect + go.opentelemetry.io/otel/exporters/jaeger v1.17.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0 // indirect + go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.24.0 // indirect + go.opentelemetry.io/otel/exporters/zipkin v1.24.0 // indirect + go.opentelemetry.io/otel/metric v1.24.0 // indirect + go.opentelemetry.io/otel/sdk v1.24.0 // indirect + go.opentelemetry.io/otel/trace v1.24.0 // indirect + go.opentelemetry.io/proto/otlp v1.3.1 // indirect + go.uber.org/automaxprocs v1.6.0 // indirect + golang.org/x/mod v0.20.0 // indirect + golang.org/x/net v0.30.0 // indirect + golang.org/x/sys v0.26.0 // indirect + golang.org/x/text v0.19.0 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240711142825-46eb208f015d // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect + google.golang.org/grpc v1.65.0 // indirect + google.golang.org/protobuf v1.35.1 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..c28c186 --- /dev/null +++ b/go.sum @@ -0,0 +1,191 @@ +ariga.io/atlas v0.19.1-0.20240203083654-5948b60a8e43 h1:GwdJbXydHCYPedeeLt4x/lrlIISQ4JTH1mRWuE5ZZ14= +ariga.io/atlas v0.19.1-0.20240203083654-5948b60a8e43/go.mod h1:uj3pm+hUTVN/X5yfdBexHlZv+1Xu5u5ZbZx7+CDavNU= +entgo.io/ent v0.14.1 h1:fUERL506Pqr92EPHJqr8EYxbPioflJo6PudkrEA8a/s= +entgo.io/ent v0.14.1/go.mod h1:MH6XLG0KXpkcDQhKiHfANZSzR55TJyPL5IGNpI8wpco= +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.2 h1:OcvFkGmslmlZibjAjaHm3L//6LiuBgolP7OputlJIzU= +github.com/DATA-DOG/go-sqlmock v1.5.2/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU= +github.com/agext/levenshtein v1.2.1 h1:QmvMAjj2aEICytGiWzmxoE0x2KZvE0fvmqMOfy2tjT8= +github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= +github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= +github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= +github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= +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.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= +github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +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.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y= +github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg= +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/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +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.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1YCS1PXdKYWi8FsN0= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0/go.mod h1:P+Lt/0by1T8bfcF3z737NnSbmxQAppXMRziHUxPOC8k= +github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw= +github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI= +github.com/hashicorp/hcl/v2 v2.13.0 h1:0Apadu1w6M11dyGFxWnmhhcMjkbAiKCv7G1r/2QgCNc= +github.com/hashicorp/hcl/v2 v2.13.0/go.mod h1:e4z5nxYlWNPdDSNYX+ph14EvWYMFm3eP0zIUqPc2jr0= +github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= +github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= +github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +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/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +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-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= +github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y= +github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= +github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 h1:DpOJ2HYzCv8LZP15IdmG+YdwD2luVPHITV96TkirNBM= +github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= +github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= +github.com/openzipkin/zipkin-go v0.4.3 h1:9EGwpqkgnwdEIJ+Od7QVSEIH+ocmm5nPat0G7sjsSdg= +github.com/openzipkin/zipkin-go v0.4.3/go.mod h1:M9wCJZFWCo2RiY+o1eBCEMe0Dp2S5LDHcMZmk3RmK7c= +github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= +github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= +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/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g= +github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U= +github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y= +github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= +github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= +github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= +github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc= +github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8= +github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= +github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= +github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= +github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= +github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= +github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= +github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= +github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= +github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= +github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I= +github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= +github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= +github.com/zclconf/go-cty v1.8.0 h1:s4AvqaeQzJIu3ndv4gVIhplVD0krU+bgrcLSVUnaWuA= +github.com/zclconf/go-cty v1.8.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= +github.com/zeromicro/go-zero v1.7.3 h1:yDUQF2DXDhUHc77/NZF6mzsoRPMBfldjPmG2O/ZSzss= +github.com/zeromicro/go-zero v1.7.3/go.mod h1:9JIW3gHBGuc9LzvjZnNwINIq9QdiKu3AigajLtkJamQ= +go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= +go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= +go.opentelemetry.io/otel/exporters/jaeger v1.17.0 h1:D7UpUy2Xc2wsi1Ras6V40q806WM07rqoCWzXu7Sqy+4= +go.opentelemetry.io/otel/exporters/jaeger v1.17.0/go.mod h1:nPCqOnEH9rNLKqH/+rrUjiMzHJdV1BlpKcTwRTyKkKI= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 h1:t6wl9SPayj+c7lEIFgm4ooDBZVb01IhLB4InpomhRw8= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0/go.mod h1:iSDOcsnSA5INXzZtwaBPrKp/lWu/V14Dd+llD0oI2EA= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0 h1:Mw5xcxMwlqoJd97vwPxA8isEaIoxsta9/Q51+TTJLGE= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0/go.mod h1:CQNu9bj7o7mC6U7+CA/schKEYakYXWr79ucDHTMGhCM= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0 h1:Xw8U6u2f8DK2XAkGRFV7BBLENgnTGX9i4rQRxJf+/vs= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0/go.mod h1:6KW1Fm6R/s6Z3PGXwSJN2K4eT6wQB3vXX6CVnYX9NmM= +go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.24.0 h1:s0PHtIkN+3xrbDOpt2M8OTG92cWqUESvzh2MxiR5xY8= +go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.24.0/go.mod h1:hZlFbDbRt++MMPCCfSJfmhkGIWnX1h3XjkfxZUjLrIA= +go.opentelemetry.io/otel/exporters/zipkin v1.24.0 h1:3evrL5poBuh1KF51D9gO/S+N/1msnm4DaBqs/rpXUqY= +go.opentelemetry.io/otel/exporters/zipkin v1.24.0/go.mod h1:0EHgD8R0+8yRhUYJOGR8Hfg2dpiJQxDOszd5smVO9wM= +go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= +go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= +go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw= +go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= +go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= +go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= +go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0= +go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8= +go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs= +go.uber.org/automaxprocs v1.6.0/go.mod h1:ifeIMSnPZuznNm6jmdzmU3/bfk01Fe2fotchwEFJ8r8= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0= +golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= +golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= +golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= +golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24= +golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ= +google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/genproto/googleapis/api v0.0.0-20240711142825-46eb208f015d h1:kHjw/5UfflP/L5EbledDrcG4C2597RtymmGRZvHiCuY= +google.golang.org/genproto/googleapis/api v0.0.0-20240711142825-46eb208f015d/go.mod h1:mw8MG/Qz5wfgYr6VqVCiZcHe/GJEfI+oGGDCohaVgB0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 h1:BwIjyKYGsK9dMCBOorzRri8MQwmi7mT9rGHsCEinZkA= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY= +google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc= +google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ= +google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= +google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/h2non/gock.v1 v1.1.2 h1:jBbHXgGBK/AoPVfJh5x4r/WxIrElvbLel8TCZkkZJoY= +gopkg.in/h2non/gock.v1 v1.1.2/go.mod h1:n7UGz/ckNChHiK05rDoiC4MYSunEC/lyaUm2WWaDva0= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 h1:pUdcCO1Lk/tbT5ztQWOBi5HBgbBP1J8+AsQnQCKsi8A= +k8s.io/utils v0.0.0-20240711033017-18e509b52bc8/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=