Skip to content

Commit 686697e

Browse files
committed
feat(account) register
Register API Query Parameter 추가 - type Spring Boot Bucket4J Config 설정 완료를 하지 못해 버전 Rollback
1 parent b93b02b commit 686697e

File tree

19 files changed

+48
-49
lines changed

19 files changed

+48
-49
lines changed

build.gradle

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ dependencies {
6868
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'
6969
implementation 'org.springframework.boot:spring-boot-starter-validation'
7070
implementation 'org.springframework.boot:spring-boot-starter-cache'
71-
implementation 'com.giffing.bucket4j.spring.boot.starter:bucket4j-spring-boot-starter:0.12.6'
71+
implementation 'com.giffing.bucket4j.spring.boot.starter:bucket4j-spring-boot-starter:0.10.3'
7272
implementation 'com.bucket4j:bucket4j-redis:8.10.1'
7373
implementation 'org.redisson:redisson-spring-boot-starter:3.28.0'
7474
implementation 'org.zalando:logbook-spring-boot-starter:3.7.2'
@@ -128,7 +128,6 @@ dependencies {
128128
implementation 'org.apache.commons:commons-lang3:3.14.0'
129129
implementation 'org.apache.commons:commons-rng-simple:1.5'
130130
implementation 'commons-io:commons-io:2.16.1'
131-
implementation 'io.vavr:vavr:1.0.0-alpha-4'
132131

133132
// API Documentation
134133
implementation 'com.epages:restdocs-api-spec-mockmvc:0.19.2'
@@ -160,7 +159,6 @@ dependencies {
160159
testImplementation 'com.icegreen:greenmail-junit5:2.0.1'
161160
testImplementation 'io.awspring.cloud:spring-cloud-aws-starter-secrets-manager:3.1.0'
162161

163-
testImplementation 'io.vavr:vavr-test:0.10.4'
164162
testImplementation 'org.awaitility:awaitility:4.2.1'
165163
testImplementation 'org.awaitility:awaitility-proxy:3.1.6'
166164
testImplementation 'org.junit-pioneer:junit-pioneer:2.2.0' // JUnit Extension

src/main/java/com/tune_fun/v1/account/adapter/input/rest/RegisterController.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
import com.tune_fun.v1.common.hexagon.WebAdapter;
88
import com.tune_fun.v1.common.response.Response;
99
import com.tune_fun.v1.common.response.ResponseMapper;
10+
import com.tune_fun.v1.vote.adapter.input.rest.RegisterType;
1011
import jakarta.validation.Valid;
1112
import lombok.RequiredArgsConstructor;
1213
import org.springframework.http.ResponseEntity;
1314
import org.springframework.web.bind.annotation.PostMapping;
1415
import org.springframework.web.bind.annotation.RequestBody;
16+
import org.springframework.web.bind.annotation.RequestParam;
1517
import org.springframework.web.bind.annotation.RestController;
1618

1719
@RestController
@@ -27,8 +29,8 @@ public class RegisterController {
2729
* @param<p> {@link AccountCommands.Register} command
2830
*/
2931
@PostMapping(value = Uris.REGISTER)
30-
public ResponseEntity<Response<RegisterResult>> register(@Valid @RequestBody final AccountCommands.Register command) {
31-
RegisterResult registerResult = registerUseCase.register(command);
32+
public ResponseEntity<Response<RegisterResult>> register(@RequestParam(name = "type") RegisterType type, @Valid @RequestBody final AccountCommands.Register command) {
33+
RegisterResult registerResult = registerUseCase.register(type, command);
3234
return responseMapper.ok(registerResult);
3335
}
3436

src/main/java/com/tune_fun/v1/account/adapter/output/persistence/AccountMapper.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
import java.util.Collections;
1414
import java.util.Set;
1515

16+
import static java.util.Collections.singleton;
17+
1618
@Mapper(
1719
config = BaseMapperConfig.class,
1820
imports = {Collections.class, Role.class}
@@ -22,7 +24,7 @@ public abstract class AccountMapper {
2224
@Mapping(target = "roles", source = "roles", qualifiedByName = "roleValues")
2325
public abstract CurrentAccount accountInfo(final AccountJpaEntity accountJpaEntity);
2426

25-
@Mapping(target = "roles", expression = "java(Collections.singletonList(Role.CLIENT_0))")
27+
@Mapping(target = "roles", source = "role", qualifiedByName = "roles")
2628
@Mapping(target = "notificationConfig.voteProgressNotification", source = "voteProgressNotification")
2729
@Mapping(target = "notificationConfig.voteEndNotification", source = "voteEndNotification")
2830
@Mapping(target = "notificationConfig.voteDeliveryNotification", source = "voteDeliveryNotification")
@@ -31,6 +33,11 @@ public abstract class AccountMapper {
3133
@Mapping(target = "roles", source = "roles", qualifiedByName = "roleValues")
3234
public abstract RegisteredAccount registeredAccountInfo(final AccountJpaEntity accountJpaEntity);
3335

36+
@Named("roles")
37+
public Set<Role> roles(String role) {
38+
return singleton(Role.valueOf(role));
39+
}
40+
3441
@Named("roleValues")
3542
public Set<String> roleValues(Set<Role> roles) {
3643
return Role.roleValues(roles);

src/main/java/com/tune_fun/v1/account/adapter/output/persistence/Role.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import lombok.Getter;
55
import org.springframework.security.core.GrantedAuthority;
66

7-
import java.util.List;
87
import java.util.Set;
98

109
import static java.util.stream.Collectors.toSet;
@@ -13,7 +12,7 @@
1312
@AllArgsConstructor
1413
public enum Role implements GrantedAuthority {
1514

16-
CLIENT_0("ROLE_CLIENT_0"),
15+
NORMAL("ROLE_NORMAL"),
1716
ARTIST("ROLE_ARTIST"),
1817
ADMIN("ROLE_ADMIN");
1918

src/main/java/com/tune_fun/v1/account/application/port/input/usecase/RegisterUseCase.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
import com.tune_fun.v1.account.application.port.input.command.AccountCommands;
44
import com.tune_fun.v1.account.domain.value.RegisterResult;
5+
import com.tune_fun.v1.vote.adapter.input.rest.RegisterType;
56

67
@FunctionalInterface
78
public interface RegisterUseCase {
8-
RegisterResult register(final AccountCommands.Register command);
9+
RegisterResult register(RegisterType type, final AccountCommands.Register command);
910
}

src/main/java/com/tune_fun/v1/account/application/service/RegisterService.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import com.tune_fun.v1.common.exception.CommonApplicationException;
1414
import com.tune_fun.v1.common.hexagon.UseCase;
1515
import com.tune_fun.v1.common.util.StringUtil;
16+
import com.tune_fun.v1.vote.adapter.input.rest.RegisterType;
1617
import lombok.RequiredArgsConstructor;
1718
import org.jetbrains.annotations.NotNull;
1819
import org.springframework.security.crypto.password.PasswordEncoder;
@@ -35,8 +36,8 @@ public class RegisterService implements RegisterUseCase {
3536
private final PasswordEncoder passwordEncoder;
3637

3738
@NotNull
38-
private static SaveAccount getSaveAccount(AccountCommands.Register command, String encodedPassword) {
39-
return new SaveAccount(
39+
private static SaveAccount getSaveAccount(final RegisterType type, final AccountCommands.Register command, final String encodedPassword) {
40+
return new SaveAccount(type.name(),
4041
StringUtil.uuid(), command.username(), encodedPassword,
4142
command.email(), command.nickname(), command.notification().voteDeliveryNotification(),
4243
command.notification().voteEndNotification(), command.notification().voteDeliveryNotification()
@@ -50,11 +51,11 @@ private static RegisterResult getRegisterResult(CurrentAccount savedAccount, Str
5051

5152
@Override
5253
@Transactional
53-
public RegisterResult register(final AccountCommands.Register command) {
54+
public RegisterResult register(final RegisterType type, final AccountCommands.Register command) {
5455
checkRegisterdAccount(command);
5556

5657
String encodedPassword = passwordEncoder.encode(command.password());
57-
SaveAccount saveAccount = getSaveAccount(command, encodedPassword);
58+
SaveAccount saveAccount = getSaveAccount(type, command, encodedPassword);
5859
CurrentAccount savedAccount = saveAccountPort.saveAccount(saveAccount);
5960

6061
String authorities = String.join(",", savedAccount.roles());

src/main/java/com/tune_fun/v1/account/application/service/oauth2/handler/OAuth2AuthenticationSuccessHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public Optional<RegisteredOAuth2Account> loadRegisteredOAuth2Account(OAuth2UserP
196196

197197
@Transactional
198198
public CurrentAccount saveBaseAccount(final OAuth2UserPrincipal principal) {
199-
SaveAccount saveAccountBehavior = new SaveAccount(StringUtil.uuid(), principal.userInfo().getEmail(),
199+
SaveAccount saveAccountBehavior = new SaveAccount("NORMAL", StringUtil.uuid(), principal.userInfo().getEmail(),
200200
"social", principal.userInfo().getEmail(), principal.userInfo().getNickname(),
201201
true, true, true);
202202
return saveAccountPort.saveAccount(saveAccountBehavior);

src/main/java/com/tune_fun/v1/account/domain/behavior/SaveAccount.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.tune_fun.v1.account.domain.behavior;
22

33
public record SaveAccount(
4+
String role,
45
String uuid,
56
String username,
67
String password,
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.tune_fun.v1.vote.adapter.input.rest;
2+
3+
public enum RegisterType {
4+
NORMAL, ARTIST
5+
}

src/main/java/com/tune_fun/v1/vote/adapter/output/persistence/VotePaperCustomRepository.java

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)