Skip to content

Commit

Permalink
Add swagger and logging
Browse files Browse the repository at this point in the history
  • Loading branch information
blaz-cerpnjak committed Mar 19, 2024
1 parent cb84d5f commit 263ccd6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions RestaurantManagementAPI/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
implementation 'io.quarkus:quarkus-arc'
testImplementation 'io.quarkus:quarkus-junit5'
implementation 'io.quarkus:quarkus-smallrye-openapi'
implementation 'org.jboss.logging:jboss-logging'
}

group 'com.blazc'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@ import jakarta.inject.Inject
import jakarta.ws.rs.*
import jakarta.ws.rs.core.MediaType
import org.bson.types.ObjectId
import org.jboss.logging.Logger

@Path("/product")
class ProductController {

companion object {
val LOG: Logger = Logger.getLogger(ProductController::class.java)
}

@Inject
lateinit var productRepository: ProductRepository

Expand All @@ -25,11 +30,12 @@ class ProductController {
@Path("/{id}")
@Produces(MediaType.APPLICATION_JSON)
fun getProductById(@PathParam("id") id: String): Uni<Product> {
lateinit var objectId: ObjectId
val objectId: ObjectId

try {
objectId = ObjectId(id)
} catch (e: Exception) {
LOG.error("Error parsing id", e)
return Uni.createFrom().failure(e)
}

Expand Down Expand Up @@ -61,11 +67,12 @@ class ProductController {
@Path("/{id}")
@Produces(MediaType.APPLICATION_JSON)
fun deleteProduct(@PathParam("id") id: String): Uni<Boolean> {
lateinit var objectId: ObjectId
val objectId: ObjectId

try {
objectId = ObjectId(id)
} catch (e: Exception) {
LOG.error("Error parsing id", e)
return Uni.createFrom().failure(e)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@ import jakarta.inject.Inject
import jakarta.ws.rs.*
import jakarta.ws.rs.core.MediaType
import org.bson.types.ObjectId
import org.jboss.logging.Logger

@Path("/restaurant")
class RestaurantController {

companion object {
val LOG: Logger = Logger.getLogger(RestaurantController::class.java)
}

@Inject
lateinit var restaurantRepository: RestaurantRepository

Expand All @@ -30,6 +35,7 @@ class RestaurantController {
try {
objectId = ObjectId(id)
} catch (e: Exception) {
LOG.error("Error parsing id", e)
return Uni.createFrom().failure(e)
}

Expand Down Expand Up @@ -57,6 +63,7 @@ class RestaurantController {
try {
objectId = ObjectId(id)
} catch (e: Exception) {
LOG.error("Error parsing id", e)
return Uni.createFrom().failure(e)
}

Expand Down

0 comments on commit 263ccd6

Please sign in to comment.