Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat]: 얄약 검색 API 구현 (#10) #11

Merged
merged 1 commit into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package org.mediscan.core.api.controller.v1
package org.mediscan.core.api.controller

import org.mediscan.core.api.controller.v1.request.PillIdentificationRequestDto
import org.mediscan.core.api.controller.v1.request.PillSearchRequestDto
import org.mediscan.core.api.controller.v1.response.PillIdentificationResponseDto
import org.mediscan.core.api.controller.v1.response.PillSearchResponseDto
import org.mediscan.core.api.domain.PillService
import org.mediscan.core.api.support.response.ApiResponse
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RestController
Expand Down Expand Up @@ -32,23 +35,17 @@ class PillIController(
return ApiResponse.success(responseDtos)
}

// @PostMapping("/pill/search")
// fun searchPill(
// @RequestBody request: PillSearchRequestDto
// ): ApiResponse<List<PillSearchResponseDto>> {
// val results = pillService.searchPill(
// request.pillShape,
// request.frontMarking,
// request.backMarking,
// request.color
// )
//
// val responseDtos = results.map { result ->
// PillSearchResponseDto(
//
// )
// }
//
// return ApiResponse.success(responseDtos)
// }
@GetMapping("/pill/search")
fun searchPill(
@RequestBody request: PillSearchRequestDto,
): ApiResponse<List<PillSearchResponseDto>> {
val results = pillService.searchPill(
request.pillShape,
request.frontMarking,
request.backMarking,
request.color,
)

return ApiResponse.success(results)
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package org.mediscan.core.api.controller.v1.request

import org.mediscan.core.enums.Color

class PillSearchRequestDto(
val pillShape: String,
val frontMarking: String,
val backMarking: String,
val color: String,
val color: Color,
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ package org.mediscan.core.api.controller.v1.response
data class PillDomainIdentificationResponseDto(
val confidence: Long,
val drugCode: String,

)
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
package org.mediscan.core.api.controller.v1.response

import org.mediscan.core.api.domain.Pill

class PillSearchResponseDto(
val pillName: String,
val itemImage: String,
val classNo: String,
)
val pillName: String?,
val itemImage: String?,
val classNo: String?,
) {
companion object {
fun toDto(pillEntities: List<Pill>): List<PillSearchResponseDto> {
return pillEntities.map { pill ->
PillSearchResponseDto(
pill.itemName,
pill.itemImage,
pill.classNo,
)
}
}
}
}

This file was deleted.

This file was deleted.

This file was deleted.

108 changes: 75 additions & 33 deletions core/core-api/src/main/kotlin/org/mediscan/core/api/domain/Pill.kt
Original file line number Diff line number Diff line change
@@ -1,37 +1,79 @@
package org.mediscan.core.api.domain

import org.mediscan.storage.db.core.PillEntity

data class Pill(
val id: Long,
val itemSeq: String,
val itemName: String,
val entpSeq: String,
val entpName: String,
val chart: String,
val itemImage: String,
val printFront: String,
val printBack: String,
val drugShape: String,
val colorClass1: String,
val colorClass2: String,
val lineFront: String,
val lineBack: String,
val lengLong: String,
val lengShort: String,
val thick: String,
val imgRegistTs: String,
val classNo: String,
val className: String,
val etcOtcName: String,
val itemPermitDate: String,
val formCodeName: String,
val markCodeFrontAnal: String,
val markCodeBackAnal: String,
val markCodeFrontImg: String,
val markCodeBackImg: String,
val itemEngName: String,
val changeDate: String,
val markCodeFront: String,
val markCodeBack: String,
val ediCode: String,
val bizrno: String,
)
val itemName: String?,
val entpSeq: String?,
val entpName: String?,
val chart: String?,
val itemImage: String?,
val printFront: String?,
val printBack: String?,
val drugShape: String?,
val colorClass1: String?,
val colorClass2: String?,
val lineFront: String?,
val lineBack: String?,
val lengLong: String?,
val lengShort: String?,
val thick: String?,
val imgRegistTs: String?,
val classNo: String?,
val className: String?,
val etcOtcName: String?,
val itemPermitDate: String?,
val formCodeName: String?,
val markCodeFrontAnal: String?,
val markCodeBackAnal: String?,
val markCodeFrontImg: String?,
val markCodeBackImg: String?,
val itemEngName: String?,
val changeDate: String?,
val markCodeFront: String?,
val markCodeBack: String?,
val ediCode: String?,
val bizrno: String?,
) {
companion object {
fun toDto(pillEntities: List<PillEntity>): List<Pill> {
return pillEntities.map { pillEntity ->
Pill(
pillEntity.itemSeq,
pillEntity.itemName,
pillEntity.entpSeq,
pillEntity.entpName,
pillEntity.chart,
pillEntity.itemImage,
pillEntity.printFront,
pillEntity.printBack,
pillEntity.drugShape,
pillEntity.colorClass1,
pillEntity.colorClass2,
pillEntity.lineFront,
pillEntity.lineBack,
pillEntity.lengLong,
pillEntity.lengShort,
pillEntity.thick,
pillEntity.imgRegistTs,
pillEntity.classNo,
pillEntity.className,
pillEntity.etcOtcName,
pillEntity.itemPermitDate,
pillEntity.formCodeName,
pillEntity.markCodeFrontAnal,
pillEntity.markCodeBackAnal,
pillEntity.markCodeFrontImg,
pillEntity.markCodeBackImg,
pillEntity.itemEngName,
pillEntity.changeDate,
pillEntity.markCodeFront,
pillEntity.markCodeBack,
pillEntity.ediCode,
pillEntity.bizrno,
)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
package org.mediscan.core.api.domain

import org.mediscan.core.enums.Color
import org.mediscan.storage.db.core.PillJpaRepository
import org.springframework.stereotype.Component

@Component
class PillReader {

// fun readPill(pillShape: String, frontMarking: String, backMarking: String, color: String): Pill {
//
// }
class PillReader(
private val pillRepository: PillJpaRepository,
) {
fun readPill(pillShape: String, frontMarking: String, backMarking: String, color: Color): List<Pill> {
val pillEntities =
pillRepository.findPillEntitiesByDrugShapeAndColorClass1OrPrintFrontOrPrintBack(
pillShape,
frontMarking,
backMarking,
color.s,
)
return Pill.toDto(pillEntities)
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package org.mediscan.core.api.domain

interface PillRepository
interface PillRepository {
fun readPill(pillShape: String, frontMarking: String, backMarking: String, color: String): Pill
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package org.mediscan.core.api.domain

import org.mediscan.core.api.controller.v1.request.PillDomainIdentificationRequestDto
import org.mediscan.core.api.controller.v1.response.PillDomainIdentificationResponseDto
import org.mediscan.core.api.controller.v1.response.PillSearchResponseDto
import org.mediscan.core.enums.Color
import org.springframework.stereotype.Service
import org.springframework.web.multipart.MultipartFile

Expand Down Expand Up @@ -31,8 +33,13 @@ class PillService(
return pillDomainResponse
}

// fun searchPill(pillShape: String, frontMarking: String, backMarking: String, color: String): List<PillDomainIdentificationResponseDto> {
// val pillDomainResponse = pillReader.readPill(pillShape, frontMarking, backMarking, color)
// return pillDomainResponse
// }
fun searchPill(
pillShape: String,
frontMarking: String,
backMarking: String,
color: Color,
): List<PillSearchResponseDto> {
val pillDomainResponse = pillReader.readPill(pillShape, frontMarking, backMarking, color)
return PillSearchResponseDto.toDto(pillDomainResponse)
}
}
Loading
Loading