Skip to content

Commit

Permalink
Merge pull request #47 from Link-MIND/test
Browse files Browse the repository at this point in the history
[Merge] merge to develop
  • Loading branch information
sss4920 committed Jan 11, 2024
2 parents c6fc393 + 16c31d0 commit 7e99d95
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 4 deletions.
2 changes: 2 additions & 0 deletions linkmind/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ dependencies {
implementation 'com.slack.api:slack-app-backend:1.28.0'
implementation 'com.slack.api:slack-api-model:1.28.0'

implementation 'io.sentry:sentry-spring-boot-starter:5.7.0'

}

tasks.named('test') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,13 @@ public ApiResponse getTimerPage(
@UserId Long userId) throws IOException {
return ApiResponse.success(Success.GET_TIMER_PAGE_SUCCESS, timerService.getTimerPage(userId));
}

@PatchMapping("/alarm/{timerId}")
@ResponseStatus(HttpStatus.OK)
public ApiResponse changeAlarm(
@UserId Long userId,
@PathVariable Long timerId) {
timerService.changeAlarm(userId, timerId);
return ApiResponse.success(Success.CHANGE_TIMER_ALARM_SUCCESS);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
import lombok.Builder;

@Builder
public record CategoriesReponse(Long CategoryId, String categoryTitle, int toastNum) {
public record CategoriesReponse(Long categoryId, String categoryTitle, int toastNum) {

}
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package com.app.toaster.controller.response.main;

import com.app.toaster.controller.response.category.CategoriesReponse;
import com.app.toaster.controller.response.toast.MainToastDto;
import com.app.toaster.domain.RecommendSite;
import lombok.Builder;

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

@Builder
public record MainPageResponseDto(String nickname, int readToastNum, int allToastNum, List<CategoriesReponse> mainCategoryListDto, List<RecommendSite> recommendedSiteListDto) {
public record MainPageResponseDto(String nickname, int readToastNum, int allToastNum, List<CategoriesReponse> mainCategoryListDto, List<MainToastDto> toastListDto, List<RecommendSite> recommendedSiteListDto) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.app.toaster.controller.response.toast;

import com.app.toaster.domain.Toast;

public record MainToastDto(Long toastId, String toastTitle, String toastImg, String toastLink) {
public static MainToastDto of(Toast toast){
return new MainToastDto(toast.getId(), toast.getTitle(), toast.getThumbnailUrl(), toast.getLinkUrl());
}
}
4 changes: 4 additions & 0 deletions linkmind/src/main/java/com/app/toaster/domain/Reminder.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,8 @@ public void updateRemindDates(ArrayList<Integer> remindDates){
public void updateComment(String comment){
this.comment = comment;
}

public void changeAlarm(){
this.isAlarm = !isAlarm;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public enum Success {
UPDATE_CATEGORY_TITLE_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 @@ -39,4 +39,5 @@ public interface ToastRepository extends JpaRepository<Toast, Long> {
Long countALLByUserAndIsReadTrue(User user);

Long countAllByUserAndIsReadFalse(User user);

}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public List<CategoriesReponse> getCategories(Long userId){
return categoryRepository.findAllByUserOrderByPriority(presentUser)
.stream()
.map(category -> CategoriesReponse.builder()
.CategoryId(category.getCategoryId())
.categoryId(category.getCategoryId())
.categoryTitle(category.getTitle())
.toastNum(toastRepository.getAllByCategory(category).size()).build()
).collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.app.toaster.controller.response.category.CategoriesReponse;
import com.app.toaster.controller.response.main.MainPageResponseDto;
import com.app.toaster.controller.response.toast.MainToastDto;
import com.app.toaster.domain.Category;
import com.app.toaster.domain.User;
import com.app.toaster.exception.Error;
Expand Down Expand Up @@ -37,10 +38,12 @@ public MainPageResponseDto getMainPage(Long userId) {
MainPageResponseDto mainPageResponseDto = MainPageResponseDto.builder().nickname(user.getNickname())
.allToastNum(allToastNum)
.readToastNum(readToastNum)
.toastListDto(toastRepository.findAll().subList(0,Math.min(3,toastRepository.findAll().size()))
.stream().map(MainToastDto::of).toList())
.recommendedSiteListDto(recommedSiteRepository.findAll().subList(0, Math.min(9, recommedSiteRepository.findAll().size())))
.mainCategoryListDto(getCategory(user).stream()
.map(category -> CategoriesReponse.builder()
.CategoryId(category.getCategoryId())
.categoryId(category.getCategoryId())
.categoryTitle(category.getTitle())
.toastNum(toastRepository.getAllByCategory(category).size()).build()
).collect(Collectors.toList())).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,20 @@ public void deleteTimer(Long userId, Long timerId){
timerRepository.delete(reminder);
}

@Transactional
public void changeAlarm(Long userId, Long timerId){
User presentUser = findUser(userId);

Reminder reminder = timerRepository.findById(timerId)
.orElseThrow(() -> new NotFoundException(Error.NOT_FOUND_TIMER, Error.NOT_FOUND_TIMER.getMessage()));

if (!presentUser.equals(reminder.getUser())){
throw new UnauthorizedException(Error.INVALID_USER_ACCESS, Error.INVALID_USER_ACCESS.getMessage());
}

reminder.changeAlarm();
}

public GetTimerPageResponseDto getTimerPage(Long userId) throws IOException {
User presentUser = findUser(userId);
ArrayList<Reminder> reminders = timerRepository.findAllByUser(presentUser);
Expand Down

0 comments on commit 7e99d95

Please sign in to comment.