Skip to content
This repository has been archived by the owner on May 25, 2022. It is now read-only.

Commit

Permalink
feat: fix source method & package issue
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Mar 22, 2022
1 parent bbfe6f3 commit 8914b76
Showing 1 changed file with 13 additions and 5 deletions.
Expand Up @@ -19,9 +19,9 @@ class ContainerRepository(systemId: String, language: String, workspace: String)
}

fun saveContainerServices(services: Array<ContainerService>) {
val serviceId = saveMainServices()
services.forEach { service ->
service.demands.map { saveDemand(it, serviceId) }.toTypedArray()
services.forEach { caller ->
val serviceId = saveMainServices()
caller.demands.map { saveDemand(it, serviceId, caller.name) }.toTypedArray()
}
}

Expand All @@ -40,7 +40,7 @@ class ContainerRepository(systemId: String, language: String, workspace: String)
return serviceId
}

private fun saveDemand(demand: ContainerDemand, serviceId: String): String {
private fun saveDemand(demand: ContainerDemand, serviceId: String, name: String): String {
val time: String = ClassRepository.currentTime
val demandId = ClassRepository.generateId()
val values: MutableMap<String, String> = HashMap()
Expand All @@ -49,7 +49,15 @@ class ContainerRepository(systemId: String, language: String, workspace: String)

values["target_http_method"] = demand.target_http_method
values["target_url"] = demand.target_url
values["source_method"] = demand.source_caller
val split = name.split("::")

if (split.size == 2) {
values["source_package"] = split[0]
values["source_method"] = split[1]
} else {
values["source_method"] = name
}

values["service_id"] = serviceId
values["system_id"] = systemId
values["updated_at"] = time
Expand Down

0 comments on commit 8914b76

Please sign in to comment.