add new que repo method, and add in amodal struct que repo
This commit is contained in:
parent
17d5622ed1
commit
5192490c05
@ -136,6 +136,7 @@ type AmoDal struct {
|
|||||||
conn *sql.DB
|
conn *sql.DB
|
||||||
queries *sqlcgen.Queries
|
queries *sqlcgen.Queries
|
||||||
AmoRepo *amo.AmoRepository
|
AmoRepo *amo.AmoRepository
|
||||||
|
QuestionRepo *question.QuestionRepository
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAmoDal(ctx context.Context, cred string) (*AmoDal, error) {
|
func NewAmoDal(ctx context.Context, cred string) (*AmoDal, error) {
|
||||||
@ -158,10 +159,16 @@ func NewAmoDal(ctx context.Context, cred string) (*AmoDal, error) {
|
|||||||
Pool: pool,
|
Pool: pool,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
questionRepo := question.NewQuestionRepository(question.Deps{
|
||||||
|
Queries: queries,
|
||||||
|
Pool: pool,
|
||||||
|
})
|
||||||
|
|
||||||
return &AmoDal{
|
return &AmoDal{
|
||||||
conn: pool,
|
conn: pool,
|
||||||
queries: queries,
|
queries: queries,
|
||||||
AmoRepo: amoRepo,
|
AmoRepo: amoRepo,
|
||||||
|
QuestionRepo: questionRepo,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -455,3 +455,33 @@ func (r *QuestionRepository) ForSortingResults(ctx context.Context, allAnswers [
|
|||||||
|
|
||||||
return sortedAllAnswers, nil
|
return sortedAllAnswers, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *QuestionRepository) GetQuestionListByIDs(ctx context.Context, ids []int32) ([]model.Question, error) {
|
||||||
|
rows, err := r.queries.GetQuestionListByIDs(ctx, ids)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var questions []model.Question
|
||||||
|
for _, row := range rows {
|
||||||
|
question := model.Question{
|
||||||
|
Id: uint64(row.ID),
|
||||||
|
QuizId: uint64(row.QuizID),
|
||||||
|
Title: row.Title,
|
||||||
|
Description: row.Description.String,
|
||||||
|
Type: string(row.Questiontype.([]byte)),
|
||||||
|
Required: row.Required.Bool,
|
||||||
|
Deleted: row.Deleted.Bool,
|
||||||
|
Page: int(row.Page.Int16),
|
||||||
|
Content: row.Content.String,
|
||||||
|
Version: int(row.Version.Int16),
|
||||||
|
ParentIds: row.ParentIds,
|
||||||
|
CreatedAt: row.CreatedAt.Time,
|
||||||
|
UpdatedAt: row.UpdatedAt.Time,
|
||||||
|
}
|
||||||
|
|
||||||
|
questions = append(questions, question)
|
||||||
|
}
|
||||||
|
|
||||||
|
return questions, nil
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user