diff --git a/out/production/resources/application.yml b/out/production/resources/application.yml index 196b4bb..04772a2 100644 --- a/out/production/resources/application.yml +++ b/out/production/resources/application.yml @@ -8,6 +8,7 @@ spring: properties: hibernate: format_sql: true + show_sql: true --- # Settings for local spring: diff --git a/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/controller/accountBookSharingController.java b/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/controller/accountBookSharingController.java index f8da3e5..eb4c425 100644 --- a/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/controller/accountBookSharingController.java +++ b/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/controller/accountBookSharingController.java @@ -1,28 +1,47 @@ -package com.umc.DongnaeFriend.domain.account.book.controller; +package com.umc.DongnaeFriend.domain.account.sharing.controller; +import com.umc.DongnaeFriend.domain.account.sharing.dto.SharingDto; +import com.umc.DongnaeFriend.domain.account.sharing.service.AccountBookSharingService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Pageable; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; +import java.util.List; + +@Slf4j @RestController @RequestMapping("/account-books/sharing") public class accountBookSharingController { + @Autowired + AccountBookSharingService accountBookSharingService; + /** * [가계부 공유] 게시글 검색 * @param keyword * @param pageable * - * + * @param pageable * size : 페이지 사이즈 * page : 페이지 * sortBy : 정렬순 - * - + * - like + * - createdAt */ @GetMapping("/search") - public ResponseEntity searchAll(@RequestParam("keyword")String keyword, @RequestParam("category") int category, Pageable pageable) { - + + public ResponseEntity searchAll(@RequestParam("keyword") String keyword, @RequestParam("category") int category, Pageable pageable) { + log.info("searching : " + keyword + category); + List res = accountBookSharingService.searchByKeyword(keyword, category, pageable); + log.info("res "); + return ResponseEntity.ok(res); } + + + + } diff --git a/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/dto/SharingDto.java b/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/dto/SharingDto.java index cc7101d..e9155d7 100644 --- a/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/dto/SharingDto.java +++ b/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/dto/SharingDto.java @@ -1,4 +1,4 @@ -package com.umc.DongnaeFriend.domain.account.book.dto; +package com.umc.DongnaeFriend.domain.account.sharing.dto; import lombok.AllArgsConstructor; import lombok.Builder; @@ -12,7 +12,7 @@ public class SharingDto { @AllArgsConstructor @NoArgsConstructor public static class ListResponse { - private String id; + private Long id; private int category; @@ -29,6 +29,9 @@ public static class ListResponse { private int commentCount; private int likes; + } + + } diff --git a/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/entity/SharingBoard.java b/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/entity/SharingBoard.java index 343fa87..8b84595 100644 --- a/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/entity/SharingBoard.java +++ b/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/entity/SharingBoard.java @@ -12,6 +12,7 @@ import com.umc.DongnaeFriend.domain.user.entity.User; import javax.persistence.*; import lombok.*; +import org.hibernate.annotations.ColumnDefault; @Getter @Builder @@ -38,4 +39,8 @@ public class SharingBoard extends BaseTimeEntity { @Column(columnDefinition = "MEDIUMTEXT", nullable = false) private String content; + + @Column(name = "view") + @ColumnDefault("0") + private Integer view; } diff --git a/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/repository/SharingBoardRepository.java b/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/repository/SharingBoardRepository.java index 51e1b58..44692ff 100644 --- a/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/repository/SharingBoardRepository.java +++ b/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/repository/SharingBoardRepository.java @@ -1,19 +1,45 @@ -package com.umc.DongnaeFriend.domain.account.book.repository; +package com.umc.DongnaeFriend.domain.account.sharing.repository; +import com.umc.DongnaeFriend.domain.account.sharing.dto.SharingDto; import com.umc.DongnaeFriend.domain.account.sharing.entity.SharingBoard; import com.umc.DongnaeFriend.domain.dongnae.entity.DongnaeBoard; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; +import javax.persistence.EntityManager; import java.util.List; -public interface SharingBoardRepository extends JpaRepository { +@Repository +public interface SharingBoardRepository extends JpaRepository { - @Query(value = "SELECT sharing_board.*, COUNT(sharing_sympathy.sharing_board_id) AS like FROM sharing_board\n" + + +// private final EntityManager em; +// +// public SharingBoardRepository(EntityManager em) { +// this.em = em; +// } + +// public List findByKeywordAAndCategory(@Param("keyword") String keyword, @Param("category") String category, Pageable pageable) { +// return em.createQuery("SELECT new com.umc.DongnaeFriend.domain.account.sharing.dto.SharingDto.ListResponse(s.id, s.category, s.title, s.content, s.createdAt, s.view, likes), count(SharingSympathy.sharingBoard.id) as likes " + +// "FROM SharingBoard s left join SharingSympathy on s.id=SharingSympathy.sharingBoard.id " + +// "WHERE (s.title LIKE %:keyword% or s.content LIKE % :keyword%) and s.category = :category " + +// "group by s.id", SharingDto.ListResponse.class) +// .setParameter("keyword", keyword) +// .setParameter("category", category) +// .getResultList(); +// } + + + @Query(value = "SELECT sharing_board.*, COUNT(sharing_sympathy.sharing_board_id) AS cnt FROM sharing_board\n" + "LEFT JOIN sharing_sympathy ON sharing_board.sharing_board_id = sharing_sympathy.sharing_board_id\n" + - "WHERE (sharing_board.title LIKE %?1% OR sharing_board.content LIKE %?2%)\n" + - "AND sharing_board.category = ?2 GROUP BY sharing_board.sharing_board_id ;", nativeQuery = true) - List findByKeywordAAndCategory(String keyword, String category, Pageable pageable); + "WHERE (sharing_board.title LIKE %:keyword% OR sharing_board.content LIKE %:keyword%)\n" + + "AND sharing_board.category = :category GROUP BY sharing_board.sharing_board_id ", nativeQuery = true) + List findByKeywordOrderByLikes(@Param("keyword") String keyword, @Param("category") String category, Pageable pageable); + + + } diff --git a/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/repository/SharingCommentRepository.java b/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/repository/SharingCommentRepository.java new file mode 100644 index 0000000..91ff0ee --- /dev/null +++ b/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/repository/SharingCommentRepository.java @@ -0,0 +1,11 @@ +package com.umc.DongnaeFriend.domain.account.sharing.repository; + +import com.umc.DongnaeFriend.domain.account.sharing.entity.SharingComment; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface SharingCommentRepository extends JpaRepository { + + public int countAllBySharingBoardId(Long sharing_board_id); +} diff --git a/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/repository/SharingImgRepository.java b/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/repository/SharingImgRepository.java new file mode 100644 index 0000000..2ce7801 --- /dev/null +++ b/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/repository/SharingImgRepository.java @@ -0,0 +1,15 @@ +package com.umc.DongnaeFriend.domain.account.sharing.repository; + +import com.umc.DongnaeFriend.domain.account.sharing.entity.SharingImg; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.stereotype.Repository; + +import java.util.Optional; + +@Repository +public interface SharingImgRepository extends JpaRepository { + + @Query(value = "SELECT * FROM sharing_img WHERE sharing_board_id = ?1 ORDER BY created_at ASC LIMIT 1", nativeQuery = true) + Optional findFirst(long sharing_board_id); +} diff --git a/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/repository/SharingSympathyRepository.java b/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/repository/SharingSympathyRepository.java new file mode 100644 index 0000000..fdd5e38 --- /dev/null +++ b/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/repository/SharingSympathyRepository.java @@ -0,0 +1,14 @@ +package com.umc.DongnaeFriend.domain.account.sharing.repository; + +import com.umc.DongnaeFriend.domain.account.sharing.entity.SharingSympathy; +import com.umc.DongnaeFriend.domain.dongnae.entity.DongnaeSympathy; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.List; + +public interface SharingSympathyRepository extends JpaRepository { + + int countAllBySharingBoardId(Long sharing_board_id); + + List findByUser_Id(long user_id); +} diff --git a/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/service/AccountBookSharingService.java b/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/service/AccountBookSharingService.java index 435bebb..c16a8f5 100644 --- a/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/service/AccountBookSharingService.java +++ b/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/service/AccountBookSharingService.java @@ -1,4 +1,11 @@ -package com.umc.DongnaeFriend.domain.account.book.service; +package com.umc.DongnaeFriend.domain.account.sharing.service; -public interface accountBookSharingService { +import com.umc.DongnaeFriend.domain.account.sharing.dto.SharingDto; +import org.springframework.data.domain.Pageable; + +import java.util.List; + +public interface AccountBookSharingService { + + List searchByKeyword(String keyword, int category, Pageable pageable); } diff --git a/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/service/AccountBookSharingServiceImpl.java b/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/service/AccountBookSharingServiceImpl.java index b437742..c2a03d0 100644 --- a/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/service/AccountBookSharingServiceImpl.java +++ b/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/service/AccountBookSharingServiceImpl.java @@ -1,37 +1,92 @@ -package com.umc.DongnaeFriend.domain.account.book.service; +package com.umc.DongnaeFriend.domain.account.sharing.service; -import com.umc.DongnaeFriend.domain.account.book.dto.SharingDto; -import com.umc.DongnaeFriend.domain.account.book.repository.SharingBoardRepository; +import com.umc.DongnaeFriend.domain.account.sharing.dto.SharingDto; +import com.umc.DongnaeFriend.domain.account.sharing.entity.SharingBoard; +import com.umc.DongnaeFriend.domain.account.sharing.entity.SharingImg; +import com.umc.DongnaeFriend.domain.account.sharing.repository.SharingBoardRepository; +import com.umc.DongnaeFriend.domain.account.sharing.repository.SharingCommentRepository; +import com.umc.DongnaeFriend.domain.account.sharing.repository.SharingImgRepository; +import com.umc.DongnaeFriend.domain.account.sharing.repository.SharingSympathyRepository; import com.umc.DongnaeFriend.domain.dongnae.entity.Dongnae; import com.umc.DongnaeFriend.domain.type.Age; import com.umc.DongnaeFriend.domain.type.Gender; import com.umc.DongnaeFriend.domain.type.SharingCategory; import com.umc.DongnaeFriend.domain.type.YesNo; import com.umc.DongnaeFriend.domain.user.entity.User; +import com.umc.DongnaeFriend.global.exception.CustomException; +import com.umc.DongnaeFriend.global.exception.ErrorCode; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import java.util.List; +import java.util.stream.Collectors; +import static com.umc.DongnaeFriend.global.util.TimeUtil.getTime; + +@Slf4j @Service -public class accountBookSharingServiceImpl implements accountBookSharingService { +public class AccountBookSharingServiceImpl implements AccountBookSharingService { //임시 유저 Dongnae dongnae = Dongnae.builder().id(1L).gu("서울구").dong("서울동").city("서울시").townName("무슨마을").build(); User user = User.builder().id(1L).age(Age.AGE10).email("email").dongnae(dongnae).gender(Gender.FEMALE).infoCert(YesNo.NO).townCert(YesNo.NO).townCertCnt(10).id(1L).kakaoId(90L).nickname("nickname").refreshToken("refreshToken").build(); - @Autowired private SharingBoardRepository sharingBoardRepository; + @Autowired + private SharingImgRepository sharingImgRepository; + + @Autowired + private SharingCommentRepository sharingCommentRepository; + + @Autowired + private SharingSympathyRepository sharingSympathyRepository; + + /* - * [가계부 공유] 게시글 검 + * [가계부 공유] 게시글 검색 */ + @Override public List searchByKeyword(String keyword, int category, Pageable pageable) { - sharingBoardRepository.findByKeywordAAndCategory(keyword, SharingCategory.valueOf(category).name(), pageable); + //TODO : 전체 카테고리 처리 + List sharingBoards = sharingBoardRepository.findByKeywordOrderByLikes(keyword, SharingCategory.valueOf(category).name(), pageable); + if (sharingBoards.isEmpty()) { + throw new CustomException(ErrorCode.NO_CONTENT_FOUND); + } + log.info("board found" + sharingBoards.get(0).getId()); + return getListResponses(sharingBoards); } + + //ListResponse 변환 + private List getListResponses(List sharingBoardList) { + return sharingBoardList.stream() + .map(origin -> SharingDto.ListResponse.builder() + .id(origin.getId()) + .category(origin.getCategory().getValue()) + .title(origin.getTitle()) + .content(origin.getContent()) + .imageUrl( + sharingImgRepository.findFirst(origin.getId()).map(SharingImg::getImageUrl).orElse("") + ) + .createdAt( + getTime(origin.getCreatedAt()) + ) + .view(origin.getView()) + .commentCount( + sharingCommentRepository.countAllBySharingBoardId(origin.getId()) + ) + .likes( + sharingSympathyRepository.countAllBySharingBoardId(origin.getId()) + ) + .build()) + .collect(Collectors.toList()); + } + + + } diff --git a/src/main/java/com/umc/DongnaeFriend/domain/dongnae/dto/DongnaeBoardDto.java b/src/main/java/com/umc/DongnaeFriend/domain/dongnae/dto/DongnaeBoardDto.java index 8fcf7bd..0dc62ea 100644 --- a/src/main/java/com/umc/DongnaeFriend/domain/dongnae/dto/DongnaeBoardDto.java +++ b/src/main/java/com/umc/DongnaeFriend/domain/dongnae/dto/DongnaeBoardDto.java @@ -10,8 +10,6 @@ import java.util.List; -import static com.umc.DongnaeFriend.domain.type.DongnaeBoardCategory.*; - public class DongnaeBoardDto { @@ -55,6 +53,7 @@ public DongnaeBoard toEntity(User user, Dongnae dongnae) { @AllArgsConstructor @NoArgsConstructor public static class ListResponse { + private Long id; private String town; private int category; diff --git a/src/main/java/com/umc/DongnaeFriend/domain/dongnae/entity/DongnaeBoard.java b/src/main/java/com/umc/DongnaeFriend/domain/dongnae/entity/DongnaeBoard.java index c5fc447..e25e247 100644 --- a/src/main/java/com/umc/DongnaeFriend/domain/dongnae/entity/DongnaeBoard.java +++ b/src/main/java/com/umc/DongnaeFriend/domain/dongnae/entity/DongnaeBoard.java @@ -6,7 +6,6 @@ import static lombok.AccessLevel.PRIVATE; import static lombok.AccessLevel.PROTECTED; -import com.fasterxml.jackson.annotation.JsonIgnore; import com.umc.DongnaeFriend.domain.BaseTimeEntity; import com.umc.DongnaeFriend.domain.dongnae.dto.DongnaeBoardDto; import com.umc.DongnaeFriend.domain.type.DongnaeBoardCategory; @@ -15,8 +14,6 @@ import lombok.*; import org.hibernate.annotations.ColumnDefault; -import java.util.List; - @Getter @Builder @NoArgsConstructor(access = PROTECTED) diff --git a/src/main/java/com/umc/DongnaeFriend/domain/dongnae/service/DongnaeBoardServiceImpl.java b/src/main/java/com/umc/DongnaeFriend/domain/dongnae/service/DongnaeBoardServiceImpl.java index c0a861a..e75a0d7 100644 --- a/src/main/java/com/umc/DongnaeFriend/domain/dongnae/service/DongnaeBoardServiceImpl.java +++ b/src/main/java/com/umc/DongnaeFriend/domain/dongnae/service/DongnaeBoardServiceImpl.java @@ -22,14 +22,14 @@ import javax.naming.AuthenticationException; import javax.persistence.EntityNotFoundException; -import java.time.Duration; -import java.time.LocalDateTime; import java.util.List; import java.util.Objects; import java.util.Optional; import java.util.stream.Collectors; +import static com.umc.DongnaeFriend.global.util.TimeUtil.getTime; + @Slf4j @Service public class DongnaeBoardServiceImpl implements DongnaeBoardService { @@ -119,9 +119,6 @@ public List searchAll(int sort) { @Override public void createBoard(DongnaeBoardDto.Request req) { //TODO : User Mapping UserRepository 필요. - Dongnae dongnae = Dongnae.builder().id(1L).gu("서울구").dong("서울동").city("서울시").townName("무슨마을").build(); - User user = User.builder().age(Age.AGE10).profileImage("profileImg").email("email").dongnae(dongnae).gender(Gender.FEMALE).infoCert(YesNo.NO).townCert(YesNo.NO).id(1L).kakaoId(90L).nickname("nickname").refreshToken("refreshToken").build(); - dongnaeBoardRepository.save(req.toEntity(user, dongnae)); } @@ -153,6 +150,7 @@ public DongnaeBoardDto.Response getBoard(long board_id) { boolean scrapOrNot = false; return DongnaeBoardDto.Response.builder() + .profileImage(user.getProfileImage()) .nickname(user.getNickname()) .category(board.get().getCategory().getValue()) @@ -207,6 +205,7 @@ public void deleteBoard(long board_id) throws AuthenticationException { private List getListResponses(List dongnaeBoardList) { return dongnaeBoardList.stream() .map(origin -> DongnaeBoardDto.ListResponse.builder() + .id(origin.getId()) .town(origin.getPlace()) .category(origin.getCategory().getValue()) .title(origin.getTitle()) @@ -229,32 +228,7 @@ private List getListResponses(List d } - //시간 계산 - private String getTime(LocalDateTime time) { - LocalDateTime now = LocalDateTime.now(); // 현재 시간 - Duration duration = Duration.between(now, time); - log.info(now.toString()); - log.info(time.toString()); - long days = -duration.toDays(); - log.info(" days: "+ days); - long hours = -duration.toHours() % 24; - log.info(" hours: "+ hours); - long minutes = -duration.toMinutes() % 60; - log.info(" minutes: "+ minutes); - - if (days >= 1){ - if (days == 1) { - return "어제"; - } - return days + "일 전"; - } - - else if (hours >= 1) { - return hours + "시간 전"; - } else return minutes + "분 전"; - - } } diff --git a/src/main/java/com/umc/DongnaeFriend/domain/type/SharingCategory.java b/src/main/java/com/umc/DongnaeFriend/domain/type/SharingCategory.java index bfd3248..e10aa9d 100644 --- a/src/main/java/com/umc/DongnaeFriend/domain/type/SharingCategory.java +++ b/src/main/java/com/umc/DongnaeFriend/domain/type/SharingCategory.java @@ -1,5 +1,7 @@ package com.umc.DongnaeFriend.domain.type; +import com.umc.DongnaeFriend.global.exception.CustomException; +import com.umc.DongnaeFriend.global.exception.ErrorCode; import lombok.Getter; import lombok.RequiredArgsConstructor; @@ -13,4 +15,13 @@ public enum SharingCategory { private final Integer value; private final String category; + + public static SharingCategory valueOf(Integer value) { + for (SharingCategory category : SharingCategory.values()) { + if (category.getValue().equals(value)) { + return category; + } else throw new CustomException(ErrorCode.INVALID_VALUE); + } + throw new IllegalArgumentException("Invalid Category: " + value); + } } diff --git a/src/main/java/com/umc/DongnaeFriend/global/exception/ErrorCode.java b/src/main/java/com/umc/DongnaeFriend/global/exception/ErrorCode.java index 9ac2371..a3a73e9 100644 --- a/src/main/java/com/umc/DongnaeFriend/global/exception/ErrorCode.java +++ b/src/main/java/com/umc/DongnaeFriend/global/exception/ErrorCode.java @@ -15,6 +15,8 @@ public enum ErrorCode { /* 50* 스크랩 */ + /* 200 NO_CONTENT : 자료를 찾을 수 없음 */ + NO_CONTENT_FOUND(NO_CONTENT, 204, "요청된 자료를 찾을 수 없습니다."), /* 400 BAD_REQUEST : 잘못된 요청 */ INVALID_REFRESH_TOKEN(BAD_REQUEST, 400, "리프레시 토큰이 유효하지 않습니다"), @@ -32,6 +34,7 @@ public enum ErrorCode { REFRESH_TOKEN_NOT_FOUND(NOT_FOUND, 404,"로그아웃 된 사용자입니다"), NOT_FOLLOW(NOT_FOUND,404, "팔로우 중이지 않습니다"), + /* 409 CONFLICT : Resource 의 현재 상태와 충돌. 보통 중복된 데이터 존재 */ DUPLICATE_RESOURCE(CONFLICT,409, "데이터가 이미 존재합니다"), diff --git a/src/main/java/com/umc/DongnaeFriend/global/util/FileUtil.java b/src/main/java/com/umc/DongnaeFriend/global/util/FileUtil.java new file mode 100644 index 0000000..5f72d7a --- /dev/null +++ b/src/main/java/com/umc/DongnaeFriend/global/util/FileUtil.java @@ -0,0 +1,25 @@ +package com.umc.DongnaeFriend.global.util; + +import org.springframework.web.multipart.MultipartFile; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +public class FileUtil { + + public static String fileUpload(List files) throws IOException { + String filepath = "/resources/static/img"; + + List list = new ArrayList<>(); + for (MultipartFile file : files) { + String originalfileName = file.getOriginalFilename(); + File dest = new File(filepath + originalfileName); + file.transferTo(dest); + list.add(dest.getPath()); + } + return String.join(",", list); + } + +} diff --git a/src/main/java/com/umc/DongnaeFriend/global/util/TimeUtil.java b/src/main/java/com/umc/DongnaeFriend/global/util/TimeUtil.java new file mode 100644 index 0000000..527175e --- /dev/null +++ b/src/main/java/com/umc/DongnaeFriend/global/util/TimeUtil.java @@ -0,0 +1,29 @@ +package com.umc.DongnaeFriend.global.util; + +import java.time.Duration; +import java.time.LocalDateTime; + +public class TimeUtil { + + //시간 계산 + public static String getTime(LocalDateTime time) { + LocalDateTime now = LocalDateTime.now(); // 현재 시간 + Duration duration = Duration.between(now, time); + + long days = -duration.toDays(); + long hours = -duration.toHours() % 24; + long minutes = -duration.toMinutes() % 60; + + if (days >= 1){ + if (days == 1) { + return "어제"; + } + return days + "일 전"; + } + + else if (hours >= 1) { + return hours + "시간 전"; + } else return minutes + "분 전"; + + } +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 196b4bb..04772a2 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -8,6 +8,7 @@ spring: properties: hibernate: format_sql: true + show_sql: true --- # Settings for local spring: diff --git a/src/main/resources/static/img/.keep b/src/main/resources/static/img/.keep new file mode 100644 index 0000000..e69de29