diff --git a/code/base-project/base-app/test2.html b/code/base-project/base-app/test2.html index cbea7827..95cdb4e1 100644 --- a/code/base-project/base-app/test2.html +++ b/code/base-project/base-app/test2.html @@ -131,6 +131,8 @@ console.log($('#subgrid').datagrid('getData')); console.log("===getChanges===") console.log($('#subgrid').datagrid('getChanges')); + console.log("===allRows===") + console.log("===allRows===") } // 打印数据 diff --git a/code/base-project/base-app/~$箱数据2000行.xlsx b/code/base-project/base-app/~$箱数据2000行.xlsx deleted file mode 100644 index 1e0c8b3a..00000000 Binary files a/code/base-project/base-app/~$箱数据2000行.xlsx and /dev/null differ 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 deleted file mode 100644 index ed468401..00000000 --- a/code/base-project/base-go-v3/biz/handler/auth/login_service.go +++ /dev/null @@ -1,73 +0,0 @@ -// Code generated by hertz generator. - -package auth - -import ( - auth "cn/oneao/base-go/biz/model/auth" - "cn/oneao/base-go/db" - "cn/oneao/base-go/ent/userinfo" - "cn/oneao/base-go/logx" - "cn/oneao/base-go/utils/jwtx" - "cn/oneao/base-go/utils/response" - "context" - "fmt" - "time" - - "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 - } - start := time.Now() // 记录开始时间 - - // 查询登录用户 - loginUser, err := db.Client.UserInfo. - Query(). - Where(userinfo.AccountEQ(req.Account), - userinfo.PasswordEQ(req.Password)). - Only(ctx) - duration := time.Since(start) // 计算耗时 - - fmt.Println("耗时:", duration) - if err != nil { - response.Fail(c).Message("账号或密码错误").Send() - return - } - - // 异步更新登录事件 - go func() { - err := db.Client.UserInfo. - Update(). - SetLastLoginTime(time.Now()). - Where(userinfo.IDEQ(loginUser.ID)). - Exec(ctx) - - if err != nil { - logx.CtxError(ctx, "更新用户登录时间失败,UserID=%d, err=%v", loginUser.ID, err) - } - }() - - // 包装数据 - 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/ping.go b/code/base-project/base-go-v3/biz/handler/ping.go deleted file mode 100644 index 950d4767..00000000 --- a/code/base-project/base-go-v3/biz/handler/ping.go +++ /dev/null @@ -1,18 +0,0 @@ -// 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 deleted file mode 100644 index 37434df6..00000000 --- a/code/base-project/base-go-v3/biz/model/api/api.pb.go +++ /dev/null @@ -1,667 +0,0 @@ -// 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 deleted file mode 100644 index 1429ca84..00000000 --- a/code/base-project/base-go-v3/biz/model/auth/login.pb.go +++ /dev/null @@ -1,277 +0,0 @@ -// 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/router/auth/login.go b/code/base-project/base-go-v3/biz/router/auth/login.go deleted file mode 100644 index ed820d4e..00000000 --- a/code/base-project/base-go-v3/biz/router/auth/login.go +++ /dev/null @@ -1,27 +0,0 @@ -// 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 deleted file mode 100644 index 9b0280a6..00000000 --- a/code/base-project/base-go-v3/biz/router/auth/middleware.go +++ /dev/null @@ -1,27 +0,0 @@ -// 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/register.go b/code/base-project/base-go-v3/biz/router/register.go deleted file mode 100644 index b01850e6..00000000 --- a/code/base-project/base-go-v3/biz/router/register.go +++ /dev/null @@ -1,15 +0,0 @@ -// Code generated by hertz generator. DO NOT EDIT. - -package router - -import ( - auth "cn/oneao/base-go/biz/router/auth" - "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! - - auth.Register(r) -} diff --git a/code/base-project/base-go-v3/config/database.go b/code/base-project/base-go-v3/config/database.go index dc8c5ed9..894f06bf 100644 --- a/code/base-project/base-go-v3/config/database.go +++ b/code/base-project/base-go-v3/config/database.go @@ -19,7 +19,7 @@ type dbConfig struct { // Db 默认值 var Db = &dbConfig{ - Host: "127.0.0.1", + Host: "117.72.182.135", Port: 5432, User: "postgres", Password: "zhang520..", diff --git a/code/base-project/base-go-v3/db/db.go b/code/base-project/base-go-v3/db/db.go deleted file mode 100644 index a458f812..00000000 --- a/code/base-project/base-go-v3/db/db.go +++ /dev/null @@ -1,56 +0,0 @@ -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/db/index.go b/code/base-project/base-go-v3/db/index.go new file mode 100644 index 00000000..a8863d1e --- /dev/null +++ b/code/base-project/base-go-v3/db/index.go @@ -0,0 +1,56 @@ +// db/db.go +package db + +import ( + "cn/oneao/base-go/config" + sqlcg "cn/oneao/base-go/db/sqlc" + "context" + "fmt" + "github.com/jackc/pgx/v5/pgxpool" + "time" +) + +var ( + DB *pgxpool.Pool + DBClient *sqlcg.Queries +) + +func InitDB() error { + cfg := config.Db + + sslMode := "disable" + if cfg.SllMode { + sslMode = "require" + } + + // 构建 DSN + dsn := fmt.Sprintf( + "postgres://%s:%s@%s:%d/%s?sslmode=%s&TimeZone=%s", + cfg.User, cfg.Password, cfg.Host, cfg.Port, cfg.Dbname, sslMode, cfg.TimeZone, + ) + + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + defer cancel() + + pool, err := pgxpool.New(ctx, dsn) + if err != nil { + return fmt.Errorf("unable to connect to database: %w", err) + } + + // 测试连接 + if err := pool.Ping(ctx); err != nil { + return fmt.Errorf("ping database failed: %w", err) + } + + DB = pool + + // 初始化 sqlc Queries,全局可用 + DBClient = sqlcg.New(DB) + + // 可选:设置连接池参数 + pool.Config().MaxConns = int32(cfg.MaxOpenConns) + pool.Config().MinConns = int32(cfg.MaxIdleConns) + pool.Config().MaxConnLifetime = cfg.ConnMaxLifetime + + return nil +} diff --git a/code/base-project/base-go-v3/db/queries/user_info.sql b/code/base-project/base-go-v3/db/queries/user_info.sql new file mode 100644 index 00000000..7af130d0 --- /dev/null +++ b/code/base-project/base-go-v3/db/queries/user_info.sql @@ -0,0 +1,23 @@ +-- name: CreateUser :execrows +-- 插入用户并返回刚创建的记录 +INSERT INTO user_info (id, account, password) +VALUES ($1, $2, $3); + +-- name: GetUserById :one +-- 根据 ID 查询单条用户记录 +SELECT * +FROM user_info +WHERE id = $1; + +-- name: GetUserByAccountAndPassword :one +-- 根据账号和密码查询单条用户记录(登录用) +SELECT * +FROM user_info +WHERE account = $1 + AND password = $2; + +-- name: UpdateUserLoginLastTime :execrows +-- 更新用户最后登录时间,并返回影响的行数 +UPDATE user_info +SET last_login_time = now() +WHERE id = $1; diff --git a/code/base-project/base-go-v3/db/schema.sql b/code/base-project/base-go-v3/db/schema.sql new file mode 100644 index 00000000..16ae1431 --- /dev/null +++ b/code/base-project/base-go-v3/db/schema.sql @@ -0,0 +1,42 @@ +CREATE TABLE user_info ( + id BIGINT PRIMARY KEY, + seq_no SERIAL, -- 自增 + account VARCHAR(255) NOT NULL UNIQUE, + password VARCHAR(255) NOT NULL, + email VARCHAR(255) UNIQUE, + username VARCHAR(50), + gender INT DEFAULT 0, + create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + last_login_time TIMESTAMP +); + +CREATE TABLE money_record( + id BIGINT PRIMARY KEY, + category_id BIGINT NOT NULL, + user_id BIGINT NOT NULL, + amount NUMERIC(12,2) NOT NULL, + remark VARCHAR(255) DEFAULT '', + record_time timestamp NOT NULL, + create_time timestamp DEFAULT CURRENT_TIMESTAMP, + update_time timestamp DEFAULT CURRENT_TIMESTAMP +); + +CREATE TABLE money_sys_category( + id BIGINT PRIMARY KEY , + name VARCHAR(255) NOT NULL , + icon VARCHAR(255) NOT NULL, + type SMALLINT DEFAULT 0, + sort_number INT DEFAULT 0, + create_time timestamp DEFAULT CURRENT_TIMESTAMP +); + +CREATE TABLE money_user_category( + id BIGINT PRIMARY KEY , + user_id BIGINT NOT NULL, + name VARCHAR(255) NOT NULL , + icon VARCHAR(255) NOT NULL, + type SMALLINT DEFAULT 0, + sort_number INT DEFAULT 0, + create_time timestamp DEFAULT CURRENT_TIMESTAMP +) diff --git a/code/base-project/base-go-v3/db/sqlc/db.go b/code/base-project/base-go-v3/db/sqlc/db.go new file mode 100644 index 00000000..4f1cfa52 --- /dev/null +++ b/code/base-project/base-go-v3/db/sqlc/db.go @@ -0,0 +1,32 @@ +// Code generated by sqlc. DO NOT EDIT. +// versions: +// sqlc v1.30.0 + +package sqlcg + +import ( + "context" + + "github.com/jackc/pgx/v5" + "github.com/jackc/pgx/v5/pgconn" +) + +type DBTX interface { + Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error) + Query(context.Context, string, ...interface{}) (pgx.Rows, error) + QueryRow(context.Context, string, ...interface{}) pgx.Row +} + +func New(db DBTX) *Queries { + return &Queries{db: db} +} + +type Queries struct { + db DBTX +} + +func (q *Queries) WithTx(tx pgx.Tx) *Queries { + return &Queries{ + db: tx, + } +} diff --git a/code/base-project/base-go-v3/db/sqlc/models.go b/code/base-project/base-go-v3/db/sqlc/models.go new file mode 100644 index 00000000..b4346c26 --- /dev/null +++ b/code/base-project/base-go-v3/db/sqlc/models.go @@ -0,0 +1,52 @@ +// Code generated by sqlc. DO NOT EDIT. +// versions: +// sqlc v1.30.0 + +package sqlcg + +import ( + "github.com/jackc/pgx/v5/pgtype" +) + +type MoneyRecord struct { + ID int64 + CategoryID int64 + UserID int64 + Amount pgtype.Numeric + Remark pgtype.Text + RecordTime pgtype.Timestamp + CreateTime pgtype.Timestamp + UpdateTime pgtype.Timestamp +} + +type MoneySysCategory struct { + ID int64 + Name string + Icon string + Type pgtype.Int2 + SortNumber pgtype.Int4 + CreateTime pgtype.Timestamp +} + +type MoneyUserCategory struct { + ID int64 + UserID int64 + Name string + Icon string + Type pgtype.Int2 + SortNumber pgtype.Int4 + CreateTime pgtype.Timestamp +} + +type UserInfo struct { + ID int64 + SeqNo pgtype.Int4 + Account string + Password string + Email pgtype.Text + Username pgtype.Text + Gender pgtype.Int4 + CreateTime pgtype.Timestamp + UpdateTime pgtype.Timestamp + LastLoginTime pgtype.Timestamp +} diff --git a/code/base-project/base-go-v3/db/sqlc/user_info.sql.go b/code/base-project/base-go-v3/db/sqlc/user_info.sql.go new file mode 100644 index 00000000..0a7c3c51 --- /dev/null +++ b/code/base-project/base-go-v3/db/sqlc/user_info.sql.go @@ -0,0 +1,101 @@ +// Code generated by sqlc. DO NOT EDIT. +// versions: +// sqlc v1.30.0 +// source: user_info.sql + +package sqlcg + +import ( + "context" +) + +const createUser = `-- name: CreateUser :execrows +INSERT INTO user_info (id, account, password) +VALUES ($1, $2, $3) +` + +type CreateUserParams struct { + ID int64 + Account string + Password string +} + +// 插入用户并返回刚创建的记录 +func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (int64, error) { + result, err := q.db.Exec(ctx, createUser, arg.ID, arg.Account, arg.Password) + if err != nil { + return 0, err + } + return result.RowsAffected(), nil +} + +const getUserByAccountAndPassword = `-- name: GetUserByAccountAndPassword :one +SELECT id, seq_no, account, password, email, username, gender, create_time, update_time, last_login_time +FROM user_info +WHERE account = $1 + AND password = $2 +` + +type GetUserByAccountAndPasswordParams struct { + Account string + Password string +} + +// 根据账号和密码查询单条用户记录(登录用) +func (q *Queries) GetUserByAccountAndPassword(ctx context.Context, arg GetUserByAccountAndPasswordParams) (UserInfo, error) { + row := q.db.QueryRow(ctx, getUserByAccountAndPassword, arg.Account, arg.Password) + var i UserInfo + err := row.Scan( + &i.ID, + &i.SeqNo, + &i.Account, + &i.Password, + &i.Email, + &i.Username, + &i.Gender, + &i.CreateTime, + &i.UpdateTime, + &i.LastLoginTime, + ) + return i, err +} + +const getUserById = `-- name: GetUserById :one +SELECT id, seq_no, account, password, email, username, gender, create_time, update_time, last_login_time +FROM user_info +WHERE id = $1 +` + +// 根据 ID 查询单条用户记录 +func (q *Queries) GetUserById(ctx context.Context, id int64) (UserInfo, error) { + row := q.db.QueryRow(ctx, getUserById, id) + var i UserInfo + err := row.Scan( + &i.ID, + &i.SeqNo, + &i.Account, + &i.Password, + &i.Email, + &i.Username, + &i.Gender, + &i.CreateTime, + &i.UpdateTime, + &i.LastLoginTime, + ) + return i, err +} + +const updateUserLoginLastTime = `-- name: UpdateUserLoginLastTime :execrows +UPDATE user_info +SET last_login_time = now() +WHERE id = $1 +` + +// 更新用户最后登录时间,并返回影响的行数 +func (q *Queries) UpdateUserLoginLastTime(ctx context.Context, id int64) (int64, error) { + result, err := q.db.Exec(ctx, updateUserLoginLastTime, id) + if err != nil { + return 0, err + } + return result.RowsAffected(), nil +} diff --git a/code/base-project/base-go-v3/ent/client.go b/code/base-project/base-go-v3/ent/client.go deleted file mode 100644 index efe85eba..00000000 --- a/code/base-project/base-go-v3/ent/client.go +++ /dev/null @@ -1,341 +0,0 @@ -// 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 deleted file mode 100644 index 2ebe1ece..00000000 --- a/code/base-project/base-go-v3/ent/ent.go +++ /dev/null @@ -1,608 +0,0 @@ -// 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 deleted file mode 100644 index 3221b370..00000000 --- a/code/base-project/base-go-v3/ent/enttest/enttest.go +++ /dev/null @@ -1,85 +0,0 @@ -// 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 deleted file mode 100644 index 8d3fdfdc..00000000 --- a/code/base-project/base-go-v3/ent/generate.go +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index d511d23c..00000000 --- a/code/base-project/base-go-v3/ent/hook/hook.go +++ /dev/null @@ -1,198 +0,0 @@ -// 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 deleted file mode 100644 index 1956a6bf..00000000 --- a/code/base-project/base-go-v3/ent/migrate/migrate.go +++ /dev/null @@ -1,64 +0,0 @@ -// 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 deleted file mode 100644 index fbaa209c..00000000 --- a/code/base-project/base-go-v3/ent/migrate/schema.go +++ /dev/null @@ -1,41 +0,0 @@ -// 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 deleted file mode 100644 index 4656b928..00000000 --- a/code/base-project/base-go-v3/ent/mutation.go +++ /dev/null @@ -1,883 +0,0 @@ -// 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 deleted file mode 100644 index 126911a0..00000000 --- a/code/base-project/base-go-v3/ent/predicate/predicate.go +++ /dev/null @@ -1,10 +0,0 @@ -// 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 deleted file mode 100644 index bdb3fbbc..00000000 --- a/code/base-project/base-go-v3/ent/runtime.go +++ /dev/null @@ -1,67 +0,0 @@ -// 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) - // 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 deleted file mode 100644 index c145156f..00000000 --- a/code/base-project/base-go-v3/ent/runtime/runtime.go +++ /dev/null @@ -1,10 +0,0 @@ -// 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 deleted file mode 100644 index 0678f4dc..00000000 --- a/code/base-project/base-go-v3/ent/schema/userinfo.go +++ /dev/null @@ -1,85 +0,0 @@ -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). - 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 deleted file mode 100644 index 896bc05b..00000000 --- a/code/base-project/base-go-v3/ent/tx.go +++ /dev/null @@ -1,210 +0,0 @@ -// 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 deleted file mode 100644 index 9b47f49c..00000000 --- a/code/base-project/base-go-v3/ent/userinfo.go +++ /dev/null @@ -1,197 +0,0 @@ -// 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 deleted file mode 100644 index 62c5fb74..00000000 --- a/code/base-project/base-go-v3/ent/userinfo/userinfo.go +++ /dev/null @@ -1,134 +0,0 @@ -// 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 - // 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 deleted file mode 100644 index 1981e65e..00000000 --- a/code/base-project/base-go-v3/ent/userinfo/where.go +++ /dev/null @@ -1,585 +0,0 @@ -// 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 deleted file mode 100644 index 2439c31b..00000000 --- a/code/base-project/base-go-v3/ent/userinfo_create.go +++ /dev/null @@ -1,391 +0,0 @@ -// 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 deleted file mode 100644 index 4347e32f..00000000 --- a/code/base-project/base-go-v3/ent/userinfo_delete.go +++ /dev/null @@ -1,88 +0,0 @@ -// 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 deleted file mode 100644 index 53a365e4..00000000 --- a/code/base-project/base-go-v3/ent/userinfo_query.go +++ /dev/null @@ -1,527 +0,0 @@ -// 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 deleted file mode 100644 index 1cc56e8f..00000000 --- a/code/base-project/base-go-v3/ent/userinfo_update.go +++ /dev/null @@ -1,562 +0,0 @@ -// 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 -} - -// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. -func (_u *UserInfoUpdate) SetNillableUpdateTime(v *time.Time) *UserInfoUpdate { - if v != nil { - _u.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) { - 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) - } -} - -// 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 -} - -// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. -func (_u *UserInfoUpdateOne) SetNillableUpdateTime(v *time.Time) *UserInfoUpdateOne { - if v != nil { - _u.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) { - 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) - } -} - -// 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 index f6560b09..915d2328 100644 --- a/code/base-project/base-go-v3/go.mod +++ b/code/base-project/base-go-v3/go.mod @@ -36,6 +36,10 @@ require ( github.com/google/uuid v1.6.0 // indirect github.com/hashicorp/hcl/v2 v2.24.0 // indirect github.com/hertz-contrib/logger/zap v1.1.0 // indirect + github.com/jackc/pgpassfile v1.0.0 // indirect + github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect + github.com/jackc/pgx/v5 v5.7.6 // indirect + github.com/jackc/puddle/v2 v2.2.2 // indirect github.com/jmoiron/sqlx v1.4.0 // indirect github.com/klauspost/cpuid/v2 v2.3.0 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect diff --git a/code/base-project/base-go-v3/go.sum b/code/base-project/base-go-v3/go.sum index 30b8aa05..adc20160 100644 --- a/code/base-project/base-go-v3/go.sum +++ b/code/base-project/base-go-v3/go.sum @@ -82,6 +82,14 @@ github.com/hertz-contrib/requestid v1.1.0/go.mod h1:+l5CbZl//cSUoos421fnDFKQ6YYl github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= +github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= +github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo= +github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= +github.com/jackc/pgx/v5 v5.7.6 h1:rWQc5FwZSPX58r1OQmkuaNicxdmExaEz5A2DO2hUuTk= +github.com/jackc/pgx/v5 v5.7.6/go.mod h1:aruU7o91Tc2q2cFp5h4uP3f6ztExVpyVv88Xl/8Vl8M= +github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo= +github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= github.com/jmoiron/sqlx v1.4.0 h1:1PLqN7S1UYp5t4SrVVnt4nUVNemrDAtxlulVe+Qgm3o= github.com/jmoiron/sqlx v1.4.0/go.mod h1:ZrZ7UsYB/weZdl2Bxg6jCRO9c3YHl8r3ahlKmRT4JLY= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= @@ -238,6 +246,7 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 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/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= 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= diff --git a/code/base-project/base-go-v3/idl/auth/login.proto b/code/base-project/base-go-v3/idl/auth/login.proto index aa78e886..58ae8471 100644 --- a/code/base-project/base-go-v3/idl/auth/login.proto +++ b/code/base-project/base-go-v3/idl/auth/login.proto @@ -1,7 +1,5 @@ syntax = "proto3"; -package auth; - option go_package = "auth"; import "api.proto"; diff --git a/code/base-project/base-go-v3/idl/auth/register.proto b/code/base-project/base-go-v3/idl/auth/register.proto index 8832b06d..b4fc588e 100644 --- a/code/base-project/base-go-v3/idl/auth/register.proto +++ b/code/base-project/base-go-v3/idl/auth/register.proto @@ -1 +1,20 @@ -package auth +syntax = "proto3"; + +option go_package = "auth"; + +import "api.proto"; + +message RegisterDefaultReq { + string Account = 1[(api.body)="account",(api.vd)="$!=''"]; + string Password = 2[(api.body)="password",(api.vd)="$!=''"]; +} + +message RegisterDefaultResp { + +} + +service RegisterService { + rpc RegisterDefault(RegisterDefaultReq) returns(RegisterDefaultResp) { + option (api.post) = "/auth/register/default"; + } +} diff --git a/code/base-project/base-go-v3/main.go b/code/base-project/base-go-v3/main.go index feca42a5..a4227814 100644 --- a/code/base-project/base-go-v3/main.go +++ b/code/base-project/base-go-v3/main.go @@ -6,6 +6,7 @@ import ( "cn/oneao/base-go/db" "cn/oneao/base-go/logx" "cn/oneao/base-go/utils/idgen" + "fmt" "github.com/cloudwego/hertz/pkg/app/server" "github.com/hertz-contrib/requestid" @@ -17,7 +18,12 @@ func main() { idgen.SetIdGenerator(options) // 初始化数据库 - db.InitDB() + err := db.InitDB() + if err != nil { + fmt.Println(err) + return + } + // 日志 logx.InitLog() diff --git a/code/base-project/base-go-v3/sqlc.yaml b/code/base-project/base-go-v3/sqlc.yaml new file mode 100644 index 00000000..d1aaa894 --- /dev/null +++ b/code/base-project/base-go-v3/sqlc.yaml @@ -0,0 +1,10 @@ +version: "2" +sql: + - engine: "postgresql" # 数据库 + queries: "db/queries" # query.sql文件的路径,该文件主要用于存储DML + schema: "db/schema.sql" # schema.sql文件的路径,该文件主要用于存储DDL + gen: + go: + package: "sqlcg" # 模块的包名 + out: "db/sqlc" # 代码生成路径 + sql_package: "pgx/v5"