Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3월 25일 배포 #78

Merged
merged 2 commits into from
Mar 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
}

/**
* 사용자 정보 조회
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@
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;

public interface CeoService {

CeoAuthRes getCeoAuthByCustomUserDetails(CustomUserDetails userDetails);

SimpleCeoInfoRes getSimpleCeoInfoById(Long id);

CeoInfoRes getCeoInfoById(Long id);

CeoLogoutRes removeRefreshTokenInDB(CustomUserDetails userDetails, HttpServletResponse response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<SaleManagementDto> saleManagementList = getSaleMoneyManagement(ceoInfo.getStore().getId(),
convertToDateTime(saleManagementReq.getMonday()));

Expand All @@ -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<Long> saleManagementTotal = sumTotalAmountByStoreIdForWeek(ceoInfo.getStore().getId(),
getStartOfWeek(convertToDateTime(saleManagementTotalMoneyReq.getMonday())),
getStartOfWeek(convertToDateTime(saleManagementTotalMoneyReq.getMonday())).plusDays(7));
Expand All @@ -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<Long> saleManagementTotal = sumTotalAmountByStoreIdForMonth(ceoInfo.getStore().getId(),
getStartOfMonth(convertToDateTime(saleManagementTotalMoneyReq.getMonday())),
getEndOfMonth(convertToDateTime(saleManagementTotalMoneyReq.getMonday())));
Expand All @@ -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));
Expand Down
Loading