JSP

 

 

 

AdminOrderListAction

package net.macaronics.web.admin.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import net.macaronics.web.controll.action.Action;
import net.macaronics.web.dao.OrderDAO;
import net.macaronics.web.dto.OrderVO;

public class AdminOrderListAction implements Action {

	private static final Logger logger=LogManager.getLogger(AdminOrderListAction.class);
	
	@Override
	public void execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		String url="admin/order/orderList.jsp";
		String key="";
		if(request.getParameter("key")!=null){
			key=request.getParameter("key");
		}
		
		OrderDAO orderDAO=OrderDAO.getInstance();
		List<OrderVO> orderList=orderDAO.listOrder(key);
		
		request.setAttribute("key", key);
		request.setAttribute("orderList", orderList);
		request.getRequestDispatcher(url).forward(request, response);
	}
	
	
 
}



 

 

DTO

public class OrderVO {
	  private int odseq;
      private int oseq;
      private String id;
      private Timestamp indate;
      private int pseq;
      private int quantity;
      private String mname;
      private String zip_num;
      private String address;
      private String phone;
      private String pname;
      private int price2;
      private String result;

setter, getter

 

DAO

//관리자 화면 - 주문관리 주문 목록 불러오기
	public List<OrderVO> listOrder(String member_name){
		List<OrderVO> orderList=new ArrayList<>();
		try{
			sqlSession=MybatisService.getFactory().openSession();
			orderList=sqlSession.selectList("order.listOrder", member_name);
			
		}catch (Exception e) {
			e.printStackTrace();
		}finally{
			MybatisService.sessionClose(sqlSession);
		}
		return orderList;
	}

	
	//관리자 화면 - 주문처리 업데이트
	public void updateOrderResult(String odseq) {
		try{
			sqlSession=MybatisService.getFactory().openSession();
			sqlSession.update("order.updateOrderResult", odseq);			
		}catch(Exception e){
			e.printStackTrace();
		}finally{
			sqlSession.commit();
			MybatisService.sessionClose(sqlSession);
		}
	}
	

 

 

 

 

 

 

Vew

orderList.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>    
<!DOCTYPE html>
<html class="no-js">   
    <head>
<jsp:include page="../../include/AdminHeader.jsp" />
    </head>   
    <body>
 <jsp:include page="../../include/AdminTopFixMenu.jsp" />   
   
        
        <div class="container-fluid">
            <div class="row-fluid">
                <div class="span3" id="sidebar">
					 <jsp:include page="../../include/AdminLeftMenu.jsp" />   
                </div>
                
                <!--/span-->
                <div class="span9" id="content">
                    <div class="row-fluid">
                        <div class="alert alert-success">
							<button type="button" class="close" data-dismiss="alert">&times;</button>
                            <h4>주문리스트</h4>
                        </div>
                        
                        
                        <div class="navbar">
                            	<div class="navbar-inner">
	                                <ul class="breadcrumb">
	                                    <i class="icon-chevron-left hide-sidebar"><a href='#' title="Hide Sidebar" rel='tooltip'>&nbsp;</a></i>
	                                    <i class="icon-chevron-right show-sidebar" style="display:none;"><a href='#' title="Show Sidebar" rel='tooltip'>&nbsp;</a></i>
	                                    <li>
	                       <form action="MacaronicsServlet" >
	                                     
	                                     주문자 이름 <input type="text" name="key" value="${key =='%' ? '':key }"> 
	                   		  <input type="hidden"  value="admin_order_list" name="command" >    
	                           <input type="submit" class="success" value="검색">               
	                      </form>              
	                    
	                    
	                                        <a href="#"></a>
	                                    </li>
	                                </ul>
                            	</div>
                        	</div>
                        
                        	
                    	</div>
                   
                   
                   <div>
                   	 
