Skip to content

Commit

Permalink
Merge branch 'develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
LEEJaeHyeok97 authored Nov 20, 2024
2 parents 7ae17ee + 6288a9f commit 9ca3a35
Show file tree
Hide file tree
Showing 23 changed files with 341 additions and 81 deletions.
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
package com.jangburich.domain.menu.domain.controller;
package com.jangburich.domain.menu.controller;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.DeleteMapping;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.jangburich.domain.menu.domain.MenuCreateRequestDTO;
import com.jangburich.domain.menu.domain.MenuGetResponseDTO;
import com.jangburich.domain.menu.domain.MenuResponse;
import com.jangburich.domain.menu.domain.MenuUpdateRequestDTO;
import com.jangburich.domain.menu.domain.service.MenuService;
import com.jangburich.domain.menu.service.MenuService;
import com.jangburich.global.payload.Message;
import com.jangburich.global.payload.ResponseCustom;
import com.jangburich.utils.parser.AuthenticationParser;
Expand Down Expand Up @@ -56,9 +58,9 @@ public ResponseCustom<Message> deleteMenu(
}

@GetMapping("")
public ResponseCustom<List<MenuGetResponseDTO>> getMenu(
Authentication authentication) {
List<MenuGetResponseDTO> menu = menuService.getMenu(AuthenticationParser.parseUserId(authentication));
public ResponseCustom<Page<MenuResponse>> getMenu(
Authentication authentication, Pageable pageable) {
Page<MenuResponse> menu = menuService.getMenu(AuthenticationParser.parseUserId(authentication), pageable);
return ResponseCustom.OK(menu);
}
}
22 changes: 22 additions & 0 deletions src/main/java/com/jangburich/domain/menu/domain/MenuResponse.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.jangburich.domain.menu.domain;

import com.querydsl.core.annotations.QueryProjection;

