-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
feat : member entity
- Loading branch information
Showing
24 changed files
with
281 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/main/java/Journey/Together/domain/member/controller/MemberController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package Journey.Together.domain.member.controller; | ||
|
||
import Journey.Together.domain.member.dto.MemberRes; | ||
import Journey.Together.domain.member.service.MemberService; | ||
import Journey.Together.global.common.ApiResponse; | ||
import Journey.Together.global.exception.Success; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/v1/member") | ||
@Tag(name = "Member", description = "사용자 관련 API") | ||
public class MemberController { | ||
|
||
private final MemberService memberService; | ||
|
||
@GetMapping("") | ||
public ApiResponse<MemberRes> getMember() { | ||
return ApiResponse.success(Success.LOGIN_SUCCESS); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
src/main/java/Journey/Together/domain/member/dto/MemberRes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package Journey.Together.domain.member.dto; | ||
|
||
public record MemberRes() { | ||
} |
65 changes: 65 additions & 0 deletions
65
src/main/java/Journey/Together/domain/member/entity/Member.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package Journey.Together.domain.member.entity; | ||
|
||
import Journey.Together.domain.member.enumerate.BloodType; | ||
import Journey.Together.domain.member.enumerate.LoginType; | ||
import Journey.Together.global.common.BaseTimeEntity; | ||
import jakarta.persistence.*; | ||
import lombok.*; | ||
|
||
@Getter | ||
@Setter | ||
@Entity | ||
@Table(name = "member") | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class Member extends BaseTimeEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "member_id", nullable = false, columnDefinition = "bigint") | ||
private Long memberId; | ||
|
||
// 이메일은 최대 255자 + 1자(@) + 69자해서 최대 320글자이므로, varchar(320) 사용 | ||
@Column(name = "email", nullable = false, columnDefinition = "varchar(320)") | ||
private String email; | ||
|
||
@Column(name = "name", nullable = false, columnDefinition = "varchar(50)") | ||
private String name; | ||
|
||
@Column(name = "phone", columnDefinition = "varchar(15)") | ||
private String phone; | ||
|
||
@Column(name = "profile_url", columnDefinition = "text") | ||
private String profileUrl; | ||
|
||
@Column(name = "login_type", nullable = false, columnDefinition = "varchar(255)") | ||
@Enumerated(EnumType.STRING) | ||
private LoginType loginType; | ||
|
||
@Column(name = "blood_type", nullable = false, columnDefinition = "varchar(255)") | ||
@Enumerated(EnumType.STRING) | ||
private BloodType bloodType; | ||
|
||
@Column(name = "birth", columnDefinition = "varchar(255)") | ||
private String birth; | ||
|
||
@Column(name = "disease", columnDefinition = "varchar(255)") | ||
private String disease; | ||
|
||
@Column(name = "allergy", columnDefinition = "varchar(255)") | ||
private String allergy; | ||
|
||
@Column(name = "medication", columnDefinition = "varchar(255)") | ||
private String medication; | ||
|
||
@Builder | ||
public Member(String email, String name, String phone, String profileUrl, String loginType,String bloodType, String birth, String allergy, String medication) { | ||
this.email = email; | ||
this.name = name; | ||
this.phone = phone; | ||
this.profileUrl = profileUrl; | ||
this.loginType = LoginType.valueOf(loginType); | ||
this.bloodType = BloodType.valueOf(bloodType); | ||
this.birth = birth; | ||
this.allergy = allergy; | ||
this.medication=medication; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/Journey/Together/domain/member/enumerate/BloodType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package Journey.Together.domain.member.enumerate; | ||
|
||
public enum BloodType { | ||
A,B,AB,O | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/Journey/Together/domain/member/enumerate/LoginType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package Journey.Together.domain.member.enumerate; | ||
|
||
public enum LoginType { | ||
KAKAO,NAVER | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/Journey/Together/domain/member/repository/MemberRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package Journey.Together.domain.member.repository; | ||
|
||
import Journey.Together.domain.member.entity.Member; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
|
||
public interface MemberRepository extends JpaRepository<Member, Long> { | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/Journey/Together/domain/member/service/MemberService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package Journey.Together.domain.member.service; | ||
|
||
import Journey.Together.domain.member.repository.MemberRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@Transactional(readOnly = true) | ||
@RequiredArgsConstructor | ||
public class MemberService { | ||
|
||
private final MemberRepository memberRepository; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/main/java/Journey/Together/global/config/SwaggerConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package Journey.Together.global.config; | ||
|
||
import io.swagger.v3.oas.models.Components; | ||
import io.swagger.v3.oas.models.OpenAPI; | ||
import io.swagger.v3.oas.models.info.Info; | ||
import io.swagger.v3.oas.models.security.SecurityRequirement; | ||
import io.swagger.v3.oas.models.security.SecurityScheme; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class SwaggerConfig { | ||
|
||
@Bean | ||
public OpenAPI openAPI() { | ||
Info info = new Info().title("Capic Swagger UI") | ||
.description("Capic API 테스트 페이지.") | ||
.version("v0.0.1"); | ||
|
||
String jwtSchemeName = "JWT Authentication"; | ||
SecurityRequirement securityRequirement = new SecurityRequirement().addList(jwtSchemeName); | ||
Components components = new Components() | ||
.addSecuritySchemes(jwtSchemeName, new SecurityScheme() | ||
.name(jwtSchemeName) | ||
.type(SecurityScheme.Type.HTTP) | ||
.scheme("bearer") | ||
.bearerFormat("JWT")); | ||
|
||
// Swagger UI 접속 후, 딱 한 번만 accessToken을 입력해주면 모든 API에 토큰 인증 작업이 적용됩니다. | ||
return new OpenAPI() | ||
.info(info) | ||
.addSecurityItem(securityRequirement) | ||
.components(components); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/Journey/Together/global/exception/ApplicationException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package Journey.Together.global.exception; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public class ApplicationException extends RuntimeException { | ||
public ErrorCode errorCode; | ||
} |
54 changes: 0 additions & 54 deletions
54
src/main/java/Journey/Together/global/exception/Error.java
This file was deleted.
Oops, something went wrong.
60 changes: 60 additions & 0 deletions
60
src/main/java/Journey/Together/global/exception/ErrorCode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package Journey.Together.global.exception; | ||
|
||
import lombok.Getter; | ||
import lombok.ToString; | ||
import org.springframework.http.HttpStatus; | ||
|
||
@Getter | ||
@ToString | ||
public enum ErrorCode { | ||
|
||
// 1000: Success Case | ||
SUCCESS(HttpStatus.OK, 1000, "정상적인 요청입니다."), | ||
CREATED(HttpStatus.CREATED, 1001, "정상적으로 생성되었습니다."), | ||
|
||
// 2000: Common Error | ||
INTERNAL_SERVER_EXCEPTION(HttpStatus.INTERNAL_SERVER_ERROR, 2000, "예기치 못한 오류가 발생했습니다."), | ||
NOT_FOUND_EXCEPTION(HttpStatus.NOT_FOUND, 2001, "존재하지 않는 리소스입니다."), | ||
INVALID_VALUE_EXCEPTION(HttpStatus.BAD_REQUEST, 2002, "올바르지 않은 요청 값입니다."), | ||
UNAUTHORIZED_EXCEPTION(HttpStatus.UNAUTHORIZED, 2003, "권한이 없는 요청입니다."), | ||
ALREADY_DELETE_EXCEPTION(HttpStatus.BAD_REQUEST, 2004, "이미 삭제된 리소스입니다."), | ||
FORBIDDEN_EXCEPTION(HttpStatus.FORBIDDEN, 2005, "인가되지 않는 요청입니다."), | ||
ALREADY_EXIST_EXCEPTION(HttpStatus.BAD_REQUEST, 2006, "이미 존재하는 리소스입니다."), | ||
|
||
|
||
// 3000: Auth Error | ||
KAKAO_TOKEN_EXCEPTION(HttpStatus.INTERNAL_SERVER_ERROR, 3000, "토큰 발급에서 오류가 발생했습니다."), | ||
KAKAO_USER_EXCEPTION(HttpStatus.INTERNAL_SERVER_ERROR, 3001, "카카오 프로필 정보를 가져오는 과정에서 오류가 발생했습니디."), | ||
WRONG_TOKEN_EXCEPTION(HttpStatus.UNAUTHORIZED, 3002, "유효하지 않은 토큰입니다."), | ||
LOGOUT_TOKEN_EXCEPTION(HttpStatus.UNAUTHORIZED, 3003, "로그아웃된 토큰입니다"), | ||
WRONG_TOKEN(HttpStatus.UNAUTHORIZED, 3004, "유효하지 않은 토큰입니다."), | ||
|
||
|
||
//4000: Apply Error | ||
NOT_APPLY_EXCEPTION(HttpStatus.BAD_REQUEST,4000,"지원 기간 지났습니다"), | ||
NOT_FOUND_POST_EXCEPTION(HttpStatus.NOT_FOUND,4001,"존재하지 않는 글입니다."), | ||
NOT_FOUND_APPLY_EXCEPTION(HttpStatus.NOT_FOUND,4002,"존재하지 않는 지원서입니다."), | ||
ALREADY_APPLY_EXCEPTION(HttpStatus.BAD_REQUEST,4003,"이미 지원했습니다."), | ||
ALREADY_DECISION_EXCEPION(HttpStatus.BAD_REQUEST,4004,"이미 지원 결정했습니다."), | ||
NOT_RECRUITING_EXCEPION(HttpStatus.BAD_REQUEST,4005,"이 공고는 모집 중이 아닙니다."), | ||
NOT_FOUND_CATEGORY_EXCEPTION(HttpStatus.NOT_FOUND,4006,"카테고리가 없습니다"), | ||
OVER_APPLY_EXCEPTION(HttpStatus.NOT_FOUND,4007,"지원 파트 정원이 찼습니다."), | ||
INVALID_STACK_TYPE_EXCEPTION(HttpStatus.NOT_FOUND,4008,"기술 스택 없습니다"), | ||
|
||
//5000: Post Error | ||
NOT_POST_EXCEPTION(HttpStatus.BAD_REQUEST,5000,"공고를 더 이상 생성할 수 없습니다"), | ||
POST_VALUE_EXCEPTION(HttpStatus.BAD_REQUEST,5001,"올바르지 않은 요청 값입니다."), | ||
NOT_FOUNT_SCRAP_EXCEPTION(HttpStatus.NOT_FOUND,5002,"스크랩 정보가 존재하지 않습니다."), | ||
ALREADY_FINISH_EXCEPTION(HttpStatus.BAD_REQUEST, 5003, "이미 모집 기간이 마감된 공고입니다."), | ||
ILLEGAL_POST_EXCEPTION(HttpStatus.BAD_REQUEST, 5004, "파트별 인원수가 전체 인원수와 일치하지 않습니다."); | ||
|
||
private final HttpStatus httpStatus; | ||
private final Integer code; | ||
private final String message; | ||
|
||
ErrorCode(HttpStatus httpStatus, Integer code, String message) { | ||
this.httpStatus = httpStatus; | ||
this.code = code; | ||
this.message = message; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/Journey/Together/global/exception/ErrorResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package Journey.Together.global.exception; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
|
||
public record ErrorResponse( | ||
LocalDateTime timestamp, | ||
Integer code, | ||
String message) { | ||
|
||
public ErrorResponse(ErrorCode errorcode) { | ||
this(LocalDateTime.now(), errorcode.getCode(), errorcode.getMessage()); | ||
} | ||
|
||
public ErrorResponse(String message) { | ||
this(LocalDateTime.now(), ErrorCode.INTERNAL_SERVER_EXCEPTION.getCode(), message); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/Journey/Together/global/exception/GlobalExceptionHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package Journey.Together.global.exception; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
import org.springframework.web.bind.annotation.RestControllerAdvice; | ||
|
||
@Slf4j | ||
@RestControllerAdvice | ||
public class GlobalExceptionHandler { | ||
|
||
@ExceptionHandler(ApplicationException.class) | ||
protected ResponseEntity<ErrorResponse> handleApplicationException(ApplicationException e){ | ||
log.error(e + " " + e.getErrorCode().toString()); | ||
return ResponseEntity.status(e.getErrorCode().getHttpStatus()) | ||
.body(new ErrorResponse(e.getErrorCode())); | ||
} | ||
|
||
@ExceptionHandler(RuntimeException.class) | ||
protected ResponseEntity<ErrorResponse> handleRuntimeException(RuntimeException e) { | ||
log.error(e.getMessage()); | ||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) | ||
.body(new ErrorResponse(e.getMessage())); | ||
} | ||
} |
10 changes: 0 additions & 10 deletions
10
src/main/java/Journey/Together/global/exception/model/BadRequestException.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.