Skip to content

Commit

Permalink
Merge pull request #276 from TEAM-MODDY/feat/#273
Browse files Browse the repository at this point in the history
#273 [feat] 마이페이지 수정을 위한 모델/디자이너 정보 조회
  • Loading branch information
hellozo0 authored Apr 21, 2024
2 parents 924e5c0 + 800f59c commit 085f88e
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public enum SuccessCode {
GET_PRE_SIGNED_URL_SUCCESS(HttpStatus.OK, "제안서 다운로드 url 생성 성공"),
GET_APPLICATION_IMG_URL_SUCCESS(HttpStatus.OK, "지원서 이미지 url 가져오기 성공"),
CHECK_VALID_APPLICATION_SUCCESS(HttpStatus.OK, "유효한 지원서 입니다."),
APPLICATION_DELETE_SUCCESS(HttpStatus.OK, "지원서 삭제하기 성공");
APPLICATION_DELETE_SUCCESS(HttpStatus.OK, "지원서 삭제하기 성공"),
FIND_DESIGNER_INFO_SUCCESS(HttpStatus.OK, "디자이너 정보 조회 성공"),
FIND_MODEL_INFO_SUCCESS(HttpStatus.OK, "모델 정보 조회 성공");

private final HttpStatus httpStatus;
private final String message;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.moddy.server.common.dto.SuccessResponse;
import com.moddy.server.common.exception.enums.SuccessCode;
import com.moddy.server.config.resolver.user.UserId;
import com.moddy.server.controller.designer.dto.response.DesignerMyPageResponse;
import com.moddy.server.controller.model.dto.DesignerInfoOpenChatDto;
import com.moddy.server.service.designer.DesignerRetrieveService;
import io.swagger.v3.oas.annotations.Operation;
Expand Down Expand Up @@ -41,4 +42,19 @@ public SuccessResponse<DesignerInfoOpenChatDto> getDesignerOpenChatInfo(
@Parameter(name = "designerId", description = "디자이너아이디") @PathVariable(value = "designerId") Long designerId) {
return SuccessResponse.success(SuccessCode.OPEN_CHAT_GET_SUCCESS, designerRetrieveService.getDesignerOpenChatInfo(designerId));
}

@Operation(summary = "[JWT] 마이페이지 디자이너 정보 조회", description = "마이페이지 수정시 디자이너 정보 조회입니다")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "디자이너 정보 조회 성공", content = @Content(schema = @Schema(implementation = DesignerMyPageResponse.class))),
@ApiResponse(responseCode = "401", description = "인증 오류 입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "500", description = "서버 내부 오류 입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
})
@GetMapping()
@SecurityRequirement(name = "JWT Auth")
public SuccessResponse<DesignerMyPageResponse> getDesignerInfo(
@Parameter(hidden = true) @UserId Long designerId){
return SuccessResponse.success(SuccessCode.FIND_DESIGNER_INFO_SUCCESS, designerRetrieveService.getDesignerInfo(designerId));
}


}
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.moddy.server.controller.designer.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;
import lombok.*;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.moddy.server.controller.designer.dto.response;

import com.moddy.server.domain.designer.HairShop;
import com.moddy.server.domain.designer.Portfolio;

import java.util.List;

