Skip to content

Commit

Permalink
Merge branch 'develop' into feature/record
Browse files Browse the repository at this point in the history
  • Loading branch information
tape4 authored Aug 2, 2024
2 parents 24da52e + 63b2209 commit a2259e6
Show file tree
Hide file tree
Showing 22 changed files with 461 additions and 297 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.openapitools:jackson-databind-nullable:0.2.1'

implementation 'org.springframework.security:spring-security-crypto'
}

tasks.named('test') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.springframework.web.bind.annotation.RestControllerAdvice;
import umc.kkijuk.server.common.domian.exception.*;
import umc.kkijuk.server.common.domian.response.ErrorResponse;
import umc.kkijuk.server.common.domian.exception.ConfirmPasswordMismatchException;
import umc.kkijuk.server.common.domian.response.ErrorResultResponse;

@RestControllerAdvice
Expand Down Expand Up @@ -42,6 +43,36 @@ public ErrorResponse InvalidTagNameException(InvalidTagNameException exception)
}

@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(ConfirmPasswordMismatchException.class)
public ErrorResponse ConfirmPasswordMismatchException(ConfirmPasswordMismatchException e) {
return new ErrorResponse(e.getMessage());
}

@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(FieldUpdateException.class)
public ErrorResponse FieldUpdateException(FieldUpdateException e) {
return new ErrorResponse(e.getMessage());
}


@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(InvalidMemberDataException.class)
public ErrorResponse InvalidMemberDataException(InvalidMemberDataException e) {
return new ErrorResponse(e.getMessage());
}

@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(CurrentPasswordMismatchException.class)
public ErrorResponse CurrentPasswordMismatchException(CurrentPasswordMismatchException e) {
return new ErrorResponse(e.getMessage());
}

@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(EmailNotFoundException.class)
public ErrorResponse EmailNotFoundException(EmailNotFoundException e) {
return new ErrorResponse(e.getMessage());
}

