Commit d4b46a55 authored by Ghitha Dinan's avatar Ghitha Dinan

province add get by name

parent 6de26e01
......@@ -32,6 +32,11 @@ class ProvinceController {
return service.getDetail(id)
}
@GetMapping(value = ["get-by-name"], produces = ["application/json"])
fun getByName(@RequestParam("name") name: String): ResponseEntity<*>? {
return service.getByName(name)
}
@PostMapping(value = [""], produces = ["application/json"])
fun saveData(@Valid @RequestBody request: Province): ResponseEntity<*>? {
return service.saveData(request)
......
......@@ -19,4 +19,6 @@ interface ProvinceService {
fun deleteData(request: DeleteDataRequest): ResponseEntity<*>?
fun datatable(req: Pagination2Request): ResponseEntity<*>?
fun getByName(name: String): ResponseEntity<*>?
}
......@@ -62,6 +62,18 @@ class ProvinceServiceImpl : ProvinceService {
}
}
override fun getByName(name: String): ResponseEntity<*>? {
try {
val data = repo.findByName(name.trim())
if (data.isPresent) {
return responseSuccess(data = data)
}
return responseNotFound()
} catch (e: Exception) {
throw e
}
}
override fun getDetail(id: String): ResponseEntity<*>? {
try {
val data = repo.findByIdAndActive(id)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment