Skip to content

Commit

Permalink
v1.3.0
Browse files Browse the repository at this point in the history
v1.3.0
  • Loading branch information
mikekks authored Jul 25, 2024
2 parents ce7fb3b + 67dc9d1 commit 82008bb
Show file tree
Hide file tree
Showing 103 changed files with 3,663 additions and 1,028 deletions.
30 changes: 22 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ services:
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
- AWS_REGION=${AWS_REGION}
- JWT_SECRET=${JWT_SECRET}
depends_on:
- nestjs
logging:
driver: "json-file"
options:
Expand Down Expand Up @@ -132,12 +130,20 @@ services:
caddy.route_2.reverse_proxy: "{{ upstreams 4000 }}"
caddy.route_3: /user/v2/*
caddy.route_3.reverse_proxy: "{{ upstreams 4000 }}"
caddy.route_4: /meeting/v2/*
caddy.route_4: /meeting/v2
caddy.route_4.reverse_proxy: "{{ upstreams 4000 }}"
caddy.route_5: /post/v2
caddy.route_5: /meeting/v2/*
caddy.route_5.reverse_proxy: "{{ upstreams 4000 }}"
caddy.route_6: /comment/v2
caddy.route_6: /post/v2
caddy.route_6.reverse_proxy: "{{ upstreams 4000 }}"
caddy.route_7: /post/v2/*
caddy.route_7.reverse_proxy: "{{ upstreams 4000 }}"
caddy.route_8: /comment/v2
caddy.route_8.reverse_proxy: "{{ upstreams 4000 }}"
caddy.route_9: /comment/v2/*
caddy.route_9.reverse_proxy: "{{ upstreams 4000 }}"
caddy.route_10: /notice/v2
caddy.route_10.reverse_proxy: "{{ upstreams 4000 }}"

nestjs-blue:
image: makerscrew/server:latest
Expand Down Expand Up @@ -221,12 +227,20 @@ services:
caddy.route_2.reverse_proxy: "{{ upstreams 4000 }}"
caddy.route_3: /user/v2/*
caddy.route_3.reverse_proxy: "{{ upstreams 4000 }}"
caddy.route_4: /meeting/v2/*
caddy.route_4: /meeting/v2
caddy.route_4.reverse_proxy: "{{ upstreams 4000 }}"
caddy.route_5: /post/v2
caddy.route_5: /meeting/v2/*
caddy.route_5.reverse_proxy: "{{ upstreams 4000 }}"
caddy.route_6: /comment/v2
caddy.route_6: /post/v2
caddy.route_6.reverse_proxy: "{{ upstreams 4000 }}"
caddy.route_7: /post/v2/*
caddy.route_7.reverse_proxy: "{{ upstreams 4000 }}"
caddy.route_8: /comment/v2
caddy.route_8.reverse_proxy: "{{ upstreams 4000 }}"
caddy.route_9: /comment/v2/*
caddy.route_9.reverse_proxy: "{{ upstreams 4000 }}"
caddy.route_10: /notice/v2
caddy.route_10.reverse_proxy: "{{ upstreams 4000 }}"

networks:
caddy:
Expand Down
6 changes: 6 additions & 0 deletions main/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ dependencies {
// MapStruct
implementation 'org.mapstruct:mapstruct:1.5.3.Final'
annotationProcessor 'org.mapstruct:mapstruct-processor:1.5.3.Final'

// queryDsl
implementation 'com.querydsl:querydsl-jpa:5.0.0:jakarta'
annotationProcessor "com.querydsl:querydsl-apt:${dependencyManagement.importedProperties['querydsl.version']}:jakarta"
annotationProcessor "jakarta.annotation:jakarta.annotation-api"
annotationProcessor "jakarta.persistence:jakarta.persistence-api"
}

tasks.named('test') {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package org.sopt.makers.crew.main.comment.v2;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import jakarta.validation.Valid;

import java.security.Principal;

import org.sopt.makers.crew.main.comment.v2.dto.query.CommentV2GetCommentsQueryDto;
import org.sopt.makers.crew.main.comment.v2.dto.request.CommentV2CreateCommentBodyDto;
import org.sopt.makers.crew.main.comment.v2.dto.request.CommentV2MentionUserInCommentRequestDto;
import org.sopt.makers.crew.main.comment.v2.dto.request.CommentV2UpdateCommentBodyDto;
import org.sopt.makers.crew.main.comment.v2.dto.response.CommentV2CreateCommentResponseDto;
import org.sopt.makers.crew.main.comment.v2.dto.response.CommentV2GetCommentsResponseDto;
import org.sopt.makers.crew.main.comment.v2.dto.response.CommentV2ReportCommentResponseDto;
import org.sopt.makers.crew.main.comment.v2.dto.response.CommentV2UpdateCommentResponseDto;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseStatus;

public interface CommentV2Api {

@Operation(summary = "모임 게시글 댓글 작성")
@ResponseStatus(HttpStatus.CREATED)
@ApiResponses(value = {
@ApiResponse(responseCode = "201", description = "성공"),
})
ResponseEntity<CommentV2CreateCommentResponseDto> createComment(
@Valid @RequestBody CommentV2CreateCommentBodyDto requestBody, Principal principal);

@Operation(summary = "모임 게시글 댓글 수정")
@ResponseStatus(HttpStatus.OK)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "성공"),
})
ResponseEntity<CommentV2UpdateCommentResponseDto> updateComment(
@PathVariable Integer commentId,
@Valid @RequestBody CommentV2UpdateCommentBodyDto requestBody,
Principal principal);

@Operation(summary = "댓글 신고하기")
@ResponseStatus(HttpStatus.CREATED)
@ApiResponses(value = {
@ApiResponse(responseCode = "201", description = "성공"),
})
ResponseEntity<CommentV2ReportCommentResponseDto> reportComment(
@PathVariable Integer commentId, Principal principal);

@Operation(summary = "모임 게시글 댓글 삭제")
@ResponseStatus(HttpStatus.NO_CONTENT)
@ApiResponses(value = {
@ApiResponse(responseCode = "204", description = "성공"),
})
ResponseEntity<Void> deleteComment(Principal principal, @PathVariable Integer commentId);

@Operation(summary = "댓글에서 유저 멘션")
@ResponseStatus(HttpStatus.OK)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "성공"),
})
ResponseEntity<Void> mentionUserInComment(
@Valid @RequestBody CommentV2MentionUserInCommentRequestDto requestBody,
Principal principal);

@Operation(summary = "모임 게시글 댓글 리스트 조회")
@ResponseStatus(HttpStatus.OK)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "성공"),
})
ResponseEntity<CommentV2GetCommentsResponseDto> getComments(@Valid @ModelAttribute CommentV2GetCommentsQueryDto requestBody, Principal principal);
}
Original file line number Diff line number Diff line change
@@ -1,42 +1,101 @@
package org.sopt.makers.crew.main.comment.v2;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;

import java.security.Principal;

import lombok.RequiredArgsConstructor;

import org.sopt.makers.crew.main.comment.v2.dto.query.CommentV2GetCommentsQueryDto;
import org.sopt.makers.crew.main.comment.v2.dto.request.CommentV2CreateCommentBodyDto;
import org.sopt.makers.crew.main.comment.v2.dto.request.CommentV2MentionUserInCommentRequestDto;
import org.sopt.makers.crew.main.comment.v2.dto.request.CommentV2UpdateCommentBodyDto;
import org.sopt.makers.crew.main.comment.v2.dto.response.CommentV2CreateCommentResponseDto;
import org.sopt.makers.crew.main.comment.v2.dto.response.CommentV2GetCommentsResponseDto;
import org.sopt.makers.crew.main.comment.v2.dto.response.CommentV2ReportCommentResponseDto;
import org.sopt.makers.crew.main.comment.v2.dto.response.CommentV2UpdateCommentResponseDto;
import org.sopt.makers.crew.main.comment.v2.service.CommentV2Service;
import org.sopt.makers.crew.main.common.util.UserUtil;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/comment/v2")
@RequiredArgsConstructor
@Tag(name = "댓글/대댓글")
public class CommentV2Controller {

private final CommentV2Service commentV2Service;

@Operation(summary = "모임 게시글 댓글 작성")
@PostMapping()
@ResponseStatus(HttpStatus.CREATED)
@ApiResponses(value = {
@ApiResponse(responseCode = "201", description = "성공"),
})
public ResponseEntity<CommentV2CreateCommentResponseDto> createComment(
@Valid @RequestBody CommentV2CreateCommentBodyDto requestBody, Principal principal) {
Integer userId = UserUtil.getUserId(principal);
return ResponseEntity.ok(commentV2Service.createComment(requestBody, userId));
}
public class CommentV2Controller implements CommentV2Api {

private final CommentV2Service commentV2Service;

@Override
@PostMapping()
public ResponseEntity<CommentV2CreateCommentResponseDto> createComment(
@Valid @RequestBody CommentV2CreateCommentBodyDto requestBody, Principal principal) {
Integer userId = UserUtil.getUserId(principal);
return ResponseEntity.ok(commentV2Service.createComment(requestBody, userId));
}

@Override
@PutMapping("/{commentId}")
public ResponseEntity<CommentV2UpdateCommentResponseDto> updateComment(
@PathVariable Integer commentId,
@Valid @RequestBody CommentV2UpdateCommentBodyDto requestBody,
Principal principal) {
Integer userId = UserUtil.getUserId(principal);
return ResponseEntity.ok(
commentV2Service.updateComment(commentId, requestBody.getContents(), userId));
}

@Override
@PostMapping("/{commentId}/report")
public ResponseEntity<CommentV2ReportCommentResponseDto> reportComment(
@PathVariable Integer commentId, Principal principal) {
Integer userId = UserUtil.getUserId(principal);
return ResponseEntity.ok(commentV2Service.reportComment(commentId, userId));
}

@Override
@DeleteMapping("/{commentId}")
public ResponseEntity<Void> deleteComment(
Principal principal,
@PathVariable Integer commentId) {
Integer userId = UserUtil.getUserId(principal);

commentV2Service.deleteComment(commentId, userId);

return ResponseEntity.noContent().build();
}

@Override
@PostMapping("/mention")
public ResponseEntity<Void> mentionUserInComment(
@Valid @RequestBody CommentV2MentionUserInCommentRequestDto requestBody,
Principal principal) {
Integer userId = UserUtil.getUserId(principal);
commentV2Service.mentionUserInComment(requestBody, userId);
return ResponseEntity.status(HttpStatus.OK).build();
}

@Override
@GetMapping
public ResponseEntity<CommentV2GetCommentsResponseDto> getComments(
@Valid @ModelAttribute CommentV2GetCommentsQueryDto requestBody,
Principal principal) {

Integer userId = UserUtil.getUserId(principal);
CommentV2GetCommentsResponseDto commentDtos = commentV2Service.getComments(requestBody.getPostId(),
requestBody.getPage(), requestBody.getTake(), userId);

return ResponseEntity.status(HttpStatus.OK).body(commentDtos);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.sopt.makers.crew.main.comment.v2.dto;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.sopt.makers.crew.main.comment.v2.dto.request.CommentV2CreateCommentBodyDto;
import org.sopt.makers.crew.main.entity.comment.Comment;
import org.sopt.makers.crew.main.entity.post.Post;
import org.sopt.makers.crew.main.entity.user.User;

@Mapper(componentModel = "spring")
public interface CommentMapper {
@Mapping(source = "post", target = "post")
@Mapping(source = "requestBody.contents", target = "contents")
@Mapping(source = "user", target = "user")
@Mapping(source = "user.id", target = "userId")
@Mapping(target = "likeCount", constant = "0")
Comment toComment(CommentV2CreateCommentBodyDto requestBody, Post post, User user, int depth, int order,
Integer parentId);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.sopt.makers.crew.main.comment.v2.dto.query;

import org.sopt.makers.crew.main.common.pagination.dto.PageOptionsDto;

import jakarta.validation.constraints.NotNull;
import lombok.Builder;
import lombok.Getter;

@Getter
public class CommentV2GetCommentsQueryDto extends PageOptionsDto {

@NotNull
private final Integer postId;

@Builder
public CommentV2GetCommentsQueryDto(Integer page, Integer take, Integer postId) {
super(page, take);
this.postId = postId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,18 @@
@Schema(description = "댓글 생성 request body dto")
public class CommentV2CreateCommentBodyDto {

@Schema(example = "1", required = true, description = "게시글 ID")
@NotNull
private Integer postId;
@Schema(example = "1", required = true, description = "게시글 ID")
@NotNull
private Integer postId;

@Schema(example = "알고보면 쓸데있는 개발 프로세스", required = true, description = "댓글 내용")
@NotEmpty
private String contents;
@Schema(example = "알고보면 쓸데있는 개발 프로세스", required = true, description = "댓글 내용")
@NotEmpty
private String contents;

@Schema(example = "댓글/대댓글 여부", required = true, description = "true")
private boolean isParent;

@Schema(example = "대댓글인 경우, 댓글의 id", required = true, description = "1")
private Integer parentCommentId;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.sopt.makers.crew.main.comment.v2.dto.request;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;

import java.util.List;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
@Schema(description = "댓글에서 유저 언급 request body dto")
public class CommentV2MentionUserInCommentRequestDto {

/**
* 주의!! : 필드명은 userIds 이지만 실제 요청받는 값은 orgId 입니다.
*/

@Schema(example = "[111, 112, 113]", required = true, description = "언급할 유저 ID")
@NotEmpty
private List<Integer> userIds;

@Schema(example = "1", required = true, description = "게시글 ID")
@NotNull
private Integer postId;

@Schema(example = "멘션내용~~", required = true, description = "멘션 내용")
private String content;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.sopt.makers.crew.main.comment.v2.dto.request;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@AllArgsConstructor
@NoArgsConstructor
@Schema(description = "댓글 업데이트 request body dto")
public class CommentV2UpdateCommentBodyDto {

@Schema(example = "알고보면 쓸데있는 개발 프로세스", description = "댓글 내용")
@NotEmpty
private String contents;

}
Loading

0 comments on commit 82008bb

Please sign in to comment.