Skip to content

Commit

Permalink
Members API endpoints (#244)
Browse files Browse the repository at this point in the history
* Members registration API + Get Members API WIP

- generated DTOs + API interfaces
- mappers for registration form and member
- endpoint implementations

* Corrected spring security for login page and API (API is default and last one)

* added missing required attributes for address Api DTO

* Member has single contact (email + phone)

* Added missing URL filter for LoginPage security configuration

* Simple in memory Crud repository

* RecordBuilder library to create builders for java 8 records

* Member registration and GET /members endpoint - still some attributes are WIP (especially detailed members list)

* Maven replaced by gradle

It seems to better handle multiple annotation processors and generators than Maven

updated readme for Gradle
Removed Maven
migrated to gradle
added gradle build folder

* Mapper testing support

* Validace registracniho formulare

* multi-field validations for registration form

* fixed optional mapstruct support

* cleanup

* Better name for in memory repository

* disabled spring security logging

* Factory for inmemory ListCrudRepository which publishes domain events same way as repositories created by Spring Data

* Member converters for Full and COmpact views. Registration of new member publishes event

* ORIS member registration stub

* Corrected path to main/java generated sources

* GET /members/{memberId} endpoint

* GET /registrationNumber endpoint

* cleanup with direction of mapping in API mappers

* Member edit endpoints (GET + PUT)

* Added Member edited event + ORIS update member info listener

* JPA replaced with SPring Data JDBC + disabled auto repository initialization for inmemorydb spring profile

* removed duplicate error for Member Not found

* added missing required constraints for suggest registration number endpoint

* cleanup

* response of POST /memberRegistration contains headers with location of created member and member id

* Cleanup of Member form constraints implementation (added constraints for edit form)

* GET /members/{memberId}/suspendMembershipForm endpoint

* POST /members/{memberId}/suspendMembershipForm endpoint

* GET /oris/userinfo/{regNum} endpoint
  • Loading branch information
dapolach authored Jun 16, 2024
1 parent a08044a commit 1a5e2a5
Show file tree
Hide file tree
Showing 91 changed files with 2,587 additions and 319 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@
.vscode/

# backend excludes
backend/target/**
backend/target/**
backend/build/**
**/.gradle/**
5 changes: 4 additions & 1 deletion backend/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# Klabis backend

## Spusteni na localhost

Aplikace ma nakonfigurovane prostredi pomoci [TestContainers](https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#features.testcontainers.at-development-time). Pro spusteni je potreba mit nainstalovany docker. Spusteni je pak mozne pomoci prikazu
```shell
mvn spring-boot:test-run
gradlew bootTestRun
```


Alternativne lze aplikaci spolecne s TestContainers spustit pomoci java main tridy `club.klabis.KlabisAppWithTestContainers`

# DevOps
Expand Down
138 changes: 138 additions & 0 deletions backend/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
import org.springframework.boot.gradle.tasks.bundling.BootBuildImage

/*
* This file was generated by the Gradle 'init' task.
*/

plugins {
java
id("org.springframework.boot") version "3.2.0"
id("io.spring.dependency-management") version "1.1.5"
id("org.openapi.generator") version "7.6.0"
}

repositories {
mavenLocal()
maven {
url = uri("https://repo.maven.apache.org/maven2/")
}
}

group = "club.zabiny"
version = "0.1-SNAPSHOT"
description = "klabis"
java.sourceCompatibility = JavaVersion.VERSION_21



val dockerImageName = "registry.polach.cloud/zbm/web-2.0/${group}.${description}:${project.version}"
println(dockerImageName)

val recordbuilderVersion = "41"
val mapstructVersion = "1.6.0.Beta1"
val mapstructSpringExtensionsVersion = "1.1.1"

dependencies {

implementation("org.springframework.boot:spring-boot-starter-actuator")
//implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-data-jdbc")
implementation("org.springframework.boot:spring-boot-starter-oauth2-authorization-server")
implementation("org.springframework.boot:spring-boot-starter-oauth2-client")
implementation("org.springframework.boot:spring-boot-starter-oauth2-resource-server")
implementation("org.springframework.boot:spring-boot-starter-web")
testImplementation("org.springframework.boot:spring-boot-devtools")
testImplementation("org.springframework.boot:spring-boot-starter-test")
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")

// Test containers
testImplementation("org.springframework.boot:spring-boot-testcontainers")
testImplementation("org.testcontainers:junit-jupiter")
testImplementation("org.testcontainers:postgresql")

// DB
runtimeOnly("org.postgresql:postgresql")
//runtimeOnly(libs.com.h2database.h2)

// OPENAPI
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.5.0")
implementation("org.openapitools:jackson-databind-nullable:0.2.6")
implementation("org.hibernate:hibernate-validator:8.0.1.Final")

// MapStruct
implementation("org.mapstruct:mapstruct:${mapstructVersion}")
implementation("org.mapstruct.extensions.spring:mapstruct-spring-annotations:${mapstructSpringExtensionsVersion}")
annotationProcessor("org.mapstruct:mapstruct-processor:${mapstructVersion}")
annotationProcessor("org.mapstruct.extensions.spring:mapstruct-spring-extensions:${mapstructSpringExtensionsVersion}")
testAnnotationProcessor("org.mapstruct.extensions.spring:mapstruct-spring-extensions:${mapstructSpringExtensionsVersion}")
testImplementation("org.mapstruct.extensions.spring:mapstruct-spring-test-extensions:${mapstructSpringExtensionsVersion}")

// RecordBuilder
annotationProcessor("io.soabase.record-builder:record-builder-processor:${recordbuilderVersion}")
compileOnly("io.soabase.record-builder:record-builder-core:${recordbuilderVersion}")

// Various
implementation("org.jmolecules:jmolecules-ddd:1.9.0")
}

tasks.withType<Test> {
useJUnitPlatform()
}

configurations {
compileOnly {
extendsFrom(configurations.annotationProcessor.get())
}
}

java.sourceSets["main"].java {
srcDir("$buildDir/generated/klabisapi/src/main/java")
}

tasks.withType<JavaCompile>() {
options.encoding = "UTF-8"
}

tasks.withType<Javadoc>() {
options.encoding = "UTF-8"
}

//tasks.register<org.openapitools.generator.gradle.plugin.tasks.GenerateTask>("generateKlabisApiServerStub") {
openApiGenerate {
// group = "openapi tools"
generatorName.set("spring")
inputSpec.set("$rootDir/../klabis-api-spec.yaml")
outputDir.set("$buildDir/generated/klabisapi")
apiPackage.set("club.klabis.api")
invokerPackage.set("org.openapi.example.invoker")
modelPackage.set("club.klabis.api.dto")
modelNameSuffix.set("ApiDto")
library.set("spring-boot")
configOptions.putAll(mapOf(
"dateLibrary" to "java8",
"useSpringBoot3" to "true",
"generateBuilders" to "true",
"useSpringController" to "false",
//"hateoas" to "false",
"booleanGetterPrefix" to "is",
"interfaceOnly" to "true",
"defaultInterfaces" to "false",
"useBeanValidation" to "true"
))
}

tasks.compileJava.get().dependsOn(tasks.openApiGenerate)

tasks.getByName<BootBuildImage>("bootBuildImage") {
imageName = dockerImageName
// publish = true
// docker {
// publishRegistry {
// username = "user"
// password = "secret"
// url = "https://docker.example.com/v1/"
// email = "[email protected]"
// }
// }
}
Binary file added backend/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions backend/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 1a5e2a5

Please sign in to comment.