Java项目:JSP蛋糕甜品店管理系统

news2025/7/19 0:07:02

作者主页:源码空间站2022

 简介:Java领域优质创作者、Java项目、学习资料、技术互助

文末获取源码

项目介绍

本项目分为前后台,分为管理员与普通用户两种角色,管理员登录后台,普通用户登录前台;

管理员角色包含以下功能:

管理员登录,订单管理,客户管理,类目管理等功能。

用户角色包含以下功能:
首页,商品分类,热销和新品,注册新用户,用户登录,查看个人中心,购买商品,查看购物车,提交订单,模拟支付成功,查看订单等功能。

环境需要

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版本;

6.是否Maven项目:否;

技术栈

JSP+CSS+jQuery+bootstrap+mysql+servlet

使用说明

1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;

2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;

若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;

3. 将项目中src/utils/DBUtil.java配置文件中的数据库配置改为自己的配置;
4. 运行项目,输入localhost:8080/jsp_cakeshop/ 登录 注:tomcat中配置项目路径必须为jsp_cakeshop,否则会有异常;
用户账号/密码:user/123456

管理员账号/密码:admin/admin

运行截图

前台界面

 

后台界面

相关代码 

GoodsDao

package dao;

import javafx.scene.control.ScrollPane;
import model.Goods;
import model.Recommend;
import org.apache.commons.dbutils.*;
import org.apache.commons.dbutils.handlers.*;
import utils.DBUtil;

import java.sql.SQLException;
import java.util.*;

public class GoodsDao {
    //select g.id,g.name,g.cover,g.price,t.name typename from recommend r,goods g,type t where type=2 and r.goods_id=g.id and g.type_id=t.id
    public List<Map<String,Object>> getGoodsList(int recommendType) throws SQLException {
        QueryRunner r = new QueryRunner(DBUtil.getDataSource());
        String sql="select g.id,g.name,g.cover,g.price,t.name typename from recommend r,goods g,type t where type=? and r.goods_id=g.id and g.type_id=t.id";
        return r.query(sql, new MapListHandler(),recommendType);
    }

