Repositories - THM-ATLAS/spring-backend GitHub Wiki
Overview
The repositories allow communication with the database.
The repository must be marked with the annotation '@Repository'.
Path
src/main/kotlin/com/example/atlasbackend/repository
Our repositories
Our repositories inherit from CrudRepository, which means they already provide some basic functionality.
To enable more functions, you can specify functions with the annotation @Query("...") a query, which is then executed on the database and returns data. If the query modifies data, such as INSERT, UPDATE, DELETE, the annotation @Modifying must also be specified.
To pass parameters to the query, you must specify the annotation @Param("name") with parameter names in the function arguments and then you can use them in the query with :name
AssetReposititory
Path
src/main/kotlin/com/example/atlasbackend/repository/AssetRepostitory.kt
functions
The AssetReposititory has no functions apart from the inherited crudRepository functions
ExerciseRepository
Path
src/main/kotlin/com/example/atlasbackend/repository/ExerciseRepository.kt
functions
getExercisesByModulereturns all exercises of the module , with input of the id of a module.getExercisesByUserreturns all exercises to which a user has access, with input of the id of a user.getModuleByExercisereturnsthe module to which a exercises belongs, with input of the id of a task.loadPagereturns a page of all exercises, with the input of a page-size and an offset.getExercisesByUserByPagelike getExercisesByUser but only returns a page of all tasks to which a user has access, with the input of a page-size and an offset.getExercisesByModuleByPagelike getExercisesByModule but only returns a page of all exercises of the module, with the input of a page-size and an offset.
ModuleRepository
Path
src/main/kotlin/com/example/atlasbackend/repository/ModuleRepository.kt
functions
addUseradds a user with a role to a module, with the input of the id of the user module and role.getUsersByModulereturns all users of the module, with the input of the id of the module.getModuleRoleByUserreturns the role the user has in the module, with the input of the id of the user and module.updateUserModuleRoleedits the role of a user in a module, with the input of the id of the role user and module.removeUserremoves a user from a module, with the input of the id of the user and module.loadPagereturns a page of all modules, with the input of a page-size and an offset.
ModuleLinkRepository
Path
src/main/kotlin/com/example/atlasbackend/repository/ModuleLinkRepository.kt
functions
getLinksreturns all links of a module with the input of the module_id
ModuleAssetRepository
Path
src/main/kotlin/com/example/atlasbackend/repository/ModuleAssetRepository.kt
functions
getAssetsreturns all Assets of a module with the input of the module_id
RatingRepository
Path
src/main/kotlin/com/example/atlasbackend/repository/RatingRepository.kt
functions
getByExerciseIdreturns all the ratings of the task with the input of the id of the task.getByUserIdreturns all the assessment of the user, with the input of the id of the user.averageExerciseRatingreturns the average rating of the task, with the input of the Id of the task.
RoleRepository
Path
src/main/kotlin/com/example/atlasbackend/repository/RoleRepository.kt
functions
getRolesByUserreturns all the roles the user has, with the input of the id of the user.giveRoleadds a role to the user, with the input of the id of the user and the role.removeRoleremoves the role of a user, with the input of the id of the user and the role.
SettingsRepository
Path
src/main/kotlin/com/example/atlasbackend/repository/SettingsRepository.kt
functions
createSettingscreates the settings of a user, with the input of the id of the user.
SubmissionRepository
Path
src/main/kotlin/com/example/atlasbackend/repository/SubmissionRepository.kt
functions
loadPagereturns a page of all submissionsgetSubmissionsByExercisereturns all submissions of a exercise, with the input the id of the exercise.getSubmissionsByExerciseByPagereturns a page of all submissions of a exercise, with the input the id of the exercise.getSubmissionsByUserreturns all submissions of a user, with the input of the id of a user.getSubmissionsByUserByPagereturns a page of all submissions of a user, with the input of the id of a user.getExerciseSubmissionForUserreturns a Submission of a user to an exercise
SubmissionTypeRepository
src/main/kotlin/com/example/atlasbackend/repository/SubmissionTypeRepository.kt
functions
The SubmissionTypeRepositoryhas no functions apart from the inherited crudRepository functions
CodeSubmissionRepository
Path
src/main/kotlin/com/example/atlasbackend/repository/CodeSubmissionRepository.kt
funtions
insertCodeSubmissionadds a code-Submission with the input of the submission_id, the content and the code-language
LanguageRepository
Path
src/main/kotlin/com/example/atlasbackend/repository/LanguageRepository.kt
functions
The LanguageRepository has no functions apart from the inheritedcrudRepository functions
FileSubmissionRepository
Path
src/main/kotlin/com/example/atlasbackend/repository/FileSubmissionRepository.kt
functions
FileSubmissionRepository has no functions apart from the inherited CrudRepository-functions
FreeSubmissionRepository
Path
src/main/kotlin/com/example/atlasbackend/repository/FreeSubmissionRepository.kt
functions
getExerciseSubmissionForUserreturn the free-text-submission of an user on an exercise with the input of the user_id and exercise_idinsertFreeSubmissionadds a free-text-Submission with the input of the submission_id and the content
McAnswerRepository
Path
src/main/kotlin/com/example/atlasbackend/repository/McAnswerRepository.kt
functions
getAnswersForQuestionreturns all answers to a Questions with the input of the question_iddelAnswersForQuestionremoves all answers to a Questions with the input of the question_idgetAnswersBySubmissionreturns all answers to a Submission with the input of the submission_idaddAnswersBySubmissionadds an answer to a Submission with the input of submission_id, answer_id and boolean markededitAnswersBySubmissionedits an answer of a Submission with the input of submission_id, answer_id and boolean markeddeleteAnswersBySubmissiondeletes all answers to a Submission with the input of the submission_id
McQuestionRepository
Path
src/main/kotlin/com/example/atlasbackend/repository/McQuestionRepository.kt
functions
getMcForExercisereturns all Questions to an exercise with the input of the exercise_iddelQuestionsForExerciseremoves all Questions to an exercise with the input of the exercise_id
TagRepository
path
src/main/kotlin/com/example/atlasbackend/repository/TagRepository.kt
functions
getExerciseTagsreturns all tags of an exercise, with the input of the id of the exercise.addExerciseTagadds a tag to an exercise, with the input of the id of the exercise and the tag.removeExerciseTagremoves a tag from a exercise, with the input of the exercise id and the tag.getModuleTagsreturns all tags of a Module, with the input of the id of the module.addModuleTagadds a tag to a Module, with the input of the id of tag and module.removeModuleTagremove a tog of a Module, with the input the id of tag and module.loadPagereturns a page of all tags
UserRepository
Path
src/main/kotlin/com/example/atlasbackend/repository/UserRepository.kt
functions
testForUserreturns the list of all users with this name, with the input of a username.getPasswordreturns the value of the user's password, with the input of a username.addPasswordprocesses the password of a user, with the input of a username and password.loadPagereturns a page of all users, with the input of a page-size and an offset.
Iconrepository
Path
src/main/kotlin/com/example/atlasbackend/repository/IconRepository.kt
functions
The Iconrepository has no functions apart from the inherited CrudRepository functions
NotificationRepository
Path
src/main/kotlin/com/example/atlasbackend/repository/NotificationRepository.kt
functions
getNotificationsByUserreturns all notifications for a user with the input of the user_idgetUserIdByNotificationreturns the user_id for a notification with the input of the notification_idgetNotificationsByModulereturns all notifications of a module with the input of the module_iddeleteByIdByUserremoves a notification of a user with the input of the notification_id and user_iddeleteByUserremoves all notifications of a user with the input of the user_idaddNotificationByUseradds a notification for a user with the input of the user_id an d notification_idgetReadStatusreturn the status if a notification is read with the input of the user_id and notification_idcountNotificationRelationsreturns the count of notifications of a user with the input of the notification_idupdateReadStatusupdates the status if the notification is read with the input of the notification_id, user_id and a boolean status
NotificationTypeRepository
Path
src/main/kotlin/com/example/atlasbackend/repository/NotificationTypeRepository.kt
functions
The NotificationTypeRepository has no functions apart from the inherited CrudRepository functions