Skip to content

Commit

Permalink
Merge pull request #18 from TG-WinG/feature/blog
Browse files Browse the repository at this point in the history
Feature/blog
  • Loading branch information
wwingyou authored Oct 14, 2024
2 parents 37efa41 + 5c4772d commit fd6929f
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 30 deletions.
2 changes: 0 additions & 2 deletions src/main/java/kr/tgwing/tech/blog/entity/Comment.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;

import kr.tgwing.tech.common.BaseEntity;
import kr.tgwing.tech.user.entity.User;
Expand All @@ -26,7 +25,6 @@
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ToString
public class Comment extends BaseEntity {

@Id @GeneratedValue
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/kr/tgwing/tech/blog/entity/Hashtag.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;

import kr.tgwing.tech.common.BaseEntity;

Expand All @@ -21,7 +20,6 @@
@AllArgsConstructor
@NoArgsConstructor
@Builder
@ToString
@Table(name = "hashtag")
public class Hashtag extends BaseEntity {

Expand Down
2 changes: 0 additions & 2 deletions src/main/java/kr/tgwing/tech/blog/entity/Post.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;

import kr.tgwing.tech.common.BaseEntity;
import kr.tgwing.tech.user.entity.User;
Expand All @@ -30,7 +29,6 @@
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ToString
@Table(name = "post")
public class Post extends BaseEntity {

Expand Down
2 changes: 0 additions & 2 deletions src/main/java/kr/tgwing/tech/blog/entity/Reply.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;

import kr.tgwing.tech.common.BaseEntity;
import kr.tgwing.tech.user.entity.User;
Expand All @@ -21,7 +20,6 @@
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ToString
public class Reply extends BaseEntity {

@Id @GeneratedValue
Expand Down
24 changes: 16 additions & 8 deletions src/main/java/kr/tgwing/tech/common/exception/ExceptionMapper.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
package kr.tgwing.tech.common.exception;

import kr.tgwing.tech.blog.exception.post.*;
import java.util.LinkedHashMap;
import java.util.Map;

import org.springframework.http.HttpStatus;

import kr.tgwing.tech.blog.exception.post.InappropriateUserPostRelationException;
import kr.tgwing.tech.blog.exception.post.PageExceededDataException;
import kr.tgwing.tech.blog.exception.post.PathHasNoPostIdException;
import kr.tgwing.tech.blog.exception.post.PostNotFoundException;
import kr.tgwing.tech.blog.exception.post.UserIsNotPostWriterException;
import kr.tgwing.tech.blog.exception.post.WrongPostRequestException;
import kr.tgwing.tech.blog.exception.reply.ReplyBadRequestException;
import kr.tgwing.tech.blog.exception.reply.ReplyForbiddenException;
import kr.tgwing.tech.blog.exception.reply.ReplyNotFoundException;
import kr.tgwing.tech.project.exception.ProjectNotFoundException;
import kr.tgwing.tech.user.exception.*;
import org.springframework.http.HttpStatus;

import java.util.LinkedHashMap;
import java.util.Map;
import kr.tgwing.tech.user.exception.EmailCodeException;
import kr.tgwing.tech.user.exception.MessageException;
import kr.tgwing.tech.user.exception.PasswordException;
import kr.tgwing.tech.user.exception.UserDuplicatedException;
import kr.tgwing.tech.user.exception.UserNotFoundException;

public class ExceptionMapper { // 예외 객체 -> 예외 상태로 바꿔주는 mapper

Expand Down Expand Up @@ -65,10 +75,8 @@ private static void setUpProjectException() {
ExceptionSituation.of("찾고자 하는 프로젝트가 존재하지 않습니다.", HttpStatus.NOT_FOUND, 6600));
}


public static ExceptionSituation getSituationOf(Exception exception) {
return mapper.get(exception.getClass());
}


}
21 changes: 10 additions & 11 deletions src/main/java/kr/tgwing/tech/file/controller/FileController.java
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
package kr.tgwing.tech.file.controller;

import kr.tgwing.tech.file.dto.DownloadResponse;
import kr.tgwing.tech.file.dto.ImageResponse;
import kr.tgwing.tech.file.service.FileServiceImpl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Profile;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.UUID;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import kr.tgwing.tech.file.dto.DownloadResponse;
import kr.tgwing.tech.file.dto.ImageResponse;
import kr.tgwing.tech.file.service.FileServiceImpl;

@Profile("dev")
@Controller
@RestController
@RequiredArgsConstructor
@Slf4j
public class FileController {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application-dev.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ spring.datasource.password=tgwing2024
spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.hibernate.ddl-auto=create
spring.jpa.open-in-view=false
spring.jpa.generate-ddl=true
spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package kr.tgwing.tech.blog.repository;

import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.Assertions.catchThrowable;

import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -33,6 +35,11 @@ void findAllPostsByTitleContainsKeywordAndHashtagIsInHashtags() {
List<Post> all = postRepository.findAll(spec);

System.out.println(all.size());
assertTrue(all.size() == 1);
assertThat(all).hasSize(1);

assertThatThrownBy(() -> { throw new RuntimeException("Boom!"); }).hasMessage("Boom!");

Throwable throwable = catchThrowable(() -> { throw new RuntimeException("Boom!"); });
assertThat(throwable).hasMessageFindingMatch("Boo");
}
}

0 comments on commit fd6929f

Please sign in to comment.