generated from VLADIMIR/template
add questions
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"evening_detective_server/internal/services/game_service"
|
||||
proto "evening_detective_server/proto"
|
||||
)
|
||||
|
||||
func mapAnswers(o []game_service.Answer) []*proto.Answer {
|
||||
res := make([]*proto.Answer, 0, len(o))
|
||||
for _, item := range o {
|
||||
res = append(res, &proto.Answer{
|
||||
QuestionCode: item.QuestionCode,
|
||||
Answer: item.Text,
|
||||
})
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func convertAnswers(o []*proto.Answer) []game_service.Answer {
|
||||
res := make([]game_service.Answer, 0, len(o))
|
||||
for _, item := range o {
|
||||
res = append(res, game_service.Answer{
|
||||
QuestionCode: item.QuestionCode,
|
||||
Text: item.Answer,
|
||||
})
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func mapAnswerScores(o []game_service.AnswerScore) []*proto.AnswerScore {
|
||||
res := make([]*proto.AnswerScore, 0, len(o))
|
||||
for _, item := range o {
|
||||
score := &proto.AnswerScore{
|
||||
QuestionCode: item.QuestionCode,
|
||||
Answer: item.Text,
|
||||
}
|
||||
if item.Score != nil {
|
||||
v := int32(*item.Score)
|
||||
score.Score = &v
|
||||
}
|
||||
res = append(res, score)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func mapTeamAnswers(o []game_service.TeamAnswers) []*proto.TeamAnswers {
|
||||
res := make([]*proto.TeamAnswers, 0, len(o))
|
||||
for _, item := range o {
|
||||
res = append(res, &proto.TeamAnswers{
|
||||
Team: mapTeam(item.Team),
|
||||
Answers: mapAnswerScores(item.Answers),
|
||||
})
|
||||
}
|
||||
return res
|
||||
}
|
||||
Reference in New Issue
Block a user