Skip to content

Commit 952d777

Browse files
fix #74
1 parent a5b2044 commit 952d777

File tree

19 files changed

+91
-33
lines changed

19 files changed

+91
-33
lines changed

docker-compose.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
name: webbudget
2+
13
services:
24
postgres:
35
container_name: wb-database
@@ -14,6 +16,18 @@ services:
1416
networks:
1517
- default
1618

19+
maildev:
20+
container_name: wb-maildev
21+
image: soulteary/maildev:latest
22+
ports:
23+
- "1080:1080"
24+
- "1025:1025"
25+
environment:
26+
- MAILDEV_INCOMING_USER=maildev
27+
- MAILDEV_INCOMING_PASS=maildev
28+
networks:
29+
- default
30+
1731
volumes:
1832
data-postgres:
1933
driver: local

src/main/kotlin/br/com/webbudget/application/payloads/registration/CostCenterPayloads.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@ data class CostCenterCreateForm(
2020
)
2121

2222
data class CostCenterUpdateForm(
23-
@field:NotBlank(message = "is-null-or-blank")
24-
@field:Size(message = "max-150-chars", max = 150)
2523
val name: String?,
2624
val description: String?,
27-
val active: Boolean = true,
25+
val active: Boolean? = true,
2826
)
2927

3028
data class CostCenterView(

src/main/kotlin/br/com/webbudget/domain/entities/registration/CostCenter.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,8 @@ class CostCenter(
1515
var active: Boolean = true,
1616
@field:Column(name = "description", columnDefinition = "TEXT")
1717
var description: String? = null,
18+
@field:Column(name = "income_budget")
19+
var incomeBudget: String? = null,
20+
@field:Column(name = "expense_budget")
21+
var expenseBudget: String? = null
1822
) : PersistentEntity<Long>()
Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
11
package br.com.webbudget.infrastructure.config.spring
22

3+
import org.springframework.context.annotation.Bean
34
import org.springframework.context.annotation.Configuration
45
import org.springframework.context.annotation.Profile
6+
import org.springframework.context.event.ApplicationEventMulticaster
7+
import org.springframework.context.event.SimpleApplicationEventMulticaster
8+
import org.springframework.core.task.support.TaskExecutorAdapter
59
import org.springframework.scheduling.annotation.EnableAsync
10+
import java.util.concurrent.Executors
611

712
@EnableAsync
813
@Profile("!test")
914
@Configuration(proxyBeanMethods = false)
10-
class AsyncConfiguration
15+
class AsyncConfiguration {
16+
17+
@Bean
18+
fun configureEventMulticaster(): ApplicationEventMulticaster {
19+
20+
val virtualThreadsTaskExecutor = TaskExecutorAdapter(Executors.newVirtualThreadPerTaskExecutor())
21+
22+
val eventMulticaster = SimpleApplicationEventMulticaster()
23+
eventMulticaster.setTaskExecutor(virtualThreadsTaskExecutor)
24+
25+
return eventMulticaster
26+
}
27+
}

src/main/kotlin/br/com/webbudget/infrastructure/config/spring/CommonsConfiguration.kt

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,11 @@ package br.com.webbudget.infrastructure.config.spring
22

33
import org.springframework.context.annotation.Bean
44
import org.springframework.context.annotation.Configuration
5-
import org.springframework.context.event.ApplicationEventMulticaster
6-
import org.springframework.context.event.SimpleApplicationEventMulticaster
7-
import org.springframework.core.task.support.TaskExecutorAdapter
85
import org.springframework.scheduling.annotation.EnableScheduling
96
import org.thymeleaf.spring6.SpringTemplateEngine
107
import org.thymeleaf.spring6.templateresolver.SpringResourceTemplateResolver
118
import org.thymeleaf.templatemode.TemplateMode.HTML
129
import java.nio.charset.StandardCharsets
13-
import java.util.concurrent.Executors
1410

1511
@Configuration
1612
@EnableScheduling
@@ -45,15 +41,4 @@ class CommonsConfiguration {
4541

4642
return templateResolver
4743
}
48-
49-
@Bean
50-
fun configureEventMulticaster(): ApplicationEventMulticaster {
51-
52-
val virtualThreadsTaskExecutor = TaskExecutorAdapter(Executors.newVirtualThreadPerTaskExecutor())
53-
54-
val eventMulticaster = SimpleApplicationEventMulticaster()
55-
eventMulticaster.setTaskExecutor(virtualThreadsTaskExecutor)
56-
57-
return eventMulticaster
58-
}
5944
}

