Compare commits

..

7 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
dmitriy.churmeev
c7f86fcf93 test value
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-04-06 22:38:28 +03:00
dmitriy.churmeev
2f5352f0b1 test value
Some checks are pending
ci/woodpecker/push/woodpecker Pipeline is running
2026-04-05 21:07:37 +03:00
dmitriy.churmeev
83bb72ad4c test value
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-04-05 20:37:18 +03:00
4 changed files with 15 additions and 20 deletions

View File

@@ -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'
//}

View File

@@ -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}")

View File

@@ -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? {

View File

@@ -20,7 +20,7 @@ spring:
# max-lifetime: 1800000 # max-lifetime: 1800000
# idle-timeout: 600000 # idle-timeout: 600000
# initialization-fail-timeout: 0 # initialization-fail-timeout: 0
url: jdbc:postgresql://192.168.2.101:5432/test_db url: jdbc:postgresql://192.168.2.110:5432/test_db
username: postgres username: postgres
password: ${SPRING_DATASOURCE_PASSWORD} password: ${SPRING_DATASOURCE_PASSWORD}
driver-class-name: org.postgresql.Driver driver-class-name: org.postgresql.Driver
@@ -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