add docker

This commit is contained in:
daniel.w 2024-08-22 22:27:13 +08:00
parent 02d623cb67
commit d7b01eb4e1
29 changed files with 4872 additions and 0 deletions

8
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="Go" enabled="true" />
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

12
.idea/dataSources.xml Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="@localhost" uuid="68b84de2-e0b4-4302-bb99-2a65764fd57a">
<driver-ref>mysql.8</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
<jdbc-url>jdbc:mysql://localhost:3306</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>
</project>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/app-cloudep-member-server.iml" filepath="$PROJECT_DIR$/.idea/app-cloudep-member-server.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

47
build/Dockerfile Normal file
View File

@ -0,0 +1,47 @@
###########
# BUILDER #
###########
FROM golang:1.22.3 as builder
ARG VERSION
ARG BUILT
ARG GIT_COMMIT
ARG SSH_PRV_KEY
# private go packages
ENV GOPRIVATE=code.30cm.net
ENV FLAG="-s -w -X main.Version=${VERSION} -X main.Built=${BUILT} -X main.GitCommit=${GIT_COMMIT}"
WORKDIR /app
COPY . .
RUN apt-get update && \
apt-get install git
# Make the root foler for our ssh
RUN mkdir -p /root/.ssh && \
chmod 0700 /root/.ssh && \
ssh-keyscan git.30cm.net > /root/.ssh/known_hosts && \
echo "$SSH_PRV_KEY" > /root/.ssh/id_rsa && \
chmod 600 /root/.ssh/id_rsa
RUN --mount=type=ssh go mod download
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-ldflags "$FLAG" \
-o service
##########
## FINAL #
##########
#
FROM gcr.io/distroless/static-debian11
WORKDIR /app
COPY --from=builder /app/service /app/service
COPY --from=builder /app/etc/service.yaml /app/etc/service.yaml
EXPOSE 8080
CMD ["/app/service"]

1
chart/readme.md Normal file
View File

@ -0,0 +1 @@
// TODO 未來要放 helm 的地方

147
client/account/account.go Normal file
View File

@ -0,0 +1,147 @@
// Code generated by goctl. DO NOT EDIT.
// Source: service.proto
package account
import (
"context"
"app-cloudep-member-server/gen_result/pb/member"
"github.com/zeromicro/go-zero/zrpc"
"google.golang.org/grpc"
)
type (
BindingUserReq = member.BindingUserReq
BindingUserResp = member.BindingUserResp
CreateLoginUserReq = member.CreateLoginUserReq
CreateUserInfoReq = member.CreateUserInfoReq
GenerateRefreshCodeReq = member.GenerateRefreshCodeReq
GenerateRefreshCodeResp = member.GenerateRefreshCodeResp
GetAccountInfoResp = member.GetAccountInfoResp
GetUIDByAccountReq = member.GetUIDByAccountReq
GetUidByAccountResp = member.GetUidByAccountResp
GetUserInfoReq = member.GetUserInfoReq
GetUserInfoResp = member.GetUserInfoResp
ListUserInfoReq = member.ListUserInfoReq
ListUserInfoResp = member.ListUserInfoResp
NoneReq = member.NoneReq
OKResp = member.OKResp
Pager = member.Pager
UpdateStatusReq = member.UpdateStatusReq
UpdateTokenReq = member.UpdateTokenReq
UpdateUserInfoReq = member.UpdateUserInfoReq
UserInfo = member.UserInfo
VerifyCode = member.VerifyCode
VerifyRefreshCodeReq = member.VerifyRefreshCodeReq
Account interface {
// CreateUserAccount 建立帳號與密碼 -> 可登入,但可不可以做其他事情看業務流程,也可以只註冊就好
CreateUserAccount(ctx context.Context, in *CreateLoginUserReq, opts ...grpc.CallOption) (*OKResp, error)
// GetUserAccountInfo 取得帳號密碼資料
GetUserAccountInfo(ctx context.Context, in *GetUIDByAccountReq, opts ...grpc.CallOption) (*GetAccountInfoResp, error)
// UpdateUserToken 更新密碼
UpdateUserToken(ctx context.Context, in *UpdateTokenReq, opts ...grpc.CallOption) (*OKResp, error)
// GetUidByAccount 用帳號換取 UID
GetUidByAccount(ctx context.Context, in *GetUIDByAccountReq, opts ...grpc.CallOption) (*GetUidByAccountResp, error)
// BindAccount 綁定帳號 -> account bind to UID
BindAccount(ctx context.Context, in *BindingUserReq, opts ...grpc.CallOption) (*BindingUserResp, error)
// BindUserInfo 初次,綁定 User Info
BindUserInfo(ctx context.Context, in *CreateUserInfoReq, opts ...grpc.CallOption) (*OKResp, error)
// UpdateUserInfo 更新 User Info
UpdateUserInfo(ctx context.Context, in *UpdateUserInfoReq, opts ...grpc.CallOption) (*OKResp, error)
// UpdateStatus 修改狀態
UpdateStatus(ctx context.Context, in *UpdateStatusReq, opts ...grpc.CallOption) (*OKResp, error)
// GetUserInfo 取得會員資訊
GetUserInfo(ctx context.Context, in *GetUserInfoReq, opts ...grpc.CallOption) (*GetUserInfoResp, error)
// ListMember 取得會員列表
ListMember(ctx context.Context, in *ListUserInfoReq, opts ...grpc.CallOption) (*ListUserInfoResp, error)
// GenerateRefreshCode 這個帳號驗證碼(十分鐘),通用的
GenerateRefreshCode(ctx context.Context, in *GenerateRefreshCodeReq, opts ...grpc.CallOption) (*GenerateRefreshCodeResp, error)
// VerifyRefreshCode 驗證忘記密碼 token
VerifyRefreshCode(ctx context.Context, in *VerifyRefreshCodeReq, opts ...grpc.CallOption) (*OKResp, error)
}
defaultAccount struct {
cli zrpc.Client
}
)
func NewAccount(cli zrpc.Client) Account {
return &defaultAccount{
cli: cli,
}
}
// CreateUserAccount 建立帳號與密碼 -> 可登入,但可不可以做其他事情看業務流程,也可以只註冊就好
func (m *defaultAccount) CreateUserAccount(ctx context.Context, in *CreateLoginUserReq, opts ...grpc.CallOption) (*OKResp, error) {
client := member.NewAccountClient(m.cli.Conn())
return client.CreateUserAccount(ctx, in, opts...)
}
// GetUserAccountInfo 取得帳號密碼資料
func (m *defaultAccount) GetUserAccountInfo(ctx context.Context, in *GetUIDByAccountReq, opts ...grpc.CallOption) (*GetAccountInfoResp, error) {
client := member.NewAccountClient(m.cli.Conn())
return client.GetUserAccountInfo(ctx, in, opts...)
}
// UpdateUserToken 更新密碼
func (m *defaultAccount) UpdateUserToken(ctx context.Context, in *UpdateTokenReq, opts ...grpc.CallOption) (*OKResp, error) {
client := member.NewAccountClient(m.cli.Conn())
return client.UpdateUserToken(ctx, in, opts...)
}
// GetUidByAccount 用帳號換取 UID
func (m *defaultAccount) GetUidByAccount(ctx context.Context, in *GetUIDByAccountReq, opts ...grpc.CallOption) (*GetUidByAccountResp, error) {
client := member.NewAccountClient(m.cli.Conn())
return client.GetUidByAccount(ctx, in, opts...)
}
// BindAccount 綁定帳號 -> account bind to UID
func (m *defaultAccount) BindAccount(ctx context.Context, in *BindingUserReq, opts ...grpc.CallOption) (*BindingUserResp, error) {
client := member.NewAccountClient(m.cli.Conn())
return client.BindAccount(ctx, in, opts...)
}
// BindUserInfo 初次,綁定 User Info
func (m *defaultAccount) BindUserInfo(ctx context.Context, in *CreateUserInfoReq, opts ...grpc.CallOption) (*OKResp, error) {
client := member.NewAccountClient(m.cli.Conn())
return client.BindUserInfo(ctx, in, opts...)
}
// UpdateUserInfo 更新 User Info
func (m *defaultAccount) UpdateUserInfo(ctx context.Context, in *UpdateUserInfoReq, opts ...grpc.CallOption) (*OKResp, error) {
client := member.NewAccountClient(m.cli.Conn())
return client.UpdateUserInfo(ctx, in, opts...)
}
// UpdateStatus 修改狀態
func (m *defaultAccount) UpdateStatus(ctx context.Context, in *UpdateStatusReq, opts ...grpc.CallOption) (*OKResp, error) {
client := member.NewAccountClient(m.cli.Conn())
return client.UpdateStatus(ctx, in, opts...)
}
// GetUserInfo 取得會員資訊
func (m *defaultAccount) GetUserInfo(ctx context.Context, in *GetUserInfoReq, opts ...grpc.CallOption) (*GetUserInfoResp, error) {
client := member.NewAccountClient(m.cli.Conn())
return client.GetUserInfo(ctx, in, opts...)
}
// ListMember 取得會員列表
func (m *defaultAccount) ListMember(ctx context.Context, in *ListUserInfoReq, opts ...grpc.CallOption) (*ListUserInfoResp, error) {
client := member.NewAccountClient(m.cli.Conn())
return client.ListMember(ctx, in, opts...)
}
// GenerateRefreshCode 這個帳號驗證碼(十分鐘),通用的
func (m *defaultAccount) GenerateRefreshCode(ctx context.Context, in *GenerateRefreshCodeReq, opts ...grpc.CallOption) (*GenerateRefreshCodeResp, error) {
client := member.NewAccountClient(m.cli.Conn())
return client.GenerateRefreshCode(ctx, in, opts...)
}
// VerifyRefreshCode 驗證忘記密碼 token
func (m *defaultAccount) VerifyRefreshCode(ctx context.Context, in *VerifyRefreshCodeReq, opts ...grpc.CallOption) (*OKResp, error) {
client := member.NewAccountClient(m.cli.Conn())
return client.VerifyRefreshCode(ctx, in, opts...)
}

37
etc/service.yaml Normal file
View File

