fix/protobuf #3

Merged
daniel.w merged 2 commits from fix/protobuf into main 2024-08-24 06:48:54 +00:00
17 changed files with 236 additions and 57 deletions

View File

@ -143,7 +143,9 @@ message UserInfo {
string language = 5;
string currency = 6;
string avatar = 7;
optional string nick_name = 8;
int64 create_time=8;
int64 update_time=9;
optional string nick_name = 10;
}
message GetUserInfoResp {
@ -165,6 +167,17 @@ message ListUserInfoResp {
Pager page =2;
}
message VerifyAuthResultReq {
string token = 1;
}
message VerifyAuthResultResp {
bool status = 1;
}
message TwitterAccessTokenResp {
string token = 1;
}
service Account {
// CreateUserAccount ->
@ -191,6 +204,7 @@ service Account {
rpc GenerateRefreshCode(GenerateRefreshCodeReq) returns(GenerateRefreshCodeResp);
// VerifyRefreshCode token
rpc VerifyRefreshCode(VerifyRefreshCodeReq) returns(OKResp);
// VerifyGoogleAuthResult google
rpc VerifyGoogleAuthResult(VerifyAuthResultReq)returns(VerifyAuthResultResp);
}
// ================ account ================

18
go.mod
View File

@ -13,7 +13,7 @@ require (
go.mongodb.org/mongo-driver v1.16.0
go.uber.org/goleak v1.3.0
go.uber.org/mock v0.4.0
golang.org/x/crypto v0.25.0
golang.org/x/crypto v0.26.0
google.golang.org/grpc v1.65.0
google.golang.org/protobuf v1.34.2
)
@ -91,15 +91,15 @@ require (
go.uber.org/automaxprocs v1.5.3 // indirect
go.uber.org/multierr v1.9.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/oauth2 v0.20.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/term v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/oauth2 v0.22.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.24.0 // indirect
golang.org/x/term v0.23.0 // indirect
golang.org/x/text v0.17.0 // indirect
golang.org/x/time v0.6.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240711142825-46eb208f015d // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect

36
go.sum
View File

@ -228,8 +228,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
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/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
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=
@ -241,17 +241,17 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY
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/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
golang.org/x/oauth2 v0.22.0 h1:BzDx2FehcG7jJwgWLELCdmLuxk2i+x9UDpSiss2u0ZA=
golang.org/x/oauth2 v0.22.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/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
golang.org/x/sync v0.8.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=
@ -263,20 +263,20 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
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/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg=
golang.org/x/sys v0.24.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/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU=
golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk=
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/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U=
golang.org/x/time v0.6.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=
@ -291,8 +291,8 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T
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/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
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=

View File

@ -30,4 +30,9 @@ type Config struct {
Database string
Collection string
}
GoogleAuth struct {
ClientID string
VerifyURL string
}
}

View File

@ -1,5 +1,7 @@
package domain
import "time"
const (
DefaultPageSize = 100
DefaultPageIndex = 1
@ -28,3 +30,12 @@ const (
AccountTypeMail AccountType = 2
AccountTypeAccount AccountType = 3
)
const (
DefaultSingleFlyCacheTimeout = 24 * time.Hour
DefaultFindDataNotFoundTimeout = 30 * time.Second
)
const (
AppName = "app-cloudep-member-service"
)

View File

@ -44,13 +44,6 @@ 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

View File

@ -51,8 +51,6 @@ func (l *CreateUserAccountLogic) CreateUserAccount(in *member.CreateLoginUserReq
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()))

View File

@ -1,7 +1,10 @@
package accountlogic
import (
"app-cloudep-member-server/internal/domain"
"context"
"errors"
"github.com/zeromicro/go-zero/core/stores/sqlx"
ers "code.30cm.net/digimon/library-go/errors"
@ -40,7 +43,17 @@ func (l *GetUidByAccountLogic) GetUidByAccount(in *member.GetUIDByAccountReq) (*
account, err := l.svcCtx.AccountToUidModel.FindOneByAccount(l.ctx, in.GetAccount())
if err != nil {
return nil, err
if errors.As(err, &sqlx.ErrNotFound) {
return nil, ers.ResourceNotFound(in.GetAccount())
}
logx.WithCallerSkip(1).WithFields(
logx.Field("app", domain.AppName),
logx.Field("func", "VerifyGoogleToken"),
logx.Field("req", in),
).Error(err.Error())
return nil, ers.DBError(err.Error())
}
return &member.GetUidByAccountResp{

View File

@ -1,9 +1,10 @@
package accountlogic
import (
"context"
ers "code.30cm.net/digimon/library-go/errors"
"context"
"errors"
"github.com/zeromicro/go-zero/core/stores/sqlx"
"app-cloudep-member-server/gen_result/pb/member"
"app-cloudep-member-server/internal/svc"
@ -40,6 +41,9 @@ func (l *GetUserAccountInfoLogic) GetUserAccountInfo(in *member.GetUIDByAccountR
account, err := l.svcCtx.AccountModel.FindOneByAccount(l.ctx, in.GetAccount())
if err != nil {
if errors.As(err, &sqlx.ErrNotFound) {
return nil, ers.ResourceNotFound(in.GetAccount())
}
return nil, ers.DBError(err.Error())
}

View File

@ -1,15 +1,14 @@
package accountlogic
import (
"app-cloudep-member-server/gen_result/pb/member"
"app-cloudep-member-server/internal/model"
"app-cloudep-member-server/internal/svc"
ers "code.30cm.net/digimon/library-go/errors"
"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"
"google.golang.org/protobuf/proto"
)
type GetUserInfoLogic struct {
@ -47,7 +46,20 @@ func (l *GetUserInfoLogic) GetUserInfo(in *member.GetUserInfoReq) (*member.GetUs
}
if entity != nil {
return &member.GetUserInfoResp{}, nil
return &member.GetUserInfoResp{
Data: &member.UserInfo{
Uid: entity.Uid,
AlarmType: member.AlarmType(entity.AlarmType),
VerifyType: member.VerifyType(entity.VerifyType),
Status: member.MemberStatus(entity.Status),
NickName: proto.String(entity.NickName),
Language: entity.Language,
Currency: entity.Currency,
Avatar: entity.Avatar,
CreateTime: entity.CreateTime,
UpdateTime: entity.UpdateTime,
},
}, nil
}
return nil, ers.ResourceNotFound("filed to get user info")

View File

@ -5,6 +5,7 @@ import (
"app-cloudep-member-server/internal/model"
"context"
"fmt"
"google.golang.org/protobuf/proto"
"strconv"
ers "code.30cm.net/digimon/library-go/errors"
@ -56,7 +57,9 @@ func (l *ListMemberLogic) ListMember(in *member.ListUserInfoReq) (*member.ListUs
Status: member.MemberStatus(item.Status),
Language: item.Language,
Currency: item.Currency,
NickName: &item.NickName,
NickName: proto.String(item.NickName),
CreateTime: item.CreateTime,
UpdateTime: item.UpdateTime,
Avatar: item.Avatar,
})
}

View File

@ -1,9 +1,12 @@
package accountlogic
import (
"app-cloudep-member-server/internal/domain"
"app-cloudep-member-server/internal/utils"
"context"
"errors"
"fmt"
"github.com/zeromicro/go-zero/core/stores/sqlx"
ers "code.30cm.net/digimon/library-go/errors"
@ -51,6 +54,16 @@ func (l *UpdateUserTokenLogic) UpdateUserToken(in *member.UpdateTokenReq) (*memb
err = l.svcCtx.AccountModel.UpdateTokenByLoginID(l.ctx, in.GetAccount(), token)
if err != nil {
if errors.As(err, &sqlx.ErrNotFound) {
return nil, ers.ResourceNotFound(in.GetAccount())
}
logx.WithCallerSkip(1).WithFields(
logx.Field("app", domain.AppName),
logx.Field("func", "VerifyGoogleToken"),
logx.Field("req", in),
).Error(err.Error())
return nil, ers.DBError(err.Error())
}

View File

@ -1,6 +1,7 @@
package accountlogic
import (
"app-cloudep-member-server/internal/domain"
"context"
"fmt"
@ -43,6 +44,11 @@ func (l *VerifyRefreshCodeLogic) VerifyRefreshCode(in *member.VerifyRefreshCodeR
rk := fmt.Sprintf("verify:%s:%s", checkType, in.GetAccount())
get, err := l.svcCtx.Redis.Get(rk)
if err != nil {
logx.WithCallerSkip(1).WithFields(
logx.Field("app", domain.AppName),
logx.Field("func", "Redis.Get"),
logx.Field("req", in),
).Error(err.Error())
return nil, ers.DBError("failed to connect to redis", err.Error())
}
@ -50,12 +56,17 @@ func (l *VerifyRefreshCodeLogic) VerifyRefreshCode(in *member.VerifyRefreshCodeR
return nil, ers.DBError("failed to get data from redis")
}
if get != fmt.Sprintf("%d", in.CodeType) {
if get != fmt.Sprintf("%s", in.VerifyCode) {
return nil, ers.ArkInternal("Illegible Verify Code")
}
_, err = l.svcCtx.Redis.Del(rk)
if err != nil {
logx.WithCallerSkip(1).WithFields(
logx.Field("app", domain.AppName),
logx.Field("func", "Redis.Del"),
logx.Field("key", rk),
).Error(err.Error())
return nil, ers.DBError("failed to del redis key", rk)
}

View File

@ -113,3 +113,17 @@ func (mr *MockAccountModelMockRecorder) Update(ctx, data any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockAccountModel)(nil).Update), ctx, data)
}
// UpdateTokenByLoginID mocks base method.
func (m *MockAccountModel) UpdateTokenByLoginID(ctx context.Context, account, token string) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "UpdateTokenByLoginID", ctx, account, token)
ret0, _ := ret[0].(error)
return ret0
}
// UpdateTokenByLoginID indicates an expected call of UpdateTokenByLoginID.
func (mr *MockAccountModelMockRecorder) UpdateTokenByLoginID(ctx, account, token any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateTokenByLoginID", reflect.TypeOf((*MockAccountModel)(nil).UpdateTokenByLoginID), ctx, account, token)
}

View File

@ -10,6 +10,7 @@
package mock
import (
member "app-cloudep-member-server/gen_result/pb/member"
model "app-cloudep-member-server/internal/model"
context "context"
sql "database/sql"
@ -41,6 +42,21 @@ func (m *MockUserTableModel) EXPECT() *MockUserTableModelMockRecorder {
return m.recorder
}
// Count mocks base method.
func (m *MockUserTableModel) Count(ctx context.Context) (int64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Count", ctx)
ret0, _ := ret[0].(int64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// Count indicates an expected call of Count.
func (mr *MockUserTableModelMockRecorder) Count(ctx any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Count", reflect.TypeOf((*MockUserTableModel)(nil).Count), ctx)
}
// Delete mocks base method.
func (m *MockUserTableModel) Delete(ctx context.Context, id int64) error {
m.ctrl.T.Helper()
@ -70,6 +86,21 @@ func (mr *MockUserTableModelMockRecorder) FindOne(ctx, id any) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindOne", reflect.TypeOf((*MockUserTableModel)(nil).FindOne), ctx, id)
}
// FindOneByNickName mocks base method.
func (m *MockUserTableModel) FindOneByNickName(ctx context.Context, uid string) (*model.UserTable, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "FindOneByNickName", ctx, uid)
ret0, _ := ret[0].(*model.UserTable)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// FindOneByNickName indicates an expected call of FindOneByNickName.
func (mr *MockUserTableModelMockRecorder) FindOneByNickName(ctx, uid any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindOneByNickName", reflect.TypeOf((*MockUserTableModel)(nil).FindOneByNickName), ctx, uid)
}
// FindOneByUid mocks base method.
func (m *MockUserTableModel) FindOneByUid(ctx context.Context, uid string) (*model.UserTable, error) {
m.ctrl.T.Helper()
@ -100,6 +131,21 @@ func (mr *MockUserTableModelMockRecorder) Insert(ctx, data any) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Insert", reflect.TypeOf((*MockUserTableModel)(nil).Insert), ctx, data)
}
// ListMembers mocks base method.
func (m *MockUserTableModel) ListMembers(ctx context.Context, params *model.UserQueryParams) ([]*model.UserTable, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ListMembers", ctx, params)
ret0, _ := ret[0].([]*model.UserTable)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ListMembers indicates an expected call of ListMembers.
func (mr *MockUserTableModelMockRecorder) ListMembers(ctx, params any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListMembers", reflect.TypeOf((*MockUserTableModel)(nil).ListMembers), ctx, params)
}
// Update mocks base method.
func (m *MockUserTableModel) Update(ctx context.Context, data *model.UserTable) error {
m.ctrl.T.Helper()
@ -113,3 +159,31 @@ func (mr *MockUserTableModelMockRecorder) Update(ctx, data any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockUserTableModel)(nil).Update), ctx, data)
}
// UpdateSome mocks base method.
func (m *MockUserTableModel) UpdateSome(ctx context.Context, newData *member.UpdateUserInfoReq) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "UpdateSome", ctx, newData)
ret0, _ := ret[0].(error)
return ret0
}
// UpdateSome indicates an expected call of UpdateSome.
func (mr *MockUserTableModelMockRecorder) UpdateSome(ctx, newData any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateSome", reflect.TypeOf((*MockUserTableModel)(nil).UpdateSome), ctx, newData)
}
// UpdateStatus mocks base method.
func (m *MockUserTableModel) UpdateStatus(ctx context.Context, uid string, status int32) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "UpdateStatus", ctx, uid, status)
ret0, _ := ret[0].(error)
return ret0
}
// UpdateStatus indicates an expected call of UpdateStatus.
func (mr *MockUserTableModelMockRecorder) UpdateStatus(ctx, uid, status any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateStatus", reflect.TypeOf((*MockUserTableModel)(nil).UpdateStatus), ctx, uid, status)
}

View File

@ -93,3 +93,9 @@ func (s *AccountServer) VerifyRefreshCode(ctx context.Context, in *member.Verify
l := accountlogic.NewVerifyRefreshCodeLogic(ctx, s.svcCtx)
return l.VerifyRefreshCode(in)
}
// VerifyGoogleAuthResult 驗證 google 登入是否有效
func (s *AccountServer) VerifyGoogleAuthResult(ctx context.Context, in *member.VerifyAuthResultReq) (*member.VerifyAuthResultResp, error) {
l := accountlogic.NewVerifyGoogleAuthResultLogic(ctx, s.svcCtx)
return l.VerifyGoogleAuthResult(in)
}

View File

@ -7,10 +7,10 @@ import (
"app-cloudep-member-server/internal/model"
mgo "app-cloudep-member-server/internal/model/mongo"
"app-cloudep-member-server/internal/usecase"
"fmt"
ers "code.30cm.net/digimon/library-go/errors"
vi "code.30cm.net/digimon/library-go/validator"
"fmt"
"github.com/zeromicro/go-zero/core/stores/cache"
"github.com/zeromicro/go-zero/core/stores/redis"
"github.com/zeromicro/go-zero/core/stores/sqlx"
)
@ -30,6 +30,7 @@ func NewServiceContext(c config.Config) *ServiceContext {
// 設置
ers.Scope = domain.Scope
// TODO 可優化項目,將連線數量以及 timeout 都便可設定
sqlConn := sqlx.NewMysql(c.DB.DsnString)
newRedis, err := redis.NewRedis(c.RedisCluster, redis.Cluster())
if err != nil {
@ -43,12 +44,19 @@ func NewServiceContext(c config.Config) *ServiceContext {
c.Mongo.Collection)
return &ServiceContext{
Config: c,
Validate: vi.MustValidator(vi.WithAccount("account")),
Redis: *newRedis,
UserModel: model.NewUserTableModel(sqlConn, c.Cache),
AccountToUidModel: model.NewAccountToUidModel(sqlConn, c.Cache),
AccountModel: model.NewAccountModel(sqlConn, c.Cache),
Config: c,
Validate: vi.MustValidator(vi.WithAccount("account")),
Redis: *newRedis,
UserModel: model.NewUserTableModel(sqlConn, c.Cache,
cache.WithExpiry(domain.DefaultSingleFlyCacheTimeout),
cache.WithNotFoundExpiry(domain.DefaultFindDataNotFoundTimeout)),
AccountToUidModel: model.NewAccountToUidModel(sqlConn, c.Cache,
cache.WithExpiry(domain.DefaultSingleFlyCacheTimeout),
cache.WithNotFoundExpiry(domain.DefaultFindDataNotFoundTimeout)),
AccountModel: model.NewAccountModel(sqlConn, c.Cache,
cache.WithExpiry(domain.DefaultSingleFlyCacheTimeout),
cache.WithNotFoundExpiry(domain.DefaultFindDataNotFoundTimeout),
),
GenUIDUseCase: usecase.MustGenerateUseCase(usecase.GenerateUseCaseParam{
GenerateUIDRepo: mongo,
}),