@ExceptionHandler(CareerValidationException.class)
public ErrorResponse CareerValidationException(CareerValidationException exception) {
return new ErrorResponse(exception.getMessage());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package umc.kkijuk.server.common.domian.exception;

public class ConfirmPasswordMismatchException extends RuntimeException {
public ConfirmPasswordMismatchException() {
super("비밀번호가 일치하지 않습니다.");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package umc.kkijuk.server.common.domian.exception;

public class CurrentPasswordMismatchException extends RuntimeException {
public CurrentPasswordMismatchException() {super("현재 비밀번호가 일치하지 않습니다.");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package umc.kkijuk.server.common.domian.exception;

public class EmailNotFoundException extends RuntimeException{
public EmailNotFoundException() {super("이메일을 찾을 수 없습니다.");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package umc.kkijuk.server.common.domian.exception;

public class FieldUpdateException extends RuntimeException{
public FieldUpdateException() {super("Field update fail.");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package umc.kkijuk.server.common.domian.exception;

public class InvalidMemberDataException extends RuntimeException{
public InvalidMemberDataException() {super("MemberData cannot be null.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@
import umc.kkijuk.server.member.controller.response.CreateMemberResponse;
import umc.kkijuk.server.member.controller.response.MemberFieldResponse;
import umc.kkijuk.server.member.controller.response.MemberInfoResponse;
import umc.kkijuk.server.member.controller.response.ResultResponse;
import umc.kkijuk.server.member.domain.Member;
import umc.kkijuk.server.member.dto.MemberFieldDto;
import umc.kkijuk.server.member.dto.MemberInfoChangeDto;
import umc.kkijuk.server.member.dto.MemberJoinDto;
import umc.kkijuk.server.member.dto.*;
import umc.kkijuk.server.member.service.MemberService;
import lombok.RequiredArgsConstructor;

Expand All @@ -34,94 +31,80 @@ public class MemberController {
description = "회원가입 요청을 받아 성공/실패 여부를 반환합니다.")
@PostMapping
public ResponseEntity<CreateMemberResponse> saveMember(@RequestBody @Valid MemberJoinDto memberJoinDto) {
String passwordConfirm = memberJoinDto.getPasswordConfirm();
if (!passwordConfirm.equals(memberJoinDto.getPassword())) {
return ResponseEntity
.status(HttpStatus.BAD_REQUEST)
.body(new CreateMemberResponse("Passwords do not match"));
}

try {
Long loginUser = LoginUser.get().getId();
memberService.join(memberJoinDto.toEntity());
return ResponseEntity
.status(HttpStatus.CREATED)
.body(new CreateMemberResponse(loginUser , "Member created successfully"));
} catch (Exception e) {
e.printStackTrace();
return ResponseEntity
.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body(new CreateMemberResponse("Member creation failed"));
}
Member joinMember = memberService.join(memberJoinDto);

return ResponseEntity
.status(HttpStatus.CREATED)
.body(new CreateMemberResponse(joinMember.getId(), "Member created successfully"));
}

@Operation(
summary = "내 정보 조회",
description = "마이페이지에서 내 정보들을 가져옵니다.")
@GetMapping("/myPage/info")
public ResponseEntity<MemberInfoResponse> getInfo() {
try {
Long loginUser = LoginUser.get().getId();
Member member = memberService.getMemberInfo(loginUser);
MemberInfoResponse response = new MemberInfoResponse(
member.getEmail(),
member.getName(),
member.getPhoneNumber(),
member.getBirthDate()
);
return ResponseEntity.ok(response);
} catch (Exception e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
}
Long loginUser = LoginUser.get().getId();
MemberInfoResponse memberInfoResponse = memberService.getMemberInfo(loginUser);
return ResponseEntity
.status(HttpStatus.OK)
.body(memberInfoResponse);
}

@Operation(
summary = "내 정보 수정",
description = "내 정보 수정 요청을 받아 성공/실패를 반환합니다.")
@PutMapping("/myPage/info")
public ResponseEntity<ResultResponse> changeMemberInfo(@RequestBody MemberInfoChangeDto memberInfoChangeDto) {
public ResponseEntity<Boolean> changeMemberInfo(@RequestBody @Valid MemberInfoChangeDto memberInfoChangeDto) {
Long loginUser = LoginUser.get().getId();
try {
memberService.updateMemberInfo(loginUser, memberInfoChangeDto);
return ResponseEntity.ok()
.body(new ResultResponse("information update success"));
}catch (Exception e){
return ResponseEntity
.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body(new ResultResponse("information update failed"));
}

memberService.updateMemberInfo(loginUser, memberInfoChangeDto);
return ResponseEntity.ok(Boolean.TRUE);
}

@Operation(
summary = "관심분야 조회",
description = "마이페이지에서 관심분야를 조회합니다.")
@GetMapping("/myPage/field")
public ResponseEntity<MemberFieldResponse> getField() {
try {
Long loginUser = LoginUser.get().getId();
List<String> memberField = memberService.getMemberField(loginUser);
return ResponseEntity.ok().body(new MemberFieldResponse(memberField));
} catch (Exception e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
}
Long loginUser = LoginUser.get().getId();
List<String> memberField = memberService.getMemberField(loginUser);
return ResponseEntity.ok().body(new MemberFieldResponse(memberField));
}

@Operation(
summary = "관심분야 등록/수정",
description = "초기/마이페이지에서 관심분야를 등록/수정합니다.")
@PostMapping({"/field", "/myPage/field"})
public ResponseEntity<MemberFieldResponse> postField(@RequestBody @Valid MemberFieldDto memberFieldDto) {
try {
Long loginUserId = LoginUser.get().getId();
List<String> updatedMember = memberService.updateMemberField(loginUserId, memberFieldDto);
MemberFieldResponse response = new MemberFieldResponse(updatedMember);
return ResponseEntity.ok(response);
} catch (Exception e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
}
public ResponseEntity<Boolean> postField(@RequestBody MemberFieldDto memberFieldDto) {

Long loginUser = LoginUser.get().getId();
memberService.updateMemberField(loginUser, memberFieldDto);
return ResponseEntity.ok(Boolean.TRUE);
}

@Operation(
summary = "비밀번호 변경",
description = "비밀번호를 변경합니다.")
@PostMapping("myPage/password")
public ResponseEntity<Boolean> changeMemberPassword(@RequestBody @Valid MemberPasswordChangeDto memberPasswordChangeDto){
Long loginUser = LoginUser.get().getId();
memberService.changeMemberPassword(loginUser, memberPasswordChangeDto);
return ResponseEntity.ok(Boolean.TRUE);
}

@Operation(
summary = "내정보 조회용 비밀번호 인증",
description = "내 정보를 조회하기 위해 비밀번호를 인증합니다.")
@PostMapping("/myPage")
public ResponseEntity<Boolean> myPagePasswordAuth(@RequestBody @Valid MyPagePasswordAuthDto myPagePasswordAuthDto){{
Long loginUser = LoginUser.get().getId();
memberService.myPagePasswordAuth(loginUser, myPagePasswordAuthDto);
return ResponseEntity.ok(Boolean.TRUE);
}

}



}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package umc.kkijuk.server.member.controller.response;

import lombok.Builder;
import lombok.Data;

import java.time.LocalDate;
Expand All @@ -14,6 +15,7 @@ public class MemberInfoResponse {
public MemberInfoResponse() {
}

@Builder
public MemberInfoResponse(String email, String name, String phoneNumber, LocalDate birthDate) {
this.email = email;
this.name = name;
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/umc/kkijuk/server/member/domain/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.time.LocalDate;
import java.util.List;

import umc.kkijuk.server.career.domain.base.BaseEntity;
import umc.kkijuk.server.common.converter.StringListToStringConverter;

@Entity
Expand Down Expand Up @@ -71,5 +72,8 @@ public void changeMemberInfo(String phoneNumber, LocalDate birthDate, MarketingA
this.marketingAgree = marketingAgree;
}

public void changeMemberPassword(String password){
this.password = password;
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package umc.kkijuk.server.member.dto;


import jakarta.validation.constraints.NotNull;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
Expand All @@ -11,9 +12,11 @@
@Data
@NoArgsConstructor
public class MemberInfoChangeDto {
private Long id; //jwt토큰으로 받을땐 제거
@NotNull
private String phoneNumber;
@NotNull
private LocalDate birthDate;
@NotNull
private MarketingAgree marketingAgree;

@Builder
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/umc/kkijuk/server/member/dto/MemberJoinDto.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package umc.kkijuk.server.member.dto;

import jakarta.validation.constraints.NotNull;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
Expand All @@ -13,13 +14,21 @@
@NoArgsConstructor
public class MemberJoinDto {

@NotNull
private String email;
@NotNull
private String name;
@NotNull
private String phoneNumber;
@NotNull
private LocalDate birthDate;
@NotNull
private String password;
@NotNull
private String passwordConfirm;
@NotNull
private MarketingAgree marketingAgree;
@NotNull
private State userState;

// @Builder
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package umc.kkijuk.server.member.dto;

import jakarta.validation.constraints.NotNull;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class MemberPasswordChangeDto {

@NotNull
private String currentPassword;
@NotNull
private String newPassword;
@NotNull
private String newPasswordConfirm;

@Builder
public MemberPasswordChangeDto(String currentPassword, String newPassword, String newPasswordConfirm) {
this.currentPassword = currentPassword;
this.newPassword = newPassword;
this.newPasswordConfirm = newPasswordConfirm;
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package umc.kkijuk.server.member.dto;

import jakarta.validation.constraints.NotNull;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class MemberPhoneNumberDto {
@NotNull
private String phoneNumber;

@Builder
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package umc.kkijuk.server.member.dto;

import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class MyPagePasswordAuthDto {

@NotNull
private String currentPassword;

public MyPagePasswordAuthDto(String currentPassword) {
this.currentPassword = currentPassword;
}
}
Loading

0 comments on commit a2259e6

Please sign in to comment.