@ -0,0 +1,37 @@
Name: member.rpc
ListenOn: 0.0.0.0:8080
Etcd:
Hosts:
- 127.0.0.1:2379
Key: member.rpc
DB:
DsnString: root:yytt@tcp(127.0.0.1:3306)/ark_member?charset=utf8mb4&parseTime=true&loc=Asia%2FTaipei
Cache:
- Host: 127.0.0.1:7001
type: cluster
- Host: 127.0.0.1:7002
type: cluster
- Host: 127.0.0.1:7003
type: cluster
- Host: 127.0.0.1:7004
type: cluster
- Host: 127.0.0.1:7005
type: cluster
- Host: 127.0.0.1:7006
type: cluster
Bcrypt:
Cost: 10
RedisCluster:
Host: 127.0.0.1:7001
Type: cluster
Mongo:
Schema: mongodb
Host: 127.0.0.1
User: ""
Password: ""
Port: "27017"
Database: digimon_member
Collection: count

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,553 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.4.0
// - protoc v3.19.4
// source: generate/protobuf/service.proto
package member
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.62.0 or later.
const _ = grpc.SupportPackageIsVersion8
const (
Account_CreateUserAccount_FullMethodName = "/member.Account/CreateUserAccount"
Account_GetUserAccountInfo_FullMethodName = "/member.Account/GetUserAccountInfo"
Account_UpdateUserToken_FullMethodName = "/member.Account/UpdateUserToken"
Account_GetUidByAccount_FullMethodName = "/member.Account/GetUidByAccount"
Account_BindAccount_FullMethodName = "/member.Account/BindAccount"
Account_BindUserInfo_FullMethodName = "/member.Account/BindUserInfo"
Account_UpdateUserInfo_FullMethodName = "/member.Account/UpdateUserInfo"
Account_UpdateStatus_FullMethodName = "/member.Account/UpdateStatus"
Account_GetUserInfo_FullMethodName = "/member.Account/GetUserInfo"
Account_ListMember_FullMethodName = "/member.Account/ListMember"
Account_GenerateRefreshCode_FullMethodName = "/member.Account/GenerateRefreshCode"
Account_VerifyRefreshCode_FullMethodName = "/member.Account/VerifyRefreshCode"
)
// AccountClient is the client API for Account 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 AccountClient interface {
// CreateUserAccount 建立帳號與密碼 -> 可登入,但可不可以做其他事情看業務流程,也可以只註冊就好
CreateUserAccount(ctx context.Context, in *CreateLoginUserReq, opts ...grpc.CallOption) (*OKResp, error)
// GetUserAccountInfo 取得帳號密碼資料
GetUserAccountInfo(ctx context.Context, in *GetUIDByAccountReq, opts ...grpc.CallOption) (*GetAccountInfoResp, error)
// UpdateUserToken 更新密碼
UpdateUserToken(ctx context.Context, in *UpdateTokenReq, opts ...grpc.CallOption) (*OKResp, error)
// GetUidByAccount 用帳號換取 UID
GetUidByAccount(ctx context.Context, in *GetUIDByAccountReq, opts ...grpc.CallOption) (*GetUidByAccountResp, error)
// BindAccount 綁定帳號 -> account bind to UID
BindAccount(ctx context.Context, in *BindingUserReq, opts ...grpc.CallOption) (*BindingUserResp, error)
// BindUserInfo 初次,綁定 User Info
BindUserInfo(ctx context.Context, in *CreateUserInfoReq, opts ...grpc.CallOption) (*OKResp, error)
// UpdateUserInfo 更新 User Info
UpdateUserInfo(ctx context.Context, in *UpdateUserInfoReq, opts ...grpc.CallOption) (*OKResp, error)
// UpdateStatus 修改狀態
UpdateStatus(ctx context.Context, in *UpdateStatusReq, opts ...grpc.CallOption) (*OKResp, error)
// GetUserInfo 取得會員資訊
GetUserInfo(ctx context.Context, in *GetUserInfoReq, opts ...grpc.CallOption) (*GetUserInfoResp, error)
// ListMember 取得會員列表
ListMember(ctx context.Context, in *ListUserInfoReq, opts ...grpc.CallOption) (*ListUserInfoResp, error)
// GenerateRefreshCode 這個帳號驗證碼(十分鐘),通用的
GenerateRefreshCode(ctx context.Context, in *GenerateRefreshCodeReq, opts ...grpc.CallOption) (*GenerateRefreshCodeResp, error)
// VerifyRefreshCode 驗證忘記密碼 token
VerifyRefreshCode(ctx context.Context, in *VerifyRefreshCodeReq, opts ...grpc.CallOption) (*OKResp, error)
}
type accountClient struct {
cc grpc.ClientConnInterface
}
func NewAccountClient(cc grpc.ClientConnInterface) AccountClient {
return &accountClient{cc}
}
func (c *accountClient) CreateUserAccount(ctx context.Context, in *CreateLoginUserReq, opts ...grpc.CallOption) (*OKResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(OKResp)
err := c.cc.Invoke(ctx, Account_CreateUserAccount_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *accountClient) GetUserAccountInfo(ctx context.Context, in *GetUIDByAccountReq, opts ...grpc.CallOption) (*GetAccountInfoResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(GetAccountInfoResp)
err := c.cc.Invoke(ctx, Account_GetUserAccountInfo_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *accountClient) UpdateUserToken(ctx context.Context, in *UpdateTokenReq, opts ...grpc.CallOption) (*OKResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(OKResp)
err := c.cc.Invoke(ctx, Account_UpdateUserToken_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *accountClient) GetUidByAccount(ctx context.Context, in *GetUIDByAccountReq, opts ...grpc.CallOption) (*GetUidByAccountResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(GetUidByAccountResp)
err := c.cc.Invoke(ctx, Account_GetUidByAccount_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *accountClient) BindAccount(ctx context.Context, in *BindingUserReq, opts ...grpc.CallOption) (*BindingUserResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(BindingUserResp)
err := c.cc.Invoke(ctx, Account_BindAccount_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *accountClient) BindUserInfo(ctx context.Context, in *CreateUserInfoReq, opts ...grpc.CallOption) (*OKResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(OKResp)
err := c.cc.Invoke(ctx, Account_BindUserInfo_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *accountClient) UpdateUserInfo(ctx context.Context, in *UpdateUserInfoReq, opts ...grpc.CallOption) (*OKResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(OKResp)
err := c.cc.Invoke(ctx, Account_UpdateUserInfo_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *accountClient) UpdateStatus(ctx context.Context, in *UpdateStatusReq, opts ...grpc.CallOption) (*OKResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(OKResp)
err := c.cc.Invoke(ctx, Account_UpdateStatus_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *accountClient) GetUserInfo(ctx context.Context, in *GetUserInfoReq, opts ...grpc.CallOption) (*GetUserInfoResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(GetUserInfoResp)
err := c.cc.Invoke(ctx, Account_GetUserInfo_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *accountClient) ListMember(ctx context.Context, in *ListUserInfoReq, opts ...grpc.CallOption) (*ListUserInfoResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ListUserInfoResp)
err := c.cc.Invoke(ctx, Account_ListMember_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *accountClient) GenerateRefreshCode(ctx context.Context, in *GenerateRefreshCodeReq, opts ...grpc.CallOption) (*GenerateRefreshCodeResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(GenerateRefreshCodeResp)
err := c.cc.Invoke(ctx, Account_GenerateRefreshCode_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *accountClient) VerifyRefreshCode(ctx context.Context, in *VerifyRefreshCodeReq, opts ...grpc.CallOption) (*OKResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(OKResp)
err := c.cc.Invoke(ctx, Account_VerifyRefreshCode_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// AccountServer is the server API for Account service.
// All implementations must embed UnimplementedAccountServer
// for forward compatibility
type AccountServer interface {
// CreateUserAccount 建立帳號與密碼 -> 可登入,但可不可以做其他事情看業務流程,也可以只註冊就好
CreateUserAccount(context.Context, *CreateLoginUserReq) (*OKResp, error)
// GetUserAccountInfo 取得帳號密碼資料
GetUserAccountInfo(context.Context, *GetUIDByAccountReq) (*GetAccountInfoResp, error)
// UpdateUserToken 更新密碼
UpdateUserToken(context.Context, *UpdateTokenReq) (*OKResp, error)
// GetUidByAccount 用帳號換取 UID
GetUidByAccount(context.Context, *GetUIDByAccountReq) (*GetUidByAccountResp, error)
// BindAccount 綁定帳號 -> account bind to UID
BindAccount(context.Context, *BindingUserReq) (*BindingUserResp, error)
// BindUserInfo 初次,綁定 User Info
BindUserInfo(context.Context, *CreateUserInfoReq) (*OKResp, error)
// UpdateUserInfo 更新 User Info
UpdateUserInfo(context.Context, *UpdateUserInfoReq) (*OKResp, error)
// UpdateStatus 修改狀態
UpdateStatus(context.Context, *UpdateStatusReq) (*OKResp, error)
// GetUserInfo 取得會員資訊
GetUserInfo(context.Context, *GetUserInfoReq) (*GetUserInfoResp, error)
// ListMember 取得會員列表
ListMember(context.Context, *ListUserInfoReq) (*ListUserInfoResp, error)
// GenerateRefreshCode 這個帳號驗證碼(十分鐘),通用的
GenerateRefreshCode(context.Context, *GenerateRefreshCodeReq) (*GenerateRefreshCodeResp, error)
// VerifyRefreshCode 驗證忘記密碼 token
VerifyRefreshCode(context.Context, *VerifyRefreshCodeReq) (*OKResp, error)
mustEmbedUnimplementedAccountServer()
}
// UnimplementedAccountServer must be embedded to have forward compatible implementations.
type UnimplementedAccountServer struct {
}
func (UnimplementedAccountServer) CreateUserAccount(context.Context, *CreateLoginUserReq) (*OKResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method CreateUserAccount not implemented")
}
func (UnimplementedAccountServer) GetUserAccountInfo(context.Context, *GetUIDByAccountReq) (*GetAccountInfoResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetUserAccountInfo not implemented")
}
func (UnimplementedAccountServer) UpdateUserToken(context.Context, *UpdateTokenReq) (*OKResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method UpdateUserToken not implemented")
}
func (UnimplementedAccountServer) GetUidByAccount(context.Context, *GetUIDByAccountReq) (*GetUidByAccountResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetUidByAccount not implemented")
}
func (UnimplementedAccountServer) BindAccount(context.Context, *BindingUserReq) (*BindingUserResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method BindAccount not implemented")
}
func (UnimplementedAccountServer) BindUserInfo(context.Context, *CreateUserInfoReq) (*OKResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method BindUserInfo not implemented")
}
func (UnimplementedAccountServer) UpdateUserInfo(context.Context, *UpdateUserInfoReq) (*OKResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method UpdateUserInfo not implemented")
}
func (UnimplementedAccountServer) UpdateStatus(context.Context, *UpdateStatusReq) (*OKResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method UpdateStatus not implemented")
}
func (UnimplementedAccountServer) GetUserInfo(context.Context, *GetUserInfoReq) (*GetUserInfoResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetUserInfo not implemented")
}
func (UnimplementedAccountServer) ListMember(context.Context, *ListUserInfoReq) (*ListUserInfoResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListMember not implemented")
}
func (UnimplementedAccountServer) GenerateRefreshCode(context.Context, *GenerateRefreshCodeReq) (*GenerateRefreshCodeResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method GenerateRefreshCode not implemented")
}
func (UnimplementedAccountServer) VerifyRefreshCode(context.Context, *VerifyRefreshCodeReq) (*OKResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method VerifyRefreshCode not implemented")
}
func (UnimplementedAccountServer) mustEmbedUnimplementedAccountServer() {}
// UnsafeAccountServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to AccountServer will
// result in compilation errors.
type UnsafeAccountServer interface {
mustEmbedUnimplementedAccountServer()
}
func RegisterAccountServer(s grpc.ServiceRegistrar, srv AccountServer) {
s.RegisterService(&Account_ServiceDesc, srv)
}
func _Account_CreateUserAccount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CreateLoginUserReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AccountServer).CreateUserAccount(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Account_CreateUserAccount_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AccountServer).CreateUserAccount(ctx, req.(*CreateLoginUserReq))
}
return interceptor(ctx, in, info, handler)
}
func _Account_GetUserAccountInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetUIDByAccountReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AccountServer).GetUserAccountInfo(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Account_GetUserAccountInfo_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AccountServer).GetUserAccountInfo(ctx, req.(*GetUIDByAccountReq))
}
return interceptor(ctx, in, info, handler)
}
func _Account_UpdateUserToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(UpdateTokenReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AccountServer).UpdateUserToken(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Account_UpdateUserToken_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AccountServer).UpdateUserToken(ctx, req.(*UpdateTokenReq))
}
return interceptor(ctx, in, info, handler)
}
func _Account_GetUidByAccount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetUIDByAccountReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AccountServer).GetUidByAccount(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Account_GetUidByAccount_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AccountServer).GetUidByAccount(ctx, req.(*GetUIDByAccountReq))
}
return interceptor(ctx, in, info, handler)
}
func _Account_BindAccount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(BindingUserReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AccountServer).BindAccount(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Account_BindAccount_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AccountServer).BindAccount(ctx, req.(*BindingUserReq))
}
return interceptor(ctx, in, info, handler)
}
func _Account_BindUserInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CreateUserInfoReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AccountServer).BindUserInfo(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Account_BindUserInfo_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AccountServer).BindUserInfo(ctx, req.(*CreateUserInfoReq))
}
return interceptor(ctx, in, info, handler)
}
func _Account_UpdateUserInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(UpdateUserInfoReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AccountServer).UpdateUserInfo(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Account_UpdateUserInfo_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AccountServer).UpdateUserInfo(ctx, req.(*UpdateUserInfoReq))
}
return interceptor(ctx, in, info, handler)
}
func _Account_UpdateStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(UpdateStatusReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AccountServer).UpdateStatus(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Account_UpdateStatus_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AccountServer).UpdateStatus(ctx, req.(*UpdateStatusReq))
}
return interceptor(ctx, in, info, handler)
}
func _Account_GetUserInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetUserInfoReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AccountServer).GetUserInfo(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Account_GetUserInfo_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AccountServer).GetUserInfo(ctx, req.(*GetUserInfoReq))
}
return interceptor(ctx, in, info, handler)
}
func _Account_ListMember_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ListUserInfoReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AccountServer).ListMember(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Account_ListMember_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AccountServer).ListMember(ctx, req.(*ListUserInfoReq))
}
return interceptor(ctx, in, info, handler)
}
func _Account_GenerateRefreshCode_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GenerateRefreshCodeReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AccountServer).GenerateRefreshCode(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Account_GenerateRefreshCode_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AccountServer).GenerateRefreshCode(ctx, req.(*GenerateRefreshCodeReq))
}
return interceptor(ctx, in, info, handler)
}
func _Account_VerifyRefreshCode_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(VerifyRefreshCodeReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AccountServer).VerifyRefreshCode(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Account_VerifyRefreshCode_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AccountServer).VerifyRefreshCode(ctx, req.(*VerifyRefreshCodeReq))
}
return interceptor(ctx, in, info, handler)
}
// Account_ServiceDesc is the grpc.ServiceDesc for Account service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Account_ServiceDesc = grpc.ServiceDesc{
ServiceName: "member.Account",
HandlerType: (*AccountServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "CreateUserAccount",
Handler: _Account_CreateUserAccount_Handler,
},
{
MethodName: "GetUserAccountInfo",
Handler: _Account_GetUserAccountInfo_Handler,
},
{
MethodName: "UpdateUserToken",
Handler: _Account_UpdateUserToken_Handler,
},
{
MethodName: "GetUidByAccount",
Handler: _Account_GetUidByAccount_Handler,
},
{
MethodName: "BindAccount",
Handler: _Account_BindAccount_Handler,
},
{
MethodName: "BindUserInfo",
Handler: _Account_BindUserInfo_Handler,
},
{
MethodName: "UpdateUserInfo",
Handler: _Account_UpdateUserInfo_Handler,
},
{
MethodName: "UpdateStatus",
Handler: _Account_UpdateStatus_Handler,
},
{
MethodName: "GetUserInfo",
Handler: _Account_GetUserInfo_Handler,
},
{
MethodName: "ListMember",
Handler: _Account_ListMember_Handler,
},
{
MethodName: "GenerateRefreshCode",
Handler: _Account_GenerateRefreshCode_Handler,
},
{
MethodName: "VerifyRefreshCode",
Handler: _Account_VerifyRefreshCode_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "generate/protobuf/service.proto",
}

