Refactored code be more readable

This commit is contained in:
2024-09-28 04:33:35 +05:30
parent c62c233778
commit 20d91d5c47
15 changed files with 263 additions and 221 deletions

View File

@@ -1,60 +1,58 @@
package dao
package net.ipksindia.dao
import model.Teller
import net.ipksindia.ItemNotFoundException
class TellerDao {
companion object {
private val tellerMap = mapOf(
"0003" to mapOf(
"00012" to "312",
"00017" to "317",
"00013" to "313",
"00014" to "314",
"00015" to "315",
"00016" to "316",
"00019" to "319",
"00020" to "320",
"00026" to "11126",
"00010" to "310"
),
"0015" to mapOf(
"00006" to "11106",
"00005" to "11105",
"00002" to "11102",
"00004" to "11104",
"00023" to "1234",
"00008" to "11108",
"00017" to "11117",
"00011" to "10111",
"00021" to "1234",
"00001" to "1234",
"00018" to "11118",
"00012" to "11112",
"00019" to "11119",
"00003" to "11103",
"00009" to "11109",
"00015" to "11115",
"00020" to "11120",
"00013" to "11113",
"00014" to "1234",
"00016" to "11116",
"00010" to "11110",
"00007" to "11107",
"00022" to "1234",
"00026" to "11126"
),
private val tellerMap = mapOf(
"0003" to mapOf(
"00012" to "312",
"00017" to "317",
"00013" to "313",
"00014" to "314",
"00015" to "315",
"00016" to "316",
"00019" to "319",
"00020" to "320",
"00026" to "11126",
"00010" to "310"
),
"0015" to mapOf(
"00006" to "11106",
"00005" to "11105",
"00002" to "11102",
"00004" to "11104",
"00023" to "1234",
"00008" to "11108",
"00017" to "11117",
"00011" to "10111",
"00021" to "1234",
"00001" to "1234",
"00018" to "11118",
"00012" to "11112",
"00019" to "11119",
"00003" to "11103",
"00009" to "11109",
"00015" to "11115",
"00020" to "11120",
"00013" to "11113",
"00014" to "1234",
"00016" to "11116",
"00010" to "11110",
"00007" to "11107",
"00022" to "1234",
"00026" to "11126"
),
)
fun getTeller(dccbCode: String, branchCode: String): Teller {
val branchList = tellerMap[dccbCode] ?: throw ItemNotFoundException("Branch Code", branchCode)
val tellerId = branchList[branchCode] ?: throw ItemNotFoundException("DCCB Code", branchCode)
val teller = Teller(
tellerId, dccbCode, branchCode
)
fun getTeller(dccbCode: String, branchCode: String): Teller? {
val branchList = tellerMap[dccbCode] ?: return null
val tellerId = branchList[branchCode] ?: return null
val teller = Teller(
tellerId,
dccbCode,
branchCode
)
return teller
}
return teller
}
}