diff --git a/code/base-project/base-go-v3/.gitignore b/code/base-project/base-go-v3/.gitignore new file mode 100644 index 00000000..101ea87c --- /dev/null +++ b/code/base-project/base-go-v3/.gitignore @@ -0,0 +1,37 @@ +*.o +*.a +*.so +_obj +_test +*.[568vq] +[568vq].out +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* +_testmain.go +*.exe +*.exe~ +*.test +*.prof +*.rar +*.zip +*.gz +*.psd +*.bmd +*.cfg +*.pptx +*.log +*nohup.out +*settings.pyc +*.sublime-project +*.sublime-workspace +!.gitkeep +.DS_Store +/.idea +/.vscode +/output +*.local.yml +dumped_hertz_remote_config.json + \ No newline at end of file diff --git a/code/base-project/base-go-v3/.hz b/code/base-project/base-go-v3/.hz new file mode 100644 index 00000000..791041dc --- /dev/null +++ b/code/base-project/base-go-v3/.hz @@ -0,0 +1,6 @@ +// Code generated by hz. DO NOT EDIT. + +hz version: v0.9.7 +handlerDir: "" +modelDir: "" +routerDir: "" diff --git a/code/base-project/base-go-v3/biz/handler/auth/login_service.go b/code/base-project/base-go-v3/biz/handler/auth/login_service.go new file mode 100644 index 00000000..1579c74d --- /dev/null +++ b/code/base-project/base-go-v3/biz/handler/auth/login_service.go @@ -0,0 +1,53 @@ +// Code generated by hertz generator. + +package auth + +import ( + "cn/oneao/base-go/db" + "cn/oneao/base-go/ent/userinfo" + "cn/oneao/base-go/utils/jwtx" + "cn/oneao/base-go/utils/response" + "context" + + auth "cn/oneao/base-go/biz/model/auth" + + "github.com/cloudwego/hertz/pkg/app" + "github.com/cloudwego/hertz/pkg/protocol/consts" +) + +// LoginDefault . +// @router /auth/login/default [POST] +func LoginDefault(ctx context.Context, c *app.RequestContext) { + var err error + var req auth.LoginDefaultReq + err = c.BindAndValidate(&req) + if err != nil { + c.String(consts.StatusBadRequest, err.Error()) + return + } + // 处理登录 + loginUser, err := db.Client.UserInfo. + Query(). + Where(userinfo.AccountEQ(req.Account), + userinfo.PasswordEQ(req.Password)). + Only(ctx) + + if err != nil { + c.String(consts.StatusInternalServerError, "账号或密码错误") + return + } + + token, err := jwtx.CreateAccessToken(loginUser.ID) + refreshToken, err := jwtx.CreateRefreshToken(loginUser.ID) + + resp := new(auth.LoginDefaultResp) + + resp.Token = token + resp.RefreshToken = refreshToken + resp.UserId = loginUser.ID + resp.Gender = loginUser.Gender + resp.SeqNo = loginUser.SeqNo + resp.Username = loginUser.Username + + response.Success(c).Data(resp).Send() +} diff --git a/code/base-project/base-go-v3/biz/handler/hello/hello_service.go b/code/base-project/base-go-v3/biz/handler/hello/hello_service.go new file mode 100644 index 00000000..d6a91719 --- /dev/null +++ b/code/base-project/base-go-v3/biz/handler/hello/hello_service.go @@ -0,0 +1,27 @@ +// Code generated by hertz generator. + +package hello + +import ( + "context" + + hello "cn/oneao/base-go/biz/model/hertz/hello" + "github.com/cloudwego/hertz/pkg/app" + "github.com/cloudwego/hertz/pkg/protocol/consts" +) + +// Method1 . +// @router /hello [GET] +func Method1(ctx context.Context, c *app.RequestContext) { + var err error + var req hello.HelloReq + err = c.BindAndValidate(&req) + if err != nil { + c.String(consts.StatusBadRequest, err.Error()) + return + } + + resp := new(hello.HelloResp) + + c.JSON(consts.StatusOK, resp) +} diff --git a/code/base-project/base-go-v3/biz/handler/ping.go b/code/base-project/base-go-v3/biz/handler/ping.go new file mode 100644 index 00000000..950d4767 --- /dev/null +++ b/code/base-project/base-go-v3/biz/handler/ping.go @@ -0,0 +1,18 @@ +// Code generated by hertz generator. + +package handler + +import ( + "context" + + "github.com/cloudwego/hertz/pkg/app" + "github.com/cloudwego/hertz/pkg/common/utils" + "github.com/cloudwego/hertz/pkg/protocol/consts" +) + +// Ping . +func Ping(ctx context.Context, c *app.RequestContext) { + c.JSON(consts.StatusOK, utils.H{ + "message": "pong", + }) +} diff --git a/code/base-project/base-go-v3/biz/model/api/api.pb.go b/code/base-project/base-go-v3/biz/model/api/api.pb.go new file mode 100644 index 00000000..37434df6 --- /dev/null +++ b/code/base-project/base-go-v3/biz/model/api/api.pb.go @@ -0,0 +1,667 @@ +// idl/api.proto; 注解拓展 + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.0 +// protoc v6.33.1 +// source: api.proto + +package api + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + descriptorpb "google.golang.org/protobuf/types/descriptorpb" + reflect "reflect" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +var file_api_proto_extTypes = []protoimpl.ExtensionInfo{ + { + ExtendedType: (*descriptorpb.FieldOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50101, + Name: "api.raw_body", + Tag: "bytes,50101,opt,name=raw_body", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.FieldOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50102, + Name: "api.query", + Tag: "bytes,50102,opt,name=query", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.FieldOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50103, + Name: "api.header", + Tag: "bytes,50103,opt,name=header", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.FieldOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50104, + Name: "api.cookie", + Tag: "bytes,50104,opt,name=cookie", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.FieldOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50105, + Name: "api.body", + Tag: "bytes,50105,opt,name=body", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.FieldOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50106, + Name: "api.path", + Tag: "bytes,50106,opt,name=path", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.FieldOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50107, + Name: "api.vd", + Tag: "bytes,50107,opt,name=vd", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.FieldOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50108, + Name: "api.form", + Tag: "bytes,50108,opt,name=form", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.FieldOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50109, + Name: "api.js_conv", + Tag: "bytes,50109,opt,name=js_conv", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.FieldOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50110, + Name: "api.file_name", + Tag: "bytes,50110,opt,name=file_name", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.FieldOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50111, + Name: "api.none", + Tag: "bytes,50111,opt,name=none", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.FieldOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50131, + Name: "api.form_compatible", + Tag: "bytes,50131,opt,name=form_compatible", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.FieldOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50132, + Name: "api.js_conv_compatible", + Tag: "bytes,50132,opt,name=js_conv_compatible", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.FieldOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50133, + Name: "api.file_name_compatible", + Tag: "bytes,50133,opt,name=file_name_compatible", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.FieldOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50134, + Name: "api.none_compatible", + Tag: "bytes,50134,opt,name=none_compatible", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.FieldOptions)(nil), + ExtensionType: (*string)(nil), + Field: 51001, + Name: "api.go_tag", + Tag: "bytes,51001,opt,name=go_tag", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.MethodOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50201, + Name: "api.get", + Tag: "bytes,50201,opt,name=get", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.MethodOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50202, + Name: "api.post", + Tag: "bytes,50202,opt,name=post", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.MethodOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50203, + Name: "api.put", + Tag: "bytes,50203,opt,name=put", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.MethodOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50204, + Name: "api.delete", + Tag: "bytes,50204,opt,name=delete", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.MethodOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50205, + Name: "api.patch", + Tag: "bytes,50205,opt,name=patch", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.MethodOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50206, + Name: "api.options", + Tag: "bytes,50206,opt,name=options", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.MethodOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50207, + Name: "api.head", + Tag: "bytes,50207,opt,name=head", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.MethodOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50208, + Name: "api.any", + Tag: "bytes,50208,opt,name=any", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.MethodOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50301, + Name: "api.gen_path", + Tag: "bytes,50301,opt,name=gen_path", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.MethodOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50302, + Name: "api.api_version", + Tag: "bytes,50302,opt,name=api_version", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.MethodOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50303, + Name: "api.tag", + Tag: "bytes,50303,opt,name=tag", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.MethodOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50304, + Name: "api.name", + Tag: "bytes,50304,opt,name=name", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.MethodOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50305, + Name: "api.api_level", + Tag: "bytes,50305,opt,name=api_level", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.MethodOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50306, + Name: "api.serializer", + Tag: "bytes,50306,opt,name=serializer", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.MethodOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50307, + Name: "api.param", + Tag: "bytes,50307,opt,name=param", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.MethodOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50308, + Name: "api.baseurl", + Tag: "bytes,50308,opt,name=baseurl", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.MethodOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50309, + Name: "api.handler_path", + Tag: "bytes,50309,opt,name=handler_path", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.MethodOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50331, + Name: "api.handler_path_compatible", + Tag: "bytes,50331,opt,name=handler_path_compatible", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.EnumValueOptions)(nil), + ExtensionType: (*int32)(nil), + Field: 50401, + Name: "api.http_code", + Tag: "varint,50401,opt,name=http_code", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.ServiceOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50402, + Name: "api.base_domain", + Tag: "bytes,50402,opt,name=base_domain", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.ServiceOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50731, + Name: "api.base_domain_compatible", + Tag: "bytes,50731,opt,name=base_domain_compatible", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.MessageOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50830, + Name: "api.reserve", + Tag: "bytes,50830,opt,name=reserve", + Filename: "api.proto", + }, +} + +// Extension fields to descriptorpb.FieldOptions. +var ( + // optional string raw_body = 50101; + E_RawBody = &file_api_proto_extTypes[0] + // optional string query = 50102; + E_Query = &file_api_proto_extTypes[1] + // optional string header = 50103; + E_Header = &file_api_proto_extTypes[2] + // optional string cookie = 50104; + E_Cookie = &file_api_proto_extTypes[3] + // optional string body = 50105; + E_Body = &file_api_proto_extTypes[4] + // optional string path = 50106; + E_Path = &file_api_proto_extTypes[5] + // optional string vd = 50107; + E_Vd = &file_api_proto_extTypes[6] + // optional string form = 50108; + E_Form = &file_api_proto_extTypes[7] + // optional string js_conv = 50109; + E_JsConv = &file_api_proto_extTypes[8] + // optional string file_name = 50110; + E_FileName = &file_api_proto_extTypes[9] + // optional string none = 50111; + E_None = &file_api_proto_extTypes[10] + // 50131~50160 used to extend field option by hz + // + // optional string form_compatible = 50131; + E_FormCompatible = &file_api_proto_extTypes[11] + // optional string js_conv_compatible = 50132; + E_JsConvCompatible = &file_api_proto_extTypes[12] + // optional string file_name_compatible = 50133; + E_FileNameCompatible = &file_api_proto_extTypes[13] + // optional string none_compatible = 50134; + E_NoneCompatible = &file_api_proto_extTypes[14] + // optional string go_tag = 51001; + E_GoTag = &file_api_proto_extTypes[15] +) + +// Extension fields to descriptorpb.MethodOptions. +var ( + // optional string get = 50201; + E_Get = &file_api_proto_extTypes[16] + // optional string post = 50202; + E_Post = &file_api_proto_extTypes[17] + // optional string put = 50203; + E_Put = &file_api_proto_extTypes[18] + // optional string delete = 50204; + E_Delete = &file_api_proto_extTypes[19] + // optional string patch = 50205; + E_Patch = &file_api_proto_extTypes[20] + // optional string options = 50206; + E_Options = &file_api_proto_extTypes[21] + // optional string head = 50207; + E_Head = &file_api_proto_extTypes[22] + // optional string any = 50208; + E_Any = &file_api_proto_extTypes[23] + // optional string gen_path = 50301; + E_GenPath = &file_api_proto_extTypes[24] // The path specified by the user when the client code is generated, with a higher priority than api_version + // optional string api_version = 50302; + E_ApiVersion = &file_api_proto_extTypes[25] // Specify the value of the :version variable in path when the client code is generated + // optional string tag = 50303; + E_Tag = &file_api_proto_extTypes[26] // rpc tag, can be multiple, separated by commas + // optional string name = 50304; + E_Name = &file_api_proto_extTypes[27] // Name of rpc + // optional string api_level = 50305; + E_ApiLevel = &file_api_proto_extTypes[28] // Interface Level + // optional string serializer = 50306; + E_Serializer = &file_api_proto_extTypes[29] // Serialization method + // optional string param = 50307; + E_Param = &file_api_proto_extTypes[30] // Whether client requests take public parameters + // optional string baseurl = 50308; + E_Baseurl = &file_api_proto_extTypes[31] // Baseurl used in ttnet routing + // optional string handler_path = 50309; + E_HandlerPath = &file_api_proto_extTypes[32] // handler_path specifies the path to generate the method + // 50331~50360 used to extend method option by hz + // + // optional string handler_path_compatible = 50331; + E_HandlerPathCompatible = &file_api_proto_extTypes[33] // handler_path specifies the path to generate the method +) + +// Extension fields to descriptorpb.EnumValueOptions. +var ( + // optional int32 http_code = 50401; + E_HttpCode = &file_api_proto_extTypes[34] +) + +// Extension fields to descriptorpb.ServiceOptions. +var ( + // optional string base_domain = 50402; + E_BaseDomain = &file_api_proto_extTypes[35] + // 50731~50760 used to extend service option by hz + // + // optional string base_domain_compatible = 50731; + E_BaseDomainCompatible = &file_api_proto_extTypes[36] +) + +// Extension fields to descriptorpb.MessageOptions. +var ( + // optional string reserve = 50830; + E_Reserve = &file_api_proto_extTypes[37] +) + +var File_api_proto protoreflect.FileDescriptor + +var file_api_proto_rawDesc = []byte{ + 0x0a, 0x09, 0x61, 0x70, 0x69, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x03, 0x61, 0x70, 0x69, + 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x3a, 0x3a, 0x0a, 0x08, 0x72, 0x61, 0x77, 0x5f, 0x62, 0x6f, 0x64, 0x79, 0x12, 0x1d, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xb5, 0x87, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x72, 0x61, 0x77, 0x42, 0x6f, 0x64, 0x79, 0x3a, 0x35, + 0x0a, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xb6, 0x87, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, + 0x71, 0x75, 0x65, 0x72, 0x79, 0x3a, 0x37, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, + 0x1d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xb7, + 0x87, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x3a, 0x37, + 0x0a, 0x06, 0x63, 0x6f, 0x6f, 0x6b, 0x69, 0x65, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, + 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xb8, 0x87, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x06, 0x63, 0x6f, 0x6f, 0x6b, 0x69, 0x65, 0x3a, 0x33, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x12, + 0x1d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xb9, + 0x87, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x3a, 0x33, 0x0a, 0x04, + 0x70, 0x61, 0x74, 0x68, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x18, 0xba, 0x87, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, + 0x68, 0x3a, 0x2f, 0x0a, 0x02, 0x76, 0x64, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xbb, 0x87, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, + 0x76, 0x64, 0x3a, 0x33, 0x0a, 0x04, 0x66, 0x6f, 0x72, 0x6d, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, + 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xbc, 0x87, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x66, 0x6f, 0x72, 0x6d, 0x3a, 0x38, 0x0a, 0x07, 0x6a, 0x73, 0x5f, 0x63, 0x6f, + 0x6e, 0x76, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x18, 0xbd, 0x87, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6a, 0x73, 0x43, 0x6f, 0x6e, + 0x76, 0x3a, 0x3c, 0x0a, 0x09, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1d, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xbe, 0x87, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x3a, + 0x33, 0x0a, 0x04, 0x6e, 0x6f, 0x6e, 0x65, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xbf, 0x87, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x6e, 0x6f, 0x6e, 0x65, 0x3a, 0x48, 0x0a, 0x0f, 0x66, 0x6f, 0x72, 0x6d, 0x5f, 0x63, 0x6f, 0x6d, + 0x70, 0x61, 0x74, 0x69, 0x62, 0x6c, 0x65, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xd3, 0x87, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, + 0x66, 0x6f, 0x72, 0x6d, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x74, 0x69, 0x62, 0x6c, 0x65, 0x3a, 0x4d, + 0x0a, 0x12, 0x6a, 0x73, 0x5f, 0x63, 0x6f, 0x6e, 0x76, 0x5f, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x74, + 0x69, 0x62, 0x6c, 0x65, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x18, 0xd4, 0x87, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x6a, 0x73, 0x43, + 0x6f, 0x6e, 0x76, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x74, 0x69, 0x62, 0x6c, 0x65, 0x3a, 0x51, 0x0a, + 0x14, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x5f, 0x63, 0x6f, 0x6d, 0x70, 0x61, + 0x74, 0x69, 0x62, 0x6c, 0x65, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xd5, 0x87, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x12, 0x66, 0x69, + 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x74, 0x69, 0x62, 0x6c, 0x65, + 0x3a, 0x48, 0x0a, 0x0f, 0x6e, 0x6f, 0x6e, 0x65, 0x5f, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x74, 0x69, + 0x62, 0x6c, 0x65, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x18, 0xd6, 0x87, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x6e, 0x6f, 0x6e, 0x65, + 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x74, 0x69, 0x62, 0x6c, 0x65, 0x3a, 0x36, 0x0a, 0x06, 0x67, 0x6f, + 0x5f, 0x74, 0x61, 0x67, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x18, 0xb9, 0x8e, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x67, 0x6f, 0x54, + 0x61, 0x67, 0x3a, 0x32, 0x0a, 0x03, 0x67, 0x65, 0x74, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, + 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x99, 0x88, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x03, 0x67, 0x65, 0x74, 0x3a, 0x34, 0x0a, 0x04, 0x70, 0x6f, 0x73, 0x74, 0x12, 0x1e, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x9a, + 0x88, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x6f, 0x73, 0x74, 0x3a, 0x32, 0x0a, 0x03, + 0x70, 0x75, 0x74, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x18, 0x9b, 0x88, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x70, 0x75, 0x74, + 0x3a, 0x38, 0x0a, 0x06, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, + 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x9c, 0x88, 0x03, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x06, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x3a, 0x36, 0x0a, 0x05, 0x70, 0x61, + 0x74, 0x63, 0x68, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x18, 0x9d, 0x88, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x70, 0x61, 0x74, + 0x63, 0x68, 0x3a, 0x3a, 0x0a, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1e, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x9e, 0x88, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3a, 0x34, + 0x0a, 0x04, 0x68, 0x65, 0x61, 0x64, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x9f, 0x88, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x68, 0x65, 0x61, 0x64, 0x3a, 0x32, 0x0a, 0x03, 0x61, 0x6e, 0x79, 0x12, 0x1e, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, + 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xa0, 0x88, 0x03, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x03, 0x61, 0x6e, 0x79, 0x3a, 0x3b, 0x0a, 0x08, 0x67, 0x65, 0x6e, 0x5f, + 0x70, 0x61, 0x74, 0x68, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xfd, 0x88, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x67, 0x65, + 0x6e, 0x50, 0x61, 0x74, 0x68, 0x3a, 0x41, 0x0a, 0x0b, 0x61, 0x70, 0x69, 0x5f, 0x76, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xfe, 0x88, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x61, 0x70, + 0x69, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x3a, 0x32, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x12, + 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, + 0xff, 0x88, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x3a, 0x34, 0x0a, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x80, 0x89, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x3a, 0x3d, 0x0a, 0x09, 0x61, 0x70, 0x69, 0x5f, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, + 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, + 0x81, 0x89, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x61, 0x70, 0x69, 0x4c, 0x65, 0x76, 0x65, + 0x6c, 0x3a, 0x40, 0x0a, 0x0a, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x72, 0x12, + 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, + 0x82, 0x89, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, + 0x7a, 0x65, 0x72, 0x3a, 0x36, 0x0a, 0x05, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x12, 0x1e, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, + 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x83, 0x89, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x3a, 0x3a, 0x0a, 0x07, 0x62, + 0x61, 0x73, 0x65, 0x75, 0x72, 0x6c, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x84, 0x89, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x62, 0x61, 0x73, 0x65, 0x75, 0x72, 0x6c, 0x3a, 0x43, 0x0a, 0x0c, 0x68, 0x61, 0x6e, 0x64, 0x6c, + 0x65, 0x72, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, + 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x85, 0x89, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0b, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x50, 0x61, 0x74, 0x68, 0x3a, 0x58, 0x0a, 0x17, + 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x63, 0x6f, 0x6d, + 0x70, 0x61, 0x74, 0x69, 0x62, 0x6c, 0x65, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, + 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x9b, 0x89, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x15, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x50, 0x61, 0x74, 0x68, 0x43, 0x6f, 0x6d, 0x70, + 0x61, 0x74, 0x69, 0x62, 0x6c, 0x65, 0x3a, 0x40, 0x0a, 0x09, 0x68, 0x74, 0x74, 0x70, 0x5f, 0x63, + 0x6f, 0x64, 0x65, 0x12, 0x21, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6e, 0x75, 0x6d, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x4f, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xe1, 0x89, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, + 0x68, 0x74, 0x74, 0x70, 0x43, 0x6f, 0x64, 0x65, 0x3a, 0x42, 0x0a, 0x0b, 0x62, 0x61, 0x73, 0x65, + 0x5f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x1f, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xe2, 0x89, 0x03, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0a, 0x62, 0x61, 0x73, 0x65, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x3a, 0x57, 0x0a, 0x16, + 0x62, 0x61, 0x73, 0x65, 0x5f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x63, 0x6f, 0x6d, 0x70, + 0x61, 0x74, 0x69, 0x62, 0x6c, 0x65, 0x12, 0x1f, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xab, 0x8c, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x14, 0x62, 0x61, 0x73, 0x65, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x43, 0x6f, 0x6d, 0x70, 0x61, + 0x74, 0x69, 0x62, 0x6c, 0x65, 0x3a, 0x3b, 0x0a, 0x07, 0x72, 0x65, 0x73, 0x65, 0x72, 0x76, 0x65, + 0x12, 0x1f, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x18, 0x8e, 0x8d, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x72, 0x65, 0x73, 0x65, 0x72, + 0x76, 0x65, 0x42, 0x20, 0x5a, 0x1e, 0x63, 0x6e, 0x2f, 0x6f, 0x6e, 0x65, 0x61, 0x6f, 0x2f, 0x62, + 0x61, 0x73, 0x65, 0x2d, 0x67, 0x6f, 0x2f, 0x62, 0x69, 0x7a, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, + 0x2f, 0x61, 0x70, 0x69, +} + +var file_api_proto_goTypes = []interface{}{ + (*descriptorpb.FieldOptions)(nil), // 0: google.protobuf.FieldOptions + (*descriptorpb.MethodOptions)(nil), // 1: google.protobuf.MethodOptions + (*descriptorpb.EnumValueOptions)(nil), // 2: google.protobuf.EnumValueOptions + (*descriptorpb.ServiceOptions)(nil), // 3: google.protobuf.ServiceOptions + (*descriptorpb.MessageOptions)(nil), // 4: google.protobuf.MessageOptions +} +var file_api_proto_depIdxs = []int32{ + 0, // 0: api.raw_body:extendee -> google.protobuf.FieldOptions + 0, // 1: api.query:extendee -> google.protobuf.FieldOptions + 0, // 2: api.header:extendee -> google.protobuf.FieldOptions + 0, // 3: api.cookie:extendee -> google.protobuf.FieldOptions + 0, // 4: api.body:extendee -> google.protobuf.FieldOptions + 0, // 5: api.path:extendee -> google.protobuf.FieldOptions + 0, // 6: api.vd:extendee -> google.protobuf.FieldOptions + 0, // 7: api.form:extendee -> google.protobuf.FieldOptions + 0, // 8: api.js_conv:extendee -> google.protobuf.FieldOptions + 0, // 9: api.file_name:extendee -> google.protobuf.FieldOptions + 0, // 10: api.none:extendee -> google.protobuf.FieldOptions + 0, // 11: api.form_compatible:extendee -> google.protobuf.FieldOptions + 0, // 12: api.js_conv_compatible:extendee -> google.protobuf.FieldOptions + 0, // 13: api.file_name_compatible:extendee -> google.protobuf.FieldOptions + 0, // 14: api.none_compatible:extendee -> google.protobuf.FieldOptions + 0, // 15: api.go_tag:extendee -> google.protobuf.FieldOptions + 1, // 16: api.get:extendee -> google.protobuf.MethodOptions + 1, // 17: api.post:extendee -> google.protobuf.MethodOptions + 1, // 18: api.put:extendee -> google.protobuf.MethodOptions + 1, // 19: api.delete:extendee -> google.protobuf.MethodOptions + 1, // 20: api.patch:extendee -> google.protobuf.MethodOptions + 1, // 21: api.options:extendee -> google.protobuf.MethodOptions + 1, // 22: api.head:extendee -> google.protobuf.MethodOptions + 1, // 23: api.any:extendee -> google.protobuf.MethodOptions + 1, // 24: api.gen_path:extendee -> google.protobuf.MethodOptions + 1, // 25: api.api_version:extendee -> google.protobuf.MethodOptions + 1, // 26: api.tag:extendee -> google.protobuf.MethodOptions + 1, // 27: api.name:extendee -> google.protobuf.MethodOptions + 1, // 28: api.api_level:extendee -> google.protobuf.MethodOptions + 1, // 29: api.serializer:extendee -> google.protobuf.MethodOptions + 1, // 30: api.param:extendee -> google.protobuf.MethodOptions + 1, // 31: api.baseurl:extendee -> google.protobuf.MethodOptions + 1, // 32: api.handler_path:extendee -> google.protobuf.MethodOptions + 1, // 33: api.handler_path_compatible:extendee -> google.protobuf.MethodOptions + 2, // 34: api.http_code:extendee -> google.protobuf.EnumValueOptions + 3, // 35: api.base_domain:extendee -> google.protobuf.ServiceOptions + 3, // 36: api.base_domain_compatible:extendee -> google.protobuf.ServiceOptions + 4, // 37: api.reserve:extendee -> google.protobuf.MessageOptions + 38, // [38:38] is the sub-list for method output_type + 38, // [38:38] is the sub-list for method input_type + 38, // [38:38] is the sub-list for extension type_name + 0, // [0:38] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_api_proto_init() } +func file_api_proto_init() { + if File_api_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_api_proto_rawDesc, + NumEnums: 0, + NumMessages: 0, + NumExtensions: 38, + NumServices: 0, + }, + GoTypes: file_api_proto_goTypes, + DependencyIndexes: file_api_proto_depIdxs, + ExtensionInfos: file_api_proto_extTypes, + }.Build() + File_api_proto = out.File + file_api_proto_rawDesc = nil + file_api_proto_goTypes = nil + file_api_proto_depIdxs = nil +} diff --git a/code/base-project/base-go-v3/biz/model/auth/login.pb.go b/code/base-project/base-go-v3/biz/model/auth/login.pb.go new file mode 100644 index 00000000..1429ca84 --- /dev/null +++ b/code/base-project/base-go-v3/biz/model/auth/login.pb.go @@ -0,0 +1,277 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.0 +// protoc v6.33.1 +// source: login.proto + +package auth + +import ( + _ "cn/oneao/base-go/biz/model/api" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type LoginDefaultReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Account string `protobuf:"bytes,1,opt,name=Account,proto3" form:"account" json:"account" vd:"$!=''"` + Password string `protobuf:"bytes,2,opt,name=Password,proto3" form:"password" json:"password" vd:"$!=''"` +} + +func (x *LoginDefaultReq) Reset() { + *x = LoginDefaultReq{} + if protoimpl.UnsafeEnabled { + mi := &file_login_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LoginDefaultReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LoginDefaultReq) ProtoMessage() {} + +func (x *LoginDefaultReq) ProtoReflect() protoreflect.Message { + mi := &file_login_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LoginDefaultReq.ProtoReflect.Descriptor instead. +func (*LoginDefaultReq) Descriptor() ([]byte, []int) { + return file_login_proto_rawDescGZIP(), []int{0} +} + +func (x *LoginDefaultReq) GetAccount() string { + if x != nil { + return x.Account + } + return "" +} + +func (x *LoginDefaultReq) GetPassword() string { + if x != nil { + return x.Password + } + return "" +} + +type LoginDefaultResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Token string `protobuf:"bytes,1,opt,name=token,proto3" form:"token" json:"token" query:"token"` + RefreshToken string `protobuf:"bytes,2,opt,name=refreshToken,proto3" form:"refreshToken" json:"refreshToken" query:"refreshToken"` + UserId int64 `protobuf:"varint,3,opt,name=userId,proto3" form:"userId" json:"userId" query:"userId"` + Username string `protobuf:"bytes,4,opt,name=username,proto3" form:"username" json:"username" query:"username"` + SeqNo int64 `protobuf:"varint,5,opt,name=seqNo,proto3" form:"seqNo" json:"seqNo" query:"seqNo"` + Gender int64 `protobuf:"varint,6,opt,name=gender,proto3" form:"gender" json:"gender" query:"gender"` +} + +func (x *LoginDefaultResp) Reset() { + *x = LoginDefaultResp{} + if protoimpl.UnsafeEnabled { + mi := &file_login_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LoginDefaultResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LoginDefaultResp) ProtoMessage() {} + +func (x *LoginDefaultResp) ProtoReflect() protoreflect.Message { + mi := &file_login_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LoginDefaultResp.ProtoReflect.Descriptor instead. +func (*LoginDefaultResp) Descriptor() ([]byte, []int) { + return file_login_proto_rawDescGZIP(), []int{1} +} + +func (x *LoginDefaultResp) GetToken() string { + if x != nil { + return x.Token + } + return "" +} + +func (x *LoginDefaultResp) GetRefreshToken() string { + if x != nil { + return x.RefreshToken + } + return "" +} + +func (x *LoginDefaultResp) GetUserId() int64 { + if x != nil { + return x.UserId + } + return 0 +} + +func (x *LoginDefaultResp) GetUsername() string { + if x != nil { + return x.Username + } + return "" +} + +func (x *LoginDefaultResp) GetSeqNo() int64 { + if x != nil { + return x.SeqNo + } + return 0 +} + +func (x *LoginDefaultResp) GetGender() int64 { + if x != nil { + return x.Gender + } + return 0 +} + +var File_login_proto protoreflect.FileDescriptor + +var file_login_proto_rawDesc = []byte{ + 0x0a, 0x0b, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x61, + 0x75, 0x74, 0x68, 0x1a, 0x09, 0x61, 0x70, 0x69, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x74, + 0x0a, 0x0f, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x52, 0x65, + 0x71, 0x12, 0x2e, 0x0a, 0x07, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x42, 0x14, 0xca, 0xbb, 0x18, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0xda, + 0xbb, 0x18, 0x05, 0x24, 0x21, 0x3d, 0x27, 0x27, 0x52, 0x07, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x12, 0x31, 0x0a, 0x08, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x42, 0x15, 0xca, 0xbb, 0x18, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, + 0x64, 0xda, 0xbb, 0x18, 0x05, 0x24, 0x21, 0x3d, 0x27, 0x27, 0x52, 0x08, 0x50, 0x61, 0x73, 0x73, + 0x77, 0x6f, 0x72, 0x64, 0x22, 0xae, 0x01, 0x0a, 0x10, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x44, 0x65, + 0x66, 0x61, 0x75, 0x6c, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, + 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x12, + 0x22, 0x0a, 0x0c, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x54, 0x6f, + 0x6b, 0x65, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x75, + 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, + 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x65, 0x71, 0x4e, 0x6f, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x73, 0x65, 0x71, 0x4e, 0x6f, 0x12, 0x16, 0x0a, + 0x06, 0x67, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x67, + 0x65, 0x6e, 0x64, 0x65, 0x72, 0x32, 0x66, 0x0a, 0x0c, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x53, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x56, 0x0a, 0x0c, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x44, 0x65, + 0x66, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x15, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x4c, 0x6f, 0x67, + 0x69, 0x6e, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x16, 0x2e, 0x61, + 0x75, 0x74, 0x68, 0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, + 0x52, 0x65, 0x73, 0x70, 0x22, 0x17, 0xd2, 0xc1, 0x18, 0x13, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2f, + 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x2f, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x42, 0x21, 0x5a, + 0x1f, 0x63, 0x6e, 0x2f, 0x6f, 0x6e, 0x65, 0x61, 0x6f, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2d, 0x67, + 0x6f, 0x2f, 0x62, 0x69, 0x7a, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2f, 0x61, 0x75, 0x74, 0x68, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_login_proto_rawDescOnce sync.Once + file_login_proto_rawDescData = file_login_proto_rawDesc +) + +func file_login_proto_rawDescGZIP() []byte { + file_login_proto_rawDescOnce.Do(func() { + file_login_proto_rawDescData = protoimpl.X.CompressGZIP(file_login_proto_rawDescData) + }) + return file_login_proto_rawDescData +} + +var file_login_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_login_proto_goTypes = []interface{}{ + (*LoginDefaultReq)(nil), // 0: auth.LoginDefaultReq + (*LoginDefaultResp)(nil), // 1: auth.LoginDefaultResp +} +var file_login_proto_depIdxs = []int32{ + 0, // 0: auth.LoginService.LoginDefault:input_type -> auth.LoginDefaultReq + 1, // 1: auth.LoginService.LoginDefault:output_type -> auth.LoginDefaultResp + 1, // [1:2] is the sub-list for method output_type + 0, // [0:1] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_login_proto_init() } +func file_login_proto_init() { + if File_login_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_login_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LoginDefaultReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_login_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LoginDefaultResp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_login_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_login_proto_goTypes, + DependencyIndexes: file_login_proto_depIdxs, + MessageInfos: file_login_proto_msgTypes, + }.Build() + File_login_proto = out.File + file_login_proto_rawDesc = nil + file_login_proto_goTypes = nil + file_login_proto_depIdxs = nil +} diff --git a/code/base-project/base-go-v3/biz/model/hertz/hello/hello.pb.go b/code/base-project/base-go-v3/biz/model/hertz/hello/hello.pb.go new file mode 100644 index 00000000..a02bf1f1 --- /dev/null +++ b/code/base-project/base-go-v3/biz/model/hertz/hello/hello.pb.go @@ -0,0 +1,216 @@ +// idl/hello/hello.proto + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.0 +// protoc v6.33.1 +// source: hello.proto + +package hello + +import ( + _ "cn/oneao/base-go/biz/model/api" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type HelloReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=Name,proto3" json:"Name" query:"name"` +} + +func (x *HelloReq) Reset() { + *x = HelloReq{} + if protoimpl.UnsafeEnabled { + mi := &file_hello_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *HelloReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HelloReq) ProtoMessage() {} + +func (x *HelloReq) ProtoReflect() protoreflect.Message { + mi := &file_hello_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use HelloReq.ProtoReflect.Descriptor instead. +func (*HelloReq) Descriptor() ([]byte, []int) { + return file_hello_proto_rawDescGZIP(), []int{0} +} + +func (x *HelloReq) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +type HelloResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + RespBody string `protobuf:"bytes,1,opt,name=RespBody,proto3" form:"RespBody" json:"RespBody" query:"RespBody"` +} + +func (x *HelloResp) Reset() { + *x = HelloResp{} + if protoimpl.UnsafeEnabled { + mi := &file_hello_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *HelloResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HelloResp) ProtoMessage() {} + +func (x *HelloResp) ProtoReflect() protoreflect.Message { + mi := &file_hello_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use HelloResp.ProtoReflect.Descriptor instead. +func (*HelloResp) Descriptor() ([]byte, []int) { + return file_hello_proto_rawDescGZIP(), []int{1} +} + +func (x *HelloResp) GetRespBody() string { + if x != nil { + return x.RespBody + } + return "" +} + +var File_hello_proto protoreflect.FileDescriptor + +var file_hello_proto_rawDesc = []byte{ + 0x0a, 0x0b, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x68, + 0x65, 0x6c, 0x6c, 0x6f, 0x1a, 0x09, 0x61, 0x70, 0x69, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, + 0x28, 0x0a, 0x08, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x12, 0x1c, 0x0a, 0x04, 0x4e, + 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x08, 0xb2, 0xbb, 0x18, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x52, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x27, 0x0a, 0x09, 0x48, 0x65, 0x6c, + 0x6c, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1a, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x42, 0x6f, + 0x64, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x52, 0x65, 0x73, 0x70, 0x42, 0x6f, + 0x64, 0x79, 0x32, 0x48, 0x0a, 0x0c, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x53, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x12, 0x38, 0x0a, 0x07, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x31, 0x12, 0x0f, 0x2e, + 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x1a, 0x10, + 0x2e, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x73, 0x70, + 0x22, 0x0a, 0xca, 0xc1, 0x18, 0x06, 0x2f, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x42, 0x28, 0x5a, 0x26, + 0x63, 0x6e, 0x2f, 0x6f, 0x6e, 0x65, 0x61, 0x6f, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2d, 0x67, 0x6f, + 0x2f, 0x62, 0x69, 0x7a, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2f, 0x68, 0x65, 0x72, 0x74, 0x7a, + 0x2f, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_hello_proto_rawDescOnce sync.Once + file_hello_proto_rawDescData = file_hello_proto_rawDesc +) + +func file_hello_proto_rawDescGZIP() []byte { + file_hello_proto_rawDescOnce.Do(func() { + file_hello_proto_rawDescData = protoimpl.X.CompressGZIP(file_hello_proto_rawDescData) + }) + return file_hello_proto_rawDescData +} + +var file_hello_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_hello_proto_goTypes = []interface{}{ + (*HelloReq)(nil), // 0: hello.HelloReq + (*HelloResp)(nil), // 1: hello.HelloResp +} +var file_hello_proto_depIdxs = []int32{ + 0, // 0: hello.HelloService.Method1:input_type -> hello.HelloReq + 1, // 1: hello.HelloService.Method1:output_type -> hello.HelloResp + 1, // [1:2] is the sub-list for method output_type + 0, // [0:1] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_hello_proto_init() } +func file_hello_proto_init() { + if File_hello_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_hello_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*HelloReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_hello_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*HelloResp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_hello_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_hello_proto_goTypes, + DependencyIndexes: file_hello_proto_depIdxs, + MessageInfos: file_hello_proto_msgTypes, + }.Build() + File_hello_proto = out.File + file_hello_proto_rawDesc = nil + file_hello_proto_goTypes = nil + file_hello_proto_depIdxs = nil +} diff --git a/code/base-project/base-go-v3/biz/router/auth/login.go b/code/base-project/base-go-v3/biz/router/auth/login.go new file mode 100644 index 00000000..ed820d4e --- /dev/null +++ b/code/base-project/base-go-v3/biz/router/auth/login.go @@ -0,0 +1,27 @@ +// Code generated by hertz generator. DO NOT EDIT. + +package auth + +import ( + auth "cn/oneao/base-go/biz/handler/auth" + "github.com/cloudwego/hertz/pkg/app/server" +) + +/* + This file will register all the routes of the services in the master idl. + And it will update automatically when you use the "update" command for the idl. + So don't modify the contents of the file, or your code will be deleted when it is updated. +*/ + +// Register register routes based on the IDL 'api.${HTTP Method}' annotation. +func Register(r *server.Hertz) { + + root := r.Group("/", rootMw()...) + { + _auth := root.Group("/auth", _authMw()...) + { + _login := _auth.Group("/login", _loginMw()...) + _login.POST("/default", append(_logindefaultMw(), auth.LoginDefault)...) + } + } +} diff --git a/code/base-project/base-go-v3/biz/router/auth/middleware.go b/code/base-project/base-go-v3/biz/router/auth/middleware.go new file mode 100644 index 00000000..9b0280a6 --- /dev/null +++ b/code/base-project/base-go-v3/biz/router/auth/middleware.go @@ -0,0 +1,27 @@ +// Code generated by hertz generator. + +package auth + +import ( + "github.com/cloudwego/hertz/pkg/app" +) + +func rootMw() []app.HandlerFunc { + // your code... + return nil +} + +func _authMw() []app.HandlerFunc { + // your code... + return nil +} + +func _loginMw() []app.HandlerFunc { + // your code... + return nil +} + +func _logindefaultMw() []app.HandlerFunc { + // your code... + return nil +} diff --git a/code/base-project/base-go-v3/biz/router/hello/hello.go b/code/base-project/base-go-v3/biz/router/hello/hello.go new file mode 100644 index 00000000..56a3056e --- /dev/null +++ b/code/base-project/base-go-v3/biz/router/hello/hello.go @@ -0,0 +1,21 @@ +// Code generated by hertz generator. DO NOT EDIT. + +package hello + +import ( + hello "cn/oneao/base-go/biz/handler/hello" + "github.com/cloudwego/hertz/pkg/app/server" +) + +/* + This file will register all the routes of the services in the master idl. + And it will update automatically when you use the "update" command for the idl. + So don't modify the contents of the file, or your code will be deleted when it is updated. +*/ + +// Register register routes based on the IDL 'api.${HTTP Method}' annotation. +func Register(r *server.Hertz) { + + root := r.Group("/", rootMw()...) + root.GET("/hello", append(_method1Mw(), hello.Method1)...) +} diff --git a/code/base-project/base-go-v3/biz/router/hello/middleware.go b/code/base-project/base-go-v3/biz/router/hello/middleware.go new file mode 100644 index 00000000..b0bd4359 --- /dev/null +++ b/code/base-project/base-go-v3/biz/router/hello/middleware.go @@ -0,0 +1,17 @@ +// Code generated by hertz generator. + +package hello + +import ( + "github.com/cloudwego/hertz/pkg/app" +) + +func rootMw() []app.HandlerFunc { + // your code... + return nil +} + +func _method1Mw() []app.HandlerFunc { + // your code... + return nil +} diff --git a/code/base-project/base-go-v3/biz/router/middleware/error.go b/code/base-project/base-go-v3/biz/router/middleware/error.go new file mode 100644 index 00000000..6b05f9cd --- /dev/null +++ b/code/base-project/base-go-v3/biz/router/middleware/error.go @@ -0,0 +1,19 @@ +package middleware + +import ( + "context" + + "github.com/cloudwego/hertz/pkg/app" +) + +// Error 中间件 +func Error() app.HandlerFunc { + return func(ctx context.Context, c *app.RequestContext) { + c.Next(ctx) + + if err := c.Errors.Last(); err != nil { + // 未知错误 -> 500 + c.JSON(500, ErrorResponse{500, "Internal Server Error"}) + } + } +} diff --git a/code/base-project/base-go-v3/biz/router/middleware/jwt.go b/code/base-project/base-go-v3/biz/router/middleware/jwt.go new file mode 100644 index 00000000..7bbaced0 --- /dev/null +++ b/code/base-project/base-go-v3/biz/router/middleware/jwt.go @@ -0,0 +1,100 @@ +package middleware + +import ( + "context" + "log" + "net/http" + "time" + + "github.com/cloudwego/hertz/pkg/app" + "github.com/hertz-contrib/jwt" +) + +var identityKey = "UserId" + +type loginForm struct { + Account string `form:"username,required" json:"username,required"` + Password string `form:"password,required" json:"password,required"` + Type int `form:"type,required" json:"type,required"` +} + +type User struct { + UserId int64 +} + +var hertzJWTMiddleware *jwt.HertzJWTMiddleware + +func init() { + middleware, err := jwt.New(&jwt.HertzJWTMiddleware{ + Realm: "test zone", + Key: []byte("secret key"), + Timeout: 30 * time.Minute, + MaxRefresh: 30 * 24 * time.Hour, + IdentityKey: identityKey, + // Token负载信息 + PayloadFunc: func(data interface{}) jwt.MapClaims { + if v, ok := data.(*User); ok { + return jwt.MapClaims{ + identityKey: v.UserId, + } + } + return jwt.MapClaims{} + }, + // 解析Token取出用户信息 + IdentityHandler: func(ctx context.Context, c *app.RequestContext) interface{} { + claims := jwt.ExtractClaims(ctx, c) + return &User{ + UserId: claims[identityKey].(int64), + } + }, + // 登录 + Authenticator: func(ctx context.Context, c *app.RequestContext) (interface{}, error) { + c.Request.RequestURI() + return nil, jwt.ErrFailedAuthentication + }, + // 权限控制 + Authorizator: func(data interface{}, ctx context.Context, c *app.RequestContext) bool { + return true + }, + // 未验证处理 + Unauthorized: func(ctx context.Context, c *app.RequestContext, code int, message string) { + c.JSON(code, map[string]interface{}{ + "code": code, + "message": message, + }) + }, + // 登录响应 + LoginResponse: func(ctx context.Context, c *app.RequestContext, code int, token string, expire time.Time) { + c.JSON(http.StatusOK, map[string]interface{}{ + "code": http.StatusOK, + "token": token, + "expire": expire.Format(time.RFC3339), + }) + }, + // 登出响应 + LogoutResponse: func(ctx context.Context, c *app.RequestContext, code int) { + c.JSON(http.StatusOK, map[string]interface{}{ + "code": http.StatusOK, + }) + }, + // 刷新Token + RefreshResponse: func(ctx context.Context, c *app.RequestContext, code int, token string, expire time.Time) { + c.JSON(http.StatusOK, map[string]interface{}{ + "code": http.StatusOK, + "token": token, + "expire": expire.Format(time.RFC3339), + }) + }, + TokenLookup: "header: Authorization", + }) + + if err != nil { + log.Fatal("JWT Error:" + err.Error()) + } + + hertzJWTMiddleware = middleware +} + +func JWT() *jwt.HertzJWTMiddleware { + return hertzJWTMiddleware +} diff --git a/code/base-project/base-go-v3/biz/router/register.go b/code/base-project/base-go-v3/biz/router/register.go new file mode 100644 index 00000000..78b63983 --- /dev/null +++ b/code/base-project/base-go-v3/biz/router/register.go @@ -0,0 +1,17 @@ +// Code generated by hertz generator. DO NOT EDIT. + +package router + +import ( + auth "cn/oneao/base-go/biz/router/auth" + hello "cn/oneao/base-go/biz/router/hello" + "github.com/cloudwego/hertz/pkg/app/server" +) + +// GeneratedRegister registers routers generated by IDL. +func GeneratedRegister(r *server.Hertz) { + //INSERT_POINT: DO NOT DELETE THIS LINE! + hello.Register(r) + + auth.Register(r) +} diff --git a/code/base-project/base-go-v3/config/app.go b/code/base-project/base-go-v3/config/app.go new file mode 100644 index 00000000..d6b6f3e2 --- /dev/null +++ b/code/base-project/base-go-v3/config/app.go @@ -0,0 +1,43 @@ +package config + +import ( + "time" +) + +type appConfig struct { + Server serverConfig + JWT jwtConfig + Snowflake snowflakeConfig +} + +type serverConfig struct { + Port string + BaseUrl string +} + +type jwtConfig struct { + Secret string + AccessExpiry time.Duration + RefreshExpiry time.Duration +} + +type snowflakeConfig struct { + DatacenterID uint16 + WorkerID uint16 +} + +var App = &appConfig{ + Server: serverConfig{ + Port: ":8086", + BaseUrl: "/app", + }, + JWT: jwtConfig{ + Secret: "3Bde3BGEbYqtqyEUzW3ry8jKFcaPH17fRmTmqE7MDr05Lwj95uruRKrrkb44TJ4s", + AccessExpiry: 30 * time.Minute, + RefreshExpiry: 30 * 24 * time.Hour, + }, + Snowflake: snowflakeConfig{ + DatacenterID: 1, + WorkerID: 1, + }, +} diff --git a/code/base-project/base-go-v3/config/database.go b/code/base-project/base-go-v3/config/database.go new file mode 100644 index 00000000..894f06bf --- /dev/null +++ b/code/base-project/base-go-v3/config/database.go @@ -0,0 +1,32 @@ +package config + +import ( + "time" +) + +type dbConfig struct { + Host string + Port int + User string + Password string + Dbname string + SllMode bool + TimeZone string + MaxOpenConns int + MaxIdleConns int + ConnMaxLifetime time.Duration +} + +// Db 默认值 +var Db = &dbConfig{ + Host: "117.72.182.135", + Port: 5432, + User: "postgres", + Password: "zhang520..", + Dbname: "base", + SllMode: false, + TimeZone: "Asia/Shanghai", + MaxOpenConns: 10, + MaxIdleConns: 5, + ConnMaxLifetime: 30 * time.Minute, +} diff --git a/code/base-project/base-go-v3/db/db.go b/code/base-project/base-go-v3/db/db.go new file mode 100644 index 00000000..a458f812 --- /dev/null +++ b/code/base-project/base-go-v3/db/db.go @@ -0,0 +1,56 @@ +package db + +import ( + "cn/oneao/base-go/config" + "cn/oneao/base-go/ent" + "database/sql" + "fmt" + "log" + + "entgo.io/ent/dialect" + entsql "entgo.io/ent/dialect/sql" + _ "github.com/lib/pq" +) + +var Client *ent.Client + +// InitDB 初始化 PostgreSQL 数据库连接(使用 sql.DB 配置连接池) +func InitDB() { + // 处理 SSLMode + sslmode := "disable" + if config.Db.SllMode { + sslmode = "require" + } + + // 构建 PostgreSQL DSN + dsn := fmt.Sprintf( + "user=%s password=%s dbname=%s host=%s port=%d sslmode=%s TimeZone=%s", + config.Db.User, + config.Db.Password, + config.Db.Dbname, + config.Db.Host, + config.Db.Port, + sslmode, + config.Db.TimeZone, + ) + + // 使用 sql.Open 创建原生 *sql.DB 对象 + db, err := sql.Open("postgres", dsn) + if err != nil { + log.Fatalf("❌ 数据库连接失败: %v", err) + } + + // 配置连接池 + db.SetMaxOpenConns(config.Db.MaxOpenConns) + db.SetMaxIdleConns(config.Db.MaxIdleConns) + db.SetConnMaxLifetime(config.Db.ConnMaxLifetime) + + // 使用 sql.DB 创建 ent.Driver + drv := entsql.OpenDB(dialect.Postgres, db) + + // 创建 ent.Client + client := ent.NewClient(ent.Driver(drv)) + + Client = client + log.Println("✅ 数据库连接完成") +} diff --git a/code/base-project/base-go-v3/ent/client.go b/code/base-project/base-go-v3/ent/client.go new file mode 100644 index 00000000..efe85eba --- /dev/null +++ b/code/base-project/base-go-v3/ent/client.go @@ -0,0 +1,341 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "log" + "reflect" + + "cn/oneao/base-go/ent/migrate" + + "cn/oneao/base-go/ent/userinfo" + + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" +) + +// Client is the client that holds all ent builders. +type Client struct { + config + // Schema is the client for creating, migrating and dropping schema. + Schema *migrate.Schema + // UserInfo is the client for interacting with the UserInfo builders. + UserInfo *UserInfoClient +} + +// NewClient creates a new client configured with the given options. +func NewClient(opts ...Option) *Client { + client := &Client{config: newConfig(opts...)} + client.init() + return client +} + +func (c *Client) init() { + c.Schema = migrate.NewSchema(c.driver) + c.UserInfo = NewUserInfoClient(c.config) +} + +type ( + // config is the configuration for the client and its builder. + config struct { + // driver used for executing database requests. + driver dialect.Driver + // debug enable a debug logging. + debug bool + // log used for logging on debug mode. + log func(...any) + // hooks to execute on mutations. + hooks *hooks + // interceptors to execute on queries. + inters *inters + } + // Option function to configure the client. + Option func(*config) +) + +// newConfig creates a new config for the client. +func newConfig(opts ...Option) config { + cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} + cfg.options(opts...) + return cfg +} + +// options applies the options on the config object. +func (c *config) options(opts ...Option) { + for _, opt := range opts { + opt(c) + } + if c.debug { + c.driver = dialect.Debug(c.driver, c.log) + } +} + +// Debug enables debug logging on the ent.Driver. +func Debug() Option { + return func(c *config) { + c.debug = true + } +} + +// Log sets the logging function for debug mode. +func Log(fn func(...any)) Option { + return func(c *config) { + c.log = fn + } +} + +// Driver configures the client driver. +func Driver(driver dialect.Driver) Option { + return func(c *config) { + c.driver = driver + } +} + +// Open opens a database/sql.DB specified by the driver name and +// the data source name, and returns a new client attached to it. +// Optional parameters can be added for configuring the client. +func Open(driverName, dataSourceName string, options ...Option) (*Client, error) { + switch driverName { + case dialect.MySQL, dialect.Postgres, dialect.SQLite: + drv, err := sql.Open(driverName, dataSourceName) + if err != nil { + return nil, err + } + return NewClient(append(options, Driver(drv))...), nil + default: + return nil, fmt.Errorf("unsupported driver: %q", driverName) + } +} + +// ErrTxStarted is returned when trying to start a new transaction from a transactional client. +var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction") + +// Tx returns a new transactional client. The provided context +// is used until the transaction is committed or rolled back. +func (c *Client) Tx(ctx context.Context) (*Tx, error) { + if _, ok := c.driver.(*txDriver); ok { + return nil, ErrTxStarted + } + tx, err := newTx(ctx, c.driver) + if err != nil { + return nil, fmt.Errorf("ent: starting a transaction: %w", err) + } + cfg := c.config + cfg.driver = tx + return &Tx{ + ctx: ctx, + config: cfg, + UserInfo: NewUserInfoClient(cfg), + }, nil +} + +// BeginTx returns a transactional client with specified options. +func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) { + if _, ok := c.driver.(*txDriver); ok { + return nil, errors.New("ent: cannot start a transaction within a transaction") + } + tx, err := c.driver.(interface { + BeginTx(context.Context, *sql.TxOptions) (dialect.Tx, error) + }).BeginTx(ctx, opts) + if err != nil { + return nil, fmt.Errorf("ent: starting a transaction: %w", err) + } + cfg := c.config + cfg.driver = &txDriver{tx: tx, drv: c.driver} + return &Tx{ + ctx: ctx, + config: cfg, + UserInfo: NewUserInfoClient(cfg), + }, nil +} + +// Debug returns a new debug-client. It's used to get verbose logging on specific operations. +// +// client.Debug(). +// UserInfo. +// Query(). +// Count(ctx) +func (c *Client) Debug() *Client { + if c.debug { + return c + } + cfg := c.config + cfg.driver = dialect.Debug(c.driver, c.log) + client := &Client{config: cfg} + client.init() + return client +} + +// Close closes the database connection and prevents new queries from starting. +func (c *Client) Close() error { + return c.driver.Close() +} + +// Use adds the mutation hooks to all the entity clients. +// In order to add hooks to a specific client, call: `client.Node.Use(...)`. +func (c *Client) Use(hooks ...Hook) { + c.UserInfo.Use(hooks...) +} + +// Intercept adds the query interceptors to all the entity clients. +// In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`. +func (c *Client) Intercept(interceptors ...Interceptor) { + c.UserInfo.Intercept(interceptors...) +} + +// Mutate implements the ent.Mutator interface. +func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { + switch m := m.(type) { + case *UserInfoMutation: + return c.UserInfo.mutate(ctx, m) + default: + return nil, fmt.Errorf("ent: unknown mutation type %T", m) + } +} + +// UserInfoClient is a client for the UserInfo schema. +type UserInfoClient struct { + config +} + +// NewUserInfoClient returns a client for the UserInfo from the given config. +func NewUserInfoClient(c config) *UserInfoClient { + return &UserInfoClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `userinfo.Hooks(f(g(h())))`. +func (c *UserInfoClient) Use(hooks ...Hook) { + c.hooks.UserInfo = append(c.hooks.UserInfo, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `userinfo.Intercept(f(g(h())))`. +func (c *UserInfoClient) Intercept(interceptors ...Interceptor) { + c.inters.UserInfo = append(c.inters.UserInfo, interceptors...) +} + +// Create returns a builder for creating a UserInfo entity. +func (c *UserInfoClient) Create() *UserInfoCreate { + mutation := newUserInfoMutation(c.config, OpCreate) + return &UserInfoCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of UserInfo entities. +func (c *UserInfoClient) CreateBulk(builders ...*UserInfoCreate) *UserInfoCreateBulk { + return &UserInfoCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *UserInfoClient) MapCreateBulk(slice any, setFunc func(*UserInfoCreate, int)) *UserInfoCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &UserInfoCreateBulk{err: fmt.Errorf("calling to UserInfoClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*UserInfoCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &UserInfoCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for UserInfo. +func (c *UserInfoClient) Update() *UserInfoUpdate { + mutation := newUserInfoMutation(c.config, OpUpdate) + return &UserInfoUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *UserInfoClient) UpdateOne(_m *UserInfo) *UserInfoUpdateOne { + mutation := newUserInfoMutation(c.config, OpUpdateOne, withUserInfo(_m)) + return &UserInfoUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *UserInfoClient) UpdateOneID(id int64) *UserInfoUpdateOne { + mutation := newUserInfoMutation(c.config, OpUpdateOne, withUserInfoID(id)) + return &UserInfoUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for UserInfo. +func (c *UserInfoClient) Delete() *UserInfoDelete { + mutation := newUserInfoMutation(c.config, OpDelete) + return &UserInfoDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *UserInfoClient) DeleteOne(_m *UserInfo) *UserInfoDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *UserInfoClient) DeleteOneID(id int64) *UserInfoDeleteOne { + builder := c.Delete().Where(userinfo.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &UserInfoDeleteOne{builder} +} + +// Query returns a query builder for UserInfo. +func (c *UserInfoClient) Query() *UserInfoQuery { + return &UserInfoQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeUserInfo}, + inters: c.Interceptors(), + } +} + +// Get returns a UserInfo entity by its id. +func (c *UserInfoClient) Get(ctx context.Context, id int64) (*UserInfo, error) { + return c.Query().Where(userinfo.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *UserInfoClient) GetX(ctx context.Context, id int64) *UserInfo { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *UserInfoClient) Hooks() []Hook { + return c.hooks.UserInfo +} + +// Interceptors returns the client interceptors. +func (c *UserInfoClient) Interceptors() []Interceptor { + return c.inters.UserInfo +} + +func (c *UserInfoClient) mutate(ctx context.Context, m *UserInfoMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&UserInfoCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&UserInfoUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&UserInfoUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&UserInfoDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown UserInfo mutation op: %q", m.Op()) + } +} + +// hooks and interceptors per client, for fast access. +type ( + hooks struct { + UserInfo []ent.Hook + } + inters struct { + UserInfo []ent.Interceptor + } +) diff --git a/code/base-project/base-go-v3/ent/ent.go b/code/base-project/base-go-v3/ent/ent.go new file mode 100644 index 00000000..2ebe1ece --- /dev/null +++ b/code/base-project/base-go-v3/ent/ent.go @@ -0,0 +1,608 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "cn/oneao/base-go/ent/userinfo" + "context" + "errors" + "fmt" + "reflect" + "sync" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ent aliases to avoid import conflicts in user's code. +type ( + Op = ent.Op + Hook = ent.Hook + Value = ent.Value + Query = ent.Query + QueryContext = ent.QueryContext + Querier = ent.Querier + QuerierFunc = ent.QuerierFunc + Interceptor = ent.Interceptor + InterceptFunc = ent.InterceptFunc + Traverser = ent.Traverser + TraverseFunc = ent.TraverseFunc + Policy = ent.Policy + Mutator = ent.Mutator + Mutation = ent.Mutation + MutateFunc = ent.MutateFunc +) + +type clientCtxKey struct{} + +// FromContext returns a Client stored inside a context, or nil if there isn't one. +func FromContext(ctx context.Context) *Client { + c, _ := ctx.Value(clientCtxKey{}).(*Client) + return c +} + +// NewContext returns a new context with the given Client attached. +func NewContext(parent context.Context, c *Client) context.Context { + return context.WithValue(parent, clientCtxKey{}, c) +} + +type txCtxKey struct{} + +// TxFromContext returns a Tx stored inside a context, or nil if there isn't one. +func TxFromContext(ctx context.Context) *Tx { + tx, _ := ctx.Value(txCtxKey{}).(*Tx) + return tx +} + +// NewTxContext returns a new context with the given Tx attached. +func NewTxContext(parent context.Context, tx *Tx) context.Context { + return context.WithValue(parent, txCtxKey{}, tx) +} + +// OrderFunc applies an ordering on the sql selector. +// Deprecated: Use Asc/Desc functions or the package builders instead. +type OrderFunc func(*sql.Selector) + +var ( + initCheck sync.Once + columnCheck sql.ColumnCheck +) + +// checkColumn checks if the column exists in the given table. +func checkColumn(t, c string) error { + initCheck.Do(func() { + columnCheck = sql.NewColumnCheck(map[string]func(string) bool{ + userinfo.Table: userinfo.ValidColumn, + }) + }) + return columnCheck(t, c) +} + +// Asc applies the given fields in ASC order. +func Asc(fields ...string) func(*sql.Selector) { + return func(s *sql.Selector) { + for _, f := range fields { + if err := checkColumn(s.TableName(), f); err != nil { + s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)}) + } + s.OrderBy(sql.Asc(s.C(f))) + } + } +} + +// Desc applies the given fields in DESC order. +func Desc(fields ...string) func(*sql.Selector) { + return func(s *sql.Selector) { + for _, f := range fields { + if err := checkColumn(s.TableName(), f); err != nil { + s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)}) + } + s.OrderBy(sql.Desc(s.C(f))) + } + } +} + +// AggregateFunc applies an aggregation step on the group-by traversal/selector. +type AggregateFunc func(*sql.Selector) string + +// As is a pseudo aggregation function for renaming another other functions with custom names. For example: +// +// GroupBy(field1, field2). +// Aggregate(ent.As(ent.Sum(field1), "sum_field1"), (ent.As(ent.Sum(field2), "sum_field2")). +// Scan(ctx, &v) +func As(fn AggregateFunc, end string) AggregateFunc { + return func(s *sql.Selector) string { + return sql.As(fn(s), end) + } +} + +// Count applies the "count" aggregation function on each group. +func Count() AggregateFunc { + return func(s *sql.Selector) string { + return sql.Count("*") + } +} + +// Max applies the "max" aggregation function on the given field of each group. +func Max(field string) AggregateFunc { + return func(s *sql.Selector) string { + if err := checkColumn(s.TableName(), field); err != nil { + s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) + return "" + } + return sql.Max(s.C(field)) + } +} + +// Mean applies the "mean" aggregation function on the given field of each group. +func Mean(field string) AggregateFunc { + return func(s *sql.Selector) string { + if err := checkColumn(s.TableName(), field); err != nil { + s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) + return "" + } + return sql.Avg(s.C(field)) + } +} + +// Min applies the "min" aggregation function on the given field of each group. +func Min(field string) AggregateFunc { + return func(s *sql.Selector) string { + if err := checkColumn(s.TableName(), field); err != nil { + s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) + return "" + } + return sql.Min(s.C(field)) + } +} + +// Sum applies the "sum" aggregation function on the given field of each group. +func Sum(field string) AggregateFunc { + return func(s *sql.Selector) string { + if err := checkColumn(s.TableName(), field); err != nil { + s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) + return "" + } + return sql.Sum(s.C(field)) + } +} + +// ValidationError returns when validating a field or edge fails. +type ValidationError struct { + Name string // Field or edge name. + err error +} + +// Error implements the error interface. +func (e *ValidationError) Error() string { + return e.err.Error() +} + +// Unwrap implements the errors.Wrapper interface. +func (e *ValidationError) Unwrap() error { + return e.err +} + +// IsValidationError returns a boolean indicating whether the error is a validation error. +func IsValidationError(err error) bool { + if err == nil { + return false + } + var e *ValidationError + return errors.As(err, &e) +} + +// NotFoundError returns when trying to fetch a specific entity and it was not found in the database. +type NotFoundError struct { + label string +} + +// Error implements the error interface. +func (e *NotFoundError) Error() string { + return "ent: " + e.label + " not found" +} + +// IsNotFound returns a boolean indicating whether the error is a not found error. +func IsNotFound(err error) bool { + if err == nil { + return false + } + var e *NotFoundError + return errors.As(err, &e) +} + +// MaskNotFound masks not found error. +func MaskNotFound(err error) error { + if IsNotFound(err) { + return nil + } + return err +} + +// NotSingularError returns when trying to fetch a singular entity and more then one was found in the database. +type NotSingularError struct { + label string +} + +// Error implements the error interface. +func (e *NotSingularError) Error() string { + return "ent: " + e.label + " not singular" +} + +// IsNotSingular returns a boolean indicating whether the error is a not singular error. +func IsNotSingular(err error) bool { + if err == nil { + return false + } + var e *NotSingularError + return errors.As(err, &e) +} + +// NotLoadedError returns when trying to get a node that was not loaded by the query. +type NotLoadedError struct { + edge string +} + +// Error implements the error interface. +func (e *NotLoadedError) Error() string { + return "ent: " + e.edge + " edge was not loaded" +} + +// IsNotLoaded returns a boolean indicating whether the error is a not loaded error. +func IsNotLoaded(err error) bool { + if err == nil { + return false + } + var e *NotLoadedError + return errors.As(err, &e) +} + +// ConstraintError returns when trying to create/update one or more entities and +// one or more of their constraints failed. For example, violation of edge or +// field uniqueness. +type ConstraintError struct { + msg string + wrap error +} + +// Error implements the error interface. +func (e ConstraintError) Error() string { + return "ent: constraint failed: " + e.msg +} + +// Unwrap implements the errors.Wrapper interface. +func (e *ConstraintError) Unwrap() error { + return e.wrap +} + +// IsConstraintError returns a boolean indicating whether the error is a constraint failure. +func IsConstraintError(err error) bool { + if err == nil { + return false + } + var e *ConstraintError + return errors.As(err, &e) +} + +// selector embedded by the different Select/GroupBy builders. +type selector struct { + label string + flds *[]string + fns []AggregateFunc + scan func(context.Context, any) error +} + +// ScanX is like Scan, but panics if an error occurs. +func (s *selector) ScanX(ctx context.Context, v any) { + if err := s.scan(ctx, v); err != nil { + panic(err) + } +} + +// Strings returns list of strings from a selector. It is only allowed when selecting one field. +func (s *selector) Strings(ctx context.Context) ([]string, error) { + if len(*s.flds) > 1 { + return nil, errors.New("ent: Strings is not achievable when selecting more than 1 field") + } + var v []string + if err := s.scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// StringsX is like Strings, but panics if an error occurs. +func (s *selector) StringsX(ctx context.Context) []string { + v, err := s.Strings(ctx) + if err != nil { + panic(err) + } + return v +} + +// String returns a single string from a selector. It is only allowed when selecting one field. +func (s *selector) String(ctx context.Context) (_ string, err error) { + var v []string + if v, err = s.Strings(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{s.label} + default: + err = fmt.Errorf("ent: Strings returned %d results when one was expected", len(v)) + } + return +} + +// StringX is like String, but panics if an error occurs. +func (s *selector) StringX(ctx context.Context) string { + v, err := s.String(ctx) + if err != nil { + panic(err) + } + return v +} + +// Ints returns list of ints from a selector. It is only allowed when selecting one field. +func (s *selector) Ints(ctx context.Context) ([]int, error) { + if len(*s.flds) > 1 { + return nil, errors.New("ent: Ints is not achievable when selecting more than 1 field") + } + var v []int + if err := s.scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// IntsX is like Ints, but panics if an error occurs. +func (s *selector) IntsX(ctx context.Context) []int { + v, err := s.Ints(ctx) + if err != nil { + panic(err) + } + return v +} + +// Int returns a single int from a selector. It is only allowed when selecting one field. +func (s *selector) Int(ctx context.Context) (_ int, err error) { + var v []int + if v, err = s.Ints(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{s.label} + default: + err = fmt.Errorf("ent: Ints returned %d results when one was expected", len(v)) + } + return +} + +// IntX is like Int, but panics if an error occurs. +func (s *selector) IntX(ctx context.Context) int { + v, err := s.Int(ctx) + if err != nil { + panic(err) + } + return v +} + +// Float64s returns list of float64s from a selector. It is only allowed when selecting one field. +func (s *selector) Float64s(ctx context.Context) ([]float64, error) { + if len(*s.flds) > 1 { + return nil, errors.New("ent: Float64s is not achievable when selecting more than 1 field") + } + var v []float64 + if err := s.scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// Float64sX is like Float64s, but panics if an error occurs. +func (s *selector) Float64sX(ctx context.Context) []float64 { + v, err := s.Float64s(ctx) + if err != nil { + panic(err) + } + return v +} + +// Float64 returns a single float64 from a selector. It is only allowed when selecting one field. +func (s *selector) Float64(ctx context.Context) (_ float64, err error) { + var v []float64 + if v, err = s.Float64s(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{s.label} + default: + err = fmt.Errorf("ent: Float64s returned %d results when one was expected", len(v)) + } + return +} + +// Float64X is like Float64, but panics if an error occurs. +func (s *selector) Float64X(ctx context.Context) float64 { + v, err := s.Float64(ctx) + if err != nil { + panic(err) + } + return v +} + +// Bools returns list of bools from a selector. It is only allowed when selecting one field. +func (s *selector) Bools(ctx context.Context) ([]bool, error) { + if len(*s.flds) > 1 { + return nil, errors.New("ent: Bools is not achievable when selecting more than 1 field") + } + var v []bool + if err := s.scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// BoolsX is like Bools, but panics if an error occurs. +func (s *selector) BoolsX(ctx context.Context) []bool { + v, err := s.Bools(ctx) + if err != nil { + panic(err) + } + return v +} + +// Bool returns a single bool from a selector. It is only allowed when selecting one field. +func (s *selector) Bool(ctx context.Context) (_ bool, err error) { + var v []bool + if v, err = s.Bools(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{s.label} + default: + err = fmt.Errorf("ent: Bools returned %d results when one was expected", len(v)) + } + return +} + +// BoolX is like Bool, but panics if an error occurs. +func (s *selector) BoolX(ctx context.Context) bool { + v, err := s.Bool(ctx) + if err != nil { + panic(err) + } + return v +} + +// withHooks invokes the builder operation with the given hooks, if any. +func withHooks[V Value, M any, PM interface { + *M + Mutation +}](ctx context.Context, exec func(context.Context) (V, error), mutation PM, hooks []Hook) (value V, err error) { + if len(hooks) == 0 { + return exec(ctx) + } + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutationT, ok := any(m).(PM) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + // Set the mutation to the builder. + *mutation = *mutationT + return exec(ctx) + }) + for i := len(hooks) - 1; i >= 0; i-- { + if hooks[i] == nil { + return value, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") + } + mut = hooks[i](mut) + } + v, err := mut.Mutate(ctx, mutation) + if err != nil { + return value, err + } + nv, ok := v.(V) + if !ok { + return value, fmt.Errorf("unexpected node type %T returned from %T", v, mutation) + } + return nv, nil +} + +// setContextOp returns a new context with the given QueryContext attached (including its op) in case it does not exist. +func setContextOp(ctx context.Context, qc *QueryContext, op string) context.Context { + if ent.QueryFromContext(ctx) == nil { + qc.Op = op + ctx = ent.NewQueryContext(ctx, qc) + } + return ctx +} + +func querierAll[V Value, Q interface { + sqlAll(context.Context, ...queryHook) (V, error) +}]() Querier { + return QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + query, ok := q.(Q) + if !ok { + return nil, fmt.Errorf("unexpected query type %T", q) + } + return query.sqlAll(ctx) + }) +} + +func querierCount[Q interface { + sqlCount(context.Context) (int, error) +}]() Querier { + return QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + query, ok := q.(Q) + if !ok { + return nil, fmt.Errorf("unexpected query type %T", q) + } + return query.sqlCount(ctx) + }) +} + +func withInterceptors[V Value](ctx context.Context, q Query, qr Querier, inters []Interceptor) (v V, err error) { + for i := len(inters) - 1; i >= 0; i-- { + qr = inters[i].Intercept(qr) + } + rv, err := qr.Query(ctx, q) + if err != nil { + return v, err + } + vt, ok := rv.(V) + if !ok { + return v, fmt.Errorf("unexpected type %T returned from %T. expected type: %T", vt, q, v) + } + return vt, nil +} + +func scanWithInterceptors[Q1 ent.Query, Q2 interface { + sqlScan(context.Context, Q1, any) error +}](ctx context.Context, rootQuery Q1, selectOrGroup Q2, inters []Interceptor, v any) error { + rv := reflect.ValueOf(v) + var qr Querier = QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + query, ok := q.(Q1) + if !ok { + return nil, fmt.Errorf("unexpected query type %T", q) + } + if err := selectOrGroup.sqlScan(ctx, query, v); err != nil { + return nil, err + } + if k := rv.Kind(); k == reflect.Pointer && rv.Elem().CanInterface() { + return rv.Elem().Interface(), nil + } + return v, nil + }) + for i := len(inters) - 1; i >= 0; i-- { + qr = inters[i].Intercept(qr) + } + vv, err := qr.Query(ctx, rootQuery) + if err != nil { + return err + } + switch rv2 := reflect.ValueOf(vv); { + case rv.IsNil(), rv2.IsNil(), rv.Kind() != reflect.Pointer: + case rv.Type() == rv2.Type(): + rv.Elem().Set(rv2.Elem()) + case rv.Elem().Type() == rv2.Type(): + rv.Elem().Set(rv2) + } + return nil +} + +// queryHook describes an internal hook for the different sqlAll methods. +type queryHook func(context.Context, *sqlgraph.QuerySpec) diff --git a/code/base-project/base-go-v3/ent/enttest/enttest.go b/code/base-project/base-go-v3/ent/enttest/enttest.go new file mode 100644 index 00000000..3221b370 --- /dev/null +++ b/code/base-project/base-go-v3/ent/enttest/enttest.go @@ -0,0 +1,85 @@ +// Code generated by ent, DO NOT EDIT. + +package enttest + +import ( + "context" + + "cn/oneao/base-go/ent" + // required by schema hooks. + _ "cn/oneao/base-go/ent/runtime" + + "cn/oneao/base-go/ent/migrate" + + "entgo.io/ent/dialect/sql/schema" +) + +type ( + // TestingT is the interface that is shared between + // testing.T and testing.B and used by enttest. + TestingT interface { + FailNow() + Error(...any) + } + + // Option configures client creation. + Option func(*options) + + options struct { + opts []ent.Option + migrateOpts []schema.MigrateOption + } +) + +// WithOptions forwards options to client creation. +func WithOptions(opts ...ent.Option) Option { + return func(o *options) { + o.opts = append(o.opts, opts...) + } +} + +// WithMigrateOptions forwards options to auto migration. +func WithMigrateOptions(opts ...schema.MigrateOption) Option { + return func(o *options) { + o.migrateOpts = append(o.migrateOpts, opts...) + } +} + +func newOptions(opts []Option) *options { + o := &options{} + for _, opt := range opts { + opt(o) + } + return o +} + +// Open calls ent.Open and auto-run migration. +func Open(t TestingT, driverName, dataSourceName string, opts ...Option) *ent.Client { + o := newOptions(opts) + c, err := ent.Open(driverName, dataSourceName, o.opts...) + if err != nil { + t.Error(err) + t.FailNow() + } + migrateSchema(t, c, o) + return c +} + +// NewClient calls ent.NewClient and auto-run migration. +func NewClient(t TestingT, opts ...Option) *ent.Client { + o := newOptions(opts) + c := ent.NewClient(o.opts...) + migrateSchema(t, c, o) + return c +} +func migrateSchema(t TestingT, c *ent.Client, o *options) { + tables, err := schema.CopyTables(migrate.Tables) + if err != nil { + t.Error(err) + t.FailNow() + } + if err := migrate.Create(context.Background(), c.Schema, tables, o.migrateOpts...); err != nil { + t.Error(err) + t.FailNow() + } +} diff --git a/code/base-project/base-go-v3/ent/generate.go b/code/base-project/base-go-v3/ent/generate.go new file mode 100644 index 00000000..8d3fdfdc --- /dev/null +++ b/code/base-project/base-go-v3/ent/generate.go @@ -0,0 +1,3 @@ +package ent + +//go:generate go run -mod=mod entgo.io/ent/cmd/ent generate ./schema diff --git a/code/base-project/base-go-v3/ent/hook/hook.go b/code/base-project/base-go-v3/ent/hook/hook.go new file mode 100644 index 00000000..d511d23c --- /dev/null +++ b/code/base-project/base-go-v3/ent/hook/hook.go @@ -0,0 +1,198 @@ +// Code generated by ent, DO NOT EDIT. + +package hook + +import ( + "cn/oneao/base-go/ent" + "context" + "fmt" +) + +// The UserInfoFunc type is an adapter to allow the use of ordinary +// function as UserInfo mutator. +type UserInfoFunc func(context.Context, *ent.UserInfoMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f UserInfoFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.UserInfoMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.UserInfoMutation", m) +} + +// Condition is a hook condition function. +type Condition func(context.Context, ent.Mutation) bool + +// And groups conditions with the AND operator. +func And(first, second Condition, rest ...Condition) Condition { + return func(ctx context.Context, m ent.Mutation) bool { + if !first(ctx, m) || !second(ctx, m) { + return false + } + for _, cond := range rest { + if !cond(ctx, m) { + return false + } + } + return true + } +} + +// Or groups conditions with the OR operator. +func Or(first, second Condition, rest ...Condition) Condition { + return func(ctx context.Context, m ent.Mutation) bool { + if first(ctx, m) || second(ctx, m) { + return true + } + for _, cond := range rest { + if cond(ctx, m) { + return true + } + } + return false + } +} + +// Not negates a given condition. +func Not(cond Condition) Condition { + return func(ctx context.Context, m ent.Mutation) bool { + return !cond(ctx, m) + } +} + +// HasOp is a condition testing mutation operation. +func HasOp(op ent.Op) Condition { + return func(_ context.Context, m ent.Mutation) bool { + return m.Op().Is(op) + } +} + +// HasAddedFields is a condition validating `.AddedField` on fields. +func HasAddedFields(field string, fields ...string) Condition { + return func(_ context.Context, m ent.Mutation) bool { + if _, exists := m.AddedField(field); !exists { + return false + } + for _, field := range fields { + if _, exists := m.AddedField(field); !exists { + return false + } + } + return true + } +} + +// HasClearedFields is a condition validating `.FieldCleared` on fields. +func HasClearedFields(field string, fields ...string) Condition { + return func(_ context.Context, m ent.Mutation) bool { + if exists := m.FieldCleared(field); !exists { + return false + } + for _, field := range fields { + if exists := m.FieldCleared(field); !exists { + return false + } + } + return true + } +} + +// HasFields is a condition validating `.Field` on fields. +func HasFields(field string, fields ...string) Condition { + return func(_ context.Context, m ent.Mutation) bool { + if _, exists := m.Field(field); !exists { + return false + } + for _, field := range fields { + if _, exists := m.Field(field); !exists { + return false + } + } + return true + } +} + +// If executes the given hook under condition. +// +// hook.If(ComputeAverage, And(HasFields(...), HasAddedFields(...))) +func If(hk ent.Hook, cond Condition) ent.Hook { + return func(next ent.Mutator) ent.Mutator { + return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if cond(ctx, m) { + return hk(next).Mutate(ctx, m) + } + return next.Mutate(ctx, m) + }) + } +} + +// On executes the given hook only for the given operation. +// +// hook.On(Log, ent.Delete|ent.Create) +func On(hk ent.Hook, op ent.Op) ent.Hook { + return If(hk, HasOp(op)) +} + +// Unless skips the given hook only for the given operation. +// +// hook.Unless(Log, ent.Update|ent.UpdateOne) +func Unless(hk ent.Hook, op ent.Op) ent.Hook { + return If(hk, Not(HasOp(op))) +} + +// FixedError is a hook returning a fixed error. +func FixedError(err error) ent.Hook { + return func(ent.Mutator) ent.Mutator { + return ent.MutateFunc(func(context.Context, ent.Mutation) (ent.Value, error) { + return nil, err + }) + } +} + +// Reject returns a hook that rejects all operations that match op. +// +// func (T) Hooks() []ent.Hook { +// return []ent.Hook{ +// Reject(ent.Delete|ent.Update), +// } +// } +func Reject(op ent.Op) ent.Hook { + hk := FixedError(fmt.Errorf("%s operation is not allowed", op)) + return On(hk, op) +} + +// Chain acts as a list of hooks and is effectively immutable. +// Once created, it will always hold the same set of hooks in the same order. +type Chain struct { + hooks []ent.Hook +} + +// NewChain creates a new chain of hooks. +func NewChain(hooks ...ent.Hook) Chain { + return Chain{append([]ent.Hook(nil), hooks...)} +} + +// Hook chains the list of hooks and returns the final hook. +func (c Chain) Hook() ent.Hook { + return func(mutator ent.Mutator) ent.Mutator { + for i := len(c.hooks) - 1; i >= 0; i-- { + mutator = c.hooks[i](mutator) + } + return mutator + } +} + +// Append extends a chain, adding the specified hook +// as the last ones in the mutation flow. +func (c Chain) Append(hooks ...ent.Hook) Chain { + newHooks := make([]ent.Hook, 0, len(c.hooks)+len(hooks)) + newHooks = append(newHooks, c.hooks...) + newHooks = append(newHooks, hooks...) + return Chain{newHooks} +} + +// Extend extends a chain, adding the specified chain +// as the last ones in the mutation flow. +func (c Chain) Extend(chain Chain) Chain { + return c.Append(chain.hooks...) +} diff --git a/code/base-project/base-go-v3/ent/migrate/migrate.go b/code/base-project/base-go-v3/ent/migrate/migrate.go new file mode 100644 index 00000000..1956a6bf --- /dev/null +++ b/code/base-project/base-go-v3/ent/migrate/migrate.go @@ -0,0 +1,64 @@ +// Code generated by ent, DO NOT EDIT. + +package migrate + +import ( + "context" + "fmt" + "io" + + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql/schema" +) + +var ( + // WithGlobalUniqueID sets the universal ids options to the migration. + // If this option is enabled, ent migration will allocate a 1<<32 range + // for the ids of each entity (table). + // Note that this option cannot be applied on tables that already exist. + WithGlobalUniqueID = schema.WithGlobalUniqueID + // WithDropColumn sets the drop column option to the migration. + // If this option is enabled, ent migration will drop old columns + // that were used for both fields and edges. This defaults to false. + WithDropColumn = schema.WithDropColumn + // WithDropIndex sets the drop index option to the migration. + // If this option is enabled, ent migration will drop old indexes + // that were defined in the schema. This defaults to false. + // Note that unique constraints are defined using `UNIQUE INDEX`, + // and therefore, it's recommended to enable this option to get more + // flexibility in the schema changes. + WithDropIndex = schema.WithDropIndex + // WithForeignKeys enables creating foreign-key in schema DDL. This defaults to true. + WithForeignKeys = schema.WithForeignKeys +) + +// Schema is the API for creating, migrating and dropping a schema. +type Schema struct { + drv dialect.Driver +} + +// NewSchema creates a new schema client. +func NewSchema(drv dialect.Driver) *Schema { return &Schema{drv: drv} } + +// Create creates all schema resources. +func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error { + return Create(ctx, s, Tables, opts...) +} + +// Create creates all table resources using the given schema driver. +func Create(ctx context.Context, s *Schema, tables []*schema.Table, opts ...schema.MigrateOption) error { + migrate, err := schema.NewMigrate(s.drv, opts...) + if err != nil { + return fmt.Errorf("ent/migrate: %w", err) + } + return migrate.Create(ctx, tables...) +} + +// WriteTo writes the schema changes to w instead of running them against the database. +// +// if err := client.Schema.WriteTo(context.Background(), os.Stdout); err != nil { +// log.Fatal(err) +// } +func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error { + return Create(ctx, &Schema{drv: &schema.WriteDriver{Writer: w, Driver: s.drv}}, Tables, opts...) +} diff --git a/code/base-project/base-go-v3/ent/migrate/schema.go b/code/base-project/base-go-v3/ent/migrate/schema.go new file mode 100644 index 00000000..fbaa209c --- /dev/null +++ b/code/base-project/base-go-v3/ent/migrate/schema.go @@ -0,0 +1,41 @@ +// Code generated by ent, DO NOT EDIT. + +package migrate + +import ( + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/dialect/sql/schema" + "entgo.io/ent/schema/field" +) + +var ( + // UserInfoColumns holds the columns for the "user_info" table. + UserInfoColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt64, Increment: true}, + {Name: "seq_no", Type: field.TypeInt64, Default: 0}, + {Name: "email", Type: field.TypeString, Unique: true, Size: 255}, + {Name: "username", Type: field.TypeString, Size: 50}, + {Name: "password", Type: field.TypeString, Size: 255}, + {Name: "gender", Type: field.TypeInt64, Default: 0}, + {Name: "account", Type: field.TypeString, Unique: true, Size: 255}, + {Name: "create_time", Type: field.TypeTime}, + {Name: "update_time", Type: field.TypeTime}, + {Name: "last_login_time", Type: field.TypeTime, Nullable: true}, + } + // UserInfoTable holds the schema information for the "user_info" table. + UserInfoTable = &schema.Table{ + Name: "user_info", + Columns: UserInfoColumns, + PrimaryKey: []*schema.Column{UserInfoColumns[0]}, + } + // Tables holds all the tables in the schema. + Tables = []*schema.Table{ + UserInfoTable, + } +) + +func init() { + UserInfoTable.Annotation = &entsql.Annotation{ + Table: "user_info", + } +} diff --git a/code/base-project/base-go-v3/ent/mutation.go b/code/base-project/base-go-v3/ent/mutation.go new file mode 100644 index 00000000..4656b928 --- /dev/null +++ b/code/base-project/base-go-v3/ent/mutation.go @@ -0,0 +1,883 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "cn/oneao/base-go/ent/predicate" + "cn/oneao/base-go/ent/userinfo" + "context" + "errors" + "fmt" + "sync" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +const ( + // Operation types. + OpCreate = ent.OpCreate + OpDelete = ent.OpDelete + OpDeleteOne = ent.OpDeleteOne + OpUpdate = ent.OpUpdate + OpUpdateOne = ent.OpUpdateOne + + // Node types. + TypeUserInfo = "UserInfo" +) + +// UserInfoMutation represents an operation that mutates the UserInfo nodes in the graph. +type UserInfoMutation struct { + config + op Op + typ string + id *int64 + seq_no *int64 + addseq_no *int64 + email *string + username *string + password *string + gender *int64 + addgender *int64 + account *string + create_time *time.Time + update_time *time.Time + last_login_time *time.Time + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*UserInfo, error) + predicates []predicate.UserInfo +} + +var _ ent.Mutation = (*UserInfoMutation)(nil) + +// userinfoOption allows management of the mutation configuration using functional options. +type userinfoOption func(*UserInfoMutation) + +// newUserInfoMutation creates new mutation for the UserInfo entity. +func newUserInfoMutation(c config, op Op, opts ...userinfoOption) *UserInfoMutation { + m := &UserInfoMutation{ + config: c, + op: op, + typ: TypeUserInfo, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withUserInfoID sets the ID field of the mutation. +func withUserInfoID(id int64) userinfoOption { + return func(m *UserInfoMutation) { + var ( + err error + once sync.Once + value *UserInfo + ) + m.oldValue = func(ctx context.Context) (*UserInfo, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().UserInfo.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withUserInfo sets the old UserInfo of the mutation. +func withUserInfo(node *UserInfo) userinfoOption { + return func(m *UserInfoMutation) { + m.oldValue = func(context.Context) (*UserInfo, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m UserInfoMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m UserInfoMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of UserInfo entities. +func (m *UserInfoMutation) SetID(id int64) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *UserInfoMutation) ID() (id int64, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *UserInfoMutation) IDs(ctx context.Context) ([]int64, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int64{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().UserInfo.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetSeqNo sets the "seq_no" field. +func (m *UserInfoMutation) SetSeqNo(i int64) { + m.seq_no = &i + m.addseq_no = nil +} + +// SeqNo returns the value of the "seq_no" field in the mutation. +func (m *UserInfoMutation) SeqNo() (r int64, exists bool) { + v := m.seq_no + if v == nil { + return + } + return *v, true +} + +// OldSeqNo returns the old "seq_no" field's value of the UserInfo entity. +// If the UserInfo 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 *UserInfoMutation) OldSeqNo(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSeqNo is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSeqNo requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSeqNo: %w", err) + } + return oldValue.SeqNo, nil +} + +// AddSeqNo adds i to the "seq_no" field. +func (m *UserInfoMutation) AddSeqNo(i int64) { + if m.addseq_no != nil { + *m.addseq_no += i + } else { + m.addseq_no = &i + } +} + +// AddedSeqNo returns the value that was added to the "seq_no" field in this mutation. +func (m *UserInfoMutation) AddedSeqNo() (r int64, exists bool) { + v := m.addseq_no + if v == nil { + return + } + return *v, true +} + +// ResetSeqNo resets all changes to the "seq_no" field. +func (m *UserInfoMutation) ResetSeqNo() { + m.seq_no = nil + m.addseq_no = nil +} + +// SetEmail sets the "email" field. +func (m *UserInfoMutation) SetEmail(s string) { + m.email = &s +} + +// Email returns the value of the "email" field in the mutation. +func (m *UserInfoMutation) Email() (r string, exists bool) { + v := m.email + if v == nil { + return + } + return *v, true +} + +// OldEmail returns the old "email" field's value of the UserInfo entity. +// If the UserInfo 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 *UserInfoMutation) OldEmail(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldEmail is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldEmail requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldEmail: %w", err) + } + return oldValue.Email, nil +} + +// ResetEmail resets all changes to the "email" field. +func (m *UserInfoMutation) ResetEmail() { + m.email = nil +} + +// SetUsername sets the "username" field. +func (m *UserInfoMutation) SetUsername(s string) { + m.username = &s +} + +// Username returns the value of the "username" field in the mutation. +func (m *UserInfoMutation) Username() (r string, exists bool) { + v := m.username + if v == nil { + return + } + return *v, true +} + +// OldUsername returns the old "username" field's value of the UserInfo entity. +// If the UserInfo 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 *UserInfoMutation) OldUsername(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUsername is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUsername requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUsername: %w", err) + } + return oldValue.Username, nil +} + +// ResetUsername resets all changes to the "username" field. +func (m *UserInfoMutation) ResetUsername() { + m.username = nil +} + +// SetPassword sets the "password" field. +func (m *UserInfoMutation) SetPassword(s string) { + m.password = &s +} + +// Password returns the value of the "password" field in the mutation. +func (m *UserInfoMutation) Password() (r string, exists bool) { + v := m.password + if v == nil { + return + } + return *v, true +} + +// OldPassword returns the old "password" field's value of the UserInfo entity. +// If the UserInfo 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 *UserInfoMutation) OldPassword(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPassword is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPassword requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPassword: %w", err) + } + return oldValue.Password, nil +} + +// ResetPassword resets all changes to the "password" field. +func (m *UserInfoMutation) ResetPassword() { + m.password = nil +} + +// SetGender sets the "gender" field. +func (m *UserInfoMutation) SetGender(i int64) { + m.gender = &i + m.addgender = nil +} + +// Gender returns the value of the "gender" field in the mutation. +func (m *UserInfoMutation) Gender() (r int64, exists bool) { + v := m.gender + if v == nil { + return + } + return *v, true +} + +// OldGender returns the old "gender" field's value of the UserInfo entity. +// If the UserInfo 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 *UserInfoMutation) OldGender(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldGender is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldGender requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldGender: %w", err) + } + return oldValue.Gender, nil +} + +// AddGender adds i to the "gender" field. +func (m *UserInfoMutation) AddGender(i int64) { + if m.addgender != nil { + *m.addgender += i + } else { + m.addgender = &i + } +} + +// AddedGender returns the value that was added to the "gender" field in this mutation. +func (m *UserInfoMutation) AddedGender() (r int64, exists bool) { + v := m.addgender + if v == nil { + return + } + return *v, true +} + +// ResetGender resets all changes to the "gender" field. +func (m *UserInfoMutation) ResetGender() { + m.gender = nil + m.addgender = nil +} + +// SetAccount sets the "account" field. +func (m *UserInfoMutation) SetAccount(s string) { + m.account = &s +} + +// Account returns the value of the "account" field in the mutation. +func (m *UserInfoMutation) Account() (r string, exists bool) { + v := m.account + if v == nil { + return + } + return *v, true +} + +// OldAccount returns the old "account" field's value of the UserInfo entity. +// If the UserInfo 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 *UserInfoMutation) OldAccount(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAccount is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAccount requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAccount: %w", err) + } + return oldValue.Account, nil +} + +// ResetAccount resets all changes to the "account" field. +func (m *UserInfoMutation) ResetAccount() { + m.account = nil +} + +// SetCreateTime sets the "create_time" field. +func (m *UserInfoMutation) SetCreateTime(t time.Time) { + m.create_time = &t +} + +// CreateTime returns the value of the "create_time" field in the mutation. +func (m *UserInfoMutation) CreateTime() (r time.Time, exists bool) { + v := m.create_time + if v == nil { + return + } + return *v, true +} + +// OldCreateTime returns the old "create_time" field's value of the UserInfo entity. +// If the UserInfo 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 *UserInfoMutation) OldCreateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) + } + return oldValue.CreateTime, nil +} + +// ResetCreateTime resets all changes to the "create_time" field. +func (m *UserInfoMutation) ResetCreateTime() { + m.create_time = nil +} + +// SetUpdateTime sets the "update_time" field. +func (m *UserInfoMutation) SetUpdateTime(t time.Time) { + m.update_time = &t +} + +// UpdateTime returns the value of the "update_time" field in the mutation. +func (m *UserInfoMutation) UpdateTime() (r time.Time, exists bool) { + v := m.update_time + if v == nil { + return + } + return *v, true +} + +// OldUpdateTime returns the old "update_time" field's value of the UserInfo entity. +// If the UserInfo 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 *UserInfoMutation) OldUpdateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err) + } + return oldValue.UpdateTime, nil +} + +// ResetUpdateTime resets all changes to the "update_time" field. +func (m *UserInfoMutation) ResetUpdateTime() { + m.update_time = nil +} + +// SetLastLoginTime sets the "last_login_time" field. +func (m *UserInfoMutation) SetLastLoginTime(t time.Time) { + m.last_login_time = &t +} + +// LastLoginTime returns the value of the "last_login_time" field in the mutation. +func (m *UserInfoMutation) LastLoginTime() (r time.Time, exists bool) { + v := m.last_login_time + if v == nil { + return + } + return *v, true +} + +// OldLastLoginTime returns the old "last_login_time" field's value of the UserInfo entity. +// If the UserInfo 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 *UserInfoMutation) OldLastLoginTime(ctx context.Context) (v *time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLastLoginTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLastLoginTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLastLoginTime: %w", err) + } + return oldValue.LastLoginTime, nil +} + +// ClearLastLoginTime clears the value of the "last_login_time" field. +func (m *UserInfoMutation) ClearLastLoginTime() { + m.last_login_time = nil + m.clearedFields[userinfo.FieldLastLoginTime] = struct{}{} +} + +// LastLoginTimeCleared returns if the "last_login_time" field was cleared in this mutation. +func (m *UserInfoMutation) LastLoginTimeCleared() bool { + _, ok := m.clearedFields[userinfo.FieldLastLoginTime] + return ok +} + +// ResetLastLoginTime resets all changes to the "last_login_time" field. +func (m *UserInfoMutation) ResetLastLoginTime() { + m.last_login_time = nil + delete(m.clearedFields, userinfo.FieldLastLoginTime) +} + +// Where appends a list predicates to the UserInfoMutation builder. +func (m *UserInfoMutation) Where(ps ...predicate.UserInfo) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the UserInfoMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *UserInfoMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.UserInfo, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *UserInfoMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *UserInfoMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (UserInfo). +func (m *UserInfoMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *UserInfoMutation) Fields() []string { + fields := make([]string, 0, 9) + if m.seq_no != nil { + fields = append(fields, userinfo.FieldSeqNo) + } + if m.email != nil { + fields = append(fields, userinfo.FieldEmail) + } + if m.username != nil { + fields = append(fields, userinfo.FieldUsername) + } + if m.password != nil { + fields = append(fields, userinfo.FieldPassword) + } + if m.gender != nil { + fields = append(fields, userinfo.FieldGender) + } + if m.account != nil { + fields = append(fields, userinfo.FieldAccount) + } + if m.create_time != nil { + fields = append(fields, userinfo.FieldCreateTime) + } + if m.update_time != nil { + fields = append(fields, userinfo.FieldUpdateTime) + } + if m.last_login_time != nil { + fields = append(fields, userinfo.FieldLastLoginTime) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *UserInfoMutation) Field(name string) (ent.Value, bool) { + switch name { + case userinfo.FieldSeqNo: + return m.SeqNo() + case userinfo.FieldEmail: + return m.Email() + case userinfo.FieldUsername: + return m.Username() + case userinfo.FieldPassword: + return m.Password() + case userinfo.FieldGender: + return m.Gender() + case userinfo.FieldAccount: + return m.Account() + case userinfo.FieldCreateTime: + return m.CreateTime() + case userinfo.FieldUpdateTime: + return m.UpdateTime() + case userinfo.FieldLastLoginTime: + return m.LastLoginTime() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *UserInfoMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case userinfo.FieldSeqNo: + return m.OldSeqNo(ctx) + case userinfo.FieldEmail: + return m.OldEmail(ctx) + case userinfo.FieldUsername: + return m.OldUsername(ctx) + case userinfo.FieldPassword: + return m.OldPassword(ctx) + case userinfo.FieldGender: + return m.OldGender(ctx) + case userinfo.FieldAccount: + return m.OldAccount(ctx) + case userinfo.FieldCreateTime: + return m.OldCreateTime(ctx) + case userinfo.FieldUpdateTime: + return m.OldUpdateTime(ctx) + case userinfo.FieldLastLoginTime: + return m.OldLastLoginTime(ctx) + } + return nil, fmt.Errorf("unknown UserInfo field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *UserInfoMutation) SetField(name string, value ent.Value) error { + switch name { + case userinfo.FieldSeqNo: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSeqNo(v) + return nil + case userinfo.FieldEmail: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetEmail(v) + return nil + case userinfo.FieldUsername: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUsername(v) + return nil + case userinfo.FieldPassword: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPassword(v) + return nil + case userinfo.FieldGender: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetGender(v) + return nil + case userinfo.FieldAccount: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAccount(v) + return nil + case userinfo.FieldCreateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreateTime(v) + return nil + case userinfo.FieldUpdateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdateTime(v) + return nil + case userinfo.FieldLastLoginTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLastLoginTime(v) + return nil + } + return fmt.Errorf("unknown UserInfo field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *UserInfoMutation) AddedFields() []string { + var fields []string + if m.addseq_no != nil { + fields = append(fields, userinfo.FieldSeqNo) + } + if m.addgender != nil { + fields = append(fields, userinfo.FieldGender) + } + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *UserInfoMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case userinfo.FieldSeqNo: + return m.AddedSeqNo() + case userinfo.FieldGender: + return m.AddedGender() + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *UserInfoMutation) AddField(name string, value ent.Value) error { + switch name { + case userinfo.FieldSeqNo: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddSeqNo(v) + return nil + case userinfo.FieldGender: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddGender(v) + return nil + } + return fmt.Errorf("unknown UserInfo numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *UserInfoMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(userinfo.FieldLastLoginTime) { + fields = append(fields, userinfo.FieldLastLoginTime) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *UserInfoMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *UserInfoMutation) ClearField(name string) error { + switch name { + case userinfo.FieldLastLoginTime: + m.ClearLastLoginTime() + return nil + } + return fmt.Errorf("unknown UserInfo nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *UserInfoMutation) ResetField(name string) error { + switch name { + case userinfo.FieldSeqNo: + m.ResetSeqNo() + return nil + case userinfo.FieldEmail: + m.ResetEmail() + return nil + case userinfo.FieldUsername: + m.ResetUsername() + return nil + case userinfo.FieldPassword: + m.ResetPassword() + return nil + case userinfo.FieldGender: + m.ResetGender() + return nil + case userinfo.FieldAccount: + m.ResetAccount() + return nil + case userinfo.FieldCreateTime: + m.ResetCreateTime() + return nil + case userinfo.FieldUpdateTime: + m.ResetUpdateTime() + return nil + case userinfo.FieldLastLoginTime: + m.ResetLastLoginTime() + return nil + } + return fmt.Errorf("unknown UserInfo field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *UserInfoMutation) AddedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *UserInfoMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *UserInfoMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *UserInfoMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *UserInfoMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *UserInfoMutation) EdgeCleared(name string) bool { + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *UserInfoMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown UserInfo unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *UserInfoMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown UserInfo edge %s", name) +} diff --git a/code/base-project/base-go-v3/ent/predicate/predicate.go b/code/base-project/base-go-v3/ent/predicate/predicate.go new file mode 100644 index 00000000..126911a0 --- /dev/null +++ b/code/base-project/base-go-v3/ent/predicate/predicate.go @@ -0,0 +1,10 @@ +// Code generated by ent, DO NOT EDIT. + +package predicate + +import ( + "entgo.io/ent/dialect/sql" +) + +// UserInfo is the predicate function for userinfo builders. +type UserInfo func(*sql.Selector) diff --git a/code/base-project/base-go-v3/ent/runtime.go b/code/base-project/base-go-v3/ent/runtime.go new file mode 100644 index 00000000..bdc4c1dd --- /dev/null +++ b/code/base-project/base-go-v3/ent/runtime.go @@ -0,0 +1,69 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "cn/oneao/base-go/ent/schema" + "cn/oneao/base-go/ent/userinfo" + "time" +) + +// The init function reads all schema descriptors with runtime code +// (default values, validators, hooks and policies) and stitches it +// to their package variables. +func init() { + userinfoFields := schema.UserInfo{}.Fields() + _ = userinfoFields + // userinfoDescSeqNo is the schema descriptor for seq_no field. + userinfoDescSeqNo := userinfoFields[1].Descriptor() + // userinfo.DefaultSeqNo holds the default value on creation for the seq_no field. + userinfo.DefaultSeqNo = userinfoDescSeqNo.Default.(int64) + // userinfoDescEmail is the schema descriptor for email field. + userinfoDescEmail := userinfoFields[2].Descriptor() + // userinfo.EmailValidator is a validator for the "email" field. It is called by the builders before save. + userinfo.EmailValidator = userinfoDescEmail.Validators[0].(func(string) error) + // userinfoDescUsername is the schema descriptor for username field. + userinfoDescUsername := userinfoFields[3].Descriptor() + // userinfo.UsernameValidator is a validator for the "username" field. It is called by the builders before save. + userinfo.UsernameValidator = func() func(string) error { + validators := userinfoDescUsername.Validators + fns := [...]func(string) error{ + validators[0].(func(string) error), + validators[1].(func(string) error), + } + return func(username string) error { + for _, fn := range fns { + if err := fn(username); err != nil { + return err + } + } + return nil + } + }() + // userinfoDescPassword is the schema descriptor for password field. + userinfoDescPassword := userinfoFields[4].Descriptor() + // userinfo.PasswordValidator is a validator for the "password" field. It is called by the builders before save. + userinfo.PasswordValidator = userinfoDescPassword.Validators[0].(func(string) error) + // userinfoDescGender is the schema descriptor for gender field. + userinfoDescGender := userinfoFields[5].Descriptor() + // userinfo.DefaultGender holds the default value on creation for the gender field. + userinfo.DefaultGender = userinfoDescGender.Default.(int64) + // userinfoDescAccount is the schema descriptor for account field. + userinfoDescAccount := userinfoFields[6].Descriptor() + // userinfo.AccountValidator is a validator for the "account" field. It is called by the builders before save. + userinfo.AccountValidator = userinfoDescAccount.Validators[0].(func(string) error) + // userinfoDescCreateTime is the schema descriptor for create_time field. + userinfoDescCreateTime := userinfoFields[7].Descriptor() + // userinfo.DefaultCreateTime holds the default value on creation for the create_time field. + userinfo.DefaultCreateTime = userinfoDescCreateTime.Default.(func() time.Time) + // userinfoDescUpdateTime is the schema descriptor for update_time field. + userinfoDescUpdateTime := userinfoFields[8].Descriptor() + // userinfo.DefaultUpdateTime holds the default value on creation for the update_time field. + userinfo.DefaultUpdateTime = userinfoDescUpdateTime.Default.(func() time.Time) + // userinfo.UpdateDefaultUpdateTime holds the default value on update for the update_time field. + userinfo.UpdateDefaultUpdateTime = userinfoDescUpdateTime.UpdateDefault.(func() time.Time) + // userinfoDescID is the schema descriptor for id field. + userinfoDescID := userinfoFields[0].Descriptor() + // userinfo.DefaultID holds the default value on creation for the id field. + userinfo.DefaultID = userinfoDescID.Default.(func() int64) +} diff --git a/code/base-project/base-go-v3/ent/runtime/runtime.go b/code/base-project/base-go-v3/ent/runtime/runtime.go new file mode 100644 index 00000000..c145156f --- /dev/null +++ b/code/base-project/base-go-v3/ent/runtime/runtime.go @@ -0,0 +1,10 @@ +// Code generated by ent, DO NOT EDIT. + +package runtime + +// The schema-stitching logic is generated in cn/oneao/base-go/ent/runtime.go + +const ( + Version = "v0.14.5" // Version of ent codegen. + Sum = "h1:Rj2WOYJtCkWyFo6a+5wB3EfBRP0rnx1fMk6gGA0UUe4=" // Sum of ent codegen. +) diff --git a/code/base-project/base-go-v3/ent/schema/userinfo.go b/code/base-project/base-go-v3/ent/schema/userinfo.go new file mode 100644 index 00000000..e11b9229 --- /dev/null +++ b/code/base-project/base-go-v3/ent/schema/userinfo.go @@ -0,0 +1,86 @@ +package schema + +import ( + "cn/oneao/base-go/utils/idgen" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema" + "entgo.io/ent/schema/field" +) + +// UserInfo schema. +type UserInfo struct { + ent.Schema +} + +// Annotations 自定义表名 + 表注释 +func (UserInfo) Annotations() []schema.Annotation { + return []schema.Annotation{ + entsql.Annotation{ + Table: "user_info", + }, + } +} + +// Fields 字段定义 +func (UserInfo) Fields() []ent.Field { + return []ent.Field{ + + field.Int64("id"). + Unique(). + Immutable(). + Comment("用户ID"). + DefaultFunc(idgen.NextId), + + field.Int64("seq_no"). + Default(0). + Comment("序号"), + + field.String("email"). + Unique(). + MaxLen(255). + Comment("邮箱"), + + field.String("username"). + NotEmpty(). + MaxLen(50). + Comment("用户名"), + + field.String("password"). + Sensitive(). + MaxLen(255). + Comment("密码"), + + field.Int64("gender"). + Default(0). + Comment("性别:0未知 1男 2女"), + + field.String("account"). + Unique(). + MaxLen(255). + Comment("登录账号"), + + // 自动创建时间 + field.Time("create_time"). + Default(time.Now). + Immutable(). + Comment("创建时间"), + + // 自动更新时间 + field.Time("update_time"). + Default(time.Now). + UpdateDefault(time.Now). + Comment("更新时间"), + + field.Time("last_login_time"). + Optional(). + Nillable(). + Comment("最近登录时间 (登录后更新)"), + } +} + +func (UserInfo) Edges() []ent.Edge { + return nil +} diff --git a/code/base-project/base-go-v3/ent/tx.go b/code/base-project/base-go-v3/ent/tx.go new file mode 100644 index 00000000..896bc05b --- /dev/null +++ b/code/base-project/base-go-v3/ent/tx.go @@ -0,0 +1,210 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "sync" + + "entgo.io/ent/dialect" +) + +// Tx is a transactional client that is created by calling Client.Tx(). +type Tx struct { + config + // UserInfo is the client for interacting with the UserInfo builders. + UserInfo *UserInfoClient + + // lazily loaded. + client *Client + clientOnce sync.Once + // ctx lives for the life of the transaction. It is + // the same context used by the underlying connection. + ctx context.Context +} + +type ( + // Committer is the interface that wraps the Commit method. + Committer interface { + Commit(context.Context, *Tx) error + } + + // The CommitFunc type is an adapter to allow the use of ordinary + // function as a Committer. If f is a function with the appropriate + // signature, CommitFunc(f) is a Committer that calls f. + CommitFunc func(context.Context, *Tx) error + + // CommitHook defines the "commit middleware". A function that gets a Committer + // and returns a Committer. For example: + // + // hook := func(next ent.Committer) ent.Committer { + // return ent.CommitFunc(func(ctx context.Context, tx *ent.Tx) error { + // // Do some stuff before. + // if err := next.Commit(ctx, tx); err != nil { + // return err + // } + // // Do some stuff after. + // return nil + // }) + // } + // + CommitHook func(Committer) Committer +) + +// Commit calls f(ctx, m). +func (f CommitFunc) Commit(ctx context.Context, tx *Tx) error { + return f(ctx, tx) +} + +// Commit commits the transaction. +func (tx *Tx) Commit() error { + txDriver := tx.config.driver.(*txDriver) + var fn Committer = CommitFunc(func(context.Context, *Tx) error { + return txDriver.tx.Commit() + }) + txDriver.mu.Lock() + hooks := append([]CommitHook(nil), txDriver.onCommit...) + txDriver.mu.Unlock() + for i := len(hooks) - 1; i >= 0; i-- { + fn = hooks[i](fn) + } + return fn.Commit(tx.ctx, tx) +} + +// OnCommit adds a hook to call on commit. +func (tx *Tx) OnCommit(f CommitHook) { + txDriver := tx.config.driver.(*txDriver) + txDriver.mu.Lock() + txDriver.onCommit = append(txDriver.onCommit, f) + txDriver.mu.Unlock() +} + +type ( + // Rollbacker is the interface that wraps the Rollback method. + Rollbacker interface { + Rollback(context.Context, *Tx) error + } + + // The RollbackFunc type is an adapter to allow the use of ordinary + // function as a Rollbacker. If f is a function with the appropriate + // signature, RollbackFunc(f) is a Rollbacker that calls f. + RollbackFunc func(context.Context, *Tx) error + + // RollbackHook defines the "rollback middleware". A function that gets a Rollbacker + // and returns a Rollbacker. For example: + // + // hook := func(next ent.Rollbacker) ent.Rollbacker { + // return ent.RollbackFunc(func(ctx context.Context, tx *ent.Tx) error { + // // Do some stuff before. + // if err := next.Rollback(ctx, tx); err != nil { + // return err + // } + // // Do some stuff after. + // return nil + // }) + // } + // + RollbackHook func(Rollbacker) Rollbacker +) + +// Rollback calls f(ctx, m). +func (f RollbackFunc) Rollback(ctx context.Context, tx *Tx) error { + return f(ctx, tx) +} + +// Rollback rollbacks the transaction. +func (tx *Tx) Rollback() error { + txDriver := tx.config.driver.(*txDriver) + var fn Rollbacker = RollbackFunc(func(context.Context, *Tx) error { + return txDriver.tx.Rollback() + }) + txDriver.mu.Lock() + hooks := append([]RollbackHook(nil), txDriver.onRollback...) + txDriver.mu.Unlock() + for i := len(hooks) - 1; i >= 0; i-- { + fn = hooks[i](fn) + } + return fn.Rollback(tx.ctx, tx) +} + +// OnRollback adds a hook to call on rollback. +func (tx *Tx) OnRollback(f RollbackHook) { + txDriver := tx.config.driver.(*txDriver) + txDriver.mu.Lock() + txDriver.onRollback = append(txDriver.onRollback, f) + txDriver.mu.Unlock() +} + +// Client returns a Client that binds to current transaction. +func (tx *Tx) Client() *Client { + tx.clientOnce.Do(func() { + tx.client = &Client{config: tx.config} + tx.client.init() + }) + return tx.client +} + +func (tx *Tx) init() { + tx.UserInfo = NewUserInfoClient(tx.config) +} + +// txDriver wraps the given dialect.Tx with a nop dialect.Driver implementation. +// The idea is to support transactions without adding any extra code to the builders. +// When a builder calls to driver.Tx(), it gets the same dialect.Tx instance. +// Commit and Rollback are nop for the internal builders and the user must call one +// of them in order to commit or rollback the transaction. +// +// If a closed transaction is embedded in one of the generated entities, and the entity +// applies a query, for example: UserInfo.QueryXXX(), the query will be executed +// through the driver which created this transaction. +// +// Note that txDriver is not goroutine safe. +type txDriver struct { + // the driver we started the transaction from. + drv dialect.Driver + // tx is the underlying transaction. + tx dialect.Tx + // completion hooks. + mu sync.Mutex + onCommit []CommitHook + onRollback []RollbackHook +} + +// newTx creates a new transactional driver. +func newTx(ctx context.Context, drv dialect.Driver) (*txDriver, error) { + tx, err := drv.Tx(ctx) + if err != nil { + return nil, err + } + return &txDriver{tx: tx, drv: drv}, nil +} + +// Tx returns the transaction wrapper (txDriver) to avoid Commit or Rollback calls +// from the internal builders. Should be called only by the internal builders. +func (tx *txDriver) Tx(context.Context) (dialect.Tx, error) { return tx, nil } + +// Dialect returns the dialect of the driver we started the transaction from. +func (tx *txDriver) Dialect() string { return tx.drv.Dialect() } + +// Close is a nop close. +func (*txDriver) Close() error { return nil } + +// Commit is a nop commit for the internal builders. +// User must call `Tx.Commit` in order to commit the transaction. +func (*txDriver) Commit() error { return nil } + +// Rollback is a nop rollback for the internal builders. +// User must call `Tx.Rollback` in order to rollback the transaction. +func (*txDriver) Rollback() error { return nil } + +// Exec calls tx.Exec. +func (tx *txDriver) Exec(ctx context.Context, query string, args, v any) error { + return tx.tx.Exec(ctx, query, args, v) +} + +// Query calls tx.Query. +func (tx *txDriver) Query(ctx context.Context, query string, args, v any) error { + return tx.tx.Query(ctx, query, args, v) +} + +var _ dialect.Driver = (*txDriver)(nil) diff --git a/code/base-project/base-go-v3/ent/userinfo.go b/code/base-project/base-go-v3/ent/userinfo.go new file mode 100644 index 00000000..9b47f49c --- /dev/null +++ b/code/base-project/base-go-v3/ent/userinfo.go @@ -0,0 +1,197 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "cn/oneao/base-go/ent/userinfo" + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// UserInfo is the model entity for the UserInfo schema. +type UserInfo struct { + config `json:"-"` + // ID of the ent. + // 用户ID + ID int64 `json:"id,omitempty"` + // 序号 + SeqNo int64 `json:"seq_no,omitempty"` + // 邮箱 + Email string `json:"email,omitempty"` + // 用户名 + Username string `json:"username,omitempty"` + // 密码 + Password string `json:"-"` + // 性别:0未知 1男 2女 + Gender int64 `json:"gender,omitempty"` + // 登录账号 + Account string `json:"account,omitempty"` + // 创建时间 + CreateTime time.Time `json:"create_time,omitempty"` + // 更新时间 + UpdateTime time.Time `json:"update_time,omitempty"` + // 最近登录时间 (登录后更新) + LastLoginTime *time.Time `json:"last_login_time,omitempty"` + selectValues sql.SelectValues +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*UserInfo) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case userinfo.FieldID, userinfo.FieldSeqNo, userinfo.FieldGender: + values[i] = new(sql.NullInt64) + case userinfo.FieldEmail, userinfo.FieldUsername, userinfo.FieldPassword, userinfo.FieldAccount: + values[i] = new(sql.NullString) + case userinfo.FieldCreateTime, userinfo.FieldUpdateTime, userinfo.FieldLastLoginTime: + values[i] = new(sql.NullTime) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the UserInfo fields. +func (_m *UserInfo) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case userinfo.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + _m.ID = int64(value.Int64) + case userinfo.FieldSeqNo: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field seq_no", values[i]) + } else if value.Valid { + _m.SeqNo = value.Int64 + } + case userinfo.FieldEmail: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field email", values[i]) + } else if value.Valid { + _m.Email = value.String + } + case userinfo.FieldUsername: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field username", values[i]) + } else if value.Valid { + _m.Username = value.String + } + case userinfo.FieldPassword: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field password", values[i]) + } else if value.Valid { + _m.Password = value.String + } + case userinfo.FieldGender: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field gender", values[i]) + } else if value.Valid { + _m.Gender = value.Int64 + } + case userinfo.FieldAccount: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field account", values[i]) + } else if value.Valid { + _m.Account = value.String + } + case userinfo.FieldCreateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field create_time", values[i]) + } else if value.Valid { + _m.CreateTime = value.Time + } + case userinfo.FieldUpdateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field update_time", values[i]) + } else if value.Valid { + _m.UpdateTime = value.Time + } + case userinfo.FieldLastLoginTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field last_login_time", values[i]) + } else if value.Valid { + _m.LastLoginTime = new(time.Time) + *_m.LastLoginTime = value.Time + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the UserInfo. +// This includes values selected through modifiers, order, etc. +func (_m *UserInfo) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// Update returns a builder for updating this UserInfo. +// Note that you need to call UserInfo.Unwrap() before calling this method if this UserInfo +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *UserInfo) Update() *UserInfoUpdateOne { + return NewUserInfoClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the UserInfo entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (_m *UserInfo) Unwrap() *UserInfo { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("ent: UserInfo is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *UserInfo) String() string { + var builder strings.Builder + builder.WriteString("UserInfo(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("seq_no=") + builder.WriteString(fmt.Sprintf("%v", _m.SeqNo)) + builder.WriteString(", ") + builder.WriteString("email=") + builder.WriteString(_m.Email) + builder.WriteString(", ") + builder.WriteString("username=") + builder.WriteString(_m.Username) + builder.WriteString(", ") + builder.WriteString("password=") + builder.WriteString(", ") + builder.WriteString("gender=") + builder.WriteString(fmt.Sprintf("%v", _m.Gender)) + builder.WriteString(", ") + builder.WriteString("account=") + builder.WriteString(_m.Account) + builder.WriteString(", ") + builder.WriteString("create_time=") + builder.WriteString(_m.CreateTime.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("update_time=") + builder.WriteString(_m.UpdateTime.Format(time.ANSIC)) + builder.WriteString(", ") + if v := _m.LastLoginTime; v != nil { + builder.WriteString("last_login_time=") + builder.WriteString(v.Format(time.ANSIC)) + } + builder.WriteByte(')') + return builder.String() +} + +// UserInfos is a parsable slice of UserInfo. +type UserInfos []*UserInfo diff --git a/code/base-project/base-go-v3/ent/userinfo/userinfo.go b/code/base-project/base-go-v3/ent/userinfo/userinfo.go new file mode 100644 index 00000000..0aabbbce --- /dev/null +++ b/code/base-project/base-go-v3/ent/userinfo/userinfo.go @@ -0,0 +1,136 @@ +// Code generated by ent, DO NOT EDIT. + +package userinfo + +import ( + "time" + + "entgo.io/ent/dialect/sql" +) + +const ( + // Label holds the string label denoting the userinfo type in the database. + Label = "user_info" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldSeqNo holds the string denoting the seq_no field in the database. + FieldSeqNo = "seq_no" + // FieldEmail holds the string denoting the email field in the database. + FieldEmail = "email" + // FieldUsername holds the string denoting the username field in the database. + FieldUsername = "username" + // FieldPassword holds the string denoting the password field in the database. + FieldPassword = "password" + // FieldGender holds the string denoting the gender field in the database. + FieldGender = "gender" + // FieldAccount holds the string denoting the account field in the database. + FieldAccount = "account" + // FieldCreateTime holds the string denoting the create_time field in the database. + FieldCreateTime = "create_time" + // FieldUpdateTime holds the string denoting the update_time field in the database. + FieldUpdateTime = "update_time" + // FieldLastLoginTime holds the string denoting the last_login_time field in the database. + FieldLastLoginTime = "last_login_time" + // Table holds the table name of the userinfo in the database. + Table = "user_info" +) + +// Columns holds all SQL columns for userinfo fields. +var Columns = []string{ + FieldID, + FieldSeqNo, + FieldEmail, + FieldUsername, + FieldPassword, + FieldGender, + FieldAccount, + FieldCreateTime, + FieldUpdateTime, + FieldLastLoginTime, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // DefaultSeqNo holds the default value on creation for the "seq_no" field. + DefaultSeqNo int64 + // EmailValidator is a validator for the "email" field. It is called by the builders before save. + EmailValidator func(string) error + // UsernameValidator is a validator for the "username" field. It is called by the builders before save. + UsernameValidator func(string) error + // PasswordValidator is a validator for the "password" field. It is called by the builders before save. + PasswordValidator func(string) error + // DefaultGender holds the default value on creation for the "gender" field. + DefaultGender int64 + // AccountValidator is a validator for the "account" field. It is called by the builders before save. + AccountValidator func(string) error + // DefaultCreateTime holds the default value on creation for the "create_time" field. + DefaultCreateTime func() time.Time + // DefaultUpdateTime holds the default value on creation for the "update_time" field. + DefaultUpdateTime func() time.Time + // UpdateDefaultUpdateTime holds the default value on update for the "update_time" field. + UpdateDefaultUpdateTime func() time.Time + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() int64 +) + +// OrderOption defines the ordering options for the UserInfo queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// BySeqNo orders the results by the seq_no field. +func BySeqNo(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSeqNo, opts...).ToFunc() +} + +// ByEmail orders the results by the email field. +func ByEmail(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldEmail, opts...).ToFunc() +} + +// ByUsername orders the results by the username field. +func ByUsername(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUsername, opts...).ToFunc() +} + +// ByPassword orders the results by the password field. +func ByPassword(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPassword, opts...).ToFunc() +} + +// ByGender orders the results by the gender field. +func ByGender(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldGender, opts...).ToFunc() +} + +// ByAccount orders the results by the account field. +func ByAccount(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldAccount, opts...).ToFunc() +} + +// ByCreateTime orders the results by the create_time field. +func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateTime, opts...).ToFunc() +} + +// ByUpdateTime orders the results by the update_time field. +func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() +} + +// ByLastLoginTime orders the results by the last_login_time field. +func ByLastLoginTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLastLoginTime, opts...).ToFunc() +} diff --git a/code/base-project/base-go-v3/ent/userinfo/where.go b/code/base-project/base-go-v3/ent/userinfo/where.go new file mode 100644 index 00000000..1981e65e --- /dev/null +++ b/code/base-project/base-go-v3/ent/userinfo/where.go @@ -0,0 +1,585 @@ +// Code generated by ent, DO NOT EDIT. + +package userinfo + +import ( + "cn/oneao/base-go/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" +) + +// ID filters vertices based on their ID field. +func ID(id int64) predicate.UserInfo { + return predicate.UserInfo(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int64) predicate.UserInfo { + return predicate.UserInfo(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int64) predicate.UserInfo { + return predicate.UserInfo(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int64) predicate.UserInfo { + return predicate.UserInfo(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int64) predicate.UserInfo { + return predicate.UserInfo(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int64) predicate.UserInfo { + return predicate.UserInfo(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int64) predicate.UserInfo { + return predicate.UserInfo(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int64) predicate.UserInfo { + return predicate.UserInfo(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int64) predicate.UserInfo { + return predicate.UserInfo(sql.FieldLTE(FieldID, id)) +} + +// SeqNo applies equality check predicate on the "seq_no" field. It's identical to SeqNoEQ. +func SeqNo(v int64) predicate.UserInfo { + return predicate.UserInfo(sql.FieldEQ(FieldSeqNo, v)) +} + +// Email applies equality check predicate on the "email" field. It's identical to EmailEQ. +func Email(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldEQ(FieldEmail, v)) +} + +// Username applies equality check predicate on the "username" field. It's identical to UsernameEQ. +func Username(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldEQ(FieldUsername, v)) +} + +// Password applies equality check predicate on the "password" field. It's identical to PasswordEQ. +func Password(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldEQ(FieldPassword, v)) +} + +// Gender applies equality check predicate on the "gender" field. It's identical to GenderEQ. +func Gender(v int64) predicate.UserInfo { + return predicate.UserInfo(sql.FieldEQ(FieldGender, v)) +} + +// Account applies equality check predicate on the "account" field. It's identical to AccountEQ. +func Account(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldEQ(FieldAccount, v)) +} + +// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. +func CreateTime(v time.Time) predicate.UserInfo { + return predicate.UserInfo(sql.FieldEQ(FieldCreateTime, v)) +} + +// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. +func UpdateTime(v time.Time) predicate.UserInfo { + return predicate.UserInfo(sql.FieldEQ(FieldUpdateTime, v)) +} + +// LastLoginTime applies equality check predicate on the "last_login_time" field. It's identical to LastLoginTimeEQ. +func LastLoginTime(v time.Time) predicate.UserInfo { + return predicate.UserInfo(sql.FieldEQ(FieldLastLoginTime, v)) +} + +// SeqNoEQ applies the EQ predicate on the "seq_no" field. +func SeqNoEQ(v int64) predicate.UserInfo { + return predicate.UserInfo(sql.FieldEQ(FieldSeqNo, v)) +} + +// SeqNoNEQ applies the NEQ predicate on the "seq_no" field. +func SeqNoNEQ(v int64) predicate.UserInfo { + return predicate.UserInfo(sql.FieldNEQ(FieldSeqNo, v)) +} + +// SeqNoIn applies the In predicate on the "seq_no" field. +func SeqNoIn(vs ...int64) predicate.UserInfo { + return predicate.UserInfo(sql.FieldIn(FieldSeqNo, vs...)) +} + +// SeqNoNotIn applies the NotIn predicate on the "seq_no" field. +func SeqNoNotIn(vs ...int64) predicate.UserInfo { + return predicate.UserInfo(sql.FieldNotIn(FieldSeqNo, vs...)) +} + +// SeqNoGT applies the GT predicate on the "seq_no" field. +func SeqNoGT(v int64) predicate.UserInfo { + return predicate.UserInfo(sql.FieldGT(FieldSeqNo, v)) +} + +// SeqNoGTE applies the GTE predicate on the "seq_no" field. +func SeqNoGTE(v int64) predicate.UserInfo { + return predicate.UserInfo(sql.FieldGTE(FieldSeqNo, v)) +} + +// SeqNoLT applies the LT predicate on the "seq_no" field. +func SeqNoLT(v int64) predicate.UserInfo { + return predicate.UserInfo(sql.FieldLT(FieldSeqNo, v)) +} + +// SeqNoLTE applies the LTE predicate on the "seq_no" field. +func SeqNoLTE(v int64) predicate.UserInfo { + return predicate.UserInfo(sql.FieldLTE(FieldSeqNo, v)) +} + +// EmailEQ applies the EQ predicate on the "email" field. +func EmailEQ(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldEQ(FieldEmail, v)) +} + +// EmailNEQ applies the NEQ predicate on the "email" field. +func EmailNEQ(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldNEQ(FieldEmail, v)) +} + +// EmailIn applies the In predicate on the "email" field. +func EmailIn(vs ...string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldIn(FieldEmail, vs...)) +} + +// EmailNotIn applies the NotIn predicate on the "email" field. +func EmailNotIn(vs ...string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldNotIn(FieldEmail, vs...)) +} + +// EmailGT applies the GT predicate on the "email" field. +func EmailGT(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldGT(FieldEmail, v)) +} + +// EmailGTE applies the GTE predicate on the "email" field. +func EmailGTE(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldGTE(FieldEmail, v)) +} + +// EmailLT applies the LT predicate on the "email" field. +func EmailLT(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldLT(FieldEmail, v)) +} + +// EmailLTE applies the LTE predicate on the "email" field. +func EmailLTE(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldLTE(FieldEmail, v)) +} + +// EmailContains applies the Contains predicate on the "email" field. +func EmailContains(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldContains(FieldEmail, v)) +} + +// EmailHasPrefix applies the HasPrefix predicate on the "email" field. +func EmailHasPrefix(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldHasPrefix(FieldEmail, v)) +} + +// EmailHasSuffix applies the HasSuffix predicate on the "email" field. +func EmailHasSuffix(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldHasSuffix(FieldEmail, v)) +} + +// EmailEqualFold applies the EqualFold predicate on the "email" field. +func EmailEqualFold(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldEqualFold(FieldEmail, v)) +} + +// EmailContainsFold applies the ContainsFold predicate on the "email" field. +func EmailContainsFold(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldContainsFold(FieldEmail, v)) +} + +// UsernameEQ applies the EQ predicate on the "username" field. +func UsernameEQ(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldEQ(FieldUsername, v)) +} + +// UsernameNEQ applies the NEQ predicate on the "username" field. +func UsernameNEQ(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldNEQ(FieldUsername, v)) +} + +// UsernameIn applies the In predicate on the "username" field. +func UsernameIn(vs ...string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldIn(FieldUsername, vs...)) +} + +// UsernameNotIn applies the NotIn predicate on the "username" field. +func UsernameNotIn(vs ...string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldNotIn(FieldUsername, vs...)) +} + +// UsernameGT applies the GT predicate on the "username" field. +func UsernameGT(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldGT(FieldUsername, v)) +} + +// UsernameGTE applies the GTE predicate on the "username" field. +func UsernameGTE(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldGTE(FieldUsername, v)) +} + +// UsernameLT applies the LT predicate on the "username" field. +func UsernameLT(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldLT(FieldUsername, v)) +} + +// UsernameLTE applies the LTE predicate on the "username" field. +func UsernameLTE(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldLTE(FieldUsername, v)) +} + +// UsernameContains applies the Contains predicate on the "username" field. +func UsernameContains(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldContains(FieldUsername, v)) +} + +// UsernameHasPrefix applies the HasPrefix predicate on the "username" field. +func UsernameHasPrefix(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldHasPrefix(FieldUsername, v)) +} + +// UsernameHasSuffix applies the HasSuffix predicate on the "username" field. +func UsernameHasSuffix(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldHasSuffix(FieldUsername, v)) +} + +// UsernameEqualFold applies the EqualFold predicate on the "username" field. +func UsernameEqualFold(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldEqualFold(FieldUsername, v)) +} + +// UsernameContainsFold applies the ContainsFold predicate on the "username" field. +func UsernameContainsFold(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldContainsFold(FieldUsername, v)) +} + +// PasswordEQ applies the EQ predicate on the "password" field. +func PasswordEQ(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldEQ(FieldPassword, v)) +} + +// PasswordNEQ applies the NEQ predicate on the "password" field. +func PasswordNEQ(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldNEQ(FieldPassword, v)) +} + +// PasswordIn applies the In predicate on the "password" field. +func PasswordIn(vs ...string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldIn(FieldPassword, vs...)) +} + +// PasswordNotIn applies the NotIn predicate on the "password" field. +func PasswordNotIn(vs ...string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldNotIn(FieldPassword, vs...)) +} + +// PasswordGT applies the GT predicate on the "password" field. +func PasswordGT(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldGT(FieldPassword, v)) +} + +// PasswordGTE applies the GTE predicate on the "password" field. +func PasswordGTE(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldGTE(FieldPassword, v)) +} + +// PasswordLT applies the LT predicate on the "password" field. +func PasswordLT(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldLT(FieldPassword, v)) +} + +// PasswordLTE applies the LTE predicate on the "password" field. +func PasswordLTE(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldLTE(FieldPassword, v)) +} + +// PasswordContains applies the Contains predicate on the "password" field. +func PasswordContains(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldContains(FieldPassword, v)) +} + +// PasswordHasPrefix applies the HasPrefix predicate on the "password" field. +func PasswordHasPrefix(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldHasPrefix(FieldPassword, v)) +} + +// PasswordHasSuffix applies the HasSuffix predicate on the "password" field. +func PasswordHasSuffix(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldHasSuffix(FieldPassword, v)) +} + +// PasswordEqualFold applies the EqualFold predicate on the "password" field. +func PasswordEqualFold(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldEqualFold(FieldPassword, v)) +} + +// PasswordContainsFold applies the ContainsFold predicate on the "password" field. +func PasswordContainsFold(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldContainsFold(FieldPassword, v)) +} + +// GenderEQ applies the EQ predicate on the "gender" field. +func GenderEQ(v int64) predicate.UserInfo { + return predicate.UserInfo(sql.FieldEQ(FieldGender, v)) +} + +// GenderNEQ applies the NEQ predicate on the "gender" field. +func GenderNEQ(v int64) predicate.UserInfo { + return predicate.UserInfo(sql.FieldNEQ(FieldGender, v)) +} + +// GenderIn applies the In predicate on the "gender" field. +func GenderIn(vs ...int64) predicate.UserInfo { + return predicate.UserInfo(sql.FieldIn(FieldGender, vs...)) +} + +// GenderNotIn applies the NotIn predicate on the "gender" field. +func GenderNotIn(vs ...int64) predicate.UserInfo { + return predicate.UserInfo(sql.FieldNotIn(FieldGender, vs...)) +} + +// GenderGT applies the GT predicate on the "gender" field. +func GenderGT(v int64) predicate.UserInfo { + return predicate.UserInfo(sql.FieldGT(FieldGender, v)) +} + +// GenderGTE applies the GTE predicate on the "gender" field. +func GenderGTE(v int64) predicate.UserInfo { + return predicate.UserInfo(sql.FieldGTE(FieldGender, v)) +} + +// GenderLT applies the LT predicate on the "gender" field. +func GenderLT(v int64) predicate.UserInfo { + return predicate.UserInfo(sql.FieldLT(FieldGender, v)) +} + +// GenderLTE applies the LTE predicate on the "gender" field. +func GenderLTE(v int64) predicate.UserInfo { + return predicate.UserInfo(sql.FieldLTE(FieldGender, v)) +} + +// AccountEQ applies the EQ predicate on the "account" field. +func AccountEQ(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldEQ(FieldAccount, v)) +} + +// AccountNEQ applies the NEQ predicate on the "account" field. +func AccountNEQ(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldNEQ(FieldAccount, v)) +} + +// AccountIn applies the In predicate on the "account" field. +func AccountIn(vs ...string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldIn(FieldAccount, vs...)) +} + +// AccountNotIn applies the NotIn predicate on the "account" field. +func AccountNotIn(vs ...string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldNotIn(FieldAccount, vs...)) +} + +// AccountGT applies the GT predicate on the "account" field. +func AccountGT(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldGT(FieldAccount, v)) +} + +// AccountGTE applies the GTE predicate on the "account" field. +func AccountGTE(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldGTE(FieldAccount, v)) +} + +// AccountLT applies the LT predicate on the "account" field. +func AccountLT(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldLT(FieldAccount, v)) +} + +// AccountLTE applies the LTE predicate on the "account" field. +func AccountLTE(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldLTE(FieldAccount, v)) +} + +// AccountContains applies the Contains predicate on the "account" field. +func AccountContains(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldContains(FieldAccount, v)) +} + +// AccountHasPrefix applies the HasPrefix predicate on the "account" field. +func AccountHasPrefix(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldHasPrefix(FieldAccount, v)) +} + +// AccountHasSuffix applies the HasSuffix predicate on the "account" field. +func AccountHasSuffix(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldHasSuffix(FieldAccount, v)) +} + +// AccountEqualFold applies the EqualFold predicate on the "account" field. +func AccountEqualFold(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldEqualFold(FieldAccount, v)) +} + +// AccountContainsFold applies the ContainsFold predicate on the "account" field. +func AccountContainsFold(v string) predicate.UserInfo { + return predicate.UserInfo(sql.FieldContainsFold(FieldAccount, v)) +} + +// CreateTimeEQ applies the EQ predicate on the "create_time" field. +func CreateTimeEQ(v time.Time) predicate.UserInfo { + return predicate.UserInfo(sql.FieldEQ(FieldCreateTime, v)) +} + +// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. +func CreateTimeNEQ(v time.Time) predicate.UserInfo { + return predicate.UserInfo(sql.FieldNEQ(FieldCreateTime, v)) +} + +// CreateTimeIn applies the In predicate on the "create_time" field. +func CreateTimeIn(vs ...time.Time) predicate.UserInfo { + return predicate.UserInfo(sql.FieldIn(FieldCreateTime, vs...)) +} + +// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. +func CreateTimeNotIn(vs ...time.Time) predicate.UserInfo { + return predicate.UserInfo(sql.FieldNotIn(FieldCreateTime, vs...)) +} + +// CreateTimeGT applies the GT predicate on the "create_time" field. +func CreateTimeGT(v time.Time) predicate.UserInfo { + return predicate.UserInfo(sql.FieldGT(FieldCreateTime, v)) +} + +// CreateTimeGTE applies the GTE predicate on the "create_time" field. +func CreateTimeGTE(v time.Time) predicate.UserInfo { + return predicate.UserInfo(sql.FieldGTE(FieldCreateTime, v)) +} + +// CreateTimeLT applies the LT predicate on the "create_time" field. +func CreateTimeLT(v time.Time) predicate.UserInfo { + return predicate.UserInfo(sql.FieldLT(FieldCreateTime, v)) +} + +// CreateTimeLTE applies the LTE predicate on the "create_time" field. +func CreateTimeLTE(v time.Time) predicate.UserInfo { + return predicate.UserInfo(sql.FieldLTE(FieldCreateTime, v)) +} + +// UpdateTimeEQ applies the EQ predicate on the "update_time" field. +func UpdateTimeEQ(v time.Time) predicate.UserInfo { + return predicate.UserInfo(sql.FieldEQ(FieldUpdateTime, v)) +} + +// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. +func UpdateTimeNEQ(v time.Time) predicate.UserInfo { + return predicate.UserInfo(sql.FieldNEQ(FieldUpdateTime, v)) +} + +// UpdateTimeIn applies the In predicate on the "update_time" field. +func UpdateTimeIn(vs ...time.Time) predicate.UserInfo { + return predicate.UserInfo(sql.FieldIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. +func UpdateTimeNotIn(vs ...time.Time) predicate.UserInfo { + return predicate.UserInfo(sql.FieldNotIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeGT applies the GT predicate on the "update_time" field. +func UpdateTimeGT(v time.Time) predicate.UserInfo { + return predicate.UserInfo(sql.FieldGT(FieldUpdateTime, v)) +} + +// UpdateTimeGTE applies the GTE predicate on the "update_time" field. +func UpdateTimeGTE(v time.Time) predicate.UserInfo { + return predicate.UserInfo(sql.FieldGTE(FieldUpdateTime, v)) +} + +// UpdateTimeLT applies the LT predicate on the "update_time" field. +func UpdateTimeLT(v time.Time) predicate.UserInfo { + return predicate.UserInfo(sql.FieldLT(FieldUpdateTime, v)) +} + +// UpdateTimeLTE applies the LTE predicate on the "update_time" field. +func UpdateTimeLTE(v time.Time) predicate.UserInfo { + return predicate.UserInfo(sql.FieldLTE(FieldUpdateTime, v)) +} + +// LastLoginTimeEQ applies the EQ predicate on the "last_login_time" field. +func LastLoginTimeEQ(v time.Time) predicate.UserInfo { + return predicate.UserInfo(sql.FieldEQ(FieldLastLoginTime, v)) +} + +// LastLoginTimeNEQ applies the NEQ predicate on the "last_login_time" field. +func LastLoginTimeNEQ(v time.Time) predicate.UserInfo { + return predicate.UserInfo(sql.FieldNEQ(FieldLastLoginTime, v)) +} + +// LastLoginTimeIn applies the In predicate on the "last_login_time" field. +func LastLoginTimeIn(vs ...time.Time) predicate.UserInfo { + return predicate.UserInfo(sql.FieldIn(FieldLastLoginTime, vs...)) +} + +// LastLoginTimeNotIn applies the NotIn predicate on the "last_login_time" field. +func LastLoginTimeNotIn(vs ...time.Time) predicate.UserInfo { + return predicate.UserInfo(sql.FieldNotIn(FieldLastLoginTime, vs...)) +} + +// LastLoginTimeGT applies the GT predicate on the "last_login_time" field. +func LastLoginTimeGT(v time.Time) predicate.UserInfo { + return predicate.UserInfo(sql.FieldGT(FieldLastLoginTime, v)) +} + +// LastLoginTimeGTE applies the GTE predicate on the "last_login_time" field. +func LastLoginTimeGTE(v time.Time) predicate.UserInfo { + return predicate.UserInfo(sql.FieldGTE(FieldLastLoginTime, v)) +} + +// LastLoginTimeLT applies the LT predicate on the "last_login_time" field. +func LastLoginTimeLT(v time.Time) predicate.UserInfo { + return predicate.UserInfo(sql.FieldLT(FieldLastLoginTime, v)) +} + +// LastLoginTimeLTE applies the LTE predicate on the "last_login_time" field. +func LastLoginTimeLTE(v time.Time) predicate.UserInfo { + return predicate.UserInfo(sql.FieldLTE(FieldLastLoginTime, v)) +} + +// LastLoginTimeIsNil applies the IsNil predicate on the "last_login_time" field. +func LastLoginTimeIsNil() predicate.UserInfo { + return predicate.UserInfo(sql.FieldIsNull(FieldLastLoginTime)) +} + +// LastLoginTimeNotNil applies the NotNil predicate on the "last_login_time" field. +func LastLoginTimeNotNil() predicate.UserInfo { + return predicate.UserInfo(sql.FieldNotNull(FieldLastLoginTime)) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.UserInfo) predicate.UserInfo { + return predicate.UserInfo(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.UserInfo) predicate.UserInfo { + return predicate.UserInfo(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.UserInfo) predicate.UserInfo { + return predicate.UserInfo(sql.NotPredicates(p)) +} diff --git a/code/base-project/base-go-v3/ent/userinfo_create.go b/code/base-project/base-go-v3/ent/userinfo_create.go new file mode 100644 index 00000000..2439c31b --- /dev/null +++ b/code/base-project/base-go-v3/ent/userinfo_create.go @@ -0,0 +1,391 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "cn/oneao/base-go/ent/userinfo" + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// UserInfoCreate is the builder for creating a UserInfo entity. +type UserInfoCreate struct { + config + mutation *UserInfoMutation + hooks []Hook +} + +// SetSeqNo sets the "seq_no" field. +func (_c *UserInfoCreate) SetSeqNo(v int64) *UserInfoCreate { + _c.mutation.SetSeqNo(v) + return _c +} + +// SetNillableSeqNo sets the "seq_no" field if the given value is not nil. +func (_c *UserInfoCreate) SetNillableSeqNo(v *int64) *UserInfoCreate { + if v != nil { + _c.SetSeqNo(*v) + } + return _c +} + +// SetEmail sets the "email" field. +func (_c *UserInfoCreate) SetEmail(v string) *UserInfoCreate { + _c.mutation.SetEmail(v) + return _c +} + +// SetUsername sets the "username" field. +func (_c *UserInfoCreate) SetUsername(v string) *UserInfoCreate { + _c.mutation.SetUsername(v) + return _c +} + +// SetPassword sets the "password" field. +func (_c *UserInfoCreate) SetPassword(v string) *UserInfoCreate { + _c.mutation.SetPassword(v) + return _c +} + +// SetGender sets the "gender" field. +func (_c *UserInfoCreate) SetGender(v int64) *UserInfoCreate { + _c.mutation.SetGender(v) + return _c +} + +// SetNillableGender sets the "gender" field if the given value is not nil. +func (_c *UserInfoCreate) SetNillableGender(v *int64) *UserInfoCreate { + if v != nil { + _c.SetGender(*v) + } + return _c +} + +// SetAccount sets the "account" field. +func (_c *UserInfoCreate) SetAccount(v string) *UserInfoCreate { + _c.mutation.SetAccount(v) + return _c +} + +// SetCreateTime sets the "create_time" field. +func (_c *UserInfoCreate) SetCreateTime(v time.Time) *UserInfoCreate { + _c.mutation.SetCreateTime(v) + return _c +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (_c *UserInfoCreate) SetNillableCreateTime(v *time.Time) *UserInfoCreate { + if v != nil { + _c.SetCreateTime(*v) + } + return _c +} + +// SetUpdateTime sets the "update_time" field. +func (_c *UserInfoCreate) SetUpdateTime(v time.Time) *UserInfoCreate { + _c.mutation.SetUpdateTime(v) + return _c +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (_c *UserInfoCreate) SetNillableUpdateTime(v *time.Time) *UserInfoCreate { + if v != nil { + _c.SetUpdateTime(*v) + } + return _c +} + +// SetLastLoginTime sets the "last_login_time" field. +func (_c *UserInfoCreate) SetLastLoginTime(v time.Time) *UserInfoCreate { + _c.mutation.SetLastLoginTime(v) + return _c +} + +// SetNillableLastLoginTime sets the "last_login_time" field if the given value is not nil. +func (_c *UserInfoCreate) SetNillableLastLoginTime(v *time.Time) *UserInfoCreate { + if v != nil { + _c.SetLastLoginTime(*v) + } + return _c +} + +// SetID sets the "id" field. +func (_c *UserInfoCreate) SetID(v int64) *UserInfoCreate { + _c.mutation.SetID(v) + return _c +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (_c *UserInfoCreate) SetNillableID(v *int64) *UserInfoCreate { + if v != nil { + _c.SetID(*v) + } + return _c +} + +// Mutation returns the UserInfoMutation object of the builder. +func (_c *UserInfoCreate) Mutation() *UserInfoMutation { + return _c.mutation +} + +// Save creates the UserInfo in the database. +func (_c *UserInfoCreate) Save(ctx context.Context) (*UserInfo, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *UserInfoCreate) SaveX(ctx context.Context) *UserInfo { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *UserInfoCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *UserInfoCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_c *UserInfoCreate) defaults() { + if _, ok := _c.mutation.SeqNo(); !ok { + v := userinfo.DefaultSeqNo + _c.mutation.SetSeqNo(v) + } + if _, ok := _c.mutation.Gender(); !ok { + v := userinfo.DefaultGender + _c.mutation.SetGender(v) + } + if _, ok := _c.mutation.CreateTime(); !ok { + v := userinfo.DefaultCreateTime() + _c.mutation.SetCreateTime(v) + } + if _, ok := _c.mutation.UpdateTime(); !ok { + v := userinfo.DefaultUpdateTime() + _c.mutation.SetUpdateTime(v) + } + if _, ok := _c.mutation.ID(); !ok { + v := userinfo.DefaultID() + _c.mutation.SetID(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *UserInfoCreate) check() error { + if _, ok := _c.mutation.SeqNo(); !ok { + return &ValidationError{Name: "seq_no", err: errors.New(`ent: missing required field "UserInfo.seq_no"`)} + } + if _, ok := _c.mutation.Email(); !ok { + return &ValidationError{Name: "email", err: errors.New(`ent: missing required field "UserInfo.email"`)} + } + if v, ok := _c.mutation.Email(); ok { + if err := userinfo.EmailValidator(v); err != nil { + return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "UserInfo.email": %w`, err)} + } + } + if _, ok := _c.mutation.Username(); !ok { + return &ValidationError{Name: "username", err: errors.New(`ent: missing required field "UserInfo.username"`)} + } + if v, ok := _c.mutation.Username(); ok { + if err := userinfo.UsernameValidator(v); err != nil { + return &ValidationError{Name: "username", err: fmt.Errorf(`ent: validator failed for field "UserInfo.username": %w`, err)} + } + } + if _, ok := _c.mutation.Password(); !ok { + return &ValidationError{Name: "password", err: errors.New(`ent: missing required field "UserInfo.password"`)} + } + if v, ok := _c.mutation.Password(); ok { + if err := userinfo.PasswordValidator(v); err != nil { + return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "UserInfo.password": %w`, err)} + } + } + if _, ok := _c.mutation.Gender(); !ok { + return &ValidationError{Name: "gender", err: errors.New(`ent: missing required field "UserInfo.gender"`)} + } + if _, ok := _c.mutation.Account(); !ok { + return &ValidationError{Name: "account", err: errors.New(`ent: missing required field "UserInfo.account"`)} + } + if v, ok := _c.mutation.Account(); ok { + if err := userinfo.AccountValidator(v); err != nil { + return &ValidationError{Name: "account", err: fmt.Errorf(`ent: validator failed for field "UserInfo.account": %w`, err)} + } + } + if _, ok := _c.mutation.CreateTime(); !ok { + return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "UserInfo.create_time"`)} + } + if _, ok := _c.mutation.UpdateTime(); !ok { + return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "UserInfo.update_time"`)} + } + return nil +} + +func (_c *UserInfoCreate) sqlSave(ctx context.Context) (*UserInfo, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != _node.ID { + id := _spec.ID.Value.(int64) + _node.ID = int64(id) + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *UserInfoCreate) createSpec() (*UserInfo, *sqlgraph.CreateSpec) { + var ( + _node = &UserInfo{config: _c.config} + _spec = sqlgraph.NewCreateSpec(userinfo.Table, sqlgraph.NewFieldSpec(userinfo.FieldID, field.TypeInt64)) + ) + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := _c.mutation.SeqNo(); ok { + _spec.SetField(userinfo.FieldSeqNo, field.TypeInt64, value) + _node.SeqNo = value + } + if value, ok := _c.mutation.Email(); ok { + _spec.SetField(userinfo.FieldEmail, field.TypeString, value) + _node.Email = value + } + if value, ok := _c.mutation.Username(); ok { + _spec.SetField(userinfo.FieldUsername, field.TypeString, value) + _node.Username = value + } + if value, ok := _c.mutation.Password(); ok { + _spec.SetField(userinfo.FieldPassword, field.TypeString, value) + _node.Password = value + } + if value, ok := _c.mutation.Gender(); ok { + _spec.SetField(userinfo.FieldGender, field.TypeInt64, value) + _node.Gender = value + } + if value, ok := _c.mutation.Account(); ok { + _spec.SetField(userinfo.FieldAccount, field.TypeString, value) + _node.Account = value + } + if value, ok := _c.mutation.CreateTime(); ok { + _spec.SetField(userinfo.FieldCreateTime, field.TypeTime, value) + _node.CreateTime = value + } + if value, ok := _c.mutation.UpdateTime(); ok { + _spec.SetField(userinfo.FieldUpdateTime, field.TypeTime, value) + _node.UpdateTime = value + } + if value, ok := _c.mutation.LastLoginTime(); ok { + _spec.SetField(userinfo.FieldLastLoginTime, field.TypeTime, value) + _node.LastLoginTime = &value + } + return _node, _spec +} + +// UserInfoCreateBulk is the builder for creating many UserInfo entities in bulk. +type UserInfoCreateBulk struct { + config + err error + builders []*UserInfoCreate +} + +// Save creates the UserInfo entities in the database. +func (_c *UserInfoCreateBulk) Save(ctx context.Context) ([]*UserInfo, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*UserInfo, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*UserInfoMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil && nodes[i].ID == 0 { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int64(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *UserInfoCreateBulk) SaveX(ctx context.Context) []*UserInfo { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *UserInfoCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *UserInfoCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/code/base-project/base-go-v3/ent/userinfo_delete.go b/code/base-project/base-go-v3/ent/userinfo_delete.go new file mode 100644 index 00000000..4347e32f --- /dev/null +++ b/code/base-project/base-go-v3/ent/userinfo_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "cn/oneao/base-go/ent/predicate" + "cn/oneao/base-go/ent/userinfo" + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// UserInfoDelete is the builder for deleting a UserInfo entity. +type UserInfoDelete struct { + config + hooks []Hook + mutation *UserInfoMutation +} + +// Where appends a list predicates to the UserInfoDelete builder. +func (_d *UserInfoDelete) Where(ps ...predicate.UserInfo) *UserInfoDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *UserInfoDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *UserInfoDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *UserInfoDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(userinfo.Table, sqlgraph.NewFieldSpec(userinfo.FieldID, field.TypeInt64)) + if ps := _d.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + _d.mutation.done = true + return affected, err +} + +// UserInfoDeleteOne is the builder for deleting a single UserInfo entity. +type UserInfoDeleteOne struct { + _d *UserInfoDelete +} + +// Where appends a list predicates to the UserInfoDelete builder. +func (_d *UserInfoDeleteOne) Where(ps ...predicate.UserInfo) *UserInfoDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *UserInfoDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{userinfo.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *UserInfoDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/code/base-project/base-go-v3/ent/userinfo_query.go b/code/base-project/base-go-v3/ent/userinfo_query.go new file mode 100644 index 00000000..53a365e4 --- /dev/null +++ b/code/base-project/base-go-v3/ent/userinfo_query.go @@ -0,0 +1,527 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "cn/oneao/base-go/ent/predicate" + "cn/oneao/base-go/ent/userinfo" + "context" + "fmt" + "math" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// UserInfoQuery is the builder for querying UserInfo entities. +type UserInfoQuery struct { + config + ctx *QueryContext + order []userinfo.OrderOption + inters []Interceptor + predicates []predicate.UserInfo + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the UserInfoQuery builder. +func (_q *UserInfoQuery) Where(ps ...predicate.UserInfo) *UserInfoQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *UserInfoQuery) Limit(limit int) *UserInfoQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *UserInfoQuery) Offset(offset int) *UserInfoQuery { + _q.ctx.Offset = &offset + return _q +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (_q *UserInfoQuery) Unique(unique bool) *UserInfoQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *UserInfoQuery) Order(o ...userinfo.OrderOption) *UserInfoQuery { + _q.order = append(_q.order, o...) + return _q +} + +// First returns the first UserInfo entity from the query. +// Returns a *NotFoundError when no UserInfo was found. +func (_q *UserInfoQuery) First(ctx context.Context) (*UserInfo, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{userinfo.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *UserInfoQuery) FirstX(ctx context.Context) *UserInfo { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first UserInfo ID from the query. +// Returns a *NotFoundError when no UserInfo ID was found. +func (_q *UserInfoQuery) FirstID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{userinfo.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *UserInfoQuery) FirstIDX(ctx context.Context) int64 { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single UserInfo entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one UserInfo entity is found. +// Returns a *NotFoundError when no UserInfo entities are found. +func (_q *UserInfoQuery) Only(ctx context.Context) (*UserInfo, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{userinfo.Label} + default: + return nil, &NotSingularError{userinfo.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *UserInfoQuery) OnlyX(ctx context.Context) *UserInfo { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only UserInfo ID in the query. +// Returns a *NotSingularError when more than one UserInfo ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *UserInfoQuery) OnlyID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{userinfo.Label} + default: + err = &NotSingularError{userinfo.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *UserInfoQuery) OnlyIDX(ctx context.Context) int64 { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of UserInfos. +func (_q *UserInfoQuery) All(ctx context.Context) ([]*UserInfo, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*UserInfo, *UserInfoQuery]() + return withInterceptors[[]*UserInfo](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *UserInfoQuery) AllX(ctx context.Context) []*UserInfo { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of UserInfo IDs. +func (_q *UserInfoQuery) IDs(ctx context.Context) (ids []int64, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(userinfo.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *UserInfoQuery) IDsX(ctx context.Context) []int64 { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *UserInfoQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, _q, querierCount[*UserInfoQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *UserInfoQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (_q *UserInfoQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *UserInfoQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the UserInfoQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (_q *UserInfoQuery) Clone() *UserInfoQuery { + if _q == nil { + return nil + } + return &UserInfoQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]userinfo.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.UserInfo{}, _q.predicates...), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + } +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// SeqNo int64 `json:"seq_no,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.UserInfo.Query(). +// GroupBy(userinfo.FieldSeqNo). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *UserInfoQuery) GroupBy(field string, fields ...string) *UserInfoGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &UserInfoGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = userinfo.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// SeqNo int64 `json:"seq_no,omitempty"` +// } +// +// client.UserInfo.Query(). +// Select(userinfo.FieldSeqNo). +// Scan(ctx, &v) +func (_q *UserInfoQuery) Select(fields ...string) *UserInfoSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &UserInfoSelect{UserInfoQuery: _q} + sbuild.label = userinfo.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a UserInfoSelect configured with the given aggregations. +func (_q *UserInfoQuery) Aggregate(fns ...AggregateFunc) *UserInfoSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *UserInfoQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !userinfo.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if _q.path != nil { + prev, err := _q.path(ctx) + if err != nil { + return err + } + _q.sql = prev + } + return nil +} + +func (_q *UserInfoQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*UserInfo, error) { + var ( + nodes = []*UserInfo{} + _spec = _q.querySpec() + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*UserInfo).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &UserInfo{config: _q.config} + nodes = append(nodes, node) + return node.assignValues(columns, values) + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + return nodes, nil +} + +func (_q *UserInfoQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique + } + return sqlgraph.CountNodes(ctx, _q.driver, _spec) +} + +func (_q *UserInfoQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(userinfo.Table, userinfo.Columns, sqlgraph.NewFieldSpec(userinfo.FieldID, field.TypeInt64)) + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if _q.path != nil { + _spec.Unique = true + } + if fields := _q.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, userinfo.FieldID) + for i := range fields { + if fields[i] != userinfo.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := _q.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := _q.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := _q.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := _q.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (_q *UserInfoQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(userinfo.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = userinfo.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if _q.sql != nil { + selector = _q.sql + selector.Select(selector.Columns(columns...)...) + } + if _q.ctx.Unique != nil && *_q.ctx.Unique { + selector.Distinct() + } + for _, p := range _q.predicates { + p(selector) + } + for _, p := range _q.order { + p(selector) + } + if offset := _q.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := _q.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// UserInfoGroupBy is the group-by builder for UserInfo entities. +type UserInfoGroupBy struct { + selector + build *UserInfoQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *UserInfoGroupBy) Aggregate(fns ...AggregateFunc) *UserInfoGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *UserInfoGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*UserInfoQuery, *UserInfoGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *UserInfoGroupBy) sqlScan(ctx context.Context, root *UserInfoQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*_g.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// UserInfoSelect is the builder for selecting fields of UserInfo entities. +type UserInfoSelect struct { + *UserInfoQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *UserInfoSelect) Aggregate(fns ...AggregateFunc) *UserInfoSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *UserInfoSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*UserInfoQuery, *UserInfoSelect](ctx, _s.UserInfoQuery, _s, _s.inters, v) +} + +func (_s *UserInfoSelect) sqlScan(ctx context.Context, root *UserInfoQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/code/base-project/base-go-v3/ent/userinfo_update.go b/code/base-project/base-go-v3/ent/userinfo_update.go new file mode 100644 index 00000000..7874d5d8 --- /dev/null +++ b/code/base-project/base-go-v3/ent/userinfo_update.go @@ -0,0 +1,564 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "cn/oneao/base-go/ent/predicate" + "cn/oneao/base-go/ent/userinfo" + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// UserInfoUpdate is the builder for updating UserInfo entities. +type UserInfoUpdate struct { + config + hooks []Hook + mutation *UserInfoMutation +} + +// Where appends a list predicates to the UserInfoUpdate builder. +func (_u *UserInfoUpdate) Where(ps ...predicate.UserInfo) *UserInfoUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetSeqNo sets the "seq_no" field. +func (_u *UserInfoUpdate) SetSeqNo(v int64) *UserInfoUpdate { + _u.mutation.ResetSeqNo() + _u.mutation.SetSeqNo(v) + return _u +} + +// SetNillableSeqNo sets the "seq_no" field if the given value is not nil. +func (_u *UserInfoUpdate) SetNillableSeqNo(v *int64) *UserInfoUpdate { + if v != nil { + _u.SetSeqNo(*v) + } + return _u +} + +// AddSeqNo adds value to the "seq_no" field. +func (_u *UserInfoUpdate) AddSeqNo(v int64) *UserInfoUpdate { + _u.mutation.AddSeqNo(v) + return _u +} + +// SetEmail sets the "email" field. +func (_u *UserInfoUpdate) SetEmail(v string) *UserInfoUpdate { + _u.mutation.SetEmail(v) + return _u +} + +// SetNillableEmail sets the "email" field if the given value is not nil. +func (_u *UserInfoUpdate) SetNillableEmail(v *string) *UserInfoUpdate { + if v != nil { + _u.SetEmail(*v) + } + return _u +} + +// SetUsername sets the "username" field. +func (_u *UserInfoUpdate) SetUsername(v string) *UserInfoUpdate { + _u.mutation.SetUsername(v) + return _u +} + +// SetNillableUsername sets the "username" field if the given value is not nil. +func (_u *UserInfoUpdate) SetNillableUsername(v *string) *UserInfoUpdate { + if v != nil { + _u.SetUsername(*v) + } + return _u +} + +// SetPassword sets the "password" field. +func (_u *UserInfoUpdate) SetPassword(v string) *UserInfoUpdate { + _u.mutation.SetPassword(v) + return _u +} + +// SetNillablePassword sets the "password" field if the given value is not nil. +func (_u *UserInfoUpdate) SetNillablePassword(v *string) *UserInfoUpdate { + if v != nil { + _u.SetPassword(*v) + } + return _u +} + +// SetGender sets the "gender" field. +func (_u *UserInfoUpdate) SetGender(v int64) *UserInfoUpdate { + _u.mutation.ResetGender() + _u.mutation.SetGender(v) + return _u +} + +// SetNillableGender sets the "gender" field if the given value is not nil. +func (_u *UserInfoUpdate) SetNillableGender(v *int64) *UserInfoUpdate { + if v != nil { + _u.SetGender(*v) + } + return _u +} + +// AddGender adds value to the "gender" field. +func (_u *UserInfoUpdate) AddGender(v int64) *UserInfoUpdate { + _u.mutation.AddGender(v) + return _u +} + +// SetAccount sets the "account" field. +func (_u *UserInfoUpdate) SetAccount(v string) *UserInfoUpdate { + _u.mutation.SetAccount(v) + return _u +} + +// SetNillableAccount sets the "account" field if the given value is not nil. +func (_u *UserInfoUpdate) SetNillableAccount(v *string) *UserInfoUpdate { + if v != nil { + _u.SetAccount(*v) + } + return _u +} + +// SetUpdateTime sets the "update_time" field. +func (_u *UserInfoUpdate) SetUpdateTime(v time.Time) *UserInfoUpdate { + _u.mutation.SetUpdateTime(v) + return _u +} + +// SetLastLoginTime sets the "last_login_time" field. +func (_u *UserInfoUpdate) SetLastLoginTime(v time.Time) *UserInfoUpdate { + _u.mutation.SetLastLoginTime(v) + return _u +} + +// SetNillableLastLoginTime sets the "last_login_time" field if the given value is not nil. +func (_u *UserInfoUpdate) SetNillableLastLoginTime(v *time.Time) *UserInfoUpdate { + if v != nil { + _u.SetLastLoginTime(*v) + } + return _u +} + +// ClearLastLoginTime clears the value of the "last_login_time" field. +func (_u *UserInfoUpdate) ClearLastLoginTime() *UserInfoUpdate { + _u.mutation.ClearLastLoginTime() + return _u +} + +// Mutation returns the UserInfoMutation object of the builder. +func (_u *UserInfoUpdate) Mutation() *UserInfoMutation { + return _u.mutation +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *UserInfoUpdate) Save(ctx context.Context) (int, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *UserInfoUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *UserInfoUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *UserInfoUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *UserInfoUpdate) defaults() { + if _, ok := _u.mutation.UpdateTime(); !ok { + v := userinfo.UpdateDefaultUpdateTime() + _u.mutation.SetUpdateTime(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *UserInfoUpdate) check() error { + if v, ok := _u.mutation.Email(); ok { + if err := userinfo.EmailValidator(v); err != nil { + return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "UserInfo.email": %w`, err)} + } + } + if v, ok := _u.mutation.Username(); ok { + if err := userinfo.UsernameValidator(v); err != nil { + return &ValidationError{Name: "username", err: fmt.Errorf(`ent: validator failed for field "UserInfo.username": %w`, err)} + } + } + if v, ok := _u.mutation.Password(); ok { + if err := userinfo.PasswordValidator(v); err != nil { + return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "UserInfo.password": %w`, err)} + } + } + if v, ok := _u.mutation.Account(); ok { + if err := userinfo.AccountValidator(v); err != nil { + return &ValidationError{Name: "account", err: fmt.Errorf(`ent: validator failed for field "UserInfo.account": %w`, err)} + } + } + return nil +} + +func (_u *UserInfoUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(userinfo.Table, userinfo.Columns, sqlgraph.NewFieldSpec(userinfo.FieldID, field.TypeInt64)) + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.SeqNo(); ok { + _spec.SetField(userinfo.FieldSeqNo, field.TypeInt64, value) + } + if value, ok := _u.mutation.AddedSeqNo(); ok { + _spec.AddField(userinfo.FieldSeqNo, field.TypeInt64, value) + } + if value, ok := _u.mutation.Email(); ok { + _spec.SetField(userinfo.FieldEmail, field.TypeString, value) + } + if value, ok := _u.mutation.Username(); ok { + _spec.SetField(userinfo.FieldUsername, field.TypeString, value) + } + if value, ok := _u.mutation.Password(); ok { + _spec.SetField(userinfo.FieldPassword, field.TypeString, value) + } + if value, ok := _u.mutation.Gender(); ok { + _spec.SetField(userinfo.FieldGender, field.TypeInt64, value) + } + if value, ok := _u.mutation.AddedGender(); ok { + _spec.AddField(userinfo.FieldGender, field.TypeInt64, value) + } + if value, ok := _u.mutation.Account(); ok { + _spec.SetField(userinfo.FieldAccount, field.TypeString, value) + } + if value, ok := _u.mutation.UpdateTime(); ok { + _spec.SetField(userinfo.FieldUpdateTime, field.TypeTime, value) + } + if value, ok := _u.mutation.LastLoginTime(); ok { + _spec.SetField(userinfo.FieldLastLoginTime, field.TypeTime, value) + } + if _u.mutation.LastLoginTimeCleared() { + _spec.ClearField(userinfo.FieldLastLoginTime, field.TypeTime) + } + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{userinfo.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// UserInfoUpdateOne is the builder for updating a single UserInfo entity. +type UserInfoUpdateOne struct { + config + fields []string + hooks []Hook + mutation *UserInfoMutation +} + +// SetSeqNo sets the "seq_no" field. +func (_u *UserInfoUpdateOne) SetSeqNo(v int64) *UserInfoUpdateOne { + _u.mutation.ResetSeqNo() + _u.mutation.SetSeqNo(v) + return _u +} + +// SetNillableSeqNo sets the "seq_no" field if the given value is not nil. +func (_u *UserInfoUpdateOne) SetNillableSeqNo(v *int64) *UserInfoUpdateOne { + if v != nil { + _u.SetSeqNo(*v) + } + return _u +} + +// AddSeqNo adds value to the "seq_no" field. +func (_u *UserInfoUpdateOne) AddSeqNo(v int64) *UserInfoUpdateOne { + _u.mutation.AddSeqNo(v) + return _u +} + +// SetEmail sets the "email" field. +func (_u *UserInfoUpdateOne) SetEmail(v string) *UserInfoUpdateOne { + _u.mutation.SetEmail(v) + return _u +} + +// SetNillableEmail sets the "email" field if the given value is not nil. +func (_u *UserInfoUpdateOne) SetNillableEmail(v *string) *UserInfoUpdateOne { + if v != nil { + _u.SetEmail(*v) + } + return _u +} + +// SetUsername sets the "username" field. +func (_u *UserInfoUpdateOne) SetUsername(v string) *UserInfoUpdateOne { + _u.mutation.SetUsername(v) + return _u +} + +// SetNillableUsername sets the "username" field if the given value is not nil. +func (_u *UserInfoUpdateOne) SetNillableUsername(v *string) *UserInfoUpdateOne { + if v != nil { + _u.SetUsername(*v) + } + return _u +} + +// SetPassword sets the "password" field. +func (_u *UserInfoUpdateOne) SetPassword(v string) *UserInfoUpdateOne { + _u.mutation.SetPassword(v) + return _u +} + +// SetNillablePassword sets the "password" field if the given value is not nil. +func (_u *UserInfoUpdateOne) SetNillablePassword(v *string) *UserInfoUpdateOne { + if v != nil { + _u.SetPassword(*v) + } + return _u +} + +// SetGender sets the "gender" field. +func (_u *UserInfoUpdateOne) SetGender(v int64) *UserInfoUpdateOne { + _u.mutation.ResetGender() + _u.mutation.SetGender(v) + return _u +} + +// SetNillableGender sets the "gender" field if the given value is not nil. +func (_u *UserInfoUpdateOne) SetNillableGender(v *int64) *UserInfoUpdateOne { + if v != nil { + _u.SetGender(*v) + } + return _u +} + +// AddGender adds value to the "gender" field. +func (_u *UserInfoUpdateOne) AddGender(v int64) *UserInfoUpdateOne { + _u.mutation.AddGender(v) + return _u +} + +// SetAccount sets the "account" field. +func (_u *UserInfoUpdateOne) SetAccount(v string) *UserInfoUpdateOne { + _u.mutation.SetAccount(v) + return _u +} + +// SetNillableAccount sets the "account" field if the given value is not nil. +func (_u *UserInfoUpdateOne) SetNillableAccount(v *string) *UserInfoUpdateOne { + if v != nil { + _u.SetAccount(*v) + } + return _u +} + +// SetUpdateTime sets the "update_time" field. +func (_u *UserInfoUpdateOne) SetUpdateTime(v time.Time) *UserInfoUpdateOne { + _u.mutation.SetUpdateTime(v) + return _u +} + +// SetLastLoginTime sets the "last_login_time" field. +func (_u *UserInfoUpdateOne) SetLastLoginTime(v time.Time) *UserInfoUpdateOne { + _u.mutation.SetLastLoginTime(v) + return _u +} + +// SetNillableLastLoginTime sets the "last_login_time" field if the given value is not nil. +func (_u *UserInfoUpdateOne) SetNillableLastLoginTime(v *time.Time) *UserInfoUpdateOne { + if v != nil { + _u.SetLastLoginTime(*v) + } + return _u +} + +// ClearLastLoginTime clears the value of the "last_login_time" field. +func (_u *UserInfoUpdateOne) ClearLastLoginTime() *UserInfoUpdateOne { + _u.mutation.ClearLastLoginTime() + return _u +} + +// Mutation returns the UserInfoMutation object of the builder. +func (_u *UserInfoUpdateOne) Mutation() *UserInfoMutation { + return _u.mutation +} + +// Where appends a list predicates to the UserInfoUpdate builder. +func (_u *UserInfoUpdateOne) Where(ps ...predicate.UserInfo) *UserInfoUpdateOne { + _u.mutation.Where(ps...) + return _u +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (_u *UserInfoUpdateOne) Select(field string, fields ...string) *UserInfoUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated UserInfo entity. +func (_u *UserInfoUpdateOne) Save(ctx context.Context) (*UserInfo, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *UserInfoUpdateOne) SaveX(ctx context.Context) *UserInfo { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *UserInfoUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *UserInfoUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *UserInfoUpdateOne) defaults() { + if _, ok := _u.mutation.UpdateTime(); !ok { + v := userinfo.UpdateDefaultUpdateTime() + _u.mutation.SetUpdateTime(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *UserInfoUpdateOne) check() error { + if v, ok := _u.mutation.Email(); ok { + if err := userinfo.EmailValidator(v); err != nil { + return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "UserInfo.email": %w`, err)} + } + } + if v, ok := _u.mutation.Username(); ok { + if err := userinfo.UsernameValidator(v); err != nil { + return &ValidationError{Name: "username", err: fmt.Errorf(`ent: validator failed for field "UserInfo.username": %w`, err)} + } + } + if v, ok := _u.mutation.Password(); ok { + if err := userinfo.PasswordValidator(v); err != nil { + return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "UserInfo.password": %w`, err)} + } + } + if v, ok := _u.mutation.Account(); ok { + if err := userinfo.AccountValidator(v); err != nil { + return &ValidationError{Name: "account", err: fmt.Errorf(`ent: validator failed for field "UserInfo.account": %w`, err)} + } + } + return nil +} + +func (_u *UserInfoUpdateOne) sqlSave(ctx context.Context) (_node *UserInfo, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(userinfo.Table, userinfo.Columns, sqlgraph.NewFieldSpec(userinfo.FieldID, field.TypeInt64)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "UserInfo.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := _u.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, userinfo.FieldID) + for _, f := range fields { + if !userinfo.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != userinfo.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.SeqNo(); ok { + _spec.SetField(userinfo.FieldSeqNo, field.TypeInt64, value) + } + if value, ok := _u.mutation.AddedSeqNo(); ok { + _spec.AddField(userinfo.FieldSeqNo, field.TypeInt64, value) + } + if value, ok := _u.mutation.Email(); ok { + _spec.SetField(userinfo.FieldEmail, field.TypeString, value) + } + if value, ok := _u.mutation.Username(); ok { + _spec.SetField(userinfo.FieldUsername, field.TypeString, value) + } + if value, ok := _u.mutation.Password(); ok { + _spec.SetField(userinfo.FieldPassword, field.TypeString, value) + } + if value, ok := _u.mutation.Gender(); ok { + _spec.SetField(userinfo.FieldGender, field.TypeInt64, value) + } + if value, ok := _u.mutation.AddedGender(); ok { + _spec.AddField(userinfo.FieldGender, field.TypeInt64, value) + } + if value, ok := _u.mutation.Account(); ok { + _spec.SetField(userinfo.FieldAccount, field.TypeString, value) + } + if value, ok := _u.mutation.UpdateTime(); ok { + _spec.SetField(userinfo.FieldUpdateTime, field.TypeTime, value) + } + if value, ok := _u.mutation.LastLoginTime(); ok { + _spec.SetField(userinfo.FieldLastLoginTime, field.TypeTime, value) + } + if _u.mutation.LastLoginTimeCleared() { + _spec.ClearField(userinfo.FieldLastLoginTime, field.TypeTime) + } + _node = &UserInfo{config: _u.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{userinfo.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} diff --git a/code/base-project/base-go-v3/go.mod b/code/base-project/base-go-v3/go.mod new file mode 100644 index 00000000..d345b222 --- /dev/null +++ b/code/base-project/base-go-v3/go.mod @@ -0,0 +1,54 @@ +module cn/oneao/base-go + +go 1.25.3 + +require ( + entgo.io/ent v0.14.5 + github.com/cloudwego/hertz v0.10.3 + github.com/golang-jwt/jwt/v4 v4.5.2 + github.com/hertz-contrib/jwt v1.0.4 + github.com/hertz-contrib/logger/zap v1.1.0 + github.com/hertz-contrib/requestid v1.1.0 + github.com/lib/pq v1.10.9 + go.uber.org/zap v1.27.1 + google.golang.org/protobuf v1.36.10 + gopkg.in/natefinch/lumberjack.v2 v2.2.1 +) + +require ( + ariga.io/atlas v0.38.0 // indirect + github.com/agext/levenshtein v1.2.3 // indirect + github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect + github.com/bmatcuk/doublestar v1.3.4 // indirect + github.com/bytedance/gopkg v0.1.3 // indirect + github.com/bytedance/sonic v1.14.2 // indirect + github.com/bytedance/sonic/loader v0.4.0 // indirect + github.com/cloudwego/base64x v0.1.6 // indirect + github.com/cloudwego/gopkg v0.1.7 // indirect + github.com/cloudwego/netpoll v0.7.2 // indirect + github.com/elastic/pkcs8 v1.0.0 // indirect + github.com/fsnotify/fsnotify v1.9.0 // indirect + github.com/go-openapi/inflect v0.21.3 // indirect + github.com/google/go-cmp v0.7.0 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/hashicorp/hcl/v2 v2.24.0 // indirect + github.com/klauspost/cpuid/v2 v2.3.0 // indirect + github.com/mitchellh/go-wordwrap v1.0.1 // indirect + github.com/nyaruka/phonenumbers v1.6.7 // indirect + github.com/tidwall/gjson v1.18.0 // indirect + github.com/tidwall/match v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect + github.com/twitchyliquid64/golang-asm v0.15.1 // indirect + github.com/zclconf/go-cty v1.17.0 // indirect + github.com/zclconf/go-cty-yaml v1.1.0 // indirect + go.uber.org/multierr v1.11.0 // indirect + golang.org/x/arch v0.23.0 // indirect + golang.org/x/crypto v0.45.0 // indirect + golang.org/x/exp v0.0.0-20251113190631-e25ba8c21ef6 // indirect + golang.org/x/mod v0.30.0 // indirect + golang.org/x/sync v0.18.0 // indirect + golang.org/x/sys v0.38.0 // indirect + golang.org/x/text v0.31.0 // indirect + golang.org/x/tools v0.39.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/code/base-project/base-go-v3/go.sum b/code/base-project/base-go-v3/go.sum new file mode 100644 index 00000000..0b75c9b4 --- /dev/null +++ b/code/base-project/base-go-v3/go.sum @@ -0,0 +1,208 @@ +ariga.io/atlas v0.38.0 h1:MwbtwVtDWJFq+ECyeTAz2ArvewDnpeiw/t/sgNdDsdo= +ariga.io/atlas v0.38.0/go.mod h1:D7XMK6ei3GvfDqvzk+2VId78j77LdqHrqPOWamn51/s= +entgo.io/ent v0.14.5 h1:Rj2WOYJtCkWyFo6a+5wB3EfBRP0rnx1fMk6gGA0UUe4= +entgo.io/ent v0.14.5/go.mod h1:zTzLmWtPvGpmSwtkaayM2cm5m819NdM7z7tYPq3vN0U= +github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= +github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= +github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= +github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= +github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY= +github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= +github.com/bmatcuk/doublestar v1.3.4 h1:gPypJ5xD31uhX6Tf54sDPUOBXTqKH4c9aPY66CyQrS0= +github.com/bmatcuk/doublestar v1.3.4/go.mod h1:wiQtGV+rzVYxB7WIlirSN++5HPtPlXEo9MEoZQC/PmE= +github.com/bytedance/go-tagexpr/v2 v2.9.2/go.mod h1:5qsx05dYOiUXOUgnQ7w3Oz8BYs2qtM/bJokdLb79wRM= +github.com/bytedance/gopkg v0.0.0-20220413063733-65bf48ffb3a7/go.mod h1:2ZlV9BaUH4+NXIBF0aMdKKAnHTzqH+iMU4KUjAbL23Q= +github.com/bytedance/gopkg v0.1.1/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP3TxducM= +github.com/bytedance/gopkg v0.1.3 h1:TPBSwH8RsouGCBcMBktLt1AymVo2TVsBVCY4b6TnZ/M= +github.com/bytedance/gopkg v0.1.3/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP3TxducM= +github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= +github.com/bytedance/sonic v1.14.2 h1:k1twIoe97C1DtYUo+fZQy865IuHia4PR5RPiuGPPIIE= +github.com/bytedance/sonic v1.14.2/go.mod h1:T80iDELeHiHKSc0C9tubFygiuXoGzrkjKzX2quAx980= +github.com/bytedance/sonic/loader v0.4.0 h1:olZ7lEqcxtZygCK9EKYKADnpQoYkRQxaeY2NYzevs+o= +github.com/bytedance/sonic/loader v0.4.0/go.mod h1:AR4NYCk5DdzZizZ5djGqQ92eEhCCcdf5x77udYiSJRo= +github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY= +github.com/cloudwego/base64x v0.1.6 h1:t11wG9AECkCDk5fMSoxmufanudBtJ+/HemLstXDLI2M= +github.com/cloudwego/base64x v0.1.6/go.mod h1:OFcloc187FXDaYHvrNIjxSe8ncn0OOM8gEHfghB2IPU= +github.com/cloudwego/gopkg v0.1.4/go.mod h1:FQuXsRWRsSqJLsMVd5SYzp8/Z1y5gXKnVvRrWUOsCMI= +github.com/cloudwego/gopkg v0.1.7 h1:P9+HwBwKIayJOg0V6hsxS3WVPzlad5BKxmDlZ8c8EkI= +github.com/cloudwego/gopkg v0.1.7/go.mod h1:FQuXsRWRsSqJLsMVd5SYzp8/Z1y5gXKnVvRrWUOsCMI= +github.com/cloudwego/hertz v0.4.2/go.mod h1:K1U0RlU07CDeBINfHNbafH/3j9uSgIW8otbjUys3OPY= +github.com/cloudwego/hertz v0.10.3 h1:NFcQAjouVJsod79XPLC/PaFfHgjMTYbiErmW+vGBi8A= +github.com/cloudwego/hertz v0.10.3/go.mod h1:W5dUFXZPZkyfjMMo3EQrMQbofuvTsctM9IxmhbkuT18= +github.com/cloudwego/netpoll v0.3.1/go.mod h1:1T2WVuQ+MQw6h6DpE45MohSvDTKdy2DlzCx2KsnPI4E= +github.com/cloudwego/netpoll v0.7.2 h1:4qDBGQ6CG2SvEXhZSDxMdtqt/NLDxjAVk0PC/biKiJo= +github.com/cloudwego/netpoll v0.7.2/go.mod h1:PI+YrmyS7cIr0+SD4seJz3Eo3ckkXdu2ZVKBLhURLNU= +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/elastic/pkcs8 v1.0.0 h1:HhitlUKxhN288kcNcYkjW6/ouvuwJWd9ioxpjnD9jVA= +github.com/elastic/pkcs8 v1.0.0/go.mod h1:ipsZToJfq1MxclVTwpG7U/bgeDtf+0HkUiOxebk95+0= +github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= +github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k= +github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= +github.com/go-openapi/inflect v0.21.3 h1:TmQvw+9eLrsNp4X0BBQacEZZtAnzk2z1FaLdQQJsDiU= +github.com/go-openapi/inflect v0.21.3/go.mod h1:INezMuUu7SJQc2AyR3WO0DqqYUJSj8Kb4hBd7WtjlAw= +github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= +github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= +github.com/golang-jwt/jwt/v4 v4.5.2 h1:YtQM7lnr8iZ+j5q71MGKkNw9Mn7AjHM68uc9g5fXeUI= +github.com/golang-jwt/jwt/v4 v4.5.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +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/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +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/hashicorp/hcl/v2 v2.24.0 h1:2QJdZ454DSsYGoaE6QheQZjtKZSUs9Nh2izTWiwQxvE= +github.com/hashicorp/hcl/v2 v2.24.0/go.mod h1:oGoO1FIQYfn/AgyOhlg9qLC6/nOJPX3qGbkZpYAcqfM= +github.com/henrylee2cn/ameda v1.4.8/go.mod h1:liZulR8DgHxdK+MEwvZIylGnmcjzQ6N6f2PlWe7nEO4= +github.com/henrylee2cn/ameda v1.4.10/go.mod h1:liZulR8DgHxdK+MEwvZIylGnmcjzQ6N6f2PlWe7nEO4= +github.com/henrylee2cn/goutil v0.0.0-20210127050712-89660552f6f8/go.mod h1:Nhe/DM3671a5udlv2AdV2ni/MZzgfv2qrPL5nIi3EGQ= +github.com/hertz-contrib/jwt v1.0.4 h1:PHddo1FDBpGHXx9nkhSwXamEyPNCkZCtszYXcRCD3q8= +github.com/hertz-contrib/jwt v1.0.4/go.mod h1:YntlFg4tdWw1CM5mELU00HbO8Gsa92xPd7EyrSYxAcg= +github.com/hertz-contrib/logger/zap v1.1.0 h1:4efINiIDJrXEtAFeEdDJvc3Hye0VFxp+0X4BwaZgxNs= +github.com/hertz-contrib/logger/zap v1.1.0/go.mod h1:D/rJJgsYn+SGaHVfVqWS3vHTbbc7ODAlJO+6smWgTeE= +github.com/hertz-contrib/requestid v1.1.0 h1:+y1cuNlNX2KUoEC1SnBJ6M55/TlMTx3M9yxkqi0oTkk= +github.com/hertz-contrib/requestid v1.1.0/go.mod h1:+l5CbZl//cSUoos421fnDFKQ6YYlVHcYc3Ri7AS8DUA= +github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= +github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y= +github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= +github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/mattn/go-sqlite3 v1.14.28 h1:ThEiQrnbtumT+QMknw63Befp/ce/nUPgBPMlRFEum7A= +github.com/mattn/go-sqlite3 v1.14.28/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= +github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= +github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +github.com/nyaruka/phonenumbers v1.0.55/go.mod h1:sDaTZ/KPX5f8qyV9qN+hIm+4ZBARJrupC6LuhshJq1U= +github.com/nyaruka/phonenumbers v1.6.7 h1:WmebT8TNEzNaui5QlrGqbccRC6dZkEkYc+MGQoILSSo= +github.com/nyaruka/phonenumbers v1.6.7/go.mod h1:7gjs+Lchqm49adhAKB5cdcng5ZXgt6x7Jgvi0ZorUtU= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +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/tidwall/gjson v1.9.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.13.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= +github.com/tidwall/match v1.2.0 h1:0pt8FlkOwjN2fPt4bIl4BoNxb98gGHN2ObFEDkrfZnM= +github.com/tidwall/match v1.2.0/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= +github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= +github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +github.com/zclconf/go-cty v1.17.0 h1:seZvECve6XX4tmnvRzWtJNHdscMtYEx5R7bnnVyd/d0= +github.com/zclconf/go-cty v1.17.0/go.mod h1:wqFzcImaLTI6A5HfsRwB0nj5n0MRZFwmey8YoFPPs3U= +github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940 h1:4r45xpDWB6ZMSMNJFMOjqrGHynW3DIBuR2H9j0ug+Mo= +github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940/go.mod h1:CmBdvvj3nqzfzJ6nTCIwDTPZ56aVGvDrmztiO5g3qrM= +github.com/zclconf/go-cty-yaml v1.1.0 h1:nP+jp0qPHv2IhUVqmQSzjvqAWcObN0KBkUl2rWBdig0= +github.com/zclconf/go-cty-yaml v1.1.0/go.mod h1:9YLUH4g7lOhVWqUbctnVlZ5KLpg7JAprQNgxSZ1Gyxs= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +go.uber.org/zap v1.27.1 h1:08RqriUEv8+ArZRYSTXy1LeBScaMpVSTBhCeaZYfMYc= +go.uber.org/zap v1.27.1/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= +golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= +golang.org/x/arch v0.23.0 h1:lKF64A2jF6Zd8L0knGltUnegD62JMFBiCPBmQpToHhg= +golang.org/x/arch v0.23.0/go.mod h1:dNHoOeKiyja7GTvF9NJS1l3Z2yntpQNzgrjh1cU103A= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= +golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= +golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q= +golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4= +golang.org/x/exp v0.0.0-20251113190631-e25ba8c21ef6 h1:zfMcR1Cs4KNuomFFgGefv5N0czO2XZpUbxGUy8i8ug0= +golang.org/x/exp v0.0.0-20251113190631-e25ba8c21ef6/go.mod h1:46edojNIoXTNOhySWIWdix628clX9ODXwPsQuG6hsK0= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.30.0 h1:fDEXFVZ/fmCKProc/yAXXUijritrDzahmwwefnjoPFk= +golang.org/x/mod v0.30.0/go.mod h1:lAsf5O2EvJeSFMiBxXDki7sCgAxEUcZHXoXMKT4GJKc= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= +golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I= +golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220110181412-a018aaa089fe/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +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.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= +golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= +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.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM= +golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM= +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.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +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-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +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-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= +gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= diff --git a/code/base-project/base-go-v3/idl/api.proto b/code/base-project/base-go-v3/idl/api.proto new file mode 100644 index 00000000..170dbed5 --- /dev/null +++ b/code/base-project/base-go-v3/idl/api.proto @@ -0,0 +1,76 @@ +// idl/api.proto; 注解拓展 +syntax = "proto2"; + +package api; + +import "google/protobuf/descriptor.proto"; + +option go_package = "/api"; + +extend google.protobuf.FieldOptions { + optional string raw_body = 50101; + optional string query = 50102; + optional string header = 50103; + optional string cookie = 50104; + optional string body = 50105; + optional string path = 50106; + optional string vd = 50107; + optional string form = 50108; + optional string js_conv = 50109; + optional string file_name = 50110; + optional string none = 50111; + + // 50131~50160 used to extend field option by hz + optional string form_compatible = 50131; + optional string js_conv_compatible = 50132; + optional string file_name_compatible = 50133; + optional string none_compatible = 50134; + // 50135 is reserved to vt_compatible + // optional FieldRules vt_compatible = 50135; + + optional string go_tag = 51001; +} + +extend google.protobuf.MethodOptions { + optional string get = 50201; + optional string post = 50202; + optional string put = 50203; + optional string delete = 50204; + optional string patch = 50205; + optional string options = 50206; + optional string head = 50207; + optional string any = 50208; + optional string gen_path = 50301; // The path specified by the user when the client code is generated, with a higher priority than api_version + optional string api_version = 50302; // Specify the value of the :version variable in path when the client code is generated + optional string tag = 50303; // rpc tag, can be multiple, separated by commas + optional string name = 50304; // Name of rpc + optional string api_level = 50305; // Interface Level + optional string serializer = 50306; // Serialization method + optional string param = 50307; // Whether client requests take public parameters + optional string baseurl = 50308; // Baseurl used in ttnet routing + optional string handler_path = 50309; // handler_path specifies the path to generate the method + + // 50331~50360 used to extend method option by hz + optional string handler_path_compatible = 50331; // handler_path specifies the path to generate the method +} + +extend google.protobuf.EnumValueOptions { + optional int32 http_code = 50401; + + // 50431~50460 used to extend enum option by hz +} + +extend google.protobuf.ServiceOptions { + optional string base_domain = 50402; + + // 50731~50760 used to extend service option by hz + optional string base_domain_compatible = 50731; +} + +extend google.protobuf.MessageOptions { + // optional FieldRules msg_vt = 50111; + + optional string reserve = 50830; + // 550831 is reserved to msg_vt_compatible + // optional FieldRules msg_vt_compatible = 50831; +} diff --git a/code/base-project/base-go-v3/idl/auth/login.proto b/code/base-project/base-go-v3/idl/auth/login.proto new file mode 100644 index 00000000..aa78e886 --- /dev/null +++ b/code/base-project/base-go-v3/idl/auth/login.proto @@ -0,0 +1,27 @@ +syntax = "proto3"; + +package auth; + +option go_package = "auth"; + +import "api.proto"; + +message LoginDefaultReq { + string Account = 1[(api.body)="account",(api.vd)="$!=''"]; + string Password = 2[(api.body)="password",(api.vd)="$!=''"]; +} + +message LoginDefaultResp { + string token = 1; + string refreshToken = 2; + int64 userId = 3; + string username = 4; + int64 seqNo = 5; + int64 gender = 6; +} + +service LoginService { + rpc LoginDefault(LoginDefaultReq) returns(LoginDefaultResp) { + option (api.post) = "/auth/login/default"; + } +} diff --git a/code/base-project/base-go-v3/idl/hello/hello.proto b/code/base-project/base-go-v3/idl/hello/hello.proto new file mode 100644 index 00000000..5e666c53 --- /dev/null +++ b/code/base-project/base-go-v3/idl/hello/hello.proto @@ -0,0 +1,22 @@ +// idl/hello/hello.proto +syntax = "proto3"; + +package hello; + +option go_package = "hertz/hello"; + +import "api.proto"; + +message HelloReq { + string Name = 1[(api.query)="name"]; +} + +message HelloResp { + string RespBody = 1; +} + +service HelloService { + rpc Method1(HelloReq) returns(HelloResp) { + option (api.get) = "/hello"; + } +} diff --git a/code/base-project/base-go-v3/log/log.go b/code/base-project/base-go-v3/log/log.go new file mode 100644 index 00000000..c445eb5a --- /dev/null +++ b/code/base-project/base-go-v3/log/log.go @@ -0,0 +1,49 @@ +package log + +import ( + "log" + "os" + "path" + "time" + + "github.com/cloudwego/hertz/pkg/common/hlog" + hertzzap "github.com/hertz-contrib/logger/zap" + "go.uber.org/zap" + "gopkg.in/natefinch/lumberjack.v2" +) + +func InitLog() { + // Customizable output directory. + var logFilePath string + dir := "./hlog" + logFilePath = dir + "/logs/" + if err := os.MkdirAll(logFilePath, 0o777); err != nil { + log.Println(err.Error()) + return + } + + // Set filename to date + logFileName := time.Now().Format("2006-01-02") + ".log" + fileName := path.Join(logFilePath, logFileName) + if _, err := os.Stat(fileName); err != nil { + if _, err := os.Create(fileName); err != nil { + log.Println(err.Error()) + return + } + } + + logger := hertzzap.NewLogger(hertzzap.WithZapOptions(zap.AddCaller(), zap.AddCallerSkip(3))) + + lumberjackLogger := &lumberjack.Logger{ + Filename: fileName, + MaxSize: 20, // A file can be up to 20M. + MaxBackups: 5, // Save up to 5 files at the same time. + MaxAge: 10, // A file can exist for a maximum of 10 days. + Compress: true, // Compress with gzip. + } + + logger.SetOutput(lumberjackLogger) + logger.SetLevel(hlog.LevelDebug) + + hlog.SetLogger(logger) +} diff --git a/code/base-project/base-go-v3/main.go b/code/base-project/base-go-v3/main.go new file mode 100644 index 00000000..2720ddc8 --- /dev/null +++ b/code/base-project/base-go-v3/main.go @@ -0,0 +1,34 @@ +package main + +import ( + "cn/oneao/base-go/config" + "cn/oneao/base-go/db" + "cn/oneao/base-go/log" + "cn/oneao/base-go/utils/idgen" + + "github.com/cloudwego/hertz/pkg/app/server" + "github.com/hertz-contrib/requestid" +) + +func main() { + + // 初始化雪花id + options := idgen.NewIdGeneratorOptions(config.App.Snowflake.WorkerID) + idgen.SetIdGenerator(options) + + // 初始化数据库 + db.InitDB() + + h := server.Default( + server.WithBasePath(config.App.Server.BaseUrl), + server.WithHostPorts(config.App.Server.Port), + ) + + // 请求 id + h.Use(requestid.New()) + + log.InitLog() + + register(h) + h.Spin() +} diff --git a/code/base-project/base-go-v3/router.go b/code/base-project/base-go-v3/router.go new file mode 100644 index 00000000..b45f223f --- /dev/null +++ b/code/base-project/base-go-v3/router.go @@ -0,0 +1,16 @@ +// Code generated by hertz generator. + +package main + +import ( + handler "cn/oneao/base-go/biz/handler" + + "github.com/cloudwego/hertz/pkg/app/server" +) + +// customizeRegister registers customize routers. +func customizedRegister(r *server.Hertz) { + r.GET("/ping", handler.Ping) + + // your code ... +} diff --git a/code/base-project/base-go-v3/router_gen.go b/code/base-project/base-go-v3/router_gen.go new file mode 100644 index 00000000..286bf31c --- /dev/null +++ b/code/base-project/base-go-v3/router_gen.go @@ -0,0 +1,16 @@ +// Code generated by hertz generator. DO NOT EDIT. + +package main + +import ( + router "cn/oneao/base-go/biz/router" + "github.com/cloudwego/hertz/pkg/app/server" +) + +// register registers all routers. +func register(r *server.Hertz) { + + router.GeneratedRegister(r) + + customizedRegister(r) +} diff --git a/code/base-project/base-go-v3/utils/idgen/DefaultIdGenerator.go b/code/base-project/base-go-v3/utils/idgen/DefaultIdGenerator.go new file mode 100644 index 00000000..826ac0bd --- /dev/null +++ b/code/base-project/base-go-v3/utils/idgen/DefaultIdGenerator.go @@ -0,0 +1,83 @@ +package idgen + +import ( + "strconv" + "time" +) + +type DefaultIdGenerator struct { + Options *IdGeneratorOptions + SnowWorker ISnowWorker + IdGeneratorException IdGeneratorException +} + +func NewDefaultIdGenerator(options *IdGeneratorOptions) *DefaultIdGenerator { + if options == nil { + panic("dig.Options error.") + } + + // 1.BaseTime + minTime := int64(631123200000) // time.Now().AddDate(-30, 0, 0).UnixNano() / 1e6 + if options.BaseTime < minTime || options.BaseTime > time.Now().UnixNano()/1e6 { + panic("BaseTime error.") + } + + // 2.WorkerIdBitLength + if options.WorkerIdBitLength <= 0 { + panic("WorkerIdBitLength error.(range:[1, 21])") + } + if options.WorkerIdBitLength+options.SeqBitLength > 22 { + panic("error:WorkerIdBitLength + SeqBitLength <= 22") + } + + // 3.WorkerId + maxWorkerIdNumber := uint16(1< maxWorkerIdNumber { + panic("WorkerId error. (range:[0, " + strconv.FormatUint(uint64(maxWorkerIdNumber), 10) + "]") + } + + // 4.SeqBitLength + if options.SeqBitLength < 2 || options.SeqBitLength > 21 { + panic("SeqBitLength error. (range:[2, 21])") + } + + // 5.MaxSeqNumber + maxSeqNumber := uint32(1< maxSeqNumber { + panic("MaxSeqNumber error. (range:[1, " + strconv.FormatUint(uint64(maxSeqNumber), 10) + "]") + } + + // 6.MinSeqNumber + if options.MinSeqNumber < 5 || options.MinSeqNumber > maxSeqNumber { + panic("MinSeqNumber error. (range:[5, " + strconv.FormatUint(uint64(maxSeqNumber), 10) + "]") + } + + var snowWorker ISnowWorker + switch options.Method { + case 1: + snowWorker = NewSnowWorkerM1(options) + case 2: + snowWorker = NewSnowWorkerM2(options) + default: + snowWorker = NewSnowWorkerM1(options) + } + + if options.Method == 1 { + time.Sleep(time.Duration(500) * time.Microsecond) + } + + return &DefaultIdGenerator{ + Options: options, + SnowWorker: snowWorker, + } +} + +func (dig DefaultIdGenerator) NewLong() int64 { + return dig.SnowWorker.NextId() +} diff --git a/code/base-project/base-go-v3/utils/idgen/IIdGenerator.go b/code/base-project/base-go-v3/utils/idgen/IIdGenerator.go new file mode 100644 index 00000000..884e145a --- /dev/null +++ b/code/base-project/base-go-v3/utils/idgen/IIdGenerator.go @@ -0,0 +1,5 @@ +package idgen + +type IIdGenerator interface { + NewLong() uint64 +} diff --git a/code/base-project/base-go-v3/utils/idgen/ISnowWorker.go b/code/base-project/base-go-v3/utils/idgen/ISnowWorker.go new file mode 100644 index 00000000..b4198231 --- /dev/null +++ b/code/base-project/base-go-v3/utils/idgen/ISnowWorker.go @@ -0,0 +1,5 @@ +package idgen + +type ISnowWorker interface { + NextId() int64 +} diff --git a/code/base-project/base-go-v3/utils/idgen/IdGeneratorException.go b/code/base-project/base-go-v3/utils/idgen/IdGeneratorException.go new file mode 100644 index 00000000..58dc11a4 --- /dev/null +++ b/code/base-project/base-go-v3/utils/idgen/IdGeneratorException.go @@ -0,0 +1,12 @@ +package idgen + +import "fmt" + +type IdGeneratorException struct { + message string + error error +} + +func (e IdGeneratorException) IdGeneratorException(message ...interface{}) { + fmt.Println(message) +} diff --git a/code/base-project/base-go-v3/utils/idgen/IdGeneratorOptions.go b/code/base-project/base-go-v3/utils/idgen/IdGeneratorOptions.go new file mode 100644 index 00000000..b728a51a --- /dev/null +++ b/code/base-project/base-go-v3/utils/idgen/IdGeneratorOptions.go @@ -0,0 +1,25 @@ +package idgen + +type IdGeneratorOptions struct { + Method uint16 // 雪花计算方法,(1-漂移算法|2-传统算法),默认1 + BaseTime int64 // 基础时间(ms单位),不能超过当前系统时间 + WorkerId uint16 // 机器码,必须由外部设定,最大值 2^WorkerIdBitLength-1 + WorkerIdBitLength byte // 机器码位长,默认值6,取值范围 [1, 15](要求:序列数位长+机器码位长不超过22) + SeqBitLength byte // 序列数位长,默认值6,取值范围 [3, 21](要求:序列数位长+机器码位长不超过22) + MaxSeqNumber uint32 // 最大序列数(含),设置范围 [MinSeqNumber, 2^SeqBitLength-1],默认值0,表示最大序列数取最大值(2^SeqBitLength-1]) + MinSeqNumber uint32 // 最小序列数(含),默认值5,取值范围 [5, MaxSeqNumber],每毫秒的前5个序列数对应编号0-4是保留位,其中1-4是时间回拨相应预留位,0是手工新值预留位 + TopOverCostCount uint32 // 最大漂移次数(含),默认2000,推荐范围500-10000(与计算能力有关) +} + +func NewIdGeneratorOptions(workerId uint16) *IdGeneratorOptions { + return &IdGeneratorOptions{ + Method: 1, + WorkerId: workerId, + BaseTime: 1582136402000, + WorkerIdBitLength: 6, + SeqBitLength: 6, + MaxSeqNumber: 0, + MinSeqNumber: 5, + TopOverCostCount: 2000, + } +} diff --git a/code/base-project/base-go-v3/utils/idgen/OverCostActionArg.go b/code/base-project/base-go-v3/utils/idgen/OverCostActionArg.go new file mode 100644 index 00000000..252b8628 --- /dev/null +++ b/code/base-project/base-go-v3/utils/idgen/OverCostActionArg.go @@ -0,0 +1,19 @@ +package idgen + +type OverCostActionArg struct { + ActionType int32 + TimeTick int64 + WorkerId uint16 + OverCostCountInOneTerm int32 + GenCountInOneTerm int32 + TermIndex int32 +} + +func (ocaa OverCostActionArg) OverCostActionArg(workerId uint16, timeTick int64, actionType int32, overCostCountInOneTerm int32, genCountWhenOverCost int32, index int32) { + ocaa.ActionType = actionType + ocaa.TimeTick = timeTick + ocaa.WorkerId = workerId + ocaa.OverCostCountInOneTerm = overCostCountInOneTerm + ocaa.GenCountInOneTerm = genCountWhenOverCost + ocaa.TermIndex = index +} diff --git a/code/base-project/base-go-v3/utils/idgen/SnowWorkerM1.go b/code/base-project/base-go-v3/utils/idgen/SnowWorkerM1.go new file mode 100644 index 00000000..481da2d8 --- /dev/null +++ b/code/base-project/base-go-v3/utils/idgen/SnowWorkerM1.go @@ -0,0 +1,243 @@ +package idgen + +import ( + "sync" + "time" +) + +// SnowWorkerM1 . +type SnowWorkerM1 struct { + BaseTime int64 //基础时间 + WorkerId uint16 //机器码 + WorkerIdBitLength byte //机器码位长 + SeqBitLength byte //自增序列数位长 + MaxSeqNumber uint32 //最大序列数(含) + MinSeqNumber uint32 //最小序列数(含) + TopOverCostCount uint32 //最大漂移次数 + _TimestampShift byte + _CurrentSeqNumber uint32 + + _LastTimeTick int64 + _TurnBackTimeTick int64 + _TurnBackIndex byte + _IsOverCost bool + _OverCostCountInOneTerm uint32 + _GenCountInOneTerm uint32 + _TermIndex uint32 + + sync.Mutex +} + +// NewSnowWorkerM1 . +func NewSnowWorkerM1(options *IdGeneratorOptions) ISnowWorker { + var workerIdBitLength byte + var seqBitLength byte + var maxSeqNumber uint32 + + // 1.BaseTime + var baseTime int64 + if options.BaseTime != 0 { + baseTime = options.BaseTime + } else { + baseTime = 1582136402000 + } + + // 2.WorkerIdBitLength + if options.WorkerIdBitLength == 0 { + workerIdBitLength = 6 + } else { + workerIdBitLength = options.WorkerIdBitLength + } + + // 3.WorkerId + var workerId = options.WorkerId + + // 4.SeqBitLength + if options.SeqBitLength == 0 { + seqBitLength = 6 + } else { + seqBitLength = options.SeqBitLength + } + + // 5.MaxSeqNumber + if options.MaxSeqNumber <= 0 { + maxSeqNumber = (1 << seqBitLength) - 1 + } else { + maxSeqNumber = options.MaxSeqNumber + } + + // 6.MinSeqNumber + var minSeqNumber = options.MinSeqNumber + + // 7.Others + var topOverCostCount = options.TopOverCostCount + if topOverCostCount == 0 { + topOverCostCount = 2000 + } + + timestampShift := (byte)(workerIdBitLength + seqBitLength) + currentSeqNumber := minSeqNumber + + return &SnowWorkerM1{ + BaseTime: baseTime, + WorkerIdBitLength: workerIdBitLength, + WorkerId: workerId, + SeqBitLength: seqBitLength, + MaxSeqNumber: maxSeqNumber, + MinSeqNumber: minSeqNumber, + TopOverCostCount: topOverCostCount, + _TimestampShift: timestampShift, + _CurrentSeqNumber: currentSeqNumber, + + _LastTimeTick: 0, + _TurnBackTimeTick: 0, + _TurnBackIndex: 0, + _IsOverCost: false, + _OverCostCountInOneTerm: 0, + _GenCountInOneTerm: 0, + _TermIndex: 0, + } +} + +// DoGenIDAction . +func (m1 *SnowWorkerM1) DoGenIdAction(arg *OverCostActionArg) { + +} + +func (m1 *SnowWorkerM1) BeginOverCostAction(useTimeTick int64) { + +} + +func (m1 *SnowWorkerM1) EndOverCostAction(useTimeTick int64) { + if m1._TermIndex > 10000 { + m1._TermIndex = 0 + } +} + +func (m1 *SnowWorkerM1) BeginTurnBackAction(useTimeTick int64) { + +} + +func (m1 *SnowWorkerM1) EndTurnBackAction(useTimeTick int64) { + +} + +func (m1 *SnowWorkerM1) NextOverCostId() int64 { + currentTimeTick := m1.GetCurrentTimeTick() + if currentTimeTick > m1._LastTimeTick { + m1.EndOverCostAction(currentTimeTick) + m1._LastTimeTick = currentTimeTick + m1._CurrentSeqNumber = m1.MinSeqNumber + m1._IsOverCost = false + m1._OverCostCountInOneTerm = 0 + m1._GenCountInOneTerm = 0 + return m1.CalcId(m1._LastTimeTick) + } + if m1._OverCostCountInOneTerm >= m1.TopOverCostCount { + m1.EndOverCostAction(currentTimeTick) + m1._LastTimeTick = m1.GetNextTimeTick() + m1._CurrentSeqNumber = m1.MinSeqNumber + m1._IsOverCost = false + m1._OverCostCountInOneTerm = 0 + m1._GenCountInOneTerm = 0 + return m1.CalcId(m1._LastTimeTick) + } + if m1._CurrentSeqNumber > m1.MaxSeqNumber { + m1._LastTimeTick++ + m1._CurrentSeqNumber = m1.MinSeqNumber + m1._IsOverCost = true + m1._OverCostCountInOneTerm++ + m1._GenCountInOneTerm++ + + return m1.CalcId(m1._LastTimeTick) + } + + m1._GenCountInOneTerm++ + return m1.CalcId(m1._LastTimeTick) +} + +// NextNormalID . +func (m1 *SnowWorkerM1) NextNormalId() int64 { + currentTimeTick := m1.GetCurrentTimeTick() + if currentTimeTick < m1._LastTimeTick { + if m1._TurnBackTimeTick < 1 { + m1._TurnBackTimeTick = m1._LastTimeTick - 1 + m1._TurnBackIndex++ + // 每毫秒序列数的前5位是预留位,0用于手工新值,1-4是时间回拨次序 + // 最多4次回拨(防止回拨重叠) + if m1._TurnBackIndex > 4 { + m1._TurnBackIndex = 1 + } + m1.BeginTurnBackAction(m1._TurnBackTimeTick) + } + + // time.Sleep(time.Duration(1) * time.Millisecond) + return m1.CalcTurnBackId(m1._TurnBackTimeTick) + } + + // 时间追平时,_TurnBackTimeTick清零 + if m1._TurnBackTimeTick > 0 { + m1.EndTurnBackAction(m1._TurnBackTimeTick) + m1._TurnBackTimeTick = 0 + } + + if currentTimeTick > m1._LastTimeTick { + m1._LastTimeTick = currentTimeTick + m1._CurrentSeqNumber = m1.MinSeqNumber + return m1.CalcId(m1._LastTimeTick) + } + + if m1._CurrentSeqNumber > m1.MaxSeqNumber { + m1.BeginOverCostAction(currentTimeTick) + m1._TermIndex++ + m1._LastTimeTick++ + m1._CurrentSeqNumber = m1.MinSeqNumber + m1._IsOverCost = true + m1._OverCostCountInOneTerm = 1 + m1._GenCountInOneTerm = 1 + + return m1.CalcId(m1._LastTimeTick) + } + + return m1.CalcId(m1._LastTimeTick) +} + +// CalcID . +func (m1 *SnowWorkerM1) CalcId(useTimeTick int64) int64 { + result := int64(useTimeTick< m2.MaxSeqNumber { + m2._CurrentSeqNumber = m2.MinSeqNumber + currentTimeTick = m2.GetNextTimeTick() + } + } else { + m2._CurrentSeqNumber = m2.MinSeqNumber + } + if currentTimeTick < m2._LastTimeTick { + fmt.Println("Time error for {0} milliseconds", strconv.FormatInt(m2._LastTimeTick-currentTimeTick, 10)) + } + m2._LastTimeTick = currentTimeTick + result := int64(currentTimeTick< 0: + expireAt := time.Now().Add(expiry) + claims.ExpiresAt = jwt.NewNumericDate(expireAt) + case expiry == -1: + claims.ExpiresAt = nil // 永不过期 + default: + expireAt := time.Now().Add(time.Hour) + claims.ExpiresAt = jwt.NewNumericDate(expireAt) + } + + token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims) + signed, err := token.SignedString([]byte(config.App.JWT.Secret)) + if err != nil { + return "", err + } + + return signed, nil +} + +// VerifyToken 验证 token 并返回结构化结果 +func VerifyToken(tokenString string) TokenResult { + result := TokenResult{ + IsValid: false, + IsExpired: false, + } + + // 🧩 1. token 为空 + if tokenString == "" { + return result + } + + // 🧩 2. 解析 token + token, err := jwt.ParseWithClaims(tokenString, &CustomClaims{}, func(token *jwt.Token) (interface{}, error) { + return []byte(config.App.JWT.Secret), nil + }) + + // 🧩 3. token 为 nil(解析异常) + if token == nil { + return result + } + + // 🧩 4. 提取 claims 并验证 + claims, ok := token.Claims.(*CustomClaims) + if !ok { + return result + } + + // 🧩 5. 解析失败或签名无效 + if err != nil || !token.Valid { + return result + } + + // ✅ 6. 填充结果 + result.Claims = claims + result.IsValid = true + + // 🧩 7. 检查是否过期 + if claims.ExpiresAt != nil && time.Now().After(claims.ExpiresAt.Time) { + result.IsExpired = true + } + + return result +} diff --git a/code/base-project/base-go-v3/utils/response/response.go b/code/base-project/base-go-v3/utils/response/response.go new file mode 100644 index 00000000..dda907f8 --- /dev/null +++ b/code/base-project/base-go-v3/utils/response/response.go @@ -0,0 +1,86 @@ +package response + +import ( + "net/http" + + "github.com/cloudwego/hertz/pkg/app" + "github.com/hertz-contrib/requestid" +) + +// Result 响应结构 +type Result struct { + Code int `json:"code"` + Message string `json:"message"` + Data interface{} `json:"data,omitempty"` + TrackId string `json:"trackId,omitempty"` +} + +// HttpCode 响应状态码 +var HttpCode = struct { + Success int + Unauthorized int + Fail int + RefreshToken int +}{ + Success: 200, + Unauthorized: 401, + Fail: 500, + RefreshToken: 402, +} + +// Builder 响应构建器 +type Builder struct { + c *app.RequestContext + result Result + statusCode int // 可自定义 HTTP 状态码 +} + +// Success 构造成功响应 +func Success(c *app.RequestContext) *Builder { + return &Builder{ + c: c, + result: Result{Code: HttpCode.Success, Message: "请求成功"}, + statusCode: http.StatusOK, + } +} + +// Fail 构造失败响应 +func Fail(c *app.RequestContext) *Builder { + return &Builder{ + c: c, + result: Result{Code: HttpCode.Fail, Message: "请求失败"}, + statusCode: http.StatusOK, + } +} + +// Status 设置自定义 HTTP 状态码 +func (b *Builder) Status(code int) *Builder { + b.statusCode = code + return b +} + +func (b *Builder) Code(code int) *Builder { + b.result.Code = code + return b +} + +func (b *Builder) Message(msg string) *Builder { + b.result.Message = msg + return b +} + +func (b *Builder) Data(data interface{}) *Builder { + b.result.Data = data + return b +} + +// Send 发送响应 +func (b *Builder) Send() { + if b.result.Data == nil { + b.result.Data = "" + } + reqID := requestid.Get(b.c) + + b.result.TrackId = reqID + b.c.JSON(200, b.result) +} diff --git a/code/base-project/genpb/.idea/.gitignore b/code/base-project/genpb/.idea/.gitignore new file mode 100644 index 00000000..13566b81 --- /dev/null +++ b/code/base-project/genpb/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/code/base-project/genpb/.idea/genpb.iml b/code/base-project/genpb/.idea/genpb.iml new file mode 100644 index 00000000..5e764c4f --- /dev/null +++ b/code/base-project/genpb/.idea/genpb.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/code/base-project/genpb/.idea/modules.xml b/code/base-project/genpb/.idea/modules.xml new file mode 100644 index 00000000..c2795d2e --- /dev/null +++ b/code/base-project/genpb/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/code/base-project/genpb/.idea/vcs.xml b/code/base-project/genpb/.idea/vcs.xml new file mode 100644 index 00000000..c2365ab1 --- /dev/null +++ b/code/base-project/genpb/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/code/base-project/genpb/genpb.exe b/code/base-project/genpb/genpb.exe new file mode 100644 index 00000000..cff080ba Binary files /dev/null and b/code/base-project/genpb/genpb.exe differ diff --git a/code/base-project/genpb/go.mod b/code/base-project/genpb/go.mod new file mode 100644 index 00000000..25ad1c07 --- /dev/null +++ b/code/base-project/genpb/go.mod @@ -0,0 +1,3 @@ +module genpb + +go 1.25 diff --git a/code/base-project/genpb/main.go b/code/base-project/genpb/main.go new file mode 100644 index 00000000..3a33faf8 --- /dev/null +++ b/code/base-project/genpb/main.go @@ -0,0 +1,102 @@ +package main + +import ( + "fmt" + "os" + "os/exec" + "path/filepath" + "strings" + "time" +) + +// 处理单个 pb.go 文件,去掉 ,omitempty +func handleFile(path string) error { + fmt.Println("正在处理文件:", path) + content, err := os.ReadFile(path) + if err != nil { + return err + } + + // 去掉 ,omitempty 标签 + newContent := strings.ReplaceAll(string(content), ",omitempty", "") + + return os.WriteFile(path, []byte(newContent), 0644) +} + +// 查找 biz/model 目录及其子目录下最新的 .pb.go 文件,忽略 biz/model/api +func findLatestPBGoFile(root string) (string, error) { + var latestFile string + var latestTime time.Time + ignoreDir := filepath.Join(root, "api") + + err := filepath.WalkDir(root, func(path string, d os.DirEntry, err error) error { + if err != nil { + return err + } + + // 忽略 biz/model/api 目录 + if d.IsDir() && strings.HasPrefix(path, ignoreDir) { + return filepath.SkipDir + } + + if !d.IsDir() && strings.HasSuffix(d.Name(), ".pb.go") { + info, err := d.Info() + if err != nil { + return err + } + + modTime := info.ModTime() + if modTime.After(latestTime) { + latestTime = modTime + latestFile = path + } + } + return nil + }) + + if err != nil { + return "", err + } + + if latestFile == "" { + return "", fmt.Errorf("未找到 .pb.go 文件") + } + + return latestFile, nil +} + +func main() { + if len(os.Args) < 2 { + fmt.Println("用法: genpb.exe ") + os.Exit(1) + } + + protoFile := os.Args[1] + + // 1. 执行 hz update(同步等待执行完毕) + cmd := exec.Command("hz", "update", "-I", "idl", "-idl", protoFile) + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + + fmt.Println("正在执行 hz update ...") + if err := cmd.Run(); err != nil { + fmt.Println("hz update 执行失败:", err) + os.Exit(1) + } + fmt.Println("hz update 执行完成.") + + // 2. 查找最新 pb.go 文件并处理 + modelDir := "biz/model" + latestFile, err := findLatestPBGoFile(modelDir) + if err != nil { + fmt.Println("查找最新 .pb.go 文件失败:", err) + os.Exit(1) + } + + if err := handleFile(latestFile); err != nil { + fmt.Println("处理 pb.go 文件失败:", err) + os.Exit(1) + } + + fmt.Println("最新 .pb.go 文件处理完成:", latestFile) +}