330
go.sum Normal file
View File

@ -0,0 +1,330 @@
code.30cm.net/digimon/library-go/errors v1.0.1 h1:9PmBQP8EiulJM4DsnO9mfYS+uLUE9dwyEjUlql14Hms=
code.30cm.net/digimon/library-go/errors v1.0.1/go.mod h1:4yVE3lyHi/cLB3W59Tw70FBqO10ZhXo470NWp7aQ0tc=
code.30cm.net/digimon/library-go/validator v1.0.0 h1:F48CU0+Z4ZZFhKHvjgm4u0M7v5wanFfVLKz+d92o+ks=
code.30cm.net/digimon/library-go/validator v1.0.0/go.mod h1:haNzZMm0PhdvhuX8R6N/ZMp4CjOhs7/dHgTHzeOTNrY=
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
github.com/DATA-DOG/go-sqlmock v1.5.2 h1:OcvFkGmslmlZibjAjaHm3L//6LiuBgolP7OputlJIzU=
github.com/DATA-DOG/go-sqlmock v1.5.2/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU=
github.com/alicebob/gopher-json v0.0.0-20230218143504-906a9b012302 h1:uvdUDbHQHO85qeSydJtItA4T55Pw6BtAejd0APRJOCE=
github.com/alicebob/gopher-json v0.0.0-20230218143504-906a9b012302/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc=
github.com/alicebob/miniredis/v2 v2.33.0 h1:uvTF0EDeu9RLnUEG27Db5I68ESoIxTiXbNUiji6lZrA=
github.com/alicebob/miniredis/v2 v2.33.0/go.mod h1:MhP4a3EU7aENRi9aO+tHfTBZicLqQevyi/DJpoj6mi0=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
github.com/bwmarrin/snowflake v0.3.0 h1:xm67bEhkKh6ij1790JB83OujPR5CzNe8QuQqAgISZN0=
github.com/bwmarrin/snowflake v0.3.0/go.mod h1:NdZxfVWX+oR6y2K0o6qAYv6gIOP9rjG0/E9WsDpxqwE=
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr4=
github.com/coreos/go-semver v0.3.1/go.mod h1:irMmmIw/7yzSRPWryHsK7EYSg09caPQL03VsM8rvUec=
github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g=
github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4=
github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI=
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE=
github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs=
github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE=
github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k=
github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14=
github.com/go-openapi/swag v0.22.4 h1:QLMzNJnMGPRNDCbySlcj1x01tzU8/9LTTL9hZZZogBU=
github.com/go-openapi/swag v0.22.4/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14=
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.22.0 h1:k6HsTZ0sTnROkhS//R0O+55JgM8C4Bx7ia+JlgcnOao=
github.com/go-playground/validator/v10 v10.22.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y=
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I=
github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec=
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1YCS1PXdKYWi8FsN0=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0/go.mod h1:P+Lt/0by1T8bfcF3z737NnSbmxQAppXMRziHUxPOC8k=
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw=
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU=
github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE=
github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/onsi/ginkgo/v2 v2.13.0 h1:0jY9lJquiL8fcf3M4LAXN5aMlS/b2BV86HFFPCPMgE4=
github.com/onsi/ginkgo/v2 v2.13.0/go.mod h1:TE309ZR8s5FsKKpuB1YAQYBzCaAfUgatB/xlT/ETL/o=
github.com/onsi/gomega v1.29.0 h1:KIA/t2t5UBzoirT4H9tsML45GEbo3ouUnBHsCfD2tVg=
github.com/onsi/gomega v1.29.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ=
github.com/openzipkin/zipkin-go v0.4.3 h1:9EGwpqkgnwdEIJ+Od7QVSEIH+ocmm5nPat0G7sjsSdg=
github.com/openzipkin/zipkin-go v0.4.3/go.mod h1:M9wCJZFWCo2RiY+o1eBCEMe0Dp2S5LDHcMZmk3RmK7c=
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g=
github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U=
github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE=
github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho=
github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw=
github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI=
github.com/prometheus/common v0.48.0 h1:QO8U2CdOzSn1BBsmXJXduaaW+dY/5QLjfB8svtSzKKE=
github.com/prometheus/common v0.48.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc=
github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo=
github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo=
github.com/redis/go-redis/v9 v9.6.1 h1:HHDteefn6ZkTtY5fGUE8tj8uy85AHk6zP7CpzIAM0y4=
github.com/redis/go-redis/v9 v9.6.1/go.mod h1:0C0c6ycQsdpVNQpxb1njEQIqkx5UcsM8FJCQLgE9+RA=
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY=
github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4=
github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8=
github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM=
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a h1:fZHgsYlfvtyqToslyjUt3VOPF4J7aK/3MPcK7xp3PDk=
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a/go.mod h1:ul22v+Nro/R083muKhosV54bj5niojjWZvU8xrevuH4=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M=
github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw=
github.com/zeromicro/go-zero v1.7.0 h1:B+y7tUVlo3qVQ6F0I0R9bi+Dq4I1QdO9ZB+dz1r0p1s=
github.com/zeromicro/go-zero v1.7.0/go.mod h1:ypW4PzQI+jUrMcNJDDQ+7YW+pE+tMua9Xj/pmtmS1Dc=
go.etcd.io/etcd/api/v3 v3.5.15 h1:3KpLJir1ZEBrYuV2v+Twaa/e2MdDCEZ/70H+lzEiwsk=
go.etcd.io/etcd/api/v3 v3.5.15/go.mod h1:N9EhGzXq58WuMllgH9ZvnEr7SI9pS0k0+DHZezGp7jM=
go.etcd.io/etcd/client/pkg/v3 v3.5.15 h1:fo0HpWz/KlHGMCC+YejpiCmyWDEuIpnTDzpJLB5fWlA=
go.etcd.io/etcd/client/pkg/v3 v3.5.15/go.mod h1:mXDI4NAOwEiszrHCb0aqfAYNCrZP4e9hRca3d1YK8EU=
go.etcd.io/etcd/client/v3 v3.5.15 h1:23M0eY4Fd/inNv1ZfU3AxrbbOdW79r9V9Rl62Nm6ip4=
go.etcd.io/etcd/client/v3 v3.5.15/go.mod h1:CLSJxrYjvLtHsrPKsy7LmZEE+DK2ktfd2bN4RhBMwlU=
go.mongodb.org/mongo-driver v1.16.0 h1:tpRsfBJMROVHKpdGyc1BBEzzjDUWjItxbVSZ8Ls4BQ4=
go.mongodb.org/mongo-driver v1.16.0/go.mod h1:oB6AhJQvFQL4LEHyXi6aJzQJtBiTQHiAd83l0GdFaiw=
go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo=
go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo=
go.opentelemetry.io/otel/exporters/jaeger v1.17.0 h1:D7UpUy2Xc2wsi1Ras6V40q806WM07rqoCWzXu7Sqy+4=
go.opentelemetry.io/otel/exporters/jaeger v1.17.0/go.mod h1:nPCqOnEH9rNLKqH/+rrUjiMzHJdV1BlpKcTwRTyKkKI=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 h1:t6wl9SPayj+c7lEIFgm4ooDBZVb01IhLB4InpomhRw8=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0/go.mod h1:iSDOcsnSA5INXzZtwaBPrKp/lWu/V14Dd+llD0oI2EA=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0 h1:Mw5xcxMwlqoJd97vwPxA8isEaIoxsta9/Q51+TTJLGE=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0/go.mod h1:CQNu9bj7o7mC6U7+CA/schKEYakYXWr79ucDHTMGhCM=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0 h1:Xw8U6u2f8DK2XAkGRFV7BBLENgnTGX9i4rQRxJf+/vs=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0/go.mod h1:6KW1Fm6R/s6Z3PGXwSJN2K4eT6wQB3vXX6CVnYX9NmM=
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.24.0 h1:s0PHtIkN+3xrbDOpt2M8OTG92cWqUESvzh2MxiR5xY8=
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.24.0/go.mod h1:hZlFbDbRt++MMPCCfSJfmhkGIWnX1h3XjkfxZUjLrIA=
go.opentelemetry.io/otel/exporters/zipkin v1.24.0 h1:3evrL5poBuh1KF51D9gO/S+N/1msnm4DaBqs/rpXUqY=
go.opentelemetry.io/otel/exporters/zipkin v1.24.0/go.mod h1:0EHgD8R0+8yRhUYJOGR8Hfg2dpiJQxDOszd5smVO9wM=
go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI=
go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco=
go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw=
go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg=
go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI=
go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU=
go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0=
go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8=
go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ=
go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
go.uber.org/automaxprocs v1.5.3 h1:kWazyxZUrS3Gs4qUpbwo5kEIMGe/DAvi5Z4tl2NW4j8=
go.uber.org/automaxprocs v1.5.3/go.mod h1:eRbA25aqJrxAbsLO0xy5jVwPt7FQnRgjW+efnwa1WM0=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU=
go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc=
go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI=
go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ=
go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60=
go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
golang.org/x/oauth2 v0.20.0 h1:4mQdhULixXKP1rwYBW0vAijoXnkTG0BLCDRzfe1idMo=
golang.org/x/oauth2 v0.20.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk=
golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/genproto/googleapis/api v0.0.0-20240711142825-46eb208f015d h1:kHjw/5UfflP/L5EbledDrcG4C2597RtymmGRZvHiCuY=
google.golang.org/genproto/googleapis/api v0.0.0-20240711142825-46eb208f015d/go.mod h1:mw8MG/Qz5wfgYr6VqVCiZcHe/GJEfI+oGGDCohaVgB0=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 h1:BwIjyKYGsK9dMCBOorzRri8MQwmi7mT9rGHsCEinZkA=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY=
google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc=
google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/h2non/gock.v1 v1.1.2 h1:jBbHXgGBK/AoPVfJh5x4r/WxIrElvbLel8TCZkkZJoY=
gopkg.in/h2non/gock.v1 v1.1.2/go.mod h1:n7UGz/ckNChHiK05rDoiC4MYSunEC/lyaUm2WWaDva0=
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
k8s.io/api v0.29.3 h1:2ORfZ7+bGC3YJqGpV0KSDDEVf8hdGQ6A03/50vj8pmw=
k8s.io/api v0.29.3/go.mod h1:y2yg2NTyHUUkIoTC+phinTnEa3KFM6RZ3szxt014a80=
k8s.io/apimachinery v0.29.4 h1:RaFdJiDmuKs/8cm1M6Dh1Kvyh59YQFDcFuFTSmXes6Q=
k8s.io/apimachinery v0.29.4/go.mod h1:i3FJVwhvSp/6n8Fl4K97PJEP8C+MM+aoDq4+ZJBf70Y=
k8s.io/client-go v0.29.3 h1:R/zaZbEAxqComZ9FHeQwOh3Y1ZUs7FaHKZdQtIc2WZg=
k8s.io/client-go v0.29.3/go.mod h1:tkDisCvgPfiRpxGnOORfkljmS+UrW+WtXAy2fTvXJB0=
k8s.io/klog/v2 v2.110.1 h1:U/Af64HJf7FcwMcXyKm2RPM22WZzyR7OSpYj5tg3cL0=
k8s.io/klog/v2 v2.110.1/go.mod h1:YGtd1984u+GgbuZ7e08/yBuAfKLSO0+uR1Fhi6ExXjo=
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 h1:aVUu9fTY98ivBPKR9Y5w/AuzbMm96cd3YHRTU83I780=
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00/go.mod h1:AsvuZPBlUDVuCdzJ87iajxtXuR9oktsTctW/R9wwouA=
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 h1:pUdcCO1Lk/tbT5ztQWOBi5HBgbBP1J8+AsQnQCKsi8A=
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4=
sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08=
sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=

