Compare commits
2 Commits
1f31f06e82
...
0f4d210960
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0f4d210960 | ||
|
|
d7c7de4764 |
@@ -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'
|
||||||
@@ -36,7 +36,7 @@ dependencies {
|
|||||||
implementation("org.springframework.boot:spring-boot-starter-actuator:3.5.7")
|
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")
|
//implementation("org.flywaydb:flyway-database-postgresql:10.10.0")
|
||||||
runtimeOnly("org.postgresql:postgresql")
|
runtimeOnly("org.postgresql:postgresql")
|
||||||
|
|
||||||
|
|||||||
@@ -1,23 +1,23 @@
|
|||||||
package com.test.entities
|
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
|
import jakarta.persistence.Column
|
||||||
//@Table(name = "test_table")
|
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 (
|
data class TestEntity (
|
||||||
|
|
||||||
// @Id
|
@Id
|
||||||
// @GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
val id: Long? = null,
|
val id: Long? = null,
|
||||||
|
|
||||||
//@Column(name = "key")
|
@Column(name = "key")
|
||||||
var key: String? = null,
|
var key: String? = null,
|
||||||
|
|
||||||
//@Column(name = "value")
|
@Column(name = "value")
|
||||||
var value: String? = null
|
var value: String? = null
|
||||||
)
|
)
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
package com.test.repository
|
package com.test.repository
|
||||||
|
|
||||||
import com.test.entities.TestEntity
|
import com.test.entities.TestEntity
|
||||||
//import org.springframework.data.jpa.repository.JpaRepository
|
import org.springframework.data.jpa.repository.JpaRepository
|
||||||
import org.springframework.stereotype.Repository
|
import org.springframework.stereotype.Repository
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
interface TestEntityRepository //: JpaRepository<TestEntity, Long>
|
interface TestEntityRepository : JpaRepository<TestEntity, Long> {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
@@ -21,29 +21,30 @@ open class TestController(private val testService: TestService) {
|
|||||||
//@PreAuthorize("hasRole('ADMIN')")
|
//@PreAuthorize("hasRole('ADMIN')")
|
||||||
//@PreAuthorize("hasRole('USER')")
|
//@PreAuthorize("hasRole('USER')")
|
||||||
|
|
||||||
// @PostMapping("/add")
|
@PostMapping("/add")
|
||||||
// fun add(@RequestBody testModel: TestModel): TestModel {
|
fun add(@RequestBody testModel: TestModel): TestModel {
|
||||||
// return testService.add(testModel)
|
return testService.add(testModel)
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// @PutMapping("/update")
|
|
||||||
// fun users(@RequestBody testModel: TestModel): TestModel {
|
@PutMapping("/update")
|
||||||
// return testService.update(testModel)
|
fun users(@RequestBody testModel: TestModel): TestModel {
|
||||||
// }
|
return testService.update(testModel)
|
||||||
//
|
}
|
||||||
// @GetMapping("/{id}")
|
|
||||||
// fun get(@PathVariable(value = "id") id: Long): TestModel {
|
@GetMapping("/{id}")
|
||||||
// return testService.get(id)!!
|
fun get(@PathVariable(value = "id") id: Long): TestModel {
|
||||||
// }
|
return testService.get(id)!!
|
||||||
//
|
}
|
||||||
// @DeleteMapping("/{id}")
|
|
||||||
// fun delete(@RequestBody id: Long) {
|
@DeleteMapping("/{id}")
|
||||||
// testService.remove(id)
|
fun delete(@RequestBody id: Long) {
|
||||||
// }
|
testService.remove(id)
|
||||||
//
|
}
|
||||||
// @GetMapping("/")
|
|
||||||
// fun getAll(): List<TestModel> {
|
@GetMapping("/")
|
||||||
// return testService.getAll()
|
fun getAll(): List<TestModel> {
|
||||||
// }
|
return testService.getAll()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -3,34 +3,34 @@ package com.test.service
|
|||||||
import com.test.entities.TestEntity
|
import com.test.entities.TestEntity
|
||||||
import com.test.model.TestModel
|
import com.test.model.TestModel
|
||||||
import com.test.repository.TestEntityRepository
|
import com.test.repository.TestEntityRepository
|
||||||
//import org.springframework.data.repository.findByIdOrNull
|
import org.springframework.data.repository.findByIdOrNull
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
class TestService() {
|
class TestService(private val testEntityRepository: TestEntityRepository) {
|
||||||
|
|
||||||
// fun add(model: TestModel): TestModel {
|
fun add(model: TestModel): TestModel {
|
||||||
// var entity = testEntityRepository.save(TestEntity(null, model.key, model.value))
|
var entity = testEntityRepository.save(TestEntity(null, model.key, model.value))
|
||||||
// return TestModel(entity.id, entity.key, entity.value)
|
return TestModel(entity.id, entity.key, entity.value)
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// fun remove(id: Long) {
|
fun remove(id: Long) {
|
||||||
// testEntityRepository.deleteById(id)
|
testEntityRepository.deleteById(id)
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// 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(null, entity.key, entity.value)
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// fun get(id: Long): TestModel? {
|
fun get(id: Long): TestModel? {
|
||||||
// return testEntityRepository.findByIdOrNull(id)?.let {
|
return testEntityRepository.findByIdOrNull(id)?.let {
|
||||||
// TestModel(it.id, it.key, it.value)
|
TestModel(it.id, it.key, it.value)
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// fun getAll(): List<TestModel> {
|
fun getAll(): List<TestModel> {
|
||||||
// return testEntityRepository.findAll()
|
return testEntityRepository.findAll()
|
||||||
// .map { entity -> TestModel(entity.id, entity.key, entity.value)}
|
.map { entity -> TestModel(entity.id, entity.key, entity.value)}
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
@@ -11,21 +11,30 @@ spring:
|
|||||||
|
|
||||||
# Datasource
|
# Datasource
|
||||||
datasource:
|
datasource:
|
||||||
|
# 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.101:5432/test_db
|
url: jdbc:postgresql://192.168.2.101: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
|
||||||
|
|
||||||
# JPA
|
# JPA
|
||||||
# jpa:
|
jpa:
|
||||||
# hibernate:
|
hibernate:
|
||||||
# # ddl-auto: validate
|
# ddl-auto: validate
|
||||||
# show-sql: true
|
show-sql: true
|
||||||
# properties:
|
properties:
|
||||||
# hibernate:
|
hibernate:
|
||||||
# format_sql: true
|
format_sql: true
|
||||||
# database: postgresql
|
# database: postgres
|
||||||
# database-platform: org.hibernate.dialect.PostgreSQLDialect
|
database-platform: org.hibernate.dialect.PostgreSQLDialect
|
||||||
|
|
||||||
# Keycloak Security
|
# Keycloak Security
|
||||||
security:
|
security:
|
||||||
@@ -45,7 +54,7 @@ logging:
|
|||||||
|
|
||||||
|
|
||||||
# # Flyway
|
# # Flyway
|
||||||
# flyway:
|
flyway:
|
||||||
# enabled: true
|
enabled: false
|
||||||
# locations: classpath:db/migration
|
# locations: classpath:db/migration
|
||||||
# baseline-on-migrate: true
|
# baseline-on-migrate: true
|
||||||
Reference in New Issue
Block a user