1.agent.jsp(房产经理总功能页面)
<%@ page import="org.apache.ibatis.session.SqlSession" %>
<%@ page import="com.xxxx.util.GetSqlSession" %>
<%@ page import="com.xxxx.mapper.AgentMapper" %>
<%@ page import="com.xxxx.entity.Agent" %><%--
Created by IntelliJ IDEA.
User: 22466
Date: 2022/11/19
Time: 19:28
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>agent.jsp</title>
</head>
<%--房产经理管理页--%>
<body>
<%
String agname= (String) request.getSession().getAttribute("uname");
SqlSession sqlSession= GetSqlSession.CreateSqlSession();
AgentMapper agentMapper=sqlSession.getMapper(AgentMapper.class);
Agent agent=agentMapper.selectByagname(agname);
%>
<a href="agifo.jsp?agid=<%=agent.getAgid()%>">查看个人信息</a><br>
<a href="agliulan.jsp?agid=<%=agent.getAgid()%>">浏览房产信息</a><br>
<a href="agjiaoyi.jsp?agid=<%=agent.getAgid()%>">房产交易</a><br>
<a href="agliulan.jsp?agid=<%=agent.getAgid()%>">查询房产</a><br>
<a href="uspwd.jsp?uname=<%=agname%>">修改个人密码</a><br>
</body>
</html>
2.agifo.jsp(房产经理查询个人信息)
<%@ page import="org.apache.ibatis.session.SqlSession" %>
<%@ page import="com.xxxx.util.GetSqlSession" %>
<%@ page import="com.xxxx.mapper.AgentMapper" %>
<%@ page import="com.xxxx.entity.Agent" %><%--
Created by IntelliJ IDEA.
User: 22466
Date: 2022/11/29
Time: 14:03
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>agifo.jsp</title>
</head>
<%--经理查询个人信息--%>
<body>
<%
String agid= request.getParameter("agid");
SqlSession sqlSession= GetSqlSession.CreateSqlSession();
AgentMapper agentMapper=sqlSession.getMapper(AgentMapper.class);
Agent agent=agentMapper.selectByagid(agid);
%>
<table align="center" width="800">
<tr>
<td>工号</td><td>姓名</td><td>家庭住址</td><td>手机</td>
</tr>
<tr>
<td><%=agent.getAgid()%></td><td><%=agent.getAgname()%></td><td><%=agent.getAgaddress()%></td><td><%=agent.getAgphone()%></td>
</tr>
</table>
</body>
</html>
3.agliulan.jsp(房产经理浏览自己管理的房产信息页面)
<%@ page import="org.apache.ibatis.session.SqlSession" %>
<%@ page import="com.xxxx.util.GetSqlSession" %>
<%@ page import="com.xxxx.mapper.AgentMapper" %>
<%@ page import="com.xxxx.entity.Agent" %>
<%@ page import="com.xxxx.mapper.HouseMapper" %>
<%@ page import="com.xxxx.entity.House" %><%--
Created by IntelliJ IDEA.
User: 22466
Date: 2022/11/29
Time: 14:08
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>agliulan.jsp</title>
</head>
<%--房产经理浏览房产信息:只能浏览自己管理的房产信息--%>
<body>
<table align="center" width="800">
<tr>
<td>房产编号</td><td>户型</td><td>房产地址</td><td>建造年份</td><td>建造面积</td><td>销售报价</td><td>销售状态</td>
</tr>
<%
String agid=request.getParameter("agid");
SqlSession sqlSession= GetSqlSession.CreateSqlSession();
HouseMapper houseMapper=sqlSession.getMapper(HouseMapper.class);
House[] houses=houseMapper.selectByaid(agid);
for (House house : houses) {
%>
<tr>
<td><%=house.getHoid()%></td><td><%=house.getHotype()%></td><td><%=house.getHoaddress()%></td><td><%=house.getHoyear()%></td><td><%=house.getHoarea()%></td><td><%=house.getHosale()%></td><td><%=house.getHostatus()%></td>
</tr>
<%
}
%>
</table>
</body>
</html>
4.agjiaoyi.jsp(房产经理房产交易功能)
<%@ page import="org.apache.ibatis.session.SqlSession" %>
<%@ page import="com.xxxx.util.GetSqlSession" %>
<%@ page import="com.xxxx.mapper.HouseMapper" %>
<%@ page import="com.xxxx.entity.House" %><%--
Created by IntelliJ IDEA.
User: 22466
Date: 2022/11/29
Time: 14:49
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>agjiaoyi.jsp</title>
</head>
<%--房产经理房产交易功能:查看意向的房产信息,点击地址可以查看详细信息--%>
<body>
<table align="center" width="800">
<tr>
<td>房产编号</td><td>房产地址</td><td>销售报价</td><td>顾客id</td>
</tr>
<%
String agid=request.getParameter("agid");
SqlSession sqlSession= GetSqlSession.CreateSqlSession();
HouseMapper houseMapper=sqlSession.getMapper(HouseMapper.class);
House[] houses=houseMapper.selectBysta();
for (House house:houses ) {
%>
<tr>
<td><%=house.getHoid()%></td><td><a href="agjiaoyirs.jsp?hoid=<%=house.getHoid()%>&uid=<%=house.getUid()%>"><%=house.getHoaddress()%></a></td><td><%=house.getHosale()%></td><td><%=house.getUid()%></td>
</tr>
<%
}
%>
</table>
</body>
</html>
5.agjiaoyirs.jsp(房产经理房产交易中显示详细信息功能)
<%@ page import="org.apache.ibatis.session.SqlSession" %>
<%@ page import="com.xxxx.util.GetSqlSession" %>
<%@ page import="com.xxxx.mapper.HouseMapper" %>
<%@ page import="com.xxxx.entity.House" %>
<%@ page import="com.xxxx.mapper.UserMapper" %>
<%@ page import="com.xxxx.entity.User" %><%--
Created by IntelliJ IDEA.
User: 22466
Date: 2022/11/29
Time: 15:02
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>agjiaoyirs.jsp</title>
</head>
<%--房产经理房产交易详细信息--%>
<body>
<table align="center" width="800">
<tr>
<td>房产编号</td><td>户型</td><td>房产地址</td><td>建造年份</td><td>建造面积</td><td>销售报价</td><td>销售状态</td>
<td>顾客ID</td><td>姓名</td><td>性别</td><td>身份证号</td><td>手机</td><td>家庭住址</td><td>操作</td>
</tr>
<%
String hoid=request.getParameter("hoid");
String uid=request.getParameter("uid");
SqlSession sqlSession= GetSqlSession.CreateSqlSession();
UserMapper userMapper=sqlSession.getMapper(UserMapper.class);
User user=userMapper.selectByusid(uid);
HouseMapper houseMapper=sqlSession.getMapper(HouseMapper.class);
House house=houseMapper.selectByhoid(hoid);
%>
<tr>
<td><%=house.getHoid()%></td><td><%=house.getHotype()%></td><td><%=house.getHoaddress()%></td><td><%=house.getHoyear()%></td><td><%=house.getHoarea()%></td><td><%=house.getHosale()%></td><td><%=house.getHostatus()%></td>
<td><%=user.getUsid()%></td>
<td><%=user.getUsname()%></td><td><%=user.getUssex()%></td><td><%=user.getUsidnum()%></td><td><%=user.getUsphone()%></td><td><%=user.getUsaddress()%></td>
<td><a href="agjiaoyiServlet?hoid=<%=house.getHoid()%>">交易</a></td>
</tr>
</table>
</body>
</html>
6.agjiaoyiServlet(房产经理房产交易Servlet)
package com.xxxx.servlet;
import com.xxxx.mapper.HouseMapper;
import com.xxxx.util.GetSqlSession;
import org.apache.ibatis.session.SqlSession;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/agjiaoyiServlet")
public class agjiaoyiServlet extends HttpServlet {
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=utf-8");
String hoid=request.getParameter("hoid");
SqlSession sqlSession= GetSqlSession.CreateSqlSession();
HouseMapper houseMapper=sqlSession.getMapper(HouseMapper.class);
houseMapper.updateStatusByhoid(hoid);
response.getWriter().write("交易成功");
response.getWriter().close();
sqlSession.close();
}
}
7.uspwd.jsp(修改个人密码功能,与顾客修改个人密码功能共用)
<%@ page import="org.apache.ibatis.session.SqlSession" %>
<%@ page import="com.xxxx.util.GetSqlSession" %>
<%@ page import="com.xxxx.mapper.LoginMapper" %>
<%@ page import="com.xxxx.entity.Login" %><%--
Created by IntelliJ IDEA.
User: 22466
Date: 2022/11/28
Time: 22:00
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>uspwd.jsp</title>
</head>
<%--顾客修改个人密码页面,要判断:输入的密码是否和旧密码相同--%>
<body>
<%
String uname=request.getParameter("uname");
request.getSession().setAttribute("uname",uname);
SqlSession sqlSession= GetSqlSession.CreateSqlSession();
LoginMapper loginMapper=sqlSession.getMapper(LoginMapper.class);
Login login=loginMapper.selectByuname(uname);
%>
<form action="uspwdServlet" method="post" id="uspwdForm">
输入旧密码:<input type="password" name="upwd1" id="upwd1"><br>
输入新密码:<input type="password" name="upwd2" id="upwd2"><br>
确认新密码:<input type="password" name="upwd3" id="upwd3"><br>
<button type="button" id="uspwdBtn">修改</button>
</form>
<script type="text/javascript" src="js/jquery-3.6.1.js"></script>
<script type="text/javascript">
$("#uspwdBtn").click(function (){
var upwd1=$("#upwd1").val();
var upwd2=$("#upwd2").val();
var upwd3=$("#upwd3").val();
if(upwd1 != <%=login.getUpwd()%>)alert("旧密码有误");
else {
if(upwd2 != upwd3) alert("两次输入的新密码不相同");
else $("#uspwdForm").submit();
}
})
</script>
</body>
</html>
8.uspwdServlet(修改个人密码Servlet)
package com.xxxx.servlet;
import com.mysql.cj.log.Log;
import com.xxxx.entity.Login;
import com.xxxx.mapper.LoginMapper;
import com.xxxx.util.GetSqlSession;
import org.apache.ibatis.session.SqlSession;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/uspwdServlet")
public class uspwdServlet extends HttpServlet {
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=utf-8");
String uname= (String) request.getSession().getAttribute("uname");
String upwd=request.getParameter("upwd2");
SqlSession sqlSession=GetSqlSession.CreateSqlSession();
LoginMapper loginMapper=sqlSession.getMapper(LoginMapper.class);
loginMapper.updateByunameupwd(uname,upwd);
response.getWriter().write("修改成功");
response.getWriter().close();
sqlSession.close();
}
}