View File

@ -0,0 +1,74 @@
package accountlogic
import (
"app-cloudep-member-server/internal/model"
"context"
"fmt"
ers "code.30cm.net/digimon/library-go/errors"
"app-cloudep-member-server/gen_result/pb/member"
"app-cloudep-member-server/internal/svc"
"github.com/zeromicro/go-zero/core/logx"
)
type BindAccountLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewBindAccountLogic(ctx context.Context, svcCtx *svc.ServiceContext) *BindAccountLogic {
return &BindAccountLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
type bindLoginUserReq struct {
Account string `json:"account" validate:"account"`
UID string `json:"uid" `
Type int64 `json:"type" validate:"required,oneof=1 2 3"`
}
// BindAccount 綁定帳號 -> account bind to UID
func (l *BindAccountLogic) BindAccount(in *member.BindingUserReq) (*member.BindingUserResp, error) {
// 驗證資料
if err := l.svcCtx.Validate.ValidateAll(&bindLoginUserReq{
Account: in.GetLoginId(),
Type: in.GetType(),
}); err != nil {
return nil, ers.InvalidFormat(err.Error())
}
// 先確定有這個Account
if _, err := l.svcCtx.AccountModel.FindOneByAccount(l.ctx, in.GetLoginId()); err != nil {
return nil, ers.ResourceNotFound(fmt.Sprintf("failed to get account : %s ", in.GetLoginId()))
}
var err error
uid := in.GetUid()
// 有 UID 綁看看沒帶UID 近來,確認沒重複就直接綁一個給他
if in.GetUid() == "" {
uid, err = l.svcCtx.GenUIDUseCase.Generate(l.ctx)
if err != nil {
return nil, ers.ArkInternal(fmt.Sprintf("[GenUIDUseCase.Generate] failed to get account : %s ", in.GetLoginId()))
}
}
if _, err := l.svcCtx.AccountToUidModel.Insert(l.ctx, &model.AccountToUid{
Account: in.LoginId,
Uid: uid,
Type: in.GetType(),
}); err != nil {
return nil, ers.DBError(err.Error())
}
return &member.BindingUserResp{
LoginId: in.LoginId,
Uid: uid,
Type: in.GetType(),
}, nil
}

View File

@ -0,0 +1,177 @@
package accountlogic
import (
"app-cloudep-member-server/gen_result/pb/member"
"app-cloudep-member-server/internal/domain"
libMock "app-cloudep-member-server/internal/mock/lib"
modelMock "app-cloudep-member-server/internal/mock/model"
usecaseMock "app-cloudep-member-server/internal/mock/usecase"
"app-cloudep-member-server/internal/model"
"app-cloudep-member-server/internal/svc"
"context"
"errors"
"fmt"
"testing"
"github.com/alicebob/miniredis/v2"
"github.com/stretchr/testify/assert"
"github.com/zeromicro/go-zero/core/stores/redis"
"go.uber.org/mock/gomock"
)
func TestBindAccountLogic_BindAccount(t *testing.T) {
// mock
ctrl := gomock.NewController(t)
defer ctrl.Finish()
mockAccountModel := modelMock.NewMockAccountModel(ctrl)
mockAccountToUidModel := modelMock.NewMockAccountToUidModel(ctrl)
mockGenUIDModel := usecaseMock.NewMockUIDGenerateUseCase(ctrl)
mockValidate := libMock.NewMockValidate(ctrl)
r1, err := miniredis.Run()
assert.NoError(t, err)
defer r1.Close()
newRedis, err := redis.NewRedis(redis.RedisConf{
Host: r1.Addr(),
Type: redis.ClusterType,
Pass: "",
})
assert.NoError(t, err)
sc := svc.ServiceContext{
AccountModel: mockAccountModel,
AccountToUidModel: mockAccountToUidModel,
GenUIDUseCase: mockGenUIDModel,
Redis: *newRedis,
Validate: mockValidate,
}
l := NewBindAccountLogic(context.Background(), &sc)
tests := []struct {
name string
input *member.BindingUserReq
setupMocks func()
expectError bool
expected *member.BindingUserResp
}{
{
name: "ok",
input: &member.BindingUserReq{
LoginId: "cat1@30cm.net",
Uid: "12345",
Type: domain.AccountTypeMail.ToInt64(),
},
setupMocks: func() {
// mock validate returns
mockValidate.EXPECT().
ValidateAll(gomock.Any()).Return(nil)
mockAccountModel.EXPECT().
FindOneByAccount(gomock.Any(), "cat1@30cm.net").
Return(&model.Account{Account: "cat1@30cm.net"}, nil)
mockAccountToUidModel.EXPECT().
Insert(gomock.Any(), gomock.Any()).
Return(nil, nil)
},
expectError: false,
expected: &member.BindingUserResp{
LoginId: "cat1@30cm.net",
Uid: "12345",
Type: domain.AccountTypeMail.ToInt64(),
},
},
{
name: "valid account without UID",
input: &member.BindingUserReq{
LoginId: "cat1@30cm.net",
Uid: "",
Type: domain.AccountTypeMail.ToInt64(),
},
setupMocks: func() {
// mock validate returns
mockValidate.EXPECT().
ValidateAll(gomock.Any()).Return(nil)
mockAccountModel.EXPECT().
FindOneByAccount(gomock.Any(), "cat1@30cm.net").
Return(&model.Account{Account: "cat1@30cm.net"}, nil)
mockGenUIDModel.EXPECT().
Generate(gomock.Any()).
Return("OOOOOOOD", nil)
mockAccountToUidModel.EXPECT().
Insert(gomock.Any(), &model.AccountToUid{Account: "cat1@30cm.net", Uid: "OOOOOOOD", Type: domain.AccountTypeMail.ToInt64()}).
Return(nil, nil)
},
expectError: false,
expected: &member.BindingUserResp{
LoginId: "cat1@30cm.net",
Uid: "OOOOOOOD",
Type: domain.AccountTypeMail.ToInt64(),
},
},
{
name: "account not found",
input: &member.BindingUserReq{
LoginId: "cat2@30cm.net",
Uid: "12345",
},
setupMocks: func() {
// mock validate returns
mockValidate.EXPECT().
ValidateAll(gomock.Any()).Return(nil)
mockAccountModel.EXPECT().
FindOneByAccount(gomock.Any(), "cat2@30cm.net").
Return(nil, errors.New("account not found"))
},
expectError: true,
},
{
name: "insert account to UID failed",
input: &member.BindingUserReq{
LoginId: "cat2@30cm.net",
Uid: "OOOOOOJ",
},
setupMocks: func() {
// mock validate returns
mockValidate.EXPECT().
ValidateAll(gomock.Any()).Return(nil)
mockAccountModel.EXPECT().
FindOneByAccount(gomock.Any(), "cat2@30cm.net").
Return(&model.Account{Account: "cat2@30cm.net"}, nil)
mockAccountToUidModel.EXPECT().
Insert(gomock.Any(), &model.AccountToUid{Account: "cat2@30cm.net", Uid: "OOOOOOJ"}).
Return(nil, errors.New("insert failed"))
},
expectError: true,
},
{
name: "failed to validate param",
input: &member.BindingUserReq{
LoginId: "cat3",
Uid: "OOOOOOOL",
},
setupMocks: func() {
// mock validate returns
mockValidate.EXPECT().
ValidateAll(gomock.Any()).Return(fmt.Errorf("invalid format: failed to get correct formate loginID "))
},
expectError: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
tt.setupMocks()
resp, err := l.BindAccount(tt.input)
if tt.expectError {
assert.Error(t, err)
} else {
assert.NoError(t, err)
assert.Equal(t, tt.expected, resp)
}
})
}
}