public record MenuResponse(
Long id,
Long storeId,
String name,
String description,
String imageUrl,
Integer price
) {
@QueryProjection
public MenuResponse(Long id, Long storeId, String name, String description, String imageUrl, Integer price) {
this.id = id;
this.storeId = storeId;
this.name = name;
this.description = description;
this.imageUrl = imageUrl;
this.price = price;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.jangburich.domain.menu.repository;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;

import com.jangburich.domain.menu.domain.Menu;
import com.jangburich.domain.menu.domain.MenuResponse;
import com.jangburich.domain.store.domain.Store;

public interface MenuRepository extends JpaRepository<Menu, Long> {
Page<MenuResponse> findAllByStore(Store store, Pageable pageable);
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package com.jangburich.domain.menu.domain.service;

import java.util.List;
package com.jangburich.domain.menu.service;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jangburich.domain.menu.domain.Menu;
import com.jangburich.domain.menu.domain.MenuCreateRequestDTO;
import com.jangburich.domain.menu.domain.MenuGetResponseDTO;
import com.jangburich.domain.menu.domain.MenuResponse;
import com.jangburich.domain.menu.domain.MenuUpdateRequestDTO;
import com.jangburich.domain.menu.domain.repository.MenuRepository;
import com.jangburich.domain.menu.repository.MenuRepository;
import com.jangburich.domain.owner.domain.Owner;
import com.jangburich.domain.owner.domain.repository.OwnerRepository;
import com.jangburich.domain.store.domain.Store;
import com.jangburich.domain.store.domain.repository.StoreRepository;
import com.jangburich.domain.store.repository.StoreRepository;
import com.jangburich.domain.user.domain.User;
import com.jangburich.domain.user.repository.UserRepository;
import com.jangburich.global.error.DefaultNullPointerException;
Expand Down Expand Up @@ -72,7 +72,7 @@ public void deleteMenu(String customOAuthUser, Long id) {
menuRepository.delete(menu);
}

public List<MenuGetResponseDTO> getMenu(String customOAuthUser) {
public Page<MenuResponse> getMenu(String customOAuthUser, Pageable pageable) {
User user = userRepository.findByProviderId(customOAuthUser)
.orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION));

Expand All @@ -82,10 +82,6 @@ public List<MenuGetResponseDTO> getMenu(String customOAuthUser) {
Store store = storeRepository.findByOwner(owner)
.orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_STORE_ID));

return menuRepository.findAllByStore(store)
.stream()
.map(menu -> new MenuGetResponseDTO(menu.getId(), menu.getName(), menu.getDescription(), menu.getImageUrl(),
menu.getPrice(), menu.getStore().getId()))
.toList();
return menuRepository.findAllByStore(store,pageable);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.jangburich.domain.common.Status;
import com.jangburich.domain.order.domain.Cart;
import com.jangburich.domain.order.domain.Orders;
import com.jangburich.domain.store.domain.Store;
import com.jangburich.domain.user.domain.User;
import java.util.List;
Expand All @@ -19,4 +20,6 @@ public interface CartRepository extends JpaRepository<Cart, Long> {
List<Cart> findAllByUserAndStatus(User user, Status status);

List<Cart> findAllByUserAndStoreAndStatus(User user, Store store, Status status);

List<Cart> findAllByOrders(Orders orders);
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,33 @@
package com.jangburich.domain.order.domain.repository;

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

import com.jangburich.domain.order.domain.OrderStatus;
import com.jangburich.domain.order.domain.Orders;
import com.querydsl.jpa.impl.JPAQueryFactory;
import lombok.RequiredArgsConstructor;

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;

@Repository
public interface OrdersRepository extends JpaRepository<Orders, Long>, OrdersQueryDslRepository {
@Query(value = "SELECT * FROM orders WHERE store_id = :storeId AND updated_at < :updatedAt AND order_status = :orderStatus",
nativeQuery = true)
List<Orders> findOrdersByStoreAndDateAndStatusNative(
@Param("storeId") Long storeId,
@Param("updatedAt") LocalDateTime updatedAt,
@Param("orderStatus") String orderStatus);

@Query("SELECT o FROM Orders o " +
"WHERE o.store.id = :storeId " +
"AND o.updatedAt >= :startOfDay " +
"AND o.updatedAt < :endOfDay " +
"AND o.orderStatus = :orderStatus")
List<Orders> findOrdersByStoreAndTodayDateAndStatus(
@Param("storeId") Long storeId,
@Param("startOfDay") LocalDateTime startOfDay,
@Param("endOfDay") LocalDateTime endOfDay,
@Param("orderStatus") OrderStatus orderStatus);
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import com.jangburich.domain.payment.exception.TeamNotFoundException;
import com.jangburich.domain.store.domain.Store;
import com.jangburich.domain.store.domain.StoreTeam;
import com.jangburich.domain.store.domain.repository.StoreRepository;
import com.jangburich.domain.store.domain.repository.StoreTeamRepository;
import com.jangburich.domain.store.repository.StoreRepository;
import com.jangburich.domain.store.repository.StoreTeamRepository;
import com.jangburich.domain.store.exception.StoreNotFoundException;
import com.jangburich.domain.team.domain.Team;
import com.jangburich.domain.team.domain.repository.TeamRepository;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package com.jangburich.domain.store.domain.controller;
package com.jangburich.domain.store.controller;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
Expand All @@ -22,11 +24,14 @@
import com.jangburich.domain.store.domain.StoreGetResponseDTO;
import com.jangburich.domain.store.domain.StoreTeamResponseDTO;
import com.jangburich.domain.store.domain.StoreUpdateRequestDTO;
import com.jangburich.domain.store.domain.dto.condition.StoreSearchCondition;
import com.jangburich.domain.store.domain.dto.condition.StoreSearchConditionWithType;
import com.jangburich.domain.store.domain.dto.response.PaymentGroupDetailResponse;
import com.jangburich.domain.store.domain.dto.response.SearchStoresResponse;
import com.jangburich.domain.store.domain.service.StoreService;
import com.jangburich.domain.store.dto.condition.StoreSearchCondition;
import com.jangburich.domain.store.dto.condition.StoreSearchConditionWithType;
import com.jangburich.domain.store.dto.response.OrdersDetailResponse;
import com.jangburich.domain.store.dto.response.OrdersGetResponse;
import com.jangburich.domain.store.dto.response.OrdersTodayResponse;
import com.jangburich.domain.store.dto.response.PaymentGroupDetailResponse;
import com.jangburich.domain.store.dto.response.SearchStoresResponse;
import com.jangburich.domain.store.service.StoreService;
import com.jangburich.global.payload.Message;
import com.jangburich.global.payload.ResponseCustom;
import com.jangburich.utils.parser.AuthenticationParser;
Expand Down Expand Up @@ -67,57 +72,71 @@ public ResponseCustom<Page<SearchStoresResponse>> searchStores(

@Operation(summary = "๊ฐ€๊ฒŒ ๋“ฑ๋ก", description = "์‹ ๊ทœ ํŒŒํŠธ๋„ˆ ๊ฐ€๊ฒŒ๋ฅผ ๋“ฑ๋กํ•ฉ๋‹ˆ๋‹ค.")
@PostMapping(value = "/create", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseCustom<Message> createStore(
Authentication authentication,
@Parameter(name = "image", description = "์—…๋กœ๋“œ ์‚ฌ์ง„ ๋ฐ์ดํ„ฐ")
@RequestPart(value = "image") MultipartFile image,
public ResponseCustom<Message> createStore(Authentication authentication,
@Parameter(name = "image", description = "์—…๋กœ๋“œ ์‚ฌ์ง„ ๋ฐ์ดํ„ฐ") @RequestPart(value = "image") MultipartFile image,
@RequestPart(value = "store") StoreCreateRequestDTO storeCreateRequestDTO) {

storeService.createStore(AuthenticationParser.parseUserId(authentication), storeCreateRequestDTO, image);
return ResponseCustom.OK(Message.builder().message("success").build());
}


@Operation(summary = "๊ฐ€๊ฒŒ ์ •๋ณด ์ˆ˜์ •", description = "๊ฐ€๊ฒŒ ์ •๋ณด๋ฅผ ์ˆ˜์ •ํ•ฉ๋‹ˆ๋‹ค.")
@PatchMapping("/update")
public ResponseCustom<Message> updateStore(
Authentication authentication,
public ResponseCustom<Message> updateStore(Authentication authentication,
@RequestBody StoreUpdateRequestDTO storeUpdateRequestDTO) {
storeService.updateStore(AuthenticationParser.parseUserId(authentication), storeUpdateRequestDTO);
return ResponseCustom.OK(Message.builder().message("success").build());
}

@Operation(summary = "๊ฐ€๊ฒŒ ์ •๋ณด ์กฐํšŒ", description = "๊ฐ€๊ฒŒ ์ƒ์„ธ ์ •๋ณด๋ฅผ ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค.")
@GetMapping("")
public ResponseCustom<StoreGetResponseDTO> getStoreInfo(
Authentication authentication) {
public ResponseCustom<StoreGetResponseDTO> getStoreInfo(Authentication authentication) {
return ResponseCustom.OK(storeService.getStoreInfo(AuthenticationParser.parseUserId(authentication)));
}

@Operation(summary = "๊ฒฐ์ œ ๊ทธ๋ฃน ์กฐํšŒ", description = "์žฅ๋ถ€ ๊ฒฐ์ œ ๊ทธ๋ฃน์„ ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค.")
@GetMapping("/payment_group")
public ResponseCustom<Page<StoreTeamResponseDTO>> getPaymentGroup(
Authentication authentication,
public ResponseCustom<Page<StoreTeamResponseDTO>> getPaymentGroup(Authentication authentication,
Pageable pageable) {
return ResponseCustom.OK(
storeService.getPaymentGroup(AuthenticationParser.parseUserId(authentication), pageable));
}

@Operation(summary = "๊ฒฐ์ œ ๊ทธ๋ฃน ์ƒ์„ธ ์กฐํšŒ", description = "์žฅ๋ถ€ ๊ฒฐ์ œ ๊ทธ๋ฃน์„ ์ƒ์„ธ ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค.")
@GetMapping("/payment_group/{teamId}")
public ResponseCustom<PaymentGroupDetailResponse> getPaymentGroupDetail(
Authentication authentication, @PathVariable Long teamId,
Pageable pageable) {
public ResponseCustom<PaymentGroupDetailResponse> getPaymentGroupDetail(Authentication authentication,
@PathVariable Long teamId, Pageable pageable) {
return ResponseCustom.OK(
storeService.getPaymentGroupDetail(AuthenticationParser.parseUserId(authentication), teamId, pageable));
}

@Operation(summary = "๊ฒฐ์ œ ๋‚ด์—ญ ์กฐํšŒ", description = "๊ฐ€๊ฒŒ์—์„œ ์ผ์–ด๋‚œ ๊ฒฐ์ œ ๋‚ด์—ญ์„ ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค.")
@GetMapping("/payment_history")
public ResponseCustom<?> getPaymentHistory(
Authentication authentication,
Pageable pageable) {
public ResponseCustom<?> getPaymentHistory(Authentication authentication, Pageable pageable) {
return ResponseCustom.OK(
storeService.getPaymentHistory(AuthenticationParser.parseUserId(authentication), pageable));
}

@Operation(summary = "์ง€๋‚œ ์ฃผ๋ฌธ ์กฐํšŒ", description = "๊ฐ€๊ฒŒ์— ์žˆ๋Š” ์ง€๋‚œ ์ฃผ๋ฌธ์„ ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค")
@GetMapping("/orders/last")
public ResponseCustom<List<OrdersGetResponse>> getLastOrders(Authentication authentication) {
List<OrdersGetResponse> ordersLast = storeService.getOrdersLast(
AuthenticationParser.parseUserId(authentication));
return ResponseCustom.OK(ordersLast);
}

@Operation(summary = "์˜ค๋Š˜ ์ฃผ๋ฌธ ์กฐํšŒ", description = "๊ฐ€๊ฒŒ์— ์žˆ๋Š” ์˜ค๋Š˜ ์ฃผ๋ฌธ์„ ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค")
@GetMapping("/orders/today")
public ResponseCustom<OrdersTodayResponse> getTodayOrders(Authentication authentication) {
return ResponseCustom.OK(storeService.getTodayOrders(
AuthenticationParser.parseUserId(authentication)));
}

@Operation(summary = "์ฃผ๋ฌธ ์ƒ์„ธ ์กฐํšŒ", description = "๊ฐ€๊ฒŒ์— ์žˆ๋Š” ์ฃผ๋ฌธ์„ ์ƒ์„ธ ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค")
@GetMapping("/orders/{ordersId}")
public ResponseCustom<OrdersDetailResponse> getOrders(Authentication authentication, @RequestParam Long orderId) {
return ResponseCustom.OK(
storeService.getOrderDetails(AuthenticationParser.parseUserId(authentication), orderId));
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.jangburich.domain.store.domain.dto.condition;
package com.jangburich.domain.store.dto.condition;

public record StoreSearchCondition(
Double lat,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.jangburich.domain.store.domain.dto.condition;
package com.jangburich.domain.store.dto.condition;

import com.querydsl.core.annotations.QueryProjection;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.jangburich.domain.store.dto.response;

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

import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@RequiredArgsConstructor
public class OrdersDetailResponse {
private Long id;
private String teamName;
private String teamUserName;
private List<Menu> menus;
private LocalDateTime dateTime;
private Integer amount;
private Integer totalPrice;
private Integer discountPrice;

@Getter
@Setter
public static class Menu {
private String menuName;
private Integer amount;
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.jangburich.domain.store.dto.response;

import java.time.LocalDateTime;

import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@RequiredArgsConstructor
public class OrdersGetResponse {
private Long id;
private String menuNames;
private LocalDateTime date;
private Integer count;
private Integer price;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.jangburich.domain.store.dto.response;

import java.util.List;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class OrdersTodayResponse {
private Integer totalPrice;
private List<OrdersGetResponse> ordersGetResponses;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.jangburich.domain.store.domain.dto.response;
package com.jangburich.domain.store.dto.response;

import org.springframework.data.domain.Page;

Expand Down
Loading

0 comments on commit 9ca3a35

Please sign in to comment.