Java项目:JSP宠物店管理系统

news/2024/5/5 9:49:31/文章来源:https://blog.csdn.net/hanyunlong1989/article/details/126965014

作者主页:夜未央5788

 简介: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项目:否;

技术栈

1. 后端:Servlet

2. 前端:JSP+CSS+JavaScript+jQuery+Bootstrap

使用说明

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_petmall 登录 注:Tomcat中配置路径必须为jsp_petmall,否则会出问题;
用户账号/密码: 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.idpublic 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);}
}

OrderDao

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);}
}

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

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

如若内容造成侵权/违法违规/事实不符,请联系dt猫网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【LeetCode每日一题】——面试题17.16.按摩师

文章目录一【题目类别】二【题目难度】三【题目编号】四【题目描述】五【题目示例】六【解题思路】八【时间频度】九【代码实现】十【提交结果】一【题目类别】 动态规划 二【题目难度】 简单 三【题目编号】 面试题17.16.按摩师 四【题目描述】 一个有名的按摩师会收到…

App移动端测试(10)—— Monkey自定义脚本案例

01、前言 Monkey自定义脚本案例&#xff1a;QQ的操作 02、Monkey API LaunchActivity(pkg_name, cl_name)启动应用的Activity。参数&#xff1a;包名和启动的 Tap(x, y, tapDuration)模拟一次手指单击事件。参数&#xff1a;x,y为控件坐标&#xff0c;tapDuration为点击的持续…

你到底是前端人还是搬砖人?推荐一款国产摸鱼神器!

☀️ 前言 大家好我是小卢&#xff0c;前几天在群里见到有群友抱怨一周内要完成这么一个大概20&#xff5e;30页的小程序。 群友: 这20多个页面一个星期让我开发完&#xff0c;我是不相信&#x1f62e;‍&#x1f4a8;。群友1: 跑吧&#xff0c;这公司留着没用了&#xff0c;不…

【Python 技能树共建】Beautiful Soup

Beautiful Soup 模块是什么 初学 Python 爬虫&#xff0c;十之八九你采集的目标是网页&#xff0c;因此快速定位到网页内容&#xff0c;就成为你面临的第一道障碍&#xff0c;本篇博客就为你详细说明最易上手的网页元素定位术&#xff0c;学完就会系列。 本文核心使用到的是 …

Spring Security 中的RBAC角色和权限

在这篇文章中&#xff0c;我们将看看使用 Spring boot的R ole B ased A ccess Control ( RBAC )。 了解 RBAC 在 RBAC 模型中存在三个关键实体。他们是&#xff0c; 用户或主题 ——执行操作的系统参与者。它可以代表一个自然人、一个自动帐户&#xff0c;甚至是另一个应用程…

专业思维导图软件 Mindjet MindManager 2021下载

Mindjet MindManager 2021 是一款专业的思维导图软件&#xff0c;美国Mindjet公司开发&#xff0c;一款视觉工作管理的思维导图软件&#xff0c;界面友好功能强大&#xff0c;头脑风暴、会议管理及项目管理工具帮您轻松创建思维导图&#xff0c;有序组织思维、资源和项目进程。…

win10+cuda+cudnn+anconda+pytorch+pycharm全家桶安装

1、下载安装cuda&#xff1a; 网址&#xff1a;CUDA Toolkit 11.7 Update 1 Downloads | NVIDIA Developer 网址下方可以找到以前版本 安装完后&#xff0c;可以在命令行窗口输入nvcc --version查看cuda版本是否正确 显卡驱动版本与cuda版本对应关系&#xff1a; 2、安装cud…

操作系统实验四 进程间通信

★观前提示&#xff1a;本篇内容为操作系统实验内容&#xff0c;代码等内容经测试没有问题&#xff0c;但是可能会不符合每个人实验的要求&#xff0c;因此以下内容建议仅做思路参考。 目录一、实验目的二、实验内容三、具体实现四、实验总结一、实验目的 多道程序设计中&…

【前端面试】-- 必知必会的promise题

Promise 想必大家都十分熟悉&#xff0c;想想就那么几个 api&#xff0c;可是你真的了解 Promise 吗&#xff1f; 请迎接测试: 以下 promise 均指代 Promise 实例&#xff0c;环境是 Node.js 题目一&#xff1a; const promise new Promise((resolve, reject) > {conso…

ES8JC-ASEMI快恢复二极管ES8JC

