Slide 14
Slide 14 text
Data Change
// データ更新情報を乗せるレスポンスかチェック
dcRes, ok := res.(dataChangeResponse)
if !ok {
return res, nil
}
// 更新,削除データを入れる変数を用意する
updated := &pb.UpdatedData{}
deleted := &pb.DeletedData{}
dataChange := datachange.Extract(ctx)
if dataChange == nil {
return res, nil
}
updatedData := dataChange.GetUpdated()
deletedData := dataChange.GetDeleted()
for _, item := range updatedData.UserItems {
pbitem := converter.ToProtoUserItem(item)
updated.Items = append(updated.Items, pbitem)
}
for _, deck := range updatedData.UserDecks {
pbdeck := converter.ToProtoUserDeck(deck)
updated.Decks = append(updated.Decks, pbdeck)
}
for _, point := range updatedData.UserPoints {
pbpoint := converter.ToProtoUserPoint(point)
updated.Points = append(updated.Points, pbpoint)
}
dcRes.SetCommonResponse(&pb.CommonResponse{
UpdatedData: updated,
DeletedData: deleted,
})
> middleware.go > middleware.go
14