Skip to content

Commit

Permalink
Merge pull request #21 from SOPT-SOPHY/feat/#19-add-member-field
Browse files Browse the repository at this point in the history
Feat/#19 add member field
  • Loading branch information
onpyeong authored Jul 8, 2023
2 parents b82fcca + ef5c9b5 commit 0541592
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.sophy.sophy.common.advice;

import io.jsonwebtoken.ExpiredJwtException;
import io.lettuce.core.RedisCommandExecutionException;
import org.sophy.sophy.common.dto.ApiResponseDto;
import org.sophy.sophy.exception.ErrorStatus;
import org.springframework.http.HttpStatus;
Expand All @@ -21,14 +22,12 @@ public class ControllerExceptionAdvice {
protected ApiResponseDto handleMethodArgumentNotValidException(final MethodArgumentNotValidException e) {
return ApiResponseDto.error(ErrorStatus.VALIDATION_REQUEST_MISSING_EXCEPTION);
}
/**
* 500 Internal Server
*/
// @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
// @ExceptionHandler(Exception.class)
// protected ApiResponseDto<Object> handleException(final Exception e) {
// return ApiResponseDto.error(ErrorStatus.INTERNAL_SERVER_ERROR);
// }

@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(RedisCommandExecutionException.class)
protected ApiResponseDto handleRedisCommandExecutionException(final RedisCommandExecutionException e) {
return ApiResponseDto.error(ErrorStatus.INVALID_TOKEN_INFO_EXCEPTION);
}

@ResponseStatus(HttpStatus.UNAUTHORIZED)
@ExceptionHandler(ExpiredJwtException.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public ApiResponseDto<MemberResponseDto> signup(@RequestBody MemberRequestDto me

@PostMapping("/login")
public ApiResponseDto<TokenDto> login(@RequestBody MemberLoginRequestDto memberLoginRequestDto) {
System.out.println(memberLoginRequestDto.getEmail() + memberLoginRequestDto.getAccessTokenExpiredTime());
return ApiResponseDto.success(SuccessStatus.LOGIN_SUCCESS, authService.login(memberLoginRequestDto));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class MemberRequestDto {

@NotBlank
@Pattern(regexp = "^[가-힣a-zA-Z]{2,10}$", message = "닉네임 형식에 맞지 않습니다.")
private String nickname;
private String name;

@NotBlank
@Pattern(
Expand All @@ -32,11 +32,17 @@ public class MemberRequestDto {
)
private String password;

@NotBlank
private String phoneNum;

public Member toMember(PasswordEncoder passwordEncoder) {
return Member.builder()
.email(email)
.nickname(nickname)
.name(name)
.password(passwordEncoder.encode(password))
.phoneNum(phoneNum)
.isAuthor(false)
.isOperator(false)
.authority(Authority.ROLE_USER)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ public class MemberResponseDto {
private String nickname;

public static MemberResponseDto of(Member member) {
return new MemberResponseDto(member.getEmail(), member.getNickname());
return new MemberResponseDto(member.getEmail(), member.getName());
}
}
24 changes: 24 additions & 0 deletions src/main/java/org/sophy/sophy/domain/Author.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.sophy.sophy.domain;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;

@Entity
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class Author {
@Id
@GeneratedValue
private Long id;

// private List<Booktalk> myBookTalkList;
//private List<Book> myBookList
private Integer matchingBookTalkCount;
private Integer recruitBookTalkCount;
}
14 changes: 14 additions & 0 deletions src/main/java/org/sophy/sophy/domain/City.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.sophy.sophy.domain;

public enum City {
UIJEONGBU_SI,
GANEUNG_DONG,
GANEUNG_1DONG,
GOSAN_DONG,
GEUMO_DONG,
NAKYANG_DONG,
NOKYANG_DONG,
MINRAK_DONG,
SANGOK_DONG,
SINGOK_1DONG
}
41 changes: 34 additions & 7 deletions src/main/java/org/sophy/sophy/domain/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,53 @@ public class Member extends AuditingTimeEntity{
private Long id;

@Column(nullable = false)
private String nickname;

@Column(nullable = false)
private boolean isAuthor;
private String name;

@Column(nullable = false)
private String email;

@Column(nullable = false)
private String password;

@Column(nullable = false)
private String phoneNum;

private String gender;
private String birth;

private City myCity;

private boolean marketingAgree;

@Column(nullable = false)
private boolean isAuthor;

@Column(nullable = false)
private boolean isOperator;

@Enumerated(EnumType.STRING)
private Authority authority;

private Integer bookCount;
private Integer bookTalkCount;

//private List<Booktalk> userBookTalk list
@OneToOne
private Author author; //(개설한 북토크 리스트 + 나의 책 리스트 + 공간 매칭 중 북토크 수 + 청중 모집 중 북토크 수)

@Builder
public Member(String nickname, boolean isAuthor, String email, String password, Authority authority) {
this.nickname = nickname;
this.isAuthor = isAuthor;
public Member(String name, String email, String password, String phoneNum, String gender, String birth
, City myCity, boolean marketingAgree, boolean isAuthor, boolean isOperator, Authority authority) {
this.name = name;
this.email = email;
this.password = password;
this.phoneNum = phoneNum;
this.gender = gender;
this.birth = birth;
this.myCity = myCity;
this.marketingAgree = marketingAgree;
this.isAuthor = isAuthor;
this.isOperator = isOperator;
this.authority = authority;
}
}
1 change: 1 addition & 0 deletions src/main/java/org/sophy/sophy/exception/ErrorStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public enum ErrorStatus {
VALIDATION_REQUEST_MISSING_EXCEPTION(HttpStatus.BAD_REQUEST, "요청값이 입력되지 않았습니다."),
INVALID_PASSWORD_EXCEPTION(HttpStatus.BAD_REQUEST, "잘못된 비밀번호가 입력됐습니다."),
INVALID_MULTIPART_EXTENSION_EXCEPTION(HttpStatus.BAD_REQUEST, "허용되지 않은 타입의 파일입니다"),
INVALID_TOKEN_INFO_EXCEPTION(HttpStatus.BAD_REQUEST, "토큰 혹은 만료시간 설정이 잘못되었습니다."),

/**
* 401 UNAUTHORIZED
Expand Down

0 comments on commit 0541592

Please sign in to comment.