Compare commits

...

9 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
dmitriy.churmeev
0f4d210960 test value
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-04-05 01:31:38 +03:00
dmitriy.churmeev
d7c7de4764 test value 2026-04-04 18:22:51 +03:00
6 changed files with 93 additions and 89 deletions

View File

@@ -36,8 +36,8 @@ dependencies {
implementation("org.springframework.boot:spring-boot-starter-actuator:3.5.7")
//implementation("org.springframework.boot:spring-boot-starter-data-jpa")
//implementation("org.flywaydb:flyway-database-postgresql:10.10.0")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
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

@@ -1,23 +1,23 @@
package com.test.entities
//
//import jakarta.persistence.Column
//import jakarta.persistence.Entity
//import jakarta.persistence.GeneratedValue
//import jakarta.persistence.GenerationType
//import jakarta.persistence.Id
//import jakarta.persistence.Table
//@Entity
//@Table(name = "test_table")
import jakarta.persistence.Column
import jakarta.persistence.Entity
import jakarta.persistence.GeneratedValue
import jakarta.persistence.GenerationType
import jakarta.persistence.Id
import jakarta.persistence.Table
@Entity
@Table(name = "test_table")
data class TestEntity (
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
val id: Long? = null,
//@Column(name = "key")
@Column(name = "key")
var key: String? = null,
//@Column(name = "value")
@Column(name = "value")
var value: String? = null
)

View File

@@ -1,10 +1,9 @@
package com.test.repository
import com.test.entities.TestEntity
//import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.stereotype.Repository
@Repository
interface TestEntityRepository //: JpaRepository<TestEntity, Long>
{
interface TestEntityRepository : JpaRepository<TestEntity, Long> {
}

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
@@ -21,29 +22,30 @@ open class TestController(private val testService: TestService) {
//@PreAuthorize("hasRole('ADMIN')")
//@PreAuthorize("hasRole('USER')")
// @PostMapping("/add")
// fun add(@RequestBody testModel: TestModel): TestModel {
// return testService.add(testModel)
// }
//
// @PutMapping("/update")
// fun users(@RequestBody testModel: TestModel): TestModel {
// return testService.update(testModel)
// }
//
// @GetMapping("/{id}")
// fun get(@PathVariable(value = "id") id: Long): TestModel {
// return testService.get(id)!!
// }
//
// @DeleteMapping("/{id}")
// fun delete(@RequestBody id: Long) {
// testService.remove(id)
// }
//
// @GetMapping("/")
// fun getAll(): List<TestModel> {
// return testService.getAll()
// }
@PostMapping("/add")
fun add(@RequestBody testModel: TestModel): ResponseEntity<TestModel> {
return ResponseEntity.ok(testService.add(testModel))
}
@PutMapping("/update")
fun users(@RequestBody testModel: TestModel): ResponseEntity<TestModel> {
return ResponseEntity.ok(testService.update(testModel))
}
@GetMapping("/{id}")
fun get(@PathVariable(value = "id") id: Long): ResponseEntity<TestModel> {
return testService.get(id)?.let { ResponseEntity.ok(it) } ?: ResponseEntity.notFound().build()
}
@DeleteMapping("/{id}")
fun delete(@RequestBody id: Long) {
testService.remove(id)
}
@GetMapping("/")
fun getAll(): List<TestModel> {
return testService.getAll()
}
}

View File

@@ -3,34 +3,34 @@ package com.test.service
import com.test.entities.TestEntity
import com.test.model.TestModel
import com.test.repository.TestEntityRepository
//import org.springframework.data.repository.findByIdOrNull
import org.springframework.data.repository.findByIdOrNull
import org.springframework.stereotype.Service
@Service
class TestService() {
class TestService(private val testEntityRepository: TestEntityRepository) {
// fun add(model: TestModel): TestModel {
// var entity = testEntityRepository.save(TestEntity(null, model.key, model.value))
// return TestModel(entity.id, entity.key, entity.value)
// }
//
// fun remove(id: Long) {
// testEntityRepository.deleteById(id)
// }
//
// fun update(model: TestModel): TestModel {
// var entity = testEntityRepository.save(TestEntity(model.id, model.key, model.value))
// return TestModel(null, entity.key, entity.value)
// }
//
// fun get(id: Long): TestModel? {
// return testEntityRepository.findByIdOrNull(id)?.let {
// TestModel(it.id, it.key, it.value)
// }
// }
//
// fun getAll(): List<TestModel> {
// return testEntityRepository.findAll()
// .map { entity -> TestModel(entity.id, entity.key, entity.value)}
// }
fun add(model: TestModel): TestModel {
var entity = testEntityRepository.save(TestEntity(null, model.key, model.value))
return TestModel(entity.id, entity.key, entity.value)
}
fun remove(id: Long) {
testEntityRepository.deleteById(id)
}
fun update(model: TestModel): TestModel {
var entity = testEntityRepository.save(TestEntity(model.id, model.key, model.value))
return TestModel(model.id, entity.key, entity.value)
}
fun get(id: Long): TestModel? {
return testEntityRepository.findByIdOrNull(id)?.let {
TestModel(it.id, it.key, it.value)
}
}
fun getAll(): List<TestModel> {
return testEntityRepository.findAll()
.map { entity -> TestModel(entity.id, entity.key, entity.value)}
}
}

View File

@@ -11,21 +11,30 @@ spring:
# Datasource
datasource:
url: jdbc:postgresql://192.168.2.101:5432/test_db
# hikari:
# connection-timeout: 30000
# minimum-idle: 5
# maximum-pool-size: 20
# connection-init-sql: SELECT 1
# validation-timeout: 5000
# max-lifetime: 1800000
# idle-timeout: 600000
# initialization-fail-timeout: 0
url: jdbc:postgresql://192.168.2.110:5432/test_db
username: postgres
password: ${SPRING_DATASOURCE_PASSWORD}
driver-class-name: org.postgresql.Driver
# JPA
# jpa:
# hibernate:
# # ddl-auto: validate
# show-sql: true
# properties:
# hibernate:
# format_sql: true
# database: postgresql
# database-platform: org.hibernate.dialect.PostgreSQLDialect
jpa:
hibernate:
# ddl-auto: validate
show-sql: true
properties:
hibernate:
format_sql: true
# database: postgres
database-platform: org.hibernate.dialect.PostgreSQLDialect
# Keycloak Security
security:
@@ -44,8 +53,8 @@ logging:
org.springframework.security: DEBUG
# # Flyway
# flyway:
# enabled: true
# locations: classpath:db/migration
# baseline-on-migrate: true
# Flyway
flyway:
enabled: enable
locations: classpath:db/migration
baseline-on-migrate: true