public record DesignerMyPageResponse(
String profileImgUrl,
String introduction,
String name,
String gender,
String phoneNumber,
HairShop hairShop,
List<String> dayOffs,
Portfolio portfolio,
String kakaoOpenChatUrl
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.moddy.server.config.resolver.user.UserId;
import com.moddy.server.controller.auth.dto.response.RegionResponse;
import com.moddy.server.controller.model.dto.response.ApplicationUserDetailResponse;
import com.moddy.server.controller.model.dto.response.ModelMyPageResponse;
import com.moddy.server.service.model.ModelRetrieveService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
Expand Down Expand Up @@ -52,4 +53,17 @@ public SuccessResponse<List<RegionResponse>> getRegionList() {
public SuccessResponse<ApplicationUserDetailResponse> getUserDetailInApplication(@Parameter(hidden = true) @UserId final Long modelId) {
return SuccessResponse.success(SuccessCode.CREATE_MODEL_APPLICATION_SUCCESS, modelRetrieveService.getModelDetailInApplication(modelId));
}

@Operation(summary = "[JWT] 마이페이지 모델 정보 조회", description = "마이페이지 수정시 모델 정보 조회입니다")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "모델 정보 조회 성공", content = @Content(schema = @Schema(implementation = ModelMyPageResponse.class))),
@ApiResponse(responseCode = "401", description = "인증 오류 입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "500", description = "서버 내부 오류 입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
})
@GetMapping()
@SecurityRequirement(name = "JWT Auth")
public SuccessResponse<ModelMyPageResponse> getDesignerInfo(
@Parameter(hidden = true) @UserId Long modelId) {
return SuccessResponse.success(SuccessCode.FIND_MODEL_INFO_SUCCESS, modelRetrieveService.getModelInfo(modelId));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.moddy.server.controller.model.dto.response;

import java.util.List;

public record ModelMyPageResponse(
String name,
String year,
String gender,
String phoneNumber,
List<String> preferRegions
) {
}
4 changes: 4 additions & 0 deletions src/main/java/com/moddy/server/domain/user/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,8 @@ public void update(String name, Gender gender, String phoneNumber, Boolean isMar
this.profileImgUrl = profileImgUrl;
this.role = role;
}

public String getSlashedPhoneNumber(String phoneNumber){
return phoneNumber.substring(0, 3) + "-" + phoneNumber.substring(3, 7) + "-" + phoneNumber.substring(7);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.moddy.server.common.exception.enums.ErrorCode;
import com.moddy.server.common.exception.model.NotFoundException;
import com.moddy.server.controller.designer.dto.response.DesignerMyPageResponse;
import com.moddy.server.controller.model.dto.DesignerInfoOpenChatDto;
import com.moddy.server.controller.model.dto.response.DesignerInfoResponse;
import com.moddy.server.domain.day_off.DayOff;
Expand All @@ -28,6 +29,14 @@ public String getDesignerName(final Long designerId) {
return designer.getName();
}

public DesignerMyPageResponse getDesignerInfo(final Long designerId) {
Designer designer = designerJpaRepository.findById(designerId).orElseThrow(() -> new NotFoundException(ErrorCode.DESIGNER_NOT_FOUND_EXCEPTION));
List<String> dayOfWeekList = getDayOfWeekList(designerId);

DesignerMyPageResponse designerMyPageResponse = new DesignerMyPageResponse(designer.getProfileImgUrl(), designer.getIntroduction(),designer.getName(), designer.getGender().getValue(), designer.getSlashedPhoneNumber(designer.getPhoneNumber()), designer.getHairShop(), dayOfWeekList, designer.getPortfolio(), designer.getKakaoOpenChatUrl());
return designerMyPageResponse;
}

public DesignerInfoOpenChatDto getDesignerOpenChatInfo(final Long designerId) {
Designer designer = designerJpaRepository.findById(designerId).orElseThrow(() -> new NotFoundException(ErrorCode.DESIGNER_NOT_FOUND_EXCEPTION));
return new DesignerInfoOpenChatDto(designer.getKakaoOpenChatUrl(), designer.getProfileImgUrl(), designer.getHairShop().getName(), designer.getName(), designer.getIntroduction());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.moddy.server.controller.auth.dto.response.RegionResponse;
import com.moddy.server.controller.model.dto.ApplicationModelInfoDto;
import com.moddy.server.controller.model.dto.response.ApplicationUserDetailResponse;
import com.moddy.server.controller.model.dto.response.ModelMyPageResponse;
import com.moddy.server.domain.model.Model;
import com.moddy.server.domain.model.repository.ModelJpaRepository;
import com.moddy.server.domain.prefer_region.PreferRegion;
Expand All @@ -27,13 +28,7 @@ public class ModelRetrieveService {

public ApplicationModelInfoDto getApplicationModelInfo(final Long modelId) {
Model model = modelJpaRepository.findById(modelId).orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_MODEL_INFO));

List<PreferRegion> preferRegions = preferRegionJpaRepository.findAllByModelId(modelId);

List<String> regionList = preferRegions.stream().map(preferregion -> {
return preferregion.getRegion().getName();
}).collect(Collectors.toList());
return new ApplicationModelInfoDto(modelId, model.getName(), model.getAge(), model.getGender().getValue(), regionList);
return new ApplicationModelInfoDto(modelId, model.getName(), model.getAge(), model.getGender().getValue(), getPreferRegionsList(modelId));
}

public List<RegionResponse> getRegionList() {
Expand All @@ -50,6 +45,12 @@ public String getModelName(final Long modelId) {
return model.getName();
}

public ModelMyPageResponse getModelInfo(final Long modelId) {
Model model = modelJpaRepository.findById(modelId).orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_MODEL_INFO));
ModelMyPageResponse modelMyPageResponse = new ModelMyPageResponse(model.getName(), model.getYear(), model.getGender().getValue(), model.getSlashedPhoneNumber(model.getPhoneNumber()), getPreferRegionsList(modelId));
return modelMyPageResponse;
}

public ApplicationUserDetailResponse getModelDetailInApplication(final Long modelId) {
final Model model = modelJpaRepository.findById(modelId).orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_MODEL_INFO));
final List<String> preferRegions = preferRegionJpaRepository.findAllByModelId(model.getId())
Expand All @@ -59,4 +60,12 @@ public ApplicationUserDetailResponse getModelDetailInApplication(final Long mode

return new ApplicationUserDetailResponse(model.getName(), model.getGender().getValue(), model.getAge(), preferRegions);
}

private List<String> getPreferRegionsList(final Long modelId){
List<PreferRegion> preferRegions = preferRegionJpaRepository.findAllByModelId(modelId);
List<String> regionList = preferRegions.stream().map(preferregion -> {
return preferregion.getRegion().getName();
}).collect(Collectors.toList());
return regionList;
}
}

0 comments on commit 085f88e

Please sign in to comment.