基于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.是否Maven项目: 是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目 6.数据库: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
* @throws IOException
*/
protected void addCategoryByAdmin(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//获取提交的参数
String name = request.getParameter("name");
//信息完整性校验
if(name==null || name.equals("")){
request.getSession().setAttribute("ADMIN_MSG_CATEGORY", "添加失败,请检查分类是否合法输入");
response.sendRedirect("admin/categorylist.jsp");
return;
//封装对象
Categories cate = new Categories();
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 {
private static final long serialVersionUID = 1L;
public CategoryServlet() {
super();
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");
String role = request.getParameter("role");
//判断是否为管理员操作
if(role!=null && role.equals("3")){
optByAdmin(request, response);
return;
/**
strNum="1";
int num = Integer.parseInt(strNum);
//获取图书信息
String isbn = request.getParameter("isbn");
BookDaoImpl dao = new BookDaoImpl();
Books book = dao.getBooksByIsbn(isbn);
//把商品添加到购物车
cart.add(book, num);
request.getSession().setAttribute("cart",cart);
//跳转页面
response.sendRedirect("addcartok.jsp");
protected void clearCart(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
* @throws IOException
*/
protected void deAmount(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//从session中获取ShoppingCart
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");
/**
* 增加购物车商品数量
* @param request
* @param response
* @throws ServletException
* @throws IOException
*/
protected void inAmount(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//从session中获取ShoppingCart
ShoppingCart cart = (ShoppingCart) request.getSession().getAttribute("cart");
if(cart!=null){
String isbn = request.getParameter("isbn");
//信息完整性校验
cart.getTotalReal();
request.getSession().setAttribute("cart", cart);
//页面跳转
showCart(request, response);
/**
* 减少购物车商品数量
* @param request
* @param response
* @throws ServletException
* @throws IOException
*/
if(si!=null){
si.inAmount();
//计算商品总价
cart.getTotalReal();
request.getSession().setAttribute("cart", cart);
//页面跳转
showCart(request, response);
/**
* 减少购物车商品数量
* @param request
* @param response
* @throws ServletException
* @throws IOException
/**
* 减少购物车商品数量
* @param request
* @param response
* @throws ServletException
* @throws IOException
*/
protected void deAmount(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//从session中获取ShoppingCart
ShoppingCart cart = (ShoppingCart) request.getSession().getAttribute("cart");
response.sendRedirect("admin/categorylist.jsp");
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");
/**
* 管理员操作
* @param request
* @param response
* @throws ServletException
* @throws IOException
*/
protected void optByAdmin(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String opt = request.getParameter("opt");
//判断是否登录
Users user = (Users) request.getSession().getAttribute("user");
if(user==null || user.getUserRoleId()!=3){
response.sendRedirect("admin/login.jsp");
return;
//判断操作
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);
}else if(opt.equals("inAmount")){
inAmount(request, response);
}else if(opt.equals("deAmount")){
//调用dao层方法
CategoriesDaoImpl dao = new CategoriesDaoImpl();
Boolean b = dao.updateCategory(c);
if(b){
initCategory(request, response);
response.sendRedirect("admin/categorylist.jsp");
/**
* 初始化分类集合
* @param request
* @param response
*/
private void initCategory(HttpServletRequest request, HttpServletResponse response){
//获取图书分类
c.setName(name);
//调用dao层方法
CategoriesDaoImpl dao = new CategoriesDaoImpl();
Boolean b = dao.updateCategory(c);
if(b){
initCategory(request, response);
response.sendRedirect("admin/categorylist.jsp");
/**
* 初始化分类集合
* @param request
* @param response
protected void addOrder(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//从session中的cart(购物车)对象
ShoppingCart cart = (ShoppingCart) request.getSession().getAttribute("cart");
//获取从jsp页面传过来的userId
Users user = (Users) request.getSession().getAttribute("user");
//将获取的数据封装成Orders对象
Orders order = new Orders();
order.setUserId(user.getId());
order.setTotalPrice(cart.getTotal());
//调用dao的添加订单方法
OrderDaoImpl dao = new OrderDaoImpl();
int orderId = dao.addOrder(order);
for(ShoppingItem item:silist){
//封装成OrderBook对象
OrderBook ob = new OrderBook();
ob.setOrderId(orderId);
ob.setBookId(item.getItem().getId());
ob.setQuantity(item.getAmount());
ob.setUnitPrice(item.getItem().getUnitPrice());
//添加到明细表
dao.addOrderBook(ob);
//清空购物车
request.getSession().removeAttribute("cart");
//页面跳转