Skip to content

Commit 2b8c733

Browse files
authored
Merge pull request #13 from Sportize/refactor/post
๐Ÿ› Fix: ์ปค๋ฎค๋‹ˆํ‹ฐ ๊ฒŒ์‹œ๊ธ€ ๊ธฐ๋Šฅ๊ด€๋ จ ๋ฒ„๊ทธ ์ˆ˜์ •
2 parents 05e1ea8 + c8b657a commit 2b8c733

File tree

13 files changed

+155
-58
lines changed

13 files changed

+155
-58
lines changed

โ€Žsrc/main/java/com/be/sportizebe/domain/comment/controller/CommentController.javaโ€Ž

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.be.sportizebe.domain.comment.dto.response.CommentResponse;
55
import com.be.sportizebe.domain.comment.service.CommentService;
66
import com.be.sportizebe.domain.user.entity.User;
7+
import com.be.sportizebe.domain.user.repository.UserRepository;
78
import com.be.sportizebe.global.response.BaseResponse;
89
import io.swagger.v3.oas.annotations.Operation;
910
import io.swagger.v3.oas.annotations.Parameter;
@@ -12,7 +13,6 @@
1213
import lombok.RequiredArgsConstructor;
1314
import org.springframework.http.HttpStatus;
1415
import org.springframework.http.ResponseEntity;
15-
import org.springframework.security.core.annotation.AuthenticationPrincipal;
1616
import org.springframework.web.bind.annotation.*;
1717

