diff --git a/Makefile b/Makefile deleted file mode 100644 index 7b94938..0000000 --- a/Makefile +++ /dev/null @@ -1,152 +0,0 @@ -# Custom configuration | 独立配置 -# Service name | 项目名称 -SERVICE=Iot_App -# Service name in specific style | 项目经过style格式化的名称 -SERVICE_STYLE=iot_app -# Service name in lowercase | 项目名称全小写格式 -SERVICE_LOWER=iot_app -# Service name in snake format | 项目名称下划线格式 -SERVICE_SNAKE=iot_app -# Service name in snake format | 项目名称短杠格式 -SERVICE_DASH=iot_app - -# The project version, if you don't use git, you should set it manually | 项目版本,如果不使用git请手动设置 -VERSION=$(shell git describe --tags --always) - -# The project file name style | 项目文件命名风格 -PROJECT_STYLE=go_zero - -# Whether to use i18n | 是否启用 i18n -PROJECT_I18N=true - -# Swagger type, support yml,json | Swagger 文件类型,支持yml,json -SWAGGER_TYPE=json - -# Ent enabled features | Ent 启用的官方特性 -ENT_FEATURE=sql/execquery,intercept,sql/modifier,privacy,entql - -# The arch of the build | 构建的架构 -GOARCH=amd64 - -# The repository of docker | Docker 仓库地址 -DOCKER_REPO=registry.cn-hangzhou.aliyuncs.com/simple_admin_vip - -# ---- You may not need to modify the codes below | 下面的代码大概率不需要更改 ---- - -GO ?= go -GOFMT ?= gofmt "-s" -GOFILES := $(shell find . -name "*.go") -LDFLAGS := -s -w - -.PHONY: test -test: # Run test for the project | 运行项目测试 - go test -v --cover ./api/internal/.. - go test -v --cover ./rpc/internal/.. - -.PHONY: fmt -fmt: # Format the codes | 格式化代码 - $(GOFMT) -w $(GOFILES) - -.PHONY: lint -lint: # Run go linter | 运行代码错误分析 - golangci-lint run -D staticcheck - -.PHONY: tools -tools: # Install the necessary tools | 安装必要的工具 - $(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@latest - $(GO) install github.com/go-swagger/go-swagger/cmd/swagger@latest - -.PHONY: docker -docker: # Build the docker image | 构建 docker 镜像 - docker build -f Dockerfile-api -t $(DOCKER_REPO)/$(SERVICE_DASH)-tenant-api:${VERSION} . - docker build -f Dockerfile-rpc -t $(DOCKER_REPO)/$(SERVICE_DASH)-tenant-rpc:${VERSION} . - @echo "Build docker successfully" - -.PHONY: publish-docker -publish-docker: # Publish docker image | 发布 docker 镜像 - docker push $(DOCKER_REPO)/$(SERVICE_DASH)-tenant-rpc:${VERSION} - docker push $(DOCKER_REPO)/$(SERVICE_DASH)-tenant-api:${VERSION} - @echo "Publish docker successfully" - -.PHONY: gen-api -gen-api: # Generate API files | 生成 API 的代码 - goctls api go --api ./api/desc/all.api --dir ./api --trans_err=true --style=$(PROJECT_STYLE) - swagger generate spec --output=./$(SERVICE_STYLE).$(SWAGGER_TYPE) --scan-models --exclude-deps - @echo "Generate API files successfully" - -.PHONY: gen-rpc -gen-rpc: # Generate RPC files from proto | 生成 RPC 的代码 - goctls rpc protoc ./rpc/$(SERVICE_STYLE).proto --style=$(PROJECT_STYLE) --go_out=./rpc/types --go-grpc_out=./rpc/types --zrpc_out=./rpc --style=$(PROJECT_STYLE) - @echo "Generate RPC files successfully" - -.PHONY: gen-ent -gen-ent: # Generate Ent codes | 生成 Ent 的代码 - go run -mod=mod entgo.io/ent/cmd/ent generate --template glob="./rpc/ent/template/*.tmpl" ./rpc/ent/schema --feature $(ENT_FEATURE) - @echo "Generate Ent files successfully" - -.PHONY: gen-rpc-ent-logic -gen-rpc-ent-logic: # Generate logic code from Ent, need model and group params | 根据 Ent 生成逻辑代码, 需要设置 model 和 group - goctls rpc ent --schema=./rpc/ent/schema --style=$(PROJECT_STYLE) --import_prefix=/rpc --service_name=$(SERVICE) --project_name=$(SERVICE_STYLE) -o=./rpc --model=$(model) --group=$(group) --i18n=$(PROJECT_I18N) --proto_out=./rpc/desc/$(shell echo $(model) | tr A-Z a-z).proto --overwrite=true - @echo "Generate logic codes from Ent successfully" - -.PHONY: build-win -build-win: # Build project for Windows | 构建Windows下的可执行文件 - env CGO_ENABLED=0 GOOS=windows GOARCH=$(GOARCH) go build -ldflags "$(LDFLAGS)" -trimpath -o $(SERVICE_STYLE)_rpc.exe ./rpc/$(SERVICE_STYLE).go - env CGO_ENABLED=0 GOOS=windows GOARCH=$(GOARCH) go build -ldflags "$(LDFLAGS)" -trimpath -o $(SERVICE_STYLE)_api.exe ./api/$(SERVICE_STYLE).go - @echo "Build project for Windows successfully" - -.PHONY: build-mac -build-mac: # Build project for MacOS | 构建MacOS下的可执行文件 - env CGO_ENABLED=0 GOOS=darwin GOARCH=$(GOARCH) go build -ldflags "$(LDFLAGS)" -trimpath -o $(SERVICE_STYLE)_rpc ./rpc/$(SERVICE_STYLE).go - env CGO_ENABLED=0 GOOS=darwin GOARCH=$(GOARCH) go build -ldflags "$(LDFLAGS)" -trimpath -o $(SERVICE_STYLE)_api ./api/$(SERVICE_STYLE).go - @echo "Build project for MacOS successfully" - -.PHONY: build-linux -build-linux: # Build project for Linux | 构建Linux下的可执行文件 - env CGO_ENABLED=0 GOOS=linux GOARCH=$(GOARCH) go build -ldflags "$(LDFLAGS)" -trimpath -o $(SERVICE_STYLE)_rpc ./rpc/$(SERVICE_STYLE).go - env CGO_ENABLED=0 GOOS=linux GOARCH=$(GOARCH) go build -ldflags "$(LDFLAGS)" -trimpath -o $(SERVICE_STYLE)_api ./api/$(SERVICE_STYLE).go - @echo "Build project for Linux successfully" - -.PHONY: gen-swagger -gen-swagger: # Generate swagger file | 生成 swagger 文件 - swagger generate spec --output=./$(SERVICE_STYLE).$(SWAGGER_TYPE) --scan-models --exclude-deps - @echo "Generate swagger successfully" - -.PHONY: serve-swagger -serve-swagger: # Run the swagger server | 运行 swagger 服务 - lsof -i:36666 | awk 'NR!=1 {print $2}' | xargs killall -9 || true - swagger serve -F=swagger --port 36666 $(SERVICE_STYLE).$(SWAGGER_TYPE) - @echo "Serve swagger-ui successfully" - -.PHONY: help -help: # Show help | 显示帮助 - @grep -E '^[a-zA-Z0-9 -]+:.*#' Makefile | sort | while read -r l; do printf "\033[1;32m$$(echo $$l | cut -f 1 -d':')\033[00m:$$(echo $$l | cut -f 2- -d'#')\n"; done - - -.PHONY: format-api -format-api: # Format API files | 格式化 API 文件 - @echo "Formatting API files..." - @if [ -f "./api/desc/all.api" ]; then \ - goctl api format --dir ./api/desc ; \ - echo "API files formatted successfully"; \ - else \ - echo "API files not found in ./desc directory"; \ - fi - @if [ -f "./*.api" ]; then \ - goctl api format --dir . --force; \ - echo "Root directory API files formatted successfully"; \ - fi - -.PHONY: format-rpc -format-rpc: # Format RPC files | 格式化 RPC 文件 - @echo "Formatting RPC files..." - @if [ -d "./rpc/desc" ]; then \ - find ./desc -name "*.proto" -exec goctl rpc protoc {} --go_out=./ --go-grpc_out=./ --zrpc_out=. \; 2>/dev/null || echo "RPC formatting completed"; \ - echo "RPC files formatted successfully"; \ - else \ - echo "RPC files directory ./rpc/desc not found"; \ - fi - -.PHONY: format-all -format-all: format-api format-rpc # Format both API and RPC files | 格式化所有 API 和 RPC 文件 - @echo "All files formatted successfully" diff --git a/README.md b/README.md index 26f832e..6c41d3b 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ -# mingyang-admin-iot-app +# mingyang-admin-app -mingyang-admin-iot-app \ No newline at end of file +mingyang-admin-app \ No newline at end of file diff --git a/api/api.go b/api/api.go index a9dd907..7ae125b 100644 --- a/api/api.go +++ b/api/api.go @@ -7,9 +7,9 @@ import ( "flag" "fmt" - "mingyang-admin-iot-app/api/internal/config" - "mingyang-admin-iot-app/api/internal/handler" - "mingyang-admin-iot-app/api/internal/svc" + "mingyang-admin-app/api/internal/config" + "mingyang-admin-app/api/internal/handler" + "mingyang-admin-app/api/internal/svc" "github.com/zeromicro/go-zero/core/conf" "github.com/zeromicro/go-zero/rest" diff --git a/api/go.mod b/api/go.mod index 059b96c..18dce02 100644 --- a/api/go.mod +++ b/api/go.mod @@ -1,3 +1,3 @@ -module mingyang-admin-iot-app/api +module mingyang-admin-app-api go 1.25.3 diff --git a/api/internal/handler/apihandler.go b/api/internal/handler/apihandler.go index 8f7a950..081f360 100644 --- a/api/internal/handler/apihandler.go +++ b/api/internal/handler/apihandler.go @@ -7,9 +7,9 @@ import ( "net/http" "github.com/zeromicro/go-zero/rest/httpx" - "mingyang-admin-iot-app/api/internal/logic" - "mingyang-admin-iot-app/api/internal/svc" - "mingyang-admin-iot-app/api/internal/types" + "mingyang-admin-app/api/internal/logic" + "mingyang-admin-app/api/internal/svc" + "mingyang-admin-app/api/internal/types" ) func ApiHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { diff --git a/api/internal/handler/routes.go b/api/internal/handler/routes.go index 6de064f..e1cf9ea 100644 --- a/api/internal/handler/routes.go +++ b/api/internal/handler/routes.go @@ -6,7 +6,7 @@ package handler import ( "net/http" - "mingyang-admin-iot-app/api/internal/svc" + "mingyang-admin-app/api/internal/svc" "github.com/zeromicro/go-zero/rest" ) diff --git a/api/internal/logic/apilogic.go b/api/internal/logic/apilogic.go index b030be9..24dfbbc 100644 --- a/api/internal/logic/apilogic.go +++ b/api/internal/logic/apilogic.go @@ -6,8 +6,8 @@ package logic import ( "context" - "mingyang-admin-iot-app/api/internal/svc" - "mingyang-admin-iot-app/api/internal/types" + "mingyang-admin-app/api/internal/svc" + "mingyang-admin-app/api/internal/types" "github.com/zeromicro/go-zero/core/logx" ) diff --git a/api/internal/svc/servicecontext.go b/api/internal/svc/servicecontext.go index 217b04f..bd2a792 100644 --- a/api/internal/svc/servicecontext.go +++ b/api/internal/svc/servicecontext.go @@ -4,7 +4,7 @@ package svc import ( - "mingyang-admin-iot-app/api/internal/config" + "mingyang-admin-app/api/internal/config" ) type ServiceContext struct { diff --git a/rpc/Makefile b/rpc/Makefile new file mode 100644 index 0000000..275f30c --- /dev/null +++ b/rpc/Makefile @@ -0,0 +1,109 @@ +# Custom configuration | 独立配置 +# Service name | 项目名称 +SERVICE=App +# Service name in specific style | 项目经过style格式化的名称 +SERVICE_STYLE=app +# Service name in lowercase | 项目名称全小写格式 +SERVICE_LOWER=app +# Service name in snake format | 项目名称下划线格式 +SERVICE_SNAKE=app +# Service name in snake format | 项目名称短杠格式 +SERVICE_DASH=app + +# The project version, if you don't use git, you should set it manually | 项目版本,如果不使用git请手动设置 +VERSION=$(shell git describe --tags --always) + +# The project file name style | 项目文件命名风格 +PROJECT_STYLE=go_zero + +# Whether to use i18n | 是否启用 i18n +PROJECT_I18N=true + +# The suffix after build or compile | 构建后缀 +PROJECT_BUILD_SUFFIX=rpc + + +# Ent enabled features | Ent 启用的官方特性 +ENT_FEATURE=sql/execquery,intercept + + +# The arch of the build | 构建的架构 +GOARCH=amd64 + +# The repository of docker | Docker 仓库地址 +DOCKER_REPO=docker.io/xxx + +# ---- You may not need to modify the codes below | 下面的代码大概率不需要更改 ---- + +model=all +group=all + +GO ?= go +GOFMT ?= gofmt "-s" +GOFILES := $(shell find . -name "*.go") +LDFLAGS := -s -w + +.PHONY: test +test: # Run test for the project | 运行项目测试 + go test -v --cover ./internal/.. + +.PHONY: fmt +fmt: # Format the codes | 格式化代码 + $(GOFMT) -w $(GOFILES) + +.PHONY: lint +lint: # Run go linter | 运行代码错误分析 + golangci-lint run -D staticcheck + +.PHONY: tools +tools: # Install the necessary tools | 安装必要的工具 + $(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@latest; + +.PHONY: docker +docker: # Build the docker image | 构建 docker 镜像 + docker build -f Dockerfile -t $(DOCKER_REPO)/$(SERVICE_DASH)-$(PROJECT_BUILD_SUFFIX):$(VERSION) . + @echo "Build docker successfully" + +.PHONY: publish-docker +publish-docker: # Publish docker image | 发布 docker 镜像 + docker push $(DOCKER_REPO)/$(SERVICE_DASH)-$(PROJECT_BUILD_SUFFIX):$(VERSION) + @echo "Publish docker successfully" + +.PHONY: gen-rpc +gen-rpc: # Generate RPC files from proto | 生成 RPC 的代码 + goctls rpc protoc ./$(SERVICE_STYLE).proto --go_out=./types --go-grpc_out=./types --zrpc_out=. --style=$(PROJECT_STYLE) +ifeq ($(shell uname -s), Darwin) + sed -i "" 's/,omitempty//g' ./types/$(SERVICE_LOWER)/*.pb.go +else + sed -i 's/,omitempty//g' ./types/$(SERVICE_LOWER)/*.pb.go +endif + @echo "Generate RPC codes successfully" + +.PHONY: gen-ent +gen-ent: # Generate Ent codes | 生成 Ent 的代码 + go run -mod=mod entgo.io/ent/cmd/ent generate --template glob="./ent/template/*.tmpl" ./ent/schema --feature $(ENT_FEATURE) + @echo "Generate Ent codes successfully" + +.PHONY: gen-rpc-ent-logic +gen-rpc-ent-logic: # Generate logic code.proto from Ent, need model and group params | 根据 Ent 生成逻辑代码, 需要设置 model 和 group + goctls rpc ent --schema=./ent/schema --style=$(PROJECT_STYLE) --multiple=false --service_name=$(SERVICE) --output=./ --model=$(model) --group=$(group) --proto_out=./desc/$(shell echo $(model) | tr A-Z a-z).proto --i18n=$(PROJECT_I18N) --overwrite=true + @echo "Generate logic codes from Ent successfully" + +.PHONY: build-win +build-win: # Build project for Windows | 构建Windows下的可执行文件 + env CGO_ENABLED=0 GOOS=windows GOARCH=$(GOARCH) go build -ldflags "$(LDFLAGS)" -trimpath -o $(SERVICE_STYLE)_$(PROJECT_BUILD_SUFFIX).exe $(SERVICE_STYLE).go + @echo "Build project for Windows successfully" + +.PHONY: build-mac +build-mac: # Build project for MacOS | 构建MacOS下的可执行文件 + env CGO_ENABLED=0 GOOS=darwin GOARCH=$(GOARCH) go build -ldflags "$(LDFLAGS)" -trimpath -o $(SERVICE_STYLE)_$(PROJECT_BUILD_SUFFIX) $(SERVICE_STYLE).go + @echo "Build project for MacOS successfully" + +.PHONY: build-linux +build-linux: # Build project for Linux | 构建Linux下的可执行文件 + env CGO_ENABLED=0 GOOS=linux GOARCH=$(GOARCH) go build -ldflags "$(LDFLAGS)" -trimpath -o $(SERVICE_STYLE)_$(PROJECT_BUILD_SUFFIX) $(SERVICE_STYLE).go + @echo "Build project for Linux successfully" + +.PHONY: help +help: # Show help | 显示帮助 + @grep -E '^[a-zA-Z0-9 -]+:.*#' Makefile | sort | while read -r l; do printf "\033[1;32m$$(echo $$l | cut -f 1 -d':')\033[00m:$$(echo $$l | cut -f 2- -d'#')\n"; done diff --git a/rpc/rpc.go b/rpc/app.go similarity index 63% rename from rpc/rpc.go rename to rpc/app.go index 4eab5ae..2332f92 100644 --- a/rpc/rpc.go +++ b/rpc/app.go @@ -3,11 +3,10 @@ package main import ( "flag" "fmt" - - "mingyang-admin-iot-app/rpc/internal/config" - "mingyang-admin-iot-app/rpc/internal/server" - "mingyang-admin-iot-app/rpc/internal/svc" - "mingyang-admin-iot-app/rpc/rpc" + "mingyang-admin-app-rpc/internal/config" + "mingyang-admin-app-rpc/internal/server" + "mingyang-admin-app-rpc/internal/svc" + "mingyang-admin-app-rpc/types/app" "github.com/zeromicro/go-zero/core/conf" "github.com/zeromicro/go-zero/core/service" @@ -16,17 +15,17 @@ import ( "google.golang.org/grpc/reflection" ) -var configFile = flag.String("f", "etc/rpc.yaml", "the config file") +var configFile = flag.String("f", "etc/app.yaml", "the config file") func main() { flag.Parse() var c config.Config - conf.MustLoad(*configFile, &c) + conf.MustLoad(*configFile, &c, conf.UseEnv()) ctx := svc.NewServiceContext(c) s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) { - rpc.RegisterRpcServer(grpcServer, server.NewRpcServer(ctx)) + app.RegisterAppServer(grpcServer, server.NewAppServer(ctx)) if c.Mode == service.DevMode || c.Mode == service.TestMode { reflection.Register(grpcServer) diff --git a/rpc/app.proto b/rpc/app.proto new file mode 100644 index 0000000..fe3b422 --- /dev/null +++ b/rpc/app.proto @@ -0,0 +1,122 @@ +syntax = "proto3"; + +package app; +option go_package = "./app"; + +import "google/protobuf/struct.proto"; + +import "google/protobuf/timestamp.proto"; + +// 账户类型枚举(手机/邮箱) +enum AccountType { + UNKNOWN = 0; + MOBILE = 1; + EMAIL = 2; +} + +// 验证码类型枚举 +enum VerifyCodeType { + REGISTER = 0; + LOGIN = 1; + RESET_PASSWORD = 2; + BIND_PHONE = 3; + BIND_EMAIL = 4; + UPDATE_PHONE = 5; + UPDATE_EMAIL = 6; + WITHDRAW = 7; + CHANGE_PAY_PASSWORD = 8; +} + +// 认证令牌 +message AuthToken { + string access_token = 1; + string refresh_token = 2; + string token_type = 3; + int32 expires_in = 4; + google.protobuf.Timestamp issued_at = 5; + google.protobuf.Timestamp expires_at = 6; + repeated string scopes = 7; +} + +message LoginRequest { + optional string username = 1; + optional string email = 2; + optional string mobile = 3; + optional string password = 4; + optional string clientIp = 5; + optional string platform = 6; + optional string login_type = 7; + optional string login_platform = 8; +} + +message LoginResponse { + UserInfo user = 1; + AuthToken auth_token = 2; +} + +message RegisterUserRequest { + optional string email = 1; + optional string password = 2; + optional string username = 3; + optional string name = 4; + optional string mobile = 5; + optional string verificationCode = 6; + optional uint32 verificationType = 7; + optional string verificationId = 8; + optional string nickName = 9; + optional string registrationSource = 10; +} + +message RegisterUserResponse { + UserInfo user = 1; + AuthToken auth_token = 2; + bool email_verification_required = 3; + bool phone_verification_required = 4; +} + +message UserInfo { + optional uint64 id = 1; + optional string username = 2; + optional string email = 3; + optional string mobile = 4; + optional string password_hash = 5; + optional string salt = 6; + optional string nickname = 7; + optional string avatar = 8; + optional string gender = 9; + optional string account_status = 10; + optional uint32 is_verified = 11; + optional int64 last_login_at = 12; + optional string last_login_ip = 13; + optional int64 login_attempts = 14; + optional int64 locked_until = 15; + optional string recovery_token = 16; + optional int64 recovery_token_expiry = 17; + optional google.protobuf.Struct metadata = 20; + optional string registration_source = 21; +} + +message VerifyCodeReq { + VerifyCodeType type = 1; + AccountType account_type = 2; + string value = 3; +} + +message VerifyCodeResp { + optional string code = 1; + optional uint32 expire = 2; +} + +// App 服务定义 +service App { + // 获取验证码 + // group: code + rpc GetVerifyCode(VerifyCodeReq) returns (VerifyCodeResp); + // 用户注册 + // group: user + rpc registerUser(RegisterUserRequest) returns (RegisterUserResponse); + // 用户登录 + // group: user + rpc loginUser(LoginRequest) returns (LoginResponse); +} + diff --git a/rpc/appclient/app.go b/rpc/appclient/app.go new file mode 100644 index 0000000..4233c11 --- /dev/null +++ b/rpc/appclient/app.go @@ -0,0 +1,61 @@ +// Code generated by goctl. DO NOT EDIT. +// Source: app.proto + +package appclient + +import ( + "context" + + "mingyang-admin-app-rpc/types/app" + + "github.com/zeromicro/go-zero/zrpc" + "google.golang.org/grpc" +) + +type ( + AuthToken = app.AuthToken + LoginRequest = app.LoginRequest + LoginResponse = app.LoginResponse + RegisterUserRequest = app.RegisterUserRequest + RegisterUserResponse = app.RegisterUserResponse + UserInfo = app.UserInfo + VerifyCodeReq = app.VerifyCodeReq + VerifyCodeResp = app.VerifyCodeResp + + App interface { + // 获取验证码 + GetVerifyCode(ctx context.Context, in *VerifyCodeReq, opts ...grpc.CallOption) (*VerifyCodeResp, error) + // 用户注册 + RegisterUser(ctx context.Context, in *RegisterUserRequest, opts ...grpc.CallOption) (*RegisterUserResponse, error) + // 用户登录 + LoginUser(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) + } + + defaultApp struct { + cli zrpc.Client + } +) + +func NewApp(cli zrpc.Client) App { + return &defaultApp{ + cli: cli, + } +} + +// 获取验证码 +func (m *defaultApp) GetVerifyCode(ctx context.Context, in *VerifyCodeReq, opts ...grpc.CallOption) (*VerifyCodeResp, error) { + client := app.NewAppClient(m.cli.Conn()) + return client.GetVerifyCode(ctx, in, opts...) +} + +// 用户注册 +func (m *defaultApp) RegisterUser(ctx context.Context, in *RegisterUserRequest, opts ...grpc.CallOption) (*RegisterUserResponse, error) { + client := app.NewAppClient(m.cli.Conn()) + return client.RegisterUser(ctx, in, opts...) +} + +// 用户登录 +func (m *defaultApp) LoginUser(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) { + client := app.NewAppClient(m.cli.Conn()) + return client.LoginUser(ctx, in, opts...) +} diff --git a/rpc/desc/app/code.proto b/rpc/desc/app/code.proto new file mode 100644 index 0000000..35f1e77 --- /dev/null +++ b/rpc/desc/app/code.proto @@ -0,0 +1,47 @@ +syntax = "proto3"; + + +package app; +option go_package = "./app"; + + +// 验证码类型枚举 +enum VerifyCodeType { + REGISTER = 0; // 注册 + LOGIN = 1; // 登录 + RESET_PASSWORD = 2; // 重置密码 + BIND_PHONE = 3; // 绑定手机 + BIND_EMAIL = 4; // 绑定邮箱 + UPDATE_PHONE = 5; // 更新手机 + UPDATE_EMAIL = 6; // 更新邮箱 + WITHDRAW = 7; // 提现 + CHANGE_PAY_PASSWORD = 8; // 修改支付密码 +} + +// 账户类型枚举(手机/邮箱) +enum AccountType { + UNKNOWN = 0; // 未知类型 + MOBILE = 1; // 手机号 + EMAIL = 2; // 邮箱 +} + + +message VerifyCodeReq{ + VerifyCodeType type = 1; // 验证码类型 + AccountType account_type = 2; // 账户类型:手机或邮箱 + string value = 3; // 手机号或邮箱地址 +} + +message VerifyCodeResp{ + optional string code = 1; // 验证码 + optional uint32 expire = 2; // 过期时间(秒) +} + + +// App 服务定义 +service App { + // 获取验证码 + // group: code + rpc GetVerifyCode(VerifyCodeReq) returns (VerifyCodeResp); + +} \ No newline at end of file diff --git a/rpc/desc/app/user.proto b/rpc/desc/app/user.proto new file mode 100644 index 0000000..42eeb44 --- /dev/null +++ b/rpc/desc/app/user.proto @@ -0,0 +1,83 @@ +syntax = "proto3"; + + +package app; +option go_package = "./app"; +import "google/protobuf/struct.proto"; +import "google/protobuf/timestamp.proto"; +message UserInfo { + optional uint64 id = 1; + optional string username = 2; + optional string email = 3; + optional string mobile = 4; + optional string password_hash = 5; + optional string salt = 6; + optional string nickname = 7; + optional string avatar = 8; + optional string gender = 9; + optional string account_status = 10; + optional uint32 is_verified = 11; + optional int64 last_login_at = 12; + optional string last_login_ip = 13; + optional int64 login_attempts = 14; + optional int64 locked_until = 15; + optional string recovery_token = 16; + optional int64 recovery_token_expiry = 17; + optional google.protobuf.Struct metadata = 20; + optional string registration_source = 21; +} + + +message RegisterUserRequest { + optional string email = 1; + optional string password = 2; + optional string username = 3; + optional string name = 4; + optional string mobile = 5; + optional string verificationCode = 6; + optional uint32 verificationType = 7; + optional string verificationId = 8; // 邮箱或手机号 + optional string nickName = 9; + optional string registrationSource = 10; +} +message RegisterUserResponse { + UserInfo user = 1; + AuthToken auth_token = 2; + bool email_verification_required = 3; + bool phone_verification_required = 4; +} + +// 认证令牌 +message AuthToken { + string access_token = 1; + string refresh_token = 2; + string token_type = 3; + int32 expires_in = 4; // 过期时间(秒) + google.protobuf.Timestamp issued_at = 5; + google.protobuf.Timestamp expires_at = 6; + repeated string scopes = 7; +} + +message LoginResponse{ + UserInfo user = 1; + AuthToken auth_token = 2; +} +message LoginRequest { + optional string username = 1; + optional string email = 2; + optional string mobile = 3; + optional string password = 4; + optional string clientIp = 5; + optional string platform = 6; + optional string login_type = 7; + optional string login_platform = 8; +} +// App 服务定义 +service App { + // 用户注册 + // group: user + rpc registerUser(RegisterUserRequest) returns (RegisterUserResponse); + // 用户登录 + // group: user + rpc loginUser(LoginRequest) returns (LoginResponse); +} \ No newline at end of file diff --git a/rpc/ent/client.go b/rpc/ent/client.go new file mode 100644 index 0000000..1c5e2de --- /dev/null +++ b/rpc/ent/client.go @@ -0,0 +1,653 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "log" + "reflect" + + "mingyang-admin-app-rpc/ent/migrate" + + "mingyang-admin-app-rpc/ent/user" + "mingyang-admin-app-rpc/ent/userloginlog" + "mingyang-admin-app-rpc/ent/userthirdauth" + + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + + stdsql "database/sql" +) + +// Client is the client that holds all ent builders. +type Client struct { + config + // Schema is the client for creating, migrating and dropping schema. + Schema *migrate.Schema + // User is the client for interacting with the User builders. + User *UserClient + // UserLoginLog is the client for interacting with the UserLoginLog builders. + UserLoginLog *UserLoginLogClient + // UserThirdAuth is the client for interacting with the UserThirdAuth builders. + UserThirdAuth *UserThirdAuthClient +} + +// 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.User = NewUserClient(c.config) + c.UserLoginLog = NewUserLoginLogClient(c.config) + c.UserThirdAuth = NewUserThirdAuthClient(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, + User: NewUserClient(cfg), + UserLoginLog: NewUserLoginLogClient(cfg), + UserThirdAuth: NewUserThirdAuthClient(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, + User: NewUserClient(cfg), + UserLoginLog: NewUserLoginLogClient(cfg), + UserThirdAuth: NewUserThirdAuthClient(cfg), + }, nil +} + +// Debug returns a new debug-client. It's used to get verbose logging on specific operations. +// +// client.Debug(). +// User. +// 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.User.Use(hooks...) + c.UserLoginLog.Use(hooks...) + c.UserThirdAuth.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.User.Intercept(interceptors...) + c.UserLoginLog.Intercept(interceptors...) + c.UserThirdAuth.Intercept(interceptors...) +} + +// Mutate implements the ent.Mutator interface. +func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { + switch m := m.(type) { + case *UserMutation: + return c.User.mutate(ctx, m) + case *UserLoginLogMutation: + return c.UserLoginLog.mutate(ctx, m) + case *UserThirdAuthMutation: + return c.UserThirdAuth.mutate(ctx, m) + default: + return nil, fmt.Errorf("ent: unknown mutation type %T", m) + } +} + +// UserClient is a client for the User schema. +type UserClient struct { + config +} + +// NewUserClient returns a client for the User from the given config. +func NewUserClient(c config) *UserClient { + return &UserClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `user.Hooks(f(g(h())))`. +func (c *UserClient) Use(hooks ...Hook) { + c.hooks.User = append(c.hooks.User, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `user.Intercept(f(g(h())))`. +func (c *UserClient) Intercept(interceptors ...Interceptor) { + c.inters.User = append(c.inters.User, interceptors...) +} + +// Create returns a builder for creating a User entity. +func (c *UserClient) Create() *UserCreate { + mutation := newUserMutation(c.config, OpCreate) + return &UserCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of User entities. +func (c *UserClient) CreateBulk(builders ...*UserCreate) *UserCreateBulk { + return &UserCreateBulk{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 *UserClient) MapCreateBulk(slice any, setFunc func(*UserCreate, int)) *UserCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &UserCreateBulk{err: fmt.Errorf("calling to UserClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*UserCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &UserCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for User. +func (c *UserClient) Update() *UserUpdate { + mutation := newUserMutation(c.config, OpUpdate) + return &UserUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *UserClient) UpdateOne(_m *User) *UserUpdateOne { + mutation := newUserMutation(c.config, OpUpdateOne, withUser(_m)) + return &UserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *UserClient) UpdateOneID(id uint64) *UserUpdateOne { + mutation := newUserMutation(c.config, OpUpdateOne, withUserID(id)) + return &UserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for User. +func (c *UserClient) Delete() *UserDelete { + mutation := newUserMutation(c.config, OpDelete) + return &UserDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *UserClient) DeleteOne(_m *User) *UserDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *UserClient) DeleteOneID(id uint64) *UserDeleteOne { + builder := c.Delete().Where(user.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &UserDeleteOne{builder} +} + +// Query returns a query builder for User. +func (c *UserClient) Query() *UserQuery { + return &UserQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeUser}, + inters: c.Interceptors(), + } +} + +// Get returns a User entity by its id. +func (c *UserClient) Get(ctx context.Context, id uint64) (*User, error) { + return c.Query().Where(user.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *UserClient) GetX(ctx context.Context, id uint64) *User { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *UserClient) Hooks() []Hook { + return c.hooks.User +} + +// Interceptors returns the client interceptors. +func (c *UserClient) Interceptors() []Interceptor { + return c.inters.User +} + +func (c *UserClient) mutate(ctx context.Context, m *UserMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&UserCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&UserUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&UserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&UserDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown User mutation op: %q", m.Op()) + } +} + +// UserLoginLogClient is a client for the UserLoginLog schema. +type UserLoginLogClient struct { + config +} + +// NewUserLoginLogClient returns a client for the UserLoginLog from the given config. +func NewUserLoginLogClient(c config) *UserLoginLogClient { + return &UserLoginLogClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `userloginlog.Hooks(f(g(h())))`. +func (c *UserLoginLogClient) Use(hooks ...Hook) { + c.hooks.UserLoginLog = append(c.hooks.UserLoginLog, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `userloginlog.Intercept(f(g(h())))`. +func (c *UserLoginLogClient) Intercept(interceptors ...Interceptor) { + c.inters.UserLoginLog = append(c.inters.UserLoginLog, interceptors...) +} + +// Create returns a builder for creating a UserLoginLog entity. +func (c *UserLoginLogClient) Create() *UserLoginLogCreate { + mutation := newUserLoginLogMutation(c.config, OpCreate) + return &UserLoginLogCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of UserLoginLog entities. +func (c *UserLoginLogClient) CreateBulk(builders ...*UserLoginLogCreate) *UserLoginLogCreateBulk { + return &UserLoginLogCreateBulk{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 *UserLoginLogClient) MapCreateBulk(slice any, setFunc func(*UserLoginLogCreate, int)) *UserLoginLogCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &UserLoginLogCreateBulk{err: fmt.Errorf("calling to UserLoginLogClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*UserLoginLogCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &UserLoginLogCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for UserLoginLog. +func (c *UserLoginLogClient) Update() *UserLoginLogUpdate { + mutation := newUserLoginLogMutation(c.config, OpUpdate) + return &UserLoginLogUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *UserLoginLogClient) UpdateOne(_m *UserLoginLog) *UserLoginLogUpdateOne { + mutation := newUserLoginLogMutation(c.config, OpUpdateOne, withUserLoginLog(_m)) + return &UserLoginLogUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *UserLoginLogClient) UpdateOneID(id uint64) *UserLoginLogUpdateOne { + mutation := newUserLoginLogMutation(c.config, OpUpdateOne, withUserLoginLogID(id)) + return &UserLoginLogUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for UserLoginLog. +func (c *UserLoginLogClient) Delete() *UserLoginLogDelete { + mutation := newUserLoginLogMutation(c.config, OpDelete) + return &UserLoginLogDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *UserLoginLogClient) DeleteOne(_m *UserLoginLog) *UserLoginLogDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *UserLoginLogClient) DeleteOneID(id uint64) *UserLoginLogDeleteOne { + builder := c.Delete().Where(userloginlog.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &UserLoginLogDeleteOne{builder} +} + +// Query returns a query builder for UserLoginLog. +func (c *UserLoginLogClient) Query() *UserLoginLogQuery { + return &UserLoginLogQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeUserLoginLog}, + inters: c.Interceptors(), + } +} + +// Get returns a UserLoginLog entity by its id. +func (c *UserLoginLogClient) Get(ctx context.Context, id uint64) (*UserLoginLog, error) { + return c.Query().Where(userloginlog.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *UserLoginLogClient) GetX(ctx context.Context, id uint64) *UserLoginLog { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *UserLoginLogClient) Hooks() []Hook { + return c.hooks.UserLoginLog +} + +// Interceptors returns the client interceptors. +func (c *UserLoginLogClient) Interceptors() []Interceptor { + return c.inters.UserLoginLog +} + +func (c *UserLoginLogClient) mutate(ctx context.Context, m *UserLoginLogMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&UserLoginLogCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&UserLoginLogUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&UserLoginLogUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&UserLoginLogDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown UserLoginLog mutation op: %q", m.Op()) + } +} + +// UserThirdAuthClient is a client for the UserThirdAuth schema. +type UserThirdAuthClient struct { + config +} + +// NewUserThirdAuthClient returns a client for the UserThirdAuth from the given config. +func NewUserThirdAuthClient(c config) *UserThirdAuthClient { + return &UserThirdAuthClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `userthirdauth.Hooks(f(g(h())))`. +func (c *UserThirdAuthClient) Use(hooks ...Hook) { + c.hooks.UserThirdAuth = append(c.hooks.UserThirdAuth, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `userthirdauth.Intercept(f(g(h())))`. +func (c *UserThirdAuthClient) Intercept(interceptors ...Interceptor) { + c.inters.UserThirdAuth = append(c.inters.UserThirdAuth, interceptors...) +} + +// Create returns a builder for creating a UserThirdAuth entity. +func (c *UserThirdAuthClient) Create() *UserThirdAuthCreate { + mutation := newUserThirdAuthMutation(c.config, OpCreate) + return &UserThirdAuthCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of UserThirdAuth entities. +func (c *UserThirdAuthClient) CreateBulk(builders ...*UserThirdAuthCreate) *UserThirdAuthCreateBulk { + return &UserThirdAuthCreateBulk{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 *UserThirdAuthClient) MapCreateBulk(slice any, setFunc func(*UserThirdAuthCreate, int)) *UserThirdAuthCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &UserThirdAuthCreateBulk{err: fmt.Errorf("calling to UserThirdAuthClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*UserThirdAuthCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &UserThirdAuthCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for UserThirdAuth. +func (c *UserThirdAuthClient) Update() *UserThirdAuthUpdate { + mutation := newUserThirdAuthMutation(c.config, OpUpdate) + return &UserThirdAuthUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *UserThirdAuthClient) UpdateOne(_m *UserThirdAuth) *UserThirdAuthUpdateOne { + mutation := newUserThirdAuthMutation(c.config, OpUpdateOne, withUserThirdAuth(_m)) + return &UserThirdAuthUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *UserThirdAuthClient) UpdateOneID(id uint64) *UserThirdAuthUpdateOne { + mutation := newUserThirdAuthMutation(c.config, OpUpdateOne, withUserThirdAuthID(id)) + return &UserThirdAuthUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for UserThirdAuth. +func (c *UserThirdAuthClient) Delete() *UserThirdAuthDelete { + mutation := newUserThirdAuthMutation(c.config, OpDelete) + return &UserThirdAuthDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *UserThirdAuthClient) DeleteOne(_m *UserThirdAuth) *UserThirdAuthDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *UserThirdAuthClient) DeleteOneID(id uint64) *UserThirdAuthDeleteOne { + builder := c.Delete().Where(userthirdauth.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &UserThirdAuthDeleteOne{builder} +} + +// Query returns a query builder for UserThirdAuth. +func (c *UserThirdAuthClient) Query() *UserThirdAuthQuery { + return &UserThirdAuthQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeUserThirdAuth}, + inters: c.Interceptors(), + } +} + +// Get returns a UserThirdAuth entity by its id. +func (c *UserThirdAuthClient) Get(ctx context.Context, id uint64) (*UserThirdAuth, error) { + return c.Query().Where(userthirdauth.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *UserThirdAuthClient) GetX(ctx context.Context, id uint64) *UserThirdAuth { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *UserThirdAuthClient) Hooks() []Hook { + return c.hooks.UserThirdAuth +} + +// Interceptors returns the client interceptors. +func (c *UserThirdAuthClient) Interceptors() []Interceptor { + return c.inters.UserThirdAuth +} + +func (c *UserThirdAuthClient) mutate(ctx context.Context, m *UserThirdAuthMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&UserThirdAuthCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&UserThirdAuthUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&UserThirdAuthUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&UserThirdAuthDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown UserThirdAuth mutation op: %q", m.Op()) + } +} + +// hooks and interceptors per client, for fast access. +type ( + hooks struct { + User, UserLoginLog, UserThirdAuth []ent.Hook + } + inters struct { + User, UserLoginLog, UserThirdAuth []ent.Interceptor + } +) + +// ExecContext allows calling the underlying ExecContext method of the driver if it is supported by it. +// See, database/sql#DB.ExecContext for more information. +func (c *config) ExecContext(ctx context.Context, query string, args ...any) (stdsql.Result, error) { + ex, ok := c.driver.(interface { + ExecContext(context.Context, string, ...any) (stdsql.Result, error) + }) + if !ok { + return nil, fmt.Errorf("Driver.ExecContext is not supported") + } + return ex.ExecContext(ctx, query, args...) +} + +// QueryContext allows calling the underlying QueryContext method of the driver if it is supported by it. +// See, database/sql#DB.QueryContext for more information. +func (c *config) QueryContext(ctx context.Context, query string, args ...any) (*stdsql.Rows, error) { + q, ok := c.driver.(interface { + QueryContext(context.Context, string, ...any) (*stdsql.Rows, error) + }) + if !ok { + return nil, fmt.Errorf("Driver.QueryContext is not supported") + } + return q.QueryContext(ctx, query, args...) +} diff --git a/rpc/ent/ent.go b/rpc/ent/ent.go new file mode 100644 index 0000000..4606520 --- /dev/null +++ b/rpc/ent/ent.go @@ -0,0 +1,612 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "mingyang-admin-app-rpc/ent/user" + "mingyang-admin-app-rpc/ent/userloginlog" + "mingyang-admin-app-rpc/ent/userthirdauth" + "reflect" + "sync" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ent aliases to avoid import conflicts in user's code.proto. +type ( + Op = ent.Op + Hook = ent.Hook + Value = ent.Value + Query = ent.Query + QueryContext = ent.QueryContext + Querier = ent.Querier + QuerierFunc = ent.QuerierFunc + Interceptor = ent.Interceptor + InterceptFunc = ent.InterceptFunc + Traverser = ent.Traverser + TraverseFunc = ent.TraverseFunc + Policy = ent.Policy + Mutator = ent.Mutator + Mutation = ent.Mutation + MutateFunc = ent.MutateFunc +) + +type clientCtxKey struct{} + +// FromContext returns a Client stored inside a context, or nil if there isn't one. +func FromContext(ctx context.Context) *Client { + c, _ := ctx.Value(clientCtxKey{}).(*Client) + return c +} + +// NewContext returns a new context with the given Client attached. +func NewContext(parent context.Context, c *Client) context.Context { + return context.WithValue(parent, clientCtxKey{}, c) +} + +type txCtxKey struct{} + +// TxFromContext returns a Tx stored inside a context, or nil if there isn't one. +func TxFromContext(ctx context.Context) *Tx { + tx, _ := ctx.Value(txCtxKey{}).(*Tx) + return tx +} + +// NewTxContext returns a new context with the given Tx attached. +func NewTxContext(parent context.Context, tx *Tx) context.Context { + return context.WithValue(parent, txCtxKey{}, tx) +} + +// OrderFunc applies an ordering on the sql selector. +// Deprecated: Use Asc/Desc functions or the package builders instead. +type OrderFunc func(*sql.Selector) + +var ( + initCheck sync.Once + columnCheck sql.ColumnCheck +) + +// checkColumn checks if the column exists in the given table. +func checkColumn(t, c string) error { + initCheck.Do(func() { + columnCheck = sql.NewColumnCheck(map[string]func(string) bool{ + user.Table: user.ValidColumn, + userloginlog.Table: userloginlog.ValidColumn, + userthirdauth.Table: userthirdauth.ValidColumn, + }) + }) + return columnCheck(t, c) +} + +// Asc applies the given fields in ASC order. +func Asc(fields ...string) func(*sql.Selector) { + return func(s *sql.Selector) { + for _, f := range fields { + if err := checkColumn(s.TableName(), f); err != nil { + s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)}) + } + s.OrderBy(sql.Asc(s.C(f))) + } + } +} + +// Desc applies the given fields in DESC order. +func Desc(fields ...string) func(*sql.Selector) { + return func(s *sql.Selector) { + for _, f := range fields { + if err := checkColumn(s.TableName(), f); err != nil { + s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)}) + } + s.OrderBy(sql.Desc(s.C(f))) + } + } +} + +// AggregateFunc applies an aggregation step on the group-by traversal/selector. +type AggregateFunc func(*sql.Selector) string + +// As is a pseudo aggregation function for renaming another other functions with custom names. For example: +// +// GroupBy(field1, field2). +// Aggregate(ent.As(ent.Sum(field1), "sum_field1"), (ent.As(ent.Sum(field2), "sum_field2")). +// Scan(ctx, &v) +func As(fn AggregateFunc, end string) AggregateFunc { + return func(s *sql.Selector) string { + return sql.As(fn(s), end) + } +} + +// Count applies the "count" aggregation function on each group. +func Count() AggregateFunc { + return func(s *sql.Selector) string { + return sql.Count("*") + } +} + +// Max applies the "max" aggregation function on the given field of each group. +func Max(field string) AggregateFunc { + return func(s *sql.Selector) string { + if err := checkColumn(s.TableName(), field); err != nil { + s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) + return "" + } + return sql.Max(s.C(field)) + } +} + +// Mean applies the "mean" aggregation function on the given field of each group. +func Mean(field string) AggregateFunc { + return func(s *sql.Selector) string { + if err := checkColumn(s.TableName(), field); err != nil { + s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) + return "" + } + return sql.Avg(s.C(field)) + } +} + +// Min applies the "min" aggregation function on the given field of each group. +func Min(field string) AggregateFunc { + return func(s *sql.Selector) string { + if err := checkColumn(s.TableName(), field); err != nil { + s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) + return "" + } + return sql.Min(s.C(field)) + } +} + +// Sum applies the "sum" aggregation function on the given field of each group. +func Sum(field string) AggregateFunc { + return func(s *sql.Selector) string { + if err := checkColumn(s.TableName(), field); err != nil { + s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) + return "" + } + return sql.Sum(s.C(field)) + } +} + +// ValidationError returns when validating a field or edge fails. +type ValidationError struct { + Name string // Field or edge name. + err error +} + +// Error implements the error interface. +func (e *ValidationError) Error() string { + return e.err.Error() +} + +// Unwrap implements the errors.Wrapper interface. +func (e *ValidationError) Unwrap() error { + return e.err +} + +// IsValidationError returns a boolean indicating whether the error is a validation error. +func IsValidationError(err error) bool { + if err == nil { + return false + } + var e *ValidationError + return errors.As(err, &e) +} + +// NotFoundError returns when trying to fetch a specific entity and it was not found in the database. +type NotFoundError struct { + label string +} + +// Error implements the error interface. +func (e *NotFoundError) Error() string { + return "ent: " + e.label + " not found" +} + +// IsNotFound returns a boolean indicating whether the error is a not found error. +func IsNotFound(err error) bool { + if err == nil { + return false + } + var e *NotFoundError + return errors.As(err, &e) +} + +// MaskNotFound masks not found error. +func MaskNotFound(err error) error { + if IsNotFound(err) { + return nil + } + return err +} + +// NotSingularError returns when trying to fetch a singular entity and more then one was found in the database. +type NotSingularError struct { + label string +} + +// Error implements the error interface. +func (e *NotSingularError) Error() string { + return "ent: " + e.label + " not singular" +} + +// IsNotSingular returns a boolean indicating whether the error is a not singular error. +func IsNotSingular(err error) bool { + if err == nil { + return false + } + var e *NotSingularError + return errors.As(err, &e) +} + +// NotLoadedError returns when trying to get a node that was not loaded by the query. +type NotLoadedError struct { + edge string +} + +// Error implements the error interface. +func (e *NotLoadedError) Error() string { + return "ent: " + e.edge + " edge was not loaded" +} + +// IsNotLoaded returns a boolean indicating whether the error is a not loaded error. +func IsNotLoaded(err error) bool { + if err == nil { + return false + } + var e *NotLoadedError + return errors.As(err, &e) +} + +// ConstraintError returns when trying to create/update one or more entities and +// one or more of their constraints failed. For example, violation of edge or +// field uniqueness. +type ConstraintError struct { + msg string + wrap error +} + +// Error implements the error interface. +func (e ConstraintError) Error() string { + return "ent: constraint failed: " + e.msg +} + +// Unwrap implements the errors.Wrapper interface. +func (e *ConstraintError) Unwrap() error { + return e.wrap +} + +// IsConstraintError returns a boolean indicating whether the error is a constraint failure. +func IsConstraintError(err error) bool { + if err == nil { + return false + } + var e *ConstraintError + return errors.As(err, &e) +} + +// selector embedded by the different Select/GroupBy builders. +type selector struct { + label string + flds *[]string + fns []AggregateFunc + scan func(context.Context, any) error +} + +// ScanX is like Scan, but panics if an error occurs. +func (s *selector) ScanX(ctx context.Context, v any) { + if err := s.scan(ctx, v); err != nil { + panic(err) + } +} + +// Strings returns list of strings from a selector. It is only allowed when selecting one field. +func (s *selector) Strings(ctx context.Context) ([]string, error) { + if len(*s.flds) > 1 { + return nil, errors.New("ent: Strings is not achievable when selecting more than 1 field") + } + var v []string + if err := s.scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// StringsX is like Strings, but panics if an error occurs. +func (s *selector) StringsX(ctx context.Context) []string { + v, err := s.Strings(ctx) + if err != nil { + panic(err) + } + return v +} + +// String returns a single string from a selector. It is only allowed when selecting one field. +func (s *selector) String(ctx context.Context) (_ string, err error) { + var v []string + if v, err = s.Strings(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{s.label} + default: + err = fmt.Errorf("ent: Strings returned %d results when one was expected", len(v)) + } + return +} + +// StringX is like String, but panics if an error occurs. +func (s *selector) StringX(ctx context.Context) string { + v, err := s.String(ctx) + if err != nil { + panic(err) + } + return v +} + +// Ints returns list of ints from a selector. It is only allowed when selecting one field. +func (s *selector) Ints(ctx context.Context) ([]int, error) { + if len(*s.flds) > 1 { + return nil, errors.New("ent: Ints is not achievable when selecting more than 1 field") + } + var v []int + if err := s.scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// IntsX is like Ints, but panics if an error occurs. +func (s *selector) IntsX(ctx context.Context) []int { + v, err := s.Ints(ctx) + if err != nil { + panic(err) + } + return v +} + +// Int returns a single int from a selector. It is only allowed when selecting one field. +func (s *selector) Int(ctx context.Context) (_ int, err error) { + var v []int + if v, err = s.Ints(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{s.label} + default: + err = fmt.Errorf("ent: Ints returned %d results when one was expected", len(v)) + } + return +} + +// IntX is like Int, but panics if an error occurs. +func (s *selector) IntX(ctx context.Context) int { + v, err := s.Int(ctx) + if err != nil { + panic(err) + } + return v +} + +// Float64s returns list of float64s from a selector. It is only allowed when selecting one field. +func (s *selector) Float64s(ctx context.Context) ([]float64, error) { + if len(*s.flds) > 1 { + return nil, errors.New("ent: Float64s is not achievable when selecting more than 1 field") + } + var v []float64 + if err := s.scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// Float64sX is like Float64s, but panics if an error occurs. +func (s *selector) Float64sX(ctx context.Context) []float64 { + v, err := s.Float64s(ctx) + if err != nil { + panic(err) + } + return v +} + +// Float64 returns a single float64 from a selector. It is only allowed when selecting one field. +func (s *selector) Float64(ctx context.Context) (_ float64, err error) { + var v []float64 + if v, err = s.Float64s(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{s.label} + default: + err = fmt.Errorf("ent: Float64s returned %d results when one was expected", len(v)) + } + return +} + +// Float64X is like Float64, but panics if an error occurs. +func (s *selector) Float64X(ctx context.Context) float64 { + v, err := s.Float64(ctx) + if err != nil { + panic(err) + } + return v +} + +// Bools returns list of bools from a selector. It is only allowed when selecting one field. +func (s *selector) Bools(ctx context.Context) ([]bool, error) { + if len(*s.flds) > 1 { + return nil, errors.New("ent: Bools is not achievable when selecting more than 1 field") + } + var v []bool + if err := s.scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// BoolsX is like Bools, but panics if an error occurs. +func (s *selector) BoolsX(ctx context.Context) []bool { + v, err := s.Bools(ctx) + if err != nil { + panic(err) + } + return v +} + +// Bool returns a single bool from a selector. It is only allowed when selecting one field. +func (s *selector) Bool(ctx context.Context) (_ bool, err error) { + var v []bool + if v, err = s.Bools(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{s.label} + default: + err = fmt.Errorf("ent: Bools returned %d results when one was expected", len(v)) + } + return +} + +// BoolX is like Bool, but panics if an error occurs. +func (s *selector) BoolX(ctx context.Context) bool { + v, err := s.Bool(ctx) + if err != nil { + panic(err) + } + return v +} + +// withHooks invokes the builder operation with the given hooks, if any. +func withHooks[V Value, M any, PM interface { + *M + Mutation +}](ctx context.Context, exec func(context.Context) (V, error), mutation PM, hooks []Hook) (value V, err error) { + if len(hooks) == 0 { + return exec(ctx) + } + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutationT, ok := any(m).(PM) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + // Set the mutation to the builder. + *mutation = *mutationT + return exec(ctx) + }) + for i := len(hooks) - 1; i >= 0; i-- { + if hooks[i] == nil { + return value, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") + } + mut = hooks[i](mut) + } + v, err := mut.Mutate(ctx, mutation) + if err != nil { + return value, err + } + nv, ok := v.(V) + if !ok { + return value, fmt.Errorf("unexpected node type %T returned from %T", v, mutation) + } + return nv, nil +} + +// setContextOp returns a new context with the given QueryContext attached (including its op) in case it does not exist. +func setContextOp(ctx context.Context, qc *QueryContext, op string) context.Context { + if ent.QueryFromContext(ctx) == nil { + qc.Op = op + ctx = ent.NewQueryContext(ctx, qc) + } + return ctx +} + +func querierAll[V Value, Q interface { + sqlAll(context.Context, ...queryHook) (V, error) +}]() Querier { + return QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + query, ok := q.(Q) + if !ok { + return nil, fmt.Errorf("unexpected query type %T", q) + } + return query.sqlAll(ctx) + }) +} + +func querierCount[Q interface { + sqlCount(context.Context) (int, error) +}]() Querier { + return QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + query, ok := q.(Q) + if !ok { + return nil, fmt.Errorf("unexpected query type %T", q) + } + return query.sqlCount(ctx) + }) +} + +func withInterceptors[V Value](ctx context.Context, q Query, qr Querier, inters []Interceptor) (v V, err error) { + for i := len(inters) - 1; i >= 0; i-- { + qr = inters[i].Intercept(qr) + } + rv, err := qr.Query(ctx, q) + if err != nil { + return v, err + } + vt, ok := rv.(V) + if !ok { + return v, fmt.Errorf("unexpected type %T returned from %T. expected type: %T", vt, q, v) + } + return vt, nil +} + +func scanWithInterceptors[Q1 ent.Query, Q2 interface { + sqlScan(context.Context, Q1, any) error +}](ctx context.Context, rootQuery Q1, selectOrGroup Q2, inters []Interceptor, v any) error { + rv := reflect.ValueOf(v) + var qr Querier = QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + query, ok := q.(Q1) + if !ok { + return nil, fmt.Errorf("unexpected query type %T", q) + } + if err := selectOrGroup.sqlScan(ctx, query, v); err != nil { + return nil, err + } + if k := rv.Kind(); k == reflect.Pointer && rv.Elem().CanInterface() { + return rv.Elem().Interface(), nil + } + return v, nil + }) + for i := len(inters) - 1; i >= 0; i-- { + qr = inters[i].Intercept(qr) + } + vv, err := qr.Query(ctx, rootQuery) + if err != nil { + return err + } + switch rv2 := reflect.ValueOf(vv); { + case rv.IsNil(), rv2.IsNil(), rv.Kind() != reflect.Pointer: + case rv.Type() == rv2.Type(): + rv.Elem().Set(rv2.Elem()) + case rv.Elem().Type() == rv2.Type(): + rv.Elem().Set(rv2) + } + return nil +} + +// queryHook describes an internal hook for the different sqlAll methods. +type queryHook func(context.Context, *sqlgraph.QuerySpec) diff --git a/rpc/ent/enttest/enttest.go b/rpc/ent/enttest/enttest.go new file mode 100644 index 0000000..dce5caf --- /dev/null +++ b/rpc/ent/enttest/enttest.go @@ -0,0 +1,85 @@ +// Code generated by ent, DO NOT EDIT. + +package enttest + +import ( + "context" + + "mingyang-admin-app-rpc/ent" + // required by schema hooks. + _ "mingyang-admin-app-rpc/ent/runtime" + + "mingyang-admin-app-rpc/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/rpc/ent/hook/hook.go b/rpc/ent/hook/hook.go new file mode 100644 index 0000000..82db553 --- /dev/null +++ b/rpc/ent/hook/hook.go @@ -0,0 +1,222 @@ +// Code generated by ent, DO NOT EDIT. + +package hook + +import ( + "context" + "fmt" + "mingyang-admin-app-rpc/ent" +) + +// The UserFunc type is an adapter to allow the use of ordinary +// function as User mutator. +type UserFunc func(context.Context, *ent.UserMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f UserFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.UserMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.UserMutation", m) +} + +// The UserLoginLogFunc type is an adapter to allow the use of ordinary +// function as UserLoginLog mutator. +type UserLoginLogFunc func(context.Context, *ent.UserLoginLogMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f UserLoginLogFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.UserLoginLogMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.UserLoginLogMutation", m) +} + +// The UserThirdAuthFunc type is an adapter to allow the use of ordinary +// function as UserThirdAuth mutator. +type UserThirdAuthFunc func(context.Context, *ent.UserThirdAuthMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f UserThirdAuthFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.UserThirdAuthMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.UserThirdAuthMutation", 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/rpc/ent/intercept/intercept.go b/rpc/ent/intercept/intercept.go new file mode 100644 index 0000000..d356832 --- /dev/null +++ b/rpc/ent/intercept/intercept.go @@ -0,0 +1,210 @@ +// Code generated by ent, DO NOT EDIT. + +package intercept + +import ( + "context" + "fmt" + + "mingyang-admin-app-rpc/ent" + "mingyang-admin-app-rpc/ent/predicate" + "mingyang-admin-app-rpc/ent/user" + "mingyang-admin-app-rpc/ent/userloginlog" + "mingyang-admin-app-rpc/ent/userthirdauth" + + "entgo.io/ent/dialect/sql" +) + +// The Query interface represents an operation that queries a graph. +// By using this interface, users can write generic code.proto that manipulates +// query builders of different types. +type Query interface { + // Type returns the string representation of the query type. + Type() string + // Limit the number of records to be returned by this query. + Limit(int) + // Offset to start from. + Offset(int) + // Unique configures the query builder to filter duplicate records. + Unique(bool) + // Order specifies how the records should be ordered. + Order(...func(*sql.Selector)) + // WhereP appends storage-level predicates to the query builder. Using this method, users + // can use type-assertion to append predicates that do not depend on any generated package. + WhereP(...func(*sql.Selector)) +} + +// The Func type is an adapter that allows ordinary functions to be used as interceptors. +// Unlike traversal functions, interceptors are skipped during graph traversals. Note that the +// implementation of Func is different from the one defined in entgo.io/ent.InterceptFunc. +type Func func(context.Context, Query) error + +// Intercept calls f(ctx, q) and then applied the next Querier. +func (f Func) Intercept(next ent.Querier) ent.Querier { + return ent.QuerierFunc(func(ctx context.Context, q ent.Query) (ent.Value, error) { + query, err := NewQuery(q) + if err != nil { + return nil, err + } + if err := f(ctx, query); err != nil { + return nil, err + } + return next.Query(ctx, q) + }) +} + +// The TraverseFunc type is an adapter to allow the use of ordinary function as Traverser. +// If f is a function with the appropriate signature, TraverseFunc(f) is a Traverser that calls f. +type TraverseFunc func(context.Context, Query) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseFunc) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseFunc) Traverse(ctx context.Context, q ent.Query) error { + query, err := NewQuery(q) + if err != nil { + return err + } + return f(ctx, query) +} + +// The UserFunc type is an adapter to allow the use of ordinary function as a Querier. +type UserFunc func(context.Context, *ent.UserQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f UserFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.UserQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.UserQuery", q) +} + +// The TraverseUser type is an adapter to allow the use of ordinary function as Traverser. +type TraverseUser func(context.Context, *ent.UserQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseUser) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseUser) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.UserQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.UserQuery", q) +} + +// The UserLoginLogFunc type is an adapter to allow the use of ordinary function as a Querier. +type UserLoginLogFunc func(context.Context, *ent.UserLoginLogQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f UserLoginLogFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.UserLoginLogQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.UserLoginLogQuery", q) +} + +// The TraverseUserLoginLog type is an adapter to allow the use of ordinary function as Traverser. +type TraverseUserLoginLog func(context.Context, *ent.UserLoginLogQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseUserLoginLog) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseUserLoginLog) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.UserLoginLogQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.UserLoginLogQuery", q) +} + +// The UserThirdAuthFunc type is an adapter to allow the use of ordinary function as a Querier. +type UserThirdAuthFunc func(context.Context, *ent.UserThirdAuthQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f UserThirdAuthFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.UserThirdAuthQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.UserThirdAuthQuery", q) +} + +// The TraverseUserThirdAuth type is an adapter to allow the use of ordinary function as Traverser. +type TraverseUserThirdAuth func(context.Context, *ent.UserThirdAuthQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseUserThirdAuth) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseUserThirdAuth) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.UserThirdAuthQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.UserThirdAuthQuery", q) +} + +// NewQuery returns the generic Query interface for the given typed query. +func NewQuery(q ent.Query) (Query, error) { + switch q := q.(type) { + case *ent.UserQuery: + return &query[*ent.UserQuery, predicate.User, user.OrderOption]{typ: ent.TypeUser, tq: q}, nil + case *ent.UserLoginLogQuery: + return &query[*ent.UserLoginLogQuery, predicate.UserLoginLog, userloginlog.OrderOption]{typ: ent.TypeUserLoginLog, tq: q}, nil + case *ent.UserThirdAuthQuery: + return &query[*ent.UserThirdAuthQuery, predicate.UserThirdAuth, userthirdauth.OrderOption]{typ: ent.TypeUserThirdAuth, tq: q}, nil + default: + return nil, fmt.Errorf("unknown query type %T", q) + } +} + +type query[T any, P ~func(*sql.Selector), R ~func(*sql.Selector)] struct { + typ string + tq interface { + Limit(int) T + Offset(int) T + Unique(bool) T + Order(...R) T + Where(...P) T + } +} + +func (q query[T, P, R]) Type() string { + return q.typ +} + +func (q query[T, P, R]) Limit(limit int) { + q.tq.Limit(limit) +} + +func (q query[T, P, R]) Offset(offset int) { + q.tq.Offset(offset) +} + +func (q query[T, P, R]) Unique(unique bool) { + q.tq.Unique(unique) +} + +func (q query[T, P, R]) Order(orders ...func(*sql.Selector)) { + rs := make([]R, len(orders)) + for i := range orders { + rs[i] = orders[i] + } + q.tq.Order(rs...) +} + +func (q query[T, P, R]) WhereP(ps ...func(*sql.Selector)) { + p := make([]P, len(ps)) + for i := range ps { + p[i] = ps[i] + } + q.tq.Where(p...) +} diff --git a/rpc/ent/migrate/migrate.go b/rpc/ent/migrate/migrate.go new file mode 100644 index 0000000..1956a6b --- /dev/null +++ b/rpc/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/rpc/ent/migrate/schema.go b/rpc/ent/migrate/schema.go new file mode 100644 index 0000000..e1b189c --- /dev/null +++ b/rpc/ent/migrate/schema.go @@ -0,0 +1,166 @@ +// Code generated by ent, DO NOT EDIT. + +package migrate + +import ( + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/dialect/sql/schema" + "entgo.io/ent/schema/field" +) + +var ( + // UserColumns holds the columns for the "user" table. + UserColumns = []*schema.Column{ + {Name: "id", Type: field.TypeUint64, Increment: true}, + {Name: "created_at", Type: field.TypeTime, Comment: "Create Time | 创建日期"}, + {Name: "updated_at", Type: field.TypeTime, Comment: "Update Time | 修改日期"}, + {Name: "status", Type: field.TypeUint8, Nullable: true, Comment: "Status 1: normal 2: ban | 状态 1 正常 2 禁用", Default: 1}, + {Name: "tenant_id", Type: field.TypeUint64, Comment: "Tenant ID | 租户 ID", Default: 1}, + {Name: "deleted_at", Type: field.TypeTime, Nullable: true, Comment: "Delete Time | 删除日期"}, + {Name: "username", Type: field.TypeString, Unique: true, Size: 50, Comment: "用户名"}, + {Name: "email", Type: field.TypeString, Unique: true, Size: 255, Comment: "邮箱"}, + {Name: "mobile", Type: field.TypeString, Nullable: true, Size: 64, Comment: "联系方式"}, + {Name: "password_hash", Type: field.TypeString, Comment: "密码"}, + {Name: "salt", Type: field.TypeString, Size: 32, Comment: "salt盐值"}, + {Name: "nickname", Type: field.TypeString, Size: 50, Comment: "昵称", Default: ""}, + {Name: "avatar", Type: field.TypeString, Nullable: true, Size: 500, Comment: "头像"}, + {Name: "gender", Type: field.TypeEnum, Comment: "性别", Enums: []string{"unknown", "male", "female", "other"}, Default: "unknown"}, + {Name: "birthday", Type: field.TypeTime, Nullable: true}, + {Name: "account_status", Type: field.TypeEnum, Comment: "账户状态", Enums: []string{"unverified", "active", "locked", "disabled"}, Default: "unverified"}, + {Name: "is_verified", Type: field.TypeUint32, Comment: "1 邮箱 ,2 电话号码", Default: 0}, + {Name: "registered_login_ip", Type: field.TypeString, Nullable: true, Size: 255, Comment: "注册IP地址"}, + {Name: "login_attempts", Type: field.TypeInt64, Comment: "登录尝试次数", Default: 0}, + {Name: "metadata", Type: field.TypeJSON, Nullable: true}, + {Name: "registration_source", Type: field.TypeString, Nullable: true, Size: 50, Comment: "注册来源"}, + } + // UserTable holds the schema information for the "user" table. + UserTable = &schema.Table{ + Name: "user", + Comment: "User Table | C端用户表", + Columns: UserColumns, + PrimaryKey: []*schema.Column{UserColumns[0]}, + Indexes: []*schema.Index{ + { + Name: "user_username", + Unique: true, + Columns: []*schema.Column{UserColumns[6]}, + }, + { + Name: "user_email", + Unique: true, + Columns: []*schema.Column{UserColumns[7]}, + }, + { + Name: "user_mobile", + Unique: true, + Columns: []*schema.Column{UserColumns[8]}, + }, + }, + } + // UserLoginLogsColumns holds the columns for the "user_login_logs" table. + UserLoginLogsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeUint64, Increment: true}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "updated_at", Type: field.TypeTime}, + {Name: "status", Type: field.TypeUint8, Nullable: true, Default: 1}, + {Name: "tenant_id", Type: field.TypeUint64, Default: 1}, + {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, + {Name: "user_id", Type: field.TypeUint64}, + {Name: "login_time", Type: field.TypeTime}, + {Name: "login_ip", Type: field.TypeString, Size: 45}, + {Name: "login_location", Type: field.TypeString, Nullable: true, Size: 200}, + {Name: "login_type", Type: field.TypeEnum, Enums: []string{"password", "sms_code", "email_code", "wechat", "alipay", "apple", "google", "other_third_party"}, Default: "password"}, + {Name: "login_platform", Type: field.TypeEnum, Enums: []string{"ios", "android"}, Default: "android"}, + {Name: "login_result", Type: field.TypeBool, Default: true}, + {Name: "failure_reason", Type: field.TypeString, Nullable: true, Size: 500}, + {Name: "session_id", Type: field.TypeString, Nullable: true, Size: 200}, + {Name: "latency_ms", Type: field.TypeInt, Nullable: true}, + {Name: "auth_id", Type: field.TypeUint64, Nullable: true}, + {Name: "additional_data", Type: field.TypeJSON, Nullable: true}, + } + // UserLoginLogsTable holds the schema information for the "user_login_logs" table. + UserLoginLogsTable = &schema.Table{ + Name: "user_login_logs", + Columns: UserLoginLogsColumns, + PrimaryKey: []*schema.Column{UserLoginLogsColumns[0]}, + Indexes: []*schema.Index{ + { + Name: "userloginlog_user_id_login_time", + Unique: false, + Columns: []*schema.Column{UserLoginLogsColumns[6], UserLoginLogsColumns[7]}, + }, + { + Name: "userloginlog_login_time", + Unique: false, + Columns: []*schema.Column{UserLoginLogsColumns[7]}, + }, + { + Name: "userloginlog_login_ip", + Unique: false, + Columns: []*schema.Column{UserLoginLogsColumns[8]}, + }, + { + Name: "userloginlog_login_type", + Unique: false, + Columns: []*schema.Column{UserLoginLogsColumns[10]}, + }, + { + Name: "userloginlog_login_platform", + Unique: false, + Columns: []*schema.Column{UserLoginLogsColumns[11]}, + }, + { + Name: "userloginlog_login_result", + Unique: false, + Columns: []*schema.Column{UserLoginLogsColumns[12]}, + }, + { + Name: "userloginlog_session_id", + Unique: false, + Columns: []*schema.Column{UserLoginLogsColumns[14]}, + }, + }, + } + // UserThirdAuthsColumns holds the columns for the "user_third_auths" table. + UserThirdAuthsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeUint64, Increment: true}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "updated_at", Type: field.TypeTime}, + {Name: "status", Type: field.TypeUint8, Nullable: true, Default: 1}, + {Name: "tenant_id", Type: field.TypeUint64, Default: 1}, + {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, + {Name: "user_id", Type: field.TypeUint64}, + {Name: "openid", Type: field.TypeString, Size: 255}, + {Name: "unionid", Type: field.TypeString, Nullable: true, Size: 255}, + {Name: "access_token", Type: field.TypeString, Nullable: true, Size: 2000}, + {Name: "refresh_token", Type: field.TypeString, Nullable: true, Size: 2000}, + {Name: "access_token_expiry", Type: field.TypeTime, Nullable: true}, + {Name: "user_info", Type: field.TypeJSON, Nullable: true}, + {Name: "platform_user_id", Type: field.TypeString, Nullable: true, Size: 255}, + {Name: "nickname", Type: field.TypeString, Nullable: true, Size: 100}, + {Name: "avatar", Type: field.TypeString, Nullable: true, Size: 500}, + {Name: "email", Type: field.TypeString, Nullable: true, Size: 255}, + {Name: "phone", Type: field.TypeString, Nullable: true, Size: 20}, + {Name: "is_bound", Type: field.TypeBool, Default: true}, + {Name: "bound_at", Type: field.TypeTime}, + {Name: "extra_data", Type: field.TypeJSON, Nullable: true}, + } + // UserThirdAuthsTable holds the schema information for the "user_third_auths" table. + UserThirdAuthsTable = &schema.Table{ + Name: "user_third_auths", + Columns: UserThirdAuthsColumns, + PrimaryKey: []*schema.Column{UserThirdAuthsColumns[0]}, + } + // Tables holds all the tables in the schema. + Tables = []*schema.Table{ + UserTable, + UserLoginLogsTable, + UserThirdAuthsTable, + } +) + +func init() { + UserTable.Annotation = &entsql.Annotation{ + Table: "user", + } +} diff --git a/rpc/ent/mutation.go b/rpc/ent/mutation.go new file mode 100644 index 0000000..b4173a7 --- /dev/null +++ b/rpc/ent/mutation.go @@ -0,0 +1,4914 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "mingyang-admin-app-rpc/ent/predicate" + "mingyang-admin-app-rpc/ent/user" + "mingyang-admin-app-rpc/ent/userloginlog" + "mingyang-admin-app-rpc/ent/userthirdauth" + "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. + TypeUser = "User" + TypeUserLoginLog = "UserLoginLog" + TypeUserThirdAuth = "UserThirdAuth" +) + +// UserMutation represents an operation that mutates the User nodes in the graph. +type UserMutation struct { + config + op Op + typ string + id *uint64 + created_at *time.Time + updated_at *time.Time + status *uint8 + addstatus *int8 + tenant_id *uint64 + addtenant_id *int64 + deleted_at *time.Time + username *string + email *string + mobile *string + password_hash *string + salt *string + nickname *string + avatar *string + gender *user.Gender + birthday *time.Time + account_status *user.AccountStatus + is_verified *uint32 + addis_verified *int32 + registered_login_ip *string + login_attempts *int64 + addlogin_attempts *int64 + metadata *map[string]interface{} + registration_source *string + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*User, error) + predicates []predicate.User +} + +var _ ent.Mutation = (*UserMutation)(nil) + +// userOption allows management of the mutation configuration using functional options. +type userOption func(*UserMutation) + +// newUserMutation creates new mutation for the User entity. +func newUserMutation(c config, op Op, opts ...userOption) *UserMutation { + m := &UserMutation{ + config: c, + op: op, + typ: TypeUser, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withUserID sets the ID field of the mutation. +func withUserID(id uint64) userOption { + return func(m *UserMutation) { + var ( + err error + once sync.Once + value *User + ) + m.oldValue = func(ctx context.Context) (*User, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().User.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withUser sets the old User of the mutation. +func withUser(node *User) userOption { + return func(m *UserMutation) { + m.oldValue = func(context.Context) (*User, 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 UserMutation) 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 UserMutation) 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 User entities. +func (m *UserMutation) SetID(id uint64) { + 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 *UserMutation) ID() (id uint64, 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 *UserMutation) IDs(ctx context.Context) ([]uint64, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []uint64{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().User.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetCreatedAt sets the "created_at" field. +func (m *UserMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *UserMutation) 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 User entity. +// If the User 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 *UserMutation) 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 *UserMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *UserMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *UserMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at + if v == nil { + return + } + return *v, true +} + +// OldUpdatedAt returns the old "updated_at" field's value of the User entity. +// If the User 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 *UserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + } + return oldValue.UpdatedAt, nil +} + +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *UserMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// SetStatus sets the "status" field. +func (m *UserMutation) SetStatus(u uint8) { + m.status = &u + m.addstatus = nil +} + +// Status returns the value of the "status" field in the mutation. +func (m *UserMutation) Status() (r uint8, exists bool) { + v := m.status + if v == nil { + return + } + return *v, true +} + +// OldStatus returns the old "status" field's value of the User entity. +// If the User 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 *UserMutation) OldStatus(ctx context.Context) (v uint8, 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 u to the "status" field. +func (m *UserMutation) AddStatus(u int8) { + if m.addstatus != nil { + *m.addstatus += u + } else { + m.addstatus = &u + } +} + +// AddedStatus returns the value that was added to the "status" field in this mutation. +func (m *UserMutation) 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 *UserMutation) ClearStatus() { + m.status = nil + m.addstatus = nil + m.clearedFields[user.FieldStatus] = struct{}{} +} + +// StatusCleared returns if the "status" field was cleared in this mutation. +func (m *UserMutation) StatusCleared() bool { + _, ok := m.clearedFields[user.FieldStatus] + return ok +} + +// ResetStatus resets all changes to the "status" field. +func (m *UserMutation) ResetStatus() { + m.status = nil + m.addstatus = nil + delete(m.clearedFields, user.FieldStatus) +} + +// SetTenantID sets the "tenant_id" field. +func (m *UserMutation) SetTenantID(u uint64) { + m.tenant_id = &u + m.addtenant_id = nil +} + +// TenantID returns the value of the "tenant_id" field in the mutation. +func (m *UserMutation) TenantID() (r uint64, exists bool) { + v := m.tenant_id + if v == nil { + return + } + return *v, true +} + +// OldTenantID returns the old "tenant_id" field's value of the User entity. +// If the User 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 *UserMutation) OldTenantID(ctx context.Context) (v uint64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTenantID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTenantID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTenantID: %w", err) + } + return oldValue.TenantID, nil +} + +// AddTenantID adds u to the "tenant_id" field. +func (m *UserMutation) AddTenantID(u int64) { + if m.addtenant_id != nil { + *m.addtenant_id += u + } else { + m.addtenant_id = &u + } +} + +// AddedTenantID returns the value that was added to the "tenant_id" field in this mutation. +func (m *UserMutation) AddedTenantID() (r int64, exists bool) { + v := m.addtenant_id + if v == nil { + return + } + return *v, true +} + +// ResetTenantID resets all changes to the "tenant_id" field. +func (m *UserMutation) ResetTenantID() { + m.tenant_id = nil + m.addtenant_id = nil +} + +// SetDeletedAt sets the "deleted_at" field. +func (m *UserMutation) SetDeletedAt(t time.Time) { + m.deleted_at = &t +} + +// DeletedAt returns the value of the "deleted_at" field in the mutation. +func (m *UserMutation) DeletedAt() (r time.Time, exists bool) { + v := m.deleted_at + if v == nil { + return + } + return *v, true +} + +// OldDeletedAt returns the old "deleted_at" field's value of the User entity. +// If the User 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 *UserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeletedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) + } + return oldValue.DeletedAt, nil +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (m *UserMutation) ClearDeletedAt() { + m.deleted_at = nil + m.clearedFields[user.FieldDeletedAt] = struct{}{} +} + +// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. +func (m *UserMutation) DeletedAtCleared() bool { + _, ok := m.clearedFields[user.FieldDeletedAt] + return ok +} + +// ResetDeletedAt resets all changes to the "deleted_at" field. +func (m *UserMutation) ResetDeletedAt() { + m.deleted_at = nil + delete(m.clearedFields, user.FieldDeletedAt) +} + +// SetUsername sets the "username" field. +func (m *UserMutation) SetUsername(s string) { + m.username = &s +} + +// Username returns the value of the "username" field in the mutation. +func (m *UserMutation) 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 User entity. +// If the User 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 *UserMutation) 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 +} + +// ResetUsername resets all changes to the "username" field. +func (m *UserMutation) ResetUsername() { + m.username = nil +} + +// SetEmail sets the "email" field. +func (m *UserMutation) SetEmail(s string) { + m.email = &s +} + +// Email returns the value of the "email" field in the mutation. +func (m *UserMutation) 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 User entity. +// If the User 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 *UserMutation) 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 +} + +// ResetEmail resets all changes to the "email" field. +func (m *UserMutation) ResetEmail() { + m.email = nil +} + +// SetMobile sets the "mobile" field. +func (m *UserMutation) SetMobile(s string) { + m.mobile = &s +} + +// Mobile returns the value of the "mobile" field in the mutation. +func (m *UserMutation) Mobile() (r string, exists bool) { + v := m.mobile + if v == nil { + return + } + return *v, true +} + +// OldMobile returns the old "mobile" field's value of the User entity. +// If the User 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 *UserMutation) OldMobile(ctx context.Context) (v *string, 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 +} + +// ClearMobile clears the value of the "mobile" field. +func (m *UserMutation) ClearMobile() { + m.mobile = nil + m.clearedFields[user.FieldMobile] = struct{}{} +} + +// MobileCleared returns if the "mobile" field was cleared in this mutation. +func (m *UserMutation) MobileCleared() bool { + _, ok := m.clearedFields[user.FieldMobile] + return ok +} + +// ResetMobile resets all changes to the "mobile" field. +func (m *UserMutation) ResetMobile() { + m.mobile = nil + delete(m.clearedFields, user.FieldMobile) +} + +// SetPasswordHash sets the "password_hash" field. +func (m *UserMutation) SetPasswordHash(s string) { + m.password_hash = &s +} + +// PasswordHash returns the value of the "password_hash" field in the mutation. +func (m *UserMutation) PasswordHash() (r string, exists bool) { + v := m.password_hash + if v == nil { + return + } + return *v, true +} + +// OldPasswordHash returns the old "password_hash" field's value of the User entity. +// If the User 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 *UserMutation) OldPasswordHash(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPasswordHash is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPasswordHash requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPasswordHash: %w", err) + } + return oldValue.PasswordHash, nil +} + +// ResetPasswordHash resets all changes to the "password_hash" field. +func (m *UserMutation) ResetPasswordHash() { + m.password_hash = nil +} + +// SetSalt sets the "salt" field. +func (m *UserMutation) SetSalt(s string) { + m.salt = &s +} + +// Salt returns the value of the "salt" field in the mutation. +func (m *UserMutation) Salt() (r string, exists bool) { + v := m.salt + if v == nil { + return + } + return *v, true +} + +// OldSalt returns the old "salt" field's value of the User entity. +// If the User 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 *UserMutation) OldSalt(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSalt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSalt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSalt: %w", err) + } + return oldValue.Salt, nil +} + +// ResetSalt resets all changes to the "salt" field. +func (m *UserMutation) ResetSalt() { + m.salt = nil +} + +// SetNickname sets the "nickname" field. +func (m *UserMutation) SetNickname(s string) { + m.nickname = &s +} + +// Nickname returns the value of the "nickname" field in the mutation. +func (m *UserMutation) 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 User entity. +// If the User 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 *UserMutation) OldNickname(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldNickname is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldNickname requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldNickname: %w", err) + } + return oldValue.Nickname, nil +} + +// ResetNickname resets all changes to the "nickname" field. +func (m *UserMutation) ResetNickname() { + m.nickname = nil +} + +// SetAvatar sets the "avatar" field. +func (m *UserMutation) SetAvatar(s string) { + m.avatar = &s +} + +// Avatar returns the value of the "avatar" field in the mutation. +func (m *UserMutation) 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 User entity. +// If the User 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 *UserMutation) 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 *UserMutation) ClearAvatar() { + m.avatar = nil + m.clearedFields[user.FieldAvatar] = struct{}{} +} + +// AvatarCleared returns if the "avatar" field was cleared in this mutation. +func (m *UserMutation) AvatarCleared() bool { + _, ok := m.clearedFields[user.FieldAvatar] + return ok +} + +// ResetAvatar resets all changes to the "avatar" field. +func (m *UserMutation) ResetAvatar() { + m.avatar = nil + delete(m.clearedFields, user.FieldAvatar) +} + +// SetGender sets the "gender" field. +func (m *UserMutation) SetGender(u user.Gender) { + m.gender = &u +} + +// Gender returns the value of the "gender" field in the mutation. +func (m *UserMutation) Gender() (r user.Gender, exists bool) { + v := m.gender + if v == nil { + return + } + return *v, true +} + +// OldGender returns the old "gender" field's value of the User entity. +// If the User 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 *UserMutation) OldGender(ctx context.Context) (v user.Gender, 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 +} + +// ResetGender resets all changes to the "gender" field. +func (m *UserMutation) ResetGender() { + m.gender = nil +} + +// SetBirthday sets the "birthday" field. +func (m *UserMutation) SetBirthday(t time.Time) { + m.birthday = &t +} + +// Birthday returns the value of the "birthday" field in the mutation. +func (m *UserMutation) Birthday() (r time.Time, exists bool) { + v := m.birthday + if v == nil { + return + } + return *v, true +} + +// OldBirthday returns the old "birthday" field's value of the User entity. +// If the User 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 *UserMutation) OldBirthday(ctx context.Context) (v *time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldBirthday is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldBirthday requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldBirthday: %w", err) + } + return oldValue.Birthday, nil +} + +// ClearBirthday clears the value of the "birthday" field. +func (m *UserMutation) ClearBirthday() { + m.birthday = nil + m.clearedFields[user.FieldBirthday] = struct{}{} +} + +// BirthdayCleared returns if the "birthday" field was cleared in this mutation. +func (m *UserMutation) BirthdayCleared() bool { + _, ok := m.clearedFields[user.FieldBirthday] + return ok +} + +// ResetBirthday resets all changes to the "birthday" field. +func (m *UserMutation) ResetBirthday() { + m.birthday = nil + delete(m.clearedFields, user.FieldBirthday) +} + +// SetAccountStatus sets the "account_status" field. +func (m *UserMutation) SetAccountStatus(us user.AccountStatus) { + m.account_status = &us +} + +// AccountStatus returns the value of the "account_status" field in the mutation. +func (m *UserMutation) AccountStatus() (r user.AccountStatus, exists bool) { + v := m.account_status + if v == nil { + return + } + return *v, true +} + +// OldAccountStatus returns the old "account_status" field's value of the User entity. +// If the User 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 *UserMutation) OldAccountStatus(ctx context.Context) (v user.AccountStatus, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAccountStatus is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAccountStatus requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAccountStatus: %w", err) + } + return oldValue.AccountStatus, nil +} + +// ResetAccountStatus resets all changes to the "account_status" field. +func (m *UserMutation) ResetAccountStatus() { + m.account_status = nil +} + +// SetIsVerified sets the "is_verified" field. +func (m *UserMutation) SetIsVerified(u uint32) { + m.is_verified = &u + m.addis_verified = nil +} + +// IsVerified returns the value of the "is_verified" field in the mutation. +func (m *UserMutation) IsVerified() (r uint32, exists bool) { + v := m.is_verified + if v == nil { + return + } + return *v, true +} + +// OldIsVerified returns the old "is_verified" field's value of the User entity. +// If the User 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 *UserMutation) OldIsVerified(ctx context.Context) (v uint32, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldIsVerified is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldIsVerified requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldIsVerified: %w", err) + } + return oldValue.IsVerified, nil +} + +// AddIsVerified adds u to the "is_verified" field. +func (m *UserMutation) AddIsVerified(u int32) { + if m.addis_verified != nil { + *m.addis_verified += u + } else { + m.addis_verified = &u + } +} + +// AddedIsVerified returns the value that was added to the "is_verified" field in this mutation. +func (m *UserMutation) AddedIsVerified() (r int32, exists bool) { + v := m.addis_verified + if v == nil { + return + } + return *v, true +} + +// ResetIsVerified resets all changes to the "is_verified" field. +func (m *UserMutation) ResetIsVerified() { + m.is_verified = nil + m.addis_verified = nil +} + +// SetRegisteredLoginIP sets the "registered_login_ip" field. +func (m *UserMutation) SetRegisteredLoginIP(s string) { + m.registered_login_ip = &s +} + +// RegisteredLoginIP returns the value of the "registered_login_ip" field in the mutation. +func (m *UserMutation) RegisteredLoginIP() (r string, exists bool) { + v := m.registered_login_ip + if v == nil { + return + } + return *v, true +} + +// OldRegisteredLoginIP returns the old "registered_login_ip" field's value of the User entity. +// If the User 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 *UserMutation) OldRegisteredLoginIP(ctx context.Context) (v *string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRegisteredLoginIP is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRegisteredLoginIP requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRegisteredLoginIP: %w", err) + } + return oldValue.RegisteredLoginIP, nil +} + +// ClearRegisteredLoginIP clears the value of the "registered_login_ip" field. +func (m *UserMutation) ClearRegisteredLoginIP() { + m.registered_login_ip = nil + m.clearedFields[user.FieldRegisteredLoginIP] = struct{}{} +} + +// RegisteredLoginIPCleared returns if the "registered_login_ip" field was cleared in this mutation. +func (m *UserMutation) RegisteredLoginIPCleared() bool { + _, ok := m.clearedFields[user.FieldRegisteredLoginIP] + return ok +} + +// ResetRegisteredLoginIP resets all changes to the "registered_login_ip" field. +func (m *UserMutation) ResetRegisteredLoginIP() { + m.registered_login_ip = nil + delete(m.clearedFields, user.FieldRegisteredLoginIP) +} + +// SetLoginAttempts sets the "login_attempts" field. +func (m *UserMutation) SetLoginAttempts(i int64) { + m.login_attempts = &i + m.addlogin_attempts = nil +} + +// LoginAttempts returns the value of the "login_attempts" field in the mutation. +func (m *UserMutation) LoginAttempts() (r int64, exists bool) { + v := m.login_attempts + if v == nil { + return + } + return *v, true +} + +// OldLoginAttempts returns the old "login_attempts" field's value of the User entity. +// If the User 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 *UserMutation) OldLoginAttempts(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLoginAttempts is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLoginAttempts requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLoginAttempts: %w", err) + } + return oldValue.LoginAttempts, nil +} + +// AddLoginAttempts adds i to the "login_attempts" field. +func (m *UserMutation) AddLoginAttempts(i int64) { + if m.addlogin_attempts != nil { + *m.addlogin_attempts += i + } else { + m.addlogin_attempts = &i + } +} + +// AddedLoginAttempts returns the value that was added to the "login_attempts" field in this mutation. +func (m *UserMutation) AddedLoginAttempts() (r int64, exists bool) { + v := m.addlogin_attempts + if v == nil { + return + } + return *v, true +} + +// ResetLoginAttempts resets all changes to the "login_attempts" field. +func (m *UserMutation) ResetLoginAttempts() { + m.login_attempts = nil + m.addlogin_attempts = nil +} + +// SetMetadata sets the "metadata" field. +func (m *UserMutation) SetMetadata(value map[string]interface{}) { + m.metadata = &value +} + +// Metadata returns the value of the "metadata" field in the mutation. +func (m *UserMutation) Metadata() (r map[string]interface{}, exists bool) { + v := m.metadata + if v == nil { + return + } + return *v, true +} + +// OldMetadata returns the old "metadata" field's value of the User entity. +// If the User 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 *UserMutation) OldMetadata(ctx context.Context) (v map[string]interface{}, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldMetadata is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldMetadata requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldMetadata: %w", err) + } + return oldValue.Metadata, nil +} + +// ClearMetadata clears the value of the "metadata" field. +func (m *UserMutation) ClearMetadata() { + m.metadata = nil + m.clearedFields[user.FieldMetadata] = struct{}{} +} + +// MetadataCleared returns if the "metadata" field was cleared in this mutation. +func (m *UserMutation) MetadataCleared() bool { + _, ok := m.clearedFields[user.FieldMetadata] + return ok +} + +// ResetMetadata resets all changes to the "metadata" field. +func (m *UserMutation) ResetMetadata() { + m.metadata = nil + delete(m.clearedFields, user.FieldMetadata) +} + +// SetRegistrationSource sets the "registration_source" field. +func (m *UserMutation) SetRegistrationSource(s string) { + m.registration_source = &s +} + +// RegistrationSource returns the value of the "registration_source" field in the mutation. +func (m *UserMutation) RegistrationSource() (r string, exists bool) { + v := m.registration_source + if v == nil { + return + } + return *v, true +} + +// OldRegistrationSource returns the old "registration_source" field's value of the User entity. +// If the User 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 *UserMutation) OldRegistrationSource(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRegistrationSource is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRegistrationSource requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRegistrationSource: %w", err) + } + return oldValue.RegistrationSource, nil +} + +// ClearRegistrationSource clears the value of the "registration_source" field. +func (m *UserMutation) ClearRegistrationSource() { + m.registration_source = nil + m.clearedFields[user.FieldRegistrationSource] = struct{}{} +} + +// RegistrationSourceCleared returns if the "registration_source" field was cleared in this mutation. +func (m *UserMutation) RegistrationSourceCleared() bool { + _, ok := m.clearedFields[user.FieldRegistrationSource] + return ok +} + +// ResetRegistrationSource resets all changes to the "registration_source" field. +func (m *UserMutation) ResetRegistrationSource() { + m.registration_source = nil + delete(m.clearedFields, user.FieldRegistrationSource) +} + +// Where appends a list predicates to the UserMutation builder. +func (m *UserMutation) Where(ps ...predicate.User) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the UserMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *UserMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.User, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *UserMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *UserMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (User). +func (m *UserMutation) 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 *UserMutation) Fields() []string { + fields := make([]string, 0, 20) + if m.created_at != nil { + fields = append(fields, user.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, user.FieldUpdatedAt) + } + if m.status != nil { + fields = append(fields, user.FieldStatus) + } + if m.tenant_id != nil { + fields = append(fields, user.FieldTenantID) + } + if m.deleted_at != nil { + fields = append(fields, user.FieldDeletedAt) + } + if m.username != nil { + fields = append(fields, user.FieldUsername) + } + if m.email != nil { + fields = append(fields, user.FieldEmail) + } + if m.mobile != nil { + fields = append(fields, user.FieldMobile) + } + if m.password_hash != nil { + fields = append(fields, user.FieldPasswordHash) + } + if m.salt != nil { + fields = append(fields, user.FieldSalt) + } + if m.nickname != nil { + fields = append(fields, user.FieldNickname) + } + if m.avatar != nil { + fields = append(fields, user.FieldAvatar) + } + if m.gender != nil { + fields = append(fields, user.FieldGender) + } + if m.birthday != nil { + fields = append(fields, user.FieldBirthday) + } + if m.account_status != nil { + fields = append(fields, user.FieldAccountStatus) + } + if m.is_verified != nil { + fields = append(fields, user.FieldIsVerified) + } + if m.registered_login_ip != nil { + fields = append(fields, user.FieldRegisteredLoginIP) + } + if m.login_attempts != nil { + fields = append(fields, user.FieldLoginAttempts) + } + if m.metadata != nil { + fields = append(fields, user.FieldMetadata) + } + if m.registration_source != nil { + fields = append(fields, user.FieldRegistrationSource) + } + 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 *UserMutation) Field(name string) (ent.Value, bool) { + switch name { + case user.FieldCreatedAt: + return m.CreatedAt() + case user.FieldUpdatedAt: + return m.UpdatedAt() + case user.FieldStatus: + return m.Status() + case user.FieldTenantID: + return m.TenantID() + case user.FieldDeletedAt: + return m.DeletedAt() + case user.FieldUsername: + return m.Username() + case user.FieldEmail: + return m.Email() + case user.FieldMobile: + return m.Mobile() + case user.FieldPasswordHash: + return m.PasswordHash() + case user.FieldSalt: + return m.Salt() + case user.FieldNickname: + return m.Nickname() + case user.FieldAvatar: + return m.Avatar() + case user.FieldGender: + return m.Gender() + case user.FieldBirthday: + return m.Birthday() + case user.FieldAccountStatus: + return m.AccountStatus() + case user.FieldIsVerified: + return m.IsVerified() + case user.FieldRegisteredLoginIP: + return m.RegisteredLoginIP() + case user.FieldLoginAttempts: + return m.LoginAttempts() + case user.FieldMetadata: + return m.Metadata() + case user.FieldRegistrationSource: + return m.RegistrationSource() + } + 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 *UserMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case user.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case user.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + case user.FieldStatus: + return m.OldStatus(ctx) + case user.FieldTenantID: + return m.OldTenantID(ctx) + case user.FieldDeletedAt: + return m.OldDeletedAt(ctx) + case user.FieldUsername: + return m.OldUsername(ctx) + case user.FieldEmail: + return m.OldEmail(ctx) + case user.FieldMobile: + return m.OldMobile(ctx) + case user.FieldPasswordHash: + return m.OldPasswordHash(ctx) + case user.FieldSalt: + return m.OldSalt(ctx) + case user.FieldNickname: + return m.OldNickname(ctx) + case user.FieldAvatar: + return m.OldAvatar(ctx) + case user.FieldGender: + return m.OldGender(ctx) + case user.FieldBirthday: + return m.OldBirthday(ctx) + case user.FieldAccountStatus: + return m.OldAccountStatus(ctx) + case user.FieldIsVerified: + return m.OldIsVerified(ctx) + case user.FieldRegisteredLoginIP: + return m.OldRegisteredLoginIP(ctx) + case user.FieldLoginAttempts: + return m.OldLoginAttempts(ctx) + case user.FieldMetadata: + return m.OldMetadata(ctx) + case user.FieldRegistrationSource: + return m.OldRegistrationSource(ctx) + } + return nil, fmt.Errorf("unknown User 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 *UserMutation) SetField(name string, value ent.Value) error { + switch name { + case user.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 user.FieldUpdatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdatedAt(v) + return nil + case user.FieldStatus: + v, ok := value.(uint8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStatus(v) + return nil + case user.FieldTenantID: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTenantID(v) + return nil + case user.FieldDeletedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeletedAt(v) + return nil + case user.FieldUsername: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUsername(v) + return nil + case user.FieldEmail: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetEmail(v) + return nil + case user.FieldMobile: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMobile(v) + return nil + case user.FieldPasswordHash: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPasswordHash(v) + return nil + case user.FieldSalt: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSalt(v) + return nil + case user.FieldNickname: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetNickname(v) + return nil + case user.FieldAvatar: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAvatar(v) + return nil + case user.FieldGender: + v, ok := value.(user.Gender) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetGender(v) + return nil + case user.FieldBirthday: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetBirthday(v) + return nil + case user.FieldAccountStatus: + v, ok := value.(user.AccountStatus) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAccountStatus(v) + return nil + case user.FieldIsVerified: + v, ok := value.(uint32) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetIsVerified(v) + return nil + case user.FieldRegisteredLoginIP: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRegisteredLoginIP(v) + return nil + case user.FieldLoginAttempts: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLoginAttempts(v) + return nil + case user.FieldMetadata: + v, ok := value.(map[string]interface{}) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMetadata(v) + return nil + case user.FieldRegistrationSource: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRegistrationSource(v) + return nil + } + return fmt.Errorf("unknown User field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *UserMutation) AddedFields() []string { + var fields []string + if m.addstatus != nil { + fields = append(fields, user.FieldStatus) + } + if m.addtenant_id != nil { + fields = append(fields, user.FieldTenantID) + } + if m.addis_verified != nil { + fields = append(fields, user.FieldIsVerified) + } + if m.addlogin_attempts != nil { + fields = append(fields, user.FieldLoginAttempts) + } + 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 *UserMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case user.FieldStatus: + return m.AddedStatus() + case user.FieldTenantID: + return m.AddedTenantID() + case user.FieldIsVerified: + return m.AddedIsVerified() + case user.FieldLoginAttempts: + return m.AddedLoginAttempts() + } + 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 *UserMutation) AddField(name string, value ent.Value) error { + switch name { + case user.FieldStatus: + v, ok := value.(int8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddStatus(v) + return nil + case user.FieldTenantID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddTenantID(v) + return nil + case user.FieldIsVerified: + v, ok := value.(int32) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddIsVerified(v) + return nil + case user.FieldLoginAttempts: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddLoginAttempts(v) + return nil + } + return fmt.Errorf("unknown User numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *UserMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(user.FieldStatus) { + fields = append(fields, user.FieldStatus) + } + if m.FieldCleared(user.FieldDeletedAt) { + fields = append(fields, user.FieldDeletedAt) + } + if m.FieldCleared(user.FieldMobile) { + fields = append(fields, user.FieldMobile) + } + if m.FieldCleared(user.FieldAvatar) { + fields = append(fields, user.FieldAvatar) + } + if m.FieldCleared(user.FieldBirthday) { + fields = append(fields, user.FieldBirthday) + } + if m.FieldCleared(user.FieldRegisteredLoginIP) { + fields = append(fields, user.FieldRegisteredLoginIP) + } + if m.FieldCleared(user.FieldMetadata) { + fields = append(fields, user.FieldMetadata) + } + if m.FieldCleared(user.FieldRegistrationSource) { + fields = append(fields, user.FieldRegistrationSource) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *UserMutation) 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 *UserMutation) ClearField(name string) error { + switch name { + case user.FieldStatus: + m.ClearStatus() + return nil + case user.FieldDeletedAt: + m.ClearDeletedAt() + return nil + case user.FieldMobile: + m.ClearMobile() + return nil + case user.FieldAvatar: + m.ClearAvatar() + return nil + case user.FieldBirthday: + m.ClearBirthday() + return nil + case user.FieldRegisteredLoginIP: + m.ClearRegisteredLoginIP() + return nil + case user.FieldMetadata: + m.ClearMetadata() + return nil + case user.FieldRegistrationSource: + m.ClearRegistrationSource() + return nil + } + return fmt.Errorf("unknown User 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 *UserMutation) ResetField(name string) error { + switch name { + case user.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case user.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + case user.FieldStatus: + m.ResetStatus() + return nil + case user.FieldTenantID: + m.ResetTenantID() + return nil + case user.FieldDeletedAt: + m.ResetDeletedAt() + return nil + case user.FieldUsername: + m.ResetUsername() + return nil + case user.FieldEmail: + m.ResetEmail() + return nil + case user.FieldMobile: + m.ResetMobile() + return nil + case user.FieldPasswordHash: + m.ResetPasswordHash() + return nil + case user.FieldSalt: + m.ResetSalt() + return nil + case user.FieldNickname: + m.ResetNickname() + return nil + case user.FieldAvatar: + m.ResetAvatar() + return nil + case user.FieldGender: + m.ResetGender() + return nil + case user.FieldBirthday: + m.ResetBirthday() + return nil + case user.FieldAccountStatus: + m.ResetAccountStatus() + return nil + case user.FieldIsVerified: + m.ResetIsVerified() + return nil + case user.FieldRegisteredLoginIP: + m.ResetRegisteredLoginIP() + return nil + case user.FieldLoginAttempts: + m.ResetLoginAttempts() + return nil + case user.FieldMetadata: + m.ResetMetadata() + return nil + case user.FieldRegistrationSource: + m.ResetRegistrationSource() + return nil + } + return fmt.Errorf("unknown User field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *UserMutation) AddedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *UserMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *UserMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *UserMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *UserMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *UserMutation) EdgeCleared(name string) bool { + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *UserMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown User 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 *UserMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown User edge %s", name) +} + +// UserLoginLogMutation represents an operation that mutates the UserLoginLog nodes in the graph. +type UserLoginLogMutation struct { + config + op Op + typ string + id *uint64 + created_at *time.Time + updated_at *time.Time + status *uint8 + addstatus *int8 + tenant_id *uint64 + addtenant_id *int64 + deleted_at *time.Time + user_id *uint64 + adduser_id *int64 + login_time *time.Time + login_ip *string + login_location *string + login_type *userloginlog.LoginType + login_platform *userloginlog.LoginPlatform + login_result *bool + failure_reason *string + session_id *string + latency_ms *int + addlatency_ms *int + auth_id *uint64 + addauth_id *int64 + additional_data *map[string]interface{} + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*UserLoginLog, error) + predicates []predicate.UserLoginLog +} + +var _ ent.Mutation = (*UserLoginLogMutation)(nil) + +// userloginlogOption allows management of the mutation configuration using functional options. +type userloginlogOption func(*UserLoginLogMutation) + +// newUserLoginLogMutation creates new mutation for the UserLoginLog entity. +func newUserLoginLogMutation(c config, op Op, opts ...userloginlogOption) *UserLoginLogMutation { + m := &UserLoginLogMutation{ + config: c, + op: op, + typ: TypeUserLoginLog, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withUserLoginLogID sets the ID field of the mutation. +func withUserLoginLogID(id uint64) userloginlogOption { + return func(m *UserLoginLogMutation) { + var ( + err error + once sync.Once + value *UserLoginLog + ) + m.oldValue = func(ctx context.Context) (*UserLoginLog, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().UserLoginLog.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withUserLoginLog sets the old UserLoginLog of the mutation. +func withUserLoginLog(node *UserLoginLog) userloginlogOption { + return func(m *UserLoginLogMutation) { + m.oldValue = func(context.Context) (*UserLoginLog, 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 UserLoginLogMutation) 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 UserLoginLogMutation) 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 UserLoginLog entities. +func (m *UserLoginLogMutation) SetID(id uint64) { + 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 *UserLoginLogMutation) ID() (id uint64, 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 *UserLoginLogMutation) IDs(ctx context.Context) ([]uint64, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []uint64{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().UserLoginLog.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetCreatedAt sets the "created_at" field. +func (m *UserLoginLogMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *UserLoginLogMutation) 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 UserLoginLog entity. +// If the UserLoginLog 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 *UserLoginLogMutation) 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 *UserLoginLogMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *UserLoginLogMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *UserLoginLogMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at + if v == nil { + return + } + return *v, true +} + +// OldUpdatedAt returns the old "updated_at" field's value of the UserLoginLog entity. +// If the UserLoginLog 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 *UserLoginLogMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + } + return oldValue.UpdatedAt, nil +} + +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *UserLoginLogMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// SetStatus sets the "status" field. +func (m *UserLoginLogMutation) SetStatus(u uint8) { + m.status = &u + m.addstatus = nil +} + +// Status returns the value of the "status" field in the mutation. +func (m *UserLoginLogMutation) Status() (r uint8, exists bool) { + v := m.status + if v == nil { + return + } + return *v, true +} + +// OldStatus returns the old "status" field's value of the UserLoginLog entity. +// If the UserLoginLog 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 *UserLoginLogMutation) OldStatus(ctx context.Context) (v uint8, 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 u to the "status" field. +func (m *UserLoginLogMutation) AddStatus(u int8) { + if m.addstatus != nil { + *m.addstatus += u + } else { + m.addstatus = &u + } +} + +// AddedStatus returns the value that was added to the "status" field in this mutation. +func (m *UserLoginLogMutation) 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 *UserLoginLogMutation) ClearStatus() { + m.status = nil + m.addstatus = nil + m.clearedFields[userloginlog.FieldStatus] = struct{}{} +} + +// StatusCleared returns if the "status" field was cleared in this mutation. +func (m *UserLoginLogMutation) StatusCleared() bool { + _, ok := m.clearedFields[userloginlog.FieldStatus] + return ok +} + +// ResetStatus resets all changes to the "status" field. +func (m *UserLoginLogMutation) ResetStatus() { + m.status = nil + m.addstatus = nil + delete(m.clearedFields, userloginlog.FieldStatus) +} + +// SetTenantID sets the "tenant_id" field. +func (m *UserLoginLogMutation) SetTenantID(u uint64) { + m.tenant_id = &u + m.addtenant_id = nil +} + +// TenantID returns the value of the "tenant_id" field in the mutation. +func (m *UserLoginLogMutation) TenantID() (r uint64, exists bool) { + v := m.tenant_id + if v == nil { + return + } + return *v, true +} + +// OldTenantID returns the old "tenant_id" field's value of the UserLoginLog entity. +// If the UserLoginLog 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 *UserLoginLogMutation) OldTenantID(ctx context.Context) (v uint64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTenantID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTenantID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTenantID: %w", err) + } + return oldValue.TenantID, nil +} + +// AddTenantID adds u to the "tenant_id" field. +func (m *UserLoginLogMutation) AddTenantID(u int64) { + if m.addtenant_id != nil { + *m.addtenant_id += u + } else { + m.addtenant_id = &u + } +} + +// AddedTenantID returns the value that was added to the "tenant_id" field in this mutation. +func (m *UserLoginLogMutation) AddedTenantID() (r int64, exists bool) { + v := m.addtenant_id + if v == nil { + return + } + return *v, true +} + +// ResetTenantID resets all changes to the "tenant_id" field. +func (m *UserLoginLogMutation) ResetTenantID() { + m.tenant_id = nil + m.addtenant_id = nil +} + +// SetDeletedAt sets the "deleted_at" field. +func (m *UserLoginLogMutation) SetDeletedAt(t time.Time) { + m.deleted_at = &t +} + +// DeletedAt returns the value of the "deleted_at" field in the mutation. +func (m *UserLoginLogMutation) DeletedAt() (r time.Time, exists bool) { + v := m.deleted_at + if v == nil { + return + } + return *v, true +} + +// OldDeletedAt returns the old "deleted_at" field's value of the UserLoginLog entity. +// If the UserLoginLog 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 *UserLoginLogMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeletedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) + } + return oldValue.DeletedAt, nil +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (m *UserLoginLogMutation) ClearDeletedAt() { + m.deleted_at = nil + m.clearedFields[userloginlog.FieldDeletedAt] = struct{}{} +} + +// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. +func (m *UserLoginLogMutation) DeletedAtCleared() bool { + _, ok := m.clearedFields[userloginlog.FieldDeletedAt] + return ok +} + +// ResetDeletedAt resets all changes to the "deleted_at" field. +func (m *UserLoginLogMutation) ResetDeletedAt() { + m.deleted_at = nil + delete(m.clearedFields, userloginlog.FieldDeletedAt) +} + +// SetUserID sets the "user_id" field. +func (m *UserLoginLogMutation) SetUserID(u uint64) { + m.user_id = &u + m.adduser_id = nil +} + +// UserID returns the value of the "user_id" field in the mutation. +func (m *UserLoginLogMutation) UserID() (r uint64, exists bool) { + v := m.user_id + if v == nil { + return + } + return *v, true +} + +// OldUserID returns the old "user_id" field's value of the UserLoginLog entity. +// If the UserLoginLog 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 *UserLoginLogMutation) OldUserID(ctx context.Context) (v uint64, 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 +} + +// AddUserID adds u to the "user_id" field. +func (m *UserLoginLogMutation) AddUserID(u int64) { + if m.adduser_id != nil { + *m.adduser_id += u + } else { + m.adduser_id = &u + } +} + +// AddedUserID returns the value that was added to the "user_id" field in this mutation. +func (m *UserLoginLogMutation) AddedUserID() (r int64, exists bool) { + v := m.adduser_id + if v == nil { + return + } + return *v, true +} + +// ResetUserID resets all changes to the "user_id" field. +func (m *UserLoginLogMutation) ResetUserID() { + m.user_id = nil + m.adduser_id = nil +} + +// SetLoginTime sets the "login_time" field. +func (m *UserLoginLogMutation) SetLoginTime(t time.Time) { + m.login_time = &t +} + +// LoginTime returns the value of the "login_time" field in the mutation. +func (m *UserLoginLogMutation) LoginTime() (r time.Time, exists bool) { + v := m.login_time + if v == nil { + return + } + return *v, true +} + +// OldLoginTime returns the old "login_time" field's value of the UserLoginLog entity. +// If the UserLoginLog 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 *UserLoginLogMutation) OldLoginTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLoginTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLoginTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLoginTime: %w", err) + } + return oldValue.LoginTime, nil +} + +// ResetLoginTime resets all changes to the "login_time" field. +func (m *UserLoginLogMutation) ResetLoginTime() { + m.login_time = nil +} + +// SetLoginIP sets the "login_ip" field. +func (m *UserLoginLogMutation) SetLoginIP(s string) { + m.login_ip = &s +} + +// LoginIP returns the value of the "login_ip" field in the mutation. +func (m *UserLoginLogMutation) LoginIP() (r string, exists bool) { + v := m.login_ip + if v == nil { + return + } + return *v, true +} + +// OldLoginIP returns the old "login_ip" field's value of the UserLoginLog entity. +// If the UserLoginLog 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 *UserLoginLogMutation) OldLoginIP(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLoginIP is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLoginIP requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLoginIP: %w", err) + } + return oldValue.LoginIP, nil +} + +// ResetLoginIP resets all changes to the "login_ip" field. +func (m *UserLoginLogMutation) ResetLoginIP() { + m.login_ip = nil +} + +// SetLoginLocation sets the "login_location" field. +func (m *UserLoginLogMutation) SetLoginLocation(s string) { + m.login_location = &s +} + +// LoginLocation returns the value of the "login_location" field in the mutation. +func (m *UserLoginLogMutation) LoginLocation() (r string, exists bool) { + v := m.login_location + if v == nil { + return + } + return *v, true +} + +// OldLoginLocation returns the old "login_location" field's value of the UserLoginLog entity. +// If the UserLoginLog 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 *UserLoginLogMutation) OldLoginLocation(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLoginLocation is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLoginLocation requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLoginLocation: %w", err) + } + return oldValue.LoginLocation, nil +} + +// ClearLoginLocation clears the value of the "login_location" field. +func (m *UserLoginLogMutation) ClearLoginLocation() { + m.login_location = nil + m.clearedFields[userloginlog.FieldLoginLocation] = struct{}{} +} + +// LoginLocationCleared returns if the "login_location" field was cleared in this mutation. +func (m *UserLoginLogMutation) LoginLocationCleared() bool { + _, ok := m.clearedFields[userloginlog.FieldLoginLocation] + return ok +} + +// ResetLoginLocation resets all changes to the "login_location" field. +func (m *UserLoginLogMutation) ResetLoginLocation() { + m.login_location = nil + delete(m.clearedFields, userloginlog.FieldLoginLocation) +} + +// SetLoginType sets the "login_type" field. +func (m *UserLoginLogMutation) SetLoginType(ut userloginlog.LoginType) { + m.login_type = &ut +} + +// LoginType returns the value of the "login_type" field in the mutation. +func (m *UserLoginLogMutation) LoginType() (r userloginlog.LoginType, exists bool) { + v := m.login_type + if v == nil { + return + } + return *v, true +} + +// OldLoginType returns the old "login_type" field's value of the UserLoginLog entity. +// If the UserLoginLog 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 *UserLoginLogMutation) OldLoginType(ctx context.Context) (v userloginlog.LoginType, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLoginType is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLoginType requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLoginType: %w", err) + } + return oldValue.LoginType, nil +} + +// ResetLoginType resets all changes to the "login_type" field. +func (m *UserLoginLogMutation) ResetLoginType() { + m.login_type = nil +} + +// SetLoginPlatform sets the "login_platform" field. +func (m *UserLoginLogMutation) SetLoginPlatform(up userloginlog.LoginPlatform) { + m.login_platform = &up +} + +// LoginPlatform returns the value of the "login_platform" field in the mutation. +func (m *UserLoginLogMutation) LoginPlatform() (r userloginlog.LoginPlatform, exists bool) { + v := m.login_platform + if v == nil { + return + } + return *v, true +} + +// OldLoginPlatform returns the old "login_platform" field's value of the UserLoginLog entity. +// If the UserLoginLog 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 *UserLoginLogMutation) OldLoginPlatform(ctx context.Context) (v userloginlog.LoginPlatform, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLoginPlatform is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLoginPlatform requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLoginPlatform: %w", err) + } + return oldValue.LoginPlatform, nil +} + +// ResetLoginPlatform resets all changes to the "login_platform" field. +func (m *UserLoginLogMutation) ResetLoginPlatform() { + m.login_platform = nil +} + +// SetLoginResult sets the "login_result" field. +func (m *UserLoginLogMutation) SetLoginResult(b bool) { + m.login_result = &b +} + +// LoginResult returns the value of the "login_result" field in the mutation. +func (m *UserLoginLogMutation) LoginResult() (r bool, exists bool) { + v := m.login_result + if v == nil { + return + } + return *v, true +} + +// OldLoginResult returns the old "login_result" field's value of the UserLoginLog entity. +// If the UserLoginLog 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 *UserLoginLogMutation) OldLoginResult(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLoginResult is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLoginResult requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLoginResult: %w", err) + } + return oldValue.LoginResult, nil +} + +// ResetLoginResult resets all changes to the "login_result" field. +func (m *UserLoginLogMutation) ResetLoginResult() { + m.login_result = nil +} + +// SetFailureReason sets the "failure_reason" field. +func (m *UserLoginLogMutation) SetFailureReason(s string) { + m.failure_reason = &s +} + +// FailureReason returns the value of the "failure_reason" field in the mutation. +func (m *UserLoginLogMutation) FailureReason() (r string, exists bool) { + v := m.failure_reason + if v == nil { + return + } + return *v, true +} + +// OldFailureReason returns the old "failure_reason" field's value of the UserLoginLog entity. +// If the UserLoginLog 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 *UserLoginLogMutation) OldFailureReason(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldFailureReason is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldFailureReason requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldFailureReason: %w", err) + } + return oldValue.FailureReason, nil +} + +// ClearFailureReason clears the value of the "failure_reason" field. +func (m *UserLoginLogMutation) ClearFailureReason() { + m.failure_reason = nil + m.clearedFields[userloginlog.FieldFailureReason] = struct{}{} +} + +// FailureReasonCleared returns if the "failure_reason" field was cleared in this mutation. +func (m *UserLoginLogMutation) FailureReasonCleared() bool { + _, ok := m.clearedFields[userloginlog.FieldFailureReason] + return ok +} + +// ResetFailureReason resets all changes to the "failure_reason" field. +func (m *UserLoginLogMutation) ResetFailureReason() { + m.failure_reason = nil + delete(m.clearedFields, userloginlog.FieldFailureReason) +} + +// SetSessionID sets the "session_id" field. +func (m *UserLoginLogMutation) SetSessionID(s string) { + m.session_id = &s +} + +// SessionID returns the value of the "session_id" field in the mutation. +func (m *UserLoginLogMutation) SessionID() (r string, exists bool) { + v := m.session_id + if v == nil { + return + } + return *v, true +} + +// OldSessionID returns the old "session_id" field's value of the UserLoginLog entity. +// If the UserLoginLog 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 *UserLoginLogMutation) OldSessionID(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSessionID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSessionID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSessionID: %w", err) + } + return oldValue.SessionID, nil +} + +// ClearSessionID clears the value of the "session_id" field. +func (m *UserLoginLogMutation) ClearSessionID() { + m.session_id = nil + m.clearedFields[userloginlog.FieldSessionID] = struct{}{} +} + +// SessionIDCleared returns if the "session_id" field was cleared in this mutation. +func (m *UserLoginLogMutation) SessionIDCleared() bool { + _, ok := m.clearedFields[userloginlog.FieldSessionID] + return ok +} + +// ResetSessionID resets all changes to the "session_id" field. +func (m *UserLoginLogMutation) ResetSessionID() { + m.session_id = nil + delete(m.clearedFields, userloginlog.FieldSessionID) +} + +// SetLatencyMs sets the "latency_ms" field. +func (m *UserLoginLogMutation) SetLatencyMs(i int) { + m.latency_ms = &i + m.addlatency_ms = nil +} + +// LatencyMs returns the value of the "latency_ms" field in the mutation. +func (m *UserLoginLogMutation) LatencyMs() (r int, exists bool) { + v := m.latency_ms + if v == nil { + return + } + return *v, true +} + +// OldLatencyMs returns the old "latency_ms" field's value of the UserLoginLog entity. +// If the UserLoginLog 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 *UserLoginLogMutation) OldLatencyMs(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLatencyMs is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLatencyMs requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLatencyMs: %w", err) + } + return oldValue.LatencyMs, nil +} + +// AddLatencyMs adds i to the "latency_ms" field. +func (m *UserLoginLogMutation) AddLatencyMs(i int) { + if m.addlatency_ms != nil { + *m.addlatency_ms += i + } else { + m.addlatency_ms = &i + } +} + +// AddedLatencyMs returns the value that was added to the "latency_ms" field in this mutation. +func (m *UserLoginLogMutation) AddedLatencyMs() (r int, exists bool) { + v := m.addlatency_ms + if v == nil { + return + } + return *v, true +} + +// ClearLatencyMs clears the value of the "latency_ms" field. +func (m *UserLoginLogMutation) ClearLatencyMs() { + m.latency_ms = nil + m.addlatency_ms = nil + m.clearedFields[userloginlog.FieldLatencyMs] = struct{}{} +} + +// LatencyMsCleared returns if the "latency_ms" field was cleared in this mutation. +func (m *UserLoginLogMutation) LatencyMsCleared() bool { + _, ok := m.clearedFields[userloginlog.FieldLatencyMs] + return ok +} + +// ResetLatencyMs resets all changes to the "latency_ms" field. +func (m *UserLoginLogMutation) ResetLatencyMs() { + m.latency_ms = nil + m.addlatency_ms = nil + delete(m.clearedFields, userloginlog.FieldLatencyMs) +} + +// SetAuthID sets the "auth_id" field. +func (m *UserLoginLogMutation) SetAuthID(u uint64) { + m.auth_id = &u + m.addauth_id = nil +} + +// AuthID returns the value of the "auth_id" field in the mutation. +func (m *UserLoginLogMutation) AuthID() (r uint64, exists bool) { + v := m.auth_id + if v == nil { + return + } + return *v, true +} + +// OldAuthID returns the old "auth_id" field's value of the UserLoginLog entity. +// If the UserLoginLog 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 *UserLoginLogMutation) OldAuthID(ctx context.Context) (v uint64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAuthID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAuthID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAuthID: %w", err) + } + return oldValue.AuthID, nil +} + +// AddAuthID adds u to the "auth_id" field. +func (m *UserLoginLogMutation) AddAuthID(u int64) { + if m.addauth_id != nil { + *m.addauth_id += u + } else { + m.addauth_id = &u + } +} + +// AddedAuthID returns the value that was added to the "auth_id" field in this mutation. +func (m *UserLoginLogMutation) AddedAuthID() (r int64, exists bool) { + v := m.addauth_id + if v == nil { + return + } + return *v, true +} + +// ClearAuthID clears the value of the "auth_id" field. +func (m *UserLoginLogMutation) ClearAuthID() { + m.auth_id = nil + m.addauth_id = nil + m.clearedFields[userloginlog.FieldAuthID] = struct{}{} +} + +// AuthIDCleared returns if the "auth_id" field was cleared in this mutation. +func (m *UserLoginLogMutation) AuthIDCleared() bool { + _, ok := m.clearedFields[userloginlog.FieldAuthID] + return ok +} + +// ResetAuthID resets all changes to the "auth_id" field. +func (m *UserLoginLogMutation) ResetAuthID() { + m.auth_id = nil + m.addauth_id = nil + delete(m.clearedFields, userloginlog.FieldAuthID) +} + +// SetAdditionalData sets the "additional_data" field. +func (m *UserLoginLogMutation) SetAdditionalData(value map[string]interface{}) { + m.additional_data = &value +} + +// AdditionalData returns the value of the "additional_data" field in the mutation. +func (m *UserLoginLogMutation) AdditionalData() (r map[string]interface{}, exists bool) { + v := m.additional_data + if v == nil { + return + } + return *v, true +} + +// OldAdditionalData returns the old "additional_data" field's value of the UserLoginLog entity. +// If the UserLoginLog 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 *UserLoginLogMutation) OldAdditionalData(ctx context.Context) (v map[string]interface{}, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAdditionalData is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAdditionalData requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAdditionalData: %w", err) + } + return oldValue.AdditionalData, nil +} + +// ClearAdditionalData clears the value of the "additional_data" field. +func (m *UserLoginLogMutation) ClearAdditionalData() { + m.additional_data = nil + m.clearedFields[userloginlog.FieldAdditionalData] = struct{}{} +} + +// AdditionalDataCleared returns if the "additional_data" field was cleared in this mutation. +func (m *UserLoginLogMutation) AdditionalDataCleared() bool { + _, ok := m.clearedFields[userloginlog.FieldAdditionalData] + return ok +} + +// ResetAdditionalData resets all changes to the "additional_data" field. +func (m *UserLoginLogMutation) ResetAdditionalData() { + m.additional_data = nil + delete(m.clearedFields, userloginlog.FieldAdditionalData) +} + +// Where appends a list predicates to the UserLoginLogMutation builder. +func (m *UserLoginLogMutation) Where(ps ...predicate.UserLoginLog) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the UserLoginLogMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *UserLoginLogMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.UserLoginLog, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *UserLoginLogMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *UserLoginLogMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (UserLoginLog). +func (m *UserLoginLogMutation) 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 *UserLoginLogMutation) Fields() []string { + fields := make([]string, 0, 17) + if m.created_at != nil { + fields = append(fields, userloginlog.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, userloginlog.FieldUpdatedAt) + } + if m.status != nil { + fields = append(fields, userloginlog.FieldStatus) + } + if m.tenant_id != nil { + fields = append(fields, userloginlog.FieldTenantID) + } + if m.deleted_at != nil { + fields = append(fields, userloginlog.FieldDeletedAt) + } + if m.user_id != nil { + fields = append(fields, userloginlog.FieldUserID) + } + if m.login_time != nil { + fields = append(fields, userloginlog.FieldLoginTime) + } + if m.login_ip != nil { + fields = append(fields, userloginlog.FieldLoginIP) + } + if m.login_location != nil { + fields = append(fields, userloginlog.FieldLoginLocation) + } + if m.login_type != nil { + fields = append(fields, userloginlog.FieldLoginType) + } + if m.login_platform != nil { + fields = append(fields, userloginlog.FieldLoginPlatform) + } + if m.login_result != nil { + fields = append(fields, userloginlog.FieldLoginResult) + } + if m.failure_reason != nil { + fields = append(fields, userloginlog.FieldFailureReason) + } + if m.session_id != nil { + fields = append(fields, userloginlog.FieldSessionID) + } + if m.latency_ms != nil { + fields = append(fields, userloginlog.FieldLatencyMs) + } + if m.auth_id != nil { + fields = append(fields, userloginlog.FieldAuthID) + } + if m.additional_data != nil { + fields = append(fields, userloginlog.FieldAdditionalData) + } + 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 *UserLoginLogMutation) Field(name string) (ent.Value, bool) { + switch name { + case userloginlog.FieldCreatedAt: + return m.CreatedAt() + case userloginlog.FieldUpdatedAt: + return m.UpdatedAt() + case userloginlog.FieldStatus: + return m.Status() + case userloginlog.FieldTenantID: + return m.TenantID() + case userloginlog.FieldDeletedAt: + return m.DeletedAt() + case userloginlog.FieldUserID: + return m.UserID() + case userloginlog.FieldLoginTime: + return m.LoginTime() + case userloginlog.FieldLoginIP: + return m.LoginIP() + case userloginlog.FieldLoginLocation: + return m.LoginLocation() + case userloginlog.FieldLoginType: + return m.LoginType() + case userloginlog.FieldLoginPlatform: + return m.LoginPlatform() + case userloginlog.FieldLoginResult: + return m.LoginResult() + case userloginlog.FieldFailureReason: + return m.FailureReason() + case userloginlog.FieldSessionID: + return m.SessionID() + case userloginlog.FieldLatencyMs: + return m.LatencyMs() + case userloginlog.FieldAuthID: + return m.AuthID() + case userloginlog.FieldAdditionalData: + return m.AdditionalData() + } + 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 *UserLoginLogMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case userloginlog.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case userloginlog.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + case userloginlog.FieldStatus: + return m.OldStatus(ctx) + case userloginlog.FieldTenantID: + return m.OldTenantID(ctx) + case userloginlog.FieldDeletedAt: + return m.OldDeletedAt(ctx) + case userloginlog.FieldUserID: + return m.OldUserID(ctx) + case userloginlog.FieldLoginTime: + return m.OldLoginTime(ctx) + case userloginlog.FieldLoginIP: + return m.OldLoginIP(ctx) + case userloginlog.FieldLoginLocation: + return m.OldLoginLocation(ctx) + case userloginlog.FieldLoginType: + return m.OldLoginType(ctx) + case userloginlog.FieldLoginPlatform: + return m.OldLoginPlatform(ctx) + case userloginlog.FieldLoginResult: + return m.OldLoginResult(ctx) + case userloginlog.FieldFailureReason: + return m.OldFailureReason(ctx) + case userloginlog.FieldSessionID: + return m.OldSessionID(ctx) + case userloginlog.FieldLatencyMs: + return m.OldLatencyMs(ctx) + case userloginlog.FieldAuthID: + return m.OldAuthID(ctx) + case userloginlog.FieldAdditionalData: + return m.OldAdditionalData(ctx) + } + return nil, fmt.Errorf("unknown UserLoginLog 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 *UserLoginLogMutation) SetField(name string, value ent.Value) error { + switch name { + case userloginlog.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 userloginlog.FieldUpdatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdatedAt(v) + return nil + case userloginlog.FieldStatus: + v, ok := value.(uint8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStatus(v) + return nil + case userloginlog.FieldTenantID: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTenantID(v) + return nil + case userloginlog.FieldDeletedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeletedAt(v) + return nil + case userloginlog.FieldUserID: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUserID(v) + return nil + case userloginlog.FieldLoginTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLoginTime(v) + return nil + case userloginlog.FieldLoginIP: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLoginIP(v) + return nil + case userloginlog.FieldLoginLocation: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLoginLocation(v) + return nil + case userloginlog.FieldLoginType: + v, ok := value.(userloginlog.LoginType) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLoginType(v) + return nil + case userloginlog.FieldLoginPlatform: + v, ok := value.(userloginlog.LoginPlatform) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLoginPlatform(v) + return nil + case userloginlog.FieldLoginResult: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLoginResult(v) + return nil + case userloginlog.FieldFailureReason: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetFailureReason(v) + return nil + case userloginlog.FieldSessionID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSessionID(v) + return nil + case userloginlog.FieldLatencyMs: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLatencyMs(v) + return nil + case userloginlog.FieldAuthID: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAuthID(v) + return nil + case userloginlog.FieldAdditionalData: + v, ok := value.(map[string]interface{}) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAdditionalData(v) + return nil + } + return fmt.Errorf("unknown UserLoginLog field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *UserLoginLogMutation) AddedFields() []string { + var fields []string + if m.addstatus != nil { + fields = append(fields, userloginlog.FieldStatus) + } + if m.addtenant_id != nil { + fields = append(fields, userloginlog.FieldTenantID) + } + if m.adduser_id != nil { + fields = append(fields, userloginlog.FieldUserID) + } + if m.addlatency_ms != nil { + fields = append(fields, userloginlog.FieldLatencyMs) + } + if m.addauth_id != nil { + fields = append(fields, userloginlog.FieldAuthID) + } + 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 *UserLoginLogMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case userloginlog.FieldStatus: + return m.AddedStatus() + case userloginlog.FieldTenantID: + return m.AddedTenantID() + case userloginlog.FieldUserID: + return m.AddedUserID() + case userloginlog.FieldLatencyMs: + return m.AddedLatencyMs() + case userloginlog.FieldAuthID: + return m.AddedAuthID() + } + 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 *UserLoginLogMutation) AddField(name string, value ent.Value) error { + switch name { + case userloginlog.FieldStatus: + v, ok := value.(int8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddStatus(v) + return nil + case userloginlog.FieldTenantID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddTenantID(v) + return nil + case userloginlog.FieldUserID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddUserID(v) + return nil + case userloginlog.FieldLatencyMs: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddLatencyMs(v) + return nil + case userloginlog.FieldAuthID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddAuthID(v) + return nil + } + return fmt.Errorf("unknown UserLoginLog numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *UserLoginLogMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(userloginlog.FieldStatus) { + fields = append(fields, userloginlog.FieldStatus) + } + if m.FieldCleared(userloginlog.FieldDeletedAt) { + fields = append(fields, userloginlog.FieldDeletedAt) + } + if m.FieldCleared(userloginlog.FieldLoginLocation) { + fields = append(fields, userloginlog.FieldLoginLocation) + } + if m.FieldCleared(userloginlog.FieldFailureReason) { + fields = append(fields, userloginlog.FieldFailureReason) + } + if m.FieldCleared(userloginlog.FieldSessionID) { + fields = append(fields, userloginlog.FieldSessionID) + } + if m.FieldCleared(userloginlog.FieldLatencyMs) { + fields = append(fields, userloginlog.FieldLatencyMs) + } + if m.FieldCleared(userloginlog.FieldAuthID) { + fields = append(fields, userloginlog.FieldAuthID) + } + if m.FieldCleared(userloginlog.FieldAdditionalData) { + fields = append(fields, userloginlog.FieldAdditionalData) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *UserLoginLogMutation) 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 *UserLoginLogMutation) ClearField(name string) error { + switch name { + case userloginlog.FieldStatus: + m.ClearStatus() + return nil + case userloginlog.FieldDeletedAt: + m.ClearDeletedAt() + return nil + case userloginlog.FieldLoginLocation: + m.ClearLoginLocation() + return nil + case userloginlog.FieldFailureReason: + m.ClearFailureReason() + return nil + case userloginlog.FieldSessionID: + m.ClearSessionID() + return nil + case userloginlog.FieldLatencyMs: + m.ClearLatencyMs() + return nil + case userloginlog.FieldAuthID: + m.ClearAuthID() + return nil + case userloginlog.FieldAdditionalData: + m.ClearAdditionalData() + return nil + } + return fmt.Errorf("unknown UserLoginLog 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 *UserLoginLogMutation) ResetField(name string) error { + switch name { + case userloginlog.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case userloginlog.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + case userloginlog.FieldStatus: + m.ResetStatus() + return nil + case userloginlog.FieldTenantID: + m.ResetTenantID() + return nil + case userloginlog.FieldDeletedAt: + m.ResetDeletedAt() + return nil + case userloginlog.FieldUserID: + m.ResetUserID() + return nil + case userloginlog.FieldLoginTime: + m.ResetLoginTime() + return nil + case userloginlog.FieldLoginIP: + m.ResetLoginIP() + return nil + case userloginlog.FieldLoginLocation: + m.ResetLoginLocation() + return nil + case userloginlog.FieldLoginType: + m.ResetLoginType() + return nil + case userloginlog.FieldLoginPlatform: + m.ResetLoginPlatform() + return nil + case userloginlog.FieldLoginResult: + m.ResetLoginResult() + return nil + case userloginlog.FieldFailureReason: + m.ResetFailureReason() + return nil + case userloginlog.FieldSessionID: + m.ResetSessionID() + return nil + case userloginlog.FieldLatencyMs: + m.ResetLatencyMs() + return nil + case userloginlog.FieldAuthID: + m.ResetAuthID() + return nil + case userloginlog.FieldAdditionalData: + m.ResetAdditionalData() + return nil + } + return fmt.Errorf("unknown UserLoginLog field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *UserLoginLogMutation) AddedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *UserLoginLogMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *UserLoginLogMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *UserLoginLogMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *UserLoginLogMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *UserLoginLogMutation) EdgeCleared(name string) bool { + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *UserLoginLogMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown UserLoginLog 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 *UserLoginLogMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown UserLoginLog edge %s", name) +} + +// UserThirdAuthMutation represents an operation that mutates the UserThirdAuth nodes in the graph. +type UserThirdAuthMutation struct { + config + op Op + typ string + id *uint64 + created_at *time.Time + updated_at *time.Time + status *uint8 + addstatus *int8 + tenant_id *uint64 + addtenant_id *int64 + deleted_at *time.Time + user_id *uint64 + adduser_id *int64 + openid *string + unionid *string + access_token *string + refresh_token *string + access_token_expiry *time.Time + user_info *map[string]interface{} + platform_user_id *string + nickname *string + avatar *string + email *string + phone *string + is_bound *bool + bound_at *time.Time + extra_data *map[string]interface{} + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*UserThirdAuth, error) + predicates []predicate.UserThirdAuth +} + +var _ ent.Mutation = (*UserThirdAuthMutation)(nil) + +// userthirdauthOption allows management of the mutation configuration using functional options. +type userthirdauthOption func(*UserThirdAuthMutation) + +// newUserThirdAuthMutation creates new mutation for the UserThirdAuth entity. +func newUserThirdAuthMutation(c config, op Op, opts ...userthirdauthOption) *UserThirdAuthMutation { + m := &UserThirdAuthMutation{ + config: c, + op: op, + typ: TypeUserThirdAuth, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withUserThirdAuthID sets the ID field of the mutation. +func withUserThirdAuthID(id uint64) userthirdauthOption { + return func(m *UserThirdAuthMutation) { + var ( + err error + once sync.Once + value *UserThirdAuth + ) + m.oldValue = func(ctx context.Context) (*UserThirdAuth, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().UserThirdAuth.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withUserThirdAuth sets the old UserThirdAuth of the mutation. +func withUserThirdAuth(node *UserThirdAuth) userthirdauthOption { + return func(m *UserThirdAuthMutation) { + m.oldValue = func(context.Context) (*UserThirdAuth, 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 UserThirdAuthMutation) 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 UserThirdAuthMutation) 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 UserThirdAuth entities. +func (m *UserThirdAuthMutation) SetID(id uint64) { + 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 *UserThirdAuthMutation) ID() (id uint64, 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 *UserThirdAuthMutation) IDs(ctx context.Context) ([]uint64, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []uint64{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().UserThirdAuth.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetCreatedAt sets the "created_at" field. +func (m *UserThirdAuthMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *UserThirdAuthMutation) 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 UserThirdAuth entity. +// If the UserThirdAuth 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 *UserThirdAuthMutation) 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 *UserThirdAuthMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *UserThirdAuthMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *UserThirdAuthMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at + if v == nil { + return + } + return *v, true +} + +// OldUpdatedAt returns the old "updated_at" field's value of the UserThirdAuth entity. +// If the UserThirdAuth 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 *UserThirdAuthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + } + return oldValue.UpdatedAt, nil +} + +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *UserThirdAuthMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// SetStatus sets the "status" field. +func (m *UserThirdAuthMutation) SetStatus(u uint8) { + m.status = &u + m.addstatus = nil +} + +// Status returns the value of the "status" field in the mutation. +func (m *UserThirdAuthMutation) Status() (r uint8, exists bool) { + v := m.status + if v == nil { + return + } + return *v, true +} + +// OldStatus returns the old "status" field's value of the UserThirdAuth entity. +// If the UserThirdAuth 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 *UserThirdAuthMutation) OldStatus(ctx context.Context) (v uint8, 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 u to the "status" field. +func (m *UserThirdAuthMutation) AddStatus(u int8) { + if m.addstatus != nil { + *m.addstatus += u + } else { + m.addstatus = &u + } +} + +// AddedStatus returns the value that was added to the "status" field in this mutation. +func (m *UserThirdAuthMutation) 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 *UserThirdAuthMutation) ClearStatus() { + m.status = nil + m.addstatus = nil + m.clearedFields[userthirdauth.FieldStatus] = struct{}{} +} + +// StatusCleared returns if the "status" field was cleared in this mutation. +func (m *UserThirdAuthMutation) StatusCleared() bool { + _, ok := m.clearedFields[userthirdauth.FieldStatus] + return ok +} + +// ResetStatus resets all changes to the "status" field. +func (m *UserThirdAuthMutation) ResetStatus() { + m.status = nil + m.addstatus = nil + delete(m.clearedFields, userthirdauth.FieldStatus) +} + +// SetTenantID sets the "tenant_id" field. +func (m *UserThirdAuthMutation) SetTenantID(u uint64) { + m.tenant_id = &u + m.addtenant_id = nil +} + +// TenantID returns the value of the "tenant_id" field in the mutation. +func (m *UserThirdAuthMutation) TenantID() (r uint64, exists bool) { + v := m.tenant_id + if v == nil { + return + } + return *v, true +} + +// OldTenantID returns the old "tenant_id" field's value of the UserThirdAuth entity. +// If the UserThirdAuth 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 *UserThirdAuthMutation) OldTenantID(ctx context.Context) (v uint64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTenantID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTenantID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTenantID: %w", err) + } + return oldValue.TenantID, nil +} + +// AddTenantID adds u to the "tenant_id" field. +func (m *UserThirdAuthMutation) AddTenantID(u int64) { + if m.addtenant_id != nil { + *m.addtenant_id += u + } else { + m.addtenant_id = &u + } +} + +// AddedTenantID returns the value that was added to the "tenant_id" field in this mutation. +func (m *UserThirdAuthMutation) AddedTenantID() (r int64, exists bool) { + v := m.addtenant_id + if v == nil { + return + } + return *v, true +} + +// ResetTenantID resets all changes to the "tenant_id" field. +func (m *UserThirdAuthMutation) ResetTenantID() { + m.tenant_id = nil + m.addtenant_id = nil +} + +// SetDeletedAt sets the "deleted_at" field. +func (m *UserThirdAuthMutation) SetDeletedAt(t time.Time) { + m.deleted_at = &t +} + +// DeletedAt returns the value of the "deleted_at" field in the mutation. +func (m *UserThirdAuthMutation) DeletedAt() (r time.Time, exists bool) { + v := m.deleted_at + if v == nil { + return + } + return *v, true +} + +// OldDeletedAt returns the old "deleted_at" field's value of the UserThirdAuth entity. +// If the UserThirdAuth 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 *UserThirdAuthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeletedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) + } + return oldValue.DeletedAt, nil +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (m *UserThirdAuthMutation) ClearDeletedAt() { + m.deleted_at = nil + m.clearedFields[userthirdauth.FieldDeletedAt] = struct{}{} +} + +// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. +func (m *UserThirdAuthMutation) DeletedAtCleared() bool { + _, ok := m.clearedFields[userthirdauth.FieldDeletedAt] + return ok +} + +// ResetDeletedAt resets all changes to the "deleted_at" field. +func (m *UserThirdAuthMutation) ResetDeletedAt() { + m.deleted_at = nil + delete(m.clearedFields, userthirdauth.FieldDeletedAt) +} + +// SetUserID sets the "user_id" field. +func (m *UserThirdAuthMutation) SetUserID(u uint64) { + m.user_id = &u + m.adduser_id = nil +} + +// UserID returns the value of the "user_id" field in the mutation. +func (m *UserThirdAuthMutation) UserID() (r uint64, exists bool) { + v := m.user_id + if v == nil { + return + } + return *v, true +} + +// OldUserID returns the old "user_id" field's value of the UserThirdAuth entity. +// If the UserThirdAuth 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 *UserThirdAuthMutation) OldUserID(ctx context.Context) (v uint64, 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 +} + +// AddUserID adds u to the "user_id" field. +func (m *UserThirdAuthMutation) AddUserID(u int64) { + if m.adduser_id != nil { + *m.adduser_id += u + } else { + m.adduser_id = &u + } +} + +// AddedUserID returns the value that was added to the "user_id" field in this mutation. +func (m *UserThirdAuthMutation) AddedUserID() (r int64, exists bool) { + v := m.adduser_id + if v == nil { + return + } + return *v, true +} + +// ResetUserID resets all changes to the "user_id" field. +func (m *UserThirdAuthMutation) ResetUserID() { + m.user_id = nil + m.adduser_id = nil +} + +// SetOpenid sets the "openid" field. +func (m *UserThirdAuthMutation) SetOpenid(s string) { + m.openid = &s +} + +// Openid returns the value of the "openid" field in the mutation. +func (m *UserThirdAuthMutation) Openid() (r string, exists bool) { + v := m.openid + if v == nil { + return + } + return *v, true +} + +// OldOpenid returns the old "openid" field's value of the UserThirdAuth entity. +// If the UserThirdAuth 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 *UserThirdAuthMutation) 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 "openid" field. +func (m *UserThirdAuthMutation) ResetOpenid() { + m.openid = nil +} + +// SetUnionid sets the "unionid" field. +func (m *UserThirdAuthMutation) SetUnionid(s string) { + m.unionid = &s +} + +// Unionid returns the value of the "unionid" field in the mutation. +func (m *UserThirdAuthMutation) Unionid() (r string, exists bool) { + v := m.unionid + if v == nil { + return + } + return *v, true +} + +// OldUnionid returns the old "unionid" field's value of the UserThirdAuth entity. +// If the UserThirdAuth 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 *UserThirdAuthMutation) OldUnionid(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUnionid is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUnionid requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUnionid: %w", err) + } + return oldValue.Unionid, nil +} + +// ClearUnionid clears the value of the "unionid" field. +func (m *UserThirdAuthMutation) ClearUnionid() { + m.unionid = nil + m.clearedFields[userthirdauth.FieldUnionid] = struct{}{} +} + +// UnionidCleared returns if the "unionid" field was cleared in this mutation. +func (m *UserThirdAuthMutation) UnionidCleared() bool { + _, ok := m.clearedFields[userthirdauth.FieldUnionid] + return ok +} + +// ResetUnionid resets all changes to the "unionid" field. +func (m *UserThirdAuthMutation) ResetUnionid() { + m.unionid = nil + delete(m.clearedFields, userthirdauth.FieldUnionid) +} + +// SetAccessToken sets the "access_token" field. +func (m *UserThirdAuthMutation) SetAccessToken(s string) { + m.access_token = &s +} + +// AccessToken returns the value of the "access_token" field in the mutation. +func (m *UserThirdAuthMutation) AccessToken() (r string, exists bool) { + v := m.access_token + if v == nil { + return + } + return *v, true +} + +// OldAccessToken returns the old "access_token" field's value of the UserThirdAuth entity. +// If the UserThirdAuth 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 *UserThirdAuthMutation) OldAccessToken(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAccessToken is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAccessToken requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAccessToken: %w", err) + } + return oldValue.AccessToken, nil +} + +// ClearAccessToken clears the value of the "access_token" field. +func (m *UserThirdAuthMutation) ClearAccessToken() { + m.access_token = nil + m.clearedFields[userthirdauth.FieldAccessToken] = struct{}{} +} + +// AccessTokenCleared returns if the "access_token" field was cleared in this mutation. +func (m *UserThirdAuthMutation) AccessTokenCleared() bool { + _, ok := m.clearedFields[userthirdauth.FieldAccessToken] + return ok +} + +// ResetAccessToken resets all changes to the "access_token" field. +func (m *UserThirdAuthMutation) ResetAccessToken() { + m.access_token = nil + delete(m.clearedFields, userthirdauth.FieldAccessToken) +} + +// SetRefreshToken sets the "refresh_token" field. +func (m *UserThirdAuthMutation) SetRefreshToken(s string) { + m.refresh_token = &s +} + +// RefreshToken returns the value of the "refresh_token" field in the mutation. +func (m *UserThirdAuthMutation) RefreshToken() (r string, exists bool) { + v := m.refresh_token + if v == nil { + return + } + return *v, true +} + +// OldRefreshToken returns the old "refresh_token" field's value of the UserThirdAuth entity. +// If the UserThirdAuth 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 *UserThirdAuthMutation) OldRefreshToken(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRefreshToken is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRefreshToken requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRefreshToken: %w", err) + } + return oldValue.RefreshToken, nil +} + +// ClearRefreshToken clears the value of the "refresh_token" field. +func (m *UserThirdAuthMutation) ClearRefreshToken() { + m.refresh_token = nil + m.clearedFields[userthirdauth.FieldRefreshToken] = struct{}{} +} + +// RefreshTokenCleared returns if the "refresh_token" field was cleared in this mutation. +func (m *UserThirdAuthMutation) RefreshTokenCleared() bool { + _, ok := m.clearedFields[userthirdauth.FieldRefreshToken] + return ok +} + +// ResetRefreshToken resets all changes to the "refresh_token" field. +func (m *UserThirdAuthMutation) ResetRefreshToken() { + m.refresh_token = nil + delete(m.clearedFields, userthirdauth.FieldRefreshToken) +} + +// SetAccessTokenExpiry sets the "access_token_expiry" field. +func (m *UserThirdAuthMutation) SetAccessTokenExpiry(t time.Time) { + m.access_token_expiry = &t +} + +// AccessTokenExpiry returns the value of the "access_token_expiry" field in the mutation. +func (m *UserThirdAuthMutation) AccessTokenExpiry() (r time.Time, exists bool) { + v := m.access_token_expiry + if v == nil { + return + } + return *v, true +} + +// OldAccessTokenExpiry returns the old "access_token_expiry" field's value of the UserThirdAuth entity. +// If the UserThirdAuth 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 *UserThirdAuthMutation) OldAccessTokenExpiry(ctx context.Context) (v *time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAccessTokenExpiry is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAccessTokenExpiry requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAccessTokenExpiry: %w", err) + } + return oldValue.AccessTokenExpiry, nil +} + +// ClearAccessTokenExpiry clears the value of the "access_token_expiry" field. +func (m *UserThirdAuthMutation) ClearAccessTokenExpiry() { + m.access_token_expiry = nil + m.clearedFields[userthirdauth.FieldAccessTokenExpiry] = struct{}{} +} + +// AccessTokenExpiryCleared returns if the "access_token_expiry" field was cleared in this mutation. +func (m *UserThirdAuthMutation) AccessTokenExpiryCleared() bool { + _, ok := m.clearedFields[userthirdauth.FieldAccessTokenExpiry] + return ok +} + +// ResetAccessTokenExpiry resets all changes to the "access_token_expiry" field. +func (m *UserThirdAuthMutation) ResetAccessTokenExpiry() { + m.access_token_expiry = nil + delete(m.clearedFields, userthirdauth.FieldAccessTokenExpiry) +} + +// SetUserInfo sets the "user_info" field. +func (m *UserThirdAuthMutation) SetUserInfo(value map[string]interface{}) { + m.user_info = &value +} + +// UserInfo returns the value of the "user_info" field in the mutation. +func (m *UserThirdAuthMutation) UserInfo() (r map[string]interface{}, exists bool) { + v := m.user_info + if v == nil { + return + } + return *v, true +} + +// OldUserInfo returns the old "user_info" field's value of the UserThirdAuth entity. +// If the UserThirdAuth 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 *UserThirdAuthMutation) OldUserInfo(ctx context.Context) (v map[string]interface{}, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUserInfo is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUserInfo requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUserInfo: %w", err) + } + return oldValue.UserInfo, nil +} + +// ClearUserInfo clears the value of the "user_info" field. +func (m *UserThirdAuthMutation) ClearUserInfo() { + m.user_info = nil + m.clearedFields[userthirdauth.FieldUserInfo] = struct{}{} +} + +// UserInfoCleared returns if the "user_info" field was cleared in this mutation. +func (m *UserThirdAuthMutation) UserInfoCleared() bool { + _, ok := m.clearedFields[userthirdauth.FieldUserInfo] + return ok +} + +// ResetUserInfo resets all changes to the "user_info" field. +func (m *UserThirdAuthMutation) ResetUserInfo() { + m.user_info = nil + delete(m.clearedFields, userthirdauth.FieldUserInfo) +} + +// SetPlatformUserID sets the "platform_user_id" field. +func (m *UserThirdAuthMutation) SetPlatformUserID(s string) { + m.platform_user_id = &s +} + +// PlatformUserID returns the value of the "platform_user_id" field in the mutation. +func (m *UserThirdAuthMutation) PlatformUserID() (r string, exists bool) { + v := m.platform_user_id + if v == nil { + return + } + return *v, true +} + +// OldPlatformUserID returns the old "platform_user_id" field's value of the UserThirdAuth entity. +// If the UserThirdAuth 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 *UserThirdAuthMutation) OldPlatformUserID(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPlatformUserID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPlatformUserID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPlatformUserID: %w", err) + } + return oldValue.PlatformUserID, nil +} + +// ClearPlatformUserID clears the value of the "platform_user_id" field. +func (m *UserThirdAuthMutation) ClearPlatformUserID() { + m.platform_user_id = nil + m.clearedFields[userthirdauth.FieldPlatformUserID] = struct{}{} +} + +// PlatformUserIDCleared returns if the "platform_user_id" field was cleared in this mutation. +func (m *UserThirdAuthMutation) PlatformUserIDCleared() bool { + _, ok := m.clearedFields[userthirdauth.FieldPlatformUserID] + return ok +} + +// ResetPlatformUserID resets all changes to the "platform_user_id" field. +func (m *UserThirdAuthMutation) ResetPlatformUserID() { + m.platform_user_id = nil + delete(m.clearedFields, userthirdauth.FieldPlatformUserID) +} + +// SetNickname sets the "nickname" field. +func (m *UserThirdAuthMutation) SetNickname(s string) { + m.nickname = &s +} + +// Nickname returns the value of the "nickname" field in the mutation. +func (m *UserThirdAuthMutation) 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 UserThirdAuth entity. +// If the UserThirdAuth 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 *UserThirdAuthMutation) 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 *UserThirdAuthMutation) ClearNickname() { + m.nickname = nil + m.clearedFields[userthirdauth.FieldNickname] = struct{}{} +} + +// NicknameCleared returns if the "nickname" field was cleared in this mutation. +func (m *UserThirdAuthMutation) NicknameCleared() bool { + _, ok := m.clearedFields[userthirdauth.FieldNickname] + return ok +} + +// ResetNickname resets all changes to the "nickname" field. +func (m *UserThirdAuthMutation) ResetNickname() { + m.nickname = nil + delete(m.clearedFields, userthirdauth.FieldNickname) +} + +// SetAvatar sets the "avatar" field. +func (m *UserThirdAuthMutation) SetAvatar(s string) { + m.avatar = &s +} + +// Avatar returns the value of the "avatar" field in the mutation. +func (m *UserThirdAuthMutation) 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 UserThirdAuth entity. +// If the UserThirdAuth 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 *UserThirdAuthMutation) 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 *UserThirdAuthMutation) ClearAvatar() { + m.avatar = nil + m.clearedFields[userthirdauth.FieldAvatar] = struct{}{} +} + +// AvatarCleared returns if the "avatar" field was cleared in this mutation. +func (m *UserThirdAuthMutation) AvatarCleared() bool { + _, ok := m.clearedFields[userthirdauth.FieldAvatar] + return ok +} + +// ResetAvatar resets all changes to the "avatar" field. +func (m *UserThirdAuthMutation) ResetAvatar() { + m.avatar = nil + delete(m.clearedFields, userthirdauth.FieldAvatar) +} + +// SetEmail sets the "email" field. +func (m *UserThirdAuthMutation) SetEmail(s string) { + m.email = &s +} + +// Email returns the value of the "email" field in the mutation. +func (m *UserThirdAuthMutation) 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 UserThirdAuth entity. +// If the UserThirdAuth 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 *UserThirdAuthMutation) 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 *UserThirdAuthMutation) ClearEmail() { + m.email = nil + m.clearedFields[userthirdauth.FieldEmail] = struct{}{} +} + +// EmailCleared returns if the "email" field was cleared in this mutation. +func (m *UserThirdAuthMutation) EmailCleared() bool { + _, ok := m.clearedFields[userthirdauth.FieldEmail] + return ok +} + +// ResetEmail resets all changes to the "email" field. +func (m *UserThirdAuthMutation) ResetEmail() { + m.email = nil + delete(m.clearedFields, userthirdauth.FieldEmail) +} + +// SetPhone sets the "phone" field. +func (m *UserThirdAuthMutation) SetPhone(s string) { + m.phone = &s +} + +// Phone returns the value of the "phone" field in the mutation. +func (m *UserThirdAuthMutation) 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 UserThirdAuth entity. +// If the UserThirdAuth 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 *UserThirdAuthMutation) 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 *UserThirdAuthMutation) ClearPhone() { + m.phone = nil + m.clearedFields[userthirdauth.FieldPhone] = struct{}{} +} + +// PhoneCleared returns if the "phone" field was cleared in this mutation. +func (m *UserThirdAuthMutation) PhoneCleared() bool { + _, ok := m.clearedFields[userthirdauth.FieldPhone] + return ok +} + +// ResetPhone resets all changes to the "phone" field. +func (m *UserThirdAuthMutation) ResetPhone() { + m.phone = nil + delete(m.clearedFields, userthirdauth.FieldPhone) +} + +// SetIsBound sets the "is_bound" field. +func (m *UserThirdAuthMutation) SetIsBound(b bool) { + m.is_bound = &b +} + +// IsBound returns the value of the "is_bound" field in the mutation. +func (m *UserThirdAuthMutation) IsBound() (r bool, exists bool) { + v := m.is_bound + if v == nil { + return + } + return *v, true +} + +// OldIsBound returns the old "is_bound" field's value of the UserThirdAuth entity. +// If the UserThirdAuth 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 *UserThirdAuthMutation) OldIsBound(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldIsBound is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldIsBound requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldIsBound: %w", err) + } + return oldValue.IsBound, nil +} + +// ResetIsBound resets all changes to the "is_bound" field. +func (m *UserThirdAuthMutation) ResetIsBound() { + m.is_bound = nil +} + +// SetBoundAt sets the "bound_at" field. +func (m *UserThirdAuthMutation) SetBoundAt(t time.Time) { + m.bound_at = &t +} + +// BoundAt returns the value of the "bound_at" field in the mutation. +func (m *UserThirdAuthMutation) BoundAt() (r time.Time, exists bool) { + v := m.bound_at + if v == nil { + return + } + return *v, true +} + +// OldBoundAt returns the old "bound_at" field's value of the UserThirdAuth entity. +// If the UserThirdAuth 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 *UserThirdAuthMutation) OldBoundAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldBoundAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldBoundAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldBoundAt: %w", err) + } + return oldValue.BoundAt, nil +} + +// ResetBoundAt resets all changes to the "bound_at" field. +func (m *UserThirdAuthMutation) ResetBoundAt() { + m.bound_at = nil +} + +// SetExtraData sets the "extra_data" field. +func (m *UserThirdAuthMutation) SetExtraData(value map[string]interface{}) { + m.extra_data = &value +} + +// ExtraData returns the value of the "extra_data" field in the mutation. +func (m *UserThirdAuthMutation) ExtraData() (r map[string]interface{}, exists bool) { + v := m.extra_data + if v == nil { + return + } + return *v, true +} + +// OldExtraData returns the old "extra_data" field's value of the UserThirdAuth entity. +// If the UserThirdAuth 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 *UserThirdAuthMutation) OldExtraData(ctx context.Context) (v map[string]interface{}, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldExtraData is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldExtraData requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldExtraData: %w", err) + } + return oldValue.ExtraData, nil +} + +// ClearExtraData clears the value of the "extra_data" field. +func (m *UserThirdAuthMutation) ClearExtraData() { + m.extra_data = nil + m.clearedFields[userthirdauth.FieldExtraData] = struct{}{} +} + +// ExtraDataCleared returns if the "extra_data" field was cleared in this mutation. +func (m *UserThirdAuthMutation) ExtraDataCleared() bool { + _, ok := m.clearedFields[userthirdauth.FieldExtraData] + return ok +} + +// ResetExtraData resets all changes to the "extra_data" field. +func (m *UserThirdAuthMutation) ResetExtraData() { + m.extra_data = nil + delete(m.clearedFields, userthirdauth.FieldExtraData) +} + +// Where appends a list predicates to the UserThirdAuthMutation builder. +func (m *UserThirdAuthMutation) Where(ps ...predicate.UserThirdAuth) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the UserThirdAuthMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *UserThirdAuthMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.UserThirdAuth, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *UserThirdAuthMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *UserThirdAuthMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (UserThirdAuth). +func (m *UserThirdAuthMutation) 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 *UserThirdAuthMutation) Fields() []string { + fields := make([]string, 0, 20) + if m.created_at != nil { + fields = append(fields, userthirdauth.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, userthirdauth.FieldUpdatedAt) + } + if m.status != nil { + fields = append(fields, userthirdauth.FieldStatus) + } + if m.tenant_id != nil { + fields = append(fields, userthirdauth.FieldTenantID) + } + if m.deleted_at != nil { + fields = append(fields, userthirdauth.FieldDeletedAt) + } + if m.user_id != nil { + fields = append(fields, userthirdauth.FieldUserID) + } + if m.openid != nil { + fields = append(fields, userthirdauth.FieldOpenid) + } + if m.unionid != nil { + fields = append(fields, userthirdauth.FieldUnionid) + } + if m.access_token != nil { + fields = append(fields, userthirdauth.FieldAccessToken) + } + if m.refresh_token != nil { + fields = append(fields, userthirdauth.FieldRefreshToken) + } + if m.access_token_expiry != nil { + fields = append(fields, userthirdauth.FieldAccessTokenExpiry) + } + if m.user_info != nil { + fields = append(fields, userthirdauth.FieldUserInfo) + } + if m.platform_user_id != nil { + fields = append(fields, userthirdauth.FieldPlatformUserID) + } + if m.nickname != nil { + fields = append(fields, userthirdauth.FieldNickname) + } + if m.avatar != nil { + fields = append(fields, userthirdauth.FieldAvatar) + } + if m.email != nil { + fields = append(fields, userthirdauth.FieldEmail) + } + if m.phone != nil { + fields = append(fields, userthirdauth.FieldPhone) + } + if m.is_bound != nil { + fields = append(fields, userthirdauth.FieldIsBound) + } + if m.bound_at != nil { + fields = append(fields, userthirdauth.FieldBoundAt) + } + if m.extra_data != nil { + fields = append(fields, userthirdauth.FieldExtraData) + } + 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 *UserThirdAuthMutation) Field(name string) (ent.Value, bool) { + switch name { + case userthirdauth.FieldCreatedAt: + return m.CreatedAt() + case userthirdauth.FieldUpdatedAt: + return m.UpdatedAt() + case userthirdauth.FieldStatus: + return m.Status() + case userthirdauth.FieldTenantID: + return m.TenantID() + case userthirdauth.FieldDeletedAt: + return m.DeletedAt() + case userthirdauth.FieldUserID: + return m.UserID() + case userthirdauth.FieldOpenid: + return m.Openid() + case userthirdauth.FieldUnionid: + return m.Unionid() + case userthirdauth.FieldAccessToken: + return m.AccessToken() + case userthirdauth.FieldRefreshToken: + return m.RefreshToken() + case userthirdauth.FieldAccessTokenExpiry: + return m.AccessTokenExpiry() + case userthirdauth.FieldUserInfo: + return m.UserInfo() + case userthirdauth.FieldPlatformUserID: + return m.PlatformUserID() + case userthirdauth.FieldNickname: + return m.Nickname() + case userthirdauth.FieldAvatar: + return m.Avatar() + case userthirdauth.FieldEmail: + return m.Email() + case userthirdauth.FieldPhone: + return m.Phone() + case userthirdauth.FieldIsBound: + return m.IsBound() + case userthirdauth.FieldBoundAt: + return m.BoundAt() + case userthirdauth.FieldExtraData: + return m.ExtraData() + } + 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 *UserThirdAuthMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case userthirdauth.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case userthirdauth.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + case userthirdauth.FieldStatus: + return m.OldStatus(ctx) + case userthirdauth.FieldTenantID: + return m.OldTenantID(ctx) + case userthirdauth.FieldDeletedAt: + return m.OldDeletedAt(ctx) + case userthirdauth.FieldUserID: + return m.OldUserID(ctx) + case userthirdauth.FieldOpenid: + return m.OldOpenid(ctx) + case userthirdauth.FieldUnionid: + return m.OldUnionid(ctx) + case userthirdauth.FieldAccessToken: + return m.OldAccessToken(ctx) + case userthirdauth.FieldRefreshToken: + return m.OldRefreshToken(ctx) + case userthirdauth.FieldAccessTokenExpiry: + return m.OldAccessTokenExpiry(ctx) + case userthirdauth.FieldUserInfo: + return m.OldUserInfo(ctx) + case userthirdauth.FieldPlatformUserID: + return m.OldPlatformUserID(ctx) + case userthirdauth.FieldNickname: + return m.OldNickname(ctx) + case userthirdauth.FieldAvatar: + return m.OldAvatar(ctx) + case userthirdauth.FieldEmail: + return m.OldEmail(ctx) + case userthirdauth.FieldPhone: + return m.OldPhone(ctx) + case userthirdauth.FieldIsBound: + return m.OldIsBound(ctx) + case userthirdauth.FieldBoundAt: + return m.OldBoundAt(ctx) + case userthirdauth.FieldExtraData: + return m.OldExtraData(ctx) + } + return nil, fmt.Errorf("unknown UserThirdAuth 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 *UserThirdAuthMutation) SetField(name string, value ent.Value) error { + switch name { + case userthirdauth.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 userthirdauth.FieldUpdatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdatedAt(v) + return nil + case userthirdauth.FieldStatus: + v, ok := value.(uint8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStatus(v) + return nil + case userthirdauth.FieldTenantID: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTenantID(v) + return nil + case userthirdauth.FieldDeletedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeletedAt(v) + return nil + case userthirdauth.FieldUserID: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUserID(v) + return nil + case userthirdauth.FieldOpenid: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetOpenid(v) + return nil + case userthirdauth.FieldUnionid: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUnionid(v) + return nil + case userthirdauth.FieldAccessToken: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAccessToken(v) + return nil + case userthirdauth.FieldRefreshToken: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRefreshToken(v) + return nil + case userthirdauth.FieldAccessTokenExpiry: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAccessTokenExpiry(v) + return nil + case userthirdauth.FieldUserInfo: + v, ok := value.(map[string]interface{}) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUserInfo(v) + return nil + case userthirdauth.FieldPlatformUserID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPlatformUserID(v) + return nil + case userthirdauth.FieldNickname: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetNickname(v) + return nil + case userthirdauth.FieldAvatar: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAvatar(v) + return nil + case userthirdauth.FieldEmail: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetEmail(v) + return nil + case userthirdauth.FieldPhone: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPhone(v) + return nil + case userthirdauth.FieldIsBound: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetIsBound(v) + return nil + case userthirdauth.FieldBoundAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetBoundAt(v) + return nil + case userthirdauth.FieldExtraData: + v, ok := value.(map[string]interface{}) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetExtraData(v) + return nil + } + return fmt.Errorf("unknown UserThirdAuth field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *UserThirdAuthMutation) AddedFields() []string { + var fields []string + if m.addstatus != nil { + fields = append(fields, userthirdauth.FieldStatus) + } + if m.addtenant_id != nil { + fields = append(fields, userthirdauth.FieldTenantID) + } + if m.adduser_id != nil { + fields = append(fields, userthirdauth.FieldUserID) + } + 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 *UserThirdAuthMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case userthirdauth.FieldStatus: + return m.AddedStatus() + case userthirdauth.FieldTenantID: + return m.AddedTenantID() + case userthirdauth.FieldUserID: + return m.AddedUserID() + } + 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 *UserThirdAuthMutation) AddField(name string, value ent.Value) error { + switch name { + case userthirdauth.FieldStatus: + v, ok := value.(int8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddStatus(v) + return nil + case userthirdauth.FieldTenantID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddTenantID(v) + return nil + case userthirdauth.FieldUserID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddUserID(v) + return nil + } + return fmt.Errorf("unknown UserThirdAuth numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *UserThirdAuthMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(userthirdauth.FieldStatus) { + fields = append(fields, userthirdauth.FieldStatus) + } + if m.FieldCleared(userthirdauth.FieldDeletedAt) { + fields = append(fields, userthirdauth.FieldDeletedAt) + } + if m.FieldCleared(userthirdauth.FieldUnionid) { + fields = append(fields, userthirdauth.FieldUnionid) + } + if m.FieldCleared(userthirdauth.FieldAccessToken) { + fields = append(fields, userthirdauth.FieldAccessToken) + } + if m.FieldCleared(userthirdauth.FieldRefreshToken) { + fields = append(fields, userthirdauth.FieldRefreshToken) + } + if m.FieldCleared(userthirdauth.FieldAccessTokenExpiry) { + fields = append(fields, userthirdauth.FieldAccessTokenExpiry) + } + if m.FieldCleared(userthirdauth.FieldUserInfo) { + fields = append(fields, userthirdauth.FieldUserInfo) + } + if m.FieldCleared(userthirdauth.FieldPlatformUserID) { + fields = append(fields, userthirdauth.FieldPlatformUserID) + } + if m.FieldCleared(userthirdauth.FieldNickname) { + fields = append(fields, userthirdauth.FieldNickname) + } + if m.FieldCleared(userthirdauth.FieldAvatar) { + fields = append(fields, userthirdauth.FieldAvatar) + } + if m.FieldCleared(userthirdauth.FieldEmail) { + fields = append(fields, userthirdauth.FieldEmail) + } + if m.FieldCleared(userthirdauth.FieldPhone) { + fields = append(fields, userthirdauth.FieldPhone) + } + if m.FieldCleared(userthirdauth.FieldExtraData) { + fields = append(fields, userthirdauth.FieldExtraData) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *UserThirdAuthMutation) 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 *UserThirdAuthMutation) ClearField(name string) error { + switch name { + case userthirdauth.FieldStatus: + m.ClearStatus() + return nil + case userthirdauth.FieldDeletedAt: + m.ClearDeletedAt() + return nil + case userthirdauth.FieldUnionid: + m.ClearUnionid() + return nil + case userthirdauth.FieldAccessToken: + m.ClearAccessToken() + return nil + case userthirdauth.FieldRefreshToken: + m.ClearRefreshToken() + return nil + case userthirdauth.FieldAccessTokenExpiry: + m.ClearAccessTokenExpiry() + return nil + case userthirdauth.FieldUserInfo: + m.ClearUserInfo() + return nil + case userthirdauth.FieldPlatformUserID: + m.ClearPlatformUserID() + return nil + case userthirdauth.FieldNickname: + m.ClearNickname() + return nil + case userthirdauth.FieldAvatar: + m.ClearAvatar() + return nil + case userthirdauth.FieldEmail: + m.ClearEmail() + return nil + case userthirdauth.FieldPhone: + m.ClearPhone() + return nil + case userthirdauth.FieldExtraData: + m.ClearExtraData() + return nil + } + return fmt.Errorf("unknown UserThirdAuth 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 *UserThirdAuthMutation) ResetField(name string) error { + switch name { + case userthirdauth.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case userthirdauth.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + case userthirdauth.FieldStatus: + m.ResetStatus() + return nil + case userthirdauth.FieldTenantID: + m.ResetTenantID() + return nil + case userthirdauth.FieldDeletedAt: + m.ResetDeletedAt() + return nil + case userthirdauth.FieldUserID: + m.ResetUserID() + return nil + case userthirdauth.FieldOpenid: + m.ResetOpenid() + return nil + case userthirdauth.FieldUnionid: + m.ResetUnionid() + return nil + case userthirdauth.FieldAccessToken: + m.ResetAccessToken() + return nil + case userthirdauth.FieldRefreshToken: + m.ResetRefreshToken() + return nil + case userthirdauth.FieldAccessTokenExpiry: + m.ResetAccessTokenExpiry() + return nil + case userthirdauth.FieldUserInfo: + m.ResetUserInfo() + return nil + case userthirdauth.FieldPlatformUserID: + m.ResetPlatformUserID() + return nil + case userthirdauth.FieldNickname: + m.ResetNickname() + return nil + case userthirdauth.FieldAvatar: + m.ResetAvatar() + return nil + case userthirdauth.FieldEmail: + m.ResetEmail() + return nil + case userthirdauth.FieldPhone: + m.ResetPhone() + return nil + case userthirdauth.FieldIsBound: + m.ResetIsBound() + return nil + case userthirdauth.FieldBoundAt: + m.ResetBoundAt() + return nil + case userthirdauth.FieldExtraData: + m.ResetExtraData() + return nil + } + return fmt.Errorf("unknown UserThirdAuth field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *UserThirdAuthMutation) AddedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *UserThirdAuthMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *UserThirdAuthMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *UserThirdAuthMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *UserThirdAuthMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *UserThirdAuthMutation) EdgeCleared(name string) bool { + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *UserThirdAuthMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown UserThirdAuth 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 *UserThirdAuthMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown UserThirdAuth edge %s", name) +} diff --git a/rpc/ent/pagination.go b/rpc/ent/pagination.go new file mode 100644 index 0000000..769db39 --- /dev/null +++ b/rpc/ent/pagination.go @@ -0,0 +1,300 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "mingyang-admin-app-rpc/ent/user" + "mingyang-admin-app-rpc/ent/userloginlog" + "mingyang-admin-app-rpc/ent/userthirdauth" +) + +const errInvalidPage = "INVALID_PAGE" + +const ( + listField = "list" + pageNumField = "pageNum" + pageSizeField = "pageSize" +) + +type PageDetails struct { + Page uint64 `json:"page"` + Size uint64 `json:"size"` + Total uint64 `json:"total"` +} + +// OrderDirection defines the directions in which to order a list of items. +type OrderDirection string + +const ( + // OrderDirectionAsc specifies an ascending order. + OrderDirectionAsc OrderDirection = "ASC" + // OrderDirectionDesc specifies a descending order. + OrderDirectionDesc OrderDirection = "DESC" +) + +// Validate the order direction value. +func (o OrderDirection) Validate() error { + if o != OrderDirectionAsc && o != OrderDirectionDesc { + return fmt.Errorf("%s is not a valid OrderDirection", o) + } + return nil +} + +// String implements fmt.Stringer interface. +func (o OrderDirection) String() string { + return string(o) +} + +func (o OrderDirection) reverse() OrderDirection { + if o == OrderDirectionDesc { + return OrderDirectionAsc + } + return OrderDirectionDesc +} + +const errInvalidPagination = "INVALID_PAGINATION" + +type UserPager struct { + Order user.OrderOption + Filter func(*UserQuery) (*UserQuery, error) +} + +// UserPaginateOption enables pagination customization. +type UserPaginateOption func(*UserPager) + +// DefaultUserOrder is the default ordering of User. +var DefaultUserOrder = Desc(user.FieldID) + +func newUserPager(opts []UserPaginateOption) (*UserPager, error) { + pager := &UserPager{} + for _, opt := range opts { + opt(pager) + } + if pager.Order == nil { + pager.Order = DefaultUserOrder + } + return pager, nil +} + +func (p *UserPager) ApplyFilter(query *UserQuery) (*UserQuery, error) { + if p.Filter != nil { + return p.Filter(query) + } + return query, nil +} + +// UserPageList is User PageList result. +type UserPageList struct { + List []*User `json:"list"` + PageDetails *PageDetails `json:"pageDetails"` +} + +func (_m *UserQuery) Page( + ctx context.Context, pageNum uint64, pageSize uint64, opts ...UserPaginateOption, +) (*UserPageList, error) { + + pager, err := newUserPager(opts) + if err != nil { + return nil, err + } + + if _m, err = pager.ApplyFilter(_m); err != nil { + return nil, err + } + + ret := &UserPageList{} + + ret.PageDetails = &PageDetails{ + Page: pageNum, + Size: pageSize, + } + + query := _m.Clone() + query.ctx.Fields = nil + count, err := query.Count(ctx) + + if err != nil { + return nil, err + } + + ret.PageDetails.Total = uint64(count) + + if pager.Order != nil { + _m = _m.Order(pager.Order) + } else { + _m = _m.Order(DefaultUserOrder) + } + + _m = _m.Offset(int((pageNum - 1) * pageSize)).Limit(int(pageSize)) + list, err := _m.All(ctx) + if err != nil { + return nil, err + } + ret.List = list + + return ret, nil +} + +type UserLoginLogPager struct { + Order userloginlog.OrderOption + Filter func(*UserLoginLogQuery) (*UserLoginLogQuery, error) +} + +// UserLoginLogPaginateOption enables pagination customization. +type UserLoginLogPaginateOption func(*UserLoginLogPager) + +// DefaultUserLoginLogOrder is the default ordering of UserLoginLog. +var DefaultUserLoginLogOrder = Desc(userloginlog.FieldID) + +func newUserLoginLogPager(opts []UserLoginLogPaginateOption) (*UserLoginLogPager, error) { + pager := &UserLoginLogPager{} + for _, opt := range opts { + opt(pager) + } + if pager.Order == nil { + pager.Order = DefaultUserLoginLogOrder + } + return pager, nil +} + +func (p *UserLoginLogPager) ApplyFilter(query *UserLoginLogQuery) (*UserLoginLogQuery, error) { + if p.Filter != nil { + return p.Filter(query) + } + return query, nil +} + +// UserLoginLogPageList is UserLoginLog PageList result. +type UserLoginLogPageList struct { + List []*UserLoginLog `json:"list"` + PageDetails *PageDetails `json:"pageDetails"` +} + +func (_m *UserLoginLogQuery) Page( + ctx context.Context, pageNum uint64, pageSize uint64, opts ...UserLoginLogPaginateOption, +) (*UserLoginLogPageList, error) { + + pager, err := newUserLoginLogPager(opts) + if err != nil { + return nil, err + } + + if _m, err = pager.ApplyFilter(_m); err != nil { + return nil, err + } + + ret := &UserLoginLogPageList{} + + ret.PageDetails = &PageDetails{ + Page: pageNum, + Size: pageSize, + } + + query := _m.Clone() + query.ctx.Fields = nil + count, err := query.Count(ctx) + + if err != nil { + return nil, err + } + + ret.PageDetails.Total = uint64(count) + + if pager.Order != nil { + _m = _m.Order(pager.Order) + } else { + _m = _m.Order(DefaultUserLoginLogOrder) + } + + _m = _m.Offset(int((pageNum - 1) * pageSize)).Limit(int(pageSize)) + list, err := _m.All(ctx) + if err != nil { + return nil, err + } + ret.List = list + + return ret, nil +} + +type UserThirdAuthPager struct { + Order userthirdauth.OrderOption + Filter func(*UserThirdAuthQuery) (*UserThirdAuthQuery, error) +} + +// UserThirdAuthPaginateOption enables pagination customization. +type UserThirdAuthPaginateOption func(*UserThirdAuthPager) + +// DefaultUserThirdAuthOrder is the default ordering of UserThirdAuth. +var DefaultUserThirdAuthOrder = Desc(userthirdauth.FieldID) + +func newUserThirdAuthPager(opts []UserThirdAuthPaginateOption) (*UserThirdAuthPager, error) { + pager := &UserThirdAuthPager{} + for _, opt := range opts { + opt(pager) + } + if pager.Order == nil { + pager.Order = DefaultUserThirdAuthOrder + } + return pager, nil +} + +func (p *UserThirdAuthPager) ApplyFilter(query *UserThirdAuthQuery) (*UserThirdAuthQuery, error) { + if p.Filter != nil { + return p.Filter(query) + } + return query, nil +} + +// UserThirdAuthPageList is UserThirdAuth PageList result. +type UserThirdAuthPageList struct { + List []*UserThirdAuth `json:"list"` + PageDetails *PageDetails `json:"pageDetails"` +} + +func (_m *UserThirdAuthQuery) Page( + ctx context.Context, pageNum uint64, pageSize uint64, opts ...UserThirdAuthPaginateOption, +) (*UserThirdAuthPageList, error) { + + pager, err := newUserThirdAuthPager(opts) + if err != nil { + return nil, err + } + + if _m, err = pager.ApplyFilter(_m); err != nil { + return nil, err + } + + ret := &UserThirdAuthPageList{} + + ret.PageDetails = &PageDetails{ + Page: pageNum, + Size: pageSize, + } + + query := _m.Clone() + query.ctx.Fields = nil + count, err := query.Count(ctx) + + if err != nil { + return nil, err + } + + ret.PageDetails.Total = uint64(count) + + if pager.Order != nil { + _m = _m.Order(pager.Order) + } else { + _m = _m.Order(DefaultUserThirdAuthOrder) + } + + _m = _m.Offset(int((pageNum - 1) * pageSize)).Limit(int(pageSize)) + list, err := _m.All(ctx) + if err != nil { + return nil, err + } + ret.List = list + + return ret, nil +} diff --git a/rpc/ent/predicate/predicate.go b/rpc/ent/predicate/predicate.go new file mode 100644 index 0000000..28c02db --- /dev/null +++ b/rpc/ent/predicate/predicate.go @@ -0,0 +1,16 @@ +// Code generated by ent, DO NOT EDIT. + +package predicate + +import ( + "entgo.io/ent/dialect/sql" +) + +// User is the predicate function for user builders. +type User func(*sql.Selector) + +// UserLoginLog is the predicate function for userloginlog builders. +type UserLoginLog func(*sql.Selector) + +// UserThirdAuth is the predicate function for userthirdauth builders. +type UserThirdAuth func(*sql.Selector) diff --git a/rpc/ent/runtime.go b/rpc/ent/runtime.go new file mode 100644 index 0000000..8db654b --- /dev/null +++ b/rpc/ent/runtime.go @@ -0,0 +1,284 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "mingyang-admin-app-rpc/ent/schema" + "mingyang-admin-app-rpc/ent/user" + "mingyang-admin-app-rpc/ent/userloginlog" + "mingyang-admin-app-rpc/ent/userthirdauth" + "time" +) + +// The init function reads all schema descriptors with runtime code.proto +// (default values, validators, hooks and policies) and stitches it +// to their package variables. +func init() { + userMixin := schema.User{}.Mixin() + userMixinFields0 := userMixin[0].Fields() + _ = userMixinFields0 + userMixinFields1 := userMixin[1].Fields() + _ = userMixinFields1 + userMixinFields2 := userMixin[2].Fields() + _ = userMixinFields2 + userFields := schema.User{}.Fields() + _ = userFields + // userDescCreatedAt is the schema descriptor for created_at field. + userDescCreatedAt := userMixinFields0[1].Descriptor() + // user.DefaultCreatedAt holds the default value on creation for the created_at field. + user.DefaultCreatedAt = userDescCreatedAt.Default.(func() time.Time) + // userDescUpdatedAt is the schema descriptor for updated_at field. + userDescUpdatedAt := userMixinFields0[2].Descriptor() + // user.DefaultUpdatedAt holds the default value on creation for the updated_at field. + user.DefaultUpdatedAt = userDescUpdatedAt.Default.(func() time.Time) + // user.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + user.UpdateDefaultUpdatedAt = userDescUpdatedAt.UpdateDefault.(func() time.Time) + // userDescStatus is the schema descriptor for status field. + userDescStatus := userMixinFields1[0].Descriptor() + // user.DefaultStatus holds the default value on creation for the status field. + user.DefaultStatus = userDescStatus.Default.(uint8) + // userDescTenantID is the schema descriptor for tenant_id field. + userDescTenantID := userMixinFields2[0].Descriptor() + // user.DefaultTenantID holds the default value on creation for the tenant_id field. + user.DefaultTenantID = userDescTenantID.Default.(uint64) + // userDescUsername is the schema descriptor for username field. + userDescUsername := userFields[0].Descriptor() + // user.UsernameValidator is a validator for the "username" field. It is called by the builders before save. + user.UsernameValidator = func() func(string) error { + validators := userDescUsername.Validators + fns := [...]func(string) error{ + validators[0].(func(string) error), + validators[1].(func(string) error), + validators[2].(func(string) error), + } + return func(username string) error { + for _, fn := range fns { + if err := fn(username); err != nil { + return err + } + } + return nil + } + }() + // userDescEmail is the schema descriptor for email field. + userDescEmail := userFields[1].Descriptor() + // user.EmailValidator is a validator for the "email" field. It is called by the builders before save. + user.EmailValidator = func() func(string) error { + validators := userDescEmail.Validators + fns := [...]func(string) error{ + validators[0].(func(string) error), + validators[1].(func(string) error), + validators[2].(func(string) error), + } + return func(email string) error { + for _, fn := range fns { + if err := fn(email); err != nil { + return err + } + } + return nil + } + }() + // userDescMobile is the schema descriptor for mobile field. + userDescMobile := userFields[2].Descriptor() + // user.MobileValidator is a validator for the "mobile" field. It is called by the builders before save. + user.MobileValidator = userDescMobile.Validators[0].(func(string) error) + // userDescPasswordHash is the schema descriptor for password_hash field. + userDescPasswordHash := userFields[3].Descriptor() + // user.PasswordHashValidator is a validator for the "password_hash" field. It is called by the builders before save. + user.PasswordHashValidator = userDescPasswordHash.Validators[0].(func(string) error) + // userDescSalt is the schema descriptor for salt field. + userDescSalt := userFields[4].Descriptor() + // user.SaltValidator is a validator for the "salt" field. It is called by the builders before save. + user.SaltValidator = func() func(string) error { + validators := userDescSalt.Validators + fns := [...]func(string) error{ + validators[0].(func(string) error), + validators[1].(func(string) error), + } + return func(salt string) error { + for _, fn := range fns { + if err := fn(salt); err != nil { + return err + } + } + return nil + } + }() + // userDescNickname is the schema descriptor for nickname field. + userDescNickname := userFields[5].Descriptor() + // user.DefaultNickname holds the default value on creation for the nickname field. + user.DefaultNickname = userDescNickname.Default.(string) + // user.NicknameValidator is a validator for the "nickname" field. It is called by the builders before save. + user.NicknameValidator = userDescNickname.Validators[0].(func(string) error) + // userDescAvatar is the schema descriptor for avatar field. + userDescAvatar := userFields[6].Descriptor() + // user.AvatarValidator is a validator for the "avatar" field. It is called by the builders before save. + user.AvatarValidator = userDescAvatar.Validators[0].(func(string) error) + // userDescIsVerified is the schema descriptor for is_verified field. + userDescIsVerified := userFields[10].Descriptor() + // user.DefaultIsVerified holds the default value on creation for the is_verified field. + user.DefaultIsVerified = userDescIsVerified.Default.(uint32) + // userDescRegisteredLoginIP is the schema descriptor for registered_login_ip field. + userDescRegisteredLoginIP := userFields[11].Descriptor() + // user.RegisteredLoginIPValidator is a validator for the "registered_login_ip" field. It is called by the builders before save. + user.RegisteredLoginIPValidator = userDescRegisteredLoginIP.Validators[0].(func(string) error) + // userDescLoginAttempts is the schema descriptor for login_attempts field. + userDescLoginAttempts := userFields[12].Descriptor() + // user.DefaultLoginAttempts holds the default value on creation for the login_attempts field. + user.DefaultLoginAttempts = userDescLoginAttempts.Default.(int64) + // userDescRegistrationSource is the schema descriptor for registration_source field. + userDescRegistrationSource := userFields[14].Descriptor() + // user.RegistrationSourceValidator is a validator for the "registration_source" field. It is called by the builders before save. + user.RegistrationSourceValidator = userDescRegistrationSource.Validators[0].(func(string) error) + userloginlogMixin := schema.UserLoginLog{}.Mixin() + userloginlogMixinFields0 := userloginlogMixin[0].Fields() + _ = userloginlogMixinFields0 + userloginlogMixinFields1 := userloginlogMixin[1].Fields() + _ = userloginlogMixinFields1 + userloginlogMixinFields2 := userloginlogMixin[2].Fields() + _ = userloginlogMixinFields2 + userloginlogFields := schema.UserLoginLog{}.Fields() + _ = userloginlogFields + // userloginlogDescCreatedAt is the schema descriptor for created_at field. + userloginlogDescCreatedAt := userloginlogMixinFields0[1].Descriptor() + // userloginlog.DefaultCreatedAt holds the default value on creation for the created_at field. + userloginlog.DefaultCreatedAt = userloginlogDescCreatedAt.Default.(func() time.Time) + // userloginlogDescUpdatedAt is the schema descriptor for updated_at field. + userloginlogDescUpdatedAt := userloginlogMixinFields0[2].Descriptor() + // userloginlog.DefaultUpdatedAt holds the default value on creation for the updated_at field. + userloginlog.DefaultUpdatedAt = userloginlogDescUpdatedAt.Default.(func() time.Time) + // userloginlog.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + userloginlog.UpdateDefaultUpdatedAt = userloginlogDescUpdatedAt.UpdateDefault.(func() time.Time) + // userloginlogDescStatus is the schema descriptor for status field. + userloginlogDescStatus := userloginlogMixinFields1[0].Descriptor() + // userloginlog.DefaultStatus holds the default value on creation for the status field. + userloginlog.DefaultStatus = userloginlogDescStatus.Default.(uint8) + // userloginlogDescTenantID is the schema descriptor for tenant_id field. + userloginlogDescTenantID := userloginlogMixinFields2[0].Descriptor() + // userloginlog.DefaultTenantID holds the default value on creation for the tenant_id field. + userloginlog.DefaultTenantID = userloginlogDescTenantID.Default.(uint64) + // userloginlogDescLoginTime is the schema descriptor for login_time field. + userloginlogDescLoginTime := userloginlogFields[1].Descriptor() + // userloginlog.DefaultLoginTime holds the default value on creation for the login_time field. + userloginlog.DefaultLoginTime = userloginlogDescLoginTime.Default.(func() time.Time) + // userloginlogDescLoginIP is the schema descriptor for login_ip field. + userloginlogDescLoginIP := userloginlogFields[2].Descriptor() + // userloginlog.LoginIPValidator is a validator for the "login_ip" field. It is called by the builders before save. + userloginlog.LoginIPValidator = func() func(string) error { + validators := userloginlogDescLoginIP.Validators + fns := [...]func(string) error{ + validators[0].(func(string) error), + validators[1].(func(string) error), + } + return func(login_ip string) error { + for _, fn := range fns { + if err := fn(login_ip); err != nil { + return err + } + } + return nil + } + }() + // userloginlogDescLoginLocation is the schema descriptor for login_location field. + userloginlogDescLoginLocation := userloginlogFields[3].Descriptor() + // userloginlog.LoginLocationValidator is a validator for the "login_location" field. It is called by the builders before save. + userloginlog.LoginLocationValidator = userloginlogDescLoginLocation.Validators[0].(func(string) error) + // userloginlogDescLoginResult is the schema descriptor for login_result field. + userloginlogDescLoginResult := userloginlogFields[6].Descriptor() + // userloginlog.DefaultLoginResult holds the default value on creation for the login_result field. + userloginlog.DefaultLoginResult = userloginlogDescLoginResult.Default.(bool) + // userloginlogDescFailureReason is the schema descriptor for failure_reason field. + userloginlogDescFailureReason := userloginlogFields[7].Descriptor() + // userloginlog.FailureReasonValidator is a validator for the "failure_reason" field. It is called by the builders before save. + userloginlog.FailureReasonValidator = userloginlogDescFailureReason.Validators[0].(func(string) error) + // userloginlogDescSessionID is the schema descriptor for session_id field. + userloginlogDescSessionID := userloginlogFields[8].Descriptor() + // userloginlog.SessionIDValidator is a validator for the "session_id" field. It is called by the builders before save. + userloginlog.SessionIDValidator = userloginlogDescSessionID.Validators[0].(func(string) error) + userthirdauthMixin := schema.UserThirdAuth{}.Mixin() + userthirdauthMixinFields0 := userthirdauthMixin[0].Fields() + _ = userthirdauthMixinFields0 + userthirdauthMixinFields1 := userthirdauthMixin[1].Fields() + _ = userthirdauthMixinFields1 + userthirdauthMixinFields2 := userthirdauthMixin[2].Fields() + _ = userthirdauthMixinFields2 + userthirdauthFields := schema.UserThirdAuth{}.Fields() + _ = userthirdauthFields + // userthirdauthDescCreatedAt is the schema descriptor for created_at field. + userthirdauthDescCreatedAt := userthirdauthMixinFields0[1].Descriptor() + // userthirdauth.DefaultCreatedAt holds the default value on creation for the created_at field. + userthirdauth.DefaultCreatedAt = userthirdauthDescCreatedAt.Default.(func() time.Time) + // userthirdauthDescUpdatedAt is the schema descriptor for updated_at field. + userthirdauthDescUpdatedAt := userthirdauthMixinFields0[2].Descriptor() + // userthirdauth.DefaultUpdatedAt holds the default value on creation for the updated_at field. + userthirdauth.DefaultUpdatedAt = userthirdauthDescUpdatedAt.Default.(func() time.Time) + // userthirdauth.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + userthirdauth.UpdateDefaultUpdatedAt = userthirdauthDescUpdatedAt.UpdateDefault.(func() time.Time) + // userthirdauthDescStatus is the schema descriptor for status field. + userthirdauthDescStatus := userthirdauthMixinFields1[0].Descriptor() + // userthirdauth.DefaultStatus holds the default value on creation for the status field. + userthirdauth.DefaultStatus = userthirdauthDescStatus.Default.(uint8) + // userthirdauthDescTenantID is the schema descriptor for tenant_id field. + userthirdauthDescTenantID := userthirdauthMixinFields2[0].Descriptor() + // userthirdauth.DefaultTenantID holds the default value on creation for the tenant_id field. + userthirdauth.DefaultTenantID = userthirdauthDescTenantID.Default.(uint64) + // userthirdauthDescOpenid is the schema descriptor for openid field. + userthirdauthDescOpenid := userthirdauthFields[1].Descriptor() + // userthirdauth.OpenidValidator is a validator for the "openid" field. It is called by the builders before save. + userthirdauth.OpenidValidator = func() func(string) error { + validators := userthirdauthDescOpenid.Validators + fns := [...]func(string) error{ + validators[0].(func(string) error), + validators[1].(func(string) error), + } + return func(openid string) error { + for _, fn := range fns { + if err := fn(openid); err != nil { + return err + } + } + return nil + } + }() + // userthirdauthDescUnionid is the schema descriptor for unionid field. + userthirdauthDescUnionid := userthirdauthFields[2].Descriptor() + // userthirdauth.UnionidValidator is a validator for the "unionid" field. It is called by the builders before save. + userthirdauth.UnionidValidator = userthirdauthDescUnionid.Validators[0].(func(string) error) + // userthirdauthDescAccessToken is the schema descriptor for access_token field. + userthirdauthDescAccessToken := userthirdauthFields[3].Descriptor() + // userthirdauth.AccessTokenValidator is a validator for the "access_token" field. It is called by the builders before save. + userthirdauth.AccessTokenValidator = userthirdauthDescAccessToken.Validators[0].(func(string) error) + // userthirdauthDescRefreshToken is the schema descriptor for refresh_token field. + userthirdauthDescRefreshToken := userthirdauthFields[4].Descriptor() + // userthirdauth.RefreshTokenValidator is a validator for the "refresh_token" field. It is called by the builders before save. + userthirdauth.RefreshTokenValidator = userthirdauthDescRefreshToken.Validators[0].(func(string) error) + // userthirdauthDescPlatformUserID is the schema descriptor for platform_user_id field. + userthirdauthDescPlatformUserID := userthirdauthFields[7].Descriptor() + // userthirdauth.PlatformUserIDValidator is a validator for the "platform_user_id" field. It is called by the builders before save. + userthirdauth.PlatformUserIDValidator = userthirdauthDescPlatformUserID.Validators[0].(func(string) error) + // userthirdauthDescNickname is the schema descriptor for nickname field. + userthirdauthDescNickname := userthirdauthFields[8].Descriptor() + // userthirdauth.NicknameValidator is a validator for the "nickname" field. It is called by the builders before save. + userthirdauth.NicknameValidator = userthirdauthDescNickname.Validators[0].(func(string) error) + // userthirdauthDescAvatar is the schema descriptor for avatar field. + userthirdauthDescAvatar := userthirdauthFields[9].Descriptor() + // userthirdauth.AvatarValidator is a validator for the "avatar" field. It is called by the builders before save. + userthirdauth.AvatarValidator = userthirdauthDescAvatar.Validators[0].(func(string) error) + // userthirdauthDescEmail is the schema descriptor for email field. + userthirdauthDescEmail := userthirdauthFields[10].Descriptor() + // userthirdauth.EmailValidator is a validator for the "email" field. It is called by the builders before save. + userthirdauth.EmailValidator = userthirdauthDescEmail.Validators[0].(func(string) error) + // userthirdauthDescPhone is the schema descriptor for phone field. + userthirdauthDescPhone := userthirdauthFields[11].Descriptor() + // userthirdauth.PhoneValidator is a validator for the "phone" field. It is called by the builders before save. + userthirdauth.PhoneValidator = userthirdauthDescPhone.Validators[0].(func(string) error) + // userthirdauthDescIsBound is the schema descriptor for is_bound field. + userthirdauthDescIsBound := userthirdauthFields[12].Descriptor() + // userthirdauth.DefaultIsBound holds the default value on creation for the is_bound field. + userthirdauth.DefaultIsBound = userthirdauthDescIsBound.Default.(bool) + // userthirdauthDescBoundAt is the schema descriptor for bound_at field. + userthirdauthDescBoundAt := userthirdauthFields[13].Descriptor() + // userthirdauth.DefaultBoundAt holds the default value on creation for the bound_at field. + userthirdauth.DefaultBoundAt = userthirdauthDescBoundAt.Default.(func() time.Time) +} diff --git a/rpc/ent/runtime/runtime.go b/rpc/ent/runtime/runtime.go new file mode 100644 index 0000000..7aba942 --- /dev/null +++ b/rpc/ent/runtime/runtime.go @@ -0,0 +1,10 @@ +// Code generated by ent, DO NOT EDIT. + +package runtime + +// The schema-stitching logic is generated in mingyang-admin-app-rpc/ent/runtime.go + +const ( + Version = "v0.14.5" // Version of ent codegen. + Sum = "h1:Rj2WOYJtCkWyFo6a+5wB3EfBRP0rnx1fMk6gGA0UUe4=" // Sum of ent codegen. +) diff --git a/rpc/ent/schema/mixins/soft_delete.go b/rpc/ent/schema/mixins/soft_delete.go new file mode 100644 index 0000000..dbe76b3 --- /dev/null +++ b/rpc/ent/schema/mixins/soft_delete.go @@ -0,0 +1,33 @@ +package mixins + +import ( + "context" + + "entgo.io/ent" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/mixin" + //"mingyang-admin-app/ent/intercept" +) + +// SoftDeleteMixin implements the soft delete pattern for schemas. +type SoftDeleteMixin struct { + mixin.Schema +} + +// Fields of the SoftDeleteMixin. +func (SoftDeleteMixin) Fields() []ent.Field { + return []ent.Field{ + field.Time("deleted_at"). + Optional(). + Comment("Delete Time | 删除日期"), + } +} + +type softDeleteKey struct{} + +// SkipSoftDelete returns a new context that skips the soft-delete interceptor/mutators. +func SkipSoftDelete(parent context.Context) context.Context { + return context.WithValue(parent, softDeleteKey{}, true) +} + +// Interceptors of the SoftDeleteMixin. diff --git a/rpc/ent/schema/user.go b/rpc/ent/schema/user.go new file mode 100644 index 0000000..b915ea9 --- /dev/null +++ b/rpc/ent/schema/user.go @@ -0,0 +1,114 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" + "github.com/saas-mingyang/mingyang-admin-common/orm/ent/mixins" + mixins2 "mingyang-admin-app-rpc/ent/schema/mixins" +) + +// User 用户表 +type User struct { + ent.Schema +} + +func (User) Fields() []ent.Field { + return []ent.Field{ + // 账号信息 + field.String("username").Comment("用户名"). + Unique(). + NotEmpty(). + MaxLen(50). + Validate(func(s string) error { + // 用户名验证逻辑 + return nil + }), + field.String("email").Comment("邮箱"). + Unique(). + NotEmpty(). + MaxLen(255). + Validate(func(s string) error { + // 邮箱格式验证 + return nil + }), + field.String("mobile").Comment("联系方式"). + Optional(). + Nillable(). + MaxLen(64), + // 密码安全 + field.String("password_hash").Comment("密码"). + NotEmpty(). + Sensitive(), + field.String("salt").Comment("salt盐值"). + NotEmpty(). + Sensitive(). + MaxLen(32), + // 个人信息 + field.String("nickname").Comment("昵称"). + Default(""). + MaxLen(50), + field.String("avatar").Comment("头像"). + Optional(). + Nillable(). + MaxLen(500), + field.Enum("gender"). + Values("unknown", "male", "female", "other").Comment("性别"). + Default("unknown"), + field.Time("birthday"). + Optional(). + Nillable(), + // 账户状态 + field.Enum("account_status"). + Values("unverified", "active", "locked", "disabled").Comment("账户状态"). + Default("unverified"), + // 验证信息 + field.Uint32("is_verified"). + Default(0).Comment("1 邮箱 ,2 电话号码"), + field.String("registered_login_ip"). + Comment("注册IP地址"). + Optional(). + Nillable(). + MaxLen(255), + field.Int64("login_attempts"). + Default(0).Comment("登录尝试次数"), + // 元数据 + field.JSON("metadata", map[string]interface{}{}). + Optional(), + field.String("registration_source").Comment("注册来源"). + Optional(). + MaxLen(50), + } +} + +func (User) Mixin() []ent.Mixin { + return []ent.Mixin{ + mixins.IDMixin{}, + mixins.StatusMixin{}, + mixins.TenantMixin{}, + mixins2.SoftDeleteMixin{}, + } +} + +func (User) Indexes() []ent.Index { + return []ent.Index{ + // 唯一索引 + index.Fields("username").Unique(), + index.Fields("email").Unique(), + index.Fields("mobile").Unique(), + } +} + +func (User) Edges() []ent.Edge { + return []ent.Edge{} +} + +func (User) Annotations() []schema.Annotation { + return []schema.Annotation{ + entsql.WithComments(true), + schema.Comment("User Table | C端用户表"), + entsql.Annotation{Table: "user"}, + } +} diff --git a/rpc/ent/schema/userloginlog.go b/rpc/ent/schema/userloginlog.go new file mode 100644 index 0000000..18d47e4 --- /dev/null +++ b/rpc/ent/schema/userloginlog.go @@ -0,0 +1,86 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" + "github.com/saas-mingyang/mingyang-admin-common/orm/ent/mixins" + mixins2 "mingyang-admin-app-rpc/ent/schema/mixins" + "time" +) + +// UserLoginLog 定义用户登录日志实体 +type UserLoginLog struct { + ent.Schema +} + +func (UserLoginLog) Fields() []ent.Field { + return []ent.Field{ + field.Uint64("user_id").Comment("用户ID"), + field.Time("login_time"). + Default(time.Now), + field.String("login_ip"). + NotEmpty(). + MaxLen(45), + field.String("login_location"). + Optional(). + MaxLen(200), + field.Enum("login_type"). + Values( + "password", + "sms_code", + "email_code", + "wechat", + "alipay", + "apple", + "google", + "other_third_party", + ). + Default("password"), + field.Enum("login_platform"). + Values( + "ios", + "android"). + Default("android"), + field.Bool("login_result"). + Comment("登录结果,是否成功"). + Default(true), + field.String("failure_reason"). + Optional(). + MaxLen(500), + field.String("session_id"). + Optional(). + MaxLen(200), + field.Int("latency_ms"). + Optional(), + field.Uint64("auth_id").Optional().Comment("auth_id"), + field.JSON("additional_data", map[string]interface{}{}). + Optional(), + } +} + +func (UserLoginLog) Mixin() []ent.Mixin { + return []ent.Mixin{ + mixins.IDMixin{}, + mixins.StatusMixin{}, + mixins.TenantMixin{}, + mixins2.SoftDeleteMixin{}, + } +} + +func (UserLoginLog) Edges() []ent.Edge { + return []ent.Edge{} + +} + +func (UserLoginLog) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("user_id", "login_time"), + index.Fields("login_time"), + index.Fields("login_ip"), + index.Fields("login_type"), + index.Fields("login_platform"), + index.Fields("login_result"), + index.Fields("session_id"), + } +} diff --git a/rpc/ent/schema/userthirdauth.go b/rpc/ent/schema/userthirdauth.go new file mode 100644 index 0000000..a3680f6 --- /dev/null +++ b/rpc/ent/schema/userthirdauth.go @@ -0,0 +1,78 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/field" + "github.com/saas-mingyang/mingyang-admin-common/orm/ent/mixins" + mixins2 "mingyang-admin-app-rpc/ent/schema/mixins" + "time" +) + +// UserThirdAuth holds the schema definition for the UserThirdAuth entity. +type UserThirdAuth struct { + ent.Schema +} + +func (UserThirdAuth) Fields() []ent.Field { + return []ent.Field{ + field.Uint64("user_id"). + Comment("用户ID"), + field.String("openid"). + NotEmpty(). + MaxLen(255), + field.String("unionid"). + Optional(). + MaxLen(255), + field.String("access_token"). + Optional(). + Sensitive(). + MaxLen(2000), + field.String("refresh_token"). + Optional(). + Sensitive(). + MaxLen(2000), + field.Time("access_token_expiry"). + Optional(). + Nillable(), + field.JSON("user_info", map[string]interface{}{}). + Optional(), + field.String("platform_user_id"). + Optional(). + MaxLen(255), + field.String("nickname"). + Optional(). + MaxLen(100), + field.String("avatar"). + Optional(). + MaxLen(500), + field.String("email"). + Optional(). + MaxLen(255), + field.String("phone"). + Optional(). + MaxLen(20), + field.Bool("is_bound"). + Default(true), + field.Time("bound_at"). + Default(time.Now), + field.JSON("extra_data", map[string]interface{}{}). + Optional(), + } +} + +func (UserThirdAuth) Mixin() []ent.Mixin { + return []ent.Mixin{ + mixins.IDMixin{}, + mixins.StatusMixin{}, + mixins.TenantMixin{}, + mixins2.SoftDeleteMixin{}, + } +} + +func (UserThirdAuth) Edges() []ent.Edge { + return []ent.Edge{} +} + +func (UserThirdAuth) Indexes() []ent.Index { + return []ent.Index{} +} diff --git a/rpc/ent/set_not_nil.go b/rpc/ent/set_not_nil.go new file mode 100644 index 0000000..ee10ebf --- /dev/null +++ b/rpc/ent/set_not_nil.go @@ -0,0 +1,1233 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "mingyang-admin-app-rpc/ent/user" + "mingyang-admin-app-rpc/ent/userloginlog" + "time" +) + +// set field if value's pointer is not nil. +func (_m *UserUpdate) SetNotNilUpdatedAt(value *time.Time) *UserUpdate { + if value != nil { + return _m.SetUpdatedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserUpdateOne) SetNotNilUpdatedAt(value *time.Time) *UserUpdateOne { + if value != nil { + return _m.SetUpdatedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserCreate) SetNotNilUpdatedAt(value *time.Time) *UserCreate { + if value != nil { + return _m.SetUpdatedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserUpdate) SetNotNilStatus(value *uint8) *UserUpdate { + if value != nil { + return _m.SetStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserUpdateOne) SetNotNilStatus(value *uint8) *UserUpdateOne { + if value != nil { + return _m.SetStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserCreate) SetNotNilStatus(value *uint8) *UserCreate { + if value != nil { + return _m.SetStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserUpdate) SetNotNilDeletedAt(value *time.Time) *UserUpdate { + if value != nil { + return _m.SetDeletedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserUpdateOne) SetNotNilDeletedAt(value *time.Time) *UserUpdateOne { + if value != nil { + return _m.SetDeletedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserCreate) SetNotNilDeletedAt(value *time.Time) *UserCreate { + if value != nil { + return _m.SetDeletedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserUpdate) SetNotNilUsername(value *string) *UserUpdate { + if value != nil { + return _m.SetUsername(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserUpdateOne) SetNotNilUsername(value *string) *UserUpdateOne { + if value != nil { + return _m.SetUsername(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserCreate) SetNotNilUsername(value *string) *UserCreate { + if value != nil { + return _m.SetUsername(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserUpdate) SetNotNilEmail(value *string) *UserUpdate { + if value != nil { + return _m.SetEmail(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserUpdateOne) SetNotNilEmail(value *string) *UserUpdateOne { + if value != nil { + return _m.SetEmail(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserCreate) SetNotNilEmail(value *string) *UserCreate { + if value != nil { + return _m.SetEmail(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserUpdate) SetNotNilMobile(value *string) *UserUpdate { + if value != nil { + return _m.SetMobile(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserUpdateOne) SetNotNilMobile(value *string) *UserUpdateOne { + if value != nil { + return _m.SetMobile(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserCreate) SetNotNilMobile(value *string) *UserCreate { + if value != nil { + return _m.SetMobile(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserUpdate) SetNotNilPasswordHash(value *string) *UserUpdate { + if value != nil { + return _m.SetPasswordHash(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserUpdateOne) SetNotNilPasswordHash(value *string) *UserUpdateOne { + if value != nil { + return _m.SetPasswordHash(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserCreate) SetNotNilPasswordHash(value *string) *UserCreate { + if value != nil { + return _m.SetPasswordHash(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserUpdate) SetNotNilSalt(value *string) *UserUpdate { + if value != nil { + return _m.SetSalt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserUpdateOne) SetNotNilSalt(value *string) *UserUpdateOne { + if value != nil { + return _m.SetSalt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserCreate) SetNotNilSalt(value *string) *UserCreate { + if value != nil { + return _m.SetSalt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserUpdate) SetNotNilNickname(value *string) *UserUpdate { + if value != nil { + return _m.SetNickname(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserUpdateOne) SetNotNilNickname(value *string) *UserUpdateOne { + if value != nil { + return _m.SetNickname(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserCreate) SetNotNilNickname(value *string) *UserCreate { + if value != nil { + return _m.SetNickname(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserUpdate) SetNotNilAvatar(value *string) *UserUpdate { + if value != nil { + return _m.SetAvatar(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserUpdateOne) SetNotNilAvatar(value *string) *UserUpdateOne { + if value != nil { + return _m.SetAvatar(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserCreate) SetNotNilAvatar(value *string) *UserCreate { + if value != nil { + return _m.SetAvatar(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserUpdate) SetNotNilGender(value *user.Gender) *UserUpdate { + if value != nil { + return _m.SetGender(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserUpdateOne) SetNotNilGender(value *user.Gender) *UserUpdateOne { + if value != nil { + return _m.SetGender(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserCreate) SetNotNilGender(value *user.Gender) *UserCreate { + if value != nil { + return _m.SetGender(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserUpdate) SetNotNilBirthday(value *time.Time) *UserUpdate { + if value != nil { + return _m.SetBirthday(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserUpdateOne) SetNotNilBirthday(value *time.Time) *UserUpdateOne { + if value != nil { + return _m.SetBirthday(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserCreate) SetNotNilBirthday(value *time.Time) *UserCreate { + if value != nil { + return _m.SetBirthday(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserUpdate) SetNotNilAccountStatus(value *user.AccountStatus) *UserUpdate { + if value != nil { + return _m.SetAccountStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserUpdateOne) SetNotNilAccountStatus(value *user.AccountStatus) *UserUpdateOne { + if value != nil { + return _m.SetAccountStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserCreate) SetNotNilAccountStatus(value *user.AccountStatus) *UserCreate { + if value != nil { + return _m.SetAccountStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserUpdate) SetNotNilIsVerified(value *uint32) *UserUpdate { + if value != nil { + return _m.SetIsVerified(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserUpdateOne) SetNotNilIsVerified(value *uint32) *UserUpdateOne { + if value != nil { + return _m.SetIsVerified(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserCreate) SetNotNilIsVerified(value *uint32) *UserCreate { + if value != nil { + return _m.SetIsVerified(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserUpdate) SetNotNilRegisteredLoginIP(value *string) *UserUpdate { + if value != nil { + return _m.SetRegisteredLoginIP(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserUpdateOne) SetNotNilRegisteredLoginIP(value *string) *UserUpdateOne { + if value != nil { + return _m.SetRegisteredLoginIP(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserCreate) SetNotNilRegisteredLoginIP(value *string) *UserCreate { + if value != nil { + return _m.SetRegisteredLoginIP(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserUpdate) SetNotNilLoginAttempts(value *int64) *UserUpdate { + if value != nil { + return _m.SetLoginAttempts(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserUpdateOne) SetNotNilLoginAttempts(value *int64) *UserUpdateOne { + if value != nil { + return _m.SetLoginAttempts(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserCreate) SetNotNilLoginAttempts(value *int64) *UserCreate { + if value != nil { + return _m.SetLoginAttempts(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserUpdate) SetNotNilMetadata(value *map[string]interface{}) *UserUpdate { + if value != nil { + return _m.SetMetadata(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserUpdateOne) SetNotNilMetadata(value *map[string]interface{}) *UserUpdateOne { + if value != nil { + return _m.SetMetadata(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserCreate) SetNotNilMetadata(value *map[string]interface{}) *UserCreate { + if value != nil { + return _m.SetMetadata(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserUpdate) SetNotNilRegistrationSource(value *string) *UserUpdate { + if value != nil { + return _m.SetRegistrationSource(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserUpdateOne) SetNotNilRegistrationSource(value *string) *UserUpdateOne { + if value != nil { + return _m.SetRegistrationSource(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserCreate) SetNotNilRegistrationSource(value *string) *UserCreate { + if value != nil { + return _m.SetRegistrationSource(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogUpdate) SetNotNilUpdatedAt(value *time.Time) *UserLoginLogUpdate { + if value != nil { + return _m.SetUpdatedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogUpdateOne) SetNotNilUpdatedAt(value *time.Time) *UserLoginLogUpdateOne { + if value != nil { + return _m.SetUpdatedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogCreate) SetNotNilUpdatedAt(value *time.Time) *UserLoginLogCreate { + if value != nil { + return _m.SetUpdatedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogUpdate) SetNotNilStatus(value *uint8) *UserLoginLogUpdate { + if value != nil { + return _m.SetStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogUpdateOne) SetNotNilStatus(value *uint8) *UserLoginLogUpdateOne { + if value != nil { + return _m.SetStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogCreate) SetNotNilStatus(value *uint8) *UserLoginLogCreate { + if value != nil { + return _m.SetStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogUpdate) SetNotNilDeletedAt(value *time.Time) *UserLoginLogUpdate { + if value != nil { + return _m.SetDeletedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogUpdateOne) SetNotNilDeletedAt(value *time.Time) *UserLoginLogUpdateOne { + if value != nil { + return _m.SetDeletedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogCreate) SetNotNilDeletedAt(value *time.Time) *UserLoginLogCreate { + if value != nil { + return _m.SetDeletedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogUpdate) SetNotNilUserID(value *uint64) *UserLoginLogUpdate { + if value != nil { + return _m.SetUserID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogUpdateOne) SetNotNilUserID(value *uint64) *UserLoginLogUpdateOne { + if value != nil { + return _m.SetUserID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogCreate) SetNotNilUserID(value *uint64) *UserLoginLogCreate { + if value != nil { + return _m.SetUserID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogUpdate) SetNotNilLoginTime(value *time.Time) *UserLoginLogUpdate { + if value != nil { + return _m.SetLoginTime(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogUpdateOne) SetNotNilLoginTime(value *time.Time) *UserLoginLogUpdateOne { + if value != nil { + return _m.SetLoginTime(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogCreate) SetNotNilLoginTime(value *time.Time) *UserLoginLogCreate { + if value != nil { + return _m.SetLoginTime(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogUpdate) SetNotNilLoginIP(value *string) *UserLoginLogUpdate { + if value != nil { + return _m.SetLoginIP(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogUpdateOne) SetNotNilLoginIP(value *string) *UserLoginLogUpdateOne { + if value != nil { + return _m.SetLoginIP(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogCreate) SetNotNilLoginIP(value *string) *UserLoginLogCreate { + if value != nil { + return _m.SetLoginIP(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogUpdate) SetNotNilLoginLocation(value *string) *UserLoginLogUpdate { + if value != nil { + return _m.SetLoginLocation(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogUpdateOne) SetNotNilLoginLocation(value *string) *UserLoginLogUpdateOne { + if value != nil { + return _m.SetLoginLocation(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogCreate) SetNotNilLoginLocation(value *string) *UserLoginLogCreate { + if value != nil { + return _m.SetLoginLocation(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogUpdate) SetNotNilLoginType(value *userloginlog.LoginType) *UserLoginLogUpdate { + if value != nil { + return _m.SetLoginType(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogUpdateOne) SetNotNilLoginType(value *userloginlog.LoginType) *UserLoginLogUpdateOne { + if value != nil { + return _m.SetLoginType(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogCreate) SetNotNilLoginType(value *userloginlog.LoginType) *UserLoginLogCreate { + if value != nil { + return _m.SetLoginType(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogUpdate) SetNotNilLoginPlatform(value *userloginlog.LoginPlatform) *UserLoginLogUpdate { + if value != nil { + return _m.SetLoginPlatform(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogUpdateOne) SetNotNilLoginPlatform(value *userloginlog.LoginPlatform) *UserLoginLogUpdateOne { + if value != nil { + return _m.SetLoginPlatform(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogCreate) SetNotNilLoginPlatform(value *userloginlog.LoginPlatform) *UserLoginLogCreate { + if value != nil { + return _m.SetLoginPlatform(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogUpdate) SetNotNilLoginResult(value *bool) *UserLoginLogUpdate { + if value != nil { + return _m.SetLoginResult(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogUpdateOne) SetNotNilLoginResult(value *bool) *UserLoginLogUpdateOne { + if value != nil { + return _m.SetLoginResult(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogCreate) SetNotNilLoginResult(value *bool) *UserLoginLogCreate { + if value != nil { + return _m.SetLoginResult(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogUpdate) SetNotNilFailureReason(value *string) *UserLoginLogUpdate { + if value != nil { + return _m.SetFailureReason(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogUpdateOne) SetNotNilFailureReason(value *string) *UserLoginLogUpdateOne { + if value != nil { + return _m.SetFailureReason(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogCreate) SetNotNilFailureReason(value *string) *UserLoginLogCreate { + if value != nil { + return _m.SetFailureReason(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogUpdate) SetNotNilSessionID(value *string) *UserLoginLogUpdate { + if value != nil { + return _m.SetSessionID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogUpdateOne) SetNotNilSessionID(value *string) *UserLoginLogUpdateOne { + if value != nil { + return _m.SetSessionID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogCreate) SetNotNilSessionID(value *string) *UserLoginLogCreate { + if value != nil { + return _m.SetSessionID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogUpdate) SetNotNilLatencyMs(value *int) *UserLoginLogUpdate { + if value != nil { + return _m.SetLatencyMs(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogUpdateOne) SetNotNilLatencyMs(value *int) *UserLoginLogUpdateOne { + if value != nil { + return _m.SetLatencyMs(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogCreate) SetNotNilLatencyMs(value *int) *UserLoginLogCreate { + if value != nil { + return _m.SetLatencyMs(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogUpdate) SetNotNilAuthID(value *uint64) *UserLoginLogUpdate { + if value != nil { + return _m.SetAuthID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogUpdateOne) SetNotNilAuthID(value *uint64) *UserLoginLogUpdateOne { + if value != nil { + return _m.SetAuthID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogCreate) SetNotNilAuthID(value *uint64) *UserLoginLogCreate { + if value != nil { + return _m.SetAuthID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogUpdate) SetNotNilAdditionalData(value *map[string]interface{}) *UserLoginLogUpdate { + if value != nil { + return _m.SetAdditionalData(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogUpdateOne) SetNotNilAdditionalData(value *map[string]interface{}) *UserLoginLogUpdateOne { + if value != nil { + return _m.SetAdditionalData(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserLoginLogCreate) SetNotNilAdditionalData(value *map[string]interface{}) *UserLoginLogCreate { + if value != nil { + return _m.SetAdditionalData(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthUpdate) SetNotNilUpdatedAt(value *time.Time) *UserThirdAuthUpdate { + if value != nil { + return _m.SetUpdatedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthUpdateOne) SetNotNilUpdatedAt(value *time.Time) *UserThirdAuthUpdateOne { + if value != nil { + return _m.SetUpdatedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthCreate) SetNotNilUpdatedAt(value *time.Time) *UserThirdAuthCreate { + if value != nil { + return _m.SetUpdatedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthUpdate) SetNotNilStatus(value *uint8) *UserThirdAuthUpdate { + if value != nil { + return _m.SetStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthUpdateOne) SetNotNilStatus(value *uint8) *UserThirdAuthUpdateOne { + if value != nil { + return _m.SetStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthCreate) SetNotNilStatus(value *uint8) *UserThirdAuthCreate { + if value != nil { + return _m.SetStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthUpdate) SetNotNilDeletedAt(value *time.Time) *UserThirdAuthUpdate { + if value != nil { + return _m.SetDeletedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthUpdateOne) SetNotNilDeletedAt(value *time.Time) *UserThirdAuthUpdateOne { + if value != nil { + return _m.SetDeletedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthCreate) SetNotNilDeletedAt(value *time.Time) *UserThirdAuthCreate { + if value != nil { + return _m.SetDeletedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthUpdate) SetNotNilUserID(value *uint64) *UserThirdAuthUpdate { + if value != nil { + return _m.SetUserID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthUpdateOne) SetNotNilUserID(value *uint64) *UserThirdAuthUpdateOne { + if value != nil { + return _m.SetUserID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthCreate) SetNotNilUserID(value *uint64) *UserThirdAuthCreate { + if value != nil { + return _m.SetUserID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthUpdate) SetNotNilOpenid(value *string) *UserThirdAuthUpdate { + if value != nil { + return _m.SetOpenid(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthUpdateOne) SetNotNilOpenid(value *string) *UserThirdAuthUpdateOne { + if value != nil { + return _m.SetOpenid(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthCreate) SetNotNilOpenid(value *string) *UserThirdAuthCreate { + if value != nil { + return _m.SetOpenid(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthUpdate) SetNotNilUnionid(value *string) *UserThirdAuthUpdate { + if value != nil { + return _m.SetUnionid(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthUpdateOne) SetNotNilUnionid(value *string) *UserThirdAuthUpdateOne { + if value != nil { + return _m.SetUnionid(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthCreate) SetNotNilUnionid(value *string) *UserThirdAuthCreate { + if value != nil { + return _m.SetUnionid(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthUpdate) SetNotNilAccessToken(value *string) *UserThirdAuthUpdate { + if value != nil { + return _m.SetAccessToken(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthUpdateOne) SetNotNilAccessToken(value *string) *UserThirdAuthUpdateOne { + if value != nil { + return _m.SetAccessToken(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthCreate) SetNotNilAccessToken(value *string) *UserThirdAuthCreate { + if value != nil { + return _m.SetAccessToken(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthUpdate) SetNotNilRefreshToken(value *string) *UserThirdAuthUpdate { + if value != nil { + return _m.SetRefreshToken(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthUpdateOne) SetNotNilRefreshToken(value *string) *UserThirdAuthUpdateOne { + if value != nil { + return _m.SetRefreshToken(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthCreate) SetNotNilRefreshToken(value *string) *UserThirdAuthCreate { + if value != nil { + return _m.SetRefreshToken(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthUpdate) SetNotNilAccessTokenExpiry(value *time.Time) *UserThirdAuthUpdate { + if value != nil { + return _m.SetAccessTokenExpiry(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthUpdateOne) SetNotNilAccessTokenExpiry(value *time.Time) *UserThirdAuthUpdateOne { + if value != nil { + return _m.SetAccessTokenExpiry(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthCreate) SetNotNilAccessTokenExpiry(value *time.Time) *UserThirdAuthCreate { + if value != nil { + return _m.SetAccessTokenExpiry(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthUpdate) SetNotNilUserInfo(value *map[string]interface{}) *UserThirdAuthUpdate { + if value != nil { + return _m.SetUserInfo(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthUpdateOne) SetNotNilUserInfo(value *map[string]interface{}) *UserThirdAuthUpdateOne { + if value != nil { + return _m.SetUserInfo(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthCreate) SetNotNilUserInfo(value *map[string]interface{}) *UserThirdAuthCreate { + if value != nil { + return _m.SetUserInfo(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthUpdate) SetNotNilPlatformUserID(value *string) *UserThirdAuthUpdate { + if value != nil { + return _m.SetPlatformUserID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthUpdateOne) SetNotNilPlatformUserID(value *string) *UserThirdAuthUpdateOne { + if value != nil { + return _m.SetPlatformUserID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthCreate) SetNotNilPlatformUserID(value *string) *UserThirdAuthCreate { + if value != nil { + return _m.SetPlatformUserID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthUpdate) SetNotNilNickname(value *string) *UserThirdAuthUpdate { + if value != nil { + return _m.SetNickname(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthUpdateOne) SetNotNilNickname(value *string) *UserThirdAuthUpdateOne { + if value != nil { + return _m.SetNickname(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthCreate) SetNotNilNickname(value *string) *UserThirdAuthCreate { + if value != nil { + return _m.SetNickname(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthUpdate) SetNotNilAvatar(value *string) *UserThirdAuthUpdate { + if value != nil { + return _m.SetAvatar(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthUpdateOne) SetNotNilAvatar(value *string) *UserThirdAuthUpdateOne { + if value != nil { + return _m.SetAvatar(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthCreate) SetNotNilAvatar(value *string) *UserThirdAuthCreate { + if value != nil { + return _m.SetAvatar(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthUpdate) SetNotNilEmail(value *string) *UserThirdAuthUpdate { + if value != nil { + return _m.SetEmail(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthUpdateOne) SetNotNilEmail(value *string) *UserThirdAuthUpdateOne { + if value != nil { + return _m.SetEmail(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthCreate) SetNotNilEmail(value *string) *UserThirdAuthCreate { + if value != nil { + return _m.SetEmail(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthUpdate) SetNotNilPhone(value *string) *UserThirdAuthUpdate { + if value != nil { + return _m.SetPhone(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthUpdateOne) SetNotNilPhone(value *string) *UserThirdAuthUpdateOne { + if value != nil { + return _m.SetPhone(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthCreate) SetNotNilPhone(value *string) *UserThirdAuthCreate { + if value != nil { + return _m.SetPhone(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthUpdate) SetNotNilIsBound(value *bool) *UserThirdAuthUpdate { + if value != nil { + return _m.SetIsBound(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthUpdateOne) SetNotNilIsBound(value *bool) *UserThirdAuthUpdateOne { + if value != nil { + return _m.SetIsBound(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthCreate) SetNotNilIsBound(value *bool) *UserThirdAuthCreate { + if value != nil { + return _m.SetIsBound(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthUpdate) SetNotNilBoundAt(value *time.Time) *UserThirdAuthUpdate { + if value != nil { + return _m.SetBoundAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthUpdateOne) SetNotNilBoundAt(value *time.Time) *UserThirdAuthUpdateOne { + if value != nil { + return _m.SetBoundAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthCreate) SetNotNilBoundAt(value *time.Time) *UserThirdAuthCreate { + if value != nil { + return _m.SetBoundAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthUpdate) SetNotNilExtraData(value *map[string]interface{}) *UserThirdAuthUpdate { + if value != nil { + return _m.SetExtraData(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthUpdateOne) SetNotNilExtraData(value *map[string]interface{}) *UserThirdAuthUpdateOne { + if value != nil { + return _m.SetExtraData(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *UserThirdAuthCreate) SetNotNilExtraData(value *map[string]interface{}) *UserThirdAuthCreate { + if value != nil { + return _m.SetExtraData(*value) + } + return _m +} diff --git a/rpc/ent/template/pagination.tmpl b/rpc/ent/template/pagination.tmpl new file mode 100644 index 0000000..e2f6bb2 --- /dev/null +++ b/rpc/ent/template/pagination.tmpl @@ -0,0 +1,170 @@ +{{/* +Copyright 2022-present Ryan SU (github.com/suyuan32). All rights reserved. +This source code is licensed under the Apache 2.0 license found +in the LICENSE file in the root directory of this source tree. +*/}} + +{{ define "pagination" }} + {{- /*gotype: entgo.io/ent/entc/gen.Graph*/ -}} + + {{ template "header" $ }} + {{ $pkg := base $.Config.Package }} + {{ template "import" $ }} + + const errInvalidPage = "INVALID_PAGE" + + const ( + listField = "list" + pageNumField = "pageNum" + pageSizeField = "pageSize" + ) + + type PageDetails struct { + Page uint64 `json:"page"` + Size uint64 `json:"size"` + Total uint64 `json:"total"` + } + + // OrderDirection defines the directions in which to order a list of items. + type OrderDirection string + + const ( + // OrderDirectionAsc specifies an ascending order. + OrderDirectionAsc OrderDirection = "ASC" + // OrderDirectionDesc specifies a descending order. + OrderDirectionDesc OrderDirection = "DESC" + ) + + // Validate the order direction value. + func (o OrderDirection) Validate() error { + if o != OrderDirectionAsc && o != OrderDirectionDesc { + return fmt.Errorf("%s is not a valid OrderDirection", o) + } + return nil + } + + // String implements fmt.Stringer interface. + func (o OrderDirection) String() string { + return string(o) + } + + func (o OrderDirection) reverse() OrderDirection { + if o == OrderDirectionDesc { + return OrderDirectionAsc + } + return OrderDirectionDesc + } + + const errInvalidPagination = "INVALID_PAGINATION" + + {{ range $node := $.Nodes -}} + {{- if ne $node.Name "CasbinRule" }} + {{ $pager := print $node.Name "Pager" }} + {{ $order := print $node.Name "Order"}} + {{ $query := print $node.Name "Query"}} + {{ $orderField := print $node.Name "OrderField"}} + type {{ $pager }} struct { + Order {{ lower $node.Name }}.OrderOption + Filter func(*{{ $query }}) (*{{ $query }}, error) + } + + {{ $opt := print $node.Name "PaginateOption" }} + // {{ $opt }} enables pagination customization. + type {{ $opt }} func(*{{ $pager }}) + + + {{ $newPager := print "new" $node.Name "Pager" -}} + {{- $defaultOrder := print "Default" $node.Name "Order" }} + + {{ range $f := $node.Fields -}} + {{- if eq $node.HasOneFieldID true}} + // {{ $defaultOrder }} is the default ordering of {{ $node.Name }}. + var {{ $defaultOrder }} = Desc({{ lower $node.Name }}.FieldID) + {{- break}} + {{- else}} + // {{ $defaultOrder }} is the default ordering of {{ $node.Name }}. + var {{ $defaultOrder }} = Desc({{ lower $node.Name }}.Field{{ $f.StructField }}) + {{- break}} + {{- end}} + {{end}} + + func {{ $newPager }}(opts []{{ $opt }}) (*{{ $pager }}, error) { + pager := &{{ $pager }}{} + for _, opt := range opts { + opt(pager) + } + if pager.Order == nil { + pager.Order = {{ $defaultOrder }} + } + return pager, nil + } + + + func (p *{{ $pager }}) ApplyFilter(query *{{ $query }}) (*{{ $query }}, error) { + if p.Filter != nil { + return p.Filter(query) + } + return query, nil + } + + {{ $pageList := print $node.Name "PageList" -}} + {{ $name := $node.Name }} + + // {{ $pageList }} is {{ $name }} PageList result. + type {{ $pageList }} struct { + List []*{{ $name }} `json:"list"` + PageDetails *PageDetails `json:"pageDetails"` + } + + + {{ $r := $node.Receiver -}} + {{ $queryName := print $node.QueryName -}} + + func ({{ $r }} *{{ $queryName }}) Page( + ctx context.Context, pageNum uint64, pageSize uint64, opts ...{{ $opt }}, + ) (*{{ $pageList }}, error) { + + pager, err := {{ $newPager }}(opts) + if err != nil { + return nil, err + } + + if {{ $r }}, err = pager.ApplyFilter({{ $r }}); err != nil { + return nil, err + } + + ret := &{{ $pageList }}{} + + ret.PageDetails = &PageDetails{ + Page: pageNum, + Size: pageSize, + } + + query := {{ $r }}.Clone() + query.ctx.Fields = nil + count, err := query.Count(ctx) + + if err != nil { + return nil, err + } + + ret.PageDetails.Total = uint64(count) + + if pager.Order != nil { + {{ $r }} = {{ $r }}.Order(pager.Order) + } else { + {{ $r }} = {{ $r }}.Order({{ $defaultOrder }}) + } + + {{ $r }} = {{ $r }}.Offset(int((pageNum - 1) * pageSize)).Limit(int(pageSize)) + list, err := {{ $r }}.All(ctx) + if err != nil { + return nil, err + } + ret.List = list + + return ret, nil + } + {{- end}} + {{- end}} +{{- end}} \ No newline at end of file diff --git a/rpc/ent/template/set_not_nil.tmpl b/rpc/ent/template/set_not_nil.tmpl new file mode 100644 index 0000000..95517e9 --- /dev/null +++ b/rpc/ent/template/set_not_nil.tmpl @@ -0,0 +1,32 @@ +{{/* +Copyright 2022-present Ryan SU (github.com/suyuan32). All rights reserved. +This source code is licensed under the Apache 2.0 license found +in the LICENSE file in the root directory of this source tree. +*/}} + +{{/* gotype: entgo.io/ent/entc/gen.Graph */}} + + +{{ define "set_not_nil" }} + + {{/* Add the base header for the generated file */}} + {{ $pkg := base $.Config.Package }} + {{ template "header" $ }} + + {{/* Loop over all updaters and implement the "SetNotNil" method for all optional fields */}} + {{ range $n := $.Nodes }} + {{ range $f := $n.MutableFields }} + {{ $set := print "Set" $f.StructField }} + + {{ range $updater := list $n.UpdateName $n.UpdateOneName $n.CreateName}} + // set field if value's pointer is not nil. + func ({{ $n.Receiver }} *{{ $updater }}) SetNotNil{{ $f.StructField }}(value {{if not (hasPrefix $f.Type.String "[]") }}*{{end}}{{ $f.Type }}) *{{ $updater }} { + if value != nil { + return {{ $n.Receiver }}.{{ $set }}({{if not (hasPrefix $f.Type.String "[]") }}*{{end}}value) + } + return {{ $n.Receiver }} + } + {{ end }} + {{ end }} + {{ end }} +{{ end }} \ No newline at end of file diff --git a/rpc/ent/tx.go b/rpc/ent/tx.go new file mode 100644 index 0000000..8f4e9c6 --- /dev/null +++ b/rpc/ent/tx.go @@ -0,0 +1,242 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + stdsql "database/sql" + "fmt" + "sync" + + "entgo.io/ent/dialect" +) + +// Tx is a transactional client that is created by calling Client.Tx(). +type Tx struct { + config + // User is the client for interacting with the User builders. + User *UserClient + // UserLoginLog is the client for interacting with the UserLoginLog builders. + UserLoginLog *UserLoginLogClient + // UserThirdAuth is the client for interacting with the UserThirdAuth builders. + UserThirdAuth *UserThirdAuthClient + + // 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.User = NewUserClient(tx.config) + tx.UserLoginLog = NewUserLoginLogClient(tx.config) + tx.UserThirdAuth = NewUserThirdAuthClient(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.proto 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: User.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) + +// ExecContext allows calling the underlying ExecContext method of the transaction if it is supported by it. +// See, database/sql#Tx.ExecContext for more information. +func (tx *txDriver) ExecContext(ctx context.Context, query string, args ...any) (stdsql.Result, error) { + ex, ok := tx.tx.(interface { + ExecContext(context.Context, string, ...any) (stdsql.Result, error) + }) + if !ok { + return nil, fmt.Errorf("Tx.ExecContext is not supported") + } + return ex.ExecContext(ctx, query, args...) +} + +// QueryContext allows calling the underlying QueryContext method of the transaction if it is supported by it. +// See, database/sql#Tx.QueryContext for more information. +func (tx *txDriver) QueryContext(ctx context.Context, query string, args ...any) (*stdsql.Rows, error) { + q, ok := tx.tx.(interface { + QueryContext(context.Context, string, ...any) (*stdsql.Rows, error) + }) + if !ok { + return nil, fmt.Errorf("Tx.QueryContext is not supported") + } + return q.QueryContext(ctx, query, args...) +} diff --git a/rpc/ent/user.go b/rpc/ent/user.go new file mode 100644 index 0000000..47b0967 --- /dev/null +++ b/rpc/ent/user.go @@ -0,0 +1,330 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "encoding/json" + "fmt" + "mingyang-admin-app-rpc/ent/user" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// User Table | C端用户表 +type User struct { + config `json:"-"` + // ID of the ent. + ID uint64 `json:"id,omitempty"` + // Create Time | 创建日期 + CreatedAt time.Time `json:"created_at,omitempty"` + // Update Time | 修改日期 + UpdatedAt time.Time `json:"updated_at,omitempty"` + // Status 1: normal 2: ban | 状态 1 正常 2 禁用 + Status uint8 `json:"status,omitempty"` + // Tenant ID | 租户 ID + TenantID uint64 `json:"tenant_id,omitempty"` + // Delete Time | 删除日期 + DeletedAt time.Time `json:"deleted_at,omitempty"` + // 用户名 + Username string `json:"username,omitempty"` + // 邮箱 + Email string `json:"email,omitempty"` + // 联系方式 + Mobile *string `json:"mobile,omitempty"` + // 密码 + PasswordHash string `json:"-"` + // salt盐值 + Salt string `json:"-"` + // 昵称 + Nickname string `json:"nickname,omitempty"` + // 头像 + Avatar *string `json:"avatar,omitempty"` + // 性别 + Gender user.Gender `json:"gender,omitempty"` + // Birthday holds the value of the "birthday" field. + Birthday *time.Time `json:"birthday,omitempty"` + // 账户状态 + AccountStatus user.AccountStatus `json:"account_status,omitempty"` + // 1 邮箱 ,2 电话号码 + IsVerified uint32 `json:"is_verified,omitempty"` + // 注册IP地址 + RegisteredLoginIP *string `json:"registered_login_ip,omitempty"` + // 登录尝试次数 + LoginAttempts int64 `json:"login_attempts,omitempty"` + // Metadata holds the value of the "metadata" field. + Metadata map[string]interface{} `json:"metadata,omitempty"` + // 注册来源 + RegistrationSource string `json:"registration_source,omitempty"` + selectValues sql.SelectValues +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*User) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case user.FieldMetadata: + values[i] = new([]byte) + case user.FieldID, user.FieldStatus, user.FieldTenantID, user.FieldIsVerified, user.FieldLoginAttempts: + values[i] = new(sql.NullInt64) + case user.FieldUsername, user.FieldEmail, user.FieldMobile, user.FieldPasswordHash, user.FieldSalt, user.FieldNickname, user.FieldAvatar, user.FieldGender, user.FieldAccountStatus, user.FieldRegisteredLoginIP, user.FieldRegistrationSource: + values[i] = new(sql.NullString) + case user.FieldCreatedAt, user.FieldUpdatedAt, user.FieldDeletedAt, user.FieldBirthday: + 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 User fields. +func (_m *User) 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 user.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + _m.ID = uint64(value.Int64) + case user.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 { + _m.CreatedAt = value.Time + } + case user.FieldUpdatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field updated_at", values[i]) + } else if value.Valid { + _m.UpdatedAt = value.Time + } + case user.FieldStatus: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field status", values[i]) + } else if value.Valid { + _m.Status = uint8(value.Int64) + } + case user.FieldTenantID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field tenant_id", values[i]) + } else if value.Valid { + _m.TenantID = uint64(value.Int64) + } + case user.FieldDeletedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field deleted_at", values[i]) + } else if value.Valid { + _m.DeletedAt = value.Time + } + case user.FieldUsername: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field username", values[i]) + } else if value.Valid { + _m.Username = value.String + } + case user.FieldEmail: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field email", values[i]) + } else if value.Valid { + _m.Email = value.String + } + case user.FieldMobile: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field mobile", values[i]) + } else if value.Valid { + _m.Mobile = new(string) + *_m.Mobile = value.String + } + case user.FieldPasswordHash: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field password_hash", values[i]) + } else if value.Valid { + _m.PasswordHash = value.String + } + case user.FieldSalt: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field salt", values[i]) + } else if value.Valid { + _m.Salt = value.String + } + case user.FieldNickname: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field nickname", values[i]) + } else if value.Valid { + _m.Nickname = value.String + } + case user.FieldAvatar: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field avatar", values[i]) + } else if value.Valid { + _m.Avatar = new(string) + *_m.Avatar = value.String + } + case user.FieldGender: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field gender", values[i]) + } else if value.Valid { + _m.Gender = user.Gender(value.String) + } + case user.FieldBirthday: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field birthday", values[i]) + } else if value.Valid { + _m.Birthday = new(time.Time) + *_m.Birthday = value.Time + } + case user.FieldAccountStatus: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field account_status", values[i]) + } else if value.Valid { + _m.AccountStatus = user.AccountStatus(value.String) + } + case user.FieldIsVerified: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field is_verified", values[i]) + } else if value.Valid { + _m.IsVerified = uint32(value.Int64) + } + case user.FieldRegisteredLoginIP: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field registered_login_ip", values[i]) + } else if value.Valid { + _m.RegisteredLoginIP = new(string) + *_m.RegisteredLoginIP = value.String + } + case user.FieldLoginAttempts: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field login_attempts", values[i]) + } else if value.Valid { + _m.LoginAttempts = value.Int64 + } + case user.FieldMetadata: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field metadata", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &_m.Metadata); err != nil { + return fmt.Errorf("unmarshal field metadata: %w", err) + } + } + case user.FieldRegistrationSource: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field registration_source", values[i]) + } else if value.Valid { + _m.RegistrationSource = value.String + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the User. +// This includes values selected through modifiers, order, etc. +func (_m *User) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// Update returns a builder for updating this User. +// Note that you need to call User.Unwrap() before calling this method if this User +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *User) Update() *UserUpdateOne { + return NewUserClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the User entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (_m *User) Unwrap() *User { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("ent: User is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *User) String() string { + var builder strings.Builder + builder.WriteString("User(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("created_at=") + builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("updated_at=") + builder.WriteString(_m.UpdatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("status=") + builder.WriteString(fmt.Sprintf("%v", _m.Status)) + builder.WriteString(", ") + builder.WriteString("tenant_id=") + builder.WriteString(fmt.Sprintf("%v", _m.TenantID)) + builder.WriteString(", ") + builder.WriteString("deleted_at=") + builder.WriteString(_m.DeletedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("username=") + builder.WriteString(_m.Username) + builder.WriteString(", ") + builder.WriteString("email=") + builder.WriteString(_m.Email) + builder.WriteString(", ") + if v := _m.Mobile; v != nil { + builder.WriteString("mobile=") + builder.WriteString(*v) + } + builder.WriteString(", ") + builder.WriteString("password_hash=") + builder.WriteString(", ") + builder.WriteString("salt=") + builder.WriteString(", ") + builder.WriteString("nickname=") + builder.WriteString(_m.Nickname) + builder.WriteString(", ") + if v := _m.Avatar; v != nil { + builder.WriteString("avatar=") + builder.WriteString(*v) + } + builder.WriteString(", ") + builder.WriteString("gender=") + builder.WriteString(fmt.Sprintf("%v", _m.Gender)) + builder.WriteString(", ") + if v := _m.Birthday; v != nil { + builder.WriteString("birthday=") + builder.WriteString(v.Format(time.ANSIC)) + } + builder.WriteString(", ") + builder.WriteString("account_status=") + builder.WriteString(fmt.Sprintf("%v", _m.AccountStatus)) + builder.WriteString(", ") + builder.WriteString("is_verified=") + builder.WriteString(fmt.Sprintf("%v", _m.IsVerified)) + builder.WriteString(", ") + if v := _m.RegisteredLoginIP; v != nil { + builder.WriteString("registered_login_ip=") + builder.WriteString(*v) + } + builder.WriteString(", ") + builder.WriteString("login_attempts=") + builder.WriteString(fmt.Sprintf("%v", _m.LoginAttempts)) + builder.WriteString(", ") + builder.WriteString("metadata=") + builder.WriteString(fmt.Sprintf("%v", _m.Metadata)) + builder.WriteString(", ") + builder.WriteString("registration_source=") + builder.WriteString(_m.RegistrationSource) + builder.WriteByte(')') + return builder.String() +} + +// Users is a parsable slice of User. +type Users []*User diff --git a/rpc/ent/user/user.go b/rpc/ent/user/user.go new file mode 100644 index 0000000..4055744 --- /dev/null +++ b/rpc/ent/user/user.go @@ -0,0 +1,290 @@ +// Code generated by ent, DO NOT EDIT. + +package user + +import ( + "fmt" + "time" + + "entgo.io/ent/dialect/sql" +) + +const ( + // Label holds the string label denoting the user type in the database. + Label = "user" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldCreatedAt holds the string denoting the created_at field in the database. + FieldCreatedAt = "created_at" + // FieldUpdatedAt holds the string denoting the updated_at field in the database. + FieldUpdatedAt = "updated_at" + // FieldStatus holds the string denoting the status field in the database. + FieldStatus = "status" + // FieldTenantID holds the string denoting the tenant_id field in the database. + FieldTenantID = "tenant_id" + // FieldDeletedAt holds the string denoting the deleted_at field in the database. + FieldDeletedAt = "deleted_at" + // FieldUsername holds the string denoting the username field in the database. + FieldUsername = "username" + // FieldEmail holds the string denoting the email field in the database. + FieldEmail = "email" + // FieldMobile holds the string denoting the mobile field in the database. + FieldMobile = "mobile" + // FieldPasswordHash holds the string denoting the password_hash field in the database. + FieldPasswordHash = "password_hash" + // FieldSalt holds the string denoting the salt field in the database. + FieldSalt = "salt" + // FieldNickname holds the string denoting the nickname field in the database. + FieldNickname = "nickname" + // FieldAvatar holds the string denoting the avatar field in the database. + FieldAvatar = "avatar" + // FieldGender holds the string denoting the gender field in the database. + FieldGender = "gender" + // FieldBirthday holds the string denoting the birthday field in the database. + FieldBirthday = "birthday" + // FieldAccountStatus holds the string denoting the account_status field in the database. + FieldAccountStatus = "account_status" + // FieldIsVerified holds the string denoting the is_verified field in the database. + FieldIsVerified = "is_verified" + // FieldRegisteredLoginIP holds the string denoting the registered_login_ip field in the database. + FieldRegisteredLoginIP = "registered_login_ip" + // FieldLoginAttempts holds the string denoting the login_attempts field in the database. + FieldLoginAttempts = "login_attempts" + // FieldMetadata holds the string denoting the metadata field in the database. + FieldMetadata = "metadata" + // FieldRegistrationSource holds the string denoting the registration_source field in the database. + FieldRegistrationSource = "registration_source" + // Table holds the table name of the user in the database. + Table = "user" +) + +// Columns holds all SQL columns for user fields. +var Columns = []string{ + FieldID, + FieldCreatedAt, + FieldUpdatedAt, + FieldStatus, + FieldTenantID, + FieldDeletedAt, + FieldUsername, + FieldEmail, + FieldMobile, + FieldPasswordHash, + FieldSalt, + FieldNickname, + FieldAvatar, + FieldGender, + FieldBirthday, + FieldAccountStatus, + FieldIsVerified, + FieldRegisteredLoginIP, + FieldLoginAttempts, + FieldMetadata, + FieldRegistrationSource, +} + +// 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 ( + // DefaultCreatedAt holds the default value on creation for the "created_at" field. + DefaultCreatedAt func() time.Time + // DefaultUpdatedAt holds the default value on creation for the "updated_at" field. + DefaultUpdatedAt func() time.Time + // UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field. + UpdateDefaultUpdatedAt func() time.Time + // DefaultStatus holds the default value on creation for the "status" field. + DefaultStatus uint8 + // DefaultTenantID holds the default value on creation for the "tenant_id" field. + DefaultTenantID uint64 + // UsernameValidator is a validator for the "username" field. It is called by the builders before save. + UsernameValidator func(string) error + // EmailValidator is a validator for the "email" field. It is called by the builders before save. + EmailValidator func(string) error + // MobileValidator is a validator for the "mobile" field. It is called by the builders before save. + MobileValidator func(string) error + // PasswordHashValidator is a validator for the "password_hash" field. It is called by the builders before save. + PasswordHashValidator func(string) error + // SaltValidator is a validator for the "salt" field. It is called by the builders before save. + SaltValidator func(string) error + // DefaultNickname holds the default value on creation for the "nickname" field. + DefaultNickname string + // NicknameValidator is a validator for the "nickname" field. It is called by the builders before save. + NicknameValidator func(string) error + // AvatarValidator is a validator for the "avatar" field. It is called by the builders before save. + AvatarValidator func(string) error + // DefaultIsVerified holds the default value on creation for the "is_verified" field. + DefaultIsVerified uint32 + // RegisteredLoginIPValidator is a validator for the "registered_login_ip" field. It is called by the builders before save. + RegisteredLoginIPValidator func(string) error + // DefaultLoginAttempts holds the default value on creation for the "login_attempts" field. + DefaultLoginAttempts int64 + // RegistrationSourceValidator is a validator for the "registration_source" field. It is called by the builders before save. + RegistrationSourceValidator func(string) error +) + +// Gender defines the type for the "gender" enum field. +type Gender string + +// GenderUnknown is the default value of the Gender enum. +const DefaultGender = GenderUnknown + +// Gender values. +const ( + GenderUnknown Gender = "unknown" + GenderMale Gender = "male" + GenderFemale Gender = "female" + GenderOther Gender = "other" +) + +func (ge Gender) String() string { + return string(ge) +} + +// GenderValidator is a validator for the "gender" field enum values. It is called by the builders before save. +func GenderValidator(ge Gender) error { + switch ge { + case GenderUnknown, GenderMale, GenderFemale, GenderOther: + return nil + default: + return fmt.Errorf("user: invalid enum value for gender field: %q", ge) + } +} + +// AccountStatus defines the type for the "account_status" enum field. +type AccountStatus string + +// AccountStatusUnverified is the default value of the AccountStatus enum. +const DefaultAccountStatus = AccountStatusUnverified + +// AccountStatus values. +const ( + AccountStatusUnverified AccountStatus = "unverified" + AccountStatusActive AccountStatus = "active" + AccountStatusLocked AccountStatus = "locked" + AccountStatusDisabled AccountStatus = "disabled" +) + +func (as AccountStatus) String() string { + return string(as) +} + +// AccountStatusValidator is a validator for the "account_status" field enum values. It is called by the builders before save. +func AccountStatusValidator(as AccountStatus) error { + switch as { + case AccountStatusUnverified, AccountStatusActive, AccountStatusLocked, AccountStatusDisabled: + return nil + default: + return fmt.Errorf("user: invalid enum value for account_status field: %q", as) + } +} + +// OrderOption defines the ordering options for the User 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() +} + +// ByCreatedAt orders the results by the created_at field. +func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() +} + +// ByUpdatedAt orders the results by the updated_at field. +func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc() +} + +// ByStatus orders the results by the status field. +func ByStatus(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStatus, opts...).ToFunc() +} + +// ByTenantID orders the results by the tenant_id field. +func ByTenantID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldTenantID, opts...).ToFunc() +} + +// ByDeletedAt orders the results by the deleted_at field. +func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeletedAt, opts...).ToFunc() +} + +// ByUsername orders the results by the username field. +func ByUsername(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUsername, opts...).ToFunc() +} + +// ByEmail orders the results by the email field. +func ByEmail(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldEmail, opts...).ToFunc() +} + +// ByMobile orders the results by the mobile field. +func ByMobile(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldMobile, opts...).ToFunc() +} + +// ByPasswordHash orders the results by the password_hash field. +func ByPasswordHash(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPasswordHash, opts...).ToFunc() +} + +// BySalt orders the results by the salt field. +func BySalt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSalt, opts...).ToFunc() +} + +// ByNickname orders the results by the nickname field. +func ByNickname(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldNickname, opts...).ToFunc() +} + +// ByAvatar orders the results by the avatar field. +func ByAvatar(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldAvatar, opts...).ToFunc() +} + +// ByGender orders the results by the gender field. +func ByGender(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldGender, opts...).ToFunc() +} + +// ByBirthday orders the results by the birthday field. +func ByBirthday(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldBirthday, opts...).ToFunc() +} + +// ByAccountStatus orders the results by the account_status field. +func ByAccountStatus(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldAccountStatus, opts...).ToFunc() +} + +// ByIsVerified orders the results by the is_verified field. +func ByIsVerified(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldIsVerified, opts...).ToFunc() +} + +// ByRegisteredLoginIP orders the results by the registered_login_ip field. +func ByRegisteredLoginIP(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldRegisteredLoginIP, opts...).ToFunc() +} + +// ByLoginAttempts orders the results by the login_attempts field. +func ByLoginAttempts(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLoginAttempts, opts...).ToFunc() +} + +// ByRegistrationSource orders the results by the registration_source field. +func ByRegistrationSource(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldRegistrationSource, opts...).ToFunc() +} diff --git a/rpc/ent/user/where.go b/rpc/ent/user/where.go new file mode 100644 index 0000000..81b7ab5 --- /dev/null +++ b/rpc/ent/user/where.go @@ -0,0 +1,1180 @@ +// Code generated by ent, DO NOT EDIT. + +package user + +import ( + "mingyang-admin-app-rpc/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" +) + +// ID filters vertices based on their ID field. +func ID(id uint64) predicate.User { + return predicate.User(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id uint64) predicate.User { + return predicate.User(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id uint64) predicate.User { + return predicate.User(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...uint64) predicate.User { + return predicate.User(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...uint64) predicate.User { + return predicate.User(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id uint64) predicate.User { + return predicate.User(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id uint64) predicate.User { + return predicate.User(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id uint64) predicate.User { + return predicate.User(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id uint64) predicate.User { + return predicate.User(sql.FieldLTE(FieldID, id)) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.User { + return predicate.User(sql.FieldEQ(FieldCreatedAt, v)) +} + +// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. +func UpdatedAt(v time.Time) predicate.User { + return predicate.User(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// Status applies equality check predicate on the "status" field. It's identical to StatusEQ. +func Status(v uint8) predicate.User { + return predicate.User(sql.FieldEQ(FieldStatus, v)) +} + +// TenantID applies equality check predicate on the "tenant_id" field. It's identical to TenantIDEQ. +func TenantID(v uint64) predicate.User { + return predicate.User(sql.FieldEQ(FieldTenantID, v)) +} + +// DeletedAt applies equality check predicate on the "deleted_at" field. It's identical to DeletedAtEQ. +func DeletedAt(v time.Time) predicate.User { + return predicate.User(sql.FieldEQ(FieldDeletedAt, v)) +} + +// Username applies equality check predicate on the "username" field. It's identical to UsernameEQ. +func Username(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldUsername, v)) +} + +// Email applies equality check predicate on the "email" field. It's identical to EmailEQ. +func Email(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldEmail, v)) +} + +// Mobile applies equality check predicate on the "mobile" field. It's identical to MobileEQ. +func Mobile(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldMobile, v)) +} + +// PasswordHash applies equality check predicate on the "password_hash" field. It's identical to PasswordHashEQ. +func PasswordHash(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldPasswordHash, v)) +} + +// Salt applies equality check predicate on the "salt" field. It's identical to SaltEQ. +func Salt(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldSalt, v)) +} + +// Nickname applies equality check predicate on the "nickname" field. It's identical to NicknameEQ. +func Nickname(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldNickname, v)) +} + +// Avatar applies equality check predicate on the "avatar" field. It's identical to AvatarEQ. +func Avatar(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldAvatar, v)) +} + +// Birthday applies equality check predicate on the "birthday" field. It's identical to BirthdayEQ. +func Birthday(v time.Time) predicate.User { + return predicate.User(sql.FieldEQ(FieldBirthday, v)) +} + +// IsVerified applies equality check predicate on the "is_verified" field. It's identical to IsVerifiedEQ. +func IsVerified(v uint32) predicate.User { + return predicate.User(sql.FieldEQ(FieldIsVerified, v)) +} + +// RegisteredLoginIP applies equality check predicate on the "registered_login_ip" field. It's identical to RegisteredLoginIPEQ. +func RegisteredLoginIP(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldRegisteredLoginIP, v)) +} + +// LoginAttempts applies equality check predicate on the "login_attempts" field. It's identical to LoginAttemptsEQ. +func LoginAttempts(v int64) predicate.User { + return predicate.User(sql.FieldEQ(FieldLoginAttempts, v)) +} + +// RegistrationSource applies equality check predicate on the "registration_source" field. It's identical to RegistrationSourceEQ. +func RegistrationSource(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldRegistrationSource, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.User { + return predicate.User(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.User { + return predicate.User(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.User { + return predicate.User(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.User { + return predicate.User(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.User { + return predicate.User(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.User { + return predicate.User(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.User { + return predicate.User(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.User { + return predicate.User(sql.FieldLTE(FieldCreatedAt, v)) +} + +// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. +func UpdatedAtEQ(v time.Time) predicate.User { + return predicate.User(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. +func UpdatedAtNEQ(v time.Time) predicate.User { + return predicate.User(sql.FieldNEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtIn applies the In predicate on the "updated_at" field. +func UpdatedAtIn(vs ...time.Time) predicate.User { + return predicate.User(sql.FieldIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. +func UpdatedAtNotIn(vs ...time.Time) predicate.User { + return predicate.User(sql.FieldNotIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtGT applies the GT predicate on the "updated_at" field. +func UpdatedAtGT(v time.Time) predicate.User { + return predicate.User(sql.FieldGT(FieldUpdatedAt, v)) +} + +// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. +func UpdatedAtGTE(v time.Time) predicate.User { + return predicate.User(sql.FieldGTE(FieldUpdatedAt, v)) +} + +// UpdatedAtLT applies the LT predicate on the "updated_at" field. +func UpdatedAtLT(v time.Time) predicate.User { + return predicate.User(sql.FieldLT(FieldUpdatedAt, v)) +} + +// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. +func UpdatedAtLTE(v time.Time) predicate.User { + return predicate.User(sql.FieldLTE(FieldUpdatedAt, v)) +} + +// StatusEQ applies the EQ predicate on the "status" field. +func StatusEQ(v uint8) predicate.User { + return predicate.User(sql.FieldEQ(FieldStatus, v)) +} + +// StatusNEQ applies the NEQ predicate on the "status" field. +func StatusNEQ(v uint8) predicate.User { + return predicate.User(sql.FieldNEQ(FieldStatus, v)) +} + +// StatusIn applies the In predicate on the "status" field. +func StatusIn(vs ...uint8) predicate.User { + return predicate.User(sql.FieldIn(FieldStatus, vs...)) +} + +// StatusNotIn applies the NotIn predicate on the "status" field. +func StatusNotIn(vs ...uint8) predicate.User { + return predicate.User(sql.FieldNotIn(FieldStatus, vs...)) +} + +// StatusGT applies the GT predicate on the "status" field. +func StatusGT(v uint8) predicate.User { + return predicate.User(sql.FieldGT(FieldStatus, v)) +} + +// StatusGTE applies the GTE predicate on the "status" field. +func StatusGTE(v uint8) predicate.User { + return predicate.User(sql.FieldGTE(FieldStatus, v)) +} + +// StatusLT applies the LT predicate on the "status" field. +func StatusLT(v uint8) predicate.User { + return predicate.User(sql.FieldLT(FieldStatus, v)) +} + +// StatusLTE applies the LTE predicate on the "status" field. +func StatusLTE(v uint8) predicate.User { + return predicate.User(sql.FieldLTE(FieldStatus, v)) +} + +// StatusIsNil applies the IsNil predicate on the "status" field. +func StatusIsNil() predicate.User { + return predicate.User(sql.FieldIsNull(FieldStatus)) +} + +// StatusNotNil applies the NotNil predicate on the "status" field. +func StatusNotNil() predicate.User { + return predicate.User(sql.FieldNotNull(FieldStatus)) +} + +// TenantIDEQ applies the EQ predicate on the "tenant_id" field. +func TenantIDEQ(v uint64) predicate.User { + return predicate.User(sql.FieldEQ(FieldTenantID, v)) +} + +// TenantIDNEQ applies the NEQ predicate on the "tenant_id" field. +func TenantIDNEQ(v uint64) predicate.User { + return predicate.User(sql.FieldNEQ(FieldTenantID, v)) +} + +// TenantIDIn applies the In predicate on the "tenant_id" field. +func TenantIDIn(vs ...uint64) predicate.User { + return predicate.User(sql.FieldIn(FieldTenantID, vs...)) +} + +// TenantIDNotIn applies the NotIn predicate on the "tenant_id" field. +func TenantIDNotIn(vs ...uint64) predicate.User { + return predicate.User(sql.FieldNotIn(FieldTenantID, vs...)) +} + +// TenantIDGT applies the GT predicate on the "tenant_id" field. +func TenantIDGT(v uint64) predicate.User { + return predicate.User(sql.FieldGT(FieldTenantID, v)) +} + +// TenantIDGTE applies the GTE predicate on the "tenant_id" field. +func TenantIDGTE(v uint64) predicate.User { + return predicate.User(sql.FieldGTE(FieldTenantID, v)) +} + +// TenantIDLT applies the LT predicate on the "tenant_id" field. +func TenantIDLT(v uint64) predicate.User { + return predicate.User(sql.FieldLT(FieldTenantID, v)) +} + +// TenantIDLTE applies the LTE predicate on the "tenant_id" field. +func TenantIDLTE(v uint64) predicate.User { + return predicate.User(sql.FieldLTE(FieldTenantID, v)) +} + +// DeletedAtEQ applies the EQ predicate on the "deleted_at" field. +func DeletedAtEQ(v time.Time) predicate.User { + return predicate.User(sql.FieldEQ(FieldDeletedAt, v)) +} + +// DeletedAtNEQ applies the NEQ predicate on the "deleted_at" field. +func DeletedAtNEQ(v time.Time) predicate.User { + return predicate.User(sql.FieldNEQ(FieldDeletedAt, v)) +} + +// DeletedAtIn applies the In predicate on the "deleted_at" field. +func DeletedAtIn(vs ...time.Time) predicate.User { + return predicate.User(sql.FieldIn(FieldDeletedAt, vs...)) +} + +// DeletedAtNotIn applies the NotIn predicate on the "deleted_at" field. +func DeletedAtNotIn(vs ...time.Time) predicate.User { + return predicate.User(sql.FieldNotIn(FieldDeletedAt, vs...)) +} + +// DeletedAtGT applies the GT predicate on the "deleted_at" field. +func DeletedAtGT(v time.Time) predicate.User { + return predicate.User(sql.FieldGT(FieldDeletedAt, v)) +} + +// DeletedAtGTE applies the GTE predicate on the "deleted_at" field. +func DeletedAtGTE(v time.Time) predicate.User { + return predicate.User(sql.FieldGTE(FieldDeletedAt, v)) +} + +// DeletedAtLT applies the LT predicate on the "deleted_at" field. +func DeletedAtLT(v time.Time) predicate.User { + return predicate.User(sql.FieldLT(FieldDeletedAt, v)) +} + +// DeletedAtLTE applies the LTE predicate on the "deleted_at" field. +func DeletedAtLTE(v time.Time) predicate.User { + return predicate.User(sql.FieldLTE(FieldDeletedAt, v)) +} + +// DeletedAtIsNil applies the IsNil predicate on the "deleted_at" field. +func DeletedAtIsNil() predicate.User { + return predicate.User(sql.FieldIsNull(FieldDeletedAt)) +} + +// DeletedAtNotNil applies the NotNil predicate on the "deleted_at" field. +func DeletedAtNotNil() predicate.User { + return predicate.User(sql.FieldNotNull(FieldDeletedAt)) +} + +// UsernameEQ applies the EQ predicate on the "username" field. +func UsernameEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldUsername, v)) +} + +// UsernameNEQ applies the NEQ predicate on the "username" field. +func UsernameNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldUsername, v)) +} + +// UsernameIn applies the In predicate on the "username" field. +func UsernameIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldUsername, vs...)) +} + +// UsernameNotIn applies the NotIn predicate on the "username" field. +func UsernameNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldUsername, vs...)) +} + +// UsernameGT applies the GT predicate on the "username" field. +func UsernameGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldUsername, v)) +} + +// UsernameGTE applies the GTE predicate on the "username" field. +func UsernameGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldUsername, v)) +} + +// UsernameLT applies the LT predicate on the "username" field. +func UsernameLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldUsername, v)) +} + +// UsernameLTE applies the LTE predicate on the "username" field. +func UsernameLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldUsername, v)) +} + +// UsernameContains applies the Contains predicate on the "username" field. +func UsernameContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldUsername, v)) +} + +// UsernameHasPrefix applies the HasPrefix predicate on the "username" field. +func UsernameHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldUsername, v)) +} + +// UsernameHasSuffix applies the HasSuffix predicate on the "username" field. +func UsernameHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldUsername, v)) +} + +// UsernameEqualFold applies the EqualFold predicate on the "username" field. +func UsernameEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldUsername, v)) +} + +// UsernameContainsFold applies the ContainsFold predicate on the "username" field. +func UsernameContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldUsername, v)) +} + +// EmailEQ applies the EQ predicate on the "email" field. +func EmailEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldEmail, v)) +} + +// EmailNEQ applies the NEQ predicate on the "email" field. +func EmailNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldEmail, v)) +} + +// EmailIn applies the In predicate on the "email" field. +func EmailIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldEmail, vs...)) +} + +// EmailNotIn applies the NotIn predicate on the "email" field. +func EmailNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldEmail, vs...)) +} + +// EmailGT applies the GT predicate on the "email" field. +func EmailGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldEmail, v)) +} + +// EmailGTE applies the GTE predicate on the "email" field. +func EmailGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldEmail, v)) +} + +// EmailLT applies the LT predicate on the "email" field. +func EmailLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldEmail, v)) +} + +// EmailLTE applies the LTE predicate on the "email" field. +func EmailLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldEmail, v)) +} + +// EmailContains applies the Contains predicate on the "email" field. +func EmailContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldEmail, v)) +} + +// EmailHasPrefix applies the HasPrefix predicate on the "email" field. +func EmailHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldEmail, v)) +} + +// EmailHasSuffix applies the HasSuffix predicate on the "email" field. +func EmailHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldEmail, v)) +} + +// EmailEqualFold applies the EqualFold predicate on the "email" field. +func EmailEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldEmail, v)) +} + +// EmailContainsFold applies the ContainsFold predicate on the "email" field. +func EmailContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldEmail, v)) +} + +// MobileEQ applies the EQ predicate on the "mobile" field. +func MobileEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldMobile, v)) +} + +// MobileNEQ applies the NEQ predicate on the "mobile" field. +func MobileNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldMobile, v)) +} + +// MobileIn applies the In predicate on the "mobile" field. +func MobileIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldMobile, vs...)) +} + +// MobileNotIn applies the NotIn predicate on the "mobile" field. +func MobileNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldMobile, vs...)) +} + +// MobileGT applies the GT predicate on the "mobile" field. +func MobileGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldMobile, v)) +} + +// MobileGTE applies the GTE predicate on the "mobile" field. +func MobileGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldMobile, v)) +} + +// MobileLT applies the LT predicate on the "mobile" field. +func MobileLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldMobile, v)) +} + +// MobileLTE applies the LTE predicate on the "mobile" field. +func MobileLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldMobile, v)) +} + +// MobileContains applies the Contains predicate on the "mobile" field. +func MobileContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldMobile, v)) +} + +// MobileHasPrefix applies the HasPrefix predicate on the "mobile" field. +func MobileHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldMobile, v)) +} + +// MobileHasSuffix applies the HasSuffix predicate on the "mobile" field. +func MobileHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldMobile, v)) +} + +// MobileIsNil applies the IsNil predicate on the "mobile" field. +func MobileIsNil() predicate.User { + return predicate.User(sql.FieldIsNull(FieldMobile)) +} + +// MobileNotNil applies the NotNil predicate on the "mobile" field. +func MobileNotNil() predicate.User { + return predicate.User(sql.FieldNotNull(FieldMobile)) +} + +// MobileEqualFold applies the EqualFold predicate on the "mobile" field. +func MobileEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldMobile, v)) +} + +// MobileContainsFold applies the ContainsFold predicate on the "mobile" field. +func MobileContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldMobile, v)) +} + +// PasswordHashEQ applies the EQ predicate on the "password_hash" field. +func PasswordHashEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldPasswordHash, v)) +} + +// PasswordHashNEQ applies the NEQ predicate on the "password_hash" field. +func PasswordHashNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldPasswordHash, v)) +} + +// PasswordHashIn applies the In predicate on the "password_hash" field. +func PasswordHashIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldPasswordHash, vs...)) +} + +// PasswordHashNotIn applies the NotIn predicate on the "password_hash" field. +func PasswordHashNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldPasswordHash, vs...)) +} + +// PasswordHashGT applies the GT predicate on the "password_hash" field. +func PasswordHashGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldPasswordHash, v)) +} + +// PasswordHashGTE applies the GTE predicate on the "password_hash" field. +func PasswordHashGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldPasswordHash, v)) +} + +// PasswordHashLT applies the LT predicate on the "password_hash" field. +func PasswordHashLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldPasswordHash, v)) +} + +// PasswordHashLTE applies the LTE predicate on the "password_hash" field. +func PasswordHashLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldPasswordHash, v)) +} + +// PasswordHashContains applies the Contains predicate on the "password_hash" field. +func PasswordHashContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldPasswordHash, v)) +} + +// PasswordHashHasPrefix applies the HasPrefix predicate on the "password_hash" field. +func PasswordHashHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldPasswordHash, v)) +} + +// PasswordHashHasSuffix applies the HasSuffix predicate on the "password_hash" field. +func PasswordHashHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldPasswordHash, v)) +} + +// PasswordHashEqualFold applies the EqualFold predicate on the "password_hash" field. +func PasswordHashEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldPasswordHash, v)) +} + +// PasswordHashContainsFold applies the ContainsFold predicate on the "password_hash" field. +func PasswordHashContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldPasswordHash, v)) +} + +// SaltEQ applies the EQ predicate on the "salt" field. +func SaltEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldSalt, v)) +} + +// SaltNEQ applies the NEQ predicate on the "salt" field. +func SaltNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldSalt, v)) +} + +// SaltIn applies the In predicate on the "salt" field. +func SaltIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldSalt, vs...)) +} + +// SaltNotIn applies the NotIn predicate on the "salt" field. +func SaltNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldSalt, vs...)) +} + +// SaltGT applies the GT predicate on the "salt" field. +func SaltGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldSalt, v)) +} + +// SaltGTE applies the GTE predicate on the "salt" field. +func SaltGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldSalt, v)) +} + +// SaltLT applies the LT predicate on the "salt" field. +func SaltLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldSalt, v)) +} + +// SaltLTE applies the LTE predicate on the "salt" field. +func SaltLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldSalt, v)) +} + +// SaltContains applies the Contains predicate on the "salt" field. +func SaltContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldSalt, v)) +} + +// SaltHasPrefix applies the HasPrefix predicate on the "salt" field. +func SaltHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldSalt, v)) +} + +// SaltHasSuffix applies the HasSuffix predicate on the "salt" field. +func SaltHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldSalt, v)) +} + +// SaltEqualFold applies the EqualFold predicate on the "salt" field. +func SaltEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldSalt, v)) +} + +// SaltContainsFold applies the ContainsFold predicate on the "salt" field. +func SaltContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldSalt, v)) +} + +// NicknameEQ applies the EQ predicate on the "nickname" field. +func NicknameEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldNickname, v)) +} + +// NicknameNEQ applies the NEQ predicate on the "nickname" field. +func NicknameNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldNickname, v)) +} + +// NicknameIn applies the In predicate on the "nickname" field. +func NicknameIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldNickname, vs...)) +} + +// NicknameNotIn applies the NotIn predicate on the "nickname" field. +func NicknameNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldNickname, vs...)) +} + +// NicknameGT applies the GT predicate on the "nickname" field. +func NicknameGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldNickname, v)) +} + +// NicknameGTE applies the GTE predicate on the "nickname" field. +func NicknameGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldNickname, v)) +} + +// NicknameLT applies the LT predicate on the "nickname" field. +func NicknameLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldNickname, v)) +} + +// NicknameLTE applies the LTE predicate on the "nickname" field. +func NicknameLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldNickname, v)) +} + +// NicknameContains applies the Contains predicate on the "nickname" field. +func NicknameContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldNickname, v)) +} + +// NicknameHasPrefix applies the HasPrefix predicate on the "nickname" field. +func NicknameHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldNickname, v)) +} + +// NicknameHasSuffix applies the HasSuffix predicate on the "nickname" field. +func NicknameHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldNickname, v)) +} + +// NicknameEqualFold applies the EqualFold predicate on the "nickname" field. +func NicknameEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldNickname, v)) +} + +// NicknameContainsFold applies the ContainsFold predicate on the "nickname" field. +func NicknameContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldNickname, v)) +} + +// AvatarEQ applies the EQ predicate on the "avatar" field. +func AvatarEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldAvatar, v)) +} + +// AvatarNEQ applies the NEQ predicate on the "avatar" field. +func AvatarNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldAvatar, v)) +} + +// AvatarIn applies the In predicate on the "avatar" field. +func AvatarIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldAvatar, vs...)) +} + +// AvatarNotIn applies the NotIn predicate on the "avatar" field. +func AvatarNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldAvatar, vs...)) +} + +// AvatarGT applies the GT predicate on the "avatar" field. +func AvatarGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldAvatar, v)) +} + +// AvatarGTE applies the GTE predicate on the "avatar" field. +func AvatarGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldAvatar, v)) +} + +// AvatarLT applies the LT predicate on the "avatar" field. +func AvatarLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldAvatar, v)) +} + +// AvatarLTE applies the LTE predicate on the "avatar" field. +func AvatarLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldAvatar, v)) +} + +// AvatarContains applies the Contains predicate on the "avatar" field. +func AvatarContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldAvatar, v)) +} + +// AvatarHasPrefix applies the HasPrefix predicate on the "avatar" field. +func AvatarHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldAvatar, v)) +} + +// AvatarHasSuffix applies the HasSuffix predicate on the "avatar" field. +func AvatarHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldAvatar, v)) +} + +// AvatarIsNil applies the IsNil predicate on the "avatar" field. +func AvatarIsNil() predicate.User { + return predicate.User(sql.FieldIsNull(FieldAvatar)) +} + +// AvatarNotNil applies the NotNil predicate on the "avatar" field. +func AvatarNotNil() predicate.User { + return predicate.User(sql.FieldNotNull(FieldAvatar)) +} + +// AvatarEqualFold applies the EqualFold predicate on the "avatar" field. +func AvatarEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldAvatar, v)) +} + +// AvatarContainsFold applies the ContainsFold predicate on the "avatar" field. +func AvatarContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldAvatar, v)) +} + +// GenderEQ applies the EQ predicate on the "gender" field. +func GenderEQ(v Gender) predicate.User { + return predicate.User(sql.FieldEQ(FieldGender, v)) +} + +// GenderNEQ applies the NEQ predicate on the "gender" field. +func GenderNEQ(v Gender) predicate.User { + return predicate.User(sql.FieldNEQ(FieldGender, v)) +} + +// GenderIn applies the In predicate on the "gender" field. +func GenderIn(vs ...Gender) predicate.User { + return predicate.User(sql.FieldIn(FieldGender, vs...)) +} + +// GenderNotIn applies the NotIn predicate on the "gender" field. +func GenderNotIn(vs ...Gender) predicate.User { + return predicate.User(sql.FieldNotIn(FieldGender, vs...)) +} + +// BirthdayEQ applies the EQ predicate on the "birthday" field. +func BirthdayEQ(v time.Time) predicate.User { + return predicate.User(sql.FieldEQ(FieldBirthday, v)) +} + +// BirthdayNEQ applies the NEQ predicate on the "birthday" field. +func BirthdayNEQ(v time.Time) predicate.User { + return predicate.User(sql.FieldNEQ(FieldBirthday, v)) +} + +// BirthdayIn applies the In predicate on the "birthday" field. +func BirthdayIn(vs ...time.Time) predicate.User { + return predicate.User(sql.FieldIn(FieldBirthday, vs...)) +} + +// BirthdayNotIn applies the NotIn predicate on the "birthday" field. +func BirthdayNotIn(vs ...time.Time) predicate.User { + return predicate.User(sql.FieldNotIn(FieldBirthday, vs...)) +} + +// BirthdayGT applies the GT predicate on the "birthday" field. +func BirthdayGT(v time.Time) predicate.User { + return predicate.User(sql.FieldGT(FieldBirthday, v)) +} + +// BirthdayGTE applies the GTE predicate on the "birthday" field. +func BirthdayGTE(v time.Time) predicate.User { + return predicate.User(sql.FieldGTE(FieldBirthday, v)) +} + +// BirthdayLT applies the LT predicate on the "birthday" field. +func BirthdayLT(v time.Time) predicate.User { + return predicate.User(sql.FieldLT(FieldBirthday, v)) +} + +// BirthdayLTE applies the LTE predicate on the "birthday" field. +func BirthdayLTE(v time.Time) predicate.User { + return predicate.User(sql.FieldLTE(FieldBirthday, v)) +} + +// BirthdayIsNil applies the IsNil predicate on the "birthday" field. +func BirthdayIsNil() predicate.User { + return predicate.User(sql.FieldIsNull(FieldBirthday)) +} + +// BirthdayNotNil applies the NotNil predicate on the "birthday" field. +func BirthdayNotNil() predicate.User { + return predicate.User(sql.FieldNotNull(FieldBirthday)) +} + +// AccountStatusEQ applies the EQ predicate on the "account_status" field. +func AccountStatusEQ(v AccountStatus) predicate.User { + return predicate.User(sql.FieldEQ(FieldAccountStatus, v)) +} + +// AccountStatusNEQ applies the NEQ predicate on the "account_status" field. +func AccountStatusNEQ(v AccountStatus) predicate.User { + return predicate.User(sql.FieldNEQ(FieldAccountStatus, v)) +} + +// AccountStatusIn applies the In predicate on the "account_status" field. +func AccountStatusIn(vs ...AccountStatus) predicate.User { + return predicate.User(sql.FieldIn(FieldAccountStatus, vs...)) +} + +// AccountStatusNotIn applies the NotIn predicate on the "account_status" field. +func AccountStatusNotIn(vs ...AccountStatus) predicate.User { + return predicate.User(sql.FieldNotIn(FieldAccountStatus, vs...)) +} + +// IsVerifiedEQ applies the EQ predicate on the "is_verified" field. +func IsVerifiedEQ(v uint32) predicate.User { + return predicate.User(sql.FieldEQ(FieldIsVerified, v)) +} + +// IsVerifiedNEQ applies the NEQ predicate on the "is_verified" field. +func IsVerifiedNEQ(v uint32) predicate.User { + return predicate.User(sql.FieldNEQ(FieldIsVerified, v)) +} + +// IsVerifiedIn applies the In predicate on the "is_verified" field. +func IsVerifiedIn(vs ...uint32) predicate.User { + return predicate.User(sql.FieldIn(FieldIsVerified, vs...)) +} + +// IsVerifiedNotIn applies the NotIn predicate on the "is_verified" field. +func IsVerifiedNotIn(vs ...uint32) predicate.User { + return predicate.User(sql.FieldNotIn(FieldIsVerified, vs...)) +} + +// IsVerifiedGT applies the GT predicate on the "is_verified" field. +func IsVerifiedGT(v uint32) predicate.User { + return predicate.User(sql.FieldGT(FieldIsVerified, v)) +} + +// IsVerifiedGTE applies the GTE predicate on the "is_verified" field. +func IsVerifiedGTE(v uint32) predicate.User { + return predicate.User(sql.FieldGTE(FieldIsVerified, v)) +} + +// IsVerifiedLT applies the LT predicate on the "is_verified" field. +func IsVerifiedLT(v uint32) predicate.User { + return predicate.User(sql.FieldLT(FieldIsVerified, v)) +} + +// IsVerifiedLTE applies the LTE predicate on the "is_verified" field. +func IsVerifiedLTE(v uint32) predicate.User { + return predicate.User(sql.FieldLTE(FieldIsVerified, v)) +} + +// RegisteredLoginIPEQ applies the EQ predicate on the "registered_login_ip" field. +func RegisteredLoginIPEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldRegisteredLoginIP, v)) +} + +// RegisteredLoginIPNEQ applies the NEQ predicate on the "registered_login_ip" field. +func RegisteredLoginIPNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldRegisteredLoginIP, v)) +} + +// RegisteredLoginIPIn applies the In predicate on the "registered_login_ip" field. +func RegisteredLoginIPIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldRegisteredLoginIP, vs...)) +} + +// RegisteredLoginIPNotIn applies the NotIn predicate on the "registered_login_ip" field. +func RegisteredLoginIPNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldRegisteredLoginIP, vs...)) +} + +// RegisteredLoginIPGT applies the GT predicate on the "registered_login_ip" field. +func RegisteredLoginIPGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldRegisteredLoginIP, v)) +} + +// RegisteredLoginIPGTE applies the GTE predicate on the "registered_login_ip" field. +func RegisteredLoginIPGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldRegisteredLoginIP, v)) +} + +// RegisteredLoginIPLT applies the LT predicate on the "registered_login_ip" field. +func RegisteredLoginIPLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldRegisteredLoginIP, v)) +} + +// RegisteredLoginIPLTE applies the LTE predicate on the "registered_login_ip" field. +func RegisteredLoginIPLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldRegisteredLoginIP, v)) +} + +// RegisteredLoginIPContains applies the Contains predicate on the "registered_login_ip" field. +func RegisteredLoginIPContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldRegisteredLoginIP, v)) +} + +// RegisteredLoginIPHasPrefix applies the HasPrefix predicate on the "registered_login_ip" field. +func RegisteredLoginIPHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldRegisteredLoginIP, v)) +} + +// RegisteredLoginIPHasSuffix applies the HasSuffix predicate on the "registered_login_ip" field. +func RegisteredLoginIPHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldRegisteredLoginIP, v)) +} + +// RegisteredLoginIPIsNil applies the IsNil predicate on the "registered_login_ip" field. +func RegisteredLoginIPIsNil() predicate.User { + return predicate.User(sql.FieldIsNull(FieldRegisteredLoginIP)) +} + +// RegisteredLoginIPNotNil applies the NotNil predicate on the "registered_login_ip" field. +func RegisteredLoginIPNotNil() predicate.User { + return predicate.User(sql.FieldNotNull(FieldRegisteredLoginIP)) +} + +// RegisteredLoginIPEqualFold applies the EqualFold predicate on the "registered_login_ip" field. +func RegisteredLoginIPEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldRegisteredLoginIP, v)) +} + +// RegisteredLoginIPContainsFold applies the ContainsFold predicate on the "registered_login_ip" field. +func RegisteredLoginIPContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldRegisteredLoginIP, v)) +} + +// LoginAttemptsEQ applies the EQ predicate on the "login_attempts" field. +func LoginAttemptsEQ(v int64) predicate.User { + return predicate.User(sql.FieldEQ(FieldLoginAttempts, v)) +} + +// LoginAttemptsNEQ applies the NEQ predicate on the "login_attempts" field. +func LoginAttemptsNEQ(v int64) predicate.User { + return predicate.User(sql.FieldNEQ(FieldLoginAttempts, v)) +} + +// LoginAttemptsIn applies the In predicate on the "login_attempts" field. +func LoginAttemptsIn(vs ...int64) predicate.User { + return predicate.User(sql.FieldIn(FieldLoginAttempts, vs...)) +} + +// LoginAttemptsNotIn applies the NotIn predicate on the "login_attempts" field. +func LoginAttemptsNotIn(vs ...int64) predicate.User { + return predicate.User(sql.FieldNotIn(FieldLoginAttempts, vs...)) +} + +// LoginAttemptsGT applies the GT predicate on the "login_attempts" field. +func LoginAttemptsGT(v int64) predicate.User { + return predicate.User(sql.FieldGT(FieldLoginAttempts, v)) +} + +// LoginAttemptsGTE applies the GTE predicate on the "login_attempts" field. +func LoginAttemptsGTE(v int64) predicate.User { + return predicate.User(sql.FieldGTE(FieldLoginAttempts, v)) +} + +// LoginAttemptsLT applies the LT predicate on the "login_attempts" field. +func LoginAttemptsLT(v int64) predicate.User { + return predicate.User(sql.FieldLT(FieldLoginAttempts, v)) +} + +// LoginAttemptsLTE applies the LTE predicate on the "login_attempts" field. +func LoginAttemptsLTE(v int64) predicate.User { + return predicate.User(sql.FieldLTE(FieldLoginAttempts, v)) +} + +// MetadataIsNil applies the IsNil predicate on the "metadata" field. +func MetadataIsNil() predicate.User { + return predicate.User(sql.FieldIsNull(FieldMetadata)) +} + +// MetadataNotNil applies the NotNil predicate on the "metadata" field. +func MetadataNotNil() predicate.User { + return predicate.User(sql.FieldNotNull(FieldMetadata)) +} + +// RegistrationSourceEQ applies the EQ predicate on the "registration_source" field. +func RegistrationSourceEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldRegistrationSource, v)) +} + +// RegistrationSourceNEQ applies the NEQ predicate on the "registration_source" field. +func RegistrationSourceNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldRegistrationSource, v)) +} + +// RegistrationSourceIn applies the In predicate on the "registration_source" field. +func RegistrationSourceIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldRegistrationSource, vs...)) +} + +// RegistrationSourceNotIn applies the NotIn predicate on the "registration_source" field. +func RegistrationSourceNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldRegistrationSource, vs...)) +} + +// RegistrationSourceGT applies the GT predicate on the "registration_source" field. +func RegistrationSourceGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldRegistrationSource, v)) +} + +// RegistrationSourceGTE applies the GTE predicate on the "registration_source" field. +func RegistrationSourceGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldRegistrationSource, v)) +} + +// RegistrationSourceLT applies the LT predicate on the "registration_source" field. +func RegistrationSourceLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldRegistrationSource, v)) +} + +// RegistrationSourceLTE applies the LTE predicate on the "registration_source" field. +func RegistrationSourceLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldRegistrationSource, v)) +} + +// RegistrationSourceContains applies the Contains predicate on the "registration_source" field. +func RegistrationSourceContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldRegistrationSource, v)) +} + +// RegistrationSourceHasPrefix applies the HasPrefix predicate on the "registration_source" field. +func RegistrationSourceHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldRegistrationSource, v)) +} + +// RegistrationSourceHasSuffix applies the HasSuffix predicate on the "registration_source" field. +func RegistrationSourceHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldRegistrationSource, v)) +} + +// RegistrationSourceIsNil applies the IsNil predicate on the "registration_source" field. +func RegistrationSourceIsNil() predicate.User { + return predicate.User(sql.FieldIsNull(FieldRegistrationSource)) +} + +// RegistrationSourceNotNil applies the NotNil predicate on the "registration_source" field. +func RegistrationSourceNotNil() predicate.User { + return predicate.User(sql.FieldNotNull(FieldRegistrationSource)) +} + +// RegistrationSourceEqualFold applies the EqualFold predicate on the "registration_source" field. +func RegistrationSourceEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldRegistrationSource, v)) +} + +// RegistrationSourceContainsFold applies the ContainsFold predicate on the "registration_source" field. +func RegistrationSourceContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldRegistrationSource, v)) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.User) predicate.User { + return predicate.User(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.User) predicate.User { + return predicate.User(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.User) predicate.User { + return predicate.User(sql.NotPredicates(p)) +} diff --git a/rpc/ent/user_create.go b/rpc/ent/user_create.go new file mode 100644 index 0000000..e9ccbb8 --- /dev/null +++ b/rpc/ent/user_create.go @@ -0,0 +1,636 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "mingyang-admin-app-rpc/ent/user" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// UserCreate is the builder for creating a User entity. +type UserCreate struct { + config + mutation *UserMutation + hooks []Hook +} + +// SetCreatedAt sets the "created_at" field. +func (_c *UserCreate) SetCreatedAt(v time.Time) *UserCreate { + _c.mutation.SetCreatedAt(v) + return _c +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_c *UserCreate) SetNillableCreatedAt(v *time.Time) *UserCreate { + if v != nil { + _c.SetCreatedAt(*v) + } + return _c +} + +// SetUpdatedAt sets the "updated_at" field. +func (_c *UserCreate) SetUpdatedAt(v time.Time) *UserCreate { + _c.mutation.SetUpdatedAt(v) + return _c +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (_c *UserCreate) SetNillableUpdatedAt(v *time.Time) *UserCreate { + if v != nil { + _c.SetUpdatedAt(*v) + } + return _c +} + +// SetStatus sets the "status" field. +func (_c *UserCreate) SetStatus(v uint8) *UserCreate { + _c.mutation.SetStatus(v) + return _c +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_c *UserCreate) SetNillableStatus(v *uint8) *UserCreate { + if v != nil { + _c.SetStatus(*v) + } + return _c +} + +// SetTenantID sets the "tenant_id" field. +func (_c *UserCreate) SetTenantID(v uint64) *UserCreate { + _c.mutation.SetTenantID(v) + return _c +} + +// SetNillableTenantID sets the "tenant_id" field if the given value is not nil. +func (_c *UserCreate) SetNillableTenantID(v *uint64) *UserCreate { + if v != nil { + _c.SetTenantID(*v) + } + return _c +} + +// SetDeletedAt sets the "deleted_at" field. +func (_c *UserCreate) SetDeletedAt(v time.Time) *UserCreate { + _c.mutation.SetDeletedAt(v) + return _c +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (_c *UserCreate) SetNillableDeletedAt(v *time.Time) *UserCreate { + if v != nil { + _c.SetDeletedAt(*v) + } + return _c +} + +// SetUsername sets the "username" field. +func (_c *UserCreate) SetUsername(v string) *UserCreate { + _c.mutation.SetUsername(v) + return _c +} + +// SetEmail sets the "email" field. +func (_c *UserCreate) SetEmail(v string) *UserCreate { + _c.mutation.SetEmail(v) + return _c +} + +// SetMobile sets the "mobile" field. +func (_c *UserCreate) SetMobile(v string) *UserCreate { + _c.mutation.SetMobile(v) + return _c +} + +// SetNillableMobile sets the "mobile" field if the given value is not nil. +func (_c *UserCreate) SetNillableMobile(v *string) *UserCreate { + if v != nil { + _c.SetMobile(*v) + } + return _c +} + +// SetPasswordHash sets the "password_hash" field. +func (_c *UserCreate) SetPasswordHash(v string) *UserCreate { + _c.mutation.SetPasswordHash(v) + return _c +} + +// SetSalt sets the "salt" field. +func (_c *UserCreate) SetSalt(v string) *UserCreate { + _c.mutation.SetSalt(v) + return _c +} + +// SetNickname sets the "nickname" field. +func (_c *UserCreate) SetNickname(v string) *UserCreate { + _c.mutation.SetNickname(v) + return _c +} + +// SetNillableNickname sets the "nickname" field if the given value is not nil. +func (_c *UserCreate) SetNillableNickname(v *string) *UserCreate { + if v != nil { + _c.SetNickname(*v) + } + return _c +} + +// SetAvatar sets the "avatar" field. +func (_c *UserCreate) SetAvatar(v string) *UserCreate { + _c.mutation.SetAvatar(v) + return _c +} + +// SetNillableAvatar sets the "avatar" field if the given value is not nil. +func (_c *UserCreate) SetNillableAvatar(v *string) *UserCreate { + if v != nil { + _c.SetAvatar(*v) + } + return _c +} + +// SetGender sets the "gender" field. +func (_c *UserCreate) SetGender(v user.Gender) *UserCreate { + _c.mutation.SetGender(v) + return _c +} + +// SetNillableGender sets the "gender" field if the given value is not nil. +func (_c *UserCreate) SetNillableGender(v *user.Gender) *UserCreate { + if v != nil { + _c.SetGender(*v) + } + return _c +} + +// SetBirthday sets the "birthday" field. +func (_c *UserCreate) SetBirthday(v time.Time) *UserCreate { + _c.mutation.SetBirthday(v) + return _c +} + +// SetNillableBirthday sets the "birthday" field if the given value is not nil. +func (_c *UserCreate) SetNillableBirthday(v *time.Time) *UserCreate { + if v != nil { + _c.SetBirthday(*v) + } + return _c +} + +// SetAccountStatus sets the "account_status" field. +func (_c *UserCreate) SetAccountStatus(v user.AccountStatus) *UserCreate { + _c.mutation.SetAccountStatus(v) + return _c +} + +// SetNillableAccountStatus sets the "account_status" field if the given value is not nil. +func (_c *UserCreate) SetNillableAccountStatus(v *user.AccountStatus) *UserCreate { + if v != nil { + _c.SetAccountStatus(*v) + } + return _c +} + +// SetIsVerified sets the "is_verified" field. +func (_c *UserCreate) SetIsVerified(v uint32) *UserCreate { + _c.mutation.SetIsVerified(v) + return _c +} + +// SetNillableIsVerified sets the "is_verified" field if the given value is not nil. +func (_c *UserCreate) SetNillableIsVerified(v *uint32) *UserCreate { + if v != nil { + _c.SetIsVerified(*v) + } + return _c +} + +// SetRegisteredLoginIP sets the "registered_login_ip" field. +func (_c *UserCreate) SetRegisteredLoginIP(v string) *UserCreate { + _c.mutation.SetRegisteredLoginIP(v) + return _c +} + +// SetNillableRegisteredLoginIP sets the "registered_login_ip" field if the given value is not nil. +func (_c *UserCreate) SetNillableRegisteredLoginIP(v *string) *UserCreate { + if v != nil { + _c.SetRegisteredLoginIP(*v) + } + return _c +} + +// SetLoginAttempts sets the "login_attempts" field. +func (_c *UserCreate) SetLoginAttempts(v int64) *UserCreate { + _c.mutation.SetLoginAttempts(v) + return _c +} + +// SetNillableLoginAttempts sets the "login_attempts" field if the given value is not nil. +func (_c *UserCreate) SetNillableLoginAttempts(v *int64) *UserCreate { + if v != nil { + _c.SetLoginAttempts(*v) + } + return _c +} + +// SetMetadata sets the "metadata" field. +func (_c *UserCreate) SetMetadata(v map[string]interface{}) *UserCreate { + _c.mutation.SetMetadata(v) + return _c +} + +// SetRegistrationSource sets the "registration_source" field. +func (_c *UserCreate) SetRegistrationSource(v string) *UserCreate { + _c.mutation.SetRegistrationSource(v) + return _c +} + +// SetNillableRegistrationSource sets the "registration_source" field if the given value is not nil. +func (_c *UserCreate) SetNillableRegistrationSource(v *string) *UserCreate { + if v != nil { + _c.SetRegistrationSource(*v) + } + return _c +} + +// SetID sets the "id" field. +func (_c *UserCreate) SetID(v uint64) *UserCreate { + _c.mutation.SetID(v) + return _c +} + +// Mutation returns the UserMutation object of the builder. +func (_c *UserCreate) Mutation() *UserMutation { + return _c.mutation +} + +// Save creates the User in the database. +func (_c *UserCreate) Save(ctx context.Context) (*User, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *UserCreate) SaveX(ctx context.Context) *User { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *UserCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *UserCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_c *UserCreate) defaults() { + if _, ok := _c.mutation.CreatedAt(); !ok { + v := user.DefaultCreatedAt() + _c.mutation.SetCreatedAt(v) + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + v := user.DefaultUpdatedAt() + _c.mutation.SetUpdatedAt(v) + } + if _, ok := _c.mutation.Status(); !ok { + v := user.DefaultStatus + _c.mutation.SetStatus(v) + } + if _, ok := _c.mutation.TenantID(); !ok { + v := user.DefaultTenantID + _c.mutation.SetTenantID(v) + } + if _, ok := _c.mutation.Nickname(); !ok { + v := user.DefaultNickname + _c.mutation.SetNickname(v) + } + if _, ok := _c.mutation.Gender(); !ok { + v := user.DefaultGender + _c.mutation.SetGender(v) + } + if _, ok := _c.mutation.AccountStatus(); !ok { + v := user.DefaultAccountStatus + _c.mutation.SetAccountStatus(v) + } + if _, ok := _c.mutation.IsVerified(); !ok { + v := user.DefaultIsVerified + _c.mutation.SetIsVerified(v) + } + if _, ok := _c.mutation.LoginAttempts(); !ok { + v := user.DefaultLoginAttempts + _c.mutation.SetLoginAttempts(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *UserCreate) check() error { + if _, ok := _c.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "User.created_at"`)} + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "User.updated_at"`)} + } + if _, ok := _c.mutation.TenantID(); !ok { + return &ValidationError{Name: "tenant_id", err: errors.New(`ent: missing required field "User.tenant_id"`)} + } + if _, ok := _c.mutation.Username(); !ok { + return &ValidationError{Name: "username", err: errors.New(`ent: missing required field "User.username"`)} + } + if v, ok := _c.mutation.Username(); ok { + if err := user.UsernameValidator(v); err != nil { + return &ValidationError{Name: "username", err: fmt.Errorf(`ent: validator failed for field "User.username": %w`, err)} + } + } + if _, ok := _c.mutation.Email(); !ok { + return &ValidationError{Name: "email", err: errors.New(`ent: missing required field "User.email"`)} + } + if v, ok := _c.mutation.Email(); ok { + if err := user.EmailValidator(v); err != nil { + return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "User.email": %w`, err)} + } + } + if v, ok := _c.mutation.Mobile(); ok { + if err := user.MobileValidator(v); err != nil { + return &ValidationError{Name: "mobile", err: fmt.Errorf(`ent: validator failed for field "User.mobile": %w`, err)} + } + } + if _, ok := _c.mutation.PasswordHash(); !ok { + return &ValidationError{Name: "password_hash", err: errors.New(`ent: missing required field "User.password_hash"`)} + } + if v, ok := _c.mutation.PasswordHash(); ok { + if err := user.PasswordHashValidator(v); err != nil { + return &ValidationError{Name: "password_hash", err: fmt.Errorf(`ent: validator failed for field "User.password_hash": %w`, err)} + } + } + if _, ok := _c.mutation.Salt(); !ok { + return &ValidationError{Name: "salt", err: errors.New(`ent: missing required field "User.salt"`)} + } + if v, ok := _c.mutation.Salt(); ok { + if err := user.SaltValidator(v); err != nil { + return &ValidationError{Name: "salt", err: fmt.Errorf(`ent: validator failed for field "User.salt": %w`, err)} + } + } + if _, ok := _c.mutation.Nickname(); !ok { + return &ValidationError{Name: "nickname", err: errors.New(`ent: missing required field "User.nickname"`)} + } + if v, ok := _c.mutation.Nickname(); ok { + if err := user.NicknameValidator(v); err != nil { + return &ValidationError{Name: "nickname", err: fmt.Errorf(`ent: validator failed for field "User.nickname": %w`, err)} + } + } + if v, ok := _c.mutation.Avatar(); ok { + if err := user.AvatarValidator(v); err != nil { + return &ValidationError{Name: "avatar", err: fmt.Errorf(`ent: validator failed for field "User.avatar": %w`, err)} + } + } + if _, ok := _c.mutation.Gender(); !ok { + return &ValidationError{Name: "gender", err: errors.New(`ent: missing required field "User.gender"`)} + } + if v, ok := _c.mutation.Gender(); ok { + if err := user.GenderValidator(v); err != nil { + return &ValidationError{Name: "gender", err: fmt.Errorf(`ent: validator failed for field "User.gender": %w`, err)} + } + } + if _, ok := _c.mutation.AccountStatus(); !ok { + return &ValidationError{Name: "account_status", err: errors.New(`ent: missing required field "User.account_status"`)} + } + if v, ok := _c.mutation.AccountStatus(); ok { + if err := user.AccountStatusValidator(v); err != nil { + return &ValidationError{Name: "account_status", err: fmt.Errorf(`ent: validator failed for field "User.account_status": %w`, err)} + } + } + if _, ok := _c.mutation.IsVerified(); !ok { + return &ValidationError{Name: "is_verified", err: errors.New(`ent: missing required field "User.is_verified"`)} + } + if v, ok := _c.mutation.RegisteredLoginIP(); ok { + if err := user.RegisteredLoginIPValidator(v); err != nil { + return &ValidationError{Name: "registered_login_ip", err: fmt.Errorf(`ent: validator failed for field "User.registered_login_ip": %w`, err)} + } + } + if _, ok := _c.mutation.LoginAttempts(); !ok { + return &ValidationError{Name: "login_attempts", err: errors.New(`ent: missing required field "User.login_attempts"`)} + } + if v, ok := _c.mutation.RegistrationSource(); ok { + if err := user.RegistrationSourceValidator(v); err != nil { + return &ValidationError{Name: "registration_source", err: fmt.Errorf(`ent: validator failed for field "User.registration_source": %w`, err)} + } + } + return nil +} + +func (_c *UserCreate) sqlSave(ctx context.Context) (*User, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != _node.ID { + id := _spec.ID.Value.(int64) + _node.ID = uint64(id) + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { + var ( + _node = &User{config: _c.config} + _spec = sqlgraph.NewCreateSpec(user.Table, sqlgraph.NewFieldSpec(user.FieldID, field.TypeUint64)) + ) + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := _c.mutation.CreatedAt(); ok { + _spec.SetField(user.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := _c.mutation.UpdatedAt(); ok { + _spec.SetField(user.FieldUpdatedAt, field.TypeTime, value) + _node.UpdatedAt = value + } + if value, ok := _c.mutation.Status(); ok { + _spec.SetField(user.FieldStatus, field.TypeUint8, value) + _node.Status = value + } + if value, ok := _c.mutation.TenantID(); ok { + _spec.SetField(user.FieldTenantID, field.TypeUint64, value) + _node.TenantID = value + } + if value, ok := _c.mutation.DeletedAt(); ok { + _spec.SetField(user.FieldDeletedAt, field.TypeTime, value) + _node.DeletedAt = value + } + if value, ok := _c.mutation.Username(); ok { + _spec.SetField(user.FieldUsername, field.TypeString, value) + _node.Username = value + } + if value, ok := _c.mutation.Email(); ok { + _spec.SetField(user.FieldEmail, field.TypeString, value) + _node.Email = value + } + if value, ok := _c.mutation.Mobile(); ok { + _spec.SetField(user.FieldMobile, field.TypeString, value) + _node.Mobile = &value + } + if value, ok := _c.mutation.PasswordHash(); ok { + _spec.SetField(user.FieldPasswordHash, field.TypeString, value) + _node.PasswordHash = value + } + if value, ok := _c.mutation.Salt(); ok { + _spec.SetField(user.FieldSalt, field.TypeString, value) + _node.Salt = value + } + if value, ok := _c.mutation.Nickname(); ok { + _spec.SetField(user.FieldNickname, field.TypeString, value) + _node.Nickname = value + } + if value, ok := _c.mutation.Avatar(); ok { + _spec.SetField(user.FieldAvatar, field.TypeString, value) + _node.Avatar = &value + } + if value, ok := _c.mutation.Gender(); ok { + _spec.SetField(user.FieldGender, field.TypeEnum, value) + _node.Gender = value + } + if value, ok := _c.mutation.Birthday(); ok { + _spec.SetField(user.FieldBirthday, field.TypeTime, value) + _node.Birthday = &value + } + if value, ok := _c.mutation.AccountStatus(); ok { + _spec.SetField(user.FieldAccountStatus, field.TypeEnum, value) + _node.AccountStatus = value + } + if value, ok := _c.mutation.IsVerified(); ok { + _spec.SetField(user.FieldIsVerified, field.TypeUint32, value) + _node.IsVerified = value + } + if value, ok := _c.mutation.RegisteredLoginIP(); ok { + _spec.SetField(user.FieldRegisteredLoginIP, field.TypeString, value) + _node.RegisteredLoginIP = &value + } + if value, ok := _c.mutation.LoginAttempts(); ok { + _spec.SetField(user.FieldLoginAttempts, field.TypeInt64, value) + _node.LoginAttempts = value + } + if value, ok := _c.mutation.Metadata(); ok { + _spec.SetField(user.FieldMetadata, field.TypeJSON, value) + _node.Metadata = value + } + if value, ok := _c.mutation.RegistrationSource(); ok { + _spec.SetField(user.FieldRegistrationSource, field.TypeString, value) + _node.RegistrationSource = value + } + return _node, _spec +} + +// UserCreateBulk is the builder for creating many User entities in bulk. +type UserCreateBulk struct { + config + err error + builders []*UserCreate +} + +// Save creates the User entities in the database. +func (_c *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*User, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*UserMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil && nodes[i].ID == 0 { + id := specs[i].ID.Value.(int64) + nodes[i].ID = uint64(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *UserCreateBulk) SaveX(ctx context.Context) []*User { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *UserCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *UserCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/rpc/ent/user_delete.go b/rpc/ent/user_delete.go new file mode 100644 index 0000000..1ddd85e --- /dev/null +++ b/rpc/ent/user_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "mingyang-admin-app-rpc/ent/predicate" + "mingyang-admin-app-rpc/ent/user" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// UserDelete is the builder for deleting a User entity. +type UserDelete struct { + config + hooks []Hook + mutation *UserMutation +} + +// Where appends a list predicates to the UserDelete builder. +func (_d *UserDelete) Where(ps ...predicate.User) *UserDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *UserDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *UserDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *UserDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(user.Table, sqlgraph.NewFieldSpec(user.FieldID, field.TypeUint64)) + if ps := _d.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + _d.mutation.done = true + return affected, err +} + +// UserDeleteOne is the builder for deleting a single User entity. +type UserDeleteOne struct { + _d *UserDelete +} + +// Where appends a list predicates to the UserDelete builder. +func (_d *UserDeleteOne) Where(ps ...predicate.User) *UserDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *UserDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{user.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *UserDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/rpc/ent/user_query.go b/rpc/ent/user_query.go new file mode 100644 index 0000000..4be6bd4 --- /dev/null +++ b/rpc/ent/user_query.go @@ -0,0 +1,527 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + "mingyang-admin-app-rpc/ent/predicate" + "mingyang-admin-app-rpc/ent/user" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// UserQuery is the builder for querying User entities. +type UserQuery struct { + config + ctx *QueryContext + order []user.OrderOption + inters []Interceptor + predicates []predicate.User + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the UserQuery builder. +func (_q *UserQuery) Where(ps ...predicate.User) *UserQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *UserQuery) Limit(limit int) *UserQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *UserQuery) Offset(offset int) *UserQuery { + _q.ctx.Offset = &offset + return _q +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (_q *UserQuery) Unique(unique bool) *UserQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *UserQuery) Order(o ...user.OrderOption) *UserQuery { + _q.order = append(_q.order, o...) + return _q +} + +// First returns the first User entity from the query. +// Returns a *NotFoundError when no User was found. +func (_q *UserQuery) First(ctx context.Context) (*User, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{user.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *UserQuery) FirstX(ctx context.Context) *User { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first User ID from the query. +// Returns a *NotFoundError when no User ID was found. +func (_q *UserQuery) FirstID(ctx context.Context) (id uint64, err error) { + var ids []uint64 + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{user.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *UserQuery) FirstIDX(ctx context.Context) uint64 { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single User entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one User entity is found. +// Returns a *NotFoundError when no User entities are found. +func (_q *UserQuery) Only(ctx context.Context) (*User, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{user.Label} + default: + return nil, &NotSingularError{user.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *UserQuery) OnlyX(ctx context.Context) *User { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only User ID in the query. +// Returns a *NotSingularError when more than one User ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *UserQuery) OnlyID(ctx context.Context) (id uint64, err error) { + var ids []uint64 + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{user.Label} + default: + err = &NotSingularError{user.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *UserQuery) OnlyIDX(ctx context.Context) uint64 { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of Users. +func (_q *UserQuery) All(ctx context.Context) ([]*User, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*User, *UserQuery]() + return withInterceptors[[]*User](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *UserQuery) AllX(ctx context.Context) []*User { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of User IDs. +func (_q *UserQuery) IDs(ctx context.Context) (ids []uint64, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(user.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *UserQuery) IDsX(ctx context.Context) []uint64 { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *UserQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, _q, querierCount[*UserQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *UserQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (_q *UserQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *UserQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the UserQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (_q *UserQuery) Clone() *UserQuery { + if _q == nil { + return nil + } + return &UserQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]user.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.User{}, _q.predicates...), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + } +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// CreatedAt time.Time `json:"created_at,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.User.Query(). +// GroupBy(user.FieldCreatedAt). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *UserQuery) GroupBy(field string, fields ...string) *UserGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &UserGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = user.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 { +// CreatedAt time.Time `json:"created_at,omitempty"` +// } +// +// client.User.Query(). +// Select(user.FieldCreatedAt). +// Scan(ctx, &v) +func (_q *UserQuery) Select(fields ...string) *UserSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &UserSelect{UserQuery: _q} + sbuild.label = user.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a UserSelect configured with the given aggregations. +func (_q *UserQuery) Aggregate(fns ...AggregateFunc) *UserSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *UserQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !user.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if _q.path != nil { + prev, err := _q.path(ctx) + if err != nil { + return err + } + _q.sql = prev + } + return nil +} + +func (_q *UserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*User, error) { + var ( + nodes = []*User{} + _spec = _q.querySpec() + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*User).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &User{config: _q.config} + nodes = append(nodes, node) + return node.assignValues(columns, values) + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + return nodes, nil +} + +func (_q *UserQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique + } + return sqlgraph.CountNodes(ctx, _q.driver, _spec) +} + +func (_q *UserQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeUint64)) + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if _q.path != nil { + _spec.Unique = true + } + if fields := _q.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, user.FieldID) + for i := range fields { + if fields[i] != user.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := _q.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := _q.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := _q.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := _q.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (_q *UserQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(user.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = user.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if _q.sql != nil { + selector = _q.sql + selector.Select(selector.Columns(columns...)...) + } + if _q.ctx.Unique != nil && *_q.ctx.Unique { + selector.Distinct() + } + for _, p := range _q.predicates { + p(selector) + } + for _, p := range _q.order { + p(selector) + } + if offset := _q.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := _q.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// UserGroupBy is the group-by builder for User entities. +type UserGroupBy struct { + selector + build *UserQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *UserGroupBy) Aggregate(fns ...AggregateFunc) *UserGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *UserGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*UserQuery, *UserGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *UserGroupBy) sqlScan(ctx context.Context, root *UserQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*_g.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// UserSelect is the builder for selecting fields of User entities. +type UserSelect struct { + *UserQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *UserSelect) Aggregate(fns ...AggregateFunc) *UserSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *UserSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*UserQuery, *UserSelect](ctx, _s.UserQuery, _s, _s.inters, v) +} + +func (_s *UserSelect) sqlScan(ctx context.Context, root *UserQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/rpc/ent/user_update.go b/rpc/ent/user_update.go new file mode 100644 index 0000000..cb469a2 --- /dev/null +++ b/rpc/ent/user_update.go @@ -0,0 +1,1104 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "mingyang-admin-app-rpc/ent/predicate" + "mingyang-admin-app-rpc/ent/user" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// UserUpdate is the builder for updating User entities. +type UserUpdate struct { + config + hooks []Hook + mutation *UserMutation +} + +// Where appends a list predicates to the UserUpdate builder. +func (_u *UserUpdate) Where(ps ...predicate.User) *UserUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *UserUpdate) SetUpdatedAt(v time.Time) *UserUpdate { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// SetStatus sets the "status" field. +func (_u *UserUpdate) SetStatus(v uint8) *UserUpdate { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_u *UserUpdate) SetNillableStatus(v *uint8) *UserUpdate { + if v != nil { + _u.SetStatus(*v) + } + return _u +} + +// AddStatus adds value to the "status" field. +func (_u *UserUpdate) AddStatus(v int8) *UserUpdate { + _u.mutation.AddStatus(v) + return _u +} + +// ClearStatus clears the value of the "status" field. +func (_u *UserUpdate) ClearStatus() *UserUpdate { + _u.mutation.ClearStatus() + return _u +} + +// SetDeletedAt sets the "deleted_at" field. +func (_u *UserUpdate) SetDeletedAt(v time.Time) *UserUpdate { + _u.mutation.SetDeletedAt(v) + return _u +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (_u *UserUpdate) SetNillableDeletedAt(v *time.Time) *UserUpdate { + if v != nil { + _u.SetDeletedAt(*v) + } + return _u +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (_u *UserUpdate) ClearDeletedAt() *UserUpdate { + _u.mutation.ClearDeletedAt() + return _u +} + +// SetUsername sets the "username" field. +func (_u *UserUpdate) SetUsername(v string) *UserUpdate { + _u.mutation.SetUsername(v) + return _u +} + +// SetNillableUsername sets the "username" field if the given value is not nil. +func (_u *UserUpdate) SetNillableUsername(v *string) *UserUpdate { + if v != nil { + _u.SetUsername(*v) + } + return _u +} + +// SetEmail sets the "email" field. +func (_u *UserUpdate) SetEmail(v string) *UserUpdate { + _u.mutation.SetEmail(v) + return _u +} + +// SetNillableEmail sets the "email" field if the given value is not nil. +func (_u *UserUpdate) SetNillableEmail(v *string) *UserUpdate { + if v != nil { + _u.SetEmail(*v) + } + return _u +} + +// SetMobile sets the "mobile" field. +func (_u *UserUpdate) SetMobile(v string) *UserUpdate { + _u.mutation.SetMobile(v) + return _u +} + +// SetNillableMobile sets the "mobile" field if the given value is not nil. +func (_u *UserUpdate) SetNillableMobile(v *string) *UserUpdate { + if v != nil { + _u.SetMobile(*v) + } + return _u +} + +// ClearMobile clears the value of the "mobile" field. +func (_u *UserUpdate) ClearMobile() *UserUpdate { + _u.mutation.ClearMobile() + return _u +} + +// SetPasswordHash sets the "password_hash" field. +func (_u *UserUpdate) SetPasswordHash(v string) *UserUpdate { + _u.mutation.SetPasswordHash(v) + return _u +} + +// SetNillablePasswordHash sets the "password_hash" field if the given value is not nil. +func (_u *UserUpdate) SetNillablePasswordHash(v *string) *UserUpdate { + if v != nil { + _u.SetPasswordHash(*v) + } + return _u +} + +// SetSalt sets the "salt" field. +func (_u *UserUpdate) SetSalt(v string) *UserUpdate { + _u.mutation.SetSalt(v) + return _u +} + +// SetNillableSalt sets the "salt" field if the given value is not nil. +func (_u *UserUpdate) SetNillableSalt(v *string) *UserUpdate { + if v != nil { + _u.SetSalt(*v) + } + return _u +} + +// SetNickname sets the "nickname" field. +func (_u *UserUpdate) SetNickname(v string) *UserUpdate { + _u.mutation.SetNickname(v) + return _u +} + +// SetNillableNickname sets the "nickname" field if the given value is not nil. +func (_u *UserUpdate) SetNillableNickname(v *string) *UserUpdate { + if v != nil { + _u.SetNickname(*v) + } + return _u +} + +// SetAvatar sets the "avatar" field. +func (_u *UserUpdate) SetAvatar(v string) *UserUpdate { + _u.mutation.SetAvatar(v) + return _u +} + +// SetNillableAvatar sets the "avatar" field if the given value is not nil. +func (_u *UserUpdate) SetNillableAvatar(v *string) *UserUpdate { + if v != nil { + _u.SetAvatar(*v) + } + return _u +} + +// ClearAvatar clears the value of the "avatar" field. +func (_u *UserUpdate) ClearAvatar() *UserUpdate { + _u.mutation.ClearAvatar() + return _u +} + +// SetGender sets the "gender" field. +func (_u *UserUpdate) SetGender(v user.Gender) *UserUpdate { + _u.mutation.SetGender(v) + return _u +} + +// SetNillableGender sets the "gender" field if the given value is not nil. +func (_u *UserUpdate) SetNillableGender(v *user.Gender) *UserUpdate { + if v != nil { + _u.SetGender(*v) + } + return _u +} + +// SetBirthday sets the "birthday" field. +func (_u *UserUpdate) SetBirthday(v time.Time) *UserUpdate { + _u.mutation.SetBirthday(v) + return _u +} + +// SetNillableBirthday sets the "birthday" field if the given value is not nil. +func (_u *UserUpdate) SetNillableBirthday(v *time.Time) *UserUpdate { + if v != nil { + _u.SetBirthday(*v) + } + return _u +} + +// ClearBirthday clears the value of the "birthday" field. +func (_u *UserUpdate) ClearBirthday() *UserUpdate { + _u.mutation.ClearBirthday() + return _u +} + +// SetAccountStatus sets the "account_status" field. +func (_u *UserUpdate) SetAccountStatus(v user.AccountStatus) *UserUpdate { + _u.mutation.SetAccountStatus(v) + return _u +} + +// SetNillableAccountStatus sets the "account_status" field if the given value is not nil. +func (_u *UserUpdate) SetNillableAccountStatus(v *user.AccountStatus) *UserUpdate { + if v != nil { + _u.SetAccountStatus(*v) + } + return _u +} + +// SetIsVerified sets the "is_verified" field. +func (_u *UserUpdate) SetIsVerified(v uint32) *UserUpdate { + _u.mutation.ResetIsVerified() + _u.mutation.SetIsVerified(v) + return _u +} + +// SetNillableIsVerified sets the "is_verified" field if the given value is not nil. +func (_u *UserUpdate) SetNillableIsVerified(v *uint32) *UserUpdate { + if v != nil { + _u.SetIsVerified(*v) + } + return _u +} + +// AddIsVerified adds value to the "is_verified" field. +func (_u *UserUpdate) AddIsVerified(v int32) *UserUpdate { + _u.mutation.AddIsVerified(v) + return _u +} + +// SetRegisteredLoginIP sets the "registered_login_ip" field. +func (_u *UserUpdate) SetRegisteredLoginIP(v string) *UserUpdate { + _u.mutation.SetRegisteredLoginIP(v) + return _u +} + +// SetNillableRegisteredLoginIP sets the "registered_login_ip" field if the given value is not nil. +func (_u *UserUpdate) SetNillableRegisteredLoginIP(v *string) *UserUpdate { + if v != nil { + _u.SetRegisteredLoginIP(*v) + } + return _u +} + +// ClearRegisteredLoginIP clears the value of the "registered_login_ip" field. +func (_u *UserUpdate) ClearRegisteredLoginIP() *UserUpdate { + _u.mutation.ClearRegisteredLoginIP() + return _u +} + +// SetLoginAttempts sets the "login_attempts" field. +func (_u *UserUpdate) SetLoginAttempts(v int64) *UserUpdate { + _u.mutation.ResetLoginAttempts() + _u.mutation.SetLoginAttempts(v) + return _u +} + +// SetNillableLoginAttempts sets the "login_attempts" field if the given value is not nil. +func (_u *UserUpdate) SetNillableLoginAttempts(v *int64) *UserUpdate { + if v != nil { + _u.SetLoginAttempts(*v) + } + return _u +} + +// AddLoginAttempts adds value to the "login_attempts" field. +func (_u *UserUpdate) AddLoginAttempts(v int64) *UserUpdate { + _u.mutation.AddLoginAttempts(v) + return _u +} + +// SetMetadata sets the "metadata" field. +func (_u *UserUpdate) SetMetadata(v map[string]interface{}) *UserUpdate { + _u.mutation.SetMetadata(v) + return _u +} + +// ClearMetadata clears the value of the "metadata" field. +func (_u *UserUpdate) ClearMetadata() *UserUpdate { + _u.mutation.ClearMetadata() + return _u +} + +// SetRegistrationSource sets the "registration_source" field. +func (_u *UserUpdate) SetRegistrationSource(v string) *UserUpdate { + _u.mutation.SetRegistrationSource(v) + return _u +} + +// SetNillableRegistrationSource sets the "registration_source" field if the given value is not nil. +func (_u *UserUpdate) SetNillableRegistrationSource(v *string) *UserUpdate { + if v != nil { + _u.SetRegistrationSource(*v) + } + return _u +} + +// ClearRegistrationSource clears the value of the "registration_source" field. +func (_u *UserUpdate) ClearRegistrationSource() *UserUpdate { + _u.mutation.ClearRegistrationSource() + return _u +} + +// Mutation returns the UserMutation object of the builder. +func (_u *UserUpdate) Mutation() *UserMutation { + return _u.mutation +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *UserUpdate) Save(ctx context.Context) (int, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *UserUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *UserUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *UserUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *UserUpdate) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := user.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *UserUpdate) check() error { + if v, ok := _u.mutation.Username(); ok { + if err := user.UsernameValidator(v); err != nil { + return &ValidationError{Name: "username", err: fmt.Errorf(`ent: validator failed for field "User.username": %w`, err)} + } + } + if v, ok := _u.mutation.Email(); ok { + if err := user.EmailValidator(v); err != nil { + return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "User.email": %w`, err)} + } + } + if v, ok := _u.mutation.Mobile(); ok { + if err := user.MobileValidator(v); err != nil { + return &ValidationError{Name: "mobile", err: fmt.Errorf(`ent: validator failed for field "User.mobile": %w`, err)} + } + } + if v, ok := _u.mutation.PasswordHash(); ok { + if err := user.PasswordHashValidator(v); err != nil { + return &ValidationError{Name: "password_hash", err: fmt.Errorf(`ent: validator failed for field "User.password_hash": %w`, err)} + } + } + if v, ok := _u.mutation.Salt(); ok { + if err := user.SaltValidator(v); err != nil { + return &ValidationError{Name: "salt", err: fmt.Errorf(`ent: validator failed for field "User.salt": %w`, err)} + } + } + if v, ok := _u.mutation.Nickname(); ok { + if err := user.NicknameValidator(v); err != nil { + return &ValidationError{Name: "nickname", err: fmt.Errorf(`ent: validator failed for field "User.nickname": %w`, err)} + } + } + if v, ok := _u.mutation.Avatar(); ok { + if err := user.AvatarValidator(v); err != nil { + return &ValidationError{Name: "avatar", err: fmt.Errorf(`ent: validator failed for field "User.avatar": %w`, err)} + } + } + if v, ok := _u.mutation.Gender(); ok { + if err := user.GenderValidator(v); err != nil { + return &ValidationError{Name: "gender", err: fmt.Errorf(`ent: validator failed for field "User.gender": %w`, err)} + } + } + if v, ok := _u.mutation.AccountStatus(); ok { + if err := user.AccountStatusValidator(v); err != nil { + return &ValidationError{Name: "account_status", err: fmt.Errorf(`ent: validator failed for field "User.account_status": %w`, err)} + } + } + if v, ok := _u.mutation.RegisteredLoginIP(); ok { + if err := user.RegisteredLoginIPValidator(v); err != nil { + return &ValidationError{Name: "registered_login_ip", err: fmt.Errorf(`ent: validator failed for field "User.registered_login_ip": %w`, err)} + } + } + if v, ok := _u.mutation.RegistrationSource(); ok { + if err := user.RegistrationSourceValidator(v); err != nil { + return &ValidationError{Name: "registration_source", err: fmt.Errorf(`ent: validator failed for field "User.registration_source": %w`, err)} + } + } + return nil +} + +func (_u *UserUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeUint64)) + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.UpdatedAt(); ok { + _spec.SetField(user.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.Status(); ok { + _spec.SetField(user.FieldStatus, field.TypeUint8, value) + } + if value, ok := _u.mutation.AddedStatus(); ok { + _spec.AddField(user.FieldStatus, field.TypeUint8, value) + } + if _u.mutation.StatusCleared() { + _spec.ClearField(user.FieldStatus, field.TypeUint8) + } + if value, ok := _u.mutation.DeletedAt(); ok { + _spec.SetField(user.FieldDeletedAt, field.TypeTime, value) + } + if _u.mutation.DeletedAtCleared() { + _spec.ClearField(user.FieldDeletedAt, field.TypeTime) + } + if value, ok := _u.mutation.Username(); ok { + _spec.SetField(user.FieldUsername, field.TypeString, value) + } + if value, ok := _u.mutation.Email(); ok { + _spec.SetField(user.FieldEmail, field.TypeString, value) + } + if value, ok := _u.mutation.Mobile(); ok { + _spec.SetField(user.FieldMobile, field.TypeString, value) + } + if _u.mutation.MobileCleared() { + _spec.ClearField(user.FieldMobile, field.TypeString) + } + if value, ok := _u.mutation.PasswordHash(); ok { + _spec.SetField(user.FieldPasswordHash, field.TypeString, value) + } + if value, ok := _u.mutation.Salt(); ok { + _spec.SetField(user.FieldSalt, field.TypeString, value) + } + if value, ok := _u.mutation.Nickname(); ok { + _spec.SetField(user.FieldNickname, field.TypeString, value) + } + if value, ok := _u.mutation.Avatar(); ok { + _spec.SetField(user.FieldAvatar, field.TypeString, value) + } + if _u.mutation.AvatarCleared() { + _spec.ClearField(user.FieldAvatar, field.TypeString) + } + if value, ok := _u.mutation.Gender(); ok { + _spec.SetField(user.FieldGender, field.TypeEnum, value) + } + if value, ok := _u.mutation.Birthday(); ok { + _spec.SetField(user.FieldBirthday, field.TypeTime, value) + } + if _u.mutation.BirthdayCleared() { + _spec.ClearField(user.FieldBirthday, field.TypeTime) + } + if value, ok := _u.mutation.AccountStatus(); ok { + _spec.SetField(user.FieldAccountStatus, field.TypeEnum, value) + } + if value, ok := _u.mutation.IsVerified(); ok { + _spec.SetField(user.FieldIsVerified, field.TypeUint32, value) + } + if value, ok := _u.mutation.AddedIsVerified(); ok { + _spec.AddField(user.FieldIsVerified, field.TypeUint32, value) + } + if value, ok := _u.mutation.RegisteredLoginIP(); ok { + _spec.SetField(user.FieldRegisteredLoginIP, field.TypeString, value) + } + if _u.mutation.RegisteredLoginIPCleared() { + _spec.ClearField(user.FieldRegisteredLoginIP, field.TypeString) + } + if value, ok := _u.mutation.LoginAttempts(); ok { + _spec.SetField(user.FieldLoginAttempts, field.TypeInt64, value) + } + if value, ok := _u.mutation.AddedLoginAttempts(); ok { + _spec.AddField(user.FieldLoginAttempts, field.TypeInt64, value) + } + if value, ok := _u.mutation.Metadata(); ok { + _spec.SetField(user.FieldMetadata, field.TypeJSON, value) + } + if _u.mutation.MetadataCleared() { + _spec.ClearField(user.FieldMetadata, field.TypeJSON) + } + if value, ok := _u.mutation.RegistrationSource(); ok { + _spec.SetField(user.FieldRegistrationSource, field.TypeString, value) + } + if _u.mutation.RegistrationSourceCleared() { + _spec.ClearField(user.FieldRegistrationSource, field.TypeString) + } + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{user.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// UserUpdateOne is the builder for updating a single User entity. +type UserUpdateOne struct { + config + fields []string + hooks []Hook + mutation *UserMutation +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *UserUpdateOne) SetUpdatedAt(v time.Time) *UserUpdateOne { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// SetStatus sets the "status" field. +func (_u *UserUpdateOne) SetStatus(v uint8) *UserUpdateOne { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_u *UserUpdateOne) SetNillableStatus(v *uint8) *UserUpdateOne { + if v != nil { + _u.SetStatus(*v) + } + return _u +} + +// AddStatus adds value to the "status" field. +func (_u *UserUpdateOne) AddStatus(v int8) *UserUpdateOne { + _u.mutation.AddStatus(v) + return _u +} + +// ClearStatus clears the value of the "status" field. +func (_u *UserUpdateOne) ClearStatus() *UserUpdateOne { + _u.mutation.ClearStatus() + return _u +} + +// SetDeletedAt sets the "deleted_at" field. +func (_u *UserUpdateOne) SetDeletedAt(v time.Time) *UserUpdateOne { + _u.mutation.SetDeletedAt(v) + return _u +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (_u *UserUpdateOne) SetNillableDeletedAt(v *time.Time) *UserUpdateOne { + if v != nil { + _u.SetDeletedAt(*v) + } + return _u +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (_u *UserUpdateOne) ClearDeletedAt() *UserUpdateOne { + _u.mutation.ClearDeletedAt() + return _u +} + +// SetUsername sets the "username" field. +func (_u *UserUpdateOne) SetUsername(v string) *UserUpdateOne { + _u.mutation.SetUsername(v) + return _u +} + +// SetNillableUsername sets the "username" field if the given value is not nil. +func (_u *UserUpdateOne) SetNillableUsername(v *string) *UserUpdateOne { + if v != nil { + _u.SetUsername(*v) + } + return _u +} + +// SetEmail sets the "email" field. +func (_u *UserUpdateOne) SetEmail(v string) *UserUpdateOne { + _u.mutation.SetEmail(v) + return _u +} + +// SetNillableEmail sets the "email" field if the given value is not nil. +func (_u *UserUpdateOne) SetNillableEmail(v *string) *UserUpdateOne { + if v != nil { + _u.SetEmail(*v) + } + return _u +} + +// SetMobile sets the "mobile" field. +func (_u *UserUpdateOne) SetMobile(v string) *UserUpdateOne { + _u.mutation.SetMobile(v) + return _u +} + +// SetNillableMobile sets the "mobile" field if the given value is not nil. +func (_u *UserUpdateOne) SetNillableMobile(v *string) *UserUpdateOne { + if v != nil { + _u.SetMobile(*v) + } + return _u +} + +// ClearMobile clears the value of the "mobile" field. +func (_u *UserUpdateOne) ClearMobile() *UserUpdateOne { + _u.mutation.ClearMobile() + return _u +} + +// SetPasswordHash sets the "password_hash" field. +func (_u *UserUpdateOne) SetPasswordHash(v string) *UserUpdateOne { + _u.mutation.SetPasswordHash(v) + return _u +} + +// SetNillablePasswordHash sets the "password_hash" field if the given value is not nil. +func (_u *UserUpdateOne) SetNillablePasswordHash(v *string) *UserUpdateOne { + if v != nil { + _u.SetPasswordHash(*v) + } + return _u +} + +// SetSalt sets the "salt" field. +func (_u *UserUpdateOne) SetSalt(v string) *UserUpdateOne { + _u.mutation.SetSalt(v) + return _u +} + +// SetNillableSalt sets the "salt" field if the given value is not nil. +func (_u *UserUpdateOne) SetNillableSalt(v *string) *UserUpdateOne { + if v != nil { + _u.SetSalt(*v) + } + return _u +} + +// SetNickname sets the "nickname" field. +func (_u *UserUpdateOne) SetNickname(v string) *UserUpdateOne { + _u.mutation.SetNickname(v) + return _u +} + +// SetNillableNickname sets the "nickname" field if the given value is not nil. +func (_u *UserUpdateOne) SetNillableNickname(v *string) *UserUpdateOne { + if v != nil { + _u.SetNickname(*v) + } + return _u +} + +// SetAvatar sets the "avatar" field. +func (_u *UserUpdateOne) SetAvatar(v string) *UserUpdateOne { + _u.mutation.SetAvatar(v) + return _u +} + +// SetNillableAvatar sets the "avatar" field if the given value is not nil. +func (_u *UserUpdateOne) SetNillableAvatar(v *string) *UserUpdateOne { + if v != nil { + _u.SetAvatar(*v) + } + return _u +} + +// ClearAvatar clears the value of the "avatar" field. +func (_u *UserUpdateOne) ClearAvatar() *UserUpdateOne { + _u.mutation.ClearAvatar() + return _u +} + +// SetGender sets the "gender" field. +func (_u *UserUpdateOne) SetGender(v user.Gender) *UserUpdateOne { + _u.mutation.SetGender(v) + return _u +} + +// SetNillableGender sets the "gender" field if the given value is not nil. +func (_u *UserUpdateOne) SetNillableGender(v *user.Gender) *UserUpdateOne { + if v != nil { + _u.SetGender(*v) + } + return _u +} + +// SetBirthday sets the "birthday" field. +func (_u *UserUpdateOne) SetBirthday(v time.Time) *UserUpdateOne { + _u.mutation.SetBirthday(v) + return _u +} + +// SetNillableBirthday sets the "birthday" field if the given value is not nil. +func (_u *UserUpdateOne) SetNillableBirthday(v *time.Time) *UserUpdateOne { + if v != nil { + _u.SetBirthday(*v) + } + return _u +} + +// ClearBirthday clears the value of the "birthday" field. +func (_u *UserUpdateOne) ClearBirthday() *UserUpdateOne { + _u.mutation.ClearBirthday() + return _u +} + +// SetAccountStatus sets the "account_status" field. +func (_u *UserUpdateOne) SetAccountStatus(v user.AccountStatus) *UserUpdateOne { + _u.mutation.SetAccountStatus(v) + return _u +} + +// SetNillableAccountStatus sets the "account_status" field if the given value is not nil. +func (_u *UserUpdateOne) SetNillableAccountStatus(v *user.AccountStatus) *UserUpdateOne { + if v != nil { + _u.SetAccountStatus(*v) + } + return _u +} + +// SetIsVerified sets the "is_verified" field. +func (_u *UserUpdateOne) SetIsVerified(v uint32) *UserUpdateOne { + _u.mutation.ResetIsVerified() + _u.mutation.SetIsVerified(v) + return _u +} + +// SetNillableIsVerified sets the "is_verified" field if the given value is not nil. +func (_u *UserUpdateOne) SetNillableIsVerified(v *uint32) *UserUpdateOne { + if v != nil { + _u.SetIsVerified(*v) + } + return _u +} + +// AddIsVerified adds value to the "is_verified" field. +func (_u *UserUpdateOne) AddIsVerified(v int32) *UserUpdateOne { + _u.mutation.AddIsVerified(v) + return _u +} + +// SetRegisteredLoginIP sets the "registered_login_ip" field. +func (_u *UserUpdateOne) SetRegisteredLoginIP(v string) *UserUpdateOne { + _u.mutation.SetRegisteredLoginIP(v) + return _u +} + +// SetNillableRegisteredLoginIP sets the "registered_login_ip" field if the given value is not nil. +func (_u *UserUpdateOne) SetNillableRegisteredLoginIP(v *string) *UserUpdateOne { + if v != nil { + _u.SetRegisteredLoginIP(*v) + } + return _u +} + +// ClearRegisteredLoginIP clears the value of the "registered_login_ip" field. +func (_u *UserUpdateOne) ClearRegisteredLoginIP() *UserUpdateOne { + _u.mutation.ClearRegisteredLoginIP() + return _u +} + +// SetLoginAttempts sets the "login_attempts" field. +func (_u *UserUpdateOne) SetLoginAttempts(v int64) *UserUpdateOne { + _u.mutation.ResetLoginAttempts() + _u.mutation.SetLoginAttempts(v) + return _u +} + +// SetNillableLoginAttempts sets the "login_attempts" field if the given value is not nil. +func (_u *UserUpdateOne) SetNillableLoginAttempts(v *int64) *UserUpdateOne { + if v != nil { + _u.SetLoginAttempts(*v) + } + return _u +} + +// AddLoginAttempts adds value to the "login_attempts" field. +func (_u *UserUpdateOne) AddLoginAttempts(v int64) *UserUpdateOne { + _u.mutation.AddLoginAttempts(v) + return _u +} + +// SetMetadata sets the "metadata" field. +func (_u *UserUpdateOne) SetMetadata(v map[string]interface{}) *UserUpdateOne { + _u.mutation.SetMetadata(v) + return _u +} + +// ClearMetadata clears the value of the "metadata" field. +func (_u *UserUpdateOne) ClearMetadata() *UserUpdateOne { + _u.mutation.ClearMetadata() + return _u +} + +// SetRegistrationSource sets the "registration_source" field. +func (_u *UserUpdateOne) SetRegistrationSource(v string) *UserUpdateOne { + _u.mutation.SetRegistrationSource(v) + return _u +} + +// SetNillableRegistrationSource sets the "registration_source" field if the given value is not nil. +func (_u *UserUpdateOne) SetNillableRegistrationSource(v *string) *UserUpdateOne { + if v != nil { + _u.SetRegistrationSource(*v) + } + return _u +} + +// ClearRegistrationSource clears the value of the "registration_source" field. +func (_u *UserUpdateOne) ClearRegistrationSource() *UserUpdateOne { + _u.mutation.ClearRegistrationSource() + return _u +} + +// Mutation returns the UserMutation object of the builder. +func (_u *UserUpdateOne) Mutation() *UserMutation { + return _u.mutation +} + +// Where appends a list predicates to the UserUpdate builder. +func (_u *UserUpdateOne) Where(ps ...predicate.User) *UserUpdateOne { + _u.mutation.Where(ps...) + return _u +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (_u *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated User entity. +func (_u *UserUpdateOne) Save(ctx context.Context) (*User, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *UserUpdateOne) SaveX(ctx context.Context) *User { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *UserUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *UserUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *UserUpdateOne) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := user.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *UserUpdateOne) check() error { + if v, ok := _u.mutation.Username(); ok { + if err := user.UsernameValidator(v); err != nil { + return &ValidationError{Name: "username", err: fmt.Errorf(`ent: validator failed for field "User.username": %w`, err)} + } + } + if v, ok := _u.mutation.Email(); ok { + if err := user.EmailValidator(v); err != nil { + return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "User.email": %w`, err)} + } + } + if v, ok := _u.mutation.Mobile(); ok { + if err := user.MobileValidator(v); err != nil { + return &ValidationError{Name: "mobile", err: fmt.Errorf(`ent: validator failed for field "User.mobile": %w`, err)} + } + } + if v, ok := _u.mutation.PasswordHash(); ok { + if err := user.PasswordHashValidator(v); err != nil { + return &ValidationError{Name: "password_hash", err: fmt.Errorf(`ent: validator failed for field "User.password_hash": %w`, err)} + } + } + if v, ok := _u.mutation.Salt(); ok { + if err := user.SaltValidator(v); err != nil { + return &ValidationError{Name: "salt", err: fmt.Errorf(`ent: validator failed for field "User.salt": %w`, err)} + } + } + if v, ok := _u.mutation.Nickname(); ok { + if err := user.NicknameValidator(v); err != nil { + return &ValidationError{Name: "nickname", err: fmt.Errorf(`ent: validator failed for field "User.nickname": %w`, err)} + } + } + if v, ok := _u.mutation.Avatar(); ok { + if err := user.AvatarValidator(v); err != nil { + return &ValidationError{Name: "avatar", err: fmt.Errorf(`ent: validator failed for field "User.avatar": %w`, err)} + } + } + if v, ok := _u.mutation.Gender(); ok { + if err := user.GenderValidator(v); err != nil { + return &ValidationError{Name: "gender", err: fmt.Errorf(`ent: validator failed for field "User.gender": %w`, err)} + } + } + if v, ok := _u.mutation.AccountStatus(); ok { + if err := user.AccountStatusValidator(v); err != nil { + return &ValidationError{Name: "account_status", err: fmt.Errorf(`ent: validator failed for field "User.account_status": %w`, err)} + } + } + if v, ok := _u.mutation.RegisteredLoginIP(); ok { + if err := user.RegisteredLoginIPValidator(v); err != nil { + return &ValidationError{Name: "registered_login_ip", err: fmt.Errorf(`ent: validator failed for field "User.registered_login_ip": %w`, err)} + } + } + if v, ok := _u.mutation.RegistrationSource(); ok { + if err := user.RegistrationSourceValidator(v); err != nil { + return &ValidationError{Name: "registration_source", err: fmt.Errorf(`ent: validator failed for field "User.registration_source": %w`, err)} + } + } + return nil +} + +func (_u *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeUint64)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "User.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := _u.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, user.FieldID) + for _, f := range fields { + if !user.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != user.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.UpdatedAt(); ok { + _spec.SetField(user.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.Status(); ok { + _spec.SetField(user.FieldStatus, field.TypeUint8, value) + } + if value, ok := _u.mutation.AddedStatus(); ok { + _spec.AddField(user.FieldStatus, field.TypeUint8, value) + } + if _u.mutation.StatusCleared() { + _spec.ClearField(user.FieldStatus, field.TypeUint8) + } + if value, ok := _u.mutation.DeletedAt(); ok { + _spec.SetField(user.FieldDeletedAt, field.TypeTime, value) + } + if _u.mutation.DeletedAtCleared() { + _spec.ClearField(user.FieldDeletedAt, field.TypeTime) + } + if value, ok := _u.mutation.Username(); ok { + _spec.SetField(user.FieldUsername, field.TypeString, value) + } + if value, ok := _u.mutation.Email(); ok { + _spec.SetField(user.FieldEmail, field.TypeString, value) + } + if value, ok := _u.mutation.Mobile(); ok { + _spec.SetField(user.FieldMobile, field.TypeString, value) + } + if _u.mutation.MobileCleared() { + _spec.ClearField(user.FieldMobile, field.TypeString) + } + if value, ok := _u.mutation.PasswordHash(); ok { + _spec.SetField(user.FieldPasswordHash, field.TypeString, value) + } + if value, ok := _u.mutation.Salt(); ok { + _spec.SetField(user.FieldSalt, field.TypeString, value) + } + if value, ok := _u.mutation.Nickname(); ok { + _spec.SetField(user.FieldNickname, field.TypeString, value) + } + if value, ok := _u.mutation.Avatar(); ok { + _spec.SetField(user.FieldAvatar, field.TypeString, value) + } + if _u.mutation.AvatarCleared() { + _spec.ClearField(user.FieldAvatar, field.TypeString) + } + if value, ok := _u.mutation.Gender(); ok { + _spec.SetField(user.FieldGender, field.TypeEnum, value) + } + if value, ok := _u.mutation.Birthday(); ok { + _spec.SetField(user.FieldBirthday, field.TypeTime, value) + } + if _u.mutation.BirthdayCleared() { + _spec.ClearField(user.FieldBirthday, field.TypeTime) + } + if value, ok := _u.mutation.AccountStatus(); ok { + _spec.SetField(user.FieldAccountStatus, field.TypeEnum, value) + } + if value, ok := _u.mutation.IsVerified(); ok { + _spec.SetField(user.FieldIsVerified, field.TypeUint32, value) + } + if value, ok := _u.mutation.AddedIsVerified(); ok { + _spec.AddField(user.FieldIsVerified, field.TypeUint32, value) + } + if value, ok := _u.mutation.RegisteredLoginIP(); ok { + _spec.SetField(user.FieldRegisteredLoginIP, field.TypeString, value) + } + if _u.mutation.RegisteredLoginIPCleared() { + _spec.ClearField(user.FieldRegisteredLoginIP, field.TypeString) + } + if value, ok := _u.mutation.LoginAttempts(); ok { + _spec.SetField(user.FieldLoginAttempts, field.TypeInt64, value) + } + if value, ok := _u.mutation.AddedLoginAttempts(); ok { + _spec.AddField(user.FieldLoginAttempts, field.TypeInt64, value) + } + if value, ok := _u.mutation.Metadata(); ok { + _spec.SetField(user.FieldMetadata, field.TypeJSON, value) + } + if _u.mutation.MetadataCleared() { + _spec.ClearField(user.FieldMetadata, field.TypeJSON) + } + if value, ok := _u.mutation.RegistrationSource(); ok { + _spec.SetField(user.FieldRegistrationSource, field.TypeString, value) + } + if _u.mutation.RegistrationSourceCleared() { + _spec.ClearField(user.FieldRegistrationSource, field.TypeString) + } + _node = &User{config: _u.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{user.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} diff --git a/rpc/ent/userloginlog.go b/rpc/ent/userloginlog.go new file mode 100644 index 0000000..dfb3fd6 --- /dev/null +++ b/rpc/ent/userloginlog.go @@ -0,0 +1,289 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "encoding/json" + "fmt" + "mingyang-admin-app-rpc/ent/userloginlog" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// UserLoginLog is the model entity for the UserLoginLog schema. +type UserLoginLog struct { + config `json:"-"` + // ID of the ent. + ID uint64 `json:"id,omitempty"` + // Create Time | 创建日期 + CreatedAt time.Time `json:"created_at,omitempty"` + // Update Time | 修改日期 + UpdatedAt time.Time `json:"updated_at,omitempty"` + // Status 1: normal 2: ban | 状态 1 正常 2 禁用 + Status uint8 `json:"status,omitempty"` + // Tenant ID | 租户 ID + TenantID uint64 `json:"tenant_id,omitempty"` + // Delete Time | 删除日期 + DeletedAt time.Time `json:"deleted_at,omitempty"` + // 用户ID + UserID uint64 `json:"user_id,omitempty"` + // LoginTime holds the value of the "login_time" field. + LoginTime time.Time `json:"login_time,omitempty"` + // LoginIP holds the value of the "login_ip" field. + LoginIP string `json:"login_ip,omitempty"` + // LoginLocation holds the value of the "login_location" field. + LoginLocation string `json:"login_location,omitempty"` + // LoginType holds the value of the "login_type" field. + LoginType userloginlog.LoginType `json:"login_type,omitempty"` + // LoginPlatform holds the value of the "login_platform" field. + LoginPlatform userloginlog.LoginPlatform `json:"login_platform,omitempty"` + // 登录结果,是否成功 + LoginResult bool `json:"login_result,omitempty"` + // FailureReason holds the value of the "failure_reason" field. + FailureReason string `json:"failure_reason,omitempty"` + // SessionID holds the value of the "session_id" field. + SessionID string `json:"session_id,omitempty"` + // LatencyMs holds the value of the "latency_ms" field. + LatencyMs int `json:"latency_ms,omitempty"` + // auth_id + AuthID uint64 `json:"auth_id,omitempty"` + // AdditionalData holds the value of the "additional_data" field. + AdditionalData map[string]interface{} `json:"additional_data,omitempty"` + selectValues sql.SelectValues +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*UserLoginLog) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case userloginlog.FieldAdditionalData: + values[i] = new([]byte) + case userloginlog.FieldLoginResult: + values[i] = new(sql.NullBool) + case userloginlog.FieldID, userloginlog.FieldStatus, userloginlog.FieldTenantID, userloginlog.FieldUserID, userloginlog.FieldLatencyMs, userloginlog.FieldAuthID: + values[i] = new(sql.NullInt64) + case userloginlog.FieldLoginIP, userloginlog.FieldLoginLocation, userloginlog.FieldLoginType, userloginlog.FieldLoginPlatform, userloginlog.FieldFailureReason, userloginlog.FieldSessionID: + values[i] = new(sql.NullString) + case userloginlog.FieldCreatedAt, userloginlog.FieldUpdatedAt, userloginlog.FieldDeletedAt, userloginlog.FieldLoginTime: + 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 UserLoginLog fields. +func (_m *UserLoginLog) 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 userloginlog.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + _m.ID = uint64(value.Int64) + case userloginlog.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 { + _m.CreatedAt = value.Time + } + case userloginlog.FieldUpdatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field updated_at", values[i]) + } else if value.Valid { + _m.UpdatedAt = value.Time + } + case userloginlog.FieldStatus: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field status", values[i]) + } else if value.Valid { + _m.Status = uint8(value.Int64) + } + case userloginlog.FieldTenantID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field tenant_id", values[i]) + } else if value.Valid { + _m.TenantID = uint64(value.Int64) + } + case userloginlog.FieldDeletedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field deleted_at", values[i]) + } else if value.Valid { + _m.DeletedAt = value.Time + } + case userloginlog.FieldUserID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field user_id", values[i]) + } else if value.Valid { + _m.UserID = uint64(value.Int64) + } + case userloginlog.FieldLoginTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field login_time", values[i]) + } else if value.Valid { + _m.LoginTime = value.Time + } + case userloginlog.FieldLoginIP: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field login_ip", values[i]) + } else if value.Valid { + _m.LoginIP = value.String + } + case userloginlog.FieldLoginLocation: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field login_location", values[i]) + } else if value.Valid { + _m.LoginLocation = value.String + } + case userloginlog.FieldLoginType: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field login_type", values[i]) + } else if value.Valid { + _m.LoginType = userloginlog.LoginType(value.String) + } + case userloginlog.FieldLoginPlatform: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field login_platform", values[i]) + } else if value.Valid { + _m.LoginPlatform = userloginlog.LoginPlatform(value.String) + } + case userloginlog.FieldLoginResult: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field login_result", values[i]) + } else if value.Valid { + _m.LoginResult = value.Bool + } + case userloginlog.FieldFailureReason: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field failure_reason", values[i]) + } else if value.Valid { + _m.FailureReason = value.String + } + case userloginlog.FieldSessionID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field session_id", values[i]) + } else if value.Valid { + _m.SessionID = value.String + } + case userloginlog.FieldLatencyMs: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field latency_ms", values[i]) + } else if value.Valid { + _m.LatencyMs = int(value.Int64) + } + case userloginlog.FieldAuthID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field auth_id", values[i]) + } else if value.Valid { + _m.AuthID = uint64(value.Int64) + } + case userloginlog.FieldAdditionalData: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field additional_data", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &_m.AdditionalData); err != nil { + return fmt.Errorf("unmarshal field additional_data: %w", err) + } + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the UserLoginLog. +// This includes values selected through modifiers, order, etc. +func (_m *UserLoginLog) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// Update returns a builder for updating this UserLoginLog. +// Note that you need to call UserLoginLog.Unwrap() before calling this method if this UserLoginLog +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *UserLoginLog) Update() *UserLoginLogUpdateOne { + return NewUserLoginLogClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the UserLoginLog entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (_m *UserLoginLog) Unwrap() *UserLoginLog { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("ent: UserLoginLog is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *UserLoginLog) String() string { + var builder strings.Builder + builder.WriteString("UserLoginLog(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("created_at=") + builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("updated_at=") + builder.WriteString(_m.UpdatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("status=") + builder.WriteString(fmt.Sprintf("%v", _m.Status)) + builder.WriteString(", ") + builder.WriteString("tenant_id=") + builder.WriteString(fmt.Sprintf("%v", _m.TenantID)) + builder.WriteString(", ") + builder.WriteString("deleted_at=") + builder.WriteString(_m.DeletedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("user_id=") + builder.WriteString(fmt.Sprintf("%v", _m.UserID)) + builder.WriteString(", ") + builder.WriteString("login_time=") + builder.WriteString(_m.LoginTime.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("login_ip=") + builder.WriteString(_m.LoginIP) + builder.WriteString(", ") + builder.WriteString("login_location=") + builder.WriteString(_m.LoginLocation) + builder.WriteString(", ") + builder.WriteString("login_type=") + builder.WriteString(fmt.Sprintf("%v", _m.LoginType)) + builder.WriteString(", ") + builder.WriteString("login_platform=") + builder.WriteString(fmt.Sprintf("%v", _m.LoginPlatform)) + builder.WriteString(", ") + builder.WriteString("login_result=") + builder.WriteString(fmt.Sprintf("%v", _m.LoginResult)) + builder.WriteString(", ") + builder.WriteString("failure_reason=") + builder.WriteString(_m.FailureReason) + builder.WriteString(", ") + builder.WriteString("session_id=") + builder.WriteString(_m.SessionID) + builder.WriteString(", ") + builder.WriteString("latency_ms=") + builder.WriteString(fmt.Sprintf("%v", _m.LatencyMs)) + builder.WriteString(", ") + builder.WriteString("auth_id=") + builder.WriteString(fmt.Sprintf("%v", _m.AuthID)) + builder.WriteString(", ") + builder.WriteString("additional_data=") + builder.WriteString(fmt.Sprintf("%v", _m.AdditionalData)) + builder.WriteByte(')') + return builder.String() +} + +// UserLoginLogs is a parsable slice of UserLoginLog. +type UserLoginLogs []*UserLoginLog diff --git a/rpc/ent/userloginlog/userloginlog.go b/rpc/ent/userloginlog/userloginlog.go new file mode 100644 index 0000000..df5d65b --- /dev/null +++ b/rpc/ent/userloginlog/userloginlog.go @@ -0,0 +1,256 @@ +// Code generated by ent, DO NOT EDIT. + +package userloginlog + +import ( + "fmt" + "time" + + "entgo.io/ent/dialect/sql" +) + +const ( + // Label holds the string label denoting the userloginlog type in the database. + Label = "user_login_log" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldCreatedAt holds the string denoting the created_at field in the database. + FieldCreatedAt = "created_at" + // FieldUpdatedAt holds the string denoting the updated_at field in the database. + FieldUpdatedAt = "updated_at" + // FieldStatus holds the string denoting the status field in the database. + FieldStatus = "status" + // FieldTenantID holds the string denoting the tenant_id field in the database. + FieldTenantID = "tenant_id" + // FieldDeletedAt holds the string denoting the deleted_at field in the database. + FieldDeletedAt = "deleted_at" + // FieldUserID holds the string denoting the user_id field in the database. + FieldUserID = "user_id" + // FieldLoginTime holds the string denoting the login_time field in the database. + FieldLoginTime = "login_time" + // FieldLoginIP holds the string denoting the login_ip field in the database. + FieldLoginIP = "login_ip" + // FieldLoginLocation holds the string denoting the login_location field in the database. + FieldLoginLocation = "login_location" + // FieldLoginType holds the string denoting the login_type field in the database. + FieldLoginType = "login_type" + // FieldLoginPlatform holds the string denoting the login_platform field in the database. + FieldLoginPlatform = "login_platform" + // FieldLoginResult holds the string denoting the login_result field in the database. + FieldLoginResult = "login_result" + // FieldFailureReason holds the string denoting the failure_reason field in the database. + FieldFailureReason = "failure_reason" + // FieldSessionID holds the string denoting the session_id field in the database. + FieldSessionID = "session_id" + // FieldLatencyMs holds the string denoting the latency_ms field in the database. + FieldLatencyMs = "latency_ms" + // FieldAuthID holds the string denoting the auth_id field in the database. + FieldAuthID = "auth_id" + // FieldAdditionalData holds the string denoting the additional_data field in the database. + FieldAdditionalData = "additional_data" + // Table holds the table name of the userloginlog in the database. + Table = "user_login_logs" +) + +// Columns holds all SQL columns for userloginlog fields. +var Columns = []string{ + FieldID, + FieldCreatedAt, + FieldUpdatedAt, + FieldStatus, + FieldTenantID, + FieldDeletedAt, + FieldUserID, + FieldLoginTime, + FieldLoginIP, + FieldLoginLocation, + FieldLoginType, + FieldLoginPlatform, + FieldLoginResult, + FieldFailureReason, + FieldSessionID, + FieldLatencyMs, + FieldAuthID, + FieldAdditionalData, +} + +// 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 ( + // DefaultCreatedAt holds the default value on creation for the "created_at" field. + DefaultCreatedAt func() time.Time + // DefaultUpdatedAt holds the default value on creation for the "updated_at" field. + DefaultUpdatedAt func() time.Time + // UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field. + UpdateDefaultUpdatedAt func() time.Time + // DefaultStatus holds the default value on creation for the "status" field. + DefaultStatus uint8 + // DefaultTenantID holds the default value on creation for the "tenant_id" field. + DefaultTenantID uint64 + // DefaultLoginTime holds the default value on creation for the "login_time" field. + DefaultLoginTime func() time.Time + // LoginIPValidator is a validator for the "login_ip" field. It is called by the builders before save. + LoginIPValidator func(string) error + // LoginLocationValidator is a validator for the "login_location" field. It is called by the builders before save. + LoginLocationValidator func(string) error + // DefaultLoginResult holds the default value on creation for the "login_result" field. + DefaultLoginResult bool + // FailureReasonValidator is a validator for the "failure_reason" field. It is called by the builders before save. + FailureReasonValidator func(string) error + // SessionIDValidator is a validator for the "session_id" field. It is called by the builders before save. + SessionIDValidator func(string) error +) + +// LoginType defines the type for the "login_type" enum field. +type LoginType string + +// LoginTypePassword is the default value of the LoginType enum. +const DefaultLoginType = LoginTypePassword + +// LoginType values. +const ( + LoginTypePassword LoginType = "password" + LoginTypeSmsCode LoginType = "sms_code" + LoginTypeEmailCode LoginType = "email_code" + LoginTypeWechat LoginType = "wechat" + LoginTypeAlipay LoginType = "alipay" + LoginTypeApple LoginType = "apple" + LoginTypeGoogle LoginType = "google" + LoginTypeOtherThirdParty LoginType = "other_third_party" +) + +func (lt LoginType) String() string { + return string(lt) +} + +// LoginTypeValidator is a validator for the "login_type" field enum values. It is called by the builders before save. +func LoginTypeValidator(lt LoginType) error { + switch lt { + case LoginTypePassword, LoginTypeSmsCode, LoginTypeEmailCode, LoginTypeWechat, LoginTypeAlipay, LoginTypeApple, LoginTypeGoogle, LoginTypeOtherThirdParty: + return nil + default: + return fmt.Errorf("userloginlog: invalid enum value for login_type field: %q", lt) + } +} + +// LoginPlatform defines the type for the "login_platform" enum field. +type LoginPlatform string + +// LoginPlatformAndroid is the default value of the LoginPlatform enum. +const DefaultLoginPlatform = LoginPlatformAndroid + +// LoginPlatform values. +const ( + LoginPlatformIos LoginPlatform = "ios" + LoginPlatformAndroid LoginPlatform = "android" +) + +func (lp LoginPlatform) String() string { + return string(lp) +} + +// LoginPlatformValidator is a validator for the "login_platform" field enum values. It is called by the builders before save. +func LoginPlatformValidator(lp LoginPlatform) error { + switch lp { + case LoginPlatformIos, LoginPlatformAndroid: + return nil + default: + return fmt.Errorf("userloginlog: invalid enum value for login_platform field: %q", lp) + } +} + +// OrderOption defines the ordering options for the UserLoginLog 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() +} + +// ByCreatedAt orders the results by the created_at field. +func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() +} + +// ByUpdatedAt orders the results by the updated_at field. +func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc() +} + +// ByStatus orders the results by the status field. +func ByStatus(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStatus, opts...).ToFunc() +} + +// ByTenantID orders the results by the tenant_id field. +func ByTenantID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldTenantID, opts...).ToFunc() +} + +// ByDeletedAt orders the results by the deleted_at field. +func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeletedAt, opts...).ToFunc() +} + +// ByUserID orders the results by the user_id field. +func ByUserID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUserID, opts...).ToFunc() +} + +// ByLoginTime orders the results by the login_time field. +func ByLoginTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLoginTime, opts...).ToFunc() +} + +// ByLoginIP orders the results by the login_ip field. +func ByLoginIP(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLoginIP, opts...).ToFunc() +} + +// ByLoginLocation orders the results by the login_location field. +func ByLoginLocation(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLoginLocation, opts...).ToFunc() +} + +// ByLoginType orders the results by the login_type field. +func ByLoginType(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLoginType, opts...).ToFunc() +} + +// ByLoginPlatform orders the results by the login_platform field. +func ByLoginPlatform(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLoginPlatform, opts...).ToFunc() +} + +// ByLoginResult orders the results by the login_result field. +func ByLoginResult(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLoginResult, opts...).ToFunc() +} + +// ByFailureReason orders the results by the failure_reason field. +func ByFailureReason(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldFailureReason, opts...).ToFunc() +} + +// BySessionID orders the results by the session_id field. +func BySessionID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSessionID, opts...).ToFunc() +} + +// ByLatencyMs orders the results by the latency_ms field. +func ByLatencyMs(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLatencyMs, opts...).ToFunc() +} + +// ByAuthID orders the results by the auth_id field. +func ByAuthID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldAuthID, opts...).ToFunc() +} diff --git a/rpc/ent/userloginlog/where.go b/rpc/ent/userloginlog/where.go new file mode 100644 index 0000000..2918df1 --- /dev/null +++ b/rpc/ent/userloginlog/where.go @@ -0,0 +1,890 @@ +// Code generated by ent, DO NOT EDIT. + +package userloginlog + +import ( + "mingyang-admin-app-rpc/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" +) + +// ID filters vertices based on their ID field. +func ID(id uint64) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id uint64) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id uint64) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...uint64) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...uint64) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id uint64) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id uint64) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id uint64) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id uint64) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldLTE(FieldID, id)) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldEQ(FieldCreatedAt, v)) +} + +// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. +func UpdatedAt(v time.Time) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// Status applies equality check predicate on the "status" field. It's identical to StatusEQ. +func Status(v uint8) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldEQ(FieldStatus, v)) +} + +// TenantID applies equality check predicate on the "tenant_id" field. It's identical to TenantIDEQ. +func TenantID(v uint64) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldEQ(FieldTenantID, v)) +} + +// DeletedAt applies equality check predicate on the "deleted_at" field. It's identical to DeletedAtEQ. +func DeletedAt(v time.Time) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldEQ(FieldDeletedAt, v)) +} + +// UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ. +func UserID(v uint64) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldEQ(FieldUserID, v)) +} + +// LoginTime applies equality check predicate on the "login_time" field. It's identical to LoginTimeEQ. +func LoginTime(v time.Time) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldEQ(FieldLoginTime, v)) +} + +// LoginIP applies equality check predicate on the "login_ip" field. It's identical to LoginIPEQ. +func LoginIP(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldEQ(FieldLoginIP, v)) +} + +// LoginLocation applies equality check predicate on the "login_location" field. It's identical to LoginLocationEQ. +func LoginLocation(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldEQ(FieldLoginLocation, v)) +} + +// LoginResult applies equality check predicate on the "login_result" field. It's identical to LoginResultEQ. +func LoginResult(v bool) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldEQ(FieldLoginResult, v)) +} + +// FailureReason applies equality check predicate on the "failure_reason" field. It's identical to FailureReasonEQ. +func FailureReason(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldEQ(FieldFailureReason, v)) +} + +// SessionID applies equality check predicate on the "session_id" field. It's identical to SessionIDEQ. +func SessionID(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldEQ(FieldSessionID, v)) +} + +// LatencyMs applies equality check predicate on the "latency_ms" field. It's identical to LatencyMsEQ. +func LatencyMs(v int) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldEQ(FieldLatencyMs, v)) +} + +// AuthID applies equality check predicate on the "auth_id" field. It's identical to AuthIDEQ. +func AuthID(v uint64) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldEQ(FieldAuthID, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldLTE(FieldCreatedAt, v)) +} + +// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. +func UpdatedAtEQ(v time.Time) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. +func UpdatedAtNEQ(v time.Time) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldNEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtIn applies the In predicate on the "updated_at" field. +func UpdatedAtIn(vs ...time.Time) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. +func UpdatedAtNotIn(vs ...time.Time) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldNotIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtGT applies the GT predicate on the "updated_at" field. +func UpdatedAtGT(v time.Time) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldGT(FieldUpdatedAt, v)) +} + +// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. +func UpdatedAtGTE(v time.Time) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldGTE(FieldUpdatedAt, v)) +} + +// UpdatedAtLT applies the LT predicate on the "updated_at" field. +func UpdatedAtLT(v time.Time) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldLT(FieldUpdatedAt, v)) +} + +// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. +func UpdatedAtLTE(v time.Time) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldLTE(FieldUpdatedAt, v)) +} + +// StatusEQ applies the EQ predicate on the "status" field. +func StatusEQ(v uint8) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldEQ(FieldStatus, v)) +} + +// StatusNEQ applies the NEQ predicate on the "status" field. +func StatusNEQ(v uint8) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldNEQ(FieldStatus, v)) +} + +// StatusIn applies the In predicate on the "status" field. +func StatusIn(vs ...uint8) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldIn(FieldStatus, vs...)) +} + +// StatusNotIn applies the NotIn predicate on the "status" field. +func StatusNotIn(vs ...uint8) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldNotIn(FieldStatus, vs...)) +} + +// StatusGT applies the GT predicate on the "status" field. +func StatusGT(v uint8) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldGT(FieldStatus, v)) +} + +// StatusGTE applies the GTE predicate on the "status" field. +func StatusGTE(v uint8) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldGTE(FieldStatus, v)) +} + +// StatusLT applies the LT predicate on the "status" field. +func StatusLT(v uint8) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldLT(FieldStatus, v)) +} + +// StatusLTE applies the LTE predicate on the "status" field. +func StatusLTE(v uint8) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldLTE(FieldStatus, v)) +} + +// StatusIsNil applies the IsNil predicate on the "status" field. +func StatusIsNil() predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldIsNull(FieldStatus)) +} + +// StatusNotNil applies the NotNil predicate on the "status" field. +func StatusNotNil() predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldNotNull(FieldStatus)) +} + +// TenantIDEQ applies the EQ predicate on the "tenant_id" field. +func TenantIDEQ(v uint64) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldEQ(FieldTenantID, v)) +} + +// TenantIDNEQ applies the NEQ predicate on the "tenant_id" field. +func TenantIDNEQ(v uint64) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldNEQ(FieldTenantID, v)) +} + +// TenantIDIn applies the In predicate on the "tenant_id" field. +func TenantIDIn(vs ...uint64) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldIn(FieldTenantID, vs...)) +} + +// TenantIDNotIn applies the NotIn predicate on the "tenant_id" field. +func TenantIDNotIn(vs ...uint64) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldNotIn(FieldTenantID, vs...)) +} + +// TenantIDGT applies the GT predicate on the "tenant_id" field. +func TenantIDGT(v uint64) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldGT(FieldTenantID, v)) +} + +// TenantIDGTE applies the GTE predicate on the "tenant_id" field. +func TenantIDGTE(v uint64) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldGTE(FieldTenantID, v)) +} + +// TenantIDLT applies the LT predicate on the "tenant_id" field. +func TenantIDLT(v uint64) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldLT(FieldTenantID, v)) +} + +// TenantIDLTE applies the LTE predicate on the "tenant_id" field. +func TenantIDLTE(v uint64) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldLTE(FieldTenantID, v)) +} + +// DeletedAtEQ applies the EQ predicate on the "deleted_at" field. +func DeletedAtEQ(v time.Time) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldEQ(FieldDeletedAt, v)) +} + +// DeletedAtNEQ applies the NEQ predicate on the "deleted_at" field. +func DeletedAtNEQ(v time.Time) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldNEQ(FieldDeletedAt, v)) +} + +// DeletedAtIn applies the In predicate on the "deleted_at" field. +func DeletedAtIn(vs ...time.Time) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldIn(FieldDeletedAt, vs...)) +} + +// DeletedAtNotIn applies the NotIn predicate on the "deleted_at" field. +func DeletedAtNotIn(vs ...time.Time) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldNotIn(FieldDeletedAt, vs...)) +} + +// DeletedAtGT applies the GT predicate on the "deleted_at" field. +func DeletedAtGT(v time.Time) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldGT(FieldDeletedAt, v)) +} + +// DeletedAtGTE applies the GTE predicate on the "deleted_at" field. +func DeletedAtGTE(v time.Time) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldGTE(FieldDeletedAt, v)) +} + +// DeletedAtLT applies the LT predicate on the "deleted_at" field. +func DeletedAtLT(v time.Time) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldLT(FieldDeletedAt, v)) +} + +// DeletedAtLTE applies the LTE predicate on the "deleted_at" field. +func DeletedAtLTE(v time.Time) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldLTE(FieldDeletedAt, v)) +} + +// DeletedAtIsNil applies the IsNil predicate on the "deleted_at" field. +func DeletedAtIsNil() predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldIsNull(FieldDeletedAt)) +} + +// DeletedAtNotNil applies the NotNil predicate on the "deleted_at" field. +func DeletedAtNotNil() predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldNotNull(FieldDeletedAt)) +} + +// UserIDEQ applies the EQ predicate on the "user_id" field. +func UserIDEQ(v uint64) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldEQ(FieldUserID, v)) +} + +// UserIDNEQ applies the NEQ predicate on the "user_id" field. +func UserIDNEQ(v uint64) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldNEQ(FieldUserID, v)) +} + +// UserIDIn applies the In predicate on the "user_id" field. +func UserIDIn(vs ...uint64) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldIn(FieldUserID, vs...)) +} + +// UserIDNotIn applies the NotIn predicate on the "user_id" field. +func UserIDNotIn(vs ...uint64) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldNotIn(FieldUserID, vs...)) +} + +// UserIDGT applies the GT predicate on the "user_id" field. +func UserIDGT(v uint64) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldGT(FieldUserID, v)) +} + +// UserIDGTE applies the GTE predicate on the "user_id" field. +func UserIDGTE(v uint64) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldGTE(FieldUserID, v)) +} + +// UserIDLT applies the LT predicate on the "user_id" field. +func UserIDLT(v uint64) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldLT(FieldUserID, v)) +} + +// UserIDLTE applies the LTE predicate on the "user_id" field. +func UserIDLTE(v uint64) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldLTE(FieldUserID, v)) +} + +// LoginTimeEQ applies the EQ predicate on the "login_time" field. +func LoginTimeEQ(v time.Time) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldEQ(FieldLoginTime, v)) +} + +// LoginTimeNEQ applies the NEQ predicate on the "login_time" field. +func LoginTimeNEQ(v time.Time) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldNEQ(FieldLoginTime, v)) +} + +// LoginTimeIn applies the In predicate on the "login_time" field. +func LoginTimeIn(vs ...time.Time) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldIn(FieldLoginTime, vs...)) +} + +// LoginTimeNotIn applies the NotIn predicate on the "login_time" field. +func LoginTimeNotIn(vs ...time.Time) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldNotIn(FieldLoginTime, vs...)) +} + +// LoginTimeGT applies the GT predicate on the "login_time" field. +func LoginTimeGT(v time.Time) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldGT(FieldLoginTime, v)) +} + +// LoginTimeGTE applies the GTE predicate on the "login_time" field. +func LoginTimeGTE(v time.Time) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldGTE(FieldLoginTime, v)) +} + +// LoginTimeLT applies the LT predicate on the "login_time" field. +func LoginTimeLT(v time.Time) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldLT(FieldLoginTime, v)) +} + +// LoginTimeLTE applies the LTE predicate on the "login_time" field. +func LoginTimeLTE(v time.Time) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldLTE(FieldLoginTime, v)) +} + +// LoginIPEQ applies the EQ predicate on the "login_ip" field. +func LoginIPEQ(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldEQ(FieldLoginIP, v)) +} + +// LoginIPNEQ applies the NEQ predicate on the "login_ip" field. +func LoginIPNEQ(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldNEQ(FieldLoginIP, v)) +} + +// LoginIPIn applies the In predicate on the "login_ip" field. +func LoginIPIn(vs ...string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldIn(FieldLoginIP, vs...)) +} + +// LoginIPNotIn applies the NotIn predicate on the "login_ip" field. +func LoginIPNotIn(vs ...string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldNotIn(FieldLoginIP, vs...)) +} + +// LoginIPGT applies the GT predicate on the "login_ip" field. +func LoginIPGT(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldGT(FieldLoginIP, v)) +} + +// LoginIPGTE applies the GTE predicate on the "login_ip" field. +func LoginIPGTE(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldGTE(FieldLoginIP, v)) +} + +// LoginIPLT applies the LT predicate on the "login_ip" field. +func LoginIPLT(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldLT(FieldLoginIP, v)) +} + +// LoginIPLTE applies the LTE predicate on the "login_ip" field. +func LoginIPLTE(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldLTE(FieldLoginIP, v)) +} + +// LoginIPContains applies the Contains predicate on the "login_ip" field. +func LoginIPContains(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldContains(FieldLoginIP, v)) +} + +// LoginIPHasPrefix applies the HasPrefix predicate on the "login_ip" field. +func LoginIPHasPrefix(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldHasPrefix(FieldLoginIP, v)) +} + +// LoginIPHasSuffix applies the HasSuffix predicate on the "login_ip" field. +func LoginIPHasSuffix(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldHasSuffix(FieldLoginIP, v)) +} + +// LoginIPEqualFold applies the EqualFold predicate on the "login_ip" field. +func LoginIPEqualFold(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldEqualFold(FieldLoginIP, v)) +} + +// LoginIPContainsFold applies the ContainsFold predicate on the "login_ip" field. +func LoginIPContainsFold(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldContainsFold(FieldLoginIP, v)) +} + +// LoginLocationEQ applies the EQ predicate on the "login_location" field. +func LoginLocationEQ(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldEQ(FieldLoginLocation, v)) +} + +// LoginLocationNEQ applies the NEQ predicate on the "login_location" field. +func LoginLocationNEQ(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldNEQ(FieldLoginLocation, v)) +} + +// LoginLocationIn applies the In predicate on the "login_location" field. +func LoginLocationIn(vs ...string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldIn(FieldLoginLocation, vs...)) +} + +// LoginLocationNotIn applies the NotIn predicate on the "login_location" field. +func LoginLocationNotIn(vs ...string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldNotIn(FieldLoginLocation, vs...)) +} + +// LoginLocationGT applies the GT predicate on the "login_location" field. +func LoginLocationGT(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldGT(FieldLoginLocation, v)) +} + +// LoginLocationGTE applies the GTE predicate on the "login_location" field. +func LoginLocationGTE(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldGTE(FieldLoginLocation, v)) +} + +// LoginLocationLT applies the LT predicate on the "login_location" field. +func LoginLocationLT(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldLT(FieldLoginLocation, v)) +} + +// LoginLocationLTE applies the LTE predicate on the "login_location" field. +func LoginLocationLTE(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldLTE(FieldLoginLocation, v)) +} + +// LoginLocationContains applies the Contains predicate on the "login_location" field. +func LoginLocationContains(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldContains(FieldLoginLocation, v)) +} + +// LoginLocationHasPrefix applies the HasPrefix predicate on the "login_location" field. +func LoginLocationHasPrefix(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldHasPrefix(FieldLoginLocation, v)) +} + +// LoginLocationHasSuffix applies the HasSuffix predicate on the "login_location" field. +func LoginLocationHasSuffix(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldHasSuffix(FieldLoginLocation, v)) +} + +// LoginLocationIsNil applies the IsNil predicate on the "login_location" field. +func LoginLocationIsNil() predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldIsNull(FieldLoginLocation)) +} + +// LoginLocationNotNil applies the NotNil predicate on the "login_location" field. +func LoginLocationNotNil() predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldNotNull(FieldLoginLocation)) +} + +// LoginLocationEqualFold applies the EqualFold predicate on the "login_location" field. +func LoginLocationEqualFold(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldEqualFold(FieldLoginLocation, v)) +} + +// LoginLocationContainsFold applies the ContainsFold predicate on the "login_location" field. +func LoginLocationContainsFold(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldContainsFold(FieldLoginLocation, v)) +} + +// LoginTypeEQ applies the EQ predicate on the "login_type" field. +func LoginTypeEQ(v LoginType) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldEQ(FieldLoginType, v)) +} + +// LoginTypeNEQ applies the NEQ predicate on the "login_type" field. +func LoginTypeNEQ(v LoginType) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldNEQ(FieldLoginType, v)) +} + +// LoginTypeIn applies the In predicate on the "login_type" field. +func LoginTypeIn(vs ...LoginType) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldIn(FieldLoginType, vs...)) +} + +// LoginTypeNotIn applies the NotIn predicate on the "login_type" field. +func LoginTypeNotIn(vs ...LoginType) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldNotIn(FieldLoginType, vs...)) +} + +// LoginPlatformEQ applies the EQ predicate on the "login_platform" field. +func LoginPlatformEQ(v LoginPlatform) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldEQ(FieldLoginPlatform, v)) +} + +// LoginPlatformNEQ applies the NEQ predicate on the "login_platform" field. +func LoginPlatformNEQ(v LoginPlatform) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldNEQ(FieldLoginPlatform, v)) +} + +// LoginPlatformIn applies the In predicate on the "login_platform" field. +func LoginPlatformIn(vs ...LoginPlatform) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldIn(FieldLoginPlatform, vs...)) +} + +// LoginPlatformNotIn applies the NotIn predicate on the "login_platform" field. +func LoginPlatformNotIn(vs ...LoginPlatform) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldNotIn(FieldLoginPlatform, vs...)) +} + +// LoginResultEQ applies the EQ predicate on the "login_result" field. +func LoginResultEQ(v bool) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldEQ(FieldLoginResult, v)) +} + +// LoginResultNEQ applies the NEQ predicate on the "login_result" field. +func LoginResultNEQ(v bool) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldNEQ(FieldLoginResult, v)) +} + +// FailureReasonEQ applies the EQ predicate on the "failure_reason" field. +func FailureReasonEQ(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldEQ(FieldFailureReason, v)) +} + +// FailureReasonNEQ applies the NEQ predicate on the "failure_reason" field. +func FailureReasonNEQ(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldNEQ(FieldFailureReason, v)) +} + +// FailureReasonIn applies the In predicate on the "failure_reason" field. +func FailureReasonIn(vs ...string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldIn(FieldFailureReason, vs...)) +} + +// FailureReasonNotIn applies the NotIn predicate on the "failure_reason" field. +func FailureReasonNotIn(vs ...string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldNotIn(FieldFailureReason, vs...)) +} + +// FailureReasonGT applies the GT predicate on the "failure_reason" field. +func FailureReasonGT(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldGT(FieldFailureReason, v)) +} + +// FailureReasonGTE applies the GTE predicate on the "failure_reason" field. +func FailureReasonGTE(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldGTE(FieldFailureReason, v)) +} + +// FailureReasonLT applies the LT predicate on the "failure_reason" field. +func FailureReasonLT(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldLT(FieldFailureReason, v)) +} + +// FailureReasonLTE applies the LTE predicate on the "failure_reason" field. +func FailureReasonLTE(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldLTE(FieldFailureReason, v)) +} + +// FailureReasonContains applies the Contains predicate on the "failure_reason" field. +func FailureReasonContains(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldContains(FieldFailureReason, v)) +} + +// FailureReasonHasPrefix applies the HasPrefix predicate on the "failure_reason" field. +func FailureReasonHasPrefix(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldHasPrefix(FieldFailureReason, v)) +} + +// FailureReasonHasSuffix applies the HasSuffix predicate on the "failure_reason" field. +func FailureReasonHasSuffix(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldHasSuffix(FieldFailureReason, v)) +} + +// FailureReasonIsNil applies the IsNil predicate on the "failure_reason" field. +func FailureReasonIsNil() predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldIsNull(FieldFailureReason)) +} + +// FailureReasonNotNil applies the NotNil predicate on the "failure_reason" field. +func FailureReasonNotNil() predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldNotNull(FieldFailureReason)) +} + +// FailureReasonEqualFold applies the EqualFold predicate on the "failure_reason" field. +func FailureReasonEqualFold(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldEqualFold(FieldFailureReason, v)) +} + +// FailureReasonContainsFold applies the ContainsFold predicate on the "failure_reason" field. +func FailureReasonContainsFold(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldContainsFold(FieldFailureReason, v)) +} + +// SessionIDEQ applies the EQ predicate on the "session_id" field. +func SessionIDEQ(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldEQ(FieldSessionID, v)) +} + +// SessionIDNEQ applies the NEQ predicate on the "session_id" field. +func SessionIDNEQ(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldNEQ(FieldSessionID, v)) +} + +// SessionIDIn applies the In predicate on the "session_id" field. +func SessionIDIn(vs ...string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldIn(FieldSessionID, vs...)) +} + +// SessionIDNotIn applies the NotIn predicate on the "session_id" field. +func SessionIDNotIn(vs ...string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldNotIn(FieldSessionID, vs...)) +} + +// SessionIDGT applies the GT predicate on the "session_id" field. +func SessionIDGT(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldGT(FieldSessionID, v)) +} + +// SessionIDGTE applies the GTE predicate on the "session_id" field. +func SessionIDGTE(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldGTE(FieldSessionID, v)) +} + +// SessionIDLT applies the LT predicate on the "session_id" field. +func SessionIDLT(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldLT(FieldSessionID, v)) +} + +// SessionIDLTE applies the LTE predicate on the "session_id" field. +func SessionIDLTE(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldLTE(FieldSessionID, v)) +} + +// SessionIDContains applies the Contains predicate on the "session_id" field. +func SessionIDContains(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldContains(FieldSessionID, v)) +} + +// SessionIDHasPrefix applies the HasPrefix predicate on the "session_id" field. +func SessionIDHasPrefix(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldHasPrefix(FieldSessionID, v)) +} + +// SessionIDHasSuffix applies the HasSuffix predicate on the "session_id" field. +func SessionIDHasSuffix(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldHasSuffix(FieldSessionID, v)) +} + +// SessionIDIsNil applies the IsNil predicate on the "session_id" field. +func SessionIDIsNil() predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldIsNull(FieldSessionID)) +} + +// SessionIDNotNil applies the NotNil predicate on the "session_id" field. +func SessionIDNotNil() predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldNotNull(FieldSessionID)) +} + +// SessionIDEqualFold applies the EqualFold predicate on the "session_id" field. +func SessionIDEqualFold(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldEqualFold(FieldSessionID, v)) +} + +// SessionIDContainsFold applies the ContainsFold predicate on the "session_id" field. +func SessionIDContainsFold(v string) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldContainsFold(FieldSessionID, v)) +} + +// LatencyMsEQ applies the EQ predicate on the "latency_ms" field. +func LatencyMsEQ(v int) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldEQ(FieldLatencyMs, v)) +} + +// LatencyMsNEQ applies the NEQ predicate on the "latency_ms" field. +func LatencyMsNEQ(v int) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldNEQ(FieldLatencyMs, v)) +} + +// LatencyMsIn applies the In predicate on the "latency_ms" field. +func LatencyMsIn(vs ...int) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldIn(FieldLatencyMs, vs...)) +} + +// LatencyMsNotIn applies the NotIn predicate on the "latency_ms" field. +func LatencyMsNotIn(vs ...int) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldNotIn(FieldLatencyMs, vs...)) +} + +// LatencyMsGT applies the GT predicate on the "latency_ms" field. +func LatencyMsGT(v int) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldGT(FieldLatencyMs, v)) +} + +// LatencyMsGTE applies the GTE predicate on the "latency_ms" field. +func LatencyMsGTE(v int) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldGTE(FieldLatencyMs, v)) +} + +// LatencyMsLT applies the LT predicate on the "latency_ms" field. +func LatencyMsLT(v int) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldLT(FieldLatencyMs, v)) +} + +// LatencyMsLTE applies the LTE predicate on the "latency_ms" field. +func LatencyMsLTE(v int) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldLTE(FieldLatencyMs, v)) +} + +// LatencyMsIsNil applies the IsNil predicate on the "latency_ms" field. +func LatencyMsIsNil() predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldIsNull(FieldLatencyMs)) +} + +// LatencyMsNotNil applies the NotNil predicate on the "latency_ms" field. +func LatencyMsNotNil() predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldNotNull(FieldLatencyMs)) +} + +// AuthIDEQ applies the EQ predicate on the "auth_id" field. +func AuthIDEQ(v uint64) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldEQ(FieldAuthID, v)) +} + +// AuthIDNEQ applies the NEQ predicate on the "auth_id" field. +func AuthIDNEQ(v uint64) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldNEQ(FieldAuthID, v)) +} + +// AuthIDIn applies the In predicate on the "auth_id" field. +func AuthIDIn(vs ...uint64) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldIn(FieldAuthID, vs...)) +} + +// AuthIDNotIn applies the NotIn predicate on the "auth_id" field. +func AuthIDNotIn(vs ...uint64) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldNotIn(FieldAuthID, vs...)) +} + +// AuthIDGT applies the GT predicate on the "auth_id" field. +func AuthIDGT(v uint64) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldGT(FieldAuthID, v)) +} + +// AuthIDGTE applies the GTE predicate on the "auth_id" field. +func AuthIDGTE(v uint64) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldGTE(FieldAuthID, v)) +} + +// AuthIDLT applies the LT predicate on the "auth_id" field. +func AuthIDLT(v uint64) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldLT(FieldAuthID, v)) +} + +// AuthIDLTE applies the LTE predicate on the "auth_id" field. +func AuthIDLTE(v uint64) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldLTE(FieldAuthID, v)) +} + +// AuthIDIsNil applies the IsNil predicate on the "auth_id" field. +func AuthIDIsNil() predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldIsNull(FieldAuthID)) +} + +// AuthIDNotNil applies the NotNil predicate on the "auth_id" field. +func AuthIDNotNil() predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldNotNull(FieldAuthID)) +} + +// AdditionalDataIsNil applies the IsNil predicate on the "additional_data" field. +func AdditionalDataIsNil() predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldIsNull(FieldAdditionalData)) +} + +// AdditionalDataNotNil applies the NotNil predicate on the "additional_data" field. +func AdditionalDataNotNil() predicate.UserLoginLog { + return predicate.UserLoginLog(sql.FieldNotNull(FieldAdditionalData)) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.UserLoginLog) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.UserLoginLog) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.UserLoginLog) predicate.UserLoginLog { + return predicate.UserLoginLog(sql.NotPredicates(p)) +} diff --git a/rpc/ent/userloginlog_create.go b/rpc/ent/userloginlog_create.go new file mode 100644 index 0000000..dcde271 --- /dev/null +++ b/rpc/ent/userloginlog_create.go @@ -0,0 +1,560 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "mingyang-admin-app-rpc/ent/userloginlog" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// UserLoginLogCreate is the builder for creating a UserLoginLog entity. +type UserLoginLogCreate struct { + config + mutation *UserLoginLogMutation + hooks []Hook +} + +// SetCreatedAt sets the "created_at" field. +func (_c *UserLoginLogCreate) SetCreatedAt(v time.Time) *UserLoginLogCreate { + _c.mutation.SetCreatedAt(v) + return _c +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_c *UserLoginLogCreate) SetNillableCreatedAt(v *time.Time) *UserLoginLogCreate { + if v != nil { + _c.SetCreatedAt(*v) + } + return _c +} + +// SetUpdatedAt sets the "updated_at" field. +func (_c *UserLoginLogCreate) SetUpdatedAt(v time.Time) *UserLoginLogCreate { + _c.mutation.SetUpdatedAt(v) + return _c +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (_c *UserLoginLogCreate) SetNillableUpdatedAt(v *time.Time) *UserLoginLogCreate { + if v != nil { + _c.SetUpdatedAt(*v) + } + return _c +} + +// SetStatus sets the "status" field. +func (_c *UserLoginLogCreate) SetStatus(v uint8) *UserLoginLogCreate { + _c.mutation.SetStatus(v) + return _c +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_c *UserLoginLogCreate) SetNillableStatus(v *uint8) *UserLoginLogCreate { + if v != nil { + _c.SetStatus(*v) + } + return _c +} + +// SetTenantID sets the "tenant_id" field. +func (_c *UserLoginLogCreate) SetTenantID(v uint64) *UserLoginLogCreate { + _c.mutation.SetTenantID(v) + return _c +} + +// SetNillableTenantID sets the "tenant_id" field if the given value is not nil. +func (_c *UserLoginLogCreate) SetNillableTenantID(v *uint64) *UserLoginLogCreate { + if v != nil { + _c.SetTenantID(*v) + } + return _c +} + +// SetDeletedAt sets the "deleted_at" field. +func (_c *UserLoginLogCreate) SetDeletedAt(v time.Time) *UserLoginLogCreate { + _c.mutation.SetDeletedAt(v) + return _c +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (_c *UserLoginLogCreate) SetNillableDeletedAt(v *time.Time) *UserLoginLogCreate { + if v != nil { + _c.SetDeletedAt(*v) + } + return _c +} + +// SetUserID sets the "user_id" field. +func (_c *UserLoginLogCreate) SetUserID(v uint64) *UserLoginLogCreate { + _c.mutation.SetUserID(v) + return _c +} + +// SetLoginTime sets the "login_time" field. +func (_c *UserLoginLogCreate) SetLoginTime(v time.Time) *UserLoginLogCreate { + _c.mutation.SetLoginTime(v) + return _c +} + +// SetNillableLoginTime sets the "login_time" field if the given value is not nil. +func (_c *UserLoginLogCreate) SetNillableLoginTime(v *time.Time) *UserLoginLogCreate { + if v != nil { + _c.SetLoginTime(*v) + } + return _c +} + +// SetLoginIP sets the "login_ip" field. +func (_c *UserLoginLogCreate) SetLoginIP(v string) *UserLoginLogCreate { + _c.mutation.SetLoginIP(v) + return _c +} + +// SetLoginLocation sets the "login_location" field. +func (_c *UserLoginLogCreate) SetLoginLocation(v string) *UserLoginLogCreate { + _c.mutation.SetLoginLocation(v) + return _c +} + +// SetNillableLoginLocation sets the "login_location" field if the given value is not nil. +func (_c *UserLoginLogCreate) SetNillableLoginLocation(v *string) *UserLoginLogCreate { + if v != nil { + _c.SetLoginLocation(*v) + } + return _c +} + +// SetLoginType sets the "login_type" field. +func (_c *UserLoginLogCreate) SetLoginType(v userloginlog.LoginType) *UserLoginLogCreate { + _c.mutation.SetLoginType(v) + return _c +} + +// SetNillableLoginType sets the "login_type" field if the given value is not nil. +func (_c *UserLoginLogCreate) SetNillableLoginType(v *userloginlog.LoginType) *UserLoginLogCreate { + if v != nil { + _c.SetLoginType(*v) + } + return _c +} + +// SetLoginPlatform sets the "login_platform" field. +func (_c *UserLoginLogCreate) SetLoginPlatform(v userloginlog.LoginPlatform) *UserLoginLogCreate { + _c.mutation.SetLoginPlatform(v) + return _c +} + +// SetNillableLoginPlatform sets the "login_platform" field if the given value is not nil. +func (_c *UserLoginLogCreate) SetNillableLoginPlatform(v *userloginlog.LoginPlatform) *UserLoginLogCreate { + if v != nil { + _c.SetLoginPlatform(*v) + } + return _c +} + +// SetLoginResult sets the "login_result" field. +func (_c *UserLoginLogCreate) SetLoginResult(v bool) *UserLoginLogCreate { + _c.mutation.SetLoginResult(v) + return _c +} + +// SetNillableLoginResult sets the "login_result" field if the given value is not nil. +func (_c *UserLoginLogCreate) SetNillableLoginResult(v *bool) *UserLoginLogCreate { + if v != nil { + _c.SetLoginResult(*v) + } + return _c +} + +// SetFailureReason sets the "failure_reason" field. +func (_c *UserLoginLogCreate) SetFailureReason(v string) *UserLoginLogCreate { + _c.mutation.SetFailureReason(v) + return _c +} + +// SetNillableFailureReason sets the "failure_reason" field if the given value is not nil. +func (_c *UserLoginLogCreate) SetNillableFailureReason(v *string) *UserLoginLogCreate { + if v != nil { + _c.SetFailureReason(*v) + } + return _c +} + +// SetSessionID sets the "session_id" field. +func (_c *UserLoginLogCreate) SetSessionID(v string) *UserLoginLogCreate { + _c.mutation.SetSessionID(v) + return _c +} + +// SetNillableSessionID sets the "session_id" field if the given value is not nil. +func (_c *UserLoginLogCreate) SetNillableSessionID(v *string) *UserLoginLogCreate { + if v != nil { + _c.SetSessionID(*v) + } + return _c +} + +// SetLatencyMs sets the "latency_ms" field. +func (_c *UserLoginLogCreate) SetLatencyMs(v int) *UserLoginLogCreate { + _c.mutation.SetLatencyMs(v) + return _c +} + +// SetNillableLatencyMs sets the "latency_ms" field if the given value is not nil. +func (_c *UserLoginLogCreate) SetNillableLatencyMs(v *int) *UserLoginLogCreate { + if v != nil { + _c.SetLatencyMs(*v) + } + return _c +} + +// SetAuthID sets the "auth_id" field. +func (_c *UserLoginLogCreate) SetAuthID(v uint64) *UserLoginLogCreate { + _c.mutation.SetAuthID(v) + return _c +} + +// SetNillableAuthID sets the "auth_id" field if the given value is not nil. +func (_c *UserLoginLogCreate) SetNillableAuthID(v *uint64) *UserLoginLogCreate { + if v != nil { + _c.SetAuthID(*v) + } + return _c +} + +// SetAdditionalData sets the "additional_data" field. +func (_c *UserLoginLogCreate) SetAdditionalData(v map[string]interface{}) *UserLoginLogCreate { + _c.mutation.SetAdditionalData(v) + return _c +} + +// SetID sets the "id" field. +func (_c *UserLoginLogCreate) SetID(v uint64) *UserLoginLogCreate { + _c.mutation.SetID(v) + return _c +} + +// Mutation returns the UserLoginLogMutation object of the builder. +func (_c *UserLoginLogCreate) Mutation() *UserLoginLogMutation { + return _c.mutation +} + +// Save creates the UserLoginLog in the database. +func (_c *UserLoginLogCreate) Save(ctx context.Context) (*UserLoginLog, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *UserLoginLogCreate) SaveX(ctx context.Context) *UserLoginLog { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *UserLoginLogCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *UserLoginLogCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_c *UserLoginLogCreate) defaults() { + if _, ok := _c.mutation.CreatedAt(); !ok { + v := userloginlog.DefaultCreatedAt() + _c.mutation.SetCreatedAt(v) + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + v := userloginlog.DefaultUpdatedAt() + _c.mutation.SetUpdatedAt(v) + } + if _, ok := _c.mutation.Status(); !ok { + v := userloginlog.DefaultStatus + _c.mutation.SetStatus(v) + } + if _, ok := _c.mutation.TenantID(); !ok { + v := userloginlog.DefaultTenantID + _c.mutation.SetTenantID(v) + } + if _, ok := _c.mutation.LoginTime(); !ok { + v := userloginlog.DefaultLoginTime() + _c.mutation.SetLoginTime(v) + } + if _, ok := _c.mutation.LoginType(); !ok { + v := userloginlog.DefaultLoginType + _c.mutation.SetLoginType(v) + } + if _, ok := _c.mutation.LoginPlatform(); !ok { + v := userloginlog.DefaultLoginPlatform + _c.mutation.SetLoginPlatform(v) + } + if _, ok := _c.mutation.LoginResult(); !ok { + v := userloginlog.DefaultLoginResult + _c.mutation.SetLoginResult(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *UserLoginLogCreate) check() error { + if _, ok := _c.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "UserLoginLog.created_at"`)} + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "UserLoginLog.updated_at"`)} + } + if _, ok := _c.mutation.TenantID(); !ok { + return &ValidationError{Name: "tenant_id", err: errors.New(`ent: missing required field "UserLoginLog.tenant_id"`)} + } + if _, ok := _c.mutation.UserID(); !ok { + return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "UserLoginLog.user_id"`)} + } + if _, ok := _c.mutation.LoginTime(); !ok { + return &ValidationError{Name: "login_time", err: errors.New(`ent: missing required field "UserLoginLog.login_time"`)} + } + if _, ok := _c.mutation.LoginIP(); !ok { + return &ValidationError{Name: "login_ip", err: errors.New(`ent: missing required field "UserLoginLog.login_ip"`)} + } + if v, ok := _c.mutation.LoginIP(); ok { + if err := userloginlog.LoginIPValidator(v); err != nil { + return &ValidationError{Name: "login_ip", err: fmt.Errorf(`ent: validator failed for field "UserLoginLog.login_ip": %w`, err)} + } + } + if v, ok := _c.mutation.LoginLocation(); ok { + if err := userloginlog.LoginLocationValidator(v); err != nil { + return &ValidationError{Name: "login_location", err: fmt.Errorf(`ent: validator failed for field "UserLoginLog.login_location": %w`, err)} + } + } + if _, ok := _c.mutation.LoginType(); !ok { + return &ValidationError{Name: "login_type", err: errors.New(`ent: missing required field "UserLoginLog.login_type"`)} + } + if v, ok := _c.mutation.LoginType(); ok { + if err := userloginlog.LoginTypeValidator(v); err != nil { + return &ValidationError{Name: "login_type", err: fmt.Errorf(`ent: validator failed for field "UserLoginLog.login_type": %w`, err)} + } + } + if _, ok := _c.mutation.LoginPlatform(); !ok { + return &ValidationError{Name: "login_platform", err: errors.New(`ent: missing required field "UserLoginLog.login_platform"`)} + } + if v, ok := _c.mutation.LoginPlatform(); ok { + if err := userloginlog.LoginPlatformValidator(v); err != nil { + return &ValidationError{Name: "login_platform", err: fmt.Errorf(`ent: validator failed for field "UserLoginLog.login_platform": %w`, err)} + } + } + if _, ok := _c.mutation.LoginResult(); !ok { + return &ValidationError{Name: "login_result", err: errors.New(`ent: missing required field "UserLoginLog.login_result"`)} + } + if v, ok := _c.mutation.FailureReason(); ok { + if err := userloginlog.FailureReasonValidator(v); err != nil { + return &ValidationError{Name: "failure_reason", err: fmt.Errorf(`ent: validator failed for field "UserLoginLog.failure_reason": %w`, err)} + } + } + if v, ok := _c.mutation.SessionID(); ok { + if err := userloginlog.SessionIDValidator(v); err != nil { + return &ValidationError{Name: "session_id", err: fmt.Errorf(`ent: validator failed for field "UserLoginLog.session_id": %w`, err)} + } + } + return nil +} + +func (_c *UserLoginLogCreate) sqlSave(ctx context.Context) (*UserLoginLog, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != _node.ID { + id := _spec.ID.Value.(int64) + _node.ID = uint64(id) + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *UserLoginLogCreate) createSpec() (*UserLoginLog, *sqlgraph.CreateSpec) { + var ( + _node = &UserLoginLog{config: _c.config} + _spec = sqlgraph.NewCreateSpec(userloginlog.Table, sqlgraph.NewFieldSpec(userloginlog.FieldID, field.TypeUint64)) + ) + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := _c.mutation.CreatedAt(); ok { + _spec.SetField(userloginlog.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := _c.mutation.UpdatedAt(); ok { + _spec.SetField(userloginlog.FieldUpdatedAt, field.TypeTime, value) + _node.UpdatedAt = value + } + if value, ok := _c.mutation.Status(); ok { + _spec.SetField(userloginlog.FieldStatus, field.TypeUint8, value) + _node.Status = value + } + if value, ok := _c.mutation.TenantID(); ok { + _spec.SetField(userloginlog.FieldTenantID, field.TypeUint64, value) + _node.TenantID = value + } + if value, ok := _c.mutation.DeletedAt(); ok { + _spec.SetField(userloginlog.FieldDeletedAt, field.TypeTime, value) + _node.DeletedAt = value + } + if value, ok := _c.mutation.UserID(); ok { + _spec.SetField(userloginlog.FieldUserID, field.TypeUint64, value) + _node.UserID = value + } + if value, ok := _c.mutation.LoginTime(); ok { + _spec.SetField(userloginlog.FieldLoginTime, field.TypeTime, value) + _node.LoginTime = value + } + if value, ok := _c.mutation.LoginIP(); ok { + _spec.SetField(userloginlog.FieldLoginIP, field.TypeString, value) + _node.LoginIP = value + } + if value, ok := _c.mutation.LoginLocation(); ok { + _spec.SetField(userloginlog.FieldLoginLocation, field.TypeString, value) + _node.LoginLocation = value + } + if value, ok := _c.mutation.LoginType(); ok { + _spec.SetField(userloginlog.FieldLoginType, field.TypeEnum, value) + _node.LoginType = value + } + if value, ok := _c.mutation.LoginPlatform(); ok { + _spec.SetField(userloginlog.FieldLoginPlatform, field.TypeEnum, value) + _node.LoginPlatform = value + } + if value, ok := _c.mutation.LoginResult(); ok { + _spec.SetField(userloginlog.FieldLoginResult, field.TypeBool, value) + _node.LoginResult = value + } + if value, ok := _c.mutation.FailureReason(); ok { + _spec.SetField(userloginlog.FieldFailureReason, field.TypeString, value) + _node.FailureReason = value + } + if value, ok := _c.mutation.SessionID(); ok { + _spec.SetField(userloginlog.FieldSessionID, field.TypeString, value) + _node.SessionID = value + } + if value, ok := _c.mutation.LatencyMs(); ok { + _spec.SetField(userloginlog.FieldLatencyMs, field.TypeInt, value) + _node.LatencyMs = value + } + if value, ok := _c.mutation.AuthID(); ok { + _spec.SetField(userloginlog.FieldAuthID, field.TypeUint64, value) + _node.AuthID = value + } + if value, ok := _c.mutation.AdditionalData(); ok { + _spec.SetField(userloginlog.FieldAdditionalData, field.TypeJSON, value) + _node.AdditionalData = value + } + return _node, _spec +} + +// UserLoginLogCreateBulk is the builder for creating many UserLoginLog entities in bulk. +type UserLoginLogCreateBulk struct { + config + err error + builders []*UserLoginLogCreate +} + +// Save creates the UserLoginLog entities in the database. +func (_c *UserLoginLogCreateBulk) Save(ctx context.Context) ([]*UserLoginLog, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*UserLoginLog, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*UserLoginLogMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil && nodes[i].ID == 0 { + id := specs[i].ID.Value.(int64) + nodes[i].ID = uint64(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *UserLoginLogCreateBulk) SaveX(ctx context.Context) []*UserLoginLog { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *UserLoginLogCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *UserLoginLogCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/rpc/ent/userloginlog_delete.go b/rpc/ent/userloginlog_delete.go new file mode 100644 index 0000000..176ae13 --- /dev/null +++ b/rpc/ent/userloginlog_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "mingyang-admin-app-rpc/ent/predicate" + "mingyang-admin-app-rpc/ent/userloginlog" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// UserLoginLogDelete is the builder for deleting a UserLoginLog entity. +type UserLoginLogDelete struct { + config + hooks []Hook + mutation *UserLoginLogMutation +} + +// Where appends a list predicates to the UserLoginLogDelete builder. +func (_d *UserLoginLogDelete) Where(ps ...predicate.UserLoginLog) *UserLoginLogDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *UserLoginLogDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *UserLoginLogDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *UserLoginLogDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(userloginlog.Table, sqlgraph.NewFieldSpec(userloginlog.FieldID, field.TypeUint64)) + if ps := _d.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + _d.mutation.done = true + return affected, err +} + +// UserLoginLogDeleteOne is the builder for deleting a single UserLoginLog entity. +type UserLoginLogDeleteOne struct { + _d *UserLoginLogDelete +} + +// Where appends a list predicates to the UserLoginLogDelete builder. +func (_d *UserLoginLogDeleteOne) Where(ps ...predicate.UserLoginLog) *UserLoginLogDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *UserLoginLogDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{userloginlog.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *UserLoginLogDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/rpc/ent/userloginlog_query.go b/rpc/ent/userloginlog_query.go new file mode 100644 index 0000000..88efb5c --- /dev/null +++ b/rpc/ent/userloginlog_query.go @@ -0,0 +1,527 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + "mingyang-admin-app-rpc/ent/predicate" + "mingyang-admin-app-rpc/ent/userloginlog" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// UserLoginLogQuery is the builder for querying UserLoginLog entities. +type UserLoginLogQuery struct { + config + ctx *QueryContext + order []userloginlog.OrderOption + inters []Interceptor + predicates []predicate.UserLoginLog + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the UserLoginLogQuery builder. +func (_q *UserLoginLogQuery) Where(ps ...predicate.UserLoginLog) *UserLoginLogQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *UserLoginLogQuery) Limit(limit int) *UserLoginLogQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *UserLoginLogQuery) Offset(offset int) *UserLoginLogQuery { + _q.ctx.Offset = &offset + return _q +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (_q *UserLoginLogQuery) Unique(unique bool) *UserLoginLogQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *UserLoginLogQuery) Order(o ...userloginlog.OrderOption) *UserLoginLogQuery { + _q.order = append(_q.order, o...) + return _q +} + +// First returns the first UserLoginLog entity from the query. +// Returns a *NotFoundError when no UserLoginLog was found. +func (_q *UserLoginLogQuery) First(ctx context.Context) (*UserLoginLog, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{userloginlog.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *UserLoginLogQuery) FirstX(ctx context.Context) *UserLoginLog { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first UserLoginLog ID from the query. +// Returns a *NotFoundError when no UserLoginLog ID was found. +func (_q *UserLoginLogQuery) FirstID(ctx context.Context) (id uint64, err error) { + var ids []uint64 + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{userloginlog.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *UserLoginLogQuery) FirstIDX(ctx context.Context) uint64 { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single UserLoginLog entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one UserLoginLog entity is found. +// Returns a *NotFoundError when no UserLoginLog entities are found. +func (_q *UserLoginLogQuery) Only(ctx context.Context) (*UserLoginLog, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{userloginlog.Label} + default: + return nil, &NotSingularError{userloginlog.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *UserLoginLogQuery) OnlyX(ctx context.Context) *UserLoginLog { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only UserLoginLog ID in the query. +// Returns a *NotSingularError when more than one UserLoginLog ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *UserLoginLogQuery) OnlyID(ctx context.Context) (id uint64, err error) { + var ids []uint64 + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{userloginlog.Label} + default: + err = &NotSingularError{userloginlog.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *UserLoginLogQuery) OnlyIDX(ctx context.Context) uint64 { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of UserLoginLogs. +func (_q *UserLoginLogQuery) All(ctx context.Context) ([]*UserLoginLog, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*UserLoginLog, *UserLoginLogQuery]() + return withInterceptors[[]*UserLoginLog](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *UserLoginLogQuery) AllX(ctx context.Context) []*UserLoginLog { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of UserLoginLog IDs. +func (_q *UserLoginLogQuery) IDs(ctx context.Context) (ids []uint64, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(userloginlog.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *UserLoginLogQuery) IDsX(ctx context.Context) []uint64 { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *UserLoginLogQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, _q, querierCount[*UserLoginLogQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *UserLoginLogQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (_q *UserLoginLogQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *UserLoginLogQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the UserLoginLogQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (_q *UserLoginLogQuery) Clone() *UserLoginLogQuery { + if _q == nil { + return nil + } + return &UserLoginLogQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]userloginlog.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.UserLoginLog{}, _q.predicates...), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + } +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// CreatedAt time.Time `json:"created_at,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.UserLoginLog.Query(). +// GroupBy(userloginlog.FieldCreatedAt). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *UserLoginLogQuery) GroupBy(field string, fields ...string) *UserLoginLogGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &UserLoginLogGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = userloginlog.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 { +// CreatedAt time.Time `json:"created_at,omitempty"` +// } +// +// client.UserLoginLog.Query(). +// Select(userloginlog.FieldCreatedAt). +// Scan(ctx, &v) +func (_q *UserLoginLogQuery) Select(fields ...string) *UserLoginLogSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &UserLoginLogSelect{UserLoginLogQuery: _q} + sbuild.label = userloginlog.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a UserLoginLogSelect configured with the given aggregations. +func (_q *UserLoginLogQuery) Aggregate(fns ...AggregateFunc) *UserLoginLogSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *UserLoginLogQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !userloginlog.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if _q.path != nil { + prev, err := _q.path(ctx) + if err != nil { + return err + } + _q.sql = prev + } + return nil +} + +func (_q *UserLoginLogQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*UserLoginLog, error) { + var ( + nodes = []*UserLoginLog{} + _spec = _q.querySpec() + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*UserLoginLog).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &UserLoginLog{config: _q.config} + nodes = append(nodes, node) + return node.assignValues(columns, values) + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + return nodes, nil +} + +func (_q *UserLoginLogQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique + } + return sqlgraph.CountNodes(ctx, _q.driver, _spec) +} + +func (_q *UserLoginLogQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(userloginlog.Table, userloginlog.Columns, sqlgraph.NewFieldSpec(userloginlog.FieldID, field.TypeUint64)) + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if _q.path != nil { + _spec.Unique = true + } + if fields := _q.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, userloginlog.FieldID) + for i := range fields { + if fields[i] != userloginlog.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := _q.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := _q.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := _q.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := _q.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (_q *UserLoginLogQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(userloginlog.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = userloginlog.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if _q.sql != nil { + selector = _q.sql + selector.Select(selector.Columns(columns...)...) + } + if _q.ctx.Unique != nil && *_q.ctx.Unique { + selector.Distinct() + } + for _, p := range _q.predicates { + p(selector) + } + for _, p := range _q.order { + p(selector) + } + if offset := _q.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := _q.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// UserLoginLogGroupBy is the group-by builder for UserLoginLog entities. +type UserLoginLogGroupBy struct { + selector + build *UserLoginLogQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *UserLoginLogGroupBy) Aggregate(fns ...AggregateFunc) *UserLoginLogGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *UserLoginLogGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*UserLoginLogQuery, *UserLoginLogGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *UserLoginLogGroupBy) sqlScan(ctx context.Context, root *UserLoginLogQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*_g.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// UserLoginLogSelect is the builder for selecting fields of UserLoginLog entities. +type UserLoginLogSelect struct { + *UserLoginLogQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *UserLoginLogSelect) Aggregate(fns ...AggregateFunc) *UserLoginLogSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *UserLoginLogSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*UserLoginLogQuery, *UserLoginLogSelect](ctx, _s.UserLoginLogQuery, _s, _s.inters, v) +} + +func (_s *UserLoginLogSelect) sqlScan(ctx context.Context, root *UserLoginLogQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/rpc/ent/userloginlog_update.go b/rpc/ent/userloginlog_update.go new file mode 100644 index 0000000..07c1b23 --- /dev/null +++ b/rpc/ent/userloginlog_update.go @@ -0,0 +1,972 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "mingyang-admin-app-rpc/ent/predicate" + "mingyang-admin-app-rpc/ent/userloginlog" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// UserLoginLogUpdate is the builder for updating UserLoginLog entities. +type UserLoginLogUpdate struct { + config + hooks []Hook + mutation *UserLoginLogMutation +} + +// Where appends a list predicates to the UserLoginLogUpdate builder. +func (_u *UserLoginLogUpdate) Where(ps ...predicate.UserLoginLog) *UserLoginLogUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *UserLoginLogUpdate) SetUpdatedAt(v time.Time) *UserLoginLogUpdate { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// SetStatus sets the "status" field. +func (_u *UserLoginLogUpdate) SetStatus(v uint8) *UserLoginLogUpdate { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_u *UserLoginLogUpdate) SetNillableStatus(v *uint8) *UserLoginLogUpdate { + if v != nil { + _u.SetStatus(*v) + } + return _u +} + +// AddStatus adds value to the "status" field. +func (_u *UserLoginLogUpdate) AddStatus(v int8) *UserLoginLogUpdate { + _u.mutation.AddStatus(v) + return _u +} + +// ClearStatus clears the value of the "status" field. +func (_u *UserLoginLogUpdate) ClearStatus() *UserLoginLogUpdate { + _u.mutation.ClearStatus() + return _u +} + +// SetDeletedAt sets the "deleted_at" field. +func (_u *UserLoginLogUpdate) SetDeletedAt(v time.Time) *UserLoginLogUpdate { + _u.mutation.SetDeletedAt(v) + return _u +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (_u *UserLoginLogUpdate) SetNillableDeletedAt(v *time.Time) *UserLoginLogUpdate { + if v != nil { + _u.SetDeletedAt(*v) + } + return _u +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (_u *UserLoginLogUpdate) ClearDeletedAt() *UserLoginLogUpdate { + _u.mutation.ClearDeletedAt() + return _u +} + +// SetUserID sets the "user_id" field. +func (_u *UserLoginLogUpdate) SetUserID(v uint64) *UserLoginLogUpdate { + _u.mutation.ResetUserID() + _u.mutation.SetUserID(v) + return _u +} + +// SetNillableUserID sets the "user_id" field if the given value is not nil. +func (_u *UserLoginLogUpdate) SetNillableUserID(v *uint64) *UserLoginLogUpdate { + if v != nil { + _u.SetUserID(*v) + } + return _u +} + +// AddUserID adds value to the "user_id" field. +func (_u *UserLoginLogUpdate) AddUserID(v int64) *UserLoginLogUpdate { + _u.mutation.AddUserID(v) + return _u +} + +// SetLoginTime sets the "login_time" field. +func (_u *UserLoginLogUpdate) SetLoginTime(v time.Time) *UserLoginLogUpdate { + _u.mutation.SetLoginTime(v) + return _u +} + +// SetNillableLoginTime sets the "login_time" field if the given value is not nil. +func (_u *UserLoginLogUpdate) SetNillableLoginTime(v *time.Time) *UserLoginLogUpdate { + if v != nil { + _u.SetLoginTime(*v) + } + return _u +} + +// SetLoginIP sets the "login_ip" field. +func (_u *UserLoginLogUpdate) SetLoginIP(v string) *UserLoginLogUpdate { + _u.mutation.SetLoginIP(v) + return _u +} + +// SetNillableLoginIP sets the "login_ip" field if the given value is not nil. +func (_u *UserLoginLogUpdate) SetNillableLoginIP(v *string) *UserLoginLogUpdate { + if v != nil { + _u.SetLoginIP(*v) + } + return _u +} + +// SetLoginLocation sets the "login_location" field. +func (_u *UserLoginLogUpdate) SetLoginLocation(v string) *UserLoginLogUpdate { + _u.mutation.SetLoginLocation(v) + return _u +} + +// SetNillableLoginLocation sets the "login_location" field if the given value is not nil. +func (_u *UserLoginLogUpdate) SetNillableLoginLocation(v *string) *UserLoginLogUpdate { + if v != nil { + _u.SetLoginLocation(*v) + } + return _u +} + +// ClearLoginLocation clears the value of the "login_location" field. +func (_u *UserLoginLogUpdate) ClearLoginLocation() *UserLoginLogUpdate { + _u.mutation.ClearLoginLocation() + return _u +} + +// SetLoginType sets the "login_type" field. +func (_u *UserLoginLogUpdate) SetLoginType(v userloginlog.LoginType) *UserLoginLogUpdate { + _u.mutation.SetLoginType(v) + return _u +} + +// SetNillableLoginType sets the "login_type" field if the given value is not nil. +func (_u *UserLoginLogUpdate) SetNillableLoginType(v *userloginlog.LoginType) *UserLoginLogUpdate { + if v != nil { + _u.SetLoginType(*v) + } + return _u +} + +// SetLoginPlatform sets the "login_platform" field. +func (_u *UserLoginLogUpdate) SetLoginPlatform(v userloginlog.LoginPlatform) *UserLoginLogUpdate { + _u.mutation.SetLoginPlatform(v) + return _u +} + +// SetNillableLoginPlatform sets the "login_platform" field if the given value is not nil. +func (_u *UserLoginLogUpdate) SetNillableLoginPlatform(v *userloginlog.LoginPlatform) *UserLoginLogUpdate { + if v != nil { + _u.SetLoginPlatform(*v) + } + return _u +} + +// SetLoginResult sets the "login_result" field. +func (_u *UserLoginLogUpdate) SetLoginResult(v bool) *UserLoginLogUpdate { + _u.mutation.SetLoginResult(v) + return _u +} + +// SetNillableLoginResult sets the "login_result" field if the given value is not nil. +func (_u *UserLoginLogUpdate) SetNillableLoginResult(v *bool) *UserLoginLogUpdate { + if v != nil { + _u.SetLoginResult(*v) + } + return _u +} + +// SetFailureReason sets the "failure_reason" field. +func (_u *UserLoginLogUpdate) SetFailureReason(v string) *UserLoginLogUpdate { + _u.mutation.SetFailureReason(v) + return _u +} + +// SetNillableFailureReason sets the "failure_reason" field if the given value is not nil. +func (_u *UserLoginLogUpdate) SetNillableFailureReason(v *string) *UserLoginLogUpdate { + if v != nil { + _u.SetFailureReason(*v) + } + return _u +} + +// ClearFailureReason clears the value of the "failure_reason" field. +func (_u *UserLoginLogUpdate) ClearFailureReason() *UserLoginLogUpdate { + _u.mutation.ClearFailureReason() + return _u +} + +// SetSessionID sets the "session_id" field. +func (_u *UserLoginLogUpdate) SetSessionID(v string) *UserLoginLogUpdate { + _u.mutation.SetSessionID(v) + return _u +} + +// SetNillableSessionID sets the "session_id" field if the given value is not nil. +func (_u *UserLoginLogUpdate) SetNillableSessionID(v *string) *UserLoginLogUpdate { + if v != nil { + _u.SetSessionID(*v) + } + return _u +} + +// ClearSessionID clears the value of the "session_id" field. +func (_u *UserLoginLogUpdate) ClearSessionID() *UserLoginLogUpdate { + _u.mutation.ClearSessionID() + return _u +} + +// SetLatencyMs sets the "latency_ms" field. +func (_u *UserLoginLogUpdate) SetLatencyMs(v int) *UserLoginLogUpdate { + _u.mutation.ResetLatencyMs() + _u.mutation.SetLatencyMs(v) + return _u +} + +// SetNillableLatencyMs sets the "latency_ms" field if the given value is not nil. +func (_u *UserLoginLogUpdate) SetNillableLatencyMs(v *int) *UserLoginLogUpdate { + if v != nil { + _u.SetLatencyMs(*v) + } + return _u +} + +// AddLatencyMs adds value to the "latency_ms" field. +func (_u *UserLoginLogUpdate) AddLatencyMs(v int) *UserLoginLogUpdate { + _u.mutation.AddLatencyMs(v) + return _u +} + +// ClearLatencyMs clears the value of the "latency_ms" field. +func (_u *UserLoginLogUpdate) ClearLatencyMs() *UserLoginLogUpdate { + _u.mutation.ClearLatencyMs() + return _u +} + +// SetAuthID sets the "auth_id" field. +func (_u *UserLoginLogUpdate) SetAuthID(v uint64) *UserLoginLogUpdate { + _u.mutation.ResetAuthID() + _u.mutation.SetAuthID(v) + return _u +} + +// SetNillableAuthID sets the "auth_id" field if the given value is not nil. +func (_u *UserLoginLogUpdate) SetNillableAuthID(v *uint64) *UserLoginLogUpdate { + if v != nil { + _u.SetAuthID(*v) + } + return _u +} + +// AddAuthID adds value to the "auth_id" field. +func (_u *UserLoginLogUpdate) AddAuthID(v int64) *UserLoginLogUpdate { + _u.mutation.AddAuthID(v) + return _u +} + +// ClearAuthID clears the value of the "auth_id" field. +func (_u *UserLoginLogUpdate) ClearAuthID() *UserLoginLogUpdate { + _u.mutation.ClearAuthID() + return _u +} + +// SetAdditionalData sets the "additional_data" field. +func (_u *UserLoginLogUpdate) SetAdditionalData(v map[string]interface{}) *UserLoginLogUpdate { + _u.mutation.SetAdditionalData(v) + return _u +} + +// ClearAdditionalData clears the value of the "additional_data" field. +func (_u *UserLoginLogUpdate) ClearAdditionalData() *UserLoginLogUpdate { + _u.mutation.ClearAdditionalData() + return _u +} + +// Mutation returns the UserLoginLogMutation object of the builder. +func (_u *UserLoginLogUpdate) Mutation() *UserLoginLogMutation { + return _u.mutation +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *UserLoginLogUpdate) Save(ctx context.Context) (int, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *UserLoginLogUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *UserLoginLogUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *UserLoginLogUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *UserLoginLogUpdate) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := userloginlog.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *UserLoginLogUpdate) check() error { + if v, ok := _u.mutation.LoginIP(); ok { + if err := userloginlog.LoginIPValidator(v); err != nil { + return &ValidationError{Name: "login_ip", err: fmt.Errorf(`ent: validator failed for field "UserLoginLog.login_ip": %w`, err)} + } + } + if v, ok := _u.mutation.LoginLocation(); ok { + if err := userloginlog.LoginLocationValidator(v); err != nil { + return &ValidationError{Name: "login_location", err: fmt.Errorf(`ent: validator failed for field "UserLoginLog.login_location": %w`, err)} + } + } + if v, ok := _u.mutation.LoginType(); ok { + if err := userloginlog.LoginTypeValidator(v); err != nil { + return &ValidationError{Name: "login_type", err: fmt.Errorf(`ent: validator failed for field "UserLoginLog.login_type": %w`, err)} + } + } + if v, ok := _u.mutation.LoginPlatform(); ok { + if err := userloginlog.LoginPlatformValidator(v); err != nil { + return &ValidationError{Name: "login_platform", err: fmt.Errorf(`ent: validator failed for field "UserLoginLog.login_platform": %w`, err)} + } + } + if v, ok := _u.mutation.FailureReason(); ok { + if err := userloginlog.FailureReasonValidator(v); err != nil { + return &ValidationError{Name: "failure_reason", err: fmt.Errorf(`ent: validator failed for field "UserLoginLog.failure_reason": %w`, err)} + } + } + if v, ok := _u.mutation.SessionID(); ok { + if err := userloginlog.SessionIDValidator(v); err != nil { + return &ValidationError{Name: "session_id", err: fmt.Errorf(`ent: validator failed for field "UserLoginLog.session_id": %w`, err)} + } + } + return nil +} + +func (_u *UserLoginLogUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(userloginlog.Table, userloginlog.Columns, sqlgraph.NewFieldSpec(userloginlog.FieldID, field.TypeUint64)) + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.UpdatedAt(); ok { + _spec.SetField(userloginlog.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.Status(); ok { + _spec.SetField(userloginlog.FieldStatus, field.TypeUint8, value) + } + if value, ok := _u.mutation.AddedStatus(); ok { + _spec.AddField(userloginlog.FieldStatus, field.TypeUint8, value) + } + if _u.mutation.StatusCleared() { + _spec.ClearField(userloginlog.FieldStatus, field.TypeUint8) + } + if value, ok := _u.mutation.DeletedAt(); ok { + _spec.SetField(userloginlog.FieldDeletedAt, field.TypeTime, value) + } + if _u.mutation.DeletedAtCleared() { + _spec.ClearField(userloginlog.FieldDeletedAt, field.TypeTime) + } + if value, ok := _u.mutation.UserID(); ok { + _spec.SetField(userloginlog.FieldUserID, field.TypeUint64, value) + } + if value, ok := _u.mutation.AddedUserID(); ok { + _spec.AddField(userloginlog.FieldUserID, field.TypeUint64, value) + } + if value, ok := _u.mutation.LoginTime(); ok { + _spec.SetField(userloginlog.FieldLoginTime, field.TypeTime, value) + } + if value, ok := _u.mutation.LoginIP(); ok { + _spec.SetField(userloginlog.FieldLoginIP, field.TypeString, value) + } + if value, ok := _u.mutation.LoginLocation(); ok { + _spec.SetField(userloginlog.FieldLoginLocation, field.TypeString, value) + } + if _u.mutation.LoginLocationCleared() { + _spec.ClearField(userloginlog.FieldLoginLocation, field.TypeString) + } + if value, ok := _u.mutation.LoginType(); ok { + _spec.SetField(userloginlog.FieldLoginType, field.TypeEnum, value) + } + if value, ok := _u.mutation.LoginPlatform(); ok { + _spec.SetField(userloginlog.FieldLoginPlatform, field.TypeEnum, value) + } + if value, ok := _u.mutation.LoginResult(); ok { + _spec.SetField(userloginlog.FieldLoginResult, field.TypeBool, value) + } + if value, ok := _u.mutation.FailureReason(); ok { + _spec.SetField(userloginlog.FieldFailureReason, field.TypeString, value) + } + if _u.mutation.FailureReasonCleared() { + _spec.ClearField(userloginlog.FieldFailureReason, field.TypeString) + } + if value, ok := _u.mutation.SessionID(); ok { + _spec.SetField(userloginlog.FieldSessionID, field.TypeString, value) + } + if _u.mutation.SessionIDCleared() { + _spec.ClearField(userloginlog.FieldSessionID, field.TypeString) + } + if value, ok := _u.mutation.LatencyMs(); ok { + _spec.SetField(userloginlog.FieldLatencyMs, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedLatencyMs(); ok { + _spec.AddField(userloginlog.FieldLatencyMs, field.TypeInt, value) + } + if _u.mutation.LatencyMsCleared() { + _spec.ClearField(userloginlog.FieldLatencyMs, field.TypeInt) + } + if value, ok := _u.mutation.AuthID(); ok { + _spec.SetField(userloginlog.FieldAuthID, field.TypeUint64, value) + } + if value, ok := _u.mutation.AddedAuthID(); ok { + _spec.AddField(userloginlog.FieldAuthID, field.TypeUint64, value) + } + if _u.mutation.AuthIDCleared() { + _spec.ClearField(userloginlog.FieldAuthID, field.TypeUint64) + } + if value, ok := _u.mutation.AdditionalData(); ok { + _spec.SetField(userloginlog.FieldAdditionalData, field.TypeJSON, value) + } + if _u.mutation.AdditionalDataCleared() { + _spec.ClearField(userloginlog.FieldAdditionalData, field.TypeJSON) + } + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{userloginlog.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// UserLoginLogUpdateOne is the builder for updating a single UserLoginLog entity. +type UserLoginLogUpdateOne struct { + config + fields []string + hooks []Hook + mutation *UserLoginLogMutation +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *UserLoginLogUpdateOne) SetUpdatedAt(v time.Time) *UserLoginLogUpdateOne { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// SetStatus sets the "status" field. +func (_u *UserLoginLogUpdateOne) SetStatus(v uint8) *UserLoginLogUpdateOne { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_u *UserLoginLogUpdateOne) SetNillableStatus(v *uint8) *UserLoginLogUpdateOne { + if v != nil { + _u.SetStatus(*v) + } + return _u +} + +// AddStatus adds value to the "status" field. +func (_u *UserLoginLogUpdateOne) AddStatus(v int8) *UserLoginLogUpdateOne { + _u.mutation.AddStatus(v) + return _u +} + +// ClearStatus clears the value of the "status" field. +func (_u *UserLoginLogUpdateOne) ClearStatus() *UserLoginLogUpdateOne { + _u.mutation.ClearStatus() + return _u +} + +// SetDeletedAt sets the "deleted_at" field. +func (_u *UserLoginLogUpdateOne) SetDeletedAt(v time.Time) *UserLoginLogUpdateOne { + _u.mutation.SetDeletedAt(v) + return _u +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (_u *UserLoginLogUpdateOne) SetNillableDeletedAt(v *time.Time) *UserLoginLogUpdateOne { + if v != nil { + _u.SetDeletedAt(*v) + } + return _u +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (_u *UserLoginLogUpdateOne) ClearDeletedAt() *UserLoginLogUpdateOne { + _u.mutation.ClearDeletedAt() + return _u +} + +// SetUserID sets the "user_id" field. +func (_u *UserLoginLogUpdateOne) SetUserID(v uint64) *UserLoginLogUpdateOne { + _u.mutation.ResetUserID() + _u.mutation.SetUserID(v) + return _u +} + +// SetNillableUserID sets the "user_id" field if the given value is not nil. +func (_u *UserLoginLogUpdateOne) SetNillableUserID(v *uint64) *UserLoginLogUpdateOne { + if v != nil { + _u.SetUserID(*v) + } + return _u +} + +// AddUserID adds value to the "user_id" field. +func (_u *UserLoginLogUpdateOne) AddUserID(v int64) *UserLoginLogUpdateOne { + _u.mutation.AddUserID(v) + return _u +} + +// SetLoginTime sets the "login_time" field. +func (_u *UserLoginLogUpdateOne) SetLoginTime(v time.Time) *UserLoginLogUpdateOne { + _u.mutation.SetLoginTime(v) + return _u +} + +// SetNillableLoginTime sets the "login_time" field if the given value is not nil. +func (_u *UserLoginLogUpdateOne) SetNillableLoginTime(v *time.Time) *UserLoginLogUpdateOne { + if v != nil { + _u.SetLoginTime(*v) + } + return _u +} + +// SetLoginIP sets the "login_ip" field. +func (_u *UserLoginLogUpdateOne) SetLoginIP(v string) *UserLoginLogUpdateOne { + _u.mutation.SetLoginIP(v) + return _u +} + +// SetNillableLoginIP sets the "login_ip" field if the given value is not nil. +func (_u *UserLoginLogUpdateOne) SetNillableLoginIP(v *string) *UserLoginLogUpdateOne { + if v != nil { + _u.SetLoginIP(*v) + } + return _u +} + +// SetLoginLocation sets the "login_location" field. +func (_u *UserLoginLogUpdateOne) SetLoginLocation(v string) *UserLoginLogUpdateOne { + _u.mutation.SetLoginLocation(v) + return _u +} + +// SetNillableLoginLocation sets the "login_location" field if the given value is not nil. +func (_u *UserLoginLogUpdateOne) SetNillableLoginLocation(v *string) *UserLoginLogUpdateOne { + if v != nil { + _u.SetLoginLocation(*v) + } + return _u +} + +// ClearLoginLocation clears the value of the "login_location" field. +func (_u *UserLoginLogUpdateOne) ClearLoginLocation() *UserLoginLogUpdateOne { + _u.mutation.ClearLoginLocation() + return _u +} + +// SetLoginType sets the "login_type" field. +func (_u *UserLoginLogUpdateOne) SetLoginType(v userloginlog.LoginType) *UserLoginLogUpdateOne { + _u.mutation.SetLoginType(v) + return _u +} + +// SetNillableLoginType sets the "login_type" field if the given value is not nil. +func (_u *UserLoginLogUpdateOne) SetNillableLoginType(v *userloginlog.LoginType) *UserLoginLogUpdateOne { + if v != nil { + _u.SetLoginType(*v) + } + return _u +} + +// SetLoginPlatform sets the "login_platform" field. +func (_u *UserLoginLogUpdateOne) SetLoginPlatform(v userloginlog.LoginPlatform) *UserLoginLogUpdateOne { + _u.mutation.SetLoginPlatform(v) + return _u +} + +// SetNillableLoginPlatform sets the "login_platform" field if the given value is not nil. +func (_u *UserLoginLogUpdateOne) SetNillableLoginPlatform(v *userloginlog.LoginPlatform) *UserLoginLogUpdateOne { + if v != nil { + _u.SetLoginPlatform(*v) + } + return _u +} + +// SetLoginResult sets the "login_result" field. +func (_u *UserLoginLogUpdateOne) SetLoginResult(v bool) *UserLoginLogUpdateOne { + _u.mutation.SetLoginResult(v) + return _u +} + +// SetNillableLoginResult sets the "login_result" field if the given value is not nil. +func (_u *UserLoginLogUpdateOne) SetNillableLoginResult(v *bool) *UserLoginLogUpdateOne { + if v != nil { + _u.SetLoginResult(*v) + } + return _u +} + +// SetFailureReason sets the "failure_reason" field. +func (_u *UserLoginLogUpdateOne) SetFailureReason(v string) *UserLoginLogUpdateOne { + _u.mutation.SetFailureReason(v) + return _u +} + +// SetNillableFailureReason sets the "failure_reason" field if the given value is not nil. +func (_u *UserLoginLogUpdateOne) SetNillableFailureReason(v *string) *UserLoginLogUpdateOne { + if v != nil { + _u.SetFailureReason(*v) + } + return _u +} + +// ClearFailureReason clears the value of the "failure_reason" field. +func (_u *UserLoginLogUpdateOne) ClearFailureReason() *UserLoginLogUpdateOne { + _u.mutation.ClearFailureReason() + return _u +} + +// SetSessionID sets the "session_id" field. +func (_u *UserLoginLogUpdateOne) SetSessionID(v string) *UserLoginLogUpdateOne { + _u.mutation.SetSessionID(v) + return _u +} + +// SetNillableSessionID sets the "session_id" field if the given value is not nil. +func (_u *UserLoginLogUpdateOne) SetNillableSessionID(v *string) *UserLoginLogUpdateOne { + if v != nil { + _u.SetSessionID(*v) + } + return _u +} + +// ClearSessionID clears the value of the "session_id" field. +func (_u *UserLoginLogUpdateOne) ClearSessionID() *UserLoginLogUpdateOne { + _u.mutation.ClearSessionID() + return _u +} + +// SetLatencyMs sets the "latency_ms" field. +func (_u *UserLoginLogUpdateOne) SetLatencyMs(v int) *UserLoginLogUpdateOne { + _u.mutation.ResetLatencyMs() + _u.mutation.SetLatencyMs(v) + return _u +} + +// SetNillableLatencyMs sets the "latency_ms" field if the given value is not nil. +func (_u *UserLoginLogUpdateOne) SetNillableLatencyMs(v *int) *UserLoginLogUpdateOne { + if v != nil { + _u.SetLatencyMs(*v) + } + return _u +} + +// AddLatencyMs adds value to the "latency_ms" field. +func (_u *UserLoginLogUpdateOne) AddLatencyMs(v int) *UserLoginLogUpdateOne { + _u.mutation.AddLatencyMs(v) + return _u +} + +// ClearLatencyMs clears the value of the "latency_ms" field. +func (_u *UserLoginLogUpdateOne) ClearLatencyMs() *UserLoginLogUpdateOne { + _u.mutation.ClearLatencyMs() + return _u +} + +// SetAuthID sets the "auth_id" field. +func (_u *UserLoginLogUpdateOne) SetAuthID(v uint64) *UserLoginLogUpdateOne { + _u.mutation.ResetAuthID() + _u.mutation.SetAuthID(v) + return _u +} + +// SetNillableAuthID sets the "auth_id" field if the given value is not nil. +func (_u *UserLoginLogUpdateOne) SetNillableAuthID(v *uint64) *UserLoginLogUpdateOne { + if v != nil { + _u.SetAuthID(*v) + } + return _u +} + +// AddAuthID adds value to the "auth_id" field. +func (_u *UserLoginLogUpdateOne) AddAuthID(v int64) *UserLoginLogUpdateOne { + _u.mutation.AddAuthID(v) + return _u +} + +// ClearAuthID clears the value of the "auth_id" field. +func (_u *UserLoginLogUpdateOne) ClearAuthID() *UserLoginLogUpdateOne { + _u.mutation.ClearAuthID() + return _u +} + +// SetAdditionalData sets the "additional_data" field. +func (_u *UserLoginLogUpdateOne) SetAdditionalData(v map[string]interface{}) *UserLoginLogUpdateOne { + _u.mutation.SetAdditionalData(v) + return _u +} + +// ClearAdditionalData clears the value of the "additional_data" field. +func (_u *UserLoginLogUpdateOne) ClearAdditionalData() *UserLoginLogUpdateOne { + _u.mutation.ClearAdditionalData() + return _u +} + +// Mutation returns the UserLoginLogMutation object of the builder. +func (_u *UserLoginLogUpdateOne) Mutation() *UserLoginLogMutation { + return _u.mutation +} + +// Where appends a list predicates to the UserLoginLogUpdate builder. +func (_u *UserLoginLogUpdateOne) Where(ps ...predicate.UserLoginLog) *UserLoginLogUpdateOne { + _u.mutation.Where(ps...) + return _u +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (_u *UserLoginLogUpdateOne) Select(field string, fields ...string) *UserLoginLogUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated UserLoginLog entity. +func (_u *UserLoginLogUpdateOne) Save(ctx context.Context) (*UserLoginLog, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *UserLoginLogUpdateOne) SaveX(ctx context.Context) *UserLoginLog { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *UserLoginLogUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *UserLoginLogUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *UserLoginLogUpdateOne) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := userloginlog.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *UserLoginLogUpdateOne) check() error { + if v, ok := _u.mutation.LoginIP(); ok { + if err := userloginlog.LoginIPValidator(v); err != nil { + return &ValidationError{Name: "login_ip", err: fmt.Errorf(`ent: validator failed for field "UserLoginLog.login_ip": %w`, err)} + } + } + if v, ok := _u.mutation.LoginLocation(); ok { + if err := userloginlog.LoginLocationValidator(v); err != nil { + return &ValidationError{Name: "login_location", err: fmt.Errorf(`ent: validator failed for field "UserLoginLog.login_location": %w`, err)} + } + } + if v, ok := _u.mutation.LoginType(); ok { + if err := userloginlog.LoginTypeValidator(v); err != nil { + return &ValidationError{Name: "login_type", err: fmt.Errorf(`ent: validator failed for field "UserLoginLog.login_type": %w`, err)} + } + } + if v, ok := _u.mutation.LoginPlatform(); ok { + if err := userloginlog.LoginPlatformValidator(v); err != nil { + return &ValidationError{Name: "login_platform", err: fmt.Errorf(`ent: validator failed for field "UserLoginLog.login_platform": %w`, err)} + } + } + if v, ok := _u.mutation.FailureReason(); ok { + if err := userloginlog.FailureReasonValidator(v); err != nil { + return &ValidationError{Name: "failure_reason", err: fmt.Errorf(`ent: validator failed for field "UserLoginLog.failure_reason": %w`, err)} + } + } + if v, ok := _u.mutation.SessionID(); ok { + if err := userloginlog.SessionIDValidator(v); err != nil { + return &ValidationError{Name: "session_id", err: fmt.Errorf(`ent: validator failed for field "UserLoginLog.session_id": %w`, err)} + } + } + return nil +} + +func (_u *UserLoginLogUpdateOne) sqlSave(ctx context.Context) (_node *UserLoginLog, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(userloginlog.Table, userloginlog.Columns, sqlgraph.NewFieldSpec(userloginlog.FieldID, field.TypeUint64)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "UserLoginLog.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := _u.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, userloginlog.FieldID) + for _, f := range fields { + if !userloginlog.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != userloginlog.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.UpdatedAt(); ok { + _spec.SetField(userloginlog.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.Status(); ok { + _spec.SetField(userloginlog.FieldStatus, field.TypeUint8, value) + } + if value, ok := _u.mutation.AddedStatus(); ok { + _spec.AddField(userloginlog.FieldStatus, field.TypeUint8, value) + } + if _u.mutation.StatusCleared() { + _spec.ClearField(userloginlog.FieldStatus, field.TypeUint8) + } + if value, ok := _u.mutation.DeletedAt(); ok { + _spec.SetField(userloginlog.FieldDeletedAt, field.TypeTime, value) + } + if _u.mutation.DeletedAtCleared() { + _spec.ClearField(userloginlog.FieldDeletedAt, field.TypeTime) + } + if value, ok := _u.mutation.UserID(); ok { + _spec.SetField(userloginlog.FieldUserID, field.TypeUint64, value) + } + if value, ok := _u.mutation.AddedUserID(); ok { + _spec.AddField(userloginlog.FieldUserID, field.TypeUint64, value) + } + if value, ok := _u.mutation.LoginTime(); ok { + _spec.SetField(userloginlog.FieldLoginTime, field.TypeTime, value) + } + if value, ok := _u.mutation.LoginIP(); ok { + _spec.SetField(userloginlog.FieldLoginIP, field.TypeString, value) + } + if value, ok := _u.mutation.LoginLocation(); ok { + _spec.SetField(userloginlog.FieldLoginLocation, field.TypeString, value) + } + if _u.mutation.LoginLocationCleared() { + _spec.ClearField(userloginlog.FieldLoginLocation, field.TypeString) + } + if value, ok := _u.mutation.LoginType(); ok { + _spec.SetField(userloginlog.FieldLoginType, field.TypeEnum, value) + } + if value, ok := _u.mutation.LoginPlatform(); ok { + _spec.SetField(userloginlog.FieldLoginPlatform, field.TypeEnum, value) + } + if value, ok := _u.mutation.LoginResult(); ok { + _spec.SetField(userloginlog.FieldLoginResult, field.TypeBool, value) + } + if value, ok := _u.mutation.FailureReason(); ok { + _spec.SetField(userloginlog.FieldFailureReason, field.TypeString, value) + } + if _u.mutation.FailureReasonCleared() { + _spec.ClearField(userloginlog.FieldFailureReason, field.TypeString) + } + if value, ok := _u.mutation.SessionID(); ok { + _spec.SetField(userloginlog.FieldSessionID, field.TypeString, value) + } + if _u.mutation.SessionIDCleared() { + _spec.ClearField(userloginlog.FieldSessionID, field.TypeString) + } + if value, ok := _u.mutation.LatencyMs(); ok { + _spec.SetField(userloginlog.FieldLatencyMs, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedLatencyMs(); ok { + _spec.AddField(userloginlog.FieldLatencyMs, field.TypeInt, value) + } + if _u.mutation.LatencyMsCleared() { + _spec.ClearField(userloginlog.FieldLatencyMs, field.TypeInt) + } + if value, ok := _u.mutation.AuthID(); ok { + _spec.SetField(userloginlog.FieldAuthID, field.TypeUint64, value) + } + if value, ok := _u.mutation.AddedAuthID(); ok { + _spec.AddField(userloginlog.FieldAuthID, field.TypeUint64, value) + } + if _u.mutation.AuthIDCleared() { + _spec.ClearField(userloginlog.FieldAuthID, field.TypeUint64) + } + if value, ok := _u.mutation.AdditionalData(); ok { + _spec.SetField(userloginlog.FieldAdditionalData, field.TypeJSON, value) + } + if _u.mutation.AdditionalDataCleared() { + _spec.ClearField(userloginlog.FieldAdditionalData, field.TypeJSON) + } + _node = &UserLoginLog{config: _u.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{userloginlog.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} diff --git a/rpc/ent/userthirdauth.go b/rpc/ent/userthirdauth.go new file mode 100644 index 0000000..8aae5ee --- /dev/null +++ b/rpc/ent/userthirdauth.go @@ -0,0 +1,325 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "encoding/json" + "fmt" + "mingyang-admin-app-rpc/ent/userthirdauth" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// UserThirdAuth is the model entity for the UserThirdAuth schema. +type UserThirdAuth struct { + config `json:"-"` + // ID of the ent. + ID uint64 `json:"id,omitempty"` + // Create Time | 创建日期 + CreatedAt time.Time `json:"created_at,omitempty"` + // Update Time | 修改日期 + UpdatedAt time.Time `json:"updated_at,omitempty"` + // Status 1: normal 2: ban | 状态 1 正常 2 禁用 + Status uint8 `json:"status,omitempty"` + // Tenant ID | 租户 ID + TenantID uint64 `json:"tenant_id,omitempty"` + // Delete Time | 删除日期 + DeletedAt time.Time `json:"deleted_at,omitempty"` + // 用户ID + UserID uint64 `json:"user_id,omitempty"` + // Openid holds the value of the "openid" field. + Openid string `json:"openid,omitempty"` + // Unionid holds the value of the "unionid" field. + Unionid string `json:"unionid,omitempty"` + // AccessToken holds the value of the "access_token" field. + AccessToken string `json:"-"` + // RefreshToken holds the value of the "refresh_token" field. + RefreshToken string `json:"-"` + // AccessTokenExpiry holds the value of the "access_token_expiry" field. + AccessTokenExpiry *time.Time `json:"access_token_expiry,omitempty"` + // UserInfo holds the value of the "user_info" field. + UserInfo map[string]interface{} `json:"user_info,omitempty"` + // PlatformUserID holds the value of the "platform_user_id" field. + PlatformUserID string `json:"platform_user_id,omitempty"` + // Nickname holds the value of the "nickname" field. + Nickname string `json:"nickname,omitempty"` + // Avatar holds the value of the "avatar" field. + Avatar string `json:"avatar,omitempty"` + // Email holds the value of the "email" field. + Email string `json:"email,omitempty"` + // Phone holds the value of the "phone" field. + Phone string `json:"phone,omitempty"` + // IsBound holds the value of the "is_bound" field. + IsBound bool `json:"is_bound,omitempty"` + // BoundAt holds the value of the "bound_at" field. + BoundAt time.Time `json:"bound_at,omitempty"` + // ExtraData holds the value of the "extra_data" field. + ExtraData map[string]interface{} `json:"extra_data,omitempty"` + selectValues sql.SelectValues +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*UserThirdAuth) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case userthirdauth.FieldUserInfo, userthirdauth.FieldExtraData: + values[i] = new([]byte) + case userthirdauth.FieldIsBound: + values[i] = new(sql.NullBool) + case userthirdauth.FieldID, userthirdauth.FieldStatus, userthirdauth.FieldTenantID, userthirdauth.FieldUserID: + values[i] = new(sql.NullInt64) + case userthirdauth.FieldOpenid, userthirdauth.FieldUnionid, userthirdauth.FieldAccessToken, userthirdauth.FieldRefreshToken, userthirdauth.FieldPlatformUserID, userthirdauth.FieldNickname, userthirdauth.FieldAvatar, userthirdauth.FieldEmail, userthirdauth.FieldPhone: + values[i] = new(sql.NullString) + case userthirdauth.FieldCreatedAt, userthirdauth.FieldUpdatedAt, userthirdauth.FieldDeletedAt, userthirdauth.FieldAccessTokenExpiry, userthirdauth.FieldBoundAt: + 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 UserThirdAuth fields. +func (_m *UserThirdAuth) 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 userthirdauth.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + _m.ID = uint64(value.Int64) + case userthirdauth.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 { + _m.CreatedAt = value.Time + } + case userthirdauth.FieldUpdatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field updated_at", values[i]) + } else if value.Valid { + _m.UpdatedAt = value.Time + } + case userthirdauth.FieldStatus: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field status", values[i]) + } else if value.Valid { + _m.Status = uint8(value.Int64) + } + case userthirdauth.FieldTenantID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field tenant_id", values[i]) + } else if value.Valid { + _m.TenantID = uint64(value.Int64) + } + case userthirdauth.FieldDeletedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field deleted_at", values[i]) + } else if value.Valid { + _m.DeletedAt = value.Time + } + case userthirdauth.FieldUserID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field user_id", values[i]) + } else if value.Valid { + _m.UserID = uint64(value.Int64) + } + case userthirdauth.FieldOpenid: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field openid", values[i]) + } else if value.Valid { + _m.Openid = value.String + } + case userthirdauth.FieldUnionid: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field unionid", values[i]) + } else if value.Valid { + _m.Unionid = value.String + } + case userthirdauth.FieldAccessToken: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field access_token", values[i]) + } else if value.Valid { + _m.AccessToken = value.String + } + case userthirdauth.FieldRefreshToken: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field refresh_token", values[i]) + } else if value.Valid { + _m.RefreshToken = value.String + } + case userthirdauth.FieldAccessTokenExpiry: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field access_token_expiry", values[i]) + } else if value.Valid { + _m.AccessTokenExpiry = new(time.Time) + *_m.AccessTokenExpiry = value.Time + } + case userthirdauth.FieldUserInfo: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field user_info", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &_m.UserInfo); err != nil { + return fmt.Errorf("unmarshal field user_info: %w", err) + } + } + case userthirdauth.FieldPlatformUserID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field platform_user_id", values[i]) + } else if value.Valid { + _m.PlatformUserID = value.String + } + case userthirdauth.FieldNickname: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field nickname", values[i]) + } else if value.Valid { + _m.Nickname = value.String + } + case userthirdauth.FieldAvatar: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field avatar", values[i]) + } else if value.Valid { + _m.Avatar = value.String + } + case userthirdauth.FieldEmail: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field email", values[i]) + } else if value.Valid { + _m.Email = value.String + } + case userthirdauth.FieldPhone: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field phone", values[i]) + } else if value.Valid { + _m.Phone = value.String + } + case userthirdauth.FieldIsBound: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field is_bound", values[i]) + } else if value.Valid { + _m.IsBound = value.Bool + } + case userthirdauth.FieldBoundAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field bound_at", values[i]) + } else if value.Valid { + _m.BoundAt = value.Time + } + case userthirdauth.FieldExtraData: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field extra_data", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &_m.ExtraData); err != nil { + return fmt.Errorf("unmarshal field extra_data: %w", err) + } + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the UserThirdAuth. +// This includes values selected through modifiers, order, etc. +func (_m *UserThirdAuth) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// Update returns a builder for updating this UserThirdAuth. +// Note that you need to call UserThirdAuth.Unwrap() before calling this method if this UserThirdAuth +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *UserThirdAuth) Update() *UserThirdAuthUpdateOne { + return NewUserThirdAuthClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the UserThirdAuth entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (_m *UserThirdAuth) Unwrap() *UserThirdAuth { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("ent: UserThirdAuth is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *UserThirdAuth) String() string { + var builder strings.Builder + builder.WriteString("UserThirdAuth(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("created_at=") + builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("updated_at=") + builder.WriteString(_m.UpdatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("status=") + builder.WriteString(fmt.Sprintf("%v", _m.Status)) + builder.WriteString(", ") + builder.WriteString("tenant_id=") + builder.WriteString(fmt.Sprintf("%v", _m.TenantID)) + builder.WriteString(", ") + builder.WriteString("deleted_at=") + builder.WriteString(_m.DeletedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("user_id=") + builder.WriteString(fmt.Sprintf("%v", _m.UserID)) + builder.WriteString(", ") + builder.WriteString("openid=") + builder.WriteString(_m.Openid) + builder.WriteString(", ") + builder.WriteString("unionid=") + builder.WriteString(_m.Unionid) + builder.WriteString(", ") + builder.WriteString("access_token=") + builder.WriteString(", ") + builder.WriteString("refresh_token=") + builder.WriteString(", ") + if v := _m.AccessTokenExpiry; v != nil { + builder.WriteString("access_token_expiry=") + builder.WriteString(v.Format(time.ANSIC)) + } + builder.WriteString(", ") + builder.WriteString("user_info=") + builder.WriteString(fmt.Sprintf("%v", _m.UserInfo)) + builder.WriteString(", ") + builder.WriteString("platform_user_id=") + builder.WriteString(_m.PlatformUserID) + builder.WriteString(", ") + builder.WriteString("nickname=") + builder.WriteString(_m.Nickname) + builder.WriteString(", ") + builder.WriteString("avatar=") + builder.WriteString(_m.Avatar) + builder.WriteString(", ") + builder.WriteString("email=") + builder.WriteString(_m.Email) + builder.WriteString(", ") + builder.WriteString("phone=") + builder.WriteString(_m.Phone) + builder.WriteString(", ") + builder.WriteString("is_bound=") + builder.WriteString(fmt.Sprintf("%v", _m.IsBound)) + builder.WriteString(", ") + builder.WriteString("bound_at=") + builder.WriteString(_m.BoundAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("extra_data=") + builder.WriteString(fmt.Sprintf("%v", _m.ExtraData)) + builder.WriteByte(')') + return builder.String() +} + +// UserThirdAuths is a parsable slice of UserThirdAuth. +type UserThirdAuths []*UserThirdAuth diff --git a/rpc/ent/userthirdauth/userthirdauth.go b/rpc/ent/userthirdauth/userthirdauth.go new file mode 100644 index 0000000..0bfb21e --- /dev/null +++ b/rpc/ent/userthirdauth/userthirdauth.go @@ -0,0 +1,226 @@ +// Code generated by ent, DO NOT EDIT. + +package userthirdauth + +import ( + "time" + + "entgo.io/ent/dialect/sql" +) + +const ( + // Label holds the string label denoting the userthirdauth type in the database. + Label = "user_third_auth" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldCreatedAt holds the string denoting the created_at field in the database. + FieldCreatedAt = "created_at" + // FieldUpdatedAt holds the string denoting the updated_at field in the database. + FieldUpdatedAt = "updated_at" + // FieldStatus holds the string denoting the status field in the database. + FieldStatus = "status" + // FieldTenantID holds the string denoting the tenant_id field in the database. + FieldTenantID = "tenant_id" + // FieldDeletedAt holds the string denoting the deleted_at field in the database. + FieldDeletedAt = "deleted_at" + // FieldUserID holds the string denoting the user_id field in the database. + FieldUserID = "user_id" + // FieldOpenid holds the string denoting the openid field in the database. + FieldOpenid = "openid" + // FieldUnionid holds the string denoting the unionid field in the database. + FieldUnionid = "unionid" + // FieldAccessToken holds the string denoting the access_token field in the database. + FieldAccessToken = "access_token" + // FieldRefreshToken holds the string denoting the refresh_token field in the database. + FieldRefreshToken = "refresh_token" + // FieldAccessTokenExpiry holds the string denoting the access_token_expiry field in the database. + FieldAccessTokenExpiry = "access_token_expiry" + // FieldUserInfo holds the string denoting the user_info field in the database. + FieldUserInfo = "user_info" + // FieldPlatformUserID holds the string denoting the platform_user_id field in the database. + FieldPlatformUserID = "platform_user_id" + // FieldNickname holds the string denoting the nickname field in the database. + FieldNickname = "nickname" + // FieldAvatar holds the string denoting the avatar field in the database. + FieldAvatar = "avatar" + // 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" + // FieldIsBound holds the string denoting the is_bound field in the database. + FieldIsBound = "is_bound" + // FieldBoundAt holds the string denoting the bound_at field in the database. + FieldBoundAt = "bound_at" + // FieldExtraData holds the string denoting the extra_data field in the database. + FieldExtraData = "extra_data" + // Table holds the table name of the userthirdauth in the database. + Table = "user_third_auths" +) + +// Columns holds all SQL columns for userthirdauth fields. +var Columns = []string{ + FieldID, + FieldCreatedAt, + FieldUpdatedAt, + FieldStatus, + FieldTenantID, + FieldDeletedAt, + FieldUserID, + FieldOpenid, + FieldUnionid, + FieldAccessToken, + FieldRefreshToken, + FieldAccessTokenExpiry, + FieldUserInfo, + FieldPlatformUserID, + FieldNickname, + FieldAvatar, + FieldEmail, + FieldPhone, + FieldIsBound, + FieldBoundAt, + FieldExtraData, +} + +// 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 ( + // DefaultCreatedAt holds the default value on creation for the "created_at" field. + DefaultCreatedAt func() time.Time + // DefaultUpdatedAt holds the default value on creation for the "updated_at" field. + DefaultUpdatedAt func() time.Time + // UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field. + UpdateDefaultUpdatedAt func() time.Time + // DefaultStatus holds the default value on creation for the "status" field. + DefaultStatus uint8 + // DefaultTenantID holds the default value on creation for the "tenant_id" field. + DefaultTenantID uint64 + // OpenidValidator is a validator for the "openid" field. It is called by the builders before save. + OpenidValidator func(string) error + // UnionidValidator is a validator for the "unionid" field. It is called by the builders before save. + UnionidValidator func(string) error + // AccessTokenValidator is a validator for the "access_token" field. It is called by the builders before save. + AccessTokenValidator func(string) error + // RefreshTokenValidator is a validator for the "refresh_token" field. It is called by the builders before save. + RefreshTokenValidator func(string) error + // PlatformUserIDValidator is a validator for the "platform_user_id" field. It is called by the builders before save. + PlatformUserIDValidator func(string) error + // NicknameValidator is a validator for the "nickname" field. It is called by the builders before save. + NicknameValidator func(string) error + // AvatarValidator is a validator for the "avatar" field. It is called by the builders before save. + AvatarValidator 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 + // DefaultIsBound holds the default value on creation for the "is_bound" field. + DefaultIsBound bool + // DefaultBoundAt holds the default value on creation for the "bound_at" field. + DefaultBoundAt func() time.Time +) + +// OrderOption defines the ordering options for the UserThirdAuth 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() +} + +// ByCreatedAt orders the results by the created_at field. +func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() +} + +// ByUpdatedAt orders the results by the updated_at field. +func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc() +} + +// ByStatus orders the results by the status field. +func ByStatus(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStatus, opts...).ToFunc() +} + +// ByTenantID orders the results by the tenant_id field. +func ByTenantID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldTenantID, opts...).ToFunc() +} + +// ByDeletedAt orders the results by the deleted_at field. +func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeletedAt, 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 openid field. +func ByOpenid(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldOpenid, opts...).ToFunc() +} + +// ByUnionid orders the results by the unionid field. +func ByUnionid(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUnionid, opts...).ToFunc() +} + +// ByAccessToken orders the results by the access_token field. +func ByAccessToken(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldAccessToken, opts...).ToFunc() +} + +// ByRefreshToken orders the results by the refresh_token field. +func ByRefreshToken(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldRefreshToken, opts...).ToFunc() +} + +// ByAccessTokenExpiry orders the results by the access_token_expiry field. +func ByAccessTokenExpiry(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldAccessTokenExpiry, opts...).ToFunc() +} + +// ByPlatformUserID orders the results by the platform_user_id field. +func ByPlatformUserID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPlatformUserID, opts...).ToFunc() +} + +// ByNickname orders the results by the nickname field. +func ByNickname(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldNickname, opts...).ToFunc() +} + +// ByAvatar orders the results by the avatar field. +func ByAvatar(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldAvatar, 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() +} + +// ByIsBound orders the results by the is_bound field. +func ByIsBound(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldIsBound, opts...).ToFunc() +} + +// ByBoundAt orders the results by the bound_at field. +func ByBoundAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldBoundAt, opts...).ToFunc() +} diff --git a/rpc/ent/userthirdauth/where.go b/rpc/ent/userthirdauth/where.go new file mode 100644 index 0000000..efb4aed --- /dev/null +++ b/rpc/ent/userthirdauth/where.go @@ -0,0 +1,1205 @@ +// Code generated by ent, DO NOT EDIT. + +package userthirdauth + +import ( + "mingyang-admin-app-rpc/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" +) + +// ID filters vertices based on their ID field. +func ID(id uint64) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id uint64) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id uint64) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...uint64) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...uint64) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id uint64) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id uint64) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id uint64) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id uint64) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldLTE(FieldID, id)) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEQ(FieldCreatedAt, v)) +} + +// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. +func UpdatedAt(v time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// Status applies equality check predicate on the "status" field. It's identical to StatusEQ. +func Status(v uint8) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEQ(FieldStatus, v)) +} + +// TenantID applies equality check predicate on the "tenant_id" field. It's identical to TenantIDEQ. +func TenantID(v uint64) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEQ(FieldTenantID, v)) +} + +// DeletedAt applies equality check predicate on the "deleted_at" field. It's identical to DeletedAtEQ. +func DeletedAt(v time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEQ(FieldDeletedAt, v)) +} + +// UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ. +func UserID(v uint64) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEQ(FieldUserID, v)) +} + +// Openid applies equality check predicate on the "openid" field. It's identical to OpenidEQ. +func Openid(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEQ(FieldOpenid, v)) +} + +// Unionid applies equality check predicate on the "unionid" field. It's identical to UnionidEQ. +func Unionid(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEQ(FieldUnionid, v)) +} + +// AccessToken applies equality check predicate on the "access_token" field. It's identical to AccessTokenEQ. +func AccessToken(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEQ(FieldAccessToken, v)) +} + +// RefreshToken applies equality check predicate on the "refresh_token" field. It's identical to RefreshTokenEQ. +func RefreshToken(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEQ(FieldRefreshToken, v)) +} + +// AccessTokenExpiry applies equality check predicate on the "access_token_expiry" field. It's identical to AccessTokenExpiryEQ. +func AccessTokenExpiry(v time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEQ(FieldAccessTokenExpiry, v)) +} + +// PlatformUserID applies equality check predicate on the "platform_user_id" field. It's identical to PlatformUserIDEQ. +func PlatformUserID(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEQ(FieldPlatformUserID, v)) +} + +// Nickname applies equality check predicate on the "nickname" field. It's identical to NicknameEQ. +func Nickname(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEQ(FieldNickname, v)) +} + +// Avatar applies equality check predicate on the "avatar" field. It's identical to AvatarEQ. +func Avatar(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEQ(FieldAvatar, v)) +} + +// Email applies equality check predicate on the "email" field. It's identical to EmailEQ. +func Email(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEQ(FieldEmail, v)) +} + +// Phone applies equality check predicate on the "phone" field. It's identical to PhoneEQ. +func Phone(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEQ(FieldPhone, v)) +} + +// IsBound applies equality check predicate on the "is_bound" field. It's identical to IsBoundEQ. +func IsBound(v bool) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEQ(FieldIsBound, v)) +} + +// BoundAt applies equality check predicate on the "bound_at" field. It's identical to BoundAtEQ. +func BoundAt(v time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEQ(FieldBoundAt, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldLTE(FieldCreatedAt, v)) +} + +// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. +func UpdatedAtEQ(v time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. +func UpdatedAtNEQ(v time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtIn applies the In predicate on the "updated_at" field. +func UpdatedAtIn(vs ...time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. +func UpdatedAtNotIn(vs ...time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNotIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtGT applies the GT predicate on the "updated_at" field. +func UpdatedAtGT(v time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldGT(FieldUpdatedAt, v)) +} + +// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. +func UpdatedAtGTE(v time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldGTE(FieldUpdatedAt, v)) +} + +// UpdatedAtLT applies the LT predicate on the "updated_at" field. +func UpdatedAtLT(v time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldLT(FieldUpdatedAt, v)) +} + +// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. +func UpdatedAtLTE(v time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldLTE(FieldUpdatedAt, v)) +} + +// StatusEQ applies the EQ predicate on the "status" field. +func StatusEQ(v uint8) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEQ(FieldStatus, v)) +} + +// StatusNEQ applies the NEQ predicate on the "status" field. +func StatusNEQ(v uint8) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNEQ(FieldStatus, v)) +} + +// StatusIn applies the In predicate on the "status" field. +func StatusIn(vs ...uint8) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldIn(FieldStatus, vs...)) +} + +// StatusNotIn applies the NotIn predicate on the "status" field. +func StatusNotIn(vs ...uint8) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNotIn(FieldStatus, vs...)) +} + +// StatusGT applies the GT predicate on the "status" field. +func StatusGT(v uint8) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldGT(FieldStatus, v)) +} + +// StatusGTE applies the GTE predicate on the "status" field. +func StatusGTE(v uint8) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldGTE(FieldStatus, v)) +} + +// StatusLT applies the LT predicate on the "status" field. +func StatusLT(v uint8) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldLT(FieldStatus, v)) +} + +// StatusLTE applies the LTE predicate on the "status" field. +func StatusLTE(v uint8) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldLTE(FieldStatus, v)) +} + +// StatusIsNil applies the IsNil predicate on the "status" field. +func StatusIsNil() predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldIsNull(FieldStatus)) +} + +// StatusNotNil applies the NotNil predicate on the "status" field. +func StatusNotNil() predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNotNull(FieldStatus)) +} + +// TenantIDEQ applies the EQ predicate on the "tenant_id" field. +func TenantIDEQ(v uint64) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEQ(FieldTenantID, v)) +} + +// TenantIDNEQ applies the NEQ predicate on the "tenant_id" field. +func TenantIDNEQ(v uint64) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNEQ(FieldTenantID, v)) +} + +// TenantIDIn applies the In predicate on the "tenant_id" field. +func TenantIDIn(vs ...uint64) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldIn(FieldTenantID, vs...)) +} + +// TenantIDNotIn applies the NotIn predicate on the "tenant_id" field. +func TenantIDNotIn(vs ...uint64) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNotIn(FieldTenantID, vs...)) +} + +// TenantIDGT applies the GT predicate on the "tenant_id" field. +func TenantIDGT(v uint64) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldGT(FieldTenantID, v)) +} + +// TenantIDGTE applies the GTE predicate on the "tenant_id" field. +func TenantIDGTE(v uint64) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldGTE(FieldTenantID, v)) +} + +// TenantIDLT applies the LT predicate on the "tenant_id" field. +func TenantIDLT(v uint64) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldLT(FieldTenantID, v)) +} + +// TenantIDLTE applies the LTE predicate on the "tenant_id" field. +func TenantIDLTE(v uint64) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldLTE(FieldTenantID, v)) +} + +// DeletedAtEQ applies the EQ predicate on the "deleted_at" field. +func DeletedAtEQ(v time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEQ(FieldDeletedAt, v)) +} + +// DeletedAtNEQ applies the NEQ predicate on the "deleted_at" field. +func DeletedAtNEQ(v time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNEQ(FieldDeletedAt, v)) +} + +// DeletedAtIn applies the In predicate on the "deleted_at" field. +func DeletedAtIn(vs ...time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldIn(FieldDeletedAt, vs...)) +} + +// DeletedAtNotIn applies the NotIn predicate on the "deleted_at" field. +func DeletedAtNotIn(vs ...time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNotIn(FieldDeletedAt, vs...)) +} + +// DeletedAtGT applies the GT predicate on the "deleted_at" field. +func DeletedAtGT(v time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldGT(FieldDeletedAt, v)) +} + +// DeletedAtGTE applies the GTE predicate on the "deleted_at" field. +func DeletedAtGTE(v time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldGTE(FieldDeletedAt, v)) +} + +// DeletedAtLT applies the LT predicate on the "deleted_at" field. +func DeletedAtLT(v time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldLT(FieldDeletedAt, v)) +} + +// DeletedAtLTE applies the LTE predicate on the "deleted_at" field. +func DeletedAtLTE(v time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldLTE(FieldDeletedAt, v)) +} + +// DeletedAtIsNil applies the IsNil predicate on the "deleted_at" field. +func DeletedAtIsNil() predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldIsNull(FieldDeletedAt)) +} + +// DeletedAtNotNil applies the NotNil predicate on the "deleted_at" field. +func DeletedAtNotNil() predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNotNull(FieldDeletedAt)) +} + +// UserIDEQ applies the EQ predicate on the "user_id" field. +func UserIDEQ(v uint64) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEQ(FieldUserID, v)) +} + +// UserIDNEQ applies the NEQ predicate on the "user_id" field. +func UserIDNEQ(v uint64) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNEQ(FieldUserID, v)) +} + +// UserIDIn applies the In predicate on the "user_id" field. +func UserIDIn(vs ...uint64) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldIn(FieldUserID, vs...)) +} + +// UserIDNotIn applies the NotIn predicate on the "user_id" field. +func UserIDNotIn(vs ...uint64) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNotIn(FieldUserID, vs...)) +} + +// UserIDGT applies the GT predicate on the "user_id" field. +func UserIDGT(v uint64) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldGT(FieldUserID, v)) +} + +// UserIDGTE applies the GTE predicate on the "user_id" field. +func UserIDGTE(v uint64) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldGTE(FieldUserID, v)) +} + +// UserIDLT applies the LT predicate on the "user_id" field. +func UserIDLT(v uint64) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldLT(FieldUserID, v)) +} + +// UserIDLTE applies the LTE predicate on the "user_id" field. +func UserIDLTE(v uint64) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldLTE(FieldUserID, v)) +} + +// OpenidEQ applies the EQ predicate on the "openid" field. +func OpenidEQ(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEQ(FieldOpenid, v)) +} + +// OpenidNEQ applies the NEQ predicate on the "openid" field. +func OpenidNEQ(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNEQ(FieldOpenid, v)) +} + +// OpenidIn applies the In predicate on the "openid" field. +func OpenidIn(vs ...string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldIn(FieldOpenid, vs...)) +} + +// OpenidNotIn applies the NotIn predicate on the "openid" field. +func OpenidNotIn(vs ...string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNotIn(FieldOpenid, vs...)) +} + +// OpenidGT applies the GT predicate on the "openid" field. +func OpenidGT(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldGT(FieldOpenid, v)) +} + +// OpenidGTE applies the GTE predicate on the "openid" field. +func OpenidGTE(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldGTE(FieldOpenid, v)) +} + +// OpenidLT applies the LT predicate on the "openid" field. +func OpenidLT(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldLT(FieldOpenid, v)) +} + +// OpenidLTE applies the LTE predicate on the "openid" field. +func OpenidLTE(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldLTE(FieldOpenid, v)) +} + +// OpenidContains applies the Contains predicate on the "openid" field. +func OpenidContains(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldContains(FieldOpenid, v)) +} + +// OpenidHasPrefix applies the HasPrefix predicate on the "openid" field. +func OpenidHasPrefix(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldHasPrefix(FieldOpenid, v)) +} + +// OpenidHasSuffix applies the HasSuffix predicate on the "openid" field. +func OpenidHasSuffix(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldHasSuffix(FieldOpenid, v)) +} + +// OpenidEqualFold applies the EqualFold predicate on the "openid" field. +func OpenidEqualFold(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEqualFold(FieldOpenid, v)) +} + +// OpenidContainsFold applies the ContainsFold predicate on the "openid" field. +func OpenidContainsFold(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldContainsFold(FieldOpenid, v)) +} + +// UnionidEQ applies the EQ predicate on the "unionid" field. +func UnionidEQ(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEQ(FieldUnionid, v)) +} + +// UnionidNEQ applies the NEQ predicate on the "unionid" field. +func UnionidNEQ(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNEQ(FieldUnionid, v)) +} + +// UnionidIn applies the In predicate on the "unionid" field. +func UnionidIn(vs ...string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldIn(FieldUnionid, vs...)) +} + +// UnionidNotIn applies the NotIn predicate on the "unionid" field. +func UnionidNotIn(vs ...string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNotIn(FieldUnionid, vs...)) +} + +// UnionidGT applies the GT predicate on the "unionid" field. +func UnionidGT(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldGT(FieldUnionid, v)) +} + +// UnionidGTE applies the GTE predicate on the "unionid" field. +func UnionidGTE(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldGTE(FieldUnionid, v)) +} + +// UnionidLT applies the LT predicate on the "unionid" field. +func UnionidLT(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldLT(FieldUnionid, v)) +} + +// UnionidLTE applies the LTE predicate on the "unionid" field. +func UnionidLTE(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldLTE(FieldUnionid, v)) +} + +// UnionidContains applies the Contains predicate on the "unionid" field. +func UnionidContains(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldContains(FieldUnionid, v)) +} + +// UnionidHasPrefix applies the HasPrefix predicate on the "unionid" field. +func UnionidHasPrefix(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldHasPrefix(FieldUnionid, v)) +} + +// UnionidHasSuffix applies the HasSuffix predicate on the "unionid" field. +func UnionidHasSuffix(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldHasSuffix(FieldUnionid, v)) +} + +// UnionidIsNil applies the IsNil predicate on the "unionid" field. +func UnionidIsNil() predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldIsNull(FieldUnionid)) +} + +// UnionidNotNil applies the NotNil predicate on the "unionid" field. +func UnionidNotNil() predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNotNull(FieldUnionid)) +} + +// UnionidEqualFold applies the EqualFold predicate on the "unionid" field. +func UnionidEqualFold(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEqualFold(FieldUnionid, v)) +} + +// UnionidContainsFold applies the ContainsFold predicate on the "unionid" field. +func UnionidContainsFold(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldContainsFold(FieldUnionid, v)) +} + +// AccessTokenEQ applies the EQ predicate on the "access_token" field. +func AccessTokenEQ(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEQ(FieldAccessToken, v)) +} + +// AccessTokenNEQ applies the NEQ predicate on the "access_token" field. +func AccessTokenNEQ(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNEQ(FieldAccessToken, v)) +} + +// AccessTokenIn applies the In predicate on the "access_token" field. +func AccessTokenIn(vs ...string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldIn(FieldAccessToken, vs...)) +} + +// AccessTokenNotIn applies the NotIn predicate on the "access_token" field. +func AccessTokenNotIn(vs ...string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNotIn(FieldAccessToken, vs...)) +} + +// AccessTokenGT applies the GT predicate on the "access_token" field. +func AccessTokenGT(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldGT(FieldAccessToken, v)) +} + +// AccessTokenGTE applies the GTE predicate on the "access_token" field. +func AccessTokenGTE(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldGTE(FieldAccessToken, v)) +} + +// AccessTokenLT applies the LT predicate on the "access_token" field. +func AccessTokenLT(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldLT(FieldAccessToken, v)) +} + +// AccessTokenLTE applies the LTE predicate on the "access_token" field. +func AccessTokenLTE(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldLTE(FieldAccessToken, v)) +} + +// AccessTokenContains applies the Contains predicate on the "access_token" field. +func AccessTokenContains(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldContains(FieldAccessToken, v)) +} + +// AccessTokenHasPrefix applies the HasPrefix predicate on the "access_token" field. +func AccessTokenHasPrefix(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldHasPrefix(FieldAccessToken, v)) +} + +// AccessTokenHasSuffix applies the HasSuffix predicate on the "access_token" field. +func AccessTokenHasSuffix(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldHasSuffix(FieldAccessToken, v)) +} + +// AccessTokenIsNil applies the IsNil predicate on the "access_token" field. +func AccessTokenIsNil() predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldIsNull(FieldAccessToken)) +} + +// AccessTokenNotNil applies the NotNil predicate on the "access_token" field. +func AccessTokenNotNil() predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNotNull(FieldAccessToken)) +} + +// AccessTokenEqualFold applies the EqualFold predicate on the "access_token" field. +func AccessTokenEqualFold(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEqualFold(FieldAccessToken, v)) +} + +// AccessTokenContainsFold applies the ContainsFold predicate on the "access_token" field. +func AccessTokenContainsFold(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldContainsFold(FieldAccessToken, v)) +} + +// RefreshTokenEQ applies the EQ predicate on the "refresh_token" field. +func RefreshTokenEQ(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEQ(FieldRefreshToken, v)) +} + +// RefreshTokenNEQ applies the NEQ predicate on the "refresh_token" field. +func RefreshTokenNEQ(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNEQ(FieldRefreshToken, v)) +} + +// RefreshTokenIn applies the In predicate on the "refresh_token" field. +func RefreshTokenIn(vs ...string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldIn(FieldRefreshToken, vs...)) +} + +// RefreshTokenNotIn applies the NotIn predicate on the "refresh_token" field. +func RefreshTokenNotIn(vs ...string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNotIn(FieldRefreshToken, vs...)) +} + +// RefreshTokenGT applies the GT predicate on the "refresh_token" field. +func RefreshTokenGT(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldGT(FieldRefreshToken, v)) +} + +// RefreshTokenGTE applies the GTE predicate on the "refresh_token" field. +func RefreshTokenGTE(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldGTE(FieldRefreshToken, v)) +} + +// RefreshTokenLT applies the LT predicate on the "refresh_token" field. +func RefreshTokenLT(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldLT(FieldRefreshToken, v)) +} + +// RefreshTokenLTE applies the LTE predicate on the "refresh_token" field. +func RefreshTokenLTE(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldLTE(FieldRefreshToken, v)) +} + +// RefreshTokenContains applies the Contains predicate on the "refresh_token" field. +func RefreshTokenContains(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldContains(FieldRefreshToken, v)) +} + +// RefreshTokenHasPrefix applies the HasPrefix predicate on the "refresh_token" field. +func RefreshTokenHasPrefix(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldHasPrefix(FieldRefreshToken, v)) +} + +// RefreshTokenHasSuffix applies the HasSuffix predicate on the "refresh_token" field. +func RefreshTokenHasSuffix(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldHasSuffix(FieldRefreshToken, v)) +} + +// RefreshTokenIsNil applies the IsNil predicate on the "refresh_token" field. +func RefreshTokenIsNil() predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldIsNull(FieldRefreshToken)) +} + +// RefreshTokenNotNil applies the NotNil predicate on the "refresh_token" field. +func RefreshTokenNotNil() predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNotNull(FieldRefreshToken)) +} + +// RefreshTokenEqualFold applies the EqualFold predicate on the "refresh_token" field. +func RefreshTokenEqualFold(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEqualFold(FieldRefreshToken, v)) +} + +// RefreshTokenContainsFold applies the ContainsFold predicate on the "refresh_token" field. +func RefreshTokenContainsFold(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldContainsFold(FieldRefreshToken, v)) +} + +// AccessTokenExpiryEQ applies the EQ predicate on the "access_token_expiry" field. +func AccessTokenExpiryEQ(v time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEQ(FieldAccessTokenExpiry, v)) +} + +// AccessTokenExpiryNEQ applies the NEQ predicate on the "access_token_expiry" field. +func AccessTokenExpiryNEQ(v time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNEQ(FieldAccessTokenExpiry, v)) +} + +// AccessTokenExpiryIn applies the In predicate on the "access_token_expiry" field. +func AccessTokenExpiryIn(vs ...time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldIn(FieldAccessTokenExpiry, vs...)) +} + +// AccessTokenExpiryNotIn applies the NotIn predicate on the "access_token_expiry" field. +func AccessTokenExpiryNotIn(vs ...time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNotIn(FieldAccessTokenExpiry, vs...)) +} + +// AccessTokenExpiryGT applies the GT predicate on the "access_token_expiry" field. +func AccessTokenExpiryGT(v time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldGT(FieldAccessTokenExpiry, v)) +} + +// AccessTokenExpiryGTE applies the GTE predicate on the "access_token_expiry" field. +func AccessTokenExpiryGTE(v time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldGTE(FieldAccessTokenExpiry, v)) +} + +// AccessTokenExpiryLT applies the LT predicate on the "access_token_expiry" field. +func AccessTokenExpiryLT(v time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldLT(FieldAccessTokenExpiry, v)) +} + +// AccessTokenExpiryLTE applies the LTE predicate on the "access_token_expiry" field. +func AccessTokenExpiryLTE(v time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldLTE(FieldAccessTokenExpiry, v)) +} + +// AccessTokenExpiryIsNil applies the IsNil predicate on the "access_token_expiry" field. +func AccessTokenExpiryIsNil() predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldIsNull(FieldAccessTokenExpiry)) +} + +// AccessTokenExpiryNotNil applies the NotNil predicate on the "access_token_expiry" field. +func AccessTokenExpiryNotNil() predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNotNull(FieldAccessTokenExpiry)) +} + +// UserInfoIsNil applies the IsNil predicate on the "user_info" field. +func UserInfoIsNil() predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldIsNull(FieldUserInfo)) +} + +// UserInfoNotNil applies the NotNil predicate on the "user_info" field. +func UserInfoNotNil() predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNotNull(FieldUserInfo)) +} + +// PlatformUserIDEQ applies the EQ predicate on the "platform_user_id" field. +func PlatformUserIDEQ(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEQ(FieldPlatformUserID, v)) +} + +// PlatformUserIDNEQ applies the NEQ predicate on the "platform_user_id" field. +func PlatformUserIDNEQ(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNEQ(FieldPlatformUserID, v)) +} + +// PlatformUserIDIn applies the In predicate on the "platform_user_id" field. +func PlatformUserIDIn(vs ...string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldIn(FieldPlatformUserID, vs...)) +} + +// PlatformUserIDNotIn applies the NotIn predicate on the "platform_user_id" field. +func PlatformUserIDNotIn(vs ...string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNotIn(FieldPlatformUserID, vs...)) +} + +// PlatformUserIDGT applies the GT predicate on the "platform_user_id" field. +func PlatformUserIDGT(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldGT(FieldPlatformUserID, v)) +} + +// PlatformUserIDGTE applies the GTE predicate on the "platform_user_id" field. +func PlatformUserIDGTE(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldGTE(FieldPlatformUserID, v)) +} + +// PlatformUserIDLT applies the LT predicate on the "platform_user_id" field. +func PlatformUserIDLT(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldLT(FieldPlatformUserID, v)) +} + +// PlatformUserIDLTE applies the LTE predicate on the "platform_user_id" field. +func PlatformUserIDLTE(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldLTE(FieldPlatformUserID, v)) +} + +// PlatformUserIDContains applies the Contains predicate on the "platform_user_id" field. +func PlatformUserIDContains(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldContains(FieldPlatformUserID, v)) +} + +// PlatformUserIDHasPrefix applies the HasPrefix predicate on the "platform_user_id" field. +func PlatformUserIDHasPrefix(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldHasPrefix(FieldPlatformUserID, v)) +} + +// PlatformUserIDHasSuffix applies the HasSuffix predicate on the "platform_user_id" field. +func PlatformUserIDHasSuffix(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldHasSuffix(FieldPlatformUserID, v)) +} + +// PlatformUserIDIsNil applies the IsNil predicate on the "platform_user_id" field. +func PlatformUserIDIsNil() predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldIsNull(FieldPlatformUserID)) +} + +// PlatformUserIDNotNil applies the NotNil predicate on the "platform_user_id" field. +func PlatformUserIDNotNil() predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNotNull(FieldPlatformUserID)) +} + +// PlatformUserIDEqualFold applies the EqualFold predicate on the "platform_user_id" field. +func PlatformUserIDEqualFold(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEqualFold(FieldPlatformUserID, v)) +} + +// PlatformUserIDContainsFold applies the ContainsFold predicate on the "platform_user_id" field. +func PlatformUserIDContainsFold(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldContainsFold(FieldPlatformUserID, v)) +} + +// NicknameEQ applies the EQ predicate on the "nickname" field. +func NicknameEQ(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEQ(FieldNickname, v)) +} + +// NicknameNEQ applies the NEQ predicate on the "nickname" field. +func NicknameNEQ(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNEQ(FieldNickname, v)) +} + +// NicknameIn applies the In predicate on the "nickname" field. +func NicknameIn(vs ...string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldIn(FieldNickname, vs...)) +} + +// NicknameNotIn applies the NotIn predicate on the "nickname" field. +func NicknameNotIn(vs ...string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNotIn(FieldNickname, vs...)) +} + +// NicknameGT applies the GT predicate on the "nickname" field. +func NicknameGT(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldGT(FieldNickname, v)) +} + +// NicknameGTE applies the GTE predicate on the "nickname" field. +func NicknameGTE(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldGTE(FieldNickname, v)) +} + +// NicknameLT applies the LT predicate on the "nickname" field. +func NicknameLT(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldLT(FieldNickname, v)) +} + +// NicknameLTE applies the LTE predicate on the "nickname" field. +func NicknameLTE(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldLTE(FieldNickname, v)) +} + +// NicknameContains applies the Contains predicate on the "nickname" field. +func NicknameContains(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldContains(FieldNickname, v)) +} + +// NicknameHasPrefix applies the HasPrefix predicate on the "nickname" field. +func NicknameHasPrefix(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldHasPrefix(FieldNickname, v)) +} + +// NicknameHasSuffix applies the HasSuffix predicate on the "nickname" field. +func NicknameHasSuffix(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldHasSuffix(FieldNickname, v)) +} + +// NicknameIsNil applies the IsNil predicate on the "nickname" field. +func NicknameIsNil() predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldIsNull(FieldNickname)) +} + +// NicknameNotNil applies the NotNil predicate on the "nickname" field. +func NicknameNotNil() predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNotNull(FieldNickname)) +} + +// NicknameEqualFold applies the EqualFold predicate on the "nickname" field. +func NicknameEqualFold(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEqualFold(FieldNickname, v)) +} + +// NicknameContainsFold applies the ContainsFold predicate on the "nickname" field. +func NicknameContainsFold(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldContainsFold(FieldNickname, v)) +} + +// AvatarEQ applies the EQ predicate on the "avatar" field. +func AvatarEQ(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEQ(FieldAvatar, v)) +} + +// AvatarNEQ applies the NEQ predicate on the "avatar" field. +func AvatarNEQ(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNEQ(FieldAvatar, v)) +} + +// AvatarIn applies the In predicate on the "avatar" field. +func AvatarIn(vs ...string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldIn(FieldAvatar, vs...)) +} + +// AvatarNotIn applies the NotIn predicate on the "avatar" field. +func AvatarNotIn(vs ...string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNotIn(FieldAvatar, vs...)) +} + +// AvatarGT applies the GT predicate on the "avatar" field. +func AvatarGT(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldGT(FieldAvatar, v)) +} + +// AvatarGTE applies the GTE predicate on the "avatar" field. +func AvatarGTE(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldGTE(FieldAvatar, v)) +} + +// AvatarLT applies the LT predicate on the "avatar" field. +func AvatarLT(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldLT(FieldAvatar, v)) +} + +// AvatarLTE applies the LTE predicate on the "avatar" field. +func AvatarLTE(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldLTE(FieldAvatar, v)) +} + +// AvatarContains applies the Contains predicate on the "avatar" field. +func AvatarContains(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldContains(FieldAvatar, v)) +} + +// AvatarHasPrefix applies the HasPrefix predicate on the "avatar" field. +func AvatarHasPrefix(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldHasPrefix(FieldAvatar, v)) +} + +// AvatarHasSuffix applies the HasSuffix predicate on the "avatar" field. +func AvatarHasSuffix(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldHasSuffix(FieldAvatar, v)) +} + +// AvatarIsNil applies the IsNil predicate on the "avatar" field. +func AvatarIsNil() predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldIsNull(FieldAvatar)) +} + +// AvatarNotNil applies the NotNil predicate on the "avatar" field. +func AvatarNotNil() predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNotNull(FieldAvatar)) +} + +// AvatarEqualFold applies the EqualFold predicate on the "avatar" field. +func AvatarEqualFold(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEqualFold(FieldAvatar, v)) +} + +// AvatarContainsFold applies the ContainsFold predicate on the "avatar" field. +func AvatarContainsFold(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldContainsFold(FieldAvatar, v)) +} + +// EmailEQ applies the EQ predicate on the "email" field. +func EmailEQ(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEQ(FieldEmail, v)) +} + +// EmailNEQ applies the NEQ predicate on the "email" field. +func EmailNEQ(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNEQ(FieldEmail, v)) +} + +// EmailIn applies the In predicate on the "email" field. +func EmailIn(vs ...string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldIn(FieldEmail, vs...)) +} + +// EmailNotIn applies the NotIn predicate on the "email" field. +func EmailNotIn(vs ...string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNotIn(FieldEmail, vs...)) +} + +// EmailGT applies the GT predicate on the "email" field. +func EmailGT(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldGT(FieldEmail, v)) +} + +// EmailGTE applies the GTE predicate on the "email" field. +func EmailGTE(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldGTE(FieldEmail, v)) +} + +// EmailLT applies the LT predicate on the "email" field. +func EmailLT(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldLT(FieldEmail, v)) +} + +// EmailLTE applies the LTE predicate on the "email" field. +func EmailLTE(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldLTE(FieldEmail, v)) +} + +// EmailContains applies the Contains predicate on the "email" field. +func EmailContains(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldContains(FieldEmail, v)) +} + +// EmailHasPrefix applies the HasPrefix predicate on the "email" field. +func EmailHasPrefix(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldHasPrefix(FieldEmail, v)) +} + +// EmailHasSuffix applies the HasSuffix predicate on the "email" field. +func EmailHasSuffix(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldHasSuffix(FieldEmail, v)) +} + +// EmailIsNil applies the IsNil predicate on the "email" field. +func EmailIsNil() predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldIsNull(FieldEmail)) +} + +// EmailNotNil applies the NotNil predicate on the "email" field. +func EmailNotNil() predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNotNull(FieldEmail)) +} + +// EmailEqualFold applies the EqualFold predicate on the "email" field. +func EmailEqualFold(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEqualFold(FieldEmail, v)) +} + +// EmailContainsFold applies the ContainsFold predicate on the "email" field. +func EmailContainsFold(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldContainsFold(FieldEmail, v)) +} + +// PhoneEQ applies the EQ predicate on the "phone" field. +func PhoneEQ(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEQ(FieldPhone, v)) +} + +// PhoneNEQ applies the NEQ predicate on the "phone" field. +func PhoneNEQ(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNEQ(FieldPhone, v)) +} + +// PhoneIn applies the In predicate on the "phone" field. +func PhoneIn(vs ...string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldIn(FieldPhone, vs...)) +} + +// PhoneNotIn applies the NotIn predicate on the "phone" field. +func PhoneNotIn(vs ...string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNotIn(FieldPhone, vs...)) +} + +// PhoneGT applies the GT predicate on the "phone" field. +func PhoneGT(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldGT(FieldPhone, v)) +} + +// PhoneGTE applies the GTE predicate on the "phone" field. +func PhoneGTE(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldGTE(FieldPhone, v)) +} + +// PhoneLT applies the LT predicate on the "phone" field. +func PhoneLT(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldLT(FieldPhone, v)) +} + +// PhoneLTE applies the LTE predicate on the "phone" field. +func PhoneLTE(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldLTE(FieldPhone, v)) +} + +// PhoneContains applies the Contains predicate on the "phone" field. +func PhoneContains(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldContains(FieldPhone, v)) +} + +// PhoneHasPrefix applies the HasPrefix predicate on the "phone" field. +func PhoneHasPrefix(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldHasPrefix(FieldPhone, v)) +} + +// PhoneHasSuffix applies the HasSuffix predicate on the "phone" field. +func PhoneHasSuffix(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldHasSuffix(FieldPhone, v)) +} + +// PhoneIsNil applies the IsNil predicate on the "phone" field. +func PhoneIsNil() predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldIsNull(FieldPhone)) +} + +// PhoneNotNil applies the NotNil predicate on the "phone" field. +func PhoneNotNil() predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNotNull(FieldPhone)) +} + +// PhoneEqualFold applies the EqualFold predicate on the "phone" field. +func PhoneEqualFold(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEqualFold(FieldPhone, v)) +} + +// PhoneContainsFold applies the ContainsFold predicate on the "phone" field. +func PhoneContainsFold(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldContainsFold(FieldPhone, v)) +} + +// IsBoundEQ applies the EQ predicate on the "is_bound" field. +func IsBoundEQ(v bool) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEQ(FieldIsBound, v)) +} + +// IsBoundNEQ applies the NEQ predicate on the "is_bound" field. +func IsBoundNEQ(v bool) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNEQ(FieldIsBound, v)) +} + +// BoundAtEQ applies the EQ predicate on the "bound_at" field. +func BoundAtEQ(v time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEQ(FieldBoundAt, v)) +} + +// BoundAtNEQ applies the NEQ predicate on the "bound_at" field. +func BoundAtNEQ(v time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNEQ(FieldBoundAt, v)) +} + +// BoundAtIn applies the In predicate on the "bound_at" field. +func BoundAtIn(vs ...time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldIn(FieldBoundAt, vs...)) +} + +// BoundAtNotIn applies the NotIn predicate on the "bound_at" field. +func BoundAtNotIn(vs ...time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNotIn(FieldBoundAt, vs...)) +} + +// BoundAtGT applies the GT predicate on the "bound_at" field. +func BoundAtGT(v time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldGT(FieldBoundAt, v)) +} + +// BoundAtGTE applies the GTE predicate on the "bound_at" field. +func BoundAtGTE(v time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldGTE(FieldBoundAt, v)) +} + +// BoundAtLT applies the LT predicate on the "bound_at" field. +func BoundAtLT(v time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldLT(FieldBoundAt, v)) +} + +// BoundAtLTE applies the LTE predicate on the "bound_at" field. +func BoundAtLTE(v time.Time) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldLTE(FieldBoundAt, v)) +} + +// ExtraDataIsNil applies the IsNil predicate on the "extra_data" field. +func ExtraDataIsNil() predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldIsNull(FieldExtraData)) +} + +// ExtraDataNotNil applies the NotNil predicate on the "extra_data" field. +func ExtraDataNotNil() predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNotNull(FieldExtraData)) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.UserThirdAuth) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.UserThirdAuth) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.UserThirdAuth) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.NotPredicates(p)) +} diff --git a/rpc/ent/userthirdauth_create.go b/rpc/ent/userthirdauth_create.go new file mode 100644 index 0000000..6427b61 --- /dev/null +++ b/rpc/ent/userthirdauth_create.go @@ -0,0 +1,607 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "mingyang-admin-app-rpc/ent/userthirdauth" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// UserThirdAuthCreate is the builder for creating a UserThirdAuth entity. +type UserThirdAuthCreate struct { + config + mutation *UserThirdAuthMutation + hooks []Hook +} + +// SetCreatedAt sets the "created_at" field. +func (_c *UserThirdAuthCreate) SetCreatedAt(v time.Time) *UserThirdAuthCreate { + _c.mutation.SetCreatedAt(v) + return _c +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_c *UserThirdAuthCreate) SetNillableCreatedAt(v *time.Time) *UserThirdAuthCreate { + if v != nil { + _c.SetCreatedAt(*v) + } + return _c +} + +// SetUpdatedAt sets the "updated_at" field. +func (_c *UserThirdAuthCreate) SetUpdatedAt(v time.Time) *UserThirdAuthCreate { + _c.mutation.SetUpdatedAt(v) + return _c +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (_c *UserThirdAuthCreate) SetNillableUpdatedAt(v *time.Time) *UserThirdAuthCreate { + if v != nil { + _c.SetUpdatedAt(*v) + } + return _c +} + +// SetStatus sets the "status" field. +func (_c *UserThirdAuthCreate) SetStatus(v uint8) *UserThirdAuthCreate { + _c.mutation.SetStatus(v) + return _c +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_c *UserThirdAuthCreate) SetNillableStatus(v *uint8) *UserThirdAuthCreate { + if v != nil { + _c.SetStatus(*v) + } + return _c +} + +// SetTenantID sets the "tenant_id" field. +func (_c *UserThirdAuthCreate) SetTenantID(v uint64) *UserThirdAuthCreate { + _c.mutation.SetTenantID(v) + return _c +} + +// SetNillableTenantID sets the "tenant_id" field if the given value is not nil. +func (_c *UserThirdAuthCreate) SetNillableTenantID(v *uint64) *UserThirdAuthCreate { + if v != nil { + _c.SetTenantID(*v) + } + return _c +} + +// SetDeletedAt sets the "deleted_at" field. +func (_c *UserThirdAuthCreate) SetDeletedAt(v time.Time) *UserThirdAuthCreate { + _c.mutation.SetDeletedAt(v) + return _c +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (_c *UserThirdAuthCreate) SetNillableDeletedAt(v *time.Time) *UserThirdAuthCreate { + if v != nil { + _c.SetDeletedAt(*v) + } + return _c +} + +// SetUserID sets the "user_id" field. +func (_c *UserThirdAuthCreate) SetUserID(v uint64) *UserThirdAuthCreate { + _c.mutation.SetUserID(v) + return _c +} + +// SetOpenid sets the "openid" field. +func (_c *UserThirdAuthCreate) SetOpenid(v string) *UserThirdAuthCreate { + _c.mutation.SetOpenid(v) + return _c +} + +// SetUnionid sets the "unionid" field. +func (_c *UserThirdAuthCreate) SetUnionid(v string) *UserThirdAuthCreate { + _c.mutation.SetUnionid(v) + return _c +} + +// SetNillableUnionid sets the "unionid" field if the given value is not nil. +func (_c *UserThirdAuthCreate) SetNillableUnionid(v *string) *UserThirdAuthCreate { + if v != nil { + _c.SetUnionid(*v) + } + return _c +} + +// SetAccessToken sets the "access_token" field. +func (_c *UserThirdAuthCreate) SetAccessToken(v string) *UserThirdAuthCreate { + _c.mutation.SetAccessToken(v) + return _c +} + +// SetNillableAccessToken sets the "access_token" field if the given value is not nil. +func (_c *UserThirdAuthCreate) SetNillableAccessToken(v *string) *UserThirdAuthCreate { + if v != nil { + _c.SetAccessToken(*v) + } + return _c +} + +// SetRefreshToken sets the "refresh_token" field. +func (_c *UserThirdAuthCreate) SetRefreshToken(v string) *UserThirdAuthCreate { + _c.mutation.SetRefreshToken(v) + return _c +} + +// SetNillableRefreshToken sets the "refresh_token" field if the given value is not nil. +func (_c *UserThirdAuthCreate) SetNillableRefreshToken(v *string) *UserThirdAuthCreate { + if v != nil { + _c.SetRefreshToken(*v) + } + return _c +} + +// SetAccessTokenExpiry sets the "access_token_expiry" field. +func (_c *UserThirdAuthCreate) SetAccessTokenExpiry(v time.Time) *UserThirdAuthCreate { + _c.mutation.SetAccessTokenExpiry(v) + return _c +} + +// SetNillableAccessTokenExpiry sets the "access_token_expiry" field if the given value is not nil. +func (_c *UserThirdAuthCreate) SetNillableAccessTokenExpiry(v *time.Time) *UserThirdAuthCreate { + if v != nil { + _c.SetAccessTokenExpiry(*v) + } + return _c +} + +// SetUserInfo sets the "user_info" field. +func (_c *UserThirdAuthCreate) SetUserInfo(v map[string]interface{}) *UserThirdAuthCreate { + _c.mutation.SetUserInfo(v) + return _c +} + +// SetPlatformUserID sets the "platform_user_id" field. +func (_c *UserThirdAuthCreate) SetPlatformUserID(v string) *UserThirdAuthCreate { + _c.mutation.SetPlatformUserID(v) + return _c +} + +// SetNillablePlatformUserID sets the "platform_user_id" field if the given value is not nil. +func (_c *UserThirdAuthCreate) SetNillablePlatformUserID(v *string) *UserThirdAuthCreate { + if v != nil { + _c.SetPlatformUserID(*v) + } + return _c +} + +// SetNickname sets the "nickname" field. +func (_c *UserThirdAuthCreate) SetNickname(v string) *UserThirdAuthCreate { + _c.mutation.SetNickname(v) + return _c +} + +// SetNillableNickname sets the "nickname" field if the given value is not nil. +func (_c *UserThirdAuthCreate) SetNillableNickname(v *string) *UserThirdAuthCreate { + if v != nil { + _c.SetNickname(*v) + } + return _c +} + +// SetAvatar sets the "avatar" field. +func (_c *UserThirdAuthCreate) SetAvatar(v string) *UserThirdAuthCreate { + _c.mutation.SetAvatar(v) + return _c +} + +// SetNillableAvatar sets the "avatar" field if the given value is not nil. +func (_c *UserThirdAuthCreate) SetNillableAvatar(v *string) *UserThirdAuthCreate { + if v != nil { + _c.SetAvatar(*v) + } + return _c +} + +// SetEmail sets the "email" field. +func (_c *UserThirdAuthCreate) SetEmail(v string) *UserThirdAuthCreate { + _c.mutation.SetEmail(v) + return _c +} + +// SetNillableEmail sets the "email" field if the given value is not nil. +func (_c *UserThirdAuthCreate) SetNillableEmail(v *string) *UserThirdAuthCreate { + if v != nil { + _c.SetEmail(*v) + } + return _c +} + +// SetPhone sets the "phone" field. +func (_c *UserThirdAuthCreate) SetPhone(v string) *UserThirdAuthCreate { + _c.mutation.SetPhone(v) + return _c +} + +// SetNillablePhone sets the "phone" field if the given value is not nil. +func (_c *UserThirdAuthCreate) SetNillablePhone(v *string) *UserThirdAuthCreate { + if v != nil { + _c.SetPhone(*v) + } + return _c +} + +// SetIsBound sets the "is_bound" field. +func (_c *UserThirdAuthCreate) SetIsBound(v bool) *UserThirdAuthCreate { + _c.mutation.SetIsBound(v) + return _c +} + +// SetNillableIsBound sets the "is_bound" field if the given value is not nil. +func (_c *UserThirdAuthCreate) SetNillableIsBound(v *bool) *UserThirdAuthCreate { + if v != nil { + _c.SetIsBound(*v) + } + return _c +} + +// SetBoundAt sets the "bound_at" field. +func (_c *UserThirdAuthCreate) SetBoundAt(v time.Time) *UserThirdAuthCreate { + _c.mutation.SetBoundAt(v) + return _c +} + +// SetNillableBoundAt sets the "bound_at" field if the given value is not nil. +func (_c *UserThirdAuthCreate) SetNillableBoundAt(v *time.Time) *UserThirdAuthCreate { + if v != nil { + _c.SetBoundAt(*v) + } + return _c +} + +// SetExtraData sets the "extra_data" field. +func (_c *UserThirdAuthCreate) SetExtraData(v map[string]interface{}) *UserThirdAuthCreate { + _c.mutation.SetExtraData(v) + return _c +} + +// SetID sets the "id" field. +func (_c *UserThirdAuthCreate) SetID(v uint64) *UserThirdAuthCreate { + _c.mutation.SetID(v) + return _c +} + +// Mutation returns the UserThirdAuthMutation object of the builder. +func (_c *UserThirdAuthCreate) Mutation() *UserThirdAuthMutation { + return _c.mutation +} + +// Save creates the UserThirdAuth in the database. +func (_c *UserThirdAuthCreate) Save(ctx context.Context) (*UserThirdAuth, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *UserThirdAuthCreate) SaveX(ctx context.Context) *UserThirdAuth { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *UserThirdAuthCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *UserThirdAuthCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_c *UserThirdAuthCreate) defaults() { + if _, ok := _c.mutation.CreatedAt(); !ok { + v := userthirdauth.DefaultCreatedAt() + _c.mutation.SetCreatedAt(v) + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + v := userthirdauth.DefaultUpdatedAt() + _c.mutation.SetUpdatedAt(v) + } + if _, ok := _c.mutation.Status(); !ok { + v := userthirdauth.DefaultStatus + _c.mutation.SetStatus(v) + } + if _, ok := _c.mutation.TenantID(); !ok { + v := userthirdauth.DefaultTenantID + _c.mutation.SetTenantID(v) + } + if _, ok := _c.mutation.IsBound(); !ok { + v := userthirdauth.DefaultIsBound + _c.mutation.SetIsBound(v) + } + if _, ok := _c.mutation.BoundAt(); !ok { + v := userthirdauth.DefaultBoundAt() + _c.mutation.SetBoundAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *UserThirdAuthCreate) check() error { + if _, ok := _c.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "UserThirdAuth.created_at"`)} + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "UserThirdAuth.updated_at"`)} + } + if _, ok := _c.mutation.TenantID(); !ok { + return &ValidationError{Name: "tenant_id", err: errors.New(`ent: missing required field "UserThirdAuth.tenant_id"`)} + } + if _, ok := _c.mutation.UserID(); !ok { + return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "UserThirdAuth.user_id"`)} + } + if _, ok := _c.mutation.Openid(); !ok { + return &ValidationError{Name: "openid", err: errors.New(`ent: missing required field "UserThirdAuth.openid"`)} + } + if v, ok := _c.mutation.Openid(); ok { + if err := userthirdauth.OpenidValidator(v); err != nil { + return &ValidationError{Name: "openid", err: fmt.Errorf(`ent: validator failed for field "UserThirdAuth.openid": %w`, err)} + } + } + if v, ok := _c.mutation.Unionid(); ok { + if err := userthirdauth.UnionidValidator(v); err != nil { + return &ValidationError{Name: "unionid", err: fmt.Errorf(`ent: validator failed for field "UserThirdAuth.unionid": %w`, err)} + } + } + if v, ok := _c.mutation.AccessToken(); ok { + if err := userthirdauth.AccessTokenValidator(v); err != nil { + return &ValidationError{Name: "access_token", err: fmt.Errorf(`ent: validator failed for field "UserThirdAuth.access_token": %w`, err)} + } + } + if v, ok := _c.mutation.RefreshToken(); ok { + if err := userthirdauth.RefreshTokenValidator(v); err != nil { + return &ValidationError{Name: "refresh_token", err: fmt.Errorf(`ent: validator failed for field "UserThirdAuth.refresh_token": %w`, err)} + } + } + if v, ok := _c.mutation.PlatformUserID(); ok { + if err := userthirdauth.PlatformUserIDValidator(v); err != nil { + return &ValidationError{Name: "platform_user_id", err: fmt.Errorf(`ent: validator failed for field "UserThirdAuth.platform_user_id": %w`, err)} + } + } + if v, ok := _c.mutation.Nickname(); ok { + if err := userthirdauth.NicknameValidator(v); err != nil { + return &ValidationError{Name: "nickname", err: fmt.Errorf(`ent: validator failed for field "UserThirdAuth.nickname": %w`, err)} + } + } + if v, ok := _c.mutation.Avatar(); ok { + if err := userthirdauth.AvatarValidator(v); err != nil { + return &ValidationError{Name: "avatar", err: fmt.Errorf(`ent: validator failed for field "UserThirdAuth.avatar": %w`, err)} + } + } + if v, ok := _c.mutation.Email(); ok { + if err := userthirdauth.EmailValidator(v); err != nil { + return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "UserThirdAuth.email": %w`, err)} + } + } + if v, ok := _c.mutation.Phone(); ok { + if err := userthirdauth.PhoneValidator(v); err != nil { + return &ValidationError{Name: "phone", err: fmt.Errorf(`ent: validator failed for field "UserThirdAuth.phone": %w`, err)} + } + } + if _, ok := _c.mutation.IsBound(); !ok { + return &ValidationError{Name: "is_bound", err: errors.New(`ent: missing required field "UserThirdAuth.is_bound"`)} + } + if _, ok := _c.mutation.BoundAt(); !ok { + return &ValidationError{Name: "bound_at", err: errors.New(`ent: missing required field "UserThirdAuth.bound_at"`)} + } + return nil +} + +func (_c *UserThirdAuthCreate) sqlSave(ctx context.Context) (*UserThirdAuth, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != _node.ID { + id := _spec.ID.Value.(int64) + _node.ID = uint64(id) + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *UserThirdAuthCreate) createSpec() (*UserThirdAuth, *sqlgraph.CreateSpec) { + var ( + _node = &UserThirdAuth{config: _c.config} + _spec = sqlgraph.NewCreateSpec(userthirdauth.Table, sqlgraph.NewFieldSpec(userthirdauth.FieldID, field.TypeUint64)) + ) + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := _c.mutation.CreatedAt(); ok { + _spec.SetField(userthirdauth.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := _c.mutation.UpdatedAt(); ok { + _spec.SetField(userthirdauth.FieldUpdatedAt, field.TypeTime, value) + _node.UpdatedAt = value + } + if value, ok := _c.mutation.Status(); ok { + _spec.SetField(userthirdauth.FieldStatus, field.TypeUint8, value) + _node.Status = value + } + if value, ok := _c.mutation.TenantID(); ok { + _spec.SetField(userthirdauth.FieldTenantID, field.TypeUint64, value) + _node.TenantID = value + } + if value, ok := _c.mutation.DeletedAt(); ok { + _spec.SetField(userthirdauth.FieldDeletedAt, field.TypeTime, value) + _node.DeletedAt = value + } + if value, ok := _c.mutation.UserID(); ok { + _spec.SetField(userthirdauth.FieldUserID, field.TypeUint64, value) + _node.UserID = value + } + if value, ok := _c.mutation.Openid(); ok { + _spec.SetField(userthirdauth.FieldOpenid, field.TypeString, value) + _node.Openid = value + } + if value, ok := _c.mutation.Unionid(); ok { + _spec.SetField(userthirdauth.FieldUnionid, field.TypeString, value) + _node.Unionid = value + } + if value, ok := _c.mutation.AccessToken(); ok { + _spec.SetField(userthirdauth.FieldAccessToken, field.TypeString, value) + _node.AccessToken = value + } + if value, ok := _c.mutation.RefreshToken(); ok { + _spec.SetField(userthirdauth.FieldRefreshToken, field.TypeString, value) + _node.RefreshToken = value + } + if value, ok := _c.mutation.AccessTokenExpiry(); ok { + _spec.SetField(userthirdauth.FieldAccessTokenExpiry, field.TypeTime, value) + _node.AccessTokenExpiry = &value + } + if value, ok := _c.mutation.UserInfo(); ok { + _spec.SetField(userthirdauth.FieldUserInfo, field.TypeJSON, value) + _node.UserInfo = value + } + if value, ok := _c.mutation.PlatformUserID(); ok { + _spec.SetField(userthirdauth.FieldPlatformUserID, field.TypeString, value) + _node.PlatformUserID = value + } + if value, ok := _c.mutation.Nickname(); ok { + _spec.SetField(userthirdauth.FieldNickname, field.TypeString, value) + _node.Nickname = value + } + if value, ok := _c.mutation.Avatar(); ok { + _spec.SetField(userthirdauth.FieldAvatar, field.TypeString, value) + _node.Avatar = value + } + if value, ok := _c.mutation.Email(); ok { + _spec.SetField(userthirdauth.FieldEmail, field.TypeString, value) + _node.Email = value + } + if value, ok := _c.mutation.Phone(); ok { + _spec.SetField(userthirdauth.FieldPhone, field.TypeString, value) + _node.Phone = value + } + if value, ok := _c.mutation.IsBound(); ok { + _spec.SetField(userthirdauth.FieldIsBound, field.TypeBool, value) + _node.IsBound = value + } + if value, ok := _c.mutation.BoundAt(); ok { + _spec.SetField(userthirdauth.FieldBoundAt, field.TypeTime, value) + _node.BoundAt = value + } + if value, ok := _c.mutation.ExtraData(); ok { + _spec.SetField(userthirdauth.FieldExtraData, field.TypeJSON, value) + _node.ExtraData = value + } + return _node, _spec +} + +// UserThirdAuthCreateBulk is the builder for creating many UserThirdAuth entities in bulk. +type UserThirdAuthCreateBulk struct { + config + err error + builders []*UserThirdAuthCreate +} + +// Save creates the UserThirdAuth entities in the database. +func (_c *UserThirdAuthCreateBulk) Save(ctx context.Context) ([]*UserThirdAuth, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*UserThirdAuth, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*UserThirdAuthMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil && nodes[i].ID == 0 { + id := specs[i].ID.Value.(int64) + nodes[i].ID = uint64(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *UserThirdAuthCreateBulk) SaveX(ctx context.Context) []*UserThirdAuth { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *UserThirdAuthCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *UserThirdAuthCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/rpc/ent/userthirdauth_delete.go b/rpc/ent/userthirdauth_delete.go new file mode 100644 index 0000000..a46b547 --- /dev/null +++ b/rpc/ent/userthirdauth_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "mingyang-admin-app-rpc/ent/predicate" + "mingyang-admin-app-rpc/ent/userthirdauth" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// UserThirdAuthDelete is the builder for deleting a UserThirdAuth entity. +type UserThirdAuthDelete struct { + config + hooks []Hook + mutation *UserThirdAuthMutation +} + +// Where appends a list predicates to the UserThirdAuthDelete builder. +func (_d *UserThirdAuthDelete) Where(ps ...predicate.UserThirdAuth) *UserThirdAuthDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *UserThirdAuthDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *UserThirdAuthDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *UserThirdAuthDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(userthirdauth.Table, sqlgraph.NewFieldSpec(userthirdauth.FieldID, field.TypeUint64)) + if ps := _d.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + _d.mutation.done = true + return affected, err +} + +// UserThirdAuthDeleteOne is the builder for deleting a single UserThirdAuth entity. +type UserThirdAuthDeleteOne struct { + _d *UserThirdAuthDelete +} + +// Where appends a list predicates to the UserThirdAuthDelete builder. +func (_d *UserThirdAuthDeleteOne) Where(ps ...predicate.UserThirdAuth) *UserThirdAuthDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *UserThirdAuthDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{userthirdauth.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *UserThirdAuthDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/rpc/ent/userthirdauth_query.go b/rpc/ent/userthirdauth_query.go new file mode 100644 index 0000000..ad9bbc5 --- /dev/null +++ b/rpc/ent/userthirdauth_query.go @@ -0,0 +1,527 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + "mingyang-admin-app-rpc/ent/predicate" + "mingyang-admin-app-rpc/ent/userthirdauth" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// UserThirdAuthQuery is the builder for querying UserThirdAuth entities. +type UserThirdAuthQuery struct { + config + ctx *QueryContext + order []userthirdauth.OrderOption + inters []Interceptor + predicates []predicate.UserThirdAuth + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the UserThirdAuthQuery builder. +func (_q *UserThirdAuthQuery) Where(ps ...predicate.UserThirdAuth) *UserThirdAuthQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *UserThirdAuthQuery) Limit(limit int) *UserThirdAuthQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *UserThirdAuthQuery) Offset(offset int) *UserThirdAuthQuery { + _q.ctx.Offset = &offset + return _q +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (_q *UserThirdAuthQuery) Unique(unique bool) *UserThirdAuthQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *UserThirdAuthQuery) Order(o ...userthirdauth.OrderOption) *UserThirdAuthQuery { + _q.order = append(_q.order, o...) + return _q +} + +// First returns the first UserThirdAuth entity from the query. +// Returns a *NotFoundError when no UserThirdAuth was found. +func (_q *UserThirdAuthQuery) First(ctx context.Context) (*UserThirdAuth, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{userthirdauth.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *UserThirdAuthQuery) FirstX(ctx context.Context) *UserThirdAuth { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first UserThirdAuth ID from the query. +// Returns a *NotFoundError when no UserThirdAuth ID was found. +func (_q *UserThirdAuthQuery) FirstID(ctx context.Context) (id uint64, err error) { + var ids []uint64 + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{userthirdauth.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *UserThirdAuthQuery) FirstIDX(ctx context.Context) uint64 { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single UserThirdAuth entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one UserThirdAuth entity is found. +// Returns a *NotFoundError when no UserThirdAuth entities are found. +func (_q *UserThirdAuthQuery) Only(ctx context.Context) (*UserThirdAuth, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{userthirdauth.Label} + default: + return nil, &NotSingularError{userthirdauth.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *UserThirdAuthQuery) OnlyX(ctx context.Context) *UserThirdAuth { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only UserThirdAuth ID in the query. +// Returns a *NotSingularError when more than one UserThirdAuth ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *UserThirdAuthQuery) OnlyID(ctx context.Context) (id uint64, err error) { + var ids []uint64 + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{userthirdauth.Label} + default: + err = &NotSingularError{userthirdauth.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *UserThirdAuthQuery) OnlyIDX(ctx context.Context) uint64 { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of UserThirdAuths. +func (_q *UserThirdAuthQuery) All(ctx context.Context) ([]*UserThirdAuth, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*UserThirdAuth, *UserThirdAuthQuery]() + return withInterceptors[[]*UserThirdAuth](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *UserThirdAuthQuery) AllX(ctx context.Context) []*UserThirdAuth { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of UserThirdAuth IDs. +func (_q *UserThirdAuthQuery) IDs(ctx context.Context) (ids []uint64, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(userthirdauth.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *UserThirdAuthQuery) IDsX(ctx context.Context) []uint64 { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *UserThirdAuthQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, _q, querierCount[*UserThirdAuthQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *UserThirdAuthQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (_q *UserThirdAuthQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *UserThirdAuthQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the UserThirdAuthQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (_q *UserThirdAuthQuery) Clone() *UserThirdAuthQuery { + if _q == nil { + return nil + } + return &UserThirdAuthQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]userthirdauth.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.UserThirdAuth{}, _q.predicates...), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + } +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// CreatedAt time.Time `json:"created_at,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.UserThirdAuth.Query(). +// GroupBy(userthirdauth.FieldCreatedAt). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *UserThirdAuthQuery) GroupBy(field string, fields ...string) *UserThirdAuthGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &UserThirdAuthGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = userthirdauth.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 { +// CreatedAt time.Time `json:"created_at,omitempty"` +// } +// +// client.UserThirdAuth.Query(). +// Select(userthirdauth.FieldCreatedAt). +// Scan(ctx, &v) +func (_q *UserThirdAuthQuery) Select(fields ...string) *UserThirdAuthSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &UserThirdAuthSelect{UserThirdAuthQuery: _q} + sbuild.label = userthirdauth.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a UserThirdAuthSelect configured with the given aggregations. +func (_q *UserThirdAuthQuery) Aggregate(fns ...AggregateFunc) *UserThirdAuthSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *UserThirdAuthQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !userthirdauth.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if _q.path != nil { + prev, err := _q.path(ctx) + if err != nil { + return err + } + _q.sql = prev + } + return nil +} + +func (_q *UserThirdAuthQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*UserThirdAuth, error) { + var ( + nodes = []*UserThirdAuth{} + _spec = _q.querySpec() + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*UserThirdAuth).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &UserThirdAuth{config: _q.config} + nodes = append(nodes, node) + return node.assignValues(columns, values) + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + return nodes, nil +} + +func (_q *UserThirdAuthQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique + } + return sqlgraph.CountNodes(ctx, _q.driver, _spec) +} + +func (_q *UserThirdAuthQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(userthirdauth.Table, userthirdauth.Columns, sqlgraph.NewFieldSpec(userthirdauth.FieldID, field.TypeUint64)) + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if _q.path != nil { + _spec.Unique = true + } + if fields := _q.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, userthirdauth.FieldID) + for i := range fields { + if fields[i] != userthirdauth.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := _q.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := _q.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := _q.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := _q.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (_q *UserThirdAuthQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(userthirdauth.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = userthirdauth.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if _q.sql != nil { + selector = _q.sql + selector.Select(selector.Columns(columns...)...) + } + if _q.ctx.Unique != nil && *_q.ctx.Unique { + selector.Distinct() + } + for _, p := range _q.predicates { + p(selector) + } + for _, p := range _q.order { + p(selector) + } + if offset := _q.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := _q.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// UserThirdAuthGroupBy is the group-by builder for UserThirdAuth entities. +type UserThirdAuthGroupBy struct { + selector + build *UserThirdAuthQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *UserThirdAuthGroupBy) Aggregate(fns ...AggregateFunc) *UserThirdAuthGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *UserThirdAuthGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*UserThirdAuthQuery, *UserThirdAuthGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *UserThirdAuthGroupBy) sqlScan(ctx context.Context, root *UserThirdAuthQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*_g.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// UserThirdAuthSelect is the builder for selecting fields of UserThirdAuth entities. +type UserThirdAuthSelect struct { + *UserThirdAuthQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *UserThirdAuthSelect) Aggregate(fns ...AggregateFunc) *UserThirdAuthSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *UserThirdAuthSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*UserThirdAuthQuery, *UserThirdAuthSelect](ctx, _s.UserThirdAuthQuery, _s, _s.inters, v) +} + +func (_s *UserThirdAuthSelect) sqlScan(ctx context.Context, root *UserThirdAuthQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/rpc/ent/userthirdauth_update.go b/rpc/ent/userthirdauth_update.go new file mode 100644 index 0000000..9451212 --- /dev/null +++ b/rpc/ent/userthirdauth_update.go @@ -0,0 +1,1138 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "mingyang-admin-app-rpc/ent/predicate" + "mingyang-admin-app-rpc/ent/userthirdauth" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// UserThirdAuthUpdate is the builder for updating UserThirdAuth entities. +type UserThirdAuthUpdate struct { + config + hooks []Hook + mutation *UserThirdAuthMutation +} + +// Where appends a list predicates to the UserThirdAuthUpdate builder. +func (_u *UserThirdAuthUpdate) Where(ps ...predicate.UserThirdAuth) *UserThirdAuthUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *UserThirdAuthUpdate) SetUpdatedAt(v time.Time) *UserThirdAuthUpdate { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// SetStatus sets the "status" field. +func (_u *UserThirdAuthUpdate) SetStatus(v uint8) *UserThirdAuthUpdate { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_u *UserThirdAuthUpdate) SetNillableStatus(v *uint8) *UserThirdAuthUpdate { + if v != nil { + _u.SetStatus(*v) + } + return _u +} + +// AddStatus adds value to the "status" field. +func (_u *UserThirdAuthUpdate) AddStatus(v int8) *UserThirdAuthUpdate { + _u.mutation.AddStatus(v) + return _u +} + +// ClearStatus clears the value of the "status" field. +func (_u *UserThirdAuthUpdate) ClearStatus() *UserThirdAuthUpdate { + _u.mutation.ClearStatus() + return _u +} + +// SetDeletedAt sets the "deleted_at" field. +func (_u *UserThirdAuthUpdate) SetDeletedAt(v time.Time) *UserThirdAuthUpdate { + _u.mutation.SetDeletedAt(v) + return _u +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (_u *UserThirdAuthUpdate) SetNillableDeletedAt(v *time.Time) *UserThirdAuthUpdate { + if v != nil { + _u.SetDeletedAt(*v) + } + return _u +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (_u *UserThirdAuthUpdate) ClearDeletedAt() *UserThirdAuthUpdate { + _u.mutation.ClearDeletedAt() + return _u +} + +// SetUserID sets the "user_id" field. +func (_u *UserThirdAuthUpdate) SetUserID(v uint64) *UserThirdAuthUpdate { + _u.mutation.ResetUserID() + _u.mutation.SetUserID(v) + return _u +} + +// SetNillableUserID sets the "user_id" field if the given value is not nil. +func (_u *UserThirdAuthUpdate) SetNillableUserID(v *uint64) *UserThirdAuthUpdate { + if v != nil { + _u.SetUserID(*v) + } + return _u +} + +// AddUserID adds value to the "user_id" field. +func (_u *UserThirdAuthUpdate) AddUserID(v int64) *UserThirdAuthUpdate { + _u.mutation.AddUserID(v) + return _u +} + +// SetOpenid sets the "openid" field. +func (_u *UserThirdAuthUpdate) SetOpenid(v string) *UserThirdAuthUpdate { + _u.mutation.SetOpenid(v) + return _u +} + +// SetNillableOpenid sets the "openid" field if the given value is not nil. +func (_u *UserThirdAuthUpdate) SetNillableOpenid(v *string) *UserThirdAuthUpdate { + if v != nil { + _u.SetOpenid(*v) + } + return _u +} + +// SetUnionid sets the "unionid" field. +func (_u *UserThirdAuthUpdate) SetUnionid(v string) *UserThirdAuthUpdate { + _u.mutation.SetUnionid(v) + return _u +} + +// SetNillableUnionid sets the "unionid" field if the given value is not nil. +func (_u *UserThirdAuthUpdate) SetNillableUnionid(v *string) *UserThirdAuthUpdate { + if v != nil { + _u.SetUnionid(*v) + } + return _u +} + +// ClearUnionid clears the value of the "unionid" field. +func (_u *UserThirdAuthUpdate) ClearUnionid() *UserThirdAuthUpdate { + _u.mutation.ClearUnionid() + return _u +} + +// SetAccessToken sets the "access_token" field. +func (_u *UserThirdAuthUpdate) SetAccessToken(v string) *UserThirdAuthUpdate { + _u.mutation.SetAccessToken(v) + return _u +} + +// SetNillableAccessToken sets the "access_token" field if the given value is not nil. +func (_u *UserThirdAuthUpdate) SetNillableAccessToken(v *string) *UserThirdAuthUpdate { + if v != nil { + _u.SetAccessToken(*v) + } + return _u +} + +// ClearAccessToken clears the value of the "access_token" field. +func (_u *UserThirdAuthUpdate) ClearAccessToken() *UserThirdAuthUpdate { + _u.mutation.ClearAccessToken() + return _u +} + +// SetRefreshToken sets the "refresh_token" field. +func (_u *UserThirdAuthUpdate) SetRefreshToken(v string) *UserThirdAuthUpdate { + _u.mutation.SetRefreshToken(v) + return _u +} + +// SetNillableRefreshToken sets the "refresh_token" field if the given value is not nil. +func (_u *UserThirdAuthUpdate) SetNillableRefreshToken(v *string) *UserThirdAuthUpdate { + if v != nil { + _u.SetRefreshToken(*v) + } + return _u +} + +// ClearRefreshToken clears the value of the "refresh_token" field. +func (_u *UserThirdAuthUpdate) ClearRefreshToken() *UserThirdAuthUpdate { + _u.mutation.ClearRefreshToken() + return _u +} + +// SetAccessTokenExpiry sets the "access_token_expiry" field. +func (_u *UserThirdAuthUpdate) SetAccessTokenExpiry(v time.Time) *UserThirdAuthUpdate { + _u.mutation.SetAccessTokenExpiry(v) + return _u +} + +// SetNillableAccessTokenExpiry sets the "access_token_expiry" field if the given value is not nil. +func (_u *UserThirdAuthUpdate) SetNillableAccessTokenExpiry(v *time.Time) *UserThirdAuthUpdate { + if v != nil { + _u.SetAccessTokenExpiry(*v) + } + return _u +} + +// ClearAccessTokenExpiry clears the value of the "access_token_expiry" field. +func (_u *UserThirdAuthUpdate) ClearAccessTokenExpiry() *UserThirdAuthUpdate { + _u.mutation.ClearAccessTokenExpiry() + return _u +} + +// SetUserInfo sets the "user_info" field. +func (_u *UserThirdAuthUpdate) SetUserInfo(v map[string]interface{}) *UserThirdAuthUpdate { + _u.mutation.SetUserInfo(v) + return _u +} + +// ClearUserInfo clears the value of the "user_info" field. +func (_u *UserThirdAuthUpdate) ClearUserInfo() *UserThirdAuthUpdate { + _u.mutation.ClearUserInfo() + return _u +} + +// SetPlatformUserID sets the "platform_user_id" field. +func (_u *UserThirdAuthUpdate) SetPlatformUserID(v string) *UserThirdAuthUpdate { + _u.mutation.SetPlatformUserID(v) + return _u +} + +// SetNillablePlatformUserID sets the "platform_user_id" field if the given value is not nil. +func (_u *UserThirdAuthUpdate) SetNillablePlatformUserID(v *string) *UserThirdAuthUpdate { + if v != nil { + _u.SetPlatformUserID(*v) + } + return _u +} + +// ClearPlatformUserID clears the value of the "platform_user_id" field. +func (_u *UserThirdAuthUpdate) ClearPlatformUserID() *UserThirdAuthUpdate { + _u.mutation.ClearPlatformUserID() + return _u +} + +// SetNickname sets the "nickname" field. +func (_u *UserThirdAuthUpdate) SetNickname(v string) *UserThirdAuthUpdate { + _u.mutation.SetNickname(v) + return _u +} + +// SetNillableNickname sets the "nickname" field if the given value is not nil. +func (_u *UserThirdAuthUpdate) SetNillableNickname(v *string) *UserThirdAuthUpdate { + if v != nil { + _u.SetNickname(*v) + } + return _u +} + +// ClearNickname clears the value of the "nickname" field. +func (_u *UserThirdAuthUpdate) ClearNickname() *UserThirdAuthUpdate { + _u.mutation.ClearNickname() + return _u +} + +// SetAvatar sets the "avatar" field. +func (_u *UserThirdAuthUpdate) SetAvatar(v string) *UserThirdAuthUpdate { + _u.mutation.SetAvatar(v) + return _u +} + +// SetNillableAvatar sets the "avatar" field if the given value is not nil. +func (_u *UserThirdAuthUpdate) SetNillableAvatar(v *string) *UserThirdAuthUpdate { + if v != nil { + _u.SetAvatar(*v) + } + return _u +} + +// ClearAvatar clears the value of the "avatar" field. +func (_u *UserThirdAuthUpdate) ClearAvatar() *UserThirdAuthUpdate { + _u.mutation.ClearAvatar() + return _u +} + +// SetEmail sets the "email" field. +func (_u *UserThirdAuthUpdate) SetEmail(v string) *UserThirdAuthUpdate { + _u.mutation.SetEmail(v) + return _u +} + +// SetNillableEmail sets the "email" field if the given value is not nil. +func (_u *UserThirdAuthUpdate) SetNillableEmail(v *string) *UserThirdAuthUpdate { + if v != nil { + _u.SetEmail(*v) + } + return _u +} + +// ClearEmail clears the value of the "email" field. +func (_u *UserThirdAuthUpdate) ClearEmail() *UserThirdAuthUpdate { + _u.mutation.ClearEmail() + return _u +} + +// SetPhone sets the "phone" field. +func (_u *UserThirdAuthUpdate) SetPhone(v string) *UserThirdAuthUpdate { + _u.mutation.SetPhone(v) + return _u +} + +// SetNillablePhone sets the "phone" field if the given value is not nil. +func (_u *UserThirdAuthUpdate) SetNillablePhone(v *string) *UserThirdAuthUpdate { + if v != nil { + _u.SetPhone(*v) + } + return _u +} + +// ClearPhone clears the value of the "phone" field. +func (_u *UserThirdAuthUpdate) ClearPhone() *UserThirdAuthUpdate { + _u.mutation.ClearPhone() + return _u +} + +// SetIsBound sets the "is_bound" field. +func (_u *UserThirdAuthUpdate) SetIsBound(v bool) *UserThirdAuthUpdate { + _u.mutation.SetIsBound(v) + return _u +} + +// SetNillableIsBound sets the "is_bound" field if the given value is not nil. +func (_u *UserThirdAuthUpdate) SetNillableIsBound(v *bool) *UserThirdAuthUpdate { + if v != nil { + _u.SetIsBound(*v) + } + return _u +} + +// SetBoundAt sets the "bound_at" field. +func (_u *UserThirdAuthUpdate) SetBoundAt(v time.Time) *UserThirdAuthUpdate { + _u.mutation.SetBoundAt(v) + return _u +} + +// SetNillableBoundAt sets the "bound_at" field if the given value is not nil. +func (_u *UserThirdAuthUpdate) SetNillableBoundAt(v *time.Time) *UserThirdAuthUpdate { + if v != nil { + _u.SetBoundAt(*v) + } + return _u +} + +// SetExtraData sets the "extra_data" field. +func (_u *UserThirdAuthUpdate) SetExtraData(v map[string]interface{}) *UserThirdAuthUpdate { + _u.mutation.SetExtraData(v) + return _u +} + +// ClearExtraData clears the value of the "extra_data" field. +func (_u *UserThirdAuthUpdate) ClearExtraData() *UserThirdAuthUpdate { + _u.mutation.ClearExtraData() + return _u +} + +// Mutation returns the UserThirdAuthMutation object of the builder. +func (_u *UserThirdAuthUpdate) Mutation() *UserThirdAuthMutation { + return _u.mutation +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *UserThirdAuthUpdate) Save(ctx context.Context) (int, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *UserThirdAuthUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *UserThirdAuthUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *UserThirdAuthUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *UserThirdAuthUpdate) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := userthirdauth.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *UserThirdAuthUpdate) check() error { + if v, ok := _u.mutation.Openid(); ok { + if err := userthirdauth.OpenidValidator(v); err != nil { + return &ValidationError{Name: "openid", err: fmt.Errorf(`ent: validator failed for field "UserThirdAuth.openid": %w`, err)} + } + } + if v, ok := _u.mutation.Unionid(); ok { + if err := userthirdauth.UnionidValidator(v); err != nil { + return &ValidationError{Name: "unionid", err: fmt.Errorf(`ent: validator failed for field "UserThirdAuth.unionid": %w`, err)} + } + } + if v, ok := _u.mutation.AccessToken(); ok { + if err := userthirdauth.AccessTokenValidator(v); err != nil { + return &ValidationError{Name: "access_token", err: fmt.Errorf(`ent: validator failed for field "UserThirdAuth.access_token": %w`, err)} + } + } + if v, ok := _u.mutation.RefreshToken(); ok { + if err := userthirdauth.RefreshTokenValidator(v); err != nil { + return &ValidationError{Name: "refresh_token", err: fmt.Errorf(`ent: validator failed for field "UserThirdAuth.refresh_token": %w`, err)} + } + } + if v, ok := _u.mutation.PlatformUserID(); ok { + if err := userthirdauth.PlatformUserIDValidator(v); err != nil { + return &ValidationError{Name: "platform_user_id", err: fmt.Errorf(`ent: validator failed for field "UserThirdAuth.platform_user_id": %w`, err)} + } + } + if v, ok := _u.mutation.Nickname(); ok { + if err := userthirdauth.NicknameValidator(v); err != nil { + return &ValidationError{Name: "nickname", err: fmt.Errorf(`ent: validator failed for field "UserThirdAuth.nickname": %w`, err)} + } + } + if v, ok := _u.mutation.Avatar(); ok { + if err := userthirdauth.AvatarValidator(v); err != nil { + return &ValidationError{Name: "avatar", err: fmt.Errorf(`ent: validator failed for field "UserThirdAuth.avatar": %w`, err)} + } + } + if v, ok := _u.mutation.Email(); ok { + if err := userthirdauth.EmailValidator(v); err != nil { + return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "UserThirdAuth.email": %w`, err)} + } + } + if v, ok := _u.mutation.Phone(); ok { + if err := userthirdauth.PhoneValidator(v); err != nil { + return &ValidationError{Name: "phone", err: fmt.Errorf(`ent: validator failed for field "UserThirdAuth.phone": %w`, err)} + } + } + return nil +} + +func (_u *UserThirdAuthUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(userthirdauth.Table, userthirdauth.Columns, sqlgraph.NewFieldSpec(userthirdauth.FieldID, field.TypeUint64)) + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.UpdatedAt(); ok { + _spec.SetField(userthirdauth.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.Status(); ok { + _spec.SetField(userthirdauth.FieldStatus, field.TypeUint8, value) + } + if value, ok := _u.mutation.AddedStatus(); ok { + _spec.AddField(userthirdauth.FieldStatus, field.TypeUint8, value) + } + if _u.mutation.StatusCleared() { + _spec.ClearField(userthirdauth.FieldStatus, field.TypeUint8) + } + if value, ok := _u.mutation.DeletedAt(); ok { + _spec.SetField(userthirdauth.FieldDeletedAt, field.TypeTime, value) + } + if _u.mutation.DeletedAtCleared() { + _spec.ClearField(userthirdauth.FieldDeletedAt, field.TypeTime) + } + if value, ok := _u.mutation.UserID(); ok { + _spec.SetField(userthirdauth.FieldUserID, field.TypeUint64, value) + } + if value, ok := _u.mutation.AddedUserID(); ok { + _spec.AddField(userthirdauth.FieldUserID, field.TypeUint64, value) + } + if value, ok := _u.mutation.Openid(); ok { + _spec.SetField(userthirdauth.FieldOpenid, field.TypeString, value) + } + if value, ok := _u.mutation.Unionid(); ok { + _spec.SetField(userthirdauth.FieldUnionid, field.TypeString, value) + } + if _u.mutation.UnionidCleared() { + _spec.ClearField(userthirdauth.FieldUnionid, field.TypeString) + } + if value, ok := _u.mutation.AccessToken(); ok { + _spec.SetField(userthirdauth.FieldAccessToken, field.TypeString, value) + } + if _u.mutation.AccessTokenCleared() { + _spec.ClearField(userthirdauth.FieldAccessToken, field.TypeString) + } + if value, ok := _u.mutation.RefreshToken(); ok { + _spec.SetField(userthirdauth.FieldRefreshToken, field.TypeString, value) + } + if _u.mutation.RefreshTokenCleared() { + _spec.ClearField(userthirdauth.FieldRefreshToken, field.TypeString) + } + if value, ok := _u.mutation.AccessTokenExpiry(); ok { + _spec.SetField(userthirdauth.FieldAccessTokenExpiry, field.TypeTime, value) + } + if _u.mutation.AccessTokenExpiryCleared() { + _spec.ClearField(userthirdauth.FieldAccessTokenExpiry, field.TypeTime) + } + if value, ok := _u.mutation.UserInfo(); ok { + _spec.SetField(userthirdauth.FieldUserInfo, field.TypeJSON, value) + } + if _u.mutation.UserInfoCleared() { + _spec.ClearField(userthirdauth.FieldUserInfo, field.TypeJSON) + } + if value, ok := _u.mutation.PlatformUserID(); ok { + _spec.SetField(userthirdauth.FieldPlatformUserID, field.TypeString, value) + } + if _u.mutation.PlatformUserIDCleared() { + _spec.ClearField(userthirdauth.FieldPlatformUserID, field.TypeString) + } + if value, ok := _u.mutation.Nickname(); ok { + _spec.SetField(userthirdauth.FieldNickname, field.TypeString, value) + } + if _u.mutation.NicknameCleared() { + _spec.ClearField(userthirdauth.FieldNickname, field.TypeString) + } + if value, ok := _u.mutation.Avatar(); ok { + _spec.SetField(userthirdauth.FieldAvatar, field.TypeString, value) + } + if _u.mutation.AvatarCleared() { + _spec.ClearField(userthirdauth.FieldAvatar, field.TypeString) + } + if value, ok := _u.mutation.Email(); ok { + _spec.SetField(userthirdauth.FieldEmail, field.TypeString, value) + } + if _u.mutation.EmailCleared() { + _spec.ClearField(userthirdauth.FieldEmail, field.TypeString) + } + if value, ok := _u.mutation.Phone(); ok { + _spec.SetField(userthirdauth.FieldPhone, field.TypeString, value) + } + if _u.mutation.PhoneCleared() { + _spec.ClearField(userthirdauth.FieldPhone, field.TypeString) + } + if value, ok := _u.mutation.IsBound(); ok { + _spec.SetField(userthirdauth.FieldIsBound, field.TypeBool, value) + } + if value, ok := _u.mutation.BoundAt(); ok { + _spec.SetField(userthirdauth.FieldBoundAt, field.TypeTime, value) + } + if value, ok := _u.mutation.ExtraData(); ok { + _spec.SetField(userthirdauth.FieldExtraData, field.TypeJSON, value) + } + if _u.mutation.ExtraDataCleared() { + _spec.ClearField(userthirdauth.FieldExtraData, field.TypeJSON) + } + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{userthirdauth.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// UserThirdAuthUpdateOne is the builder for updating a single UserThirdAuth entity. +type UserThirdAuthUpdateOne struct { + config + fields []string + hooks []Hook + mutation *UserThirdAuthMutation +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *UserThirdAuthUpdateOne) SetUpdatedAt(v time.Time) *UserThirdAuthUpdateOne { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// SetStatus sets the "status" field. +func (_u *UserThirdAuthUpdateOne) SetStatus(v uint8) *UserThirdAuthUpdateOne { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_u *UserThirdAuthUpdateOne) SetNillableStatus(v *uint8) *UserThirdAuthUpdateOne { + if v != nil { + _u.SetStatus(*v) + } + return _u +} + +// AddStatus adds value to the "status" field. +func (_u *UserThirdAuthUpdateOne) AddStatus(v int8) *UserThirdAuthUpdateOne { + _u.mutation.AddStatus(v) + return _u +} + +// ClearStatus clears the value of the "status" field. +func (_u *UserThirdAuthUpdateOne) ClearStatus() *UserThirdAuthUpdateOne { + _u.mutation.ClearStatus() + return _u +} + +// SetDeletedAt sets the "deleted_at" field. +func (_u *UserThirdAuthUpdateOne) SetDeletedAt(v time.Time) *UserThirdAuthUpdateOne { + _u.mutation.SetDeletedAt(v) + return _u +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (_u *UserThirdAuthUpdateOne) SetNillableDeletedAt(v *time.Time) *UserThirdAuthUpdateOne { + if v != nil { + _u.SetDeletedAt(*v) + } + return _u +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (_u *UserThirdAuthUpdateOne) ClearDeletedAt() *UserThirdAuthUpdateOne { + _u.mutation.ClearDeletedAt() + return _u +} + +// SetUserID sets the "user_id" field. +func (_u *UserThirdAuthUpdateOne) SetUserID(v uint64) *UserThirdAuthUpdateOne { + _u.mutation.ResetUserID() + _u.mutation.SetUserID(v) + return _u +} + +// SetNillableUserID sets the "user_id" field if the given value is not nil. +func (_u *UserThirdAuthUpdateOne) SetNillableUserID(v *uint64) *UserThirdAuthUpdateOne { + if v != nil { + _u.SetUserID(*v) + } + return _u +} + +// AddUserID adds value to the "user_id" field. +func (_u *UserThirdAuthUpdateOne) AddUserID(v int64) *UserThirdAuthUpdateOne { + _u.mutation.AddUserID(v) + return _u +} + +// SetOpenid sets the "openid" field. +func (_u *UserThirdAuthUpdateOne) SetOpenid(v string) *UserThirdAuthUpdateOne { + _u.mutation.SetOpenid(v) + return _u +} + +// SetNillableOpenid sets the "openid" field if the given value is not nil. +func (_u *UserThirdAuthUpdateOne) SetNillableOpenid(v *string) *UserThirdAuthUpdateOne { + if v != nil { + _u.SetOpenid(*v) + } + return _u +} + +// SetUnionid sets the "unionid" field. +func (_u *UserThirdAuthUpdateOne) SetUnionid(v string) *UserThirdAuthUpdateOne { + _u.mutation.SetUnionid(v) + return _u +} + +// SetNillableUnionid sets the "unionid" field if the given value is not nil. +func (_u *UserThirdAuthUpdateOne) SetNillableUnionid(v *string) *UserThirdAuthUpdateOne { + if v != nil { + _u.SetUnionid(*v) + } + return _u +} + +// ClearUnionid clears the value of the "unionid" field. +func (_u *UserThirdAuthUpdateOne) ClearUnionid() *UserThirdAuthUpdateOne { + _u.mutation.ClearUnionid() + return _u +} + +// SetAccessToken sets the "access_token" field. +func (_u *UserThirdAuthUpdateOne) SetAccessToken(v string) *UserThirdAuthUpdateOne { + _u.mutation.SetAccessToken(v) + return _u +} + +// SetNillableAccessToken sets the "access_token" field if the given value is not nil. +func (_u *UserThirdAuthUpdateOne) SetNillableAccessToken(v *string) *UserThirdAuthUpdateOne { + if v != nil { + _u.SetAccessToken(*v) + } + return _u +} + +// ClearAccessToken clears the value of the "access_token" field. +func (_u *UserThirdAuthUpdateOne) ClearAccessToken() *UserThirdAuthUpdateOne { + _u.mutation.ClearAccessToken() + return _u +} + +// SetRefreshToken sets the "refresh_token" field. +func (_u *UserThirdAuthUpdateOne) SetRefreshToken(v string) *UserThirdAuthUpdateOne { + _u.mutation.SetRefreshToken(v) + return _u +} + +// SetNillableRefreshToken sets the "refresh_token" field if the given value is not nil. +func (_u *UserThirdAuthUpdateOne) SetNillableRefreshToken(v *string) *UserThirdAuthUpdateOne { + if v != nil { + _u.SetRefreshToken(*v) + } + return _u +} + +// ClearRefreshToken clears the value of the "refresh_token" field. +func (_u *UserThirdAuthUpdateOne) ClearRefreshToken() *UserThirdAuthUpdateOne { + _u.mutation.ClearRefreshToken() + return _u +} + +// SetAccessTokenExpiry sets the "access_token_expiry" field. +func (_u *UserThirdAuthUpdateOne) SetAccessTokenExpiry(v time.Time) *UserThirdAuthUpdateOne { + _u.mutation.SetAccessTokenExpiry(v) + return _u +} + +// SetNillableAccessTokenExpiry sets the "access_token_expiry" field if the given value is not nil. +func (_u *UserThirdAuthUpdateOne) SetNillableAccessTokenExpiry(v *time.Time) *UserThirdAuthUpdateOne { + if v != nil { + _u.SetAccessTokenExpiry(*v) + } + return _u +} + +// ClearAccessTokenExpiry clears the value of the "access_token_expiry" field. +func (_u *UserThirdAuthUpdateOne) ClearAccessTokenExpiry() *UserThirdAuthUpdateOne { + _u.mutation.ClearAccessTokenExpiry() + return _u +} + +// SetUserInfo sets the "user_info" field. +func (_u *UserThirdAuthUpdateOne) SetUserInfo(v map[string]interface{}) *UserThirdAuthUpdateOne { + _u.mutation.SetUserInfo(v) + return _u +} + +// ClearUserInfo clears the value of the "user_info" field. +func (_u *UserThirdAuthUpdateOne) ClearUserInfo() *UserThirdAuthUpdateOne { + _u.mutation.ClearUserInfo() + return _u +} + +// SetPlatformUserID sets the "platform_user_id" field. +func (_u *UserThirdAuthUpdateOne) SetPlatformUserID(v string) *UserThirdAuthUpdateOne { + _u.mutation.SetPlatformUserID(v) + return _u +} + +// SetNillablePlatformUserID sets the "platform_user_id" field if the given value is not nil. +func (_u *UserThirdAuthUpdateOne) SetNillablePlatformUserID(v *string) *UserThirdAuthUpdateOne { + if v != nil { + _u.SetPlatformUserID(*v) + } + return _u +} + +// ClearPlatformUserID clears the value of the "platform_user_id" field. +func (_u *UserThirdAuthUpdateOne) ClearPlatformUserID() *UserThirdAuthUpdateOne { + _u.mutation.ClearPlatformUserID() + return _u +} + +// SetNickname sets the "nickname" field. +func (_u *UserThirdAuthUpdateOne) SetNickname(v string) *UserThirdAuthUpdateOne { + _u.mutation.SetNickname(v) + return _u +} + +// SetNillableNickname sets the "nickname" field if the given value is not nil. +func (_u *UserThirdAuthUpdateOne) SetNillableNickname(v *string) *UserThirdAuthUpdateOne { + if v != nil { + _u.SetNickname(*v) + } + return _u +} + +// ClearNickname clears the value of the "nickname" field. +func (_u *UserThirdAuthUpdateOne) ClearNickname() *UserThirdAuthUpdateOne { + _u.mutation.ClearNickname() + return _u +} + +// SetAvatar sets the "avatar" field. +func (_u *UserThirdAuthUpdateOne) SetAvatar(v string) *UserThirdAuthUpdateOne { + _u.mutation.SetAvatar(v) + return _u +} + +// SetNillableAvatar sets the "avatar" field if the given value is not nil. +func (_u *UserThirdAuthUpdateOne) SetNillableAvatar(v *string) *UserThirdAuthUpdateOne { + if v != nil { + _u.SetAvatar(*v) + } + return _u +} + +// ClearAvatar clears the value of the "avatar" field. +func (_u *UserThirdAuthUpdateOne) ClearAvatar() *UserThirdAuthUpdateOne { + _u.mutation.ClearAvatar() + return _u +} + +// SetEmail sets the "email" field. +func (_u *UserThirdAuthUpdateOne) SetEmail(v string) *UserThirdAuthUpdateOne { + _u.mutation.SetEmail(v) + return _u +} + +// SetNillableEmail sets the "email" field if the given value is not nil. +func (_u *UserThirdAuthUpdateOne) SetNillableEmail(v *string) *UserThirdAuthUpdateOne { + if v != nil { + _u.SetEmail(*v) + } + return _u +} + +// ClearEmail clears the value of the "email" field. +func (_u *UserThirdAuthUpdateOne) ClearEmail() *UserThirdAuthUpdateOne { + _u.mutation.ClearEmail() + return _u +} + +// SetPhone sets the "phone" field. +func (_u *UserThirdAuthUpdateOne) SetPhone(v string) *UserThirdAuthUpdateOne { + _u.mutation.SetPhone(v) + return _u +} + +// SetNillablePhone sets the "phone" field if the given value is not nil. +func (_u *UserThirdAuthUpdateOne) SetNillablePhone(v *string) *UserThirdAuthUpdateOne { + if v != nil { + _u.SetPhone(*v) + } + return _u +} + +// ClearPhone clears the value of the "phone" field. +func (_u *UserThirdAuthUpdateOne) ClearPhone() *UserThirdAuthUpdateOne { + _u.mutation.ClearPhone() + return _u +} + +// SetIsBound sets the "is_bound" field. +func (_u *UserThirdAuthUpdateOne) SetIsBound(v bool) *UserThirdAuthUpdateOne { + _u.mutation.SetIsBound(v) + return _u +} + +// SetNillableIsBound sets the "is_bound" field if the given value is not nil. +func (_u *UserThirdAuthUpdateOne) SetNillableIsBound(v *bool) *UserThirdAuthUpdateOne { + if v != nil { + _u.SetIsBound(*v) + } + return _u +} + +// SetBoundAt sets the "bound_at" field. +func (_u *UserThirdAuthUpdateOne) SetBoundAt(v time.Time) *UserThirdAuthUpdateOne { + _u.mutation.SetBoundAt(v) + return _u +} + +// SetNillableBoundAt sets the "bound_at" field if the given value is not nil. +func (_u *UserThirdAuthUpdateOne) SetNillableBoundAt(v *time.Time) *UserThirdAuthUpdateOne { + if v != nil { + _u.SetBoundAt(*v) + } + return _u +} + +// SetExtraData sets the "extra_data" field. +func (_u *UserThirdAuthUpdateOne) SetExtraData(v map[string]interface{}) *UserThirdAuthUpdateOne { + _u.mutation.SetExtraData(v) + return _u +} + +// ClearExtraData clears the value of the "extra_data" field. +func (_u *UserThirdAuthUpdateOne) ClearExtraData() *UserThirdAuthUpdateOne { + _u.mutation.ClearExtraData() + return _u +} + +// Mutation returns the UserThirdAuthMutation object of the builder. +func (_u *UserThirdAuthUpdateOne) Mutation() *UserThirdAuthMutation { + return _u.mutation +} + +// Where appends a list predicates to the UserThirdAuthUpdate builder. +func (_u *UserThirdAuthUpdateOne) Where(ps ...predicate.UserThirdAuth) *UserThirdAuthUpdateOne { + _u.mutation.Where(ps...) + return _u +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (_u *UserThirdAuthUpdateOne) Select(field string, fields ...string) *UserThirdAuthUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated UserThirdAuth entity. +func (_u *UserThirdAuthUpdateOne) Save(ctx context.Context) (*UserThirdAuth, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *UserThirdAuthUpdateOne) SaveX(ctx context.Context) *UserThirdAuth { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *UserThirdAuthUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *UserThirdAuthUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *UserThirdAuthUpdateOne) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := userthirdauth.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *UserThirdAuthUpdateOne) check() error { + if v, ok := _u.mutation.Openid(); ok { + if err := userthirdauth.OpenidValidator(v); err != nil { + return &ValidationError{Name: "openid", err: fmt.Errorf(`ent: validator failed for field "UserThirdAuth.openid": %w`, err)} + } + } + if v, ok := _u.mutation.Unionid(); ok { + if err := userthirdauth.UnionidValidator(v); err != nil { + return &ValidationError{Name: "unionid", err: fmt.Errorf(`ent: validator failed for field "UserThirdAuth.unionid": %w`, err)} + } + } + if v, ok := _u.mutation.AccessToken(); ok { + if err := userthirdauth.AccessTokenValidator(v); err != nil { + return &ValidationError{Name: "access_token", err: fmt.Errorf(`ent: validator failed for field "UserThirdAuth.access_token": %w`, err)} + } + } + if v, ok := _u.mutation.RefreshToken(); ok { + if err := userthirdauth.RefreshTokenValidator(v); err != nil { + return &ValidationError{Name: "refresh_token", err: fmt.Errorf(`ent: validator failed for field "UserThirdAuth.refresh_token": %w`, err)} + } + } + if v, ok := _u.mutation.PlatformUserID(); ok { + if err := userthirdauth.PlatformUserIDValidator(v); err != nil { + return &ValidationError{Name: "platform_user_id", err: fmt.Errorf(`ent: validator failed for field "UserThirdAuth.platform_user_id": %w`, err)} + } + } + if v, ok := _u.mutation.Nickname(); ok { + if err := userthirdauth.NicknameValidator(v); err != nil { + return &ValidationError{Name: "nickname", err: fmt.Errorf(`ent: validator failed for field "UserThirdAuth.nickname": %w`, err)} + } + } + if v, ok := _u.mutation.Avatar(); ok { + if err := userthirdauth.AvatarValidator(v); err != nil { + return &ValidationError{Name: "avatar", err: fmt.Errorf(`ent: validator failed for field "UserThirdAuth.avatar": %w`, err)} + } + } + if v, ok := _u.mutation.Email(); ok { + if err := userthirdauth.EmailValidator(v); err != nil { + return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "UserThirdAuth.email": %w`, err)} + } + } + if v, ok := _u.mutation.Phone(); ok { + if err := userthirdauth.PhoneValidator(v); err != nil { + return &ValidationError{Name: "phone", err: fmt.Errorf(`ent: validator failed for field "UserThirdAuth.phone": %w`, err)} + } + } + return nil +} + +func (_u *UserThirdAuthUpdateOne) sqlSave(ctx context.Context) (_node *UserThirdAuth, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(userthirdauth.Table, userthirdauth.Columns, sqlgraph.NewFieldSpec(userthirdauth.FieldID, field.TypeUint64)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "UserThirdAuth.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := _u.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, userthirdauth.FieldID) + for _, f := range fields { + if !userthirdauth.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != userthirdauth.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.UpdatedAt(); ok { + _spec.SetField(userthirdauth.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.Status(); ok { + _spec.SetField(userthirdauth.FieldStatus, field.TypeUint8, value) + } + if value, ok := _u.mutation.AddedStatus(); ok { + _spec.AddField(userthirdauth.FieldStatus, field.TypeUint8, value) + } + if _u.mutation.StatusCleared() { + _spec.ClearField(userthirdauth.FieldStatus, field.TypeUint8) + } + if value, ok := _u.mutation.DeletedAt(); ok { + _spec.SetField(userthirdauth.FieldDeletedAt, field.TypeTime, value) + } + if _u.mutation.DeletedAtCleared() { + _spec.ClearField(userthirdauth.FieldDeletedAt, field.TypeTime) + } + if value, ok := _u.mutation.UserID(); ok { + _spec.SetField(userthirdauth.FieldUserID, field.TypeUint64, value) + } + if value, ok := _u.mutation.AddedUserID(); ok { + _spec.AddField(userthirdauth.FieldUserID, field.TypeUint64, value) + } + if value, ok := _u.mutation.Openid(); ok { + _spec.SetField(userthirdauth.FieldOpenid, field.TypeString, value) + } + if value, ok := _u.mutation.Unionid(); ok { + _spec.SetField(userthirdauth.FieldUnionid, field.TypeString, value) + } + if _u.mutation.UnionidCleared() { + _spec.ClearField(userthirdauth.FieldUnionid, field.TypeString) + } + if value, ok := _u.mutation.AccessToken(); ok { + _spec.SetField(userthirdauth.FieldAccessToken, field.TypeString, value) + } + if _u.mutation.AccessTokenCleared() { + _spec.ClearField(userthirdauth.FieldAccessToken, field.TypeString) + } + if value, ok := _u.mutation.RefreshToken(); ok { + _spec.SetField(userthirdauth.FieldRefreshToken, field.TypeString, value) + } + if _u.mutation.RefreshTokenCleared() { + _spec.ClearField(userthirdauth.FieldRefreshToken, field.TypeString) + } + if value, ok := _u.mutation.AccessTokenExpiry(); ok { + _spec.SetField(userthirdauth.FieldAccessTokenExpiry, field.TypeTime, value) + } + if _u.mutation.AccessTokenExpiryCleared() { + _spec.ClearField(userthirdauth.FieldAccessTokenExpiry, field.TypeTime) + } + if value, ok := _u.mutation.UserInfo(); ok { + _spec.SetField(userthirdauth.FieldUserInfo, field.TypeJSON, value) + } + if _u.mutation.UserInfoCleared() { + _spec.ClearField(userthirdauth.FieldUserInfo, field.TypeJSON) + } + if value, ok := _u.mutation.PlatformUserID(); ok { + _spec.SetField(userthirdauth.FieldPlatformUserID, field.TypeString, value) + } + if _u.mutation.PlatformUserIDCleared() { + _spec.ClearField(userthirdauth.FieldPlatformUserID, field.TypeString) + } + if value, ok := _u.mutation.Nickname(); ok { + _spec.SetField(userthirdauth.FieldNickname, field.TypeString, value) + } + if _u.mutation.NicknameCleared() { + _spec.ClearField(userthirdauth.FieldNickname, field.TypeString) + } + if value, ok := _u.mutation.Avatar(); ok { + _spec.SetField(userthirdauth.FieldAvatar, field.TypeString, value) + } + if _u.mutation.AvatarCleared() { + _spec.ClearField(userthirdauth.FieldAvatar, field.TypeString) + } + if value, ok := _u.mutation.Email(); ok { + _spec.SetField(userthirdauth.FieldEmail, field.TypeString, value) + } + if _u.mutation.EmailCleared() { + _spec.ClearField(userthirdauth.FieldEmail, field.TypeString) + } + if value, ok := _u.mutation.Phone(); ok { + _spec.SetField(userthirdauth.FieldPhone, field.TypeString, value) + } + if _u.mutation.PhoneCleared() { + _spec.ClearField(userthirdauth.FieldPhone, field.TypeString) + } + if value, ok := _u.mutation.IsBound(); ok { + _spec.SetField(userthirdauth.FieldIsBound, field.TypeBool, value) + } + if value, ok := _u.mutation.BoundAt(); ok { + _spec.SetField(userthirdauth.FieldBoundAt, field.TypeTime, value) + } + if value, ok := _u.mutation.ExtraData(); ok { + _spec.SetField(userthirdauth.FieldExtraData, field.TypeJSON, value) + } + if _u.mutation.ExtraDataCleared() { + _spec.ClearField(userthirdauth.FieldExtraData, field.TypeJSON) + } + _node = &UserThirdAuth{config: _u.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{userthirdauth.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} diff --git a/rpc/etc/app.yaml b/rpc/etc/app.yaml new file mode 100644 index 0000000..49521e2 --- /dev/null +++ b/rpc/etc/app.yaml @@ -0,0 +1,42 @@ +Name: rpc.rpc +ListenOn: 0.0.0.0:8080 + + +DatabaseConf: + Type: postgres + Host: 192.168.201.188 + Port: 5432 + DBName: Lei_app_dev + Username: postgres + Password: AM38xymTdFree4Fh + MaxOpenConn: 100 + SSLMode: disable + CacheTime: 5 + # 添加以下配置启用 SQL 日志 + Debug: true + LogSlowThreshold: 600ms + + +jwt: + access_token_secret: your-super-secret-access-token-key-change-in-production + refresh_token_secret: your-super-secret-refresh-token-key-change-in-production + access_token_expiry: 24h + refresh_token_expiry: 720h + issuer: user-system + + + +RedisConf: + Host: 192.168.201.58:6379 + Db: 1 + +Log: + ServiceName: appRpcLogger + Mode: console + Path: /home/data/logs/app/rpc + Encoding: json + Level: info + Compress: false + KeepDays: 7 + StackCoolDownMillis: 100 + diff --git a/rpc/etc/rpc.yaml b/rpc/etc/rpc.yaml deleted file mode 100644 index 04a62cb..0000000 --- a/rpc/etc/rpc.yaml +++ /dev/null @@ -1,6 +0,0 @@ -Name: rpc.rpc -ListenOn: 0.0.0.0:8080 -Etcd: - Hosts: - - 127.0.0.1:2379 - Key: rpc.rpc diff --git a/rpc/go.mod b/rpc/go.mod index e9bd2ab..3843094 100644 --- a/rpc/go.mod +++ b/rpc/go.mod @@ -1,92 +1,135 @@ -module mingyang-admin-iot-app/rpc +module mingyang-admin-app-rpc go 1.25.3 require ( - github.com/zeromicro/go-zero v1.9.3 - google.golang.org/grpc v1.77.0 + entgo.io/ent v0.14.5 + github.com/go-redis/redis/v8 v8.11.5 + github.com/golang-jwt/jwt/v5 v5.3.0 + github.com/ip2location/ip2location-go/v9 v9.8.0 + github.com/redis/go-redis/v9 v9.16.0 + github.com/saas-mingyang/mingyang-admin-common v0.3.3 + github.com/zeromicro/go-zero v1.9.1 + golang.org/x/crypto v0.44.0 + google.golang.org/grpc v1.76.0 google.golang.org/protobuf v1.36.10 ) require ( + filippo.io/edwards25519 v1.1.0 // indirect + github.com/go-sql-driver/mysql v1.9.3 // indirect + github.com/lib/pq v1.10.9 // indirect + github.com/mattn/go-sqlite3 v1.14.32 // indirect + lukechampine.com/uint128 v1.2.0 // indirect +) + +require ( + ariga.io/atlas v0.38.0 // indirect + github.com/agext/levenshtein v1.2.3 // indirect + github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect github.com/beorn7/perks v1.0.1 // indirect - github.com/cenkalti/backoff/v4 v4.3.0 // indirect + github.com/bmatcuk/doublestar v1.3.4 // indirect + github.com/cenkalti/backoff/v5 v5.0.3 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/coreos/go-semver v0.3.1 // indirect - github.com/coreos/go-systemd/v22 v22.5.0 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect + github.com/coreos/go-systemd/v22 v22.6.0 // indirect + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect - github.com/emicklei/go-restful/v3 v3.11.0 // indirect + github.com/emicklei/go-restful/v3 v3.13.0 // indirect github.com/fatih/color v1.18.0 // indirect + github.com/fxamacker/cbor/v2 v2.9.0 // indirect github.com/go-logr/logr v1.4.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect - github.com/go-openapi/jsonpointer v0.19.6 // indirect - github.com/go-openapi/jsonreference v0.20.2 // indirect - github.com/go-openapi/swag v0.22.4 // indirect + github.com/go-openapi/inflect v0.21.3 // indirect; indirectf + github.com/go-openapi/jsonpointer v0.22.1 // indirect + github.com/go-openapi/jsonreference v0.21.2 // indirect + github.com/go-openapi/swag v0.25.1 // indirect + github.com/go-openapi/swag/cmdutils v0.25.1 // indirect + github.com/go-openapi/swag/conv v0.25.1 // indirect + github.com/go-openapi/swag/fileutils v0.25.1 // indirect + github.com/go-openapi/swag/jsonname v0.25.1 // indirect + github.com/go-openapi/swag/jsonutils v0.25.1 // indirect + github.com/go-openapi/swag/loading v0.25.1 // indirect + github.com/go-openapi/swag/mangling v0.25.1 // indirect + github.com/go-openapi/swag/netutils v0.25.1 // indirect + github.com/go-openapi/swag/stringutils v0.25.1 // indirect + github.com/go-openapi/swag/typeutils v0.25.1 // indirect + github.com/go-openapi/swag/yamlutils v0.25.1 // indirect + github.com/gofrs/uuid/v5 v5.4.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.5.4 // indirect - github.com/google/gnostic-models v0.6.8 // indirect + github.com/google/gnostic-models v0.7.0 // indirect github.com/google/go-cmp v0.7.0 // indirect - github.com/google/gofuzz v1.2.0 // indirect github.com/google/uuid v1.6.0 // indirect github.com/grafana/pyroscope-go v1.2.7 // indirect github.com/grafana/pyroscope-go/godeltaprof v0.1.9 // indirect - github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect - github.com/josharian/intern v1.0.0 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3 // indirect + github.com/hashicorp/hcl/v2 v2.24.0 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/klauspost/compress v1.17.11 // indirect - github.com/mailru/easyjson v0.7.7 // indirect - github.com/mattn/go-colorable v0.1.13 // indirect + github.com/klauspost/compress v1.18.1 // indirect + github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect + github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect - github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // 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.21.1 // indirect - github.com/prometheus/client_model v0.6.1 // indirect - github.com/prometheus/common v0.62.0 // indirect - github.com/prometheus/procfs v0.15.1 // indirect - github.com/redis/go-redis/v9 v9.16.0 // indirect + github.com/pelletier/go-toml/v2 v2.2.4 // indirect + github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect + github.com/prometheus/client_golang v1.23.2 // indirect + github.com/prometheus/client_model v0.6.2 // indirect + github.com/prometheus/common v0.67.2 // indirect + github.com/prometheus/procfs v0.19.2 // indirect + github.com/saas-mingyang/mingyang-admin-core v0.0.0-20251107040124-c97a0a448793 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect - go.etcd.io/etcd/api/v3 v3.5.15 // indirect - go.etcd.io/etcd/client/pkg/v3 v3.5.15 // indirect - go.etcd.io/etcd/client/v3 v3.5.15 // indirect + github.com/x448/float16 v0.8.4 // indirect + github.com/zclconf/go-cty v1.17.0 // indirect + github.com/zclconf/go-cty-yaml v1.1.0 // indirect + go.etcd.io/etcd/api/v3 v3.6.5 // indirect + go.etcd.io/etcd/client/pkg/v3 v3.6.5 // indirect + go.etcd.io/etcd/client/v3 v3.6.5 // indirect go.opentelemetry.io/auto/sdk v1.2.1 // indirect go.opentelemetry.io/otel v1.38.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/exporters/otlp/otlptrace v1.38.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.38.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.38.0 // indirect + go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.38.0 // indirect + go.opentelemetry.io/otel/exporters/zipkin v1.38.0 // indirect go.opentelemetry.io/otel/metric v1.38.0 // indirect go.opentelemetry.io/otel/sdk v1.38.0 // indirect go.opentelemetry.io/otel/trace v1.38.0 // indirect - go.opentelemetry.io/proto/otlp v1.3.1 // indirect - go.uber.org/atomic v1.10.0 // indirect + go.opentelemetry.io/proto/otlp v1.9.0 // indirect go.uber.org/automaxprocs v1.6.0 // indirect - go.uber.org/mock v0.4.0 // indirect - go.uber.org/multierr v1.9.0 // indirect - go.uber.org/zap v1.24.0 // indirect - golang.org/x/net v0.46.1-0.20251013234738-63d1a5100f82 // indirect + go.uber.org/mock v0.6.0 // indirect + go.uber.org/multierr v1.11.0 // indirect + go.uber.org/zap v1.27.0 // indirect + go.yaml.in/yaml/v2 v2.4.3 // indirect + go.yaml.in/yaml/v3 v3.0.4 // indirect + golang.org/x/mod v0.30.0 // indirect + golang.org/x/net v0.47.0 // indirect golang.org/x/oauth2 v0.32.0 // indirect - golang.org/x/sys v0.37.0 // indirect - golang.org/x/term v0.36.0 // indirect - golang.org/x/text v0.30.0 // indirect - golang.org/x/time v0.10.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20251022142026-3a174f9686a8 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20251022142026-3a174f9686a8 // indirect + golang.org/x/sync v0.18.0 // indirect + golang.org/x/sys v0.38.0 // indirect + golang.org/x/term v0.37.0 // indirect + golang.org/x/text v0.31.0 // indirect + golang.org/x/time v0.14.0 // indirect + golang.org/x/tools v0.39.0 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20251111163417-95abcf5c77ba // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20251111163417-95abcf5c77ba // indirect + gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/api v0.29.3 // indirect - k8s.io/apimachinery v0.29.4 // indirect - k8s.io/client-go v0.29.3 // indirect - k8s.io/klog/v2 v2.110.1 // indirect - k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect - k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect - sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect - sigs.k8s.io/yaml v1.3.0 // indirect + k8s.io/api v0.34.1 // indirect + k8s.io/apimachinery v0.34.1 // indirect + k8s.io/client-go v0.34.1 // indirect + k8s.io/klog/v2 v2.130.1 // indirect + k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 // indirect + k8s.io/utils v0.0.0-20251002143259-bc988d571ff4 // indirect + sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect + sigs.k8s.io/randfill v1.0.0 // indirect + sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect + sigs.k8s.io/yaml v1.6.0 // indirect ) + +replace github.com/zeromicro/go-zero v1.9.1 => github.com/suyuan32/simple-admin-tools v1.9.1 diff --git a/rpc/go.sum b/rpc/go.sum new file mode 100644 index 0000000..3e1e837 --- /dev/null +++ b/rpc/go.sum @@ -0,0 +1,353 @@ +ariga.io/atlas v0.38.0 h1:MwbtwVtDWJFq+ECyeTAz2ArvewDnpeiw/t/sgNdDsdo= +ariga.io/atlas v0.38.0/go.mod h1:D7XMK6ei3GvfDqvzk+2VId78j77LdqHrqPOWamn51/s= +entgo.io/ent v0.14.5 h1:Rj2WOYJtCkWyFo6a+5wB3EfBRP0rnx1fMk6gGA0UUe4= +entgo.io/ent v0.14.5/go.mod h1:zTzLmWtPvGpmSwtkaayM2cm5m819NdM7z7tYPq3vN0U= +filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= +filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= +github.com/DATA-DOG/go-sqlmock v1.5.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.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= +github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= +github.com/alicebob/miniredis/v2 v2.35.0 h1:QwLphYqCEAo1eu1TqPRN2jgVMPBweeQcR21jeqDCONI= +github.com/alicebob/miniredis/v2 v2.35.0/go.mod h1:TcL7YfarKPGDAthEtl5NBeHZfeUQj6OXMm/+iu5cLMM= +github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY= +github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bmatcuk/doublestar v1.3.4 h1:gPypJ5xD31uhX6Tf54sDPUOBXTqKH4c9aPY66CyQrS0= +github.com/bmatcuk/doublestar v1.3.4/go.mod h1:wiQtGV+rzVYxB7WIlirSN++5HPtPlXEo9MEoZQC/PmE= +github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs= +github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c= +github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA= +github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0= +github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1xcsSM= +github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw= +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/clipperhouse/uax29/v2 v2.2.0 h1:ChwIKnQN3kcZteTXMgb1wztSgaU+ZemkgWdohwgs8tY= +github.com/clipperhouse/uax29/v2 v2.2.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJSwu5BF98AuoVM= +github.com/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr4= +github.com/coreos/go-semver v0.3.1/go.mod h1:irMmmIw/7yzSRPWryHsK7EYSg09caPQL03VsM8rvUec= +github.com/coreos/go-systemd/v22 v22.6.0 h1:aGVa/v8B7hpb0TKl0MWoAavPDmHvobFe5R5zn0bCJWo= +github.com/coreos/go-systemd/v22 v22.6.0/go.mod h1:iG+pp635Fo7ZmV/j14KUcmEyWF+0X7Lua8rrTWzYgWU= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= +github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= +github.com/emicklei/go-restful/v3 v3.13.0 h1:C4Bl2xDndpU6nJ4bc1jXd+uTmYPVUwkD6bFY/oTyCes= +github.com/emicklei/go-restful/v3 v3.13.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= +github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= +github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/fxamacker/cbor/v2 v2.9.0 h1:NpKPmjDBgUfBms6tr6JZkTHtfFGcMKsw3eGcmD/sapM= +github.com/fxamacker/cbor/v2 v2.9.0/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= +github.com/go-logr/logr v1.4.3/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.21.3 h1:TmQvw+9eLrsNp4X0BBQacEZZtAnzk2z1FaLdQQJsDiU= +github.com/go-openapi/inflect v0.21.3/go.mod h1:INezMuUu7SJQc2AyR3WO0DqqYUJSj8Kb4hBd7WtjlAw= +github.com/go-openapi/jsonpointer v0.22.1 h1:sHYI1He3b9NqJ4wXLoJDKmUmHkWy/L7rtEo92JUxBNk= +github.com/go-openapi/jsonpointer v0.22.1/go.mod h1:pQT9OsLkfz1yWoMgYFy4x3U5GY5nUlsOn1qSBH5MkCM= +github.com/go-openapi/jsonreference v0.21.2 h1:Wxjda4M/BBQllegefXrY/9aq1fxBA8sI5M/lFU6tSWU= +github.com/go-openapi/jsonreference v0.21.2/go.mod h1:pp3PEjIsJ9CZDGCNOyXIQxsNuroxm8FAJ/+quA0yKzQ= +github.com/go-openapi/swag v0.25.1 h1:6uwVsx+/OuvFVPqfQmOOPsqTcm5/GkBhNwLqIR916n8= +github.com/go-openapi/swag v0.25.1/go.mod h1:bzONdGlT0fkStgGPd3bhZf1MnuPkf2YAys6h+jZipOo= +github.com/go-openapi/swag/cmdutils v0.25.1 h1:nDke3nAFDArAa631aitksFGj2omusks88GF1VwdYqPY= +github.com/go-openapi/swag/cmdutils v0.25.1/go.mod h1:pdae/AFo6WxLl5L0rq87eRzVPm/XRHM3MoYgRMvG4A0= +github.com/go-openapi/swag/conv v0.25.1 h1:+9o8YUg6QuqqBM5X6rYL/p1dpWeZRhoIt9x7CCP+he0= +github.com/go-openapi/swag/conv v0.25.1/go.mod h1:Z1mFEGPfyIKPu0806khI3zF+/EUXde+fdeksUl2NiDs= +github.com/go-openapi/swag/fileutils v0.25.1 h1:rSRXapjQequt7kqalKXdcpIegIShhTPXx7yw0kek2uU= +github.com/go-openapi/swag/fileutils v0.25.1/go.mod h1:+NXtt5xNZZqmpIpjqcujqojGFek9/w55b3ecmOdtg8M= +github.com/go-openapi/swag/jsonname v0.25.1 h1:Sgx+qbwa4ej6AomWC6pEfXrA6uP2RkaNjA9BR8a1RJU= +github.com/go-openapi/swag/jsonname v0.25.1/go.mod h1:71Tekow6UOLBD3wS7XhdT98g5J5GR13NOTQ9/6Q11Zo= +github.com/go-openapi/swag/jsonutils v0.25.1 h1:AihLHaD0brrkJoMqEZOBNzTLnk81Kg9cWr+SPtxtgl8= +github.com/go-openapi/swag/jsonutils v0.25.1/go.mod h1:JpEkAjxQXpiaHmRO04N1zE4qbUEg3b7Udll7AMGTNOo= +github.com/go-openapi/swag/jsonutils/fixtures_test v0.25.1 h1:DSQGcdB6G0N9c/KhtpYc71PzzGEIc/fZ1no35x4/XBY= +github.com/go-openapi/swag/jsonutils/fixtures_test v0.25.1/go.mod h1:kjmweouyPwRUEYMSrbAidoLMGeJ5p6zdHi9BgZiqmsg= +github.com/go-openapi/swag/loading v0.25.1 h1:6OruqzjWoJyanZOim58iG2vj934TysYVptyaoXS24kw= +github.com/go-openapi/swag/loading v0.25.1/go.mod h1:xoIe2EG32NOYYbqxvXgPzne989bWvSNoWoyQVWEZicc= +github.com/go-openapi/swag/mangling v0.25.1 h1:XzILnLzhZPZNtmxKaz/2xIGPQsBsvmCjrJOWGNz/ync= +github.com/go-openapi/swag/mangling v0.25.1/go.mod h1:CdiMQ6pnfAgyQGSOIYnZkXvqhnnwOn997uXZMAd/7mQ= +github.com/go-openapi/swag/netutils v0.25.1 h1:2wFLYahe40tDUHfKT1GRC4rfa5T1B4GWZ+msEFA4Fl4= +github.com/go-openapi/swag/netutils v0.25.1/go.mod h1:CAkkvqnUJX8NV96tNhEQvKz8SQo2KF0f7LleiJwIeRE= +github.com/go-openapi/swag/stringutils v0.25.1 h1:Xasqgjvk30eUe8VKdmyzKtjkVjeiXx1Iz0zDfMNpPbw= +github.com/go-openapi/swag/stringutils v0.25.1/go.mod h1:JLdSAq5169HaiDUbTvArA2yQxmgn4D6h4A+4HqVvAYg= +github.com/go-openapi/swag/typeutils v0.25.1 h1:rD/9HsEQieewNt6/k+JBwkxuAHktFtH3I3ysiFZqukA= +github.com/go-openapi/swag/typeutils v0.25.1/go.mod h1:9McMC/oCdS4BKwk2shEB7x17P6HmMmA6dQRtAkSnNb8= +github.com/go-openapi/swag/yamlutils v0.25.1 h1:mry5ez8joJwzvMbaTGLhw8pXUnhDK91oSJLDPF1bmGk= +github.com/go-openapi/swag/yamlutils v0.25.1/go.mod h1:cm9ywbzncy3y6uPm/97ysW8+wZ09qsks+9RS8fLWKqg= +github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI= +github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo= +github.com/go-sql-driver/mysql v1.9.3 h1:U/N249h2WzJ3Ukj8SowVFjdtZKfu9vlLZxjPXV1aweo= +github.com/go-sql-driver/mysql v1.9.3/go.mod h1:qn46aNg1333BRMNU69Lq93t8du/dwxI64Gl8i5p1WMU= +github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= +github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= +github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= +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/gofrs/uuid/v5 v5.4.0 h1:EfbpCTjqMuGyq5ZJwxqzn3Cbr2d0rUZU7v5ycAk/e/0= +github.com/gofrs/uuid/v5 v5.4.0/go.mod h1:CDOjlDMVAtN56jqyRUZh58JT31Tiw7/oQyEXZV+9bD8= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo= +github.com/golang-jwt/jwt/v5 v5.3.0/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/google/gnostic-models v0.7.0 h1:qwTtogB15McXDaNqTZdzPJRHvaVJlAl+HVQnLmJEJxo= +github.com/google/gnostic-models v0.7.0/go.mod h1:whL5G0m6dmc5cPxKc5bdKdEN3UjI7OUGxBlw57miDrQ= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgYQBbFN4U4JNXUNYpxael3UzMyo= +github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= +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/grafana/pyroscope-go v1.2.7 h1:VWBBlqxjyR0Cwk2W6UrE8CdcdD80GOFNutj0Kb1T8ac= +github.com/grafana/pyroscope-go v1.2.7/go.mod h1:o/bpSLiJYYP6HQtvcoVKiE9s5RiNgjYTj1DhiddP2Pc= +github.com/grafana/pyroscope-go/godeltaprof v0.1.9 h1:c1Us8i6eSmkW+Ez05d3co8kasnuOY813tbMN8i/a3Og= +github.com/grafana/pyroscope-go/godeltaprof v0.1.9/go.mod h1:2+l7K7twW49Ct4wFluZD3tZ6e0SjanjcUUBPVD/UuGU= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3 h1:NmZ1PKzSTQbuGHw9DGPFomqkkLWMC+vZCkfs+FHv1Vg= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3/go.mod h1:zQrxl1YP88HQlA6i9c63DSVPFklWpGX4OWAc9bFuaH4= +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.24.0 h1:2QJdZ454DSsYGoaE6QheQZjtKZSUs9Nh2izTWiwQxvE= +github.com/hashicorp/hcl/v2 v2.24.0/go.mod h1:oGoO1FIQYfn/AgyOhlg9qLC6/nOJPX3qGbkZpYAcqfM= +github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= +github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/ip2location/ip2location-go/v9 v9.8.0 h1:drPzGjj1EBl45I33ErMHFtIfsQ3mR85dAQbqMDbi9mc= +github.com/ip2location/ip2location-go/v9 v9.8.0/go.mod h1:MPLnsKxwQlvd2lBNcQCsLoyzJLDBFizuO67wXXdzoyI= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co= +github.com/klauspost/compress v1.18.1/go.mod h1:ZQFFVG+MdnR0P+l6wpXgIL4NTtwiKIdBnrBd8Nrxr+0= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= +github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= +github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-runewidth v0.0.19 h1:v++JhqYnZuu5jSKrk9RbgF5v4CGUjqRfBm05byFGLdw= +github.com/mattn/go-runewidth v0.0.19/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs= +github.com/mattn/go-sqlite3 v1.14.32 h1:JD12Ag3oLy1zQA+BNn74xRgaBbdhbNIDYvQUEuuErjs= +github.com/mattn/go-sqlite3 v1.14.32/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= +github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= +github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee h1:W5t00kpgFdJifH4BDsTlE89Zl93FEloxaWZfGcifgq8= +github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +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/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= +github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= +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/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= +github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= +github.com/onsi/ginkgo/v2 v2.21.0 h1:7rg/4f3rB88pb5obDgNZrNHrQ4e6WpjonchcpuBRnZM= +github.com/onsi/ginkgo/v2 v2.21.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo= +github.com/onsi/gomega v1.35.1 h1:Cwbd75ZBPxFSuZ6T+rN/WCb/gOc6YgFBXLlZLhC7Ds4= +github.com/onsi/gomega v1.35.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog= +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.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4= +github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/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.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h0RJWRi/o0o= +github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg= +github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk= +github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE= +github.com/prometheus/common v0.67.2 h1:PcBAckGFTIHt2+L3I33uNRTlKTplNzFctXcWhPyAEN8= +github.com/prometheus/common v0.67.2/go.mod h1:63W3KZb1JOKgcjlIr64WW/LvFGAqKPj0atm+knVGEko= +github.com/prometheus/procfs v0.19.2 h1:zUMhqEW66Ex7OXIiDkll3tl9a1ZdilUOd/F6ZXw4Vws= +github.com/prometheus/procfs v0.19.2/go.mod h1:M0aotyiemPhBCM0z5w87kL22CxfcH05ZpYlu+b4J7mw= +github.com/redis/go-redis/v9 v9.16.0 h1:OotgqgLSRCmzfqChbQyG1PHC3tLNR89DG4jdOERSEP4= +github.com/redis/go-redis/v9 v9.16.0/go.mod h1:u410H11HMLoB+TP67dz8rL9s6QW2j76l0//kSOd3370= +github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= +github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= +github.com/saas-mingyang/mingyang-admin-common v0.3.3 h1:Pe1IYBaE7v541WKnEFPwiOC9yMzhmvVQ4+rSfRdEC1M= +github.com/saas-mingyang/mingyang-admin-common v0.3.3/go.mod h1:mAweT+3C08LGdr14AQNz9Sx5COPEpTtL6dr5fQAKqWc= +github.com/saas-mingyang/mingyang-admin-core v0.0.0-20251107040124-c97a0a448793 h1:wSJjRdeAIX++S1lDSInYlIPg6OyPKCakHBJTNG683RI= +github.com/saas-mingyang/mingyang-admin-core v0.0.0-20251107040124-c97a0a448793/go.mod h1:wMcbdgNDZ+ZNB4inJb68MD2vAJ2iintwm3EYQn4F7Sc= +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.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o= +github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +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.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= +github.com/suyuan32/simple-admin-tools v1.9.1 h1:RRFT2Dn22H/b0A4aB+ixul/6xzmTFXG10ER64DuCS0A= +github.com/suyuan32/simple-admin-tools v1.9.1/go.mod h1:v3y8WAJTCt+g/+Ve0BZuSga38gwdDh/2WNuvve9Tz2Y= +github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= +github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M= +github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw= +github.com/zclconf/go-cty v1.17.0 h1:seZvECve6XX4tmnvRzWtJNHdscMtYEx5R7bnnVyd/d0= +github.com/zclconf/go-cty v1.17.0/go.mod h1:wqFzcImaLTI6A5HfsRwB0nj5n0MRZFwmey8YoFPPs3U= +github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940 h1:4r45xpDWB6ZMSMNJFMOjqrGHynW3DIBuR2H9j0ug+Mo= +github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940/go.mod h1:CmBdvvj3nqzfzJ6nTCIwDTPZ56aVGvDrmztiO5g3qrM= +github.com/zclconf/go-cty-yaml v1.1.0 h1:nP+jp0qPHv2IhUVqmQSzjvqAWcObN0KBkUl2rWBdig0= +github.com/zclconf/go-cty-yaml v1.1.0/go.mod h1:9YLUH4g7lOhVWqUbctnVlZ5KLpg7JAprQNgxSZ1Gyxs= +go.etcd.io/etcd/api/v3 v3.6.5 h1:pMMc42276sgR1j1raO/Qv3QI9Af/AuyQUW6CBAWuntA= +go.etcd.io/etcd/api/v3 v3.6.5/go.mod h1:ob0/oWA/UQQlT1BmaEkWQzI0sJ1M0Et0mMpaABxguOQ= +go.etcd.io/etcd/client/pkg/v3 v3.6.5 h1:Duz9fAzIZFhYWgRjp/FgNq2gO1jId9Yae/rLn3RrBP8= +go.etcd.io/etcd/client/pkg/v3 v3.6.5/go.mod h1:8Wx3eGRPiy0qOFMZT/hfvdos+DjEaPxdIDiCDUv/FQk= +go.etcd.io/etcd/client/v3 v3.6.5 h1:yRwZNFBx/35VKHTcLDeO7XVLbCBFbPi+XV4OC3QJf2U= +go.etcd.io/etcd/client/v3 v3.6.5/go.mod h1:ZqwG/7TAFZ0BJ0jXRPoJjKQJtbFo/9NIY8uoFFKcCyo= +go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64= +go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y= +go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= +go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.38.0 h1:GqRJVj7UmLjCVyVJ3ZFLdPRmhDUp2zFmQe3RHIOsw24= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.38.0/go.mod h1:ri3aaHSmCTVYu2AWv44YMauwAQc0aqI9gHKIcSbI1pU= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.38.0 h1:lwI4Dc5leUqENgGuQImwLo4WnuXFPetmPpkLi2IrX54= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.38.0/go.mod h1:Kz/oCE7z5wuyhPxsXDuaPteSWqjSBD5YaSdbxZYGbGk= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.38.0 h1:aTL7F04bJHUlztTsNGJ2l+6he8c+y/b//eR0jjjemT4= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.38.0/go.mod h1:kldtb7jDTeol0l3ewcmd8SDvx3EmIE7lyvqbasU3QC4= +go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.38.0 h1:kJxSDN4SgWWTjG/hPp3O7LCGLcHXFlvS2/FFOrwL+SE= +go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.38.0/go.mod h1:mgIOzS7iZeKJdeB8/NYHrJ48fdGc71Llo5bJ1J4DWUE= +go.opentelemetry.io/otel/exporters/zipkin v1.38.0 h1:0rJ2TmzpHDG+Ib9gPmu3J3cE0zXirumQcKS4wCoZUa0= +go.opentelemetry.io/otel/exporters/zipkin v1.38.0/go.mod h1:Su/nq/K5zRjDKKC3Il0xbViE3juWgG3JDoqLumFx5G0= +go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA= +go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI= +go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E= +go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg= +go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM= +go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA= +go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE= +go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs= +go.opentelemetry.io/proto/otlp v1.9.0 h1:l706jCMITVouPOqEnii2fIAuO3IVGBRPV5ICjceRb/A= +go.opentelemetry.io/proto/otlp v1.9.0/go.mod h1:xE+Cx5E/eEHw+ISFkwPLwCZefwVjY+pqKg1qcK03+/4= +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= +go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y= +go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= +go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= +go.yaml.in/yaml/v2 v2.4.3 h1:6gvOSjQoTB3vt1l+CU+tSyi/HOjfOjRLJ4YwYZGwRO0= +go.yaml.in/yaml/v2 v2.4.3/go.mod h1:zSxWcmIDjOzPXpjlTTbAsKokqkDNAVtZO0WOMiT90s8= +go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= +go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.44.0 h1:A97SsFvM3AIwEEmTBiaxPPTYpDC47w720rdiiUvgoAU= +golang.org/x/crypto v0.44.0/go.mod h1:013i+Nw79BMiQiMsOPcVCB5ZIJbYkerPrGnOa00tvmc= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.30.0 h1:fDEXFVZ/fmCKProc/yAXXUijritrDzahmwwefnjoPFk= +golang.org/x/mod v0.30.0/go.mod h1:lAsf5O2EvJeSFMiBxXDki7sCgAxEUcZHXoXMKT4GJKc= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY= +golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU= +golang.org/x/oauth2 v0.32.0 h1:jsCblLleRMDrxMN29H3z/k1KliIvpLgCkE6R8FXXNgY= +golang.org/x/oauth2 v0.32.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I= +golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= +golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/term v0.37.0 h1:8EGAD0qCmHYZg6J17DvsMy9/wJ7/D/4pV/wfnld5lTU= +golang.org/x/term v0.37.0/go.mod h1:5pB4lxRNYYVZuTLmy8oR2BH8dflOR+IbTYFD8fi3254= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM= +golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM= +golang.org/x/time v0.14.0 h1:MRx4UaLrDotUKUdCIqzPC48t1Y9hANFKIRpNx+Te8PI= +golang.org/x/time v0.14.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.39.0 h1:ik4ho21kwuQln40uelmciQPp9SipgNDdrafrYA4TmQQ= +golang.org/x/tools v0.39.0/go.mod h1:JnefbkDPyD8UU2kI5fuf8ZX4/yUeh9W877ZeBONxUqQ= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= +gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= +google.golang.org/genproto/googleapis/api v0.0.0-20251111163417-95abcf5c77ba h1:B14OtaXuMaCQsl2deSvNkyPKIzq3BjfxQp8d00QyWx4= +google.golang.org/genproto/googleapis/api v0.0.0-20251111163417-95abcf5c77ba/go.mod h1:G5IanEx8/PgI9w6CFcYQf7jMtHQhZruvfM1i3qOqk5U= +google.golang.org/genproto/googleapis/rpc v0.0.0-20251111163417-95abcf5c77ba h1:UKgtfRM7Yh93Sya0Fo8ZzhDP4qBckrrxEr2oF5UIVb8= +google.golang.org/genproto/googleapis/rpc v0.0.0-20251111163417-95abcf5c77ba/go.mod h1:7i2o+ce6H/6BluujYR+kqX3GKH+dChPTQU19wjRPiGk= +google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= +google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c= +google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= +google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/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/evanphx/json-patch.v4 v4.13.0 h1:czT3CmqEaQ1aanPc5SdlgQrrEIb8w/wwCvWWnfEbYzo= +gopkg.in/evanphx/json-patch.v4 v4.13.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M= +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/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= +gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +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.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +k8s.io/api v0.34.1 h1:jC+153630BMdlFukegoEL8E/yT7aLyQkIVuwhmwDgJM= +k8s.io/api v0.34.1/go.mod h1:SB80FxFtXn5/gwzCoN6QCtPD7Vbu5w2n1S0J5gFfTYk= +k8s.io/apimachinery v0.34.1 h1:dTlxFls/eikpJxmAC7MVE8oOeP1zryV7iRyIjB0gky4= +k8s.io/apimachinery v0.34.1/go.mod h1:/GwIlEcWuTX9zKIg2mbw0LRFIsXwrfoVxn+ef0X13lw= +k8s.io/client-go v0.34.1 h1:ZUPJKgXsnKwVwmKKdPfw4tB58+7/Ik3CrjOEhsiZ7mY= +k8s.io/client-go v0.34.1/go.mod h1:kA8v0FP+tk6sZA0yKLRG67LWjqufAoSHA2xVGKw9Of8= +k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= +k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= +k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 h1:Y3gxNAuB0OBLImH611+UDZcmKS3g6CthxToOb37KgwE= +k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912/go.mod h1:kdmbQkyfwUagLfXIad1y2TdrjPFWp2Q89B3qkRwf/pQ= +k8s.io/utils v0.0.0-20251002143259-bc988d571ff4 h1:SjGebBtkBqHFOli+05xYbK8YF1Dzkbzn+gDM4X9T4Ck= +k8s.io/utils v0.0.0-20251002143259-bc988d571ff4/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +lukechampine.com/uint128 v1.2.0 h1:mBi/5l91vocEN8otkC5bDLhi2KdCticRiwbdB0O+rjI= +lukechampine.com/uint128 v1.2.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= +sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 h1:IpInykpT6ceI+QxKBbEflcR5EXP7sU1kvOlxwZh5txg= +sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730/go.mod h1:mdzfpAEoE6DHQEN0uh9ZbOCuHbLK5wOm7dK4ctXE9Tg= +sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= +sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/structured-merge-diff/v6 v6.3.0 h1:jTijUJbW353oVOd9oTlifJqOGEkUw2jB/fXCbTiQEco= +sigs.k8s.io/structured-merge-diff/v6 v6.3.0/go.mod h1:M3W8sfWvn2HhQDIbGWj3S099YozAsymCo/wrT5ohRUE= +sigs.k8s.io/yaml v1.6.0 h1:G8fkbMSAFqgEFgh4b1wmtzDnioxFCUgTZhlbj5P9QYs= +sigs.k8s.io/yaml v1.6.0/go.mod h1:796bPqUfzR/0jLAl6XjHl3Ck7MiyVv8dbTdyT3/pMf4= diff --git a/rpc/internal/config/config.go b/rpc/internal/config/config.go index c1f85b9..1ec0f14 100644 --- a/rpc/internal/config/config.go +++ b/rpc/internal/config/config.go @@ -1,7 +1,27 @@ package config -import "github.com/zeromicro/go-zero/zrpc" +import ( + "github.com/saas-mingyang/mingyang-admin-common/config" + "github.com/zeromicro/go-zero/zrpc" + "time" +) type Config struct { zrpc.RpcServerConf + DatabaseConf config.DatabaseConf + JWTConf JWTConfig + RedisConf config.RedisConf + RedisRedisConf config.RedisConf + AppRpc zrpc.RpcClientConf + IP2Location struct { + DBPath string `json:",default=./data/IP2LOCATION-LITE-DB.BIN"` + } +} + +type JWTConfig struct { + AccessTokenSecret string `mapstructure:"access_token_secret"` + RefreshTokenSecret string `mapstructure:"refresh_token_secret"` + AccessTokenExpiry time.Duration `mapstructure:"access_token_expiry"` + RefreshTokenExpiry time.Duration `mapstructure:"refresh_token_expiry"` + Issuer string `mapstructure:"issuer"` } diff --git a/rpc/internal/jwt_manager/jwt_manager.go b/rpc/internal/jwt_manager/jwt_manager.go new file mode 100644 index 0000000..1933843 --- /dev/null +++ b/rpc/internal/jwt_manager/jwt_manager.go @@ -0,0 +1,125 @@ +package jwt_manager + +import ( + "errors" + "fmt" + "github.com/golang-jwt/jwt/v5" + "mingyang-admin-app-rpc/internal/config" + "time" +) + +type JWTManager struct { + accessTokenSecret []byte + refreshTokenSecret []byte + accessTokenExpiry time.Duration + refreshTokenExpiry time.Duration + issuer string +} + +type Claims struct { + UserID uint64 `json:"user_id"` + Type string `json:"type"` // "access" or "refresh" + jwt.RegisteredClaims +} + +func NewJWTManager(config *config.JWTConfig) *JWTManager { + return &JWTManager{ + accessTokenSecret: []byte(config.AccessTokenSecret), + refreshTokenSecret: []byte(config.RefreshTokenSecret), + accessTokenExpiry: config.AccessTokenExpiry, + refreshTokenExpiry: config.RefreshTokenExpiry, + issuer: config.Issuer, + } +} + +// GenerateAccessToken 生成访问令牌 +func (m *JWTManager) GenerateAccessToken(userID uint64) (string, *Claims, error) { + return m.generateToken(userID, "access", m.accessTokenExpiry, m.accessTokenSecret) +} + +// GenerateRefreshToken 生成刷新令牌 +func (m *JWTManager) GenerateRefreshToken(userID uint64) (string, *Claims, error) { + return m.generateToken(userID, "refresh", m.refreshTokenExpiry, m.refreshTokenSecret) +} + +func (m *JWTManager) generateToken(userID uint64, tokenType string, expiry time.Duration, secret []byte) (string, *Claims, error) { + claims := &Claims{ + UserID: userID, + Type: tokenType, + RegisteredClaims: jwt.RegisteredClaims{ + ExpiresAt: jwt.NewNumericDate(time.Now().Add(expiry)), + IssuedAt: jwt.NewNumericDate(time.Now()), + Issuer: m.issuer, + Subject: fmt.Sprint(userID), + }, + } + + token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims) + tokenString, err := token.SignedString(secret) + if err != nil { + return "", nil, err + } + + return tokenString, claims, nil +} + +// VerifyAccessToken 验证访问令牌 +func (m *JWTManager) VerifyAccessToken(tokenString string) (*Claims, error) { + return m.verifyToken(tokenString, m.accessTokenSecret, "access") +} + +// VerifyRefreshToken 验证刷新令牌 +func (m *JWTManager) VerifyRefreshToken(tokenString string) (*Claims, error) { + return m.verifyToken(tokenString, m.refreshTokenSecret, "refresh") +} + +func (m *JWTManager) verifyToken(tokenString string, secret []byte, expectedType string) (*Claims, error) { + token, err := jwt.ParseWithClaims(tokenString, &Claims{}, func(token *jwt.Token) (interface{}, error) { + if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok { + return nil, fmt.Errorf("unexpected signing method: %v", token.Header["alg"]) + } + return secret, nil + }) + + if err != nil { + return nil, err + } + + if claims, ok := token.Claims.(*Claims); ok && token.Valid { + if claims.Type != expectedType { + return nil, errors.New("invalid token type") + } + return claims, nil + } + + return nil, errors.New("invalid token") +} + +// GenerateTokenPair 生成令牌对 +func (m *JWTManager) GenerateTokenPair(userID uint64) (*TokenPair, error) { + accessToken, accessClaims, err := m.GenerateAccessToken(userID) + if err != nil { + return nil, err + } + + refreshToken, refreshClaims, err := m.GenerateRefreshToken(userID) + if err != nil { + return nil, err + } + + return &TokenPair{ + AccessToken: accessToken, + RefreshToken: refreshToken, + AccessTokenExpiresAt: accessClaims.ExpiresAt.Time, + RefreshTokenExpiresAt: refreshClaims.ExpiresAt.Time, + TokenType: "Bearer", + }, nil +} + +type TokenPair struct { + AccessToken string `json:"access_token"` + RefreshToken string `json:"refresh_token"` + AccessTokenExpiresAt time.Time `json:"access_token_expires_at"` + RefreshTokenExpiresAt time.Time `json:"refresh_token_expires_at"` + TokenType string `json:"token_type"` +} diff --git a/rpc/internal/logic/cacherepo/cache_repo.go b/rpc/internal/logic/cacherepo/cache_repo.go new file mode 100644 index 0000000..ae153a6 --- /dev/null +++ b/rpc/internal/logic/cacherepo/cache_repo.go @@ -0,0 +1,149 @@ +package cacherepo + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "github.com/go-redis/redis/v8" + "github.com/zeromicro/go-zero/core/logx" + "mingyang-admin-app-rpc/internal/svc" + "time" +) + +type CacheRepository struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewCacheRepository(ctx context.Context, svcCtx *svc.ServiceContext) *CacheRepository { + return &CacheRepository{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +// SetVerificationCode 设置验证码 +func (r *CacheRepository) SetVerificationCode(ctx context.Context, key, code string, expiry time.Duration) error { + data := VerificationCodeData{ + Code: code, + Attempts: 0, + CreatedAt: time.Now(), + } + + jsonData, err := json.Marshal(data) + if err != nil { + return err + } + + return r.svcCtx.Redis.Set(ctx, key, jsonData, expiry).Err() +} + +// GetVerificationCode 获取验证码 +func (r *CacheRepository) GetVerificationCode(ctx context.Context, key string) (*VerificationCodeData, error) { + data, err := r.svcCtx.Redis.Get(ctx, key).Result() + if err != nil { + return nil, err + } + + var codeData VerificationCodeData + if err := json.Unmarshal([]byte(data), &codeData); err != nil { + return nil, err + } + + return &codeData, nil +} + +// IncrementVerificationAttempts 增加验证尝试次数 +func (r *CacheRepository) IncrementVerificationAttempts(ctx context.Context, key string) error { + data, err := r.GetVerificationCode(ctx, key) + if err != nil { + return err + } + if data == nil { + return fmt.Errorf("verification code.proto not found") + } + + data.Attempts++ + jsonData, err := json.Marshal(data) + if err != nil { + return err + } + + // 重新设置过期时间 + ttl := r.svcCtx.Redis.TTL(ctx, key).Val() + return r.svcCtx.Redis.Set(ctx, key, jsonData, ttl).Err() +} + +// DeleteVerificationCode 删除验证码 +func (r *CacheRepository) DeleteVerificationCode(ctx context.Context, key string) error { + return r.svcCtx.Redis.Del(ctx, key).Err() +} + +// SetPasswordResetToken 设置密码重置令牌 +func (r *CacheRepository) SetPasswordResetToken(ctx context.Context, key, token string, expiry time.Duration) error { + return r.svcCtx.Redis.Set(ctx, key, token, expiry).Err() +} + +// GetPasswordResetToken 获取密码重置令牌 +func (r *CacheRepository) GetPasswordResetToken(ctx context.Context, key string) (string, error) { + return r.svcCtx.Redis.Get(ctx, key).Result() +} + +// DeletePasswordResetToken 删除密码重置令牌 +func (r *CacheRepository) DeletePasswordResetToken(ctx context.Context, key string) error { + return r.svcCtx.Redis.Del(ctx, key).Err() +} + +// SetSession 设置会话 +func (r *CacheRepository) SetSession(ctx context.Context, key string, data interface{}, expiry time.Duration) error { + jsonData, err := json.Marshal(data) + if err != nil { + return err + } + + return r.svcCtx.Redis.Set(ctx, key, jsonData, expiry).Err() +} + +// GetSession 获取会话 +func (r *CacheRepository) GetSession(ctx context.Context, key string, result interface{}) error { + data, err := r.svcCtx.Redis.Get(ctx, key).Result() + if err != nil { + return err + } + + return json.Unmarshal([]byte(data), result) +} + +// DeleteSession 删除会话 +func (r *CacheRepository) DeleteSession(ctx context.Context, key string) error { + return r.svcCtx.Redis.Del(ctx, key).Err() +} + +// RateLimit 限流 +func (r *CacheRepository) RateLimit(ctx context.Context, key string, limit int, window time.Duration) (bool, error) { + count, err := r.svcCtx.Redis.Get(ctx, key).Int() + if err != nil && !errors.Is(err, redis.Nil) { + return false, err + } + + if count >= limit { + return false, nil + } + + pipe := r.svcCtx.Redis.Pipeline() + pipe.Incr(ctx, key) + pipe.Expire(ctx, key, window) + + _, err = pipe.Exec(ctx) + return err == nil, err +} + +// VerificationCodeData 数据模型 +type VerificationCodeData struct { + Code string `json:"code.proto"` + Attempts int `json:"attempts"` + CreatedAt time.Time `json:"created_at"` +} diff --git a/rpc/internal/logic/code/get_verify_code_logic.go b/rpc/internal/logic/code/get_verify_code_logic.go new file mode 100644 index 0000000..bf9860c --- /dev/null +++ b/rpc/internal/logic/code/get_verify_code_logic.go @@ -0,0 +1,49 @@ +package code + +import ( + "context" + "github.com/zeromicro/go-zero/core/logx" + "mingyang-admin-app-rpc/internal/logic/cacherepo" + "mingyang-admin-app-rpc/internal/svc" + "mingyang-admin-app-rpc/types/app" +) + +type GetVerifyCodeLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger + cacheRepo *cacherepo.CacheRepository +} + +func NewGetVerifyCodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetVerifyCodeLogic { + return &GetVerifyCodeLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + cacheRepo: cacherepo.NewCacheRepository(ctx, svcCtx), + } +} + +// GetVerifyCode 获取验证码 +func (l *GetVerifyCodeLogic) GetVerifyCode(in *app.VerifyCodeReq) (*app.VerifyCodeResp, error) { + codeType := in.GetAccountType() + switch codeType { + case app.AccountType_MOBILE: + // TODO: 调用短信服务获取验证码 + l.SendMobileMessage(in) + case app.AccountType_EMAIL: + // TODO: 调用邮件服务获取验证码 + l.SendEmailMessage(in) + } + + return &app.VerifyCodeResp{}, nil +} + +func (l *GetVerifyCodeLogic) SendMobileMessage(in *app.VerifyCodeReq) { + //l.cacheRepo.SetVerificationCode(l.ctx, in.Value, nil, 10*time.Minute) + +} + +func (l *GetVerifyCodeLogic) SendEmailMessage(in *app.VerifyCodeReq) { + +} diff --git a/rpc/internal/logic/pinglogic.go b/rpc/internal/logic/pinglogic.go deleted file mode 100644 index edb9fc9..0000000 --- a/rpc/internal/logic/pinglogic.go +++ /dev/null @@ -1,30 +0,0 @@ -package logic - -import ( - "context" - - "mingyang-admin-iot-app/rpc/internal/svc" - "mingyang-admin-iot-app/rpc/rpc" - - "github.com/zeromicro/go-zero/core/logx" -) - -type PingLogic struct { - ctx context.Context - svcCtx *svc.ServiceContext - logx.Logger -} - -func NewPingLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PingLogic { - return &PingLogic{ - ctx: ctx, - svcCtx: svcCtx, - Logger: logx.WithContext(ctx), - } -} - -func (l *PingLogic) Ping(in *rpc.Request) (*rpc.Response, error) { - // todo: add your logic here and delete this line - - return &rpc.Response{}, nil -} diff --git a/rpc/internal/logic/user/login_user_logic.go b/rpc/internal/logic/user/login_user_logic.go new file mode 100644 index 0000000..d2e675b --- /dev/null +++ b/rpc/internal/logic/user/login_user_logic.go @@ -0,0 +1,229 @@ +package user + +import ( + "context" + "errors" + "fmt" + "github.com/saas-mingyang/mingyang-admin-common/utils/sonyflake" + "golang.org/x/crypto/bcrypt" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/types/known/timestamppb" + "mingyang-admin-app-rpc/ent" + "mingyang-admin-app-rpc/ent/predicate" + "mingyang-admin-app-rpc/ent/user" + "mingyang-admin-app-rpc/ent/userloginlog" + "mingyang-admin-app-rpc/internal/jwt_manager" + "mingyang-admin-app-rpc/internal/util" + "time" + + "mingyang-admin-app-rpc/internal/svc" + "mingyang-admin-app-rpc/types/app" + + "github.com/zeromicro/go-zero/core/logx" +) + +type LoginUserLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger + jwt *jwt_manager.JWTManager +} + +func NewLoginUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *LoginUserLogic { + return &LoginUserLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + jwt: jwt_manager.NewJWTManager(&svcCtx.Config.JWTConf), + } +} + +// LoginUser 用户登录 +func (l *LoginUserLogic) LoginUser(in *app.LoginRequest) (*app.LoginResponse, error) { + // 1. 参数验证 + if err := l.validateLoginRequest(in); err != nil { + return nil, status.Error(codes.InvalidArgument, err.Error()) + } + // 2. 根据登录标识查询用户 + user, err := l.getUserByIdentifier(in) + if err != nil { + // 避免泄露用户是否存在的信息,统一返回相同错误 + return nil, status.Error(codes.Unauthenticated, "invalid credentials") + } + // 3. 检查账户状态 + if err := l.checkAccountStatus(user); err != nil { + return nil, err + } + // 4. 验证密码 + if !l.verifyPassword(user, in.GetPassword()) { + // 记录登录失败尝试 + go l.recordLogin(user, in, nil, false) + return nil, status.Error(codes.Unauthenticated, "invalid credentials") + } + // 5. 生成访问令牌和刷新令牌 + tokenPair, userThirdAuth, err := l.generateTokenPair(user, in) + if err != nil { + return nil, status.Error(codes.Internal, "failed to generate token") + } + // 6. 记录成功登录日志 + go l.recordLogin(user, in, userThirdAuth, true) + // 7. 返回响应 + return l.buildLoginResponse(user, tokenPair), nil +} + +func (l *LoginUserLogic) validateLoginRequest(in *app.LoginRequest) error { + // 检查登录标识是否提供 + if in.GetUsername() == "" && in.GetMobile() == "" && in.GetEmail() == "" { + return errors.New("username, mobile or email is required") + } + // 检查密码是否提供 + if in.GetPassword() == "" { + return errors.New("password is required") + } + // 验证邮箱格式(如果提供了邮箱) + if in.GetEmail() != "" && !util.ValidateEmail(in.GetEmail()) { + return errors.New("invalid email format") + } + + // 验证手机号格式(如果提供了手机号) + if in.GetMobile() != "" && util.ValidatePhone(in.GetMobile()) { + return errors.New("invalid mobile format") + } + return nil +} + +func (l *LoginUserLogic) getUserByIdentifier(in *app.LoginRequest) (*ent.User, error) { + var conditions []predicate.User + // 根据提供的标识构建查询条件 + if in.GetUsername() != "" { + conditions = append(conditions, user.UsernameEQ(in.GetUsername())) + } + if in.GetMobile() != "" { + conditions = append(conditions, user.MobileEQ(in.GetMobile())) + } + if in.GetEmail() != "" { + conditions = append(conditions, user.EmailEQ(in.GetEmail())) + } + // 查询用户,同时加载关联数据(如角色、权限等) + user, err := l.svcCtx.DB.User.Query(). + Where(user.Or(conditions...)). + Only(l.ctx) + if err != nil { + if ent.IsNotFound(err) { + // 用户不存在,返回统一错误信息 + return nil, errors.New("user not found") + } + return nil, fmt.Errorf("failed to query user: %w", err) + } + return user, nil +} + +func (l *LoginUserLogic) checkAccountStatus(user *ent.User) error { + switch user.AccountStatus { + case "locked": + // 锁定已过期,可以尝试解锁 + case "suspended": + return errors.New("account suspended") + case "banned": + return errors.New("account banned") + case "deleted": + return errors.New("account deleted") + } + return nil +} + +func (l *LoginUserLogic) verifyPassword(user *ent.User, password string) bool { + // 使用bcrypt验证密码 + err := bcrypt.CompareHashAndPassword([]byte(user.PasswordHash), []byte(password)) + if err != nil { + // 密码错误,增加登录尝试次数 + l.incrementLoginAttempts(user) + return false + } + // 密码正确,重置登录尝试次数 + l.resetLoginAttempts(user) + return true +} + +func (l *LoginUserLogic) recordLogin(user *ent.User, in *app.LoginRequest, userThirdAuth *ent.UserThirdAuth, loginResult bool) { + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + defer cancel() + _, err := l.svcCtx.DB.UserLoginLog.Create(). + SetUserID(user.ID). + SetLoginTime(time.Now()). + SetLoginIP(in.GetClientIp()). + SetLoginType(userloginlog.LoginType(in.GetLoginType())). + SetLoginPlatform(userloginlog.LoginPlatform(in.GetPlatform())). + SetFailureReason("password_incorrect"). + SetLoginResult(loginResult). + SetAuthID(userThirdAuth.ID). + Save(ctx) + if err != nil { + l.Logger.Errorf("failed to record failed login: %v", err) + } +} + +func (l *LoginUserLogic) generateTokenPair(user *ent.User, in *app.LoginRequest) (*jwt_manager.TokenPair, *ent.UserThirdAuth, error) { + // 生成访问令牌 + tokenPair, err := l.jwt.GenerateTokenPair(user.ID) + if err != nil { + return nil, nil, fmt.Errorf("failed to generate access token: %w", err) + } + // 保存令牌到数据库 + userThirdAuth := l.saveRefreshToken(user, tokenPair, in) + return tokenPair, userThirdAuth, nil +} + +// 构建登录响应 +func (l *LoginUserLogic) buildLoginResponse(user *ent.User, tokenPair *jwt_manager.TokenPair) *app.LoginResponse { + response := &app.LoginResponse{ + User: l.convertUserToProto(user), + AuthToken: &app.AuthToken{ + AccessToken: tokenPair.AccessToken, + RefreshToken: tokenPair.RefreshToken, + TokenType: tokenPair.TokenType, + ExpiresAt: timestamppb.New(tokenPair.AccessTokenExpiresAt), + }, + } + return response +} + +// 增加登录尝试次数 +func (l *LoginUserLogic) incrementLoginAttempts(user *ent.User) { + +} + +// 重置登录尝试次数 +func (l *LoginUserLogic) resetLoginAttempts(user *ent.User) { + +} + +// 保存刷新令牌到数据库 +func (l *LoginUserLogic) saveRefreshToken(user *ent.User, tokenPair *jwt_manager.TokenPair, in *app.LoginRequest) *ent.UserThirdAuth { + userThirdAuth, err := l.svcCtx.DB.UserThirdAuth.Create(). + SetUserID(user.ID). + SetRefreshToken(tokenPair.RefreshToken). + SetAccessToken(tokenPair.AccessToken). + SetAccessTokenExpiry(tokenPair.AccessTokenExpiresAt). + SetBoundAt(time.Now()). + SetID(sonyflake.NextID()). + SetEmail(in.GetEmail()). + SetPhone(in.GetMobile()). + Save(l.ctx) + if err != nil { + l.Errorf("saveRefreshToken err: %v", err) + return nil + } + return userThirdAuth +} + +func (l *LoginUserLogic) convertUserToProto(u *ent.User) *app.UserInfo { + return &app.UserInfo{ + Id: &u.ID, + Username: &u.Username, + Nickname: &u.Nickname, + Avatar: u.Avatar, + Email: &u.Email, + } +} diff --git a/rpc/internal/logic/user/register_user_logic.go b/rpc/internal/logic/user/register_user_logic.go new file mode 100644 index 0000000..d2b7a98 --- /dev/null +++ b/rpc/internal/logic/user/register_user_logic.go @@ -0,0 +1,150 @@ +package user + +import ( + "context" + "errors" + "fmt" + "github.com/zeromicro/go-zero/core/logx" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/types/known/timestamppb" + "mingyang-admin-app-rpc/internal/jwt_manager" + "mingyang-admin-app-rpc/internal/logic/cacherepo" + "mingyang-admin-app-rpc/internal/svc" + "mingyang-admin-app-rpc/internal/util" + "mingyang-admin-app-rpc/types/app" + "strings" + "time" +) + +type RegisterUserLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger + jwtManager *jwt_manager.JWTManager +} + +func NewRegisterUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RegisterUserLogic { + return &RegisterUserLogic{ + ctx: ctx, + svcCtx: svcCtx, + jwtManager: jwt_manager.NewJWTManager(&svcCtx.Config.JWTConf), + Logger: logx.WithContext(ctx), + } +} + +// RegisterUser 用户注册 +func (s *RegisterUserLogic) RegisterUser(req *app.RegisterUserRequest) (*app.RegisterUserResponse, error) { + // 1. 验证输入 + if err := s.validateRegisterRequest(req); err != nil { + return nil, status.Errorf(codes.InvalidArgument, "validation failed: %v", err) + } + + // 2. 验证验证码 + if err := s.verifyRegistrationCode(s.ctx, req); err != nil { + return nil, status.Errorf(codes.InvalidArgument, "verification failed: %v", err) + } + + // 3. 验证密码强度 + if err := util.ValidatePasswordStrength(req.GetPassword()); err != nil { + return nil, status.Errorf(codes.InvalidArgument, "password validation failed: %v", err) + } + // 4. 哈希密码 + passwordHash, err := util.HashPassword(req.GetPassword()) + if err != nil { + return nil, status.Errorf(codes.Internal, "failed to hash password: %v", err) + } + + // 5. 标准化手机号格式 + var mobile string + if req.GetMobile() != "" { + normalizedPhone := util.NormalizePhone(req.GetMobile()) + mobile = normalizedPhone + } + + // 6. 准备用户数据 + userData := CreateUserData{ + Username: strings.ToLower(strings.TrimSpace(req.GetUsername())), + Email: strings.ToLower(strings.TrimSpace(req.GetEmail())), + Mobile: mobile, + PasswordHash: passwordHash, + Nickname: req.GetNickName(), + RegistrationSource: req.GetRegistrationSource(), + Metadata: map[string]interface{}{ + "registered_via": req.RegistrationSource, + "registered_at": time.Now().Format(time.RFC3339), + }, + } + + userRepo := NewUser(s.ctx, s.svcCtx) + + user, err := userRepo.CreateUser(s.ctx, &userData) + + if err != nil { + if strings.Contains(err.Error(), "already exists") { + return nil, status.Errorf(codes.AlreadyExists, "user already exists") + } + return nil, status.Errorf(codes.Internal, "failed to create user: %v", err) + } + + // 8. 生成JWT令牌 + tokenPair, err := s.jwtManager.GenerateTokenPair(*user.Id) + if err != nil { + // 注意:这里不应该返回错误,因为用户已经创建成功 + // 只是记录日志,继续处理 + fmt.Printf("Failed to generate token for user %v: %v\n", user.Id, err) + } + + // 10. 发送欢迎邮件(异步) + go func() { + //todo 发送欢迎邮件 + + }() + // 11. 构建响应 + response := &app.RegisterUserResponse{ + User: user, + } + if tokenPair != nil { + response.AuthToken = &app.AuthToken{ + AccessToken: tokenPair.AccessToken, + RefreshToken: tokenPair.RefreshToken, + TokenType: tokenPair.TokenType, + ExpiresIn: int32(tokenPair.AccessTokenExpiresAt.Sub(time.Now()).Seconds()), + IssuedAt: timestamppb.New(time.Now()), + ExpiresAt: timestamppb.New(tokenPair.AccessTokenExpiresAt), + } + } + return response, nil +} + +// validateRegisterRequest 验证注册请求 +func (s *RegisterUserLogic) validateRegisterRequest(req *app.RegisterUserRequest) error { + return nil +} + +// verifyRegistrationCode 验证注册验证码 +func (s *RegisterUserLogic) verifyRegistrationCode(ctx context.Context, req *app.RegisterUserRequest) error { + key := req.GetVerificationId() + cacheRepository := cacherepo.NewCacheRepository(ctx, s.svcCtx) + // 获取验证码数据 + codeData, err := cacheRepository.GetVerificationCode(ctx, key) + if err != nil { + return fmt.Errorf("failed to get verification code.proto: %w", err) + } + if codeData == nil { + return errors.New("verification code.proto expired or not found") + } + // 验证验证码 + if codeData.Code != req.GetVerificationCode() { + // 增加尝试次数 + if err := cacheRepository.IncrementVerificationAttempts(ctx, key); err != nil { + fmt.Printf("Failed to increment verification attempts: %v\n", err) + } + return errors.New("invalid verification code.proto") + } + // 验证成功,删除验证码 + if err := cacheRepository.DeleteVerificationCode(ctx, key); err != nil { + fmt.Printf("Failed to delete verification code.proto: %v\n", err) + } + return nil +} diff --git a/rpc/internal/logic/user/user_logic.go b/rpc/internal/logic/user/user_logic.go new file mode 100644 index 0000000..d5aa919 --- /dev/null +++ b/rpc/internal/logic/user/user_logic.go @@ -0,0 +1,116 @@ +package user + +import ( + "context" + "errors" + "fmt" + "github.com/saas-mingyang/mingyang-admin-common/utils/sonyflake" + "github.com/zeromicro/go-zero/core/logx" + "mingyang-admin-app-rpc/ent" + "mingyang-admin-app-rpc/ent/user" + "mingyang-admin-app-rpc/internal/svc" + "mingyang-admin-app-rpc/types/app" + "time" +) + +type User struct { + client *ent.Client + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewUser(ctx context.Context, svcCtx *svc.ServiceContext) *User { + return &User{ + client: svcCtx.DB, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +// CreateUser 创建用户 +func (u *User) CreateUser(ctx context.Context, req *CreateUserData) (*app.UserInfo, error) { + tx, err := u.client.Tx(ctx) + if err != nil { + return nil, fmt.Errorf("starting transaction: %w", err) + } + defer func() { + if err != nil { + if rollbackErr := tx.Rollback(); rollbackErr != nil { + err = fmt.Errorf("%w, rollback error: %v", err, rollbackErr) + } + } + }() + // 1. 检查用户名、邮箱、手机号是否已存在 + exists, err := tx.User.Query(). + Where( + user.Or( + user.UsernameEQ(req.Username), + user.EmailEQ(req.Email), + user.MobileEQ(req.Mobile), + ), + ).Exist(ctx) + + if err != nil { + return nil, fmt.Errorf("checking existing user: %w", err) + } + if exists { + return nil, errors.New("username, email or phone already exists") + } + // 2. 创建用户 + userObj, err := tx.User. + Create(). + SetID(sonyflake.NextID()). + SetUsername(req.Username). + SetEmail(req.Email). + SetMobile(req.Mobile). + SetPasswordHash(req.PasswordHash). + SetNickname(req.Nickname). + SetRegistrationSource(req.RegistrationSource). + SetMetadata(req.Metadata). + Save(ctx) + if err != nil { + return nil, fmt.Errorf("creating user: %w", err) + } + // 4. 提交事务 + if err := tx.Commit(); err != nil { + return nil, fmt.Errorf("committing transaction: %w", err) + } + gender := userObj.Gender.String() + accountStatus := userObj.AccountStatus.String() + return &app.UserInfo{ + Id: &userObj.ID, + Username: &userObj.Username, + Email: &userObj.Email, + Nickname: &userObj.Nickname, + Avatar: userObj.Avatar, + PasswordHash: &userObj.PasswordHash, + Salt: &userObj.Salt, + Mobile: userObj.Mobile, + Gender: &gender, + AccountStatus: &accountStatus, + IsVerified: &userObj.IsVerified, + RegistrationSource: &userObj.RegistrationSource, + }, nil +} + +type CreateUserData struct { + UserId *uint64 + Username string + Email string + Mobile string + PasswordHash string + Nickname string + RegistrationSource string + Metadata map[string]interface{} + ThirdPartyAuth *ThirdPartyAuthData +} + +type ThirdPartyAuthData struct { + UserID uint64 + Openid string + Unionid string + AccessToken *string + RefreshToken *string + AccessTokenExpiry *time.Time + UserInfo map[string]interface{} +} diff --git a/rpc/internal/server/app_server.go b/rpc/internal/server/app_server.go new file mode 100644 index 0000000..73e8e33 --- /dev/null +++ b/rpc/internal/server/app_server.go @@ -0,0 +1,42 @@ +// Code generated by goctl. DO NOT EDIT. +// Source: app.proto + +package server + +import ( + "context" + + "mingyang-admin-app-rpc/internal/logic/code" + "mingyang-admin-app-rpc/internal/logic/user" + "mingyang-admin-app-rpc/internal/svc" + "mingyang-admin-app-rpc/types/app" +) + +type AppServer struct { + svcCtx *svc.ServiceContext + app.UnimplementedAppServer +} + +func NewAppServer(svcCtx *svc.ServiceContext) *AppServer { + return &AppServer{ + svcCtx: svcCtx, + } +} + +// 获取验证码 +func (s *AppServer) GetVerifyCode(ctx context.Context, in *app.VerifyCodeReq) (*app.VerifyCodeResp, error) { + l := code.NewGetVerifyCodeLogic(ctx, s.svcCtx) + return l.GetVerifyCode(in) +} + +// 用户注册 +func (s *AppServer) RegisterUser(ctx context.Context, in *app.RegisterUserRequest) (*app.RegisterUserResponse, error) { + l := user.NewRegisterUserLogic(ctx, s.svcCtx) + return l.RegisterUser(in) +} + +// 用户登录 +func (s *AppServer) LoginUser(ctx context.Context, in *app.LoginRequest) (*app.LoginResponse, error) { + l := user.NewLoginUserLogic(ctx, s.svcCtx) + return l.LoginUser(in) +} diff --git a/rpc/internal/server/rpcserver.go b/rpc/internal/server/rpcserver.go deleted file mode 100644 index d12ab1a..0000000 --- a/rpc/internal/server/rpcserver.go +++ /dev/null @@ -1,29 +0,0 @@ -// Code generated by goctl. DO NOT EDIT. -// goctl 1.9.2 -// Source: rpc.proto - -package server - -import ( - "context" - - "mingyang-admin-iot-app/rpc/internal/logic" - "mingyang-admin-iot-app/rpc/internal/svc" - "mingyang-admin-iot-app/rpc/rpc" -) - -type RpcServer struct { - svcCtx *svc.ServiceContext - rpc.UnimplementedRpcServer -} - -func NewRpcServer(svcCtx *svc.ServiceContext) *RpcServer { - return &RpcServer{ - svcCtx: svcCtx, - } -} - -func (s *RpcServer) Ping(ctx context.Context, in *rpc.Request) (*rpc.Response, error) { - l := logic.NewPingLogic(ctx, s.svcCtx) - return l.Ping(in) -} diff --git a/rpc/internal/service/user_service.go b/rpc/internal/service/user_service.go new file mode 100644 index 0000000..6d43c33 --- /dev/null +++ b/rpc/internal/service/user_service.go @@ -0,0 +1 @@ +package service diff --git a/rpc/internal/util/jwt_utils.go b/rpc/internal/util/jwt_utils.go new file mode 100644 index 0000000..c7d8682 --- /dev/null +++ b/rpc/internal/util/jwt_utils.go @@ -0,0 +1 @@ +package util diff --git a/rpc/internal/util/password_utils.go b/rpc/internal/util/password_utils.go new file mode 100644 index 0000000..3427b4c --- /dev/null +++ b/rpc/internal/util/password_utils.go @@ -0,0 +1,120 @@ +package util + +import ( + "crypto/rand" + "crypto/sha256" + "encoding/base64" + "fmt" + "strings" + "time" + + "golang.org/x/crypto/bcrypt" +) + +// HashPassword 使用bcrypt加密密码 +func HashPassword(password string) (string, error) { + bytes, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost) + if err != nil { + return "", fmt.Errorf("failed to hash password: %w", err) + } + return string(bytes), nil +} + +// CheckPassword 验证密码 +func CheckPassword(password, hash string) bool { + err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password)) + return err == nil +} + +// GenerateRandomString 生成随机字符串 +func GenerateRandomString(n int) (string, error) { + b := make([]byte, n) + _, err := rand.Read(b) + if err != nil { + return "", err + } + return base64.URLEncoding.EncodeToString(b)[:n], nil +} + +// GenerateVerificationToken 生成验证令牌 +func GenerateVerificationToken() (string, error) { + return GenerateRandomString(32) +} + +// GeneratePasswordResetToken 生成密码重置令牌 +func GeneratePasswordResetToken() (string, error) { + token, err := GenerateRandomString(32) + if err != nil { + return "", err + } + // 添加时间戳防止重复 + return fmt.Sprintf("%s_%d", token, time.Now().Unix()), nil +} + +// NormalizePhone 标准化手机号格式 +func NormalizePhone(phone string) string { + // 移除所有非数字字符 + phone = strings.Map(func(r rune) rune { + if r >= '0' && r <= '9' { + return r + } + return -1 + }, phone) + + // 如果以0开头,去掉0 + if strings.HasPrefix(phone, "0") { + phone = phone[1:] + } + + // 如果以86开头,去掉86 + if strings.HasPrefix(phone, "86") { + phone = phone[2:] + } + + return phone +} + +// ValidatePasswordStrength 验证密码强度 +func ValidatePasswordStrength(password string) error { + if len(password) < 8 { + return fmt.Errorf("password must be at least 8 characters long") + } + + var hasUpper, hasLower, hasDigit bool + for _, char := range password { + switch { + case 'A' <= char && char <= 'Z': + hasUpper = true + case 'a' <= char && char <= 'z': + hasLower = true + case '0' <= char && char <= '9': + hasDigit = true + case strings.ContainsRune("!@#$%^&*()-_=+[]{}|;:,.<>?", char): + _ = true + } + } + + // 至少包含大小写字母和数字 + if !hasUpper || !hasLower || !hasDigit { + return fmt.Errorf("password must contain uppercase letters, lowercase letters and numbers") + } + + return nil +} + +// GenerateSalt 生成盐值(如果需要自定义加密算法) +func GenerateSalt() (string, error) { + salt := make([]byte, 16) + _, err := rand.Read(salt) + if err != nil { + return "", err + } + return base64.StdEncoding.EncodeToString(salt), nil +} + +// HashPasswordWithSalt 使用盐值哈希密码 +func HashPasswordWithSalt(password, salt string) string { + hash := sha256.New() + hash.Write([]byte(password + salt)) + return fmt.Sprintf("%x", hash.Sum(nil)) +} diff --git a/rpc/internal/util/validator_utils.go b/rpc/internal/util/validator_utils.go new file mode 100644 index 0000000..9d88579 --- /dev/null +++ b/rpc/internal/util/validator_utils.go @@ -0,0 +1,65 @@ +package util + +import ( + "regexp" + "unicode" +) + +// ValidateEmail 验证邮箱格式 +func ValidateEmail(email string) bool { + emailRegex := regexp.MustCompile(`^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$`) + return emailRegex.MatchString(email) +} + +// ValidatePhone 验证手机号格式 +func ValidatePhone(phone string) bool { + // 支持国际格式:+8613812345678 + // 或国内格式:13812345678 + phoneRegex := regexp.MustCompile(`^\+?[1-9]\d{1,14}$`) + return phoneRegex.MatchString(phone) +} + +// ValidateUsername 验证用户名格式 +func ValidateUsername(username string) bool { + // 用户名:3-20个字符,只能包含字母、数字、下划线 + if len(username) < 3 || len(username) > 20 { + return false + } + + usernameRegex := regexp.MustCompile(`^[a-zA-Z0-9_]+$`) + return usernameRegex.MatchString(username) +} + +// ValidateNickname 验证昵称格式 +func ValidateNickname(nickname string) bool { + // 昵称:1-50个字符,不能包含敏感字符 + if len(nickname) == 0 || len(nickname) > 50 { + return false + } + + // 检查是否包含表情符号(可选) + for _, r := range nickname { + if unicode.Is(unicode.Sk, r) { + return false + } + } + + return true +} + +// ValidateRealName 验证真实姓名 +func ValidateRealName(name string) bool { + // 真实姓名:2-50个字符,只能是中文或英文字母 + if len(name) < 2 || len(name) > 50 { + return false + } + + // 检查是否只包含中文和英文字母 + for _, r := range name { + if !unicode.Is(unicode.Han, r) && !unicode.IsLetter(r) && r != '·' && r != ' ' { + return false + } + } + + return true +} diff --git a/rpc/rpc.proto b/rpc/rpc.proto deleted file mode 100644 index d0cd986..0000000 --- a/rpc/rpc.proto +++ /dev/null @@ -1,16 +0,0 @@ -syntax = "proto3"; - -package rpc; -option go_package="./rpc"; - -message Request { - string ping = 1; -} - -message Response { - string pong = 1; -} - -service Rpc { - rpc Ping(Request) returns(Response); -} diff --git a/rpc/rpc/rpc.pb.go b/rpc/rpc/rpc.pb.go deleted file mode 100644 index 19066aa..0000000 --- a/rpc/rpc/rpc.pb.go +++ /dev/null @@ -1,173 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.10 -// protoc v3.21.11 -// source: rpc.proto - -package rpc - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type Request struct { - state protoimpl.MessageState `protogen:"open.v1"` - Ping string `protobuf:"bytes,1,opt,name=ping,proto3" json:"ping,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Request) Reset() { - *x = Request{} - mi := &file_rpc_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Request) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Request) ProtoMessage() {} - -func (x *Request) ProtoReflect() protoreflect.Message { - mi := &file_rpc_proto_msgTypes[0] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Request.ProtoReflect.Descriptor instead. -func (*Request) Descriptor() ([]byte, []int) { - return file_rpc_proto_rawDescGZIP(), []int{0} -} - -func (x *Request) GetPing() string { - if x != nil { - return x.Ping - } - return "" -} - -type Response struct { - state protoimpl.MessageState `protogen:"open.v1"` - Pong string `protobuf:"bytes,1,opt,name=pong,proto3" json:"pong,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Response) Reset() { - *x = Response{} - mi := &file_rpc_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Response) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Response) ProtoMessage() {} - -func (x *Response) ProtoReflect() protoreflect.Message { - mi := &file_rpc_proto_msgTypes[1] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Response.ProtoReflect.Descriptor instead. -func (*Response) Descriptor() ([]byte, []int) { - return file_rpc_proto_rawDescGZIP(), []int{1} -} - -func (x *Response) GetPong() string { - if x != nil { - return x.Pong - } - return "" -} - -var File_rpc_proto protoreflect.FileDescriptor - -const file_rpc_proto_rawDesc = "" + - "\n" + - "\trpc.proto\x12\x03rpc\"\x1d\n" + - "\aRequest\x12\x12\n" + - "\x04ping\x18\x01 \x01(\tR\x04ping\"\x1e\n" + - "\bResponse\x12\x12\n" + - "\x04pong\x18\x01 \x01(\tR\x04pong2*\n" + - "\x03Rpc\x12#\n" + - "\x04Ping\x12\f.rpc.Request\x1a\r.rpc.ResponseB\aZ\x05./rpcb\x06proto3" - -var ( - file_rpc_proto_rawDescOnce sync.Once - file_rpc_proto_rawDescData []byte -) - -func file_rpc_proto_rawDescGZIP() []byte { - file_rpc_proto_rawDescOnce.Do(func() { - file_rpc_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_rpc_proto_rawDesc), len(file_rpc_proto_rawDesc))) - }) - return file_rpc_proto_rawDescData -} - -var file_rpc_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_rpc_proto_goTypes = []any{ - (*Request)(nil), // 0: rpc.Request - (*Response)(nil), // 1: rpc.Response -} -var file_rpc_proto_depIdxs = []int32{ - 0, // 0: rpc.Rpc.Ping:input_type -> rpc.Request - 1, // 1: rpc.Rpc.Ping:output_type -> rpc.Response - 1, // [1:2] is the sub-list for method output_type - 0, // [0:1] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_rpc_proto_init() } -func file_rpc_proto_init() { - if File_rpc_proto != nil { - return - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_rpc_proto_rawDesc), len(file_rpc_proto_rawDesc)), - NumEnums: 0, - NumMessages: 2, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_rpc_proto_goTypes, - DependencyIndexes: file_rpc_proto_depIdxs, - MessageInfos: file_rpc_proto_msgTypes, - }.Build() - File_rpc_proto = out.File - file_rpc_proto_goTypes = nil - file_rpc_proto_depIdxs = nil -} diff --git a/rpc/rpc/rpc_grpc.pb.go b/rpc/rpc/rpc_grpc.pb.go deleted file mode 100644 index f7a332b..0000000 --- a/rpc/rpc/rpc_grpc.pb.go +++ /dev/null @@ -1,121 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.6.0 -// - protoc v3.21.11 -// source: rpc.proto - -package rpc - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.64.0 or later. -const _ = grpc.SupportPackageIsVersion9 - -const ( - Rpc_Ping_FullMethodName = "/rpc.Rpc/Ping" -) - -// RpcClient is the client API for Rpc service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type RpcClient interface { - Ping(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) -} - -type rpcClient struct { - cc grpc.ClientConnInterface -} - -func NewRpcClient(cc grpc.ClientConnInterface) RpcClient { - return &rpcClient{cc} -} - -func (c *rpcClient) Ping(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(Response) - err := c.cc.Invoke(ctx, Rpc_Ping_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -// RpcServer is the server API for Rpc service. -// All implementations must embed UnimplementedRpcServer -// for forward compatibility. -type RpcServer interface { - Ping(context.Context, *Request) (*Response, error) - mustEmbedUnimplementedRpcServer() -} - -// UnimplementedRpcServer must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedRpcServer struct{} - -func (UnimplementedRpcServer) Ping(context.Context, *Request) (*Response, error) { - return nil, status.Error(codes.Unimplemented, "method Ping not implemented") -} -func (UnimplementedRpcServer) mustEmbedUnimplementedRpcServer() {} -func (UnimplementedRpcServer) testEmbeddedByValue() {} - -// UnsafeRpcServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to RpcServer will -// result in compilation errors. -type UnsafeRpcServer interface { - mustEmbedUnimplementedRpcServer() -} - -func RegisterRpcServer(s grpc.ServiceRegistrar, srv RpcServer) { - // If the following call panics, it indicates UnimplementedRpcServer was - // embedded by pointer and is nil. This will cause panics if an - // unimplemented method is ever invoked, so we test this at initialization - // time to prevent it from happening at runtime later due to I/O. - if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { - t.testEmbeddedByValue() - } - s.RegisterService(&Rpc_ServiceDesc, srv) -} - -func _Rpc_Ping_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(Request) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(RpcServer).Ping(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: Rpc_Ping_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RpcServer).Ping(ctx, req.(*Request)) - } - return interceptor(ctx, in, info, handler) -} - -// Rpc_ServiceDesc is the grpc.ServiceDesc for Rpc service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var Rpc_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "rpc.Rpc", - HandlerType: (*RpcServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Ping", - Handler: _Rpc_Ping_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "rpc.proto", -} diff --git a/rpc/rpcclient/rpc.go b/rpc/rpcclient/rpc.go deleted file mode 100644 index 5571c12..0000000 --- a/rpc/rpcclient/rpc.go +++ /dev/null @@ -1,38 +0,0 @@ -// Code generated by goctl. DO NOT EDIT. -// goctl 1.9.2 -// Source: rpc.proto - -package rpcclient - -import ( - "context" - - "mingyang-admin-iot-app/rpc/rpc" - - "github.com/zeromicro/go-zero/zrpc" - "google.golang.org/grpc" -) - -type ( - Request = rpc.Request - Response = rpc.Response - - Rpc interface { - Ping(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) - } - - defaultRpc struct { - cli zrpc.Client - } -) - -func NewRpc(cli zrpc.Client) Rpc { - return &defaultRpc{ - cli: cli, - } -} - -func (m *defaultRpc) Ping(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) { - client := rpc.NewRpcClient(m.cli.Conn()) - return client.Ping(ctx, in, opts...) -} diff --git a/rpc/types/app/app.pb.go b/rpc/types/app/app.pb.go new file mode 100644 index 0000000..56c2da1 --- /dev/null +++ b/rpc/types/app/app.pb.go @@ -0,0 +1,1090 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.10 +// protoc v3.21.11 +// source: app.proto + +package app + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + structpb "google.golang.org/protobuf/types/known/structpb" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// 账户类型枚举(手机/邮箱) +type AccountType int32 + +const ( + AccountType_UNKNOWN AccountType = 0 + AccountType_MOBILE AccountType = 1 + AccountType_EMAIL AccountType = 2 +) + +// Enum value maps for AccountType. +var ( + AccountType_name = map[int32]string{ + 0: "UNKNOWN", + 1: "MOBILE", + 2: "EMAIL", + } + AccountType_value = map[string]int32{ + "UNKNOWN": 0, + "MOBILE": 1, + "EMAIL": 2, + } +) + +func (x AccountType) Enum() *AccountType { + p := new(AccountType) + *p = x + return p +} + +func (x AccountType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (AccountType) Descriptor() protoreflect.EnumDescriptor { + return file_app_proto_enumTypes[0].Descriptor() +} + +func (AccountType) Type() protoreflect.EnumType { + return &file_app_proto_enumTypes[0] +} + +func (x AccountType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use AccountType.Descriptor instead. +func (AccountType) EnumDescriptor() ([]byte, []int) { + return file_app_proto_rawDescGZIP(), []int{0} +} + +// 验证码类型枚举 +type VerifyCodeType int32 + +const ( + VerifyCodeType_REGISTER VerifyCodeType = 0 + VerifyCodeType_LOGIN VerifyCodeType = 1 + VerifyCodeType_RESET_PASSWORD VerifyCodeType = 2 + VerifyCodeType_BIND_PHONE VerifyCodeType = 3 + VerifyCodeType_BIND_EMAIL VerifyCodeType = 4 + VerifyCodeType_UPDATE_PHONE VerifyCodeType = 5 + VerifyCodeType_UPDATE_EMAIL VerifyCodeType = 6 + VerifyCodeType_WITHDRAW VerifyCodeType = 7 + VerifyCodeType_CHANGE_PAY_PASSWORD VerifyCodeType = 8 +) + +// Enum value maps for VerifyCodeType. +var ( + VerifyCodeType_name = map[int32]string{ + 0: "REGISTER", + 1: "LOGIN", + 2: "RESET_PASSWORD", + 3: "BIND_PHONE", + 4: "BIND_EMAIL", + 5: "UPDATE_PHONE", + 6: "UPDATE_EMAIL", + 7: "WITHDRAW", + 8: "CHANGE_PAY_PASSWORD", + } + VerifyCodeType_value = map[string]int32{ + "REGISTER": 0, + "LOGIN": 1, + "RESET_PASSWORD": 2, + "BIND_PHONE": 3, + "BIND_EMAIL": 4, + "UPDATE_PHONE": 5, + "UPDATE_EMAIL": 6, + "WITHDRAW": 7, + "CHANGE_PAY_PASSWORD": 8, + } +) + +func (x VerifyCodeType) Enum() *VerifyCodeType { + p := new(VerifyCodeType) + *p = x + return p +} + +func (x VerifyCodeType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (VerifyCodeType) Descriptor() protoreflect.EnumDescriptor { + return file_app_proto_enumTypes[1].Descriptor() +} + +func (VerifyCodeType) Type() protoreflect.EnumType { + return &file_app_proto_enumTypes[1] +} + +func (x VerifyCodeType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use VerifyCodeType.Descriptor instead. +func (VerifyCodeType) EnumDescriptor() ([]byte, []int) { + return file_app_proto_rawDescGZIP(), []int{1} +} + +// 认证令牌 +type AuthToken struct { + state protoimpl.MessageState `protogen:"open.v1"` + AccessToken string `protobuf:"bytes,1,opt,name=access_token,json=accessToken,proto3" json:"access_token"` + RefreshToken string `protobuf:"bytes,2,opt,name=refresh_token,json=refreshToken,proto3" json:"refresh_token"` + TokenType string `protobuf:"bytes,3,opt,name=token_type,json=tokenType,proto3" json:"token_type"` + ExpiresIn int32 `protobuf:"varint,4,opt,name=expires_in,json=expiresIn,proto3" json:"expires_in"` + IssuedAt *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=issued_at,json=issuedAt,proto3" json:"issued_at"` + ExpiresAt *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=expires_at,json=expiresAt,proto3" json:"expires_at"` + Scopes []string `protobuf:"bytes,7,rep,name=scopes,proto3" json:"scopes"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *AuthToken) Reset() { + *x = AuthToken{} + mi := &file_app_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *AuthToken) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AuthToken) ProtoMessage() {} + +func (x *AuthToken) ProtoReflect() protoreflect.Message { + mi := &file_app_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AuthToken.ProtoReflect.Descriptor instead. +func (*AuthToken) Descriptor() ([]byte, []int) { + return file_app_proto_rawDescGZIP(), []int{0} +} + +func (x *AuthToken) GetAccessToken() string { + if x != nil { + return x.AccessToken + } + return "" +} + +func (x *AuthToken) GetRefreshToken() string { + if x != nil { + return x.RefreshToken + } + return "" +} + +func (x *AuthToken) GetTokenType() string { + if x != nil { + return x.TokenType + } + return "" +} + +func (x *AuthToken) GetExpiresIn() int32 { + if x != nil { + return x.ExpiresIn + } + return 0 +} + +func (x *AuthToken) GetIssuedAt() *timestamppb.Timestamp { + if x != nil { + return x.IssuedAt + } + return nil +} + +func (x *AuthToken) GetExpiresAt() *timestamppb.Timestamp { + if x != nil { + return x.ExpiresAt + } + return nil +} + +func (x *AuthToken) GetScopes() []string { + if x != nil { + return x.Scopes + } + return nil +} + +type LoginRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Username *string `protobuf:"bytes,1,opt,name=username,proto3,oneof" json:"username"` + Email *string `protobuf:"bytes,2,opt,name=email,proto3,oneof" json:"email"` + Mobile *string `protobuf:"bytes,3,opt,name=mobile,proto3,oneof" json:"mobile"` + Password *string `protobuf:"bytes,4,opt,name=password,proto3,oneof" json:"password"` + ClientIp *string `protobuf:"bytes,5,opt,name=clientIp,proto3,oneof" json:"clientIp"` + Platform *string `protobuf:"bytes,6,opt,name=platform,proto3,oneof" json:"platform"` + LoginType *string `protobuf:"bytes,7,opt,name=login_type,json=loginType,proto3,oneof" json:"login_type"` + LoginPlatform *string `protobuf:"bytes,8,opt,name=login_platform,json=loginPlatform,proto3,oneof" json:"login_platform"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *LoginRequest) Reset() { + *x = LoginRequest{} + mi := &file_app_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *LoginRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LoginRequest) ProtoMessage() {} + +func (x *LoginRequest) ProtoReflect() protoreflect.Message { + mi := &file_app_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LoginRequest.ProtoReflect.Descriptor instead. +func (*LoginRequest) Descriptor() ([]byte, []int) { + return file_app_proto_rawDescGZIP(), []int{1} +} + +func (x *LoginRequest) GetUsername() string { + if x != nil && x.Username != nil { + return *x.Username + } + return "" +} + +func (x *LoginRequest) GetEmail() string { + if x != nil && x.Email != nil { + return *x.Email + } + return "" +} + +func (x *LoginRequest) GetMobile() string { + if x != nil && x.Mobile != nil { + return *x.Mobile + } + return "" +} + +func (x *LoginRequest) GetPassword() string { + if x != nil && x.Password != nil { + return *x.Password + } + return "" +} + +func (x *LoginRequest) GetClientIp() string { + if x != nil && x.ClientIp != nil { + return *x.ClientIp + } + return "" +} + +func (x *LoginRequest) GetPlatform() string { + if x != nil && x.Platform != nil { + return *x.Platform + } + return "" +} + +func (x *LoginRequest) GetLoginType() string { + if x != nil && x.LoginType != nil { + return *x.LoginType + } + return "" +} + +func (x *LoginRequest) GetLoginPlatform() string { + if x != nil && x.LoginPlatform != nil { + return *x.LoginPlatform + } + return "" +} + +type LoginResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + User *UserInfo `protobuf:"bytes,1,opt,name=user,proto3" json:"user"` + AuthToken *AuthToken `protobuf:"bytes,2,opt,name=auth_token,json=authToken,proto3" json:"auth_token"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *LoginResponse) Reset() { + *x = LoginResponse{} + mi := &file_app_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *LoginResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LoginResponse) ProtoMessage() {} + +func (x *LoginResponse) ProtoReflect() protoreflect.Message { + mi := &file_app_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LoginResponse.ProtoReflect.Descriptor instead. +func (*LoginResponse) Descriptor() ([]byte, []int) { + return file_app_proto_rawDescGZIP(), []int{2} +} + +func (x *LoginResponse) GetUser() *UserInfo { + if x != nil { + return x.User + } + return nil +} + +func (x *LoginResponse) GetAuthToken() *AuthToken { + if x != nil { + return x.AuthToken + } + return nil +} + +type RegisterUserRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Email *string `protobuf:"bytes,1,opt,name=email,proto3,oneof" json:"email"` + Password *string `protobuf:"bytes,2,opt,name=password,proto3,oneof" json:"password"` + Username *string `protobuf:"bytes,3,opt,name=username,proto3,oneof" json:"username"` + Name *string `protobuf:"bytes,4,opt,name=name,proto3,oneof" json:"name"` + Mobile *string `protobuf:"bytes,5,opt,name=mobile,proto3,oneof" json:"mobile"` + VerificationCode *string `protobuf:"bytes,6,opt,name=verificationCode,proto3,oneof" json:"verificationCode"` + VerificationType *uint32 `protobuf:"varint,7,opt,name=verificationType,proto3,oneof" json:"verificationType"` + VerificationId *string `protobuf:"bytes,8,opt,name=verificationId,proto3,oneof" json:"verificationId"` + NickName *string `protobuf:"bytes,9,opt,name=nickName,proto3,oneof" json:"nickName"` + RegistrationSource *string `protobuf:"bytes,10,opt,name=registrationSource,proto3,oneof" json:"registrationSource"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RegisterUserRequest) Reset() { + *x = RegisterUserRequest{} + mi := &file_app_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RegisterUserRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RegisterUserRequest) ProtoMessage() {} + +func (x *RegisterUserRequest) ProtoReflect() protoreflect.Message { + mi := &file_app_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RegisterUserRequest.ProtoReflect.Descriptor instead. +func (*RegisterUserRequest) Descriptor() ([]byte, []int) { + return file_app_proto_rawDescGZIP(), []int{3} +} + +func (x *RegisterUserRequest) GetEmail() string { + if x != nil && x.Email != nil { + return *x.Email + } + return "" +} + +func (x *RegisterUserRequest) GetPassword() string { + if x != nil && x.Password != nil { + return *x.Password + } + return "" +} + +func (x *RegisterUserRequest) GetUsername() string { + if x != nil && x.Username != nil { + return *x.Username + } + return "" +} + +func (x *RegisterUserRequest) GetName() string { + if x != nil && x.Name != nil { + return *x.Name + } + return "" +} + +func (x *RegisterUserRequest) GetMobile() string { + if x != nil && x.Mobile != nil { + return *x.Mobile + } + return "" +} + +func (x *RegisterUserRequest) GetVerificationCode() string { + if x != nil && x.VerificationCode != nil { + return *x.VerificationCode + } + return "" +} + +func (x *RegisterUserRequest) GetVerificationType() uint32 { + if x != nil && x.VerificationType != nil { + return *x.VerificationType + } + return 0 +} + +func (x *RegisterUserRequest) GetVerificationId() string { + if x != nil && x.VerificationId != nil { + return *x.VerificationId + } + return "" +} + +func (x *RegisterUserRequest) GetNickName() string { + if x != nil && x.NickName != nil { + return *x.NickName + } + return "" +} + +func (x *RegisterUserRequest) GetRegistrationSource() string { + if x != nil && x.RegistrationSource != nil { + return *x.RegistrationSource + } + return "" +} + +type RegisterUserResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + User *UserInfo `protobuf:"bytes,1,opt,name=user,proto3" json:"user"` + AuthToken *AuthToken `protobuf:"bytes,2,opt,name=auth_token,json=authToken,proto3" json:"auth_token"` + EmailVerificationRequired bool `protobuf:"varint,3,opt,name=email_verification_required,json=emailVerificationRequired,proto3" json:"email_verification_required"` + PhoneVerificationRequired bool `protobuf:"varint,4,opt,name=phone_verification_required,json=phoneVerificationRequired,proto3" json:"phone_verification_required"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RegisterUserResponse) Reset() { + *x = RegisterUserResponse{} + mi := &file_app_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RegisterUserResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RegisterUserResponse) ProtoMessage() {} + +func (x *RegisterUserResponse) ProtoReflect() protoreflect.Message { + mi := &file_app_proto_msgTypes[4] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RegisterUserResponse.ProtoReflect.Descriptor instead. +func (*RegisterUserResponse) Descriptor() ([]byte, []int) { + return file_app_proto_rawDescGZIP(), []int{4} +} + +func (x *RegisterUserResponse) GetUser() *UserInfo { + if x != nil { + return x.User + } + return nil +} + +func (x *RegisterUserResponse) GetAuthToken() *AuthToken { + if x != nil { + return x.AuthToken + } + return nil +} + +func (x *RegisterUserResponse) GetEmailVerificationRequired() bool { + if x != nil { + return x.EmailVerificationRequired + } + return false +} + +func (x *RegisterUserResponse) GetPhoneVerificationRequired() bool { + if x != nil { + return x.PhoneVerificationRequired + } + return false +} + +type UserInfo struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id *uint64 `protobuf:"varint,1,opt,name=id,proto3,oneof" json:"id"` + Username *string `protobuf:"bytes,2,opt,name=username,proto3,oneof" json:"username"` + Email *string `protobuf:"bytes,3,opt,name=email,proto3,oneof" json:"email"` + Mobile *string `protobuf:"bytes,4,opt,name=mobile,proto3,oneof" json:"mobile"` + PasswordHash *string `protobuf:"bytes,5,opt,name=password_hash,json=passwordHash,proto3,oneof" json:"password_hash"` + Salt *string `protobuf:"bytes,6,opt,name=salt,proto3,oneof" json:"salt"` + Nickname *string `protobuf:"bytes,7,opt,name=nickname,proto3,oneof" json:"nickname"` + Avatar *string `protobuf:"bytes,8,opt,name=avatar,proto3,oneof" json:"avatar"` + Gender *string `protobuf:"bytes,9,opt,name=gender,proto3,oneof" json:"gender"` + AccountStatus *string `protobuf:"bytes,10,opt,name=account_status,json=accountStatus,proto3,oneof" json:"account_status"` + IsVerified *uint32 `protobuf:"varint,11,opt,name=is_verified,json=isVerified,proto3,oneof" json:"is_verified"` + LastLoginAt *int64 `protobuf:"varint,12,opt,name=last_login_at,json=lastLoginAt,proto3,oneof" json:"last_login_at"` + LastLoginIp *string `protobuf:"bytes,13,opt,name=last_login_ip,json=lastLoginIp,proto3,oneof" json:"last_login_ip"` + LoginAttempts *int64 `protobuf:"varint,14,opt,name=login_attempts,json=loginAttempts,proto3,oneof" json:"login_attempts"` + LockedUntil *int64 `protobuf:"varint,15,opt,name=locked_until,json=lockedUntil,proto3,oneof" json:"locked_until"` + RecoveryToken *string `protobuf:"bytes,16,opt,name=recovery_token,json=recoveryToken,proto3,oneof" json:"recovery_token"` + RecoveryTokenExpiry *int64 `protobuf:"varint,17,opt,name=recovery_token_expiry,json=recoveryTokenExpiry,proto3,oneof" json:"recovery_token_expiry"` + Metadata *structpb.Struct `protobuf:"bytes,20,opt,name=metadata,proto3,oneof" json:"metadata"` + RegistrationSource *string `protobuf:"bytes,21,opt,name=registration_source,json=registrationSource,proto3,oneof" json:"registration_source"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UserInfo) Reset() { + *x = UserInfo{} + mi := &file_app_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UserInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UserInfo) ProtoMessage() {} + +func (x *UserInfo) ProtoReflect() protoreflect.Message { + mi := &file_app_proto_msgTypes[5] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UserInfo.ProtoReflect.Descriptor instead. +func (*UserInfo) Descriptor() ([]byte, []int) { + return file_app_proto_rawDescGZIP(), []int{5} +} + +func (x *UserInfo) GetId() uint64 { + if x != nil && x.Id != nil { + return *x.Id + } + return 0 +} + +func (x *UserInfo) GetUsername() string { + if x != nil && x.Username != nil { + return *x.Username + } + return "" +} + +func (x *UserInfo) GetEmail() string { + if x != nil && x.Email != nil { + return *x.Email + } + return "" +} + +func (x *UserInfo) GetMobile() string { + if x != nil && x.Mobile != nil { + return *x.Mobile + } + return "" +} + +func (x *UserInfo) GetPasswordHash() string { + if x != nil && x.PasswordHash != nil { + return *x.PasswordHash + } + return "" +} + +func (x *UserInfo) GetSalt() string { + if x != nil && x.Salt != nil { + return *x.Salt + } + return "" +} + +func (x *UserInfo) GetNickname() string { + if x != nil && x.Nickname != nil { + return *x.Nickname + } + return "" +} + +func (x *UserInfo) GetAvatar() string { + if x != nil && x.Avatar != nil { + return *x.Avatar + } + return "" +} + +func (x *UserInfo) GetGender() string { + if x != nil && x.Gender != nil { + return *x.Gender + } + return "" +} + +func (x *UserInfo) GetAccountStatus() string { + if x != nil && x.AccountStatus != nil { + return *x.AccountStatus + } + return "" +} + +func (x *UserInfo) GetIsVerified() uint32 { + if x != nil && x.IsVerified != nil { + return *x.IsVerified + } + return 0 +} + +func (x *UserInfo) GetLastLoginAt() int64 { + if x != nil && x.LastLoginAt != nil { + return *x.LastLoginAt + } + return 0 +} + +func (x *UserInfo) GetLastLoginIp() string { + if x != nil && x.LastLoginIp != nil { + return *x.LastLoginIp + } + return "" +} + +func (x *UserInfo) GetLoginAttempts() int64 { + if x != nil && x.LoginAttempts != nil { + return *x.LoginAttempts + } + return 0 +} + +func (x *UserInfo) GetLockedUntil() int64 { + if x != nil && x.LockedUntil != nil { + return *x.LockedUntil + } + return 0 +} + +func (x *UserInfo) GetRecoveryToken() string { + if x != nil && x.RecoveryToken != nil { + return *x.RecoveryToken + } + return "" +} + +func (x *UserInfo) GetRecoveryTokenExpiry() int64 { + if x != nil && x.RecoveryTokenExpiry != nil { + return *x.RecoveryTokenExpiry + } + return 0 +} + +func (x *UserInfo) GetMetadata() *structpb.Struct { + if x != nil { + return x.Metadata + } + return nil +} + +func (x *UserInfo) GetRegistrationSource() string { + if x != nil && x.RegistrationSource != nil { + return *x.RegistrationSource + } + return "" +} + +type VerifyCodeReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + Type VerifyCodeType `protobuf:"varint,1,opt,name=type,proto3,enum=app.VerifyCodeType" json:"type"` + AccountType AccountType `protobuf:"varint,2,opt,name=account_type,json=accountType,proto3,enum=app.AccountType" json:"account_type"` + Value string `protobuf:"bytes,3,opt,name=value,proto3" json:"value"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *VerifyCodeReq) Reset() { + *x = VerifyCodeReq{} + mi := &file_app_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *VerifyCodeReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*VerifyCodeReq) ProtoMessage() {} + +func (x *VerifyCodeReq) ProtoReflect() protoreflect.Message { + mi := &file_app_proto_msgTypes[6] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use VerifyCodeReq.ProtoReflect.Descriptor instead. +func (*VerifyCodeReq) Descriptor() ([]byte, []int) { + return file_app_proto_rawDescGZIP(), []int{6} +} + +func (x *VerifyCodeReq) GetType() VerifyCodeType { + if x != nil { + return x.Type + } + return VerifyCodeType_REGISTER +} + +func (x *VerifyCodeReq) GetAccountType() AccountType { + if x != nil { + return x.AccountType + } + return AccountType_UNKNOWN +} + +func (x *VerifyCodeReq) GetValue() string { + if x != nil { + return x.Value + } + return "" +} + +type VerifyCodeResp struct { + state protoimpl.MessageState `protogen:"open.v1"` + Code *string `protobuf:"bytes,1,opt,name=code,proto3,oneof" json:"code"` + Expire *uint32 `protobuf:"varint,2,opt,name=expire,proto3,oneof" json:"expire"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *VerifyCodeResp) Reset() { + *x = VerifyCodeResp{} + mi := &file_app_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *VerifyCodeResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*VerifyCodeResp) ProtoMessage() {} + +func (x *VerifyCodeResp) ProtoReflect() protoreflect.Message { + mi := &file_app_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use VerifyCodeResp.ProtoReflect.Descriptor instead. +func (*VerifyCodeResp) Descriptor() ([]byte, []int) { + return file_app_proto_rawDescGZIP(), []int{7} +} + +func (x *VerifyCodeResp) GetCode() string { + if x != nil && x.Code != nil { + return *x.Code + } + return "" +} + +func (x *VerifyCodeResp) GetExpire() uint32 { + if x != nil && x.Expire != nil { + return *x.Expire + } + return 0 +} + +var File_app_proto protoreflect.FileDescriptor + +const file_app_proto_rawDesc = "" + + "\n" + + "\tapp.proto\x12\x03app\x1a\x1cgoogle/protobuf/struct.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\x9d\x02\n" + + "\tAuthToken\x12!\n" + + "\faccess_token\x18\x01 \x01(\tR\vaccessToken\x12#\n" + + "\rrefresh_token\x18\x02 \x01(\tR\frefreshToken\x12\x1d\n" + + "\n" + + "token_type\x18\x03 \x01(\tR\ttokenType\x12\x1d\n" + + "\n" + + "expires_in\x18\x04 \x01(\x05R\texpiresIn\x127\n" + + "\tissued_at\x18\x05 \x01(\v2\x1a.google.protobuf.TimestampR\bissuedAt\x129\n" + + "\n" + + "expires_at\x18\x06 \x01(\v2\x1a.google.protobuf.TimestampR\texpiresAt\x12\x16\n" + + "\x06scopes\x18\a \x03(\tR\x06scopes\"\x85\x03\n" + + "\fLoginRequest\x12\x1f\n" + + "\busername\x18\x01 \x01(\tH\x00R\busername\x88\x01\x01\x12\x19\n" + + "\x05email\x18\x02 \x01(\tH\x01R\x05email\x88\x01\x01\x12\x1b\n" + + "\x06mobile\x18\x03 \x01(\tH\x02R\x06mobile\x88\x01\x01\x12\x1f\n" + + "\bpassword\x18\x04 \x01(\tH\x03R\bpassword\x88\x01\x01\x12\x1f\n" + + "\bclientIp\x18\x05 \x01(\tH\x04R\bclientIp\x88\x01\x01\x12\x1f\n" + + "\bplatform\x18\x06 \x01(\tH\x05R\bplatform\x88\x01\x01\x12\"\n" + + "\n" + + "login_type\x18\a \x01(\tH\x06R\tloginType\x88\x01\x01\x12*\n" + + "\x0elogin_platform\x18\b \x01(\tH\aR\rloginPlatform\x88\x01\x01B\v\n" + + "\t_usernameB\b\n" + + "\x06_emailB\t\n" + + "\a_mobileB\v\n" + + "\t_passwordB\v\n" + + "\t_clientIpB\v\n" + + "\t_platformB\r\n" + + "\v_login_typeB\x11\n" + + "\x0f_login_platform\"a\n" + + "\rLoginResponse\x12!\n" + + "\x04user\x18\x01 \x01(\v2\r.app.UserInfoR\x04user\x12-\n" + + "\n" + + "auth_token\x18\x02 \x01(\v2\x0e.app.AuthTokenR\tauthToken\"\xa6\x04\n" + + "\x13RegisterUserRequest\x12\x19\n" + + "\x05email\x18\x01 \x01(\tH\x00R\x05email\x88\x01\x01\x12\x1f\n" + + "\bpassword\x18\x02 \x01(\tH\x01R\bpassword\x88\x01\x01\x12\x1f\n" + + "\busername\x18\x03 \x01(\tH\x02R\busername\x88\x01\x01\x12\x17\n" + + "\x04name\x18\x04 \x01(\tH\x03R\x04name\x88\x01\x01\x12\x1b\n" + + "\x06mobile\x18\x05 \x01(\tH\x04R\x06mobile\x88\x01\x01\x12/\n" + + "\x10verificationCode\x18\x06 \x01(\tH\x05R\x10verificationCode\x88\x01\x01\x12/\n" + + "\x10verificationType\x18\a \x01(\rH\x06R\x10verificationType\x88\x01\x01\x12+\n" + + "\x0everificationId\x18\b \x01(\tH\aR\x0everificationId\x88\x01\x01\x12\x1f\n" + + "\bnickName\x18\t \x01(\tH\bR\bnickName\x88\x01\x01\x123\n" + + "\x12registrationSource\x18\n" + + " \x01(\tH\tR\x12registrationSource\x88\x01\x01B\b\n" + + "\x06_emailB\v\n" + + "\t_passwordB\v\n" + + "\t_usernameB\a\n" + + "\x05_nameB\t\n" + + "\a_mobileB\x13\n" + + "\x11_verificationCodeB\x13\n" + + "\x11_verificationTypeB\x11\n" + + "\x0f_verificationIdB\v\n" + + "\t_nickNameB\x15\n" + + "\x13_registrationSource\"\xe8\x01\n" + + "\x14RegisterUserResponse\x12!\n" + + "\x04user\x18\x01 \x01(\v2\r.app.UserInfoR\x04user\x12-\n" + + "\n" + + "auth_token\x18\x02 \x01(\v2\x0e.app.AuthTokenR\tauthToken\x12>\n" + + "\x1bemail_verification_required\x18\x03 \x01(\bR\x19emailVerificationRequired\x12>\n" + + "\x1bphone_verification_required\x18\x04 \x01(\bR\x19phoneVerificationRequired\"\x87\b\n" + + "\bUserInfo\x12\x13\n" + + "\x02id\x18\x01 \x01(\x04H\x00R\x02id\x88\x01\x01\x12\x1f\n" + + "\busername\x18\x02 \x01(\tH\x01R\busername\x88\x01\x01\x12\x19\n" + + "\x05email\x18\x03 \x01(\tH\x02R\x05email\x88\x01\x01\x12\x1b\n" + + "\x06mobile\x18\x04 \x01(\tH\x03R\x06mobile\x88\x01\x01\x12(\n" + + "\rpassword_hash\x18\x05 \x01(\tH\x04R\fpasswordHash\x88\x01\x01\x12\x17\n" + + "\x04salt\x18\x06 \x01(\tH\x05R\x04salt\x88\x01\x01\x12\x1f\n" + + "\bnickname\x18\a \x01(\tH\x06R\bnickname\x88\x01\x01\x12\x1b\n" + + "\x06avatar\x18\b \x01(\tH\aR\x06avatar\x88\x01\x01\x12\x1b\n" + + "\x06gender\x18\t \x01(\tH\bR\x06gender\x88\x01\x01\x12*\n" + + "\x0eaccount_status\x18\n" + + " \x01(\tH\tR\raccountStatus\x88\x01\x01\x12$\n" + + "\vis_verified\x18\v \x01(\rH\n" + + "R\n" + + "isVerified\x88\x01\x01\x12'\n" + + "\rlast_login_at\x18\f \x01(\x03H\vR\vlastLoginAt\x88\x01\x01\x12'\n" + + "\rlast_login_ip\x18\r \x01(\tH\fR\vlastLoginIp\x88\x01\x01\x12*\n" + + "\x0elogin_attempts\x18\x0e \x01(\x03H\rR\rloginAttempts\x88\x01\x01\x12&\n" + + "\flocked_until\x18\x0f \x01(\x03H\x0eR\vlockedUntil\x88\x01\x01\x12*\n" + + "\x0erecovery_token\x18\x10 \x01(\tH\x0fR\rrecoveryToken\x88\x01\x01\x127\n" + + "\x15recovery_token_expiry\x18\x11 \x01(\x03H\x10R\x13recoveryTokenExpiry\x88\x01\x01\x128\n" + + "\bmetadata\x18\x14 \x01(\v2\x17.google.protobuf.StructH\x11R\bmetadata\x88\x01\x01\x124\n" + + "\x13registration_source\x18\x15 \x01(\tH\x12R\x12registrationSource\x88\x01\x01B\x05\n" + + "\x03_idB\v\n" + + "\t_usernameB\b\n" + + "\x06_emailB\t\n" + + "\a_mobileB\x10\n" + + "\x0e_password_hashB\a\n" + + "\x05_saltB\v\n" + + "\t_nicknameB\t\n" + + "\a_avatarB\t\n" + + "\a_genderB\x11\n" + + "\x0f_account_statusB\x0e\n" + + "\f_is_verifiedB\x10\n" + + "\x0e_last_login_atB\x10\n" + + "\x0e_last_login_ipB\x11\n" + + "\x0f_login_attemptsB\x0f\n" + + "\r_locked_untilB\x11\n" + + "\x0f_recovery_tokenB\x18\n" + + "\x16_recovery_token_expiryB\v\n" + + "\t_metadataB\x16\n" + + "\x14_registration_source\"\x83\x01\n" + + "\rVerifyCodeReq\x12'\n" + + "\x04type\x18\x01 \x01(\x0e2\x13.app.VerifyCodeTypeR\x04type\x123\n" + + "\faccount_type\x18\x02 \x01(\x0e2\x10.app.AccountTypeR\vaccountType\x12\x14\n" + + "\x05value\x18\x03 \x01(\tR\x05value\"Z\n" + + "\x0eVerifyCodeResp\x12\x17\n" + + "\x04code\x18\x01 \x01(\tH\x00R\x04code\x88\x01\x01\x12\x1b\n" + + "\x06expire\x18\x02 \x01(\rH\x01R\x06expire\x88\x01\x01B\a\n" + + "\x05_codeB\t\n" + + "\a_expire*1\n" + + "\vAccountType\x12\v\n" + + "\aUNKNOWN\x10\x00\x12\n" + + "\n" + + "\x06MOBILE\x10\x01\x12\t\n" + + "\x05EMAIL\x10\x02*\xa8\x01\n" + + "\x0eVerifyCodeType\x12\f\n" + + "\bREGISTER\x10\x00\x12\t\n" + + "\x05LOGIN\x10\x01\x12\x12\n" + + "\x0eRESET_PASSWORD\x10\x02\x12\x0e\n" + + "\n" + + "BIND_PHONE\x10\x03\x12\x0e\n" + + "\n" + + "BIND_EMAIL\x10\x04\x12\x10\n" + + "\fUPDATE_PHONE\x10\x05\x12\x10\n" + + "\fUPDATE_EMAIL\x10\x06\x12\f\n" + + "\bWITHDRAW\x10\a\x12\x17\n" + + "\x13CHANGE_PAY_PASSWORD\x10\b2\xb8\x01\n" + + "\x03App\x128\n" + + "\rGetVerifyCode\x12\x12.app.VerifyCodeReq\x1a\x13.app.VerifyCodeResp\x12C\n" + + "\fregisterUser\x12\x18.app.RegisterUserRequest\x1a\x19.app.RegisterUserResponse\x122\n" + + "\tloginUser\x12\x11.app.LoginRequest\x1a\x12.app.LoginResponseB\aZ\x05./appb\x06proto3" + +var ( + file_app_proto_rawDescOnce sync.Once + file_app_proto_rawDescData []byte +) + +func file_app_proto_rawDescGZIP() []byte { + file_app_proto_rawDescOnce.Do(func() { + file_app_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_app_proto_rawDesc), len(file_app_proto_rawDesc))) + }) + return file_app_proto_rawDescData +} + +var file_app_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_app_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_app_proto_goTypes = []any{ + (AccountType)(0), // 0: app.AccountType + (VerifyCodeType)(0), // 1: app.VerifyCodeType + (*AuthToken)(nil), // 2: app.AuthToken + (*LoginRequest)(nil), // 3: app.LoginRequest + (*LoginResponse)(nil), // 4: app.LoginResponse + (*RegisterUserRequest)(nil), // 5: app.RegisterUserRequest + (*RegisterUserResponse)(nil), // 6: app.RegisterUserResponse + (*UserInfo)(nil), // 7: app.UserInfo + (*VerifyCodeReq)(nil), // 8: app.VerifyCodeReq + (*VerifyCodeResp)(nil), // 9: app.VerifyCodeResp + (*timestamppb.Timestamp)(nil), // 10: google.protobuf.Timestamp + (*structpb.Struct)(nil), // 11: google.protobuf.Struct +} +var file_app_proto_depIdxs = []int32{ + 10, // 0: app.AuthToken.issued_at:type_name -> google.protobuf.Timestamp + 10, // 1: app.AuthToken.expires_at:type_name -> google.protobuf.Timestamp + 7, // 2: app.LoginResponse.user:type_name -> app.UserInfo + 2, // 3: app.LoginResponse.auth_token:type_name -> app.AuthToken + 7, // 4: app.RegisterUserResponse.user:type_name -> app.UserInfo + 2, // 5: app.RegisterUserResponse.auth_token:type_name -> app.AuthToken + 11, // 6: app.UserInfo.metadata:type_name -> google.protobuf.Struct + 1, // 7: app.VerifyCodeReq.type:type_name -> app.VerifyCodeType + 0, // 8: app.VerifyCodeReq.account_type:type_name -> app.AccountType + 8, // 9: app.App.GetVerifyCode:input_type -> app.VerifyCodeReq + 5, // 10: app.App.registerUser:input_type -> app.RegisterUserRequest + 3, // 11: app.App.loginUser:input_type -> app.LoginRequest + 9, // 12: app.App.GetVerifyCode:output_type -> app.VerifyCodeResp + 6, // 13: app.App.registerUser:output_type -> app.RegisterUserResponse + 4, // 14: app.App.loginUser:output_type -> app.LoginResponse + 12, // [12:15] is the sub-list for method output_type + 9, // [9:12] is the sub-list for method input_type + 9, // [9:9] is the sub-list for extension type_name + 9, // [9:9] is the sub-list for extension extendee + 0, // [0:9] is the sub-list for field type_name +} + +func init() { file_app_proto_init() } +func file_app_proto_init() { + if File_app_proto != nil { + return + } + file_app_proto_msgTypes[1].OneofWrappers = []any{} + file_app_proto_msgTypes[3].OneofWrappers = []any{} + file_app_proto_msgTypes[5].OneofWrappers = []any{} + file_app_proto_msgTypes[7].OneofWrappers = []any{} + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_app_proto_rawDesc), len(file_app_proto_rawDesc)), + NumEnums: 2, + NumMessages: 8, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_app_proto_goTypes, + DependencyIndexes: file_app_proto_depIdxs, + EnumInfos: file_app_proto_enumTypes, + MessageInfos: file_app_proto_msgTypes, + }.Build() + File_app_proto = out.File + file_app_proto_goTypes = nil + file_app_proto_depIdxs = nil +} diff --git a/rpc/types/app/app_grpc.pb.go b/rpc/types/app/app_grpc.pb.go new file mode 100644 index 0000000..ee436d3 --- /dev/null +++ b/rpc/types/app/app_grpc.pb.go @@ -0,0 +1,213 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.6.0 +// - protoc v3.21.11 +// source: app.proto + +package app + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + App_GetVerifyCode_FullMethodName = "/app.App/GetVerifyCode" + App_RegisterUser_FullMethodName = "/app.App/registerUser" + App_LoginUser_FullMethodName = "/app.App/loginUser" +) + +// AppClient is the client API for App service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// App 服务定义 +type AppClient interface { + // 获取验证码 + // group: code + GetVerifyCode(ctx context.Context, in *VerifyCodeReq, opts ...grpc.CallOption) (*VerifyCodeResp, error) + // 用户注册 + // group: user + RegisterUser(ctx context.Context, in *RegisterUserRequest, opts ...grpc.CallOption) (*RegisterUserResponse, error) + // 用户登录 + // group: user + LoginUser(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) +} + +type appClient struct { + cc grpc.ClientConnInterface +} + +func NewAppClient(cc grpc.ClientConnInterface) AppClient { + return &appClient{cc} +} + +func (c *appClient) GetVerifyCode(ctx context.Context, in *VerifyCodeReq, opts ...grpc.CallOption) (*VerifyCodeResp, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(VerifyCodeResp) + err := c.cc.Invoke(ctx, App_GetVerifyCode_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *appClient) RegisterUser(ctx context.Context, in *RegisterUserRequest, opts ...grpc.CallOption) (*RegisterUserResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(RegisterUserResponse) + err := c.cc.Invoke(ctx, App_RegisterUser_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *appClient) LoginUser(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(LoginResponse) + err := c.cc.Invoke(ctx, App_LoginUser_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// AppServer is the server API for App service. +// All implementations must embed UnimplementedAppServer +// for forward compatibility. +// +// App 服务定义 +type AppServer interface { + // 获取验证码 + // group: code + GetVerifyCode(context.Context, *VerifyCodeReq) (*VerifyCodeResp, error) + // 用户注册 + // group: user + RegisterUser(context.Context, *RegisterUserRequest) (*RegisterUserResponse, error) + // 用户登录 + // group: user + LoginUser(context.Context, *LoginRequest) (*LoginResponse, error) + mustEmbedUnimplementedAppServer() +} + +// UnimplementedAppServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedAppServer struct{} + +func (UnimplementedAppServer) GetVerifyCode(context.Context, *VerifyCodeReq) (*VerifyCodeResp, error) { + return nil, status.Error(codes.Unimplemented, "method GetVerifyCode not implemented") +} +func (UnimplementedAppServer) RegisterUser(context.Context, *RegisterUserRequest) (*RegisterUserResponse, error) { + return nil, status.Error(codes.Unimplemented, "method RegisterUser not implemented") +} +func (UnimplementedAppServer) LoginUser(context.Context, *LoginRequest) (*LoginResponse, error) { + return nil, status.Error(codes.Unimplemented, "method LoginUser not implemented") +} +func (UnimplementedAppServer) mustEmbedUnimplementedAppServer() {} +func (UnimplementedAppServer) testEmbeddedByValue() {} + +// UnsafeAppServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to AppServer will +// result in compilation errors. +type UnsafeAppServer interface { + mustEmbedUnimplementedAppServer() +} + +func RegisterAppServer(s grpc.ServiceRegistrar, srv AppServer) { + // If the following call panics, it indicates UnimplementedAppServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&App_ServiceDesc, srv) +} + +func _App_GetVerifyCode_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(VerifyCodeReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AppServer).GetVerifyCode(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: App_GetVerifyCode_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AppServer).GetVerifyCode(ctx, req.(*VerifyCodeReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _App_RegisterUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RegisterUserRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AppServer).RegisterUser(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: App_RegisterUser_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AppServer).RegisterUser(ctx, req.(*RegisterUserRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _App_LoginUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(LoginRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AppServer).LoginUser(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: App_LoginUser_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AppServer).LoginUser(ctx, req.(*LoginRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// App_ServiceDesc is the grpc.ServiceDesc for App service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var App_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "app.App", + HandlerType: (*AppServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetVerifyCode", + Handler: _App_GetVerifyCode_Handler, + }, + { + MethodName: "registerUser", + Handler: _App_RegisterUser_Handler, + }, + { + MethodName: "loginUser", + Handler: _App_LoginUser_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "app.proto", +}