Skip to content
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

Merged
merged 18 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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, "성별을 찾을 수 없습니다"),
Copy link
Member

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이 맞는 것 같습니다 하하..


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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p4 :
위의 에러코드들 처럼 ErrorCode 주석 아래 공백 지우면 좋을것 같아요!

METHOD_NOT_ALLOWED_EXCEPTION(HttpStatus.METHOD_NOT_ALLOWED, "지원하지 않는 메소드 입니다."),

// 500
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
@AllArgsConstructor
public enum SuccessCode {


Copy link
Member

Choose a reason for hiding this comment

The 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, "마이페이지 유저 정보 조회 성공입니다.");


Copy link
Member

Choose a reason for hiding this comment

The 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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p1
println은 지워주세요!

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,

Copy link
Member

Choose a reason for hiding this comment

The 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
) {

}
6 changes: 6 additions & 0 deletions src/main/java/com/moddy/server/domain/BaseTimeEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@

import jakarta.persistence.EntityListeners;
import jakarta.persistence.MappedSuperclass;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.time.LocalDateTime;

@SuperBuilder
@MappedSuperclass
@NoArgsConstructor
@AllArgsConstructor
@EntityListeners(AuditingEntityListener.class)
public abstract class BaseTimeEntity {

Expand Down
13 changes: 13 additions & 0 deletions src/main/java/com/moddy/server/domain/day_off/DayOfWeek.java
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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p4
findByDayOfWeek는 어떨까요..?

return Stream.of(DayOfWeek.values())
.filter(c -> c.getValue().equals(dayOfWeek))
.findFirst()
.orElseThrow(() -> new BadRequestException(ErrorCode.INVALID_DAY_OF_WEEK_EXCEPTION));
}
}
13 changes: 9 additions & 4 deletions src/main/java/com/moddy/server/domain/day_off/DayOff.java
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{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p1
base entity 를 제거하면 안됩니다..!


@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand All @@ -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> {
}
10 changes: 10 additions & 0 deletions src/main/java/com/moddy/server/domain/designer/Designer.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@
import jakarta.persistence.Embedded;
import jakarta.persistence.Entity;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;


@Entity
@Getter
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
public class Designer extends User {

@Embedded
Expand All @@ -22,4 +30,6 @@ public class Designer extends User {
@NotNull
private String kakaoOpenChatUrl;



}
14 changes: 10 additions & 4 deletions src/main/java/com/moddy/server/domain/designer/HairShop.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,26 @@
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;
import lombok.*;

@Embeddable
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Getter
@ToString
public class HairShop {
@NotNull

@Column(name = "hair_shop_name")
@NotNull
private String name;

@NotNull

@Column(name = "hair_shop_address")
@NotNull
private String address;

@NotNull
@Column(name = "hair_shop_detail_address")
@NotNull
private String detailAddress;
}
6 changes: 6 additions & 0 deletions src/main/java/com/moddy/server/domain/designer/Portfolio.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@

import jakarta.persistence.Embeddable;
import jakarta.validation.constraints.NotNull;
import lombok.*;

@Embeddable
@AllArgsConstructor
@NoArgsConstructor
@Getter
@Builder
@ToString
public class Portfolio {
@NotNull
private String instagramUrl;
Expand Down
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> {

}
13 changes: 13 additions & 0 deletions src/main/java/com/moddy/server/domain/user/Gender.java
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));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p2
DAY_OF_WEEK_EXCEPTION이 아닌 INVALID_GENDER_EXCEPTION인 것 같습니다!

}
29 changes: 19 additions & 10 deletions src/main/java/com/moddy/server/domain/user/User.java
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
Expand All @@ -35,7 +34,7 @@ public class User extends BaseTimeEntity {
private String phoneNumber;

@NotNull
private String isMarketingAgree;
private Boolean isMarketingAgree;

@NotNull
private String profileImgUrl;
Expand All @@ -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;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p2
사용하지 않은 생성자인 듯 합니다! 제거해주세요!

}
Loading