Skip to content

Commit

Permalink
Merge pull request #77 from 1223v/ceonameapi
Browse files Browse the repository at this point in the history
Feat: 사용자 이름 조회 API 추가
  • Loading branch information
1223v authored Mar 23, 2024
2 parents 9099b45 + 245f487 commit b4254e8
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 0 deletions.
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

0 comments on commit b4254e8

Please sign in to comment.