    public Map<String,Object> getScrollGood()throws SQLException{
        QueryRunner r = new QueryRunner(DBUtil.getDataSource());
        String sql="select g.id,g.name,g.cover,g.price  from recommend r,goods g where type=1 and r.goods_id=g.id";
        return r.query(sql, new MapHandler());
    }
    public List<Goods> selectGoodsByTypeID(int typeID,int pageNumber,int pageSize) throws SQLException {
        if(typeID==0)
        {
            String sql="select * from goods limit ? , ?";
            QueryRunner r=new QueryRunner(DBUtil.getDataSource());
            return  r.query(sql,new BeanListHandler<Goods>(Goods.class),(pageNumber-1)*pageSize,pageSize);
        }
        else
        {
            String sql="select * from goods where type_id=? limit ? , ?";
            QueryRunner r=new QueryRunner(DBUtil.getDataSource());
            return  r.query(sql,new BeanListHandler<Goods>(Goods.class),typeID,(pageNumber-1)*pageSize,pageSize);
        }
    }
    public int getCountOfGoodsByTypeID(int typeID) throws SQLException {
        String sql="";
        QueryRunner r=new QueryRunner(DBUtil.getDataSource());
        if(typeID==0)
        {
            sql="select count(*) from goods";
            return r.query(sql,new ScalarHandler<Long>()).intValue();
        }
        else
        {
            sql="select count(*) from goods where type_id=?";
            return r.query(sql,new ScalarHandler<Long>(),typeID).intValue();
        }
    }
    public List<Goods> selectGoodsbyRecommend(int type,int pageNumber,int pageSize) throws SQLException {
        QueryRunner r = new QueryRunner(DBUtil.getDataSource());
        if(type==0) {
            //当不添加推荐类型限制的时候
            String sql = " select g.id,g.name,g.cover,g.image1,g.image2,g.intro,g.price,g.stock,t.name typename from goods g,type t where g.type_id=t.id order by g.id limit ?,?";
            return r.query(sql, new BeanListHandler<Goods>(Goods.class),(pageNumber-1)*pageSize,pageSize);

        }

        String sql = " select g.id,g.name,g.cover,g.image1,g.image2,g.intro,g.price,g.stock,t.name typename from goods g,recommend r,type t where g.id=r.goods_id and g.type_id=t.id and r.type=? order by g.id limit ?,?";
        return r.query(sql, new BeanListHandler<Goods>(Goods.class),type,(pageNumber-1)*pageSize,pageSize);
    }
    public int getRecommendCountOfGoodsByTypeID(int type) throws SQLException {
        if(type==0)return getCountOfGoodsByTypeID(0);
        QueryRunner r = new QueryRunner(DBUtil.getDataSource());
        String sql = "select count(*) from recommend where type=?";
        return r.query(sql, new ScalarHandler<Long>(),type).intValue();
    }
    public Goods getGoodsById(int id) throws SQLException {
        QueryRunner r = new QueryRunner(DBUtil.getDataSource());
        String sql = "select g.id,g.name,g.cover,g.image1,g.image2,g.price,g.intro,g.stock,t.id typeid,t.name typename from goods g,type t where g.id = ? and g.type_id=t.id";
        return r.query(sql, new BeanHandler<Goods>(Goods.class),id);
    }
    public int getSearchCount(String keyword) throws SQLException {
        QueryRunner r = new QueryRunner(DBUtil.getDataSource());
        String sql = "select count(*) from goods where name like ?";
        return r.query(sql, new ScalarHandler<Long>(),"%"+keyword+"%").intValue();
    }
    public List<Goods> selectSearchGoods(String keyword, int pageNumber, int pageSize) throws SQLException{
        QueryRunner r = new QueryRunner(DBUtil.getDataSource());
        String sql = "select * from goods where name like ? limit ?,?";
        return r.query(sql, new BeanListHandler<Goods>(Goods.class),"%"+keyword+"%",(pageNumber-1)*pageSize,pageSize);
    }
    public boolean isScroll(Goods g) throws SQLException {
        return isRecommend(g, 1);
    }
    public boolean isHot(Goods g) throws SQLException {
        return isRecommend(g, 2);
    }
    public boolean isNew(Goods g) throws SQLException {
        return isRecommend(g, 3);
    }
    private boolean isRecommend(Goods g,int type) throws SQLException {
        QueryRunner r = new QueryRunner(DBUtil.getDataSource());
        String sql = "select * from recommend where type=? and goods_id=?";
        Recommend recommend = r.query(sql, new BeanHandler<Recommend>(Recommend.class),type,g.getId());
        if(recommend==null) {
            return false;
        }else {
            return true;
        }
    }
    public void addRecommend(int id,int type) throws SQLException {
        QueryRunner r = new QueryRunner(DBUtil.getDataSource());
        String sql = "insert into recommend(type,goods_id) values(?,?)";
        r.update(sql,type,id);
    }
    public void removeRecommend(int id,int type) throws SQLException {
        QueryRunner r = new QueryRunner(DBUtil.getDataSource());
        String sql = "delete from recommend where type=? and goods_id=?";
        r.update(sql,type,id);
    }
    public void insert(Goods g) throws SQLException {
        QueryRunner r = new QueryRunner(DBUtil.getDataSource());
        String sql = "insert into goods(name,cover,image1,image2,price,intro,stock,type_id) values(?,?,?,?,?,?,?,?)";
        r.update(sql,g.getName(),g.getCover(),g.getImage1(),g.getImage2(),g.getPrice(),g.getIntro(),g.getStock(),g.getType().getId());
    }
    public void update(Goods g) throws SQLException {
        QueryRunner r = new QueryRunner(DBUtil.getDataSource());
        String sql = "update goods set name=?,cover=?,image1=?,image2=?,price=?,intro=?,stock=?,type_id=? where id=?";
        r.update(sql,g.getName(),g.getCover(),g.getImage1(),g.getImage2(),g.getPrice(),g.getIntro(),g.getStock(),g.getType().getId(),g.getId());
    }
    public void delete(int id) throws SQLException {
        QueryRunner r = new QueryRunner(DBUtil.getDataSource());
        String sql = "delete from goods where id = ?";
        r.update(sql,id);
    }
}


package dao;

import model.*;
import org.apache.commons.dbutils.*;
import utils.*;
import java.math.*;
import java.sql.*;
import java.util.*;
import org.apache.commons.dbutils.handlers.*;

