Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/main/java/com/swyp8team2/common/dev/DataInitializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public void init() {
List<User> users = new ArrayList<>();
List<Post> posts = new ArrayList<>();
for (int i = 0; i < 10; i++) {
User user = userRepository.save(User.create(adjectives.get(i).getAdjective(), "https://t1.kakaocdn.net/account_images/default_profile.jpeg"));
String userName = adjectives.size() < 10 ? "user" + i : adjectives.get(i).getAdjective();
User user = userRepository.save(User.create(userName, "https://t1.kakaocdn.net/account_images/default_profile.jpeg"));
users.add(user);
for (int j = 0; j < 30; j += 2) {
ImageFile imageFile1 = imageFileRepository.save(ImageFile.create(new ImageFileDto("202502240006030.png", "https://image.photopic.site/images-dev/202502240006030.png", "https://image.photopic.site/images-dev/resized_202502240006030.png")));
Expand Down
28 changes: 2 additions & 26 deletions src/main/java/com/swyp8team2/post/presentation/PostController.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,24 @@
import com.swyp8team2.auth.domain.UserInfo;
import com.swyp8team2.common.dto.CursorBasePaginatedResponse;
import com.swyp8team2.post.application.PostService;
import com.swyp8team2.post.presentation.dto.AuthorDto;
import com.swyp8team2.post.presentation.dto.CreatePostRequest;
import com.swyp8team2.post.presentation.dto.PostImageVoteStatusResponse;
import com.swyp8team2.post.presentation.dto.PostResponse;
import com.swyp8team2.post.presentation.dto.SimplePostResponse;
import com.swyp8team2.post.presentation.dto.PostImageResponse;
import jakarta.validation.Valid;
import jakarta.validation.constraints.Min;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;

Expand Down Expand Up @@ -62,26 +58,6 @@ public ResponseEntity<List<PostImageVoteStatusResponse>> findVoteStatus(
return ResponseEntity.ok(postService.findPostStatus(postId));
}

// @GetMapping("/{shareUrl}")
public ResponseEntity<PostResponse> findPost(@PathVariable("shareUrl") String shareUrl) {
return ResponseEntity.ok(new PostResponse(
1L,
new AuthorDto(
1L,
"author",
"https://image.photopic.site/profile-image"
),
"description",
List.of(
new PostImageResponse(1L, "λ½€λ˜A", "https://image.photopic.site/image/1", "https://image.photopic.site/image/resize/1", true),
new PostImageResponse(2L, "λ½€λ˜B", "https://image.photopic.site/image/2", "https://image.photopic.site/image/resize/1", false)
),
"https://photopic.site/shareurl",
true,
LocalDateTime.of(2025, 2, 13, 12, 0)
));
}

@PostMapping("/{postId}/close")
public ResponseEntity<Void> closePost(
@PathVariable("postId") Long postId,
Expand All @@ -100,7 +76,7 @@ public ResponseEntity<PostResponse> deletePost(
return ResponseEntity.ok().build();
}

@GetMapping("/me")
@GetMapping("/user")
public ResponseEntity<CursorBasePaginatedResponse<SimplePostResponse>> findMyPosts(
@RequestParam(name = "cursor", required = false) @Min(0) Long cursor,
@RequestParam(name = "size", required = false, defaultValue = "10") @Min(1) int size,
Expand All @@ -109,7 +85,7 @@ public ResponseEntity<CursorBasePaginatedResponse<SimplePostResponse>> findMyPos
return ResponseEntity.ok(postService.findMyPosts(userInfo.userId(), cursor, size));
}

@GetMapping("/voted")
@GetMapping("/user/voted")
public ResponseEntity<CursorBasePaginatedResponse<SimplePostResponse>> findVotedPosts(
@RequestParam(name = "cursor", required = false) @Min(0) Long cursor,
@RequestParam(name = "size", required = false, defaultValue = "10") @Min(1) int size,
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
server:
port: 8080
spring:
profiles:
active: local

---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ void findMyPost() throws Exception {
.willReturn(response);

//when then
mockMvc.perform(get("/posts/me")
mockMvc.perform(get("/posts/user")
.header(HttpHeaders.AUTHORIZATION, "Bearer token"))
.andExpect(status().isOk())
.andExpect(content().json(objectMapper.writeValueAsString(response)))
Expand Down Expand Up @@ -251,7 +251,7 @@ void findVotedPost() throws Exception {
.willReturn(response);

//when then
mockMvc.perform(get("/posts/voted")
mockMvc.perform(get("/posts/user/voted")
.header(HttpHeaders.AUTHORIZATION, "Bearer token"))
.andExpect(status().isOk())
.andExpect(content().json(objectMapper.writeValueAsString(response)))
Expand Down