fix<页面调整>
parent
3d64451e43
commit
78f1155583
|
@ -12,8 +12,8 @@ public class UserDao {
|
|||
private final QueryRunner queryRunner = new QueryRunner(DBUtils.getDataSource());
|
||||
|
||||
public int addUser(String username, String phone,String password) throws Exception {
|
||||
String sql = "INSERT INTO user (username,phone, password,admin) VALUES (?, ?,?,?)";
|
||||
return queryRunner.update(sql, username, phone,password,0);
|
||||
String sql = "INSERT INTO user (username,phone, password,role) VALUES (?, ?,?,?)";
|
||||
return queryRunner.update(sql, username, phone,password,"user");
|
||||
}
|
||||
|
||||
public User getUserById(int id) throws Exception {
|
||||
|
|
|
@ -6,17 +6,17 @@ public class User {
|
|||
private int id;
|
||||
private String username;
|
||||
private String password;
|
||||
private Boolean admin;
|
||||
private String role;
|
||||
private String phone;
|
||||
|
||||
public User() {
|
||||
}
|
||||
|
||||
public User(int id, String username, String password, Boolean admin, String phone) {
|
||||
public User(int id, String username, String password, String role, String phone) {
|
||||
this.id = id;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.admin = admin;
|
||||
this.role=role;
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
|
@ -44,12 +44,12 @@ public class User {
|
|||
this.password = password;
|
||||
}
|
||||
|
||||
public Boolean getAdmin() {
|
||||
return admin;
|
||||
public String getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setAdmin(Boolean admin) {
|
||||
this.admin = admin;
|
||||
public void setRole(String role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
|
|
|
@ -2,22 +2,23 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<script src="https://www.liyansheng.top/cdn/watermark.js"></script>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Add Computer</title>
|
||||
<title>电脑产品发布</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Add New Computer</h1>
|
||||
<h1>电脑产品发布</h1>
|
||||
<form action="/addComputer" method="post">
|
||||
<label for="name">Name: </label><br>
|
||||
<label for="name">名称: </label><br>
|
||||
<input type="text" id="name" name="name"><br><br>
|
||||
<label for="price">Price: </label><br>
|
||||
<label for="price">价格: </label><br>
|
||||
<input type="text" id="price" name="price"><br><br>
|
||||
<label for="stock">Stock: </label><br>
|
||||
<label for="stock">库存: </label><br>
|
||||
<input type="text" id="stock" name="stock"><br><br>
|
||||
<input type="submit" value="Add Computer">
|
||||
<input type="submit" value="确定">
|
||||
</form>
|
||||
<br>
|
||||
<a href="/computerList">Back to List</a>
|
||||
<a href="/computerList">返回电脑列表</a>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<script src="https://www.liyansheng.top/cdn/watermark.js"></script>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>购物车</title>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<script src="https://www.liyansheng.top/cdn/watermark.js"></script>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>订单确认</title>
|
||||
|
|
|
@ -1,46 +1,61 @@
|
|||
<%@ page contentType="text/html; charset=UTF-8" language="java" %>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Computer List</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Computer List</h1>
|
||||
<table border="1">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Name</th>
|
||||
<th>Price</th>
|
||||
<th>Stock</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<c:forEach var="computer" items="${computers}">
|
||||
<tr>
|
||||
<td>${computer.id}</td>
|
||||
<td>${computer.name}</td>
|
||||
<td>${computer.price}</td>
|
||||
<td>${computer.stock}</td>
|
||||
<td>
|
||||
<a href="/editComputer?id=${computer.id}">Edit</a> |
|
||||
<a href="/deleteComputer?id=${computer.id}">Delete</a> |
|
||||
<a href="/cart?action=add&id=${computer.id}">加购</a>
|
||||
</td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
<hr>
|
||||
<p style="color: red;">${requestScope.msg}</p>
|
||||
<a href="/cart?action=list">我的购物车</a>
|
||||
<br/>
|
||||
<a href="/addComputer">Add New Computer</a>
|
||||
<br>
|
||||
<a href="/">主页</a>
|
||||
</body>
|
||||
</html>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<script src="https://www.liyansheng.top/cdn/watermark.js"></script>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>电脑产品列表</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>电脑产品列表</h1>
|
||||
<table border="1">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>名称</th>
|
||||
<th>价格</th>
|
||||
<th>库存</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<c:forEach var="computer" items="${computers}">
|
||||
<tr>
|
||||
<td>${computer.id}</td>
|
||||
<td>${computer.name}</td>
|
||||
<td>${computer.price}</td>
|
||||
<td>${computer.stock}</td>
|
||||
<td>
|
||||
<c:if test="${sessionScope.user.role == 'admin'}">
|
||||
<a href="/editComputer?id=${computer.id}">编辑</a> |
|
||||
<a href="/deleteComputer?id=${computer.id}">删除</a>
|
||||
</c:if>
|
||||
|
||||
|
||||
<c:if test="${sessionScope.user.role == 'user'}">
|
||||
<a href="/cart?action=add&id=${computer.id}">加购</a>
|
||||
</c:if>
|
||||
</td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
<hr>
|
||||
<p style="color: red;">${requestScope.msg}</p>
|
||||
|
||||
<br />
|
||||
<c:if test="${sessionScope.user.role == 'user'}">
|
||||
<a href="/cart?action=list">我的购物车</a>
|
||||
</c:if>
|
||||
<c:if test="${sessionScope.user.role == 'admin'}">
|
||||
<a href="/addComputer">发布电脑产品</a>
|
||||
</c:if>
|
||||
<br>
|
||||
<a href="/">主页</a>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -3,23 +3,24 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<script src="https://www.liyansheng.top/cdn/watermark.js"></script>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Update Computer</title>
|
||||
<title>更新电脑信息</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Update Computer</h1>
|
||||
<h1>更新电脑信息</h1>
|
||||
<form action="/editComputer" method="post">
|
||||
<input type="hidden" name="id" value="${computer.id}">
|
||||
<label for="name">Name: </label><br>
|
||||
<label for="name">名称: </label><br>
|
||||
<input type="text" id="name" name="name" value="${computer.name}"><br><br>
|
||||
<label for="price">Price: </label><br>
|
||||
<label for="price">价格: </label><br>
|
||||
<input type="text" id="price" name="price" value="${computer.price}"><br><br>
|
||||
<label for="stock">Stock: </label><br>
|
||||
<label for="stock">库存: </label><br>
|
||||
<input type="text" id="stock" name="stock" value="${computer.stock}"><br><br>
|
||||
<input type="submit" value="Update Computer">
|
||||
<input type="submit" value="提交修改">
|
||||
</form>
|
||||
<br>
|
||||
<a href="/computerList">Back to List</a>
|
||||
<a href="/computerList">返回电脑列表</a>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -4,13 +4,20 @@
|
|||
<body>
|
||||
<script src="https://www.liyansheng.top/cdn/watermark.js"></script>
|
||||
<h2>电脑商城-首页</h2>
|
||||
<p>你好!${sessionScope.user.username}</p>
|
||||
<c:if test="${sessionScope.user!= null}">
|
||||
<a href="/computerList">电脑列表</a>
|
||||
<a href="/user?action=list">用户列表</a>
|
||||
<a href="/cart?action=list">我的购物车</a>
|
||||
<a href="/orders?action=all">所有订单</a>
|
||||
<a href="/computerList">电脑选购</a>
|
||||
<c:if test="${sessionScope.user.role == 'user'}">
|
||||
<a href="/cart?action=list">我的购物车</a>
|
||||
<a href="/orders?action=my">我的订单</a>
|
||||
</c:if>
|
||||
|
||||
<c:if test="${sessionScope.user.role == 'admin'}">
|
||||
<a href="/user?action=list">用户列表</a>
|
||||
<a href="/orders?action=all">所有订单</a>
|
||||
</c:if>
|
||||
<a href="/logout">注销登录</a>
|
||||
<a href="/orders?action=my">我的订单</a>
|
||||
|
||||
</c:if>
|
||||
<c:if test="${sessionScope.user == null}">
|
||||
<p>请登录后查看更多内容~</p>
|
||||
|
@ -18,5 +25,7 @@
|
|||
<a href="/register">注册</a>
|
||||
<a href="/login">登录</a>
|
||||
</c:if>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -3,6 +3,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<script src="https://www.liyansheng.top/cdn/watermark.js"></script>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>我的订单</title>
|
||||
|
@ -22,7 +23,6 @@
|
|||
<th>总金额</th>
|
||||
<th>地址</th>
|
||||
<th>商品信息</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -34,9 +34,6 @@
|
|||
<td>${order.totalPrice}</td>
|
||||
<td>${order.address}</td>
|
||||
<td>${order.remark}</td>
|
||||
<td>
|
||||
<a href="/orders?action=delete&id=${order.id}">删除</a>
|
||||
</td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</tbody>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<script src="https://www.liyansheng.top/cdn/watermark.js"></script>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>订单列表</title>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<script src="https://www.liyansheng.top/cdn/watermark.js"></script>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>操作结果</title>
|
||||
|
|
|
@ -3,12 +3,13 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<script src="https://www.liyansheng.top/cdn/watermark.js"></script>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>user List</title>
|
||||
<title>系统用户</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>user List</h1>
|
||||
<h1>系统用户</h1>
|
||||
<table border="1">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -25,10 +26,9 @@
|
|||
<td>${user.id}</td>
|
||||
<td>${user.username}</td>
|
||||
<td>${user.phone}</td>
|
||||
<td>${user.admin}</td>
|
||||
<td>${user.role}</td>
|
||||
<td>
|
||||
<a href="/edituser?id=${user.id}">Edit</a> |
|
||||
<a href="/deleteuser?id=${user.id}">Delete</a>
|
||||
<a href="javascript:void(0)" >Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
|
|
Reference in New Issue