Skip to content

Commit

Permalink
Rename BankData to Terminal.
Browse files Browse the repository at this point in the history
  • Loading branch information
AmirRajabii committed Dec 3, 2024
1 parent 90be7d3 commit 97750a7
Show file tree
Hide file tree
Showing 21 changed files with 228 additions and 190 deletions.
4 changes: 2 additions & 2 deletions common/src/main/kotlin/co/nilin/opex/common/OpexError.kt
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ enum class OpexError(val code: Int, val message: String?, val status: HttpStatus
GatewayNotFount(6031, null, HttpStatus.NOT_FOUND),
GatewayIsExist(6032, null, HttpStatus.NOT_FOUND),
InvalidDeposit(6033, "Invalid deposit", HttpStatus.BAD_REQUEST),
BankDataIsExist(6034, "This identifier is exist", HttpStatus.BAD_REQUEST),
BankDataNotFound(6035, "Object not found", HttpStatus.BAD_REQUEST),
TerminalIsExist(6034, "This identifier is exist", HttpStatus.BAD_REQUEST),
TerminalNotFound(6035, "Object not found", HttpStatus.BAD_REQUEST),


// code 7000: api
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import kotlinx.coroutines.runBlocking
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.annotation.Value
import org.springframework.context.annotation.DependsOn
import org.springframework.context.annotation.Profile
import org.springframework.core.env.Environment
import org.springframework.stereotype.Component
import java.math.BigDecimal
Expand All @@ -34,7 +33,7 @@ class InitializeService(
private val currencyRepository: CurrencyRepositoryV2,
private val walletOwnerRepository: WalletOwnerRepository,
private val walletRepository: WalletRepository,
private val walletLimitsRepository: WalletLimitsRepository ,
private val walletLimitsRepository: WalletLimitsRepository,
private val environment: Environment
) {
@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ package co.nilin.opex.wallet.app.controller
import co.nilin.opex.wallet.app.dto.CurrenciesDto
import co.nilin.opex.wallet.app.dto.CurrencyDto
import co.nilin.opex.wallet.app.service.CurrencyServiceV2
import co.nilin.opex.wallet.core.inout.BankDataCommand
import co.nilin.opex.wallet.core.inout.TerminalCommand
import co.nilin.opex.wallet.core.inout.CurrencyGatewayCommand
import co.nilin.opex.wallet.core.inout.GatewayType
import co.nilin.opex.wallet.core.spi.GatewayBankDataManager
import co.nilin.opex.wallet.core.spi.GatewayTerminalManager
import org.springframework.web.bind.annotation.*

@RestController
@RequestMapping("/currency")
class CurrencyController(
private val currencyService: CurrencyServiceV2,
private val gatewayBankDataManager: GatewayBankDataManager
private val gatewayTerminalManager: GatewayTerminalManager
) {

@PostMapping("")
Expand Down Expand Up @@ -116,28 +116,28 @@ class CurrencyController(
}


@PostMapping("/gateway/{gatewayUuid}/bank-data")
suspend fun assignBankDataToGateway(
@PostMapping("/gateway/{gatewayUuid}/terminal")
suspend fun assignTerminalToGateway(
@PathVariable("gatewayUuid") gatewayUuid: String,
@RequestBody bankData: List<String>
@RequestBody terminal: List<String>
) {
return gatewayBankDataManager.assignBankDataToGateway(gatewayUuid, bankData)
return gatewayTerminalManager.assignTerminalToGateway(gatewayUuid, terminal)
}


@GetMapping("/gateway/{gatewayUuid}/bank-data")
suspend fun getGatewayBankData(
@GetMapping("/gateway/{gatewayUuid}/terminal")
suspend fun getGatewayTerminal(
@PathVariable("gatewayUuid") gatewayUuid: String
): List<BankDataCommand>? {
return gatewayBankDataManager.getAssignedBankDataToGateway(gatewayUuid)
): List<TerminalCommand>? {
return gatewayTerminalManager.getAssignedTerminalToGateway(gatewayUuid)
}

@DeleteMapping("/gateway/{gatewayUuid}/bank-data")
suspend fun revokeBankDataFromGateway(
@DeleteMapping("/gateway/{gatewayUuid}/terminal")
suspend fun revokeTerminalFromGateway(
@PathVariable("gatewayUuid") gatewayUuid: String,
@RequestBody bankData: List<String>
@RequestBody terminal: List<String>
) {
return gatewayBankDataManager.revokeBankDataToGateway(gatewayUuid, bankData)
return gatewayTerminalManager.revokeTerminalToGateway(gatewayUuid, terminal)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import co.nilin.opex.wallet.app.dto.AdminSearchDepositRequest
import co.nilin.opex.wallet.app.dto.ManualTransferRequest
import co.nilin.opex.wallet.app.service.DepositService
import co.nilin.opex.wallet.core.inout.*
import co.nilin.opex.wallet.core.spi.BankDataManager
import co.nilin.opex.wallet.core.spi.TerminalManager
import io.swagger.annotations.ApiResponse
import io.swagger.annotations.Example
import io.swagger.annotations.ExampleProperty
Expand All @@ -22,7 +22,7 @@ import java.util.*

class DepositAdminController(
private val depositService: DepositService,
private val bankDataManager: BankDataManager
private val terminalManager: TerminalManager
) {


Expand Down Expand Up @@ -75,41 +75,41 @@ class DepositAdminController(
}


@PostMapping("/bank-data")
suspend fun registerAdminBankData(
@RequestBody body: BankDataCommand
): BankDataCommand? {
return bankDataManager.save(body.apply { uuid = UUID.randomUUID().toString() })
@PostMapping("/terminal")
suspend fun registerAdminTerminal(
@RequestBody body: TerminalCommand
): TerminalCommand? {
return terminalManager.save(body.apply { uuid = UUID.randomUUID().toString() })
}


@PutMapping("/bank-data/{uuid}")
suspend fun updateBankData(
@PathVariable("uuid") bankDataUuid: String,
@RequestBody body: BankDataCommand
): BankDataCommand? {
return bankDataManager.update(body.apply { uuid = bankDataUuid })
@PutMapping("/terminal/{uuid}")
suspend fun updateTerminal(
@PathVariable("uuid") terminalUuid: String,
@RequestBody body: TerminalCommand
): TerminalCommand? {
return terminalManager.update(body.apply { uuid = terminalUuid })
}


@DeleteMapping("/bank-data/{uuid}")
suspend fun deleteBankData(
@PathVariable("uuid") bankDataUuid: String,
@DeleteMapping("/terminal/{uuid}")
suspend fun deleteTerminal(
@PathVariable("uuid") terminalUuid: String,
) {
bankDataManager.delete(bankDataUuid)
terminalManager.delete(terminalUuid)
}

@GetMapping("/bank-data")
suspend fun getBankData(
): List<BankDataCommand>? {
return bankDataManager.fetchBankData()
@GetMapping("/terminal")
suspend fun getTerminal(
): List<TerminalCommand>? {
return terminalManager.fetchTerminal()
}

@GetMapping("/bank-data/{uuid}")
suspend fun getBankData(
@PathVariable("uuid") bankDataUuid: String,
@GetMapping("/terminal/{uuid}")
suspend fun getTerminal(
@PathVariable("uuid") terminalUuid: String,
) {
bankDataManager.fetchBankData(bankDataUuid)
terminalManager.fetchTerminal(terminalUuid)
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package co.nilin.opex.wallet.core.inout

data class BankDataCommand(
data class TerminalCommand(
var uuid: String?,
var owner: String,
var identifier: String,
var active: Boolean? = true,
var type: TransferMethod,
var bankSwiftCode: String
var metaData: String,
var description : String?
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package co.nilin.opex.wallet.core.inout

enum class TransferMethod {
CARD, SHEBA, IPG, OPEX
CARD, SHEBA, IPG, EXCHANGE
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package co.nilin.opex.wallet.core.spi

import co.nilin.opex.wallet.core.inout.TerminalCommand

interface GatewayTerminalManager {
suspend fun assignTerminalToGateway(gatewayUuid: String, terminal: List<String>)

suspend fun getAssignedTerminalToGateway(gatewayUuid: String): List<TerminalCommand>?

suspend fun revokeTerminalToGateway(gatewayUuid: String, terminal: List<String>)

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package co.nilin.opex.wallet.core.spi

import co.nilin.opex.wallet.core.inout.TerminalCommand

interface TerminalManager {

suspend fun save(terminalCommand: TerminalCommand): TerminalCommand?
suspend fun update(terminalCommand: TerminalCommand): TerminalCommand?
suspend fun delete(uuid: String)
suspend fun fetchTerminal(): List<TerminalCommand>?
suspend fun fetchTerminal(uuid: String): TerminalCommand?
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package co.nilin.opex.wallet.ports.postgres.dao

import co.nilin.opex.wallet.ports.postgres.model.TerminalModel
import co.nilin.opex.wallet.ports.postgres.model.GatewayTerminalModel
import org.springframework.data.r2dbc.repository.Query
import org.springframework.data.repository.reactive.ReactiveCrudRepository
import org.springframework.stereotype.Repository
import reactor.core.publisher.Flux
import reactor.core.publisher.Mono

@Repository
interface GatewayTerminalRepository : ReactiveCrudRepository<GatewayTerminalModel, Long> {

fun deleteByTerminalIdAndGatewayId(terminalId: Long, gatewayId: Long): Mono<Void>

@Query("select b.* from gateway_terminal gt join terminal t on gt.terminal_id=t.id where gt.gateway_id=:gatewayId ")
fun findByGatewayId(gatewayId: Long): Flux<TerminalModel>?
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package co.nilin.opex.wallet.ports.postgres.dao

import co.nilin.opex.wallet.ports.postgres.model.TerminalModel
import org.springframework.data.repository.reactive.ReactiveCrudRepository
import org.springframework.stereotype.Repository
import reactor.core.publisher.Mono

@Repository
interface TerminalRepository : ReactiveCrudRepository<TerminalModel, Long> {
fun findByIdentifier(identifier: String): Mono<TerminalModel>?
fun findByUuid(uuid: String): Mono<TerminalModel>?


}

This file was deleted.

Loading

0 comments on commit 97750a7

Please sign in to comment.