View File

@ -0,0 +1,92 @@
package accountlogic
import (
"app-cloudep-member-server/internal/model"
"context"
"errors"
"time"
ers "code.30cm.net/digimon/library-go/errors"
"github.com/go-sql-driver/mysql"
"app-cloudep-member-server/gen_result/pb/member"
"app-cloudep-member-server/internal/svc"
"github.com/zeromicro/go-zero/core/logx"
)
type BindUserInfoLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
type createUserInfo struct {
Uid string `validate:"required"`
VerifyType int32 `validate:"required,oneof=0 1 2 3"`
AlarmType int32 `validate:"required,oneof=0 1 2"`
Status int32 `validate:"required,oneof=1 2 3 4 5 6"`
RoleId string `validate:"required"`
Language string `validate:"required"`
Currency string `validate:"required"`
NickName string `validate:"required"`
}
func NewBindUserInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *BindUserInfoLogic {
return &BindUserInfoLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
type createUserInfoReq struct {
Uid string `validate:"required"` // 唯一辨識碼
Language string `validate:"required"`
Currency string `validate:"required"`
// VerifyType int32 `validate:"required,oneof=0 1 2 3 4"` // 驗證類型 0. 異常 [ 1.信箱 2.手機 3. GA 4. 關閉] 兩步驟驗證狀態
// AlarmType int32 `validate:"required,oneof=0 1 2"` // 告警狀態 0. 異常 1. 正常(未告警) 2.系統告警中
// Status int32 `validate:"required,oneof=1 2 3 4 5"` // 會員狀態 0. 異常 1. 尚未驗證 2. 啟用 3. 停權中 4. 信箱以驗證 5. 手機以驗證
// Language string
// Currency string
// NickName string
// Avatar string // 會員頭像
}
// BindUserInfo 初次,綁定 User Info
func (l *BindUserInfoLogic) BindUserInfo(in *member.CreateUserInfoReq) (*member.OKResp, error) {
// 驗證資料
if err := l.svcCtx.Validate.ValidateAll(&createUserInfoReq{
Uid: in.GetUid(),
Language: in.GetLanguage(),
Currency: in.GetCurrency(),
}); err != nil {
return nil, ers.InvalidFormat(err.Error())
}
// 有些應為預設資料,不應該被新增
now := time.Now().UTC().Unix()
if _, err := l.svcCtx.UserModel.Insert(l.ctx, &model.UserTable{
Uid: in.GetUid(),
VerifyType: int64(member.VerifyType_VERIFY_NOT.Number()), // 預設為沒有設定兩步驟驗證
AlarmType: int64(member.AlarmType_ALARM_NOT.Number()), // 預設狀態為沒有被系統告警過
Status: int64(member.MemberStatus_STATUS_VERIFY.Number()), // 預設狀態為尚未驗證
Language: in.GetLanguage(),
Currency: in.GetCurrency(),
NickName: in.GetNickName(),
Avatar: in.GetAvatar(),
CreateTime: now,
UpdateTime: now,
}); err != nil {
// 新增進去
var mysqlErr *mysql.MySQLError
if errors.As(err, &mysqlErr) && mysqlErr.Number == 1062 {
// 處理重複條目錯誤
return nil, ers.DBDuplicate(in.GetUid())
}
return nil, ers.DBError(err.Error())
}
return &member.OKResp{}, nil
}

View File

@ -0,0 +1,144 @@
package accountlogic
import (
"app-cloudep-member-server/gen_result/pb/member"
libMock "app-cloudep-member-server/internal/mock/lib"
modelMock "app-cloudep-member-server/internal/mock/model"
"app-cloudep-member-server/internal/svc"
"context"
"fmt"
"testing"
"github.com/alicebob/miniredis/v2"
"github.com/go-sql-driver/mysql"
"github.com/stretchr/testify/assert"
"github.com/zeromicro/go-zero/core/stores/redis"
"go.uber.org/mock/gomock"
"google.golang.org/protobuf/proto"
)
func TestBindUserInfoLogic_BindUserInfo(t *testing.T) {
// mock
ctrl := gomock.NewController(t)
defer ctrl.Finish()
mockUserModel := modelMock.NewMockUserTableModel(ctrl)
mockValidate := libMock.NewMockValidate(ctrl)
r1, err := miniredis.Run()
assert.NoError(t, err)
defer r1.Close()
newRedis, err := redis.NewRedis(redis.RedisConf{
Host: r1.Addr(),
Type: redis.ClusterType,
Pass: "",
})
assert.NoError(t, err)
sc := svc.ServiceContext{
UserModel: mockUserModel,
Redis: *newRedis,
Validate: mockValidate,
}
l := NewBindUserInfoLogic(context.Background(), &sc)
tests := []struct {
name string
input *member.CreateUserInfoReq
setupMocks func()
expectError bool
expected *member.OKResp
}{
{
name: "ok",
input: &member.CreateUserInfoReq{
Uid: "2024101598765",
VerifyType: 1,
AlarmType: 2,
Status: 3,
Language: "en",
Currency: "USDT",
NickName: proto.String("Test User"),
},
setupMocks: func() {
mockValidate.EXPECT().
ValidateAll(gomock.Any()).
Return(nil)
mockUserModel.EXPECT().
Insert(gomock.Any(), gomock.Any()).
Return(nil, nil)
},
expectError: false,
expected: &member.OKResp{},
},
{
name: "invalid user info",
input: &member.CreateUserInfoReq{
Uid: "",
},
setupMocks: func() {
mockValidate.EXPECT().
ValidateAll(gomock.Any()).
Return(fmt.Errorf("validation error"))
},
expectError: true,
},
{
name: "duplicate entry",
input: &member.CreateUserInfoReq{
Uid: "test_uid",
VerifyType: 1,
AlarmType: 2,
Status: 3,
Language: "en",
Currency: "USD",
NickName: proto.String("Test User"),
},
setupMocks: func() {
mockValidate.EXPECT().
ValidateAll(gomock.Any()).
Return(nil)
mockUserModel.EXPECT().
Insert(gomock.Any(), gomock.Any()).
Return(nil, &mysql.MySQLError{Number: 1062, Message: "Duplicate entry"})
},
expectError: true,
},
{
name: "database error",
input: &member.CreateUserInfoReq{
Uid: "test_uid",
VerifyType: 1,
AlarmType: 2,
Status: 3,
Language: "en",
Currency: "USD",
NickName: proto.String("Test User"),
},
setupMocks: func() {
mockValidate.EXPECT().
ValidateAll(gomock.Any()).
Return(nil)
mockUserModel.EXPECT().
Insert(gomock.Any(), gomock.Any()).
Return(nil, fmt.Errorf("database error"))
},
expectError: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
tt.setupMocks()
resp, err := l.BindUserInfo(tt.input)
if tt.expectError {
assert.Error(t, err)
} else {
assert.NoError(t, err)
assert.Equal(t, tt.expected, resp)
}
})
}
}

