Skip to content

Commit

Permalink
๐Ÿš€ :: Api-v0.0.8-1
Browse files Browse the repository at this point in the history
๐Ÿš€ :: Api-v0.0.8-1
  • Loading branch information
ImNM authored Jan 31, 2023
2 parents 2fb76ed + 35ab5a6 commit 4e3efb4
Show file tree
Hide file tree
Showing 101 changed files with 2,132 additions and 372 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,35 @@
import band.gosrock.common.annotation.ExplainError;
import band.gosrock.common.exception.DuDoongCodeException;
import band.gosrock.common.interfaces.SwaggerExampleExceptions;
import band.gosrock.domain.domains.cart.exception.CartInvalidItemKindPolicyException;
import band.gosrock.domain.domains.cart.exception.CartInvalidOptionAnswerException;
import band.gosrock.domain.domains.cart.exception.CartItemNotOneTypeException;
import band.gosrock.domain.domains.cart.exception.CartNotAnswerAllOptionGroupException;
import band.gosrock.domain.domains.event.exception.EventIsNotOpenStatusException;
import band.gosrock.domain.domains.event.exception.EventTicketingTimeIsPassedException;
import band.gosrock.domain.domains.ticket_item.exception.TicketItemQuantityLackException;
import band.gosrock.domain.domains.ticket_item.exception.TicketPurchaseLimitException;

