add checkout verify code

This commit is contained in:
daniel.w 2024-08-26 16:33:48 +08:00
parent 627c160aea
commit 41477c4ec6
7 changed files with 17 additions and 7 deletions

5
.gitignore vendored
View File

@ -2,5 +2,6 @@
go.sum
account/
gen_result/
etc/service.yaml
client/
etc/permission.yaml
client/
.DS_Store

View File

@ -19,7 +19,7 @@ fmt: # 格式優化
.PHONY: gen-rpc
gen-rpc: # 建立 rpc code
goctl rpc protoc ./generate/protobuf/service.proto -m --style=$(GO_ZERO_STYLE) --go_out=./gen_result/pb --go-grpc_out=./gen_result/pb --zrpc_out=.
goctl rpc protoc ./generate/protobuf/permission.proto -m --style=$(GO_ZERO_STYLE) --go_out=./gen_result/pb --go-grpc_out=./gen_result/pb --zrpc_out=.
go mod tidy
@echo "Generate core-api files successfully"

2
go.mod
View File

@ -7,6 +7,7 @@ require (
code.30cm.net/digimon/library-go/validator v1.0.0
code.30cm.net/wanderland/library-go/errors v1.0.1
github.com/golang-jwt/jwt/v4 v4.5.0
github.com/google/uuid v1.6.0
github.com/zeromicro/go-zero v1.7.0
go.uber.org/mock v0.4.0
google.golang.org/grpc v1.65.0
@ -40,7 +41,6 @@ require (
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect

View File

@ -240,11 +240,20 @@ func (t *tokenRepository) setRelation(ctx context.Context, tx redis.Pipeliner, u
if err := tx.SAdd(ctx, domain.UIDTokenRedisKey.With(uid).ToString(), tokenID).Err(); err != nil {
return err
}
// 設置 UID 鍵的過期時間
if err := tx.Expire(ctx, domain.UIDTokenRedisKey.With(uid).ToString(), ttl).Err(); err != nil {
return err
}
if err := tx.SAdd(ctx, domain.DeviceTokenRedisKey.With(deviceID).ToString(), tokenID).Err(); err != nil {
return err
}
// 設置 deviceID 鍵的過期時間
if err := tx.Expire(ctx, domain.DeviceTokenRedisKey.With(deviceID).ToString(), ttl).Err(); err != nil {
return err
}
return nil
}

View File

@ -1,5 +1,5 @@
// Code generated by goctl. DO NOT EDIT.
// Source: service.proto
// Source: permission.proto
package server
@ -7,7 +7,7 @@ import (
"context"
"app-cloudep-permission-server/gen_result/pb/permission"
tokenservicelogic "app-cloudep-permission-server/internal/logic/tokenservice"
"app-cloudep-permission-server/internal/logic/tokenservice"
"app-cloudep-permission-server/internal/svc"
)

View File

@ -16,7 +16,7 @@ import (
"google.golang.org/grpc/reflection"
)
var configFile = flag.String("f", "etc/service.yaml", "the config file")
var configFile = flag.String("f", "etc/permission.yaml", "the config file")
func main() {
flag.Parse()