-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#47 [feat] 디자이너 회원가입 기능 구현 #63
Changes from 15 commits
684e066
ec51145
136674d
93cde86
f6cd102
02ba3a4
f5acee3
de2ada0
d4b3c25
09a2ba1
9ae1614
de83404
a368743
203304a
4418462
96c798a
7fcf823
cce504c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,12 +17,17 @@ public enum ErrorCode { | |
TOKEN_TIME_EXPIRED_EXCEPTION(HttpStatus.UNAUTHORIZED, "토큰이 만료되었습니다. 다시 로그인 해주세요."), | ||
|
||
//404 | ||
|
||
INVALID_DAY_OF_WEEK_EXCEPTION(HttpStatus.NOT_FOUND, "요일을 찾을 수 없습니다"), | ||
INVALID_GENDER_EXCEPTION(HttpStatus.NOT_FOUND, "성별을 찾을 수 없습니다"), | ||
|
||
NOT_FOUND_MODEL_STATUS(HttpStatus.NOT_FOUND, "모델의 지원서 작성과 제안서 도착 상태를 알 수 없습니다."), | ||
NOT_FOUND_MODEL_INFO(HttpStatus.NOT_FOUND, "모델 정보를 찾을 수 없습니다."), | ||
NOT_FOUND_PREFER_OFFER_CONDITION(HttpStatus.NOT_FOUND, "선호 제안조건을 찾을 수 없습니다."), | ||
USER_NOT_FOUND_EXCEPTION(HttpStatus.NOT_FOUND, "해당 유저는 존재하지 않습니다."), | ||
|
||
// 405 METHOD_NOT_ALLOWED | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. p4 : |
||
METHOD_NOT_ALLOWED_EXCEPTION(HttpStatus.METHOD_NOT_ALLOWED, "지원하지 않는 메소드 입니다."), | ||
|
||
// 500 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,10 +8,13 @@ | |
@AllArgsConstructor | ||
public enum SuccessCode { | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. p4: |
||
DESIGNER_CREATE_SUCCESS(HttpStatus.OK, "디자이너 회원가입 성공"), | ||
FIND_MODEL_MAIN_INFO_SUCCESS(HttpStatus.OK, "모델 메인 뷰 조회 성공"), | ||
SOCIAL_LOGIN_SUCCESS(HttpStatus.OK, "카카오 로그인 성공입니다."), | ||
USER_MY_PAGE_SUCCESS(HttpStatus.OK, "마이페이지 유저 정보 조회 성공입니다."); | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. p4: |
||
private final HttpStatus httpStatus; | ||
private final String message; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.moddy.server.controller.auth.dto.request; | ||
|
||
public record SocialLoginRequest( | ||
String code | ||
) { | ||
public static SocialLoginRequest of(String code) { | ||
return new SocialLoginRequest(code); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.moddy.server.controller.designer; | ||
|
||
|
||
import com.moddy.server.common.dto.ErrorResponse; | ||
import com.moddy.server.common.dto.SuccessResponse; | ||
import com.moddy.server.common.exception.enums.SuccessCode; | ||
import com.moddy.server.config.resolver.kakao.KakaoCode; | ||
import com.moddy.server.controller.designer.dto.request.DesignerCreateRequest; | ||
import com.moddy.server.controller.designer.dto.response.DesignerCreateResponse; | ||
import com.moddy.server.service.DesignerService; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.media.Content; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
import io.swagger.v3.oas.annotations.security.SecurityRequirement; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
|
||
@RestController | ||
@RequestMapping("/auth/signup/") | ||
@Tag(name = "ModelController") | ||
@RequiredArgsConstructor | ||
public class DesignerController { | ||
|
||
private final DesignerService designerService; | ||
|
||
@Operation(summary = "[KAKAO CODE] 디자이너 회원가입 뷰 조회", description = "디자이너 회원가입 뷰 조회 API입니다.") | ||
@ApiResponses({ | ||
@ApiResponse(responseCode = "200", description = "디자이너 회원가입 성공", content = @Content(schema = @Schema(implementation = DesignerCreateResponse.class))), | ||
@ApiResponse(responseCode = "500", description = "서버 내부 오류 입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), | ||
}) | ||
@SecurityRequirement(name = "JWT Auth") | ||
@PostMapping(value = "/designer", consumes = {MediaType.APPLICATION_JSON_VALUE, MediaType.MULTIPART_FORM_DATA_VALUE}) | ||
SuccessResponse<DesignerCreateResponse> createDesigner(@Parameter(hidden = true) @KakaoCode String kakaoCode, @ModelAttribute DesignerCreateRequest request) { | ||
System.out.println(request); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. p1 |
||
return SuccessResponse.success(SuccessCode.DESIGNER_CREATE_SUCCESS, designerService.createDesigner(kakaoCode, request)); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.moddy.server.controller.designer.dto.request; | ||
|
||
import com.moddy.server.domain.day_off.DayOfWeek; | ||
import com.moddy.server.domain.designer.HairShop; | ||
import com.moddy.server.domain.designer.Portfolio; | ||
import com.moddy.server.domain.user.Gender; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
import java.util.List; | ||
|
||
@Schema | ||
public record DesignerCreateRequest( | ||
MultipartFile profileImg, | ||
String name, | ||
Gender gender, | ||
String phoneNumber, | ||
Boolean isMarketingAgree, | ||
String hairShopName, | ||
String hairShopAddress, | ||
String hairShopAddressDetail, | ||
|
||
String instagramUrl, | ||
String naverPlaceUrl, | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. p2 |
||
String introduction, | ||
String kakaoOpenChatUrl, | ||
List<DayOfWeek> dayOffs | ||
|
||
) { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.moddy.server.controller.designer.dto.response; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
@Schema(description = "디자이너 회원가입 뷰 Response DTO") | ||
public record DesignerCreateResponse( | ||
String accessToken, | ||
String refreshToken | ||
) { | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,25 @@ | ||
package com.moddy.server.domain.day_off; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.moddy.server.common.exception.enums.ErrorCode; | ||
import com.moddy.server.common.exception.model.BadRequestException; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
import java.util.stream.Stream; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum DayOfWeek { | ||
NOTHING("없음"), MON("월"), TUE("화"), WED("수"), THU("목"), FRI("금"), SAT("토"), SUN("일"); | ||
|
||
private final String value; | ||
|
||
@JsonCreator(mode = JsonCreator.Mode.DELEGATING) | ||
public static DayOfWeek findByDay(String dayOfWeek) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. p4 |
||
return Stream.of(DayOfWeek.values()) | ||
.filter(c -> c.getValue().equals(dayOfWeek)) | ||
.findFirst() | ||
.orElseThrow(() -> new BadRequestException(ErrorCode.INVALID_DAY_OF_WEEK_EXCEPTION)); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
package com.moddy.server.domain.day_off; | ||
|
||
import com.moddy.server.domain.BaseTimeEntity; | ||
import com.moddy.server.domain.user.User; | ||
import com.moddy.server.domain.designer.Designer; | ||
import jakarta.persistence.*; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.*; | ||
|
||
@Getter | ||
@Builder | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Entity | ||
public class DayOff extends BaseTimeEntity { | ||
public class DayOff{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. p1 |
||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
|
@@ -15,10 +19,11 @@ public class DayOff extends BaseTimeEntity { | |
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "user_id") | ||
@NotNull | ||
private User user; | ||
private Designer designer; | ||
|
||
@Enumerated(EnumType.STRING) | ||
@NotNull | ||
private DayOfWeek dayOfWeek; | ||
|
||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.moddy.server.domain.day_off.repository; | ||
|
||
import com.moddy.server.domain.day_off.DayOff; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface DayOffJpaRepository extends JpaRepository<DayOff, Long> { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.moddy.server.domain.designer.repository; | ||
|
||
import com.moddy.server.domain.designer.Designer; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface DesignerJpaRepository extends JpaRepository<Designer, Long> { | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,24 @@ | ||
package com.moddy.server.domain.user; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.moddy.server.common.exception.enums.ErrorCode; | ||
import com.moddy.server.common.exception.model.BadRequestException; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
import java.util.stream.Stream; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum Gender { | ||
MALE("남성"), FEMALE("여성"); | ||
private final String value; | ||
|
||
@JsonCreator(mode = JsonCreator.Mode.DELEGATING) | ||
public static Gender findByGender(String gender) { | ||
return Stream.of(Gender.values()) | ||
.filter(c -> c.getValue().equals(gender)) | ||
.findFirst() | ||
.orElseThrow(() -> new BadRequestException(ErrorCode.INVALID_DAY_OF_WEEK_EXCEPTION)); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. p2 |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,19 @@ | ||
package com.moddy.server.domain.user; | ||
|
||
import com.moddy.server.domain.BaseTimeEntity; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.EnumType; | ||
import jakarta.persistence.Enumerated; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.Inheritance; | ||
import jakarta.persistence.InheritanceType; | ||
import jakarta.persistence.*; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.*; | ||
|
||
import lombok.Getter; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
@Entity | ||
@Inheritance(strategy = InheritanceType.JOINED) | ||
@Getter | ||
@SuperBuilder | ||
@Inheritance(strategy = InheritanceType.JOINED) | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class User extends BaseTimeEntity { | ||
|
||
@Id | ||
|
@@ -35,7 +34,7 @@ public class User extends BaseTimeEntity { | |
private String phoneNumber; | ||
|
||
@NotNull | ||
private String isMarketingAgree; | ||
private Boolean isMarketingAgree; | ||
|
||
@NotNull | ||
private String profileImgUrl; | ||
|
@@ -44,4 +43,14 @@ public class User extends BaseTimeEntity { | |
@Enumerated(EnumType.STRING) | ||
private Role role; | ||
|
||
public User(String kakaoId, String name, Gender gender, String phoneNumber, Boolean isMarketingAgree, String profileImgUrl ) { | ||
this.kakaoId = kakaoId; | ||
this.name = name; | ||
this.gender = gender; | ||
this.phoneNumber = phoneNumber; | ||
this.isMarketingAgree = isMarketingAgree; | ||
this.profileImgUrl = profileImgUrl; | ||
this.role = role; | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. p2 |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p2
해당 에러는 클라이언트가 속성 값을 잘못 입력했을 때 생기는 에러이기 때문에
BAD_REQUEST , 400 에러인 것 같습니다!
+) 제가 전에 404라고 한 것 같은데, 400이 맞는 것 같습니다 하하..