View File

@ -0,0 +1,82 @@
package accountlogic
import (
"app-cloudep-member-server/internal/model"
"app-cloudep-member-server/internal/utils"
"context"
"errors"
"fmt"
"time"
ers "code.30cm.net/digimon/library-go/errors"
"github.com/go-sql-driver/mysql"
"app-cloudep-member-server/gen_result/pb/member"
"app-cloudep-member-server/internal/svc"
"github.com/zeromicro/go-zero/core/logx"
)
type CreateUserAccountLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewCreateUserAccountLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateUserAccountLogic {
return &CreateUserAccountLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
type createLoginUserReq struct {
LoginId string `json:"login_id" validate:"account"`
Platform int64 `json:"platform" validate:"required,oneof=1 2 3"`
Token string `json:"token" validate:"required"`
}
// HasPasswordFunc 這樣方便測試
var HasPasswordFunc = utils.HashPassword
// CreateUserAccount 建立帳號與密碼 -> 可登入,但可不可以做其他事情看業務流程,也可以只註冊就好
func (l *CreateUserAccountLogic) CreateUserAccount(in *member.CreateLoginUserReq) (*member.OKResp, error) {
// 驗證資料
if err := l.svcCtx.Validate.ValidateAll(&createLoginUserReq{
LoginId: in.GetLoginId(),
Platform: in.GetPlatform(),
Token: in.GetToken(),
}); err != nil {
return nil, ers.InvalidFormat(err.Error())
}
// TODO 檢查平台,依照不同平台,做不同的事
token, err := HasPasswordFunc(in.GetToken(), l.svcCtx.Config.Bcrypt.Cost)
if err != nil {
return nil, ers.ArkInternal(fmt.Sprintf("failed to encrypt err: %v", err.Error()))
}
// 新增進去
now := time.Now().UTC().Unix()
_, err = l.svcCtx.AccountModel.Insert(l.ctx, &model.Account{
Account: in.LoginId,
Token: token,
Platform: in.Platform,
CreateTime: now,
UpdateTime: now,
})
if err != nil {
// 新增進去
var mysqlErr *mysql.MySQLError
if errors.As(err, &mysqlErr) && mysqlErr.Number == 1062 {
// 處理重複條目錯誤
return nil, ers.DBDuplicate(in.LoginId)
}
return nil, ers.DBError(err.Error())
}
return &member.OKResp{}, nil
}

View File

@ -0,0 +1,158 @@
package accountlogic
import (
"app-cloudep-member-server/gen_result/pb/member"
libMock "app-cloudep-member-server/internal/mock/lib"
modelMock "app-cloudep-member-server/internal/mock/model"
usecaseMock "app-cloudep-member-server/internal/mock/usecase"
"app-cloudep-member-server/internal/svc"
"context"
"fmt"
"testing"
"github.com/alicebob/miniredis/v2"
"github.com/go-sql-driver/mysql"
"github.com/stretchr/testify/assert"
"github.com/zeromicro/go-zero/core/stores/redis"
"go.uber.org/mock/gomock"
)
func TestCreateUserAccountLogic_CreateUserAccount(t *testing.T) {
// mock
ctrl := gomock.NewController(t)
defer ctrl.Finish()
modelAccountModel := modelMock.NewMockAccountModel(ctrl)
mockGenUIDModel := usecaseMock.NewMockUIDGenerateUseCase(ctrl)
mockValidate := libMock.NewMockValidate(ctrl)
r1, err := miniredis.Run()
assert.NoError(t, err)
defer r1.Close()
newRedis, err := redis.NewRedis(redis.RedisConf{
Host: r1.Addr(),
Type: redis.ClusterType,
Pass: "",
})
assert.NoError(t, err)
sc := svc.ServiceContext{
AccountModel: modelAccountModel,
GenUIDUseCase: mockGenUIDModel,
Redis: *newRedis,
Validate: mockValidate,
}
l := NewCreateUserAccountLogic(context.Background(), &sc)
tests := []struct {
name string
input *member.CreateLoginUserReq
setupMocks func()
expectError bool
expected *member.OKResp
}{
{
name: "ok",
input: &member.CreateLoginUserReq{
LoginId: "test_user",
Platform: 1,
Token: "password123",
},
setupMocks: func() {
mockValidate.EXPECT().
ValidateAll(gomock.Any()).
Return(nil)
modelAccountModel.EXPECT().
Insert(gomock.Any(), gomock.Any()).
Return(nil, nil)
},
expectError: false,
expected: &member.OKResp{},
},
{
name: "validation failure",
input: &member.CreateLoginUserReq{
LoginId: "test_user",
Platform: 1,
Token: "password123",
},
setupMocks: func() {
mockValidate.EXPECT().
ValidateAll(gomock.Any()).
Return(fmt.Errorf("validation error"))
},
expectError: true,
},
{
name: "password hash failure",
input: &member.CreateLoginUserReq{
LoginId: "test_user",
Platform: 1,
Token: "password123",
},
setupMocks: func() {
mockValidate.EXPECT().
ValidateAll(gomock.Any()).
Return(nil)
HasPasswordFunc = func(password string, cost int) (string, error) {
return "", fmt.Errorf("hash error")
}
},
expectError: true,
},
{
name: "duplicate entry error",
input: &member.CreateLoginUserReq{
LoginId: "test_user",
Platform: 1,
Token: "password123",
},
setupMocks: func() {
mockValidate.EXPECT().
ValidateAll(gomock.Any()).
Return(nil)
HasPasswordFunc = func(password string, cost int) (string, error) {
return "hashedpassword", nil
}
modelAccountModel.EXPECT().
Insert(gomock.Any(), gomock.Any()).
Return(nil, &mysql.MySQLError{Number: 1062, Message: "Duplicate entry"})
},
expectError: true,
},
{
name: "database error",
input: &member.CreateLoginUserReq{
LoginId: "test_user",
Platform: 1,
Token: "password123",
},
setupMocks: func() {
mockValidate.EXPECT().
ValidateAll(gomock.Any()).
Return(nil)
HasPasswordFunc = func(password string, cost int) (string, error) {
return "hashedpassword", nil
}
modelAccountModel.EXPECT().
Insert(gomock.Any(), gomock.Any()).
Return(nil, fmt.Errorf("database error"))
},
expectError: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
tt.setupMocks()
resp, err := l.CreateUserAccount(tt.input)
if tt.expectError {
assert.Error(t, err)
} else {
assert.NoError(t, err)
assert.Equal(t, tt.expected, resp)
}
})
}
}

View File