public class OrderDao {
    public void insertOrder(Connection con, Order order) throws SQLException {
        QueryRunner r = new QueryRunner();
        String sql = "insert into `order`(total,amount,status,paytype,name,phone,address,datetime,user_id) values(?,?,?,?,?,?,?,?,?)";
        r.update(con,sql,
                order.getTotal(),order.getAmount(),order.getStatus(),
                order.getPaytype(),order.getName(),order.getPhone(),
                order.getAddress(),order.getDatetime(),order.getUser().getId() );
    }
    public int getLastInsertId(Connection con) throws SQLException {
        QueryRunner r = new QueryRunner();
        String sql = "select last_insert_id()";
        BigInteger bi = r.query(con, sql,new ScalarHandler<BigInteger>());
        return Integer.parseInt(bi.toString());
    }
    public void insertOrderItem(Connection con, OrderItem item) throws SQLException {
        QueryRunner r = new QueryRunner();
        String sql ="insert into orderitem(price,amount,goods_id,order_id) values(?,?,?,?)";
        r.update(con,sql,item.getPrice(),item.getAmount(),item.getGoods().getId(),item.getOrder().getId());
    }
    public List<Order> selectAll(int userid) throws SQLException {
        QueryRunner r = new QueryRunner(DBUtil.getDataSource());
        String sql = "select * from `order` where user_id=? order by datetime desc";
        return r.query(sql, new BeanListHandler<Order>(Order.class),userid);
    }
    public List<OrderItem> selectAllItem(int orderid) throws SQLException{
        QueryRunner r = new QueryRunner(DBUtil.getDataSource());
        String sql = "select i.id,i.price,i.amount,g.name from orderitem i,goods g where order_id=? and i.goods_id=g.id";
        return r.query(sql, new BeanListHandler<OrderItem>(OrderItem.class),orderid);
    }
    public int getOrderCount(int status) throws SQLException {
        QueryRunner r = new QueryRunner(DBUtil.getDataSource());
        String sql = "";
        if(status==0) {
            sql = "select count(*) from `order`";
            return r.query(sql, new ScalarHandler<Long>()).intValue();
        }else {
            sql = "select count(*) from `order` where status=?";
            return r.query(sql, new ScalarHandler<Long>(),status).intValue();
        }
    }
    public List<Order> selectOrderList(int status, int pageNumber, int pageSize) throws SQLException {
        QueryRunner r = new QueryRunner(DBUtil.getDataSource());
        if(status==0) {
            String sql = "select o.id,o.total,o.amount,o.status,o.paytype,o.name,o.phone,o.address,o.datetime,u.username from `order` o,user u where o.user_id=u.id order by o.datetime desc limit ?,?";
            return r.query(sql, new BeanListHandler<Order>(Order.class), (pageNumber-1)*pageSize,pageSize );
        }else {
            String sql = "select o.id,o.total,o.amount,o.status,o.paytype,o.name,o.phone,o.address,o.datetime,u.username from `order` o,user u where o.user_id=u.id and o.status=? order by o.datetime desc limit ?,?";
            return r.query(sql, new BeanListHandler<Order>(Order.class),status, (pageNumber-1)*pageSize,pageSize );
        }
    }
    public void updateStatus(int id,int status) throws SQLException {
        QueryRunner r = new QueryRunner(DBUtil.getDataSource());
        String sql ="update `order` set status=? where id = ?";
        r.update(sql,status,id);
    }
    public void deleteOrder(Connection con ,int id) throws SQLException {
        QueryRunner r = new QueryRunner();
        String sql ="delete from `order` where id = ?";
        r.update(con,sql,id);
    }
    public void deleteOrderItem(Connection con ,int id) throws SQLException {
        QueryRunner r = new QueryRunner();
        String sql ="delete from orderitem where order_id=?";
        r.update(con,sql,id);
    }
}

TypeDao

package dao;

import model.Type;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import utils.DBUtil;

import java.sql.SQLException;
import java.util.List;

public class TypeDao
{
    public List<Type> GetAllType() throws SQLException {
        QueryRunner r=new QueryRunner(DBUtil.getDataSource());
        String sql="select * from type";
        return r.query(sql,new BeanListHandler<Type>(Type.class));
    }
    public Type selectTypeNameByID(int typeid) throws SQLException {
        QueryRunner r=new QueryRunner(DBUtil.getDataSource());
        String sql="select * from type where id=?";
        return r.query(sql,new BeanHandler<Type>(Type.class),typeid);
    }
    public Type select(int id) throws SQLException {
        QueryRunner r = new QueryRunner(DBUtil.getDataSource());
        String sql = "select * from type where id = ?";
        return r.query(sql, new BeanHandler<Type>(Type.class),id);
    }
    public void insert(Type t) throws SQLException {
        QueryRunner r = new QueryRunner(DBUtil.getDataSource());
        String sql = "insert into type(name) values(?)";
        r.update(sql,t.getName());
    }
    public void update(Type t) throws SQLException {
        QueryRunner r = new QueryRunner(DBUtil.getDataSource());
        String sql = "update type set name=? where id = ?";
        r.update(sql,t.getName(),t.getId());
    }
    public void delete(int id) throws SQLException {
        QueryRunner r = new QueryRunner(DBUtil.getDataSource());
        String sql = "delete from type where id = ?";
        r.update(sql,id);
    }
}

