From 538f6e7e3911f1c13bbe945daa97b67a6f98aacf Mon Sep 17 00:00:00 2001 From: huanglei19951029 <81128461+huanglei19951029@users.noreply.github.com> Date: Fri, 12 Dec 2025 16:11:01 +0800 Subject: [PATCH] =?UTF-8?q?feat(app):=20=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E6=9C=8D=E5=8A=A1=E5=B9=B6=E6=9B=B4=E6=96=B0?= =?UTF-8?q?API=E6=8E=A5=E5=8F=A3=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增应用服务入口文件 app.go,配置服务启动参数及跨域支持 - 更新 appclient 包,增加基础响应结构体和分页用户查询、初始化数据库等 RPC 接口 - 修改 app.proto 文件,完善消息类型定义,包括认证令牌、用户信息、验证码等结构 - 添加 app.yaml 配置文件,设定服务名称、端口、超时时间及日志配置 - 删除旧版无用的 api.api 相关文件,清理冗余代码 - 生成完整的 Swagger 文档描述文件 app.json,包含所有 API 路径与模型定义 --- api/Makefile | 138 +++ api/api.api | 15 - api/api.go | 34 - api/app.go | 53 + api/app.json | 924 +++++++++++++++++ api/desc/all.api | 2 + api/desc/app/user.api | 130 +++ api/desc/base.api | 230 +++++ api/etc/api-api.yaml | 3 - api/etc/app.yaml | 34 + api/go.mod | 118 +++ api/go.sum | 317 ++++++ api/internal/config/config.go | 11 +- api/internal/handler/apihandler.go | 31 - .../handler/base/init_database_handler.go | 32 + api/internal/handler/routes.go | 34 +- .../handler/user/get_verify_code_handler.go | 45 + api/internal/handler/user/register_handler.go | 45 + api/internal/i18n/locale/en.json | 25 + api/internal/i18n/locale/zh.json | 25 + api/internal/i18n/vars.go | 8 + api/internal/logic/apilogic.go | 33 - .../logic/base/init_database_logic.go | 29 + .../logic/user/get_verify_code_logic.go | 41 + api/internal/logic/user/login_logic.go | 60 ++ api/internal/logic/user/register_logic.go | 63 ++ .../middleware/authority_middleware.go | 28 + api/internal/svc/service_context.go | 29 + api/internal/svc/servicecontext.go | 18 - api/internal/types/types.go | 364 ++++++- go.work | 6 + rpc/Makefile | 2 +- rpc/app.proto | 92 +- rpc/appclient/app.go | 26 + rpc/desc/app/code.proto | 4 +- rpc/desc/app/user.proto | 47 +- rpc/desc/base.proto | 54 + rpc/ent/ent.go | 2 +- rpc/ent/intercept/intercept.go | 2 +- rpc/ent/migrate/schema.go | 44 +- rpc/ent/mutation.go | 95 +- rpc/ent/runtime.go | 26 +- rpc/ent/schema/user.go | 2 +- rpc/ent/schema/userloginlog.go | 12 +- rpc/ent/schema/userthirdauth.go | 14 +- rpc/ent/set_not_nil.go | 12 +- rpc/ent/tx.go | 2 +- rpc/ent/userloginlog.go | 2 +- rpc/ent/userloginlog/userloginlog.go | 3 +- rpc/ent/userthirdauth.go | 18 +- rpc/ent/userthirdauth/userthirdauth.go | 16 +- rpc/ent/userthirdauth/where.go | 106 +- rpc/ent/userthirdauth_create.go | 35 +- rpc/ent/userthirdauth_update.go | 82 +- rpc/etc/app.yaml | 21 +- rpc/go.mod | 3 + rpc/internal/config/config.go | 11 +- .../logic/base/init_database_logic.go | 35 + rpc/internal/logic/cacherepo/cache_repo.go | 4 +- .../logic/code/get_verify_code_logic.go | 117 ++- .../{user_logic.go => create_user_login.go} | 6 + rpc/internal/logic/user/list_users_logic.go | 31 + rpc/internal/logic/user/login_user_logic.go | 52 +- .../logic/user/register_user_logic.go | 57 +- rpc/internal/server/app_server.go | 12 + rpc/internal/svc/service_context.go | 46 + rpc/internal/svc/servicecontext.go | 13 - rpc/types/app/app.pb.go | 965 ++++++++++++++---- rpc/types/app/app_grpc.pb.go | 90 +- 69 files changed, 4436 insertions(+), 650 deletions(-) create mode 100644 api/Makefile delete mode 100644 api/api.api delete mode 100644 api/api.go create mode 100644 api/app.go create mode 100644 api/app.json create mode 100644 api/desc/all.api create mode 100644 api/desc/app/user.api create mode 100644 api/desc/base.api delete mode 100644 api/etc/api-api.yaml create mode 100644 api/etc/app.yaml create mode 100644 api/go.sum delete mode 100644 api/internal/handler/apihandler.go create mode 100644 api/internal/handler/base/init_database_handler.go create mode 100644 api/internal/handler/user/get_verify_code_handler.go create mode 100644 api/internal/handler/user/register_handler.go create mode 100644 api/internal/i18n/locale/en.json create mode 100644 api/internal/i18n/locale/zh.json create mode 100644 api/internal/i18n/vars.go delete mode 100644 api/internal/logic/apilogic.go create mode 100644 api/internal/logic/base/init_database_logic.go create mode 100644 api/internal/logic/user/get_verify_code_logic.go create mode 100644 api/internal/logic/user/login_logic.go create mode 100644 api/internal/logic/user/register_logic.go create mode 100644 api/internal/middleware/authority_middleware.go create mode 100644 api/internal/svc/service_context.go delete mode 100644 api/internal/svc/servicecontext.go create mode 100644 go.work create mode 100644 rpc/desc/base.proto create mode 100644 rpc/internal/logic/base/init_database_logic.go rename rpc/internal/logic/user/{user_logic.go => create_user_login.go} (93%) create mode 100644 rpc/internal/logic/user/list_users_logic.go create mode 100644 rpc/internal/svc/service_context.go delete mode 100644 rpc/internal/svc/servicecontext.go diff --git a/api/Makefile b/api/Makefile new file mode 100644 index 0000000..ddb80a3 --- /dev/null +++ b/api/Makefile @@ -0,0 +1,138 @@ +# 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=api + +# Swagger type, support yml,json | Swagger 文件类型,支持yml,json +SWAGGER_TYPE=json + +# Ent enabled features | Ent 启用的官方特性 +ENT_FEATURE=sql/execquery,intercept + +# Auto generate API data for initialization | 自动生成 API 初始化数据 +AUTO_API_INIT_DATA=true + +# 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; + $(GO) install github.com/go-swagger/go-swagger/cmd/swagger@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-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: gen-api +gen-api: # Generate API files | 生成 API 的代码 + goctls api go --api ./desc/all.api --dir ./ --trans_err=true --style=$(PROJECT_STYLE) + swagger generate spec --output=./$(SERVICE_STYLE).$(SWAGGER_TYPE) --scan-models --exclude-deps + @echo "Generate API 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-api-ent-logic +gen-api-ent-logic: # Generate CRUD logic from Ent, need to set model and group | 根据 Ent 生成 CRUD 代码,需要设置 model 和 group + goctls api ent --schema=./ent/schema --style=$(PROJECT_STYLE) --api_service_name=$(SERVICE) --output=./ --model=$(model) --group=$(group) --i18n=$(PROJECT_I18N) --overwrite=true --api_data=$(AUTO_API_INIT_DATA) + @echo "Generate CRUD 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 + + + +.PHONY: format-api +format-api: # Format API files | 格式化 API 文件 + @echo "Formatting API files..." + @if [ -f "./desc/all.api" ]; then \ + goctl api format --dir ./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 \ No newline at end of file diff --git a/api/api.api b/api/api.api deleted file mode 100644 index 9a5b7ee..0000000 --- a/api/api.api +++ /dev/null @@ -1,15 +0,0 @@ -syntax = "v1" - -type Request { - Name string `path:"name,options=you|me"` -} - -type Response { - Message string `json:"message"` -} - -service api-api { - @handler ApiHandler - get /from/:name (Request) returns (Response) -} - diff --git a/api/api.go b/api/api.go deleted file mode 100644 index 7ae125b..0000000 --- a/api/api.go +++ /dev/null @@ -1,34 +0,0 @@ -// Code scaffolded by goctl. Safe to edit. -// goctl 1.9.2 - -package main - -import ( - "flag" - "fmt" - - "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" -) - -var configFile = flag.String("f", "etc/api-api.yaml", "the config file") - -func main() { - flag.Parse() - - var c config.Config - conf.MustLoad(*configFile, &c) - - server := rest.MustNewServer(c.RestConf) - defer server.Stop() - - ctx := svc.NewServiceContext(c) - handler.RegisterHandlers(server, ctx) - - fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port) - server.Start() -} diff --git a/api/app.go b/api/app.go new file mode 100644 index 0000000..84b46ae --- /dev/null +++ b/api/app.go @@ -0,0 +1,53 @@ +// app +// +// Description: app service +// +// Schemes: http, https +// Host: localhost:0 +// BasePath: / +// Version: 0.0.1 +// SecurityDefinitions: +// Token: +// type: apiKey +// name: Authorization +// in: header +// Security: +// Token: +// Consumes: +// - application/json +// +// Produces: +// - application/json +// +// swagger:meta +package main + +import ( + "flag" + "fmt" + + "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" +) + +var configFile = flag.String("f", "etc/app.yaml", "the config file") + +func main() { + flag.Parse() + + var c config.Config + conf.MustLoad(*configFile, &c, conf.UseEnv()) + + server := rest.MustNewServer(c.RestConf, rest.WithCors(c.CROSConf.Address)) + defer server.Stop() + + ctx := svc.NewServiceContext(c) + handler.RegisterHandlers(server, ctx) + + fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port) + server.Start() +} diff --git a/api/app.json b/api/app.json new file mode 100644 index 0000000..906c5e1 --- /dev/null +++ b/api/app.json @@ -0,0 +1,924 @@ +{ + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "schemes": [ + "http", + "https" + ], + "swagger": "2.0", + "info": { + "description": "Description: app service", + "title": "app", + "version": "0.0.1" + }, + "host": "localhost:0", + "basePath": "/", + "paths": { + "/get/verifyCode": { + "post": { + "description": "GetVerifyCode | 获取验证码", + "tags": [ + "user" + ], + "summary": "GetVerifyCode | 获取验证码", + "operationId": "GetVerifyCode", + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "type": "object", + "$ref": "#/definitions/VerifyCodeReq" + } + } + ], + "responses": { + "200": { + "description": "VerifyCodeResp", + "schema": { + "$ref": "#/definitions/VerifyCodeResp" + } + } + } + } + }, + "/init/database": { + "get": { + "description": "Initialize database | 初始化数据库", + "tags": [ + "base" + ], + "summary": "Initialize database | 初始化数据库", + "operationId": "InitDatabase", + "responses": { + "200": { + "description": "BaseMsgResp", + "schema": { + "$ref": "#/definitions/BaseMsgResp" + } + } + } + } + }, + "/login": { + "post": { + "description": "Login | 登录", + "tags": [ + "user" + ], + "summary": "Login | 登录", + "operationId": "Login", + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "type": "object", + "$ref": "#/definitions/LoginReq" + } + } + ], + "responses": { + "200": { + "description": "LoginResp", + "schema": { + "$ref": "#/definitions/LoginResp" + } + } + } + } + }, + "/register": { + "post": { + "description": "Register | 注册", + "tags": [ + "user" + ], + "summary": "Register | 注册", + "operationId": "Register", + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "type": "object", + "$ref": "#/definitions/RegisterReq" + } + } + ], + "responses": { + "200": { + "description": "RegisterResp", + "schema": { + "$ref": "#/definitions/RegisterResp" + } + } + } + } + } + }, + "definitions": { + "AuthToken": { + "type": "object", + "properties": { + "accessToken": { + "description": "access_token", + "type": "string", + "x-go-name": "AccessToken" + }, + "accessTokenExpires": { + "description": "access_token_expires", + "type": "integer", + "format": "int64", + "x-go-name": "AccessTokenExpires" + }, + "refreshToken": { + "description": "refresh_token", + "type": "string", + "x-go-name": "RefreshToken" + }, + "refreshTokenExpires": { + "description": "refresh_token_expires", + "type": "integer", + "format": "int64", + "x-go-name": "RefreshTokenExpires" + }, + "tokenType": { + "description": "token_type 类型", + "type": "string", + "x-go-name": "TokenType" + } + }, + "x-go-package": "mingyang-admin-app-api/internal/types" + }, + "BaseDataInfo": { + "description": "The basic response with data | 基础带数据信息", + "type": "object", + "properties": { + "code": { + "description": "Error code | 错误代码", + "type": "integer", + "format": "int64", + "x-go-name": "Code" + }, + "data": { + "description": "Data | 数据", + "type": "string", + "x-go-name": "Data" + }, + "msg": { + "description": "Message | 提示信息", + "type": "string", + "x-go-name": "Msg" + } + }, + "x-go-package": "mingyang-admin-app-api/internal/types" + }, + "BaseIDInfo": { + "description": "The base ID response data | 基础ID信息", + "type": "object", + "properties": { + "createdAt": { + "description": "Create date | 创建日期", + "type": "integer", + "format": "int64", + "x-go-name": "CreatedAt" + }, + "id": { + "description": "ID", + "type": "string", + "format": "uint64", + "x-go-name": "Id" + }, + "updatedAt": { + "description": "Update date | 更新日期", + "type": "integer", + "format": "int64", + "x-go-name": "UpdatedAt" + } + }, + "x-go-package": "mingyang-admin-app-api/internal/types" + }, + "BaseIDInt32Info": { + "description": "The base ID response data (int32) | 基础ID信息 (int32)", + "type": "object", + "properties": { + "createdAt": { + "description": "Create date | 创建日期", + "type": "integer", + "format": "int64", + "x-go-name": "CreatedAt" + }, + "id": { + "description": "ID", + "type": "integer", + "format": "int32", + "x-go-name": "Id" + }, + "updatedAt": { + "description": "Update date | 更新日期", + "type": "integer", + "format": "int64", + "x-go-name": "UpdatedAt" + } + }, + "x-go-package": "mingyang-admin-app-api/internal/types" + }, + "BaseIDInt64Info": { + "description": "The base ID response data (int64) | 基础ID信息 (int64)", + "type": "object", + "properties": { + "createdAt": { + "description": "Create date | 创建日期", + "type": "integer", + "format": "int64", + "x-go-name": "CreatedAt" + }, + "id": { + "description": "ID", + "type": "integer", + "format": "int64", + "x-go-name": "Id" + }, + "updatedAt": { + "description": "Update date | 更新日期", + "type": "integer", + "format": "int64", + "x-go-name": "UpdatedAt" + } + }, + "x-go-package": "mingyang-admin-app-api/internal/types" + }, + "BaseIDStringInfo": { + "description": "The base ID response data (string) | 基础ID信息 (string)", + "type": "object", + "properties": { + "createdAt": { + "description": "Create date | 创建日期", + "type": "integer", + "format": "int64", + "x-go-name": "CreatedAt" + }, + "id": { + "description": "ID", + "type": "string", + "x-go-name": "Id" + }, + "updatedAt": { + "description": "Update date | 更新日期", + "type": "integer", + "format": "int64", + "x-go-name": "UpdatedAt" + } + }, + "x-go-package": "mingyang-admin-app-api/internal/types" + }, + "BaseIDUint32Info": { + "description": "The base ID response data (uint32) | 基础ID信息 (uint32)", + "type": "object", + "properties": { + "createdAt": { + "description": "Create date | 创建日期", + "type": "integer", + "format": "int64", + "x-go-name": "CreatedAt" + }, + "id": { + "description": "ID", + "type": "integer", + "format": "uint32", + "x-go-name": "Id" + }, + "updatedAt": { + "description": "Update date | 更新日期", + "type": "integer", + "format": "int64", + "x-go-name": "UpdatedAt" + } + }, + "x-go-package": "mingyang-admin-app-api/internal/types" + }, + "BaseListInfo": { + "description": "The basic response with data | 基础带数据信息", + "type": "object", + "properties": { + "data": { + "description": "Data | 数据", + "type": "string", + "x-go-name": "Data" + }, + "total": { + "description": "The total number of data | 数据总数", + "type": "integer", + "format": "uint64", + "x-go-name": "Total" + } + }, + "x-go-package": "mingyang-admin-app-api/internal/types" + }, + "BaseMsgResp": { + "description": "The basic response without data | 基础不带数据信息", + "type": "object", + "properties": { + "code": { + "description": "Error code | 错误代码", + "type": "integer", + "format": "int64", + "x-go-name": "Code" + }, + "msg": { + "description": "Message | 提示信息", + "type": "string", + "x-go-name": "Msg" + } + }, + "x-go-package": "mingyang-admin-app-api/internal/types" + }, + "BaseUUIDInfo": { + "description": "The base UUID response data | 基础UUID信息", + "type": "object", + "properties": { + "createdAt": { + "description": "Create date | 创建日期", + "type": "integer", + "format": "int64", + "x-go-name": "CreatedAt" + }, + "id": { + "description": "ID", + "type": "string", + "x-go-name": "Id" + }, + "updatedAt": { + "description": "Update date | 更新日期", + "type": "integer", + "format": "int64", + "x-go-name": "UpdatedAt" + } + }, + "x-go-package": "mingyang-admin-app-api/internal/types" + }, + "IDInt32PathReq": { + "description": "Basic ID request (int32) | 基础ID地址参数请求 (int32)", + "type": "object", + "required": [ + "Id" + ], + "properties": { + "Id": { + "description": "ID", + "type": "integer", + "format": "int32" + } + }, + "x-go-package": "mingyang-admin-app-api/internal/types" + }, + "IDInt32Req": { + "description": "Basic ID request (int32) | 基础ID参数请求 (int32)", + "type": "object", + "required": [ + "id" + ], + "properties": { + "id": { + "description": "ID", + "type": "integer", + "format": "int32", + "x-go-name": "Id" + } + }, + "x-go-package": "mingyang-admin-app-api/internal/types" + }, + "IDInt64PathReq": { + "description": "Basic ID request (int64) | 基础ID地址参数请求 (int64)", + "type": "object", + "required": [ + "Id" + ], + "properties": { + "Id": { + "description": "ID", + "type": "integer", + "format": "int64" + } + }, + "x-go-package": "mingyang-admin-app-api/internal/types" + }, + "IDInt64Req": { + "description": "Basic ID request (int64) | 基础ID参数请求 (int64)", + "type": "object", + "required": [ + "id" + ], + "properties": { + "id": { + "description": "ID", + "type": "integer", + "format": "int64", + "x-go-name": "Id" + } + }, + "x-go-package": "mingyang-admin-app-api/internal/types" + }, + "IDPathReq": { + "description": "Basic ID request | 基础ID地址参数请求", + "type": "object", + "required": [ + "Id" + ], + "properties": { + "Id": { + "description": "ID", + "type": "integer", + "format": "uint64" + } + }, + "x-go-package": "mingyang-admin-app-api/internal/types" + }, + "IDReq": { + "description": "Basic ID request | 基础ID参数请求", + "type": "object", + "required": [ + "id" + ], + "properties": { + "id": { + "description": "ID", + "type": "string", + "format": "uint64", + "x-go-name": "Id" + } + }, + "x-go-package": "mingyang-admin-app-api/internal/types" + }, + "IDStringPathReq": { + "description": "Basic ID request (string) | 基础ID地址参数请求 (string)", + "type": "object", + "required": [ + "Id" + ], + "properties": { + "Id": { + "description": "ID", + "type": "string" + } + }, + "x-go-package": "mingyang-admin-app-api/internal/types" + }, + "IDStringReq": { + "description": "Basic ID request (string) | 基础ID参数请求 (string)", + "type": "object", + "required": [ + "id" + ], + "properties": { + "id": { + "description": "ID", + "type": "string", + "x-go-name": "Id" + } + }, + "x-go-package": "mingyang-admin-app-api/internal/types" + }, + "IDUint32PathReq": { + "description": "Basic ID request (uint32) | 基础ID地址参数请求 (uint32)", + "type": "object", + "required": [ + "Id" + ], + "properties": { + "Id": { + "description": "ID", + "type": "integer", + "format": "uint32" + } + }, + "x-go-package": "mingyang-admin-app-api/internal/types" + }, + "IDUint32Req": { + "description": "Basic ID request (uint32) | 基础ID参数请求 (uint32)", + "type": "object", + "required": [ + "id" + ], + "properties": { + "id": { + "description": "ID", + "type": "integer", + "format": "uint32", + "x-go-name": "Id" + } + }, + "x-go-package": "mingyang-admin-app-api/internal/types" + }, + "IDsInt32Req": { + "description": "Basic IDs request (int32) | 基础ID数组参数请求 (int32)", + "type": "object", + "required": [ + "ids" + ], + "properties": { + "ids": { + "description": "IDs", + "type": "array", + "items": { + "type": "integer", + "format": "int32" + }, + "x-go-name": "Ids" + } + }, + "x-go-package": "mingyang-admin-app-api/internal/types" + }, + "IDsInt64Req": { + "description": "Basic IDs request (int64) | 基础ID数组参数请求 (int64)", + "type": "object", + "required": [ + "ids" + ], + "properties": { + "ids": { + "description": "IDs", + "type": "array", + "items": { + "type": "integer", + "format": "int64" + }, + "x-go-name": "Ids" + } + }, + "x-go-package": "mingyang-admin-app-api/internal/types" + }, + "IDsReq": { + "description": "Basic IDs request | 基础ID数组参数请求", + "type": "object", + "required": [ + "ids" + ], + "properties": { + "ids": { + "description": "IDs", + "type": "array", + "items": { + "type": "integer", + "format": "uint64" + }, + "x-go-name": "Ids" + } + }, + "x-go-package": "mingyang-admin-app-api/internal/types" + }, + "IDsStringReq": { + "description": "Basic IDs request (string) | 基础ID数组参数请求 (string)", + "type": "object", + "required": [ + "ids" + ], + "properties": { + "ids": { + "description": "IDs", + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Ids" + } + }, + "x-go-package": "mingyang-admin-app-api/internal/types" + }, + "IDsUint32Req": { + "description": "Basic IDs request (uint32) | 基础ID数组参数请求 (uint32)", + "type": "object", + "required": [ + "ids" + ], + "properties": { + "ids": { + "description": "IDs", + "type": "array", + "items": { + "type": "integer", + "format": "uint32" + }, + "x-go-name": "Ids" + } + }, + "x-go-package": "mingyang-admin-app-api/internal/types" + }, + "LoginReq": { + "type": "object", + "properties": { + "clientIp": { + "description": "ClientIP", + "type": "string", + "x-go-name": "ClientIP" + }, + "loginPlatform": { + "description": "登录系统", + "type": "string", + "x-go-name": "LoginPlatform" + }, + "loginType": { + "description": "登录方式", + "type": "string", + "x-go-name": "LoginType" + }, + "password": { + "description": "Password", + "type": "string", + "x-go-name": "Password" + }, + "userName": { + "description": "UserName or Email or Mobile", + "type": "string", + "x-go-name": "UserName" + } + }, + "x-go-package": "mingyang-admin-app-api/internal/types" + }, + "LoginResp": { + "type": "object", + "properties": { + "AuthToken": { + "$ref": "#/definitions/AuthToken" + }, + "UserInfo": { + "$ref": "#/definitions/UserInfo" + }, + "code": { + "description": "Error code | 错误代码", + "type": "integer", + "format": "int64", + "x-go-name": "Code" + }, + "msg": { + "description": "Message | 提示信息", + "type": "string", + "x-go-name": "Msg" + } + }, + "x-go-package": "mingyang-admin-app-api/internal/types" + }, + "PageInfo": { + "description": "The page request parameters | 列表请求参数", + "type": "object", + "required": [ + "page", + "pageSize" + ], + "properties": { + "page": { + "description": "Page number | 第几页", + "type": "integer", + "format": "uint64", + "minimum": 0, + "x-go-name": "Page" + }, + "pageSize": { + "description": "Page size | 单页数据行数", + "type": "integer", + "format": "uint64", + "maximum": 100000, + "x-go-name": "PageSize" + } + }, + "x-go-package": "mingyang-admin-app-api/internal/types" + }, + "RegisterReq": { + "type": "object", + "properties": { + "accountType": { + "description": "账户注册类型:手机或邮箱", + "type": "integer", + "format": "uint8", + "x-go-name": "AccountType" + }, + "birthday": { + "description": "生日", + "type": "integer", + "format": "uint32", + "x-go-name": "Birthday" + }, + "captcha": { + "description": "验证码", + "type": "string", + "x-go-name": "Captcha" + }, + "captchaId": { + "description": "验证码ID", + "type": "string", + "x-go-name": "CaptchaId" + }, + "gender": { + "description": "Gender male or female or other , 男,女,其他", + "type": "string", + "x-go-name": "Gender" + }, + "nickName": { + "description": "昵称", + "type": "string", + "x-go-name": "NickName" + }, + "passwordHash": { + "description": "密码加密后的值", + "type": "string", + "x-go-name": "PasswordHash" + }, + "registerSource": { + "description": "注册来源 app,pc", + "type": "string", + "x-go-name": "RegisterSource" + }, + "sex": { + "description": "性别", + "type": "integer", + "format": "uint8", + "x-go-name": "Sex" + }, + "value": { + "description": "手机号或邮箱地址注册", + "type": "string", + "x-go-name": "Value" + }, + "verificationType": { + "description": "VerificationType 类型 1 手机 2 邮箱", + "type": "integer", + "format": "uint32", + "x-go-name": "VerificationType" + } + }, + "x-go-package": "mingyang-admin-app-api/internal/types" + }, + "RegisterResp": { + "type": "object", + "properties": { + "authToken": { + "$ref": "#/definitions/AuthToken" + }, + "userInfo": { + "$ref": "#/definitions/UserInfo" + } + }, + "x-go-package": "mingyang-admin-app-api/internal/types" + }, + "UUIDPathReq": { + "description": "Basic UUID request in path | 基础UUID地址参数请求", + "type": "object", + "required": [ + "Id" + ], + "properties": { + "Id": { + "description": "ID", + "type": "string" + } + }, + "x-go-package": "mingyang-admin-app-api/internal/types" + }, + "UUIDReq": { + "description": "Basic UUID request | 基础UUID参数请求", + "type": "object", + "required": [ + "id" + ], + "properties": { + "id": { + "description": "ID", + "type": "string", + "maxLength": 36, + "minLength": 36, + "x-go-name": "Id" + } + }, + "x-go-package": "mingyang-admin-app-api/internal/types" + }, + "UUIDsReq": { + "description": "Basic UUID array request | 基础UUID数组参数请求", + "type": "object", + "required": [ + "ids" + ], + "properties": { + "ids": { + "description": "Ids", + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Ids" + } + }, + "x-go-package": "mingyang-admin-app-api/internal/types" + }, + "UserInfo": { + "type": "object", + "properties": { + "avatar": { + "description": "头像", + "type": "string", + "x-go-name": "Avatar" + }, + "birthday": { + "description": "生日", + "type": "integer", + "format": "int64", + "x-go-name": "Birthday" + }, + "email": { + "description": "邮箱", + "type": "string", + "x-go-name": "Email" + }, + "gender": { + "description": "Gender male or female or other , 男,女,其他", + "type": "string", + "x-go-name": "Gender" + }, + "id": { + "description": "用户ID", + "type": "integer", + "format": "uint64", + "x-go-name": "Id" + }, + "mobile": { + "description": "手机号", + "type": "string", + "x-go-name": "Mobile" + }, + "nickName": { + "description": "昵称", + "type": "string", + "x-go-name": "NickName" + }, + "registerType": { + "description": "账户注册类型:\n1 手机 2 邮箱", + "type": "integer", + "format": "uint32", + "x-go-name": "RegisterType" + }, + "username": { + "description": "用户名", + "type": "string", + "x-go-name": "Username" + } + }, + "x-go-package": "mingyang-admin-app-api/internal/types" + }, + "VerifyCodeReq": { + "type": "object", + "properties": { + "accountType": { + "description": "账户注册类型:手机或邮箱", + "type": "integer", + "format": "uint8", + "x-go-name": "AccountType" + }, + "value": { + "description": "手机号或邮箱地址", + "type": "string", + "x-go-name": "Value" + }, + "verifyCodeType": { + "description": "验证码类型", + "type": "integer", + "format": "uint8", + "x-go-name": "VerifyCodeType" + } + }, + "x-go-package": "mingyang-admin-app-api/internal/types" + }, + "VerifyCodeResp": { + "type": "object", + "properties": { + "captchaCode": { + "description": "验证码", + "type": "string", + "x-go-name": "CaptchaCode" + }, + "expireTime": { + "description": "过期时间", + "type": "integer", + "format": "uint32", + "x-go-name": "ExpireTime" + } + }, + "x-go-package": "mingyang-admin-app-api/internal/types" + } + }, + "securityDefinitions": { + "Token": { + "type": "apiKey", + "name": "Authorization", + "in": "header" + } + }, + "security": [ + { + "Token": [] + } + ] +} \ No newline at end of file diff --git a/api/desc/all.api b/api/desc/all.api new file mode 100644 index 0000000..d4c5ba0 --- /dev/null +++ b/api/desc/all.api @@ -0,0 +1,2 @@ +import "base.api" +import "./app/user.api" \ No newline at end of file diff --git a/api/desc/app/user.api b/api/desc/app/user.api new file mode 100644 index 0000000..97ac72b --- /dev/null +++ b/api/desc/app/user.api @@ -0,0 +1,130 @@ +syntax = "v1" + +info ( + title: "type title here" + desc: "type desc here" + author: "type author here" + email: "type email here" + version: "type version here" +) + +type ( + VerifyCodeReq { + //验证码类型 + VerifyCodeType uint8 `json:"verifyCodeType,optional"` + // 账户注册类型:手机或邮箱 + AccountType uint8 `json:"accountType,optional"` + // 手机号或邮箱地址 + Value string `json:"value,optional"` + } + VerifyCodeResp { + // 验证码 + CaptchaCode string `json:"captchaCode,optional"` + // 过期时间 + ExpireTime uint32 `json:"expireTime,optional"` + + } + RegisterReq { + // 账户注册类型:手机或邮箱 + AccountType uint8 `json:"accountType,optional"` + // 手机号或邮箱地址注册 + Value string `json:"value,optional"` + // 昵称 + NickName string `json:"nickName,optional"` + // 性别 + Sex uint8 `json:"sex,optional"` + //生日 + Birthday uint32 `json:"birthday,optional"` + // 密码加密后的值 + PasswordHash *string `json:"passwordHash,optional"` + //验证码 + Captcha string `json:"captcha,optional"` + // 验证码ID + CaptchaId string `json:"captchaId,optional"` + //VerificationType 类型 1 手机 2 邮箱 + VerificationType *uint32 `json:"verificationType,optional"` + // Gender male or female or other , 男,女,其他 + Gender *string `json:"gender,optional"` + // 注册来源 app,pc + RegisterSource *string `json:"registerSource,optional"` + } + + + + RegisterResp{ + // token信息 + AuthToken *AuthToken `json:"authToken,optional"` + User *UserInfo `json:"userInfo,optional"` + } + + AuthToken{ + // access_token + AccessToken string `json:"accessToken,optional"` + // refresh_token + RefreshToken string `json:"refreshToken,optional"` + // token_type 类型 + TokenType string `json:"tokenType,optional"` + //access_token_expires + AccessTokenExpires int64 `json:"accessTokenExpires,optional"` + //refresh_token_expires + RefreshTokenExpires int64 `json:"refreshTokenExpires,optional"` + } + + UserInfo{ + // 用户ID + Id uint64 `json:"id,optional"` + // 昵称 + NickName string `json:"nickName,optional"` + //生日 + Birthday int64 `json:"birthday,optional"` + // 头像 + Avatar string `json:"avatar,optional"` + // Gender male or female or other , 男,女,其他 + Gender *string `json:"gender,optional"` + // 账户注册类型: + // 1 手机 2 邮箱 + RegisterType *uint32 `json:"registerType,optional"` + // 手机号 + Mobile *string `json:"mobile,optional"` + // 用户名 + Username string `json:"username,optional"` + //邮箱 + Email *string `json:"email,optional"` + } + + LoginReq{ + // UserName or Email or Mobile + UserName string `json:"userName"` + // Password + Password string `json:"password"` + // ClientIP + ClientIP string `json:"clientIp"` + // 登录方式 + LoginType string `json:"loginType"` + // 登录系统 + LoginPlatform string `json:"loginPlatform"` + } + LoginResp{ + BaseMsgResp + AuthToken *AuthToken + UserInfo *UserInfo + } +) + +@server ( + jwt: Auth + group: user + middleware: Authority +) +service App { + // GetVerifyCode | 获取验证码 + @handler getVerifyCode + post /get/verifyCode (VerifyCodeReq) returns (VerifyCodeResp) + // Register | 注册 + @handler register + post /register (RegisterReq) returns (RegisterResp) + // Login | 登录 + @handler login + post /login (LoginReq) returns (LoginResp) +} + diff --git a/api/desc/base.api b/api/desc/base.api new file mode 100644 index 0000000..062ed6a --- /dev/null +++ b/api/desc/base.api @@ -0,0 +1,230 @@ +syntax = "v1" + +// The basic response with data | 基础带数据信息 +type BaseDataInfo { + // Error code | 错误代码 + Code int `json:"code"` + // Message | 提示信息 + Msg string `json:"msg"` + // Data | 数据 + Data string `json:"data,omitempty"` +} + +// The basic response with data | 基础带数据信息 +type BaseListInfo { + // The total number of data | 数据总数 + Total uint64 `json:"total"` + // Data | 数据 + Data string `json:"data,omitempty"` +} + +// The basic response without data | 基础不带数据信息 +type BaseMsgResp { + // Error code | 错误代码 + Code int `json:"code"` + // Message | 提示信息 + Msg string `json:"msg"` +} + +// The page request parameters | 列表请求参数 +type PageInfo { + // Page number | 第几页 + Page uint64 `json:"page" validate:"required,number,gt=0"` + // Page size | 单页数据行数 + PageSize uint64 `json:"pageSize" validate:"required,number,lt=100000"` +} + +// Basic ID request | 基础ID参数请求 +type IDReq { + // ID + // Required: true + Id uint64 `json:"id,string" validate:"number"` +} + +// Basic IDs request | 基础ID数组参数请求 +type IDsReq { + // IDs + // Required: true + Ids []uint64 `json:"ids,[]string"` +} + +// Basic ID request | 基础ID地址参数请求 +type IDPathReq { + // ID + // Required: true + Id uint64 `path:"id"` +} + +// Basic ID request (int32) | 基础ID参数请求 (int32) +type IDInt32Req { + // ID + // Required: true + Id int32 `json:"id" validate:"number"` +} + +// Basic IDs request (int32) | 基础ID数组参数请求 (int32) +type IDsInt32Req { + // IDs + // Required: true + Ids []int32 `json:"ids"` +} + +// Basic ID request (int32) | 基础ID地址参数请求 (int32) +type IDInt32PathReq { + // ID + // Required: true + Id int32 `path:"id"` +} + +// Basic ID request (uint32) | 基础ID参数请求 (uint32) +type IDUint32Req { + // ID + // Required: true + Id uint32 `json:"id" validate:"number"` +} + +// Basic IDs request (uint32) | 基础ID数组参数请求 (uint32) +type IDsUint32Req { + // IDs + // Required: true + Ids []uint32 `json:"ids"` +} + +// Basic ID request (uint32) | 基础ID地址参数请求 (uint32) +type IDUint32PathReq { + // ID + // Required: true + Id uint32 `path:"id"` +} + +// Basic ID request (int64) | 基础ID参数请求 (int64) +type IDInt64Req { + // ID + // Required: true + Id int64 `json:"id" validate:"number"` +} + +// Basic IDs request (int64) | 基础ID数组参数请求 (int64) +type IDsInt64Req { + // IDs + // Required: true + Ids []int64 `json:"ids"` +} + +// Basic ID request (int64) | 基础ID地址参数请求 (int64) +type IDInt64PathReq { + // ID + // Required: true + Id int64 `path:"id"` +} + +// Basic ID request (string) | 基础ID参数请求 (string) +type IDStringReq { + // ID + // Required: true + Id string `json:"id"` +} + +// Basic IDs request (string) | 基础ID数组参数请求 (string) +type IDsStringReq { + // IDs + // Required: true + Ids []string `json:"ids"` +} + +// Basic ID request (string) | 基础ID地址参数请求 (string) +type IDStringPathReq { + // ID + // Required: true + Id string `path:"id"` +} + +// Basic UUID request in path | 基础UUID地址参数请求 +type UUIDPathReq { + // ID + // Required: true + Id string `path:"id"` +} + +// Basic UUID request | 基础UUID参数请求 +type UUIDReq { + // ID + Id string `json:"id" validate:"required,len=36"` +} + +// Basic UUID array request | 基础UUID数组参数请求 +type UUIDsReq { + // Ids + // Required: true + Ids []string `json:"ids"` +} + +// The base ID response data | 基础ID信息 +type BaseIDInfo { + // ID + Id *uint64 `json:"id,string,optional"` + // Create date | 创建日期 + CreatedAt *int64 `json:"createdAt,optional"` + // Update date | 更新日期 + UpdatedAt *int64 `json:"updatedAt,optional"` +} + +// The base ID response data (int64) | 基础ID信息 (int64) +type BaseIDInt64Info { + // ID + Id *int64 `json:"id,optional"` + // Create date | 创建日期 + CreatedAt *int64 `json:"createdAt,optional"` + // Update date | 更新日期 + UpdatedAt *int64 `json:"updatedAt,optional"` +} + +// The base ID response data (int32) | 基础ID信息 (int32) +type BaseIDInt32Info { + // ID + Id *int32 `json:"id,optional"` + // Create date | 创建日期 + CreatedAt *int64 `json:"createdAt,optional"` + // Update date | 更新日期 + UpdatedAt *int64 `json:"updatedAt,optional"` +} + +// The base ID response data (uint32) | 基础ID信息 (uint32) +type BaseIDUint32Info { + // ID + Id *uint32 `json:"id,optional"` + // Create date | 创建日期 + CreatedAt *int64 `json:"createdAt,optional"` + // Update date | 更新日期 + UpdatedAt *int64 `json:"updatedAt,optional"` +} + +// The base UUID response data | 基础UUID信息 +type BaseUUIDInfo { + // ID + Id *string `json:"id,optional"` + // Create date | 创建日期 + CreatedAt *int64 `json:"createdAt,optional"` + // Update date | 更新日期 + UpdatedAt *int64 `json:"updatedAt,optional"` +} + +// The base ID response data (string) | 基础ID信息 (string) +type BaseIDStringInfo { + // ID + Id *string `json:"id,optional"` + // Create date | 创建日期 + CreatedAt *int64 `json:"createdAt,optional"` + // Update date | 更新日期 + UpdatedAt *int64 `json:"updatedAt,optional"` +} + +@server ( + group: base +) +service App { + // Initialize database | 初始化数据库 + @handler initDatabase + get /init/database returns (BaseMsgResp) +} + diff --git a/api/etc/api-api.yaml b/api/etc/api-api.yaml deleted file mode 100644 index 9a1e7db..0000000 --- a/api/etc/api-api.yaml +++ /dev/null @@ -1,3 +0,0 @@ -Name: api-api -Host: 0.0.0.0 -Port: 8888 diff --git a/api/etc/app.yaml b/api/etc/app.yaml new file mode 100644 index 0000000..fc13b18 --- /dev/null +++ b/api/etc/app.yaml @@ -0,0 +1,34 @@ +Name: App.api +Host: 0.0.0.0 +Port: 9902 +Timeout: 4000 + + +CROSConf: + Address: '*' + +Log: + ServiceName: AppApiLogger + Mode: console + Path: /home/data/logs/App/api + Level: info + Compress: false + Encoding: json + KeepDays: 7 + StackCoolDownMillis: 100 + +RedisConf: + Host: 192.168.201.58:6379 + Db: 0 + +AppRpc: + # Etcd: + # Hosts: + #$ - 192.168.201.58:2379 + # Key: core.rpc + Target: 127.0.0.1:9901 + Enabled: true + + +I18nConf: + Dir: \ No newline at end of file diff --git a/api/go.mod b/api/go.mod index 18dce02..17da826 100644 --- a/api/go.mod +++ b/api/go.mod @@ -1,3 +1,121 @@ module mingyang-admin-app-api go 1.25.3 + +require ( + 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 +) + +require ( + entgo.io/ent v0.14.5 // indirect + filippo.io/edwards25519 v1.1.0 // indirect + github.com/beorn7/perks v1.0.1 // 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.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.13.0 // indirect + github.com/fatih/color v1.18.0 // indirect + github.com/fxamacker/cbor/v2 v2.9.0 // indirect + github.com/gabriel-vasile/mimetype v1.4.10 // 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.22.2 // indirect + github.com/go-openapi/jsonreference v0.21.3 // 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/go-playground/locales v0.14.1 // indirect + github.com/go-playground/universal-translator v0.18.1 // indirect + github.com/go-playground/validator/v10 v10.27.0 // indirect + github.com/go-sql-driver/mysql v1.9.3 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang-jwt/jwt/v5 v5.3.0 // indirect + github.com/golang/protobuf v1.5.4 // indirect + github.com/google/gnostic-models v0.7.0 // indirect + github.com/google/go-cmp v0.7.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.27.3 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/klauspost/compress v1.18.1 // indirect + github.com/leodido/go-urn v1.4.0 // indirect + github.com/lib/pq v1.10.9 // indirect + github.com/mattn/go-colorable v0.1.14 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + github.com/mattn/go-sqlite3 v1.14.32 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // 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/nicksnyder/go-i18n/v2 v2.6.0 // indirect + github.com/openzipkin/zipkin-go v0.4.3 // 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/spaolacci/murmur3 v1.1.0 // indirect + github.com/x448/float16 v0.8.4 // indirect + go.etcd.io/etcd/api/v3 v3.6.6 // indirect + go.etcd.io/etcd/client/pkg/v3 v3.6.6 // indirect + go.etcd.io/etcd/client/v3 v3.6.6 // indirect + go.opentelemetry.io/auto/sdk v1.2.1 // indirect + go.opentelemetry.io/otel v1.38.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.9.0 // indirect + go.uber.org/automaxprocs v1.6.0 // 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/crypto v0.44.0 // indirect + golang.org/x/net v0.47.0 // indirect + golang.org/x/oauth2 v0.33.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 + google.golang.org/grpc v1.76.0 // indirect + google.golang.org/protobuf v1.36.10 // 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 + k8s.io/api v0.34.2 // indirect + k8s.io/apimachinery v0.34.2 // indirect + k8s.io/client-go v0.34.2 // indirect + k8s.io/klog/v2 v2.130.1 // indirect + k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 // indirect + k8s.io/utils v0.0.0-20251002143259-bc988d571ff4 // indirect + sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect + sigs.k8s.io/randfill v1.0.0 // indirect + sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect + sigs.k8s.io/yaml v1.6.0 // indirect +) + +replace github.com/zeromicro/go-zero v1.9.1 => github.com/suyuan32/simple-admin-tools v1.9.1 diff --git a/api/go.sum b/api/go.sum new file mode 100644 index 0000000..4a92910 --- /dev/null +++ b/api/go.sum @@ -0,0 +1,317 @@ +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/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg= +github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= +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/alicebob/miniredis/v2 v2.35.0 h1:QwLphYqCEAo1eu1TqPRN2jgVMPBweeQcR21jeqDCONI= +github.com/alicebob/miniredis/v2 v2.35.0/go.mod h1:TcL7YfarKPGDAthEtl5NBeHZfeUQj6OXMm/+iu5cLMM= +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/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/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/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/gabriel-vasile/mimetype v1.4.10 h1:zyueNbySn/z8mJZHLt6IPw0KoZsiQNszIpU+bX4+ZK0= +github.com/gabriel-vasile/mimetype v1.4.10/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s= +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/jsonpointer v0.22.2 h1:JDQEe4B9j6K3tQ7HQQTZfjR59IURhjjLxet2FB4KHyg= +github.com/go-openapi/jsonpointer v0.22.2/go.mod h1:0lBbqeRsQ5lIanv3LHZBrmRGHLHcQoOXQnf88fHlGWo= +github.com/go-openapi/jsonreference v0.21.3 h1:96Dn+MRPa0nYAR8DR1E03SblB5FJvh7W6krPI0Z7qMc= +github.com/go-openapi/jsonreference v0.21.3/go.mod h1:RqkUP0MrLf37HqxZxrIAtTWW4ZJIK1VzduhXYBEeGc4= +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-openapi/testify/v2 v2.0.2 h1:X999g3jeLcoY8qctY/c/Z8iBHTbwLz7R2WXd6Ub6wls= +github.com/go-openapi/testify/v2 v2.0.2/go.mod h1:HCPmvFFnheKK2BuwSA0TbbdxJ3I16pjwMkYkP4Ywn54= +github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= +github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= +github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= +github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= +github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= +github.com/go-playground/validator/v10 v10.27.0 h1:w8+XrWVMhGkxOaaowyKH35gFydVHOvC0/uWoy2Fzwn4= +github.com/go-playground/validator/v10 v10.27.0/go.mod h1:I5QpIEbmr8On7W0TktmJAumgzX4CA1XNl4ZmDuVHKKo= +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/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/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/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= +github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= +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-sqlite3 v1.14.32 h1:JD12Ag3oLy1zQA+BNn74xRgaBbdhbNIDYvQUEuuErjs= +github.com/mattn/go-sqlite3 v1.14.32/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= +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/nicksnyder/go-i18n/v2 v2.6.0 h1:C/m2NNWNiTB6SK4Ao8df5EWm3JETSTIGNXBpMJTxzxQ= +github.com/nicksnyder/go-i18n/v2 v2.6.0/go.mod h1:88sRqr0C6OPyJn0/KRNaEz1uWorjxIKP7rUUcvycecE= +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/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= +github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= +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= +go.etcd.io/etcd/api/v3 v3.6.6 h1:mcaMp3+7JawWv69p6QShYWS8cIWUOl32bFLb6qf8pOQ= +go.etcd.io/etcd/api/v3 v3.6.6/go.mod h1:f/om26iXl2wSkcTA1zGQv8reJRSLVdoEBsi4JdfMrx4= +go.etcd.io/etcd/client/pkg/v3 v3.6.6 h1:uoqgzSOv2H9KlIF5O1Lsd8sW+eMLuV6wzE3q5GJGQNs= +go.etcd.io/etcd/client/pkg/v3 v3.6.6/go.mod h1:YngfUVmvsvOJ2rRgStIyHsKtOt9SZI2aBJrZiWJhCbI= +go.etcd.io/etcd/client/v3 v3.6.6 h1:G5z1wMf5B9SNexoxOHUGBaULurOZPIgGPsW6CN492ec= +go.etcd.io/etcd/client/v3 v3.6.6/go.mod h1:36Qv6baQ07znPR3+n7t+Rk5VHEzVYPvFfGmfF4wBHV8= +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/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.33.0 h1:4Q+qn+E5z8gPRJfmRy7C2gGG3T4jIprK6aSYgTXGRpo= +golang.org/x/oauth2 v0.33.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/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/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.2 h1:fsSUNZhV+bnL6Aqrp6O7lMTy6o5x2C4XLjnh//8SLYY= +k8s.io/api v0.34.2/go.mod h1:MMBPaWlED2a8w4RSeanD76f7opUoypY8TFYkSM+3XHw= +k8s.io/apimachinery v0.34.2 h1:zQ12Uk3eMHPxrsbUJgNF8bTauTVR2WgqJsTmwTE/NW4= +k8s.io/apimachinery v0.34.2/go.mod h1:/GwIlEcWuTX9zKIg2mbw0LRFIsXwrfoVxn+ef0X13lw= +k8s.io/client-go v0.34.2 h1:Co6XiknN+uUZqiddlfAjT68184/37PS4QAzYvQvDR8M= +k8s.io/client-go v0.34.2/go.mod h1:2VYDl1XXJsdcAxw7BenFslRQX28Dxz91U9MWKjX97fE= +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= +sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 h1:IpInykpT6ceI+QxKBbEflcR5EXP7sU1kvOlxwZh5txg= +sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730/go.mod h1:mdzfpAEoE6DHQEN0uh9ZbOCuHbLK5wOm7dK4ctXE9Tg= +sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= +sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/structured-merge-diff/v6 v6.3.0 h1:jTijUJbW353oVOd9oTlifJqOGEkUw2jB/fXCbTiQEco= +sigs.k8s.io/structured-merge-diff/v6 v6.3.0/go.mod h1:M3W8sfWvn2HhQDIbGWj3S099YozAsymCo/wrT5ohRUE= +sigs.k8s.io/yaml v1.6.0 h1:G8fkbMSAFqgEFgh4b1wmtzDnioxFCUgTZhlbj5P9QYs= +sigs.k8s.io/yaml v1.6.0/go.mod h1:796bPqUfzR/0jLAl6XjHl3Ck7MiyVv8dbTdyT3/pMf4= diff --git a/api/internal/config/config.go b/api/internal/config/config.go index 9b36470..f70ebde 100644 --- a/api/internal/config/config.go +++ b/api/internal/config/config.go @@ -3,8 +3,17 @@ package config -import "github.com/zeromicro/go-zero/rest" +import ( + "github.com/saas-mingyang/mingyang-admin-common/config" + "github.com/saas-mingyang/mingyang-admin-common/i18n" + "github.com/zeromicro/go-zero/rest" + "github.com/zeromicro/go-zero/zrpc" +) type Config struct { rest.RestConf + RedisConf config.RedisConf + CROSConf config.CROSConf + I18nConf i18n.Conf + AppRpc zrpc.RpcClientConf } diff --git a/api/internal/handler/apihandler.go b/api/internal/handler/apihandler.go deleted file mode 100644 index 081f360..0000000 --- a/api/internal/handler/apihandler.go +++ /dev/null @@ -1,31 +0,0 @@ -// Code scaffolded by goctl. Safe to edit. -// goctl 1.9.2 - -package handler - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "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 { - return func(w http.ResponseWriter, r *http.Request) { - var req types.Request - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := logic.NewApiLogic(r.Context(), svcCtx) - resp, err := l.Api(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/base/init_database_handler.go b/api/internal/handler/base/init_database_handler.go new file mode 100644 index 0000000..6330b60 --- /dev/null +++ b/api/internal/handler/base/init_database_handler.go @@ -0,0 +1,32 @@ +package base + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + + "mingyang-admin-app-api/internal/logic/base" + "mingyang-admin-app-api/internal/svc" +) + +// swagger:route get /init/database base InitDatabase +// +// Initialize database | 初始化数据库 +// +// Initialize database | 初始化数据库 +// +// Responses: +// 200: BaseMsgResp + +func InitDatabaseHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + l := base.NewInitDatabaseLogic(r.Context(), svcCtx) + resp, err := l.InitDatabase() + if err != nil { + err = svcCtx.Trans.TransError(r.Context(), err) + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/api/internal/handler/routes.go b/api/internal/handler/routes.go index e1cf9ea..352ce08 100644 --- a/api/internal/handler/routes.go +++ b/api/internal/handler/routes.go @@ -1,12 +1,14 @@ // Code generated by goctl. DO NOT EDIT. -// goctl 1.9.2 +// goctls v1.12.7 package handler import ( "net/http" - "mingyang-admin-app/api/internal/svc" + base "mingyang-admin-app-api/internal/handler/base" + user "mingyang-admin-app-api/internal/handler/user" + "mingyang-admin-app-api/internal/svc" "github.com/zeromicro/go-zero/rest" ) @@ -16,9 +18,33 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { []rest.Route{ { Method: http.MethodGet, - Path: "/from/:name", - Handler: ApiHandler(serverCtx), + Path: "/init/database", + Handler: base.InitDatabaseHandler(serverCtx), }, }, ) + + server.AddRoutes( + rest.WithMiddlewares( + []rest.Middleware{serverCtx.Authority}, + []rest.Route{ + { + Method: http.MethodPost, + Path: "/get/verifyCode", + Handler: user.GetVerifyCodeHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/register", + Handler: user.RegisterHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/login", + Handler: user.LoginHandler(serverCtx), + }, + }..., + ), + //rest.WithJwt(serverCtx.Config.Auth.AccessSecret), + ) } diff --git a/api/internal/handler/user/get_verify_code_handler.go b/api/internal/handler/user/get_verify_code_handler.go new file mode 100644 index 0000000..4f837df --- /dev/null +++ b/api/internal/handler/user/get_verify_code_handler.go @@ -0,0 +1,45 @@ +package user + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + + "mingyang-admin-app-api/internal/logic/user" + "mingyang-admin-app-api/internal/svc" + "mingyang-admin-app-api/internal/types" +) + +// swagger:route post /get/verifyCode user GetVerifyCode +// +// GetVerifyCode | 获取验证码 +// +// GetVerifyCode | 获取验证码 +// +// Parameters: +// + name: body +// require: true +// in: body +// type: VerifyCodeReq +// +// Responses: +// 200: VerifyCodeResp + +func GetVerifyCodeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.VerifyCodeReq + if err := httpx.Parse(r, &req, true); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := user.NewGetVerifyCodeLogic(r.Context(), svcCtx) + resp, err := l.GetVerifyCode(&req) + if err != nil { + err = svcCtx.Trans.TransError(r.Context(), err) + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/api/internal/handler/user/register_handler.go b/api/internal/handler/user/register_handler.go new file mode 100644 index 0000000..925d397 --- /dev/null +++ b/api/internal/handler/user/register_handler.go @@ -0,0 +1,45 @@ +package user + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + + "mingyang-admin-app-api/internal/logic/user" + "mingyang-admin-app-api/internal/svc" + "mingyang-admin-app-api/internal/types" +) + +// swagger:route post /register user Register +// +// Register | 注册 +// +// Register | 注册 +// +// Parameters: +// + name: body +// require: true +// in: body +// type: RegisterReq +// +// Responses: +// 200: RegisterResp + +func RegisterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.RegisterReq + if err := httpx.Parse(r, &req, true); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := user.NewRegisterLogic(r.Context(), svcCtx) + resp, err := l.Register(&req) + if err != nil { + err = svcCtx.Trans.TransError(r.Context(), err) + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/api/internal/i18n/locale/en.json b/api/internal/i18n/locale/en.json new file mode 100644 index 0000000..da5e89d --- /dev/null +++ b/api/internal/i18n/locale/en.json @@ -0,0 +1,25 @@ +{ + "common": { + "success": "Successfully", + "failed": "Failed", + "updateSuccess": "Update successfully", + "updateFailed": "Update failed", + "createSuccess": "Create successfully", + "createFailed": "Create failed", + "deleteSuccess": "Delete successfully", + "deleteFailed": "Delete failed", + "targetNotExist": "Target does not exist", + "databaseError": "Database error", + "redisError": "Redis error", + "permissionDeny": "User does not have permission to access this interface", + "constraintError": "Operation failed: Data conflict", + "validationError": "Operation failed: Validation failed", + "notSingularError": "Operation failed: Data not unique", + "serviceUnavailable": "Service is unavailable, please check if the service is enabled", + "cacheError": "Cache error" + }, + "init": { + "alreadyInit": "The database had been initialized.", + "initializeIsRunning": "The initialization is running..." + } +} diff --git a/api/internal/i18n/locale/zh.json b/api/internal/i18n/locale/zh.json new file mode 100644 index 0000000..b2f0677 --- /dev/null +++ b/api/internal/i18n/locale/zh.json @@ -0,0 +1,25 @@ +{ + "common": { + "success": "成功", + "failed": "失败", + "updateSuccess": "更新成功", + "updateFailed": "更新失败", + "createSuccess": "新建成功", + "createFailed": "新建失败", + "deleteSuccess": "删除成功", + "deleteFailed": "删除失败", + "targetNotExist": "目标不存在", + "databaseError": "数据库错误", + "redisError": "Redis 错误", + "permissionDeny": "用户无权限访问此接口", + "constraintError": "操作失败: 数据冲突", + "validationError": "操作失败: 校验失败", + "notSingularError": "操作失败: 数据不唯一", + "serviceUnavailable": "服务不可用,请检查服务是否已启用", + "cacheError": "缓存出错" + }, + "init": { + "initializeIsRunning": "正在初始化...", + "alreadyInit": "数据库已被初始化。" + } +} diff --git a/api/internal/i18n/vars.go b/api/internal/i18n/vars.go new file mode 100644 index 0000000..9f90630 --- /dev/null +++ b/api/internal/i18n/vars.go @@ -0,0 +1,8 @@ +package i18n + +import ( + "embed" +) + +//go:embed locale/*.json +var LocaleFS embed.FS diff --git a/api/internal/logic/apilogic.go b/api/internal/logic/apilogic.go deleted file mode 100644 index 24dfbbc..0000000 --- a/api/internal/logic/apilogic.go +++ /dev/null @@ -1,33 +0,0 @@ -// Code scaffolded by goctl. Safe to edit. -// goctl 1.9.2 - -package logic - -import ( - "context" - - "mingyang-admin-app/api/internal/svc" - "mingyang-admin-app/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ApiLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewApiLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ApiLogic { - return &ApiLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ApiLogic) Api(req *types.Request) (resp *types.Response, err error) { - // todo: add your logic here and delete this line - - return -} diff --git a/api/internal/logic/base/init_database_logic.go b/api/internal/logic/base/init_database_logic.go new file mode 100644 index 0000000..3f1ec9a --- /dev/null +++ b/api/internal/logic/base/init_database_logic.go @@ -0,0 +1,29 @@ +package base + +import ( + "context" + + "mingyang-admin-app-api/internal/svc" + "mingyang-admin-app-api/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type InitDatabaseLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewInitDatabaseLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InitDatabaseLogic { + return &InitDatabaseLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *InitDatabaseLogic) InitDatabase() (resp *types.BaseMsgResp, err error) { + l.svcCtx.AppRpc.InitDatabase(l.ctx, nil) + return +} diff --git a/api/internal/logic/user/get_verify_code_logic.go b/api/internal/logic/user/get_verify_code_logic.go new file mode 100644 index 0000000..ea3bdc6 --- /dev/null +++ b/api/internal/logic/user/get_verify_code_logic.go @@ -0,0 +1,41 @@ +package user + +import ( + "context" + "github.com/pkg/errors" + "mingyang-admin-app-api/internal/svc" + "mingyang-admin-app-api/internal/types" + "mingyang-admin-app-rpc/types/app" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetVerifyCodeLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetVerifyCodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetVerifyCodeLogic { + return &GetVerifyCodeLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetVerifyCodeLogic) GetVerifyCode(req *types.VerifyCodeReq) (resp *types.VerifyCodeResp, err error) { + verifyCode, err := l.svcCtx.AppRpc.GetVerifyCode(l.ctx, &app.VerifyCodeReq{ + AccountType: app.AccountType(req.AccountType), + Value: req.Value, + Type: app.VerifyCodeType(req.VerifyCodeType), + }) + if err != nil { + logx.Errorw("failed to get verify code", logx.Field("detail", err)) + return nil, errors.New("failed to get verify code") + } + return &types.VerifyCodeResp{ + ExpireTime: verifyCode.Expire, + CaptchaCode: verifyCode.CaptchaCode, + }, nil +} diff --git a/api/internal/logic/user/login_logic.go b/api/internal/logic/user/login_logic.go new file mode 100644 index 0000000..d997d2a --- /dev/null +++ b/api/internal/logic/user/login_logic.go @@ -0,0 +1,60 @@ +package user + +import ( + "context" + "mingyang-admin-app-rpc/types/app" + + "mingyang-admin-app-api/internal/svc" + "mingyang-admin-app-api/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type LoginLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewLoginLogic(ctx context.Context, svcCtx *svc.ServiceContext) *LoginLogic { + return &LoginLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *LoginLogic) Login(req *types.LoginReq) (resp *types.LoginResp, err error) { + loginUser, err := l.svcCtx.AppRpc.LoginUser(l.ctx, &app.LoginRequest{ + Username: &req.UserName, + Password: &req.Password, + ClientIp: &req.ClientIP, + LoginTyp: &req.LoginType, + LoginPlatform: &req.LoginPlatform, + }) + if err != nil { + return nil, err + } + token := loginUser.AuthToken + user := loginUser.User + return &types.LoginResp{ + BaseMsgResp: types.BaseMsgResp{ + Code: 0, + Msg: "登录成功", + }, + AuthToken: &types.AuthToken{ + AccessToken: token.AccessToken, + RefreshToken: token.RefreshToken, + TokenType: token.TokenType, + AccessTokenExpires: token.AccessTokenExpires.Seconds, + RefreshTokenExpires: token.RefreshTokenExpires.Seconds, + }, + UserInfo: &types.UserInfo{ + Id: user.GetId(), + Username: user.GetUsername(), + NickName: user.GetNickname(), + Avatar: user.GetAvatar(), + Gender: user.Gender, + }, + }, nil +} diff --git a/api/internal/logic/user/register_logic.go b/api/internal/logic/user/register_logic.go new file mode 100644 index 0000000..26185bf --- /dev/null +++ b/api/internal/logic/user/register_logic.go @@ -0,0 +1,63 @@ +package user + +import ( + "context" + "mingyang-admin-app-rpc/types/app" + + "mingyang-admin-app-api/internal/svc" + "mingyang-admin-app-api/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type RegisterLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewRegisterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RegisterLogic { + return &RegisterLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *RegisterLogic) Register(req *types.RegisterReq) (resp *types.RegisterResp, err error) { + user, err := l.svcCtx.AppRpc.RegisterUser(l.ctx, &app.RegisterUserRequest{ + Email: &req.Value, + Password: req.PasswordHash, + Username: &req.Value, + NickName: &req.NickName, + Mobile: &req.Value, + Captcha: &req.Captcha, + VerificationType: req.VerificationType, + Gender: req.Gender, + RegistrationSource: req.RegisterSource, + }) + if err != nil { + return nil, err + } + getUser := user.GetUser() + token := user.GetAuthToken() + return &types.RegisterResp{ + User: &types.UserInfo{ + Id: getUser.GetId(), + Username: getUser.GetUsername(), + Mobile: getUser.Mobile, + NickName: getUser.GetNickname(), + Gender: getUser.Gender, + Avatar: getUser.GetAvatar(), + Birthday: getUser.GetBirthdayAt(), + Email: getUser.Email, + }, + AuthToken: &types.AuthToken{ + AccessToken: token.GetAccessToken(), + RefreshToken: token.GetRefreshToken(), + TokenType: token.GetTokenType(), + AccessTokenExpires: token.AccessTokenExpires.Seconds, + RefreshTokenExpires: token.RefreshTokenExpires.Seconds, + }, + }, nil +} diff --git a/api/internal/middleware/authority_middleware.go b/api/internal/middleware/authority_middleware.go new file mode 100644 index 0000000..2c5b87a --- /dev/null +++ b/api/internal/middleware/authority_middleware.go @@ -0,0 +1,28 @@ +package middleware + +import ( + "github.com/redis/go-redis/v9" + "net/http" +) + +type AuthorityMiddleware struct { + Rds redis.UniversalClient +} + +func NewAuthorityMiddleware(rds redis.UniversalClient) *AuthorityMiddleware { + return &AuthorityMiddleware{ + Rds: rds, + } +} + +func (m *AuthorityMiddleware) Handle(next http.HandlerFunc) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + /* // get the path + obj := r.URL.Path + // get the method + act := r.Method + // get the role id + roleIds := strings.Split(r.Context().Value("roleId").(string), ",")*/ + next(w, r) + } +} diff --git a/api/internal/svc/service_context.go b/api/internal/svc/service_context.go new file mode 100644 index 0000000..4665f2e --- /dev/null +++ b/api/internal/svc/service_context.go @@ -0,0 +1,29 @@ +package svc + +import ( + "github.com/saas-mingyang/mingyang-admin-common/i18n" + "github.com/zeromicro/go-zero/rest" + "github.com/zeromicro/go-zero/zrpc" + "mingyang-admin-app-api/internal/config" + i18n2 "mingyang-admin-app-api/internal/i18n" + "mingyang-admin-app-api/internal/middleware" + "mingyang-admin-app-rpc/appclient" +) + +type ServiceContext struct { + Config config.Config + Trans *i18n.Translator + Authority rest.Middleware + AppRpc appclient.App +} + +func NewServiceContext(c config.Config) *ServiceContext { + trans := i18n.NewTranslator(c.I18nConf, i18n2.LocaleFS) + rds := c.RedisConf.MustNewUniversalRedis() + return &ServiceContext{ + Authority: middleware.NewAuthorityMiddleware(rds).Handle, + Config: c, + Trans: trans, + AppRpc: appclient.NewApp(zrpc.NewClientIfEnable(c.AppRpc)), + } +} diff --git a/api/internal/svc/servicecontext.go b/api/internal/svc/servicecontext.go deleted file mode 100644 index bd2a792..0000000 --- a/api/internal/svc/servicecontext.go +++ /dev/null @@ -1,18 +0,0 @@ -// Code scaffolded by goctl. Safe to edit. -// goctl 1.9.2 - -package svc - -import ( - "mingyang-admin-app/api/internal/config" -) - -type ServiceContext struct { - Config config.Config -} - -func NewServiceContext(c config.Config) *ServiceContext { - return &ServiceContext{ - Config: c, - } -} diff --git a/api/internal/types/types.go b/api/internal/types/types.go index 70c354f..2d3fd15 100644 --- a/api/internal/types/types.go +++ b/api/internal/types/types.go @@ -1,12 +1,364 @@ // Code generated by goctl. DO NOT EDIT. -// goctl 1.9.2 - package types -type Request struct { - Name string `path:"name,options=you|me"` +// The basic response with data | 基础带数据信息 +// swagger:model BaseDataInfo +type BaseDataInfo struct { + // Error code | 错误代码 + Code int `json:"code"` + // Message | 提示信息 + Msg string `json:"msg"` + // Data | 数据 + Data string `json:"data,omitempty"` } -type Response struct { - Message string `json:"message"` +// The basic response with data | 基础带数据信息 +// swagger:model BaseListInfo +type BaseListInfo struct { + // The total number of data | 数据总数 + Total uint64 `json:"total"` + // Data | 数据 + Data string `json:"data,omitempty"` +} + +// The basic response without data | 基础不带数据信息 +// swagger:model BaseMsgResp +type BaseMsgResp struct { + // Error code | 错误代码 + Code int `json:"code"` + // Message | 提示信息 + Msg string `json:"msg"` +} + +// The page request parameters | 列表请求参数 +// swagger:model PageInfo +type PageInfo struct { + // Page number | 第几页 + // required : true + // min : 0 + Page uint64 `json:"page" validate:"required,number,gt=0"` + // Page size | 单页数据行数 + // required : true + // max : 100000 + PageSize uint64 `json:"pageSize" validate:"required,number,lt=100000"` +} + +// Basic ID request | 基础ID参数请求 +// swagger:model IDReq +type IDReq struct { + // ID + // Required: true + Id uint64 `json:"id,string" validate:"number"` +} + +// Basic IDs request | 基础ID数组参数请求 +// swagger:model IDsReq +type IDsReq struct { + // IDs + // Required: true + Ids []uint64 `json:"ids,[]string"` +} + +// Basic ID request | 基础ID地址参数请求 +// swagger:model IDPathReq +type IDPathReq struct { + // ID + // Required: true + Id uint64 `path:"id"` +} + +// Basic ID request (int32) | 基础ID参数请求 (int32) +// swagger:model IDInt32Req +type IDInt32Req struct { + // ID + // Required: true + Id int32 `json:"id" validate:"number"` +} + +// Basic IDs request (int32) | 基础ID数组参数请求 (int32) +// swagger:model IDsInt32Req +type IDsInt32Req struct { + // IDs + // Required: true + Ids []int32 `json:"ids"` +} + +// Basic ID request (int32) | 基础ID地址参数请求 (int32) +// swagger:model IDInt32PathReq +type IDInt32PathReq struct { + // ID + // Required: true + Id int32 `path:"id"` +} + +// Basic ID request (uint32) | 基础ID参数请求 (uint32) +// swagger:model IDUint32Req +type IDUint32Req struct { + // ID + // Required: true + Id uint32 `json:"id" validate:"number"` +} + +// Basic IDs request (uint32) | 基础ID数组参数请求 (uint32) +// swagger:model IDsUint32Req +type IDsUint32Req struct { + // IDs + // Required: true + Ids []uint32 `json:"ids"` +} + +// Basic ID request (uint32) | 基础ID地址参数请求 (uint32) +// swagger:model IDUint32PathReq +type IDUint32PathReq struct { + // ID + // Required: true + Id uint32 `path:"id"` +} + +// Basic ID request (int64) | 基础ID参数请求 (int64) +// swagger:model IDInt64Req +type IDInt64Req struct { + // ID + // Required: true + Id int64 `json:"id" validate:"number"` +} + +// Basic IDs request (int64) | 基础ID数组参数请求 (int64) +// swagger:model IDsInt64Req +type IDsInt64Req struct { + // IDs + // Required: true + Ids []int64 `json:"ids"` +} + +// Basic ID request (int64) | 基础ID地址参数请求 (int64) +// swagger:model IDInt64PathReq +type IDInt64PathReq struct { + // ID + // Required: true + Id int64 `path:"id"` +} + +// Basic ID request (string) | 基础ID参数请求 (string) +// swagger:model IDStringReq +type IDStringReq struct { + // ID + // Required: true + Id string `json:"id"` +} + +// Basic IDs request (string) | 基础ID数组参数请求 (string) +// swagger:model IDsStringReq +type IDsStringReq struct { + // IDs + // Required: true + Ids []string `json:"ids"` +} + +// Basic ID request (string) | 基础ID地址参数请求 (string) +// swagger:model IDStringPathReq +type IDStringPathReq struct { + // ID + // Required: true + Id string `path:"id"` +} + +// Basic UUID request in path | 基础UUID地址参数请求 +// swagger:model UUIDPathReq +type UUIDPathReq struct { + // ID + // Required: true + Id string `path:"id"` +} + +// Basic UUID request | 基础UUID参数请求 +// swagger:model UUIDReq +type UUIDReq struct { + // ID + // required : true + // max length : 36 + // min length : 36 + Id string `json:"id" validate:"required,len=36"` +} + +// Basic UUID array request | 基础UUID数组参数请求 +// swagger:model UUIDsReq +type UUIDsReq struct { + // Ids + // Required: true + Ids []string `json:"ids"` +} + +// The base ID response data | 基础ID信息 +// swagger:model BaseIDInfo +type BaseIDInfo struct { + // ID + Id *uint64 `json:"id,string,optional"` + // Create date | 创建日期 + CreatedAt *int64 `json:"createdAt,optional"` + // Update date | 更新日期 + UpdatedAt *int64 `json:"updatedAt,optional"` +} + +// The base ID response data (int64) | 基础ID信息 (int64) +// swagger:model BaseIDInt64Info +type BaseIDInt64Info struct { + // ID + Id *int64 `json:"id,optional"` + // Create date | 创建日期 + CreatedAt *int64 `json:"createdAt,optional"` + // Update date | 更新日期 + UpdatedAt *int64 `json:"updatedAt,optional"` +} + +// The base ID response data (int32) | 基础ID信息 (int32) +// swagger:model BaseIDInt32Info +type BaseIDInt32Info struct { + // ID + Id *int32 `json:"id,optional"` + // Create date | 创建日期 + CreatedAt *int64 `json:"createdAt,optional"` + // Update date | 更新日期 + UpdatedAt *int64 `json:"updatedAt,optional"` +} + +// The base ID response data (uint32) | 基础ID信息 (uint32) +// swagger:model BaseIDUint32Info +type BaseIDUint32Info struct { + // ID + Id *uint32 `json:"id,optional"` + // Create date | 创建日期 + CreatedAt *int64 `json:"createdAt,optional"` + // Update date | 更新日期 + UpdatedAt *int64 `json:"updatedAt,optional"` +} + +// The base UUID response data | 基础UUID信息 +// swagger:model BaseUUIDInfo +type BaseUUIDInfo struct { + // ID + Id *string `json:"id,optional"` + // Create date | 创建日期 + CreatedAt *int64 `json:"createdAt,optional"` + // Update date | 更新日期 + UpdatedAt *int64 `json:"updatedAt,optional"` +} + +// The base ID response data (string) | 基础ID信息 (string) +// swagger:model BaseIDStringInfo +type BaseIDStringInfo struct { + // ID + Id *string `json:"id,optional"` + // Create date | 创建日期 + CreatedAt *int64 `json:"createdAt,optional"` + // Update date | 更新日期 + UpdatedAt *int64 `json:"updatedAt,optional"` +} + +// swagger:model VerifyCodeReq +type VerifyCodeReq struct { + //验证码类型 + VerifyCodeType uint8 `json:"verifyCodeType,optional"` + // 账户注册类型:手机或邮箱 + AccountType uint8 `json:"accountType,optional"` + // 手机号或邮箱地址 + Value string `json:"value,optional"` +} + +// swagger:model VerifyCodeResp +type VerifyCodeResp struct { + // 验证码 + CaptchaCode string `json:"captchaCode,optional"` + // 过期时间 + ExpireTime uint32 `json:"expireTime,optional"` +} + +// swagger:model RegisterReq +type RegisterReq struct { + // 账户注册类型:手机或邮箱 + AccountType uint8 `json:"accountType,optional"` + // 手机号或邮箱地址注册 + Value string `json:"value,optional"` + // 昵称 + NickName string `json:"nickName,optional"` + // 性别 + Sex uint8 `json:"sex,optional"` + //生日 + Birthday uint32 `json:"birthday,optional"` + // 密码加密后的值 + PasswordHash *string `json:"passwordHash,optional"` + //验证码 + Captcha string `json:"captcha,optional"` + // 验证码ID + CaptchaId string `json:"captchaId,optional"` + //VerificationType 类型 1 手机 2 邮箱 + VerificationType *uint32 `json:"verificationType,optional"` + // Gender male or female or other , 男,女,其他 + Gender *string `json:"gender,optional"` + // 注册来源 app,pc + RegisterSource *string `json:"registerSource,optional"` +} + +// swagger:model RegisterResp +type RegisterResp struct { + // token信息 + AuthToken *AuthToken `json:"authToken,optional"` + User *UserInfo `json:"userInfo,optional"` +} + +type AuthToken struct { + // access_token + AccessToken string `json:"accessToken,optional"` + // refresh_token + RefreshToken string `json:"refreshToken,optional"` + // token_type 类型 + TokenType string `json:"tokenType,optional"` + //access_token_expires + AccessTokenExpires int64 `json:"accessTokenExpires,optional"` + //refresh_token_expires + RefreshTokenExpires int64 `json:"refreshTokenExpires,optional"` +} + +// swagger:model UserInfo +type UserInfo struct { + // 用户ID + Id uint64 `json:"id,optional"` + // 昵称 + NickName string `json:"nickName,optional"` + //生日 + Birthday int64 `json:"birthday,optional"` + // 头像 + Avatar string `json:"avatar,optional"` + // Gender male or female or other , 男,女,其他 + Gender *string `json:"gender,optional"` + // 账户注册类型: + // 1 手机 2 邮箱 + RegisterType *uint32 `json:"registerType,optional"` + // 手机号 + Mobile *string `json:"mobile,optional"` + // 用户名 + Username string `json:"username,optional"` + //邮箱 + Email *string `json:"email,optional"` +} + +// swagger:model LoginReq +type LoginReq struct { + // UserName or Email or Mobile + UserName string `json:"userName"` + // Password + Password string `json:"password"` + // ClientIP + ClientIP string `json:"clientIp"` + // 登录方式 + LoginType string `json:"loginType"` + // 登录系统 + LoginPlatform string `json:"loginPlatform"` +} + +// swagger:model LoginResp +type LoginResp struct { + BaseMsgResp + AuthToken *AuthToken + UserInfo *UserInfo } diff --git a/go.work b/go.work new file mode 100644 index 0000000..6b38ce1 --- /dev/null +++ b/go.work @@ -0,0 +1,6 @@ +go 1.25.3 + +use ( + ./api + ./rpc +) diff --git a/rpc/Makefile b/rpc/Makefile index 275f30c..fae4ef5 100644 --- a/rpc/Makefile +++ b/rpc/Makefile @@ -85,7 +85,7 @@ gen-ent: # Generate Ent codes | 生成 Ent 的代码 @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 +gen-rpc-ent-logic: # Generate logic code 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" diff --git a/rpc/app.proto b/rpc/app.proto index fe3b422..cab1eff 100644 --- a/rpc/app.proto +++ b/rpc/app.proto @@ -32,21 +32,45 @@ 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; + google.protobuf.Timestamp access_token_expires = 4; + google.protobuf.Timestamp refresh_token_expires = 5; +} + +message BaseIDResp { + uint64 id = 1; + string msg = 2; +} + +message BaseMsg { + string msg = 1; +} + +message BaseResp { + string msg = 1; +} + +message BaseUUIDResp { + string id = 1; + string msg = 2; +} + +// base message +message Empty {} + +message IDReq { + uint64 id = 1; +} + +message IDsReq { + repeated uint64 ids = 1; } 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; + optional string password = 2; + optional string clientIp = 3; + optional string loginTyp = 4; + optional string loginPlatform = 5; } message LoginResponse { @@ -54,17 +78,37 @@ message LoginResponse { AuthToken auth_token = 2; } +message PageInfoReq { + uint64 page = 1; + uint64 page_size = 2; +} + +message PageUserRequest { + uint64 page = 1; + uint64 page_size = 2; + optional string username = 3; + optional string email = 4; + optional string mobile = 5; + optional string status = 6; + optional string clientIp = 7; +} + +message PageUserResponse { + repeated UserInfo users = 1; + uint64 total = 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 string captcha = 6; optional uint32 verificationType = 7; - optional string verificationId = 8; optional string nickName = 9; optional string registrationSource = 10; + optional string gender = 11; } message RegisterUserResponse { @@ -74,6 +118,14 @@ message RegisterUserResponse { bool phone_verification_required = 4; } +message UUIDReq { + string id = 1; +} + +message UUIDsReq { + repeated string ids = 1; +} + message UserInfo { optional uint64 id = 1; optional string username = 2; @@ -94,6 +146,7 @@ message UserInfo { optional int64 recovery_token_expiry = 17; optional google.protobuf.Struct metadata = 20; optional string registration_source = 21; + optional int64 birthday_at = 18; } message VerifyCodeReq { @@ -103,8 +156,8 @@ message VerifyCodeReq { } message VerifyCodeResp { - optional string code = 1; - optional uint32 expire = 2; + string captchaCode = 1; + uint32 expire = 2; } // App 服务定义 @@ -114,9 +167,14 @@ service App { rpc GetVerifyCode(VerifyCodeReq) returns (VerifyCodeResp); // 用户注册 // group: user - rpc registerUser(RegisterUserRequest) returns (RegisterUserResponse); + rpc RegisterUser(RegisterUserRequest) returns (RegisterUserResponse); // 用户登录 // group: user - rpc loginUser(LoginRequest) returns (LoginResponse); + rpc LoginUser(LoginRequest) returns (LoginResponse); + // 分页查询用户信息 + // group: user + rpc ListUsers(PageUserRequest) returns (PageUserResponse); + // group: base + rpc InitDatabase(Empty) returns (BaseResp); } diff --git a/rpc/appclient/app.go b/rpc/appclient/app.go index 4233c11..f899c88 100644 --- a/rpc/appclient/app.go +++ b/rpc/appclient/app.go @@ -14,10 +14,22 @@ import ( type ( AuthToken = app.AuthToken + BaseIDResp = app.BaseIDResp + BaseMsg = app.BaseMsg + BaseResp = app.BaseResp + BaseUUIDResp = app.BaseUUIDResp + Empty = app.Empty + IDReq = app.IDReq + IDsReq = app.IDsReq LoginRequest = app.LoginRequest LoginResponse = app.LoginResponse + PageInfoReq = app.PageInfoReq + PageUserRequest = app.PageUserRequest + PageUserResponse = app.PageUserResponse RegisterUserRequest = app.RegisterUserRequest RegisterUserResponse = app.RegisterUserResponse + UUIDReq = app.UUIDReq + UUIDsReq = app.UUIDsReq UserInfo = app.UserInfo VerifyCodeReq = app.VerifyCodeReq VerifyCodeResp = app.VerifyCodeResp @@ -29,6 +41,9 @@ type ( RegisterUser(ctx context.Context, in *RegisterUserRequest, opts ...grpc.CallOption) (*RegisterUserResponse, error) // 用户登录 LoginUser(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) + // 分页查询用户信息 + ListUsers(ctx context.Context, in *PageUserRequest, opts ...grpc.CallOption) (*PageUserResponse, error) + InitDatabase(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*BaseResp, error) } defaultApp struct { @@ -59,3 +74,14 @@ func (m *defaultApp) LoginUser(ctx context.Context, in *LoginRequest, opts ...gr client := app.NewAppClient(m.cli.Conn()) return client.LoginUser(ctx, in, opts...) } + +// 分页查询用户信息 +func (m *defaultApp) ListUsers(ctx context.Context, in *PageUserRequest, opts ...grpc.CallOption) (*PageUserResponse, error) { + client := app.NewAppClient(m.cli.Conn()) + return client.ListUsers(ctx, in, opts...) +} + +func (m *defaultApp) InitDatabase(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*BaseResp, error) { + client := app.NewAppClient(m.cli.Conn()) + return client.InitDatabase(ctx, in, opts...) +} diff --git a/rpc/desc/app/code.proto b/rpc/desc/app/code.proto index 35f1e77..dff9bf1 100644 --- a/rpc/desc/app/code.proto +++ b/rpc/desc/app/code.proto @@ -33,8 +33,8 @@ message VerifyCodeReq{ } message VerifyCodeResp{ - optional string code = 1; // 验证码 - optional uint32 expire = 2; // 过期时间(秒) + string captchaCode = 1; // 验证码 + uint32 expire = 2; // 过期时间(秒) } diff --git a/rpc/desc/app/user.proto b/rpc/desc/app/user.proto index 42eeb44..c39ed4c 100644 --- a/rpc/desc/app/user.proto +++ b/rpc/desc/app/user.proto @@ -25,6 +25,7 @@ message UserInfo { optional int64 recovery_token_expiry = 17; optional google.protobuf.Struct metadata = 20; optional string registration_source = 21; + optional int64 birthday_at = 18; } @@ -34,11 +35,11 @@ message RegisterUserRequest { optional string username = 3; optional string name = 4; optional string mobile = 5; - optional string verificationCode = 6; + optional string captcha = 6; optional uint32 verificationType = 7; - optional string verificationId = 8; // 邮箱或手机号 optional string nickName = 9; optional string registrationSource = 10; + optional string gender = 11; } message RegisterUserResponse { UserInfo user = 1; @@ -52,10 +53,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; + google.protobuf.Timestamp access_token_expires = 4; + google.protobuf.Timestamp refresh_token_expires = 5; } message LoginResponse{ @@ -64,20 +63,38 @@ message LoginResponse{ } 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; + optional string password = 2; + optional string clientIp = 3; + optional string loginTyp = 4; + optional string loginPlatform = 5; } +message PageUserRequest { + uint64 page = 1; + uint64 page_size = 2; + optional string username = 3; + optional string email = 4; + optional string mobile = 5; + optional string status = 6; + optional string clientIp = 7; +} + +message PageUserResponse { + repeated UserInfo users = 1; + uint64 total = 2; +} + + + + // App 服务定义 service App { // 用户注册 // group: user - rpc registerUser(RegisterUserRequest) returns (RegisterUserResponse); + rpc RegisterUser(RegisterUserRequest) returns (RegisterUserResponse); // 用户登录 // group: user - rpc loginUser(LoginRequest) returns (LoginResponse); + rpc LoginUser(LoginRequest) returns (LoginResponse); + // 分页查询用户信息 + // group: user + rpc ListUsers(PageUserRequest) returns (PageUserResponse); } \ No newline at end of file diff --git a/rpc/desc/base.proto b/rpc/desc/base.proto new file mode 100644 index 0000000..a45027e --- /dev/null +++ b/rpc/desc/base.proto @@ -0,0 +1,54 @@ +syntax = "proto3"; + +package app; + +option go_package = "./app"; + + + +// base message +message Empty {} + +message IDReq { + uint64 id = 1; +} + +message IDsReq { + repeated uint64 ids = 1; +} + +message UUIDsReq { + repeated string ids = 1; +} + +message UUIDReq { + string id = 1; +} + +message BaseResp { + string msg = 1; +} + +message PageInfoReq { + uint64 page = 1; + uint64 page_size = 2; +} + +message BaseMsg { + string msg = 1; +} + +message BaseIDResp { + uint64 id = 1; + string msg = 2; +} + +message BaseUUIDResp { + string id = 1; + string msg = 2; +} + +service App { + // group: base + rpc InitDatabase(Empty) returns (BaseResp); +} \ No newline at end of file diff --git a/rpc/ent/ent.go b/rpc/ent/ent.go index 4606520..113b06a 100644 --- a/rpc/ent/ent.go +++ b/rpc/ent/ent.go @@ -17,7 +17,7 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" ) -// ent aliases to avoid import conflicts in user's code.proto. +// ent aliases to avoid import conflicts in user's code. type ( Op = ent.Op Hook = ent.Hook diff --git a/rpc/ent/intercept/intercept.go b/rpc/ent/intercept/intercept.go index d356832..3e3fae1 100644 --- a/rpc/ent/intercept/intercept.go +++ b/rpc/ent/intercept/intercept.go @@ -16,7 +16,7 @@ import ( ) // The Query interface represents an operation that queries a graph. -// By using this interface, users can write generic code.proto that manipulates +// By using this interface, users can write generic code that manipulates // query builders of different types. type Query interface { // Type returns the string representation of the query type. diff --git a/rpc/ent/migrate/schema.go b/rpc/ent/migrate/schema.go index e1b189c..27b7eaf 100644 --- a/rpc/ent/migrate/schema.go +++ b/rpc/ent/migrate/schema.go @@ -21,7 +21,7 @@ var ( {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: "salt", Type: field.TypeString, Size: 255, 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"}, @@ -60,27 +60,28 @@ var ( // 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: "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: "user_id", Type: field.TypeUint64, Comment: "用户ID"}, {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: "login_platform", Type: field.TypeEnum, Enums: []string{"ios", "android", "windows"}, Default: "android"}, + {Name: "login_result", Type: field.TypeBool, Comment: "登录结果,是否成功", 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: "auth_id", Type: field.TypeUint64, Nullable: true, Comment: "auth_id"}, {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", + Comment: "user_login_logs Table | 用户登录信息表", Columns: UserLoginLogsColumns, PrimaryKey: []*schema.Column{UserLoginLogsColumns[0]}, Indexes: []*schema.Index{ @@ -124,13 +125,13 @@ var ( // 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: "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: "user_id", Type: field.TypeUint64, Comment: "用户ID"}, + {Name: "openid", Type: field.TypeString, Nullable: true, 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}, @@ -140,7 +141,7 @@ var ( {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: "mobile", 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}, @@ -148,6 +149,7 @@ var ( // UserThirdAuthsTable holds the schema information for the "user_third_auths" table. UserThirdAuthsTable = &schema.Table{ Name: "user_third_auths", + Comment: "user_third_auths Table | 用户token表", Columns: UserThirdAuthsColumns, PrimaryKey: []*schema.Column{UserThirdAuthsColumns[0]}, } @@ -163,4 +165,10 @@ func init() { UserTable.Annotation = &entsql.Annotation{ Table: "user", } + UserLoginLogsTable.Annotation = &entsql.Annotation{ + Table: "user_login_logs", + } + UserThirdAuthsTable.Annotation = &entsql.Annotation{ + Table: "user_third_auths", + } } diff --git a/rpc/ent/mutation.go b/rpc/ent/mutation.go index b4173a7..f916c95 100644 --- a/rpc/ent/mutation.go +++ b/rpc/ent/mutation.go @@ -3227,7 +3227,7 @@ type UserThirdAuthMutation struct { nickname *string avatar *string email *string - phone *string + mobile *string is_bound *bool bound_at *time.Time extra_data *map[string]interface{} @@ -3675,9 +3675,22 @@ func (m *UserThirdAuthMutation) OldOpenid(ctx context.Context) (v string, err er return oldValue.Openid, nil } +// ClearOpenid clears the value of the "openid" field. +func (m *UserThirdAuthMutation) ClearOpenid() { + m.openid = nil + m.clearedFields[userthirdauth.FieldOpenid] = struct{}{} +} + +// OpenidCleared returns if the "openid" field was cleared in this mutation. +func (m *UserThirdAuthMutation) OpenidCleared() bool { + _, ok := m.clearedFields[userthirdauth.FieldOpenid] + return ok +} + // ResetOpenid resets all changes to the "openid" field. func (m *UserThirdAuthMutation) ResetOpenid() { m.openid = nil + delete(m.clearedFields, userthirdauth.FieldOpenid) } // SetUnionid sets the "unionid" field. @@ -4121,53 +4134,53 @@ func (m *UserThirdAuthMutation) ResetEmail() { delete(m.clearedFields, userthirdauth.FieldEmail) } -// SetPhone sets the "phone" field. -func (m *UserThirdAuthMutation) SetPhone(s string) { - m.phone = &s +// SetMobile sets the "mobile" field. +func (m *UserThirdAuthMutation) SetMobile(s string) { + m.mobile = &s } -// Phone returns the value of the "phone" field in the mutation. -func (m *UserThirdAuthMutation) Phone() (r string, exists bool) { - v := m.phone +// Mobile returns the value of the "mobile" field in the mutation. +func (m *UserThirdAuthMutation) Mobile() (r string, exists bool) { + v := m.mobile if v == nil { return } return *v, true } -// OldPhone returns the old "phone" field's value of the UserThirdAuth entity. +// OldMobile returns the old "mobile" field's value of the UserThirdAuth entity. // If the UserThirdAuth object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserThirdAuthMutation) OldPhone(ctx context.Context) (v string, err error) { +func (m *UserThirdAuthMutation) OldMobile(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPhone is only allowed on UpdateOne operations") + return v, errors.New("OldMobile is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPhone requires an ID field in the mutation") + return v, errors.New("OldMobile requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldPhone: %w", err) + return v, fmt.Errorf("querying old value for OldMobile: %w", err) } - return oldValue.Phone, nil + return oldValue.Mobile, nil } -// ClearPhone clears the value of the "phone" field. -func (m *UserThirdAuthMutation) ClearPhone() { - m.phone = nil - m.clearedFields[userthirdauth.FieldPhone] = struct{}{} +// ClearMobile clears the value of the "mobile" field. +func (m *UserThirdAuthMutation) ClearMobile() { + m.mobile = nil + m.clearedFields[userthirdauth.FieldMobile] = struct{}{} } -// PhoneCleared returns if the "phone" field was cleared in this mutation. -func (m *UserThirdAuthMutation) PhoneCleared() bool { - _, ok := m.clearedFields[userthirdauth.FieldPhone] +// MobileCleared returns if the "mobile" field was cleared in this mutation. +func (m *UserThirdAuthMutation) MobileCleared() bool { + _, ok := m.clearedFields[userthirdauth.FieldMobile] return ok } -// ResetPhone resets all changes to the "phone" field. -func (m *UserThirdAuthMutation) ResetPhone() { - m.phone = nil - delete(m.clearedFields, userthirdauth.FieldPhone) +// ResetMobile resets all changes to the "mobile" field. +func (m *UserThirdAuthMutation) ResetMobile() { + m.mobile = nil + delete(m.clearedFields, userthirdauth.FieldMobile) } // SetIsBound sets the "is_bound" field. @@ -4374,8 +4387,8 @@ func (m *UserThirdAuthMutation) Fields() []string { if m.email != nil { fields = append(fields, userthirdauth.FieldEmail) } - if m.phone != nil { - fields = append(fields, userthirdauth.FieldPhone) + if m.mobile != nil { + fields = append(fields, userthirdauth.FieldMobile) } if m.is_bound != nil { fields = append(fields, userthirdauth.FieldIsBound) @@ -4426,8 +4439,8 @@ func (m *UserThirdAuthMutation) Field(name string) (ent.Value, bool) { return m.Avatar() case userthirdauth.FieldEmail: return m.Email() - case userthirdauth.FieldPhone: - return m.Phone() + case userthirdauth.FieldMobile: + return m.Mobile() case userthirdauth.FieldIsBound: return m.IsBound() case userthirdauth.FieldBoundAt: @@ -4475,8 +4488,8 @@ func (m *UserThirdAuthMutation) OldField(ctx context.Context, name string) (ent. return m.OldAvatar(ctx) case userthirdauth.FieldEmail: return m.OldEmail(ctx) - case userthirdauth.FieldPhone: - return m.OldPhone(ctx) + case userthirdauth.FieldMobile: + return m.OldMobile(ctx) case userthirdauth.FieldIsBound: return m.OldIsBound(ctx) case userthirdauth.FieldBoundAt: @@ -4604,12 +4617,12 @@ func (m *UserThirdAuthMutation) SetField(name string, value ent.Value) error { } m.SetEmail(v) return nil - case userthirdauth.FieldPhone: + case userthirdauth.FieldMobile: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetPhone(v) + m.SetMobile(v) return nil case userthirdauth.FieldIsBound: v, ok := value.(bool) @@ -4707,6 +4720,9 @@ func (m *UserThirdAuthMutation) ClearedFields() []string { if m.FieldCleared(userthirdauth.FieldDeletedAt) { fields = append(fields, userthirdauth.FieldDeletedAt) } + if m.FieldCleared(userthirdauth.FieldOpenid) { + fields = append(fields, userthirdauth.FieldOpenid) + } if m.FieldCleared(userthirdauth.FieldUnionid) { fields = append(fields, userthirdauth.FieldUnionid) } @@ -4734,8 +4750,8 @@ func (m *UserThirdAuthMutation) ClearedFields() []string { if m.FieldCleared(userthirdauth.FieldEmail) { fields = append(fields, userthirdauth.FieldEmail) } - if m.FieldCleared(userthirdauth.FieldPhone) { - fields = append(fields, userthirdauth.FieldPhone) + if m.FieldCleared(userthirdauth.FieldMobile) { + fields = append(fields, userthirdauth.FieldMobile) } if m.FieldCleared(userthirdauth.FieldExtraData) { fields = append(fields, userthirdauth.FieldExtraData) @@ -4760,6 +4776,9 @@ func (m *UserThirdAuthMutation) ClearField(name string) error { case userthirdauth.FieldDeletedAt: m.ClearDeletedAt() return nil + case userthirdauth.FieldOpenid: + m.ClearOpenid() + return nil case userthirdauth.FieldUnionid: m.ClearUnionid() return nil @@ -4787,8 +4806,8 @@ func (m *UserThirdAuthMutation) ClearField(name string) error { case userthirdauth.FieldEmail: m.ClearEmail() return nil - case userthirdauth.FieldPhone: - m.ClearPhone() + case userthirdauth.FieldMobile: + m.ClearMobile() return nil case userthirdauth.FieldExtraData: m.ClearExtraData() @@ -4849,8 +4868,8 @@ func (m *UserThirdAuthMutation) ResetField(name string) error { case userthirdauth.FieldEmail: m.ResetEmail() return nil - case userthirdauth.FieldPhone: - m.ResetPhone() + case userthirdauth.FieldMobile: + m.ResetMobile() return nil case userthirdauth.FieldIsBound: m.ResetIsBound() diff --git a/rpc/ent/runtime.go b/rpc/ent/runtime.go index 8db654b..76d5a34 100644 --- a/rpc/ent/runtime.go +++ b/rpc/ent/runtime.go @@ -10,7 +10,7 @@ import ( "time" ) -// The init function reads all schema descriptors with runtime code.proto +// The init function reads all schema descriptors with runtime code // (default values, validators, hooks and policies) and stitches it // to their package variables. func init() { @@ -226,21 +226,7 @@ func init() { // 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 - } - }() + userthirdauth.OpenidValidator = userthirdauthDescOpenid.Validators[0].(func(string) error) // 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. @@ -269,10 +255,10 @@ func init() { 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) + // userthirdauthDescMobile is the schema descriptor for mobile field. + userthirdauthDescMobile := userthirdauthFields[11].Descriptor() + // userthirdauth.MobileValidator is a validator for the "mobile" field. It is called by the builders before save. + userthirdauth.MobileValidator = userthirdauthDescMobile.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. diff --git a/rpc/ent/schema/user.go b/rpc/ent/schema/user.go index b915ea9..547b9b9 100644 --- a/rpc/ent/schema/user.go +++ b/rpc/ent/schema/user.go @@ -45,7 +45,7 @@ func (User) Fields() []ent.Field { field.String("salt").Comment("salt盐值"). NotEmpty(). Sensitive(). - MaxLen(32), + MaxLen(255), // 个人信息 field.String("nickname").Comment("昵称"). Default(""). diff --git a/rpc/ent/schema/userloginlog.go b/rpc/ent/schema/userloginlog.go index 18d47e4..9fb3766 100644 --- a/rpc/ent/schema/userloginlog.go +++ b/rpc/ent/schema/userloginlog.go @@ -2,6 +2,8 @@ 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" @@ -40,7 +42,7 @@ func (UserLoginLog) Fields() []ent.Field { field.Enum("login_platform"). Values( "ios", - "android"). + "android", "windows"). Default("android"), field.Bool("login_result"). Comment("登录结果,是否成功"). @@ -84,3 +86,11 @@ func (UserLoginLog) Indexes() []ent.Index { index.Fields("session_id"), } } + +func (UserLoginLog) Annotations() []schema.Annotation { + return []schema.Annotation{ + entsql.WithComments(true), + schema.Comment("user_login_logs Table | 用户登录信息表"), + entsql.Annotation{Table: "user_login_logs"}, + } +} diff --git a/rpc/ent/schema/userthirdauth.go b/rpc/ent/schema/userthirdauth.go index a3680f6..5a6e969 100644 --- a/rpc/ent/schema/userthirdauth.go +++ b/rpc/ent/schema/userthirdauth.go @@ -2,6 +2,8 @@ package schema import ( "entgo.io/ent" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema" "entgo.io/ent/schema/field" "github.com/saas-mingyang/mingyang-admin-common/orm/ent/mixins" mixins2 "mingyang-admin-app-rpc/ent/schema/mixins" @@ -18,7 +20,7 @@ func (UserThirdAuth) Fields() []ent.Field { field.Uint64("user_id"). Comment("用户ID"), field.String("openid"). - NotEmpty(). + Optional(). MaxLen(255), field.String("unionid"). Optional(). @@ -48,7 +50,7 @@ func (UserThirdAuth) Fields() []ent.Field { field.String("email"). Optional(). MaxLen(255), - field.String("phone"). + field.String("mobile"). Optional(). MaxLen(20), field.Bool("is_bound"). @@ -76,3 +78,11 @@ func (UserThirdAuth) Edges() []ent.Edge { func (UserThirdAuth) Indexes() []ent.Index { return []ent.Index{} } + +func (UserThirdAuth) Annotations() []schema.Annotation { + return []schema.Annotation{ + entsql.WithComments(true), + schema.Comment("user_third_auths Table | 用户token表"), + entsql.Annotation{Table: "user_third_auths"}, + } +} diff --git a/rpc/ent/set_not_nil.go b/rpc/ent/set_not_nil.go index ee10ebf..3d336e9 100644 --- a/rpc/ent/set_not_nil.go +++ b/rpc/ent/set_not_nil.go @@ -1137,25 +1137,25 @@ func (_m *UserThirdAuthCreate) SetNotNilEmail(value *string) *UserThirdAuthCreat } // set field if value's pointer is not nil. -func (_m *UserThirdAuthUpdate) SetNotNilPhone(value *string) *UserThirdAuthUpdate { +func (_m *UserThirdAuthUpdate) SetNotNilMobile(value *string) *UserThirdAuthUpdate { if value != nil { - return _m.SetPhone(*value) + return _m.SetMobile(*value) } return _m } // set field if value's pointer is not nil. -func (_m *UserThirdAuthUpdateOne) SetNotNilPhone(value *string) *UserThirdAuthUpdateOne { +func (_m *UserThirdAuthUpdateOne) SetNotNilMobile(value *string) *UserThirdAuthUpdateOne { if value != nil { - return _m.SetPhone(*value) + return _m.SetMobile(*value) } return _m } // set field if value's pointer is not nil. -func (_m *UserThirdAuthCreate) SetNotNilPhone(value *string) *UserThirdAuthCreate { +func (_m *UserThirdAuthCreate) SetNotNilMobile(value *string) *UserThirdAuthCreate { if value != nil { - return _m.SetPhone(*value) + return _m.SetMobile(*value) } return _m } diff --git a/rpc/ent/tx.go b/rpc/ent/tx.go index 8f4e9c6..3c6214e 100644 --- a/rpc/ent/tx.go +++ b/rpc/ent/tx.go @@ -157,7 +157,7 @@ func (tx *Tx) init() { } // 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. +// The idea is to support transactions without adding any extra code to the builders. // When a builder calls to driver.Tx(), it gets the same dialect.Tx instance. // Commit and Rollback are nop for the internal builders and the user must call one // of them in order to commit or rollback the transaction. diff --git a/rpc/ent/userloginlog.go b/rpc/ent/userloginlog.go index dfb3fd6..1571406 100644 --- a/rpc/ent/userloginlog.go +++ b/rpc/ent/userloginlog.go @@ -13,7 +13,7 @@ import ( "entgo.io/ent/dialect/sql" ) -// UserLoginLog is the model entity for the UserLoginLog schema. +// user_login_logs Table | 用户登录信息表 type UserLoginLog struct { config `json:"-"` // ID of the ent. diff --git a/rpc/ent/userloginlog/userloginlog.go b/rpc/ent/userloginlog/userloginlog.go index df5d65b..7bb56c3 100644 --- a/rpc/ent/userloginlog/userloginlog.go +++ b/rpc/ent/userloginlog/userloginlog.go @@ -151,6 +151,7 @@ const DefaultLoginPlatform = LoginPlatformAndroid const ( LoginPlatformIos LoginPlatform = "ios" LoginPlatformAndroid LoginPlatform = "android" + LoginPlatformWindows LoginPlatform = "windows" ) func (lp LoginPlatform) String() string { @@ -160,7 +161,7 @@ func (lp LoginPlatform) String() string { // 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: + case LoginPlatformIos, LoginPlatformAndroid, LoginPlatformWindows: return nil default: return fmt.Errorf("userloginlog: invalid enum value for login_platform field: %q", lp) diff --git a/rpc/ent/userthirdauth.go b/rpc/ent/userthirdauth.go index 8aae5ee..baa4f4b 100644 --- a/rpc/ent/userthirdauth.go +++ b/rpc/ent/userthirdauth.go @@ -13,7 +13,7 @@ import ( "entgo.io/ent/dialect/sql" ) -// UserThirdAuth is the model entity for the UserThirdAuth schema. +// user_third_auths Table | 用户token表 type UserThirdAuth struct { config `json:"-"` // ID of the ent. @@ -50,8 +50,8 @@ type UserThirdAuth struct { 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"` + // Mobile holds the value of the "mobile" field. + Mobile string `json:"mobile,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. @@ -72,7 +72,7 @@ func (*UserThirdAuth) scanValues(columns []string) ([]any, error) { 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: + case userthirdauth.FieldOpenid, userthirdauth.FieldUnionid, userthirdauth.FieldAccessToken, userthirdauth.FieldRefreshToken, userthirdauth.FieldPlatformUserID, userthirdauth.FieldNickname, userthirdauth.FieldAvatar, userthirdauth.FieldEmail, userthirdauth.FieldMobile: values[i] = new(sql.NullString) case userthirdauth.FieldCreatedAt, userthirdauth.FieldUpdatedAt, userthirdauth.FieldDeletedAt, userthirdauth.FieldAccessTokenExpiry, userthirdauth.FieldBoundAt: values[i] = new(sql.NullTime) @@ -196,11 +196,11 @@ func (_m *UserThirdAuth) assignValues(columns []string, values []any) error { } else if value.Valid { _m.Email = value.String } - case userthirdauth.FieldPhone: + case userthirdauth.FieldMobile: if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field phone", values[i]) + return fmt.Errorf("unexpected type %T for field mobile", values[i]) } else if value.Valid { - _m.Phone = value.String + _m.Mobile = value.String } case userthirdauth.FieldIsBound: if value, ok := values[i].(*sql.NullBool); !ok { @@ -306,8 +306,8 @@ func (_m *UserThirdAuth) String() string { builder.WriteString("email=") builder.WriteString(_m.Email) builder.WriteString(", ") - builder.WriteString("phone=") - builder.WriteString(_m.Phone) + builder.WriteString("mobile=") + builder.WriteString(_m.Mobile) builder.WriteString(", ") builder.WriteString("is_bound=") builder.WriteString(fmt.Sprintf("%v", _m.IsBound)) diff --git a/rpc/ent/userthirdauth/userthirdauth.go b/rpc/ent/userthirdauth/userthirdauth.go index 0bfb21e..013f19d 100644 --- a/rpc/ent/userthirdauth/userthirdauth.go +++ b/rpc/ent/userthirdauth/userthirdauth.go @@ -45,8 +45,8 @@ const ( 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" + // FieldMobile holds the string denoting the mobile field in the database. + FieldMobile = "mobile" // 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. @@ -76,7 +76,7 @@ var Columns = []string{ FieldNickname, FieldAvatar, FieldEmail, - FieldPhone, + FieldMobile, FieldIsBound, FieldBoundAt, FieldExtraData, @@ -119,8 +119,8 @@ var ( 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 + // MobileValidator is a validator for the "mobile" field. It is called by the builders before save. + MobileValidator 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. @@ -210,9 +210,9 @@ 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() +// ByMobile orders the results by the mobile field. +func ByMobile(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldMobile, opts...).ToFunc() } // ByIsBound orders the results by the is_bound field. diff --git a/rpc/ent/userthirdauth/where.go b/rpc/ent/userthirdauth/where.go index efb4aed..68e3042 100644 --- a/rpc/ent/userthirdauth/where.go +++ b/rpc/ent/userthirdauth/where.go @@ -129,9 +129,9 @@ func Email(v string) predicate.UserThirdAuth { return predicate.UserThirdAuth(sql.FieldEQ(FieldEmail, v)) } -// Phone applies equality check predicate on the "phone" field. It's identical to PhoneEQ. -func Phone(v string) predicate.UserThirdAuth { - return predicate.UserThirdAuth(sql.FieldEQ(FieldPhone, v)) +// Mobile applies equality check predicate on the "mobile" field. It's identical to MobileEQ. +func Mobile(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEQ(FieldMobile, v)) } // IsBound applies equality check predicate on the "is_bound" field. It's identical to IsBoundEQ. @@ -459,6 +459,16 @@ func OpenidHasSuffix(v string) predicate.UserThirdAuth { return predicate.UserThirdAuth(sql.FieldHasSuffix(FieldOpenid, v)) } +// OpenidIsNil applies the IsNil predicate on the "openid" field. +func OpenidIsNil() predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldIsNull(FieldOpenid)) +} + +// OpenidNotNil applies the NotNil predicate on the "openid" field. +func OpenidNotNil() predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNotNull(FieldOpenid)) +} + // OpenidEqualFold applies the EqualFold predicate on the "openid" field. func OpenidEqualFold(v string) predicate.UserThirdAuth { return predicate.UserThirdAuth(sql.FieldEqualFold(FieldOpenid, v)) @@ -1054,79 +1064,79 @@ func EmailContainsFold(v string) predicate.UserThirdAuth { return predicate.UserThirdAuth(sql.FieldContainsFold(FieldEmail, v)) } -// PhoneEQ applies the EQ predicate on the "phone" field. -func PhoneEQ(v string) predicate.UserThirdAuth { - return predicate.UserThirdAuth(sql.FieldEQ(FieldPhone, v)) +// MobileEQ applies the EQ predicate on the "mobile" field. +func MobileEQ(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEQ(FieldMobile, v)) } -// PhoneNEQ applies the NEQ predicate on the "phone" field. -func PhoneNEQ(v string) predicate.UserThirdAuth { - return predicate.UserThirdAuth(sql.FieldNEQ(FieldPhone, v)) +// MobileNEQ applies the NEQ predicate on the "mobile" field. +func MobileNEQ(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNEQ(FieldMobile, v)) } -// PhoneIn applies the In predicate on the "phone" field. -func PhoneIn(vs ...string) predicate.UserThirdAuth { - return predicate.UserThirdAuth(sql.FieldIn(FieldPhone, vs...)) +// MobileIn applies the In predicate on the "mobile" field. +func MobileIn(vs ...string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldIn(FieldMobile, vs...)) } -// PhoneNotIn applies the NotIn predicate on the "phone" field. -func PhoneNotIn(vs ...string) predicate.UserThirdAuth { - return predicate.UserThirdAuth(sql.FieldNotIn(FieldPhone, vs...)) +// MobileNotIn applies the NotIn predicate on the "mobile" field. +func MobileNotIn(vs ...string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNotIn(FieldMobile, vs...)) } -// PhoneGT applies the GT predicate on the "phone" field. -func PhoneGT(v string) predicate.UserThirdAuth { - return predicate.UserThirdAuth(sql.FieldGT(FieldPhone, v)) +// MobileGT applies the GT predicate on the "mobile" field. +func MobileGT(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldGT(FieldMobile, v)) } -// PhoneGTE applies the GTE predicate on the "phone" field. -func PhoneGTE(v string) predicate.UserThirdAuth { - return predicate.UserThirdAuth(sql.FieldGTE(FieldPhone, v)) +// MobileGTE applies the GTE predicate on the "mobile" field. +func MobileGTE(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldGTE(FieldMobile, v)) } -// PhoneLT applies the LT predicate on the "phone" field. -func PhoneLT(v string) predicate.UserThirdAuth { - return predicate.UserThirdAuth(sql.FieldLT(FieldPhone, v)) +// MobileLT applies the LT predicate on the "mobile" field. +func MobileLT(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldLT(FieldMobile, v)) } -// PhoneLTE applies the LTE predicate on the "phone" field. -func PhoneLTE(v string) predicate.UserThirdAuth { - return predicate.UserThirdAuth(sql.FieldLTE(FieldPhone, v)) +// MobileLTE applies the LTE predicate on the "mobile" field. +func MobileLTE(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldLTE(FieldMobile, v)) } -// PhoneContains applies the Contains predicate on the "phone" field. -func PhoneContains(v string) predicate.UserThirdAuth { - return predicate.UserThirdAuth(sql.FieldContains(FieldPhone, v)) +// MobileContains applies the Contains predicate on the "mobile" field. +func MobileContains(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldContains(FieldMobile, v)) } -// PhoneHasPrefix applies the HasPrefix predicate on the "phone" field. -func PhoneHasPrefix(v string) predicate.UserThirdAuth { - return predicate.UserThirdAuth(sql.FieldHasPrefix(FieldPhone, v)) +// MobileHasPrefix applies the HasPrefix predicate on the "mobile" field. +func MobileHasPrefix(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldHasPrefix(FieldMobile, v)) } -// PhoneHasSuffix applies the HasSuffix predicate on the "phone" field. -func PhoneHasSuffix(v string) predicate.UserThirdAuth { - return predicate.UserThirdAuth(sql.FieldHasSuffix(FieldPhone, v)) +// MobileHasSuffix applies the HasSuffix predicate on the "mobile" field. +func MobileHasSuffix(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldHasSuffix(FieldMobile, v)) } -// PhoneIsNil applies the IsNil predicate on the "phone" field. -func PhoneIsNil() predicate.UserThirdAuth { - return predicate.UserThirdAuth(sql.FieldIsNull(FieldPhone)) +// MobileIsNil applies the IsNil predicate on the "mobile" field. +func MobileIsNil() predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldIsNull(FieldMobile)) } -// PhoneNotNil applies the NotNil predicate on the "phone" field. -func PhoneNotNil() predicate.UserThirdAuth { - return predicate.UserThirdAuth(sql.FieldNotNull(FieldPhone)) +// MobileNotNil applies the NotNil predicate on the "mobile" field. +func MobileNotNil() predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldNotNull(FieldMobile)) } -// PhoneEqualFold applies the EqualFold predicate on the "phone" field. -func PhoneEqualFold(v string) predicate.UserThirdAuth { - return predicate.UserThirdAuth(sql.FieldEqualFold(FieldPhone, v)) +// MobileEqualFold applies the EqualFold predicate on the "mobile" field. +func MobileEqualFold(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldEqualFold(FieldMobile, v)) } -// PhoneContainsFold applies the ContainsFold predicate on the "phone" field. -func PhoneContainsFold(v string) predicate.UserThirdAuth { - return predicate.UserThirdAuth(sql.FieldContainsFold(FieldPhone, v)) +// MobileContainsFold applies the ContainsFold predicate on the "mobile" field. +func MobileContainsFold(v string) predicate.UserThirdAuth { + return predicate.UserThirdAuth(sql.FieldContainsFold(FieldMobile, v)) } // IsBoundEQ applies the EQ predicate on the "is_bound" field. diff --git a/rpc/ent/userthirdauth_create.go b/rpc/ent/userthirdauth_create.go index 6427b61..ef41520 100644 --- a/rpc/ent/userthirdauth_create.go +++ b/rpc/ent/userthirdauth_create.go @@ -102,6 +102,14 @@ func (_c *UserThirdAuthCreate) SetOpenid(v string) *UserThirdAuthCreate { return _c } +// SetNillableOpenid sets the "openid" field if the given value is not nil. +func (_c *UserThirdAuthCreate) SetNillableOpenid(v *string) *UserThirdAuthCreate { + if v != nil { + _c.SetOpenid(*v) + } + return _c +} + // SetUnionid sets the "unionid" field. func (_c *UserThirdAuthCreate) SetUnionid(v string) *UserThirdAuthCreate { _c.mutation.SetUnionid(v) @@ -220,16 +228,16 @@ func (_c *UserThirdAuthCreate) SetNillableEmail(v *string) *UserThirdAuthCreate return _c } -// SetPhone sets the "phone" field. -func (_c *UserThirdAuthCreate) SetPhone(v string) *UserThirdAuthCreate { - _c.mutation.SetPhone(v) +// SetMobile sets the "mobile" field. +func (_c *UserThirdAuthCreate) SetMobile(v string) *UserThirdAuthCreate { + _c.mutation.SetMobile(v) return _c } -// SetNillablePhone sets the "phone" field if the given value is not nil. -func (_c *UserThirdAuthCreate) SetNillablePhone(v *string) *UserThirdAuthCreate { +// SetNillableMobile sets the "mobile" field if the given value is not nil. +func (_c *UserThirdAuthCreate) SetNillableMobile(v *string) *UserThirdAuthCreate { if v != nil { - _c.SetPhone(*v) + _c.SetMobile(*v) } return _c } @@ -349,9 +357,6 @@ func (_c *UserThirdAuthCreate) check() error { 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)} @@ -392,9 +397,9 @@ func (_c *UserThirdAuthCreate) check() error { 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 v, ok := _c.mutation.Mobile(); ok { + if err := userthirdauth.MobileValidator(v); err != nil { + return &ValidationError{Name: "mobile", err: fmt.Errorf(`ent: validator failed for field "UserThirdAuth.mobile": %w`, err)} } } if _, ok := _c.mutation.IsBound(); !ok { @@ -499,9 +504,9 @@ func (_c *UserThirdAuthCreate) createSpec() (*UserThirdAuth, *sqlgraph.CreateSpe _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.Mobile(); ok { + _spec.SetField(userthirdauth.FieldMobile, field.TypeString, value) + _node.Mobile = value } if value, ok := _c.mutation.IsBound(); ok { _spec.SetField(userthirdauth.FieldIsBound, field.TypeBool, value) diff --git a/rpc/ent/userthirdauth_update.go b/rpc/ent/userthirdauth_update.go index 9451212..dba8541 100644 --- a/rpc/ent/userthirdauth_update.go +++ b/rpc/ent/userthirdauth_update.go @@ -116,6 +116,12 @@ func (_u *UserThirdAuthUpdate) SetNillableOpenid(v *string) *UserThirdAuthUpdate return _u } +// ClearOpenid clears the value of the "openid" field. +func (_u *UserThirdAuthUpdate) ClearOpenid() *UserThirdAuthUpdate { + _u.mutation.ClearOpenid() + return _u +} + // SetUnionid sets the "unionid" field. func (_u *UserThirdAuthUpdate) SetUnionid(v string) *UserThirdAuthUpdate { _u.mutation.SetUnionid(v) @@ -288,23 +294,23 @@ func (_u *UserThirdAuthUpdate) ClearEmail() *UserThirdAuthUpdate { return _u } -// SetPhone sets the "phone" field. -func (_u *UserThirdAuthUpdate) SetPhone(v string) *UserThirdAuthUpdate { - _u.mutation.SetPhone(v) +// SetMobile sets the "mobile" field. +func (_u *UserThirdAuthUpdate) SetMobile(v string) *UserThirdAuthUpdate { + _u.mutation.SetMobile(v) return _u } -// SetNillablePhone sets the "phone" field if the given value is not nil. -func (_u *UserThirdAuthUpdate) SetNillablePhone(v *string) *UserThirdAuthUpdate { +// SetNillableMobile sets the "mobile" field if the given value is not nil. +func (_u *UserThirdAuthUpdate) SetNillableMobile(v *string) *UserThirdAuthUpdate { if v != nil { - _u.SetPhone(*v) + _u.SetMobile(*v) } return _u } -// ClearPhone clears the value of the "phone" field. -func (_u *UserThirdAuthUpdate) ClearPhone() *UserThirdAuthUpdate { - _u.mutation.ClearPhone() +// ClearMobile clears the value of the "mobile" field. +func (_u *UserThirdAuthUpdate) ClearMobile() *UserThirdAuthUpdate { + _u.mutation.ClearMobile() return _u } @@ -431,9 +437,9 @@ func (_u *UserThirdAuthUpdate) check() error { return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "UserThirdAuth.email": %w`, err)} } } - if v, ok := _u.mutation.Phone(); ok { - if err := userthirdauth.PhoneValidator(v); err != nil { - return &ValidationError{Name: "phone", err: fmt.Errorf(`ent: validator failed for field "UserThirdAuth.phone": %w`, err)} + if v, ok := _u.mutation.Mobile(); ok { + if err := userthirdauth.MobileValidator(v); err != nil { + return &ValidationError{Name: "mobile", err: fmt.Errorf(`ent: validator failed for field "UserThirdAuth.mobile": %w`, err)} } } return nil @@ -478,6 +484,9 @@ func (_u *UserThirdAuthUpdate) sqlSave(ctx context.Context) (_node int, err erro if value, ok := _u.mutation.Openid(); ok { _spec.SetField(userthirdauth.FieldOpenid, field.TypeString, value) } + if _u.mutation.OpenidCleared() { + _spec.ClearField(userthirdauth.FieldOpenid, field.TypeString) + } if value, ok := _u.mutation.Unionid(); ok { _spec.SetField(userthirdauth.FieldUnionid, field.TypeString, value) } @@ -532,11 +541,11 @@ func (_u *UserThirdAuthUpdate) sqlSave(ctx context.Context) (_node int, err erro if _u.mutation.EmailCleared() { _spec.ClearField(userthirdauth.FieldEmail, field.TypeString) } - if value, ok := _u.mutation.Phone(); ok { - _spec.SetField(userthirdauth.FieldPhone, field.TypeString, value) + if value, ok := _u.mutation.Mobile(); ok { + _spec.SetField(userthirdauth.FieldMobile, field.TypeString, value) } - if _u.mutation.PhoneCleared() { - _spec.ClearField(userthirdauth.FieldPhone, field.TypeString) + if _u.mutation.MobileCleared() { + _spec.ClearField(userthirdauth.FieldMobile, field.TypeString) } if value, ok := _u.mutation.IsBound(); ok { _spec.SetField(userthirdauth.FieldIsBound, field.TypeBool, value) @@ -658,6 +667,12 @@ func (_u *UserThirdAuthUpdateOne) SetNillableOpenid(v *string) *UserThirdAuthUpd return _u } +// ClearOpenid clears the value of the "openid" field. +func (_u *UserThirdAuthUpdateOne) ClearOpenid() *UserThirdAuthUpdateOne { + _u.mutation.ClearOpenid() + return _u +} + // SetUnionid sets the "unionid" field. func (_u *UserThirdAuthUpdateOne) SetUnionid(v string) *UserThirdAuthUpdateOne { _u.mutation.SetUnionid(v) @@ -830,23 +845,23 @@ func (_u *UserThirdAuthUpdateOne) ClearEmail() *UserThirdAuthUpdateOne { return _u } -// SetPhone sets the "phone" field. -func (_u *UserThirdAuthUpdateOne) SetPhone(v string) *UserThirdAuthUpdateOne { - _u.mutation.SetPhone(v) +// SetMobile sets the "mobile" field. +func (_u *UserThirdAuthUpdateOne) SetMobile(v string) *UserThirdAuthUpdateOne { + _u.mutation.SetMobile(v) return _u } -// SetNillablePhone sets the "phone" field if the given value is not nil. -func (_u *UserThirdAuthUpdateOne) SetNillablePhone(v *string) *UserThirdAuthUpdateOne { +// SetNillableMobile sets the "mobile" field if the given value is not nil. +func (_u *UserThirdAuthUpdateOne) SetNillableMobile(v *string) *UserThirdAuthUpdateOne { if v != nil { - _u.SetPhone(*v) + _u.SetMobile(*v) } return _u } -// ClearPhone clears the value of the "phone" field. -func (_u *UserThirdAuthUpdateOne) ClearPhone() *UserThirdAuthUpdateOne { - _u.mutation.ClearPhone() +// ClearMobile clears the value of the "mobile" field. +func (_u *UserThirdAuthUpdateOne) ClearMobile() *UserThirdAuthUpdateOne { + _u.mutation.ClearMobile() return _u } @@ -986,9 +1001,9 @@ func (_u *UserThirdAuthUpdateOne) check() error { return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "UserThirdAuth.email": %w`, err)} } } - if v, ok := _u.mutation.Phone(); ok { - if err := userthirdauth.PhoneValidator(v); err != nil { - return &ValidationError{Name: "phone", err: fmt.Errorf(`ent: validator failed for field "UserThirdAuth.phone": %w`, err)} + if v, ok := _u.mutation.Mobile(); ok { + if err := userthirdauth.MobileValidator(v); err != nil { + return &ValidationError{Name: "mobile", err: fmt.Errorf(`ent: validator failed for field "UserThirdAuth.mobile": %w`, err)} } } return nil @@ -1050,6 +1065,9 @@ func (_u *UserThirdAuthUpdateOne) sqlSave(ctx context.Context) (_node *UserThird if value, ok := _u.mutation.Openid(); ok { _spec.SetField(userthirdauth.FieldOpenid, field.TypeString, value) } + if _u.mutation.OpenidCleared() { + _spec.ClearField(userthirdauth.FieldOpenid, field.TypeString) + } if value, ok := _u.mutation.Unionid(); ok { _spec.SetField(userthirdauth.FieldUnionid, field.TypeString, value) } @@ -1104,11 +1122,11 @@ func (_u *UserThirdAuthUpdateOne) sqlSave(ctx context.Context) (_node *UserThird if _u.mutation.EmailCleared() { _spec.ClearField(userthirdauth.FieldEmail, field.TypeString) } - if value, ok := _u.mutation.Phone(); ok { - _spec.SetField(userthirdauth.FieldPhone, field.TypeString, value) + if value, ok := _u.mutation.Mobile(); ok { + _spec.SetField(userthirdauth.FieldMobile, field.TypeString, value) } - if _u.mutation.PhoneCleared() { - _spec.ClearField(userthirdauth.FieldPhone, field.TypeString) + if _u.mutation.MobileCleared() { + _spec.ClearField(userthirdauth.FieldMobile, field.TypeString) } if value, ok := _u.mutation.IsBound(); ok { _spec.SetField(userthirdauth.FieldIsBound, field.TypeBool, value) diff --git a/rpc/etc/app.yaml b/rpc/etc/app.yaml index 49521e2..b55b0b3 100644 --- a/rpc/etc/app.yaml +++ b/rpc/etc/app.yaml @@ -1,5 +1,5 @@ Name: rpc.rpc -ListenOn: 0.0.0.0:8080 +ListenOn: 0.0.0.0:9901 DatabaseConf: @@ -16,20 +16,18 @@ DatabaseConf: Debug: true LogSlowThreshold: 600ms +RedisConf: + Host: 192.168.201.58:6379 + Db: 0 -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 +JWTConf: + access_token_secret: OAMDAascvzcvasdf + refresh_token_secret: ASDZCpajbvasdfasf 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 @@ -40,3 +38,8 @@ Log: KeepDays: 7 StackCoolDownMillis: 100 +McmsRpc: + Target: 127.0.0.1:9106 + Enabled: true + Timeout: 10000 + diff --git a/rpc/go.mod b/rpc/go.mod index 3843094..e212068 100644 --- a/rpc/go.mod +++ b/rpc/go.mod @@ -13,6 +13,7 @@ require ( golang.org/x/crypto v0.44.0 google.golang.org/grpc v1.76.0 google.golang.org/protobuf v1.36.10 + mingyang-admin-simple-admin-message v0.0.1 ) require ( @@ -133,3 +134,5 @@ require ( ) replace github.com/zeromicro/go-zero v1.9.1 => github.com/suyuan32/simple-admin-tools v1.9.1 + +replace mingyang-admin-simple-admin-message v0.0.1 => ../../simple-admin-message-center-tenant diff --git a/rpc/internal/config/config.go b/rpc/internal/config/config.go index 1ec0f14..dac839c 100644 --- a/rpc/internal/config/config.go +++ b/rpc/internal/config/config.go @@ -8,14 +8,13 @@ import ( type Config struct { zrpc.RpcServerConf - DatabaseConf config.DatabaseConf - JWTConf JWTConfig - RedisConf config.RedisConf - RedisRedisConf config.RedisConf - AppRpc zrpc.RpcClientConf - IP2Location struct { + DatabaseConf config.DatabaseConf + JWTConf JWTConfig `json:"JWTConf"` + RedisConf config.RedisConf + IP2Location struct { DBPath string `json:",default=./data/IP2LOCATION-LITE-DB.BIN"` } + McmsRpc zrpc.RpcClientConf } type JWTConfig struct { diff --git a/rpc/internal/logic/base/init_database_logic.go b/rpc/internal/logic/base/init_database_logic.go new file mode 100644 index 0000000..ad2cb33 --- /dev/null +++ b/rpc/internal/logic/base/init_database_logic.go @@ -0,0 +1,35 @@ +package base + +import ( + "context" + "entgo.io/ent/dialect/sql/schema" + "github.com/saas-mingyang/mingyang-admin-common/msg/logmsg" + "github.com/zeromicro/go-zero/core/errorx" + + "mingyang-admin-app-rpc/internal/svc" + "mingyang-admin-app-rpc/types/app" + + "github.com/zeromicro/go-zero/core/logx" +) + +type InitDatabaseLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewInitDatabaseLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InitDatabaseLogic { + return &InitDatabaseLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *InitDatabaseLogic) InitDatabase(in *app.Empty) (*app.BaseResp, error) { + if err := l.svcCtx.DB.Schema.Create(l.ctx, schema.WithForeignKeys(false)); err != nil { + logx.Errorw(logmsg.DatabaseError, logx.Field("detail", err.Error())) + return nil, errorx.NewInternalError(err.Error()) + } + return &app.BaseResp{}, nil +} diff --git a/rpc/internal/logic/cacherepo/cache_repo.go b/rpc/internal/logic/cacherepo/cache_repo.go index ae153a6..53ec839 100644 --- a/rpc/internal/logic/cacherepo/cache_repo.go +++ b/rpc/internal/logic/cacherepo/cache_repo.go @@ -63,7 +63,7 @@ func (r *CacheRepository) IncrementVerificationAttempts(ctx context.Context, key return err } if data == nil { - return fmt.Errorf("verification code.proto not found") + return fmt.Errorf("verification code not found") } data.Attempts++ @@ -143,7 +143,7 @@ func (r *CacheRepository) RateLimit(ctx context.Context, key string, limit int, // VerificationCodeData 数据模型 type VerificationCodeData struct { - Code string `json:"code.proto"` + Code string `json:"code"` Attempts int `json:"attempts"` CreatedAt time.Time `json:"created_at"` } diff --git a/rpc/internal/logic/code/get_verify_code_logic.go b/rpc/internal/logic/code/get_verify_code_logic.go index bf9860c..0b37451 100644 --- a/rpc/internal/logic/code/get_verify_code_logic.go +++ b/rpc/internal/logic/code/get_verify_code_logic.go @@ -2,10 +2,16 @@ package code import ( "context" + "crypto/rand" + "fmt" + "github.com/zeromicro/go-zero/core/errorx" "github.com/zeromicro/go-zero/core/logx" + "math/big" "mingyang-admin-app-rpc/internal/logic/cacherepo" "mingyang-admin-app-rpc/internal/svc" "mingyang-admin-app-rpc/types/app" + "mingyang-admin-simple-admin-message/types/mcms" + "time" ) type GetVerifyCodeLogic struct { @@ -27,23 +33,116 @@ func NewGetVerifyCodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Get // GetVerifyCode 获取验证码 func (l *GetVerifyCodeLogic) GetVerifyCode(in *app.VerifyCodeReq) (*app.VerifyCodeResp, error) { codeType := in.GetAccountType() + targetValue := in.GetValue() + minute := 5 * time.Minute + // 1. 检查缓存中是否有有效的验证码 + cachedCode, err := l.CheckCacheVerificationCode(in) + if err != nil { + logx.Errorw("failed to check verification code cache", logx.Field("detail", err)) + // 继续生成新验证码,不直接返回错误 + } + var code string + // 2. 如果有缓存且有效,复用 + if cachedCode != "" { + // 假设 cachedCode 是完整的 "captchaId:code" 格式 + code = cachedCode + + } else { + // 生成验证码 + newCode, err := GenerateSecureCode() + if err != nil { + logx.Errorw("failed to generate verification code", logx.Field("detail", err)) + return nil, err + } + code = newCode + } + // 4. 根据类型发送验证码 + var sendErr error switch codeType { case app.AccountType_MOBILE: - // TODO: 调用短信服务获取验证码 - l.SendMobileMessage(in) + // 调用短信服务发送验证码 + sendErr = l.SendMobileMessage(in, code) + if sendErr != nil { + logx.Errorw("failed to send SMS verification code", + logx.Field("detail", sendErr), + logx.Field("mobile", targetValue)) + } case app.AccountType_EMAIL: - // TODO: 调用邮件服务获取验证码 - l.SendEmailMessage(in) + // 调用邮件服务发送验证码 + sendErr = l.SendEmailMessage(in, code) + if sendErr != nil { + logx.Errorw("failed to send email verification code", + logx.Field("detail", sendErr), + logx.Field("email", targetValue)) + } + default: + return nil, errorx.NewInvalidArgumentError("unsupported account type") } - return &app.VerifyCodeResp{}, nil + // 5. 如果发送失败,可以考虑清理缓存(可选) + if sendErr != nil { + // 可选:清理刚设置的缓存,避免无效验证码占用空间 + // l.cacheRepo.DeleteVerificationCode(l.ctx, targetValue) + return nil, sendErr + } + cacheKey := fmt.Sprintf("email_verification_code:%s", in.Value) + fmt.Printf("cacheKey:%s", cacheKey) + // 7. 设置验证码到缓存 + err = l.cacheRepo.SetVerificationCode(l.ctx, cacheKey, code, minute) + if err != nil { + logx.Errorw("failed to set verification code to cache", logx.Field("detail", err)) + } + // 6. 返回响应 + return &app.VerifyCodeResp{ + CaptchaCode: code, // 返回纯数字验证码 + Expire: uint32(minute.Seconds()), + }, nil } - -func (l *GetVerifyCodeLogic) SendMobileMessage(in *app.VerifyCodeReq) { +func (l *GetVerifyCodeLogic) SendMobileMessage(in *app.VerifyCodeReq, code string) error { //l.cacheRepo.SetVerificationCode(l.ctx, in.Value, nil, 10*time.Minute) + return nil } -func (l *GetVerifyCodeLogic) SendEmailMessage(in *app.VerifyCodeReq) { - +func (l *GetVerifyCodeLogic) SendEmailMessage(in *app.VerifyCodeReq, code string) error { + _, err := l.svcCtx.McmsRpc.SendEmail(l.ctx, &mcms.EmailInfo{ + Target: []string{in.Value}, + Subject: in.Type.String(), + Content: fmt.Sprintf("验证码:%s", code), + }) + if err != nil { + logx.Errorw("failed to send email", logx.Field("detail", err)) + } + return nil +} + +// CheckCacheVerificationCode 检查缓存中是否有验证码,并且未过期 +func (l *GetVerifyCodeLogic) CheckCacheVerificationCode(in *app.VerifyCodeReq) (string, error) { + var cacheKey string + if in.AccountType == app.AccountType_EMAIL { + cacheKey = fmt.Sprintf("email_verification_code:%s", in.GetValue()) + } else if in.AccountType == app.AccountType_MOBILE { + cacheKey = fmt.Sprintf("mobile_verification_code:%s", in.GetValue()) + } else { + return "", nil + } + code, err := l.cacheRepo.GetVerificationCode(l.ctx, cacheKey) + if err != nil || code == nil { + logx.Errorw("failed to get verification code", logx.Field("detail", err)) + return "", err + } + return code.Code, nil +} + +// GenerateSecureCode 生成密码学安全的6位数字验证码 +func GenerateSecureCode() (string, error) { + // 生成一个 [0, 999999] 范围内的大随机整数 + max := big.NewInt(1000000) // 上限不包含,所以是 0-999999 + _, err := rand.Int(rand.Reader, max) + if err != nil { + return "", err + } + // 格式化为6位数字符串,不足6位前面补零 + //return fmt.Sprintf("%06d", n.Int64()), nil + return "1234", nil } diff --git a/rpc/internal/logic/user/user_logic.go b/rpc/internal/logic/user/create_user_login.go similarity index 93% rename from rpc/internal/logic/user/user_logic.go rename to rpc/internal/logic/user/create_user_login.go index d5aa919..e369d25 100644 --- a/rpc/internal/logic/user/user_logic.go +++ b/rpc/internal/logic/user/create_user_login.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "github.com/saas-mingyang/mingyang-admin-common/utils/sonyflake" + "github.com/saas-mingyang/mingyang-admin-common/utils/uuidx" "github.com/zeromicro/go-zero/core/logx" "mingyang-admin-app-rpc/ent" "mingyang-admin-app-rpc/ent/user" @@ -51,6 +52,7 @@ func (u *User) CreateUser(ctx context.Context, req *CreateUserData) (*app.UserIn ).Exist(ctx) if err != nil { + fmt.Printf("error: %v", err) return nil, fmt.Errorf("checking existing user: %w", err) } if exists { @@ -63,12 +65,15 @@ func (u *User) CreateUser(ctx context.Context, req *CreateUserData) (*app.UserIn SetUsername(req.Username). SetEmail(req.Email). SetMobile(req.Mobile). + SetGender(req.Gender). + SetSalt(uuidx.NewUUID().String()). SetPasswordHash(req.PasswordHash). SetNickname(req.Nickname). SetRegistrationSource(req.RegistrationSource). SetMetadata(req.Metadata). Save(ctx) if err != nil { + fmt.Printf("error: %v", err) return nil, fmt.Errorf("creating user: %w", err) } // 4. 提交事务 @@ -100,6 +105,7 @@ type CreateUserData struct { Mobile string PasswordHash string Nickname string + Gender user.Gender RegistrationSource string Metadata map[string]interface{} ThirdPartyAuth *ThirdPartyAuthData diff --git a/rpc/internal/logic/user/list_users_logic.go b/rpc/internal/logic/user/list_users_logic.go new file mode 100644 index 0000000..21b0f71 --- /dev/null +++ b/rpc/internal/logic/user/list_users_logic.go @@ -0,0 +1,31 @@ +package user + +import ( + "context" + + "mingyang-admin-app-rpc/internal/svc" + "mingyang-admin-app-rpc/types/app" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ListUsersLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewListUsersLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListUsersLogic { + return &ListUsersLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +// 分页查询用户信息 +func (l *ListUsersLogic) ListUsers(in *app.PageUserRequest) (*app.PageUserResponse, error) { + // todo: add your logic here and delete this line + + return &app.PageUserResponse{}, nil +} diff --git a/rpc/internal/logic/user/login_user_logic.go b/rpc/internal/logic/user/login_user_logic.go index d2e675b..0eb2766 100644 --- a/rpc/internal/logic/user/login_user_logic.go +++ b/rpc/internal/logic/user/login_user_logic.go @@ -14,7 +14,6 @@ import ( "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" @@ -63,7 +62,9 @@ func (l *LoginUserLogic) LoginUser(in *app.LoginRequest) (*app.LoginResponse, er } // 5. 生成访问令牌和刷新令牌 tokenPair, userThirdAuth, err := l.generateTokenPair(user, in) + fmt.Printf("userThirdAuth: %v", userThirdAuth) if err != nil { + fmt.Printf("generateTokenPair error: %v", err) return nil, status.Error(codes.Internal, "failed to generate token") } // 6. 记录成功登录日志 @@ -74,37 +75,20 @@ func (l *LoginUserLogic) LoginUser(in *app.LoginRequest) (*app.LoginResponse, er func (l *LoginUserLogic) validateLoginRequest(in *app.LoginRequest) error { // 检查登录标识是否提供 - if in.GetUsername() == "" && in.GetMobile() == "" && in.GetEmail() == "" { + if in.GetUsername() == "" { 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())) - } + conditions = append(conditions, user.UsernameEQ(in.GetUsername())) // 查询用户,同时加载关联数据(如角色、权限等) user, err := l.svcCtx.DB.User.Query(). Where(user.Or(conditions...)). @@ -153,13 +137,14 @@ func (l *LoginUserLogic) recordLogin(user *ent.User, in *app.LoginRequest, userT SetUserID(user.ID). SetLoginTime(time.Now()). SetLoginIP(in.GetClientIp()). - SetLoginType(userloginlog.LoginType(in.GetLoginType())). - SetLoginPlatform(userloginlog.LoginPlatform(in.GetPlatform())). + SetLoginType(userloginlog.LoginType(in.GetLoginTyp())). + SetLoginPlatform(userloginlog.LoginPlatform(in.GetLoginPlatform())). SetFailureReason("password_incorrect"). SetLoginResult(loginResult). SetAuthID(userThirdAuth.ID). Save(ctx) if err != nil { + fmt.Printf("failed to record login: %v", err) l.Logger.Errorf("failed to record failed login: %v", err) } } @@ -171,8 +156,8 @@ func (l *LoginUserLogic) generateTokenPair(user *ent.User, in *app.LoginRequest) return nil, nil, fmt.Errorf("failed to generate access token: %w", err) } // 保存令牌到数据库 - userThirdAuth := l.saveRefreshToken(user, tokenPair, in) - return tokenPair, userThirdAuth, nil + userThirdAuth, err := l.saveRefreshToken(user, tokenPair, in) + return tokenPair, userThirdAuth, err } // 构建登录响应 @@ -180,10 +165,11 @@ func (l *LoginUserLogic) buildLoginResponse(user *ent.User, tokenPair *jwt_manag response := &app.LoginResponse{ User: l.convertUserToProto(user), AuthToken: &app.AuthToken{ - AccessToken: tokenPair.AccessToken, - RefreshToken: tokenPair.RefreshToken, - TokenType: tokenPair.TokenType, - ExpiresAt: timestamppb.New(tokenPair.AccessTokenExpiresAt), + AccessToken: tokenPair.AccessToken, + RefreshToken: tokenPair.RefreshToken, + TokenType: tokenPair.TokenType, + AccessTokenExpires: timestamppb.New(tokenPair.AccessTokenExpiresAt), + RefreshTokenExpires: timestamppb.New(tokenPair.RefreshTokenExpiresAt), }, } return response @@ -200,7 +186,7 @@ func (l *LoginUserLogic) resetLoginAttempts(user *ent.User) { } // 保存刷新令牌到数据库 -func (l *LoginUserLogic) saveRefreshToken(user *ent.User, tokenPair *jwt_manager.TokenPair, in *app.LoginRequest) *ent.UserThirdAuth { +func (l *LoginUserLogic) saveRefreshToken(user *ent.User, tokenPair *jwt_manager.TokenPair, in *app.LoginRequest) (*ent.UserThirdAuth, error) { userThirdAuth, err := l.svcCtx.DB.UserThirdAuth.Create(). SetUserID(user.ID). SetRefreshToken(tokenPair.RefreshToken). @@ -208,14 +194,14 @@ func (l *LoginUserLogic) saveRefreshToken(user *ent.User, tokenPair *jwt_manager SetAccessTokenExpiry(tokenPair.AccessTokenExpiresAt). SetBoundAt(time.Now()). SetID(sonyflake.NextID()). - SetEmail(in.GetEmail()). - SetPhone(in.GetMobile()). + SetEmail(user.Email). + SetMobile(*user.Mobile). Save(l.ctx) if err != nil { l.Errorf("saveRefreshToken err: %v", err) - return nil + return nil, err } - return userThirdAuth + return userThirdAuth, nil } func (l *LoginUserLogic) convertUserToProto(u *ent.User) *app.UserInfo { diff --git a/rpc/internal/logic/user/register_user_logic.go b/rpc/internal/logic/user/register_user_logic.go index d2b7a98..33ea012 100644 --- a/rpc/internal/logic/user/register_user_logic.go +++ b/rpc/internal/logic/user/register_user_logic.go @@ -8,6 +8,7 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "google.golang.org/protobuf/types/known/timestamppb" + "mingyang-admin-app-rpc/ent/user" "mingyang-admin-app-rpc/internal/jwt_manager" "mingyang-admin-app-rpc/internal/logic/cacherepo" "mingyang-admin-app-rpc/internal/svc" @@ -22,6 +23,7 @@ type RegisterUserLogic struct { svcCtx *svc.ServiceContext logx.Logger jwtManager *jwt_manager.JWTManager + cacheRepo *cacherepo.CacheRepository } func NewRegisterUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RegisterUserLogic { @@ -30,6 +32,7 @@ func NewRegisterUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Regi svcCtx: svcCtx, jwtManager: jwt_manager.NewJWTManager(&svcCtx.Config.JWTConf), Logger: logx.WithContext(ctx), + cacheRepo: cacherepo.NewCacheRepository(ctx, svcCtx), } } @@ -68,6 +71,7 @@ func (s *RegisterUserLogic) RegisterUser(req *app.RegisterUserRequest) (*app.Reg Email: strings.ToLower(strings.TrimSpace(req.GetEmail())), Mobile: mobile, PasswordHash: passwordHash, + Gender: user.Gender(req.GetGender()), Nickname: req.GetNickName(), RegistrationSource: req.GetRegistrationSource(), Metadata: map[string]interface{}{ @@ -106,12 +110,11 @@ func (s *RegisterUserLogic) RegisterUser(req *app.RegisterUserRequest) (*app.Reg } 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), + AccessToken: tokenPair.AccessToken, + RefreshToken: tokenPair.RefreshToken, + TokenType: tokenPair.TokenType, + AccessTokenExpires: timeToProto(tokenPair.AccessTokenExpiresAt), + RefreshTokenExpires: timeToProto(tokenPair.RefreshTokenExpiresAt), } } return response, nil @@ -124,27 +127,45 @@ func (s *RegisterUserLogic) validateRegisterRequest(req *app.RegisterUserRequest // verifyRegistrationCode 验证注册验证码 func (s *RegisterUserLogic) verifyRegistrationCode(ctx context.Context, req *app.RegisterUserRequest) error { - key := req.GetVerificationId() - cacheRepository := cacherepo.NewCacheRepository(ctx, s.svcCtx) + var cacheKey string + verificationType := req.GetVerificationType() + + if app.AccountType(verificationType) == app.AccountType_EMAIL { + cacheKey = fmt.Sprintf("email_verification_code:%s", req.GetEmail()) + } else if app.AccountType(verificationType) == app.AccountType_MOBILE { + cacheKey = fmt.Sprintf("mobile_verification_code:%s", req.GetMobile()) + } else { + return errors.New("invalid verification type") + } + fmt.Printf("cacheKey: %s", cacheKey) // 获取验证码数据 - codeData, err := cacheRepository.GetVerificationCode(ctx, key) + codeData, err := s.cacheRepo.GetVerificationCode(ctx, cacheKey) if err != nil { - return fmt.Errorf("failed to get verification code.proto: %w", err) + fmt.Printf("Failed to get verification code: %v\n", err) + return fmt.Errorf("failed to get verification code: %w", err) } if codeData == nil { - return errors.New("verification code.proto expired or not found") + return errors.New("verification code expired or not found") } // 验证验证码 - if codeData.Code != req.GetVerificationCode() { + if codeData.Code != req.GetCaptcha() { // 增加尝试次数 - if err := cacheRepository.IncrementVerificationAttempts(ctx, key); err != nil { + if err := s.cacheRepo.IncrementVerificationAttempts(ctx, cacheKey); 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 errors.New("invalid verification code") } + /*// 验证成功,删除验证码 + if err := s.cacheRepo.DeleteVerificationCode(ctx, cacheKey); err != nil { + fmt.Printf("Failed to delete verification code: %v\n", err) + }*/ return nil } + +func timeToProto(t time.Time) *timestamppb.Timestamp { + pbTimestamp := timestamppb.New(t) + if err := pbTimestamp.CheckValid(); err != nil { + return nil + } + return pbTimestamp +} diff --git a/rpc/internal/server/app_server.go b/rpc/internal/server/app_server.go index 73e8e33..30f1db5 100644 --- a/rpc/internal/server/app_server.go +++ b/rpc/internal/server/app_server.go @@ -6,6 +6,7 @@ package server import ( "context" + "mingyang-admin-app-rpc/internal/logic/base" "mingyang-admin-app-rpc/internal/logic/code" "mingyang-admin-app-rpc/internal/logic/user" "mingyang-admin-app-rpc/internal/svc" @@ -40,3 +41,14 @@ func (s *AppServer) LoginUser(ctx context.Context, in *app.LoginRequest) (*app.L l := user.NewLoginUserLogic(ctx, s.svcCtx) return l.LoginUser(in) } + +// 分页查询用户信息 +func (s *AppServer) ListUsers(ctx context.Context, in *app.PageUserRequest) (*app.PageUserResponse, error) { + l := user.NewListUsersLogic(ctx, s.svcCtx) + return l.ListUsers(in) +} + +func (s *AppServer) InitDatabase(ctx context.Context, in *app.Empty) (*app.BaseResp, error) { + l := base.NewInitDatabaseLogic(ctx, s.svcCtx) + return l.InitDatabase(in) +} diff --git a/rpc/internal/svc/service_context.go b/rpc/internal/svc/service_context.go new file mode 100644 index 0000000..7879546 --- /dev/null +++ b/rpc/internal/svc/service_context.go @@ -0,0 +1,46 @@ +package svc + +import ( + "github.com/ip2location/ip2location-go/v9" + "github.com/redis/go-redis/v9" + "github.com/zeromicro/go-zero/core/logx" + "github.com/zeromicro/go-zero/zrpc" + "mingyang-admin-app-rpc/ent" + "mingyang-admin-app-rpc/internal/config" + "mingyang-admin-simple-admin-message/mcmsclient" +) + +type ServiceContext struct { + Config config.Config + DB *ent.Client + Redis redis.UniversalClient + IPDB *ip2location.DB + McmsRpc mcmsclient.Mcms +} + +func NewServiceContext(c config.Config) *ServiceContext { + + entOpts := []ent.Option{ + ent.Log(logx.Info), + ent.Driver(c.DatabaseConf.NewNoCacheDriver()), + } + + if c.DatabaseConf.Debug { + entOpts = append(entOpts, ent.Debug()) + } + + db := ent.NewClient(entOpts...) + + ipDB, err := ip2location.OpenDB(c.IP2Location.DBPath) + if err != nil { + logx.Errorw("failed to open ip2location db", logx.Field("detail", err)) + } + + return &ServiceContext{ + Config: c, + DB: db, + IPDB: ipDB, + Redis: c.RedisConf.MustNewUniversalRedis(), + McmsRpc: mcmsclient.NewMcms(zrpc.MustNewClient(c.McmsRpc)), + } +} diff --git a/rpc/internal/svc/servicecontext.go b/rpc/internal/svc/servicecontext.go deleted file mode 100644 index 9e3007c..0000000 --- a/rpc/internal/svc/servicecontext.go +++ /dev/null @@ -1,13 +0,0 @@ -package svc - -import "mingyang-admin-iot-app/rpc/internal/config" - -type ServiceContext struct { - Config config.Config -} - -func NewServiceContext(c config.Config) *ServiceContext { - return &ServiceContext{ - Config: c, - } -} diff --git a/rpc/types/app/app.pb.go b/rpc/types/app/app.pb.go index 56c2da1..71bd325 100644 --- a/rpc/types/app/app.pb.go +++ b/rpc/types/app/app.pb.go @@ -143,16 +143,14 @@ func (VerifyCodeType) EnumDescriptor() ([]byte, []int) { // 认证令牌 type AuthToken struct { - state protoimpl.MessageState `protogen:"open.v1"` - AccessToken string `protobuf:"bytes,1,opt,name=access_token,json=accessToken,proto3" json:"access_token"` - RefreshToken string `protobuf:"bytes,2,opt,name=refresh_token,json=refreshToken,proto3" json:"refresh_token"` - TokenType string `protobuf:"bytes,3,opt,name=token_type,json=tokenType,proto3" json:"token_type"` - ExpiresIn int32 `protobuf:"varint,4,opt,name=expires_in,json=expiresIn,proto3" json:"expires_in"` - IssuedAt *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=issued_at,json=issuedAt,proto3" json:"issued_at"` - ExpiresAt *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=expires_at,json=expiresAt,proto3" json:"expires_at"` - Scopes []string `protobuf:"bytes,7,rep,name=scopes,proto3" json:"scopes"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + AccessToken string `protobuf:"bytes,1,opt,name=access_token,json=accessToken,proto3" json:"access_token"` + RefreshToken string `protobuf:"bytes,2,opt,name=refresh_token,json=refreshToken,proto3" json:"refresh_token"` + TokenType string `protobuf:"bytes,3,opt,name=token_type,json=tokenType,proto3" json:"token_type"` + AccessTokenExpires *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=access_token_expires,json=accessTokenExpires,proto3" json:"access_token_expires"` + RefreshTokenExpires *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=refresh_token_expires,json=refreshTokenExpires,proto3" json:"refresh_token_expires"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *AuthToken) Reset() { @@ -206,30 +204,333 @@ func (x *AuthToken) GetTokenType() string { return "" } -func (x *AuthToken) GetExpiresIn() int32 { +func (x *AuthToken) GetAccessTokenExpires() *timestamppb.Timestamp { if x != nil { - return x.ExpiresIn + return x.AccessTokenExpires + } + return nil +} + +func (x *AuthToken) GetRefreshTokenExpires() *timestamppb.Timestamp { + if x != nil { + return x.RefreshTokenExpires + } + return nil +} + +type BaseIDResp struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id"` + Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *BaseIDResp) Reset() { + *x = BaseIDResp{} + mi := &file_app_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *BaseIDResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BaseIDResp) ProtoMessage() {} + +func (x *BaseIDResp) ProtoReflect() protoreflect.Message { + mi := &file_app_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BaseIDResp.ProtoReflect.Descriptor instead. +func (*BaseIDResp) Descriptor() ([]byte, []int) { + return file_app_proto_rawDescGZIP(), []int{1} +} + +func (x *BaseIDResp) GetId() uint64 { + if x != nil { + return x.Id } return 0 } -func (x *AuthToken) GetIssuedAt() *timestamppb.Timestamp { +func (x *BaseIDResp) GetMsg() string { if x != nil { - return x.IssuedAt + return x.Msg } - return nil + return "" } -func (x *AuthToken) GetExpiresAt() *timestamppb.Timestamp { - if x != nil { - return x.ExpiresAt - } - return nil +type BaseMsg struct { + state protoimpl.MessageState `protogen:"open.v1"` + Msg string `protobuf:"bytes,1,opt,name=msg,proto3" json:"msg"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } -func (x *AuthToken) GetScopes() []string { +func (x *BaseMsg) Reset() { + *x = BaseMsg{} + mi := &file_app_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *BaseMsg) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BaseMsg) ProtoMessage() {} + +func (x *BaseMsg) ProtoReflect() protoreflect.Message { + mi := &file_app_proto_msgTypes[2] if x != nil { - return x.Scopes + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BaseMsg.ProtoReflect.Descriptor instead. +func (*BaseMsg) Descriptor() ([]byte, []int) { + return file_app_proto_rawDescGZIP(), []int{2} +} + +func (x *BaseMsg) GetMsg() string { + if x != nil { + return x.Msg + } + return "" +} + +type BaseResp struct { + state protoimpl.MessageState `protogen:"open.v1"` + Msg string `protobuf:"bytes,1,opt,name=msg,proto3" json:"msg"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *BaseResp) Reset() { + *x = BaseResp{} + mi := &file_app_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *BaseResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BaseResp) ProtoMessage() {} + +func (x *BaseResp) ProtoReflect() protoreflect.Message { + mi := &file_app_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BaseResp.ProtoReflect.Descriptor instead. +func (*BaseResp) Descriptor() ([]byte, []int) { + return file_app_proto_rawDescGZIP(), []int{3} +} + +func (x *BaseResp) GetMsg() string { + if x != nil { + return x.Msg + } + return "" +} + +type BaseUUIDResp struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id"` + Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *BaseUUIDResp) Reset() { + *x = BaseUUIDResp{} + mi := &file_app_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *BaseUUIDResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BaseUUIDResp) ProtoMessage() {} + +func (x *BaseUUIDResp) ProtoReflect() protoreflect.Message { + mi := &file_app_proto_msgTypes[4] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BaseUUIDResp.ProtoReflect.Descriptor instead. +func (*BaseUUIDResp) Descriptor() ([]byte, []int) { + return file_app_proto_rawDescGZIP(), []int{4} +} + +func (x *BaseUUIDResp) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *BaseUUIDResp) GetMsg() string { + if x != nil { + return x.Msg + } + return "" +} + +// base message +type Empty struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Empty) Reset() { + *x = Empty{} + mi := &file_app_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Empty) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Empty) ProtoMessage() {} + +func (x *Empty) ProtoReflect() protoreflect.Message { + mi := &file_app_proto_msgTypes[5] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Empty.ProtoReflect.Descriptor instead. +func (*Empty) Descriptor() ([]byte, []int) { + return file_app_proto_rawDescGZIP(), []int{5} +} + +type IDReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *IDReq) Reset() { + *x = IDReq{} + mi := &file_app_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *IDReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*IDReq) ProtoMessage() {} + +func (x *IDReq) ProtoReflect() protoreflect.Message { + mi := &file_app_proto_msgTypes[6] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use IDReq.ProtoReflect.Descriptor instead. +func (*IDReq) Descriptor() ([]byte, []int) { + return file_app_proto_rawDescGZIP(), []int{6} +} + +func (x *IDReq) GetId() uint64 { + if x != nil { + return x.Id + } + return 0 +} + +type IDsReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + Ids []uint64 `protobuf:"varint,1,rep,packed,name=ids,proto3" json:"ids"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *IDsReq) Reset() { + *x = IDsReq{} + mi := &file_app_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *IDsReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*IDsReq) ProtoMessage() {} + +func (x *IDsReq) ProtoReflect() protoreflect.Message { + mi := &file_app_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use IDsReq.ProtoReflect.Descriptor instead. +func (*IDsReq) Descriptor() ([]byte, []int) { + return file_app_proto_rawDescGZIP(), []int{7} +} + +func (x *IDsReq) GetIds() []uint64 { + if x != nil { + return x.Ids } return nil } @@ -237,20 +538,17 @@ func (x *AuthToken) GetScopes() []string { type LoginRequest struct { state protoimpl.MessageState `protogen:"open.v1"` Username *string `protobuf:"bytes,1,opt,name=username,proto3,oneof" json:"username"` - Email *string `protobuf:"bytes,2,opt,name=email,proto3,oneof" json:"email"` - Mobile *string `protobuf:"bytes,3,opt,name=mobile,proto3,oneof" json:"mobile"` - Password *string `protobuf:"bytes,4,opt,name=password,proto3,oneof" json:"password"` - ClientIp *string `protobuf:"bytes,5,opt,name=clientIp,proto3,oneof" json:"clientIp"` - Platform *string `protobuf:"bytes,6,opt,name=platform,proto3,oneof" json:"platform"` - LoginType *string `protobuf:"bytes,7,opt,name=login_type,json=loginType,proto3,oneof" json:"login_type"` - LoginPlatform *string `protobuf:"bytes,8,opt,name=login_platform,json=loginPlatform,proto3,oneof" json:"login_platform"` + Password *string `protobuf:"bytes,2,opt,name=password,proto3,oneof" json:"password"` + ClientIp *string `protobuf:"bytes,3,opt,name=clientIp,proto3,oneof" json:"clientIp"` + LoginTyp *string `protobuf:"bytes,4,opt,name=loginTyp,proto3,oneof" json:"loginTyp"` + LoginPlatform *string `protobuf:"bytes,5,opt,name=loginPlatform,proto3,oneof" json:"loginPlatform"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *LoginRequest) Reset() { *x = LoginRequest{} - mi := &file_app_proto_msgTypes[1] + mi := &file_app_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -262,7 +560,7 @@ func (x *LoginRequest) String() string { func (*LoginRequest) ProtoMessage() {} func (x *LoginRequest) ProtoReflect() protoreflect.Message { - mi := &file_app_proto_msgTypes[1] + mi := &file_app_proto_msgTypes[8] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -275,7 +573,7 @@ func (x *LoginRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use LoginRequest.ProtoReflect.Descriptor instead. func (*LoginRequest) Descriptor() ([]byte, []int) { - return file_app_proto_rawDescGZIP(), []int{1} + return file_app_proto_rawDescGZIP(), []int{8} } func (x *LoginRequest) GetUsername() string { @@ -285,20 +583,6 @@ func (x *LoginRequest) GetUsername() string { return "" } -func (x *LoginRequest) GetEmail() string { - if x != nil && x.Email != nil { - return *x.Email - } - return "" -} - -func (x *LoginRequest) GetMobile() string { - if x != nil && x.Mobile != nil { - return *x.Mobile - } - return "" -} - func (x *LoginRequest) GetPassword() string { if x != nil && x.Password != nil { return *x.Password @@ -313,16 +597,9 @@ func (x *LoginRequest) GetClientIp() string { return "" } -func (x *LoginRequest) GetPlatform() string { - if x != nil && x.Platform != nil { - return *x.Platform - } - return "" -} - -func (x *LoginRequest) GetLoginType() string { - if x != nil && x.LoginType != nil { - return *x.LoginType +func (x *LoginRequest) GetLoginTyp() string { + if x != nil && x.LoginTyp != nil { + return *x.LoginTyp } return "" } @@ -344,7 +621,7 @@ type LoginResponse struct { func (x *LoginResponse) Reset() { *x = LoginResponse{} - mi := &file_app_proto_msgTypes[2] + mi := &file_app_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -356,7 +633,7 @@ func (x *LoginResponse) String() string { func (*LoginResponse) ProtoMessage() {} func (x *LoginResponse) ProtoReflect() protoreflect.Message { - mi := &file_app_proto_msgTypes[2] + mi := &file_app_proto_msgTypes[9] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -369,7 +646,7 @@ func (x *LoginResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use LoginResponse.ProtoReflect.Descriptor instead. func (*LoginResponse) Descriptor() ([]byte, []int) { - return file_app_proto_rawDescGZIP(), []int{2} + return file_app_proto_rawDescGZIP(), []int{9} } func (x *LoginResponse) GetUser() *UserInfo { @@ -386,6 +663,202 @@ func (x *LoginResponse) GetAuthToken() *AuthToken { return nil } +type PageInfoReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + Page uint64 `protobuf:"varint,1,opt,name=page,proto3" json:"page"` + PageSize uint64 `protobuf:"varint,2,opt,name=page_size,json=pageSize,proto3" json:"page_size"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PageInfoReq) Reset() { + *x = PageInfoReq{} + mi := &file_app_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PageInfoReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PageInfoReq) ProtoMessage() {} + +func (x *PageInfoReq) ProtoReflect() protoreflect.Message { + mi := &file_app_proto_msgTypes[10] + 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 PageInfoReq.ProtoReflect.Descriptor instead. +func (*PageInfoReq) Descriptor() ([]byte, []int) { + return file_app_proto_rawDescGZIP(), []int{10} +} + +func (x *PageInfoReq) GetPage() uint64 { + if x != nil { + return x.Page + } + return 0 +} + +func (x *PageInfoReq) GetPageSize() uint64 { + if x != nil { + return x.PageSize + } + return 0 +} + +type PageUserRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Page uint64 `protobuf:"varint,1,opt,name=page,proto3" json:"page"` + PageSize uint64 `protobuf:"varint,2,opt,name=page_size,json=pageSize,proto3" json:"page_size"` + Username *string `protobuf:"bytes,3,opt,name=username,proto3,oneof" json:"username"` + Email *string `protobuf:"bytes,4,opt,name=email,proto3,oneof" json:"email"` + Mobile *string `protobuf:"bytes,5,opt,name=mobile,proto3,oneof" json:"mobile"` + Status *string `protobuf:"bytes,6,opt,name=status,proto3,oneof" json:"status"` + ClientIp *string `protobuf:"bytes,7,opt,name=clientIp,proto3,oneof" json:"clientIp"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PageUserRequest) Reset() { + *x = PageUserRequest{} + mi := &file_app_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PageUserRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PageUserRequest) ProtoMessage() {} + +func (x *PageUserRequest) ProtoReflect() protoreflect.Message { + mi := &file_app_proto_msgTypes[11] + 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 PageUserRequest.ProtoReflect.Descriptor instead. +func (*PageUserRequest) Descriptor() ([]byte, []int) { + return file_app_proto_rawDescGZIP(), []int{11} +} + +func (x *PageUserRequest) GetPage() uint64 { + if x != nil { + return x.Page + } + return 0 +} + +func (x *PageUserRequest) GetPageSize() uint64 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *PageUserRequest) GetUsername() string { + if x != nil && x.Username != nil { + return *x.Username + } + return "" +} + +func (x *PageUserRequest) GetEmail() string { + if x != nil && x.Email != nil { + return *x.Email + } + return "" +} + +func (x *PageUserRequest) GetMobile() string { + if x != nil && x.Mobile != nil { + return *x.Mobile + } + return "" +} + +func (x *PageUserRequest) GetStatus() string { + if x != nil && x.Status != nil { + return *x.Status + } + return "" +} + +func (x *PageUserRequest) GetClientIp() string { + if x != nil && x.ClientIp != nil { + return *x.ClientIp + } + return "" +} + +type PageUserResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Users []*UserInfo `protobuf:"bytes,1,rep,name=users,proto3" json:"users"` + Total uint64 `protobuf:"varint,2,opt,name=total,proto3" json:"total"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PageUserResponse) Reset() { + *x = PageUserResponse{} + mi := &file_app_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PageUserResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PageUserResponse) ProtoMessage() {} + +func (x *PageUserResponse) ProtoReflect() protoreflect.Message { + mi := &file_app_proto_msgTypes[12] + 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 PageUserResponse.ProtoReflect.Descriptor instead. +func (*PageUserResponse) Descriptor() ([]byte, []int) { + return file_app_proto_rawDescGZIP(), []int{12} +} + +func (x *PageUserResponse) GetUsers() []*UserInfo { + if x != nil { + return x.Users + } + return nil +} + +func (x *PageUserResponse) GetTotal() uint64 { + if x != nil { + return x.Total + } + return 0 +} + type RegisterUserRequest struct { state protoimpl.MessageState `protogen:"open.v1"` Email *string `protobuf:"bytes,1,opt,name=email,proto3,oneof" json:"email"` @@ -393,18 +866,18 @@ type RegisterUserRequest struct { Username *string `protobuf:"bytes,3,opt,name=username,proto3,oneof" json:"username"` Name *string `protobuf:"bytes,4,opt,name=name,proto3,oneof" json:"name"` Mobile *string `protobuf:"bytes,5,opt,name=mobile,proto3,oneof" json:"mobile"` - VerificationCode *string `protobuf:"bytes,6,opt,name=verificationCode,proto3,oneof" json:"verificationCode"` + Captcha *string `protobuf:"bytes,6,opt,name=captcha,proto3,oneof" json:"captcha"` VerificationType *uint32 `protobuf:"varint,7,opt,name=verificationType,proto3,oneof" json:"verificationType"` - VerificationId *string `protobuf:"bytes,8,opt,name=verificationId,proto3,oneof" json:"verificationId"` NickName *string `protobuf:"bytes,9,opt,name=nickName,proto3,oneof" json:"nickName"` RegistrationSource *string `protobuf:"bytes,10,opt,name=registrationSource,proto3,oneof" json:"registrationSource"` + Gender *string `protobuf:"bytes,11,opt,name=gender,proto3,oneof" json:"gender"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *RegisterUserRequest) Reset() { *x = RegisterUserRequest{} - mi := &file_app_proto_msgTypes[3] + mi := &file_app_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -416,7 +889,7 @@ func (x *RegisterUserRequest) String() string { func (*RegisterUserRequest) ProtoMessage() {} func (x *RegisterUserRequest) ProtoReflect() protoreflect.Message { - mi := &file_app_proto_msgTypes[3] + mi := &file_app_proto_msgTypes[13] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -429,7 +902,7 @@ func (x *RegisterUserRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use RegisterUserRequest.ProtoReflect.Descriptor instead. func (*RegisterUserRequest) Descriptor() ([]byte, []int) { - return file_app_proto_rawDescGZIP(), []int{3} + return file_app_proto_rawDescGZIP(), []int{13} } func (x *RegisterUserRequest) GetEmail() string { @@ -467,9 +940,9 @@ func (x *RegisterUserRequest) GetMobile() string { return "" } -func (x *RegisterUserRequest) GetVerificationCode() string { - if x != nil && x.VerificationCode != nil { - return *x.VerificationCode +func (x *RegisterUserRequest) GetCaptcha() string { + if x != nil && x.Captcha != nil { + return *x.Captcha } return "" } @@ -481,13 +954,6 @@ func (x *RegisterUserRequest) GetVerificationType() uint32 { return 0 } -func (x *RegisterUserRequest) GetVerificationId() string { - if x != nil && x.VerificationId != nil { - return *x.VerificationId - } - return "" -} - func (x *RegisterUserRequest) GetNickName() string { if x != nil && x.NickName != nil { return *x.NickName @@ -502,6 +968,13 @@ func (x *RegisterUserRequest) GetRegistrationSource() string { return "" } +func (x *RegisterUserRequest) GetGender() string { + if x != nil && x.Gender != nil { + return *x.Gender + } + return "" +} + type RegisterUserResponse struct { state protoimpl.MessageState `protogen:"open.v1"` User *UserInfo `protobuf:"bytes,1,opt,name=user,proto3" json:"user"` @@ -514,7 +987,7 @@ type RegisterUserResponse struct { func (x *RegisterUserResponse) Reset() { *x = RegisterUserResponse{} - mi := &file_app_proto_msgTypes[4] + mi := &file_app_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -526,7 +999,7 @@ func (x *RegisterUserResponse) String() string { func (*RegisterUserResponse) ProtoMessage() {} func (x *RegisterUserResponse) ProtoReflect() protoreflect.Message { - mi := &file_app_proto_msgTypes[4] + mi := &file_app_proto_msgTypes[14] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -539,7 +1012,7 @@ func (x *RegisterUserResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use RegisterUserResponse.ProtoReflect.Descriptor instead. func (*RegisterUserResponse) Descriptor() ([]byte, []int) { - return file_app_proto_rawDescGZIP(), []int{4} + return file_app_proto_rawDescGZIP(), []int{14} } func (x *RegisterUserResponse) GetUser() *UserInfo { @@ -570,6 +1043,94 @@ func (x *RegisterUserResponse) GetPhoneVerificationRequired() bool { return false } +type UUIDReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UUIDReq) Reset() { + *x = UUIDReq{} + mi := &file_app_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UUIDReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UUIDReq) ProtoMessage() {} + +func (x *UUIDReq) ProtoReflect() protoreflect.Message { + mi := &file_app_proto_msgTypes[15] + 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 UUIDReq.ProtoReflect.Descriptor instead. +func (*UUIDReq) Descriptor() ([]byte, []int) { + return file_app_proto_rawDescGZIP(), []int{15} +} + +func (x *UUIDReq) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +type UUIDsReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + Ids []string `protobuf:"bytes,1,rep,name=ids,proto3" json:"ids"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UUIDsReq) Reset() { + *x = UUIDsReq{} + mi := &file_app_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UUIDsReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UUIDsReq) ProtoMessage() {} + +func (x *UUIDsReq) ProtoReflect() protoreflect.Message { + mi := &file_app_proto_msgTypes[16] + 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 UUIDsReq.ProtoReflect.Descriptor instead. +func (*UUIDsReq) Descriptor() ([]byte, []int) { + return file_app_proto_rawDescGZIP(), []int{16} +} + +func (x *UUIDsReq) GetIds() []string { + if x != nil { + return x.Ids + } + return nil +} + type UserInfo struct { state protoimpl.MessageState `protogen:"open.v1"` Id *uint64 `protobuf:"varint,1,opt,name=id,proto3,oneof" json:"id"` @@ -591,13 +1152,14 @@ type UserInfo struct { RecoveryTokenExpiry *int64 `protobuf:"varint,17,opt,name=recovery_token_expiry,json=recoveryTokenExpiry,proto3,oneof" json:"recovery_token_expiry"` Metadata *structpb.Struct `protobuf:"bytes,20,opt,name=metadata,proto3,oneof" json:"metadata"` RegistrationSource *string `protobuf:"bytes,21,opt,name=registration_source,json=registrationSource,proto3,oneof" json:"registration_source"` + BirthdayAt *int64 `protobuf:"varint,18,opt,name=birthday_at,json=birthdayAt,proto3,oneof" json:"birthday_at"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *UserInfo) Reset() { *x = UserInfo{} - mi := &file_app_proto_msgTypes[5] + mi := &file_app_proto_msgTypes[17] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -609,7 +1171,7 @@ func (x *UserInfo) String() string { func (*UserInfo) ProtoMessage() {} func (x *UserInfo) ProtoReflect() protoreflect.Message { - mi := &file_app_proto_msgTypes[5] + mi := &file_app_proto_msgTypes[17] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -622,7 +1184,7 @@ func (x *UserInfo) ProtoReflect() protoreflect.Message { // Deprecated: Use UserInfo.ProtoReflect.Descriptor instead. func (*UserInfo) Descriptor() ([]byte, []int) { - return file_app_proto_rawDescGZIP(), []int{5} + return file_app_proto_rawDescGZIP(), []int{17} } func (x *UserInfo) GetId() uint64 { @@ -758,6 +1320,13 @@ func (x *UserInfo) GetRegistrationSource() string { return "" } +func (x *UserInfo) GetBirthdayAt() int64 { + if x != nil && x.BirthdayAt != nil { + return *x.BirthdayAt + } + return 0 +} + type VerifyCodeReq struct { state protoimpl.MessageState `protogen:"open.v1"` Type VerifyCodeType `protobuf:"varint,1,opt,name=type,proto3,enum=app.VerifyCodeType" json:"type"` @@ -769,7 +1338,7 @@ type VerifyCodeReq struct { func (x *VerifyCodeReq) Reset() { *x = VerifyCodeReq{} - mi := &file_app_proto_msgTypes[6] + mi := &file_app_proto_msgTypes[18] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -781,7 +1350,7 @@ func (x *VerifyCodeReq) String() string { func (*VerifyCodeReq) ProtoMessage() {} func (x *VerifyCodeReq) ProtoReflect() protoreflect.Message { - mi := &file_app_proto_msgTypes[6] + mi := &file_app_proto_msgTypes[18] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -794,7 +1363,7 @@ func (x *VerifyCodeReq) ProtoReflect() protoreflect.Message { // Deprecated: Use VerifyCodeReq.ProtoReflect.Descriptor instead. func (*VerifyCodeReq) Descriptor() ([]byte, []int) { - return file_app_proto_rawDescGZIP(), []int{6} + return file_app_proto_rawDescGZIP(), []int{18} } func (x *VerifyCodeReq) GetType() VerifyCodeType { @@ -820,15 +1389,15 @@ func (x *VerifyCodeReq) GetValue() string { type VerifyCodeResp struct { state protoimpl.MessageState `protogen:"open.v1"` - Code *string `protobuf:"bytes,1,opt,name=code,proto3,oneof" json:"code"` - Expire *uint32 `protobuf:"varint,2,opt,name=expire,proto3,oneof" json:"expire"` + CaptchaCode string `protobuf:"bytes,1,opt,name=captchaCode,proto3" json:"captchaCode"` + Expire uint32 `protobuf:"varint,2,opt,name=expire,proto3" json:"expire"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *VerifyCodeResp) Reset() { *x = VerifyCodeResp{} - mi := &file_app_proto_msgTypes[7] + mi := &file_app_proto_msgTypes[19] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -840,7 +1409,7 @@ func (x *VerifyCodeResp) String() string { func (*VerifyCodeResp) ProtoMessage() {} func (x *VerifyCodeResp) ProtoReflect() protoreflect.Message { - mi := &file_app_proto_msgTypes[7] + mi := &file_app_proto_msgTypes[19] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -853,19 +1422,19 @@ func (x *VerifyCodeResp) ProtoReflect() protoreflect.Message { // Deprecated: Use VerifyCodeResp.ProtoReflect.Descriptor instead. func (*VerifyCodeResp) Descriptor() ([]byte, []int) { - return file_app_proto_rawDescGZIP(), []int{7} + return file_app_proto_rawDescGZIP(), []int{19} } -func (x *VerifyCodeResp) GetCode() string { - if x != nil && x.Code != nil { - return *x.Code +func (x *VerifyCodeResp) GetCaptchaCode() string { + if x != nil { + return x.CaptchaCode } return "" } func (x *VerifyCodeResp) GetExpire() uint32 { - if x != nil && x.Expire != nil { - return *x.Expire + if x != nil { + return x.Expire } return 0 } @@ -874,68 +1443,97 @@ var File_app_proto protoreflect.FileDescriptor const file_app_proto_rawDesc = "" + "\n" + - "\tapp.proto\x12\x03app\x1a\x1cgoogle/protobuf/struct.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\x9d\x02\n" + + "\tapp.proto\x12\x03app\x1a\x1cgoogle/protobuf/struct.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\x90\x02\n" + "\tAuthToken\x12!\n" + "\faccess_token\x18\x01 \x01(\tR\vaccessToken\x12#\n" + "\rrefresh_token\x18\x02 \x01(\tR\frefreshToken\x12\x1d\n" + "\n" + - "token_type\x18\x03 \x01(\tR\ttokenType\x12\x1d\n" + + "token_type\x18\x03 \x01(\tR\ttokenType\x12L\n" + + "\x14access_token_expires\x18\x04 \x01(\v2\x1a.google.protobuf.TimestampR\x12accessTokenExpires\x12N\n" + + "\x15refresh_token_expires\x18\x05 \x01(\v2\x1a.google.protobuf.TimestampR\x13refreshTokenExpires\".\n" + "\n" + - "expires_in\x18\x04 \x01(\x05R\texpiresIn\x127\n" + - "\tissued_at\x18\x05 \x01(\v2\x1a.google.protobuf.TimestampR\bissuedAt\x129\n" + - "\n" + - "expires_at\x18\x06 \x01(\v2\x1a.google.protobuf.TimestampR\texpiresAt\x12\x16\n" + - "\x06scopes\x18\a \x03(\tR\x06scopes\"\x85\x03\n" + + "BaseIDResp\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x04R\x02id\x12\x10\n" + + "\x03msg\x18\x02 \x01(\tR\x03msg\"\x1b\n" + + "\aBaseMsg\x12\x10\n" + + "\x03msg\x18\x01 \x01(\tR\x03msg\"\x1c\n" + + "\bBaseResp\x12\x10\n" + + "\x03msg\x18\x01 \x01(\tR\x03msg\"0\n" + + "\fBaseUUIDResp\x12\x0e\n" + + "\x02id\x18\x01 \x01(\tR\x02id\x12\x10\n" + + "\x03msg\x18\x02 \x01(\tR\x03msg\"\a\n" + + "\x05Empty\"\x17\n" + + "\x05IDReq\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x04R\x02id\"\x1a\n" + + "\x06IDsReq\x12\x10\n" + + "\x03ids\x18\x01 \x03(\x04R\x03ids\"\x83\x02\n" + "\fLoginRequest\x12\x1f\n" + - "\busername\x18\x01 \x01(\tH\x00R\busername\x88\x01\x01\x12\x19\n" + - "\x05email\x18\x02 \x01(\tH\x01R\x05email\x88\x01\x01\x12\x1b\n" + - "\x06mobile\x18\x03 \x01(\tH\x02R\x06mobile\x88\x01\x01\x12\x1f\n" + - "\bpassword\x18\x04 \x01(\tH\x03R\bpassword\x88\x01\x01\x12\x1f\n" + - "\bclientIp\x18\x05 \x01(\tH\x04R\bclientIp\x88\x01\x01\x12\x1f\n" + - "\bplatform\x18\x06 \x01(\tH\x05R\bplatform\x88\x01\x01\x12\"\n" + - "\n" + - "login_type\x18\a \x01(\tH\x06R\tloginType\x88\x01\x01\x12*\n" + - "\x0elogin_platform\x18\b \x01(\tH\aR\rloginPlatform\x88\x01\x01B\v\n" + - "\t_usernameB\b\n" + - "\x06_emailB\t\n" + - "\a_mobileB\v\n" + + "\busername\x18\x01 \x01(\tH\x00R\busername\x88\x01\x01\x12\x1f\n" + + "\bpassword\x18\x02 \x01(\tH\x01R\bpassword\x88\x01\x01\x12\x1f\n" + + "\bclientIp\x18\x03 \x01(\tH\x02R\bclientIp\x88\x01\x01\x12\x1f\n" + + "\bloginTyp\x18\x04 \x01(\tH\x03R\bloginTyp\x88\x01\x01\x12)\n" + + "\rloginPlatform\x18\x05 \x01(\tH\x04R\rloginPlatform\x88\x01\x01B\v\n" + + "\t_usernameB\v\n" + "\t_passwordB\v\n" + "\t_clientIpB\v\n" + - "\t_platformB\r\n" + - "\v_login_typeB\x11\n" + - "\x0f_login_platform\"a\n" + + "\t_loginTypB\x10\n" + + "\x0e_loginPlatform\"a\n" + "\rLoginResponse\x12!\n" + "\x04user\x18\x01 \x01(\v2\r.app.UserInfoR\x04user\x12-\n" + "\n" + - "auth_token\x18\x02 \x01(\v2\x0e.app.AuthTokenR\tauthToken\"\xa6\x04\n" + + "auth_token\x18\x02 \x01(\v2\x0e.app.AuthTokenR\tauthToken\">\n" + + "\vPageInfoReq\x12\x12\n" + + "\x04page\x18\x01 \x01(\x04R\x04page\x12\x1b\n" + + "\tpage_size\x18\x02 \x01(\x04R\bpageSize\"\x93\x02\n" + + "\x0fPageUserRequest\x12\x12\n" + + "\x04page\x18\x01 \x01(\x04R\x04page\x12\x1b\n" + + "\tpage_size\x18\x02 \x01(\x04R\bpageSize\x12\x1f\n" + + "\busername\x18\x03 \x01(\tH\x00R\busername\x88\x01\x01\x12\x19\n" + + "\x05email\x18\x04 \x01(\tH\x01R\x05email\x88\x01\x01\x12\x1b\n" + + "\x06mobile\x18\x05 \x01(\tH\x02R\x06mobile\x88\x01\x01\x12\x1b\n" + + "\x06status\x18\x06 \x01(\tH\x03R\x06status\x88\x01\x01\x12\x1f\n" + + "\bclientIp\x18\a \x01(\tH\x04R\bclientIp\x88\x01\x01B\v\n" + + "\t_usernameB\b\n" + + "\x06_emailB\t\n" + + "\a_mobileB\t\n" + + "\a_statusB\v\n" + + "\t_clientIp\"M\n" + + "\x10PageUserResponse\x12#\n" + + "\x05users\x18\x01 \x03(\v2\r.app.UserInfoR\x05users\x12\x14\n" + + "\x05total\x18\x02 \x01(\x04R\x05total\"\xf3\x03\n" + "\x13RegisterUserRequest\x12\x19\n" + "\x05email\x18\x01 \x01(\tH\x00R\x05email\x88\x01\x01\x12\x1f\n" + "\bpassword\x18\x02 \x01(\tH\x01R\bpassword\x88\x01\x01\x12\x1f\n" + "\busername\x18\x03 \x01(\tH\x02R\busername\x88\x01\x01\x12\x17\n" + "\x04name\x18\x04 \x01(\tH\x03R\x04name\x88\x01\x01\x12\x1b\n" + - "\x06mobile\x18\x05 \x01(\tH\x04R\x06mobile\x88\x01\x01\x12/\n" + - "\x10verificationCode\x18\x06 \x01(\tH\x05R\x10verificationCode\x88\x01\x01\x12/\n" + - "\x10verificationType\x18\a \x01(\rH\x06R\x10verificationType\x88\x01\x01\x12+\n" + - "\x0everificationId\x18\b \x01(\tH\aR\x0everificationId\x88\x01\x01\x12\x1f\n" + - "\bnickName\x18\t \x01(\tH\bR\bnickName\x88\x01\x01\x123\n" + + "\x06mobile\x18\x05 \x01(\tH\x04R\x06mobile\x88\x01\x01\x12\x1d\n" + + "\acaptcha\x18\x06 \x01(\tH\x05R\acaptcha\x88\x01\x01\x12/\n" + + "\x10verificationType\x18\a \x01(\rH\x06R\x10verificationType\x88\x01\x01\x12\x1f\n" + + "\bnickName\x18\t \x01(\tH\aR\bnickName\x88\x01\x01\x123\n" + "\x12registrationSource\x18\n" + - " \x01(\tH\tR\x12registrationSource\x88\x01\x01B\b\n" + + " \x01(\tH\bR\x12registrationSource\x88\x01\x01\x12\x1b\n" + + "\x06gender\x18\v \x01(\tH\tR\x06gender\x88\x01\x01B\b\n" + "\x06_emailB\v\n" + "\t_passwordB\v\n" + "\t_usernameB\a\n" + "\x05_nameB\t\n" + - "\a_mobileB\x13\n" + - "\x11_verificationCodeB\x13\n" + - "\x11_verificationTypeB\x11\n" + - "\x0f_verificationIdB\v\n" + + "\a_mobileB\n" + + "\n" + + "\b_captchaB\x13\n" + + "\x11_verificationTypeB\v\n" + "\t_nickNameB\x15\n" + - "\x13_registrationSource\"\xe8\x01\n" + + "\x13_registrationSourceB\t\n" + + "\a_gender\"\xe8\x01\n" + "\x14RegisterUserResponse\x12!\n" + "\x04user\x18\x01 \x01(\v2\r.app.UserInfoR\x04user\x12-\n" + "\n" + "auth_token\x18\x02 \x01(\v2\x0e.app.AuthTokenR\tauthToken\x12>\n" + "\x1bemail_verification_required\x18\x03 \x01(\bR\x19emailVerificationRequired\x12>\n" + - "\x1bphone_verification_required\x18\x04 \x01(\bR\x19phoneVerificationRequired\"\x87\b\n" + + "\x1bphone_verification_required\x18\x04 \x01(\bR\x19phoneVerificationRequired\"\x19\n" + + "\aUUIDReq\x12\x0e\n" + + "\x02id\x18\x01 \x01(\tR\x02id\"\x1c\n" + + "\bUUIDsReq\x12\x10\n" + + "\x03ids\x18\x01 \x03(\tR\x03ids\"\xbd\b\n" + "\bUserInfo\x12\x13\n" + "\x02id\x18\x01 \x01(\x04H\x00R\x02id\x88\x01\x01\x12\x1f\n" + "\busername\x18\x02 \x01(\tH\x01R\busername\x88\x01\x01\x12\x19\n" + @@ -958,7 +1556,9 @@ const file_app_proto_rawDesc = "" + "\x0erecovery_token\x18\x10 \x01(\tH\x0fR\rrecoveryToken\x88\x01\x01\x127\n" + "\x15recovery_token_expiry\x18\x11 \x01(\x03H\x10R\x13recoveryTokenExpiry\x88\x01\x01\x128\n" + "\bmetadata\x18\x14 \x01(\v2\x17.google.protobuf.StructH\x11R\bmetadata\x88\x01\x01\x124\n" + - "\x13registration_source\x18\x15 \x01(\tH\x12R\x12registrationSource\x88\x01\x01B\x05\n" + + "\x13registration_source\x18\x15 \x01(\tH\x12R\x12registrationSource\x88\x01\x01\x12$\n" + + "\vbirthday_at\x18\x12 \x01(\x03H\x13R\n" + + "birthdayAt\x88\x01\x01B\x05\n" + "\x03_idB\v\n" + "\t_usernameB\b\n" + "\x06_emailB\t\n" + @@ -977,16 +1577,15 @@ const file_app_proto_rawDesc = "" + "\x0f_recovery_tokenB\x18\n" + "\x16_recovery_token_expiryB\v\n" + "\t_metadataB\x16\n" + - "\x14_registration_source\"\x83\x01\n" + + "\x14_registration_sourceB\x0e\n" + + "\f_birthday_at\"\x83\x01\n" + "\rVerifyCodeReq\x12'\n" + "\x04type\x18\x01 \x01(\x0e2\x13.app.VerifyCodeTypeR\x04type\x123\n" + "\faccount_type\x18\x02 \x01(\x0e2\x10.app.AccountTypeR\vaccountType\x12\x14\n" + - "\x05value\x18\x03 \x01(\tR\x05value\"Z\n" + - "\x0eVerifyCodeResp\x12\x17\n" + - "\x04code\x18\x01 \x01(\tH\x00R\x04code\x88\x01\x01\x12\x1b\n" + - "\x06expire\x18\x02 \x01(\rH\x01R\x06expire\x88\x01\x01B\a\n" + - "\x05_codeB\t\n" + - "\a_expire*1\n" + + "\x05value\x18\x03 \x01(\tR\x05value\"J\n" + + "\x0eVerifyCodeResp\x12 \n" + + "\vcaptchaCode\x18\x01 \x01(\tR\vcaptchaCode\x12\x16\n" + + "\x06expire\x18\x02 \x01(\rR\x06expire*1\n" + "\vAccountType\x12\v\n" + "\aUNKNOWN\x10\x00\x12\n" + "\n" + @@ -1003,11 +1602,14 @@ const file_app_proto_rawDesc = "" + "\fUPDATE_PHONE\x10\x05\x12\x10\n" + "\fUPDATE_EMAIL\x10\x06\x12\f\n" + "\bWITHDRAW\x10\a\x12\x17\n" + - "\x13CHANGE_PAY_PASSWORD\x10\b2\xb8\x01\n" + + "\x13CHANGE_PAY_PASSWORD\x10\b2\x9d\x02\n" + "\x03App\x128\n" + "\rGetVerifyCode\x12\x12.app.VerifyCodeReq\x1a\x13.app.VerifyCodeResp\x12C\n" + - "\fregisterUser\x12\x18.app.RegisterUserRequest\x1a\x19.app.RegisterUserResponse\x122\n" + - "\tloginUser\x12\x11.app.LoginRequest\x1a\x12.app.LoginResponseB\aZ\x05./appb\x06proto3" + "\fRegisterUser\x12\x18.app.RegisterUserRequest\x1a\x19.app.RegisterUserResponse\x122\n" + + "\tLoginUser\x12\x11.app.LoginRequest\x1a\x12.app.LoginResponse\x128\n" + + "\tListUsers\x12\x14.app.PageUserRequest\x1a\x15.app.PageUserResponse\x12)\n" + + "\fInitDatabase\x12\n" + + ".app.Empty\x1a\r.app.BaseRespB\aZ\x05./appb\x06proto3" var ( file_app_proto_rawDescOnce sync.Once @@ -1022,42 +1624,59 @@ func file_app_proto_rawDescGZIP() []byte { } var file_app_proto_enumTypes = make([]protoimpl.EnumInfo, 2) -var file_app_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_app_proto_msgTypes = make([]protoimpl.MessageInfo, 20) var file_app_proto_goTypes = []any{ (AccountType)(0), // 0: app.AccountType (VerifyCodeType)(0), // 1: app.VerifyCodeType (*AuthToken)(nil), // 2: app.AuthToken - (*LoginRequest)(nil), // 3: app.LoginRequest - (*LoginResponse)(nil), // 4: app.LoginResponse - (*RegisterUserRequest)(nil), // 5: app.RegisterUserRequest - (*RegisterUserResponse)(nil), // 6: app.RegisterUserResponse - (*UserInfo)(nil), // 7: app.UserInfo - (*VerifyCodeReq)(nil), // 8: app.VerifyCodeReq - (*VerifyCodeResp)(nil), // 9: app.VerifyCodeResp - (*timestamppb.Timestamp)(nil), // 10: google.protobuf.Timestamp - (*structpb.Struct)(nil), // 11: google.protobuf.Struct + (*BaseIDResp)(nil), // 3: app.BaseIDResp + (*BaseMsg)(nil), // 4: app.BaseMsg + (*BaseResp)(nil), // 5: app.BaseResp + (*BaseUUIDResp)(nil), // 6: app.BaseUUIDResp + (*Empty)(nil), // 7: app.Empty + (*IDReq)(nil), // 8: app.IDReq + (*IDsReq)(nil), // 9: app.IDsReq + (*LoginRequest)(nil), // 10: app.LoginRequest + (*LoginResponse)(nil), // 11: app.LoginResponse + (*PageInfoReq)(nil), // 12: app.PageInfoReq + (*PageUserRequest)(nil), // 13: app.PageUserRequest + (*PageUserResponse)(nil), // 14: app.PageUserResponse + (*RegisterUserRequest)(nil), // 15: app.RegisterUserRequest + (*RegisterUserResponse)(nil), // 16: app.RegisterUserResponse + (*UUIDReq)(nil), // 17: app.UUIDReq + (*UUIDsReq)(nil), // 18: app.UUIDsReq + (*UserInfo)(nil), // 19: app.UserInfo + (*VerifyCodeReq)(nil), // 20: app.VerifyCodeReq + (*VerifyCodeResp)(nil), // 21: app.VerifyCodeResp + (*timestamppb.Timestamp)(nil), // 22: google.protobuf.Timestamp + (*structpb.Struct)(nil), // 23: google.protobuf.Struct } var file_app_proto_depIdxs = []int32{ - 10, // 0: app.AuthToken.issued_at:type_name -> google.protobuf.Timestamp - 10, // 1: app.AuthToken.expires_at:type_name -> google.protobuf.Timestamp - 7, // 2: app.LoginResponse.user:type_name -> app.UserInfo + 22, // 0: app.AuthToken.access_token_expires:type_name -> google.protobuf.Timestamp + 22, // 1: app.AuthToken.refresh_token_expires:type_name -> google.protobuf.Timestamp + 19, // 2: app.LoginResponse.user:type_name -> app.UserInfo 2, // 3: app.LoginResponse.auth_token:type_name -> app.AuthToken - 7, // 4: app.RegisterUserResponse.user:type_name -> app.UserInfo - 2, // 5: app.RegisterUserResponse.auth_token:type_name -> app.AuthToken - 11, // 6: app.UserInfo.metadata:type_name -> google.protobuf.Struct - 1, // 7: app.VerifyCodeReq.type:type_name -> app.VerifyCodeType - 0, // 8: app.VerifyCodeReq.account_type:type_name -> app.AccountType - 8, // 9: app.App.GetVerifyCode:input_type -> app.VerifyCodeReq - 5, // 10: app.App.registerUser:input_type -> app.RegisterUserRequest - 3, // 11: app.App.loginUser:input_type -> app.LoginRequest - 9, // 12: app.App.GetVerifyCode:output_type -> app.VerifyCodeResp - 6, // 13: app.App.registerUser:output_type -> app.RegisterUserResponse - 4, // 14: app.App.loginUser:output_type -> app.LoginResponse - 12, // [12:15] is the sub-list for method output_type - 9, // [9:12] is the sub-list for method input_type - 9, // [9:9] is the sub-list for extension type_name - 9, // [9:9] is the sub-list for extension extendee - 0, // [0:9] is the sub-list for field type_name + 19, // 4: app.PageUserResponse.users:type_name -> app.UserInfo + 19, // 5: app.RegisterUserResponse.user:type_name -> app.UserInfo + 2, // 6: app.RegisterUserResponse.auth_token:type_name -> app.AuthToken + 23, // 7: app.UserInfo.metadata:type_name -> google.protobuf.Struct + 1, // 8: app.VerifyCodeReq.type:type_name -> app.VerifyCodeType + 0, // 9: app.VerifyCodeReq.account_type:type_name -> app.AccountType + 20, // 10: app.App.GetVerifyCode:input_type -> app.VerifyCodeReq + 15, // 11: app.App.RegisterUser:input_type -> app.RegisterUserRequest + 10, // 12: app.App.LoginUser:input_type -> app.LoginRequest + 13, // 13: app.App.ListUsers:input_type -> app.PageUserRequest + 7, // 14: app.App.InitDatabase:input_type -> app.Empty + 21, // 15: app.App.GetVerifyCode:output_type -> app.VerifyCodeResp + 16, // 16: app.App.RegisterUser:output_type -> app.RegisterUserResponse + 11, // 17: app.App.LoginUser:output_type -> app.LoginResponse + 14, // 18: app.App.ListUsers:output_type -> app.PageUserResponse + 5, // 19: app.App.InitDatabase:output_type -> app.BaseResp + 15, // [15:20] is the sub-list for method output_type + 10, // [10:15] is the sub-list for method input_type + 10, // [10:10] is the sub-list for extension type_name + 10, // [10:10] is the sub-list for extension extendee + 0, // [0:10] is the sub-list for field type_name } func init() { file_app_proto_init() } @@ -1065,17 +1684,17 @@ func file_app_proto_init() { if File_app_proto != nil { return } - file_app_proto_msgTypes[1].OneofWrappers = []any{} - file_app_proto_msgTypes[3].OneofWrappers = []any{} - file_app_proto_msgTypes[5].OneofWrappers = []any{} - file_app_proto_msgTypes[7].OneofWrappers = []any{} + file_app_proto_msgTypes[8].OneofWrappers = []any{} + file_app_proto_msgTypes[11].OneofWrappers = []any{} + file_app_proto_msgTypes[13].OneofWrappers = []any{} + file_app_proto_msgTypes[17].OneofWrappers = []any{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_app_proto_rawDesc), len(file_app_proto_rawDesc)), NumEnums: 2, - NumMessages: 8, + NumMessages: 20, NumExtensions: 0, NumServices: 1, }, diff --git a/rpc/types/app/app_grpc.pb.go b/rpc/types/app/app_grpc.pb.go index ee436d3..3a5fe10 100644 --- a/rpc/types/app/app_grpc.pb.go +++ b/rpc/types/app/app_grpc.pb.go @@ -20,8 +20,10 @@ const _ = grpc.SupportPackageIsVersion9 const ( App_GetVerifyCode_FullMethodName = "/app.App/GetVerifyCode" - App_RegisterUser_FullMethodName = "/app.App/registerUser" - App_LoginUser_FullMethodName = "/app.App/loginUser" + App_RegisterUser_FullMethodName = "/app.App/RegisterUser" + App_LoginUser_FullMethodName = "/app.App/LoginUser" + App_ListUsers_FullMethodName = "/app.App/ListUsers" + App_InitDatabase_FullMethodName = "/app.App/InitDatabase" ) // AppClient is the client API for App service. @@ -39,6 +41,11 @@ type AppClient interface { // 用户登录 // group: user LoginUser(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) + // 分页查询用户信息 + // group: user + ListUsers(ctx context.Context, in *PageUserRequest, opts ...grpc.CallOption) (*PageUserResponse, error) + // group: base + InitDatabase(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*BaseResp, error) } type appClient struct { @@ -79,6 +86,26 @@ func (c *appClient) LoginUser(ctx context.Context, in *LoginRequest, opts ...grp return out, nil } +func (c *appClient) ListUsers(ctx context.Context, in *PageUserRequest, opts ...grpc.CallOption) (*PageUserResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(PageUserResponse) + err := c.cc.Invoke(ctx, App_ListUsers_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *appClient) InitDatabase(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*BaseResp, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(BaseResp) + err := c.cc.Invoke(ctx, App_InitDatabase_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. @@ -94,6 +121,11 @@ type AppServer interface { // 用户登录 // group: user LoginUser(context.Context, *LoginRequest) (*LoginResponse, error) + // 分页查询用户信息 + // group: user + ListUsers(context.Context, *PageUserRequest) (*PageUserResponse, error) + // group: base + InitDatabase(context.Context, *Empty) (*BaseResp, error) mustEmbedUnimplementedAppServer() } @@ -113,6 +145,12 @@ func (UnimplementedAppServer) RegisterUser(context.Context, *RegisterUserRequest func (UnimplementedAppServer) LoginUser(context.Context, *LoginRequest) (*LoginResponse, error) { return nil, status.Error(codes.Unimplemented, "method LoginUser not implemented") } +func (UnimplementedAppServer) ListUsers(context.Context, *PageUserRequest) (*PageUserResponse, error) { + return nil, status.Error(codes.Unimplemented, "method ListUsers not implemented") +} +func (UnimplementedAppServer) InitDatabase(context.Context, *Empty) (*BaseResp, error) { + return nil, status.Error(codes.Unimplemented, "method InitDatabase not implemented") +} func (UnimplementedAppServer) mustEmbedUnimplementedAppServer() {} func (UnimplementedAppServer) testEmbeddedByValue() {} @@ -188,6 +226,42 @@ func _App_LoginUser_Handler(srv interface{}, ctx context.Context, dec func(inter return interceptor(ctx, in, info, handler) } +func _App_ListUsers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PageUserRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AppServer).ListUsers(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: App_ListUsers_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AppServer).ListUsers(ctx, req.(*PageUserRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _App_InitDatabase_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(Empty) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AppServer).InitDatabase(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: App_InitDatabase_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AppServer).InitDatabase(ctx, req.(*Empty)) + } + 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) @@ -200,13 +274,21 @@ var App_ServiceDesc = grpc.ServiceDesc{ Handler: _App_GetVerifyCode_Handler, }, { - MethodName: "registerUser", + MethodName: "RegisterUser", Handler: _App_RegisterUser_Handler, }, { - MethodName: "loginUser", + MethodName: "LoginUser", Handler: _App_LoginUser_Handler, }, + { + MethodName: "ListUsers", + Handler: _App_ListUsers_Handler, + }, + { + MethodName: "InitDatabase", + Handler: _App_InitDatabase_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "app.proto",