diff --git a/src/main/java/com/readyvery/readyverydemo/src/ceo/CeoController.java b/src/main/java/com/readyvery/readyverydemo/src/ceo/CeoController.java index 9c11ed2..434e317 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/ceo/CeoController.java +++ b/src/main/java/com/readyvery/readyverydemo/src/ceo/CeoController.java @@ -25,6 +25,7 @@ import com.readyvery.readyverydemo.src.ceo.dto.CeoLogoutRes; import com.readyvery.readyverydemo.src.ceo.dto.CeoMetaInfoRes; import com.readyvery.readyverydemo.src.ceo.dto.CeoRemoveRes; +import com.readyvery.readyverydemo.src.ceo.dto.SimpleCeoInfoRes; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -58,6 +59,18 @@ public CeoAuthRes userAuth(@AuthenticationPrincipal CustomUserDetails userDetail return ceoServiceImpl.getCeoAuthByCustomUserDetails(userDetails); } + /** + * 사용자 이름 정보 조회 + */ + @Operation(summary = "사용자 이름 조회", description = "사용자의 간단한 정보를 조회합니다.", tags = {"유저 정보"}) + @ApiResponses({ + @ApiResponse(responseCode = "200", description = "OK") + }) + @GetMapping("/user/name") + public SimpleCeoInfoRes simpleUserInfo(@AuthenticationPrincipal CustomUserDetails userDetails) { + return ceoServiceImpl.getSimpleCeoInfoById(userDetails.getId()); + } + /** * 사용자 정보 조회 */ diff --git a/src/main/java/com/readyvery/readyverydemo/src/ceo/CeoService.java b/src/main/java/com/readyvery/readyverydemo/src/ceo/CeoService.java index a8d1c37..47227d0 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/ceo/CeoService.java +++ b/src/main/java/com/readyvery/readyverydemo/src/ceo/CeoService.java @@ -16,6 +16,7 @@ import com.readyvery.readyverydemo.src.ceo.dto.CeoLogoutRes; import com.readyvery.readyverydemo.src.ceo.dto.CeoMetaInfoRes; import com.readyvery.readyverydemo.src.ceo.dto.CeoRemoveRes; +import com.readyvery.readyverydemo.src.ceo.dto.SimpleCeoInfoRes; import jakarta.servlet.http.HttpServletResponse; @@ -23,6 +24,8 @@ public interface CeoService { CeoAuthRes getCeoAuthByCustomUserDetails(CustomUserDetails userDetails); + SimpleCeoInfoRes getSimpleCeoInfoById(Long id); + CeoInfoRes getCeoInfoById(Long id); CeoLogoutRes removeRefreshTokenInDB(CustomUserDetails userDetails, HttpServletResponse response); diff --git a/src/main/java/com/readyvery/readyverydemo/src/ceo/CeoServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/ceo/CeoServiceImpl.java index 717cf1d..2db558e 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/ceo/CeoServiceImpl.java +++ b/src/main/java/com/readyvery/readyverydemo/src/ceo/CeoServiceImpl.java @@ -35,6 +35,7 @@ import com.readyvery.readyverydemo.src.ceo.dto.CeoMapper; import com.readyvery.readyverydemo.src.ceo.dto.CeoMetaInfoRes; import com.readyvery.readyverydemo.src.ceo.dto.CeoRemoveRes; +import com.readyvery.readyverydemo.src.ceo.dto.SimpleCeoInfoRes; import com.readyvery.readyverydemo.src.smsauthentication.VerificationService; import jakarta.servlet.http.Cookie; @@ -62,6 +63,12 @@ public CeoAuthRes getCeoAuthByCustomUserDetails(CustomUserDetails userDetails) { } + @Override + public SimpleCeoInfoRes getSimpleCeoInfoById(Long id) { + CeoInfo ceoInfo = ceoServiceFacade.getCeoInfo(id); + return ceoMapper.simpleCeoInfoToSimpleCeoInfoRes(ceoInfo.getNickName()); + } + @Override public CeoInfoRes getCeoInfoById(Long id) { CeoInfo ceoInfo = ceoServiceFacade.getCeoInfo(id); diff --git a/src/main/java/com/readyvery/readyverydemo/src/ceo/dto/CeoMapper.java b/src/main/java/com/readyvery/readyverydemo/src/ceo/dto/CeoMapper.java index 30316d2..7939641 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/ceo/dto/CeoMapper.java +++ b/src/main/java/com/readyvery/readyverydemo/src/ceo/dto/CeoMapper.java @@ -9,6 +9,12 @@ @Component public class CeoMapper { + public SimpleCeoInfoRes simpleCeoInfoToSimpleCeoInfoRes(String name) { + return SimpleCeoInfoRes.builder() + .name(name) + .build(); + } + public CeoAuthRes ceoInfoToCeoAuthRes(CustomUserDetails userDetails) { return CeoAuthRes.builder() .id(userDetails.getId()) diff --git a/src/main/java/com/readyvery/readyverydemo/src/ceo/dto/SimpleCeoInfoRes.java b/src/main/java/com/readyvery/readyverydemo/src/ceo/dto/SimpleCeoInfoRes.java new file mode 100644 index 0000000..027e9e5 --- /dev/null +++ b/src/main/java/com/readyvery/readyverydemo/src/ceo/dto/SimpleCeoInfoRes.java @@ -0,0 +1,10 @@ +package com.readyvery.readyverydemo.src.ceo.dto; + +import lombok.Builder; +import lombok.Getter; + +@Builder +@Getter +public class SimpleCeoInfoRes { + private String name; +} diff --git a/src/main/java/com/readyvery/readyverydemo/src/sale/SaleServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/sale/SaleServiceImpl.java index f0d3647..dbf3034 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/sale/SaleServiceImpl.java +++ b/src/main/java/com/readyvery/readyverydemo/src/sale/SaleServiceImpl.java @@ -50,6 +50,9 @@ public TotalSaleRes getTotalSaleMoney(Long id) { public SaleManagementRes getSaleManagementMoney(Long id, SaleManagementReq saleManagementReq) { CeoInfo ceoInfo = ceoServiceFacade.getCeoInfo(id); + if (ceoInfo.getStore() == null) { + throw new BusinessLogicException(ExceptionCode.STORE_NOT_FOUND); + } List saleManagementList = getSaleMoneyManagement(ceoInfo.getStore().getId(), convertToDateTime(saleManagementReq.getMonday())); @@ -65,6 +68,9 @@ public SaleManagementRes getSaleManagementMoney(Long id, SaleManagementReq saleM public SaleManagementTotalMoneyRes getWeekSaleManagementMoney(Long id, SaleManagementTotalMoneyReq saleManagementTotalMoneyReq) { CeoInfo ceoInfo = ceoServiceFacade.getCeoInfo(id); + if (ceoInfo.getStore() == null) { + throw new BusinessLogicException(ExceptionCode.STORE_NOT_FOUND); + } Optional saleManagementTotal = sumTotalAmountByStoreIdForWeek(ceoInfo.getStore().getId(), getStartOfWeek(convertToDateTime(saleManagementTotalMoneyReq.getMonday())), getStartOfWeek(convertToDateTime(saleManagementTotalMoneyReq.getMonday())).plusDays(7)); @@ -80,6 +86,9 @@ public SaleManagementTotalMoneyRes getWeekSaleManagementMoney(Long id, public SaleManagementTotalMoneyRes getMonthlySalesAmount(Long id, SaleManagementTotalMoneyReq saleManagementTotalMoneyReq) { CeoInfo ceoInfo = ceoServiceFacade.getCeoInfo(id); + if (ceoInfo.getStore() == null) { + throw new BusinessLogicException(ExceptionCode.STORE_NOT_FOUND); + } Optional saleManagementTotal = sumTotalAmountByStoreIdForMonth(ceoInfo.getStore().getId(), getStartOfMonth(convertToDateTime(saleManagementTotalMoneyReq.getMonday())), getEndOfMonth(convertToDateTime(saleManagementTotalMoneyReq.getMonday()))); @@ -94,7 +103,11 @@ public SaleManagementTotalMoneyRes getMonthlySalesAmount(Long id, @Override public SaleManagementTotalOrderRes getSaleManagementOrder(Long id, SaleManagementTotalOrderReq saleManagementTotalOrderReq) { + CeoInfo ceoInfo = ceoServiceFacade.getCeoInfo(id); + if (ceoInfo.getStore() == null) { + throw new BusinessLogicException(ExceptionCode.STORE_NOT_FOUND); + } Long saleManagementWeekTotal = countOrdersByStoreIdForWeek(ceoInfo.getStore().getId(), getStartOfWeek(convertToDateTime(saleManagementTotalOrderReq.getMonday())), getStartOfWeek(convertToDateTime(saleManagementTotalOrderReq.getMonday())).plusDays(7));