Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1948c6c

Browse files
committed
feat: add server side render module
1 parent 525b08c commit 1948c6c

30 files changed

+369
-209
lines changed

‎api/pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@
234234
<excludes>
235235
<exclude>db/migration/**/*</exclude>
236236
<exclude>com/github/throyer/example/modules/infra/**/*</exclude>
237+
<exclude>com/github/throyer/example/modules/ssr/**/*</exclude>
238+
<exclude>com/github/throyer/example/modules/shared/**/*</exclude>
237239
</excludes>
238240
</configuration>
239241
</plugin>

‎api/src/main/java/com/github/throyer/example/modules/infra/http/Responses.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import com.github.throyer.example.modules.shared.errors.ApiError;
1818
import com.github.throyer.example.modules.shared.utils.JSON;
19-
import com.github.throyer.example.modules.toasts.Toasts;
19+
import com.github.throyer.example.modules.ssr.toasts.Toasts;
2020

2121
import lombok.extern.log4j.Log4j2;
2222

‎api/src/main/java/com/github/throyer/example/modules/mail/validations/EmailValidations.java

Lines changed: 17 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
import org.springframework.beans.factory.annotation.Autowired;
99
import org.springframework.stereotype.Component;
10-
import org.springframework.validation.BindingResult;
11-
import org.springframework.validation.ObjectError;
1210

1311
import com.github.throyer.example.modules.mail.models.Addressable;
1412
import com.github.throyer.example.modules.shared.errors.ValidationError;
@@ -17,52 +15,29 @@
1715

