-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
1,531 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
ok-marketplace-be/ok-marketplace-api-log1/build.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import org.openapitools.generator.gradle.plugin.tasks.GenerateTask | ||
|
||
plugins { | ||
id("build-kmp") | ||
alias(libs.plugins.crowdproj.generator) | ||
alias(libs.plugins.kotlinx.serialization) | ||
} | ||
|
||
crowdprojGenerate { | ||
packageName.set("${project.group}.api.log1") | ||
inputSpec.set(rootProject.ext["spec-log1"] as String) | ||
} | ||
|
||
kotlin { | ||
sourceSets { | ||
val commonMain by getting { | ||
kotlin.srcDirs(layout.buildDirectory.dir("generate-resources/src/commonMain/kotlin")) | ||
dependencies { | ||
implementation(kotlin("stdlib-common")) | ||
implementation(libs.coroutines.core) | ||
implementation(libs.kotlinx.serialization.core) | ||
implementation(libs.kotlinx.serialization.json) | ||
|
||
implementation(project(":ok-marketplace-common")) | ||
} | ||
} | ||
val commonTest by getting { | ||
dependencies { | ||
implementation(kotlin("test-common")) | ||
implementation(kotlin("test-annotations-common")) | ||
} | ||
} | ||
val jvmMain by getting { | ||
dependencies { | ||
implementation(kotlin("stdlib-jdk8")) | ||
} | ||
} | ||
val jvmTest by getting { | ||
dependencies { | ||
implementation(kotlin("test-junit")) | ||
} | ||
} | ||
|
||
all { | ||
languageSettings.optIn("kotlin.RequiresOptIn") | ||
} | ||
} | ||
} | ||
|
||
tasks { | ||
val openApiGenerateTask: GenerateTask = getByName("openApiGenerate", GenerateTask::class) { | ||
outputDir.set(layout.buildDirectory.file("generate-resources").get().toString()) | ||
finalizedBy("compileCommonMainKotlinMetadata") | ||
} | ||
filter { it.name.startsWith("compile") }.forEach { | ||
it.dependsOn(openApiGenerateTask) | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
ok-marketplace-be/ok-marketplace-api-log1/src/commonMain/kotlin/MkplContext2Log.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package ru.otus.otuskotlin.marketplace.api.log1.mapper | ||
|
||
import kotlinx.datetime.Clock | ||
import ru.otus.otuskotlin.marketplace.api.log1.models.* | ||
import ru.otus.otuskotlin.marketplace.common.MkplContext | ||
import ru.otus.otuskotlin.marketplace.common.models.* | ||
|
||
fun MkplContext.toLog(logId: String) = CommonLogModel( | ||
messageTime = Clock.System.now().toString(), | ||
logId = logId, | ||
source = "ok-marketplace", | ||
ad = toMkplLog(), | ||
errors = errors.map { it.toLog() }, | ||
) | ||
|
||
private fun MkplContext.toMkplLog(): MkplLogModel? { | ||
val adNone = MkplAd() | ||
return MkplLogModel( | ||
requestId = requestId.takeIf { it != MkplRequestId.NONE }?.asString(), | ||
requestAd = adRequest.takeIf { it != adNone }?.toLog(), | ||
responseAd = adResponse.takeIf { it != adNone }?.toLog(), | ||
responseAds = adsResponse.takeIf { it.isNotEmpty() }?.filter { it != adNone }?.map { it.toLog() }, | ||
requestFilter = adFilterRequest.takeIf { it != MkplAdFilter() }?.toLog(), | ||
).takeIf { it != MkplLogModel() } | ||
} | ||
|
||
private fun MkplAdFilter.toLog() = AdFilterLog( | ||
searchString = searchString.takeIf { it.isNotBlank() }, | ||
ownerId = ownerId.takeIf { it != MkplUserId.NONE }?.asString(), | ||
dealSide = dealSide.takeIf { it != MkplDealSide.NONE }?.name, | ||
) | ||
|
||
private fun MkplError.toLog() = ErrorLogModel( | ||
message = message.takeIf { it.isNotBlank() }, | ||
field = field.takeIf { it.isNotBlank() }, | ||
code = code.takeIf { it.isNotBlank() }, | ||
level = level.name, | ||
) | ||
|
||
private fun MkplAd.toLog() = AdLog( | ||
id = id.takeIf { it != MkplAdId.NONE }?.asString(), | ||
title = title.takeIf { it.isNotBlank() }, | ||
description = description.takeIf { it.isNotBlank() }, | ||
adType = adType.takeIf { it != MkplDealSide.NONE }?.name, | ||
visibility = visibility.takeIf { it != MkplVisibility.NONE }?.name, | ||
ownerId = ownerId.takeIf { it != MkplUserId.NONE }?.asString(), | ||
productId = productId.takeIf { it != MkplProductId.NONE }?.asString(), | ||
permissions = permissionsClient.takeIf { it.isNotEmpty() }?.map { it.name }?.toSet(), | ||
) |
37 changes: 37 additions & 0 deletions
37
ok-marketplace-be/ok-marketplace-app-common/build.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
plugins { | ||
id("build-kmp") | ||
} | ||
|
||
kotlin { | ||
sourceSets { | ||
val coroutinesVersion: String by project | ||
commonMain { | ||
dependencies { | ||
implementation(kotlin("stdlib-jdk8")) | ||
|
||
// transport models | ||
implementation(project(":ok-marketplace-common")) | ||
implementation(project(":ok-marketplace-api-log1")) | ||
} | ||
} | ||
commonTest { | ||
dependencies { | ||
implementation(kotlin("test-common")) | ||
implementation(kotlin("test-annotations-common")) | ||
|
||
implementation(libs.coroutines.core) | ||
} | ||
} | ||
|
||
jvmTest { | ||
dependencies { | ||
implementation(kotlin("test")) | ||
} | ||
} | ||
nativeTest { | ||
dependencies { | ||
implementation(kotlin("test")) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
plugins { | ||
id("build-jvm") | ||
application | ||
} | ||
|
||
application { | ||
mainClass.set("ru.otus.otuskotlin.marketplace.app.tmp.MainKt") | ||
} | ||
|
||
dependencies { | ||
implementation(project(":ok-marketplace-api-log1")) | ||
implementation("ru.otus.otuskotlin.marketplace.libs:ok-marketplace-lib-logging-common") | ||
implementation("ru.otus.otuskotlin.marketplace.libs:ok-marketplace-lib-logging-logback") | ||
|
||
implementation(project(":ok-marketplace-common")) | ||
|
||
implementation(libs.coroutines.core) | ||
} |
Oops, something went wrong.