init
This commit is contained in:
commit
b38bffe86e
15 changed files with 590 additions and 0 deletions
15
src/main/kotlin/com/example/demo/App.kt
Normal file
15
src/main/kotlin/com/example/demo/App.kt
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
package com.example.demo
|
||||
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication
|
||||
import org.springframework.boot.runApplication
|
||||
|
||||
@SpringBootApplication
|
||||
class Application
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
runApplication<Application>(*args)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
16
src/main/kotlin/com/example/demo/Config.kt
Normal file
16
src/main/kotlin/com/example/demo/Config.kt
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
package com.example.demo
|
||||
|
||||
import org.springframework.context.annotation.Bean
|
||||
import org.springframework.context.annotation.Configuration
|
||||
import org.springframework.context.annotation.Profile
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity
|
||||
import org.springframework.security.web.SecurityFilterChain
|
||||
|
||||
|
||||
@Profile("local")
|
||||
@Configuration
|
||||
class SecurityConfig {
|
||||
@Bean
|
||||
fun securityFilterChain(http: HttpSecurity): SecurityFilterChain =
|
||||
http.authorizeHttpRequests { it.anyRequest().permitAll() }.csrf { it.disable() }.build()
|
||||
}
|
||||
19
src/main/kotlin/com/example/demo/api/HelloController.kt
Normal file
19
src/main/kotlin/com/example/demo/api/HelloController.kt
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package com.example.demo.api
|
||||
|
||||
import com.example.demo.service.HelloService
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.PostMapping
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/public")
|
||||
class HelloController(
|
||||
private val helloService: HelloService
|
||||
) {
|
||||
@GetMapping("/test")
|
||||
fun hello() = helloService.findHello()
|
||||
|
||||
@PostMapping("/test")
|
||||
fun createHello() = helloService.addHello()
|
||||
}
|
||||
20
src/main/kotlin/com/example/demo/service/HelloService.kt
Normal file
20
src/main/kotlin/com/example/demo/service/HelloService.kt
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
package com.example.demo.service
|
||||
|
||||
import com.example.jooq.Tables
|
||||
import org.jooq.DSLContext
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
@Service
|
||||
class HelloService(
|
||||
private val dslContext: DSLContext
|
||||
) {
|
||||
fun findHello(): String {
|
||||
val test = dslContext.select().from(Tables.HELLO).fetchOne { it[Tables.HELLO.HELLO_] as String }
|
||||
|
||||
return test ?: "no hello found"
|
||||
}
|
||||
|
||||
fun addHello() {
|
||||
dslContext.insertInto(Tables.HELLO).set(Tables.HELLO.HELLO_, "Hello World!!").execute()
|
||||
}
|
||||
}
|
||||
13
src/main/resources/application.yaml
Normal file
13
src/main/resources/application.yaml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
spring:
|
||||
application:
|
||||
name: demo
|
||||
datasource:
|
||||
url: jdbc:postgresql://localhost:5432/postgres?useSSL=false&serverTimezone=UTC
|
||||
username: postgres
|
||||
password: postgres
|
||||
threads:
|
||||
virtual:
|
||||
enabled: true
|
||||
|
||||
server:
|
||||
port: 8081
|
||||
20
src/main/resources/db/changelog/db.changelog-master.yaml
Normal file
20
src/main/resources/db/changelog/db.changelog-master.yaml
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
databaseChangeLog:
|
||||
- changeSet:
|
||||
id: 1
|
||||
author: whocares
|
||||
changes:
|
||||
- createTable:
|
||||
tableName: hello
|
||||
columns:
|
||||
- column:
|
||||
name: id
|
||||
type: int
|
||||
autoIncrement: true
|
||||
constraints:
|
||||
primaryKey: true
|
||||
nullable: false
|
||||
- column:
|
||||
name: hello
|
||||
type: varchar(50)
|
||||
constraints:
|
||||
nullable: false
|
||||
13
src/test/kotlin/com/example/demo/AppTests.kt
Normal file
13
src/test/kotlin/com/example/demo/AppTests.kt
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
package com.example.demo
|
||||
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.springframework.boot.test.context.SpringBootTest
|
||||
|
||||
@SpringBootTest
|
||||
class AppTests {
|
||||
|
||||
@Test
|
||||
fun contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue