Skip to content

Commit e92d40b

Browse files
committed
modify create project
1 parent 1fe0cd4 commit e92d40b

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

server/internal/adapter/gql/resolver_mutation_storytelling.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ package gql
22

33
import (
44
"context"
5+
"encoding/json"
56
"errors"
7+
"fmt"
68

79
"github.com/reearth/reearth/server/internal/adapter/gql/gqlmodel"
810
"github.com/reearth/reearth/server/internal/usecase/interfaces"
@@ -21,7 +23,13 @@ func (r *mutationResolver) CreateStory(ctx context.Context, input gqlmodel.Creat
2123
Title: input.Title,
2224
Index: input.Index,
2325
}
26+
fmt.Println("===================")
27+
b, err := json.MarshalIndent(inp, "", " ")
28+
if err != nil {
29+
fmt.Println("JSON Marshal error:", err)
2430

31+
}
32+
fmt.Println(string(b))
2533
res, err := usecases(ctx).StoryTelling.Create(ctx, inp, getOperator(ctx))
2634
if err != nil {
2735
return nil, err
@@ -150,6 +158,16 @@ func (r *mutationResolver) CreateStoryPage(ctx context.Context, input gqlmodel.C
150158
return nil, err
151159
}
152160

161+
// type CreatePageParam struct {
162+
// SceneID id.SceneID
163+
// StoryID id.StoryID
164+
// Title *string
165+
// Swipeable *bool
166+
// Layers *[]id.NLSLayerID
167+
// SwipeableLayers *[]id.NLSLayerID
168+
// Index *int
169+
// }
170+
153171
inp := interfaces.CreatePageParam{
154172
SceneID: sceneId,
155173
StoryID: storyId,

server/internal/adapter/internalapi/server.go

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ func (s server) CreateProject(ctx context.Context, req *pb.CreateProjectRequest)
7171
op, uc := adapter.Operator(ctx), adapter.Usecases(ctx)
7272

7373
wId, err := accountdomain.WorkspaceIDFrom(req.TeamId)
74-
7574
if err != nil {
7675
return nil, err
7776
}
@@ -84,7 +83,38 @@ func (s server) CreateProject(ctx context.Context, req *pb.CreateProjectRequest)
8483
CoreSupport: req.CoreSupport,
8584
Visibility: req.Visibility,
8685
}, op)
86+
if err != nil {
87+
return nil, err
88+
}
89+
90+
c, err := uc.Scene.Create(ctx, p.ID(), true, op)
91+
if err != nil {
92+
return nil, err
93+
}
8794

95+
index := 0
96+
storyInput := interfaces.CreateStoryInput{
97+
SceneID: c.ID(),
98+
Title: "Default",
99+
Index: &index,
100+
}
101+
st, err := uc.StoryTelling.Create(ctx, storyInput, op)
102+
if err != nil {
103+
return nil, err
104+
}
105+
106+
title := "Page"
107+
swipeable := false
108+
pageParam := interfaces.CreatePageParam{
109+
SceneID: c.ID(),
110+
StoryID: st.Id(),
111+
Title: &title,
112+
Swipeable: &swipeable,
113+
Layers: &[]id.NLSLayerID{},
114+
SwipeableLayers: &[]id.NLSLayerID{},
115+
Index: &index,
116+
}
117+
_, _, err = uc.StoryTelling.CreatePage(ctx, pageParam, op)
88118
if err != nil {
89119
return nil, err
90120
}

0 commit comments

Comments
 (0)