refactor(api): 重构API模块包路径并生成新的RPC客户端
- 修改了API模块中的包导入路径,从"mingyang-admin-iot-app"改为"mingyang-admin-app" - 为应用服务生成了新的RPC客户端代码文件(app.go) - 更新了RPC服务端配置文件名及内部模块引用路径 - 新增了认证相关消息结构体定义文件(app.pb.go),包括账户类型、验证码类型等枚举以及登录、注册等相关请求响应结构体 - 实现了获取验证码、用户注册和用户登录三个核心接口的客户端调用逻辑 - 调整了RPC服务启动时的环境变量加载方式,并更新了服务注册方法名称
This commit is contained in:
parent
454ce2fb78
commit
cd34f7a6c3
152
Makefile
152
Makefile
|
|
@ -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"
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
# mingyang-admin-iot-app
|
||||
# mingyang-admin-app
|
||||
|
||||
mingyang-admin-iot-app
|
||||
mingyang-admin-app
|
||||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
module mingyang-admin-iot-app/api
|
||||
module mingyang-admin-app-api
|
||||
|
||||
go 1.25.3
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
package svc
|
||||
|
||||
import (
|
||||
"mingyang-admin-iot-app/api/internal/config"
|
||||
"mingyang-admin-app/api/internal/config"
|
||||
)
|
||||
|
||||
type ServiceContext struct {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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)
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
@ -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...)
|
||||
}
|
||||
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -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...)
|
||||
}
|
||||
|
|
@ -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)
|
||||
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
@ -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...)
|
||||
}
|
||||
|
|
@ -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...)
|
||||
}
|
||||
|
|
@ -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...)
|
||||
}
|
||||
|
|
@ -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",
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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)
|
||||
|
|
@ -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)
|
||||
}
|
||||
|
|
@ -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.
|
||||
)
|
||||
|
|
@ -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.
|
||||
|
|
@ -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"},
|
||||
}
|
||||
}
|
||||
|
|
@ -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"),
|
||||
}
|
||||
}
|
||||
|
|
@ -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{}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -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}}
|
||||
|
|
@ -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 }}
|
||||
|
|
@ -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...)
|
||||
}
|
||||
|
|
@ -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=<sensitive>")
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("salt=<sensitive>")
|
||||
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
|
||||
|
|
@ -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()
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
@ -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)
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -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
|
||||
|
|
@ -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()
|
||||
}
|
||||
|
|
@ -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))
|
||||
}
|
||||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
@ -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)
|
||||
}
|
||||
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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=<sensitive>")
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("refresh_token=<sensitive>")
|
||||
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
|
||||
|
|
@ -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()
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
@ -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)
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -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
|
||||
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
Name: rpc.rpc
|
||||
ListenOn: 0.0.0.0:8080
|
||||
Etcd:
|
||||
Hosts:
|
||||
- 127.0.0.1:2379
|
||||
Key: rpc.rpc
|
||||
151
rpc/go.mod
151
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
|
||||
|
|
|
|||
|
|
@ -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=
|
||||
|
|
@ -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"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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"`
|
||||
}
|
||||
|
|
@ -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"`
|
||||
}
|
||||
|
|
@ -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) {
|
||||
|
||||
}
|
||||
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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{}
|
||||
}
|
||||
|
|
@ -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)
|
||||
}
|
||||
|
|
@ -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)
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
package service
|
||||
|
|
@ -0,0 +1 @@
|
|||
package util
|
||||
|
|
@ -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))
|
||||
}
|
||||
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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",
|
||||
}
|
||||
|
|
@ -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...)
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -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",
|
||||
}
|
||||
Loading…
Reference in New Issue