src/main/kotlin/br/com/webbudget/infrastructure/config/spring/SecurityConfiguration.kt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ import org.springframework.security.oauth2.jwt.NimbusJwtEncoder
2929
import org.springframework.security.oauth2.server.resource.web.BearerTokenAuthenticationEntryPoint
3030
import org.springframework.security.oauth2.server.resource.web.access.BearerTokenAccessDeniedHandler
3131
import org.springframework.security.web.SecurityFilterChain
32+
import org.springframework.web.cors.CorsConfiguration
33+
import org.springframework.web.cors.CorsConfigurationSource
34+
import org.springframework.web.cors.UrlBasedCorsConfigurationSource
3235
import java.security.interfaces.RSAPrivateKey
3336
import java.security.interfaces.RSAPublicKey
3437

@@ -45,6 +48,7 @@ class SecurityConfiguration(
4548
@Bean
4649
fun configureSecurity(http: HttpSecurity): SecurityFilterChain {
4750
http {
51+
cors { }
4852
csrf { disable() }
4953
authorizeHttpRequests {
5054
authorize("/actuator/health/**", permitAll)
@@ -69,6 +73,20 @@ class SecurityConfiguration(
6973
return http.build()
7074
}
7175

76+
@Bean
77+
fun corsConfigurationSource(@Value("\${web-budget.frontend-url}") frontendUrl: String): CorsConfigurationSource {
78+
79+
val configuration = CorsConfiguration()
80+
configuration.allowedOrigins = listOf(frontendUrl)
81+
configuration.allowedMethods = listOf("GET", "POST", "PUT", "DELETE", "HEAD")
82+
configuration.allowedHeaders = listOf("*")
83+
84+
val source = UrlBasedCorsConfigurationSource()
85+
source.registerCorsConfiguration("/**", configuration)
86+
87+
return source
88+
}
89+
7290
@Bean
7391
fun configureJwtDecoder(): JwtDecoder = NimbusJwtDecoder.withPublicKey(publicKey).build()
7492

src/main/resources/config/application.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,20 @@ spring:
2222
change-log: db/changelog/db.changelog.master.xml
2323

2424
mail:
25-
host: ${MAIL_HOST}
26-
port: ${MAIL_PORT:587}
27-
username: ${MAIL_USER}
28-
password: ${MAIL_PASSWORD}
25+
host: ${MAIL_HOST:localhost}
26+
port: ${MAIL_PORT:1025}
27+
username: ${MAIL_USER:maildev}
28+
password: ${MAIL_PASSWORD:maildev}
2929
properties:
3030
mail.transport.protocol: smtp
3131
mail.smtp.auth: true
3232
mail.smtp.starttls.enable: true
3333
mail.debug: false
3434

35+
threads:
36+
virtual:
37+
enabled: true
38+
3539
server:
3640
port: ${APPLICATION_PORT:8085}
3741
servlet:

src/main/resources/db/changelog/db.changelog.20210403.xml renamed to src/main/resources/db/changelog/2021/04/03-changelog.xml

File renamed without changes.

src/main/resources/db/changelog/db.changelog.20210404.xml renamed to src/main/resources/db/changelog/2021/04/04-changelog.xml

File renamed without changes.

src/main/resources/db/changelog/db.changelog.20220620.xml renamed to src/main/resources/db/changelog/2021/06/20-changelog.xml

File renamed without changes.

0 commit comments

Comments
 (0)