如果也想学习本系统,下面领取。关注并回复:064jsp

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/36193.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Zookeeper

文章目录Zk介绍特点数据结构应用场景Zk安装、集群下载、启动配置参数解读Zookeeper 集群操作选举机制&#xff08;面试重点&#xff09;客户端命令行操作客户端界面节点类型&#xff08;持久 / 短暂 / 有序号 / 无序号&#xff09;监听器1&#xff09;节点的值变化监听2&#x…

【通信】基于matlab模拟室内VLC模型(含BER和SNR)附matlab代码

✅作者简介&#xff1a;热爱科研的Matlab仿真开发者&#xff0c;修心和技术同步精进&#xff0c;matlab项目合作可私信。 &#x1f34e;个人主页&#xff1a;Matlab科研工作室 &#x1f34a;个人信条&#xff1a;格物致知。 更多Matlab仿真内容点击&#x1f447; 智能优化算法 …

短视频平台如何保证内容安全问题?

本文首发于&#xff1a;行者AI谛听 近些年&#xff0c;短视频的安全意识越来越强&#xff0c;随着各大平台的用户暴增&#xff0c;平台的一些审核及运营都有着巨大的挑战。那么对于平台来说&#xff0c;如何保证内容安全呢&#xff1f; 很多短视频平台的内容有着爆炸式的增长&a…

Vue3动态路由(Vite+Vue3+TS+Mock)

一、动态路由简介 Vue通过路由进行页面管理&#xff0c;不同的路由绑定到不同的页面。一般来说&#xff0c;前端直接写好的路由为静态路由&#xff0c;在不修改代码的情况下&#xff0c;路由表是不会改变的。对于不需要动态改变路由表的网站&#xff0c;静态路由就已经足够了&…

关于数据治理工具的选型,你了解多少?

数据治理的本质是盘点数据资产、治理数据质量&#xff0c;实施数据全生命周期的管理&#xff0c;这里面包括了建组织、立制度或者使用一款数据治理的软件帮助企业开展数据治理的相关工作等等。根据不同的数据治理项目特点&#xff0c;会用到不同的技术或工具。拥有一套趁手好用…

功率放大器的三种类型是什么意思

很多人都知道功率放大器&#xff0c;但是却不知道同样都是功率放大器&#xff0c;但是名字相同&#xff0c;作用却是完全不同的&#xff0c;总是会有工程师发出这样的疑问“功率放大器的三种类型是什么以及功率放大器怎么选择型号”等等&#xff0c;今天就请安泰电子来为我们解…

SpringBoot整合Alibaba-Dubbo和Apache-Dubbo

文章目录1 Alibaba整合Dubbo1.1 服务提供者1.1.1 服务提供者接口1.1.2 服务提供者实现类1.1.2.1 项目结构图1.1.2.2 pom.xml1.1.2.3 服务实现类1.1.2.4 配置文件1.1.2.5 启动类1.2 服务消费者1.2.1 项目结构图示1.2.2 请求入口1.2.3 配置文件1.2.4 启动类2 Apache整合Dubbo2.1 …

Pytorch学习笔记(四)官方60min入门教程之图像分类器

你已经了解了如何定义神经网络&#xff0c;计算损失值和网络里权重的更新。 现在你也许会想应该怎么处理数据&#xff1f; 通常来说&#xff0c;当你处理图像&#xff0c;文本&#xff0c;语音或者视频数据时&#xff0c;你可以使用标准 python 包将数据加载成 numpy 数组格式…

Web3中文|10月份超48%的以太坊NFT交易额是假的

来源 | cryptoslate 编译 | BoweniNFTnews.com 10月份全球NFT销售额超过8.5亿美元&#xff0c;总交易量约为300万笔。 NFT月销售额 数据来源&#xff1a;Footprint Analytics 在市场状况不佳的情况下&#xff0c;仍有大量唯一买家与卖家。10月份有超过100 万的唯一买家和卖家…

第九章 哈希表 AcWing 1532. 找硬币

