Compare commits

...

4 Commits

Author SHA1 Message Date
dmitriy.churmeev
b715214b2f change crud service
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-04-08 22:27:21 +03:00
dmitriy.churmeev
138ad908f0 change rest controller
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-04-08 22:13:03 +03:00
dmitriy.churmeev
e9cf6a1d33 test value
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-04-07 20:09:28 +03:00
dmitriy.churmeev
cac169c09b test value 2026-04-06 23:01:58 +03:00
4 changed files with 14 additions and 19 deletions

View File

@@ -3,7 +3,7 @@ plugins {
id 'org.jetbrains.kotlin.plugin.spring' version '1.9.25'
id 'org.springframework.boot' version '3.5.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'
@@ -37,7 +37,7 @@ dependencies {
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")
@@ -55,9 +55,3 @@ kotlin {
tasks.named('test') {
useJUnitPlatform()
}
//flyway {
// url = 'jdbc:postgresql://localhost:5432/app_db'
// user = 'root'
// password = 'root'
//}

View File

@@ -3,6 +3,7 @@ package com.test.rest
import com.test.model.TestModel
import com.test.service.TestService
import org.slf4j.LoggerFactory
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.DeleteMapping
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
@@ -22,19 +23,19 @@ open class TestController(private val testService: TestService) {
//@PreAuthorize("hasRole('USER')")
@PostMapping("/add")
fun add(@RequestBody testModel: TestModel): TestModel {
return testService.add(testModel)
fun add(@RequestBody testModel: TestModel): ResponseEntity<TestModel> {
return ResponseEntity.ok(testService.add(testModel))
}
@PutMapping("/update")
fun users(@RequestBody testModel: TestModel): TestModel {
return testService.update(testModel)
fun users(@RequestBody testModel: TestModel): ResponseEntity<TestModel> {
return ResponseEntity.ok(testService.update(testModel))
}
@GetMapping("/{id}")
fun get(@PathVariable(value = "id") id: Long): TestModel {
return testService.get(id)!!
fun get(@PathVariable(value = "id") id: Long): ResponseEntity<TestModel> {
return testService.get(id)?.let { ResponseEntity.ok(it) } ?: ResponseEntity.notFound().build()
}
@DeleteMapping("/{id}")

View File

@@ -20,7 +20,7 @@ class TestService(private val testEntityRepository: TestEntityRepository) {
fun update(model: TestModel): TestModel {
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? {

View File

@@ -53,8 +53,8 @@ logging:
org.springframework.security: DEBUG
# # Flyway
# Flyway
flyway:
enabled: false
# locations: classpath:db/migration
# baseline-on-migrate: true
enabled: enable
locations: classpath:db/migration
baseline-on-migrate: true