This repository has been archived by the owner on Aug 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from f-lab-edu/feature/3
#10 Feature/3
- Loading branch information
Showing
12 changed files
with
570 additions
and
49 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
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,77 @@ | ||
package com.delfood.controller; | ||
|
||
import com.delfood.dto.ShopDTO; | ||
import com.delfood.service.ShopService; | ||
import javax.servlet.http.HttpSession; | ||
import lombok.Getter; | ||
import lombok.NonNull; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.log4j.Log4j2; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/owners/shops/") | ||
@Log4j2 | ||
public class ShopController { | ||
@Autowired | ||
private ShopService shopService; | ||
|
||
/** | ||
* 입점 메서드. | ||
* | ||
* @author jun | ||
* @param session 로그인한 사장님 정보를 불러오기 위한 세션 | ||
* @param shopInfo 입력받은 매장 정보 | ||
* @return | ||
*/ | ||
@PostMapping | ||
public ResponseEntity<OpenShopResponse> openShop(HttpSession session, | ||
@RequestBody ShopDTO shopInfo) { | ||
String ownerId = (String) session.getAttribute("LOGIN_OWNER_ID"); | ||
|
||
// 로그인 하지 않았을 시 401코드를 반환한다. | ||
if (ownerId == null) { | ||
return new ResponseEntity<ShopController.OpenShopResponse>(OpenShopResponse.NO_LOGIN, | ||
HttpStatus.UNAUTHORIZED); | ||
} | ||
|
||
shopInfo.setOwnerId(ownerId); | ||
|
||
// 입력한 데이터 중 필수 데이터가 null일 경우 400 에러코드를 반환한다. | ||
if (ShopDTO.hasNullDataBeforeCreate(shopInfo)) { | ||
return new ResponseEntity<ShopController.OpenShopResponse>(OpenShopResponse.NULL_ARGUMENTS, | ||
HttpStatus.BAD_REQUEST); | ||
} | ||
|
||
shopService.newShop(shopInfo); | ||
|
||
|
||
return new ResponseEntity<ShopController.OpenShopResponse>(OpenShopResponse.SUCCESS, | ||
HttpStatus.CREATED); | ||
} | ||
|
||
|
||
|
||
// Response 객체 | ||
@Getter | ||
@RequiredArgsConstructor | ||
private static class OpenShopResponse { | ||
enum Result { | ||
SUCCESS, NO_LOGIN, NULL_ARGUMENTS | ||
} | ||
|
||
@NonNull | ||
Result result; | ||
|
||
private static OpenShopResponse SUCCESS = new OpenShopResponse(Result.SUCCESS); | ||
private static OpenShopResponse NO_LOGIN = new OpenShopResponse(Result.NO_LOGIN); | ||
private static OpenShopResponse NULL_ARGUMENTS = new OpenShopResponse(Result.NULL_ARGUMENTS); | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.delfood.dto; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
|
||
@Getter | ||
@Setter | ||
@ToString | ||
public class MenuCategoryDTO { | ||
// 주력 메뉴 | ||
// 한식, 분식, 카페, 일식, | ||
// 치킨, 피자, 아시안, 양식, | ||
// 중국집, 족발보쌈, 야식, 찜탕, | ||
// 도시락, 패스트푸드, 프렌차이즈 | ||
|
||
// KOREAN, SCHOOL_FOOD, CAFE, JAPANESE, | ||
// CHICKEN, PIZZA, ASIAN, WESTERN, | ||
// CHINESE, BOSSAM, MIDNIGHT_MEAL, SOUP, | ||
// LUNCHBOX, FAST_FOOD, FRANCHISE | ||
private Long id; | ||
private String name; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
package com.delfood.dto; | ||
|
||
import java.time.LocalDateTime; | ||
import lombok.Getter; | ||
import lombok.NonNull; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
|
||
@Getter | ||
@Setter | ||
@ToString | ||
public class ShopDTO { | ||
|
||
// 배달 타입. 자체배달, 라이더 매칭 배달 | ||
enum DeliveeryType { | ||
SELF_DELIVERY, COMPANY_DELIVERY | ||
} | ||
|
||
|
||
|
||
enum Status { | ||
DEFAULT, DELETED | ||
} | ||
|
||
// 즉시 결제, 만나서 결제 | ||
enum OrderType { | ||
THIS_PAYMENT, MEET_PAYMENT | ||
} | ||
|
||
enum WorkCondition { | ||
OPEN, CLOSE | ||
} | ||
|
||
|
||
// 아아디 | ||
@NonNull | ||
private Long id; | ||
|
||
// 가게 이름 | ||
@NonNull | ||
private String name; | ||
|
||
// 배달형태 | ||
@NonNull | ||
private DeliveeryType deliveryType; | ||
|
||
// 주력메뉴 치킨, 피자, 분식 등 | ||
@NonNull | ||
private Long signatureMenuId; | ||
|
||
// 가게 전화번호 | ||
private String tel; | ||
|
||
// 우편 번호 | ||
private String zipcode; | ||
|
||
// 주소 | ||
private String address; | ||
|
||
// 상세주소 | ||
private String addressDetail; | ||
|
||
// 사업자번호 | ||
@NonNull | ||
private String bizNumber; | ||
|
||
// 가게 소개 | ||
@NonNull | ||
private String info; | ||
|
||
// 최소 주문금액 | ||
@NonNull | ||
private Long minOrderPrice; | ||
|
||
// 안내 및 혜택 | ||
private String notice; | ||
|
||
// 운영 시간 | ||
private String operatingTime; | ||
|
||
// 배달지역 | ||
private String deliveryLocation; | ||
|
||
// 사장 아이디 | ||
private String ownerId; | ||
|
||
// 가게 등록일 | ||
private LocalDateTime createdAt; | ||
|
||
// 최종 수정일 | ||
private LocalDateTime updatedAt; | ||
|
||
// 상태 삭제되었을시 DELETE 평소에는 DEFAULT | ||
private Status status; | ||
|
||
// 주문 타입 바로결제, 전화결제 등 결정 | ||
@NonNull | ||
private OrderType orderType; | ||
|
||
// 원산지 정보 원산지 표기정보를 작성 | ||
private String originInfo; | ||
|
||
// 영업 상태 OPEN, CLOSED 등 | ||
private WorkCondition workCondition; | ||
|
||
/** | ||
* 매장 입점 전 필수 입력 데이터가 누락된 것이 없는지 확인. | ||
* @author jun | ||
* @param shopInfo 매장 데이터 | ||
* @return 누락된 데이터가 있다면 true | ||
*/ | ||
public static boolean hasNullDataBeforeCreate(ShopDTO shopInfo) { | ||
if (shopInfo.getName() == null | ||
|| shopInfo.getDeliveryType() == null | ||
|| shopInfo.getSignatureMenuId() == null | ||
|| shopInfo.getBizNumber() == null | ||
|| shopInfo.getInfo() == null | ||
|| shopInfo.getMinOrderPrice() == null | ||
|| shopInfo.getOrderType() == null) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
} |
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
Oops, something went wrong.