Compare commits
4 Commits
c7f86fcf93
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b715214b2f | ||
|
|
138ad908f0 | ||
|
|
e9cf6a1d33 | ||
|
|
cac169c09b |
10
build.gradle
10
build.gradle
@@ -3,7 +3,7 @@ plugins {
|
|||||||
id 'org.jetbrains.kotlin.plugin.spring' version '1.9.25'
|
id 'org.jetbrains.kotlin.plugin.spring' version '1.9.25'
|
||||||
id 'org.springframework.boot' version '3.5.7'
|
id 'org.springframework.boot' version '3.5.7'
|
||||||
id 'io.spring.dependency-management' version '1.1.7'
|
id 'io.spring.dependency-management' version '1.1.7'
|
||||||
//id 'org.flywaydb.flyway' version '10.15.2'
|
id 'org.flywaydb.flyway' version '10.15.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
group = 'com.test'
|
group = 'com.test'
|
||||||
@@ -37,7 +37,7 @@ dependencies {
|
|||||||
|
|
||||||
|
|
||||||
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
|
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
|
||||||
//implementation("org.flywaydb:flyway-database-postgresql:10.10.0")
|
implementation("org.flywaydb:flyway-database-postgresql")
|
||||||
runtimeOnly("org.postgresql:postgresql")
|
runtimeOnly("org.postgresql:postgresql")
|
||||||
|
|
||||||
|
|
||||||
@@ -55,9 +55,3 @@ kotlin {
|
|||||||
tasks.named('test') {
|
tasks.named('test') {
|
||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
}
|
}
|
||||||
|
|
||||||
//flyway {
|
|
||||||
// url = 'jdbc:postgresql://localhost:5432/app_db'
|
|
||||||
// user = 'root'
|
|
||||||
// password = 'root'
|
|
||||||
//}
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.test.rest
|
|||||||
import com.test.model.TestModel
|
import com.test.model.TestModel
|
||||||
import com.test.service.TestService
|
import com.test.service.TestService
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
|
import org.springframework.http.ResponseEntity
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping
|
import org.springframework.web.bind.annotation.DeleteMapping
|
||||||
import org.springframework.web.bind.annotation.GetMapping
|
import org.springframework.web.bind.annotation.GetMapping
|
||||||
import org.springframework.web.bind.annotation.PathVariable
|
import org.springframework.web.bind.annotation.PathVariable
|
||||||
@@ -22,19 +23,19 @@ open class TestController(private val testService: TestService) {
|
|||||||
//@PreAuthorize("hasRole('USER')")
|
//@PreAuthorize("hasRole('USER')")
|
||||||
|
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
fun add(@RequestBody testModel: TestModel): TestModel {
|
fun add(@RequestBody testModel: TestModel): ResponseEntity<TestModel> {
|
||||||
return testService.add(testModel)
|
return ResponseEntity.ok(testService.add(testModel))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@PutMapping("/update")
|
@PutMapping("/update")
|
||||||
fun users(@RequestBody testModel: TestModel): TestModel {
|
fun users(@RequestBody testModel: TestModel): ResponseEntity<TestModel> {
|
||||||
return testService.update(testModel)
|
return ResponseEntity.ok(testService.update(testModel))
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
fun get(@PathVariable(value = "id") id: Long): TestModel {
|
fun get(@PathVariable(value = "id") id: Long): ResponseEntity<TestModel> {
|
||||||
return testService.get(id)!!
|
return testService.get(id)?.let { ResponseEntity.ok(it) } ?: ResponseEntity.notFound().build()
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/{id}")
|
@DeleteMapping("/{id}")
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class TestService(private val testEntityRepository: TestEntityRepository) {
|
|||||||
|
|
||||||
fun update(model: TestModel): TestModel {
|
fun update(model: TestModel): TestModel {
|
||||||
var entity = testEntityRepository.save(TestEntity(model.id, model.key, model.value))
|
var entity = testEntityRepository.save(TestEntity(model.id, model.key, model.value))
|
||||||
return TestModel(null, entity.key, entity.value)
|
return TestModel(model.id, entity.key, entity.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun get(id: Long): TestModel? {
|
fun get(id: Long): TestModel? {
|
||||||
|
|||||||
@@ -53,8 +53,8 @@ logging:
|
|||||||
org.springframework.security: DEBUG
|
org.springframework.security: DEBUG
|
||||||
|
|
||||||
|
|
||||||
# # Flyway
|
# Flyway
|
||||||
flyway:
|
flyway:
|
||||||
enabled: false
|
enabled: enable
|
||||||
# locations: classpath:db/migration
|
locations: classpath:db/migration
|
||||||
# baseline-on-migrate: true
|
baseline-on-migrate: true
|
||||||
Reference in New Issue
Block a user