基于javaweb+mysql的ssm学生二手书籍管理系统(java+ssm+elementui+vue+layui+mysql)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8、Node.js≥10
开发工具
后端:eclipse/idea/myeclipse/sts等均可配置运行
前端:WebStorm/VSCode/HBuilderX等均可
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SSM学生二手书籍管理系统(java+ssm+elementui+vue+layui+mysql)
项目介绍
SSM学生二手书籍交易平台
角色:管理员、卖家、用户
前台主要功能包括:首页、书籍信息、留言反馈、个人中心、购物车;
后台主要分为管理员、用户、卖家; 管理员主要功能:首页、个人中心、用户管理、卖家管理、书籍分类管理、书籍信息管理、留言板管理、管理员管理、系统管理; 用户主要功能:首页、个人中心、我的收藏管理、留言板管理; 卖家主要功能:首页、个人中心、书籍信息管理、订单管理;
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.数据库:MySql 5.7/8.0等版本均可;
技术栈
后端:SSM(Spring+SpringMVC+Mybatis)
前端:ElementUI+Vue+LayUI+bootstrap+jquery
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应sql文件名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,修改配置,运行项目; 3. 将项目中config.properties配置文件中的数据库配置改为自己的配置,然后运行; 网址:http://localhost:8080/ssmxm4f1/admin/dist/index.html 后台管理 管理员:abo 密码:abo 用户账号密码:用户1/123456 http://localhost:8080/ssmxm4f1/front/index.html 前台 用户账号密码:用户1/123456 卖家账号密码:卖家1/123456
//如果返回的订单Id不为-1,则表示添加订单成功
if(orderId!=-1){
//获取购物车中的所有图书种类
Collection<ShoppingItem> silist = cart.getItems();
//遍历每一项图书
for(ShoppingItem item:silist){
//封装成OrderBook对象
OrderBook ob = new OrderBook();
ob.setOrderId(orderId);
ob.setBookId(item.getItem().getId());
cart = new ShoppingCart();
request.getSession().setAttribute("cart", cart);
Users user = (Users) request.getSession().getAttribute("user");
if(user!=null){
//页面跳转
response.sendRedirect("user/usercart.jsp");
}else{
//页面跳转
response.sendRedirect("showcart.jsp");
/**
* 增加购物车商品数量
* @param request
* @param response
* @throws ServletException
//计算商品总价
cart.getTotalReal();
request.getSession().setAttribute("cart", cart);
//页面跳转
showCart(request, response);
/**
* 减少购物车商品数量
* @param request
* @param response
* @throws ServletException
* @throws IOException
cart.getTotalReal();
request.getSession().setAttribute("cart", cart);
showCart(request, response);
订单管理控制层:
@WebServlet("/OrderServlet")
public class OrderServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
public OrderServlet() {
super();
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.sendRedirect("admin/categorylist.jsp");
return;
//封装对象
Categories cate = new Categories();
cate.setName(name);
//调用dao层方法
CategoriesDaoImpl dao = new CategoriesDaoImpl();
if(dao.addCategory(cate)){
request.getSession().setAttribute("ADMIN_MSG_CATEGORY", "添加成功");
//初始化分类集合
initCategory(request, response);
}else{
request.getSession().setAttribute("ADMIN_MSG_CATEGORY", "添加失败");
//页面跳转
if(user!=null){
//页面跳转
response.sendRedirect("user/usercart.jsp");
}else{
//页面跳转
response.sendRedirect("showcart.jsp");
/**
* 增加购物车商品数量
* @param request
* @param response
}else{
request.getSession().setAttribute("ADMIN_MSG_CATEGORY", "添加失败");
//页面跳转
response.sendRedirect("admin/categorylist.jsp");
/**
* 编辑分类
* @param request
* @param response
* @throws ServletException
* @throws IOException
*/
private void editCategoryByAdmin(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
}else if(opt.equals("inAmount")){
inAmount(request, response);
}else if(opt.equals("deAmount")){
deAmount(request, response);
}else{
response.sendRedirect("index.jsp");
/**
* 添加商品到购物车
* @param request
* @param response
* @throws ServletException
* @throws IOException
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String opt = request.getParameter("opt");
//判断操作
if(opt.equals("buy")){
buyCart(request, response);
}else if(opt.equals("del")){
delCart(request, response);
}else if(opt.equals("clear")){
clearCart(request, response);
}else if(opt.equals("show")){
showCart(request, response);
* 查看订单
* @param request
* @param response
* @throws ServletException
* @throws IOException
*/
protected void showOrder(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//获取session中的user对象
Users user = (Users) request.getSession().getAttribute("user");
//调用dao层的获取订单方法
OrderDaoImpl dao = new OrderDaoImpl();
ShoppingCart cart = (ShoppingCart) request.getSession().getAttribute("cart");
if(cart!=null){
String isbn = request.getParameter("isbn");
//信息完整性校验
if(isbn!=null && !isbn.equals("")){
//获取ShoppingItem
ShoppingItem si = cart.getItem(isbn);
if(si!=null && si.getAmount()>1)
si.deAmount();
//计算商品总价
/**
* 添加商品到购物车
* @param request
* @param response
* @throws ServletException
* @throws IOException
*/
protected void buyCart(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
ShoppingCart cart = (ShoppingCart) request.getSession().getAttribute("cart");
if(cart==null){
cart = new ShoppingCart();
//获取购买数量
String strNum = request.getParameter("num");
request.getSession().setAttribute("ADMIN_MSG_CATEGORY", "添加成功");
//初始化分类集合
initCategory(request, response);
}else{
request.getSession().setAttribute("ADMIN_MSG_CATEGORY", "添加失败");
//页面跳转
response.sendRedirect("admin/categorylist.jsp");
/**
* 编辑分类
* @param request
* @param response
* @throws ServletException
* @throws IOException
*/
cart.getTotalReal();
request.getSession().setAttribute("cart", cart);
//页面跳转
showCart(request, response);
/**
* 减少购物车商品数量
* @param request
* @param response
* @throws ServletException
* @throws IOException
*/
}else{
request.getSession().setAttribute("ADMIN_MSG_CATEGORY", "添加失败");
//页面跳转
response.sendRedirect("admin/categorylist.jsp");
/**
* 编辑分类
* @param request
* @param response
* @throws ServletException
* @throws IOException
*/
private void editCategoryByAdmin(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if(StringUtil.isNumber(request.getParameter("cid"))==false){
return;
//封装对象
Categories c = new Categories();
c.setId(cId);
c.setName(name);
//调用dao层方法
CategoriesDaoImpl dao = new CategoriesDaoImpl();
Boolean b = dao.updateCategory(c);
if(b){
initCategory(request, response);
response.sendRedirect("admin/categorylist.jsp");
/**
doPost(request, response);
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//判断是否登录
if(request.getSession().getAttribute("user")==null){
//跳转页面
response.sendRedirect("login.jsp");
return;
//判断操作
String opt = request.getParameter("opt");
if(opt.equals("add")){
addOrder(request, response);
if(opt.equals("show")){
showOrder(request, response);
/**