<%@ 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>
<c:choose>
<c:when test="${param.result == 'loginfail'}">
<script type="text/javascript">
alert("아이디와 비밀번호가 틀립니다.")
</script>
</c:when>
</c:choose>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<header>
<h1 align="center">
통합 관리 프로그램 v1.3
</h1>
</header>
</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="/kim14_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="scorein">점수입력</a></li>
<li><a href="scoreout">점수출력</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="payin">급여입력</a></li>
<li><a href="payout">급여출력</a></li>
<li><a href="paysearch">급여검색</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="bookin">도서입력</a></li>
<li><a href="bookout">도서출력</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="member"><span class="glyphicon glyphicon-user"></span>회원가입</a></li>
<li><a href="login"><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>
<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(){
$("#reset1").click(function(){
$("#id").val('');
$("#pw").val('');
$("#name").val('');
$("#jumin").val('');
$("#phone").val('');
$("#bigo").val('');
});
$("#idcheck1").click(function(){
var id = $("#id").val();
$.ajax ({
type:"post",
async:true,
dataType:"text",
url:"idcheck",
data:{"id":id},
success:function(cnt) {
if(cnt==0) {
alert("사용 가능한 아이디입니다.")
}
else {
alert("중복된 아이디입니다.")
}
},
error:function(request,status,error){
alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error);
}
});
});
$("#load1").click(function(){
$.ajax ({
type:"post",
dataType:"json",
url:"memberout",
success:function(data){
var htm = "<table border='1' align='center' width='800px'>";
htm+= "<tr>";
htm+= "<th>아이디</th><th>이름</th><th>나이</th><th>성별</th><th>전화</th><th>취미</th><th>인사말</th>";
htm+= "</tr>";
for(var i in data) {
htm+= "<tr>";
htm+= "<td>"+data[i].id+"</td>";
htm+= "<td>"+data[i].name+"</td>";
htm+= "<td>"+data[i].age+"</td>";
htm+= "<td>"+data[i].gender+"</td>";
htm+= "<td>"+data[i].phone+"</td>";
htm+= "<td>"+data[i].hobby+"</td>";
htm+= "<td>"+data[i].bigo+"</td>";
htm+= "</tr>";
}
htm+="</table>";
$("#out").html(htm);
},
error:function(request,status,error){
alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error);
}
});
});
});
</script>
<title>Insert title here</title>
</head>
<body>
<h3 align="center">회원가입</h3>
<form action="membersave">
<table border="1" align="center">
<tr>
<th>아이디</th>
<td>
<input type="text" name="id" id="id">
<input type="button" value="중복체크" id="idcheck1">
</td>
</tr>
<tr>
<th>비밀번호</th>
<td><input type="text" name="pw" id="pw"></td>
</tr>
<tr>
<th>이름</th>
<td><input type="text" name="name" id="name"></td>
</tr>
<tr>
<th>주민번호</th>
<td><input type="text" name="jumin" id="jumin"></td>
</tr>
<tr>
<th>전화번호</th>
<td><input type="text" name="phone" id="phone"></td>
</tr>
<tr>
<th>취미</th>
<td>
<select name="hobby" id="hobby">
<option value="영화관람">영화관람
<option value="자전거">자전거
<option value="책보기">책보기
<option value="산책">산책
</select>
</td>
</tr>
<tr>
<th>가입인사말</th>
<td><textarea rows="10" cols="30" name="bigo" id="bigo"></textarea></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="가입">
<input type="button" value="입력초기화" id="reset1">
<input type="button" value="불러오기" id="load1">
</td>
</tr>
</table>
</form>
<div id="out"></div>
</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">
<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="member">
<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>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<h3 align="center">점수입력</h3>
<form action="scoresave">
<table border="1" align="center">
<tr>
<th>아이디</th>
<td><input type="text" name="id"></td>
</tr>
<tr>
<th>반</th>
<td><input type="text" name="ban"></td>
</tr>
<tr>
<th>번호</th>
<td><input type="text" name="num"></td>
</tr>
<tr>
<th>이름</th>
<td><input type="text" name="name"></td>
</tr>
<tr>
<th>국어</th>
<td><input type="text" name="kor"></td>
</tr>
<tr>
<th>영어</th>
<td><input type="text" name="eng"></td>
</tr>
<tr>
<th>수학</th>
<td><input type="text" name="mat"></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" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<c:choose>
<c:when test="${login==true && dto != null}">
<h3 align="center">점수출력</h3>
<table border="1" align="center" width="800px">
<tr>
<th>아이디</th><th>반</th><th>번호</th><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.id}</td><td>${list.ban}</td><td>${list.num}</td><td>${list.name}</td>
<td>${list.kor}</td><td>${list.eng}</td><td>${list.mat}</td><td>${list.tot}</td>
<td><fmt:formatNumber value="${list.avg}" pattern="#,##0.00"/></td><td>${list.hak}</td><td>${list.bangrade}</td><td>${list.totgrade}</td>
</tr>
</c:forEach>
</table>
</c:when>
<c:otherwise>
<script type="text/javascript">
alert("로그인후 사용가능합니다.")
window.location.href = 'login';
</script>
</c:otherwise>
</c:choose>
</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="paysave">
<table border="1" align="center">
<tr>
<th>아이디</th>
<td><input type="text" name="id"></td>
</tr>
<tr>
<th>이름</th>
<td><input type="text" name="name"></td>
</tr>
<tr>
<th>부서</th>
<td>
<select name="busea">
<option value="인사부">인사부
<option value="재정부">재정부
<option value="감찰부">감찰부
<option value="홍보부">홍보부
</select>
</td>
</tr>
<tr>
<th>가족수</th>
<td><input type="text" name="family"></td>
</tr>
<tr>
<th>입사일</th>
<td><input type="date" name="indate"></td>
</tr>
<tr>
<th>현재날짜</th>
<td><input type="date" name="dday" value="2023-03-10"></td>
</tr>
<tr>
<th>직위</th>
<td>
<select name="grade">
<option value="사원">사원
<option value="대리">대리
<option value="과장">과장
<option value="부장">부장
<option value="이사">이사
</select>
</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" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<c:choose>
<c:when test="${login==true && dto != null}">
<h3 align="center">급여출력</h3>
<table border="1" align="center" width="800px">
<tr>
<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.id}</td><td>${list.name}</td><td>${list.busea}</td>
<td><fmt:formatNumber value="${list.fsudang}" pattern="#,##0"/></td>
<td><fmt:formatNumber value="${list.bsudang}" pattern="#,##0"/></td>
<td><fmt:formatNumber value="${list.gsudang}" pattern="#,##0"/></td>
<td><fmt:formatNumber value="${list.fsudang+list.bsudang+list.gsudang}" pattern="#,##0"/></td>
<td>
<a href="pdelete?name=${list.name}">❌
<a href="pmodify?name=${list.name}">✅
</td>
</tr>
</c:forEach>
</table>
</c:when>
<c:otherwise>
<script type="text/javascript">
alert("로그인후 사용가능합니다.")
window.location.href = 'login';
</script>
</c:otherwise>
</c:choose>
</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="pmodify2">
<table border="1" align="center">
<tr>
<th>아이디</th>
<td><input type="text" name="id" value="${dto.id}" readonly></td>
</tr>
<tr>
<th>이름</th>
<td><input type="text" name="name" value="${dto.name}" readonly></td>
</tr>
<tr>
<th>부서</th>
<td>
<select name="busea" value="${dto.busea}">
<option value="인사부">인사부
<option value="재정부">재정부
<option value="감찰부">감찰부
<option value="홍보부">홍보부
</select>
</td>
</tr>
<tr>
<th>가족수</th>
<td><input type="text" name="family" value="${dto.family}"></td>
</tr>
<tr>
<th>입사일</th>
<td><input type="date" name="indate" value="${dto.indate}"></td>
</tr>
<tr>
<th>현재날짜</th>
<td><input type="date" name="dday" value="2023-03-10"></td>
</tr>
<tr>
<th>직위</th>
<td>
<select name="grade" value="${dto.grade}">
<option value="사원">사원
<option value="대리">대리
<option value="과장">과장
<option value="부장">부장
<option value="이사">이사
</select>
</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="paysearch2">
<table border="1" align="center">
<tr>
<th>기준</th>
<td>
<select name="items">
<option value="name">이름
<option value="busea">부서
<option value="id">아이디
</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>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<h3 align="center">도서입력</h3>
<form action="booksave" enctype="multipart/form-data" method="post">
<table border="1" align="center">
<tr>
<th>일련번호</th>
<td><input type="text" name="num"></td>
</tr>
<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>
<textarea rows="10" cols="30" name="bigo"></textarea>
</td>
</tr>
<tr>
<th>표지</th>
<td><input type="file" name="poster"></td>
</tr>
<tr>
<th>가격</th>
<td><input type="text" name="price"></td>
</tr>
<tr>
<th>출판사</th>
<td><input type="text" name="publish"></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" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<c:choose>
<c:when test="${login==true && dto != null}">
<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>${list.bname}</td><td>${list.writer}</td>
<td>
<a href="bookout2?num=${list.num}">
<img src="resources/${list.poster}" width="60px" height="80px">
</a>
</td>
<td>
<fmt:formatNumber value="${list.price}" pattern="#,##0"/>
</td>
<td>
<a href="bookout3?publish=${list.publish}">
${list.publish}
</a>
</td>
</tr>
</c:forEach>
</table>
</c:when>
<c:otherwise>
<script type="text/javascript">
alert("로그인후 사용가능합니다.")
window.location.href = 'login';
</script>
</c:otherwise>
</c:choose>
</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" %>
<!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>
</tr>
<c:forEach items="${list}" var="list">
<tr>
<td>${list.num}</td><td>${list.bname}</td><td>${list.bigo}</td>
<td>
<a href="bookout">
<img src="resources/${list.poster}" width="160px" height="200px">
</a>
</td>
</tr>
</c:forEach>
</table>
</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="memberinput" extends="baseLayout">
<put-attribute name="title" value="회원가입"/>
<put-attribute name="body" value="/WEB-INF/views/memberinput.jsp"/>
</definition>
<definition name="scoreinput" extends="baseLayout">
<put-attribute name="title" value="점수입력폼"/>
<put-attribute name="body" value="/WEB-INF/views/scoreinput.jsp"/>
</definition>
<definition name="scoreoutput" extends="baseLayout">
<put-attribute name="title" value="점수출력폼"/>
<put-attribute name="body" value="/WEB-INF/views/scoreoutput.jsp"/>
</definition>
<definition name="payinput" extends="baseLayout">
<put-attribute name="title" value="급여입력폼"/>
<put-attribute name="body" value="/WEB-INF/views/payinput.jsp"/>
</definition>
<definition name="payoutput" extends="baseLayout">
<put-attribute name="title" value="급여출력폼"/>
<put-attribute name="body" value="/WEB-INF/views/payoutput.jsp"/>
</definition>
<definition name="bookinput" extends="baseLayout">
<put-attribute name="title" value="도서입력폼"/>
<put-attribute name="body" value="/WEB-INF/views/bookinput.jsp"/>
</definition>
<definition name="bookoutput" extends="baseLayout">
<put-attribute name="title" value="도서출력폼"/>
<put-attribute name="body" value="/WEB-INF/views/bookoutput.jsp"/>
</definition>
<definition name="bookoutput2" extends="baseLayout">
<put-attribute name="title" value="도서출력폼2"/>
<put-attribute name="body" value="/WEB-INF/views/bookoutput2.jsp"/>
</definition>
<definition name="login" extends="baseLayout">
<put-attribute name="title" value="로그인폼"/>
<put-attribute name="body" value="/WEB-INF/views/login.jsp"/>
</definition>
<definition name="paymodifyform" extends="baseLayout">
<put-attribute name="title" value="급여수정폼"/>
<put-attribute name="body" value="/WEB-INF/views/paymodifyform.jsp"/>
</definition>
<definition name="paysearchform" extends="baseLayout">
<put-attribute name="title" value="급여검색폼"/>
<put-attribute name="body" value="/WEB-INF/views/paysearchform.jsp"/>
</definition>
</tiles-definitions>
package com.ezen.kim14_001.member;
public class MemberDTO {
String id,pw,name,jumin,phone,hobby,bigo;
int age;
String gender;
public MemberDTO() {
}
public MemberDTO(String id, String pw, String name, String jumin, String phone, String hobby, String bigo, int age,
String gender) {
super();
this.id = id;
this.pw = pw;
this.name = name;
this.jumin = jumin;
this.phone = phone;
this.hobby = hobby;
this.bigo = bigo;
this.age = age;
this.gender = gender;
}
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 String getJumin() {
return jumin;
}
public void setJumin(String jumin) {
this.jumin = jumin;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getHobby() {
return hobby;
}
public void setHobby(String hobby) {
this.hobby = hobby;
}
public String getBigo() {
return bigo;
}
public void setBigo(String bigo) {
this.bigo = bigo;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
}
package com.ezen.kim14_001.member;
import java.util.ArrayList;
public interface ServiceMem {
public void insert(String id,String pw,String name,String jumin,String phone,String hobby,String bigo);
public String idcheck(String id);
public ArrayList<MemberDTO> out();
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.kim14_001.member.ServiceMem">
<insert id="insert">
insert into member0310 values (#{param1},#{param2},#{param3},#{param4},#{param5},#{param6},#{param7})
</insert>
<select id="idcheck" resultType="String">
select count(*) from member0310 where id = #{param1}
</select>
<select id="out" resultType="com.ezen.kim14_001.member.MemberDTO">
select * from member0310
</select>
<select id="logincheck" resultType="com.ezen.kim14_001.member.MemberDTO">
select * from member0310 where id=#{param1} and pw=#{param2}
</select>
</mapper>
package com.ezen.kim14_001.member;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.ibatis.session.SqlSession;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
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.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
@Controller
public class MemberController {
@Autowired
SqlSession sqlsession;
@RequestMapping(value="/member")
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");
String jumin = request.getParameter("jumin");
String phone = request.getParameter("phone");
String hobby = request.getParameter("hobby");
String bigo = request.getParameter("bigo");
ServiceMem ssm = sqlsession.getMapper(ServiceMem.class);
ssm.insert(id,pw,name,jumin,phone,hobby,bigo);
return "redirect:member";
}
@ResponseBody
@RequestMapping(value="/idcheck")
public String ko3(String id) {
ServiceMem ssm = sqlsession.getMapper(ServiceMem.class);
String cnt = ssm.idcheck(id);
return cnt;
}
@ResponseBody
@RequestMapping(value="/memberout",method = RequestMethod.POST,produces = "application/text;charset=UTF-8")
public String ko4() {
ServiceMem ssm = sqlsession.getMapper(ServiceMem.class);
ArrayList<MemberDTO> list = ssm.out();
JSONArray array = new JSONArray();
for(int i=0;i<list.size();i++) {
JSONObject jobj = new JSONObject();
String id = list.get(i).getId();
String name = list.get(i).getName();
String jumin = list.get(i).getJumin();
int jumincheck = Integer.parseInt(jumin.substring(7,8));
int juminyear = Integer.parseInt(jumin.substring(0,2));
if(jumincheck==1 || jumincheck==2) {
juminyear=juminyear+1900;
}
else {
juminyear=juminyear+2000;
}
GregorianCalendar gc = new GregorianCalendar();
int nowyear = gc.get(Calendar.YEAR);
int age = nowyear-juminyear+1;
String gender = null;
if(jumincheck==1 || jumincheck==3) {
gender="남자";
}
else {
gender="여자";
}
String phone = list.get(i).getPhone();
String hobby = list.get(i).getHobby();
String bigo = list.get(i).getBigo();
jobj.put("id", id);
jobj.put("name", name);
jobj.put("age", age);
jobj.put("gender", gender);
jobj.put("phone", phone);
jobj.put("hobby", hobby);
jobj.put("bigo", bigo);
array.add(jobj);
}
String jsoninfo = array.toJSONString();
return jsoninfo;
}
@RequestMapping(value="/login")
public String ko5() {
return "login";
}
@RequestMapping(value="/logincheck")
public String ko6(HttpServletRequest request,RedirectAttributes ra) {
String id = request.getParameter("id");
String pw = request.getParameter("pw");
ServiceMem ssm = sqlsession.getMapper(ServiceMem.class);
MemberDTO dto = ssm.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:login";
}
return "main";
}
@RequestMapping(value="/logout")
public String ko7(HttpServletRequest request) {
HttpSession hs = request.getSession();
hs.removeAttribute("dto");
hs.removeAttribute("login");
hs.setAttribute("login", false);
return "main";
}
}
package com.ezen.kim14_001.score;
public class ScoreDTO {
String id;
int ban,num;
String name;
int kor,eng,mat;
int tot;
double avg;
String hak;
int bangrade,totgrade;
public ScoreDTO() {
}
public ScoreDTO(String id, int ban, int num, String name, int kor, int eng, int mat, int tot, double avg,
String hak, int bangrade, int totgrade) {
super();
this.id = id;
this.ban = ban;
this.num = num;
this.name = name;
this.kor = kor;
this.eng = eng;
this.mat = mat;
this.tot = tot;
this.avg = avg;
this.hak = hak;
this.bangrade = bangrade;
this.totgrade = totgrade;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public int getBan() {
return ban;
}
public void setBan(int ban) {
this.ban = ban;
}
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;
}
public int getBangrade() {
return bangrade;
}
public void setBangrade(int bangrade) {
this.bangrade = bangrade;
}
public int getTotgrade() {
return totgrade;
}
public void setTotgrade(int totgrade) {
this.totgrade = totgrade;
}
}
package com.ezen.kim14_001.score;
import java.util.ArrayList;
public interface ServiceScore {
public void insert(String id,int ban,int num,String name,int kor,int eng,int mat);
public ArrayList<ScoreDTO> out();
}
<?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.kim14_001.score.ServiceScore">
<insert id="insert">
insert into score0310 values (#{param1},#{param2},#{param3},#{param4},#{param5},#{param6},#{param7})
</insert>
<select id="out" resultType="com.ezen.kim14_001.score.ScoreDTO">
select id,ban,num,name,kor,eng,mat,(kor+eng+mat) as tot,(kor+eng+mat)/3 as avg,
case
when (kor+eng+mat)/3>=90 then 'A'
when (kor+eng+mat)/3>=80 then 'B'
when (kor+eng+mat)/3>=70 then 'C'
when (kor+eng+mat)/3>=60 then 'D'
else 'E'
end "hak",
rank() over (order by (kor+eng+mat) desc) as totgrade,
rank() over (partition by(ban) order by (kor+eng+mat) desc) as bangrade
from score0310
</select>
</mapper>
package com.ezen.kim14_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;
@Controller
public class ScoreController {
@Autowired
SqlSession sqlsession;
@RequestMapping(value="/scorein")
public String ko1() {
return "scoreinput";
}
@RequestMapping(value="/scoresave")
public String ko2(HttpServletRequest request) {
String id = request.getParameter("id");
int ban = Integer.parseInt(request.getParameter("ban"));
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"));
ServiceScore ss2 = sqlsession.getMapper(ServiceScore.class);
ss2.insert(id,ban,num,name,kor,eng,mat);
return "redirect:scorein";
}
@RequestMapping(value="/scoreout")
public String ko3(Model mo) {
ServiceScore ss2 = sqlsession.getMapper(ServiceScore.class);
ArrayList<ScoreDTO> list = ss2.out();
mo.addAttribute("list", list);
return "scoreoutput";
}
}
package com.ezen.kim14_001.pay;
public class PayDTO {
String id,name,busea;
int family;
String indate,dday,grade;
int fsudang,bsudang,gsudang,tot;
public PayDTO() {
}
public PayDTO(String id, String name, String busea, int family, String indate, String dday, String grade,
int fsudang, int bsudang, int gsudang, int tot) {
super();
this.id = id;
this.name = name;
this.busea = busea;
this.family = family;
this.indate = indate;
this.dday = dday;
this.grade = grade;
this.fsudang = fsudang;
this.bsudang = bsudang;
this.gsudang = gsudang;
this.tot = tot;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getBusea() {
return busea;
}
public void setBusea(String busea) {
this.busea = busea;
}
public int getFamily() {
return family;
}
public void setFamily(int family) {
this.family = family;
}
public String getIndate() {
return indate;
}
public void setIndate(String indate) {
this.indate = indate;
}
public String getDday() {
return dday;
}
public void setDday(String dday) {
this.dday = dday;
}
public String getGrade() {
return grade;
}
public void setGrade(String grade) {
this.grade = grade;
}
public int getFsudang() {
return fsudang;
}
public void setFsudang(int fsudang) {
this.fsudang = fsudang;
}
public int getBsudang() {
return bsudang;
}
public void setBsudang(int bsudang) {
this.bsudang = bsudang;
}
public int getGsudang() {
return gsudang;
}
public void setGsudang(int gsudang) {
this.gsudang = gsudang;
}
public int getTot() {
return tot;
}
public void setTot(int tot) {
this.tot = tot;
}
}
package com.ezen.kim14_001.pay;
import java.util.ArrayList;
public interface ServicePay {
public void insert(String id,String name,String busea,int family,String indate,String dday,String grade);
public ArrayList<PayDTO> out();
public void delete(String name);
public PayDTO modify1(String name);
public void modify2(String id,String name,String busea,int family,String indate,String dday,String grade);
public ArrayList<PayDTO> searchname(String value);
public ArrayList<PayDTO> searchbusea(String value);
public ArrayList<PayDTO> searchid(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.kim14_001.pay.ServicePay">
<insert id="insert">
insert into pay0310 values (#{param1},#{param2},#{param3},#{param4},#{param5},#{param6},#{param7})
</insert>
<select id="out" resultType="com.ezen.kim14_001.pay.PayDTO">
select id,name,busea,
decode(family,1,100000,
2,200000,
3,300000,
4,400000,
500000) as fsudang,
decode(trunc(MONTHS_BETWEEN(dday,indate)/12)+1,
1,1000000,
2,2000000,
3,3000000,
4,4000000,
5000000) as bsudang,
case grade
when '이사' then 7000000
when '부장' then 5000000
when '과장' then 4000000
when '대리' then 3000000
when '사원' then 2000000
end as gsudang
from pay0310
</select>
<delete id="delete">
delete from pay0310 where name = #{param1}
</delete>
<select id="modify1" resultType="com.ezen.kim14_001.pay.PayDTO">
select * from pay0310 where name = #{param1}
</select>
<update id="modify2">
update pay0310 set id=#{param1},busea=#{param3},family=#{param4},indate=#{param5},dday=#{param6},grade=#{param7} where name=#{param2}
</update>
<select id="searchname" resultType="com.ezen.kim14_001.pay.PayDTO">
select id,name,busea,
decode(family,1,100000,
2,200000,
3,300000,
4,400000,
500000) as fsudang,
decode(trunc(MONTHS_BETWEEN(dday,indate)/12)+1,
1,1000000,
2,2000000,
3,3000000,
4,4000000,
5000000) as bsudang,
case grade
when '이사' then 7000000
when '부장' then 5000000
when '과장' then 4000000
when '대리' then 3000000
when '사원' then 2000000
end as gsudang
from pay0310 where name like '%'||#{param1}||'%'
</select>
<select id="searchbusea" resultType="com.ezen.kim14_001.pay.PayDTO">
select id,name,busea,
decode(family,1,100000,
2,200000,
3,300000,
4,400000,
500000) as fsudang,
decode(trunc(MONTHS_BETWEEN(dday,indate)/12)+1,
1,1000000,
2,2000000,
3,3000000,
4,4000000,
5000000) as bsudang,
case grade
when '이사' then 7000000
when '부장' then 5000000
when '과장' then 4000000
when '대리' then 3000000
when '사원' then 2000000
end as gsudang
from pay0310 where busea like '%'||#{param1}||'%'
</select>
<select id="searchid" resultType="com.ezen.kim14_001.pay.PayDTO">
select id,name,busea,
decode(family,1,100000,
2,200000,
3,300000,
4,400000,
500000) as fsudang,
decode(trunc(MONTHS_BETWEEN(dday,indate)/12)+1,
1,1000000,
2,2000000,
3,3000000,
4,4000000,
5000000) as bsudang,
case grade
when '이사' then 7000000
when '부장' then 5000000
when '과장' then 4000000
when '대리' then 3000000
when '사원' then 2000000
end as gsudang
from pay0310 where id like '%'||#{param1}||'%'
</select>
</mapper>
package com.ezen.kim14_001.pay;
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.kim14_001.score.ScoreDTO;
import com.ezen.kim14_001.score.ServiceScore;
@Controller
public class PayController {
@Autowired
SqlSession sqlsession;
@RequestMapping(value="/payin")
public String ko1() {
return "payinput";
}
@RequestMapping(value="/paysave")
public String ko2(HttpServletRequest request) {
String id = request.getParameter("id");
String name = request.getParameter("name");
String busea = request.getParameter("busea");
int family = Integer.parseInt(request.getParameter("family"));
String indate = request.getParameter("indate");
String dday = request.getParameter("dday");
String grade = request.getParameter("grade");
ServicePay ss3 = sqlsession.getMapper(ServicePay.class);
ss3.insert(id,name,busea,family,indate,dday,grade);
return "redirect:payin";
}
@RequestMapping(value="/payout")
public String ko3(Model mo) {
ServicePay ss3 = sqlsession.getMapper(ServicePay.class);
ArrayList<PayDTO> list = ss3.out();
mo.addAttribute("list", list);
return "payoutput";
}
@RequestMapping(value="/pdelete")
public String ko4(HttpServletRequest request) {
String name = request.getParameter("name");
ServicePay ss3 = sqlsession.getMapper(ServicePay.class);
ss3.delete(name);
return "redirect:payout";
}
@RequestMapping(value="/pmodify")
public String ko5(HttpServletRequest request,Model mo) {
String name = request.getParameter("name");
ServicePay ss3 = sqlsession.getMapper(ServicePay.class);
PayDTO dto = ss3.modify1(name);
mo.addAttribute("dto",dto);
return "paymodifyform";
}
@RequestMapping(value="/pmodify2")
public String ko6(HttpServletRequest request) {
String id = request.getParameter("id");
String name = request.getParameter("name");
String busea = request.getParameter("busea");
int family = Integer.parseInt(request.getParameter("family"));
String indate = request.getParameter("indate");
String dday = request.getParameter("dday");
String grade = request.getParameter("grade");
ServicePay ss3 = sqlsession.getMapper(ServicePay.class);
ss3.modify2(id,name,busea,family,indate,dday,grade);
return "redirect:payout";
}
@RequestMapping(value="/paysearch")
public String ko7() {
return "paysearchform";
}
@RequestMapping(value="/paysearch2")
public String ko8(HttpServletRequest request,Model mo) {
String items = request.getParameter("items");
String value = request.getParameter("value");
ServicePay ss3 = sqlsession.getMapper(ServicePay.class);
ArrayList<PayDTO> list;
if(items.equals("name")) {
list = ss3.searchname(value);
}
else if(items.equals("busea")) {
list = ss3.searchbusea(value);
}
else {
list = ss3.searchid(value);
}
mo.addAttribute("list", list);
return "payoutput";
}
}
package com.ezen.kim14_001.book;
public class BookDTO {
int num;
String bname,writer,bigo,poster;
int price;
String publish;
public BookDTO() {
}
public BookDTO(int num, String bname, String writer, String bigo, String poster, int price, String publish) {
super();
this.num = num;
this.bname = bname;
this.writer = writer;
this.bigo = bigo;
this.poster = poster;
this.price = price;
this.publish = publish;
}
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 getBigo() {
return bigo;
}
public void setBigo(String bigo) {
this.bigo = bigo;
}
public String getPoster() {
return poster;
}
public void setPoster(String poster) {
this.poster = poster;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
public String getPublish() {
return publish;
}
public void setPublish(String publish) {
this.publish = publish;
}
}
package com.ezen.kim14_001.book;
import java.util.ArrayList;
public interface ServiceBook {
public void insert(int num,String bname,String writer,String bigo,String poster,int price,String publish);
public ArrayList<BookDTO> out();
public ArrayList<BookDTO> out2(int num);
public ArrayList<BookDTO> out3(String publish);
}
<?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.kim14_001.book.ServiceBook">
<insert id="insert">
insert into book0310 values (#{param1},#{param2},#{param3},#{param4},#{param5},#{param6},#{param7})
</insert>
<select id="out" resultType="com.ezen.kim14_001.book.BookDTO">
select * from book0310
</select>
<select id="out2" resultType="com.ezen.kim14_001.book.BookDTO">
select * from book0310 where num = #{param1}
</select>
<select id="out3" resultType="com.ezen.kim14_001.book.BookDTO">
select * from book0310 where publish = #{param1}
</select>
</mapper>
package com.ezen.kim14_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) {
int num = Integer.parseInt(mul.getParameter("num"));
String bname = mul.getParameter("bname");
String writer = mul.getParameter("writer");
String bigo = mul.getParameter("bigo");
MultipartFile mf = mul.getFile("poster");
String poster = mf.getOriginalFilename();
String uploadpath = "C:\\12월국비\\spring\\day14_001\\src\\main\\webapp\\resources";
File savefile = new File(uploadpath,poster);
try {
mf.transferTo(savefile);
}
catch(Exception e) {
e.printStackTrace();
}
int price = Integer.parseInt(mul.getParameter("price"));
String publish = mul.getParameter("publish");
ServiceBook ss4 = sqlsession.getMapper(ServiceBook.class);
ss4.insert(num,bname,writer,bigo,poster,price,publish);
return "redirect:bookin";
}
@RequestMapping(value="/bookout")
public String ko3(Model mo) {
ServiceBook ss4 = sqlsession.getMapper(ServiceBook.class);
ArrayList<BookDTO> list = ss4.out();
mo.addAttribute("list", list);
return "bookoutput";
}
@RequestMapping(value="/bookout2")
public String ko4(HttpServletRequest request,Model mo) {
int num = Integer.parseInt(request.getParameter("num"));
ServiceBook ss4 = sqlsession.getMapper(ServiceBook.class);
ArrayList<BookDTO> list = ss4.out2(num);
mo.addAttribute("list", list);
return "bookoutput2";
}
@RequestMapping(value="/bookout3")
public String ko5(HttpServletRequest request,Model mo) {
String publish = request.getParameter("publish");
ServiceBook ss4 = sqlsession.getMapper(ServiceBook.class);
ArrayList<BookDTO> list = ss4.out3(publish);
mo.addAttribute("list", list);
return "bookoutput";
}
}
'SPRING' 카테고리의 다른 글
230314_게시판 (0) | 2023.03.14 |
---|---|
230313_게시판 (0) | 2023.03.13 |
230309_AJAX (0) | 2023.03.09 |
230308_AJAX (0) | 2023.03.08 |
230307_Tiles (0) | 2023.03.07 |
댓글