Compare commits
	
		
			3 Commits
		
	
	
		
			b67ae5a1e5
			...
			83a57e750f
		
	
	| Author | SHA1 | Date | 
|---|---|---|
|  | 83a57e750f | |
|  | 41477c4ec6 | |
|  | 627c160aea | 
|  | @ -2,5 +2,6 @@ | |||
| go.sum | ||||
| account/ | ||||
| gen_result/ | ||||
| etc/service.yaml | ||||
| client/ | ||||
| etc/permission.yaml | ||||
| client/ | ||||
| .DS_Store | ||||
							
								
								
									
										2
									
								
								Makefile
								
								
								
								
							
							
						
						
									
										2
									
								
								Makefile
								
								
								
								
							|  | @ -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
								
								
								
								
							
							
						
						
									
										2
									
								
								go.mod
								
								
								
								
							|  | @ -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 | ||||
|  |  | |||
|  | @ -1,9 +1,10 @@ | |||
| package tokenservicelogic | ||||
| 
 | ||||
| import ( | ||||
| 	ers "code.30cm.net/digimon/library-go/errors" | ||||
| 	"context" | ||||
| 
 | ||||
| 	ers "code.30cm.net/digimon/library-go/errors" | ||||
| 
 | ||||
| 	"app-cloudep-permission-server/gen_result/pb/permission" | ||||
| 	"app-cloudep-permission-server/internal/svc" | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,9 +1,10 @@ | |||
| package tokenservicelogic | ||||
| 
 | ||||
| import ( | ||||
| 	ers "code.30cm.net/digimon/library-go/errors" | ||||
| 	"context" | ||||
| 
 | ||||
| 	ers "code.30cm.net/digimon/library-go/errors" | ||||
| 
 | ||||
| 	"app-cloudep-permission-server/gen_result/pb/permission" | ||||
| 	"app-cloudep-permission-server/internal/svc" | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,9 +1,10 @@ | |||
| package tokenservicelogic | ||||
| 
 | ||||
| import ( | ||||
| 	ers "code.30cm.net/digimon/library-go/errors" | ||||
| 	"context" | ||||
| 
 | ||||
| 	ers "code.30cm.net/digimon/library-go/errors" | ||||
| 
 | ||||
| 	"app-cloudep-permission-server/gen_result/pb/permission" | ||||
| 	"app-cloudep-permission-server/internal/svc" | ||||
| 
 | ||||
|  |  | |||
|  | @ -2,9 +2,10 @@ package tokenservicelogic | |||
| 
 | ||||
| import ( | ||||
| 	"app-cloudep-permission-server/internal/domain" | ||||
| 	ers "code.30cm.net/digimon/library-go/errors" | ||||
| 	"context" | ||||
| 
 | ||||
| 	ers "code.30cm.net/digimon/library-go/errors" | ||||
| 
 | ||||
| 	"app-cloudep-permission-server/gen_result/pb/permission" | ||||
| 	"app-cloudep-permission-server/internal/svc" | ||||
| 
 | ||||
|  |  | |||
|  | @ -2,9 +2,10 @@ package tokenservicelogic | |||
| 
 | ||||
| import ( | ||||
| 	"app-cloudep-permission-server/internal/domain" | ||||
| 	ers "code.30cm.net/digimon/library-go/errors" | ||||
| 	"context" | ||||
| 
 | ||||
| 	ers "code.30cm.net/digimon/library-go/errors" | ||||
| 
 | ||||
| 	"app-cloudep-permission-server/gen_result/pb/permission" | ||||
| 	"app-cloudep-permission-server/internal/svc" | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,11 +3,12 @@ package tokenservicelogic | |||
| import ( | ||||
| 	"app-cloudep-permission-server/internal/domain" | ||||
| 	"app-cloudep-permission-server/internal/entity" | ||||
| 	ers "code.30cm.net/digimon/library-go/errors" | ||||
| 	"context" | ||||
| 	"github.com/google/uuid" | ||||
| 	"time" | ||||
| 
 | ||||
| 	ers "code.30cm.net/digimon/library-go/errors" | ||||
| 	"github.com/google/uuid" | ||||
| 
 | ||||
| 	"app-cloudep-permission-server/gen_result/pb/permission" | ||||
| 	"app-cloudep-permission-server/internal/svc" | ||||
| 
 | ||||
|  |  | |||
|  | @ -4,11 +4,12 @@ import ( | |||
| 	"app-cloudep-permission-server/internal/config" | ||||
| 	"app-cloudep-permission-server/internal/domain" | ||||
| 	"app-cloudep-permission-server/internal/entity" | ||||
| 	ers "code.30cm.net/digimon/library-go/errors" | ||||
| 	"context" | ||||
| 	"github.com/google/uuid" | ||||
| 	"time" | ||||
| 
 | ||||
| 	ers "code.30cm.net/digimon/library-go/errors" | ||||
| 	"github.com/google/uuid" | ||||
| 
 | ||||
| 	"app-cloudep-permission-server/gen_result/pb/permission" | ||||
| 	"app-cloudep-permission-server/internal/svc" | ||||
| 
 | ||||
|  |  | |||
|  | @ -2,9 +2,10 @@ package tokenservicelogic | |||
| 
 | ||||
| import ( | ||||
| 	"app-cloudep-permission-server/internal/domain" | ||||
| 	ers "code.30cm.net/digimon/library-go/errors" | ||||
| 	"context" | ||||
| 
 | ||||
| 	ers "code.30cm.net/digimon/library-go/errors" | ||||
| 
 | ||||
| 	"app-cloudep-permission-server/gen_result/pb/permission" | ||||
| 	"app-cloudep-permission-server/internal/svc" | ||||
| 
 | ||||
|  |  | |||
|  | @ -7,8 +7,9 @@ import ( | |||
| 	"crypto/sha256" | ||||
| 	"encoding/hex" | ||||
| 	"fmt" | ||||
| 	"github.com/golang-jwt/jwt/v4" | ||||
| 	"time" | ||||
| 
 | ||||
| 	"github.com/golang-jwt/jwt/v4" | ||||
| ) | ||||
| 
 | ||||
| var generateAccessTokenFunc = generateAccessToken | ||||
|  |  | |||
|  | @ -1,9 +1,10 @@ | |||
| package tokenservicelogic | ||||
| 
 | ||||
| import ( | ||||
| 	ers "code.30cm.net/digimon/library-go/errors" | ||||
| 	"context" | ||||
| 
 | ||||
| 	ers "code.30cm.net/digimon/library-go/errors" | ||||
| 
 | ||||
| 	"app-cloudep-permission-server/gen_result/pb/permission" | ||||
| 	"app-cloudep-permission-server/internal/svc" | ||||
| 
 | ||||
|  |  | |||
|  | @ -241,10 +241,20 @@ func (t *tokenRepository) setRelation(ctx context.Context, tx redis.Pipeliner, u | |||
| 		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 | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| // Code generated by goctl. DO NOT EDIT.
 | ||||
| // Source: service.proto
 | ||||
| // Source: permission.proto
 | ||||
| 
 | ||||
| package server | ||||
| 
 | ||||
|  |  | |||
|  | @ -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() | ||||
		Loading…
	
		Reference in New Issue