Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- GRANT VIEW
- 집합_SET
- 대덕인재개발원
- exception
- EnhancedFor
- 컬렉션 타입
- 오라클
- 예외처리
- NestedFor
- 사용자예외클래스생성
- 메소드오버로딩
- 한국건설관리시스템
- abstract
- 컬렉션프레임워크
- 참조형변수
- 생성자오버로드
- 자동차수리시스템
- oracle
- 정수형타입
- cursor문
- 다형성
- 제네릭
- 객체 비교
- 환경설정
- 추상메서드
- 인터페이스
- 예외미루기
- Java
- 어윈 사용법
- 자바
Archives
- Today
- Total
거니의 velog
8. 관리자 페이지 (5) : 메뉴 관리 본문
public int menuCreate() {
String menuCode = ""; // 메뉴코드
String menuNm = ""; // 메뉴명
long menuPrice = 0; // 메뉴가격
int remainQty = 0; // 잔여수량
String stoCode = ""; // 업체코드
String createMenu = ""; // 메뉴 생성
System.out.println(" ───────────────────────────────────────────────────");
System.out.println("어느 가게에서 메뉴를 등록하십니까?");
System.out.println("1. 업체코드로 등록");
System.out.println("2. 업체명으로 업체코드 검색");
System.out.println(" ───────────────────────────────────────────────────");
System.out.print(" >> ");
int storeChoi = ScanUtil.nextIntegerLine();
if(storeChoi == 1) {
while(true) {
System.out.println(" ───────────────────────────────────────────────────");
System.out.println(" 업체코드 입력");
System.out.println(" ───────────────────────────────────────────────────");
System.out.print(" >> ");
stoCode = ScanUtil.nextLine();
if(ValidationUtil.validationCode(stoCode)) {
menuCode = stoCode.substring(2, 4); // 카테고리코드
break;
}
}
}else if(storeChoi == 2) {
System.out.println(" ───────────────────────────────────────────────────");
System.out.println(" 업체명을 입력해 주세요.");
System.out.println(" ───────────────────────────────────────────────────");
System.out.print(" >> ");
String storeName = ScanUtil.nextLine();
List<Object> searchStoreName = new ArrayList<>();
searchStoreName.add(storeName);
List<Map<String, Object>> storeInfo = adminReadDAO.storeSearchFromStoName(searchStoreName);
if(NullCheckUtil.isEmpty(storeInfo)) {
System.out.println(" ───────────────────────────────────────────────────");
System.out.println("등록된 업체가 없습니다!");
System.out.println(" ───────────────────────────────────────────────────");
}else {
List<Map<String, Object>> storeALL = adminReadDAO.storeALL();
int maxStoCodeLen = gapUtil.gapFullCnt(storeALL, "STOCODE");
int maxNmLen = gapUtil.gapFullCnt(storeALL, "STONM");
int maxAddLen = gapUtil.gapFullCnt(storeALL, "STOADD");
System.out.println(" ──────────────────────────────────────────────────────────────────────────");
System.out.println("업체코드 업체명 업체주소");
System.out.println(" ──────────────────────────────────────────────────────────────────────────");
for(Map<String, Object> item : storeInfo) {
int storeStoCodeLen = gapUtil.gapCnt("STOCODE");
int storeNmLen = gapUtil.gapCnt("STONM");
int storeAddLen = gapUtil.gapCnt("STOADD");
StringBuilder memSTOCODE = gapUtil.gapFullSpace(String.valueOf(item.get("STOCODE")), maxStoCodeLen, storeStoCodeLen);
StringBuilder memNM = gapUtil.gapFullSpace(String.valueOf(item.get("STONM")), maxNmLen, storeNmLen);
StringBuilder memADD = gapUtil.gapFullSpace(String.valueOf(item.get("STOADD")), maxAddLen, storeAddLen);
System.out.printf("%-" + maxStoCodeLen + "s%-" + maxNmLen + "s%-" + maxAddLen + "s\n", memSTOCODE, memNM, memADD);
}
}
EnterUtil.enterNext(2);
return View.ADMIN_MENU_MANAGEMENT;
}
List<Object> searchStoNm = new ArrayList<>();
searchStoNm.add(stoCode);
Map<String, Object> stoName = adminCreateDAO.searchStoreName(searchStoNm);
String stoNameStr = stoName.get("STONM").toString();
while(true) {
System.out.println(" ───────────────────────────────────────────────────");
System.out.println("[ " + stoNameStr + " ] 가게에 메뉴를 등록합니다.");
System.out.println();
System.out.println("무슨 종류의 메뉴를 등록하시겠습니까?");
System.out.println();
System.out.println("1. 대표메뉴");
System.out.println("2. 싱글메뉴");
System.out.println("3. 세트메뉴");
System.out.println("4. 사이드메뉴");
System.out.println("5. 음료메뉴");
System.out.println(" ───────────────────────────────────────────────────");
System.out.print(" >> ");
int GuSelect = ScanUtil.nextIntegerLine();
if(GuSelect == 1) {
menuCode += "REP";
break;
}else if(GuSelect == 2) {
menuCode += "SIG";
break;
}else if(GuSelect == 3) {
menuCode += "SET";
break;
}else if(GuSelect == 4) {
menuCode += "SID";
break;
}else if(GuSelect == 5) {
menuCode += "BEV";
break;
}else {
System.out.println("올바로 입력해 주세요.");
}
}
menuCode += "%";
List<Object> cdStr = new ArrayList<>();
cdStr.add(menuCode);
List<Map<String, Object>> searchMenuCode = adminCreateDAO.searchMenuCode(cdStr);
if(NullCheckUtil.isEmpty(searchMenuCode)) {
menuCode += "01";
menuCode = menuCode.replace("%", "");
}else {
menuCode += searchMenuCode.get(0).get("MENUCODE").toString();
menuCode = menuCode.replace("%", "");
}
while(true) {
System.out.println(" ───────────────────────────────────────────────────");
System.out.println("메뉴명을 입력해 주세요. (한글만 입력 가능, 띄어쓰기 허용)");
System.out.println(" ───────────────────────────────────────────────────");
System.out.print(" >> ");
menuNm = ScanUtil.nextLine();
System.out.println();
if(ValidationUtil.validationMenuName(menuNm)) break;
}
while(true) {
System.out.println(" ───────────────────────────────────────────────────");
System.out.println("메뉴가격을 입력해 주세요. (0 ~ 9999999999)");
System.out.println(" ───────────────────────────────────────────────────");
System.out.print(" >> ");
menuPrice = ScanUtil.nextLong();
System.out.println();
if(ValidationUtil.validationPrice(menuPrice)) break;
}
while(true) {
System.out.println(" ───────────────────────────────────────────────────");
System.out.println("메뉴 수량을 입력해 주세요. (0 ~ 999999999)");
System.out.println(" ───────────────────────────────────────────────────");
System.out.print(" >> ");
remainQty = ScanUtil.nextInt();
System.out.println();
if(ValidationUtil.validationMenuRemainQty(remainQty)) break;
}
while(true) {
System.out.println(" ───────────────────────────────────────────────────");
System.out.println("메뉴를 등록하시겠습니까? (y / n)");
System.out.println(" ───────────────────────────────────────────────────");
System.out.print(" >> ");
createMenu = ScanUtil.nextLine();
if(ValidationUtil.validationYN(createMenu)) break;
}
if(createMenu.equals("n")) {
System.out.println(" ───────────────────────────────────────────────────");
System.out.println("메뉴 등록을 취소합니다.");
System.out.println(" ───────────────────────────────────────────────────");
EnterUtil.enterNext(2);
return View.ADMIN_MENU_MANAGEMENT;
}else if(createMenu.equals("y")) {
List<Object> param = new ArrayList<>();
param.add(menuCode);
param.add(menuNm);
param.add(menuPrice);
param.add(remainQty);
param.add(stoCode);
int isSuccess = adminCreateDAO.createMenu(param);
if (isSuccess > 0) {
System.out.println(" ───────────────────────────────────────────────────");
System.out.println("메뉴 등록이 완료되었습니다!");
System.out.println(" ───────────────────────────────────────────────────");
EnterUtil.enterNext(2);
}else {
System.out.println(" ───────────────────────────────────────────────────");
System.out.println(">> 메뉴 등록 실패! <<");
System.out.println(" ───────────────────────────────────────────────────");
EnterUtil.enterNext(2);
}
}
return View.ADMIN_MENU_MANAGEMENT;
}
public int menuRead() {
List<Map<String, Object>> menuALL = adminReadDAO.menuALL();
if(NullCheckUtil.isEmpty(menuALL)) {
System.out.println("등록된 메뉴가 없습니다!");
}else {
int maxMenuCodeLen = gapUtil.gapFullCnt(menuALL, "MENUCODE");
int maxNmLen = gapUtil.gapFullCnt(menuALL, "MENUNM");
int maxPriceLen = gapUtil.gapFullCnt(menuALL, "MENUPRICE");
int maxQtyLen = gapUtil.gapFullCnt(menuALL, "REMAINQTY");
int maxStoCodeLen = gapUtil.gapFullCnt(menuALL, "STONM");
// 페이징 기능
int pageNumber = 1; // 현재 페이지 번호
int pageSize = 5; // 페이지당 표시할 데이터 수
int startIndex = (pageNumber - 1) * pageSize; // 시작 인덱스
int endIndex = Math.min(startIndex + pageSize, menuALL.size()); // 끝 인덱스
int pageRowCnt = menuALL.size(); // 로우 개수
int totalPageSize = pageRowCnt / pageSize; // 총 페이지 개수
if(pageRowCnt % pageSize != 0) { // 다음 페이지까지 로우가 남음
totalPageSize++;
}
System.out.println(" ───────────────────────────────────────────────────");
System.out.println(" 1. 전체목록 보기");
System.out.println(" 2. 페이지 목록 보기");
System.out.println(" 3. 부분 검색");
System.out.println(" ───────────────────────────────────────────────────");
System.out.print(" >> ");
int choice = ScanUtil.nextInt();
if(choice == 1) { // 전체 검색
System.out.println(" ───────────────────────────────────────────────────");
System.out.println(" 총 메뉴 수 "+ pageRowCnt +" 개");
System.out.println(" ───────────────────────────────────────────────────");
System.out.println("메뉴코드 메뉴명 가격 재고 업체명");
System.out.println(" ───────────────────────────────────────────────────");
for(Map<String, Object> item : menuALL) {
int memMenuCodeLen = gapUtil.gapCnt(item, "MENUCODE");
int memNMLen = gapUtil.gapCnt(item, "MENUNM");
int memPRICELen = gapUtil.gapCnt(item, "MENUPRICE");
int memQTYLen = gapUtil.gapCnt(item, "REMAINQTY");
int memStoCodeLen = gapUtil.gapCnt(item, "STONM");
StringBuilder memMenuCode = gapUtil.gapFullSpace(String.valueOf(item.get("MENUCODE")), maxMenuCodeLen, memMenuCodeLen);
StringBuilder memNM = gapUtil.gapFullSpace(String.valueOf(item.get("MENUNM")), maxNmLen, memNMLen);
StringBuilder memPRICE = gapUtil.gapFullSpace(String.valueOf(item.get("MENUPRICE")), maxPriceLen, memPRICELen);
StringBuilder memQTY = gapUtil.gapFullSpace(String.valueOf(item.get("REMAINQTY")), maxQtyLen, memQTYLen);
StringBuilder memStoCode = gapUtil.gapFullSpace(String.valueOf(item.get("STONM")), maxStoCodeLen, memStoCodeLen);
System.out.printf("%-" + maxMenuCodeLen + "s%-" + maxNmLen + "s%-" + maxPriceLen + "s%-" + maxQtyLen + "s%" + maxStoCodeLen + "s\n", memMenuCode, memNM, memPRICE, memQTY, memStoCode);
}
EnterUtil.enterNext(1);
}else if(choice == 2) { // 페이징 검색
System.out.println(" ───────────────────────────────────────────────────");
System.out.println(" 한 페이지에 몇 개의 데이터를 보시겠습니까?");
System.out.println(" ───────────────────────────────────────────────────");
System.out.print(" >> ");
pageSize = ScanUtil.nextInt();
startIndex = (pageNumber - 1) * pageSize;
endIndex = Math.min(startIndex + pageSize, menuALL.size());
totalPageSize = pageRowCnt / pageSize; // 총 페이지 개수
if(pageRowCnt % pageSize != 0) { // 다음 페이지까지 로우가 남음
totalPageSize++;
}
System.out.println(" ───────────────────────────────────────────────────");
System.out.println(" 총 메뉴 수 "+ pageRowCnt +" 개 : " + pageNumber + " / " + totalPageSize + " 페이지");
System.out.println(" ───────────────────────────────────────────────────");
System.out.println("메뉴코드 메뉴명 가격 재고 업체명");
System.out.println(" ───────────────────────────────────────────────────");
for(int i = startIndex; i < endIndex; i++) {
int memMenuCodeLen = gapUtil.gapCnt(String.valueOf(menuALL.get(i).get("MENUCODE")));
int memNMLen = gapUtil.gapCnt(String.valueOf(menuALL.get(i).get("MENUNM")));
int memPRICELen = gapUtil.gapCnt(String.valueOf(menuALL.get(i).get("MENUPRICE")));
int memQTYLen = gapUtil.gapCnt(String.valueOf(menuALL.get(i).get("REMAINQTY")));
int memStoCodeLen = gapUtil.gapCnt(String.valueOf(menuALL.get(i).get("STONM")));
StringBuilder memMenuCode = gapUtil.gapFullSpace(String.valueOf(menuALL.get(i).get("MENUCODE")), maxMenuCodeLen, memMenuCodeLen);
StringBuilder memNM = gapUtil.gapFullSpace(String.valueOf(menuALL.get(i).get("MENUNM")), maxNmLen, memNMLen);
StringBuilder memPRICE = gapUtil.gapFullSpace(String.valueOf(menuALL.get(i).get("MENUPRICE")), maxPriceLen, memPRICELen);
StringBuilder memQTY = gapUtil.gapFullSpace(String.valueOf(menuALL.get(i).get("REMAINQTY")), maxQtyLen, memQTYLen);
StringBuilder memStoCode = gapUtil.gapFullSpace(String.valueOf(menuALL.get(i).get("STONM")), maxStoCodeLen, memStoCodeLen);
System.out.printf("%-" + maxMenuCodeLen + "s%-" + maxNmLen + "s%-" + maxPriceLen + "s%-" + maxQtyLen + "s%" + maxStoCodeLen + "s\n", memMenuCode, memNM, memPRICE, memQTY, memStoCode);
}
while(true) {
System.out.println(" ───────────────────────────────────────────────────");
System.out.println(" 1. 원하는 페이지 보기");
System.out.println(" 0. 이전 화면");
System.out.println(" ───────────────────────────────────────────────────");
System.out.print(" >> ");
int pageListSelect = ScanUtil.nextInt();
if(pageListSelect == 1) {
System.out.println(" ───────────────────────────────────────────────────");
System.out.println(" 몇 페이지를 보시겠습니까?");
System.out.println(" ───────────────────────────────────────────────────");
System.out.print(" >> ");
pageNumber = ScanUtil.nextInt();
if(pageNumber > totalPageSize || pageNumber <= 0) {
System.out.println(" ───────────────────────────────────────────────────");
System.out.println(" 총 메뉴 수 "+ pageRowCnt +" 개 : " + pageNumber + " / " + totalPageSize + " 페이지");
System.out.println(" ───────────────────────────────────────────────────");
System.out.println("메뉴코드 메뉴명 가격 재고 업체명");
System.out.println(" ───────────────────────────────────────────────────");
System.out.println("해당 페이지는 정보가 없습니다.");
}else {
startIndex = (pageNumber - 1) * pageSize;
endIndex = Math.min(startIndex + pageSize, menuALL.size());
System.out.println(" ───────────────────────────────────────────────────");
System.out.println(" 총 메뉴 수 "+ pageRowCnt +" 개 : " + pageNumber + " / " + totalPageSize + " 페이지");
System.out.println(" ───────────────────────────────────────────────────");
System.out.println("메뉴코드 메뉴명 가격 재고 업체명");
System.out.println(" ───────────────────────────────────────────────────");
for(int i = startIndex; i < endIndex; i++) {
int memMenuCodeLen = gapUtil.gapCnt(String.valueOf(menuALL.get(i).get("MENUCODE")));
int memNMLen = gapUtil.gapCnt(String.valueOf(menuALL.get(i).get("MENUNM")));
int memPRICELen = gapUtil.gapCnt(String.valueOf(menuALL.get(i).get("MENUPRICE")));
int memQTYLen = gapUtil.gapCnt(String.valueOf(menuALL.get(i).get("REMAINQTY")));
int memStoCodeLen = gapUtil.gapCnt(String.valueOf(menuALL.get(i).get("STONM")));
StringBuilder memMenuCode = gapUtil.gapFullSpace(String.valueOf(menuALL.get(i).get("MENUCODE")), maxMenuCodeLen, memMenuCodeLen);
StringBuilder memNM = gapUtil.gapFullSpace(String.valueOf(menuALL.get(i).get("MENUNM")), maxNmLen, memNMLen);
StringBuilder memPRICE = gapUtil.gapFullSpace(String.valueOf(menuALL.get(i).get("MENUPRICE")), maxPriceLen, memPRICELen);
StringBuilder memQTY = gapUtil.gapFullSpace(String.valueOf(menuALL.get(i).get("REMAINQTY")), maxQtyLen, memQTYLen);
StringBuilder memStoCode = gapUtil.gapFullSpace(String.valueOf(menuALL.get(i).get("STONM")), maxStoCodeLen, memStoCodeLen);
System.out.printf("%-" + maxMenuCodeLen + "s%-" + maxNmLen + "s%-" + maxPriceLen + "s%-" + maxQtyLen + "s%" + maxStoCodeLen + "s\n", memMenuCode, memNM, memPRICE, memQTY, memStoCode);
}
}
}else if(pageListSelect == 0) {
return View.ADMIN_MENU_MANAGEMENT;
}
}
}else if(choice == 3) { // 부분 검색
System.out.println(" ───────────────────────────────────────────────────");
System.out.println(" 1. 메뉴코드로 검색");
System.out.println(" 2. 메뉴명으로 검색");
System.out.println(" 3. 메뉴가격으로 검색");
System.out.println(" 4. 가게명으로 검색");
System.out.println(" ───────────────────────────────────────────────────");
System.out.print(" >> ");
int searchno = ScanUtil.nextInt();
if(searchno == 1) {
System.out.print("메뉴코드 >> ");
String storeCodeStr = ScanUtil.nextLine();
List<Object> searchStoCode = new ArrayList<>();
searchStoCode.add(storeCodeStr);
Map<String, Object> storeInfo = adminReadDAO.menuSearchFromMenuCode(searchStoCode);
if(NullCheckUtil.isEmpty(storeInfo)) {
System.out.println(" ───────────────────────────────────────────────────");
System.out.println("등록된 메뉴가 없습니다!");
System.out.println(" ───────────────────────────────────────────────────");
}else {
int memMenuCodeLen = gapUtil.gapCnt(storeInfo, "MENUCODE");
int memNMLen = gapUtil.gapCnt(storeInfo, "MENUNM");
int memPRICELen = gapUtil.gapCnt(storeInfo, "MENUPRICE");
int memQTYLen = gapUtil.gapCnt(storeInfo, "REMAINQTY");
int memStoCodeLen = gapUtil.gapCnt(storeInfo, "STONM");
StringBuilder memMenuCode = gapUtil.gapFullSpace(String.valueOf(storeInfo.get("MENUCODE")), maxMenuCodeLen, memMenuCodeLen);
StringBuilder memNM = gapUtil.gapFullSpace(String.valueOf(storeInfo.get("MENUNM")), maxNmLen, memNMLen);
StringBuilder memPRICE = gapUtil.gapFullSpace(String.valueOf(storeInfo.get("MENUPRICE")), maxPriceLen, memPRICELen);
StringBuilder memQTY = gapUtil.gapFullSpace(String.valueOf(storeInfo.get("REMAINQTY")), maxQtyLen, memQTYLen);
StringBuilder memStoCode = gapUtil.gapFullSpace(String.valueOf(storeInfo.get("STONM")), maxStoCodeLen, memStoCodeLen);
System.out.println(" ───────────────────────────────────────────────────");
System.out.println("메뉴코드 메뉴명 가격 재고 업체명");
System.out.println(" ───────────────────────────────────────────────────");
System.out.printf("%-" + maxMenuCodeLen + "s%-" + maxNmLen + "s%-" + maxPriceLen + "s%-" + maxQtyLen + "s%" + maxStoCodeLen + "s\n", memMenuCode, memNM, memPRICE, memQTY, memStoCode);
}
EnterUtil.enterNext(2);
}else if(searchno == 2) {
System.out.print("메뉴명 >> ");
String storeMenuNameStr = ScanUtil.nextLine();
List<Object> searchMenuName = new ArrayList<>();
searchMenuName.add(storeMenuNameStr);
List<Map<String, Object>> storeInfo = adminReadDAO.menuSearchFromMenuName(searchMenuName);
if(NullCheckUtil.isEmpty(storeInfo)) {
System.out.println(" ───────────────────────────────────────────────────");
System.out.println("등록된 메뉴가 없습니다!");
System.out.println(" ───────────────────────────────────────────────────");
}else {
System.out.println(" ───────────────────────────────────────────────────");
System.out.println("메뉴코드 메뉴명 가격 재고 업체명");
System.out.println(" ───────────────────────────────────────────────────");
for(Map<String, Object> item : storeInfo) {
int memMenuCodeLen = gapUtil.gapCnt(item, "MENUCODE");
int memNMLen = gapUtil.gapCnt(item, "MENUNM");
int memPRICELen = gapUtil.gapCnt(item, "MENUPRICE");
int memQTYLen = gapUtil.gapCnt(item, "REMAINQTY");
int memStoCodeLen = gapUtil.gapCnt(item, "STONM");
StringBuilder memMenuCode = gapUtil.gapFullSpace(String.valueOf(item.get("MENUCODE")), maxMenuCodeLen, memMenuCodeLen);
StringBuilder memNM = gapUtil.gapFullSpace(String.valueOf(item.get("MENUNM")), maxNmLen, memNMLen);
StringBuilder memPRICE = gapUtil.gapFullSpace(String.valueOf(item.get("MENUPRICE")), maxPriceLen, memPRICELen);
StringBuilder memQTY = gapUtil.gapFullSpace(String.valueOf(item.get("REMAINQTY")), maxQtyLen, memQTYLen);
StringBuilder memStoCode = gapUtil.gapFullSpace(String.valueOf(item.get("STONM")), maxStoCodeLen, memStoCodeLen);
System.out.printf("%-" + maxMenuCodeLen + "s%-" + maxNmLen + "s%-" + maxPriceLen + "s%-" + maxQtyLen + "s%" + maxStoCodeLen + "s\n", memMenuCode, memNM, memPRICE, memQTY, memStoCode);
}
}
EnterUtil.enterNext(2);
}else if(searchno == 3) {
System.out.print("얼마 이상을 검색할까요? (0 ~ 9999999999) >> ");
long storeMenuPriceInt = ScanUtil.nextLong();
List<Object> searchMenuPrice = new ArrayList<>();
searchMenuPrice.add(storeMenuPriceInt);
List<Map<String, Object>> storeInfo = adminReadDAO.menuSearchFromMenuPrice(searchMenuPrice);
if(NullCheckUtil.isEmpty(storeInfo)) {
System.out.println(" ───────────────────────────────────────────────────");
System.out.println("등록된 메뉴가 없습니다!");
System.out.println(" ───────────────────────────────────────────────────");
}else {
System.out.println(" ───────────────────────────────────────────────────");
System.out.println("메뉴코드 메뉴명 가격 재고 업체명");
System.out.println(" ───────────────────────────────────────────────────");
for(Map<String, Object> item : storeInfo) {
int memMenuCodeLen = gapUtil.gapCnt(item, "MENUCODE");
int memNMLen = gapUtil.gapCnt(item, "MENUNM");
int memPRICELen = gapUtil.gapCnt(item, "MENUPRICE");
int memQTYLen = gapUtil.gapCnt(item, "REMAINQTY");
int memStoCodeLen = gapUtil.gapCnt(item, "STONM");
StringBuilder memMenuCode = gapUtil.gapFullSpace(String.valueOf(item.get("MENUCODE")), maxMenuCodeLen, memMenuCodeLen);
StringBuilder memNM = gapUtil.gapFullSpace(String.valueOf(item.get("MENUNM")), maxNmLen, memNMLen);
StringBuilder memPRICE = gapUtil.gapFullSpace(String.valueOf(item.get("MENUPRICE")), maxPriceLen, memPRICELen);
StringBuilder memQTY = gapUtil.gapFullSpace(String.valueOf(item.get("REMAINQTY")), maxQtyLen, memQTYLen);
StringBuilder memStoCode = gapUtil.gapFullSpace(String.valueOf(item.get("STONM")), maxStoCodeLen, memStoCodeLen);
System.out.printf("%-" + maxMenuCodeLen + "s%-" + maxNmLen + "s%-" + maxPriceLen + "s%-" + maxQtyLen + "s%" + maxStoCodeLen + "s\n", memMenuCode, memNM, memPRICE, memQTY, memStoCode);
}
}
EnterUtil.enterNext(2);
}else if(searchno == 4) {
System.out.print("업체명 >> ");
String storeStoCodeStr = ScanUtil.nextLine();
List<Object> searchStoCode = new ArrayList<>();
searchStoCode.add(storeStoCodeStr);
List<Map<String, Object>> storeInfo = adminReadDAO.menuSearchFromStoCode(searchStoCode);
if(NullCheckUtil.isEmpty(storeInfo)) {
System.out.println(" ───────────────────────────────────────────────────");
System.out.println("등록된 메뉴가 없습니다!");
System.out.println(" ───────────────────────────────────────────────────");
}else {
System.out.println(" ───────────────────────────────────────────────────");
System.out.println("메뉴코드 메뉴명 가격 재고 업체명");
System.out.println(" ───────────────────────────────────────────────────");
for(Map<String, Object> item : storeInfo) {
int memMenuCodeLen = gapUtil.gapCnt(item, "MENUCODE");
int memNMLen = gapUtil.gapCnt(item, "MENUNM");
int memPRICELen = gapUtil.gapCnt(item, "MENUPRICE");
int memQTYLen = gapUtil.gapCnt(item, "REMAINQTY");
int memStoCodeLen = gapUtil.gapCnt(item, "STONM");
StringBuilder memMenuCode = gapUtil.gapFullSpace(String.valueOf(item.get("MENUCODE")), maxMenuCodeLen, memMenuCodeLen);
StringBuilder memNM = gapUtil.gapFullSpace(String.valueOf(item.get("MENUNM")), maxNmLen, memNMLen);
StringBuilder memPRICE = gapUtil.gapFullSpace(String.valueOf(item.get("MENUPRICE")), maxPriceLen, memPRICELen);
StringBuilder memQTY = gapUtil.gapFullSpace(String.valueOf(item.get("REMAINQTY")), maxQtyLen, memQTYLen);
StringBuilder memStoCode = gapUtil.gapFullSpace(String.valueOf(item.get("STONM")), maxStoCodeLen, memStoCodeLen);
System.out.printf("%-" + maxMenuCodeLen + "s%-" + maxNmLen + "s%-" + maxPriceLen + "s%-" + maxQtyLen + "s%" + maxStoCodeLen + "s\n", memMenuCode, memNM, memPRICE, memQTY, memStoCode);
}
}
EnterUtil.enterNext(2);
}
}
}
return View.ADMIN_MENU_MANAGEMENT;
}
public int menuUpdate() {
List<Object> param = new ArrayList<Object>();
String sql = " UPDATE MENU SET ";
int flag = 0; // 수정 여부 확인
String yesOrNot = ""; // y, n 입력
String menuCode = ""; // 메뉴코드
String menuNm = ""; // 메뉴명
long menuPrice = 0; // 메뉴가격
int remainQty = 0; // 잔여수량
while(true) {
System.out.println(" ───────────────────────────────────────────────────");
System.out.println(" 변경할 메뉴코드를 입력하세요. ( ex. YGSIG112 ) ");
System.out.println(" ───────────────────────────────────────────────────");
System.out.print(" >> ");
menuCode = ScanUtil.nextLine();
if (ValidationUtil.validationCode(menuCode)) {
param.add(menuCode);
break;
}
}
while(true) {
System.out.println(" ───────────────────────────────────────────────────");
System.out.println(" 메뉴명을 변경하시겠습니까? (y/n)");
System.out.println(" ───────────────────────────────────────────────────");
System.out.print(" >> ");
yesOrNot = ScanUtil.nextLine();
if(ValidationUtil.validationYN(yesOrNot)) break;
}
if(yesOrNot.equals("y")) {
while(true) {
System.out.println(" ───────────────────────────────────────────────────");
System.out.println(" * 변경할 메뉴명 입력 [ 한글, 띄어쓰기 입력 ]");
System.out.println(" ───────────────────────────────────────────────────");
System.out.print(" >> ");
menuNm = ScanUtil.nextLine();
if (ValidationUtil.validationMenuName(menuNm)) {
sql += "MENUNM = '"+ menuNm + "', ";
break;
}
}
}
while(true) {
System.out.println(" ───────────────────────────────────────────────────");
System.out.println(" 메뉴가격을 변경하시겠습니까? (y/n)");
System.out.println(" ───────────────────────────────────────────────────");
System.out.print(" >> ");
yesOrNot = ScanUtil.nextLine();
if(ValidationUtil.validationYN(yesOrNot)) break;
}
if(yesOrNot.equals("y")) {
while(true) {
System.out.println(" ───────────────────────────────────────────────────");
System.out.println(" * 변경할 메뉴가격 입력 [ 0 ~ 9999999999 ]");
System.out.println(" ───────────────────────────────────────────────────");
System.out.print(" >> ");
menuPrice = ScanUtil.nextLongLine();
if (ValidationUtil.validationPrice(menuPrice)) {
sql += "MENUPRICE = '"+ menuPrice + "', ";
break;
}
}
}
while(true) {
System.out.println(" ───────────────────────────────────────────────────");
System.out.println(" 메뉴수량을 변경하시겠습니까? (y/n)");
System.out.println(" ───────────────────────────────────────────────────");
System.out.print(" >> ");
yesOrNot = ScanUtil.nextLine();
if(ValidationUtil.validationYN(yesOrNot)) break;
}
if(yesOrNot.equals("y")) {
while(true) {
System.out.println(" ───────────────────────────────────────────────────");
System.out.println(" * 변경할 메뉴수량 입력 [ 0 ~ 999999999 ]");
System.out.println(" ───────────────────────────────────────────────────");
System.out.print(" >> ");
remainQty = ScanUtil.nextIntegerLine();
if (ValidationUtil.validationMenuRemainQty(remainQty)) {
sql += "REMAINQTY = '"+ remainQty + "', ";
break;
}
}
}
int sqllen = sql.length();
sql = sql.substring(0, sqllen-2); // (endindex-1)-1[,]
sql += " WHERE MENUCODE = ? ";
while(true) {
System.out.println(" ───────────────────────────────────────────────────");
System.out.println(" 메뉴 정보를 변경하시겠습니까? (y/n)");
System.out.println(" ───────────────────────────────────────────────────");
System.out.print(" >> ");
yesOrNot = ScanUtil.nextLine();
if(ValidationUtil.validationYN(yesOrNot)) break;
}
if(yesOrNot.equals("y")) {
flag = adminUpdateDAO.update(sql, param);
if(flag != 0) {
System.out.println(" ───────────────────────────────────────────────────");
System.out.println(" 메뉴 수정이 완료되었습니다.");
System.out.println(" ───────────────────────────────────────────────────");
EnterUtil.enterNext(2);
}else {
System.out.println(" ───────────────────────────────────────────────────");
System.out.println(" 메뉴 수정이 실패했습니다.");
System.out.println(" ───────────────────────────────────────────────────");
EnterUtil.enterNext(2);
}
}else if(yesOrNot.equals("n")) {
System.out.println(" ───────────────────────────────────────────────────");
System.out.println(" 메뉴 정보 관리 페이지로 이동합니다.");
System.out.println(" ───────────────────────────────────────────────────");
EnterUtil.enterNext(2);
}
return View.ADMIN_MENU_MANAGEMENT;
}
public int menuDelete() {
String menuCodeStr = ""; // 메뉴 코드
String deleteMenu = ""; // 메뉴 삭제
List<Map<String, Object>> menuALL = adminReadDAO.menuALL();
if(NullCheckUtil.isEmpty(menuALL)) {
System.out.println("등록된 메뉴가 없습니다!");
}else {
int maxMenuCodeLen = gapUtil.gapFullCnt(menuALL, "MENUCODE");
int maxNmLen = gapUtil.gapFullCnt(menuALL, "MENUNM");
int maxPriceLen = gapUtil.gapFullCnt(menuALL, "MENUPRICE");
int maxQtyLen = gapUtil.gapFullCnt(menuALL, "REMAINQTY");
int maxStoNmLen = gapUtil.gapFullCnt(menuALL, "STONM");
System.out.println(" ───────────────────────────────────────────────────");
System.out.println("메뉴 삭제");
System.out.println("1. 메뉴코드 입력");
System.out.println("2. 메뉴명 검색");
System.out.println(" ───────────────────────────────────────────────────");
System.out.print(" >> ");
int menuChoice = ScanUtil.nextIntegerLine();
if(menuChoice == 1) {
while(true) {
System.out.println(" ───────────────────────────────────────────────────");
System.out.println("삭제하실 메뉴코드를 입력해 주세요.");
System.out.println(" ───────────────────────────────────────────────────");
System.out.print(" >> ");
menuCodeStr = ScanUtil.nextLine();
System.out.println();
if(ValidationUtil.validationCode(menuCodeStr)) break;
}
}else if(menuChoice == 2) {
System.out.println(" ───────────────────────────────────────────────────");
System.out.println(" 검색하실 메뉴명을 입력해 주세요.");
System.out.println(" ───────────────────────────────────────────────────");
System.out.print(" >> ");
String storeMenuNameStr = ScanUtil.nextLine();
List<Object> searchMenuName = new ArrayList<>();
searchMenuName.add(storeMenuNameStr);
List<Map<String, Object>> storeInfo = adminReadDAO.menuSearchFromMenuName(searchMenuName);
if(NullCheckUtil.isEmpty(storeInfo)) {
System.out.println(" ───────────────────────────────────────────────────");
System.out.println("등록된 메뉴가 없습니다!");
System.out.println(" ───────────────────────────────────────────────────");
}else {
System.out.println(" ──────────────────────────────────────────────────");
System.out.println("메뉴코드 메뉴명 가격 재고 업체명");
System.out.println(" ──────────────────────────────────────────────────");
for(Map<String, Object> item : storeInfo) {
int memMenuCodeLen = gapUtil.gapCnt(item, "MENUCODE");
int memNMLen = gapUtil.gapCnt(item, "MENUNM");
int memPRICELen = gapUtil.gapCnt(item, "MENUPRICE");
int memQTYLen = gapUtil.gapCnt(item, "REMAINQTY");
int memStoNmLen = gapUtil.gapCnt(item, "STONM");
StringBuilder memMenuCode = gapUtil.gapFullSpace(String.valueOf(item.get("MENUCODE")), maxMenuCodeLen, memMenuCodeLen);
StringBuilder memNM = gapUtil.gapFullSpace(String.valueOf(item.get("MENUNM")), maxNmLen, memNMLen);
StringBuilder memPRICE = gapUtil.gapFullSpace(String.valueOf(item.get("MENUPRICE")), maxPriceLen, memPRICELen);
StringBuilder memQTY = gapUtil.gapFullSpace(String.valueOf(item.get("REMAINQTY")), maxQtyLen, memQTYLen);
StringBuilder memStoNm = gapUtil.gapFullSpace(String.valueOf(item.get("STONM")), maxStoNmLen, memStoNmLen);
System.out.printf("%-" + maxMenuCodeLen + "s%-" + maxNmLen + "s%-" + maxPriceLen + "s%-" + maxQtyLen + "s%" + maxStoNmLen + "s\n", memMenuCode, memNM, memPRICE, memQTY, memStoNm);
}
}
EnterUtil.enterNext(2);
return View.ADMIN_MENU_MANAGEMENT;
}
}
List<Object> searchMenuName = new ArrayList<>();
searchMenuName.add(menuCodeStr);
Map<String, Object> menuName = adminDeleteDAO.searchMenuName(searchMenuName);
String menuNameStr = menuName.get("MENUNM").toString();
while(true) {
System.out.println(" ───────────────────────────────────────────────────");
System.out.println(" [ "+ menuNameStr +" ] 메뉴를 삭제하시겠습니까? (y / n)");
System.out.println(" ───────────────────────────────────────────────────");
System.out.print(" >> ");
deleteMenu = ScanUtil.nextLine();
if(ValidationUtil.validationYN(deleteMenu)) break;
}
if(deleteMenu.equals("n")) {
System.out.println(" ───────────────────────────────────────────────────");
System.out.println("메뉴 삭제를 취소합니다.");
System.out.println(" ───────────────────────────────────────────────────");
EnterUtil.enterNext(2);
return View.ADMIN_MENU_MANAGEMENT;
}else if(deleteMenu.equals("y")) {
List<Object> param = new ArrayList<>();
param.add(menuCodeStr);
int isSuccess = adminDeleteDAO.deleteMenu(param);
if (isSuccess > 0) {
System.out.println(" ───────────────────────────────────────────────────");
System.out.println("메뉴 삭제가 완료되었습니다!");
System.out.println(" ───────────────────────────────────────────────────");
EnterUtil.enterNext(2);
}else {
System.out.println(" ───────────────────────────────────────────────────");
System.out.println(">> 메뉴 삭제 실패! <<");
System.out.println(" ───────────────────────────────────────────────────");
EnterUtil.enterNext(2);
}
}
return View.ADMIN_MENU_MANAGEMENT;
}
'대덕인재개발원 > 대덕인재개발원_1st project' 카테고리의 다른 글
10. AdminCreateDAO (0) | 2023.08.19 |
---|---|
9. 관리자 페이지 (6) : 라이더 관리 (0) | 2023.08.19 |
7. 관리자 페이지 (4) : 주문내역 관리 (0) | 2023.08.19 |
6. 관리자 페이지 (3) : 가게 리스트 관리 (0) | 2023.08.19 |
5. 관리자 페이지 (2) : 회원정보 관리 (0) | 2023.08.19 |