Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat/#242] 링크 이동, 최근 본 링크 구현 #244

Merged
merged 5 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
Expand Up @@ -4,8 +4,7 @@
import com.app.toaster.config.UserId;
import com.app.toaster.controller.request.category.*;
import com.app.toaster.controller.response.category.CategoriesResponse;
import com.app.toaster.controller.response.toast.ToastFilter;
import com.app.toaster.controller.response.category.CategoryResponse;
import com.app.toaster.toast.controller.response.ToastFilter;
import com.app.toaster.controller.response.category.GetCategoryResponseDto;
import com.app.toaster.controller.valid.Severity;
import com.app.toaster.controller.valid.TitleValid;
Expand All @@ -14,14 +13,12 @@
import com.app.toaster.service.search.SearchService;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/category")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
import org.springframework.web.bind.annotation.*;

import com.app.toaster.common.dto.ApiResponse;
import com.app.toaster.config.UserId;
import com.app.toaster.controller.valid.TitleValid;
import com.app.toaster.service.UserService;
import com.app.toaster.service.search.SearchService;
import com.app.toaster.service.toast.ToastService;

import lombok.RequiredArgsConstructor;

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package com.app.toaster.controller.response.category;

import com.app.toaster.controller.response.auth.TokenResponseDto;
import com.app.toaster.controller.response.toast.ToastDto;
import com.app.toaster.domain.Toast;
import com.app.toaster.toast.controller.response.ToastDto;
import lombok.Builder;

import java.util.ArrayList;
import java.util.List;

@Builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.List;

import com.app.toaster.controller.response.toast.ToastDto;
import com.app.toaster.toast.controller.response.ToastDto;

