-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
19 changed files
with
888 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 17 additions & 17 deletions
34
linkmind/src/main/java/com/app/toaster/config/JpaQueryFactoryConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
package com.app.toaster.config; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
|
||
import jakarta.persistence.EntityManager; | ||
|
||
@Configuration | ||
public class JpaQueryFactoryConfig { | ||
|
||
@Bean | ||
JPAQueryFactory jpaQueryFactory(EntityManager em) { | ||
return new JPAQueryFactory(em); | ||
} | ||
} | ||
// package com.app.toaster.config; | ||
// | ||
// import org.springframework.context.annotation.Bean; | ||
// import org.springframework.context.annotation.Configuration; | ||
// | ||
// import com.querydsl.jpa.impl.JPAQueryFactory; | ||
// | ||
// import jakarta.persistence.EntityManager; | ||
// | ||
// @Configuration | ||
// public class JpaQueryFactoryConfig { | ||
// | ||
// @Bean | ||
// JPAQueryFactory jpaQueryFactory(EntityManager em) { | ||
// return new JPAQueryFactory(em); | ||
// } | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
154 changes: 154 additions & 0 deletions
154
linkmind/src/main/java/com/app/toaster/infrastructure/querydsl/CustomToastRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
// package com.app.toaster.infrastructure.querydsl; | ||
// | ||
// import static com.app.toaster.domain.QToast.*; | ||
// import static com.app.toaster.domain.QUser.*; | ||
// | ||
// import java.time.LocalDateTime; | ||
// import java.util.ArrayList; | ||
// import java.util.List; | ||
// import org.springframework.data.jpa.repository.Modifying; | ||
// import org.springframework.data.jpa.repository.Query; | ||
// import org.springframework.data.repository.query.Param; | ||
// import org.springframework.stereotype.Repository; | ||
// | ||
// 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.domain.User; | ||
// import com.querydsl.core.types.Path; | ||
// import com.querydsl.core.types.dsl.BooleanExpression; | ||
// import com.querydsl.jpa.impl.JPAQueryFactory; | ||
// | ||
// import jakarta.persistence.EntityManager; | ||
// import lombok.RequiredArgsConstructor; | ||
// | ||
// @Repository | ||
// @RequiredArgsConstructor | ||
// public class CustomToastRepository { | ||
// private final JPAQueryFactory queryFactory; | ||
// // private final EntityManager em; | ||
// public List<Toast> getAllByCategory(Category category){ | ||
// return queryFactory.select(toast) | ||
// .from(toast) | ||
// .where(eqCategoryId(category.getCategoryId())) | ||
// .fetch(); | ||
// } | ||
// | ||
// private BooleanExpression eqCategoryId(Long id){ | ||
// if (id == null){ | ||
// return null; | ||
// } | ||
// return toast.category.categoryId.eq(id); | ||
// } | ||
// | ||
// ArrayList<Toast> findByIsReadAndCategory(Boolean isRead, Category category){ | ||
// return null; | ||
// }; | ||
// | ||
// ArrayList<Toast> getAllByUser(User user){ | ||
// return null; | ||
// } | ||
// | ||
// List<Toast> getAllByUserOrderByCreatedAtDesc(User user){ | ||
// return null; | ||
// } | ||
// | ||
// | ||
// ArrayList<Toast> getAllByUserAndIsReadIsTrue(User user){ | ||
// return null; | ||
// } | ||
// | ||
// | ||
// // @Modifying | ||
// // @Query("UPDATE Toast t SET t.category = null WHERE t.category.categoryId IN :categoryIds") | ||
// // void updateCategoryIdsToNull(@Param("categoryIds") List<Long> categoryIds){ | ||
// // } | ||
// | ||
// //querydsl의 수정은 bulkupdate라 영속성컨텍스트를 안거치기 때문에 무조건 flush,clear해주자. | ||
// void updateCategoryIdsToNull(List<Long> categoryIds){ | ||
// queryFactory.update(toast) | ||
// .set(toast.category, (Category)null) | ||
// .where(toast.category.categoryId.in(categoryIds)) | ||
// .execute(); | ||
// // em.flush(); //test 코드에서는 따로 em을 주입하는 중이므로 테스트 후 넣자. | ||
// // em.clear(); | ||
// } | ||
// | ||
// | ||
// List<Toast> searchToastsByQuery(Long userId, String query){ | ||
// return queryFactory.select(toast) | ||
// .from(toast) | ||
// .leftJoin(toast.user, user).fetchJoin() | ||
// .where(eqToastOwner(userId), containToastTitle(query)) | ||
// .fetch(); | ||
// } | ||
// private BooleanExpression eqToastOwner(Long userId){ | ||
// return userId != null?toast.user.userId.eq(userId):null; | ||
// } | ||
// | ||
// private BooleanExpression containToastTitle(String query){ | ||
// if (query == null || query.isEmpty() || query.isBlank()){ | ||
// return null; | ||
// } | ||
// return toast.title.containsIgnoreCase(query); | ||
// } | ||
// | ||
// | ||
// | ||
// Long countAllByUser(User user){ | ||
// return null; | ||
// } | ||
// | ||
// | ||
// Long countALLByUserAndIsReadTrue(User user){ | ||
// return null; | ||
// } | ||
// | ||
// | ||
// Long countALLByUserAndIsReadFalse(User user){ | ||
// return null; | ||
// } | ||
// | ||
// | ||
// Long countAllByCategory(Category category){ | ||
// return null; | ||
// } | ||
// | ||
// | ||
// Long countAllByCategoryAndIsReadTrue(Category category){ | ||
// return null; | ||
// } | ||
// | ||
// | ||
// Long countAllByCategoryAndIsReadFalse(Category category){ | ||
// return null; | ||
// } | ||
// | ||
// | ||
// Integer getUnReadToastNumber(Long userId){ | ||
// | ||
// Integer count = queryFactory.select(toast.count().intValue()) | ||
// .from(toast) | ||
// .where(eqToastOwner(userId).and(toast.isRead.isFalse())) | ||
// .fetchOne(); | ||
// return (count!=null)?count:0; | ||
// } | ||
// | ||
// | ||
// @Query("SELECT COUNT(t) FROM Toast t WHERE t.user=:user AND t.createdAt >= :startOfWeek AND t.createdAt <= :endOfWeek") | ||
// Long countAllByCreatedAtThisWeek(@Param("startOfWeek") LocalDateTime startOfWeek, | ||
// @Param("endOfWeek") LocalDateTime endOfWeek, @Param("user") User user){ | ||
// return null; | ||
// } | ||
// | ||
// | ||
// @Query("SELECT COUNT(t) FROM Toast t WHERE t.user=:user AND t.isRead = true AND t.updateAt >= :startOfWeek AND t.updateAt <= :endOfWeek") | ||
// Long countAllByUpdateAtThisWeek(@Param("startOfWeek") LocalDateTime startOfWeek, | ||
// @Param("endOfWeek") LocalDateTime endOfWeek, | ||
// @Param("user") User user){ | ||
// return null; | ||
// } | ||
// | ||
// | ||
// } |
41 changes: 41 additions & 0 deletions
41
linkmind/src/main/java/com/app/toaster/popup/controller/PopupController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.app.toaster.popup.controller; | ||
|
||
import org.springframework.validation.annotation.Validated; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PatchMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import com.app.toaster.popup.controller.request.PopUpRequestDto; | ||
import com.app.toaster.popup.controller.response.InvisibleResponseDto; | ||
import com.app.toaster.popup.controller.response.PopupResponseDto; | ||
import com.app.toaster.popup.service.PopupService; | ||
import com.app.toaster.common.dto.ApiResponse; | ||
import com.app.toaster.config.UserId; | ||
import com.app.toaster.exception.Success; | ||
|
||
import jakarta.validation.Valid; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/v2/popup") | ||
@Validated | ||
public class PopupController { | ||
private final PopupService popupService; | ||
|
||
|
||
@PatchMapping | ||
public ApiResponse<InvisibleResponseDto> updateInvisible(@UserId Long userId, @RequestBody @Valid PopUpRequestDto popUpRequestDto){ | ||
return ApiResponse.success(Success.UPDATE_POPUP_SUCCESS, popupService.updatePopupInvisible(userId,popUpRequestDto)); | ||
} | ||
|
||
@GetMapping | ||
public ApiResponse<PopupResponseDto> getPopUpInformation(@UserId Long userId){ | ||
return ApiResponse.success(Success.GET_POPUP_SUCCESS, popupService.findPopupInformation(userId)); | ||
} | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
linkmind/src/main/java/com/app/toaster/popup/controller/request/PopUpRequestDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.app.toaster.popup.controller.request; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
|
||
public record PopUpRequestDto( | ||
Long popupId, | ||
@NotNull | ||
Long hideDate | ||
) { | ||
} |
Oops, something went wrong.