본문 바로가기
SPRING

230317_게시판

by 경 훈 2023. 3. 17.
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<meta charset="UTF-8">
<c:choose>
	<c:when test="${param.result == 'loginfail'}">
		<script type="text/javascript">
		Swal.fire({
			position: 'center',
			icon: 'error',
			title: '아이디 혹은 비밀번호가 틀림',
			showConfirmButton: false,
			timer: 1500
		})
		</script>
	</c:when>
</c:choose>
<title>Insert title here</title>
</head>
<header>
<h1 align="center">
UI 구현
</h1>
</header>
<nav class="navbar navbar-inverse">
	<div class="container-fluid">
	<div class="navbar-header">
		<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
			<span class="icon-bar"></span>
			<span class="icon-bar"></span>
			<span class="icon-bar"></span>                        
		</button>
	<a class="navbar-brand" href="/kim19_001/">HOME</a>
	</div> 
	<div class="collapse navbar-collapse" id="myNavbar">
	<ul class="nav navbar-nav">
		<li class="active">
		</li>
		<li class="dropdown">
		<a class="dropdown-toggle" data-toggle="dropdown" href="#">도서관리<span class="caret"></span></a>
			<ul class="dropdown-menu">
				<li><a href="bookin">입력</a></li>
				<li><a href="bookout">출력</a></li>
				<li><a href="booksearch">검색</a></li>
			</ul>
		</li>
		<li class="dropdown">
		<a class="dropdown-toggle" data-toggle="dropdown" href="#">멤버<span class="caret"></span></a>
			<ul class="dropdown-menu">
				<li><a href="memberin">회원가입</a></li>
				<li><a href="loginin">로그인</a></li>
			</ul>
		</li>
		<li class="dropdown">
		<a class="dropdown-toggle" data-toggle="dropdown" href="#">점수관리<span class="caret"></span></a>
			<ul class="dropdown-menu">
				<li><a href="scorein">점수입력</a></li>
				<li><a href="scoreout">점수출력</a></li>
				<li><a href="scoresearch">점수검색</a></li>
			</ul>
		</li>
	</ul>
	<ul class="nav navbar-nav navbar-right">
		<c:choose>
			<c:when test="${login==true && dto != null}">
				<li><a href="logout">${dto.id}님 환영합니다</a></li>
				<li><a href="logout"><span class="glyphicon glyphicon-log-out"></span>로그아웃</a></li>
			</c:when>
			<c:otherwise>
				<li><a href="memberin"><span class="glyphicon glyphicon-user"></span>회원가입</a></li>
				<li><a href="loginin"><span class="glyphicon glyphicon-log-in"></span>로그인</a></li>
			</c:otherwise>
		</c:choose>
	</ul>
	</div>
	</div>
</nav>
</html>

 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<h3 align="center">도서입력</h3>
	<form action="booksave" method="post" enctype="multipart/form-data">
		<table border="1" align="center">
			<tr>
				<th>도서명</th>
				<td><input type="text" name="bname"></td>
			</tr>
			<tr>
				<th>저자명</th>
				<td><input type="text" name="writer"></td>
			</tr>
			<tr>
				<th>분류</th>
				<td>
					<select name="part">
						<option value="IT">IT
						<option value="경제">경제
						<option value="인문">인문
					</select>
				</td>
			</tr>
			<tr>
				<th>출판사</th>
				<td><input type="text" name="publish"></td>
			</tr>
			<tr>
				<th>가격</th>
				<td><input type="text" name="price"></td>
			</tr>
			<tr>
				<th>이미지</th>
				<td><input type="file" name="poster"></td>
			</tr>
			<tr>
				<th>특징</th>
				<td>
					<textarea rows="10" cols="30" name="bigo"></textarea>
				</td>
			</tr>
			<tr>
				<td colspan="2" align="center">
					<input type="submit" value="전송">
					<input type="reset" value="초기화">
				</td>
			</tr>
		</table>
	</form>
</body>
</html>

 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<h3 align="center">도서출력</h3>
	<table border="1" align="center" width="800px">
		<tr>
			<th>책번호</th><th>도서명</th><th>가격</th>
			<th>책표지</th><th>조회수</th><th>비고</th>
		</tr>
		<c:forEach items="${list}" var="list">
		<tr>
			<td>${list.num}</td>
			<td>
				<a href="bookout2?bname=${list.bname}">${list.bname}</a>
			</td>
			<td>
			<fmt:formatNumber value="${list.price}" pattern="#,##0"/>
			</td>
			<td>
				<img src="resources/${list.poster}" width="30px" height="40px">
			</td>
			<td>${list.readcnt}</td>
			<td>
				<a href="delete?bname=${list.bname}">&#10060;</a>
				<a href="modify?bname=${list.bname}">&#9989;</a>
			</td>
		</tr>
		</c:forEach>
		<tr style="border-left:none;border-right:none;border-bottom:none">
			<td colspan="6" style="text-align: center;">
				<c:if test="${paging.startPage !=1}">
					<a href="bookout?nowPage=${paging.startPage-1}&cntPerPage=${paging.cntPerPage}">◀</a>
				</c:if>
				<c:forEach begin="${paging.startPage}" end="${paging.endPage}" var="p">
				<c:choose>
					<c:when test="${p == paging.nowPage}">
						<b><span style="color:red;font-family:bold">${p}</span></b>
					</c:when>
					<c:when test="${p != paging.nowPage}">
						<a href="bookout?nowPage=${p}&cntPerPage=${paging.cntPerPage}">${p}</a>
					</c:when>
				</c:choose>
				</c:forEach>
				<c:if test="${paging.endPage != paging.lastPage}">
					<a href="bookout?nowPage=${paging.endPage+1}&cntPerPage=${paging.cntPerPage}">▶</a>
				</c:if>
			</td>
		</tr>
	</table>
</body>
</html>

 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<h3 align="center">도서상세출력</h3>
	<table border="1" align="center">
		<tr>
			<th>도서명</th><th>책소개</th><th>책표지</th><th>조회수</th>
		</tr>
		<tr>
			<td>${dto.bname}</td>
			<td>${dto.bigo}</td>
			<td>
				<img src="resources/${dto.poster}" width="240px" height="320px">
			</td>
			<td>${dto.readcnt}</td>
		</tr>
	</table>
