-
Notifications
You must be signed in to change notification settings - Fork 4
/
faq.go
34 lines (29 loc) · 893 Bytes
/
faq.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
package model
import (
"context"
"github.com/bcc-code/bcc-media-platform/backend/common"
"github.com/bcc-code/bcc-media-platform/backend/user"
"github.com/bcc-code/bcc-media-platform/backend/utils"
)
// FAQCategoryFrom returns a gql category from category
func FAQCategoryFrom(ctx context.Context, i *common.FAQCategory) *FAQCategory {
ginCtx, _ := utils.GinCtx(ctx)
languages := user.GetLanguagesFromCtx(ginCtx)
return &FAQCategory{
ID: i.ID.String(),
Title: i.Title.Get(languages),
}
}
// QuestionFrom returns a gql question from question
func QuestionFrom(ctx context.Context, i *common.Question) *Question {
ginCtx, _ := utils.GinCtx(ctx)
languages := user.GetLanguagesFromCtx(ginCtx)
return &Question{
ID: i.ID.String(),
Category: &FAQCategory{
ID: i.CategoryID.String(),
},
Question: i.Question.Get(languages),
Answer: i.Answer.Get(languages),
}
}