                   	 <form method="post" action="" name="frm">
                   	 <div class="table-responsive">
                   	 <table class="table">
                   	   <tr class="success">
                   	   	 <th>주문번호(처리여부) </th>
                   	   	 <th>주문자</th>
                   	   	 <th>상품명</th>
                   	   	 <th>수량</th>
                   	   	 <th>배송지</th>
                   	   	 <th>전화</th>
                   	   	 <th>주문일</th>
                   	   </tr>
                   	  <c:if test="${empty orderList or orderList.size()==0 }" >
                   	  	<tr>
                   	  	  <td colspan="6" class="text-center"> 검색된 상품이 없습니다.</td>
                   	  	</tr>
                   	  </c:if> 
                   	  <c:forEach items="${orderList}" var="orderVO"> 
	                   	   <tr>
	                   	   <td>
	                   	   <c:choose>
		                   	   	<c:when test="${orderVO.result=='1' }">
									( <input type="checkbox" name="result" value="${orderVO.odseq }"> <small style="color:red;">미처리 </small> )				                   	   		
		                   	   	</c:when>
	                   	    <c:otherwise>
(<input type="checkbox" checked="checked" disabled="disabled" > 처리완료)
	                   	    </c:otherwise>
	                   	   </c:choose>
	                  	   
	                   	   </td>
	                   	   <td>${orderVO.mname}</td>
	                   	   <td>${orderVO.pname}</td>
	                   	   <td>${orderVO.quantity}</td>
	                   	   <td>${orderVO.address}</td>
	                   	   <td>${orderVO.phone}</td>
	                   	   <td>${orderVO.indate}</td>
	                    	   
	                   	   </tr>
                   	   </c:forEach>
                   	   
                   	   <tfoot>
                   	   <tr>
                   	   	<td colspan="7" class="text-center"><button onclick="go_order_save()" class="btn btn-success">주문처리(입금확인)</button>  </td>
                   	   </tr>
                   	   </tfoot>
                   	 </table>
                   	 </div>
                   	 </form>
                   	 
                   </div>
                    
                    </div>
                </div>
         
           
            </div>
            <hr>

<script>


function go_order_save() {
	var count=0;
	$('input:checkbox[name=result]').each(function() {
	   if($(this).is(':checked'))
		   count++;
	});

	if(count==0 || count==undefined){
		alert("주문처리할 항목을 선택해 주세요.")
		return;
	}else{
		document.frm.action="MacaronicsServlet?command=admin_order_save";
		document.frm.submit();
	}
}



</script>

            
 <jsp:include page="../../include/AdminFooter.jsp" />   
 
 
 
         

 

 

orderList.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>    
<!DOCTYPE html>
<html class="no-js">   
    <head>
<jsp:include page="../../include/AdminHeader.jsp" />
    </head>   
    <body>
 <jsp:include page="../../include/AdminTopFixMenu.jsp" />   
   
        
        <div class="container-fluid">
            <div class="row-fluid">
                <div class="span3" id="sidebar">
					 <jsp:include page="../../include/AdminLeftMenu.jsp" />   
                </div>
                
                <!--/span-->
                <div class="span9" id="content">
                    <div class="row-fluid">
                        <div class="alert alert-success">
							<button type="button" class="close" data-dismiss="alert">&times;</button>
                            <h4>주문리스트</h4>
                        </div>
                        
                        
                        <div class="navbar">
                            	<div class="navbar-inner">
	                                <ul class="breadcrumb">
	                                    <i class="icon-chevron-left hide-sidebar"><a href='#' title="Hide Sidebar" rel='tooltip'>&nbsp;</a></i>
	                                    <i class="icon-chevron-right show-sidebar" style="display:none;"><a href='#' title="Show Sidebar" rel='tooltip'>&nbsp;</a></i>
	                                    <li>
	                       <form action="MacaronicsServlet" >
	                                     
	                                     주문자 이름 <input type="text" name="key" value="${key =='%' ? '':key }"> 
	                   		  <input type="hidden"  value="admin_order_list" name="command" >    
	                           <input type="submit" class="success" value="검색">               
	                      </form>              
	                    
	                    
	                                        <a href="#"></a>
	                                    </li>
	                                </ul>
                            	</div>
                        	</div>
                        
                        	
                    	</div>
                   
                   
                   <div>
                   	 