</body>
</html>

 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<h3 align="center">도서수정</h3>
	<form action="bookmodifysave" method="post" enctype="multipart/form-data">
		<table border="1" align="center">
			<tr>
				<th>도서명</th>
				<td><input type="text" name="bname" value="${dto.bname}" readonly></td>
			</tr>
			<tr>
				<th>저자명</th>
				<td><input type="text" name="writer" value="${dto.writer}"></td>
			</tr>
			<tr>
				<th>분류</th>
				<td>
					<select name="part">
						<option value="IT">IT
						<option value="경제">경제
						<option value="인문">인문
					</select>
				</td>
			</tr>
			<tr>
				<th>출판사</th>
				<td><input type="text" name="publish" value="${dto.publish}"></td>
			</tr>
			<tr>
				<th>가격</th>
				<td><input type="text" name="price" value="${dto.price}"></td>
			</tr>
			<tr>
				<th>이미지</th>
				<td>
					<input type="file" name="poster">
					<img src="resources/${dto.poster}" width="30px" height="40px">
				</td>
			</tr>
			<tr>
				<th>특징</th>
				<td>
					<textarea rows="10" cols="30" name="bigo">${dto.bigo}</textarea>
				</td>
			</tr>
			<tr>
				<td colspan="2" align="center">
					<input type="submit" value="수정">
					<input type="reset" value="초기화">
				</td>
			</tr>
		</table>
	</form>
</body>
</html>

 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<h3 align="center">도서검색</h3>
	<form action="booksearchout" method="post">
		<table border="1" align="center">
			<tr>
				<th>검색분류</th>
				<td>
					<select name="items">
						<option value="writer">저자
						<option value="publish">출판사
						<option value="part">분류
					</select>
				</td>
			</tr>
			<tr>
				<th>데이터</th>
				<td><input type="text" name="value"></td>
			</tr>
			<tr>
				<td colspan="2" align="center">
					<input type="submit" value="검색">
					<input type="reset" value="초기화">
				</td>
			</tr>
		</table>
	</form>
</body>
</html>

 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-3.6.0.min.js"></script>
<link rel="stylesheet" href="//code.jauery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code,jwuery.com/ui/1.12.1/jquery-ui.js"></script>
<meta charset="UTF-8">
<script type="text/javascript">
	$(function() {
		$("#checksubmit").click(function(){
			var id = $("#id").val();
			if(id==""){
				alert("아이디가 없음");
				$("#id").focus();
				return;
			}
			var vid = /^[a-zA-Z]{4,10}$/;
			if(!vid.test(id)) {
				alert("아이디는 대소문자 4~10글자만 가능합니다")
				$("#id").focus();
				return;
			}
			var idcheck =$("#idcheck").attr("idcheck");
			if(idcheck=="" || idcheck=="N") {
				alert("아이디 중복검사 해주세요!");
				$("#idcheck").focus();
				return;
			}
			$("#form1").submit();
		});
		$("#idcheck").click(function() {
			var id = $("#id").val();
			$.ajax({
				type:"post",
				async:true,
				url:"idcheck",
				dataType:"text",
				data:{"id":id},
				success:function(cnt) {
					if(cnt==0) {
						$('#idcheck').attr('idcheck','Y');
						alert("사용가능한 아이디")
					}
					else {
						$('#idcheck').attr('idcheck','N');
						alert("중복된 아이디")
					}
				}
			});
		});
	});
</script>
<title>Insert title here</title>
</head>
<body>
	<h3 align="center">회원가입</h3>
	<form action="membersave" method="post" id="form1">
		<table border="1" align="center">
			<tr>
				<th>아이디</th>
				<td>
					<input type="text" name="id" id="id">
					<input type="button" value="중복검사" id="idcheck" idcheck="">
				</td>
			</tr>
			<tr>
				<th>비밀번호</th>
				<td><input type="text" name="pw"></td>
			</tr>
			<tr>
				<th>이름</th>
				<td><input type="text" name="name"></td>
			</tr>
			<tr>
				<th>나이</th>
				<td><input type="text" name="age"></td>
			</tr>
			<tr>
				<th>전화번호</th>
				<td><input type="text" name="phone"></td>
			</tr>
			<tr>
				<th>주소</th>
				<td><input type="text" name="address"></td>
			</tr>
			<tr>
				<td colspan="2" align="center">
					<input type="button" value="검사후전송" id="checksubmit">
					<input type="reset" value="초기화">
				</td>
			</tr>
		</table>
	</form>
</body>
</html>

 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<h3 align="center">로그인</h3>
	<form action="logincheck" method="post">
		<table border="1" align="center">
			<tr>
				<th>아이디</th>
				<td><input type="text" name="id"></td>
			</tr>
			<tr>
				<th>비밀번호</th>
				<td><input type="password" name="pw"></td>
			</tr>
			<tr>
				<td colspan="2" align="center">
					<input type="submit" value="로그인">
					<a href="memberin"><input type="button" value="회원가입"></a>
				</td>
			</tr>
		</table>
	</form>
</body>
</html>

 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-3.6.0.min.js"></script>
