diff --git a/README-NEW.md b/README-NEW.md index 07712c4..8a8696d 100644 --- a/README-NEW.md +++ b/README-NEW.md @@ -45,7 +45,8 @@ cd order ```bash mkdir ../rpc/proto mv order.proto proto/ -修改 option go_package="./order"; 为 option go_package="lone-services/rpc/order"; +修改 option go_package="./order"; 为 option go_package="lone-services/rpc/order"; + ``` ### 3. 删除order目录 diff --git a/bff/etc/admin.pb b/bff/etc/admin.pb deleted file mode 100644 index 3ebf565..0000000 Binary files a/bff/etc/admin.pb and /dev/null differ diff --git a/bff/etc/user.pb b/bff/etc/user.pb deleted file mode 100644 index c0ae403..0000000 Binary files a/bff/etc/user.pb and /dev/null differ diff --git a/lone-services.zip b/lone-services.zip deleted file mode 100644 index 36bb4fc..0000000 Binary files a/lone-services.zip and /dev/null differ diff --git a/user/Dockerfile b/user/Dockerfile deleted file mode 100644 index 43eabab..0000000 --- a/user/Dockerfile +++ /dev/null @@ -1,38 +0,0 @@ -# syntax=docker/dockerfile:1 - -FROM golang:1.26.5-alpine AS builder - -WORKDIR /src - -ENV GOPROXY=https://goproxy.cn,direct \ - CGO_ENABLED=0 \ - GOOS=linux \ - GOARCH=amd64 - -COPY pkg ./pkg -COPY user/go.mod user/go.sum ./user/ - -WORKDIR /src/user -RUN --mount=type=cache,target=/go/pkg/mod \ - go mod download - -COPY user/ ./ -RUN --mount=type=cache,target=/go/pkg/mod \ - --mount=type=cache,target=/root/.cache/go-build \ - go build -ldflags="-s -w" -o /out/user . - -FROM alpine:3.22 - -WORKDIR /app - -ENV TZ=Asia/Shanghai - -RUN apk add --no-cache tzdata \ - && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ - && echo "Asia/Shanghai" > /etc/timezone - -COPY --from=builder /out/user . - -EXPOSE 10300 - -CMD ["./user", "-f", "etc/user.yaml"] diff --git a/user/etc/user.yaml b/user/etc/user.yaml deleted file mode 100644 index dd536ee..0000000 --- a/user/etc/user.yaml +++ /dev/null @@ -1,7 +0,0 @@ -Nacos: - Hosts: - - rnacos:8848 - NamespaceId: test - Group: LONE_SERVICES - RegisterIP: user - ConfigID: user \ No newline at end of file diff --git a/user/internal/dao/user.go b/user/internal/dao/user.go deleted file mode 100644 index 38bfd36..0000000 --- a/user/internal/dao/user.go +++ /dev/null @@ -1,112 +0,0 @@ -package dao - -import "pkg.local/utils" - -type UserCreate struct { - Id int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"` - Openid string `gorm:"column:openid" json:"openid"` - Username string `gorm:"column:username" json:"username"` - Nickname string `gorm:"column:nickname" json:"nickname"` - Avatar string `gorm:"column:avatar" json:"avatar"` - Mobile string `gorm:"column:mobile" json:"mobile"` - Gender uint8 `gorm:"column:gender" json:"gender"` - Birthday string `gorm:"column:birthday" json:"birthday"` - AppId uint32 `gorm:"column:app_id" json:"app_id"` - Status uint8 `gorm:"column:status" json:"status"` - IsRegistered uint8 `gorm:"column:is_registered" json:"is_registered"` - IsFaceVerified uint8 `gorm:"column:is_face_verified" json:"is_face_verified"` - IsProfileCompleted uint8 `gorm:"column:is_profile_completed" json:"is_profile_completed"` - OnTrialNum int `gorm:"column:on_trial_num" json:"on_trial_num"` -} - -type UserCreateByPwd struct { - Id int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"` - Type uint8 `gorm:"column:type" json:"type"` - Account string `gorm:"column:account" json:"account"` - Password string `gorm:"column:password" json:"password"` - Salt string `gorm:"column:salt" json:"salt"` - Mobile string `gorm:"column:mobile" json:"mobile"` - AppId uint32 `gorm:"column:app_id" json:"app_id"` - Status uint8 `gorm:"column:status" json:"status"` - IsRegistered uint8 `gorm:"column:is_registered" json:"is_registered"` - IsFaceVerified uint8 `gorm:"column:is_face_verified" json:"is_face_verified"` - IsProfileCompleted uint8 `gorm:"column:is_profile_completed" json:"is_profile_completed"` - OnTrialNum int `gorm:"column:on_trial_num" json:"on_trial_num"` -} - -type UserExist struct { - Id int64 `gorm:"column:id" json:"id"` -} - -type UserInfo struct { - Id int64 `gorm:"column:id" json:"id"` - Openid string `gorm:"column:openid" json:"openid"` - Username string `gorm:"column:username" json:"username"` - Nickname string `gorm:"column:nickname" json:"nickname"` - Avatar string `gorm:"column:avatar" json:"avatar"` - Mobile string `gorm:"column:mobile" json:"mobile"` - Gender uint8 `gorm:"column:gender" json:"gender"` - Birthday string `gorm:"column:birthday" json:"birthday"` - Type uint8 `gorm:"column:type" json:"type"` - Account string `gorm:"column:account" json:"account"` - AppId uint32 `gorm:"column:app_id" json:"app_id"` - Status uint8 `gorm:"column:status" json:"status"` -} - -type UserLoginRow struct { - UserInfo - Salt string `gorm:"column:salt" json:"-"` - Password string `gorm:"column:password" json:"-"` -} - -type Token struct { - Token string `json:"token"` - Refresh string `json:"refresh"` - Info UserLoginSession `json:"info"` -} - -type UserLoginSession struct { - Id int64 `json:"id"` - Openid string `json:"openid"` - Username string `json:"username"` - Nickname string `json:"nickname"` - Avatar string `json:"avatar"` - Mobile string `json:"mobile"` - Gender uint8 `json:"gender"` - Birthday string `json:"birthday"` - Type uint8 `json:"type"` - Account string `json:"account"` - AppId uint32 `json:"app_id"` - LastTime utils.CustomTime `json:"last_time"` -} - -type UserListRow struct { - Id int64 `gorm:"column:id" json:"id"` - Username string `gorm:"column:username" json:"username"` - Nickname string `gorm:"column:nickname" json:"nickname"` - Avatar string `gorm:"column:avatar" json:"avatar"` - Mobile string `gorm:"column:mobile" json:"mobile"` - OnTrialNum int `gorm:"column:on_trial_num" json:"on_trial_num"` - Gender int `gorm:"column:gender" json:"gender"` - Birthday string `gorm:"column:birthday" json:"birthday"` - CreatedAt utils.CustomTime `gorm:"column:created_at" json:"created_at"` - UpdatedAt utils.CustomTime `gorm:"column:updated_at" json:"updated_at"` -} - -type UserListItem struct { - Id int64 `json:"id"` - Username string `json:"username"` - Nickname string `json:"nickname"` - HeadPortrait string `json:"head_portrait"` - Mobile string `json:"mobile"` - OnTrialNum int `json:"on_trial_num"` - Gender int `json:"gender"` - Birthday string `json:"birthday"` - CreatedAt utils.CustomTime `json:"created_at"` - UpdatedAt utils.CustomTime `json:"updated_at"` -} - -type UserItemsData struct { - Count int64 `json:"count"` - Items []UserListItem `json:"items"` -} diff --git a/user/internal/logic/useritemslogic.go b/user/internal/logic/useritemslogic.go deleted file mode 100644 index 81142eb..0000000 --- a/user/internal/logic/useritemslogic.go +++ /dev/null @@ -1,97 +0,0 @@ -package logic - -import ( - "context" - - "user/internal/dao" - "user/internal/model" - "user/internal/svc" - "user/user" - "user/validator" - - "pkg.local/log" - "pkg.local/modelbase" - "pkg.local/utils" - validateService "pkg.local/validate" - - "github.com/zeromicro/go-zero/core/logx" -) - -type UserItemsLogic struct { - ctx context.Context - svcCtx *svc.ServiceContext - logx.Logger -} - -func NewUserItemsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserItemsLogic { - return &UserItemsLogic{ - ctx: ctx, - svcCtx: svcCtx, - Logger: logx.WithContext(ctx), - } -} - -func (l *UserItemsLogic) UserItems(in *user.UserItemsReq) (*user.Response, error) { - var v validator.UserItemsValidator - if msg := validateService.ValidateFromProto(in, &v); msg != utils.StringEmpty { - return outResponse(utils.ErrorParams, msg), nil - } - - adminInfo := utils.GetUserFromCtx(l.ctx) - if adminInfo.ID < utils.NumberOne { - return failResponse(utils.ErrorNoLoginInfo), nil - } - - page := int(v.Page) - size := int(v.Size) - if page < modelbase.DefaultPage { - page = modelbase.DefaultPage - } - if size < utils.NumberOne { - size = modelbase.DefaultSize - } - - where := map[string]string{} - if v.Mobile != utils.StringEmpty { - mobile, cErr := utils.Crypto{}.AESEncryptECB(v.Mobile) - if cErr != nil { - log.Errorf("user items encrypt mobile: %v", cErr) - return failResponse(utils.ErrorEncryptAesError), nil - } - where["mobile"] = mobile - } - - var list []dao.UserListRow - result, err := model.UserModel{}.Init().Page(modelbase.Params{ - Eq: where, - Order: "id DESC", - Page: page, - Size: size, - }, &list) - if err != nil { - log.Errorf("user items: %v", err) - return failResponse(utils.Fail), nil - } - - items := make([]dao.UserListItem, 0, len(list)) - for _, row := range list { - headPortrait, _ := utils.BuildImageURL(row.Avatar).(string) - items = append(items, dao.UserListItem{ - Id: row.Id, - Username: row.Username, - Nickname: row.Nickname, - HeadPortrait: headPortrait, - Mobile: utils.DecryptMobile(row.Mobile), - OnTrialNum: row.OnTrialNum, - Gender: row.Gender, - Birthday: row.Birthday, - CreatedAt: row.CreatedAt, - UpdatedAt: row.UpdatedAt, - }) - } - - return okResponse(dao.UserItemsData{ - Count: result.Count, - Items: items, - }), nil -} diff --git a/user/internal/logic/userstatuslogic.go b/user/internal/logic/userstatuslogic.go deleted file mode 100644 index 6c07b73..0000000 --- a/user/internal/logic/userstatuslogic.go +++ /dev/null @@ -1,58 +0,0 @@ -package logic - -import ( - "context" - "strconv" - - "user/internal/model" - "user/internal/svc" - "user/user" - "user/validator" - - "pkg.local/log" - "pkg.local/modelbase" - "pkg.local/utils" - validateService "pkg.local/validate" - - "github.com/zeromicro/go-zero/core/logx" -) - -type UserStatusLogic struct { - ctx context.Context - svcCtx *svc.ServiceContext - logx.Logger -} - -func NewUserStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserStatusLogic { - return &UserStatusLogic{ - ctx: ctx, - svcCtx: svcCtx, - Logger: logx.WithContext(ctx), - } -} - -func (l *UserStatusLogic) UserStatus(in *user.UserStatusReq) (*user.Response, error) { - var v validator.UserStatusValidator - if msg := validateService.ValidateFromProto(in, &v); msg != utils.StringEmpty { - return outResponse(utils.ErrorParams, msg), nil - } - - adminInfo := utils.GetUserFromCtx(l.ctx) - if adminInfo.ID < utils.NumberOne { - return failResponse(utils.ErrorNoLoginInfo), nil - } - - _, err := model.UserModel{}.Init().Edit(modelbase.Params{ - Eq: map[string]string{ - "id": strconv.FormatInt(v.Id, utils.NumberTen), - }, - }, map[string]interface{}{ - "status": v.Status, - }) - if err != nil { - log.Errorf("user status: %v", err) - return failResponse(utils.Fail), nil - } - - return okResponse(nil), nil -} diff --git a/user/internal/server/userserver.go b/user/internal/server/userserver.go deleted file mode 100644 index 56a02ea..0000000 --- a/user/internal/server/userserver.go +++ /dev/null @@ -1,49 +0,0 @@ -// Code generated by goctl. DO NOT EDIT. -// goctl 1.10.1 -// Source: user.proto - -package server - -import ( - "context" - - "user/internal/logic" - "user/internal/svc" - "user/user" -) - -type UserServer struct { - svcCtx *svc.ServiceContext - user.UnimplementedUserServer -} - -func NewUserServer(svcCtx *svc.ServiceContext) *UserServer { - return &UserServer{ - svcCtx: svcCtx, - } -} - -func (s *UserServer) Register(ctx context.Context, in *user.RegisterReq) (*user.Response, error) { - l := logic.NewRegisterLogic(ctx, s.svcCtx) - return l.Register(in) -} - -func (s *UserServer) RegisterByUser(ctx context.Context, in *user.RegisterByUserReq) (*user.Response, error) { - l := logic.NewRegisterByUserLogic(ctx, s.svcCtx) - return l.RegisterByUser(in) -} - -func (s *UserServer) Login(ctx context.Context, in *user.LoginReq) (*user.Response, error) { - l := logic.NewLoginLogic(ctx, s.svcCtx) - return l.Login(in) -} - -func (s *UserServer) UserItems(ctx context.Context, in *user.UserItemsReq) (*user.Response, error) { - l := logic.NewUserItemsLogic(ctx, s.svcCtx) - return l.UserItems(in) -} - -func (s *UserServer) UserStatus(ctx context.Context, in *user.UserStatusReq) (*user.Response, error) { - l := logic.NewUserStatusLogic(ctx, s.svcCtx) - return l.UserStatus(in) -} diff --git a/user/proto/user.proto b/user/proto/user.proto deleted file mode 100644 index 9dd6c22..0000000 --- a/user/proto/user.proto +++ /dev/null @@ -1,84 +0,0 @@ -syntax = "proto3"; - -package user; -option go_package="./user"; - -import "google/api/annotations.proto"; - -message Response { - int32 code = 1; - string msg = 2; - string data = 3; -} - -// 小程序注册 -message RegisterReq { - string openid = 1; // 可空;空则服务端模拟 - string nickname = 2; - string avatar = 3; - string mobile = 4; - uint32 gender = 5; // 1男 2女 - string birthday = 6; - string username = 7; - uint32 app_id = 8; // 应用标识 -} - -// 账号密码注册 -message RegisterByUserReq { - uint32 type = 1; // 1手机号 2邮箱 - string account = 2; - string pwd = 3; - string code = 4; - uint32 app_id = 5; // 应用标识 -} - -// openid 登录 -message LoginReq { - string openid = 1; -} - -// 管理端用户列表 -message UserItemsReq { - string mobile = 1; - int32 page = 2; - int32 size = 3; -} - -// 管理端修改用户状态 -message UserStatusReq { - int64 id = 1; - int32 status = 2; -} - -service User { - rpc Register(RegisterReq) returns (Response) { - option (google.api.http) = { - post: "/customer/v3/register" - body: "*" - }; - } - rpc RegisterByUser(RegisterByUserReq) returns (Response) { - option (google.api.http) = { - post: "/customer/v3/register/user" - body: "*" - }; - } - rpc Login(LoginReq) returns (Response) { - option (google.api.http) = { - post: "/customer/v3/login" - body: "*" - }; - } - rpc UserItems(UserItemsReq) returns (Response) { - option (google.api.http) = { - get: "/admin/v3/user/items" - body: "*" - }; - } - rpc UserStatus(UserStatusReq) returns (Response) { - option (google.api.http) = { - put: "/admin/v3/user/status" - body: "*" - }; - } -} diff --git a/user/run.toml b/user/run.toml deleted file mode 100644 index 1bf7e6e..0000000 --- a/user/run.toml +++ /dev/null @@ -1,43 +0,0 @@ -[base] - login_out_time=43200 - login_refresh_out_time=83200 - name = "user-service" - listenOn = "0.0.0.0:10300" - mode = "dev" -[log] - path = "logs" - serviceName = "user-service" - mode = "file" - encoding = "plain" - level = "info" - keepDays = 7 - maxSize = 50 - maxBackups = 5 - compress = false -# 测试的地址 -[mysql] - host = '39.106.171.204' - port = 33066 - user = 'root' - password = 'MOLXRZNOU4Y4' - database = 'dms-users' - charset = 'utf8mb4' - prefix = '' - debug = true -[mysql_read] - host = '39.106.171.204' - port = 33066 - user = 'root' - password = 'MOLXRZNOU4Y4' - database = 'dms-users' - charset = 'utf8mb4' - prefix = '' - -[redis] - host = '39.106.171.204' - password = 'lLMLcuPpzSj' - port = 6379 - db = 0 - -[encrypt] - data_key = "u2t9T3luZtoRfhBstkFN6TiIMW38BA8a" #内容数据, \ No newline at end of file diff --git a/user/user/user.pb.go b/user/user/user.pb.go deleted file mode 100644 index 87740a6..0000000 --- a/user/user/user.pb.go +++ /dev/null @@ -1,524 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.11 -// protoc v3.19.4 -// source: proto/user.proto - -package user - -import ( - _ "google.golang.org/genproto/googleapis/api/annotations" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type Response struct { - state protoimpl.MessageState `protogen:"open.v1"` - Code int32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"` - Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"` - Data string `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Response) Reset() { - *x = Response{} - mi := &file_proto_user_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Response) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Response) ProtoMessage() {} - -func (x *Response) ProtoReflect() protoreflect.Message { - mi := &file_proto_user_proto_msgTypes[0] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Response.ProtoReflect.Descriptor instead. -func (*Response) Descriptor() ([]byte, []int) { - return file_proto_user_proto_rawDescGZIP(), []int{0} -} - -func (x *Response) GetCode() int32 { - if x != nil { - return x.Code - } - return 0 -} - -func (x *Response) GetMsg() string { - if x != nil { - return x.Msg - } - return "" -} - -func (x *Response) GetData() string { - if x != nil { - return x.Data - } - return "" -} - -// 小程序注册 -type RegisterReq struct { - state protoimpl.MessageState `protogen:"open.v1"` - Openid string `protobuf:"bytes,1,opt,name=openid,proto3" json:"openid,omitempty"` // 可空;空则服务端模拟 - Nickname string `protobuf:"bytes,2,opt,name=nickname,proto3" json:"nickname,omitempty"` - Avatar string `protobuf:"bytes,3,opt,name=avatar,proto3" json:"avatar,omitempty"` - Mobile string `protobuf:"bytes,4,opt,name=mobile,proto3" json:"mobile,omitempty"` - Gender uint32 `protobuf:"varint,5,opt,name=gender,proto3" json:"gender,omitempty"` // 1男 2女 - Birthday string `protobuf:"bytes,6,opt,name=birthday,proto3" json:"birthday,omitempty"` - Username string `protobuf:"bytes,7,opt,name=username,proto3" json:"username,omitempty"` - AppId uint32 `protobuf:"varint,8,opt,name=app_id,json=appId,proto3" json:"app_id,omitempty"` // 应用标识 - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RegisterReq) Reset() { - *x = RegisterReq{} - mi := &file_proto_user_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RegisterReq) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RegisterReq) ProtoMessage() {} - -func (x *RegisterReq) ProtoReflect() protoreflect.Message { - mi := &file_proto_user_proto_msgTypes[1] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RegisterReq.ProtoReflect.Descriptor instead. -func (*RegisterReq) Descriptor() ([]byte, []int) { - return file_proto_user_proto_rawDescGZIP(), []int{1} -} - -func (x *RegisterReq) GetOpenid() string { - if x != nil { - return x.Openid - } - return "" -} - -func (x *RegisterReq) GetNickname() string { - if x != nil { - return x.Nickname - } - return "" -} - -func (x *RegisterReq) GetAvatar() string { - if x != nil { - return x.Avatar - } - return "" -} - -func (x *RegisterReq) GetMobile() string { - if x != nil { - return x.Mobile - } - return "" -} - -func (x *RegisterReq) GetGender() uint32 { - if x != nil { - return x.Gender - } - return 0 -} - -func (x *RegisterReq) GetBirthday() string { - if x != nil { - return x.Birthday - } - return "" -} - -func (x *RegisterReq) GetUsername() string { - if x != nil { - return x.Username - } - return "" -} - -func (x *RegisterReq) GetAppId() uint32 { - if x != nil { - return x.AppId - } - return 0 -} - -// 账号密码注册 -type RegisterByUserReq struct { - state protoimpl.MessageState `protogen:"open.v1"` - Type uint32 `protobuf:"varint,1,opt,name=type,proto3" json:"type,omitempty"` // 1手机号 2邮箱 - Account string `protobuf:"bytes,2,opt,name=account,proto3" json:"account,omitempty"` - Pwd string `protobuf:"bytes,3,opt,name=pwd,proto3" json:"pwd,omitempty"` - Code string `protobuf:"bytes,4,opt,name=code,proto3" json:"code,omitempty"` - AppId uint32 `protobuf:"varint,5,opt,name=app_id,json=appId,proto3" json:"app_id,omitempty"` // 应用标识 - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RegisterByUserReq) Reset() { - *x = RegisterByUserReq{} - mi := &file_proto_user_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RegisterByUserReq) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RegisterByUserReq) ProtoMessage() {} - -func (x *RegisterByUserReq) ProtoReflect() protoreflect.Message { - mi := &file_proto_user_proto_msgTypes[2] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RegisterByUserReq.ProtoReflect.Descriptor instead. -func (*RegisterByUserReq) Descriptor() ([]byte, []int) { - return file_proto_user_proto_rawDescGZIP(), []int{2} -} - -func (x *RegisterByUserReq) GetType() uint32 { - if x != nil { - return x.Type - } - return 0 -} - -func (x *RegisterByUserReq) GetAccount() string { - if x != nil { - return x.Account - } - return "" -} - -func (x *RegisterByUserReq) GetPwd() string { - if x != nil { - return x.Pwd - } - return "" -} - -func (x *RegisterByUserReq) GetCode() string { - if x != nil { - return x.Code - } - return "" -} - -func (x *RegisterByUserReq) GetAppId() uint32 { - if x != nil { - return x.AppId - } - return 0 -} - -// openid 登录 -type LoginReq struct { - state protoimpl.MessageState `protogen:"open.v1"` - Openid string `protobuf:"bytes,1,opt,name=openid,proto3" json:"openid,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *LoginReq) Reset() { - *x = LoginReq{} - mi := &file_proto_user_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *LoginReq) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*LoginReq) ProtoMessage() {} - -func (x *LoginReq) ProtoReflect() protoreflect.Message { - mi := &file_proto_user_proto_msgTypes[3] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use LoginReq.ProtoReflect.Descriptor instead. -func (*LoginReq) Descriptor() ([]byte, []int) { - return file_proto_user_proto_rawDescGZIP(), []int{3} -} - -func (x *LoginReq) GetOpenid() string { - if x != nil { - return x.Openid - } - return "" -} - -// 管理端用户列表 -type UserItemsReq struct { - state protoimpl.MessageState `protogen:"open.v1"` - Mobile string `protobuf:"bytes,1,opt,name=mobile,proto3" json:"mobile,omitempty"` - Page int32 `protobuf:"varint,2,opt,name=page,proto3" json:"page,omitempty"` - Size int32 `protobuf:"varint,3,opt,name=size,proto3" json:"size,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UserItemsReq) Reset() { - *x = UserItemsReq{} - mi := &file_proto_user_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UserItemsReq) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UserItemsReq) ProtoMessage() {} - -func (x *UserItemsReq) ProtoReflect() protoreflect.Message { - mi := &file_proto_user_proto_msgTypes[4] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UserItemsReq.ProtoReflect.Descriptor instead. -func (*UserItemsReq) Descriptor() ([]byte, []int) { - return file_proto_user_proto_rawDescGZIP(), []int{4} -} - -func (x *UserItemsReq) GetMobile() string { - if x != nil { - return x.Mobile - } - return "" -} - -func (x *UserItemsReq) GetPage() int32 { - if x != nil { - return x.Page - } - return 0 -} - -func (x *UserItemsReq) GetSize() int32 { - if x != nil { - return x.Size - } - return 0 -} - -// 管理端修改用户状态 -type UserStatusReq struct { - state protoimpl.MessageState `protogen:"open.v1"` - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - Status int32 `protobuf:"varint,2,opt,name=status,proto3" json:"status,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UserStatusReq) Reset() { - *x = UserStatusReq{} - mi := &file_proto_user_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UserStatusReq) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UserStatusReq) ProtoMessage() {} - -func (x *UserStatusReq) ProtoReflect() protoreflect.Message { - mi := &file_proto_user_proto_msgTypes[5] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UserStatusReq.ProtoReflect.Descriptor instead. -func (*UserStatusReq) Descriptor() ([]byte, []int) { - return file_proto_user_proto_rawDescGZIP(), []int{5} -} - -func (x *UserStatusReq) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *UserStatusReq) GetStatus() int32 { - if x != nil { - return x.Status - } - return 0 -} - -var File_proto_user_proto protoreflect.FileDescriptor - -const file_proto_user_proto_rawDesc = "" + - "\n" + - "\x10proto/user.proto\x12\x04user\x1a\x1cgoogle/api/annotations.proto\"D\n" + - "\bResponse\x12\x12\n" + - "\x04code\x18\x01 \x01(\x05R\x04code\x12\x10\n" + - "\x03msg\x18\x02 \x01(\tR\x03msg\x12\x12\n" + - "\x04data\x18\x03 \x01(\tR\x04data\"\xd8\x01\n" + - "\vRegisterReq\x12\x16\n" + - "\x06openid\x18\x01 \x01(\tR\x06openid\x12\x1a\n" + - "\bnickname\x18\x02 \x01(\tR\bnickname\x12\x16\n" + - "\x06avatar\x18\x03 \x01(\tR\x06avatar\x12\x16\n" + - "\x06mobile\x18\x04 \x01(\tR\x06mobile\x12\x16\n" + - "\x06gender\x18\x05 \x01(\rR\x06gender\x12\x1a\n" + - "\bbirthday\x18\x06 \x01(\tR\bbirthday\x12\x1a\n" + - "\busername\x18\a \x01(\tR\busername\x12\x15\n" + - "\x06app_id\x18\b \x01(\rR\x05appId\"~\n" + - "\x11RegisterByUserReq\x12\x12\n" + - "\x04type\x18\x01 \x01(\rR\x04type\x12\x18\n" + - "\aaccount\x18\x02 \x01(\tR\aaccount\x12\x10\n" + - "\x03pwd\x18\x03 \x01(\tR\x03pwd\x12\x12\n" + - "\x04code\x18\x04 \x01(\tR\x04code\x12\x15\n" + - "\x06app_id\x18\x05 \x01(\rR\x05appId\"\"\n" + - "\bLoginReq\x12\x16\n" + - "\x06openid\x18\x01 \x01(\tR\x06openid\"N\n" + - "\fUserItemsReq\x12\x16\n" + - "\x06mobile\x18\x01 \x01(\tR\x06mobile\x12\x12\n" + - "\x04page\x18\x02 \x01(\x05R\x04page\x12\x12\n" + - "\x04size\x18\x03 \x01(\x05R\x04size\"7\n" + - "\rUserStatusReq\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12\x16\n" + - "\x06status\x18\x02 \x01(\x05R\x06status2\xa8\x03\n" + - "\x04User\x12O\n" + - "\bRegister\x12\x11.user.RegisterReq\x1a\x0e.user.Response\" \x82\xd3\xe4\x93\x02\x1a:\x01*\"\x15/customer/v3/register\x12`\n" + - "\x0eRegisterByUser\x12\x17.user.RegisterByUserReq\x1a\x0e.user.Response\"%\x82\xd3\xe4\x93\x02\x1f:\x01*\"\x1a/customer/v3/register/user\x12F\n" + - "\x05Login\x12\x0e.user.LoginReq\x1a\x0e.user.Response\"\x1d\x82\xd3\xe4\x93\x02\x17:\x01*\"\x12/customer/v3/login\x12P\n" + - "\tUserItems\x12\x12.user.UserItemsReq\x1a\x0e.user.Response\"\x1f\x82\xd3\xe4\x93\x02\x19:\x01*\x12\x14/admin/v3/user/items\x12S\n" + - "\n" + - "UserStatus\x12\x13.user.UserStatusReq\x1a\x0e.user.Response\" \x82\xd3\xe4\x93\x02\x1a:\x01*\x1a\x15/admin/v3/user/statusB\bZ\x06./userb\x06proto3" - -var ( - file_proto_user_proto_rawDescOnce sync.Once - file_proto_user_proto_rawDescData []byte -) - -func file_proto_user_proto_rawDescGZIP() []byte { - file_proto_user_proto_rawDescOnce.Do(func() { - file_proto_user_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_proto_user_proto_rawDesc), len(file_proto_user_proto_rawDesc))) - }) - return file_proto_user_proto_rawDescData -} - -var file_proto_user_proto_msgTypes = make([]protoimpl.MessageInfo, 6) -var file_proto_user_proto_goTypes = []any{ - (*Response)(nil), // 0: user.Response - (*RegisterReq)(nil), // 1: user.RegisterReq - (*RegisterByUserReq)(nil), // 2: user.RegisterByUserReq - (*LoginReq)(nil), // 3: user.LoginReq - (*UserItemsReq)(nil), // 4: user.UserItemsReq - (*UserStatusReq)(nil), // 5: user.UserStatusReq -} -var file_proto_user_proto_depIdxs = []int32{ - 1, // 0: user.User.Register:input_type -> user.RegisterReq - 2, // 1: user.User.RegisterByUser:input_type -> user.RegisterByUserReq - 3, // 2: user.User.Login:input_type -> user.LoginReq - 4, // 3: user.User.UserItems:input_type -> user.UserItemsReq - 5, // 4: user.User.UserStatus:input_type -> user.UserStatusReq - 0, // 5: user.User.Register:output_type -> user.Response - 0, // 6: user.User.RegisterByUser:output_type -> user.Response - 0, // 7: user.User.Login:output_type -> user.Response - 0, // 8: user.User.UserItems:output_type -> user.Response - 0, // 9: user.User.UserStatus:output_type -> user.Response - 5, // [5:10] is the sub-list for method output_type - 0, // [0:5] 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_proto_user_proto_init() } -func file_proto_user_proto_init() { - if File_proto_user_proto != nil { - return - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_proto_user_proto_rawDesc), len(file_proto_user_proto_rawDesc)), - NumEnums: 0, - NumMessages: 6, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_proto_user_proto_goTypes, - DependencyIndexes: file_proto_user_proto_depIdxs, - MessageInfos: file_proto_user_proto_msgTypes, - }.Build() - File_proto_user_proto = out.File - file_proto_user_proto_goTypes = nil - file_proto_user_proto_depIdxs = nil -} diff --git a/user/user/user_grpc.pb.go b/user/user/user_grpc.pb.go deleted file mode 100644 index e21c4f2..0000000 --- a/user/user/user_grpc.pb.go +++ /dev/null @@ -1,273 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.6.2 -// - protoc v3.19.4 -// source: proto/user.proto - -package user - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.64.0 or later. -const _ = grpc.SupportPackageIsVersion9 - -const ( - User_Register_FullMethodName = "/user.User/Register" - User_RegisterByUser_FullMethodName = "/user.User/RegisterByUser" - User_Login_FullMethodName = "/user.User/Login" - User_UserItems_FullMethodName = "/user.User/UserItems" - User_UserStatus_FullMethodName = "/user.User/UserStatus" -) - -// UserClient is the client API for User service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type UserClient interface { - Register(ctx context.Context, in *RegisterReq, opts ...grpc.CallOption) (*Response, error) - RegisterByUser(ctx context.Context, in *RegisterByUserReq, opts ...grpc.CallOption) (*Response, error) - Login(ctx context.Context, in *LoginReq, opts ...grpc.CallOption) (*Response, error) - UserItems(ctx context.Context, in *UserItemsReq, opts ...grpc.CallOption) (*Response, error) - UserStatus(ctx context.Context, in *UserStatusReq, opts ...grpc.CallOption) (*Response, error) -} - -type userClient struct { - cc grpc.ClientConnInterface -} - -func NewUserClient(cc grpc.ClientConnInterface) UserClient { - return &userClient{cc} -} - -func (c *userClient) Register(ctx context.Context, in *RegisterReq, opts ...grpc.CallOption) (*Response, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(Response) - err := c.cc.Invoke(ctx, User_Register_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *userClient) RegisterByUser(ctx context.Context, in *RegisterByUserReq, opts ...grpc.CallOption) (*Response, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(Response) - err := c.cc.Invoke(ctx, User_RegisterByUser_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *userClient) Login(ctx context.Context, in *LoginReq, opts ...grpc.CallOption) (*Response, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(Response) - err := c.cc.Invoke(ctx, User_Login_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *userClient) UserItems(ctx context.Context, in *UserItemsReq, opts ...grpc.CallOption) (*Response, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(Response) - err := c.cc.Invoke(ctx, User_UserItems_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *userClient) UserStatus(ctx context.Context, in *UserStatusReq, opts ...grpc.CallOption) (*Response, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(Response) - err := c.cc.Invoke(ctx, User_UserStatus_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -// UserServer is the server API for User service. -// All implementations must embed UnimplementedUserServer -// for forward compatibility. -type UserServer interface { - Register(context.Context, *RegisterReq) (*Response, error) - RegisterByUser(context.Context, *RegisterByUserReq) (*Response, error) - Login(context.Context, *LoginReq) (*Response, error) - UserItems(context.Context, *UserItemsReq) (*Response, error) - UserStatus(context.Context, *UserStatusReq) (*Response, error) - mustEmbedUnimplementedUserServer() -} - -// UnimplementedUserServer must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedUserServer struct{} - -func (UnimplementedUserServer) Register(context.Context, *RegisterReq) (*Response, error) { - return nil, status.Error(codes.Unimplemented, "method Register not implemented") -} -func (UnimplementedUserServer) RegisterByUser(context.Context, *RegisterByUserReq) (*Response, error) { - return nil, status.Error(codes.Unimplemented, "method RegisterByUser not implemented") -} -func (UnimplementedUserServer) Login(context.Context, *LoginReq) (*Response, error) { - return nil, status.Error(codes.Unimplemented, "method Login not implemented") -} -func (UnimplementedUserServer) UserItems(context.Context, *UserItemsReq) (*Response, error) { - return nil, status.Error(codes.Unimplemented, "method UserItems not implemented") -} -func (UnimplementedUserServer) UserStatus(context.Context, *UserStatusReq) (*Response, error) { - return nil, status.Error(codes.Unimplemented, "method UserStatus not implemented") -} -func (UnimplementedUserServer) mustEmbedUnimplementedUserServer() {} -func (UnimplementedUserServer) testEmbeddedByValue() {} - -// UnsafeUserServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to UserServer will -// result in compilation errors. -type UnsafeUserServer interface { - mustEmbedUnimplementedUserServer() -} - -func RegisterUserServer(s grpc.ServiceRegistrar, srv UserServer) { - // If the following call panics, it indicates UnimplementedUserServer was - // embedded by pointer and is nil. This will cause panics if an - // unimplemented method is ever invoked, so we test this at initialization - // time to prevent it from happening at runtime later due to I/O. - if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { - t.testEmbeddedByValue() - } - s.RegisterService(&User_ServiceDesc, srv) -} - -func _User_Register_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(RegisterReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(UserServer).Register(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: User_Register_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(UserServer).Register(ctx, req.(*RegisterReq)) - } - return interceptor(ctx, in, info, handler) -} - -func _User_RegisterByUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(RegisterByUserReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(UserServer).RegisterByUser(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: User_RegisterByUser_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(UserServer).RegisterByUser(ctx, req.(*RegisterByUserReq)) - } - return interceptor(ctx, in, info, handler) -} - -func _User_Login_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(LoginReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(UserServer).Login(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: User_Login_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(UserServer).Login(ctx, req.(*LoginReq)) - } - return interceptor(ctx, in, info, handler) -} - -func _User_UserItems_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UserItemsReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(UserServer).UserItems(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: User_UserItems_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(UserServer).UserItems(ctx, req.(*UserItemsReq)) - } - return interceptor(ctx, in, info, handler) -} - -func _User_UserStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UserStatusReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(UserServer).UserStatus(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: User_UserStatus_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(UserServer).UserStatus(ctx, req.(*UserStatusReq)) - } - return interceptor(ctx, in, info, handler) -} - -// User_ServiceDesc is the grpc.ServiceDesc for User service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var User_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "user.User", - HandlerType: (*UserServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Register", - Handler: _User_Register_Handler, - }, - { - MethodName: "RegisterByUser", - Handler: _User_RegisterByUser_Handler, - }, - { - MethodName: "Login", - Handler: _User_Login_Handler, - }, - { - MethodName: "UserItems", - Handler: _User_UserItems_Handler, - }, - { - MethodName: "UserStatus", - Handler: _User_UserStatus_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "proto/user.proto", -} diff --git a/user/userclient/user.go b/user/userclient/user.go deleted file mode 100644 index bd0a44f..0000000 --- a/user/userclient/user.go +++ /dev/null @@ -1,66 +0,0 @@ -// Code generated by goctl. DO NOT EDIT. -// goctl 1.10.1 -// Source: user.proto - -package userclient - -import ( - "context" - - "user/user" - - "github.com/zeromicro/go-zero/zrpc" - "google.golang.org/grpc" -) - -type ( - LoginReq = user.LoginReq - RegisterByUserReq = user.RegisterByUserReq - RegisterReq = user.RegisterReq - Response = user.Response - UserItemsReq = user.UserItemsReq - UserStatusReq = user.UserStatusReq - - User interface { - Register(ctx context.Context, in *RegisterReq, opts ...grpc.CallOption) (*Response, error) - RegisterByUser(ctx context.Context, in *RegisterByUserReq, opts ...grpc.CallOption) (*Response, error) - Login(ctx context.Context, in *LoginReq, opts ...grpc.CallOption) (*Response, error) - UserItems(ctx context.Context, in *UserItemsReq, opts ...grpc.CallOption) (*Response, error) - UserStatus(ctx context.Context, in *UserStatusReq, opts ...grpc.CallOption) (*Response, error) - } - - defaultUser struct { - cli zrpc.Client - } -) - -func NewUser(cli zrpc.Client) User { - return &defaultUser{ - cli: cli, - } -} - -func (m *defaultUser) Register(ctx context.Context, in *RegisterReq, opts ...grpc.CallOption) (*Response, error) { - client := user.NewUserClient(m.cli.Conn()) - return client.Register(ctx, in, opts...) -} - -func (m *defaultUser) RegisterByUser(ctx context.Context, in *RegisterByUserReq, opts ...grpc.CallOption) (*Response, error) { - client := user.NewUserClient(m.cli.Conn()) - return client.RegisterByUser(ctx, in, opts...) -} - -func (m *defaultUser) Login(ctx context.Context, in *LoginReq, opts ...grpc.CallOption) (*Response, error) { - client := user.NewUserClient(m.cli.Conn()) - return client.Login(ctx, in, opts...) -} - -func (m *defaultUser) UserItems(ctx context.Context, in *UserItemsReq, opts ...grpc.CallOption) (*Response, error) { - client := user.NewUserClient(m.cli.Conn()) - return client.UserItems(ctx, in, opts...) -} - -func (m *defaultUser) UserStatus(ctx context.Context, in *UserStatusReq, opts ...grpc.CallOption) (*Response, error) { - client := user.NewUserClient(m.cli.Conn()) - return client.UserStatus(ctx, in, opts...) -} diff --git a/user/validator/user.go b/user/validator/user.go deleted file mode 100644 index 9940fdc..0000000 --- a/user/validator/user.go +++ /dev/null @@ -1,83 +0,0 @@ -package validator - -import "pkg.local/validate" - -type RegisterValidator struct { - Openid string - Nickname string `validate:"required"` - Avatar string `validate:"required"` - Mobile string `validate:"required"` - Gender uint32 `validate:"required,oneof=1 2"` - Birthday string `validate:"required"` - Username string `validate:"required"` - AppId uint32 `validate:"required"` -} - -func (p RegisterValidator) GetMessage() validate.ValidatorMessages { - return validate.ValidatorMessages{ - "Nickname.required": "昵称不能为空", - "Avatar.required": "头像不能为空", - "Mobile.required": "手机号不能为空", - "Gender.required": "性别不能为空", - "Gender.oneof": "性别传值不对", - "Birthday.required": "生日不能为空", - "Username.required": "姓名不能为空", - "AppId.required": "应用标识不能为空", - } -} - -type RegisterByUserValidator struct { - Type uint32 `validate:"required,oneof=1 2"` - Account string `validate:"required"` - Pwd string `validate:"required"` - Code string `validate:"required"` - AppId uint32 `validate:"required"` -} - -func (p RegisterByUserValidator) GetMessage() validate.ValidatorMessages { - return validate.ValidatorMessages{ - "Type.required": "类型不能为空", - "Type.oneof": "类型传值不对", - "Account.required": "账号不能为空", - "Pwd.required": "密码不能为空", - "Code.required": "验证码不能为空", - "AppId.required": "应用标识不能为空", - } -} - -type LoginValidator struct { - Openid string `validate:"required"` -} - -func (p LoginValidator) GetMessage() validate.ValidatorMessages { - return validate.ValidatorMessages{ - "Openid.required": "Openid不能为空", - } -} - -type UserItemsValidator struct { - Mobile string - Page int32 `validate:"omitempty,min=1"` - Size int32 `validate:"omitempty,min=1,max=100"` -} - -func (p UserItemsValidator) GetMessage() validate.ValidatorMessages { - return validate.ValidatorMessages{ - "Page.min": "页码最小为1", - "Size.min": "每页数量最小为1", - "Size.max": "每页数量最大为100", - } -} - -type UserStatusValidator struct { - Id int64 `validate:"required"` - Status int32 `validate:"required,oneof=1 2"` -} - -func (p UserStatusValidator) GetMessage() validate.ValidatorMessages { - return validate.ValidatorMessages{ - "Id.required": "用户ID不能为空", - "Status.required": "状态不能为空", - "Status.oneof": "状态传值不对", - } -}