Add endpoint to retrieve all available languages in VocabController and VocabRouter
- Introduced a new method in VocabService to list all languages from the database. - Updated VocabController to wrap the new method for user access. - Added a new route in VocabRouter to handle requests for all languages. - Modified VocabCourseListView to utilize the new endpoint for loading languages, enhancing the course selection experience.
This commit is contained in:
@@ -147,6 +147,24 @@ export default class VocabService {
|
||||
return { languages: rows };
|
||||
}
|
||||
|
||||
async listAllLanguages() {
|
||||
// Gibt alle verfügbaren Sprachen zurück (für Kursliste)
|
||||
const rows = await sequelize.query(
|
||||
`
|
||||
SELECT
|
||||
id,
|
||||
name
|
||||
FROM community.vocab_language
|
||||
ORDER BY name ASC
|
||||
`,
|
||||
{
|
||||
type: sequelize.QueryTypes.SELECT,
|
||||
}
|
||||
);
|
||||
|
||||
return { languages: rows };
|
||||
}
|
||||
|
||||
async listLanguagesForMenu(userId) {
|
||||
// userId ist die numerische community.user.id
|
||||
const rows = await sequelize.query(
|
||||
|
||||
Reference in New Issue
Block a user