<link rel="stylesheet" href="//code.jauery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code,jwuery.com/ui/1.12.1/jquery-ui.js"></script>
<meta charset="UTF-8">
<script type="text/javascript">
	$(function() {
		$("#checksubmit").click(function(){
			var num = $("#num").val();
			if(num==""){
				alert("학번 없음");
				$("#num").focus();
				return;
			}
			var vnum = /^[0-9]{8,8}$/;
			if(!vnum.test(num)) {
				alert("학번은 숫자로만 8자만 가능")
				$("#num").focus();
				return;
			}
			var name = $("#name").val();
			if(name==""){
				alert("이름 없음");
				$("#name").focus();
				return;
			}
			var vname = /^[가-힣]{2,5}$/;
			if(!vname.test(name)) {
				alert("이름은 2~5자 한글 가능")
				$("#name").focus();
				return;
			}
			var kor = $("#kor").val();
			if(kor==""){
				alert("국어점수 없음");
				$("#kor").focus();
				return;
			}
			var vkor = /^[0-9]{0,3}$/;
			if(!vkor.test(kor)) {
				alert("국어점수는 0~100 숫자 가능")
				$("#kor").focus();
				return;
			}
			var eng = $("#eng").val();
			if(eng==""){
				alert("영어점수 없음");
				$("#eng").focus();
				return;
			}
			var veng = /^[0-9]{0,3}$/;
			if(!veng.test(eng)) {
				alert("영어점수는 0~100 숫자 가능")
				$("#eng").focus();
				return;
			}
			var mat = $("#mat").val();
			if(mat==""){
				alert("수학점수 없음");
				$("#mat").focus();
				return;
			}
			var vmat = /^[0-9]{0,3}$/;
			if(!vmat.test(mat)) {
				alert("수학점수는 0~100 숫자 가능")
				$("#mat").focus();
				return;
			}
			$("#form1").submit();
		});
	});
</script>
<title>Insert title here</title>
</head>
<body>
	<h3 align="center">점수입력</h3>
	<form action="scoresave" method="post" id="form1">
		<table border="1" align="center">
			<tr>
				<th>학번</th>
				<td><input type="text" name="num" id="num"></td>
			</tr>
			<tr>
				<th>이름</th>
				<td><input type="text" name="name" id="name"></td>
			</tr>
			<tr>
				<th>국어</th>
				<td><input type="text" name="kor" id="kor"></td>
			</tr>
			<tr>
				<th>영어</th>
				<td><input type="text" name="eng" id="eng"></td>
			</tr>
			<tr>
				<th>수학</th>
				<td><input type="text" name="mat" id="mat"></td>
			</tr>
			<tr>
				<td colspan="2" align="center">
					<input type="button" value="검사후전송" id="checksubmit">
					<input type="reset" value="초기화">
				</td>
			</tr>
		</table>
	</form>
</body>
</html>

 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<h3 align="center">점수출력</h3>
	<table border="1" align="center" width="1200px">
		<tr>
			<th>학번</th><th>이름</th><th>국어</th>
			<th>영어</th><th>수학</th><th>총점</th>
			<th>평균</th><th>학점</th><th>비고</th>
		</tr>
		<c:forEach items="${list}" var="list">
		<tr>
			<td>${list.num}</td>
			<td>
				<a href="scoreout2?name=${list.name}">${list.name}</a>
			</td>
			<td>${list.kor}</td><td>${list.eng}</td><td>${list.mat}</td>
			<td>${list.tot}</td><td>${list.avg}</td><td>${list.hak}</td>
			<td>
				<a href="scoredelete?name=${list.name}">&#10060;</a>
				<a href="scoremodify2?name=${list.name}">&#9989;</a>
			</td>
		</tr>
		</c:forEach>
		<tr style="border-left:none;border-right:none;border-bottom:none">
			<td colspan="9" style="text-align: center;">
				<c:if test="${paging.startPage !=1}">
					<a href="scoreout?nowPage=${paging.startPage-1}&cntPerPage=${paging.cntPerPage}">◀</a>
				</c:if>
				<c:forEach begin="${paging.startPage}" end="${paging.endPage}" var="p">
				<c:choose>
					<c:when test="${p == paging.nowPage}">
						<b><span style="color:red;font-family:bold">${p}</span></b>
					</c:when>
					<c:when test="${p != paging.nowPage}">
						<a href="scoreout?nowPage=${p}&cntPerPage=${paging.cntPerPage}">${p}</a>
					</c:when>
				</c:choose>
				</c:forEach>
				<c:if test="${paging.endPage != paging.lastPage}">
					<a href="scoreout?nowPage=${paging.endPage+1}&cntPerPage=${paging.cntPerPage}">▶</a>
				</c:if>
			</td>
		</tr>
	</table>
</body>
</html>

 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<h3 align="center">점수인적사항출력</h3>
	<table border="1" align="center" width="1200px">
		<tr>
			<th>이름</th><th>나이</th><th>전화번호</th><th>주소</th>
		</tr>
		<tr>
			<td>${dto.name}</td><td>${dto.age}</td>
			<td>${dto.phone}</td><td>${dto.address}</td>
		</tr>
	</table>
</body>
</html>

 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-3.6.0.min.js"></script>
<link rel="stylesheet" href="//code.jauery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code,jwuery.com/ui/1.12.1/jquery-ui.js"></script>
<meta charset="UTF-8">
<script type="text/javascript">
	$(function() {
		$("#checksubmit").click(function(){
			var num = $("#num").val();
			if(num==""){
				alert("학번 없음");
				$("#num").focus();
				return;
			}
			var vnum = /^[0-9]{8,8}$/;
			if(!vnum.test(num)) {
				alert("학번은 숫자로만 8자만 가능")
				$("#num").focus();
				return;
			}
			var name = $("#name").val();
			if(name==""){
				alert("이름 없음");
				$("#name").focus();
				return;
			}
			var vname = /^[가-힣]{2,5}$/;
			if(!vname.test(name)) {
				alert("이름은 2~5자 한글 가능")
				$("#name").focus();
				return;
			}
			var kor = $("#kor").val();
			if(kor==""){
				alert("국어점수 없음");
				$("#kor").focus();
				return;
			}
			var vkor = /^[0-9]{0,3}$/;
			if(!vkor.test(kor)) {
				alert("국어점수는 0~100 숫자 가능")
				$("#kor").focus();
				return;
			}
			var eng = $("#eng").val();
			if(eng==""){
				alert("영어점수 없음");
				$("#eng").focus();
				return;
			}
			var veng = /^[0-9]{0,3}$/;
			if(!veng.test(eng)) {
				alert("영어점수는 0~100 숫자 가능")
				$("#eng").focus();
				return;
			}
			var mat = $("#mat").val();
			if(mat==""){
				alert("수학점수 없음");
				$("#mat").focus();
				return;
			}
			var vmat = /^[0-9]{0,3}$/;
			if(!vmat.test(mat)) {
				alert("수학점수는 0~100 숫자 가능")
				$("#mat").focus();
				return;
			}
			$("#form1").submit();
		});
	});