@ExceptionDoc
public class CreateCartExceptionDocs implements SwaggerExampleExceptions {

@ExplainError("์•„์ดํ…œ์— ๋Œ€ํ•œ ์˜ต์…˜์— ๋Œ€ํ•œ ์‘๋‹ต์„ ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ์•ˆํ–ˆ์„๋•Œ ( ํ•œ ์˜ต์…˜๊ทธ๋ฃน์— ํ•œ ์‘๋‹ต, ์˜ต์…˜๊ทธ๋ฃน์— ์‘๋‹ต์•ˆํ–ˆ์„๋•Œ)")
public DuDoongCodeException ์‘๋‹ต_์˜ฌ๋ฐ”๋ฅด๊ฒŒ_์•ˆํ–ˆ์„_๋•Œ = CartInvalidOptionAnswerException.EXCEPTION;

@ExplainError("์นดํŠธ๋ฅผ ๋‹ด์„ ๋•Œ ํ•œ ์•„์ดํ…œ ์ข…๋ฅ˜ ( ํ•œ ์•„์ด๋””๋กœ๋งŒ ๋‹ด์•„์ฃผ์„ธ์š” ), ์ •์ฑ… ์œ„๋ฐ˜์ž…๋‹ˆ๋‹ค.")
public DuDoongCodeException ํ•œ_์ข…๋ฅ˜_์•„์ดํ…œ๋งŒ_์žฅ๋ฐ”๊ตฌ๋‹ˆ์— = CartInvalidItemKindPolicyException.EXCEPTION;
@ExplainError("๋ชจ๋“  ์งˆ๋ฌธ์ง€์— ๋Œ€๋‹ต์„ ์•ˆํ–ˆ์„ ๋•Œ")
public DuDoongCodeException ์‘๋‹ต_๋‹ค๋Œ€๋‹ต_์•ˆํ–ˆ์„๋•Œ = CartNotAnswerAllOptionGroupException.EXCEPTION;

@ExplainError("์ด๋ฒคํŠธ๊ฐ€ ์—ด๋ฆฐ ์ƒํƒœ๊ฐ€ ์•„๋‹๋•Œ")
public DuDoongCodeException ์ด๋ฒคํŠธ_๋‹ซํž˜ = EventIsNotOpenStatusException.EXCEPTION;

@ExplainError("์ด๋ฒคํŠธ ํ‹ฐ์ผ“ํŒ… ์‹œ๊ฐ„์ด ์ง€๋‚ฌ์„๋•Œ.")
public DuDoongCodeException ํ‹ฐ์ผ“ํŒ…_์‹œ๊ฐ„์ง€๋‚จ = EventTicketingTimeIsPassedException.EXCEPTION;

@ExplainError("ํ‹ฐ์ผ“ ์•„์ดํ…œ์ด ํ•œ ์ข…๋ฅ˜๊ฐ€ ์•„๋‹ ๋–„")
public DuDoongCodeException ์•„์ดํ…œ์€_ํ•œ์ข…๋ฅ˜์—ฌ์•ผํ•จ = CartItemNotOneTypeException.EXCEPTION;

@ExplainError("์•„์ดํ…œ์˜ ์žฌ๊ณ ๊ฐ€ ๋ถ€์กฑํ•œ ์ƒํƒœ์ผ ๋•Œ")
public DuDoongCodeException ํ‹ฐ์ผ“ํŒ…_์žฌ๊ณ ๋ถ€์กฑ = TicketItemQuantityLackException.EXCEPTION;

@ExplainError("ํ‹ฐ์ผ“๋‹น 1์ธ๋‹น ๊ตฌ๋งค๊ฐฏ์ˆ˜ ์ œํ•œ์„ ๋„˜์—ˆ์„๋•Œ")
public DuDoongCodeException ํ‹ฐ์ผ“ํŒ…_๊ตฌ๋งค๊ฐฏ์ˆ˜์ œํ•œ = TicketPurchaseLimitException.EXCEPTION;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@

import band.gosrock.api.comment.model.request.CreateCommentRequest;
import band.gosrock.api.comment.model.response.CreateCommentResponse;
import band.gosrock.api.comment.model.response.RetrieveCommentCountResponse;
import band.gosrock.api.comment.model.response.RetrieveCommentListResponse;
import band.gosrock.api.comment.model.response.RetrieveRandomCommentResponse;
import band.gosrock.api.comment.service.CreateCommentUseCase;
import band.gosrock.api.comment.service.DeleteCommentUseCase;
import band.gosrock.api.comment.service.RetrieveCommentCountUseCase;
import band.gosrock.api.comment.service.RetrieveCommentUseCase;
import band.gosrock.api.comment.service.RetrieveRandomCommentUseCase;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import javax.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
Expand All @@ -30,6 +36,12 @@ public class CommentController {

private final RetrieveCommentUseCase retrieveCommentUseCase;

private final DeleteCommentUseCase deleteCommentUseCase;

private final RetrieveCommentCountUseCase retrieveCommentCountUseCase;

private final RetrieveRandomCommentUseCase retrieveRandomCommentUseCase;

@Operation(summary = "์‘์›๊ธ€์„ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.")
@PostMapping
public CreateCommentResponse postComment(
Expand All @@ -44,4 +56,22 @@ public RetrieveCommentListResponse getComments(
@PathVariable Long eventId, @RequestParam(required = false) Long lastId) {
return retrieveCommentUseCase.execute(eventId, lastId);
}

@Operation(summary = "[์–ด๋“œ๋ฏผ ๊ธฐ๋Šฅ] ์‘์›๊ธ€์„ ์‚ญ์ œํ•ฉ๋‹ˆ๋‹ค.")
@DeleteMapping(value = "/{commentId}")
public void deleteComment(@PathVariable Long eventId, @PathVariable Long commentId) {
deleteCommentUseCase.execute(eventId, commentId);
}

@Operation(summary = "์‘์›๊ธ€ ๊ฐœ์ˆ˜๋ฅผ ์นด์šดํŒ…ํ•ฉ๋‹ˆ๋‹ค.")
@GetMapping(value = "/counts")
public RetrieveCommentCountResponse getCommentCounts(@PathVariable Long eventId) {
return retrieveCommentCountUseCase.execute(eventId);
}

@Operation(summary = "์‘์›๊ธ€์„ ๋žœ๋ค์œผ๋กœ ๋ฝ‘์•„์˜ต๋‹ˆ๋‹ค.")
@GetMapping(value = "/random")
public RetrieveRandomCommentResponse getRandomComment(@PathVariable Long eventId) {
return retrieveRandomCommentUseCase.execute(eventId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

import band.gosrock.api.comment.model.request.CreateCommentRequest;
import band.gosrock.api.comment.model.response.CreateCommentResponse;
import band.gosrock.api.comment.model.response.RetrieveCommentCountResponse;
import band.gosrock.api.comment.model.response.RetrieveCommentListResponse;
import band.gosrock.api.comment.model.response.RetrieveRandomCommentResponse;
import band.gosrock.common.annotation.Mapper;
import band.gosrock.domain.domains.comment.adaptor.CommentAdaptor;
import band.gosrock.domain.domains.comment.domain.Comment;
Expand Down Expand Up @@ -35,4 +37,17 @@ public RetrieveCommentListResponse toRetrieveCommentListResponse(
Slice<Comment> comments = commentAdaptor.searchComment(commentCondition);
return RetrieveCommentListResponse.of(comments, currentUserId);
}

@Transactional(readOnly = true)
public Comment retrieveComment(Long commentId) {
return commentAdaptor.queryComment(commentId);
}

public RetrieveCommentCountResponse toRetrieveCommentCountResponse(Long commentCount) {
return RetrieveCommentCountResponse.of(commentCount);
}

public RetrieveRandomCommentResponse toRetrieveRandomCommentResponse(Comment comment) {
return RetrieveRandomCommentResponse.of(comment);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package band.gosrock.api.comment.model.response;


import lombok.Builder;
import lombok.Getter;

@Getter
@Builder
public class RetrieveCommentCountResponse {

private final Long commentCounts;

public static RetrieveCommentCountResponse of(Long commentCounts) {
return RetrieveCommentCountResponse.builder().commentCounts(commentCounts).build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package band.gosrock.api.comment.model.response;


import band.gosrock.domain.common.vo.CommentInfoVo;
import band.gosrock.domain.domains.comment.domain.Comment;
import lombok.Builder;
import lombok.Getter;

@Getter
@Builder
public class RetrieveRandomCommentResponse {

private final CommentInfoVo commentInfo;

public static RetrieveRandomCommentResponse of(Comment comment) {
return RetrieveRandomCommentResponse.builder()
.commentInfo(comment.toCommentInfoVo())
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package band.gosrock.api.comment.service;


import band.gosrock.api.comment.mapper.CommentMapper;
import band.gosrock.api.common.UserUtils;
import band.gosrock.common.annotation.UseCase;
import band.gosrock.domain.domains.comment.domain.Comment;
import band.gosrock.domain.domains.comment.service.CommentDomainService;
import band.gosrock.domain.domains.event.service.EventService;
import lombok.RequiredArgsConstructor;
import org.springframework.transaction.annotation.Transactional;

@UseCase
@RequiredArgsConstructor
public class DeleteCommentUseCase {

private final UserUtils userUtils;

private final CommentMapper commentMapper;

private final EventService eventService;

private final CommentDomainService commentDomainService;

@Transactional
public void execute(Long eventId, Long commentId) {
Long currentUserId = userUtils.getCurrentUserId();
// ๊ถŒํ•œ ๊ฒ€์‚ฌ
eventService.checkEventHost(currentUserId, eventId);
Comment comment = commentMapper.retrieveComment(commentId);
commentDomainService.deleteComment(comment, eventId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package band.gosrock.api.comment.service;


import band.gosrock.api.comment.mapper.CommentMapper;
import band.gosrock.api.comment.model.response.RetrieveCommentCountResponse;
import band.gosrock.common.annotation.UseCase;
import band.gosrock.domain.domains.comment.adaptor.CommentAdaptor;
import band.gosrock.domain.domains.event.adaptor.EventAdaptor;
import band.gosrock.domain.domains.event.domain.Event;
import lombok.RequiredArgsConstructor;
import org.springframework.transaction.annotation.Transactional;

@UseCase
@RequiredArgsConstructor
public class RetrieveCommentCountUseCase {

private final CommentAdaptor commentAdaptor;

private final CommentMapper commentMapper;

private final EventAdaptor eventAdaptor;

@Transactional(readOnly = true)
public RetrieveCommentCountResponse execute(Long eventId) {
Event event = eventAdaptor.findById(eventId);
Long commentCount = commentAdaptor.queryCommentCount(event.getId());
return commentMapper.toRetrieveCommentCountResponse(commentCount);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package band.gosrock.api.comment.service;


import band.gosrock.api.comment.mapper.CommentMapper;
import band.gosrock.api.comment.model.response.RetrieveRandomCommentResponse;
import band.gosrock.common.annotation.UseCase;
import band.gosrock.domain.domains.comment.adaptor.CommentAdaptor;
import band.gosrock.domain.domains.comment.domain.Comment;
import band.gosrock.domain.domains.event.adaptor.EventAdaptor;
import band.gosrock.domain.domains.event.domain.Event;
import lombok.RequiredArgsConstructor;
import org.springframework.transaction.annotation.Transactional;

@UseCase
@RequiredArgsConstructor
public class RetrieveRandomCommentUseCase {

private final CommentAdaptor commentAdaptor;

private final CommentMapper commentMapper;

private final EventAdaptor eventAdaptor;

@Transactional(readOnly = true)
public RetrieveRandomCommentResponse execute(Long eventId) {
Event event = eventAdaptor.findById(eventId);
Comment comment = commentAdaptor.queryRandomComment(event.getId());
return commentMapper.toRetrieveRandomCommentResponse(comment);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import band.gosrock.api.coupon.service.CreateCouponUseCase;
import band.gosrock.api.coupon.service.CreateUserCouponUseCase;
import band.gosrock.api.coupon.service.ReadIssuedCouponUseCase;
import band.gosrock.api.coupon.service.ReadMyPageIssuedCouponUseCase;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
Expand All @@ -22,9 +21,8 @@
public class CouponController {

private final CreateCouponUseCase createCouponUseCase;
private final ReadIssuedCouponUseCase readIssuedCouponUseCase;
private final CreateUserCouponUseCase createUserCouponUseCase;
private final ReadMyPageIssuedCouponUseCase readMyPageIssuedCouponUseCase;
private final ReadIssuedCouponUseCase readIssuedCouponUseCase;

@Operation(summary = "์ฟ ํฐ ์บ ํŽ˜์ธ ์ƒ์„ฑ API")
@PostMapping("/campaigns")
Expand All @@ -33,13 +31,6 @@ public CreateCouponCampaignResponse createCouponCampaign(
return createCouponUseCase.execute(createCouponCampaignRequest);
}

@Deprecated
@Operation(summary = "์ฃผ๋ฌธ์‹œ ์ฟ ํฐ ์กฐํšŒ API(์‚ญ์ œ ์˜ˆ์ •)")
@GetMapping("/issuedCoupons/orders")
public ReadIssuedCouponOrderResponse getAllIssuedCouponsUsedInOrders() {
return readIssuedCouponUseCase.execute();
}

@Operation(summary = "์œ ์ € ์ฟ ํฐ ๋ฐœ๊ธ‰ API")
@PostMapping("/campaigns/{coupon_code}")
public CreateUserCouponResponse createUserCoupon(
Expand All @@ -50,7 +41,7 @@ public CreateUserCouponResponse createUserCoupon(
@Operation(summary = "๋‚ด ์ฟ ํฐ ์กฐํšŒ API")
@GetMapping("")
public ReadIssuedCouponResponse getAllMyIssuedCoupons(
@RequestParam(required = false, defaultValue = "false") Boolean expired) {
return readMyPageIssuedCouponUseCase.execute(expired);
@RequestParam(required = false, defaultValue = "true") Boolean expired) {
return readIssuedCouponUseCase.execute(expired);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


import band.gosrock.common.annotation.DateFormat;
import band.gosrock.domain.common.vo.DateTimePeriod;
import band.gosrock.domain.domains.coupon.domain.*;
import io.swagger.v3.oas.annotations.media.Schema;
import java.time.LocalDateTime;
Expand Down Expand Up @@ -55,25 +54,4 @@ public class CreateCouponCampaignRequest {

@NotBlank(message = "couponCode๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.")
private String couponCode;

public CouponCampaign toOnceEntity() {
CouponStockInfo couponStockInfo =
CouponStockInfo.builder()
.issuedAmount(issuedAmount)
.remainingAmount(issuedAmount)
.build();
DateTimePeriod dateTimePeriod =
DateTimePeriod.builder().startAt(startAt).endAt(endAt).build();

return CouponCampaign.builder()
.hostId(hostId)
.discountType(discountType)
.applyTarget(applyTarget)
.validTerm(validTerm)
.dateTimePeriod(dateTimePeriod)
.couponStockInfo(couponStockInfo)
.discountAmount(discountAmount)
.couponCode(couponCode)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package band.gosrock.api.coupon.dto.response;


import band.gosrock.domain.domains.coupon.domain.CouponCampaign;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;

Expand All @@ -10,18 +9,4 @@ public record CreateCouponCampaignResponse(
@Schema(description = "์ฟ ํฐ ์บ ํŽ˜์ธ ID") Long couponCampaignId,
@Schema(description = "์ฟ ํฐ ์ฝ”๋“œ") String couponCode,
@Schema(description = "์ƒ์„ฑํ•œ ์ฟ ํฐ ์ด ๋งค์ˆ˜") Long issuedAmount,
@Schema(description = "์ฟ ํฐ ์ƒ์„ฑํ•œ ํ˜ธ์ŠคํŠธ ID") Long hostId) {

/*
๋‚˜์ค‘์— ๋””์ž์ธ ๋‚˜์˜ค๊ณ  ๋” ํ•„์š”ํ•œ ๋ฆฌ์Šคํฐ์Šค ๊ฐ’ ์žˆ์œผ๋ฉด ์ถ”๊ฐ€ํ•  ์˜ˆ์ •์ž…๋‹ˆ๋‹ค.
*/

public static CreateCouponCampaignResponse of(CouponCampaign couponCampaign, Long hostId) {
return CreateCouponCampaignResponse.builder()
.couponCampaignId(couponCampaign.getId())
.couponCode(couponCampaign.getCouponCode())
.issuedAmount(couponCampaign.getCouponStockInfo().getIssuedAmount())
.hostId(hostId)
.build();
}
}
@Schema(description = "์ฟ ํฐ ์ƒ์„ฑํ•œ ํ˜ธ์ŠคํŠธ ID") Long hostId) {}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public class CreateUserCouponResponse {
@Schema(description = "์ฟ ํฐ ์ฝ”๋“œ")
private final String couponCode;

// TODO : DateFormat ์–ด๋…ธํ…Œ์ด์…˜ ์ ์šฉ
@Schema(type = "string", pattern = "yyyy-MM-dd HH:mm", description = "์ฟ ํฐ ์œ ํšจ ๊ธฐ๊ฐ„")
@DateFormat
private final LocalDateTime validTerm;
Expand Down
Loading

0 comments on commit 4e3efb4

Please sign in to comment.