diff --git a/server/src/main/java/org/tattour/server/domain/admin/controller/AdminController.java b/server/src/main/java/org/tattour/server/domain/admin/controller/AdminController.java index e97ebba3..e201575b 100644 --- a/server/src/main/java/org/tattour/server/domain/admin/controller/AdminController.java +++ b/server/src/main/java/org/tattour/server/domain/admin/controller/AdminController.java @@ -9,7 +9,6 @@ import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; import java.util.List; -import java.util.Objects; import javax.servlet.http.HttpServletRequest; import javax.validation.Valid; import lombok.RequiredArgsConstructor; @@ -27,8 +26,6 @@ import org.springframework.web.multipart.MultipartFile; import org.tattour.server.domain.admin.controller.dto.request.AdminLoginReq; import org.tattour.server.domain.admin.controller.dto.request.ApplyStickerDiscountReq; -import org.tattour.server.domain.admin.controller.dto.request.CancelPointChargeRequestReq; -import org.tattour.server.domain.admin.controller.dto.request.ConfirmPointChargeRequestReq; import org.tattour.server.domain.admin.controller.dto.request.PatchCustomProcessReq; import org.tattour.server.domain.admin.controller.dto.request.PostDiscountReq; import org.tattour.server.domain.admin.controller.dto.request.PostStickerReq; @@ -41,17 +38,9 @@ import org.tattour.server.domain.order.controller.dto.request.PatchOrderStatusReq; import org.tattour.server.domain.order.facade.OrderFacade; import org.tattour.server.domain.order.facade.dto.request.UpdateOrderStatusReq; -import org.tattour.server.domain.point.domain.PointLogCategory; -import org.tattour.server.domain.point.facade.PointFacade; -import org.tattour.server.domain.point.facade.dto.request.ConfirmPointChargeReq; -import org.tattour.server.domain.point.facade.dto.request.ReadPointChargeRequestListReq; -import org.tattour.server.domain.point.facade.dto.request.ReadPointLogListReq; -import org.tattour.server.domain.point.facade.dto.response.ConfirmPointChargeRes; -import org.tattour.server.domain.point.facade.dto.response.ReadPointChargeRequestListRes; -import org.tattour.server.domain.point.facade.dto.response.ReadPointLogListRes; +import org.tattour.server.domain.order.facade.dto.response.ReadOrderHistoryListRes; import org.tattour.server.domain.sticker.facade.StickerFacade; import org.tattour.server.domain.sticker.facade.dto.response.ReadStickerRes; -import org.tattour.server.domain.user.controller.dto.response.PostLoginRes; import org.tattour.server.global.config.annotations.UserId; import org.tattour.server.global.dto.BaseResponse; import org.tattour.server.global.dto.FailResponse; @@ -66,7 +55,6 @@ public class AdminController { private final AdminFacade adminFacade; - private final PointFacade pointFacade; private final OrderFacade orderFacade; private final DiscountFacade discountFacade; private final StickerFacade stickerFacade; @@ -97,7 +85,7 @@ public ResponseEntity adminLogin( @ApiResponse( responseCode = "200", description = "조회에 성공했습니다.", - content = @Content(schema = @Schema(implementation = PostLoginRes.class))), + content = @Content(schema = @Schema(implementation = ReadOrderHistoryListRes.class))), @ApiResponse( responseCode = "400", description = "잘못된 요청입니다.", @@ -151,149 +139,7 @@ public ResponseEntity patchOrderStatus( return BaseResponse.success(SuccessType.UPDATE_ORDER_STATUS_SUCCESS); } - - @Operation(summary = "포인트 충전 신청 내역 불러오기", description = "userId, 완료 여부를 기준으로 포인트 신청 내역 조회") - @ApiResponses(value = { - @ApiResponse( - responseCode = "200", - description = "조회에 성공했습니다.", - content = @Content(schema = @Schema(implementation = ReadPointChargeRequestListRes.class))), - @ApiResponse( - responseCode = "400", - description = "잘못된 요청입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "500", - description = "알 수 없는 서버 에러가 발생했습니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))) - }) - @GetMapping("/point/request") - public ResponseEntity getPointChargeRequest( - @Parameter(description = "user Id") @RequestParam(required = false) Integer userId, - @Parameter(description = "처리 완료 여부") @RequestParam(required = false) Boolean isCompleted - ) { - return BaseResponse.success(SuccessType.GET_SUCCESS, - pointFacade.readPointChargeRequest( - ReadPointChargeRequestListReq.of( - userId, - isCompleted))); - } - - @Operation(summary = "포인트 충전 요청 확인") - @ApiResponses(value = { - @ApiResponse( - responseCode = "201", - description = "포인트 충전 확정에 성공했습니다.", - content = @Content(schema = @Schema(implementation = SuccessResponse.class))), - @ApiResponse( - responseCode = "202", - description = "금액이 일치하지 않아 충전 확정이 불가능합니다.", - content = @Content(schema = @Schema(implementation = ConfirmPointChargeRes.class))), - @ApiResponse( - responseCode = "400", - description = "잘못된 요청입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "404", - description = "존재하지 않는 포인트 충전 요청입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "404", - description = "존재하지 않는 유저입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "409", - description = "이미 처리된 포인트 충전 요청입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "500", - description = "알 수 없는 서버 에러가 발생했습니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))) - }) - @PostMapping("/point/request/confirm") - public ResponseEntity confirmPointChargeRequest( - @RequestBody @Valid ConfirmPointChargeRequestReq req - ) { - ConfirmPointChargeRes response = pointFacade.confirmPointChargeRequest( - ConfirmPointChargeReq.of( - req.getId(), - req.getUserId(), - req.getTransferredAmount())); - - if (Objects.isNull(response)) { - return BaseResponse.success(SuccessType.POINT_CHARGE_CONFIRM_SUCCESS); - } else { - return BaseResponse.success(SuccessType.POINT_CHARGE_CONFIRM_FAIL, response); - } - } - - @Operation(summary = "포인트 충전 요청 취소") - @ApiResponses(value = { - @ApiResponse( - responseCode = "200", - description = "포인트 충전 취소에 성공했습니다.", - content = @Content(schema = @Schema(implementation = SuccessResponse.class))), - @ApiResponse( - responseCode = "400", - description = "잘못된 요청입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "404", - description = "존재하지 않는 유저입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "404", - description = "존재하지 않는 포인트 충전 요청입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "409", - description = "이미 처리된 포인트 충전 요청입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "409", - description = "송금 금액과 충전 금액이 일치합니다. 충전 요청을 취소할 수 없습니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "500", - description = "알 수 없는 서버 에러가 발생했습니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))) - }) - @PostMapping("/point/request/cancel") - public ResponseEntity cancelPointChargeRequest( - @RequestBody @Valid CancelPointChargeRequestReq req - ) { - pointFacade.cancelPointChargeRequest(req); - return BaseResponse.success(SuccessType.POINT_CHARGE_CANCEL_SUCCESS); - } - - @Operation(summary = "포인트 로그 불러오기") - @ApiResponses(value = { - @ApiResponse( - responseCode = "200", - description = "포인트 로그 조회에 성공했습니다.", - content = @Content(schema = @Schema(implementation = ReadPointLogListRes.class))), - @ApiResponse( - responseCode = "400", - description = "잘못된 요청입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "500", - description = "알 수 없는 서버 에러가 발생했습니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))) - }) - @GetMapping("/pointlog") - public ResponseEntity getPointLog( - @Parameter(description = "user id") @RequestParam(required = false) Integer userId, - @Parameter(description = "포인트 로그 카테고리", example = "충전 취소") - @RequestParam(required = false) String category - ) { - return BaseResponse.success( - SuccessType.READ_POINT_LOG_SUCCESS, pointFacade.readPointLog( - ReadPointLogListReq.of( - userId, - PointLogCategory.fromValue(category)))); - } - + @PostMapping(value = "/stickers", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) @Operation(summary = "스티커 등록") @ApiResponses(value = { diff --git a/server/src/main/java/org/tattour/server/domain/custom/controller/CustomController.java b/server/src/main/java/org/tattour/server/domain/custom/controller/CustomController.java index 3f3a9f0b..30ba5b72 100644 --- a/server/src/main/java/org/tattour/server/domain/custom/controller/CustomController.java +++ b/server/src/main/java/org/tattour/server/domain/custom/controller/CustomController.java @@ -21,8 +21,8 @@ import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; -import org.tattour.server.domain.custom.controller.dto.request.PostCustomReq; import org.tattour.server.domain.custom.controller.dto.request.PatchCustomReq; +import org.tattour.server.domain.custom.controller.dto.request.PostCustomReq; import org.tattour.server.domain.custom.controller.dto.response.PatchCustomRes; import org.tattour.server.domain.custom.controller.dto.response.PostCustomRes; import org.tattour.server.domain.custom.facade.CustomFacade; @@ -39,49 +39,48 @@ @Tag(name = "Custom", description = "Custom API Document") public class CustomController { - private final CustomFacade customFacade; + private final CustomFacade customFacade; + + @PostMapping(value = "/apply") + @Operation(summary = "커스텀 도안 신청") + @ApiResponses(value = { + @ApiResponse(responseCode = "201", description = "success", + content = @Content(schema = @Schema(implementation = PostCustomRes.class))), + @ApiResponse(responseCode = "400, 500", description = "error", + content = @Content(schema = @Schema(implementation = FailResponse.class))) + }) + public ResponseEntity postCustom( + @Parameter(hidden = true) @UserId Integer userId, + @RequestBody @Valid PostCustomReq request + ) { + PostCustomRes response = PostCustomRes.from( + (customFacade.createCustom(request.getHaveDesign(), userId))); + return BaseResponse.success(SuccessType.CREATE_CUSTOM_SUCCESS, response); + } - @PostMapping(value = "/apply") - @Operation(summary = "커스텀 도안 신청") - @ApiResponses(value = { - @ApiResponse(responseCode = "201", description = "success", - content = @Content(schema = @Schema(implementation = PostCustomRes.class))), - @ApiResponse(responseCode = "400, 500", description = "error", - content = @Content(schema = @Schema(implementation = FailResponse.class))) - }) - public ResponseEntity postCustom( - @Parameter(hidden = true) @UserId Integer userId, - @RequestBody @Valid PostCustomReq request - ) { - PostCustomRes response = PostCustomRes.from( - (customFacade.createCustom(request.getHaveDesign(), userId))); - return BaseResponse.success(SuccessType.CREATE_CUSTOM_SUCCESS, response); - } + // todo: 클라이언트에서 customInfo의 content-type을 application/json으로 설정해줘야함 + @PatchMapping(value = "/update", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) + @Operation(summary = "커스텀 도안 수정", description = "customInfo ContentType: application/json" + + " / customId 를 제외한 모든 컬럼 null 값 가능" + + " / size : " + + " / 테마, 스타일 타입은 Integer") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "success", + content = @Content(schema = @Schema(implementation = PatchCustomRes.class))), + @ApiResponse(responseCode = "400, 500", description = "error", + content = @Content(schema = @Schema(implementation = FailResponse.class))) + }) + public ResponseEntity patchCustom( + @Parameter(hidden = true) @UserId Integer userId, + @RequestPart @Valid PatchCustomReq customInfo, + @RequestPart(required = false) MultipartFile handDrawingImage, + @RequestPart(required = false) List customImages + ) { + PatchCustomRes response = + PatchCustomRes.from( + customFacade.updateCustom( + customInfo.newUpdateCustomReq(userId, customImages, handDrawingImage))); - @PatchMapping(value = "/update", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - @Operation(summary = "커스텀 도안 수정", description = "customInfo ContentType: application/json" - + " / customId 를 제외한 모든 컬럼 null 값 가능" - + " / size : " - + " / 테마, 스타일 타입은 Integer") - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "success", - content = @Content(schema = @Schema(implementation = PatchCustomRes.class))), - @ApiResponse(responseCode = "400, 500", description = "error", - content = @Content(schema = @Schema(implementation = FailResponse.class))) - }) - public ResponseEntity patchCustom( - @Parameter(hidden = true) @UserId Integer userId, - @RequestPart @Valid PatchCustomReq customInfo, - @RequestPart(required = false) MultipartFile handDrawingImage, - @RequestPart(required = false) List customImages - ) { - PatchCustomRes response = - PatchCustomRes.from( - customFacade.updateCustom( - customInfo.newUpdateCustomReq( - userId, - customImages, - handDrawingImage))); - return BaseResponse.success(SuccessType.UPDATE_CUSTOM_SUCCESS, response); - } + return BaseResponse.success(SuccessType.UPDATE_CUSTOM_SUCCESS, response); + } } \ No newline at end of file diff --git a/server/src/main/java/org/tattour/server/domain/custom/domain/Custom.java b/server/src/main/java/org/tattour/server/domain/custom/domain/Custom.java index 45474278..1924e423 100644 --- a/server/src/main/java/org/tattour/server/domain/custom/domain/Custom.java +++ b/server/src/main/java/org/tattour/server/domain/custom/domain/Custom.java @@ -162,7 +162,7 @@ public void setCustomProcess(CustomProcess process) { } public Integer calPrice() { - Integer price = size.getPrice() * count; + int price = size.getPrice() * count; if (isPublic) { price -= size.getDiscountPrice(); } diff --git a/server/src/main/java/org/tattour/server/domain/custom/facade/dto/response/ReadCustomRes.java b/server/src/main/java/org/tattour/server/domain/custom/facade/dto/response/ReadCustomRes.java index ebc5fd4d..f6a5fbce 100644 --- a/server/src/main/java/org/tattour/server/domain/custom/facade/dto/response/ReadCustomRes.java +++ b/server/src/main/java/org/tattour/server/domain/custom/facade/dto/response/ReadCustomRes.java @@ -7,104 +7,95 @@ import lombok.Builder; import lombok.Getter; import org.tattour.server.domain.custom.domain.Custom; +import org.tattour.server.domain.custom.domain.CustomImage; @Getter @Builder(access = AccessLevel.PRIVATE) public class ReadCustomRes { - private Integer id; - private Integer userId; - private Integer stickerId; - private List themes; - private List styles; - private String mainImageUrl; - private String handDrawingImageUrl; - private List images; - private Boolean haveDesign; - private String size; - private String name; - private String description; - private String demand; - private Integer count; - private Boolean isColored; - private Boolean isPublic; - private Boolean isCompleted; - private Integer price; - private String process; - private Integer viewCount; + private Integer id; + private Integer userId; + private Integer stickerId; + private List themes; + private List styles; + private String mainImageUrl; + private String handDrawingImageUrl; + private List images; + private Boolean haveDesign; + private String size; + private String name; + private String description; + private String demand; + private Integer count; + private Boolean isColored; + private Boolean isPublic; + private Boolean isCompleted; + private Integer price; + private String process; + private Integer viewCount; - public static ReadCustomRes from(Custom custom) { - List themes = getThemeNameList(custom); - List styles = getStyleList(custom); - List images = getImageList(custom); - return ReadCustomRes.builder() - .id(custom.getId()) - .userId(custom.getUser().getId()) - .themes(themes) - .styles(styles) - .mainImageUrl(custom.getMainImageUrl()) - .images(images) - .handDrawingImageUrl(custom.getHandDrawingImageUrl()) - .haveDesign(custom.getHaveDesign()) - .size(getSizeString(custom)) - .name(custom.getName()) - .description(custom.getDescription()) - .demand(custom.getDemand()) - .count(custom.getCount()) - .isColored(custom.getIsColored()) - .isPublic(custom.getIsPublic()) - .isCompleted(custom.getIsCompleted()) - .price(custom.getPrice()) - .process(getProcessString(custom)) - .viewCount(custom.getViewCount()) - .build(); - } - // Todo : 주석 지우기 + public static ReadCustomRes from(Custom custom) { + List themes = getThemeNameList(custom); + List styles = getStyleList(custom); + List images = getImageList(custom); + return ReadCustomRes.builder() + .id(custom.getId()) + .userId(custom.getUser().getId()) + .themes(themes) + .styles(styles) + .mainImageUrl(custom.getMainImageUrl()) + .images(images) + .handDrawingImageUrl(custom.getHandDrawingImageUrl()) + .haveDesign(custom.getHaveDesign()) + .size(getSizeString(custom)) + .name(custom.getName()) + .description(custom.getDescription()) + .demand(custom.getDemand()) + .count(custom.getCount()) + .isColored(custom.getIsColored()) + .isPublic(custom.getIsPublic()) + .isCompleted(custom.getIsCompleted()) + .price(custom.getPrice()) + .process(getProcessString(custom)) + .viewCount(custom.getViewCount()) + .build(); + } - private static List getImageList(Custom custom) { -// if (Objects.isNull(custom.getImages())) { -// return null; -// } - return custom - .getImages() - .stream() - .map(customImage -> customImage.getImageUrl()) - .collect(Collectors.toList()); - } + private static List getImageList(Custom custom) { + return custom + .getImages() + .stream() + .map(CustomImage::getImageUrl) + .collect(Collectors.toList()); + } - private static List getStyleList(Custom custom) { -// if (Objects.isNull(custom.getCustomStyles())) { -// return null; -// } - return custom - .getCustomStyles() - .stream() - .map(customStyle -> customStyle.getStyle().getName()) - .collect(Collectors.toList()); - } + private static List getStyleList(Custom custom) { + return custom + .getCustomStyles() + .stream() + .map(customStyle -> customStyle.getStyle().getName()) + .collect(Collectors.toList()); + } - private static List getThemeNameList(Custom custom) { -// if (Objects.isNull(custom.getCustomThemes())) { -// return null; -// } - return custom - .getCustomThemes() - .stream() - .map(customTheme -> customTheme.getTheme().getName()) - .collect(Collectors.toList()); - } + private static List getThemeNameList(Custom custom) { + return custom + .getCustomThemes() + .stream() + .map(customTheme -> customTheme.getTheme().getName()) + .collect(Collectors.toList()); + } - private static String getSizeString(Custom custom) { - if (Objects.isNull(custom.getSize())) { - return null; - } - return custom.getSize().getSize(); - } + private static String getSizeString(Custom custom) { + if (Objects.isNull(custom.getSize())) { + return null; + } + return custom.getSize().getSize(); + } - private static String getProcessString(Custom custom) { - if (Objects.isNull(custom.getProcess())) { - return null; - } - return custom.getProcess().getValue(); - } + private static String getProcessString(Custom custom) { + if (Objects.isNull(custom.getProcess())) { + return null; + } + return custom.getProcess().getValue(); + } } \ No newline at end of file diff --git a/server/src/main/java/org/tattour/server/domain/custom/facade/impl/CustomFacadeImpl.java b/server/src/main/java/org/tattour/server/domain/custom/facade/impl/CustomFacadeImpl.java index b7595940..55cc38d6 100644 --- a/server/src/main/java/org/tattour/server/domain/custom/facade/impl/CustomFacadeImpl.java +++ b/server/src/main/java/org/tattour/server/domain/custom/facade/impl/CustomFacadeImpl.java @@ -13,18 +13,13 @@ import org.tattour.server.domain.custom.facade.dto.request.UpdateCustomReq; import org.tattour.server.domain.custom.facade.dto.response.ReadCustomRes; import org.tattour.server.domain.custom.facade.dto.response.ReadCustomSummaryListRes; +import org.tattour.server.domain.custom.provider.impl.CustomProviderImpl; import org.tattour.server.domain.custom.service.CustomImageService; import org.tattour.server.domain.custom.service.CustomService; import org.tattour.server.domain.custom.service.CustomStyleService; import org.tattour.server.domain.custom.service.CustomThemeService; -import org.tattour.server.domain.point.domain.PointLogCategory; -import org.tattour.server.domain.point.domain.UserPointLog; -import org.tattour.server.domain.point.service.PointService; -import org.tattour.server.domain.custom.provider.impl.CustomProviderImpl; import org.tattour.server.domain.user.domain.User; import org.tattour.server.domain.user.service.UserService; -import org.tattour.server.global.exception.BusinessException; -import org.tattour.server.global.exception.ErrorType; import org.tattour.server.infra.discord.service.DiscordMessageService; import org.tattour.server.infra.s3.S3Service; @@ -33,124 +28,110 @@ @RequiredArgsConstructor public class CustomFacadeImpl implements CustomFacade { - private final CustomService customService; - private final CustomImageService customImageService; - private final CustomThemeService customThemeService; - private final CustomStyleService customStyleService; - private final UserService userService; - private final PointService pointService; - private final S3Service s3Service; - private final DiscordMessageService discordMessageService; - private final CustomProviderImpl customProvider; + private final CustomService customService; + private final CustomImageService customImageService; + private final CustomThemeService customThemeService; + private final CustomStyleService customStyleService; + private final UserService userService; + private final S3Service s3Service; + private final DiscordMessageService discordMessageService; + private final CustomProviderImpl customProvider; - private static final String directoryPath = "custom"; - private static final Integer customPoint = 990; + private static final String directoryPath = "custom"; - @Override - @Transactional - public Integer createCustom(Boolean haveDesign, Integer userId) { - User user = userService.readUserById(userId); - if (user.isLackOfPoint(customPoint)) { - throw new BusinessException(ErrorType.LACK_OF_POINT_EXCEPTION); - } - userService.updateUserPoint(user, -customPoint); - pointService.savePointLog( - UserPointLog.of( - PointLogCategory.APPLY_CUSTOM, - "커스텀 스티커 신청", - customPoint, - user.getPoint(), - user)); - Custom custom = customService.createInitCustom(user, haveDesign); - customService.save(custom); - return custom.getId(); - } + @Override + @Transactional + public Integer createCustom(Boolean haveDesign, Integer userId) { + User user = userService.readUserById(userId); + Custom custom = customService.createInitCustom(user, haveDesign); + customService.save(custom); + return custom.getId(); + } - @Override - public ReadCustomRes readCustomById(Integer customId, Integer userId) { - Custom custom = customProvider.getCustomById(customId, userId); - return ReadCustomRes.from(custom); - } + @Override + public ReadCustomRes readCustomById(Integer customId, Integer userId) { + Custom custom = customProvider.getCustomById(customId, userId); + return ReadCustomRes.from(custom); + } - @Override - @Transactional(readOnly = true) - public ReadCustomSummaryListRes readCustomSummaryCompleteListByUserId(Integer userId) { - List customs = customProvider.getAllByUserIdAndIsCompleted(userId); - return ReadCustomSummaryListRes.from(customs); - } + @Override + @Transactional(readOnly = true) + public ReadCustomSummaryListRes readCustomSummaryCompleteListByUserId(Integer userId) { + List customs = customProvider.getAllByUserIdAndIsCompleted(userId); + return ReadCustomSummaryListRes.from(customs); + } - @Override - @Transactional(readOnly = true) - public ReadCustomSummaryListRes readCustomSummaryInCompleteListByUserId(Integer userId) { - List customs = customProvider.getAllByUserIdAndIsCompletedFalse(userId); - return ReadCustomSummaryListRes.from(customs); - } + @Override + @Transactional(readOnly = true) + public ReadCustomSummaryListRes readCustomSummaryInCompleteListByUserId(Integer userId) { + List customs = customProvider.getAllByUserIdAndIsCompletedFalse(userId); + return ReadCustomSummaryListRes.from(customs); + } - @Override - @Transactional - public ReadCustomRes updateCustom(UpdateCustomReq updateCustomReq) { - Custom custom = customProvider.getCustomById( - updateCustomReq.getCustomId(), - updateCustomReq.getUserId()); - Custom updateCustom = updateCustomReq.newCustom(); + @Override + @Transactional + public ReadCustomRes updateCustom(UpdateCustomReq updateCustomReq) { + Custom custom = customProvider.getCustomById( + updateCustomReq.getCustomId(), + updateCustomReq.getUserId()); + Custom updateCustom = updateCustomReq.newCustom(); - // 손그림 등록 - if (!Objects.isNull(updateCustomReq.getHandDrawingImage())) { - customService.setHandDrawingImage( - updateCustom, - updateCustomReq.getHandDrawingImage()); - } + // 손그림 등록 + if (!Objects.isNull(updateCustomReq.getHandDrawingImage())) { + customService.setHandDrawingImage( + updateCustom, + updateCustomReq.getHandDrawingImage()); + } - // 이미지 리스트의 첫번째가 메인 이미지임 - if (!Objects.isNull(updateCustomReq.getImages())) { - if (updateCustomReq.getImages().size() > 0) { - customService.setMainImageUrl( - updateCustom, - updateCustomReq.getImages().get(0)); - updateCustomReq.getImages().remove(0); - } - } - customService.updateCustom(custom, updateCustom); + // 이미지 리스트의 첫번째가 메인 이미지임 + if (!Objects.isNull(updateCustomReq.getImages())) { + if (updateCustomReq.getImages().size() > 0) { + customService.setMainImageUrl( + updateCustom, + updateCustomReq.getImages().get(0)); + updateCustomReq.getImages().remove(0); + } + } + customService.updateCustom(custom, updateCustom); - // 이미지들 등록 - if (!Objects.isNull(updateCustomReq.getImages())) { - List customImages = - s3Service.uploadImageList( - updateCustomReq.getImages(), - directoryPath) - .stream() - .map(image -> CustomImage.of(image, custom)) - .collect(Collectors.toList()); - customImageService.saveAll(customImages); - } + // 이미지들 등록 + if (!Objects.isNull(updateCustomReq.getImages())) { + List customImages = + s3Service.uploadImageList( + updateCustomReq.getImages(), + directoryPath) + .stream() + .map(image -> CustomImage.of(image, custom)) + .collect(Collectors.toList()); + customImageService.saveAll(customImages); + } - // 테마 등록 - if (!Objects.isNull(updateCustomReq.getThemes())) { - customThemeService.saveAllByCustomAndThemeIdList( - custom, - updateCustomReq.getThemes()); - } - // 스타일 등록 - if (!Objects.isNull(updateCustomReq.getStyles())) { - customStyleService.saveByCustomAndStyleIdList( - custom, - updateCustomReq.getStyles()); - } - if (custom.getIsCompleted()) { - discordMessageService.sendCustomApplyMessage(custom); - userService.updateUserPoint(custom.getUser(), -custom.getPrice()); - } - return ReadCustomRes.from(custom); - } + // 테마 등록 + if (!Objects.isNull(updateCustomReq.getThemes())) { + customThemeService.saveAllByCustomAndThemeIdList( + custom, + updateCustomReq.getThemes()); + } + // 스타일 등록 + if (!Objects.isNull(updateCustomReq.getStyles())) { + customStyleService.saveByCustomAndStyleIdList( + custom, + updateCustomReq.getStyles()); + } + if (custom.getIsCompleted()) { + discordMessageService.sendCustomApplyMessage(custom); + } + return ReadCustomRes.from(custom); + } - @Override - @Transactional - public ReadCustomRes updateCustomProcess(UpdateCustomReq updateCustomReq) { - Custom custom = - customProvider.getCustomById( - updateCustomReq.getCustomId(), - updateCustomReq.getUserId()); - customService.updateCustomProcess(custom, updateCustomReq.getCustomProcess()); - return ReadCustomRes.from(custom); - } + @Override + @Transactional + public ReadCustomRes updateCustomProcess(UpdateCustomReq updateCustomReq) { + Custom custom = + customProvider.getCustomById( + updateCustomReq.getCustomId(), + updateCustomReq.getUserId()); + customService.updateCustomProcess(custom, updateCustomReq.getCustomProcess()); + return ReadCustomRes.from(custom); + } } diff --git a/server/src/main/java/org/tattour/server/domain/order/controller/dto/response/ReadOrderSheetRes.java b/server/src/main/java/org/tattour/server/domain/order/controller/dto/response/ReadOrderSheetRes.java index 2b0cf00f..c79ffc89 100644 --- a/server/src/main/java/org/tattour/server/domain/order/controller/dto/response/ReadOrderSheetRes.java +++ b/server/src/main/java/org/tattour/server/domain/order/controller/dto/response/ReadOrderSheetRes.java @@ -5,8 +5,6 @@ import lombok.AllArgsConstructor; import lombok.Getter; import org.tattour.server.domain.order.provider.vo.OrderAmountInfo; -import org.tattour.server.domain.user.provider.vo.HomeUserInfo; -import org.tattour.server.domain.user.provider.vo.UserPointAfterOrderInfo; import org.tattour.server.domain.sticker.provider.vo.ReadOrderSheetStickerInfo; import org.tattour.server.domain.user.provider.vo.UserProfileInfo; @@ -16,17 +14,12 @@ public class ReadOrderSheetRes { private UserProfileInfo userProfileInfo; private ReadOrderSheetStickerInfo readOrderSheetStickerInfo; - private OrderAmountInfo orderAmountInfo; - - private UserPointAfterOrderInfo userPointAfterOrderInfo; public static ReadOrderSheetRes of( UserProfileInfo userProfileInfo, ReadOrderSheetStickerInfo readOrderSheetStickerInfo, - OrderAmountInfo orderAmountInfo, - UserPointAfterOrderInfo userPointAfterOrderInfo) { - return new ReadOrderSheetRes(userProfileInfo, readOrderSheetStickerInfo, orderAmountInfo, - userPointAfterOrderInfo); + OrderAmountInfo orderAmountInfo) { + return new ReadOrderSheetRes(userProfileInfo, readOrderSheetStickerInfo, orderAmountInfo); } } diff --git a/server/src/main/java/org/tattour/server/domain/order/facade/dto/request/ReadOrderSheetReq.java b/server/src/main/java/org/tattour/server/domain/order/facade/dto/request/ReadOrderSheetReq.java index 5a59939a..fde562e2 100644 --- a/server/src/main/java/org/tattour/server/domain/order/facade/dto/request/ReadOrderSheetReq.java +++ b/server/src/main/java/org/tattour/server/domain/order/facade/dto/request/ReadOrderSheetReq.java @@ -20,8 +20,7 @@ public class ReadOrderSheetReq { @NotNull(message = "shippingFee is null") private Integer shippingFee; - public static ReadOrderSheetReq of(Integer userId, Integer stickerId, Integer count, - Integer shippingFee) { + public static ReadOrderSheetReq of(Integer userId, Integer stickerId, Integer count, Integer shippingFee) { return new ReadOrderSheetReq(userId, stickerId, count, shippingFee); } } diff --git a/server/src/main/java/org/tattour/server/domain/order/facade/impl/OrderFacadeImpl.java b/server/src/main/java/org/tattour/server/domain/order/facade/impl/OrderFacadeImpl.java index 94cf6d6a..f7251d00 100644 --- a/server/src/main/java/org/tattour/server/domain/order/facade/impl/OrderFacadeImpl.java +++ b/server/src/main/java/org/tattour/server/domain/order/facade/impl/OrderFacadeImpl.java @@ -13,22 +13,17 @@ import org.tattour.server.domain.order.facade.dto.request.ReadOrderSheetReq; import org.tattour.server.domain.order.facade.dto.request.UpdateOrderStatusReq; import org.tattour.server.domain.order.facade.dto.response.ReadOrderHistoryListRes; -import org.tattour.server.domain.order.provider.vo.OrderAmountInfo; -import org.tattour.server.domain.order.provider.vo.OrderHistoryPageInfo; -import org.tattour.server.domain.point.domain.PointLogCategory; -import org.tattour.server.domain.point.domain.UserPointLog; -import org.tattour.server.domain.sticker.domain.Sticker; -import org.tattour.server.domain.user.domain.User; -import org.tattour.server.domain.user.provider.vo.UserPointAfterOrderInfo; import org.tattour.server.domain.order.facade.dto.response.ReadUserOrderHistoryListRes; import org.tattour.server.domain.order.provider.impl.OrderProviderImpl; +import org.tattour.server.domain.order.provider.vo.OrderAmountInfo; +import org.tattour.server.domain.order.provider.vo.OrderHistoryPageInfo; import org.tattour.server.domain.order.service.impl.OrderServiceImpl; -import org.tattour.server.domain.point.service.impl.PointServiceImpl; -import org.tattour.server.domain.sticker.provider.vo.ReadOrderSheetStickerInfo; +import org.tattour.server.domain.sticker.domain.Sticker; import org.tattour.server.domain.sticker.provider.impl.StickerProviderImpl; +import org.tattour.server.domain.sticker.provider.vo.ReadOrderSheetStickerInfo; +import org.tattour.server.domain.user.domain.User; import org.tattour.server.domain.user.provider.impl.UserProviderImpl; import org.tattour.server.domain.user.provider.vo.UserProfileInfo; -import org.tattour.server.domain.user.service.impl.UserServiceImpl; import org.tattour.server.global.exception.BusinessException; import org.tattour.server.global.exception.ErrorType; import org.tattour.server.global.util.EntityDtoMapper; @@ -42,8 +37,6 @@ public class OrderFacadeImpl implements OrderFacade { private final OrderServiceImpl orderService; private final StickerProviderImpl stickerProvider; private final UserProviderImpl userProvider; - private final UserServiceImpl userService; - private final PointServiceImpl pointService; private final DiscordMessageService discordMessageService; @Override @@ -56,8 +49,7 @@ public ReadOrderSheetRes readOrderSheet(ReadOrderSheetReq req) { UserProfileInfo userProfileInfo = userProvider.readUserProfileInfo(user); // 스티커 정보(배너이미지, 이름, 원래가격, 할인가격) + 개수 - ReadOrderSheetStickerInfo readOrderSheetStickerInfo = - stickerProvider.readOrderSheetStickerInfo(sticker); + ReadOrderSheetStickerInfo readOrderSheetStickerInfo = stickerProvider.readOrderSheetStickerInfo(sticker); readOrderSheetStickerInfo.setCount(req.getCount()); // 결제 금액 정보 @@ -70,28 +62,15 @@ public ReadOrderSheetRes readOrderSheet(ReadOrderSheetReq req) { req.getCount(), req.getShippingFee()); - // 포인트 - // 보유 포인트, 남는 포인트 - UserPointAfterOrderInfo userPointAfterOrderInfo = - userProvider.readUserPointAfterOrderInfo( - user, - orderAmountInfo.getTotalAmount()); - - return ReadOrderSheetRes.of(userProfileInfo, readOrderSheetStickerInfo, orderAmountInfo, - userPointAfterOrderInfo); + return ReadOrderSheetRes.of(userProfileInfo, readOrderSheetStickerInfo, orderAmountInfo); } @Override @Transactional public void createOrder(CreateOrderRequest req) { User user = userProvider.readUserById(req.getUserId()); - - if (userProvider.isUserPointLack(user, req.getTotalAmount())) { - throw new BusinessException(ErrorType.LACK_OF_POINT_EXCEPTION); - } - - // 주문내역 생성 Sticker sticker = stickerProvider.getById(req.getStickerId()); + Order order = orderService.saveOrder( Order.of( sticker.getName(), @@ -109,19 +88,6 @@ public void createOrder(CreateOrderRequest req) { user, sticker)); - // userPoint 수정 - userService.updateUserPoint(user, -req.getTotalAmount()); - - // 포인트 로그 저장 - pointService.savePointLog( - UserPointLog.of( - PointLogCategory.PURCHASE, - null, - -req.getTotalAmount(), - user.getPoint(), - user - )); - discordMessageService.sendOrderStickerMessage(order); } @@ -144,34 +110,18 @@ public ReadOrderHistoryListRes readOrderHistoryOnPage(int page) { } @Override + @Transactional public void updateOrderStatus(UpdateOrderStatusReq req) { Order order = orderProvider.readOrderById(req.getOrderId()); - User user = userProvider.readUserById(order.getUser().getId()); - - // 주문취소일 경우 - if (req.getOrderStatus().equals(OrderStatus.CANCEL)) { - if (!order.getOrderStatus().equals(OrderStatus.CANCEL)) { - // 상태 변경 - order.setOrderStatus(req.getOrderStatus()); - orderService.saveOrder(order); - - // 유저 포인트 변경 - userService.updateUserPoint(user, order.getTotalAmount()); - - // 포인트 로그 남기기 - pointService.savePointLog( - UserPointLog.of( - PointLogCategory.CANCEL_PURCHASE, - order.getSticker().getName(), - order.getTotalAmount(), - user.getPoint(), - user)); - } else { + OrderStatus requestedStatus = req.getOrderStatus(); + + if (order.getOrderStatus().equals(requestedStatus)) { + if (requestedStatus.equals(OrderStatus.CANCEL)) { throw new BusinessException(ErrorType.ALREADY_CANCELED_ORDER_HISTORY_EXCEPTION); } - } else { - order.setOrderStatus(req.getOrderStatus()); - orderService.saveOrder(order); } + + order.setOrderStatus(req.getOrderStatus()); + orderService.saveOrder(order); } } diff --git a/server/src/main/java/org/tattour/server/domain/order/provider/vo/OrderAmountInfo.java b/server/src/main/java/org/tattour/server/domain/order/provider/vo/OrderAmountInfo.java index 38109d0a..0617802f 100644 --- a/server/src/main/java/org/tattour/server/domain/order/provider/vo/OrderAmountInfo.java +++ b/server/src/main/java/org/tattour/server/domain/order/provider/vo/OrderAmountInfo.java @@ -9,7 +9,6 @@ @AllArgsConstructor public class OrderAmountInfo { - @Schema(description = "총 결제금액", example = "12000") private Integer totalAmount; @@ -19,8 +18,7 @@ public class OrderAmountInfo { @Schema(description = "배송비", example = "3000") private Integer shippingFee; - public static OrderAmountInfo of(Integer totalAmount, Integer productAmount, - Integer shippingFee) { + public static OrderAmountInfo of(Integer totalAmount, Integer productAmount, Integer shippingFee) { return new OrderAmountInfo(totalAmount, productAmount, shippingFee); } } diff --git a/server/src/main/java/org/tattour/server/domain/order/service/impl/OrderServiceImpl.java b/server/src/main/java/org/tattour/server/domain/order/service/impl/OrderServiceImpl.java index ccc88c74..209586ae 100644 --- a/server/src/main/java/org/tattour/server/domain/order/service/impl/OrderServiceImpl.java +++ b/server/src/main/java/org/tattour/server/domain/order/service/impl/OrderServiceImpl.java @@ -4,20 +4,8 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.tattour.server.domain.order.domain.Order; -import org.tattour.server.domain.order.facade.dto.request.CreateOrderRequest; -import org.tattour.server.domain.order.provider.impl.OrderProviderImpl; import org.tattour.server.domain.order.repository.impl.OrderRepositoryImpl; import org.tattour.server.domain.order.service.OrderService; -import org.tattour.server.domain.order.facade.dto.request.UpdateOrderStatusReq; -import org.tattour.server.domain.point.service.impl.PointServiceImpl; -import org.tattour.server.domain.sticker.domain.Sticker; -import org.tattour.server.domain.sticker.provider.impl.StickerProviderImpl; -import org.tattour.server.domain.order.domain.OrderStatus; -import org.tattour.server.domain.user.domain.User; -import org.tattour.server.domain.user.provider.impl.UserProviderImpl; -import org.tattour.server.domain.user.service.impl.UserServiceImpl; -import org.tattour.server.global.exception.BusinessException; -import org.tattour.server.global.exception.ErrorType; @Service @RequiredArgsConstructor diff --git a/server/src/main/java/org/tattour/server/domain/point/dao/PointDao.java b/server/src/main/java/org/tattour/server/domain/point/dao/PointDao.java deleted file mode 100644 index 9191a12d..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/dao/PointDao.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.tattour.server.domain.point.dao; - -import java.util.ArrayList; -import java.util.List; -import javax.sql.DataSource; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.stereotype.Repository; -import org.tattour.server.domain.order.domain.OrderStatus; -import org.tattour.server.domain.point.domain.PointLogCategory; -import org.tattour.server.domain.point.provider.vo.PointChargeRequestInfo; -import org.tattour.server.domain.point.provider.vo.PointLogInfo; - -@Repository -public class PointDao { - - private final JdbcTemplate jdbcTemplate; - - public PointDao(DataSource dataSource) { - this.jdbcTemplate = new JdbcTemplate(dataSource); - } - - // 조건에 따라 유저 포인트 충전 요청 내역 가져오기 - public List findPointChargeRequestResList(Integer userId, - Boolean isCompleted) { - String query = - "SELECT * " - + "FROM point_charge_request " - + "WHERE 1=1 "; - List params = new ArrayList<>(); - - if (userId != null) { - params.add(userId); - query += "AND user_id = ? "; - } - - if (isCompleted != null) { - params.add(isCompleted); - query += "AND is_completed = ? "; - } - - return jdbcTemplate.query(query, - (rs, rownum) -> PointChargeRequestInfo.builder() - .id(rs.getInt("id")) - .userId(rs.getInt("user_id")) - .chargeAmount(rs.getInt("charge_amount")) - .transferredAmount(rs.getInt("transferred_amount")) - .isDeposited(rs.getBoolean("is_deposited")) - .isAmountMatched(rs.getBoolean("is_amount_matched")) - .isCompleted(rs.getBoolean("is_completed")) - .createdAt(rs.getString("created_at")) - .lastUpdatedAt(rs.getString("last_updated_at")) - .state(rs.getBoolean("state")) - .build(), - params.toArray()); - } - - // 조건에 따라 포인트 로그 불러오기 - public List findPointLogResList(Integer userId, String category) { - String query = - "SELECT * FROM user_point_log " - + "WHERE 1=1 "; - List params = new ArrayList<>(); - - if (userId != null) { - params.add(userId); - query += "AND user_id = ? "; - } - - if (category != null) { - params.add(category); - query += "AND title = ? "; - } - - return jdbcTemplate.query(query, - (rs, rownum) -> PointLogInfo.builder() - .id(rs.getInt("id")) - .userId(rs.getInt("user_id")) - .title(PointLogCategory.valueOf(rs.getString("title")).getValue()) - .content(rs.getString("content")) - .amount(rs.getInt("amount")) - .resultPointAmount(rs.getInt("result_point_amount")) - .createdAt(rs.getString("created_at")) - .state(rs.getBoolean("state")) - .build(), - params.toArray()); - } -} diff --git a/server/src/main/java/org/tattour/server/domain/point/domain/PointChargeRequest.java b/server/src/main/java/org/tattour/server/domain/point/domain/PointChargeRequest.java deleted file mode 100644 index 70733dba..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/domain/PointChargeRequest.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.tattour.server.domain.point.domain; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NoArgsConstructor; -import org.hibernate.annotations.DynamicInsert; -import org.tattour.server.domain.user.domain.User; - -@Entity -@DynamicInsert -@Getter -@NoArgsConstructor(access = AccessLevel.PROTECTED) -public class PointChargeRequest { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Integer id; - private Integer chargeAmount; - private Integer transferredAmount; - @Column(columnDefinition = "tinyint") - private Boolean isDeposited; - @Column(columnDefinition = "tinyint") - private Boolean isAmountMatched; - @Column(columnDefinition = "tinyint") - private Boolean isApproved; - @Column(columnDefinition = "tinyint") - private Boolean isCompleted; - @Column(columnDefinition = "Timestamp") - private String createdAt; - @Column(columnDefinition = "Timestamp") - private String lastUpdatedAt; - @Column(columnDefinition = "tinyint") - private Boolean state; - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "user_id") - private User user; - - private PointChargeRequest(User user, Integer chargeAmount) { - this.user = user; - this.chargeAmount = chargeAmount; - } - - public static PointChargeRequest of(User user, Integer chargeAmount) { - return new PointChargeRequest(user, chargeAmount); - } - - public void setProperties(Integer transferredAmount, Boolean isDeposited, - Boolean isAmountMatched, Boolean isApproved, Boolean isCompleted) { - this.transferredAmount = transferredAmount; - this.isDeposited = isDeposited; - this.isAmountMatched = isAmountMatched; - this.isApproved = isApproved; - this.isCompleted = isCompleted; - } -} diff --git a/server/src/main/java/org/tattour/server/domain/point/domain/PointLogCategory.java b/server/src/main/java/org/tattour/server/domain/point/domain/PointLogCategory.java deleted file mode 100644 index f9282f9a..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/domain/PointLogCategory.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.tattour.server.domain.point.domain; - -import java.util.Arrays; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -@Getter -@RequiredArgsConstructor(access = AccessLevel.PRIVATE) -public enum PointLogCategory { - PURCHASE("상품 구매"), - APPLY_CUSTOM("커스텀 신청"), - CANCEL_PURCHASE("결제 취소"), - REQUEST_CHARGE("포인트 충전 요청"), - CANCEL_CHARGE("충전 취소"), - ; - - private final String value; - - public static PointLogCategory fromValue(String value) { - return Arrays.stream(PointLogCategory.values()) - .filter(category -> category.value.equals(value)) - .findFirst() - .orElseThrow(() -> new IllegalArgumentException( - "입력한 value와 일치하는 Enum 타입이 없습니다: " + value)); - } -} diff --git a/server/src/main/java/org/tattour/server/domain/point/domain/UserPointLog.java b/server/src/main/java/org/tattour/server/domain/point/domain/UserPointLog.java deleted file mode 100644 index a379008a..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/domain/UserPointLog.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.tattour.server.domain.point.domain; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import lombok.AccessLevel; -import lombok.NoArgsConstructor; -import org.hibernate.annotations.DynamicInsert; -import org.tattour.server.domain.user.domain.User; - -@Entity -@DynamicInsert -@NoArgsConstructor(access = AccessLevel.PROTECTED) -public class UserPointLog { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Integer id; - @Column(name = "title") - @Enumerated(EnumType.STRING) - private PointLogCategory pointLogCategory; - private String content; - @Column(columnDefinition = "Timestamp") - private String createdAt; - private Integer amount; - private Integer resultPointAmount; - @Column(columnDefinition = "tinyint") - private Boolean state; - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "user_id") - private User user; - - private UserPointLog(PointLogCategory pointLogCategory, String content, Integer amount, - Integer resultPointAmount, User user) { - this.pointLogCategory = pointLogCategory; - this.content = content; - this.amount = amount; - this.resultPointAmount = resultPointAmount; - this.user = user; - } - - public static UserPointLog of(PointLogCategory pointLogCategory, String content, Integer amount, - Integer resultPointAmount, User user) { - return new UserPointLog(pointLogCategory, content, amount, resultPointAmount, user); - } -} diff --git a/server/src/main/java/org/tattour/server/domain/point/facade/PointFacade.java b/server/src/main/java/org/tattour/server/domain/point/facade/PointFacade.java deleted file mode 100644 index 8bb5941f..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/facade/PointFacade.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.tattour.server.domain.point.facade; - -import org.tattour.server.domain.admin.controller.dto.request.CancelPointChargeRequestReq; -import org.tattour.server.domain.point.facade.dto.request.CreatePointChargeRequestReq; -import org.tattour.server.domain.point.facade.dto.request.ReadPointChargeRequestListReq; -import org.tattour.server.domain.point.facade.dto.request.ReadPointLogListReq; -import org.tattour.server.domain.point.facade.dto.response.ReadPointChargeRequestListRes; -import org.tattour.server.domain.point.facade.dto.response.ReadPointLogListRes; -import org.tattour.server.domain.point.facade.dto.request.ConfirmPointChargeReq; -import org.tattour.server.domain.point.facade.dto.response.ConfirmPointChargeRes; - -public interface PointFacade { - // 포인트 충전 요청 - void createPointChargeRequest(CreatePointChargeRequestReq req); - - // 포인트 충전 요청 신청 내역 가져오기 - ReadPointChargeRequestListRes readPointChargeRequest(ReadPointChargeRequestListReq req); - - // 포인트 충전 요청 확인 - ConfirmPointChargeRes confirmPointChargeRequest(ConfirmPointChargeReq req); - - // 포인트 충전 요청 취소 - void cancelPointChargeRequest(CancelPointChargeRequestReq req); - - // 포인트 로그 불러오기 - ReadPointLogListRes readPointLog(ReadPointLogListReq req); -} diff --git a/server/src/main/java/org/tattour/server/domain/point/facade/dto/request/ConfirmPointChargeReq.java b/server/src/main/java/org/tattour/server/domain/point/facade/dto/request/ConfirmPointChargeReq.java deleted file mode 100644 index 65eaf79c..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/facade/dto/request/ConfirmPointChargeReq.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.tattour.server.domain.point.facade.dto.request; - -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor(access = AccessLevel.PRIVATE) -public class ConfirmPointChargeReq { - private int id; - private int userId; - private int transferredAmount; - - public static ConfirmPointChargeReq of(int id, int userId, int transferredAmount) { - return new ConfirmPointChargeReq(id, userId, transferredAmount); - } -} diff --git a/server/src/main/java/org/tattour/server/domain/point/facade/dto/request/CreatePointChargeRequestReq.java b/server/src/main/java/org/tattour/server/domain/point/facade/dto/request/CreatePointChargeRequestReq.java deleted file mode 100644 index 5414713c..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/facade/dto/request/CreatePointChargeRequestReq.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.tattour.server.domain.point.facade.dto.request; - -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor(access = AccessLevel.PRIVATE) -public class CreatePointChargeRequestReq { - - private int userId; - private int chargeAmount; - - public static CreatePointChargeRequestReq of(int userId, int chargeAmount) { - return new CreatePointChargeRequestReq(userId, chargeAmount); - } -} diff --git a/server/src/main/java/org/tattour/server/domain/point/facade/dto/request/ReadPointChargeRequestListReq.java b/server/src/main/java/org/tattour/server/domain/point/facade/dto/request/ReadPointChargeRequestListReq.java deleted file mode 100644 index a1f6fd1d..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/facade/dto/request/ReadPointChargeRequestListReq.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.tattour.server.domain.point.facade.dto.request; - -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Getter -@NoArgsConstructor(access = AccessLevel.PRIVATE) -@AllArgsConstructor(access = AccessLevel.PRIVATE) -public class ReadPointChargeRequestListReq { - private Integer userId; - private Boolean isCompleted; - public static ReadPointChargeRequestListReq of(Integer userId, Boolean isCompleted){ - return new ReadPointChargeRequestListReq(userId, isCompleted); - } -} diff --git a/server/src/main/java/org/tattour/server/domain/point/facade/dto/request/ReadPointLogListReq.java b/server/src/main/java/org/tattour/server/domain/point/facade/dto/request/ReadPointLogListReq.java deleted file mode 100644 index 4e8ebc86..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/facade/dto/request/ReadPointLogListReq.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.tattour.server.domain.point.facade.dto.request; - -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import org.tattour.server.domain.point.domain.PointLogCategory; - -@Getter -@NoArgsConstructor(access = AccessLevel.PRIVATE) -@AllArgsConstructor(access = AccessLevel.PRIVATE) -public class ReadPointLogListReq { - Integer userId; - PointLogCategory category; - - public static ReadPointLogListReq of(Integer userId, PointLogCategory category){ - return new ReadPointLogListReq(userId, category); - } -} diff --git a/server/src/main/java/org/tattour/server/domain/point/facade/dto/response/ConfirmPointChargeRes.java b/server/src/main/java/org/tattour/server/domain/point/facade/dto/response/ConfirmPointChargeRes.java deleted file mode 100644 index a21b390b..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/facade/dto/response/ConfirmPointChargeRes.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.tattour.server.domain.point.facade.dto.response; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.tattour.server.domain.custom.facade.dto.response.ReadCustomSummaryListRes; -import org.tattour.server.domain.order.facade.dto.response.ReadUserOrderHistoryListRes; -import org.tattour.server.domain.user.provider.vo.UserContactInfo; - -@Schema(description = "송금 금액이 다를 경우 user 정보 Response") -@Getter -@AllArgsConstructor(access = AccessLevel.PRIVATE) -public class ConfirmPointChargeRes { - - // 유저 정보 - UserContactInfo userContactInfo; - // 포인트 충전 내역 - ReadPointChargeRequestListRes readPointChargeRequestListRes; - // 구매 내역 - ReadUserOrderHistoryListRes orderHistoryListRes; - // 커스텀 신청내역 - ReadCustomSummaryListRes readCustomSummaryListRes; - - public static ConfirmPointChargeRes of( - UserContactInfo userContactInfo, - ReadPointChargeRequestListRes readPointChargeRequestListRes, - ReadUserOrderHistoryListRes readUserOrderHistoryListRes, - ReadCustomSummaryListRes readCustomSummaryListRes) { - return new ConfirmPointChargeRes(userContactInfo, readPointChargeRequestListRes, - readUserOrderHistoryListRes, readCustomSummaryListRes); - } -} diff --git a/server/src/main/java/org/tattour/server/domain/point/facade/dto/response/ReadPointChargeRequestListRes.java b/server/src/main/java/org/tattour/server/domain/point/facade/dto/response/ReadPointChargeRequestListRes.java deleted file mode 100644 index 8a3607ad..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/facade/dto/response/ReadPointChargeRequestListRes.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.tattour.server.domain.point.facade.dto.response; - -import io.swagger.v3.oas.annotations.media.Schema; -import java.util.List; -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.tattour.server.domain.point.provider.vo.PointChargeRequestInfo; - -@Schema(description = "포인트 충전 요청 내역 리스트 Response") -@Getter -@AllArgsConstructor(access = AccessLevel.PRIVATE) -public class ReadPointChargeRequestListRes { - - List pointChargeRequestInfoList; - - public static ReadPointChargeRequestListRes of( - List pointChargeRequestInfoList) { - return new ReadPointChargeRequestListRes(pointChargeRequestInfoList); - } -} diff --git a/server/src/main/java/org/tattour/server/domain/point/facade/dto/response/ReadPointLogListRes.java b/server/src/main/java/org/tattour/server/domain/point/facade/dto/response/ReadPointLogListRes.java deleted file mode 100644 index 9be910fe..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/facade/dto/response/ReadPointLogListRes.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.tattour.server.domain.point.facade.dto.response; - -import java.util.List; -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.tattour.server.domain.point.provider.vo.PointLogInfo; - -@Getter -@AllArgsConstructor(access = AccessLevel.PRIVATE) -public class ReadPointLogListRes { - - List pointLogInfoList; - - public static ReadPointLogListRes of(List pointLogInfoList) { - return new ReadPointLogListRes(pointLogInfoList); - } -} diff --git a/server/src/main/java/org/tattour/server/domain/point/facade/impl/PointFacadeImpl.java b/server/src/main/java/org/tattour/server/domain/point/facade/impl/PointFacadeImpl.java deleted file mode 100644 index f8a50847..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/facade/impl/PointFacadeImpl.java +++ /dev/null @@ -1,167 +0,0 @@ -package org.tattour.server.domain.point.facade.impl; - -import java.util.Objects; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; -import org.tattour.server.domain.admin.controller.dto.request.CancelPointChargeRequestReq; -import org.tattour.server.domain.custom.facade.dto.response.ReadCustomSummaryListRes; -import org.tattour.server.domain.custom.provider.CustomProvider; -import org.tattour.server.domain.order.facade.dto.response.ReadUserOrderHistoryListRes; -import org.tattour.server.domain.order.provider.OrderProvider; -import org.tattour.server.domain.point.domain.PointChargeRequest; -import org.tattour.server.domain.point.domain.PointLogCategory; -import org.tattour.server.domain.point.domain.UserPointLog; -import org.tattour.server.domain.point.facade.PointFacade; -import org.tattour.server.domain.point.facade.dto.request.ConfirmPointChargeReq; -import org.tattour.server.domain.point.facade.dto.request.CreatePointChargeRequestReq; -import org.tattour.server.domain.point.facade.dto.request.ReadPointChargeRequestListReq; -import org.tattour.server.domain.point.facade.dto.request.ReadPointLogListReq; -import org.tattour.server.domain.point.facade.dto.response.ConfirmPointChargeRes; -import org.tattour.server.domain.point.facade.dto.response.ReadPointChargeRequestListRes; -import org.tattour.server.domain.point.facade.dto.response.ReadPointLogListRes; -import org.tattour.server.domain.point.provider.PointProvider; -import org.tattour.server.domain.point.service.PointService; -import org.tattour.server.domain.user.domain.User; -import org.tattour.server.domain.user.provider.UserProvider; -import org.tattour.server.domain.user.provider.vo.UserContactInfo; -import org.tattour.server.domain.user.service.UserService; -import org.tattour.server.global.exception.BusinessException; -import org.tattour.server.global.exception.ErrorType; -import org.tattour.server.global.util.EntityDtoMapper; -import org.tattour.server.infra.discord.service.DiscordMessageService; - -@Service -@RequiredArgsConstructor -public class PointFacadeImpl implements PointFacade { - - private final PointService pointService; - private final PointProvider pointProvider; - private final UserService userService; - private final UserProvider userProvider; - private final CustomProvider customProvider; - private final OrderProvider orderProvider; - private final DiscordMessageService discordMessageService; - - - @Override - public void createPointChargeRequest(CreatePointChargeRequestReq req) { - User user = userProvider.readUserById(req.getUserId()); - - pointService.savePointChargeRequest(PointChargeRequest.of(user, req.getChargeAmount())); - userService.updateUserPoint(user, req.getChargeAmount()); - pointService.savePointLog( - UserPointLog.of( - PointLogCategory.REQUEST_CHARGE, - null, - req.getChargeAmount(), - user.getPoint(), - user)); - - discordMessageService.sendPointChargeLogMessage(user, req.getChargeAmount()); - } - - @Override - public ReadPointChargeRequestListRes readPointChargeRequest(ReadPointChargeRequestListReq req) { - return pointProvider.readAllPointChargeRequest(req.getUserId(), req.getIsCompleted()); - } - - @Override - public ConfirmPointChargeRes confirmPointChargeRequest(ConfirmPointChargeReq req) { - PointChargeRequest pointChargeRequest = pointProvider.readPointChargeRequestById( - req.getId()); - - if (!pointChargeRequest.getIsCompleted()) { - // 처리된 요청이 아니면 - if (req.getTransferredAmount() == pointChargeRequest.getChargeAmount()) { - // 송금된 값이 일치하면 - // PointChargeRequest의 상태를 변경하기 - pointService.updatePointChargeRequest(pointChargeRequest, - req.getTransferredAmount(), - true, true, true, true); - - return null; - } else { - // 일치하지 않으면 - String baseDate = pointChargeRequest.getCreatedAt(); - - // 유저 정보 - User user = userProvider.readUserById(req.getUserId()); - UserContactInfo userContactInfo = EntityDtoMapper.INSTANCE.toUserContactInfo(user); - - // 포인트 충전 내역 - ReadPointChargeRequestListRes readPointChargeRequestListRes = - pointProvider.readPointChargeRequestAfterDate(req.getUserId(), baseDate); - readPointChargeRequestListRes - .getPointChargeRequestInfoList() - .add(0, EntityDtoMapper.INSTANCE.toGetPointChargeRequestRes( - pointChargeRequest)); - - // 구매 내역 - ReadUserOrderHistoryListRes readUserOrderHistoryListRes = - ReadUserOrderHistoryListRes.of( - orderProvider.readOrderHistoryAfterDate( - req.getUserId(), - baseDate)); - - // 커스텀 신청내역 - ReadCustomSummaryListRes readCustomSummaryListRes = - ReadCustomSummaryListRes.from( - customProvider.getCustomByUserIdAfterDate( - req.getUserId(), - baseDate) - ); - - return ConfirmPointChargeRes.of(userContactInfo, - readPointChargeRequestListRes, - readUserOrderHistoryListRes, - readCustomSummaryListRes); - } - } else { - // 이미 처리된 요청이면 - throw new BusinessException(ErrorType.ALREADY_COMPLETED_POINT_CHARGE_REQUEST_EXCEPTION); - } - } - - @Override - public void cancelPointChargeRequest(CancelPointChargeRequestReq req) { - PointChargeRequest pointChargeRequest = pointProvider.readPointChargeRequestById( - req.getId()); - - if (pointChargeRequest.getIsCompleted()) { - // 이미 처리된 요청이면 반려 - throw new BusinessException(ErrorType.ALREADY_COMPLETED_POINT_CHARGE_REQUEST_EXCEPTION); - } else { - if (Objects.equals(req.getTransferredAmount(), pointChargeRequest.getChargeAmount())) { - // 송금 금액이 충전 금액이 같으면 반려 - throw new BusinessException(ErrorType.AMOUNT_MATCHED_EXCEPTION); - } else { - // PointChargeRequest의 상태를 변경하기 - pointService.updatePointChargeRequest( - pointChargeRequest, req.getTransferredAmount(), true, - false, false, true); - - // 포인트 로그 남기기 - User user = userProvider.readUserById(req.getUserId()); - int amount = pointChargeRequest.getChargeAmount(); - int resultPoint = user.getPoint() - amount; - - pointService.savePointLog( - UserPointLog.of( - PointLogCategory.CANCEL_CHARGE, - req.getReason(), - -pointChargeRequest.getChargeAmount(), - resultPoint, - user)); - - // 유저 포인트 처리 - userService.updateUserPoint(user, -amount); - } - } - } - - @Override - public ReadPointLogListRes readPointLog(ReadPointLogListReq req) { - return ReadPointLogListRes.of( - pointProvider.readPointLog(req.getUserId(), req.getCategory().name())); - } -} diff --git a/server/src/main/java/org/tattour/server/domain/point/provider/PointProvider.java b/server/src/main/java/org/tattour/server/domain/point/provider/PointProvider.java deleted file mode 100644 index 28905d08..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/provider/PointProvider.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.tattour.server.domain.point.provider; - -import java.util.List; -import org.tattour.server.domain.point.domain.PointChargeRequest; -import org.tattour.server.domain.point.facade.dto.response.ReadPointChargeRequestListRes; -import org.tattour.server.domain.point.provider.vo.PointLogInfo; -import org.tattour.server.domain.user.domain.User; - -public interface PointProvider { - - // id로 포인트 충전 요청 가져오기 - PointChargeRequest readPointChargeRequestById(Integer id); - - // id와 날짜로 포인트 충전 요청 가져오기 - ReadPointChargeRequestListRes readPointChargeRequestAfterDate(int userId, String date); - - // 조건에 따라 포인트 충전 요청 가져오기 - ReadPointChargeRequestListRes readAllPointChargeRequest(Integer userId, Boolean isCompleted); - - // 조건에 따라 포인트 로그 가져오기 - List readPointLog(Integer userId, String category); -} diff --git a/server/src/main/java/org/tattour/server/domain/point/provider/impl/PointProviderImpl.java b/server/src/main/java/org/tattour/server/domain/point/provider/impl/PointProviderImpl.java deleted file mode 100644 index 1fe57371..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/provider/impl/PointProviderImpl.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.tattour.server.domain.point.provider.impl; - -import java.util.List; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; -import org.tattour.server.domain.point.dao.PointDao; -import org.tattour.server.domain.point.domain.PointChargeRequest; -import org.tattour.server.domain.point.domain.PointLogCategory; -import org.tattour.server.domain.point.provider.PointProvider; -import org.tattour.server.domain.point.facade.dto.response.ReadPointChargeRequestListRes; -import org.tattour.server.domain.point.provider.vo.PointLogInfo; -import org.tattour.server.domain.point.repository.impl.PointChargeRequestRepositoryImpl; -import org.tattour.server.global.exception.BusinessException; -import org.tattour.server.global.exception.ErrorType; -import org.tattour.server.global.util.EntityDtoMapper; - -@Service -@RequiredArgsConstructor -public class PointProviderImpl implements PointProvider { - - private final PointDao pointDao; - private final PointChargeRequestRepositoryImpl pointChargeRequestRepository; - - @Override - public PointChargeRequest readPointChargeRequestById(Integer id) { - return pointChargeRequestRepository.findById(id) - .orElseThrow(() -> new BusinessException( - ErrorType.NOT_FOUND_POINT_CHARGE_REQUEST_EXCEPTION)); - } - - @Override - public ReadPointChargeRequestListRes readPointChargeRequestAfterDate(int userId, String date) { - return ReadPointChargeRequestListRes.of( - EntityDtoMapper.INSTANCE.toGetPointChargeRequestResList( - pointChargeRequestRepository - .findPointChargeRequestByUser_IdAndCreatedAtAfter(userId, date))); - } - - @Override - public ReadPointChargeRequestListRes readAllPointChargeRequest(Integer userId, - Boolean isCompleted) { - return ReadPointChargeRequestListRes.of( - pointDao.findPointChargeRequestResList(userId, isCompleted)); - } - - @Override - public List readPointLog(Integer userId, String category) { - return pointDao.findPointLogResList(userId, category); - } -} diff --git a/server/src/main/java/org/tattour/server/domain/point/provider/vo/PointChargeRequestInfo.java b/server/src/main/java/org/tattour/server/domain/point/provider/vo/PointChargeRequestInfo.java deleted file mode 100644 index b57baf40..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/provider/vo/PointChargeRequestInfo.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.tattour.server.domain.point.provider.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.Setter; - -@Schema(description = "포인트 충전 요청 내역 Response") -@Getter -@Setter -@Builder -@AllArgsConstructor(access = AccessLevel.PRIVATE) -public class PointChargeRequestInfo { - - @Schema(description = "포인트 충전 요청 id") - private int id; - - @Schema(description = "user Id") - private int userId; - - @Schema(description = "충전 금액", example = "5000") - private Integer chargeAmount; - - @Schema(description = "송금된 금액", example = "3000") - private Integer transferredAmount; - - @Schema(description = "입금 여부", example = "true") - private Boolean isDeposited; - - @Schema(description = "금액 일치 여부", example = "false") - private Boolean isAmountMatched; - - @Schema(description = "", example = "") - private Boolean isApproved; - - @Schema(description = "", example = "") - private Boolean isCompleted; - - @Schema(description = "", example = "") - private String createdAt; - - @Schema(description = "", example = "") - private String lastUpdatedAt; - - @Schema(description = "", example = "") - private Boolean state; -} diff --git a/server/src/main/java/org/tattour/server/domain/point/provider/vo/PointLogInfo.java b/server/src/main/java/org/tattour/server/domain/point/provider/vo/PointLogInfo.java deleted file mode 100644 index a34ec14c..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/provider/vo/PointLogInfo.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.tattour.server.domain.point.provider.vo; - -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; - -@Getter -@Builder -@AllArgsConstructor(access = AccessLevel.PRIVATE) -public class PointLogInfo { - - private int id; - private int userId; - private String title; - private String content; - private Integer amount; - private int resultPointAmount; - private String createdAt; - private Boolean state; -} diff --git a/server/src/main/java/org/tattour/server/domain/point/repository/PointChargeRequestRepository.java b/server/src/main/java/org/tattour/server/domain/point/repository/PointChargeRequestRepository.java deleted file mode 100644 index ad68d5e6..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/repository/PointChargeRequestRepository.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.tattour.server.domain.point.repository; - -public interface PointChargeRequestRepository { - -} diff --git a/server/src/main/java/org/tattour/server/domain/point/repository/UserPointLogRepository.java b/server/src/main/java/org/tattour/server/domain/point/repository/UserPointLogRepository.java deleted file mode 100644 index bf219d4f..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/repository/UserPointLogRepository.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.tattour.server.domain.point.repository; - -public interface UserPointLogRepository { - -} diff --git a/server/src/main/java/org/tattour/server/domain/point/repository/impl/PointChargeRequestRepositoryImpl.java b/server/src/main/java/org/tattour/server/domain/point/repository/impl/PointChargeRequestRepositoryImpl.java deleted file mode 100644 index 88d3db17..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/repository/impl/PointChargeRequestRepositoryImpl.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.tattour.server.domain.point.repository.impl; - -import java.util.List; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; -import org.tattour.server.domain.point.domain.PointChargeRequest; - -@Repository -public interface PointChargeRequestRepositoryImpl extends - JpaRepository { - - List findPointChargeRequestByUser_IdAndCreatedAtAfter(Integer userId, - String date); -} diff --git a/server/src/main/java/org/tattour/server/domain/point/repository/impl/UserPointLogRepositoryImpl.java b/server/src/main/java/org/tattour/server/domain/point/repository/impl/UserPointLogRepositoryImpl.java deleted file mode 100644 index 4e6c1bec..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/repository/impl/UserPointLogRepositoryImpl.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.tattour.server.domain.point.repository.impl; - -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; -import org.tattour.server.domain.point.domain.UserPointLog; - -@Repository -public interface UserPointLogRepositoryImpl extends JpaRepository { - -} diff --git a/server/src/main/java/org/tattour/server/domain/point/service/PointService.java b/server/src/main/java/org/tattour/server/domain/point/service/PointService.java deleted file mode 100644 index 40a6c3c6..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/service/PointService.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.tattour.server.domain.point.service; - -import org.tattour.server.domain.point.domain.PointChargeRequest; -import org.tattour.server.domain.point.domain.UserPointLog; - -public interface PointService { - - void savePointChargeRequest(PointChargeRequest pointChargeRequest); - - void savePointLog(UserPointLog userPointLog); - - // TODO : 삭제하기 - void updatePointChargeRequest(PointChargeRequest pointChargeRequest, int transferredAmount, - boolean isDeposited, boolean isAmountMatched, boolean isApproved, boolean isCompleted); -} diff --git a/server/src/main/java/org/tattour/server/domain/point/service/impl/PointServiceImpl.java b/server/src/main/java/org/tattour/server/domain/point/service/impl/PointServiceImpl.java deleted file mode 100644 index 63e3b2c8..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/service/impl/PointServiceImpl.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.tattour.server.domain.point.service.impl; - -import java.util.Objects; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.tattour.server.domain.admin.controller.dto.request.CancelPointChargeRequestReq; -import org.tattour.server.domain.point.domain.PointChargeRequest; -import org.tattour.server.domain.point.domain.PointLogCategory; -import org.tattour.server.domain.point.domain.UserPointLog; -import org.tattour.server.domain.point.provider.impl.PointProviderImpl; -import org.tattour.server.domain.point.repository.impl.PointChargeRequestRepositoryImpl; -import org.tattour.server.domain.point.repository.impl.UserPointLogRepositoryImpl; -import org.tattour.server.domain.point.service.PointService; -import org.tattour.server.domain.user.domain.User; -import org.tattour.server.domain.user.provider.impl.UserProviderImpl; -import org.tattour.server.domain.user.service.impl.UserServiceImpl; -import org.tattour.server.global.exception.BusinessException; -import org.tattour.server.global.exception.ErrorType; - -@Service -@RequiredArgsConstructor -public class PointServiceImpl implements PointService { - - private final PointChargeRequestRepositoryImpl pointChargeRequestRepository; - private final UserPointLogRepositoryImpl userPointLogRepository; - private final UserProviderImpl userProvider; - private final UserServiceImpl userService; - private final PointProviderImpl pointProvider; - - @Override - @Transactional - public void savePointChargeRequest(PointChargeRequest pointChargeRequest) { - pointChargeRequestRepository.save(pointChargeRequest); - } - - @Override - @Transactional - public void savePointLog(UserPointLog userPointLog) { - userPointLogRepository.save(userPointLog); - } - - @Override - @Transactional - public void updatePointChargeRequest(PointChargeRequest pointChargeRequest, - int transferredAmount, - boolean isDeposited, boolean isAmountMatched, boolean isApproved, boolean isCompleted) { - pointChargeRequest.setProperties(transferredAmount, isDeposited, isAmountMatched, - isApproved, isCompleted); - - pointChargeRequestRepository.save(pointChargeRequest); - } -} - - - diff --git a/server/src/main/java/org/tattour/server/domain/sticker/provider/impl/StickerProviderImpl.java b/server/src/main/java/org/tattour/server/domain/sticker/provider/impl/StickerProviderImpl.java index 47a52b8c..1cf3cf57 100644 --- a/server/src/main/java/org/tattour/server/domain/sticker/provider/impl/StickerProviderImpl.java +++ b/server/src/main/java/org/tattour/server/domain/sticker/provider/impl/StickerProviderImpl.java @@ -16,68 +16,67 @@ @RequiredArgsConstructor public class StickerProviderImpl implements StickerProvider { - private final StickerRepository stickerRepository; + private final StickerRepository stickerRepository; - @Override - public Sticker getById(Integer id) { - return stickerRepository.findById(id) - .orElseThrow(NotFoundStickerException::new); - } + @Override + public Sticker getById(Integer id) { + return stickerRepository.findById(id) + .orElseThrow(NotFoundStickerException::new); + } - @Override - public List getAllCustomStickerOrderByOrder() { - return stickerRepository - .findAllByStateAndIsCustomInOrderOrder(); - } + @Override + public List getAllCustomStickerOrderByOrder() { + return stickerRepository + .findAllByStateAndIsCustomInOrderOrder(); + } - @Override - public List getAllByThemeAndStyleOrderByOrder(String themeName, String styleName) { - return stickerRepository - .findAllByThemeNameAndStyleNameAndStateInOrderOrder(themeName, styleName); - } + @Override + public List getAllByThemeAndStyleOrderByOrder(String themeName, String styleName) { + return stickerRepository + .findAllByThemeNameAndStyleNameAndStateInOrderOrder(themeName, styleName); + } - @Override - public List getAllByThemeAndStyleOrderByPrice(String themeName, String styleName) { - return stickerRepository - .findAllByThemeNameAndStyleNameAndStateInOrderPrice(themeName, styleName); - } + @Override + public List getAllByThemeAndStyleOrderByPrice(String themeName, String styleName) { + return stickerRepository + .findAllByThemeNameAndStyleNameAndStateInOrderPrice(themeName, styleName); + } - @Override - public List getAllByThemeAndStyleOrderByPriceDesc(String themeName, String styleName) { - return stickerRepository - .findAllByThemeNameAndStyleNameAndStateInOrderPriceDesc(themeName, styleName); - } + @Override + public List getAllByThemeAndStyleOrderByPriceDesc(String themeName, String styleName) { + return stickerRepository + .findAllByThemeNameAndStyleNameAndStateInOrderPriceDesc(themeName, styleName); + } - @Override - public List getAllSameThemeOrStyleById(Integer id) { - return stickerRepository - .findAllSameThemeOrStyleById(id); - } + @Override + public List getAllSameThemeOrStyleById(Integer id) { + return stickerRepository + .findAllSameThemeOrStyleById(id); + } - @Override - public List getAllByThemeOrStyleOrNameLike(String word) { - if(Objects.isNull(word)) { - return null; - } - return stickerRepository - .findAllByThemeNameOrStyleNameOrNameContaining(word); - } + @Override + public List getAllByThemeOrStyleOrNameLike(String word) { + if (Objects.isNull(word)) { + return null; + } + return stickerRepository + .findAllByThemeNameOrStyleNameOrNameContaining(word); + } - // Todo : 리펙토링하기 of -> from? - @Override - public ReadOrderSheetStickerInfo readOrderSheetStickerInfo(Sticker sticker) { - Integer discountedPrice = getDiscountPrice(sticker); - return ReadOrderSheetStickerInfo.of( - sticker.getMainImageUrl(), - sticker.getName(), - sticker.getPrice(), - discountedPrice); - } + @Override + public ReadOrderSheetStickerInfo readOrderSheetStickerInfo(Sticker sticker) { + Integer discountedPrice = getDiscountPrice(sticker); + return ReadOrderSheetStickerInfo.of( + sticker.getMainImageUrl(), + sticker.getName(), + sticker.getPrice(), + discountedPrice); + } - private static Integer getDiscountPrice(Sticker sticker) { - if (Objects.isNull(sticker.getDiscount())) { - return null; - } - return (sticker.getPrice() * (100 - sticker.getDiscount().getDiscountRate())) / 100; - } + private static Integer getDiscountPrice(Sticker sticker) { + if (Objects.isNull(sticker.getDiscount())) { + return null; + } + return (sticker.getPrice() * (100 - sticker.getDiscount().getDiscountRate())) / 100; + } } diff --git a/server/src/main/java/org/tattour/server/domain/user/controller/UserController.java b/server/src/main/java/org/tattour/server/domain/user/controller/UserController.java index e567693f..9bc9f11a 100644 --- a/server/src/main/java/org/tattour/server/domain/user/controller/UserController.java +++ b/server/src/main/java/org/tattour/server/domain/user/controller/UserController.java @@ -28,28 +28,25 @@ import org.tattour.server.domain.custom.facade.CustomFacade; import org.tattour.server.domain.custom.facade.dto.response.ReadCustomRes; import org.tattour.server.domain.custom.facade.dto.response.ReadCustomSummaryListRes; -import org.tattour.server.domain.point.facade.PointFacade; -import org.tattour.server.domain.point.facade.dto.request.CreatePointChargeRequestReq; -import org.tattour.server.domain.user.controller.dto.request.PostPointChargeRequest; +import org.tattour.server.domain.user.controller.dto.request.PatchUserInfoReq; +import org.tattour.server.domain.user.controller.dto.request.PostLoginReq; import org.tattour.server.domain.user.controller.dto.request.PostProductLikedReq; import org.tattour.server.domain.user.controller.dto.request.PostUserShippingAddrReq; +import org.tattour.server.domain.user.controller.dto.response.PostLoginRes; import org.tattour.server.domain.user.facade.UserFacade; import org.tattour.server.domain.user.facade.dto.request.CompareVerificationCodeReq; import org.tattour.server.domain.user.facade.dto.request.CreateLoginReq; import org.tattour.server.domain.user.facade.dto.request.RemoveProductLikedReq; import org.tattour.server.domain.user.facade.dto.request.SaveProductLikedReq; -import org.tattour.server.domain.user.facade.dto.response.ReadUserProfileRes; -import org.tattour.server.domain.user.facade.dto.response.ProductLikedListRes; import org.tattour.server.domain.user.facade.dto.request.SaveUserShippingAddrReq; import org.tattour.server.domain.user.facade.dto.request.UpdateUserProfileReq; +import org.tattour.server.domain.user.facade.dto.response.ProductLikedListRes; +import org.tattour.server.domain.user.facade.dto.response.ReadUserProfileRes; import org.tattour.server.global.config.annotations.UserId; import org.tattour.server.global.dto.BaseResponse; import org.tattour.server.global.dto.FailResponse; import org.tattour.server.global.dto.SuccessResponse; import org.tattour.server.global.dto.SuccessType; -import org.tattour.server.domain.user.controller.dto.request.PostLoginReq; -import org.tattour.server.domain.user.controller.dto.request.PatchUserInfoReq; -import org.tattour.server.domain.user.controller.dto.response.PostLoginRes; @RestController @RequestMapping("/api/v1/user") @@ -58,376 +55,342 @@ @Tag(name = "User", description = "User API Document") public class UserController { - private final UserFacade userFacade; - private final PointFacade pointFacade; - private final CustomFacade customFacade; - - @Operation(summary = "소셜 회원가입 / 로그인", description = "소셜 회원가입 / 로그인 api") - @ApiResponses(value = { - @ApiResponse( - responseCode = "201", - description = "로그인에 성공했습니다.", - content = @Content(schema = @Schema(implementation = PostLoginRes.class))), - @ApiResponse( - responseCode = "400", - description = "잘못된 요청입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "404", - description = "존재하지 않는 유저입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "500", - description = "알 수 없는 서버 에러가 발생했습니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))) - }) - @PostMapping("/signup") - public ResponseEntity signup( - @Parameter(description = "Authentication Code", required = true) @RequestHeader("code") String code, - @RequestBody @Valid PostLoginReq req, - HttpServletRequest request) { - return BaseResponse.success(SuccessType.LOGIN_SUCCESS, - userFacade.signup(CreateLoginReq.of(req.getSocialPlatform(), code, - request.getHeader("origin")))); - } - - - @Operation(summary = "user 로그아웃", description = "user 로그아웃") - @ApiResponses(value = { - @ApiResponse( - responseCode = "200", - description = "로그아웃에 성공했습니다.", - content = @Content(schema = @Schema(implementation = SuccessResponse.class))), - @ApiResponse( - responseCode = "400", - description = "잘못된 요청입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "404", - description = "존재하지 않는 유저입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "500", - description = "알 수 없는 서버 에러가 발생했습니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))) - }) - @PatchMapping("/logout") - public ResponseEntity userLogout( - @Parameter(hidden = true) @UserId Integer userId - ) { - userFacade.userLogout(userId); - return BaseResponse.success(SuccessType.LOGOUT_SUCCESS); - } + private final UserFacade userFacade; + private final CustomFacade customFacade; + @Operation(summary = "소셜 회원가입 / 로그인", description = "소셜 회원가입 / 로그인 api") + @ApiResponses(value = { + @ApiResponse( + responseCode = "201", + description = "로그인에 성공했습니다.", + content = @Content(schema = @Schema(implementation = PostLoginRes.class))), + @ApiResponse( + responseCode = "400", + description = "잘못된 요청입니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))), + @ApiResponse( + responseCode = "404", + description = "존재하지 않는 유저입니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))), + @ApiResponse( + responseCode = "500", + description = "알 수 없는 서버 에러가 발생했습니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))) + }) + @PostMapping("/signup") + public ResponseEntity signup( + @Parameter(description = "Authentication Code", required = true) @RequestHeader String code, + @RequestBody @Valid PostLoginReq req, + HttpServletRequest request) { + return BaseResponse.success(SuccessType.LOGIN_SUCCESS, + userFacade.signup(CreateLoginReq.of(req.getSocialPlatform(), code, request.getHeader("origin")))); + } - @Operation(summary = "user 이름, 전화번호 추가", description = "회원가입 시 user 이름, 전화번호 추가") - @ApiResponses(value = { - @ApiResponse( - responseCode = "200", - description = "갱신에 성공했습니다.", - content = @Content(schema = @Schema(implementation = SuccessResponse.class))), - @ApiResponse( - responseCode = "400", - description = "잘못된 요청입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "404", - description = "존재하지 않는 유저입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "500", - description = "알 수 없는 서버 에러가 발생했습니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))) - }) - @PatchMapping("/profile") - public ResponseEntity updateUserProfile( - @Parameter(hidden = true) @UserId Integer userId, - @RequestBody @Valid PatchUserInfoReq req - ) { - userFacade.updateUserProfile( - UpdateUserProfileReq.of( - userId, - req.getName(), - req.getPhoneNumber())); - return BaseResponse.success(SuccessType.UPDATE_SUCCESS); - } + @Operation(summary = "user 로그아웃", description = "user 로그아웃") + @ApiResponses(value = { + @ApiResponse( + responseCode = "200", + description = "로그아웃에 성공했습니다.", + content = @Content(schema = @Schema(implementation = SuccessResponse.class))), + @ApiResponse( + responseCode = "400", + description = "잘못된 요청입니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))), + @ApiResponse( + responseCode = "404", + description = "존재하지 않는 유저입니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))), + @ApiResponse( + responseCode = "500", + description = "알 수 없는 서버 에러가 발생했습니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))) + }) + @PatchMapping("/logout") + public ResponseEntity userLogout( + @Parameter(hidden = true) @UserId Integer userId + ) { + userFacade.userLogout(userId); + return BaseResponse.success(SuccessType.LOGOUT_SUCCESS); + } - @Operation(summary = "user profile 정보 가져오기", description = "user 이름, 포인트 불러오기") - @ApiResponses(value = { - @ApiResponse( - responseCode = "200", - description = "조회에 성공했습니다.", - content = @Content(schema = @Schema(implementation = ReadUserProfileRes.class))), - @ApiResponse( - responseCode = "400", - description = "잘못된 요청입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "404", - description = "존재하지 않는 유저입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "500", - description = "알 수 없는 서버 에러가 발생했습니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))) - }) - @GetMapping("/profile") - public ResponseEntity getUserProfile( - @Parameter(hidden = true) @UserId Integer userId - ) { - return BaseResponse.success(SuccessType.GET_SUCCESS, userFacade.readUserProfile(userId)); - } + @Operation(summary = "user 이름, 전화번호 추가", description = "회원가입 시 user 이름, 전화번호 추가") + @ApiResponses(value = { + @ApiResponse( + responseCode = "200", + description = "갱신에 성공했습니다.", + content = @Content(schema = @Schema(implementation = SuccessResponse.class))), + @ApiResponse( + responseCode = "400", + description = "잘못된 요청입니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))), + @ApiResponse( + responseCode = "404", + description = "존재하지 않는 유저입니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))), + @ApiResponse( + responseCode = "500", + description = "알 수 없는 서버 에러가 발생했습니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))) + }) + @PatchMapping("/profile") + public ResponseEntity updateUserProfile( + @Parameter(hidden = true) @UserId Integer userId, + @RequestBody @Valid PatchUserInfoReq req + ) { + userFacade.updateUserProfile( + UpdateUserProfileReq.of( + userId, + req.getName(), + req.getPhoneNumber())); + return BaseResponse.success(SuccessType.UPDATE_SUCCESS); + } - @Operation(summary = "인증번호 검증", description = "user 전화번호 인증번호 검증") - @ApiResponses(value = { - // TODO : 명세서 Schema 검증하기 - @ApiResponse( - responseCode = "200", - description = "인증코드 검증에 성공했습니다.", - content = @Content(schema = @Schema(implementation = SuccessResponse.class))), - @ApiResponse( - responseCode = "202", - description = "인증번호 검증에 실패했습니다.", - content = @Content(schema = @Schema(implementation = SuccessResponse.class))), - @ApiResponse( - responseCode = "400", - description = "잘못된 요청입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "404", - description = "유효한 인증번호가 존재하지 않습니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "500", - description = "알 수 없는 서버 에러가 발생했습니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))) - }) - @GetMapping("/phonenumber/verification") - public ResponseEntity verifyCode( - @Parameter(hidden = true) @UserId Integer userId, - @Parameter(description = "인증번호", example = "123456") - @RequestParam - @NotNull(message = "verificationCode is null") - @Min(100000) - @Max(999999) - Integer verificationCode) { - if (userFacade.verifyCode(CompareVerificationCodeReq.of(userId, verificationCode))) { - return BaseResponse.success(SuccessType.CODE_VERIFICATION_SUCCESS, true); - } else { - return BaseResponse.success(SuccessType.CODE_VALIDATION_FAIL, false); - } - } + @Operation(summary = "user profile 정보 가져오기") + @ApiResponses(value = { + @ApiResponse( + responseCode = "200", + description = "조회에 성공했습니다.", + content = @Content(schema = @Schema(implementation = ReadUserProfileRes.class))), + @ApiResponse( + responseCode = "400", + description = "잘못된 요청입니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))), + @ApiResponse( + responseCode = "404", + description = "존재하지 않는 유저입니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))), + @ApiResponse( + responseCode = "500", + description = "알 수 없는 서버 에러가 발생했습니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))) + }) + @GetMapping("/profile") + public ResponseEntity getUserProfile( + @Parameter(hidden = true) @UserId Integer userId + ) { + return BaseResponse.success(SuccessType.GET_SUCCESS, userFacade.readUserProfile(userId)); + } - @Operation(summary = "좋아요 누른 타투 저장", description = "user 좋아요 누른 타투 저장") - @ApiResponses(value = { - @ApiResponse( - responseCode = "201", - description = "생성에 성공했습니다.", - content = @Content(schema = @Schema(implementation = SuccessResponse.class))), - @ApiResponse( - responseCode = "400", - description = "잘못된 요청입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "404", - description = "존재하지 않는 유저입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "404", - description = "존재하지 않는 스티커입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "409", - description = "이미 존재하는 좋아요한 상품입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "500", - description = "알 수 없는 서버 에러가 발생했습니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))) - }) - @PostMapping("/productliked/save") - public ResponseEntity saveProductLiked( - @Parameter(hidden = true) @UserId Integer userId, - @RequestBody @Valid PostProductLikedReq req - ) { - userFacade.saveProductLiked(SaveProductLikedReq.of(userId, req.getStickerId())); + @Operation(summary = "인증번호 검증", description = "user 전화번호 인증번호 검증") + @ApiResponses(value = { + @ApiResponse( + responseCode = "200", + description = "인증코드 검증에 성공했습니다.", + content = @Content(schema = @Schema(implementation = SuccessResponse.class))), + @ApiResponse( + responseCode = "202", + description = "인증번호 검증에 실패했습니다.", + content = @Content(schema = @Schema(implementation = SuccessResponse.class))), + @ApiResponse( + responseCode = "400", + description = "잘못된 요청입니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))), + @ApiResponse( + responseCode = "404", + description = "유효한 인증번호가 존재하지 않습니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))), + @ApiResponse( + responseCode = "500", + description = "알 수 없는 서버 에러가 발생했습니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))) + }) + @GetMapping("/phonenumber/verification") + public ResponseEntity verifyCode( + @Parameter(hidden = true) @UserId Integer userId, + @Parameter(description = "인증번호", example = "123456") + @RequestParam + @NotNull(message = "verificationCode is null") + @Min(100000) + @Max(999999) + Integer verificationCode) { + if (userFacade.verifyCode(CompareVerificationCodeReq.of(userId, verificationCode))) { + return BaseResponse.success(SuccessType.CODE_VERIFICATION_SUCCESS, true); + } else { + return BaseResponse.success(SuccessType.CODE_VALIDATION_FAIL, false); + } + } - return BaseResponse.success(SuccessType.CREATE_SUCCESS); - } + @Operation(summary = "좋아요 누른 타투 저장", description = "user 좋아요 누른 타투 저장") + @ApiResponses(value = { + @ApiResponse( + responseCode = "201", + description = "생성에 성공했습니다.", + content = @Content(schema = @Schema(implementation = SuccessResponse.class))), + @ApiResponse( + responseCode = "400", + description = "잘못된 요청입니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))), + @ApiResponse( + responseCode = "404", + description = "존재하지 않는 유저입니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))), + @ApiResponse( + responseCode = "404", + description = "존재하지 않는 스티커입니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))), + @ApiResponse( + responseCode = "409", + description = "이미 존재하는 좋아요한 상품입니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))), + @ApiResponse( + responseCode = "500", + description = "알 수 없는 서버 에러가 발생했습니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))) + }) + @PostMapping("/productliked/save") + public ResponseEntity saveProductLiked( + @Parameter(hidden = true) @UserId Integer userId, + @RequestBody @Valid PostProductLikedReq req + ) { + userFacade.saveProductLiked(SaveProductLikedReq.of(userId, req.getStickerId())); - @Operation(summary = "좋아요 누른 타투 삭제", description = "user 좋아요 누른 타투 삭제") - @ApiResponses(value = { - @ApiResponse( - responseCode = "200", - description = "삭제에 성공했습니다.", - content = @Content(schema = @Schema(implementation = SuccessResponse.class))), - @ApiResponse( - responseCode = "400", - description = "잘못된 요청입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "404", - description = "존재하지 않는 데이터입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "500", - description = "알 수 없는 서버 에러가 발생했습니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))) - }) - @DeleteMapping("/productliked/sticker/{stickerId}/delete") - public ResponseEntity deleteProductLiked( - @Parameter(hidden = true) @UserId Integer userId, - @Parameter(description = "스티커 id", required = true) - @PathVariable @NotNull(message = "stickerId is null") Integer stickerId - ) { - userFacade.deleteProductLiked(RemoveProductLikedReq.of(userId, stickerId)); + return BaseResponse.success(SuccessType.CREATE_SUCCESS); + } - return BaseResponse.success(SuccessType.DELETE_SUCCESS); - } + @Operation(summary = "좋아요 누른 타투 삭제", description = "user 좋아요 누른 타투 삭제") + @ApiResponses(value = { + @ApiResponse( + responseCode = "200", + description = "삭제에 성공했습니다.", + content = @Content(schema = @Schema(implementation = SuccessResponse.class))), + @ApiResponse( + responseCode = "400", + description = "잘못된 요청입니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))), + @ApiResponse( + responseCode = "404", + description = "존재하지 않는 데이터입니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))), + @ApiResponse( + responseCode = "500", + description = "알 수 없는 서버 에러가 발생했습니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))) + }) + @DeleteMapping("/productliked/sticker/{stickerId}/delete") + public ResponseEntity deleteProductLiked( + @Parameter(hidden = true) @UserId Integer userId, + @Parameter(description = "스티커 id", required = true) + @PathVariable @NotNull(message = "stickerId is null") Integer stickerId + ) { + userFacade.deleteProductLiked(RemoveProductLikedReq.of(userId, stickerId)); - @Operation(summary = "좋아요 누른 타투 불러오기", description = "user 좋아요 누른 타투 스티커 불러오기") - @ApiResponses(value = { - @ApiResponse( - responseCode = "200", - description = "조회에 성공했습니다.", - content = @Content(schema = @Schema(implementation = ProductLikedListRes.class))), - @ApiResponse( - responseCode = "400", - description = "잘못된 요청입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "500", - description = "알 수 없는 서버 에러가 발생했습니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))) - }) - @GetMapping("/productliked/saved") - public ResponseEntity getProductLiked( - @Parameter(hidden = true) @UserId Integer userId - ) { - return BaseResponse.success(SuccessType.GET_SUCCESS, - userFacade.readProductLikedByUserId(userId)); - } + return BaseResponse.success(SuccessType.DELETE_SUCCESS); + } - @Operation(summary = "배송지 등록", description = "user 배송지 등록") - @ApiResponses(value = { - @ApiResponse( - responseCode = "201", - description = "생성에 성공했습니다.", - content = @Content(schema = @Schema(implementation = SuccessResponse.class))), - @ApiResponse( - responseCode = "400", - description = "잘못된 요청입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "500", - description = "알 수 없는 서버 에러가 발생했습니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))) - }) - @PostMapping("/address") - public ResponseEntity createShippingAddr( - @Parameter(hidden = true) @UserId Integer userId, - @RequestBody @Valid PostUserShippingAddrReq req - ) { - userFacade.saveUserShippingAddr( - SaveUserShippingAddrReq.of( - userId, - req.getRecipientName(), - req.getContact(), - req.getMailingAddress(), - req.getBaseAddress(), - req.getDetailAddress())); + @Operation(summary = "좋아요 누른 타투 불러오기", description = "user 좋아요 누른 타투 스티커 불러오기") + @ApiResponses(value = { + @ApiResponse( + responseCode = "200", + description = "조회에 성공했습니다.", + content = @Content(schema = @Schema(implementation = ProductLikedListRes.class))), + @ApiResponse( + responseCode = "400", + description = "잘못된 요청입니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))), + @ApiResponse( + responseCode = "500", + description = "알 수 없는 서버 에러가 발생했습니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))) + }) + @GetMapping("/productliked/saved") + public ResponseEntity getProductLiked( + @Parameter(hidden = true) @UserId Integer userId + ) { + return BaseResponse.success(SuccessType.GET_SUCCESS, + userFacade.readProductLikedByUserId(userId)); + } - return BaseResponse.success(SuccessType.CREATE_SUCCESS); - } + @Operation(summary = "배송지 등록", description = "user 배송지 등록") + @ApiResponses(value = { + @ApiResponse( + responseCode = "201", + description = "생성에 성공했습니다.", + content = @Content(schema = @Schema(implementation = SuccessResponse.class))), + @ApiResponse( + responseCode = "400", + description = "잘못된 요청입니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))), + @ApiResponse( + responseCode = "500", + description = "알 수 없는 서버 에러가 발생했습니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))) + }) + @PostMapping("/address") + public ResponseEntity createShippingAddr( + @Parameter(hidden = true) @UserId Integer userId, + @RequestBody @Valid PostUserShippingAddrReq req + ) { + userFacade.saveUserShippingAddr( + SaveUserShippingAddrReq.of( + userId, + req.getRecipientName(), + req.getContact(), + req.getMailingAddress(), + req.getBaseAddress(), + req.getDetailAddress())); - @Operation(summary = "포인트 충전 신청", description = "user 포인트 충전 신청") - @ApiResponses(value = { - @ApiResponse( - responseCode = "201", - description = "생성에 성공했습니다.", - content = @Content(schema = @Schema(implementation = SuccessResponse.class))), - @ApiResponse( - responseCode = "400", - description = "잘못된 요청입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "404", - description = "존재하지 않는 유저입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "500", - description = "알 수 없는 서버 에러가 발생했습니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))) - }) - @PostMapping("/point/charge") - public ResponseEntity createPointChargeRequest( - @Parameter(hidden = true) @UserId Integer userId, - @RequestBody @Valid PostPointChargeRequest req - ) { - pointFacade.createPointChargeRequest( - CreatePointChargeRequestReq.of(userId, req.getChargeAmount())); - return BaseResponse.success(SuccessType.CREATE_POINT_CHARGE_REQUEST_SUCCESS); - } + return BaseResponse.success(SuccessType.CREATE_SUCCESS); + } - @GetMapping("/custom/complete") - @Operation(summary = "신청한 커스텀 도안 조회") - @ApiResponses(value = { - @ApiResponse(responseCode = "200", - description = "success", - content = @Content(schema = @Schema(implementation = ReadCustomSummaryListRes.class))), - @ApiResponse(responseCode = "400, 500", - description = "error", - content = @Content(schema = @Schema(implementation = FailResponse.class))) - }) - public ResponseEntity getUserCustomCompleteList( - @Parameter(hidden = true) @UserId Integer userId - ) { - ReadCustomSummaryListRes response = - customFacade.readCustomSummaryCompleteListByUserId(userId); - return BaseResponse.success(SuccessType.READ_COMPLETE_CUSTOM_SUMMARY_SUCCESS, response); - } + @GetMapping("/custom/complete") + @Operation(summary = "신청한 커스텀 도안 조회") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", + description = "success", + content = @Content(schema = @Schema(implementation = ReadCustomSummaryListRes.class))), + @ApiResponse(responseCode = "400, 500", + description = "error", + content = @Content(schema = @Schema(implementation = FailResponse.class))) + }) + public ResponseEntity getUserCustomCompleteList( + @Parameter(hidden = true) @UserId Integer userId + ) { + ReadCustomSummaryListRes response = + customFacade.readCustomSummaryCompleteListByUserId(userId); + return BaseResponse.success(SuccessType.READ_COMPLETE_CUSTOM_SUMMARY_SUCCESS, response); + } - @GetMapping("/custom/incomplete") - @Operation(summary = "커스텀 도안 임시저장 조회") - @ApiResponses(value = { - @ApiResponse(responseCode = "200", - description = "success", - content = @Content(schema = @Schema(implementation = ReadCustomSummaryListRes.class))), - @ApiResponse(responseCode = "400, 500", - description = "error", - content = @Content(schema = @Schema(implementation = FailResponse.class))) - }) - public ResponseEntity getUserCustomIncompleteList( - @Parameter(hidden = true) @UserId Integer userId - ) { - ReadCustomSummaryListRes response = - customFacade.readCustomSummaryInCompleteListByUserId(userId); - return BaseResponse.success(SuccessType.READ_INCOMPLETE_CUSTOM_SUMMARY_SUCCESS, response); - } + @GetMapping("/custom/incomplete") + @Operation(summary = "커스텀 도안 임시저장 조회") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", + description = "success", + content = @Content(schema = @Schema(implementation = ReadCustomSummaryListRes.class))), + @ApiResponse(responseCode = "400, 500", + description = "error", + content = @Content(schema = @Schema(implementation = FailResponse.class))) + }) + public ResponseEntity getUserCustomIncompleteList( + @Parameter(hidden = true) @UserId Integer userId + ) { + ReadCustomSummaryListRes response = + customFacade.readCustomSummaryInCompleteListByUserId(userId); + return BaseResponse.success(SuccessType.READ_INCOMPLETE_CUSTOM_SUMMARY_SUCCESS, response); + } - @GetMapping("/custom/{customId}") - @Operation(summary = "내 도안 상세정보 조회") - @ApiResponses(value = { - @ApiResponse(responseCode = "200", - description = "success", - content = @Content(schema = @Schema(implementation = ReadCustomRes.class))), - @ApiResponse(responseCode = "400, 500", - description = "error", - content = @Content(schema = @Schema(implementation = FailResponse.class))) - }) - public ResponseEntity getOneUserCustomInfo( - @Parameter(hidden = true) @UserId Integer userId, - @PathVariable(value = "customId") Integer customId - ) { - ReadCustomRes response = customFacade.readCustomById(customId, userId); - return BaseResponse.success(SuccessType.READ_ONE_CUSTOM_SUCCESS, response); - } + @GetMapping("/custom/{customId}") + @Operation(summary = "내 도안 상세정보 조회") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", + description = "success", + content = @Content(schema = @Schema(implementation = ReadCustomRes.class))), + @ApiResponse(responseCode = "400, 500", + description = "error", + content = @Content(schema = @Schema(implementation = FailResponse.class))) + }) + public ResponseEntity getOneUserCustomInfo( + @Parameter(hidden = true) @UserId Integer userId, + @PathVariable(value = "customId") Integer customId + ) { + ReadCustomRes response = customFacade.readCustomById(customId, userId); + return BaseResponse.success(SuccessType.READ_ONE_CUSTOM_SUCCESS, response); + } } \ No newline at end of file diff --git a/server/src/main/java/org/tattour/server/domain/user/domain/User.java b/server/src/main/java/org/tattour/server/domain/user/domain/User.java index eb873c0c..d6cb7c6b 100644 --- a/server/src/main/java/org/tattour/server/domain/user/domain/User.java +++ b/server/src/main/java/org/tattour/server/domain/user/domain/User.java @@ -30,8 +30,7 @@ public class User { @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer id; private String name; - private Long kakaoId; - private Integer point; + private Long socialId; private String phoneNumber; private String accessToken; private String refreshToken; @@ -51,26 +50,26 @@ public class User { @OneToMany(mappedBy = "user", cascade = CascadeType.ALL) private List productLikeds; - public User(Long kakaoId, SocialPlatform socialPlatform, String accessToken, - String refreshToken) { - this.kakaoId = kakaoId; + public User(Long socialId, SocialPlatform socialPlatform, String accessToken, + String refreshToken) { + this.socialId = socialId; this.socialPlatform = socialPlatform; this.accessToken = accessToken; this.refreshToken = refreshToken; } - public User(Long kakaoId, SocialPlatform socialPlatform) { - this.kakaoId = kakaoId; + public User(Long socialId, SocialPlatform socialPlatform) { + this.socialId = socialId; this.socialPlatform = socialPlatform; } - public static User of(Long kakaoId, SocialPlatform socialPlatform, String accessToken, - String refreshToken) { - return new User(kakaoId, socialPlatform, accessToken, refreshToken); + public static User of(Long socialId, SocialPlatform socialPlatform, String accessToken, + String refreshToken) { + return new User(socialId, socialPlatform, accessToken, refreshToken); } - public static User of(Long kakaoId, SocialPlatform socialPlatform) { - return new User(kakaoId, socialPlatform); + public static User of(Long socialId, SocialPlatform socialPlatform) { + return new User(socialId, socialPlatform); } public void setUserInfo(String name, String phoneNumber) { @@ -83,16 +82,8 @@ public void setSocialToken(String accessToken, String refreshToken) { this.refreshToken = refreshToken; } - public void setUserPoint(int amount) { - this.point = amount; - } - public void deleteToken() { this.accessToken = null; this.refreshToken = null; } - - public boolean isLackOfPoint(int amount) { - return this.point < amount; - } } diff --git a/server/src/main/java/org/tattour/server/domain/user/facade/impl/UserFacadeImpl.java b/server/src/main/java/org/tattour/server/domain/user/facade/impl/UserFacadeImpl.java index 56390b0c..d05cb308 100644 --- a/server/src/main/java/org/tattour/server/domain/user/facade/impl/UserFacadeImpl.java +++ b/server/src/main/java/org/tattour/server/domain/user/facade/impl/UserFacadeImpl.java @@ -51,15 +51,13 @@ public PostLoginRes signup(CreateLoginReq req) { } System.out.println("Origin = " + req.getOrigin()); - SocialService socialService = socialServiceProvider - .getSocialService(req.getSocialPlatform()); + SocialService socialService = socialServiceProvider.getSocialService(req.getSocialPlatform()); - KakaoLoginInfo kakaoLoginInfo = - (KakaoLoginInfo) socialService.getSocialLoginResponse( - GetSocialLoginReq.of(req.getCode(), req.getOrigin())); + KakaoLoginInfo kakaoLoginInfo = (KakaoLoginInfo) socialService + .getSocialLoginResponse(GetSocialLoginReq.of(req.getCode(), req.getOrigin())); - boolean isUserExist = userProvider.checkDuplicationByKakaoId( - kakaoLoginInfo.getSocialUserInfoRes().getId()); + boolean isUserExist = userProvider + .checkDuplicationByKakaoId(kakaoLoginInfo.getSocialUserInfoRes().getId()); User user = isUserExist ? userProvider.readUserByKakaoId(kakaoLoginInfo.getSocialUserInfoRes().getId()) @@ -100,8 +98,8 @@ public ReadUserProfileRes readUserProfile(int userId) { @Override public Boolean verifyCode(CompareVerificationCodeReq req) { - return phoneNumberVerificationCodeProvider.compareVerficationCode(req.getUserId(), - req.getVerificationCode()); + return phoneNumberVerificationCodeProvider + .compareVerficationCode(req.getUserId(), req.getVerificationCode()); } @Override diff --git a/server/src/main/java/org/tattour/server/domain/user/provider/UserProvider.java b/server/src/main/java/org/tattour/server/domain/user/provider/UserProvider.java index 5e2f6cc5..a355edc5 100644 --- a/server/src/main/java/org/tattour/server/domain/user/provider/UserProvider.java +++ b/server/src/main/java/org/tattour/server/domain/user/provider/UserProvider.java @@ -2,7 +2,6 @@ import org.tattour.server.domain.user.domain.User; import org.tattour.server.domain.user.provider.vo.HomeUserInfo; -import org.tattour.server.domain.user.provider.vo.UserPointAfterOrderInfo; import org.tattour.server.domain.user.provider.vo.UserProfileInfo; public interface UserProvider { @@ -20,13 +19,4 @@ public interface UserProvider { // 이메일로 유저 중복 확인 boolean checkDuplicationByKakaoId(Long kakaoId); - - // 포인트 부족 확인 - Boolean isUserPointLack(User user, int totalAmount); - - // 주문 후 포인트 정보 가져오기 - UserPointAfterOrderInfo readUserPointAfterOrderInfo(User user, int totalAmount); - - // 주문 후 남은 포인트 계산 - int calculateRestPointAfterOrder(int userPoint, int totalAmount); } diff --git a/server/src/main/java/org/tattour/server/domain/user/provider/impl/ProductLikedProviderImpl.java b/server/src/main/java/org/tattour/server/domain/user/provider/impl/ProductLikedProviderImpl.java index 901d723e..5c1053cc 100644 --- a/server/src/main/java/org/tattour/server/domain/user/provider/impl/ProductLikedProviderImpl.java +++ b/server/src/main/java/org/tattour/server/domain/user/provider/impl/ProductLikedProviderImpl.java @@ -27,14 +27,9 @@ public ProductLiked readProductLikedByUserIdAndStickerId(Integer userId, Integer .orElseThrow(() -> new BusinessException(ErrorType.NOT_FOUND_RESOURCE)); } - //TODO : 리팩토링? @Override public List readLikedProductsByUserId(Integer userId) { return productLikedRepository.findAllByUser_IdOrderByCreatedAtDesc(userId); - // 모아서 리스트로 만들기 -// List stickerList = productLikedList.stream() -// .map(ProductLiked::getSticker) -// .collect(Collectors.toList()); } @Override diff --git a/server/src/main/java/org/tattour/server/domain/user/provider/impl/UserProviderImpl.java b/server/src/main/java/org/tattour/server/domain/user/provider/impl/UserProviderImpl.java index 0f7878e4..1991005c 100644 --- a/server/src/main/java/org/tattour/server/domain/user/provider/impl/UserProviderImpl.java +++ b/server/src/main/java/org/tattour/server/domain/user/provider/impl/UserProviderImpl.java @@ -6,7 +6,6 @@ import org.tattour.server.domain.user.exception.NotFoundUserException; import org.tattour.server.domain.user.provider.UserProvider; import org.tattour.server.domain.user.provider.vo.HomeUserInfo; -import org.tattour.server.domain.user.provider.vo.UserPointAfterOrderInfo; import org.tattour.server.domain.user.provider.vo.UserProfileInfo; import org.tattour.server.domain.user.repository.impl.UserRepositoryImpl; import org.tattour.server.global.util.EntityDtoMapper; @@ -25,7 +24,7 @@ public User readUserById(int id) { @Override public User readUserByKakaoId(Long kakaoId) { - return userRepository.findByKakaoId(kakaoId) + return userRepository.findBySocialId(kakaoId) .orElseThrow(NotFoundUserException::new); } @@ -41,25 +40,6 @@ public UserProfileInfo readUserProfileInfo(User user) { @Override public boolean checkDuplicationByKakaoId(Long kakaoId) { - return userRepository.findByKakaoId(kakaoId).isPresent(); - } - - @Override - public Boolean isUserPointLack(User user, int totalAmount) { - return totalAmount > user.getPoint(); - } - - @Override - public UserPointAfterOrderInfo readUserPointAfterOrderInfo(User user, int totalAmount) { - int userPoint = user.getPoint(); - int resultPoint = calculateRestPointAfterOrder(userPoint, totalAmount); - boolean isLacked = resultPoint < 0; - - return UserPointAfterOrderInfo.of(userPoint, resultPoint, isLacked); - } - - @Override - public int calculateRestPointAfterOrder(int userPoint, int totalAmount) { - return userPoint - totalAmount; + return userRepository.findBySocialId(kakaoId).isPresent(); } } diff --git a/server/src/main/java/org/tattour/server/domain/user/provider/vo/HomeUserInfo.java b/server/src/main/java/org/tattour/server/domain/user/provider/vo/HomeUserInfo.java index 94599f73..f4d43715 100644 --- a/server/src/main/java/org/tattour/server/domain/user/provider/vo/HomeUserInfo.java +++ b/server/src/main/java/org/tattour/server/domain/user/provider/vo/HomeUserInfo.java @@ -11,10 +11,7 @@ public class HomeUserInfo { @Schema(description = "이름", example = "userName") private String name; - @Schema(description = "포인트", example = "3000") - private Integer point; - - public static HomeUserInfo of(String name, Integer point) { - return new HomeUserInfo(name, point); + public static HomeUserInfo of(String name) { + return new HomeUserInfo(name); } } diff --git a/server/src/main/java/org/tattour/server/domain/user/provider/vo/UserContactInfo.java b/server/src/main/java/org/tattour/server/domain/user/provider/vo/UserContactInfo.java deleted file mode 100644 index 2934af33..00000000 --- a/server/src/main/java/org/tattour/server/domain/user/provider/vo/UserContactInfo.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.tattour.server.domain.user.provider.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Getter; -import lombok.Setter; - -@Schema(description = "user 정보") -@Getter -@Setter -public class UserContactInfo { - - @Schema(description = "user id") - private Integer id; - - @Schema(description = "이름", example = "userName") - private String name; - - @Schema(description = "전화번호", example = "01012345678") - private String phoneNumber; -} diff --git a/server/src/main/java/org/tattour/server/domain/user/provider/vo/UserProfileInfo.java b/server/src/main/java/org/tattour/server/domain/user/provider/vo/UserProfileInfo.java index d01afa10..89eba478 100644 --- a/server/src/main/java/org/tattour/server/domain/user/provider/vo/UserProfileInfo.java +++ b/server/src/main/java/org/tattour/server/domain/user/provider/vo/UserProfileInfo.java @@ -8,11 +8,13 @@ @Builder @Getter public class UserProfileInfo { + @Schema(description = "user Id") private int id; + @Schema(description = "user 이름", example = "김타투") private String name; + @Schema(description = "user 전화번호", example = "01012345678") private String phoneNumber; - } diff --git a/server/src/main/java/org/tattour/server/domain/user/repository/impl/UserRepositoryImpl.java b/server/src/main/java/org/tattour/server/domain/user/repository/impl/UserRepositoryImpl.java index ae488966..e4241d3e 100644 --- a/server/src/main/java/org/tattour/server/domain/user/repository/impl/UserRepositoryImpl.java +++ b/server/src/main/java/org/tattour/server/domain/user/repository/impl/UserRepositoryImpl.java @@ -7,12 +7,5 @@ @Repository public interface UserRepositoryImpl extends JpaRepository { - - @Override - S save(S entity); - - @Override - Optional findById(Integer integer); - - Optional findByKakaoId(Long kakaoId); + Optional findBySocialId(Long socialId); } diff --git a/server/src/main/java/org/tattour/server/domain/user/service/UserService.java b/server/src/main/java/org/tattour/server/domain/user/service/UserService.java index 60d5dd62..b1b1b78c 100644 --- a/server/src/main/java/org/tattour/server/domain/user/service/UserService.java +++ b/server/src/main/java/org/tattour/server/domain/user/service/UserService.java @@ -15,7 +15,4 @@ public interface UserService { // 로그아웃 void deleteSocialAccessToken(Integer userId); - - // 유저 포인트 수정 - void updateUserPoint(User user, Integer totalAmount); } diff --git a/server/src/main/java/org/tattour/server/domain/user/service/impl/UserServiceImpl.java b/server/src/main/java/org/tattour/server/domain/user/service/impl/UserServiceImpl.java index 9dfb42a5..3024e11b 100644 --- a/server/src/main/java/org/tattour/server/domain/user/service/impl/UserServiceImpl.java +++ b/server/src/main/java/org/tattour/server/domain/user/service/impl/UserServiceImpl.java @@ -3,13 +3,11 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.tattour.server.domain.user.domain.User; import org.tattour.server.domain.user.exception.NotFoundUserException; import org.tattour.server.domain.user.provider.impl.UserProviderImpl; import org.tattour.server.domain.user.repository.impl.UserRepositoryImpl; import org.tattour.server.domain.user.service.UserService; -import org.tattour.server.domain.user.domain.User; -import org.tattour.server.global.exception.BusinessException; -import org.tattour.server.global.exception.ErrorType; @Service @RequiredArgsConstructor @@ -43,12 +41,4 @@ public void deleteSocialAccessToken(Integer userId) { user.deleteToken(); userRepository.save(user); } - - @Override - @Transactional - public void updateUserPoint(User user, Integer totalAmount) { - int resultPoint = user.getPoint() + totalAmount; - user.setUserPoint(resultPoint); - userRepository.save(user); - } } diff --git a/server/src/main/java/org/tattour/server/global/config/interceptors/AdminRoleInterceptor.java b/server/src/main/java/org/tattour/server/global/config/interceptors/AdminRoleInterceptor.java index b1835ff6..6602dfbc 100644 --- a/server/src/main/java/org/tattour/server/global/config/interceptors/AdminRoleInterceptor.java +++ b/server/src/main/java/org/tattour/server/global/config/interceptors/AdminRoleInterceptor.java @@ -32,8 +32,6 @@ public boolean preHandle( final JwtContent content = jwtService.getJwtContents(token); try { - System.out.println("content.getRole() = " + content.getRole()); - final UserRole role = UserRole.valueOf(content.getRole()); if (!role.equals(UserRole.ADMIN)) { diff --git a/server/src/main/java/org/tattour/server/global/config/resolver/UserIdResolver.java b/server/src/main/java/org/tattour/server/global/config/resolver/UserIdResolver.java index 257d5bed..824c459c 100644 --- a/server/src/main/java/org/tattour/server/global/config/resolver/UserIdResolver.java +++ b/server/src/main/java/org/tattour/server/global/config/resolver/UserIdResolver.java @@ -21,7 +21,6 @@ public class UserIdResolver implements HandlerMethodArgumentResolver { private final JwtService jwtService; - private static final String HEADER_PREFIX = "Bearer "; @Override public boolean supportsParameter(MethodParameter parameter) { @@ -46,8 +45,6 @@ public Object resolveArgument( final JwtContent content = jwtService.getJwtContents(token); try { - System.out.println("content.getRole() = " + content.getRole()); - final UserRole role = UserRole.valueOf(content.getRole()); final Integer userId = Integer.parseInt(content.getUserId()); diff --git a/server/src/main/java/org/tattour/server/global/util/EntityDtoMapper.java b/server/src/main/java/org/tattour/server/global/util/EntityDtoMapper.java index dece6f17..d96389be 100644 --- a/server/src/main/java/org/tattour/server/global/util/EntityDtoMapper.java +++ b/server/src/main/java/org/tattour/server/global/util/EntityDtoMapper.java @@ -11,12 +11,9 @@ import org.tattour.server.domain.order.domain.Order; import org.tattour.server.domain.order.provider.vo.OrderHistoryInfo; import org.tattour.server.domain.order.provider.vo.UserOrderHistoryInfo; -import org.tattour.server.domain.point.domain.PointChargeRequest; -import org.tattour.server.domain.point.provider.vo.PointChargeRequestInfo; import org.tattour.server.domain.sticker.provider.vo.StickerLikedInfo; import org.tattour.server.domain.user.domain.ProductLiked; import org.tattour.server.domain.user.domain.User; -import org.tattour.server.domain.user.provider.vo.UserContactInfo; import org.tattour.server.domain.user.provider.vo.HomeUserInfo; import org.tattour.server.domain.user.provider.vo.UserProfileInfo; @@ -28,9 +25,6 @@ public interface EntityDtoMapper { // User HomeUserInfo toHomeUserInfo(User user); - @Mapping(target = "id", source = "user.id") - UserContactInfo toUserContactInfo(User user); - @Mapping(target = "id", source = "user.id") UserProfileInfo toUserProfileInfo(User user); @@ -65,12 +59,6 @@ public interface EntityDtoMapper { @IterableMapping(elementTargetType = OrderHistoryInfo.class) List toOrderHistoryInfoPage(Page orderPage); - // Point - @Mapping(target = "userId", source = "user.id") - PointChargeRequestInfo toGetPointChargeRequestRes(PointChargeRequest pointChargeRequest); - - List toGetPointChargeRequestResList( - List pointChargeRequestList); // Custom CreateCustomSummaryRes toCustomApplySummaryInfo(Custom custom); diff --git a/server/src/main/java/org/tattour/server/infra/socialLogin/client/kakao/service/impl/KakaoSocialService.java b/server/src/main/java/org/tattour/server/infra/socialLogin/client/kakao/service/impl/KakaoSocialService.java index 89fbe722..307c2e1c 100644 --- a/server/src/main/java/org/tattour/server/infra/socialLogin/client/kakao/service/impl/KakaoSocialService.java +++ b/server/src/main/java/org/tattour/server/infra/socialLogin/client/kakao/service/impl/KakaoSocialService.java @@ -5,12 +5,10 @@ import org.springframework.stereotype.Service; import org.tattour.server.infra.socialLogin.client.kakao.KakaoApiClient; import org.tattour.server.infra.socialLogin.client.kakao.KakaoAuthApiClient; -import org.tattour.server.infra.socialLogin.client.kakao.service.dto.response.KakaoAccessTokenRes; -import org.tattour.server.infra.socialLogin.client.kakao.service.dto.response.KakaoUserInfoRes; import org.tattour.server.infra.socialLogin.client.kakao.service.SocialService; import org.tattour.server.infra.socialLogin.client.kakao.service.dto.request.GetSocialLoginReq; -import org.tattour.server.domain.user.provider.impl.UserProviderImpl; -import org.tattour.server.domain.user.service.impl.UserServiceImpl; +import org.tattour.server.infra.socialLogin.client.kakao.service.dto.response.KakaoAccessTokenRes; +import org.tattour.server.infra.socialLogin.client.kakao.service.dto.response.KakaoUserInfoRes; import org.tattour.server.infra.socialLogin.client.kakao.service.vo.KakaoLoginInfo; @Service @@ -22,8 +20,6 @@ public class KakaoSocialService extends SocialService { private final KakaoApiClient kakaoApiClient; private final KakaoAuthApiClient kakaoAuthApiClient; - private final UserServiceImpl userService; - private final UserProviderImpl userProvider; @Override public KakaoLoginInfo getSocialLoginResponse(GetSocialLoginReq req) {