Skip to content

Commit

Permalink
Merge pull request #117 from BudgetBuddiesTeam/dev
Browse files Browse the repository at this point in the history
[v3] dto 이름 수정
  • Loading branch information
wnd01jun authored Aug 14, 2024
2 parents 088aa46 + be9099b commit e43842b
Show file tree
Hide file tree
Showing 30 changed files with 154 additions and 172 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@
import com.bbteam.budgetbuddies.domain.comment.service.CommentService;
import com.bbteam.budgetbuddies.domain.comment.validation.ExistComment;
import com.bbteam.budgetbuddies.domain.user.validation.ExistUser;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

Expand All @@ -20,53 +18,53 @@
public class CommentController implements CommentControllerApi {

@Qualifier("discountCommentService")
private final CommentService<CommentRequestDto.DiscountInfoCommentDto,
CommentResponseDto.DiscountInfoCommentDto> discountCommentService;
private final CommentService<CommentRequestDto.DiscountInfoCommentRequestDto,
CommentResponseDto.DiscountInfoCommentResponseDto> discountCommentService;

@Qualifier("supportCommentService")
private final CommentService<CommentRequestDto.SupportInfoCommentDto,
CommentResponseDto.SupportInfoCommentDto> supportCommentService;
private final CommentService<CommentRequestDto.SupportInfoCommentRequestDto,
CommentResponseDto.SupportInfoCommentResponseDto> supportCommentService;

public CommentController(CommentService<CommentRequestDto.DiscountInfoCommentDto,
CommentResponseDto.DiscountInfoCommentDto> discountCommentService,
CommentService<CommentRequestDto.SupportInfoCommentDto,
CommentResponseDto.SupportInfoCommentDto> supportCommentService) {
public CommentController(CommentService<CommentRequestDto.DiscountInfoCommentRequestDto,
CommentResponseDto.DiscountInfoCommentResponseDto> discountCommentService,
CommentService<CommentRequestDto.SupportInfoCommentRequestDto,
CommentResponseDto.SupportInfoCommentResponseDto> supportCommentService) {
this.discountCommentService = discountCommentService;
this.supportCommentService = supportCommentService;
}

@PostMapping("/discounts/comments")
public ApiResponse<CommentResponseDto.DiscountInfoCommentDto> saveDiscountInfoComment(
public ApiResponse<CommentResponseDto.DiscountInfoCommentResponseDto> saveDiscountInfoComment(
@RequestParam("userId") @ExistUser Long userId,
@RequestBody CommentRequestDto.DiscountInfoCommentDto discountInfoCommentDto){
CommentResponseDto.DiscountInfoCommentDto dto = discountCommentService.saveComment(userId, discountInfoCommentDto);
@RequestBody CommentRequestDto.DiscountInfoCommentRequestDto discountInfoCommentRequestDto){
CommentResponseDto.DiscountInfoCommentResponseDto dto = discountCommentService.saveComment(userId, discountInfoCommentRequestDto);
return ApiResponse.onSuccess(dto);
}


@GetMapping("/discounts/{discountInfoId}/comments")
public ApiResponse<Page<CommentResponseDto.DiscountInfoCommentDto>> findAllByDiscountInfo(
public ApiResponse<Page<CommentResponseDto.DiscountInfoCommentResponseDto>> findAllByDiscountInfo(
@PathVariable("discountInfoId") Long discountInfoId,
@PageableDefault(size = 20, page = 0) Pageable pageable){
Page<CommentResponseDto.DiscountInfoCommentDto> result = discountCommentService.findByInfoWithPaging(discountInfoId, pageable);
Page<CommentResponseDto.DiscountInfoCommentResponseDto> result = discountCommentService.findByInfoWithPaging(discountInfoId, pageable);
return ApiResponse.onSuccess(result);
}


@PostMapping("/supports/comments")
public ApiResponse<CommentResponseDto.SupportInfoCommentDto> saveSupportInfoComment(
public ApiResponse<CommentResponseDto.SupportInfoCommentResponseDto> saveSupportInfoComment(
@RequestParam("userId") @ExistUser Long userId,
@RequestBody CommentRequestDto.SupportInfoCommentDto supportInfoCommentDto){
CommentResponseDto.SupportInfoCommentDto dto = supportCommentService.saveComment(userId, supportInfoCommentDto);
@RequestBody CommentRequestDto.SupportInfoCommentRequestDto supportInfoCommentRequestDto){
CommentResponseDto.SupportInfoCommentResponseDto dto = supportCommentService.saveComment(userId, supportInfoCommentRequestDto);
return ApiResponse.onSuccess(dto);
}


@GetMapping("/supports/{supportInfoId}/comments")
public ApiResponse<Page<CommentResponseDto.SupportInfoCommentDto>> findAllBySupportInfo(
public ApiResponse<Page<CommentResponseDto.SupportInfoCommentResponseDto>> findAllBySupportInfo(
@PathVariable("supportInfoId") Long supportInfoId,
@PageableDefault(size = 20, page = 0)Pageable pageable){
Page<CommentResponseDto.SupportInfoCommentDto> result = supportCommentService.findByInfoWithPaging(supportInfoId, pageable);
Page<CommentResponseDto.SupportInfoCommentResponseDto> result = supportCommentService.findByInfoWithPaging(supportInfoId, pageable);
return ApiResponse.onSuccess(result);
}

Expand All @@ -77,28 +75,28 @@ public ApiResponse<String> deleteComment(@PathVariable("commentId") @ExistCommen
}

@GetMapping("/supports/comments/getOne/{commentId}")
public ApiResponse<CommentResponseDto.SupportInfoCommentDto> findSupportOne(@PathVariable("commentId")Long commentId) {
CommentResponseDto.SupportInfoCommentDto result = supportCommentService.findCommentOne(commentId);
public ApiResponse<CommentResponseDto.SupportInfoCommentResponseDto> findSupportOne(@PathVariable("commentId")Long commentId) {
CommentResponseDto.SupportInfoCommentResponseDto result = supportCommentService.findCommentOne(commentId);
return ApiResponse.onSuccess(result);
}

@PutMapping("/supports/comments/modify")
public ApiResponse<CommentResponseDto.SupportInfoCommentDto> modifySupportOne(
@RequestBody CommentRequestDto.CommentModifyDto dto) {
CommentResponseDto.SupportInfoCommentDto result = supportCommentService.modifyComment(dto);
public ApiResponse<CommentResponseDto.SupportInfoCommentResponseDto> modifySupportOne(
@RequestBody CommentRequestDto.CommentModifyRequestDto dto) {
CommentResponseDto.SupportInfoCommentResponseDto result = supportCommentService.modifyComment(dto);
return ApiResponse.onSuccess(result);
}

@GetMapping("/discounts/comments/getOne/{commentId}")
public ApiResponse<CommentResponseDto.DiscountInfoCommentDto> findDiscountOne(@PathVariable("commentId")Long commentId) {
CommentResponseDto.DiscountInfoCommentDto result = discountCommentService.findCommentOne(commentId);
public ApiResponse<CommentResponseDto.DiscountInfoCommentResponseDto> findDiscountOne(@PathVariable("commentId")Long commentId) {
CommentResponseDto.DiscountInfoCommentResponseDto result = discountCommentService.findCommentOne(commentId);
return ApiResponse.onSuccess(result);
}

@PutMapping("/discounts/comments/modify")
public ApiResponse<CommentResponseDto.DiscountInfoCommentDto> modifyDiscountOne(
@RequestBody CommentRequestDto.CommentModifyDto dto) {
CommentResponseDto.DiscountInfoCommentDto result = discountCommentService.modifyComment(dto);
public ApiResponse<CommentResponseDto.DiscountInfoCommentResponseDto> modifyDiscountOne(
@RequestBody CommentRequestDto.CommentModifyRequestDto dto) {
CommentResponseDto.DiscountInfoCommentResponseDto result = discountCommentService.modifyComment(dto);
return ApiResponse.onSuccess(result);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import jakarta.validation.Valid;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
Expand All @@ -30,9 +28,9 @@ public interface CommentControllerApi {
@Parameter(name = "discountInfoId", description = "댓글을 다는 할인 정보 게시글 id입니다. requestBody"),
@Parameter(name = "content", description = "댓글 내용입니다. requestBody"),
})
ApiResponse<CommentResponseDto.DiscountInfoCommentDto> saveDiscountInfoComment(
ApiResponse<CommentResponseDto.DiscountInfoCommentResponseDto> saveDiscountInfoComment(
@ExistUser Long userId,
CommentRequestDto.DiscountInfoCommentDto discountInfoCommentDto);
CommentRequestDto.DiscountInfoCommentRequestDto discountInfoCommentRequestDto);


@Operation(summary = "[User] 특정 할인 정보 게시글의 댓글 조회하기", description = "특정 할인 정보 게시글의 댓글을 가져오는 API입니다.")
Expand All @@ -44,7 +42,7 @@ ApiResponse<CommentResponseDto.DiscountInfoCommentDto> saveDiscountInfoComment(
@Parameter(name = "page", description = "페이징을 위한 페이지 번호입니다. 0부터 시작합니다. parameter"),
@Parameter(name = "size", description = "페이징을 위한 페이지 사이즈입니다. default는 20입니다. parameter")
})
ApiResponse<Page<CommentResponseDto.DiscountInfoCommentDto>> findAllByDiscountInfo(
ApiResponse<Page<CommentResponseDto.DiscountInfoCommentResponseDto>> findAllByDiscountInfo(
Long discountInfoId,
Pageable pageable);

Expand All @@ -57,9 +55,9 @@ ApiResponse<Page<CommentResponseDto.DiscountInfoCommentDto>> findAllByDiscountIn
@Parameter(name = "supportInfoId", description = "댓글을 다는 지원 정보 게시글 id입니다. requestBody"),
@Parameter(name = "content", description = "댓글 내용입니다. requestBody"),
})
ApiResponse<CommentResponseDto.SupportInfoCommentDto> saveSupportInfoComment(
ApiResponse<CommentResponseDto.SupportInfoCommentResponseDto> saveSupportInfoComment(
@ExistUser Long userId,
CommentRequestDto.SupportInfoCommentDto supportInfoCommentDto);
CommentRequestDto.SupportInfoCommentRequestDto supportInfoCommentRequestDto);

@Operation(summary = "[User] 특정 지원 정보 게시글의 댓글 조회하기", description = "특정 지원 정보 게시글의 댓글을 가져오는 API입니다.")
@ApiResponses({
Expand All @@ -72,7 +70,7 @@ ApiResponse<CommentResponseDto.SupportInfoCommentDto> saveSupportInfoComment(


})
ApiResponse<Page<CommentResponseDto.SupportInfoCommentDto>> findAllBySupportInfo(
ApiResponse<Page<CommentResponseDto.SupportInfoCommentResponseDto>> findAllBySupportInfo(
Long supportInfoId,
Pageable pageable);

Expand All @@ -92,7 +90,7 @@ ApiResponse<Page<CommentResponseDto.SupportInfoCommentDto>> findAllBySupportInfo
@Parameters({
@Parameter(name = "commentId", description = "조회할 댓글 id 입니다. pathVariable")
})
ApiResponse<CommentResponseDto.SupportInfoCommentDto> findSupportOne(@RequestParam("commentId")Long commentId);
ApiResponse<CommentResponseDto.SupportInfoCommentResponseDto> findSupportOne(@RequestParam("commentId")Long commentId);

@Operation(summary = "[User] SupportInfo의 댓글 변경 API", description = "특정 댓글을 변경하는 API입니다.")
@ApiResponses({
Expand All @@ -103,8 +101,8 @@ ApiResponse<Page<CommentResponseDto.SupportInfoCommentDto>> findAllBySupportInfo
@Parameter(name = "content", description = "변경할 댓글 내용입니다.. requestbody")

})
ApiResponse<CommentResponseDto.SupportInfoCommentDto> modifySupportOne(
@RequestBody CommentRequestDto.CommentModifyDto dto);
ApiResponse<CommentResponseDto.SupportInfoCommentResponseDto> modifySupportOne(
@RequestBody CommentRequestDto.CommentModifyRequestDto dto);


@Operation(summary = "[User] DiscountInfo의 특정 댓글 요청 API", description = "특정 댓글을 요청하는 API입니다.")
Expand All @@ -114,7 +112,7 @@ ApiResponse<CommentResponseDto.SupportInfoCommentDto> modifySupportOne(
@Parameters({
@Parameter(name = "commentId", description = "조회할 댓글 id 입니다. pathVariable")
})
ApiResponse<CommentResponseDto.DiscountInfoCommentDto> findDiscountOne(@RequestParam("commentId")Long commentId);
ApiResponse<CommentResponseDto.DiscountInfoCommentResponseDto> findDiscountOne(@RequestParam("commentId")Long commentId);

@Operation(summary = "[User] DiscountInfo의 댓글 변경 API", description = "특정 댓글을 변경하는 API입니다.")
@ApiResponses({
Expand All @@ -125,7 +123,7 @@ ApiResponse<CommentResponseDto.SupportInfoCommentDto> modifySupportOne(
@Parameter(name = "content", description = "변경할 댓글 내용입니다.. requestbody")

})
ApiResponse<CommentResponseDto.DiscountInfoCommentDto> modifyDiscountOne(
@RequestBody CommentRequestDto.CommentModifyDto dto);
ApiResponse<CommentResponseDto.DiscountInfoCommentResponseDto> modifyDiscountOne(
@RequestBody CommentRequestDto.CommentModifyRequestDto dto);

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

public class CommentConverter {

public static Comment toDiscountComment(CommentRequestDto.DiscountInfoCommentDto dto, User user, DiscountInfo discountInfo,
public static Comment toDiscountComment(CommentRequestDto.DiscountInfoCommentRequestDto dto, User user, DiscountInfo discountInfo,
Integer anonymousNumber) {
return Comment.builder()
.user(user)
Expand All @@ -19,7 +19,7 @@ public static Comment toDiscountComment(CommentRequestDto.DiscountInfoCommentDto
.build();
}

public static Comment toSupportComment(CommentRequestDto.SupportInfoCommentDto dto, User user, SupportInfo supportInfo,
public static Comment toSupportComment(CommentRequestDto.SupportInfoCommentRequestDto dto, User user, SupportInfo supportInfo,
Integer anonymousNumber) {
return Comment.builder()
.user(user)
Expand All @@ -29,8 +29,8 @@ public static Comment toSupportComment(CommentRequestDto.SupportInfoCommentDto d
.build();
}

public static CommentResponseDto.DiscountInfoCommentDto toDiscountInfoCommentDto(Comment comment){
return CommentResponseDto.DiscountInfoCommentDto.builder()
public static CommentResponseDto.DiscountInfoCommentResponseDto toDiscountInfoCommentDto(Comment comment){
return CommentResponseDto.DiscountInfoCommentResponseDto.builder()
.commentId(comment.getId())
.discountInfoId(comment.getDiscountInfo().getId())
.userId(comment.getUser().getId())
Expand All @@ -41,8 +41,8 @@ public static CommentResponseDto.DiscountInfoCommentDto toDiscountInfoCommentDto

}

public static CommentResponseDto.SupportInfoCommentDto toSupportInfoCommentDto(Comment comment){
return CommentResponseDto.SupportInfoCommentDto.builder()
public static CommentResponseDto.SupportInfoCommentResponseDto toSupportInfoCommentDto(Comment comment){
return CommentResponseDto.SupportInfoCommentResponseDto.builder()
.commentId(comment.getId())
.supportInfoId(comment.getSupportInfo().getId())
.userId(comment.getUser().getId())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@
public class CommentRequestDto {
@Getter
@Builder
public static class DiscountInfoCommentDto {
public static class DiscountInfoCommentRequestDto {
private String content;
private Long discountInfoId;
}

@Getter
@Builder
public static class SupportInfoCommentDto {
public static class SupportInfoCommentRequestDto {
private String content;
private Long supportInfoId;
}

@Getter
@Builder
public static class CommentModifyDto {
public static class CommentModifyRequestDto {
private String content;
private Long commentId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
import lombok.Builder;
import lombok.Getter;

import java.time.LocalDate;
import java.time.LocalDateTime;

public class CommentResponseDto {

@Getter
@Builder
public static class DiscountInfoCommentDto{
public static class DiscountInfoCommentResponseDto {
private Long commentId;
private Long userId;
private Long discountInfoId;
Expand All @@ -24,7 +23,7 @@ public static class DiscountInfoCommentDto{

@Getter
@Builder
public static class SupportInfoCommentDto{
public static class SupportInfoCommentResponseDto {
private Long commentId;
private Long userId;
private Long supportInfoId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
package com.bbteam.budgetbuddies.domain.comment.service;

import com.bbteam.budgetbuddies.domain.comment.converter.CommentConverter;
import com.bbteam.budgetbuddies.domain.comment.dto.CommentRequestDto;
import com.bbteam.budgetbuddies.domain.comment.dto.CommentResponseDto;
import com.bbteam.budgetbuddies.domain.comment.entity.Comment;
import com.bbteam.budgetbuddies.domain.discountinfo.entity.DiscountInfo;
import com.bbteam.budgetbuddies.domain.user.entity.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.NoSuchElementException;
import java.util.Optional;
import java.util.stream.Collectors;

public interface CommentService<R, T> {

Expand All @@ -33,7 +26,7 @@ public interface CommentService<R, T> {



T modifyComment(CommentRequestDto.CommentModifyDto dto);
T modifyComment(CommentRequestDto.CommentModifyRequestDto dto);

Optional<Comment> findById(Long commentId);
}
Loading

0 comments on commit e43842b

Please sign in to comment.