Refactor: Remove deprecated gRPC service files and implement new API structure
- Deleted old gRPC service definitions in `game_grpc.pb.go` and `public.go`. - Added new API server implementations for objectstory, player, and shop services. - Introduced configuration files for new APIs in `etc/*.yaml`. - Created main entry points for each service in `objectstory.go`, `player.go`, and `shop.go`. - Removed unused user update handler and user API files. - Added utility functions for context management and HTTP header parsing. - Introduced PostgreSQL backup configuration in `backup/postgreSql.yaml`.
This commit is contained in:
@@ -11,8 +11,8 @@ import (
|
||||
type Config struct {
|
||||
rest.RestConf
|
||||
FileRpcConf zrpc.RpcClientConf
|
||||
Logger struct {
|
||||
AccessSecret string
|
||||
AccessExpire int64
|
||||
}
|
||||
//Logger struct {
|
||||
// AccessSecret string
|
||||
// AccessExpire int64
|
||||
//}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||
},
|
||||
}...,
|
||||
),
|
||||
rest.WithJwt(serverCtx.Config.Logger.AccessSecret),
|
||||
rest.WithPrefix("/api/v1"),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"juwan-backend/app/objectstory/api/internal/svc"
|
||||
"juwan-backend/app/objectstory/api/internal/types"
|
||||
"juwan-backend/app/objectstory/rpc/fileservice"
|
||||
"juwan-backend/common/utils/contextx"
|
||||
"juwan-backend/common/utils/contextj"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
@@ -36,9 +36,9 @@ func (l *GetFileLogic) GetFile(req *types.GetFileReq) (string, error) {
|
||||
return "", errors.New("file id is required")
|
||||
}
|
||||
|
||||
userID, err := contextx.UserIDFrom(l.ctx)
|
||||
userID, err := contextj.UserIDFrom(l.ctx)
|
||||
if err != nil {
|
||||
return "", contextx.ERRILLEGALUSER
|
||||
return "", contextj.ERRILLEGALUSER
|
||||
}
|
||||
|
||||
rpcResp, err := l.svcCtx.FileRpc.GetFileUrl(l.ctx, &fileservice.GetFileUrlReq{
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"juwan-backend/app/objectstory/api/internal/svc"
|
||||
"juwan-backend/app/objectstory/api/internal/types"
|
||||
"juwan-backend/app/objectstory/rpc/fileservice"
|
||||
"juwan-backend/common/utils/contextx"
|
||||
"juwan-backend/common/utils/contextj"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
@@ -42,7 +42,13 @@ func (l *UploadLogic) Upload(req *types.UploadReq, r *http.Request) (resp *types
|
||||
if err != nil {
|
||||
return nil, errors.New("file is required")
|
||||
}
|
||||
defer file.Close()
|
||||
defer func() {
|
||||
err := file.Close()
|
||||
if err != nil {
|
||||
logx.Errorf("failed to close file: %v", err)
|
||||
return
|
||||
}
|
||||
}()
|
||||
|
||||
fileData, err := io.ReadAll(file)
|
||||
if err != nil {
|
||||
@@ -52,9 +58,9 @@ func (l *UploadLogic) Upload(req *types.UploadReq, r *http.Request) (resp *types
|
||||
return nil, errors.New("empty file is not allowed")
|
||||
}
|
||||
|
||||
userID, err := contextx.UserIDFrom(l.ctx)
|
||||
userID, err := contextj.UserIDFrom(l.ctx)
|
||||
if err != nil {
|
||||
return nil, contextx.ERRILLEGALUSER
|
||||
return nil, contextj.ERRILLEGALUSER
|
||||
}
|
||||
|
||||
rpcResp, err := l.svcCtx.FileRpc.Upload(l.ctx, &fileservice.UploadFileMetadataReq{
|
||||
|
||||
Reference in New Issue
Block a user