add update node

This commit is contained in:
2025-12-07 03:41:45 +07:00
parent 2192bf4e77
commit 49c415d4b9
13 changed files with 538 additions and 236 deletions
+28 -5
View File
@@ -187,7 +187,7 @@ func (s *Services) AddTeams(ctx context.Context, req *proto.AddTeamsReq) (*proto
}
func (s *Services) DownloadTeamsQrCodesFile(ctx context.Context, req *proto.DownloadTeamsQrCodesFileReq) (*proto.DownloadTeamsQrCodesFileRsp, error) {
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
ctx, cancel := context.WithTimeout(ctx, 3*time.Second)
defer cancel()
teams, err := s.repository.GetTeams(ctx)
if err != nil {
@@ -200,20 +200,43 @@ func (s *Services) DownloadTeamsQrCodesFile(ctx context.Context, req *proto.Down
return &proto.DownloadTeamsQrCodesFileRsp{Result: b}, nil
}
func (s *Services) UpdateNode(ctx context.Context, req *proto.UpdateNodeReq) (*proto.UpdateNodeRsp, error) {
applications := make([]*story_service.GraphApplication, 0, len(req.Node.Applications))
for _, application := range req.Node.Applications {
applications = append(
applications,
&story_service.GraphApplication{
Name: application.Name,
},
)
}
node := &story_service.GraphNode{
ID: req.Node.Id,
Label: req.Node.Label,
Name: req.Node.Name,
Text: req.Node.Text,
Applications: applications,
}
if err := s.storyService.UpdatePlace(node); err != nil {
return nil, err
}
return &proto.UpdateNodeRsp{}, nil
}
func (s *Services) GetGraph(ctx context.Context, req *proto.GetGraphReq) (*proto.GetGraphRsp, error) {
graph := s.storyService.GetGraph(ctx)
nodes := make([]*proto.GetGraphRsp_Node, 0, len(graph.Nodes))
nodes := make([]*proto.GraphNode, 0, len(graph.Nodes))
for _, node := range graph.Nodes {
applications := make([]*proto.GetGraphRsp_Application, 0, len(node.Applications))
applications := make([]*proto.GraphApplication, 0, len(node.Applications))
for _, application := range node.Applications {
applications = append(
applications,
&proto.GetGraphRsp_Application{
&proto.GraphApplication{
Name: application.Name,
},
)
}
nodes = append(nodes, &proto.GetGraphRsp_Node{
nodes = append(nodes, &proto.GraphNode{
Id: node.ID,
Label: node.Label,
Name: node.Name,