public record SearchMainResult(String keyword, List<ToastDto> toasts, List<CategoryResult> categories) {
public static SearchMainResult of(String keyword, List<ToastDto> toasts, List<CategoryResult> categories){
Expand Down
2 changes: 2 additions & 0 deletions linkmind/src/main/java/com/app/toaster/exception/Success.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public enum Success {
GET_SITES_SUCCESS(HttpStatus.OK, "추천 사이트 조회 성공"),
GET_SETTINGS_SUCCESS(HttpStatus.OK, "설정 페이지 조회 성공"),
GET_POPUP_SUCCESS(HttpStatus.OK, "팝업 정보 조회 성공"),
GET_RECENT_TOAST_SUCCESS(HttpStatus.OK, "최근 저장한 토스트 조회 성공"),

GET_CATEORIES_SUCCESS(HttpStatus.OK, "전체 카테고리 조회 성공"),
GET_CATEORY_SUCCESS(HttpStatus.OK, "세부 카테고리 조회 성공"),
Expand All @@ -47,6 +48,7 @@ public enum Success {

UPDATE_ISREAD_SUCCESS(HttpStatus.OK, "열람여부 수정 완료"),
UPDATE_CATEGORY_TITLE_SUCCESS(HttpStatus.OK, "카테고리 수정 완료"),
MOVE_CATEGORY_SUCCESS(HttpStatus.OK, "카테고리 이동 성공"),
UPDATE_TIMER_DATETIME_SUCCESS(HttpStatus.OK, "타이머 시간/날짜 수정 완료"),
UPDATE_TIMER_COMMENT_SUCCESS(HttpStatus.OK, "타이머 코멘트 수정 완료"),
CHANGE_TIMER_ALARM_SUCCESS(HttpStatus.OK, "타이머 알람여부 수정 완료"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// import com.app.toaster.domain.Category;
// import com.app.toaster.domain.QToast;
// import com.app.toaster.domain.QUser;
// import com.app.toaster.domain.Toast;
// import com.app.toaster.toast.domain.Toast;
// import com.app.toaster.domain.User;
// import com.querydsl.core.types.Path;
// import com.querydsl.core.types.dsl.BooleanExpression;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import com.app.toaster.exception.Error;
import com.app.toaster.exception.model.BadRequestException;
import com.app.toaster.exception.model.NotFoundException;
import com.app.toaster.infrastructure.ToastRepository;
import com.app.toaster.toast.infrastructure.ToastRepository;
import com.app.toaster.infrastructure.UserRepository;

// import com.app.toaster.infrastructure.querydsl.CustomToastRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;

import com.app.toaster.common.dto.ApiResponse;
import com.app.toaster.config.jwt.JwtService;
import com.app.toaster.controller.request.auth.SignInRequestDto;
import com.app.toaster.controller.response.auth.SignInResponseDto;
Expand All @@ -17,21 +15,19 @@
import com.app.toaster.domain.User;
import com.app.toaster.exception.Error;
import com.app.toaster.exception.Success;
import com.app.toaster.exception.model.BadRequestException;
import com.app.toaster.exception.model.CustomException;
import com.app.toaster.exception.model.NotFoundException;
import com.app.toaster.exception.model.UnprocessableEntityException;
import com.app.toaster.external.client.slack.SlackApi;
import com.app.toaster.infrastructure.CategoryRepository;
import com.app.toaster.infrastructure.TimerRepository;
import com.app.toaster.infrastructure.ToastRepository;
import com.app.toaster.toast.infrastructure.ToastRepository;
import com.app.toaster.infrastructure.UserRepository;
import com.app.toaster.popup.entity.PopupInvisibleManager;
import com.app.toaster.popup.infrastructure.PopupManagerRepository;
import com.app.toaster.service.auth.apple.AppleSignInService;
import com.app.toaster.service.auth.kakao.KakaoSignInService;
import com.app.toaster.service.auth.kakao.LoginResult;
import com.app.toaster.service.toast.ToastService;
import com.app.toaster.toast.service.ToastService;

import lombok.RequiredArgsConstructor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
import com.app.toaster.controller.request.category.*;
import com.app.toaster.controller.response.category.CategoriesResponse;
import com.app.toaster.controller.response.category.DuplicatedResponse;
import com.app.toaster.controller.response.toast.ToastDto;
import com.app.toaster.controller.response.toast.ToastFilter;
import com.app.toaster.toast.controller.response.ToastDto;
import com.app.toaster.toast.controller.response.ToastFilter;
import com.app.toaster.controller.response.category.CategoryResponse;
import com.app.toaster.controller.response.category.GetCategoryResponseDto;
import com.app.toaster.domain.Category;
import com.app.toaster.domain.Reminder;
import com.app.toaster.domain.Toast;
import com.app.toaster.toast.domain.Toast;
import com.app.toaster.domain.User;
import com.app.toaster.exception.Error;
import com.app.toaster.exception.model.BadRequestException;
import com.app.toaster.exception.model.CustomException;
import com.app.toaster.exception.model.NotFoundException;
import com.app.toaster.infrastructure.CategoryRepository;
import com.app.toaster.infrastructure.TimerRepository;
import com.app.toaster.infrastructure.ToastRepository;
import com.app.toaster.toast.infrastructure.ToastRepository;
import com.app.toaster.infrastructure.UserRepository;

import lombok.RequiredArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.app.toaster.service.link;

import com.app.toaster.controller.response.toast.WeekLinkDto;
import com.app.toaster.toast.controller.response.WeekLinkDto;
import com.app.toaster.domain.Link;
import com.app.toaster.infrastructure.LinkRepository;
import lombok.RequiredArgsConstructor;
Expand All @@ -9,10 +9,7 @@

import java.time.Duration;
import java.time.LocalDateTime;
import java.time.Period;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@Service
@RequiredArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,19 @@

import com.app.toaster.common.dto.ApiResponse;
import com.app.toaster.controller.response.search.CategoryResult;
import com.app.toaster.controller.response.search.SearchCategoryResult;
import com.app.toaster.controller.response.search.SearchMainResult;
import com.app.toaster.controller.response.search.ToastResult;
import com.app.toaster.controller.response.toast.ToastDto;
import com.app.toaster.toast.controller.response.ToastDto;
import com.app.toaster.domain.Category;
import com.app.toaster.domain.Toast;
import com.app.toaster.toast.domain.Toast;
import com.app.toaster.domain.User;
import com.app.toaster.exception.Error;
import com.app.toaster.exception.Success;
import com.app.toaster.exception.model.BadRequestException;
import com.app.toaster.exception.model.CustomException;
import com.app.toaster.exception.model.NotFoundException;
import com.app.toaster.infrastructure.CategoryRepository;
import com.app.toaster.infrastructure.ToastRepository;
import com.app.toaster.toast.infrastructure.ToastRepository;
import com.app.toaster.infrastructure.UserRepository;
import com.google.protobuf.Api;

import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;

@Service
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package com.app.toaster.controller;
package com.app.toaster.toast.controller;

import java.io.IOException;
import java.util.List;

import com.app.toaster.controller.request.toast.UpdateToastDto;
import com.app.toaster.controller.response.toast.ModifiedTitle;
import com.app.toaster.controller.response.toast.WeekLinkDto;
import com.app.toaster.service.link.LinkService;
import com.app.toaster.toast.controller.request.*;
import com.app.toaster.toast.controller.response.*;
import org.springframework.http.HttpStatus;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
Expand All @@ -22,13 +21,9 @@
import com.app.toaster.common.dto.ApiResponse;
// import com.app.toaster.config.UserId;
import com.app.toaster.config.UserId;
import com.app.toaster.controller.request.toast.IsReadDto;
import com.app.toaster.controller.request.toast.OgRequestDto;
import com.app.toaster.controller.request.toast.SaveToastDto;
import com.app.toaster.controller.response.toast.IsReadResponse;
import com.app.toaster.exception.Success;
import com.app.toaster.service.parse.ParsingService;
import com.app.toaster.service.toast.ToastService;
import com.app.toaster.toast.service.ToastService;

import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -89,6 +84,14 @@ public ApiResponse<List<WeekLinkDto>> getWeekLinks(
return ApiResponse.success(Success.GET_LINKS_SUCCESS, linkService.getWeekLinks());
}

@GetMapping("/recent-saved")
@ResponseStatus(HttpStatus.OK)
public ApiResponse<List<ToastDto>> getRecentSavedLinks(
@UserId Long userId
) {
return ApiResponse.success(Success.GET_RECENT_TOAST_SUCCESS, toastService.getToastTop3_savedRecently(userId));
}

@PatchMapping("/title")
@ResponseStatus(HttpStatus.OK)
public ApiResponse<ModifiedTitle> modifyTitle(
Expand All @@ -98,5 +101,13 @@ public ApiResponse<ModifiedTitle> modifyTitle(
return ApiResponse.success(Success.UPDATE_TOAST_TITLE_SUCCESS, toastService.modifyTitle(userId,updateToastDto));
}

@PatchMapping("/category")
@ResponseStatus(HttpStatus.OK)
public ApiResponse<ModifiedCategory> modifyCategory(
@UserId Long userId,
@Valid @RequestBody MoveToastDto updateToastDto
){
return ApiResponse.success(Success.MOVE_CATEGORY_SUCCESS, toastService.modifyClip(userId,updateToastDto));
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.app.toaster.controller.request.toast;
package com.app.toaster.toast.controller.request;

public record IsReadDto(Long toastId, Boolean isRead) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.app.toaster.toast.controller.request;

import jakarta.validation.constraints.NotNull;

public record MoveToastDto(Long toastId, @NotNull Long categoryId) {
Copy link
Member

Choose a reason for hiding this comment

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

toastId는 NotNull 애노테이션 하지않은이유가 있을까요???

Copy link
Contributor Author

Choose a reason for hiding this comment

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

전체 카테고리를 생각하다가 헷갈렸던 것 같네요..! toastId는 null이면 안될 것 같습니다!

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.app.toaster.toast.controller.request;

public record OgRequestDto(String linkUrl) {
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.app.toaster.controller.request.toast;
package com.app.toaster.toast.controller.request;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.app.toaster.controller.request.toast;
package com.app.toaster.toast.controller.request;

import com.app.toaster.controller.valid.Severity;
import com.app.toaster.controller.valid.TitleValid;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.app.toaster.controller.response.toast;
package com.app.toaster.toast.controller.response;

public record IsReadResponse(Boolean isRead) {
public static IsReadResponse of(Boolean isRead){
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.app.toaster.toast.controller.response;

public record ModifiedCategory(Long categoryId) {
public static ModifiedCategory of(Long categoryId){
return new ModifiedCategory(categoryId);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.app.toaster.controller.response.toast;
package com.app.toaster.toast.controller.response;

public record ModifiedTitle(String updatedTitle) {
public static ModifiedTitle of(String updatedTitle){
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.app.toaster.controller.response.toast;
package com.app.toaster.toast.controller.response;

import com.app.toaster.controller.response.category.GetCategoryResponseDto;
import com.app.toaster.domain.Toast;
import com.app.toaster.toast.domain.Toast;

public record ToastDto (Long toastId, String toastTitle, String linkUrl, Boolean isRead, String categoryTitle, String thumbnailUrl){
public static ToastDto of(Toast toast){
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.app.toaster.controller.response.toast;
package com.app.toaster.toast.controller.response;

public enum ToastFilter {
ALL,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.app.toaster.controller.response.toast;
package com.app.toaster.toast.controller.response;

import com.app.toaster.domain.Link;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.app.toaster.domain;
package com.app.toaster.toast.domain;

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

import com.app.toaster.domain.Category;
import com.app.toaster.domain.User;
import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.Builder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
package com.app.toaster.infrastructure;
package com.app.toaster.toast.infrastructure;

import com.app.toaster.domain.Category;
import com.app.toaster.domain.User;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import com.app.toaster.domain.Category;
import com.app.toaster.domain.Toast;
import com.app.toaster.domain.User;
import com.app.toaster.toast.domain.Toast;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.time.LocalDateTime;
Expand Down Expand Up @@ -64,4 +61,6 @@ Long countAllByUpdateAtThisWeek(@Param("startOfWeek") LocalDateTime startOfWeek,
@Param("endOfWeek") LocalDateTime endOfWeek,
@Param("user") User user);

List<Toast> findTop3ByUserOrderByCreatedAtDesc(User user);

}
Loading
Loading