From c175d9895b936c90f03e3ff5d6acbb48b14da3dc Mon Sep 17 00:00:00 2001 From: "dmitriy.churmeev" Date: Sat, 4 Apr 2026 03:01:07 +0300 Subject: [PATCH] test value --- build.gradle | 2 +- .../kotlin/com/test/entities/TestEntity.kt | 26 +++++----- .../test/repository/TestEntityRepository.kt | 5 +- .../kotlin/com/test/rest/TestController.kt | 48 +++++++++--------- .../kotlin/com/test/service/TestService.kt | 50 +++++++++---------- 5 files changed, 67 insertions(+), 64 deletions(-) diff --git a/build.gradle b/build.gradle index afa9ec3..d81bd79 100644 --- a/build.gradle +++ b/build.gradle @@ -36,7 +36,7 @@ dependencies { implementation("org.springframework.boot:spring-boot-starter-actuator:3.5.7") - 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") runtimeOnly("org.postgresql:postgresql") diff --git a/src/main/kotlin/com/test/entities/TestEntity.kt b/src/main/kotlin/com/test/entities/TestEntity.kt index c142514..bc3bdd1 100644 --- a/src/main/kotlin/com/test/entities/TestEntity.kt +++ b/src/main/kotlin/com/test/entities/TestEntity.kt @@ -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 -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") +//@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 ) \ No newline at end of file diff --git a/src/main/kotlin/com/test/repository/TestEntityRepository.kt b/src/main/kotlin/com/test/repository/TestEntityRepository.kt index f991c49..8270f29 100644 --- a/src/main/kotlin/com/test/repository/TestEntityRepository.kt +++ b/src/main/kotlin/com/test/repository/TestEntityRepository.kt @@ -1,9 +1,10 @@ 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 { +interface TestEntityRepository //: JpaRepository +{ } \ No newline at end of file diff --git a/src/main/kotlin/com/test/rest/TestController.kt b/src/main/kotlin/com/test/rest/TestController.kt index fea0249..fb58198 100644 --- a/src/main/kotlin/com/test/rest/TestController.kt +++ b/src/main/kotlin/com/test/rest/TestController.kt @@ -19,30 +19,32 @@ open class TestController(private val testService: TestService) { private val logger = LoggerFactory.getLogger(TestController::class.java) //@PreAuthorize("hasRole('ADMIN')") - @PostMapping("/add") - fun add(@RequestBody testModel: TestModel): TestModel { - return testService.add(testModel) - } - //@PreAuthorize("hasRole('USER')") - @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 { - return testService.getAll() - } +// +// @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 { +// return testService.getAll() +// } } \ No newline at end of file diff --git a/src/main/kotlin/com/test/service/TestService.kt b/src/main/kotlin/com/test/service/TestService.kt index 78f3959..1da2cef 100644 --- a/src/main/kotlin/com/test/service/TestService.kt +++ b/src/main/kotlin/com/test/service/TestService.kt @@ -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(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 { - 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(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 { +// return testEntityRepository.findAll() +// .map { entity -> TestModel(entity.id, entity.key, entity.value)} +// } } \ No newline at end of file