Skip to content

Commit

Permalink
Merge pull request #193 from Link-MIND/test
Browse files Browse the repository at this point in the history
[Merge] 각종 버그 해결
  • Loading branch information
sss4920 authored Jan 18, 2024
2 parents fdb5ce8 + 323b15d commit 21738aa
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void increasePriorityByOne(@Param("categoryId") Long categoryId,

Long countAllByUser(User user);

Long countAllByTitle(String title);
Long countAllByTitleAndUser(String title);



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class UserService {
private final ToastRepository toastRepository;
private final CategoryRepository categoryRepository;

@Transactional(readOnly = true)
public MyPageResponse getMyPage(Long userId){
User user = userRepository.findByUserId(userId)
.orElseThrow(()-> new NotFoundException(Error.NOT_FOUND_USER_EXCEPTION, Error.NOT_FOUND_USER_EXCEPTION.getMessage()));
Expand All @@ -59,6 +60,7 @@ public Boolean allowedPushNotification(Long userId, Boolean fcmIsAllowed) {
return fcmIsAllowed;
}

@Transactional(readOnly = true)
public SettingResponse getSettings(Long userId){
User user = userRepository.findByUserId(userId)
.orElseThrow(()-> new NotFoundException(Error.NOT_FOUND_USER_EXCEPTION, Error.NOT_FOUND_USER_EXCEPTION.getMessage()));
Expand All @@ -68,6 +70,7 @@ public SettingResponse getSettings(Long userId){
);
}

@Transactional(readOnly = true)
public MainPageResponseDto getMainPage(Long userId){
User user = userRepository.findByUserId(userId)
.orElseThrow(() -> new NotFoundException(Error.NOT_FOUND_USER_EXCEPTION, Error.NOT_FOUND_USER_EXCEPTION.getMessage()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void createCategory(final Long userId, final CreateCategoryDto createCate
Error.BAD_REQUEST_CREATE_CLIP_EXCEPTION.getMessage());
}

if(categoryRepository.countAllByTitle(createCategoryDto.categoryTitle())>0){
if(categoryRepository.countAllByTitleAndUser(createCategoryDto.categoryTitle())>0){
throw new CustomException(Error.UNPROCESSABLE_CREATE_TIMER_EXCEPTION, Error.UNPROCESSABLE_CREATE_TIMER_EXCEPTION.getMessage());
}

Expand Down Expand Up @@ -94,7 +94,7 @@ public void deleteCategory(final ArrayList<Long> deleteCategoryDto) {
}

}

@Transactional(readOnly = true)
public CategoriesResponse getCategories(final Long userId) {
User presentUser = findUser(userId);

Expand All @@ -108,7 +108,7 @@ public CategoriesResponse getCategories(final Long userId) {
).collect(Collectors.toList()));

}

@Transactional
public GetCategoryResponseDto getCategory(final Long userId, final Long categoryId, final ToastFilter filter) {
User presentUser = findUser(userId);
if (categoryId == 0) {
Expand Down Expand Up @@ -169,7 +169,7 @@ private User findUser(Long userId) {
() -> new NotFoundException(Error.NOT_FOUND_USER_EXCEPTION, Error.NOT_FOUND_USER_EXCEPTION.getMessage())
);
}

@Transactional(readOnly = true)
public DuplicatedResponse checkDuplicatedTitle(Long userId, String title) {
return DuplicatedResponse.of(categoryRepository.existsCategoriesByUserAndTitle(findUser(userId), title));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.stream.Collectors;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.app.toaster.common.dto.ApiResponse;
import com.app.toaster.controller.response.search.CategoryResult;
Expand Down Expand Up @@ -34,6 +35,7 @@ public class SearchService {
private final UserRepository userRepository;
private final CategoryRepository categoryRepository;

@Transactional(readOnly = true)
public ApiResponse<SearchMainResult> searchMain(Long userId, String searchParam){
if(searchParam.isBlank()){
throw new BadRequestException(Error.BAD_REQUEST_VALIDATION, Error.BAD_REQUEST_URL.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void createTimer(Long userId, CreateTimerRequestDto createTimerRequestDto
fcmService.schedulePushAlarm(cronExpression, reminder.getId());
}
}

@Transactional(readOnly = true)
public GetTimerResponseDto getTimer(Long userId, Long timerId){
Reminder reminder = timerRepository.findById(timerId)
.orElseThrow(() -> new NotFoundException(Error.NOT_FOUND_TIMER, Error.NOT_FOUND_TIMER.getMessage()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ public void createToast(Long userId, SaveToastDto saveToastDto){
}

}

@Transactional
public IsReadResponse readToast(Long userId, IsReadDto isReadDto){
User presentUser = userRepository.findByUserId(userId).orElseThrow(
Expand Down

0 comments on commit 21738aa

Please sign in to comment.