购物网站(测试+步骤+代码)
一、功能需求
1、只有注册用户成功登录之后才可查看商品类别,查看商品,选购商品,生成订单、查看订单。
2、只有管理员才有权限进入购物网后台管理,进行用户管理、类别管理、商品管理与订单管理。
二、设计思路
1、采用MVC设计模式
分层架构:展现层(JSP)<——>控制层(Servlet)<——>业务层(Service)<——>模型层(Dao)<——>数据库(DB)
2、前台
(1)登录——显示商品类别——显示某类商品信息——查看购物车——生成订单——支付
(2)注册<——>登录
3、后台
(1)用户管理:用户的增删改查
(2)类别管理:商品类别的增删改查
(3)商品管理:商品的增删改查
(4)订单管理:订单的查看与删除
说明:只完成了用户管理中的查看用户功能。其他功能,有兴趣的不妨拿来操练一下。
4、西蒙购物网业务流程图
三、实现步骤
(一)创建数据库
创建MySQL数据库simonshop,包含四张表:用户表(t_user)、类别表(t_category)、商品表(t_product)和订单表(t_order)。
1、用户表t_user
(1)表结构
(2)表记录
2、类别表t_category
(1)表结构
(2)表记录
3、商品表t_product
(1)表结构
(2)表记录
4、订单表t_order
(1)表结构
(2)表记录
(二)创建Web项目simonshop
1、创建Web项目simonshop
2、在项目结构窗口里设置Artifacts名称:simonshop
3、配置服务器(Server)
4、设置部署(Deployment)
(三)创建实体类
在src里创建net.hw.shop.bean包,创建四个实体类:User、Category、Product与Order,与四张表t_user、t_category、t_product与t_order一一对应。
1、用户实体类User
package net.hw.shop.bean;
/**
- 功能:用户实体类
- 作者:谭琮建
- 日期:2019年12月2日
*/
import java.util.Date;
public class User {
/**
* 用户标识符
/
private int id;
/*
* 用户名
/
private String username;
/*
* 密码
/
private String password;
/*
* 电话号码
/
private String telephone;
/*
* 注册时间
/
private Date registerTime;
/*
* 权限(0:管理员;1:普通用户)
*/
private int popedom;
public int getId() {return id;
}public void setId(int id) {this.id = id;
}public String getUsername() {return username;
}public void setUsername(String username) {this.username = username;
}public String getPassword() {return password;
}public void setPassword(String password) {this.password = password;
}public String getTelephone() {return telephone;
}public void setTelephone(String telephone) {this.telephone = telephone;
}public Date getRegisterTime() {return registerTime;
}public void setRegisterTime(Date registerTime) {this.registerTime = registerTime;
}public int getPopedom() {return popedom;
}public void setPopedom(int popedom) {this.popedom = popedom;
}@Override
public String toString() {return "User{" +"id=" + id +", username='" + username + '\'' +", password='" + password + '\'' +", telephone='" + telephone + '\'' +", registerTime=" + registerTime +", popedom=" + popedom +'}';
}
package net.hw.shop.bean;
/**
public class Product {
/**
* 商品标识符
/
private int id;
/*
* 商品名称
/
private String name;
/*
* 商品单价
/
private double price;
/*
* 商品上架时间
/
private Date addTime;
/*
* 商品所属类别标识符
*/
private int categoryId;
public int getId() {return id;
}public void setId(int id) {this.id = id;
}public String getName() {return name;
}public void setName(String name) {this.name = name;
}public double getPrice() {return price;
}public void setPrice(double price) {this.price = price;
}public Date getAddTime() {return addTime;
}public void setAddTime(Date addTime) {this.addTime = addTime;
}public int getCategoryId() {return categoryId;
}public void setCategoryId(int categoryId) {this.categoryId = categoryId;
}@Override
public String toString() {return "Product{" +"id=" + id +", name='" + name + '\'' +", price=" + price +", addTime=" + addTime +", categoryId=" + categoryId +'}';
}
2、类别实体类Category
package net.hw.shop.bean;
/**
功能:商品类别实体类
作者:谭琮建
日期:2019年12月2日
/
public class Category {
/*- 类别标识符
/
private int id;
/* - 类别名称
*/
private String name;
public int getId() {
return id;
}public void setId(int id) {
this.id = id;
}public String getName() {
return name;
}public void setName(String name) {
this.name = name;
}@Override
public String toString() {
return “Category{” +
“id=” + id +
“, name=’” + name + ‘’’ +
‘}’;
}
}
3、商品实体类Product- 类别标识符
- 功能:商品实体类
- 作者:谭琮建
- 日期:2019年12月2日
*/
import java.util.Date;
4、订单实体类Order
package net.hw.shop.bean;
/**
- 功能:订单实体类
- 作者:谭琮建
- 日期:2019年12月2日
*/
import java.util.Date;
public class Order {
/**
* 订单标识符
/
private int id;
/*
* 用户名
/
private String username;
/*
* 联系电话
/
private String telephone;
/*
* 订单总金额
/
private double totalPrice;
/*
* 送货地址
/
private String deliveryAddress;
/*
* 下单时间
*/
private Date orderTime;
public int getId() {return id;
}public void setId(int id) {this.id = id;
}public String getUsername() {return username;
}public void setUsername(String username) {this.username = username;
}public String getTelephone() {return telephone;
}public void setTelephone(String telephone) {this.telephone = telephone;
}public double getTotalPrice() {return totalPrice;
}public void setTotalPrice(double totalPrice) {this.totalPrice = totalPrice;
}public String getDeliveryAddress() {return deliveryAddress;
}public void setDeliveryAddress(String deliveryAddress) {this.deliveryAddress = deliveryAddress;
}public Date getOrderTime() {return orderTime;
}public void setOrderTime(Date orderTime) {this.orderTime = orderTime;
}@Override
public String toString() {return "Order{" +"id=" + id +", username='" + username + '\'' +", telephone='" + telephone + '\'' +", totalPrice=" + totalPrice +", deliveryAddress='" + deliveryAddress + '\'' +", orderTime=" + orderTime +'}';
}
- (四)创建数据库工具类ConnectionManager
1、在web\WEB-INF目录下创建lib子目录,添加MySQL驱动程序的jar包
2、在src下创建net.hw.shop.dbutil包,在里面创建ConnectionManager类
package net.hw.shop.dbutil;
/**
- 功能:数据库连接管理类
- 作者:谭琮建
- 日期:2019年12月2日
*/
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import javax.swing.JOptionPane;
public class ConnectionManager {
/**
* 数据库驱动程序
/
private static final String DRIVER = “com.mysql.jdbc.Driver”;
/*
* 数据库统一资源标识符
/
private static final String URL = “jdbc:mysql://localhost:3306/simonshop”;
/*
* 数据库用户名
/
private static final String USERNAME = “root”;
/*
* 数据库密码
*/
private static final String PASSWORD = “P@ssw0rd”;
/*** 私有化构造方法,拒绝实例化*/
private ConnectionManager() {
}/*** 获取数据库连接静态方法** @return 数据库连接对象*/
public static Connection getConnection() {// 定义数据库连接Connection conn = null;try {// 安装数据库驱动程序Class.forName(DRIVER);// 获得数据库连接conn = DriverManager.getConnection(URL+ "?useUnicode=true&characterEncoding=UTF8", USERNAME, PASSWORD);} catch (ClassNotFoundException e) {e.printStackTrace();} catch (SQLException e) {e.printStackTrace();}// 返回数据库连接return conn;
}/*** 关闭数据库连接静态方法** @param conn*/
public static void closeConnection(Connection conn) {// 判断数据库连接是否为空if (conn != null) {// 判断数据库连接是否关闭try {if (!conn.isClosed()) {// 关闭数据库连接conn.close();}} catch (SQLException e) {e.printStackTrace();}}
}/*** 测试数据库连接是否成功** @param args*/
public static void main(String[] args) {// 获得数据库连接Connection conn = getConnection();// 判断是否连接成功if (conn != null) {JOptionPane.showMessageDialog(null, "恭喜,数据库连接成功!");} else {JOptionPane.showMessageDialog(null, "遗憾,数据库连接失败!");}// 关闭数据库连接closeConnection(conn);
}
}
运行程序,查看结果:
采用数据库连接池,效率更高,建议大家使用数据源方式来获取数据库连接。大家可以参看:Java Web学习笔记07:数据源和JavaBean
(五)数据访问接口(XXXDao)
在src里创建net.hw.shop.dao包,在里面创建UserDao、CategoryDao、ProductDao与OrderDao。
1、用户数据访问接口UserDao
package net.hw.shop.dao;
/**
- 功能:用户数据访问接口
- 作者:谭琮建
- 日期:2019年12月2日
*/
import java.util.List;
import net.hw.shop.bean.User;
public interface UserDao {
// 插入用户
int insert(User user);
// 按标识符删除用户
int deleteById(int id);
// 更新用户
int update(User user);
// 按标识符查询用户
User findById(int id);
// 按用户名查询用户
List findByUsername(String username);
// 查询全部用户
List findAll();
// 用户登录
User login(String username, String password);
}
2、类别数据访问接口CategoryDao
package net.hw.shop.dao;
/**
- 功能:类别数据访问接口
- 作者:谭琮建
- 日期:2019年12月10日
*/
import java.util.List;
import net.hw.shop.bean.Category;
public interface CategoryDao {
// 插入类别
int insert(Category category);
// 按标识符删除类别
int deleteById(int id);
// 更新类别
int update(Category category);
// 按标识符查询类别
Category findById(int id);
// 查询全部类别
List findAll();
}
3、商品数据访问接口ProductDao
package net.hw.shop.dao;
/**
- 功能:商品数据访问接口
- 作者:谭琮建
- 日期:2019年12月2日
*/
import java.util.List;
import net.hw.shop.bean.Product;
public interface ProductDao {
// 插入商品
int insert(Product product);
// 按标识符删除商品
int deleteById(int id);
// 更新商品
int update(Product product);
// 按标识符查询商品
Product findById(int id);
// 按类别查询商品
List findByCategoryId(int categoryId);
// 查询全部商品
List findAll();
}
4、订单数据访问接口OrderDao
package net.hw.shop.dao;
/**
- 功能:订单数据访问接口
- 作者:谭琮建
- 日期:2019年12月25日
*/
import java.util.List;
import net.hw.shop.bean.Order;
public interface OrderDao {
// 插入订单
int insert(Order order);
// 按标识符删除订单
int deleteById(int id);
// 更新订单
int update(Order order);
// 按标识符查询订单
Order findById(int id);
// 查询最后一个订单
Order findLast();
// 查询全部订单
List findAll();
}
(六)数据访问接口实现类XXXDaoImpl
在src下创建net.hw.shop.dao.impl包,在里面创建UserDaoImpl、CategoryDaoImpl、ProductDaoImpl与OrderDaoImpl。
1、用户数据访问接口实现类UserDaoImpl
package net.hw.shop.dao.impl;
/**
- 功能:用户数据访问接口实现类
- 作者:谭琮建
- 日期:2019年12月2日
*/
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import net.hw.shop.bean.User;
import net.hw.shop.dao.UserDao;
import net.hw.shop.dbutil.ConnectionManager;
public class UserDaoImpl implements UserDao {
/**
* 插入用户
*/
@Override
public int insert(User user) {
// 定义插入记录数
int count = 0;
// 获得数据库连接Connection conn = ConnectionManager.getConnection();// 定义SQL字符串String strSQL = "INSERT INTO t_user (username, password, telephone, register_time, popedom)"+ " VALUES (?, ?, ?, ?, ?)";try {// 创建预备语句对象PreparedStatement pstmt = conn.prepareStatement(strSQL);// 设置占位符的值pstmt.setString(1, user.getUsername());pstmt.setString(2, user.getPassword());pstmt.setString(3, user.getTelephone());pstmt.setTimestamp(4, new Timestamp(user.getRegisterTime().getTime()));pstmt.setInt(5, user.getPopedom());// 执行更新操作,插入新记录count = pstmt.executeUpdate();// 关闭预备语句对象pstmt.close();} catch (SQLException e) {e.printStackTrace();} finally {ConnectionManager.closeConnection(conn);}// 返回插入记录数return count;
}/*** 删除用户记录*/
@Override
public int deleteById(int id) {// 定义删除记录数int count = 0;// 获得数据库连接Connection conn = ConnectionManager.getConnection();// 定义SQL字符串String strSQL = "DELETE FROM t_user WHERE id = ?";try {// 创建预备语句对象PreparedStatement pstmt = conn.prepareStatement(strSQL);// 设置占位符的值pstmt.setInt(1, id);// 执行更新操作,删除记录count = pstmt.executeUpdate();// 关闭预备语句对象pstmt.close();} catch (SQLException e) {e.printStackTrace();} finally {ConnectionManager.closeConnection(conn);}// 返回删除记录数return count;
}/*** 更新用户*/
@Override
public int update(User user) {// 定义更新记录数int count = 0;// 获得数据库连接Connection conn = ConnectionManager.getConnection();// 定义SQL字符串String strSQL = "UPDATE t_user SET username = ?, password = ?, telephone = ?,"+ " register_time = ?, popedom = ? WHERE id = ?";try {// 创建预备语句对象PreparedStatement pstmt = conn.prepareStatement(strSQL);// 设置占位符的值pstmt.setString(1, user.getUsername());pstmt.setString(2, user.getPassword());pstmt.setString(3, user.getTelephone());pstmt.setTimestamp(4, new Timestamp(user.getRegisterTime().getTime()));pstmt.setInt(5, user.getPopedom());pstmt.setInt(6, user.getId());// 执行更新操作,更新记录count = pstmt.executeUpdate();// 关闭预备语句对象pstmt.close();} catch (SQLException e) {e.printStackTrace();} finally {ConnectionManager.closeConnection(conn);}// 返回更新记录数return count;
}/*** 按标识符查询用户*/
@Override
public User findById(int id) {// 声明用户User user = null;// 获取数据库连接对象Connection conn = ConnectionManager.getConnection();// 定义SQL字符串String strSQL = "SELECT * FROM t_user WHERE id = ?";try {// 创建预备语句对象PreparedStatement pstmt = conn.prepareStatement(strSQL);// 设置占位符的值pstmt.setInt(1, id);// 执行SQL查询,返回结果集ResultSet rs = pstmt.executeQuery();// 判断结果集是否有记录if (rs.next()) {// 实例化用户user = new User();// 利用当前记录字段值去设置商品类别的属性user.setId(rs.getInt("id"));user.setUsername(rs.getString("username"));user.setPassword(rs.getString("password"));user.setTelephone(rs.getString("telephone"));user.setRegisterTime(rs.getTimestamp("register_time"));user.setPopedom(rs.getInt("popedom"));}} catch (SQLException e) {e.printStackTrace();} finally {ConnectionManager.closeConnection(conn);}// 返回用户return user;
}@Override
public List<User> findByUsername(String username) {// 声明用户列表List<User> users = new ArrayList<User>();// 获取数据库连接对象Connection conn = ConnectionManager.getConnection();// 定义SQL字符串String strSQL = "SELECT * FROM t_user WHERE username = ?";try {// 创建预备语句对象PreparedStatement pstmt = conn.prepareStatement(strSQL);// 设置占位符的值pstmt.setString(1, username);// 执行SQL查询,返回结果集ResultSet rs = pstmt.executeQuery();// 遍历结果集while (rs.next()) {// 创建类别实体User user = new User();// 设置实体属性user.setId(rs.getInt("id"));user.setUsername(rs.getString("username"));user.setPassword(rs.getString("password"));user.setTelephone(rs.getString("telephone"));user.setRegisterTime(rs.getTimestamp("register_time"));user.setPopedom(rs.getInt("popedom"));// 将实体添加到用户列表users.add(user);}// 关闭结果集rs.close();// 关闭语句对象pstmt.close();} catch (SQLException e) {e.printStackTrace();} finally {// 关闭数据库连接ConnectionManager.closeConnection(conn);}// 返回用户列表return users;
}@Override
public List<User> findAll() {// 声明用户列表List<User> users = new ArrayList<User>();// 获取数据库连接对象Connection conn = ConnectionManager.getConnection();// 定义SQL字符串String strSQL = "SELECT * FROM t_user";try {// 创建语句对象Statement stmt = conn.createStatement();// 执行SQL,返回结果集ResultSet rs = stmt.executeQuery(strSQL);// 遍历结果集while (rs.next()) {// 创建用户实体User user = new User();// 设置实体属性user.setId(rs.getInt("id"));user.setUsername(rs.getString("username"));user.setPassword(rs.getString("password"));user.setTelephone(rs.getString("telephone"));user.setRegisterTime(rs.getTimestamp("register_time"));user.setPopedom(rs.getInt("popedom"));// 将实体添加到用户列表users.add(user);}// 关闭结果集rs.close();// 关闭语句对象stmt.close();} catch (SQLException e) {e.printStackTrace();} finally {// 关闭数据库连接ConnectionManager.closeConnection(conn);}// 返回用户列表return users;
}/*** 登录方法*/
@Override
public User login(String username, String password) {// 定义用户对象User user = null;// 获取数据库连接Connection conn = ConnectionManager.getConnection();// 定义SQL字符串String strSQL = "SELECT * FROM t_user WHERE username = ? AND password = ?";try {// 创建预备语句对象PreparedStatement psmt = conn.prepareStatement(strSQL);// 设置占位符的值psmt.setString(1, username);psmt.setString(2, password);// 执行查询,返回结果集ResultSet rs = psmt.executeQuery();// 判断结果集是否有记录if (rs.next()) {// 实例化用户对象user = new User();// 用记录值设置用户属性user.setId(rs.getInt("id"));user.setUsername(rs.getString("username"));user.setPassword(rs.getString("password"));user.setTelephone(rs.getString("telephone"));user.setRegisterTime(rs.getDate("register_time"));user.setPopedom(rs.getInt("popedom"));}// 关闭结果集rs.close();// 关闭预备语句psmt.close();} catch (SQLException e) {e.printStackTrace();} finally {// 关闭数据库连接ConnectionManager.closeConnection(conn);}// 返回用户对象return user;
}
}
我们需要对用户数据访问接口实现类的各个方法进行单元测试,采用JUnit来进行单元测试。
在项目根目录创建一个test文件夹,然后在项目结构窗口里将其标记为"Tests",这样文件夹颜色变成绿色。
在test文件夹里创建net.hw.shop.dao.impl包,在里面创建测试类TestUserDaoImpl:
(1)编写测试登录方法testLogin()
将光标定位到@Test注解符,按组合键Alt + Enter:
package net.hw.shop.dao.impl;
import net.hw.shop.bean.User;
import net.hw.shop.dao.UserDao;
import org.junit.Test;
public class TestUserDaoImpl {
@Test
public void testLogin() {
String username, password;
username = "admin";password = "12345";// 父接口指向子类对象UserDao userDao = new UserDaoImpl();User user = userDao.login(username, password);// 判断用户登录是否成功if (user != null) {System.out.println("恭喜,登录成功!");} else {System.out.println("遗憾,登录失败!");}
}
}
运行单元测试方法testLogin():
查看单元测试结果:
修改一下登录用户,再进行单元测试,看结果如何:
(2)编写测试方法testUpdate()
将用户【涂文艳】的密码改为“903213",电话改为“13945457890”。涂文艳用户的id是4
运行单元测试方法testUpdate(),结果如下:
测试删除testDeleteById()
测试testFindByUsername()
修改为没有的用户名
测试testFindById()
换一个数据库没有的ID
思考题:
(1)如何避免插入同名用户?插入同名用户时,提示用户名已存在。
(2)如何避免更新用户记录时注册时间在当前时间之后的问题?
2、类别数据访问接口实现类CategoryDaoImpl
package net.hw.shop.dao.impl;
/**
- 功能:类别数据访问接口实现类
- 作者:谭琮建
- 日期:2019年12月10日
*/
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import net.hw.shop.bean.Category;
import net.hw.shop.dao.CategoryDao;
import net.hw.shop.dbutil.ConnectionManager;
public class CategoryDaoImpl implements CategoryDao {
/**
* 插入类别
*/
@Override
public int insert(Category category) {
// 定义插入记录数
int count = 0;
// 获得数据库连接Connection conn = ConnectionManager.getConnection();// 定义SQL字符串String strSQL = "INSERT INTO t_category (name) VALUES (?)";try {// 创建预备语句对象PreparedStatement pstmt = conn.prepareStatement(strSQL);// 设置占位符的值pstmt.setString(1, category.getName());// 执行更新操作,插入新录count = pstmt.executeUpdate();// 关闭预备语句对象pstmt.close();} catch (SQLException e) {e.printStackTrace();} finally {ConnectionManager.closeConnection(conn);}// 返回插入记录数return count;
}/*** 删除类别*/
@Override
public int deleteById(int id) {// 定义删除记录数int count = 0;// 获得数据库连接Connection conn = ConnectionManager.getConnection();// 定义SQL字符串String strSQL = "DELETE FROM t_category WHERE id = ?";try {// 创建预备语句对象PreparedStatement pstmt = conn.prepareStatement(strSQL);// 设置占位符的值pstmt.setInt(1, id);// 执行更新操作,删除记录count = pstmt.executeUpdate();// 关闭预备语句对象pstmt.close();} catch (SQLException e) {e.printStackTrace();} finally {ConnectionManager.closeConnection(conn);}// 返回删除记录数return count;
}/*** 更新类别*/
@Override
public int update(Category category) {// 定义更新记录数int count = 0;// 获得数据库连接Connection conn = ConnectionManager.getConnection();// 定义SQL字符串String strSQL = "UPDATE t_category SET name = ? WHERE id = ?";try {// 创建预备语句对象PreparedStatement pstmt = conn.prepareStatement(strSQL);// 设置占位符的值pstmt.setString(1, category.getName());pstmt.setInt(2, category.getId());// 执行更新操作,更新记录count = pstmt.executeUpdate();// 关闭预备语句对象pstmt.close();} catch (SQLException e) {e.printStackTrace();} finally {ConnectionManager.closeConnection(conn);}// 返回更新记录数return count;
}/*** 按标识符查询类别*/
@Override
public Category findById(int id) {// 声明商品类别Category category = null;// 获取数据库连接对象Connection conn = ConnectionManager.getConnection();// 定义SQL字符串String strSQL = "SELECT * FROM t_category WHERE id = ?";try {// 创建预备语句对象PreparedStatement pstmt = conn.prepareStatement(strSQL);// 设置占位符的值pstmt.setInt(1, id);// 执行SQL查询,返回结果集ResultSet rs = pstmt.executeQuery();// 判断结果集是否有记录if (rs.next()) {// 实例化商品类别category = new Category();// 利用当前记录字段值去设置商品类别的属性category.setId(rs.getInt("id"));category.setName(rs.getString("name"));}} catch (SQLException e) {e.printStackTrace();} finally {ConnectionManager.closeConnection(conn);}// 返回商品类别return category;
}/*** 查询全部类别*/
@Override
public List<Category> findAll() {// 声明类别列表List<Category> categories = new ArrayList<Category>();// 获取数据库连接对象Connection conn = ConnectionManager.getConnection();// 定义SQL字符串String strSQL = "SELECT * FROM t_category";try {// 创建语句对象Statement stmt = conn.createStatement();// 执行SQL,返回结果集ResultSet rs = stmt.executeQuery(strSQL);// 遍历结果集while (rs.next()) {// 创建类别实体Category category = new Category();// 设置实体属性category.setId(rs.getInt("id"));category.setName(rs.getString("name"));// 将实体添加到类别列表categories.add(category);}// 关闭结果集rs.close();// 关闭语句对象stmt.close();} catch (SQLException e) {e.printStackTrace();} finally {// 关闭数据库连接ConnectionManager.closeConnection(conn);}// 返回类别列表return categories;
}
}
创建测试类TestCategoryDaoImpl,编写测试方法testFindAll():
判断集合categories是否为空,可以有两种处理方式:
categories.size() > 0
!categories.isEmpty()
测试testInsert()方法
测试testDeleteById()方法
测试testUpdate()方法
测试testFindById()方法
3、商品数据访问接口实现类ProductDaoImpl
package net.hw.shop.dao.impl;
/**
- 功能:产品数据访问接口实现类
- 作者:谭琮建
- 日期:2019年12月2日
*/
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import net.hw.shop.bean.Product;
import net.hw.shop.dao.ProductDao;
import net.hw.shop.dbutil.ConnectionManager;
public class ProductDaoImpl implements ProductDao {
/**
* 插入商品
*/
@Override
public int insert(Product product) {
// 定义插入记录数
int count = 0;
// 获得数据库连接Connection conn = ConnectionManager.getConnection();// 定义SQL字符串String strSQL = "INSERT INTO t_product (name, price, add_time, category_id)" + " VALUES (?, ?, ?, ?)";try {// 创建预备语句对象PreparedStatement pstmt = conn.prepareStatement(strSQL);// 设置占位符的值pstmt.setString(1, product.getName());pstmt.setDouble(2, product.getPrice());pstmt.setTimestamp(3, new Timestamp(product.getAddTime().getTime()));pstmt.setInt(4, product.getCategoryId());// 执行更新操作,插入新记录count = pstmt.executeUpdate();// 关闭预备语句对象pstmt.close();} catch (SQLException e) {e.printStackTrace();} finally {ConnectionManager.closeConnection(conn);}// 返回插入记录数return count;
}/*** 删除商品*/
@Override
public int deleteById(int id) {// 定义删除记录数int count = 0;// 获得数据库连接Connection conn = ConnectionManager.getConnection();// 定义SQL字符串String strSQL = "DELETE FROM t_product WHERE id = ?";try {// 创建预备语句对象PreparedStatement pstmt = conn.prepareStatement(strSQL);// 设置占位符的值pstmt.setInt(1, id);// 执行更新操作,删除记录count = pstmt.executeUpdate();// 关闭预备语句对象pstmt.close();} catch (SQLException e) {e.printStackTrace();} finally {ConnectionManager.closeConnection(conn);}// 返回删除记录数return count;
}/*** 更新商品*/
@Override
public int update(Product product) {// 定义更新记录数int count = 0;// 获得数据库连接Connection conn = ConnectionManager.getConnection();// 定义SQL字符串String strSQL = "UPDATE t_product SET name = ?, price = ?, add_time = ?,"+ " category_id = ? WHERE id = ?";try {// 创建预备语句对象PreparedStatement pstmt = conn.prepareStatement(strSQL);// 设置占位符的值pstmt.setString(1, product.getName());pstmt.setDouble(2, product.getPrice());pstmt.setTimestamp(3, new Timestamp(product.getAddTime().getTime()));pstmt.setInt(4, product.getCategoryId());pstmt.setInt(5, product.getId());// 执行更新操作,更新记录count = pstmt.executeUpdate();// 关闭预备语句对象pstmt.close();} catch (SQLException e) {e.printStackTrace();} finally {ConnectionManager.closeConnection(conn);}// 返回更新记录数return count;
}/*** 按标识符查找商品*/
@Override
public Product findById(int id) {// 声明商品Product product = null;// 获取数据库连接对象Connection conn = ConnectionManager.getConnection();// 定义SQL字符串String strSQL = "SELECT * FROM t_product WHERE id = ?";try {// 创建预备语句对象PreparedStatement pstmt = conn.prepareStatement(strSQL);// 设置占位符的值pstmt.setInt(1, id);// 执行SQL查询,返回结果集ResultSet rs = pstmt.executeQuery();// 判断结果集是否有记录if (rs.next()) {// 实例化商品product = new Product();// 利用当前记录字段值去设置商品类别的属性product.setId(rs.getInt("id"));product.setName(rs.getString("name"));product.setPrice(rs.getDouble("price"));product.setAddTime(rs.getTimestamp("add_time"));product.setCategoryId(rs.getInt("category_id"));}} catch (SQLException e) {e.printStackTrace();} finally {ConnectionManager.closeConnection(conn);}// 返回商品return product;
}/*** 按类别查询商品*/
@Override
public List<Product> findByCategoryId(int categoryId) {// 定义商品列表List<Product> products = new ArrayList<Product>();// 获取数据库连接Connection conn = ConnectionManager.getConnection();// 定义SQL字符串String strSQL = "SELECT * FROM t_product WHERE category_id = ?";try {// 创建预备语句PreparedStatement pstmt = conn.prepareStatement(strSQL);// 设置占位符的值pstmt.setInt(1, categoryId);// 执行SQL语句,返回结果集ResultSet rs = pstmt.executeQuery();// 遍历结果集,将其中的每条记录生成商品对象,添加到商品列表while (rs.next()) {// 实例化商品对象Product product = new Product();// 利用当前记录字段值设置实体对应属性product.setId(rs.getInt("id"));product.setName(rs.getString("name"));product.setPrice(rs.getDouble("price"));product.setAddTime(rs.getTimestamp("add_time"));product.setCategoryId(rs.getInt("category_id"));// 将商品添加到商品列表products.add(product);}} catch (SQLException e) {e.printStackTrace();} finally {ConnectionManager.closeConnection(conn);}// 返回商品列表return products;
}/*** 查询全部商品*/
@Override
public List<Product> findAll() {// 声明商品列表List<Product> products = new ArrayList<Product>();// 获取数据库连接对象Connection conn = ConnectionManager.getConnection();// 定义SQL字符串String strSQL = "SELECT * FROM t_product";try {// 创建语句对象Statement stmt = conn.createStatement();// 执行SQL,返回结果集ResultSet rs = stmt.executeQuery(strSQL);// 遍历结果集while (rs.next()) {// 创建商品实体Product product = new Product();// 设置实体属性product.setId(rs.getInt("id"));product.setName(rs.getString("name"));product.setPrice(rs.getDouble("price"));product.setAddTime(rs.getTimestamp("add_time"));product.setCategoryId(rs.getInt("category_id"));// 将实体添加到商品列表products.add(product);}// 关闭结果集rs.close();// 关闭语句对象stmt.close();} catch (SQLException e) {e.printStackTrace();} finally {// 关闭数据库连接ConnectionManager.closeConnection(conn);}// 返回商品列表return products;
}
- 创建测试类TestProductDaoImpl,编写测试方法testFindByCategoryId():
运行测试方法testFindByCategoryId(),结果如下:
修改一下查询的类别id,比如改成5,再运行测试方法testFindByCategoryId(),结果如下:
我们打开t_category表,添加一条新记录:
此时,再运行测试方法testFindByCategoryId(),结果如下:
为了不影响后面的操作,我们还是将【时尚服装】类别删除。
课堂练习:编写方法测试ProductDaoImpl其余方法。
4、订单数据访问接口实现类OrderDaoImpl
package net.hw.shop.dao.impl;
/**
- 功能:订单数据访问接口实现类
- 作者:谭琮建
- 日期:2019年12月2日
*/
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import net.hw.shop.bean.Order;
import net.hw.shop.dao.OrderDao;
import net.hw.shop.dbutil.ConnectionManager;
public class OrderDaoImpl implements OrderDao {
/**
* 插入订单
*/
@Override
public int insert(Order order) {
// 定义插入记录数
int count = 0;
// 获得数据库连接Connection conn = ConnectionManager.getConnection();// 定义SQL字符串String strSQL = "INSERT INTO t_order (username, telephone, total_price, delivery_address, order_time)"+ " VALUES (?, ?, ?, ?, ?)";try {// 创建预备语句对象PreparedStatement pstmt = conn.prepareStatement(strSQL);// 设置占位符的值pstmt.setString(1, order.getUsername());pstmt.setString(2, order.getTelephone());pstmt.setDouble(3, order.getTotalPrice());pstmt.setString(4, order.getDeliveryAddress());pstmt.setTimestamp(5, new Timestamp(order.getOrderTime().getTime()));// 执行更新操作,插入记录count = pstmt.executeUpdate();// 关闭预备语句对象pstmt.close();} catch (SQLException e) {e.printStackTrace();} finally {ConnectionManager.closeConnection(conn);}// 返回插入记录数return count;
}/*** 删除订单*/
@Override
public int deleteById(int id) {// 定义删除记录数int count = 0;// 获得数据库连接Connection conn = ConnectionManager.getConnection();// 定义SQL字符串String strSQL = "DELETE FROM t_order WHERE id = ?";try {// 创建预备语句对象PreparedStatement pstmt = conn.prepareStatement(strSQL);// 设置占位符的值pstmt.setInt(1, id);// 执行更新操作,删除记录count = pstmt.executeUpdate();// 关闭预备语句对象pstmt.close();} catch (SQLException e) {e.printStackTrace();} finally {ConnectionManager.closeConnection(conn);}// 返回删除记录数return count;
}/*** 更新订单*/
@Override
public int update(Order order) {// 定义更新记录数int count = 0;// 获得数据库连接Connection conn = ConnectionManager.getConnection();// 定义SQL字符串String strSQL = "UPDATE t_order SET username = ?, telephone = ?, total_price = ?,"+ " delivery_address = ?, order_time = ? WHERE id = ?";try {// 创建预备语句对象PreparedStatement pstmt = conn.prepareStatement(strSQL);// 设置占位符的值pstmt.setString(1, order.getUsername());pstmt.setString(2, order.getTelephone());pstmt.setDouble(3, order.getTotalPrice());pstmt.setString(4, order.getDeliveryAddress());pstmt.setTimestamp(5, new Timestamp(order.getOrderTime().getTime()));pstmt.setInt(6, order.getId());// 执行更新操作,更新记录count = pstmt.executeUpdate();// 关闭预备语句对象pstmt.close();} catch (SQLException e) {e.printStackTrace();} finally {ConnectionManager.closeConnection(conn);}// 返回更新记录数return count;
}/*** 查询最后一个订单*/
@Override
public Order findLast() {// 声明订单Order order = null;// 获取数据库连接对象Connection conn = ConnectionManager.getConnection();// 定义SQL字符串String strSQL = "SELECT * FROM t_order";try {// 创建语句对象Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);// 执行SQL,返回结果集ResultSet rs = stmt.executeQuery(strSQL);// 定位到最后一条记录if (rs.last()) {// 创建订单实体order = new Order();// 设置实体属性order.setId(rs.getInt("id"));order.setUsername(rs.getString("username"));order.setTelephone(rs.getString("telephone"));order.setTotalPrice(rs.getDouble("total_price"));order.setDeliveryAddress(rs.getString("delivery_address"));order.setOrderTime(rs.getTimestamp("order_time"));}// 关闭结果集rs.close();// 关闭语句对象stmt.close();} catch (SQLException e) {e.printStackTrace();} finally {// 关闭数据库连接ConnectionManager.closeConnection(conn);}// 返回订单对象return order;
}/*** 按标识符查询订单*/
@Override
public Order findById(int id) {// 声明订单Order order = null;// 获取数据库连接对象Connection conn = ConnectionManager.getConnection();// 定义SQL字符串String strSQL = "SELECT * FROM t_order WHERE id = ?";try {// 创建预备语句对象PreparedStatement pstmt = conn.prepareStatement(strSQL);// 设置占位符的值pstmt.setInt(1, id);// 执行SQL查询,返回结果集ResultSet rs = pstmt.executeQuery();// 判断结果集是否有记录if (rs.next()) {// 实例化订单order = new Order();// 利用当前记录字段值去设置订单的属性order.setId(rs.getInt("id"));order.setUsername(rs.getString("username"));order.setTelephone(rs.getString("telephone"));order.setDeliveryAddress(rs.getString("delivery_address"));order.setOrderTime(rs.getTimestamp("order_time"));}} catch (SQLException e) {e.printStackTrace();} finally {ConnectionManager.closeConnection(conn);}// 返回订单return order;
}/*** 查询全部订单*/
@Override
public List<Order> findAll() {// 声明订单列表List<Order> orders = new ArrayList<Order>();// 获取数据库连接对象Connection conn = ConnectionManager.getConnection();// 定义SQL字符串String strSQL = "SELECT * FROM t_order";try {// 创建语句对象Statement stmt = conn.createStatement();// 执行SQL,返回结果集ResultSet rs = stmt.executeQuery(strSQL);// 遍历结果集while (rs.next()) {// 创建订单实体Order order = new Order();// 设置实体属性order.setId(rs.getInt("id"));order.setUsername(rs.getString("username"));order.setTelephone(rs.getString("telephone"));order.setDeliveryAddress(rs.getString("delivery_address"));order.setOrderTime(rs.getTimestamp("order_time"));// 将实体添加到订单列表orders.add(order);}// 关闭结果集rs.close();// 关闭语句对象stmt.close();} catch (SQLException e) {e.printStackTrace();} finally {// 关闭数据库连接ConnectionManager.closeConnection(conn);}// 返回用户列表return orders;
}
}
创建测试类TestOrderDaoImpl,编写测试方法testFinAll():
测试testInsert()方法
测试testDeleteById()方法
测试testUpdate()方法
测试testFindLast()方法
(七)数据访问服务类XXXService
在src里创建net.hw.shop.service包,在里面创建四个服务类:UserService、CategoryService、ProductService与OrderService。
1、用户服务类UserService
package net.hw.shop.service;
/**
- 功能:用户服务类
- 作者:谭琮建
- 日期:2019年12月2日
*/
- 日期:2019年12月2日
import java.util.List;
import net.hw.shop.bean.User;
import net.hw.shop.dao.UserDao;
import net.hw.shop.dao.impl.UserDaoImpl;
public class UserService {
/**
* 声明用户访问对象
*/
private UserDao userDao = new UserDaoImpl();
public int addUser(User user) {return userDao.insert(user);
}public int deleteUserById(int id) {return userDao.deleteById(id);
}public int updateUser(User user) {return userDao.update(user);
}public User findUserById(int id) {return userDao.findById(id);
}public List<User> findUsersByUsername(String username) {return userDao.findByUsername(username);
}public List<User> findAllUsers() {return userDao.findAll();
}public User login(String username, String password) {return userDao.login(username, password);
}
}
2、类别服务类CategoryService
package net.hw.shop.service;
/**
- 功能:类别服务类
- 作者:谭琮建
- 日期:2019年12月2日
*/
import java.util.List;
import net.hw.shop.bean.Category;
import net.hw.shop.dao.CategoryDao;
import net.hw.shop.dao.impl.CategoryDaoImpl;
public class CategoryService {
/**
* 声明类别数据访问对象
*/
private CategoryDao categoryDao = new CategoryDaoImpl();
public int addCategory(Category category) {return categoryDao.insert(category);
}public int deleteCategoryById(int id) {return categoryDao.deleteById(id);
}public int updateCategory(Category category) {return categoryDao.update(category);
}public Category findCategoryById(int id) {return categoryDao.findById(id);
}public List<Category> findAllCategories() {return categoryDao.findAll();
}
- 3、商品服务类ProductService
package net.hw.shop.service;
/**
- 功能:商品服务类
- 作者:谭琮建
- 日期:2019年12月2日
*/
import java.util.List;
import net.hw.shop.bean.Product;
import net.hw.shop.dao.ProductDao;
import net.hw.shop.dao.impl.ProductDaoImpl;
public class ProductService {
/**
* 声明商品数据访问对象
*/
private ProductDao productDao = new ProductDaoImpl();
public int addProduct(Product product) {return productDao.insert(product);
}public int deleteProductById(int id) {return productDao.deleteById(id);
}public int updateProduct(Product product) {return productDao.update(product);
}public Product findProductById(int id) {return productDao.findById(id);
}public List<Product> findProductsByCategoryId(int categoryId) {return productDao.findByCategoryId(categoryId);
}public List<Product> findAllProducts() {return productDao.findAll();
}
}
4、订单服务类OrderService
package net.hw.shop.service;
/**
- 功能:订单服务类
- 作者:谭琮建
- 日期:2019年12月2日
*/
import java.util.List;
import net.hw.shop.bean.Order;
import net.hw.shop.dao.OrderDao;
import net.hw.shop.dao.impl.OrderDaoImpl;
public class OrderService {
/**
* 声明订单数据访问对象
*/
OrderDao orderDao = new OrderDaoImpl();
public int addOrder(Order order) {return orderDao.insert(order);
}public int deleteOrderById(int id) {return orderDao.deleteById(id);
}public int updateOrder(Order order) {return orderDao.update(order);
}public Order findOrderById(int id) {return orderDao.findById(id);
}public Order findLastOrder() {return orderDao.findLast();
}public List<Order> findAllOrders() {return orderDao.findAll();
}
}
课堂练习:创建四个测试类TestUserService、TestCategoryService、TestProductService与TestOrderService,编写测试方法测试四个服务类里的各个方法。
1、创建TestUserService
package net.hw.shop.service;import net.hw.shop.bean.User;
import org.junit.Test;import java.util.Date;
import java.util.List;public class TestUserService {@Testpublic void addUser(){UserService service = new UserService();User user = new User();user.setUsername("谭琮建");user.setPassword("123456");user.setTelephone("13388456688");user.setRegisterTime(new Date());int count = service.addUser(user);if (count>0){System.out.println("恭喜,用户插入成功!");System.out.println(service.findUserById(service.findAllUsers().size()));}else {System.out.println("遗憾用户插入失败!");}}@Testpublic void deleteUserById(){UserService service = new UserService();int count =service.deleteUserById(1);if (count>0){System.out.println("恭喜,学生记录删除成功");}else {System.out.println("遗憾,学生记录删除失败");}}@Testpublic void updateUser(){UserService service = new UserService();User user = service.findUserById(4);user.setPassword("903213");user.setTelephone("13945457890");int count = service.updateUser(user);if (count > 0){System.out.println("恭喜,用户更新成功");}else{System.out.println("遗憾,用户更新失败");}user = service.findUserById(4);System.out.println(user);}@Testpublic void findUserById(){UserService service = new UserService();User user = service.findUserById(3);System.out.println(user);}@Testpublic void findUsersByUsername(){UserService service = new UserService();String name = "李三";List<User> users = service.findUsersByUsername(name);if (users.size()>0){for (User user :users){System.out.println(user);}}else {System.out.println("温馨提示:查询无此人");}}@Testpublic void findAllUsers(){UserService service = new UserService();List<User> users = service.findAllUsers();for (User user:users){System.out.println(user);}}@Testpublic void login() {String username, password;username = "admin";password = "12345";// 父接口指向子类对象UserService service = new UserService();User user = service.login(username, password);// 判断用户登录是否成功if (user != null) {System.out.println("恭喜,登录成功!");} else {System.out.println("遗憾,登录失败!");}}
}
测试addUser()
测试 deleteUserById()
测试updateUser()
测试findUserById()
换一个没有的id
测试findUsersByUsername()
这里我们更换一个名字
查询结果
测试findAllUsers()方法
测试login()方法
这里我们将用户名修改为ss后:
结果
2、创建TestCategoryService
package net.hw.shop.service;import net.hw.shop.bean.Category;
import org.junit.Test;import java.util.List;public class TestCategoryService {@Testpublic void addCategory(){CategoryService categoryDao = new CategoryService();Category category = new Category();category.setId(5);category.setName("化妆用品");int count = categoryDao.addCategory(category);if (count>0){System.out.println("恭喜,商品类插入成功!");}else {System.out.println("遗憾,商品类插入失败!");}}@Testpublic void deleteCategoryById( ){CategoryService categoryDao = new CategoryService();int count =categoryDao.deleteCategoryById(5);if (count>0){System.out.println("恭喜,商品类删除成功");}else {System.out.println("遗憾,商品类删除失败");}}@Testpublic void updateCategory(){CategoryService categoryDao = new CategoryService();Category category = categoryDao.findCategoryById(1);category.setName("男士服装");int count = categoryDao.updateCategory(category);if (count > 0){System.out.println("恭喜,用户更新成功");}else{System.out.println("遗憾,用户更新失败");}category = categoryDao.findCategoryById(1);System.out.println(category);}@Testpublic void findCategoryById(){CategoryService categoryDao = new CategoryService();Category category = categoryDao.findCategoryById(3);System.out.println(category);}@Testpublic void findAllCategories(){CategoryService categoryDao = new CategoryService();List<Category> categories = categoryDao.findAllCategories();if (categories.size()>0){for (Category category: categories){System.out.println(category);}}else {System.out.println("没有商品类别!");}}
}
3、创建TestProductService
package net.hw.shop.service;import net.hw.shop.bean.Product;
import net.hw.shop.dao.CategoryDao;
import net.hw.shop.dao.impl.CategoryDaoImpl;
import org.junit.Test;import java.util.Date;
import java.util.List;public class TestProductService {@Testpublic void testInsert(){ProductService service = new ProductService();Product product = new Product();product.setId(15);product.setName("苹果电脑");product.setPrice(8888.0);product.setAddTime(new Date());product.setCategoryId(1);int count = service.addProduct(product);if (count>0){System.out.println("恭喜,商品插入成功!");System.out.println(service.findProductById(service.findAllProducts().size()));}else {System.out.println("遗憾,商品类插入失败!");}}@Testpublic void testDeleteById(){ProductService service = new ProductService();int count =service.deleteProductById(1);if (count>0){System.out.println("恭喜,商品类删除成功");}else {System.out.println("遗憾,商品类删除失败");}}@Testpublic void updateProduct(){ProductService service = new ProductService();Product product =service.findProductById(1);product.setName("小米电视");product.setPrice(6666.0);int count = service.updateProduct(product);if (count > 0){System.out.println("恭喜,商品更新成功");}else{System.out.println("遗憾,商品更新失败");}product = service.findProductById(1);System.out.println(product);}@Testpublic void findProductById(){ProductService service = new ProductService();Product product = service.findProductById(3);System.out.println(product);}@Testpublic void findProductsByCategoryId(){ProductService service = new ProductService();int categoryId = 5;CategoryDao categoryDao = new CategoryDaoImpl();if (categoryDao.findById(categoryId)!=null) {String categoryName = categoryDao.findById(categoryId).getName();List<Product> products = service.findProductsByCategoryId(categoryId);if(!products.isEmpty()){for (Product product : products){System.out.println(product);}}else {System.out.println("["+categoryName+"]类别没有商品!");}}else {System.out.println("["+categoryId+"]不存在!");}}@Testpublic void findAllProducts(){ProductService service = new ProductService();List<Product> products = service.findAllProducts();if (products.size()>0){for (Product product:products ){System.out.println(product);}}else {System.out.println("类别没有商品!");}}
}
4、创建TestOrderService
package net.hw.shop.service;import net.hw.shop.bean.Order;
import org.junit.Test;import java.util.Date;
import java.util.List;public class TestOrderService {@Testpublic void addOrder(){OrderService service = new OrderService();Order order = new Order();order.setId(3);order.setUsername("李明");order.setTelephone("13419854562");order.setTotalPrice(0.0);order.setDeliveryAddress("泸职院信息工程系");order.setOrderTime(new Date());int count = service.addOrder(order);if (count>0){System.out.println("恭喜,订单插入成功!");System.out.println(service.findOrderById(service.findAllOrders().size()));}else {System.out.println("遗憾,订单插入失败!");}}@Testpublic void deleteOrderById(int id){OrderService service = new OrderService();int count =service.deleteOrderById(3);if (count>0){System.out.println("恭喜,订单删除成功");}else {System.out.println("遗憾,订单删除失败");}}@Testpublic void updateOrder( ){OrderService service = new OrderService();Order order = service.findOrderById(1);order.setUsername("王二");int count = service.updateOrder(order);if (count > 0){System.out.println("恭喜,用户更新成功");}else{System.out.println("遗憾,用户更新失败");}order = service.findOrderById(1);System.out.println(order);}@Testpublic void findOrderById(){OrderService service = new OrderService();Order order = service.findOrderById(3);System.out.println(order);}@Testpublic void findLastOrder(){OrderService service = new OrderService();Order order = service.findLastOrder();System.out.println(order);}@Testpublic void findAllOrders(){OrderService service = new OrderService();List<Order> orders=service.findAllOrders();if (orders.size()>0){for (Order order:orders){System.out.println(order);}}else {System.out.println("没有订单!");}}
}
购物网站(测试+步骤+代码)相关推荐
- 测试基于php的购物网站,基于ThinkPHP开发的购物网站-微淘淘开发笔记
历经半个多月的断断续续的编写,一款基于ThinkPHP的购物网站开发完成并完成了初步的测试检测与修复,这款程序可以称之为到现在为止完全我自己独立编写完成的最大规模的一个 PHP 程序,为其起名叫做微淘 ...
- 200行代码搞定一个购物网站+电影站+APP
以前有一个朋友问我,说想做一个购物网站 ,电影站 ,需要APP 形式提供 . 问我一个星期能不能搞定,听了他的奇葩需求后,有点被耍的感觉,在普通人眼里 一个程序可能就是半天就做出来的东西. 后来仔细想 ...
- HTML5期末大作业:网购网站设计——品优购(4页) HTML+CSS+JavaScript 大学生网购网页设计模板代码 学生简单购物网站设计成品
HTML5期末大作业:网购网站设计--品优购(4页) HTML+CSS+JavaScript 大学生网购网页设计模板代码 学生简单购物网站设计成品 常见网页设计作业题材有 个人. 美食. 公司. 学校 ...
- 淘宝搜索代码大全,轻松让你的网站论坛升级成为“购物网站”
网络购物已经成为时下最流行的消费方式之一, 大大小小购物网站的兴起无疑印证了网络购物对网民的吸引力, 如果能在自己的网站.论坛或者博客增加购物功能, 必然将对提升站点流量与用户粘性起到极大的推动作用, ...
- (附源码)spring boot校园购物网站 毕业设计041037
springboot校园购物网站APP 摘要 21世纪的今天,随着社会的不断发展与进步,人们对于信息科学化的认识,已由低层次向高层次发展,由原来的感性认识向理性认识提高,管理工作的重要性已逐渐被人们所 ...
- (附源码)springboot校园购物网站APP 毕业设计041037
springboot校园购物网站APP 摘 要 21世纪的今天,随着社会的不断发展与进步,人们对于信息科学化的认识,已由低层次向高层次发展,由原来的感性认识向理性认识提高,管理工作的重要性已逐渐被人们 ...
- APP+spring boot校园购物网站 毕业设计-附源码041037
springboot校园购物网站APP 摘 要 21世纪的今天,随着社会的不断发展与进步,人们对于信息科学化的认识,已由低层次向高层次发展,由原来的感性认识向理性认识提高,管理工作的重要性已逐渐被人们 ...
- node.js基于WebStorm服装购物网站的设计与实现毕业设计源码281444
摘 要 随着社会的发展,计算机的优势和普及使得服装购物网站的开发成为必需.服装购物网站主要是借助计算机,通过对首页.站点管理(轮播图.公告栏)用户管理(管理员.普通用户)内容管理(交流论坛.论坛分类 ...
- mysql基于WebStorm服装购物网站的设计与实现毕业设计源码281444
摘 要 随着社会的发展,计算机的优势和普及使得服装购物网站的开发成为必需.服装购物网站主要是借助计算机,通过对首页.站点管理(轮播图.公告栏)用户管理(管理员.普通用户)内容管理(交流论坛.论坛分类 ...
- 如何制作自己的网页java_怎样制作自己的购物网站页面?
如果是自己去做一个购物网站,推荐你采用以下步骤 一.项目大致分析 我这个网站做来干什么,有什么用,几个人做,多长时间做完,采用什么架构,需要用到什么技术等. 二.具体分析 既然是用Java做,你就不得 ...
最新文章
- nacos 配置动态刷新_nacos配置中心修改后刷新
- 独家 | 手把手教你处理数据中的缺失值
- 新51CTO博客体验笔记
- 文巾解题 180. 连续出现的数字
- 【NOIP2015模拟10.22】最小代价
- C++虚基类成员可见性
- LeetCode 1776. 车队 II(单调栈)
- 多线程:三大不安全案例
- html二叉树遍历,二叉树的遍历(前序、中序、后序、层次)
- JS设计模式——10.门面模式
- 瑞幸咖啡考虑重回纳斯达克上市 官方回应:报道不实
- 2018百度之星资格赛:1002:子串查询
- html游戏导出存档,switch怎么导出存档-switch导出存档教程
- html+圆角六边形,CSS3 圆角六边形
- 超说网络NO.4 | 深入了解应用层原理(中科大 郑烇)
- 室内定位:基于NB/LTE Cat.1蜂窝网络的穿戴设备定位 BLE-4
- 游戏精细化营销不靠买量 获客也能踩着夏天的西瓜皮直线上升!
- 训练自己的点云数据进行3D目标检测
- 中国轮胎行业前景规划及未来发展趋势展望报告2022-2028年版
- 《滚石》评出最伟大100首英文歌