-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
114 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
core/core-api/src/main/kotlin/org/mediscan/core/api/domain/PillReader.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
storage/db-core/src/main/kotlin/org/mediscan/storage/db/core/PillQuerydslRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.mediscan.storage.db.core | ||
|
||
interface PillQuerydslRepository { | ||
fun findPillEntities( | ||
shape: String, | ||
frontMarking: String?, | ||
backMarking: String?, | ||
color: String, | ||
): List<PillEntity> | ||
} |
39 changes: 39 additions & 0 deletions
39
storage/db-core/src/main/kotlin/org/mediscan/storage/db/core/PillQuerydslRepositoryImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.mediscan.storage.db.core | ||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory | ||
import org.mediscan.storage.db.core.QPillEntity.pillEntity | ||
|
||
class PillQuerydslRepositoryImpl( | ||
private val queryFactory: JPAQueryFactory, | ||
) : PillQuerydslRepository { | ||
override fun findPillEntities( | ||
shape: String, | ||
frontMarking: String?, | ||
backMarking: String?, | ||
color: String, | ||
): List<PillEntity> { | ||
val pillEntities: List<PillEntity> | ||
|
||
val result1 = queryFactory.selectFrom(pillEntity) | ||
.where( | ||
pillEntity.drugShape.eq(shape) | ||
.and(frontMarking?.let { pillEntity.printFront.eq(it) } ?: pillEntity.printFront.isNull) | ||
.and(backMarking?.let { pillEntity.printBack.eq(it) } ?: pillEntity.printBack.isNull) | ||
.and(pillEntity.colorClass1.eq(color)), | ||
) | ||
.fetch() | ||
|
||
val result2 = queryFactory.selectFrom(pillEntity) | ||
.where( | ||
pillEntity.drugShape.eq(shape) | ||
.and(backMarking?.let { pillEntity.printFront.eq(it) } ?: pillEntity.printFront.isNull) | ||
.and(frontMarking?.let { pillEntity.printBack.eq(it) } ?: pillEntity.printBack.isNull) | ||
.and(pillEntity.colorClass1.eq(color)), | ||
) | ||
.fetch() | ||
|
||
pillEntities = result1 + result2 | ||
pillEntities.distinct() | ||
return pillEntities | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
storage/db-core/src/main/kotlin/org/mediscan/storage/db/core/config/CoreQuerydslConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.mediscan.storage.db.core.config | ||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory | ||
import jakarta.persistence.EntityManager | ||
import org.springframework.context.annotation.Bean | ||
import org.springframework.context.annotation.Configuration | ||
|
||
@Configuration | ||
class CoreQuerydslConfig( | ||
val em: EntityManager, | ||
) { | ||
@Bean | ||
fun queryFactory(): JPAQueryFactory { | ||
return JPAQueryFactory(em) | ||
} | ||
} |