Compare commits
5 Commits
feature/do
...
feature/fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
99715d0d14 | ||
|
|
ffa6b3f623 | ||
|
|
9fa7446487 | ||
|
|
33c485b691 | ||
|
|
88fe7ca6c5 |
@@ -1,7 +1,7 @@
|
|||||||
plugins {
|
plugins {
|
||||||
java
|
java
|
||||||
id("org.springframework.boot") version "2.6.7"
|
id("org.springframework.boot") version "2.6.7"
|
||||||
id("io.spring.dependency-management") version "1.0.11.RELEASE"
|
id("io.spring.dependency-management") version "1.0.11.RELEASE"
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "com.ticketing"
|
group = "com.ticketing"
|
||||||
@@ -9,18 +9,18 @@ version = "0.0.1-SNAPSHOT"
|
|||||||
|
|
||||||
val javaVersion = JavaVersion.VERSION_11
|
val javaVersion = JavaVersion.VERSION_11
|
||||||
java {
|
java {
|
||||||
sourceCompatibility = javaVersion
|
sourceCompatibility = javaVersion
|
||||||
targetCompatibility = javaVersion
|
targetCompatibility = javaVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
configurations {
|
configurations {
|
||||||
compileOnly {
|
compileOnly {
|
||||||
extendsFrom(configurations.annotationProcessor.get())
|
extendsFrom(configurations.annotationProcessor.get())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -33,36 +33,36 @@ dependencies {
|
|||||||
implementation("org.springframework.boot:spring-boot-starter-actuator")
|
implementation("org.springframework.boot:spring-boot-starter-actuator")
|
||||||
implementation("org.springframework.boot:spring-boot-starter-log4j2")
|
implementation("org.springframework.boot:spring-boot-starter-log4j2")
|
||||||
implementation("org.projectlombok:lombok:1.18.20")
|
implementation("org.projectlombok:lombok:1.18.20")
|
||||||
implementation("io.springfox:springfox-boot-starter:3.0.0")
|
implementation("io.springfox:springfox-boot-starter:3.0.0")
|
||||||
implementation("io.springfox:springfox-swagger-ui:3.0.0")
|
implementation("io.springfox:springfox-swagger-ui:3.0.0")
|
||||||
implementation("com.github.ulisesbocchio:jasypt-spring-boot-starter:3.0.4")
|
implementation("com.github.ulisesbocchio:jasypt-spring-boot-starter:3.0.4")
|
||||||
implementation("com.lmax:disruptor:3.4.2")
|
implementation("com.lmax:disruptor:3.4.2")
|
||||||
implementation("io.jsonwebtoken:jjwt-api:0.11.2")
|
implementation("io.jsonwebtoken:jjwt-api:0.11.2")
|
||||||
implementation("com.googlecode.json-simple:json-simple:1.1.1")
|
implementation("com.googlecode.json-simple:json-simple:1.1.1")
|
||||||
implementation("org.springframework.boot:spring-boot-starter-data-redis")
|
implementation("org.springframework.boot:spring-boot-starter-data-redis")
|
||||||
|
|
||||||
modules {
|
modules {
|
||||||
module("org.springframework.boot:spring-boot-starter-logging") {
|
module("org.springframework.boot:spring-boot-starter-logging") {
|
||||||
replacedBy("org.springframework.boot:spring-boot-starter-log4j2", "Use Log4j2 instead of Logback")
|
replacedBy("org.springframework.boot:spring-boot-starter-log4j2", "Use Log4j2 instead of Logback")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
||||||
testImplementation("org.springframework.security:spring-security-test")
|
testImplementation("org.springframework.security:spring-security-test")
|
||||||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.1")
|
testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.1")
|
||||||
|
|
||||||
compileOnly("org.projectlombok:lombok")
|
compileOnly("org.projectlombok:lombok")
|
||||||
runtimeOnly("mysql:mysql-connector-java")
|
runtimeOnly("mysql:mysql-connector-java")
|
||||||
runtimeOnly("io.jsonwebtoken:jjwt-impl:0.11.2")
|
runtimeOnly("io.jsonwebtoken:jjwt-impl:0.11.2")
|
||||||
runtimeOnly("io.jsonwebtoken:jjwt-jackson:0.11.2")
|
runtimeOnly("io.jsonwebtoken:jjwt-jackson:0.11.2")
|
||||||
annotationProcessor("org.projectlombok:lombok")
|
annotationProcessor("org.projectlombok:lombok")
|
||||||
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
|
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
|
||||||
|
|
||||||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.1")
|
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.1")
|
||||||
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
||||||
testImplementation("org.springframework.security:spring-security-test")
|
testImplementation("org.springframework.security:spring-security-test")
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<Test> {
|
tasks.withType<Test> {
|
||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import com.ticketing.server.user.application.response.SignUpResponse;
|
|||||||
import com.ticketing.server.user.application.response.TokenDto;
|
import com.ticketing.server.user.application.response.TokenDto;
|
||||||
import com.ticketing.server.user.application.response.UserChangePasswordResponse;
|
import com.ticketing.server.user.application.response.UserChangePasswordResponse;
|
||||||
import com.ticketing.server.user.application.response.UserDeleteResponse;
|
import com.ticketing.server.user.application.response.UserDeleteResponse;
|
||||||
|
import com.ticketing.server.user.application.response.UserDetailResponse;
|
||||||
import com.ticketing.server.user.domain.User;
|
import com.ticketing.server.user.domain.User;
|
||||||
import com.ticketing.server.user.service.UserServiceImpl;
|
import com.ticketing.server.user.service.UserServiceImpl;
|
||||||
import com.ticketing.server.user.service.interfaces.AuthenticationService;
|
import com.ticketing.server.user.service.interfaces.AuthenticationService;
|
||||||
@@ -19,8 +20,11 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.access.annotation.Secured;
|
import org.springframework.security.access.annotation.Secured;
|
||||||
|
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
||||||
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
@@ -45,6 +49,13 @@ public class UserController {
|
|||||||
return ResponseEntity.status(HttpStatus.CREATED).body(SignUpResponse.from(user));
|
return ResponseEntity.status(HttpStatus.CREATED).body(SignUpResponse.from(user));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/info")
|
||||||
|
@Secured("ROLE_GUEST")
|
||||||
|
public ResponseEntity<UserDetailResponse> myInfo(@AuthenticationPrincipal UserDetails userRequest) {
|
||||||
|
User user = userService.findByEmail(userRequest.getUsername());
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(UserDetailResponse.from(user));
|
||||||
|
}
|
||||||
|
|
||||||
@DeleteMapping
|
@DeleteMapping
|
||||||
@Secured("ROLE_GUEST")
|
@Secured("ROLE_GUEST")
|
||||||
public ResponseEntity<UserDeleteResponse> deleteUser(@RequestBody @Valid UserDeleteRequest request) {
|
public ResponseEntity<UserDeleteResponse> deleteUser(@RequestBody @Valid UserDeleteRequest request) {
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.ticketing.server.user.application.response;
|
||||||
|
|
||||||
|
import com.ticketing.server.user.domain.User;
|
||||||
|
import com.ticketing.server.user.domain.UserGrade;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class UserDetailResponse {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private String email;
|
||||||
|
private UserGrade grade;
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
public static UserDetailResponse from(User user) {
|
||||||
|
return new UserDetailResponse(user.getName(), user.getEmail(), user.getGrade(), user.getPhone());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -39,13 +39,7 @@ public class UserServiceImpl implements UserService {
|
|||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public User delete(@Valid DeleteUserDTO deleteUserDto) {
|
public User delete(@Valid DeleteUserDTO deleteUserDto) {
|
||||||
User user = userRepository.findByEmail(deleteUserDto.getEmail())
|
User user = findByEmail(deleteUserDto.getEmail());
|
||||||
.orElseThrow(() -> {
|
|
||||||
log.error("존재하지 않는 이메일 입니다. :: {}", deleteUserDto.getEmail());
|
|
||||||
throw new EmailNotFoundException();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
return user.delete(deleteUserDto);
|
return user.delete(deleteUserDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,6 +50,16 @@ public class UserServiceImpl implements UserService {
|
|||||||
return user.changePassword(changePasswordDto);
|
return user.changePassword(changePasswordDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public User findByEmail(String email) {
|
||||||
|
return userRepository.findByEmail(email)
|
||||||
|
.orElseThrow(() -> {
|
||||||
|
log.error("존재하지 않는 이메일 입니다. :: {}", email);
|
||||||
|
throw new EmailNotFoundException();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private User findNotDeletedUserByEmail(String email) {
|
private User findNotDeletedUserByEmail(String email) {
|
||||||
return userRepository.findByEmailAndIsDeletedFalse(email)
|
return userRepository.findByEmailAndIsDeletedFalse(email)
|
||||||
.orElseThrow(() -> {
|
.orElseThrow(() -> {
|
||||||
|
|||||||
@@ -14,4 +14,5 @@ public interface UserService {
|
|||||||
|
|
||||||
User changePassword(@Valid ChangePasswordDTO changePasswordDto);
|
User changePassword(@Valid ChangePasswordDTO changePasswordDto);
|
||||||
|
|
||||||
|
User findByEmail(String email);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ jasypt:
|
|||||||
bean: jasyptStringEncryptor
|
bean: jasyptStringEncryptor
|
||||||
|
|
||||||
jwt:
|
jwt:
|
||||||
access-header: ACCESS_TOKEN
|
access-header: Authorization
|
||||||
refresh-header: REFRESH_TOKEN
|
refresh-header: REFRESH_TOKEN
|
||||||
prefix: Bearer
|
prefix: Bearer
|
||||||
secret-key: Zi1sYWItdGlja2V0aW5nLXByb2plY3Qtc3ByaW5nLWJvb3Qtc2VjdXJpdHktand0LXNlY3JldC1rZXktZi1sYWItdGlja2V0aW5nLXByb2plY3Qtc3ByaW5nLWJvb3Qtc2VjdXJpdHktand0LXNlY3JldC1rZXkK
|
secret-key: Zi1sYWItdGlja2V0aW5nLXByb2plY3Qtc3ByaW5nLWJvb3Qtc2VjdXJpdHktand0LXNlY3JldC1rZXktZi1sYWItdGlja2V0aW5nLXByb2plY3Qtc3ByaW5nLWJvb3Qtc2VjdXJpdHktand0LXNlY3JldC1rZXkK
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class JwtPropertiesTest {
|
|||||||
// when
|
// when
|
||||||
// then
|
// then
|
||||||
assertAll(
|
assertAll(
|
||||||
() -> assertThat(jwtProperties.getAccessHeader()).isEqualTo("ACCESS_TOKEN")
|
() -> assertThat(jwtProperties.getAccessHeader()).isEqualTo("Authorization")
|
||||||
, () -> assertThat(jwtProperties.getRefreshHeader()).isEqualTo("REFRESH_TOKEN")
|
, () -> assertThat(jwtProperties.getRefreshHeader()).isEqualTo("REFRESH_TOKEN")
|
||||||
, () -> assertThat(jwtProperties.getPrefix()).isEqualTo("Bearer")
|
, () -> assertThat(jwtProperties.getPrefix()).isEqualTo("Bearer")
|
||||||
, () -> assertThat(jwtProperties.getAccessTokenValidityInSeconds()).isEqualTo(60)
|
, () -> assertThat(jwtProperties.getAccessTokenValidityInSeconds()).isEqualTo(60)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.ticketing.server.user.service;
|
|||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertAll;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
@@ -92,7 +93,10 @@ class UserServiceImplTest {
|
|||||||
User user = userService.delete(deleteUserDto);
|
User user = userService.delete(deleteUserDto);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(user).isNotNull();
|
assertAll(
|
||||||
|
() -> assertThat(user.isDeleted()).isTrue(),
|
||||||
|
() -> assertThat(user.getDeletedAt()).isNotNull()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -16,12 +16,16 @@ spring:
|
|||||||
hibernate:
|
hibernate:
|
||||||
ddl-auto: create
|
ddl-auto: create
|
||||||
|
|
||||||
|
mvc:
|
||||||
|
pathmatch:
|
||||||
|
matching-strategy: ant_path_matcher
|
||||||
|
|
||||||
jasypt:
|
jasypt:
|
||||||
encryptor:
|
encryptor:
|
||||||
bean: jasyptStringEncryptor
|
bean: jasyptStringEncryptor
|
||||||
|
|
||||||
jwt:
|
jwt:
|
||||||
access-header: ACCESS_TOKEN
|
access-header: Authorization
|
||||||
refresh-header: REFRESH_TOKEN
|
refresh-header: REFRESH_TOKEN
|
||||||
prefix: Bearer
|
prefix: Bearer
|
||||||
secret-key: Zi1sYWItdGlja2V0aW5nLXByb2plY3Qtc3ByaW5nLWJvb3Qtc2VjdXJpdHktand0LXNlY3JldC1rZXktZi1sYWItdGlja2V0aW5nLXByb2plY3Qtc3ByaW5nLWJvb3Qtc2VjdXJpdHktand0LXNlY3JldC1rZXkK
|
secret-key: Zi1sYWItdGlja2V0aW5nLXByb2plY3Qtc3ByaW5nLWJvb3Qtc2VjdXJpdHktand0LXNlY3JldC1rZXktZi1sYWItdGlja2V0aW5nLXByb2plY3Qtc3ByaW5nLWJvb3Qtc2VjdXJpdHktand0LXNlY3JldC1rZXkK
|
||||||
|
|||||||
Reference in New Issue
Block a user