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
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.example.FixLog.controller;

import com.example.FixLog.dto.post.NewPostRequestDto;
import com.example.FixLog.dto.post.PostRequestDto;
import com.example.FixLog.dto.Response;
import com.example.FixLog.dto.post.PostResponseDto;
Expand Down Expand Up @@ -34,8 +33,8 @@ public Response<String> uploadImage(@RequestPart("imageFile") MultipartFile imag
// 게시글 수정하기
@PatchMapping("/{postId}/edit")
public Response<Object> editPost(@PathVariable("postId") Long postId,
@RequestBody NewPostRequestDto newPostRequestDto){
postService.editPost(postId, newPostRequestDto);
@RequestBody PostRequestDto postRequestDto){
postService.editPost(postId, postRequestDto);
return Response.success("게시글 수정 성공.", null);
}

Expand Down
8 changes: 7 additions & 1 deletion src/main/java/com/example/FixLog/domain/tag/Tag.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@ public class Tag {
@Column(length = 20, nullable = false)
private String tagName;

@Column(nullable = false)
private String tagInfo;

public static Tag of(TagCategory tagCategory, String tagName) {
Tag tag = new Tag();
tag.tagCategory = tagCategory;
tag.tagName = tagName;
return tag;
}

public static Tag of(TagCategory tagCategory, String tagName, String tagInfo) {
Tag tag = new Tag();
tag.tagCategory = tagCategory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,31 @@ public class MyPostPageResponseDto {
private int likeCount;
private int forkCount;
private String nickname;
private String profileImageUrl;

// 이미지 null일 때 default 사진으로 변경 - 프로필 사진
public static String getDefaultProfile(String image){
String imageUrl = (image == null || image.isBlank())
? "https://fixlog-bucket.s3.ap-northeast-2.amazonaws.com/default/profile.png" : image;
System.out.println(imageUrl);
return imageUrl;
}
// 이미지 null일 때 default 사진으로 변경 - 썸네일
public static String getDefaultCover(String image){
String imageUrl = (image == null || image.isBlank())
? "https://fixlogsmwubucket.s3.ap-northeast-2.amazonaws.com/default/DefaulThumnail.png" : image;
System.out.println(imageUrl);
return imageUrl;
}
Comment on lines +28 to +41
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

URL 오타 수정 필요

기본 이미지 처리 메서드 추가는 좋으나, 38번 라인의 URL에 오타가 있습니다.

-                ? "https://fixlogsmwubucket.s3.ap-northeast-2.amazonaws.com/default/DefaulThumnail.png" : image;
+                ? "https://fixlogsmwubucket.s3.ap-northeast-2.amazonaws.com/default/DefaultThumbnail.png" : image;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// 이미지 null일 때 default 사진으로 변경 - 프로필 사진
public static String getDefaultProfile(String image){
String imageUrl = (image == null || image.isBlank())
? "https://fixlog-bucket.s3.ap-northeast-2.amazonaws.com/default/profile.png" : image;
System.out.println(imageUrl);
return imageUrl;
}
// 이미지 null일 때 default 사진으로 변경 - 썸네일
public static String getDefaultCover(String image){
String imageUrl = (image == null || image.isBlank())
? "https://fixlogsmwubucket.s3.ap-northeast-2.amazonaws.com/default/DefaulThumnail.png" : image;
System.out.println(imageUrl);
return imageUrl;
}
// 이미지 null일 때 default 사진으로 변경 - 프로필 사진
public static String getDefaultProfile(String image){
String imageUrl = (image == null || image.isBlank())
? "https://fixlog-bucket.s3.ap-northeast-2.amazonaws.com/default/profile.png" : image;
System.out.println(imageUrl);
return imageUrl;
}
// 이미지 null일 때 default 사진으로 변경 - 썸네일
public static String getDefaultCover(String image){
String imageUrl = (image == null || image.isBlank())
? "https://fixlogsmwubucket.s3.ap-northeast-2.amazonaws.com/default/DefaultThumbnail.png" : image;
System.out.println(imageUrl);
return imageUrl;
}
🤖 Prompt for AI Agents
In src/main/java/com/example/FixLog/dto/post/MyPostPageResponseDto.java between
lines 28 and 41, the URL in the getDefaultCover method contains a typo in the
domain name. Correct the URL by fixing the domain from "fixlogsmwubucket" to the
proper bucket name, ensuring it matches the intended S3 bucket URL for the
default thumbnail image.


public static MyPostPageResponseDto from(Post post, int forkCount) {
return MyPostPageResponseDto.builder()
.postId(post.getPostId())
.nickname(post.getUserId().getNickname())
.postTitle(post.getPostTitle())
.postSummary(generateSummary(post.getProblem()))
.imageUrl(post.getCoverImage())
.imageUrl(getDefaultCover(post.getCoverImage()))
.profileImageUrl(getDefaultProfile(post.getUserId().getProfileImageUrl()))
.tags(post.getPostTags().stream().map(tag -> tag.getTagId().getTagName()).toList())
.createdAt(post.getCreatedAt())
.likeCount(post.getPostLikes().size())
Expand Down
21 changes: 0 additions & 21 deletions src/main/java/com/example/FixLog/dto/post/NewPostRequestDto.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ public class PostRequestDto {
private String referenceLink;
private String extraContent;

private List<Long> tags;
private List<String> tags;
}
11 changes: 10 additions & 1 deletion src/main/java/com/example/FixLog/exception/CustomException.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,16 @@
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
public class CustomException extends RuntimeException {
private final ErrorCode errorCode;

public CustomException(ErrorCode errorCode) {
super(errorCode.getMessage());
this.errorCode = errorCode;
}

public CustomException(ErrorCode errorCode, String detailMessage) {
super(detailMessage);
this.errorCode = errorCode;
}
}
1 change: 1 addition & 0 deletions src/main/java/com/example/FixLog/exception/ErrorCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public enum ErrorCode {
TAG_NOT_FOUND(HttpStatus.NOT_FOUND, "없는 태그 번호입니다."),
SORT_NOT_EXIST(HttpStatus.BAD_REQUEST, "사용할 수 없는 정렬입니다."),
INVALID_PASSWORD(HttpStatus.UNAUTHORIZED, "비밀번호가 일치하지 않습니다."),
POST_UPDATE_FORBIDDEN(HttpStatus.FORBIDDEN, "본인 게시글만 수정할 수 있습니다."),
REQUIRED_TAGS_MISSING(HttpStatus.BAD_REQUEST, "태그를 선택해주세요."),
REQUIRED_CONTENT_MISSING(HttpStatus.BAD_REQUEST, "필수 본문이 입력되지 않았습니다."),
SAME_AS_OLD_PASSWORD(HttpStatus.BAD_REQUEST, "다른 비밀번호 입력 바랍니다."),
Expand Down
67 changes: 34 additions & 33 deletions src/main/java/com/example/FixLog/mock/TagMockDataInitializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,45 +32,46 @@ public void run(String... args) {
List<Tag> tagsToInsert = new ArrayList<>();

// BIG_CATEGORY
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(BIG_CATEGORY, "백엔드", "backend"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(BIG_CATEGORY, "머신러닝", "machine learning"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(BIG_CATEGORY, "프론트엔드", "frontend"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(BIG_CATEGORY, "backend"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(BIG_CATEGORY, "machine-learning"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(BIG_CATEGORY, "frontend"));

// MAJOR_CATEGORY
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MAJOR_CATEGORY, "장고", "django"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MAJOR_CATEGORY, "스프링부트", "spring-boot"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MAJOR_CATEGORY, "넥스트", "next.js"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MAJOR_CATEGORY, "케라스", "keras"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MAJOR_CATEGORY, "파이토치", "pytorch"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MAJOR_CATEGORY, "사이킷런", "scikit-learn"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MAJOR_CATEGORY, "노드", "node.js"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MAJOR_CATEGORY, "리액트", "react"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MAJOR_CATEGORY, "리액트 네이티브", "react-native"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MAJOR_CATEGORY, "django"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MAJOR_CATEGORY, "spring-boot"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MAJOR_CATEGORY, "next.js"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MAJOR_CATEGORY, "keras"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MAJOR_CATEGORY, "pytorch"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MAJOR_CATEGORY, "scikit-learn"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MAJOR_CATEGORY, "node.js"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MAJOR_CATEGORY, "react"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MAJOR_CATEGORY, "react-native"));

// MIDDLE_CATEGORY
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MIDDLE_CATEGORY, "CSS", "css"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MIDDLE_CATEGORY, "자바스크립트", "javascript"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MIDDLE_CATEGORY, "R", "r"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MIDDLE_CATEGORY, "JSON", "json"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MIDDLE_CATEGORY, "자바", "java"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MIDDLE_CATEGORY, "Haskell", "haskell"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MIDDLE_CATEGORY, "파이썬", "python"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MIDDLE_CATEGORY, "C", "c"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MIDDLE_CATEGORY, "css"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MIDDLE_CATEGORY, "javascript"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MIDDLE_CATEGORY, "r"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MIDDLE_CATEGORY, "json"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MIDDLE_CATEGORY, "java"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MIDDLE_CATEGORY, "haskell"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MIDDLE_CATEGORY, "python"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MIDDLE_CATEGORY, "c"));

// MINOR_CATEGORY
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MINOR_CATEGORY, "NullPointerException", "null-pointer-exception"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MINOR_CATEGORY, "500 Internal Server Error", "500-error"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MINOR_CATEGORY, "CORS 정책 오류", "cors-error"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MINOR_CATEGORY, "Database connection timeout", "db-timeout"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MINOR_CATEGORY, "ClassNotFoundException", "class-not-found"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MINOR_CATEGORY, "Cannot read property of undefined", "undefined-property"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MINOR_CATEGORY, "상태(state) 업데이트 누락", "state-missing"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MINOR_CATEGORY, "HTTP 에러", "http-error"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MINOR_CATEGORY, "렌더링 무한 루프", "render-loop"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MINOR_CATEGORY, "스타일 깨짐", "style-break"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MINOR_CATEGORY, "404 Not Found", "404-error"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MINOR_CATEGORY, "Permission Error", "permission-error"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MINOR_CATEGORY, "OutOfMemoryError", "out-of-memory"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MINOR_CATEGORY, "null-pointer-exception", "NullPointerException"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MINOR_CATEGORY, "500-error", "500 Internal Server Error"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MINOR_CATEGORY, "cors-error", "CORS 정책 오류"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MINOR_CATEGORY, "db-timeout", "Database connection timeout"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MINOR_CATEGORY, "class-not-found", "ClassNotFoundException"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MINOR_CATEGORY, "undefined-property", "Cannot read property of undefined"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MINOR_CATEGORY, "state-missing", "상태(state) 업데이트 누락"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MINOR_CATEGORY, "http-error", "HTTP 에러"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MINOR_CATEGORY, "render-loop", "렌더링 무한 루프"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MINOR_CATEGORY, "style-break", "스타일 깨짐"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MINOR_CATEGORY, "404-error", "404 Not Found"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MINOR_CATEGORY, "permission-error", "Permission Error"));
addIfNotExist(tagsToInsert, existingTagNames, Tag.of(MINOR_CATEGORY, "out-of-memory", "OutOfMemoryError"));


if (!tagsToInsert.isEmpty()) {
tagRepository.saveAll(tagsToInsert);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.Optional;

public interface TagRepository extends JpaRepository<Tag, Long> {
Page<Tag> findAll(Pageable pageable);
Optional<Tag> findByTagName(String tagName);
}
27 changes: 17 additions & 10 deletions src/main/java/com/example/FixLog/service/MainPageService.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,20 @@ public MainPageService(PostRepository postRepository, MemberService memberServic
this.memberService = memberService;
}

// 이미지 null일 때 default 사진으로 변경 (프로필 사진,
public String getDefaultImage(String image){
// 이미지 null일 때 default 사진으로 변경 - 프로필 사진
public String getDefaultProfile(String image){
String imageUrl = (image == null || image.isBlank())
? "https://fixlog-bucket.s3.ap-northeast-2.amazonaws.com/default/profile.png" : image;
System.out.println(imageUrl);
return imageUrl;
}
// 이미지 null일 때 default 사진으로 변경 - 썸네일
public String getDefaultCover(String image){
String imageUrl = (image == null || image.isBlank())
? "https://fixlogsmwubucket.s3.ap-northeast-2.amazonaws.com/default/DefaulThumnail.png" : image;
System.out.println(imageUrl);
return imageUrl;
}
Comment on lines +30 to +43
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

이미지 타입별 메서드 분리는 좋으나 URL 오타 수정 필요

프로필과 썸네일 이미지를 구분하여 처리하는 것은 좋은 설계입니다. 하지만 40번 라인의 URL에 오타가 있습니다.

-                ? "https://fixlogsmwubucket.s3.ap-northeast-2.amazonaws.com/default/DefaulThumnail.png" : image;
+                ? "https://fixlogsmwubucket.s3.ap-northeast-2.amazonaws.com/default/DefaultThumbnail.png" : image;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// 이미지 null일 때 default 사진으로 변경 - 프로필 사진
public String getDefaultProfile(String image){
String imageUrl = (image == null || image.isBlank())
? "https://fixlog-bucket.s3.ap-northeast-2.amazonaws.com/default/profile.png" : image;
System.out.println(imageUrl);
return imageUrl;
}
// 이미지 null일 때 default 사진으로 변경 - 썸네일
public String getDefaultCover(String image){
String imageUrl = (image == null || image.isBlank())
? "https://fixlogsmwubucket.s3.ap-northeast-2.amazonaws.com/default/DefaulThumnail.png" : image;
System.out.println(imageUrl);
return imageUrl;
}
// 이미지 null일 때 default 사진으로 변경 - 썸네일
public String getDefaultCover(String image){
String imageUrl = (image == null || image.isBlank())
? "https://fixlogsmwubucket.s3.ap-northeast-2.amazonaws.com/default/DefaultThumbnail.png" : image;
System.out.println(imageUrl);
return imageUrl;
}
🤖 Prompt for AI Agents
In src/main/java/com/example/FixLog/service/MainPageService.java between lines
30 and 43, the URL in the getDefaultCover method contains a typo in the bucket
name and the default thumbnail filename. Correct the URL to match the proper
bucket name and filename format, ensuring it is consistent with the profile
image URL style and points to the correct resource.


// 메인페이지 보기
public MainPageResponseDto mainPageView(int sort, int size){
Expand All @@ -44,9 +51,9 @@ public MainPageResponseDto mainPageView(int sort, int size){
if (optionalMember.isPresent()) {
Member member = optionalMember.get();
String imageUrl = member.getProfileImageUrl();
profileImageUrl = getDefaultImage(imageUrl);
profileImageUrl = getDefaultProfile(imageUrl);
} else {
profileImageUrl = "https://example.com/default-cover-image.png"; // 비로그인 기본 이미지
profileImageUrl = "https://fixlog-bucket.s3.ap-northeast-2.amazonaws.com/default/profile.png"; // 비로그인 기본 이미지
}

// 페이지 (글 12개) 불러오기
Expand All @@ -67,11 +74,11 @@ public MainPageResponseDto mainPageView(int sort, int size){
List<MainPagePostResponseDto> postList = posts.stream()
.map(post -> new MainPagePostResponseDto(
post.getPostTitle(),
getDefaultImage(post.getCoverImage()),
getDefaultCover(post.getCoverImage()),
post.getPostTags().stream()
.map(postTag -> postTag.getTagId().getTagName())
.collect(Collectors.toList()),
getDefaultImage(post.getUserId().getProfileImageUrl()),
getDefaultProfile(post.getUserId().getProfileImageUrl()),
post.getUserId().getNickname(),
post.getCreatedAt().toLocalDate(),
post.getPostLikes().size()
Expand All @@ -90,9 +97,9 @@ public MainPageResponseDto mainPageFullView(int sort, int page, int size){
if (optionalMember.isPresent()) {
Member member = optionalMember.get();
String imageUrl = member.getProfileImageUrl();
profileImageUrl = getDefaultImage(imageUrl);
profileImageUrl = getDefaultProfile(imageUrl);
} else {
profileImageUrl = "https://example.com/default-cover-image.png"; // 비로그인 기본 이미지
profileImageUrl = "https://fixlog-bucket.s3.ap-northeast-2.amazonaws.com/default/profile.png"; // 비로그인 기본 이미지
}

// 페이지 설정 (한 페이지당 12개)
Expand All @@ -109,11 +116,11 @@ public MainPageResponseDto mainPageFullView(int sort, int page, int size){
List<MainPagePostResponseDto> postList = postPage.stream()
.map(post -> new MainPagePostResponseDto(
post.getPostTitle(),
getDefaultImage(post.getCoverImage()),
getDefaultCover(post.getCoverImage()),
post.getPostTags().stream()
.map(postTag -> postTag.getTagId().getTagName())
.collect(Collectors.toList()),
getDefaultImage(post.getUserId().getProfileImageUrl()),
getDefaultProfile(post.getUserId().getProfileImageUrl()),
post.getUserId().getNickname(),
post.getCreatedAt().toLocalDate(),
post.getPostLikes().size()
Expand Down
Loading