</script>
<title>Insert title here</title>
</head>
<body>
	<h3 align="center">점수수정폼</h3>
	<form action="scoremodifysave" method="post" id="form1">
		<table border="1" align="center">
			<tr>
				<th>학번</th>
				<td><input type="text" name="num" id="num" value="${dto1.num}"></td>
			</tr>
			<tr>
				<th>이름</th>
				<td><input type="text" name="name" id="name" value="${dto1.name}" readonly></td>
			</tr>
			<tr>
				<th>국어</th>
				<td><input type="text" name="kor" id="kor" value="${dto1.kor}"></td>
			</tr>
			<tr>
				<th>영어</th>
				<td><input type="text" name="eng" id="eng" value="${dto1.eng}"></td>
			</tr>
			<tr>
				<th>수학</th>
				<td><input type="text" name="mat" id="mat" value="${dto1.mat}"></td>
			</tr>
			<tr>
				<td colspan="2" align="center">
					<input type="button" value="검사후수정" id="checksubmit">
					<input type="reset" value="초기화">
				</td>
			</tr>
		</table>
	</form>
</body>
</html>

 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<h3 align="center">점수검색</h3>
	<form action="scoresearchout" method="post">
		<table border="1" align="center">
			<tr>
				<th>검색분류</th>
				<td>
					<select name="items">
						<option value="num">학번
						<option value="name">이름
					</select>
				</td>
			</tr>
			<tr>
				<th>데이터</th>
				<td><input type="text" name="value"></td>
			</tr>
			<tr>
				<td colspan="2" align="center">
					<input type="submit" value="검색">
					<input type="reset" value="초기화">
				</td>
			</tr>
		</table>
	</form>
</body>
</html>

 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
"http://tiles.apache.org/dtds/tiles-config_2_0.dtd">
<tiles-definitions>
	<definition name="baseLayout" template="/WEB-INF/views/layout.jsp">
		<put-attribute name="title" value=""/>
		<put-attribute name="top" value="/WEB-INF/views/top.jsp"/>
		<put-attribute name="body" value=""/>
		<put-attribute name="footer" value="/WEB-INF/views/footer.jsp"/>
	</definition>	   
	<definition name="main" extends="baseLayout">
		<put-attribute name="title" value="메인화면"/>
		<put-attribute name="body" value="/WEB-INF/views/main.jsp"/>
	</definition>  
	<definition name="bookinput" extends="baseLayout">
		<put-attribute name="title" value="도서입력"/>
		<put-attribute name="body" value="/WEB-INF/views/book/bookinput.jsp"/>
	</definition>  
	<definition name="bookoutput" extends="baseLayout">
		<put-attribute name="title" value="도서출력"/>
		<put-attribute name="body" value="/WEB-INF/views/book/bookoutput.jsp"/>
	</definition>  
		<definition name="bookoutput2" extends="baseLayout">
		<put-attribute name="title" value="도서상세출력"/>
		<put-attribute name="body" value="/WEB-INF/views/book/bookoutput2.jsp"/>
	</definition>  
	<definition name="booksearch" extends="baseLayout">
		<put-attribute name="title" value="도서검색"/>
		<put-attribute name="body" value="/WEB-INF/views/book/booksearch.jsp"/>
	</definition>  
	<definition name="bookmodify" extends="baseLayout">
		<put-attribute name="title" value="도서수정"/>
		<put-attribute name="body" value="/WEB-INF/views/book/bookmodify.jsp"/>
	</definition>  
	<definition name="memberinput" extends="baseLayout">
		<put-attribute name="title" value="회원가입"/>
		<put-attribute name="body" value="/WEB-INF/views/member/memberinput.jsp"/>
	</definition>  
	<definition name="logininput" extends="baseLayout">
		<put-attribute name="title" value="로그인폼"/>
		<put-attribute name="body" value="/WEB-INF/views/member/logininput.jsp"/>
	</definition>  
	<definition name="scoreinput" extends="baseLayout">
		<put-attribute name="title" value="점수입력"/>
		<put-attribute name="body" value="/WEB-INF/views/score/scoreinput.jsp"/>
	</definition>  
	<definition name="scoreoutput" extends="baseLayout">
		<put-attribute name="title" value="점수출력"/>
		<put-attribute name="body" value="/WEB-INF/views/score/scoreoutput.jsp"/>
	</definition>  
	<definition name="scoreoutput2" extends="baseLayout">
		<put-attribute name="title" value="점수출력2"/>
		<put-attribute name="body" value="/WEB-INF/views/score/scoreoutput2.jsp"/>
	</definition>  
	<definition name="scoremodifyform" extends="baseLayout">
		<put-attribute name="title" value="점수수정폼2"/>
		<put-attribute name="body" value="/WEB-INF/views/score/scoremodifyform.jsp"/>
	</definition>  
	<definition name="scoresearch" extends="baseLayout">
		<put-attribute name="title" value="점수검색"/>
		<put-attribute name="body" value="/WEB-INF/views/score/scoresearch.jsp"/>
	</definition>  
</tiles-definitions>

package com.ezen.kim19_001.book;

public class BookDTO {
	int num;
	String bname,writer,part,publish;
	int price;
	String poster,bigo;
	int readcnt,groups,step,indent;
	public BookDTO() {
	}
	public BookDTO(int num, String bname, String writer, String part, String publish, int price, String poster,
			String bigo, int readcnt, int groups, int step, int indent) {
		super();
		this.num = num;
		this.bname = bname;
		this.writer = writer;
		this.part = part;
		this.publish = publish;
		this.price = price;
		this.poster = poster;
		this.bigo = bigo;
		this.readcnt = readcnt;
		this.groups = groups;
		this.step = step;
		this.indent = indent;
	}
	public int getNum() {
		return num;
	}
	public void setNum(int num) {
		this.num = num;
	}
	public String getBname() {
		return bname;
	}
	public void setBname(String bname) {
		this.bname = bname;
	}
	public String getWriter() {
		return writer;
	}
	public void setWriter(String writer) {
		this.writer = writer;
	}
	public String getPart() {
		return part;
	}
	public void setPart(String part) {
		this.part = part;
	}
	public String getPublish() {
		return publish;
	}
	public void setPublish(String publish) {
		this.publish = publish;
	}
	public int getPrice() {
		return price;
	}
	public void setPrice(int price) {
		this.price = price;
	}
	public String getPoster() {
		return poster;
	}
	public void setPoster(String poster) {
		this.poster = poster;
	}
	public String getBigo() {
		return bigo;
	}
	public void setBigo(String bigo) {
		this.bigo = bigo;
	}
	public int getReadcnt() {
		return readcnt;
	}
	public void setReadcnt(int readcnt) {
		this.readcnt = readcnt;
	}
	public int getGroups() {
		return groups;
	}
	public void setGroups(int groups) {
		this.groups = groups;
	}
	public int getStep() {
		return step;
	}
	public void setStep(int step) {
		this.step = step;
	}
	public int getIndent() {
		return indent;
	}
	public void setIndent(int indent) {
		this.indent = indent;
	}
}

 