编辑:ll ES8JC-ASEMI快恢复二极管ES8JC 型号:ES8JC 品牌:ASEMI 封装:SMC 特性:快恢复二极管 正向电流:8A 反向耐压:600V 恢复时间:35ns 引脚数量:2 芯片个数:1 芯片尺寸:84MIL 浪涌电流:125A 漏电流:<5ua 工作温度:-40℃~150℃ 包装方式:30/管;3000/箱 备受…

华为云各Region网络延迟实测

一、测试综述 测试内容&#xff1a; 序号 评测内容 测试日期 1 华为云各大区公网接入网络延迟 2022-09-20 2 华为云各大区之间网络延迟&#xff08;通过公网&#xff09; 2022-09-20 3 华为云各大区之间网络延迟&#xff08;通过云连接&#xff09; 2022-09-20 测…

【Linux】聊聊删文件的那些破事

聊聊删文件的那些破事前言正文rm命令find命令perl方式10w文件删除对比50w文件删除对比100w文件删除对比结语前言 在操作系统的日常运维中&#xff0c;我们经常会做文件的创建、删除、修改操作&#xff0c;尤其是删除&#xff0c;无论是定期清理日志文件&#xff0c;还是做完一…

传统光流方法汇总

又搬运了一个3d视觉相关的~~ 还是先道歉 就是学习用 还是公交上回家看那种 ~~ 这次分享传统光流方法汇总及其在深度学习中的应用&#xff01;&#xff08;基于相位/能量/匹配/变分&#xff09; 回望传统光流估计方法 近年来&#xff0c;随着深度学习技术的快速发展&#xff…

嵌入式分享合集63

一、PCB为什么一定要做阻抗 在具有电阻、电感和电容的电路里&#xff0c;对交流电所起的阻碍作用叫做阻抗。阻抗常用Z表示&#xff0c;是一个复数&#xff0c;实部称为电阻&#xff0c;虚部称为电抗。 其中电容在电路中对交流电所起的阻碍作用称为容抗&#xff0c;电感在电路…

Pr:多机位编辑

很多时候一个机位满足不了影视创作的需求。比如拍摄人物动作&#xff0c;如果能使远景、近景、特写等一些镜头相互衔接&#xff0c;将会使得角色显得更加丰富饱满。不同的景别传达着不同的信息&#xff0c;更容易交待环境和表达角色的情绪。早期人们在拍摄的同时完成多机位切换…

应用层 HTTP 代理服务器转发消息时的相关头部 请求头 X-Forwarded-For

在http消息传递过程当中会经过很多正向代理服务器和反向代理服务器&#xff0c;这些代理服务器在转发消息的时候会涉及到http的头部&#xff0c;下面将会介绍这些头部&#xff0c;包括由于存在这些代理服务器所以客户端和源服务器之前有许多的tcp连接&#xff0c;有一些http头部…

Flutter快学快用15 服务通信:Flutter 中常见的网络协议

上一课时之前&#xff0c;我们的接口都是在代码中模拟假数据&#xff0c;并没有从服务端获取数据&#xff0c;但是在实际开发中&#xff0c;必须与服务端进行交互。本课时主要介绍在 Flutter 中常见的网络传输协议序列化方式&#xff0c;并对其中比较常用的协议进行简单实践&am…

大数据培训技术phoenix表操作

phoenix表操作 1 显示所有表 &#xff01;table 或 &#xff01;tables 2 创建表 CREATE TABLE IF NOT EXISTS us_population ( State CHAR(2) NOT NULL, City VARCHAR NOT NULL, Population BIGINT CONSTRAINT my_pk PRIMARY KEY (state, city)); 如下显示&#xff1a; 在p…

超级基础篇_疑惑实验

1、多态&#xff1a; 多态是什么&#xff1f; 多态是同一个行为具有多个不同表现形式或形态的能力。 多态就是同一个接口&#xff0c;使用不同的实例而执行不同操作多态的优点 1.消除类型之间的耦合关系 2. 可替换性 3. 可扩充性 …

树的应用 —— 二叉树:二叉树的性质

树的应用 —— 二叉树 二叉树&#xff08;Binary Tree&#xff09;是n &#xff08;n ≥0&#xff09;个节点构成的集合&#xff0c;或为空树&#xff08;n 0&#xff09;&#xff0c;或为非空树。 对于非空树T &#xff0c;要满足&#xff1a; ①有且仅有一个被称为根的节点…