                   	 <form method="post" action="" name="frm">
                   	 <div class="table-responsive">
                   	 <table class="table">
                   	   <tr class="success">
                   	   	 <th>주문번호(처리여부) </th>
                   	   	 <th>주문자</th>
                   	   	 <th>상품명</th>
                   	   	 <th>수량</th>
                   	   	 <th>배송지</th>
                   	   	 <th>전화</th>
                   	   	 <th>주문일</th>
                   	   </tr>
                   	  <c:if test="${empty orderList or orderList.size()==0 }" >
                   	  	<tr>
                   	  	  <td colspan="6" class="text-center"> 검색된 상품이 없습니다.</td>
                   	  	</tr>
                   	  </c:if> 
                   	  <c:forEach items="${orderList}" var="orderVO"> 
	                   	   <tr>
	                   	   <td>
	                   	   <c:choose>
		                   	   	<c:when test="${orderVO.result=='1' }">
									( <input type="checkbox" name="result" value="${orderVO.odseq }"> <small style="color:red;">미처리 </small> )				                   	   		
		                   	   	</c:when>
	                   	    <c:otherwise>
(<input type="checkbox" checked="checked" disabled="disabled" > 처리완료)
	                   	    </c:otherwise>
	                   	   </c:choose>
	                  	   
	                   	   </td>
	                   	   <td>${orderVO.mname}</td>
	                   	   <td>${orderVO.pname}</td>
	                   	   <td>${orderVO.quantity}</td>
	                   	   <td>${orderVO.address}</td>
	                   	   <td>${orderVO.phone}</td>
	                   	   <td>${orderVO.indate}</td>
	                    	   
	                   	   </tr>
                   	   </c:forEach>
                   	   
                   	   <tfoot>
                   	   <tr>
                   	   	<td colspan="7" class="text-center"><button onclick="go_order_save()" class="btn btn-success">주문처리(입금확인)</button>  </td>
                   	   </tr>
                   	   </tfoot>
                   	 </table>
                   	 </div>
                   	 </form>
                   	 
                   </div>
                    
                    </div>
                </div>
         
           
            </div>
            <hr>

<script>


function go_order_save() {
	var count=0;
	$('input:checkbox[name=result]').each(function() {
	   if($(this).is(':checked'))
		   count++;
	});

	if(count==0 || count==undefined){
		alert("주문처리할 항목을 선택해 주세요.")
		return;
	}else{
		document.frm.action="MacaronicsServlet?command=admin_order_save";
		document.frm.submit();
	}
}



</script>

            
 <jsp:include page="../../include/AdminFooter.jsp" />   
 
 
 
         

 

 

AdminOrderSaveAction

package net.macaronics.web.admin.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import net.macaronics.web.controll.action.Action;
import net.macaronics.web.dao.OrderDAO;

public class AdminOrderSaveAction implements Action{

	private static Logger logger =LogManager.getLogger(AdminOrderSaveAction.class);
	
	@Override
	public void execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		String url="MacaronicsServlet?command=admin_order_list";
		
		String[] resultArr =request.getParameterValues("result");
		
		for(String oseq: resultArr){
			logger.info("AdminOrderSaveAction -  {} ", oseq);
			OrderDAO orderDAO =OrderDAO.getInstance();
			orderDAO.updateOrderResult(oseq);
	    }
		
		response.sendRedirect(url);
		
	}
	
	
	

	
	
}


 

 

Mapper

	<!-- 관리자 화면 주문  처리하기 위한 주문 목록 불러오기-->
	<select id="listOrder" resultType="net.macaronics.web.dto.OrderVO">
	 select * from ORDER_VIEW where mname  like '%'|| #{mname} ||'%' order by result, oseq desc 
	</select>


	<update id="updateOrderResult">
		update TBL_ORDER_DETAIL set result='2' where odseq=#{odseq}
	</update>

 

 

 

 

제작 : macaronics.net - Developer  Jun Ho Choi

소스 :  https://github.com/braverokmc79/jsp_sin

 

${request.getContextPath() } 처리를 안한 부분이 있으므로 

루트 설정( http://macaronics.net/index.php/m01/jsp/view/1352)    및 server.xml  에서 DB 컨넥션 설정은 필수 설정이다.

 

 

 

jsp

 

about author

PHRASE

Level 60  라이트

강이나 못이 깊으면 물고기와 자라가 모여들고 산림이 무성하면 새와 짐승이 모여든다. 바른 정치를 행하는 곳에 백성들도 순종하는 것이다. -순자

댓글 ( 4)

댓글 남기기

작성