package com.ezen.kim19_001.book;

public class PageDTO {
	private int nowPage, startPage, endPage, total, cntPerPage, lastPage, start, end;
	private int cntPage=10;  
	public int getCntPage() {
	return cntPage;
	}
	public void setCntPage(int cntPage) {
		this.cntPage = cntPage;
	}
	public PageDTO() {
	}
	public PageDTO(int total, int nowPage, int cntPerPage) {
		setNowPage(nowPage);
		setCntPerPage(cntPerPage);
		setTotal(total);
		calcLastPage(getTotal(), getCntPerPage());
		calcStartEndPage(getNowPage(), cntPage);
		calcStartEnd(getNowPage(), getCntPerPage());
	}   
	public void calcLastPage(int total, int cntPerPage) {
		setLastPage((int) Math.ceil((double)total / (double)cntPerPage));
	}   
	public void calcStartEndPage(int nowPage, int cntPage) {
		setEndPage(((int)Math.ceil((double)nowPage / (double)cntPage)) * cntPage);
		if (getLastPage() < getEndPage()) {
			setEndPage(getLastPage());
		}
		setStartPage(getEndPage() - cntPage + 1);
		if(getStartPage()<1) {
			setStartPage(1);
		}
	}
	public void calcStartEnd(int nowPage, int cntPerPage) {
	setEnd(nowPage * cntPerPage);
	setStart(getEnd() - cntPerPage + 1);
	}
	public int getNowPage() {
	return nowPage;
	}
	public void setNowPage(int nowPage) {
	this.nowPage = nowPage;
	}
	public int getStartPage() {
	return startPage;
	}
	public void setStartPage(int startPage) {
	this.startPage = startPage;
	}
	public int getEndPage() {
	return endPage;
	}
	public void setEndPage(int endPage) {
	this.endPage = endPage;
	}
	public int getTotal() {
	return total;
	}
	public void setTotal(int total) {
	this.total = total;
	}
	public int getCntPerPage() {
	return cntPerPage;
	}
	public void setCntPerPage(int cntPerPage) {
	this.cntPerPage = cntPerPage;
	}
	public int getLastPage() {
	return lastPage;
	}
	public void setLastPage(int lastPage) {
	this.lastPage = lastPage;
	}
	public int getStart() {
	return start;
	}
	public void setStart(int start) {
	this.start = start;
	}
	public int getEnd() {
	return end;
	}
	public void setEnd(int end) {
	this.end = end;
	}
}

 

package com.ezen.kim19_001.book;

import java.util.ArrayList;

