first commit
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
package com.frankenergie.smartasset
|
||||
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication
|
||||
import org.springframework.boot.runApplication
|
||||
|
||||
@SpringBootApplication
|
||||
class SmartAssetTestApplication
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
runApplication<SmartAssetTestApplication>(*args)
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.frankenergie.smartasset.controller
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
|
||||
@RestController
|
||||
class HealthController {
|
||||
@GetMapping("/")
|
||||
fun hello() = mapOf("message" to "smart-asset-test-Frank is running")
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.frankenergie.smartasset.controller
|
||||
|
||||
import com.frankenergie.smartasset.model.OrderUpdateRequest
|
||||
import com.frankenergie.smartasset.model.OrderUpdateResponse
|
||||
import com.frankenergie.smartasset.service.OrderBookService
|
||||
import org.springframework.http.ResponseEntity
|
||||
import org.springframework.web.bind.annotation.PostMapping
|
||||
import org.springframework.web.bind.annotation.RequestBody
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
class OrderUpdateController(private val orderBookService: OrderBookService) {
|
||||
|
||||
@PostMapping("/orderupdate")
|
||||
fun orderUpdate(@RequestBody request: OrderUpdateRequest): ResponseEntity<OrderUpdateResponse> {
|
||||
val response = orderBookService.processOrder(request)
|
||||
return ResponseEntity.ok(response)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.frankenergie.smartasset.model
|
||||
|
||||
enum class OrderSide {
|
||||
BUY, SELL
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.frankenergie.smartasset.model
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
import java.math.BigDecimal
|
||||
import java.time.LocalDateTime
|
||||
|
||||
data class OrderUpdateRequest(
|
||||
@JsonProperty("delivery_start_time") val deliveryStartTime: LocalDateTime,
|
||||
@JsonProperty("delivery_end_time") val deliveryEndTime: LocalDateTime,
|
||||
@JsonProperty("order_side") val orderSide: OrderSide,
|
||||
@JsonProperty("quantity") val quantity: BigDecimal,
|
||||
@JsonProperty("price") val price: BigDecimal
|
||||
)
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.frankenergie.smartasset.model
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
import java.time.Instant
|
||||
|
||||
data class OrderUpdateResponse(
|
||||
@JsonProperty("order_id") val orderId: String,
|
||||
@JsonProperty("status") val status: String,
|
||||
@JsonProperty("timestamp") val timestamp: Instant
|
||||
)
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.frankenergie.smartasset.service
|
||||
|
||||
import com.frankenergie.smartasset.model.OrderUpdateRequest
|
||||
import com.frankenergie.smartasset.model.OrderUpdateResponse
|
||||
import org.springframework.stereotype.Service
|
||||
import java.time.Instant
|
||||
import java.util.UUID
|
||||
|
||||
@Service
|
||||
class OrderBookService {
|
||||
|
||||
fun processOrder(request: OrderUpdateRequest): OrderUpdateResponse {
|
||||
val orderId = UUID.randomUUID().toString()
|
||||
|
||||
// TODO: implement order book logic
|
||||
|
||||
return OrderUpdateResponse(
|
||||
orderId = orderId,
|
||||
status = "ACCEPTED",
|
||||
timestamp = Instant.now()
|
||||
)
|
||||
}
|
||||
}
|
||||
1
src/main/resources/application.properties
Normal file
1
src/main/resources/application.properties
Normal file
@@ -0,0 +1 @@
|
||||
spring.application.name=smart-asset-test
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.frankenergie.smartasset
|
||||
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.springframework.boot.test.context.SpringBootTest
|
||||
|
||||
@SpringBootTest
|
||||
class SmartAssetTestApplicationTests {
|
||||
|
||||
@Test
|
||||
fun contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user