@ -0,0 +1,120 @@
package accountlogic
import (
"context"
"crypto/rand"
"fmt"
"math/big"
"strconv"
ers "code.30cm.net/digimon/library-go/errors"
"app-cloudep-member-server/gen_result/pb/member"
"app-cloudep-member-server/internal/svc"
"github.com/zeromicro/go-zero/core/logx"
)
type GenerateRefreshCodeLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGenerateRefreshCodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GenerateRefreshCodeLogic {
return &GenerateRefreshCodeLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
type generateRefreshCodeReq struct {
Account string `json:"account" validate:"account"`
// CodeType 1 register_email, 2 register_phone, 3 forget_email
CodeType int32 `json:"code_type" validate:"required,oneof=1 2 3"`
}
// GenerateRefreshCode 這個帳號驗證碼(十分鐘),通用的
func (l *GenerateRefreshCodeLogic) GenerateRefreshCode(in *member.GenerateRefreshCodeReq) (*member.GenerateRefreshCodeResp, error) {
// 驗證資料
if err := l.svcCtx.Validate.ValidateAll(&generateRefreshCodeReq{
Account: in.GetAccount(),
CodeType: in.GetCodeType(),
}); err != nil {
return nil, ers.InvalidFormat(err.Error())
}
checkType, status := getCodeNameByCode(in.GetCodeType())
if !status {
return nil, ers.InvalidFormat(fmt.Errorf("failed to get correct code type").Error())
}
rk := fmt.Sprintf("verify:%s:%s", checkType, in.GetAccount())
// 拿過就不要再拿了
get, err := l.svcCtx.Redis.Get(rk)
if err != nil {
return nil, ers.DBError("failed to connect to redis", err.Error())
}
if get != "" {
return &member.GenerateRefreshCodeResp{
Data: &member.VerifyCode{
VerifyCode: get,
},
}, nil
}
code, err := generateVerifyCode(6)
if !status {
return nil, ers.ArkInternal(err.Error())
}
err = l.svcCtx.Redis.Setex(rk, code, 600)
if err != nil {
return nil, ers.ArkInternal(err.Error())
}
return &member.GenerateRefreshCodeResp{
Data: &member.VerifyCode{
VerifyCode: code,
},
}, nil
}
var codeMap = map[int32]string{
1: "email",
2: "phone",
3: "forget_email",
}
func getCodeNameByCode(code int32) (string, bool) {
res, ok := codeMap[code]
if !ok {
return "", false
}
return res, true
}
func generateVerifyCode(digits int) (string, error) {
if digits <= 0 {
// 預設為六位數
digits = 6
}
// 計算最大值 (10^digits - 1)
exp := new(big.Int).Exp(big.NewInt(10), big.NewInt(int64(digits)), nil)
// 生成隨機數
randomNumber, err := rand.Int(rand.Reader, exp)
if err != nil {
return "", err
}
// 將隨機數轉換為 string
verifyCode := strconv.Itoa(int(randomNumber.Int64()))
// 如果隨機數的位數少於指定的位數,則補 0
if len(verifyCode) < digits {
verifyCode = fmt.Sprintf("%0*d", digits, randomNumber)
}
return verifyCode, nil
}

View File

@ -0,0 +1,51 @@
package accountlogic
import (
"testing"
"github.com/stretchr/testify/assert"
)
func Test_getCodeNameByCode(t *testing.T) {
type args struct {
code int32
}
tests := []struct {
name string
args args
want string
want1 bool
}{
{
name: "email",
args: args{
code: 1,
},
want: "email",
want1: true,
},
{
name: "phone",
args: args{
code: 2,
},
want: "phone",
want1: true,
},
{
name: "none",
args: args{
code: 4,
},
want: "",
want1: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, got1 := getCodeNameByCode(tt.args.code)
assert.Equalf(t, tt.want, got, "getCodeNameByCode(%v)", tt.args.code)
assert.Equalf(t, tt.want1, got1, "getCodeNameByCode(%v)", tt.args.code)
})
}
}

View File

