71 lines
1.6 KiB
Go
71 lines
1.6 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: learning_tree.sql
|
|
|
|
package dbgen
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const GetFullLearningTree = `-- name: GetFullLearningTree :many
|
|
SELECT
|
|
c.id AS course_id,
|
|
c.title AS course_title,
|
|
p.id AS program_id,
|
|
p.title AS program_title,
|
|
l.id AS level_id,
|
|
l.title AS level_title,
|
|
m.id AS module_id,
|
|
m.title AS module_title
|
|
FROM courses c
|
|
JOIN programs p ON p.course_id = c.id
|
|
JOIN levels l ON l.program_id = p.id
|
|
LEFT JOIN modules m ON m.level_id = l.id
|
|
WHERE c.is_active = true
|
|
ORDER BY p.display_order, l.level_index, m.display_order
|
|
`
|
|
|
|
type GetFullLearningTreeRow struct {
|
|
CourseID int64 `json:"course_id"`
|
|
CourseTitle string `json:"course_title"`
|
|
ProgramID int64 `json:"program_id"`
|
|
ProgramTitle string `json:"program_title"`
|
|
LevelID int64 `json:"level_id"`
|
|
LevelTitle string `json:"level_title"`
|
|
ModuleID pgtype.Int8 `json:"module_id"`
|
|
ModuleTitle pgtype.Text `json:"module_title"`
|
|
}
|
|
|
|
func (q *Queries) GetFullLearningTree(ctx context.Context) ([]GetFullLearningTreeRow, error) {
|
|
rows, err := q.db.Query(ctx, GetFullLearningTree)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []GetFullLearningTreeRow
|
|
for rows.Next() {
|
|
var i GetFullLearningTreeRow
|
|
if err := rows.Scan(
|
|
&i.CourseID,
|
|
&i.CourseTitle,
|
|
&i.ProgramID,
|
|
&i.ProgramTitle,
|
|
&i.LevelID,
|
|
&i.LevelTitle,
|
|
&i.ModuleID,
|
|
&i.ModuleTitle,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|