Skip to content

Commit

Permalink
fix: fix when controllers empty
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Jul 26, 2023
1 parent 1af9ccb commit 6baa6b8
Showing 1 changed file with 7 additions and 2 deletions.
Expand Up @@ -69,7 +69,10 @@ class JavaSpringCodeCreator(val project: Project) : SpringBaseCrud {
return
}

val targetControllerFile = getAllControllerFiles().first { it.name == "$targetController.java" }
val allControllerFiles = getAllControllerFiles()
if (allControllerFiles.isEmpty()) return

val targetControllerFile = allControllerFiles.first { it.name == "$targetController.java" }

updateCodeMethod(targetControllerFile, targetController, code, project, psiElementFactory)
}
Expand Down Expand Up @@ -103,7 +106,9 @@ class JavaSpringCodeCreator(val project: Project) : SpringBaseCrud {

override fun createEntity(code: String): DtClass? = createClassByCode(code, getAllEntityFiles(), "model")
override fun createDto(code: String): DtClass? = createClassByCode(code, getAllDtoFiles(), "dto")
override fun createRepository(code: String): DtClass? = createClassByCode(code, getAllRepositoryFiles(), "repository")
override fun createRepository(code: String): DtClass? =
createClassByCode(code, getAllRepositoryFiles(), "repository")

override fun createService(code: String): DtClass? = createClassByCode(code, getAllServiceFiles(), "service")

private fun createClassByCode(code: String, psiFiles: List<PsiFile>, layerName: String): DtClass? {
Expand Down

0 comments on commit 6baa6b8

Please sign in to comment.