Compare commits

...

4 Commits

Author SHA1 Message Date
16e954101f Add exec uitils for command line with executable 2020-08-21 21:31:30 +07:00
61369fc2bf Updated swagger ui config 2020-08-21 15:57:51 +07:00
da16ea9afe Updated the revision for back account 2020-08-21 13:43:55 +07:00
fedc1029ce updated the git cached 2020-08-21 13:00:51 +07:00
8 changed files with 96 additions and 7 deletions

1
.gitignore vendored
View File

@@ -4,6 +4,7 @@ build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
application-dev.yml
### STS ###
.apt_generated

View File

@@ -1,7 +1,13 @@
package com.cubetiqs.demo.axon
import com.cubetiqs.demo.axon.util.ExecUtils
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.http.MediaType
import org.springframework.util.FileCopyUtils
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RestController
import javax.servlet.http.HttpServletResponse
@SpringBootApplication
class AxonApplication
@@ -9,3 +15,15 @@ class AxonApplication
fun main(args: Array<String>) {
runApplication<AxonApplication>(*args)
}
@RestController
class MyDumper {
@GetMapping("/dump")
fun dumper(
response: HttpServletResponse
) {
response.contentType = MediaType.APPLICATION_OCTET_STREAM_VALUE
val data = ExecUtils.execMySqlDump()
FileCopyUtils.copy(data ?: ByteArray(0), response.outputStream)
}
}

View File

@@ -11,12 +11,14 @@ import org.axonframework.commandhandling.CommandHandler
import org.axonframework.eventsourcing.EventSourcingHandler
import org.axonframework.modelling.command.AggregateIdentifier
import org.axonframework.modelling.command.AggregateLifecycle
import org.axonframework.serialization.Revision
import org.axonframework.spring.stereotype.Aggregate
import java.math.BigDecimal
import java.util.UUID
@Aggregate
class BankAccountAggregate() {
@Revision("1.0")
final class BankAccountAggregate() {
@AggregateIdentifier
private var id: UUID? = null
private var balance: BigDecimal? = null

View File

@@ -17,7 +17,6 @@ import java.util.concurrent.CompletableFuture
class SwaggerConfiguration {
@Bean
fun apiDocket(): Docket {
val ignoreClasses = arrayListOf(CompletableFuture::class.java).toTypedArray()
return Docket(DocumentationType.SWAGGER_2)
.select()
.apis(
@@ -26,7 +25,6 @@ class SwaggerConfiguration {
)
.paths(PathSelectors.any())
.build()
.ignoredParameterTypes(*ignoreClasses)
.apiInfo(apiInfo)
}

View File

@@ -0,0 +1,17 @@
package com.cubetiqs.demo.axon.config
import org.springframework.context.annotation.Configuration
import org.springframework.web.servlet.config.annotation.EnableWebMvc
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
@Configuration
@EnableWebMvc
class WebConfig : WebMvcConfigurer {
override fun addResourceHandlers(registry: ResourceHandlerRegistry) {
registry.addResourceHandler("swagger-ui.html")
.addResourceLocations("classpath:/META-INF/resources/")
registry.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/")
}
}

View File

@@ -0,0 +1,43 @@
package com.cubetiqs.demo.axon.util
import java.io.BufferedInputStream
import java.io.ByteArrayOutputStream
object ExecUtils {
private const val MYSQLDUMP_FILE = "mysqldump"
fun execMySqlDump(): ByteArray? {
var results: ByteArray?
try {
val command: MutableList<String> = mutableListOf()
command.add(MYSQLDUMP_FILE)
command.add("--databases")
command.add("orderwebapp")
command.add("--host")
command.add("192.168.0.204")
command.add("-usombochea")
command.add("-p@Csb632612")
val builder = ProcessBuilder(*command.toTypedArray())
.redirectErrorStream(false)
val process = builder.start()
BufferedInputStream(process.inputStream).use {
ByteArrayOutputStream().use { stdout ->
while (true) {
val x = it.read()
if (x == -1) {
break
}
stdout.write(x)
}
results = stdout.toByteArray()
process.waitFor()
}
}
} catch (e: Exception) {
println(e.message)
return null
}
return results
}
}

View File

@@ -6,9 +6,9 @@ spring:
name: axon-demo
datasource:
driverClassName: org.postgresql.Driver
url: jdbc:postgresql://${POSTGRES_HOST:192.168.0.202}:${POSTGRES_PORT:5432}/${POSTGRES_DB:axon_demo}
username: ${POSTGRES_USERNAME:cubetiq}
password: ${POSTGRES_PASSWORD:Root$}
url: jdbc:postgresql://${POSTGRES_HOST:localhost}:${POSTGRES_PORT:5432}/${POSTGRES_DB:axon_demo}
username: ${POSTGRES_USERNAME:root}
password: ${POSTGRES_PASSWORD:root}
hikari:
max-lifetime: 1800000
connection-timeout: 30000
@@ -37,7 +37,7 @@ axon:
serializer:
general: jackson
axonserver:
servers: 192.168.0.202
servers: localhost
logging:
level.root: debug

View File

@@ -0,0 +1,10 @@
import com.cubetiqs.demo.axon.util.ExecUtils
import org.junit.jupiter.api.Test
class TestExecUtils {
@Test
fun dump() {
val dump = ExecUtils.execMySqlDump()
println("Dump size: ${dump?.size}")
}
}