1816
@Component
1917
public class EmailValidations {
20-
private static UserRepository repository;
18+
private static UserRepository repository;
2119

22-
@Autowired
23-
public EmailValidations(UserRepository repository) {
24-
EmailValidations.repository = repository;
25-
}
26-
27-
public static void validateEmailUniqueness(Addressable entity) {
28-
if (repository.existsByEmail(entity.getEmail())) {
29-
throw new BadRequestException(List.of(new ValidationError("email", message(EMAIL_ALREADY_USED_MESSAGE))));
30-
}
31-
}
32-
33-
public static void validateEmailUniqueness(Addressable entity, BindingResult validations) {
34-
if (repository.existsByEmail(entity.getEmail())) {
35-
validations.addError(new ObjectError("email", message(EMAIL_ALREADY_USED_MESSAGE)));
36-
}
37-
}
38-
39-
public static void validateEmailUniquenessOnModify(Addressable newEntity, Addressable actualEntity) {
40-
var newEmail = newEntity.getEmail();
41-
var actualEmail = actualEntity.getEmail();
42-
43-
var changedEmail = !actualEmail.equals(newEmail);
44-
45-
var emailAlreadyUsed = repository.existsByEmail(newEmail);
20+
@Autowired
21+
public EmailValidations(UserRepository repository) {
22+
EmailValidations.repository = repository;
23+
}
4624

47-
if (changedEmail && emailAlreadyUsed) {
48-
thrownewBadRequestException(List.of(newValidationError("email", message(EMAIL_ALREADY_USED_MESSAGE))));
49-
}
25+
publicstaticvoidvalidateEmailUniqueness(Addressableentity) {
26+
if (repository.existsByEmail(entity.getEmail())) {
27+
thrownewBadRequestException(List.of(newValidationError("email", message(EMAIL_ALREADY_USED_MESSAGE))));
5028
}
29+
}
5130

52-
public static void validateEmailUniquenessOnModify(
53-
Addressable newEntity,
54-
Addressable actualEntity,
55-
BindingResult validations
56-
) {
57-
var newEmail = newEntity.getEmail();
58-
var actualEmail = actualEntity.getEmail();
31+
public static void validateEmailUniquenessOnModify(Addressable newEntity, Addressable actualEntity) {
32+
var newEmail = newEntity.getEmail();
33+
var actualEmail = actualEntity.getEmail();
5934

60-
var changedEmail = !actualEmail.equals(newEmail);
35+
var changedEmail = !actualEmail.equals(newEmail);
6136

62-
var emailAlreadyUsed = repository.existsByEmail(newEmail);
37+
var emailAlreadyUsed = repository.existsByEmail(newEmail);
6338

64-
if (changedEmail && emailAlreadyUsed) {
65-
validations.addError(new ObjectError("email", message(EMAIL_ALREADY_USED_MESSAGE)));
66-
}
39+
if (changedEmail && emailAlreadyUsed) {
40+
throw new BadRequestException(List.of(new ValidationError("email", message(EMAIL_ALREADY_USED_MESSAGE))));
6741
}
42+
}
6843
}

‎api/src/main/java/com/github/throyer/example/modules/management/entities/Auditable.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,14 @@
1919
import com.github.throyer.example.modules.management.models.Entity;
2020
import com.github.throyer.example.modules.users.entities.User;
2121

22+
import lombok.EqualsAndHashCode;
23+
2224
@MappedSuperclass
25+
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
2326
public abstract class Auditable implements Entity {
2427

2528
@Override
29+
@EqualsAndHashCode.Include
2630
public abstract Long getId();
2731

2832
@JsonIgnore

‎api/src/main/java/com/github/throyer/example/modules/recoveries/controllers/RecoveriesController.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
import org.springframework.web.bind.annotation.ResponseStatus;
1010
import org.springframework.web.bind.annotation.RestController;
1111

12-
import com.github.throyer.example.modules.recoveries.models.RecoveryConfirm;
13-
import com.github.throyer.example.modules.recoveries.models.RecoveryRequest;
14-
import com.github.throyer.example.modules.recoveries.models.RecoveryUpdate;
12+
import com.github.throyer.example.modules.recoveries.dtos.RecoveryConfirm;
13+
import com.github.throyer.example.modules.recoveries.dtos.RecoveryRequest;
14+
import com.github.throyer.example.modules.recoveries.dtos.RecoveryUpdate;
1515
import com.github.throyer.example.modules.recoveries.services.RecoveryConfirmService;
1616
import com.github.throyer.example.modules.recoveries.services.RecoveryService;
1717
import com.github.throyer.example.modules.recoveries.services.RecoveryUpdateService;

‎api/src/main/java/com/github/throyer/example/modules/recoveries/models/RecoveryConfirm.java renamed to ‎api/src/main/java/com/github/throyer/example/modules/recoveries/dtos/RecoveryConfirm.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.github.throyer.example.modules.recoveries.models;
1+
package com.github.throyer.example.modules.recoveries.dtos;
22

33
import lombok.Getter;
44
import lombok.Setter;

‎api/src/main/java/com/github/throyer/example/modules/recoveries/models/RecoveryEmail.java renamed to ‎api/src/main/java/com/github/throyer/example/modules/recoveries/dtos/RecoveryEmail.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.github.throyer.example.modules.recoveries.models;
1+
package com.github.throyer.example.modules.recoveries.dtos;
22

33
import org.thymeleaf.context.Context;
44

‎api/src/main/java/com/github/throyer/example/modules/recoveries/models/RecoveryRequest.java renamed to ‎api/src/main/java/com/github/throyer/example/modules/recoveries/dtos/RecoveryRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.github.throyer.example.modules.recoveries.models;
1+
package com.github.throyer.example.modules.recoveries.dtos;
22

33
import javax.validation.constraints.Email;
44
import javax.validation.constraints.NotEmpty;

‎api/src/main/java/com/github/throyer/example/modules/recoveries/models/RecoveryUpdate.java renamed to ‎api/src/main/java/com/github/throyer/example/modules/recoveries/dtos/RecoveryUpdate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.github.throyer.example.modules.recoveries.models;
1+
package com.github.throyer.example.modules.recoveries.dtos;
22

33
import lombok.Getter;
44
import lombok.Setter;

‎api/src/main/java/com/github/throyer/example/modules/recoveries/services/RecoveryService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
import org.springframework.stereotype.Service;
1212

1313
import com.github.throyer.example.modules.mail.services.MailService;
14+
import com.github.throyer.example.modules.recoveries.dtos.RecoveryEmail;
1415
import com.github.throyer.example.modules.recoveries.entities.Recovery;
15-
import com.github.throyer.example.modules.recoveries.models.RecoveryEmail;
1616
import com.github.throyer.example.modules.recoveries.repositories.RecoveryRepository;
1717
import com.github.throyer.example.modules.users.repositories.UserRepository;
1818

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /