merge feature/fix_proto_name into main

This commit is contained in:
daniel.w 2024-08-27 15:51:14 +08:00
commit 83a57e750f
17 changed files with 39 additions and 18 deletions

3
.gitignore vendored
View File

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

View File

@ -19,7 +19,7 @@ fmt: # 格式優化
.PHONY: gen-rpc .PHONY: gen-rpc
gen-rpc: # 建立 rpc code 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 go mod tidy
@echo "Generate core-api files successfully" @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/digimon/library-go/validator v1.0.0
code.30cm.net/wanderland/library-go/errors v1.0.1 code.30cm.net/wanderland/library-go/errors v1.0.1
github.com/golang-jwt/jwt/v4 v4.5.0 github.com/golang-jwt/jwt/v4 v4.5.0
github.com/google/uuid v1.6.0
github.com/zeromicro/go-zero v1.7.0 github.com/zeromicro/go-zero v1.7.0
go.uber.org/mock v0.4.0 go.uber.org/mock v0.4.0
google.golang.org/grpc v1.65.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/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.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/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
github.com/josharian/intern v1.0.0 // indirect github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect github.com/json-iterator/go v1.1.12 // indirect

View File

@ -1,9 +1,10 @@
package tokenservicelogic package tokenservicelogic
import ( import (
ers "code.30cm.net/digimon/library-go/errors"
"context" "context"
ers "code.30cm.net/digimon/library-go/errors"
"app-cloudep-permission-server/gen_result/pb/permission" "app-cloudep-permission-server/gen_result/pb/permission"
"app-cloudep-permission-server/internal/svc" "app-cloudep-permission-server/internal/svc"

View File

@ -1,9 +1,10 @@
package tokenservicelogic package tokenservicelogic
import ( import (
ers "code.30cm.net/digimon/library-go/errors"
"context" "context"
ers "code.30cm.net/digimon/library-go/errors"
"app-cloudep-permission-server/gen_result/pb/permission" "app-cloudep-permission-server/gen_result/pb/permission"
"app-cloudep-permission-server/internal/svc" "app-cloudep-permission-server/internal/svc"

View File

@ -1,9 +1,10 @@
package tokenservicelogic package tokenservicelogic
import ( import (
ers "code.30cm.net/digimon/library-go/errors"
"context" "context"
ers "code.30cm.net/digimon/library-go/errors"
"app-cloudep-permission-server/gen_result/pb/permission" "app-cloudep-permission-server/gen_result/pb/permission"
"app-cloudep-permission-server/internal/svc" "app-cloudep-permission-server/internal/svc"

View File

@ -2,9 +2,10 @@ package tokenservicelogic
import ( import (
"app-cloudep-permission-server/internal/domain" "app-cloudep-permission-server/internal/domain"
ers "code.30cm.net/digimon/library-go/errors"
"context" "context"
ers "code.30cm.net/digimon/library-go/errors"
"app-cloudep-permission-server/gen_result/pb/permission" "app-cloudep-permission-server/gen_result/pb/permission"
"app-cloudep-permission-server/internal/svc" "app-cloudep-permission-server/internal/svc"

View File

@ -2,9 +2,10 @@ package tokenservicelogic
import ( import (
"app-cloudep-permission-server/internal/domain" "app-cloudep-permission-server/internal/domain"
ers "code.30cm.net/digimon/library-go/errors"
"context" "context"
ers "code.30cm.net/digimon/library-go/errors"
"app-cloudep-permission-server/gen_result/pb/permission" "app-cloudep-permission-server/gen_result/pb/permission"
"app-cloudep-permission-server/internal/svc" "app-cloudep-permission-server/internal/svc"

View File

@ -3,11 +3,12 @@ package tokenservicelogic
import ( import (
"app-cloudep-permission-server/internal/domain" "app-cloudep-permission-server/internal/domain"
"app-cloudep-permission-server/internal/entity" "app-cloudep-permission-server/internal/entity"
ers "code.30cm.net/digimon/library-go/errors"
"context" "context"
"github.com/google/uuid"
"time" "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/gen_result/pb/permission"
"app-cloudep-permission-server/internal/svc" "app-cloudep-permission-server/internal/svc"

View File

@ -4,11 +4,12 @@ import (
"app-cloudep-permission-server/internal/config" "app-cloudep-permission-server/internal/config"
"app-cloudep-permission-server/internal/domain" "app-cloudep-permission-server/internal/domain"
"app-cloudep-permission-server/internal/entity" "app-cloudep-permission-server/internal/entity"
ers "code.30cm.net/digimon/library-go/errors"
"context" "context"
"github.com/google/uuid"
"time" "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/gen_result/pb/permission"
"app-cloudep-permission-server/internal/svc" "app-cloudep-permission-server/internal/svc"

View File

@ -2,9 +2,10 @@ package tokenservicelogic
import ( import (
"app-cloudep-permission-server/internal/domain" "app-cloudep-permission-server/internal/domain"
ers "code.30cm.net/digimon/library-go/errors"
"context" "context"
ers "code.30cm.net/digimon/library-go/errors"
"app-cloudep-permission-server/gen_result/pb/permission" "app-cloudep-permission-server/gen_result/pb/permission"
"app-cloudep-permission-server/internal/svc" "app-cloudep-permission-server/internal/svc"

View File

@ -7,8 +7,9 @@ import (
"crypto/sha256" "crypto/sha256"
"encoding/hex" "encoding/hex"
"fmt" "fmt"
"github.com/golang-jwt/jwt/v4"
"time" "time"
"github.com/golang-jwt/jwt/v4"
) )
var generateAccessTokenFunc = generateAccessToken var generateAccessTokenFunc = generateAccessToken

View File

@ -1,9 +1,10 @@
package tokenservicelogic package tokenservicelogic
import ( import (
ers "code.30cm.net/digimon/library-go/errors"
"context" "context"
ers "code.30cm.net/digimon/library-go/errors"
"app-cloudep-permission-server/gen_result/pb/permission" "app-cloudep-permission-server/gen_result/pb/permission"
"app-cloudep-permission-server/internal/svc" "app-cloudep-permission-server/internal/svc"

View File

@ -241,10 +241,20 @@ func (t *tokenRepository) setRelation(ctx context.Context, tx redis.Pipeliner, u
return err 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 { if err := tx.SAdd(ctx, domain.DeviceTokenRedisKey.With(deviceID).ToString(), tokenID).Err(); err != nil {
return err return err
} }
// 設置 deviceID 鍵的過期時間
if err := tx.Expire(ctx, domain.DeviceTokenRedisKey.With(deviceID).ToString(), ttl).Err(); err != nil {
return err
}
return nil return nil
} }

View File

@ -1,5 +1,5 @@
// Code generated by goctl. DO NOT EDIT. // Code generated by goctl. DO NOT EDIT.
// Source: service.proto // Source: permission.proto
package server package server

View File

@ -16,7 +16,7 @@ import (
"google.golang.org/grpc/reflection" "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() { func main() {
flag.Parse() flag.Parse()