-
Notifications
You must be signed in to change notification settings - Fork 2
/
retrieve_room_initial_data.go
63 lines (50 loc) · 1.22 KB
/
retrieve_room_initial_data.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package room
import (
"github.com/kaikourok/lunchtote-backend/entity/model"
"golang.org/x/sync/errgroup"
)
func (s *RoomUsecase) RetrieveRoomInitialData(characterId, roomId int) (initialData *model.RoomInitialData, err error) {
logger := s.registry.GetLogger()
repository := s.registry.GetRepository()
initialData = &model.RoomInitialData{}
var eg errgroup.Group
eg.Go(func() error {
title, err := repository.RetrieveRoomTitle(roomId)
if err != nil {
logger.Error(err)
return err
}
initialData.Title = title
return nil
})
eg.Go(func() error {
permissions, _, banned, err := repository.RetrieveRoomOwnPermissions(characterId, roomId)
if err != nil {
logger.Error(err)
return err
}
initialData.Permissions = *permissions
initialData.Banned = banned
return nil
})
eg.Go(func() error {
relations, err := repository.RetrieveRoomRelations(roomId)
if err != nil {
logger.Error(err)
return err
}
initialData.Relations = *relations
return nil
})
eg.Go(func() error {
states, err := repository.RetrieveRoomSubscribeStates(characterId, roomId)
if err != nil {
logger.Error(err)
return err
}
initialData.SubscribeStates = *states
return nil
})
err = eg.Wait()
return
}