public interface Service1 {
	public void insert(String bname,String writer,String part,String publish,int price,String poster,String bigo);
	public int cntnotice();
	public ArrayList<BookDTO> out(PageDTO dto);
	public void readcnt(String bname);
	public BookDTO out2(String bname);
	public void delete(String bname);
	public BookDTO modify2(String bname);
	public void modifyupdate(String bname,String writer,String part,String publish,int price,String poster,String bigo);
	public ArrayList<BookDTO> searchwriter(String value);
	public ArrayList<BookDTO> searchpublish(String value);
	public ArrayList<BookDTO> searchpart(String value);
}

 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
    PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
    "https://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.ezen.kim19_001.book.Service1">
	<insert id="insert">
		insert into db03171 (num,bname,writer,part,publish,price,poster,bigo,groups) 
		values (num0317_SEQ.nextval,#{param1},#{param2},#{param3},#{param4},#{param5},#{param6},#{param7},num0317_SEQ.currval)
	</insert>
	<select id="cntnotice" resultType="int">
		select count(*) from db03171
	</select>
	<select id="out" resultType="com.ezen.kim19_001.book.BookDTO">
		select * from (
		select rownum rn,A.* from(  
		select * from db03171)A)
		where rn between #{start} AND #{end}
	</select>
	<update id="readcnt">
		update db03171 set readcnt = readcnt+1 where bname = #{param1}
	</update>
	<select id="out2" resultType="com.ezen.kim19_001.book.BookDTO">
		select * from db03171 where bname = #{param1}
	</select>
	<delete id="delete">
		delete from db03171 where bname = #{param1}
	</delete>
	<select id="modify2" resultType="com.ezen.kim19_001.book.BookDTO">
		select * from db03171 where bname = #{param1}
	</select>
	<update id="modifyupdate">
		update db03171 set writer=#{param2},part=#{param3},publish=#{param4},
		price=#{param5},poster=#{param6},bigo=#{param7} where bname=#{param1}
	</update>
	<select id="searchwriter" resultType="com.ezen.kim19_001.book.BookDTO">
		select * from db03171 where writer like '%'||#{param1}||'%'
	</select>
	<select id="searchpublish" resultType="com.ezen.kim19_001.book.BookDTO">
		select * from db03171 where publish like '%'||#{param1}||'%'
	</select>
	<select id="searchpart" resultType="com.ezen.kim19_001.book.BookDTO">
		select * from db03171 where part like '%'||#{param1}||'%'
	</select>
</mapper>

 

package com.ezen.kim19_001.book;

import java.io.File;
import java.util.ArrayList;

import javax.servlet.http.HttpServletRequest;

import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;


@Controller
public class BookController {
	@Autowired
	SqlSession sqlsession;
	@RequestMapping(value="/bookin")
	public String ko1() {
		return "bookinput";
	}
	@RequestMapping(value="/booksave")
	public String ko2(MultipartHttpServletRequest mul) throws Exception {
		String bname = mul.getParameter("bname");
		String writer = mul.getParameter("writer");
		String part = mul.getParameter("part");
		String publish = mul.getParameter("publish");
		int price = Integer.parseInt(mul.getParameter("price"));
		MultipartFile mf = mul.getFile("poster");
		String poster = mf.getOriginalFilename();
		String path = "C:\\12월국비\\spring\\day19_001\\src\\main\\webapp\\resources";
		mf.transferTo(new File(path,poster));
		String bigo = mul.getParameter("bigo");
		Service1 ss1 = sqlsession.getMapper(Service1.class);
		ss1.insert(bname,writer,part,publish,price,poster,bigo);
		return "redirect:bookin";
	}
	@RequestMapping(value="/bookout")
	public String ko3(HttpServletRequest request,PageDTO dto,Model mo) {
		String nowPage = request.getParameter("nowPage");
		String cntPerPage = request.getParameter("cntPerPage");
		Service1 ss1 = sqlsession.getMapper(Service1.class);
		int total = ss1.cntnotice();
		if(nowPage==null && cntPerPage == null) {
			nowPage = "1";
			cntPerPage = "10";
		}
		else if(nowPage==null) {
			nowPage = "1";
		}
		else if(cntPerPage == null) {
			cntPerPage = "10";
		}
		dto = new PageDTO(total,Integer.parseInt(nowPage),Integer.parseInt(cntPerPage));
		mo.addAttribute("paging", dto);
		ArrayList<BookDTO> list = ss1.out(dto);
		mo.addAttribute("list", list);
		return "bookoutput";
	}
	@RequestMapping(value="/bookout2")
	public String ko4(HttpServletRequest request,Model mo) {
		String bname = request.getParameter("bname");
		Service1 ss1 = sqlsession.getMapper(Service1.class);
		ss1.readcnt(bname);
		BookDTO dto = ss1.out2(bname);
		mo.addAttribute("dto", dto);
		return "bookoutput2";
	}
	@RequestMapping(value="/delete")
	public String ko5(HttpServletRequest request) {
		String bname = request.getParameter("bname");
		Service1 ss1 = sqlsession.getMapper(Service1.class);
		ss1.delete(bname);
		return "redirect:bookout";
	}
	@RequestMapping(value="/modify")
	public String ko6(HttpServletRequest request,Model mo) {
		String bname = request.getParameter("bname");
		Service1 ss1 = sqlsession.getMapper(Service1.class);
		BookDTO dto = ss1.modify2(bname);
		mo.addAttribute("dto", dto);
		return "bookmodify";
	}
	@RequestMapping(value="/bookmodifysave")
	public String ko7(MultipartHttpServletRequest mul) throws Exception {
		String bname = mul.getParameter("bname");
		String writer = mul.getParameter("writer");
		String part = mul.getParameter("part");
		String publish = mul.getParameter("publish");
		int price = Integer.parseInt(mul.getParameter("price"));
		MultipartFile mf = mul.getFile("poster");
		String poster = mf.getOriginalFilename();
		String path = "C:\\12월국비\\spring\\day19_001\\src\\main\\webapp\\resources";
		mf.transferTo(new File(path,poster));
		String bigo = mul.getParameter("bigo");
		Service1 ss1 = sqlsession.getMapper(Service1.class);
		ss1.modifyupdate(bname,writer,part,publish,price,poster,bigo);
		return "redirect:bookout";
	}
	@RequestMapping(value="/booksearch")
	public String ko8() {
		return "booksearch";
	}
	@RequestMapping(value="/booksearchout")
	public String ko9(HttpServletRequest request,Model mo) {
		String items = request.getParameter("items");
		String value = request.getParameter("value");
		Service1 ss1 = sqlsession.getMapper(Service1.class);
		ArrayList<BookDTO> list;
		if(items.equals("writer")) {
			list = ss1.searchwriter(value);
		}
		else if(items.equals("publish")) {
			list = ss1.searchpublish(value);
		}
		else {
			list = ss1.searchpart(value);
		}
		mo.addAttribute("list", list);
		return "bookoutput";
	}
}

package com.ezen.kim19_001.member;

public class MemberDTO {
	String id,pw,name;
	int age;
	String phone,address;
	public MemberDTO() {
	}
	public MemberDTO(String id, String pw, String name, int age, String phone, String address) {
		super();
		this.id = id;
		this.pw = pw;
		this.name = name;
		this.age = age;
		this.phone = phone;
		this.address = address;
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getPw() {
		return pw;
	}
	public void setPw(String pw) {
		this.pw = pw;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getAge() {
		return age;
	}
	public void setAge(int age) {
		this.age = age;
	}
	public String getPhone() {
		return phone;
	}
	public void setPhone(String phone) {
		this.phone = phone;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
}

 

package com.ezen.kim19_001.member;

public interface Service2 {
	public void insert(String id,String pw,String name,int age,String phone,String address);
	public String idcheck(String id);
	public MemberDTO logincheck(String id,String pw);
}

 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
    PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
    "https://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.ezen.kim19_001.member.Service2">
	<insert id="insert">
		insert into db03172 values (#{param1},#{param2},#{param3},#{param4},#{param5},#{param6})
	</insert>
	<select id="idcheck" resultType="String">
		select count(*) from db03172 where id = #{param1}
	</select>
	<select id="logincheck" resultType="com.ezen.kim19_001.member.MemberDTO">
		select * from db03172 where id = #{param1} and pw = #{param2}
	</select>
</mapper>

 

package com.ezen.kim19_001.member;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

@Controller
public class MemberController {
	@Autowired
	SqlSession sqlsession;
	@RequestMapping(value="/memberin")
	public String ko1() {
		return "memberinput";
	}
	@RequestMapping(value="/membersave")
	public String ko2(HttpServletRequest request) {
		String id = request.getParameter("id");
		String pw = request.getParameter("pw");
		String name = request.getParameter("name");
		int age = Integer.parseInt(request.getParameter("age"));
		String phone = request.getParameter("phone");
		String address = request.getParameter("address");
		Service2 ss2 = sqlsession.getMapper(Service2.class);
		ss2.insert(id,pw,name,age,phone,address);
		return "redirect:memberin";
	}
	@ResponseBody
	@RequestMapping(value="/idcheck")
	public String ko3(String id) {
		Service2 ss2 = sqlsession.getMapper(Service2.class);
		String cnt = ss2.idcheck(id);
		return cnt;
	}
	@RequestMapping(value="/loginin")
	public String ko4() {
		return "logininput";
	}
	@RequestMapping(value="/logincheck")
	public String ko5(HttpServletRequest request,RedirectAttributes ra) {
		String id = request.getParameter("id");
		String pw = request.getParameter("pw");
		Service2 ss2 = sqlsession.getMapper(Service2.class);
		MemberDTO dto =ss2.logincheck(id,pw);
		HttpSession hs = request.getSession();
		if(dto != null) {
			hs.setAttribute("dto", dto);
			hs.setAttribute("login", true);
		}
		else {
			hs.setAttribute("login", false);
			ra.addAttribute("result", "loginfail");
			return "redirect:loginin";
		}
		return "main";
	}
	@RequestMapping(value="/logout")
	public String ko5(HttpServletRequest request) {
		Service2 ss2 = sqlsession.getMapper(Service2.class);
		HttpSession hs = request.getSession();
		hs.removeAttribute("dto");
		hs.removeAttribute("login");
		hs.setAttribute("login", false);
		return "main";
	}
}

package com.ezen.kim19_001.score;

public class ScoreDTO {
	int num;
	String name;
	int kor,eng,mat,tot;
	double avg;
	String hak;
	public ScoreDTO() {
	}
	public ScoreDTO(int num, String name, int kor, int eng, int mat, int tot, double avg, String hak) {
		super();
		this.num = num;
		this.name = name;
		this.kor = kor;
		this.eng = eng;
		this.mat = mat;
		this.tot = tot;
		this.avg = avg;
		this.hak = hak;
	}
	public int getNum() {
		return num;
	}
	public void setNum(int num) {
		this.num = num;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getKor() {
		return kor;
	}
	public void setKor(int kor) {
		this.kor = kor;
	}
	public int getEng() {
		return eng;
	}
	public void setEng(int eng) {
		this.eng = eng;
	}
	public int getMat() {
		return mat;
	}
	public void setMat(int mat) {
		this.mat = mat;
	}
	public int getTot() {
		return tot;
	}
	public void setTot(int tot) {
		this.tot = tot;
	}
	public double getAvg() {
		return avg;
	}
	public void setAvg(double avg) {
		this.avg = avg;
	}
	public String getHak() {
		return hak;
	}
	public void setHak(String hak) {
		this.hak = hak;
	}
}

 

package com.ezen.kim19_001.score;

public class PageDTO {
	private int nowPage, startPage, endPage, total, cntPerPage, lastPage, start, end;
	private int cntPage=5;  
	public int getCntPage() {
	return cntPage;
	}
	public void setCntPage(int cntPage) {
		this.cntPage = cntPage;
	}
	public PageDTO() {
	}
	public PageDTO(int total, int nowPage, int cntPerPage) {
		setNowPage(nowPage);
		setCntPerPage(cntPerPage);
		setTotal(total);
		calcLastPage(getTotal(), getCntPerPage());
		calcStartEndPage(getNowPage(), cntPage);
		calcStartEnd(getNowPage(), getCntPerPage());
	}   
	public void calcLastPage(int total, int cntPerPage) {
		setLastPage((int) Math.ceil((double)total / (double)cntPerPage));
	}   
	public void calcStartEndPage(int nowPage, int cntPage) {
		setEndPage(((int)Math.ceil((double)nowPage / (double)cntPage)) * cntPage);
		if (getLastPage() < getEndPage()) {
			setEndPage(getLastPage());
		}
		setStartPage(getEndPage() - cntPage + 1);
		if(getStartPage()<1) {
			setStartPage(1);
		}
	}
	public void calcStartEnd(int nowPage, int cntPerPage) {
	setEnd(nowPage * cntPerPage);
	setStart(getEnd() - cntPerPage + 1);
	}
	public int getNowPage() {
	return nowPage;
	}
	public void setNowPage(int nowPage) {
	this.nowPage = nowPage;
	}
	public int getStartPage() {
	return startPage;
	}
	public void setStartPage(int startPage) {
	this.startPage = startPage;
	}
	public int getEndPage() {
	return endPage;
	}
	public void setEndPage(int endPage) {
	this.endPage = endPage;
	}
	public int getTotal() {
	return total;
	}
	public void setTotal(int total) {
	this.total = total;
	}
	public int getCntPerPage() {
	return cntPerPage;
	}
	public void setCntPerPage(int cntPerPage) {
	this.cntPerPage = cntPerPage;
	}
	public int getLastPage() {
	return lastPage;
	}
	public void setLastPage(int lastPage) {
	this.lastPage = lastPage;
	}
	public int getStart() {
	return start;
	}
	public void setStart(int start) {
	this.start = start;
	}
	public int getEnd() {
	return end;
	}
	public void setEnd(int end) {
	this.end = end;
	}
}

 

package com.ezen.kim19_001.score;

import java.util.ArrayList;

import com.ezen.kim19_001.member.MemberDTO;

public interface Service3 {
	public void insert(int num,String name,int kor,int eng,int mat,int tot,double avg,String hak);
	public int cntnotice();
	public ArrayList<ScoreDTO> out(PageDTO dto);
	public MemberDTO out2(String name);
	public void delete(String name);
	public ScoreDTO modify(String name);
	public void modifysave(int num,String name,int kor,int eng,int mat,int tot,double avg,String hak);
	public ArrayList<ScoreDTO> searchnum(String value);
	public ArrayList<ScoreDTO> searchname(String value);
}

 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
    PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
    "https://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.ezen.kim19_001.score.Service3">
	<insert id="insert">
		insert into db03173 values (#{param1},#{param2},#{param3},#{param4},#{param5},#{param6},#{param7},#{param8})
	</insert>
	<select id="cntnotice" resultType="int">
		select count(*) from db03173
	</select>
	<select id="out" resultType="com.ezen.kim19_001.score.ScoreDTO">
		select * from (
		select rownum rn,A.* from(  
		select * from db03173 order by tot desc)A)
		where rn between #{start} AND #{end}
	</select>
	<select id="out2" resultType="com.ezen.kim19_001.member.MemberDTO">
		select * from db03172 where name = #{param1}
	</select>
	<delete id="delete">
		delete from db03173 where name = #{param1}
	</delete>
	<select id="scoremodify" resultType="com.ezen.kim19_001.score.ScoreDTO">
		select * from db03173 where name = #{param1}
	</select>
	<update id="modifysave">
		update db03173 set num =#{param1},kor=#{param3},eng=#{param4},
		mat=#{param5},tot=#{param6},avg=#{param7},hak=#{param8} 
		where name = #{param2}
	</update>
	<select id="searchnum" resultType="com.ezen.kim19_001.score.ScoreDTO">
		select * from db03173 where num like '%'||#{param1}||'%'
	</select>
	<select id="searchname" resultType="com.ezen.kim19_001.score.ScoreDTO">
		select * from db03173 where name like '%'||#{param1}||'%'
	</select>
</mapper>

 

package com.ezen.kim19_001.score;

import java.util.ArrayList;

import javax.servlet.http.HttpServletRequest;

import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.ezen.kim19_001.member.MemberDTO;

@Controller
public class ScoreController {
	@Autowired
	SqlSession sqlsession;
	@RequestMapping(value="/scorein")
	public String ko1() {
		return "scoreinput";
	}
	@RequestMapping(value="/scoresave")
	public String ko2(HttpServletRequest request) {
		int num = Integer.parseInt(request.getParameter("num"));
		String name = request.getParameter("name");
		int kor = Integer.parseInt(request.getParameter("kor"));
		int eng = Integer.parseInt(request.getParameter("eng"));
		int mat = Integer.parseInt(request.getParameter("mat"));
		int tot = kor+eng+mat;
		double avg = (double)tot/3;
		String hak = "";
		if(avg>=90) hak="A";
		else if(avg>=80) hak="B";
		else if(avg>=70) hak="C";
		else if(avg>=60) hak="D";
		else hak="F";
		Service3 ss3 = sqlsession.getMapper(Service3.class);
		ss3.insert(num,name,kor,eng,mat,tot,avg,hak);
		return "scoreinput";
	}
	@RequestMapping(value="/scoreout")
	public String ko3(HttpServletRequest request,PageDTO dto,Model mo) {
		String nowPage = request.getParameter("nowPage");
		String cntPerPage = request.getParameter("cntPerPage");
		Service3 ss3 = sqlsession.getMapper(Service3.class);
		int total = ss3.cntnotice();
		if(nowPage==null && cntPerPage == null) {
			nowPage = "1";
			cntPerPage = "5";
		}
		else if(nowPage==null) {
			nowPage = "1"; 
		}
		else if(cntPerPage == null) {
			cntPerPage = "5";
		}
		dto = new PageDTO(total,Integer.parseInt(nowPage),Integer.parseInt(cntPerPage));
		mo.addAttribute("paging",dto);
		ArrayList<ScoreDTO> list = ss3.out(dto);
		mo.addAttribute("list", list);
		return "scoreoutput";
	}
	@RequestMapping(value="/scoreout2")
	public String ko4(HttpServletRequest request,Model mo) {
		String name = request.getParameter("name");
		Service3 ss3 = sqlsession.getMapper(Service3.class);
		MemberDTO dto = ss3.out2(name);
		mo.addAttribute("dto", dto);
		return "scoreoutput2";
	}
	@RequestMapping(value="/scoredelete")
	public String ko5(HttpServletRequest request) {
		String name = request.getParameter("name");
		Service3 ss3 = sqlsession.getMapper(Service3.class);
		ss3.delete(name);
		return "redirect:scoreout";
	}
	@RequestMapping(value="/scoremodify2")
	public String ko6(HttpServletRequest request,Model mo) {
		String name = request.getParameter("name");
		Service3 ss3 = sqlsession.getMapper(Service3.class);
		ScoreDTO dto1 =ss3.modify(name);
		mo.addAttribute("dto1", dto1);
		return "scoremodifyform";
	}
	@RequestMapping(value="/scoremodifysave")
	public String ko7(HttpServletRequest request) {
		int num = Integer.parseInt(request.getParameter("num"));
		String name = request.getParameter("name");
		int kor = Integer.parseInt(request.getParameter("kor"));
		int eng = Integer.parseInt(request.getParameter("eng"));
		int mat = Integer.parseInt(request.getParameter("mat"));
		int tot = kor+eng+mat;
		double avg = (double)tot/3;
		String hak = "";
		if(avg>=90) hak="A";
		else if(avg>=80) hak="B";
		else if(avg>=70) hak="C";
		else if(avg>=60) hak="D";
		else hak="F";
		Service3 ss3 = sqlsession.getMapper(Service3.class);
		ss3.modifysave(num,name,kor,eng,mat,tot,avg,hak);
		return "redirect:scoreout";
	}
	@RequestMapping(value="/scoresearch")
	public String ko8() {
		return "scoresearch";
	}
	@RequestMapping(value="/scoresearchout")
	public String ko9(HttpServletRequest request,Model mo) {
		String items = request.getParameter("items");
		String value = request.getParameter("value");
		Service3 ss3 = sqlsession.getMapper(Service3.class);
		ArrayList<ScoreDTO> list;
		if(items.equals("num")) {
			list = ss3.searchnum(value);
		}
		else {
			list = ss3.searchname(value);
		}
		mo.addAttribute("list", list);
		return "scoreoutput";
	}
}

 

'SPRING' 카테고리의 다른 글

230320_Git  (0) 2023.03.20
230316_게시판  (0) 2023.03.16
230315_게시판  (0) 2023.03.15
230314_게시판  (0) 2023.03.14
230313_게시판  (0) 2023.03.13

댓글