-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
src/main/java/com/beotkkot/qtudy/dto/request/comments/CommentsRequestDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.beotkkot.qtudy.dto.request.comments; | ||
|
||
import com.beotkkot.qtudy.domain.comments.Comments; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.text.SimpleDateFormat; | ||
import java.time.Instant; | ||
import java.util.Date; | ||
|
||
@NoArgsConstructor | ||
@Getter | ||
public class CommentsRequestDto { | ||
private String content; | ||
private Long userUid; | ||
|
||
public Comments toEntity(Long postId) { | ||
Date now = Date.from(Instant.now()); | ||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
String writeDatetime = simpleDateFormat.format(now); | ||
|
||
return Comments.builder() | ||
.userUid(userUid) | ||
.postId(postId) | ||
.content(content) | ||
.createdAt(writeDatetime) | ||
.build(); | ||
} | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/com/beotkkot/qtudy/dto/response/comments/CommentsResponseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.beotkkot.qtudy.dto.response.comments; | ||
|
||
import com.beotkkot.qtudy.common.ResponseCode; | ||
import com.beotkkot.qtudy.common.ResponseMessage; | ||
import com.beotkkot.qtudy.dto.response.ResponseDto; | ||
import lombok.Getter; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
|
||
@Getter | ||
public class CommentsResponseDto extends ResponseDto{ | ||
public CommentsResponseDto() { | ||
super(ResponseCode.SUCCESS, ResponseMessage.SUCCESS); | ||
} | ||
|
||
public static ResponseEntity<CommentsResponseDto> success() { | ||
CommentsResponseDto result = new CommentsResponseDto(); | ||
return ResponseEntity.status(HttpStatus.OK).body(result); | ||
} | ||
|
||
public static ResponseEntity<ResponseDto> notExistedPost(){ | ||
ResponseDto result = new ResponseDto(ResponseCode.NOT_EXISTED_POST, ResponseMessage.NOT_EXISTED_POST); | ||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(result); | ||
} | ||
|
||
public static ResponseEntity<ResponseDto> notExistedUser() { | ||
ResponseDto result = new ResponseDto(ResponseCode.NOT_EXISTED_USER, ResponseMessage.NOT_EXISTED_USER); | ||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(result); | ||
} | ||
|
||
public static ResponseEntity<? super CommentsResponseDto> notExistedComment() { | ||
ResponseDto result = new ResponseDto(ResponseCode.NOT_EXISTED_COMMENT, ResponseMessage.NOT_EXISTED_COMMENT); | ||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(result); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/com/beotkkot/qtudy/dto/response/comments/GetCommentsAllResponseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.beotkkot.qtudy.dto.response.comments; | ||
|
||
import com.beotkkot.qtudy.common.ResponseCode; | ||
import com.beotkkot.qtudy.common.ResponseMessage; | ||
import com.beotkkot.qtudy.dto.object.CommentListItem; | ||
import com.beotkkot.qtudy.dto.response.ResponseDto; | ||
import lombok.Getter; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
|
||
import java.util.List; | ||
|
||
|
||
@Getter | ||
public class GetCommentsAllResponseDto extends ResponseDto { | ||
private int page; | ||
private List<CommentListItem> commentList; | ||
|
||
public GetCommentsAllResponseDto(List<CommentListItem> commentListItem, int page) { | ||
super(ResponseCode.SUCCESS, ResponseMessage.SUCCESS); | ||
this.page = page; | ||
this.commentList = commentListItem; | ||
} | ||
|
||
public static ResponseEntity<GetCommentsAllResponseDto> success(List<CommentListItem> commentListItem, int page) { | ||
GetCommentsAllResponseDto result = new GetCommentsAllResponseDto(commentListItem, page); | ||
return ResponseEntity.status(HttpStatus.OK).body(result); | ||
} | ||
|
||
public static ResponseEntity<ResponseDto> notExistedPost(){ | ||
ResponseDto result = new ResponseDto(ResponseCode.NOT_EXISTED_POST, ResponseMessage.NOT_EXISTED_POST); | ||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(result); | ||
} | ||
} | ||
|
||
|
||
|