@ -0,0 +1,50 @@
package accountlogic
import (
"context"
ers "code.30cm.net/digimon/library-go/errors"
"app-cloudep-member-server/gen_result/pb/member"
"app-cloudep-member-server/internal/svc"
"github.com/zeromicro/go-zero/core/logx"
)
type GetUidByAccountLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetUidByAccountLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUidByAccountLogic {
return &GetUidByAccountLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
type getUidByAccountReq struct {
Account string `json:"account" validate:"account"`
}
// GetUidByAccount 用帳號換取 UID
func (l *GetUidByAccountLogic) GetUidByAccount(in *member.GetUIDByAccountReq) (*member.GetUidByAccountResp, error) {
// 驗證資料
if err := l.svcCtx.Validate.ValidateAll(&getUidByAccountReq{
Account: in.GetAccount(),
}); err != nil {
return nil, ers.InvalidFormat(err.Error())
}
account, err := l.svcCtx.AccountToUidModel.FindOneByAccount(l.ctx, in.GetAccount())
if err != nil {
return nil, err
}
return &member.GetUidByAccountResp{
Uid: account.Uid,
Account: in.GetAccount(),
}, nil
}

View File

@ -0,0 +1,54 @@
package accountlogic
import (
"context"
ers "code.30cm.net/digimon/library-go/errors"
"app-cloudep-member-server/gen_result/pb/member"
"app-cloudep-member-server/internal/svc"
"github.com/zeromicro/go-zero/core/logx"
)
type GetUserAccountInfoLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetUserAccountInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUserAccountInfoLogic {
return &GetUserAccountInfoLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
type getUserAccountReq struct {
LoginId string `json:"login_id" validate:"account"`
}
// GetUserAccountInfo 取得帳號密碼資料
func (l *GetUserAccountInfoLogic) GetUserAccountInfo(in *member.GetUIDByAccountReq) (*member.GetAccountInfoResp, error) {
// 驗證資料
if err := l.svcCtx.Validate.ValidateAll(getUserAccountReq{
LoginId: in.GetAccount(),
}); err != nil {
return nil, ers.InvalidFormat(err.Error())
}
account, err := l.svcCtx.AccountModel.FindOneByAccount(l.ctx, in.GetAccount())
if err != nil {
return nil, ers.DBError(err.Error())
}
return &member.GetAccountInfoResp{
Data: &member.CreateLoginUserReq{
LoginId: account.Account,
Token: account.Token,
Platform: account.Platform,
},
}, nil
}

View File

@ -0,0 +1,54 @@
package accountlogic
import (
"app-cloudep-member-server/internal/model"
"context"
ers "code.30cm.net/digimon/library-go/errors"
"app-cloudep-member-server/gen_result/pb/member"
"app-cloudep-member-server/internal/svc"
"github.com/zeromicro/go-zero/core/logx"
)
type GetUserInfoLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetUserInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUserInfoLogic {
return &GetUserInfoLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// GetUserInfo 取得會員資訊
func (l *GetUserInfoLogic) GetUserInfo(in *member.GetUserInfoReq) (*member.GetUserInfoResp, error) {
var entity *model.UserTable
var err error
if in.GetUid() != "" {
entity, err = l.svcCtx.UserModel.FindOneByUid(l.ctx, in.GetUid())
if err != nil {
return nil, ers.DBError(err.Error())
}
} else {
if in.GetNickName() != "" {
entity, err = l.svcCtx.UserModel.FindOneByNickName(l.ctx, in.GetNickName())
if err != nil {
return nil, ers.DBError(err.Error())
}
}
}
if entity != nil {
return &member.GetUserInfoResp{}, nil
}
return nil, ers.ResourceNotFound("filed to get user info")
}

View File

@ -0,0 +1,156 @@
package accountlogic
import (
"app-cloudep-member-server/internal/domain"
"app-cloudep-member-server/internal/model"
"context"
"fmt"
"strconv"
ers "code.30cm.net/digimon/library-go/errors"
"app-cloudep-member-server/gen_result/pb/member"
"app-cloudep-member-server/internal/svc"
"github.com/zeromicro/go-zero/core/logx"
)
type ListMemberLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewListMemberLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListMemberLogic {
return &ListMemberLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// ListMember 取得會員列表
func (l *ListMemberLogic) ListMember(in *member.ListUserInfoReq) (*member.ListUserInfoResp, error) {
params, err := parse(in)
if err != nil {
return nil, ers.InvalidFormat("failed to get correct param", err.Error())
}
members, err := l.svcCtx.UserModel.ListMembers(l.ctx, &params)
if err != nil {
return nil, ers.DBError(err.Error())
}
count, err := l.svcCtx.UserModel.Count(l.ctx)
if err != nil {
return nil, ers.DBError(err.Error())
}
var data = make([]*member.UserInfo, 0, len(members))
for _, item := range members {
data = append(data, &member.UserInfo{
Uid: item.Uid,
VerifyType: member.VerifyType(item.VerifyType),
AlarmType: member.AlarmType(item.AlarmType),
Status: member.MemberStatus(item.Status),
Language: item.Language,
Currency: item.Currency,
NickName: &item.NickName,
Avatar: item.Avatar,
})
}
return &member.ListUserInfoResp{
Data: data,
Page: &member.Pager{
Total: count,
Size: in.PageSize,
Index: in.PageIndex,
},
}, nil
}
func parse(in *member.ListUserInfoReq) (model.UserQueryParams, error) {
var filter model.UserQueryParams
// 設置 PageSize
filter.PageSize = getValidPageSize(in.PageSize)
// 設置 PageIndex
filter.PageIndex = getValidPageIndex(in.PageIndex)
// 設置 VerifyType
svt := fmt.Sprintf("%d", in.GetVerifyType().Number())
vt, err := getInt32FromStringPointer(&svt)
if err != nil {
return model.UserQueryParams{}, err
}
if vt != nil {
filter.VerifyType = vt
}
// 設置 AlarmType
sat := fmt.Sprintf("%d", in.GetAlarmType().Number())
at, err := getInt32FromStringPointer(&sat)
if err != nil {
return model.UserQueryParams{}, err
}
if at != nil {
filter.AlarmType = at
}
// 設置 Status
sst := fmt.Sprintf("%d", in.GetStatus().Number())
st, err := getInt32FromStringPointer(&sst)
if err != nil {
return model.UserQueryParams{}, err
}
if st != nil {
filter.Status = st
}
// 設置 CreateStartTime
if in.CreateStartTime != nil {
ct := in.GetCreateStartTime()
filter.CreateStartTime = &ct
}
// 設置 CreateEndTime
if in.CreateEndTime != nil {
et := in.GetCreateEndTime()
filter.CreateEndTime = &et
}
return filter, nil
}
func getValidPageSize(pageSize int64) int64 {
if pageSize <= 0 {
return domain.DefaultPageSize
}
return pageSize
}
func getValidPageIndex(pageIndex int64) int64 {
if pageIndex <= 0 {
return domain.DefaultPageIndex
}
return pageIndex
}
func getInt32FromStringPointer(strPtr *string) (*int32, error) {
if strPtr == nil {
return nil, nil
}
value, err := strconv.Atoi(*strPtr)
if err != nil {
return nil, err
}
int32Value := int32(value)
if int32Value == 0 {
return nil, nil
}
return &int32Value, nil
}

View File

@ -0,0 +1,49 @@
package accountlogic
import (
"context"
ers "code.30cm.net/digimon/library-go/errors"
"app-cloudep-member-server/gen_result/pb/member"
"app-cloudep-member-server/internal/svc"
"github.com/zeromicro/go-zero/core/logx"
)
type UpdateStatusLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewUpdateStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateStatusLogic {
return &UpdateStatusLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
type updateStatusReq struct {
UID string `json:"uid" validate:"required"`
Status int32 `json:"status" validate:"required,oneof=1 2 3 4 5 6"`
}
// UpdateStatus 修改狀態
func (l *UpdateStatusLogic) UpdateStatus(in *member.UpdateStatusReq) (*member.OKResp, error) {
// 驗證資料
if err := l.svcCtx.Validate.ValidateAll(&updateStatusReq{
UID: in.GetUid(),
Status: int32(in.GetStatus()),
}); err != nil {
return nil, ers.InvalidFormat(err.Error())
}
err := l.svcCtx.UserModel.UpdateStatus(l.ctx, in.GetUid(), int32(in.GetStatus()))
if err != nil {
return nil, ers.DBError(err.Error())
}
return &member.OKResp{}, nil
}

View File

@ -0,0 +1,36 @@
package accountlogic
import (
"context"
ers "code.30cm.net/digimon/library-go/errors"
"app-cloudep-member-server/gen_result/pb/member"
"app-cloudep-member-server/internal/svc"
"github.com/zeromicro/go-zero/core/logx"
)
type UpdateUserInfoLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewUpdateUserInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateUserInfoLogic {
return &UpdateUserInfoLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// UpdateUserInfo 更新 User Info
func (l *UpdateUserInfoLogic) UpdateUserInfo(in *member.UpdateUserInfoReq) (*member.OKResp, error) {
err := l.svcCtx.UserModel.UpdateSome(l.ctx, in)
if err != nil {
return nil, ers.DBError(err.Error())
}
return &member.OKResp{}, nil
}

View File

@ -0,0 +1,58 @@
package accountlogic
import (
"app-cloudep-member-server/internal/utils"
"context"
"fmt"
ers "code.30cm.net/digimon/library-go/errors"
"app-cloudep-member-server/gen_result/pb/member"
"app-cloudep-member-server/internal/svc"
"github.com/zeromicro/go-zero/core/logx"
)
type UpdateUserTokenLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewUpdateUserTokenLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateUserTokenLogic {
return &UpdateUserTokenLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
type updateUserTokenReq struct {
LoginId string `json:"login_id" validate:"account"`
Platform int64 `json:"platform" validate:"required,oneof=1"` // '平台類型 1. ark 只有我們自己平台才可以改密碼
Token string `json:"token" validate:"required"`
}
// UpdateUserToken 更新密碼
func (l *UpdateUserTokenLogic) UpdateUserToken(in *member.UpdateTokenReq) (*member.OKResp, error) {
// 驗證資料
if err := l.svcCtx.Validate.ValidateAll(&updateUserTokenReq{
LoginId: in.GetAccount(),
Token: in.GetToken(),
Platform: in.GetPlatform(),
}); err != nil {
return nil, ers.InvalidFormat(err.Error())
}
token, err := utils.HashPassword(in.GetToken(), l.svcCtx.Config.Bcrypt.Cost)
if err != nil {
return nil, ers.ArkInternal(fmt.Sprintf("failed to encrypt err: %v", err.Error()))
}
err = l.svcCtx.AccountModel.UpdateTokenByLoginID(l.ctx, in.GetAccount(), token)
if err != nil {
return nil, ers.DBError(err.Error())
}
return &member.OKResp{}, nil
}

View File

@ -0,0 +1,63 @@
package accountlogic
import (
"context"
"fmt"
ers "code.30cm.net/digimon/library-go/errors"
"app-cloudep-member-server/gen_result/pb/member"
"app-cloudep-member-server/internal/svc"
"github.com/zeromicro/go-zero/core/logx"
)
type VerifyRefreshCodeLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewVerifyRefreshCodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *VerifyRefreshCodeLogic {
return &VerifyRefreshCodeLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// VerifyRefreshCode 驗證忘記密碼 token
func (l *VerifyRefreshCodeLogic) VerifyRefreshCode(in *member.VerifyRefreshCodeReq) (*member.OKResp, error) {
// 驗證資料
if err := l.svcCtx.Validate.ValidateAll(&generateRefreshCodeReq{
Account: in.GetAccount(),
CodeType: in.GetCodeType(),
}); err != nil {
return nil, ers.InvalidFormat(err.Error())
}
checkType, status := getCodeNameByCode(in.GetCodeType())
if !status {
return nil, ers.InvalidFormat(fmt.Errorf("failed to get correct code type").Error())
}
rk := fmt.Sprintf("verify:%s:%s", checkType, in.GetAccount())
get, err := l.svcCtx.Redis.Get(rk)
if err != nil {
return nil, ers.DBError("failed to connect to redis", err.Error())
}
if get == "" {
return nil, ers.DBError("failed to get data from redis")
}
if get != fmt.Sprintf("%d", in.CodeType) {
return nil, ers.ArkInternal("Illegible Verify Code")
}
_, err = l.svcCtx.Redis.Del(rk)
if err != nil {
return nil, ers.DBError("failed to del redis key", rk)
}
return &member.OKResp{}, nil
}

View File

@ -0,0 +1,95 @@
// Code generated by goctl. DO NOT EDIT.
// Source: service.proto
package server
import (
"context"
"app-cloudep-member-server/gen_result/pb/member"
accountlogic "app-cloudep-member-server/internal/logic/account"
"app-cloudep-member-server/internal/svc"
)
type AccountServer struct {
svcCtx *svc.ServiceContext
member.UnimplementedAccountServer
}
func NewAccountServer(svcCtx *svc.ServiceContext) *AccountServer {
return &AccountServer{
svcCtx: svcCtx,
}
}
// CreateUserAccount 建立帳號與密碼 -> 可登入,但可不可以做其他事情看業務流程,也可以只註冊就好
func (s *AccountServer) CreateUserAccount(ctx context.Context, in *member.CreateLoginUserReq) (*member.OKResp, error) {
l := accountlogic.NewCreateUserAccountLogic(ctx, s.svcCtx)
return l.CreateUserAccount(in)
}
// GetUserAccountInfo 取得帳號密碼資料
func (s *AccountServer) GetUserAccountInfo(ctx context.Context, in *member.GetUIDByAccountReq) (*member.GetAccountInfoResp, error) {
l := accountlogic.NewGetUserAccountInfoLogic(ctx, s.svcCtx)
return l.GetUserAccountInfo(in)
}
// UpdateUserToken 更新密碼
func (s *AccountServer) UpdateUserToken(ctx context.Context, in *member.UpdateTokenReq) (*member.OKResp, error) {
l := accountlogic.NewUpdateUserTokenLogic(ctx, s.svcCtx)
return l.UpdateUserToken(in)
}
// GetUidByAccount 用帳號換取 UID
func (s *AccountServer) GetUidByAccount(ctx context.Context, in *member.GetUIDByAccountReq) (*member.GetUidByAccountResp, error) {
l := accountlogic.NewGetUidByAccountLogic(ctx, s.svcCtx)
return l.GetUidByAccount(in)
}
// BindAccount 綁定帳號 -> account bind to UID
func (s *AccountServer) BindAccount(ctx context.Context, in *member.BindingUserReq) (*member.BindingUserResp, error) {
l := accountlogic.NewBindAccountLogic(ctx, s.svcCtx)
return l.BindAccount(in)
}
// BindUserInfo 初次,綁定 User Info
func (s *AccountServer) BindUserInfo(ctx context.Context, in *member.CreateUserInfoReq) (*member.OKResp, error) {
l := accountlogic.NewBindUserInfoLogic(ctx, s.svcCtx)
return l.BindUserInfo(in)
}
// UpdateUserInfo 更新 User Info
func (s *AccountServer) UpdateUserInfo(ctx context.Context, in *member.UpdateUserInfoReq) (*member.OKResp, error) {
l := accountlogic.NewUpdateUserInfoLogic(ctx, s.svcCtx)
return l.UpdateUserInfo(in)
}
// UpdateStatus 修改狀態
func (s *AccountServer) UpdateStatus(ctx context.Context, in *member.UpdateStatusReq) (*member.OKResp, error) {
l := accountlogic.NewUpdateStatusLogic(ctx, s.svcCtx)
return l.UpdateStatus(in)
}
// GetUserInfo 取得會員資訊
func (s *AccountServer) GetUserInfo(ctx context.Context, in *member.GetUserInfoReq) (*member.GetUserInfoResp, error) {
l := accountlogic.NewGetUserInfoLogic(ctx, s.svcCtx)
return l.GetUserInfo(in)
}
// ListMember 取得會員列表
func (s *AccountServer) ListMember(ctx context.Context, in *member.ListUserInfoReq) (*member.ListUserInfoResp, error) {
l := accountlogic.NewListMemberLogic(ctx, s.svcCtx)
return l.ListMember(in)
}
// GenerateRefreshCode 這個帳號驗證碼(十分鐘),通用的
func (s *AccountServer) GenerateRefreshCode(ctx context.Context, in *member.GenerateRefreshCodeReq) (*member.GenerateRefreshCodeResp, error) {
l := accountlogic.NewGenerateRefreshCodeLogic(ctx, s.svcCtx)
return l.GenerateRefreshCode(in)
}
// VerifyRefreshCode 驗證忘記密碼 token
func (s *AccountServer) VerifyRefreshCode(ctx context.Context, in *member.VerifyRefreshCodeReq) (*member.OKResp, error) {
l := accountlogic.NewVerifyRefreshCodeLogic(ctx, s.svcCtx)
return l.VerifyRefreshCode(in)
}