第九章 哈希表 AcWing 1532. 找硬币 原题链接 AcWing 1532. 找硬币 算法标签 哈希表 双指针 思路 使用哈希表集合 用一个哈希表存储硬币。 对于每一枚硬币 x&#xff0c;判断在集合中是否存在 y&#xff0c;使得 x y m。 如果存在&#xff0c;则是一组解&#xff0c;判…

Linux Command htpasswd 创建密码文件

文章目录Linux Command htpasswd 创建密码文件1. 简介2. 安装3. 语法4. 选项5. 示例6. 其他Linux Command htpasswd 创建密码文件 1. 简介 htpasswd是Apache的Web服务器内置的工具,用于创建和更新储存用户名和用户基本认证的密码文件。 2. 安装 centos 7、 redhat&#xff…

MCE | 靶向 cGAS-STING 通路或可治疗渐冻症

自从 12 年前被发现以来&#xff0c;STING 途径就吸引了众多TOP生物学家的关注&#xff0c;去年 3 月&#xff0c;陈志坚教授带领的研究团队和其合作者在 Nature 上同日发表三篇论文&#xff0c;让 cGAS-STING 通路大火了一把&#xff0c;并被认为是未来十年内肿瘤免疫靶点的“…

指静脉当前遇到的问题

一、《基于改进残差网络的指静脉识别算法》_易芮 2020.5.20 ①采集到的指静脉图像质量不高"边缘曝光"及手指的自由度导致图像存在的偏移问题 &#xff08;传统的指静脉识别技术是基于图像的纹理、特征点等细节进行特征提取&#xff0c;若图像质量较差的话&#xff…

thymeleaf抽取公共页面

thymeleaf抽取公共页面Thymeleaf中th:include、th:replace、th:insert、th:fragment用法及区别th:include、th:replace、th:insert区别在开发Web网站的时候&#xff0c;HTML页面有很多是相同的&#xff0c;如果每一个页面都写一遍&#xff0c;不仅非常麻烦&#xff0c;而且非常…

基于粒子群算法的城轨列车牵引多目标能耗优化问题附matlab代码

✅作者简介&#xff1a;热爱科研的Matlab仿真开发者&#xff0c;修心和技术同步精进&#xff0c;matlab项目合作可私信。 &#x1f34e;个人主页&#xff1a;Matlab科研工作室 &#x1f34a;个人信条&#xff1a;格物致知。 更多Matlab仿真内容点击&#x1f447; 智能优化算法 …

python基础之元组

文章目录一、元组注意&#xff1a;二、创建元组怎么验证这个变量真的是一个元组类型&#xff1a;三、使用迭代遍历元组四、应用场景五、格式化字符串后面的&#xff08;&#xff09;本质上就是元组六、元组和列表之间的转换一、元组 元组&#xff08;Tuple&#xff09;与列表类…

Python(PyQt5)制作帮助文档查看器(可显示后缀名为md的文件)同时显示文本和图片

先看完整效果图: 帮助文档查看器是很多程序中必备要素,而利用Qt中的QTreeView组件可以很方便的查看文件,而QTextBrowser可以直接显示格式化的MarkDown文本。因此可以利用这两个组件制作一个帮助文件查看器。 未优化 效果图: 问题优化: 你会发现QT treeView列宽设置不成功问题…

Mybatis-Plus 06 条件构造器和常用接口

一、wapper介绍 Wrapper &#xff1a; 条件构造抽象类&#xff0c;最顶端父类 AbstractWrapper &#xff1a; 用于查询条件封装&#xff0c;生成 sql 的 where 条件 ​ QueryWrapper &#xff1a; 查询条件封装 ​ UpdateWrapper &#xff1a; Update 条件封装 AbstractL…

PG::Inclusiveness

nmap -Pn -p- -T4 --min-rate1000 192.168.134.14 nmap -Pn -p 21,22,80 -sCV 192.168.134.14 80端口是默认页面&#xff0c;先查看21端口FTP服务的匿名登录&#xff0c;并未发现可利用信息。 继续查看80端口&#xff0c;在robots.txt中得到提示。 https://www.howtogeek.co…

【Kubernetes | Pod 系列】Pod的 YAML 清单文件详解

目录3. Pod的 YAML 清单文件3.1 获取资源对象 YAML3.2 解析 YAML 清单文件&#xff08;1&#xff09;apiVersion查看 Kubernetes API 中全部的 API 组&#xff08;2&#xff09;kind查看 Kubernetes 中全部的对象资源类型&#xff08;3&#xff09;metadata&#xff08;4&#…