作者主页:源码空间站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项目:否;

技术栈

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

Java项目:JSP宠物店管理系统相关推荐

  1. 宿舍管理系统 住宿管理系统 寝室管理系统源码 java项目jsp web项目

    宿舍管理系统 住宿管理系统 寝室管理系统源码 java项目jsp web项目 [源码+数据库+文档齐全] 宿舍管理系统主要实现的功能有:学生管理.宿舍管理.评分管理.损坏管理.访客管理.班级管理.系统 ...

  2. 电影影院管理系统电影购票系统java项目jsp web项目

    电影影院管理系统电影购票系统java项目jsp web项目基于javaweb的在线电影院售票管理系统 电影影院管理系统电影购票系统java项目jspweb项目-Java文档类资源-CSDN下载电影影院 ...

  3. 图书管理系统java项目jsp web项

    图书管理系统java项目jsp web项 源码+数据库+文档+运行环境齐全! 图书信息浏览,图书借阅,图书归还,个人信息管理,最佳读者,借阅排行,问题反馈等. 管理员功能可以实现读者管理,图书管理,借 ...

  4. java计算机毕业设计宠物店管理系统MyBatis+系统+LW文档+源码+调试部署

    java计算机毕业设计宠物店管理系统MyBatis+系统+LW文档+源码+调试部署 java计算机毕业设计宠物店管理系统MyBatis+系统+LW文档+源码+调试部署 本源码技术栈: 项目架构:B/S ...

  5. [附源码]计算机毕业设计JAVA基于JSP健身房管理系统

    [附源码]计算机毕业设计JAVA基于JSP健身房管理系统 项目运行 环境配置: Jdk1.8 + Tomcat7.0 + Mysql + HBuilderX(Webstorm也行)+ Eclispe( ...

  6. java计算机毕业设计宠物店管理系统(附源码、数据库)

    java计算机毕业设计宠物店管理系统(附源码.数据库) 项目运行 环境配置: Jdk1.8 + Tomcat8.5 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(I ...

  7. Java项目01-菜谱管理系统控制台实现

    Java项目01-菜谱管理系统控制台实现: 源代码及展示视频请到资源处下载,也可私聊本人提供免积分百度云下载,另外后续还有Java Swing+数据库实现的界面项目哦! 系统主界面: Java Swi ...

  8. 完成我的第一个java项目“评标人才库管理系统”——环境配置+创项目

    完成我的第一个java项目"评标人才库管理系统"--环境配置+创项目 idea配置maven环境 创建第一个Spring项目 idea配置maven环境 1.下载maven htt ...

  9. Java项目实战---歌曲管理系统

    Java项目实战-歌曲管理系统 声明:本人仅整理了代码,方便大家进行调试优化,功能上还存在很多纰漏,欢迎大家评论区讨论 代码原地址放于文章末尾 一.实验目的: 掌握类的定义,JAVA应用程序的设计与实 ...

最新文章

  1. affectnet数据集_处理表情识别中的坏数据:一篇CVPR 2020及两篇TIP的解读
  2. 关于时间类型数据的转换
  3. SPSS数据记录的选择(Select Cases)
  4. 换光纤猫 ZXA10 F420
  5. python标准库math用来计算平方根的函数_《Python程序设计方案》题库
  6. 某企业管理软件开发公司校园招聘的小组讨论面试题
  7. OC中的字符串常用方法
  8. sqlite insert数据要用“?”代替“%s”
  9. ascii码扩展 php,php与ascii码
  10. Android点击EditText文本框之外任何地方隐藏键盘的解决办法
  11. 漫谈LiteOS-LiteOS SDK支持RISC-V架构
  12. c语言检测数独是否正确,会数独的大佬请进。这是个判断九宫格数独是否正确的程序。...
  13. IIS7.0 Url Rewrite
  14. html图片无损压缩,有损压缩和无损压缩的区别是什么
  15. 上市公司慈善捐赠金额数据(2009-2018年)
  16. 第4章-一阶多智体系统一致性 -> 连续时间系统一致性
  17. Linux实训项目二 用户和组的管理
  18. Settings provider system和global表格数据访问
  19. 机器视觉实验四: 为人脸添加装饰物特效实验(OpenCV-python代码)
  20. 【云原生进阶之容器】第二章Controller Manager原理2.8节--Resync机制

热门文章

  1. Python---短信接口demo,对接创蓝253云通讯paas平台
  2. 欧姆龙SysmacStudio 关于模块化编程的使用技巧---全局变量和数据类型
  3. 宏杉科技的第一,不是魔术变出来的
  4. 逆袭之路——python学习笔记【day08】
  5. SpringBoot 入坑(九)Docker (容器路径挂载)resource busy 问题
  6. 视频教程:YUV420和RGB相互转换--C++实现(二)
  7. 算法笔记(重要知识点梳理)一:C语言
  8. SQL笔试题(持续更新)
  9. 解决无法直接打开EXCEL文件的问题
  10. Dig HOWTO 中文手册--dig命令使用大全