1818
import java.util.List;
@@ -24,13 +24,16 @@
2424
public class CommentController {
2525

2626
private final CommentService commentService;
27+
private final UserRepository userRepository; // TODO: ์ธ์ฆ ๋กœ์ง ๊ฐœ๋ฐœ ํ›„ ์ œ๊ฑฐ
2728

2829
@PostMapping
2930
@Operation(summary = "๋Œ“๊ธ€ ์ƒ์„ฑ", description = "๊ฒŒ์‹œ๊ธ€์— ๋Œ“๊ธ€ ๋˜๋Š” ๋Œ€๋Œ“๊ธ€ ์ƒ์„ฑ")
3031
public ResponseEntity<BaseResponse<CommentResponse>> createComment(
3132
@Parameter(description = "๊ฒŒ์‹œ๊ธ€ ID") @PathVariable Long postId,
32-
@RequestBody @Valid CreateCommentRequest request,
33-
@AuthenticationPrincipal User user) {
33+
@RequestBody @Valid CreateCommentRequest request) {
34+
// TODO: ์ธ์ฆ ๋กœ์ง ๊ฐœ๋ฐœ ํ›„ @AuthenticationPrincipal User user๋กœ ๋ณ€๊ฒฝ
35+
User user = userRepository.findById(1L)
36+
.orElseThrow(() -> new RuntimeException("ํ…Œ์ŠคํŠธ ์œ ์ €๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค. users ํ…Œ์ด๋ธ”์— id=1์ธ ์œ ์ €๋ฅผ ์ถ”๊ฐ€ํ•ด์ฃผ์„ธ์š”."));
3437
CommentResponse response = commentService.createComment(postId, request, user);
3538
return ResponseEntity.status(HttpStatus.CREATED)
3639
.body(BaseResponse.success("๋Œ“๊ธ€ ์ƒ์„ฑ ์„ฑ๊ณต", response));
@@ -44,15 +47,17 @@ public ResponseEntity<BaseResponse<List<CommentResponse>>> getComments(
4447
return ResponseEntity.ok(BaseResponse.success(responses));
4548
}
4649

47-
// @DeleteMapping("/{commentId}")
48-
// @Operation(summary = "๋Œ“๊ธ€ ์‚ญ์ œ", description = "๋Œ“๊ธ€ ์‚ญ์ œ (๋Œ€๋Œ“๊ธ€๋„ ํ•จ๊ป˜ ์‚ญ์ œ)")
49-
// public ResponseEntity<BaseResponse<Void>> deleteComment(
50-
// @Parameter(description = "๊ฒŒ์‹œ๊ธ€ ID") @PathVariable Long postId,
51-
// @Parameter(description = "๋Œ“๊ธ€ ID") @PathVariable Long commentId,
52-
// @AuthenticationPrincipal User user) {
53-
// commentService.deleteComment(commentId, user);
54-
// return ResponseEntity.ok(BaseResponse.success("๋Œ“๊ธ€ ์‚ญ์ œ ์„ฑ๊ณต", null));
55-
// }
50+
@DeleteMapping("/{commentId}")
51+
@Operation(summary = "๋Œ“๊ธ€ ์‚ญ์ œ", description = "๋Œ“๊ธ€ ์‚ญ์ œ (๋Œ€๋Œ“๊ธ€๋„ ํ•จ๊ป˜ ์‚ญ์ œ)")
52+
public ResponseEntity<BaseResponse<Void>> deleteComment(
53+
@Parameter(description = "๊ฒŒ์‹œ๊ธ€ ID") @PathVariable Long postId,
54+
@Parameter(description = "๋Œ“๊ธ€ ID") @PathVariable Long commentId) {
55+
// TODO: ์ธ์ฆ ๋กœ์ง ๊ฐœ๋ฐœ ํ›„ @AuthenticationPrincipal User user๋กœ ๋ณ€๊ฒฝ
56+
User user = userRepository.findById(1L)
57+
.orElseThrow(() -> new RuntimeException("ํ…Œ์ŠคํŠธ ์œ ์ €๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค. users ํ…Œ์ด๋ธ”์— id=1์ธ ์œ ์ €๋ฅผ ์ถ”๊ฐ€ํ•ด์ฃผ์„ธ์š”."));
58+
commentService.deleteComment(commentId, user);
59+
return ResponseEntity.ok(BaseResponse.success("๋Œ“๊ธ€ ์‚ญ์ œ ์„ฑ๊ณต", null));
60+
}
5661

5762
@GetMapping("/count")
5863
@Operation(summary = "๋Œ“๊ธ€ ์ˆ˜ ์กฐํšŒ", description = "๊ฒŒ์‹œ๊ธ€์˜ ์ด ๋Œ“๊ธ€ ์ˆ˜ ์กฐํšŒ")

โ€Žsrc/main/java/com/be/sportizebe/domain/comment/entity/Comment.javaโ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ public class Comment extends BaseTimeEntity {
3636
private User user; // ์ž‘์„ฑ์ž (ํ”„๋ก์‹œ ๊ฐ์ฒด)
3737

3838
@ManyToOne(fetch = FetchType.LAZY)
39-
@JoinColumn(name = "parent_id")
40-
private Comment parent; // ๋ถ€๋ชจ ๋Œ“๊ธ€ (null์ด๋ฉด ์ผ๋ฐ˜ ๋Œ“๊ธ€)
39+
@JoinColumn(name = "parent_id") // ์ž๊ธฐ ์ฐธ์กฐ
40+
private Comment parent; // ๋ถ€๋ชจ ๋Œ“๊ธ€ (null์ด๋ฉด ๋ถ€๋ชจ ๋Œ“๊ธ€)
4141

4242
@OneToMany(mappedBy = "parent", cascade = CascadeType.ALL, orphanRemoval = true)
4343
@Builder.Default

โ€Žsrc/main/java/com/be/sportizebe/domain/comment/exception/CommentErrorCode.javaโ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ public enum CommentErrorCode implements BaseErrorCode {
1212
COMMENT_DELETE_DENIED("C002", "๋Œ“๊ธ€ ์‚ญ์ œ ๊ถŒํ•œ์ด ์—†์Šต๋‹ˆ๋‹ค.", HttpStatus.FORBIDDEN),
1313
COMMENT_UPDATE_DENIED("C003", "๋Œ“๊ธ€ ์ˆ˜์ • ๊ถŒํ•œ์ด ์—†์Šต๋‹ˆ๋‹ค.", HttpStatus.FORBIDDEN),
1414
INVALID_PARENT_COMMENT("C004", "์œ ํšจํ•˜์ง€ ์•Š์€ ๋ถ€๋ชจ ๋Œ“๊ธ€์ž…๋‹ˆ๋‹ค.", HttpStatus.BAD_REQUEST),
15-
COMMENT_PARENT_POST_MISMATCH("C005", "๋ถ€๋ชจ ๋Œ“๊ธ€ ๋‹ค๋ฅธ ๊ฒŒ์‹œ๊ธ€์— ์†ํ•ด์žˆ์Šต๋‹ˆ๋‹ค.", HttpStatus.BAD_REQUEST);
15+
COMMENT_PARENT_POST_MISMATCH("C005", "๋ถ€๋ชจ ๋Œ“๊ธ€ ๋‹ค๋ฅธ ๊ฒŒ์‹œ๊ธ€์— ์†ํ•ด์žˆ์Šต๋‹ˆ๋‹ค.", HttpStatus.BAD_REQUEST),
16+
NESTED_REPLY_NOT_ALLOWED("C006", "๋Œ€๋Œ“๊ธ€์—๋Š” ๋‹ต๊ธ€์„ ๋‹ฌ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.", HttpStatus.BAD_REQUEST);
1617

1718
private final String code;
1819
private final String message;

โ€Žsrc/main/java/com/be/sportizebe/domain/comment/service/CommentService.javaโ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public interface CommentService {
1515
List<CommentResponse> getCommentsByPostId(Long postId);
1616

1717
// ๋Œ“๊ธ€ ์‚ญ์ œ
18-
// void deleteComment(Long commentId, User user);
18+
void deleteComment(Long commentId, User user);
1919

2020
// ๊ฒŒ์‹œ๊ธ€์˜ ๋Œ“๊ธ€ ์ˆ˜ ์กฐํšŒ
2121
long getCommentCount(Long postId);

โ€Žsrc/main/java/com/be/sportizebe/domain/comment/service/CommentServiceImpl.javaโ€Ž

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,19 @@ public CommentResponse createComment(Long postId, CreateCommentRequest request,
3434

3535
// ๋ถ€๋ชจ ๋Œ“๊ธ€ ์กฐํšŒ (๋Œ€๋Œ“๊ธ€์ธ ๊ฒฝ์šฐ)
3636
Comment parent = null; // null๋กœ ์ดˆ๊ธฐํ™”
37-
if (request.parentId() != null) { // parentId๊ฐ€ null์ด ์•„๋‹ˆ๋ฉด ๋Œ€๋Œ“๊ธ€์ด๊ธฐ ๋•Œ๋ฌธ์— ๋ถ€๋ชจ ๋Œ“๊ธ€ ์กฐํšŒ๊ฐ€ ํ•„์š”ํ•จ
37+
if (request.parentId() != null) { // parentId๊ฐ€ null์ด ์•„๋‹ˆ๋ฉด ๋Œ€๋Œ“๊ธ€์ด๊ธฐ ๋•Œ๋ฌธ์— ๋ถ€๋ชจ ๋Œ“๊ธ€ ์กฐํšŒ๋กœ ๊ฒ€์ฆ ํ•„์š”ํ•จ
3838
parent = commentRepository.findById(request.parentId())
3939
.orElseThrow(() -> new CustomException(CommentErrorCode.COMMENT_NOT_FOUND));
4040

4141
// ํ•ด๋‹น ๋Œ€๋Œ“๊ธ€์˜ ๋ถ€๋ชจ ๋Œ“๊ธ€์ด ๊ฐ™์€ ๊ฒŒ์‹œ๊ธ€์— ์†ํ•˜๋Š”์ง€ ๊ฒ€์ฆ
4242
if(parent.getPost().getId() != post.getId()) {
4343
throw new CustomException(CommentErrorCode.COMMENT_PARENT_POST_MISMATCH);
4444
}
45+
46+
// ๋ถ€๋ชจ ๋Œ“๊ธ€์ด ์ด๋ฏธ ๋Œ€๋Œ“๊ธ€์ธ ๊ฒฝ์šฐ ๋‹ต๊ธ€ ๋ถˆ๊ฐ€ (๋Œ“๊ธ€ ๊นŠ์ด 1๋‹จ๊ณ„๋กœ ์ œํ•œ)
47+
if(parent.getParent() != null) {
48+
throw new CustomException(CommentErrorCode.NESTED_REPLY_NOT_ALLOWED);
49+
}
4550
}
4651

4752
// ๋Œ“๊ธ€ ์ƒ์„ฑ
@@ -65,19 +70,19 @@ public List<CommentResponse> getCommentsByPostId(Long postId) {
6570
.toList();
6671
}
6772

68-
// @Override
69-
// @Transactional
70-
// public void deleteComment(Long commentId, User user) {
71-
// Comment comment = commentRepository.findById(commentId)
72-
// .orElseThrow(() -> new CustomException(CommentErrorCode.COMMENT_NOT_FOUND));
73-
//
74-
// // ์ž‘์„ฑ์ž ํ™•์ธ
75-
// if (!comment.getUser().getId().equals(user.getId())) {
76-
// throw new CustomException(CommentErrorCode.COMMENT_DELETE_DENIED);
77-
// }
78-
//
79-
// commentRepository.delete(comment);
80-
// }
73+
@Override
74+
@Transactional
75+
public void deleteComment(Long commentId, User user) {
76+
Comment comment = commentRepository.findById(commentId)
77+
.orElseThrow(() -> new CustomException(CommentErrorCode.COMMENT_NOT_FOUND));
78+
79+
// ์ž‘์„ฑ์ž ํ™•์ธ
80+
if (comment.getUser().getId() != user.getId()) {
81+
throw new CustomException(CommentErrorCode.COMMENT_DELETE_DENIED);
82+
}
83+
84+
commentRepository.delete(comment);
85+
}
8186

8287
@Override
8388
public long getCommentCount(Long postId) {
Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package com.be.sportizebe.domain.post.controller;
22

33
import com.be.sportizebe.domain.post.dto.request.CreatePostRequest;
4-
import com.be.sportizebe.domain.post.dto.response.CreatePostResponse;
4+
import com.be.sportizebe.domain.post.dto.request.UpdatePostRequest;
5+
import com.be.sportizebe.domain.post.dto.response.PostResponse;
56
import com.be.sportizebe.domain.post.entity.PostProperty;
67
import com.be.sportizebe.domain.post.service.PostService;
8+
import com.be.sportizebe.domain.user.entity.User;
9+
import com.be.sportizebe.domain.user.repository.UserRepository;
710
import com.be.sportizebe.global.response.BaseResponse;
811
import io.swagger.v3.oas.annotations.Operation;
912
import io.swagger.v3.oas.annotations.Parameter;
@@ -12,11 +15,7 @@
1215
import lombok.RequiredArgsConstructor;
1316
import org.springframework.http.HttpStatus;
1417
import org.springframework.http.ResponseEntity;
15-
import org.springframework.web.bind.annotation.PathVariable;
16-
import org.springframework.web.bind.annotation.PostMapping;
17-
import org.springframework.web.bind.annotation.RequestBody;
18-
import org.springframework.web.bind.annotation.RequestMapping;
19-
import org.springframework.web.bind.annotation.RestController;
18+
import org.springframework.web.bind.annotation.*;
2019

2120
@RestController
2221
@RequiredArgsConstructor
@@ -25,14 +24,41 @@
2524
public class PostController {
2625

2726
private final PostService postService;
27+
private final UserRepository userRepository; // TODO: ์ธ์ฆ ๋กœ์ง ๊ฐœ๋ฐœ ํ›„ ์ œ๊ฑฐ
2828

2929
@PostMapping("/posts/{property}")
3030
@Operation(summary = "๊ฒŒ์‹œ๊ธ€ ์ƒ์„ฑ", description = "๊ฒŒ์‹œํŒ ์ข…๋ฅ˜๋ณ„ ๊ฒŒ์‹œ๊ธ€ ์ƒ์„ฑ")
31-
public ResponseEntity<BaseResponse<CreatePostResponse>> createPost(
31+
public ResponseEntity<BaseResponse<PostResponse>> createPost(
3232
@Parameter(description = "๊ฒŒ์‹œํŒ ์ข…๋ฅ˜ (SOCCER, BASKETBALL, FREE)") @PathVariable PostProperty property,
3333
@RequestBody @Valid CreatePostRequest request) {
34-
CreatePostResponse response = postService.createPost(property, request);
34+
// TODO: ์ธ์ฆ ๋กœ์ง ๊ฐœ๋ฐœ ํ›„ @AuthenticationPrincipal User user๋กœ ๋ณ€๊ฒฝ
35+
User user = userRepository.findById(1L)
36+
.orElseThrow(() -> new RuntimeException("ํ…Œ์ŠคํŠธ ์œ ์ €๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค. users ํ…Œ์ด๋ธ”์— id=1์ธ ์œ ์ €๋ฅผ ์ถ”๊ฐ€ํ•ด์ฃผ์„ธ์š”."));
37+
PostResponse response = postService.createPost(property, request, user);
3538
return ResponseEntity.status(HttpStatus.CREATED)
3639
.body(BaseResponse.success("๊ฒŒ์‹œ๊ธ€ ์ƒ์„ฑ ์„ฑ๊ณต", response));
3740
}
41+
42+
@PutMapping("/posts/{postId}")
43+
@Operation(summary = "๊ฒŒ์‹œ๊ธ€ ์ˆ˜์ •", description = "๊ฒŒ์‹œ๊ธ€ ์ˆ˜์ • (์ž‘์„ฑ์ž๋งŒ ๊ฐ€๋Šฅ)")
44+
public ResponseEntity<BaseResponse<PostResponse>> updatePost(
45+
@Parameter(description = "๊ฒŒ์‹œ๊ธ€ ID") @PathVariable Long postId,
46+
@RequestBody @Valid UpdatePostRequest request) {
47+
// TODO: ์ธ์ฆ ๋กœ์ง ๊ฐœ๋ฐœ ํ›„ @AuthenticationPrincipal User user๋กœ ๋ณ€๊ฒฝ
48+
User user = userRepository.findById(1L)
49+
.orElseThrow(() -> new RuntimeException("ํ…Œ์ŠคํŠธ ์œ ์ €๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค. users ํ…Œ์ด๋ธ”์— id=1์ธ ์œ ์ €๋ฅผ ์ถ”๊ฐ€ํ•ด์ฃผ์„ธ์š”."));
50+
PostResponse response = postService.updatePost(postId, request, user);
51+
return ResponseEntity.ok(BaseResponse.success("๊ฒŒ์‹œ๊ธ€ ์ˆ˜์ • ์„ฑ๊ณต", response));
52+
}
53+
54+
@DeleteMapping("/posts/{postId}")
55+
@Operation(summary = "๊ฒŒ์‹œ๊ธ€ ์‚ญ์ œ", description = "๊ฒŒ์‹œ๊ธ€ ์‚ญ์ œ (์ž‘์„ฑ์ž๋งŒ ๊ฐ€๋Šฅ)")
56+
public ResponseEntity<BaseResponse<Void>> deletePost(
57+
@Parameter(description = "๊ฒŒ์‹œ๊ธ€ ID") @PathVariable Long postId) {
58+
// TODO: ์ธ์ฆ ๋กœ์ง ๊ฐœ๋ฐœ ํ›„ @AuthenticationPrincipal User user๋กœ ๋ณ€๊ฒฝ
59+
User user = userRepository.findById(1L)
60+
.orElseThrow(() -> new RuntimeException("ํ…Œ์ŠคํŠธ ์œ ์ €๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค. users ํ…Œ์ด๋ธ”์— id=1์ธ ์œ ์ €๋ฅผ ์ถ”๊ฐ€ํ•ด์ฃผ์„ธ์š”."));
61+
postService.deletePost(postId, user);
62+
return ResponseEntity.ok(BaseResponse.success("๊ฒŒ์‹œ๊ธ€ ์‚ญ์ œ ์„ฑ๊ณต", null));
63+
}
3864
}

โ€Žsrc/main/java/com/be/sportizebe/domain/post/dto/request/CreatePostRequest.javaโ€Ž

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.be.sportizebe.domain.post.entity.Post;
44
import com.be.sportizebe.domain.post.entity.PostProperty;
5+
import com.be.sportizebe.domain.user.entity.User;
56
import jakarta.validation.constraints.NotBlank;
67
import lombok.Builder;
78

@@ -12,13 +13,14 @@ public record CreatePostRequest(
1213
boolean isAnonymous,
1314
String imgUrl) {
1415

15-
public Post toEntity(PostProperty property) { // DTO -> Entity ๋ณ€ํ™˜
16+
public Post toEntity(PostProperty property, User user) { // DTO -> Entity ๋ณ€ํ™˜
1617
return Post.builder()
1718
.title(title)
1819
.content(content)
1920
.isAnonymous(isAnonymous)
2021
.imgUrl(imgUrl)
2122
.property(property)
23+
.user(user)
2224
.build();
2325
}
2426
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.be.sportizebe.domain.post.dto.request;
2+
3+
import jakarta.validation.constraints.NotBlank;
4+
5+
public record UpdatePostRequest(
6+
@NotBlank(message = "์ œ๋ชฉ์€ ํ•„์ˆ˜์ž…๋‹ˆ๋‹ค.") String title,
7+
@NotBlank(message = "๋‚ด์šฉ์€ ํ•„์ˆ˜์ž…๋‹ˆ๋‹ค.") String content,
8+
String imgUrl) {
9+
}

src/main/java/com/be/sportizebe/domain/post/dto/response/CreatePostResponse.java renamed to src/main/java/com/be/sportizebe/domain/post/dto/response/PostResponse.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,19 @@
55
import lombok.Builder;
66

77
@Builder
8-
@Schema(title = "CreatePostResponse DTO", description = "๊ฒŒ์‹œ๊ธ€ ์ƒ์„ฑ ์‘๋‹ต")
9-
public record CreatePostResponse(
8+
@Schema(title = "PostResponse DTO", description = "๊ฒŒ์‹œ๊ธ€ ๊ด€๋ จ ์‘๋‹ต")
9+
public record PostResponse(
1010
@Schema(description = "๊ฒŒ์‹œ๊ธ€ ๊ณ ์œ ๋ฒˆํ˜ธ", example = "1") Long postId,
11+
@Schema(description = "๊ฒŒ์‹œ๊ธ€ ์ œ๋ชฉ", example = "๊ฒŒ์‹œ๊ธ€ ์ œ๋ชฉ ...") String title,
1112
@Schema(description = "๊ฒŒ์‹œ๊ธ€ ๋‚ด์šฉ", example = "๊ฒŒ์‹œ๊ธ€ ๊ธ€ ๋‚ด์šฉ ...") String content,
1213
@Schema(description = "๊ฒŒ์‹œ๊ธ€ ๋“ฑ๋ก์ž", example = "์‚ฌ์šฉ์ž๋ช…") String publisher,
1314
@Schema(description = "๊ฒŒ์‹œ๊ธ€ ์‚ฌ์ง„ url", example = "s3 url") String imgUrl,
1415
@Schema(description = "์ต๋ช… ์—ฌ๋ถ€", example = "true:์ต๋ช… / false:์‚ฌ์šฉ์ž๋ช…") String isAnonymous) {
1516

16-
public static CreatePostResponse from(Post post) { // Post -> Resonse ๋ณ€ํ™˜
17-
return CreatePostResponse.builder()
17+
public static PostResponse from(Post post) { // Post -> Response ๋ณ€ํ™˜
18+
return PostResponse.builder()
1819
.postId(post.getId())
20+
.title(post.getTitle())
1921
.content(post.getContent())
2022
.publisher(post.isAnonymous() ? "์ต๋ช…" : "์‚ฌ์šฉ์ž๋ช…") // TODO: User ๋งคํ•‘ ํ•„์š”
2123
.imgUrl(post.getImgUrl())

โ€Žsrc/main/java/com/be/sportizebe/domain/post/entity/Post.javaโ€Ž

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,10 @@ public class Post extends BaseTimeEntity {
3636
@ManyToOne(fetch = FetchType.LAZY)
3737
@JoinColumn(name = "user_id")
3838
private User user; // ์ž‘์„ฑ์ž
39+
40+
public void update(String title, String content, String imgUrl) {
41+
this.title = title;
42+
this.content = content;
43+
this.imgUrl = imgUrl;
44+
}
3945
}

0 commit comments

Comments
ย (0)