Java项目:宠物领养寄养商城系统(java+Springboot+HTML+bootstrap+mysql)

本文主要是介绍Java项目:宠物领养寄养商城系统(java+Springboot+HTML+bootstrap+mysql),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

源码获取:俺的博客首页 "资源" 里下载!

项目介绍

管理员角色:
用户管理、角色管理、菜单管理、宠物信息、视频管理、在线留言、宠物用品管理、
常见问题管理、购物车、商城订单、领养订单、寄养订单

用户角色:
领养宠物、寄养宠物、视频秀、买家秀、在线留言、加入购物车、
购买、商城订单、领养订单、寄养订单

环境需要

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. 后端:SpringBoot+Mybatis

2. 前端:HTML+CSS+Bootstrap+jQuery

使用说明

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

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

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

3. 将项目中application.properties配置文件中的数据库配置改为自己的配置;
4. 运行项目,登录地址:http://localhost:8089/login

管理员: admin/admin123

普通账户: liming/123456

 

 

 

 

 

用户信息管理控制层:

/*** 用户信息* */
@Controller
@RequestMapping("/system/user")
public class UserController extends BaseController
{private String prefix = "system/user";@Autowiredprivate IUserService userService;@Autowiredprivate IRoleService roleService;@Autowiredprivate IPostService postService;@RequiresPermissions("system:user:view")@GetMapping()public String user(){return prefix + "/user";}@RequiresPermissions("system:user:list")@PostMapping("/list")@ResponseBodypublic TableDataInfo list(User user){startPage();List<User> list = userService.selectUserList(user);return getDataTable(list);}@Log(title = "用户管理", businessType = BusinessType.EXPORT)@RequiresPermissions("system:user:export")@PostMapping("/export")@ResponseBodypublic AjaxResult export(User user){List<User> list = userService.selectUserList(user);ExcelUtil<User> util = new ExcelUtil<User>(User.class);return util.exportExcel(list, "用户数据");}@Log(title = "用户管理", businessType = BusinessType.IMPORT)@RequiresPermissions("system:user:import")@PostMapping("/importData")@ResponseBodypublic AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception{ExcelUtil<User> util = new ExcelUtil<User>(User.class);List<User> userList = util.importExcel(file.getInputStream());String message = userService.importUser(userList, updateSupport);return AjaxResult.success(message);}@RequiresPermissions("system:user:view")@GetMapping("/importTemplate")@ResponseBodypublic AjaxResult importTemplate(){ExcelUtil<User> util = new ExcelUtil<User>(User.class);return util.importTemplateExcel("用户数据");}/*** 新增用户*/@GetMapping("/add")public String add(ModelMap mmap){mmap.put("roles", roleService.selectRoleAll());mmap.put("posts", postService.selectPostAll());return prefix + "/add";}/*** 新增保存用户*/@RequiresPermissions("system:user:add")@Log(title = "用户管理", businessType = BusinessType.INSERT)@PostMapping("/add")@ResponseBodypublic AjaxResult addSave(@Validated User user){if (UserConstants.USER_NAME_NOT_UNIQUE.equals(userService.checkLoginNameUnique(user.getLoginName()))){return error("新增用户'" + user.getLoginName() + "'失败,登录账号已存在");}else if (UserConstants.USER_PHONE_NOT_UNIQUE.equals(userService.checkPhoneUnique(user))){return error("新增用户'" + user.getLoginName() + "'失败,手机号码已存在");}else if (UserConstants.USER_EMAIL_NOT_UNIQUE.equals(userService.checkEmailUnique(user))){return error("新增用户'" + user.getLoginName() + "'失败,邮箱账号已存在");}return toAjax(userService.insertUser(user));}/*** 修改用户*/@GetMapping("/edit/{userId}")public String edit(@PathVariable("userId") Long userId, ModelMap mmap){mmap.put("user", userService.selectUserById(userId));mmap.put("roles", roleService.selectRolesByUserId(userId));mmap.put("posts", postService.selectPostsByUserId(userId));return prefix + "/edit";}/*** 修改保存用户*/@RequiresPermissions("system:user:edit")@Log(title = "用户管理", businessType = BusinessType.UPDATE)@PostMapping("/edit")@ResponseBodypublic AjaxResult editSave(@Validated User user){userService.checkUserAllowed(user);if (UserConstants.USER_PHONE_NOT_UNIQUE.equals(userService.checkPhoneUnique(user))){return error("修改用户'" + user.getLoginName() + "'失败,手机号码已存在");}else if (UserConstants.USER_EMAIL_NOT_UNIQUE.equals(userService.checkEmailUnique(user))){return error("修改用户'" + user.getLoginName() + "'失败,邮箱账号已存在");}return toAjax(userService.updateUser(user));}@RequiresPermissions("system:user:resetPwd")@Log(title = "重置密码", businessType = BusinessType.UPDATE)@GetMapping("/resetPwd/{userId}")public String resetPwd(@PathVariable("userId") Long userId, ModelMap mmap){mmap.put("user", userService.selectUserById(userId));return prefix + "/resetPwd";}@RequiresPermissions("system:user:resetPwd")@Log(title = "重置密码", businessType = BusinessType.UPDATE)@PostMapping("/resetPwd")@ResponseBodypublic AjaxResult resetPwdSave(User user){userService.checkUserAllowed(user);if (userService.resetUserPwd(user) > 0){if (ShiroUtils.getUserId() == user.getUserId()){setSysUser(userService.selectUserById(user.getUserId()));}return success();}return error();}@RequiresPermissions("system:user:remove")@Log(title = "用户管理", businessType = BusinessType.DELETE)@PostMapping("/remove")@ResponseBodypublic AjaxResult remove(String ids){try{return toAjax(userService.deleteUserByIds(ids));}catch (Exception e){return error(e.getMessage());}}/*** 校验用户名*/@PostMapping("/checkLoginNameUnique")@ResponseBodypublic String checkLoginNameUnique(User user){return userService.checkLoginNameUnique(user.getLoginName());}/*** 校验手机号码*/@PostMapping("/checkPhoneUnique")@ResponseBodypublic String checkPhoneUnique(User user){return userService.checkPhoneUnique(user);}/*** 校验email邮箱*/@PostMapping("/checkEmailUnique")@ResponseBodypublic String checkEmailUnique(User user){return userService.checkEmailUnique(user);}/*** 用户状态修改*/@Log(title = "用户管理", businessType = BusinessType.UPDATE)@RequiresPermissions("system:user:edit")@PostMapping("/changeStatus")@ResponseBodypublic AjaxResult changeStatus(User user){userService.checkUserAllowed(user);return toAjax(userService.changeStatus(user));}
}

商品管理Controller:

/*** 商品管理Controller* */
@Controller
@RequestMapping("/system/product")
public class ProductController extends BaseController
{private String prefix = "system/product";@Autowiredprivate IProductService productService;@Autowiredprivate ITypeService typeService;@RequiresPermissions("system:product:view")@GetMapping()public String product(){return prefix + "/product";}@GetMapping("/pet")public String pet(){return "system/pet/pet";}@PostMapping("/petList")@ResponseBodypublic TableDataInfo petList(Product product){startPage();product.setProductType("宠物信息");List<Product> list = productService.selectProductList(product);return getDataTable(list);}/*** 查询商品管理列表*/@RequiresPermissions("system:product:list")@PostMapping("/list")@ResponseBodypublic TableDataInfo list(Product product){startPage();product.setProductType("宠物用品");List<Product> list = productService.selectProductList(product);return getDataTable(list);}/*** 导出商品管理列表*/@RequiresPermissions("system:product:export")@Log(title = "商品管理", businessType = BusinessType.EXPORT)@PostMapping("/export")@ResponseBodypublic AjaxResult export(Product product){List<Product> list = productService.selectProductList(product);ExcelUtil<Product> util = new ExcelUtil<Product>(Product.class);return util.exportExcel(list, "product");}/*** 新增商品管理*/@GetMapping("/add")public String add( ModelMap mmap){return prefix + "/add";}/*** 新增商品管理*/@GetMapping("/petAdd")public String petAdd( ModelMap mmap){return "system/pet/add";}/*** 新增保存商品管理* @throws IOException */@RequiresPermissions("system:product:add")@Log(title = "商品管理", businessType = BusinessType.INSERT)@PostMapping("/add")@ResponseBodypublic AjaxResult addSave(Product product) throws IOException{User user = ShiroUtils.getSysUser();product.setUserId(user.getUserId());return toAjax(productService.insertProduct(product));}/*** 修改商品管理*/@GetMapping("/edit/{productId}")public String edit(@PathVariable("productId") Long productId, ModelMap mmap){Product product = productService.selectProductById(productId);mmap.put("product", product);return prefix + "/edit";}/*** 修改宠物管理*/@GetMapping("/petEdit/{productId}")public String petAdit(@PathVariable("productId") Long productId, ModelMap mmap){Product product = productService.selectProductById(productId);mmap.put("product", product);return prefix + "/edit";}/*** 修改保存商品管理*/@RequiresPermissions("system:product:edit")@Log(title = "商品管理", businessType = BusinessType.UPDATE)@PostMapping("/edit")@ResponseBodypublic AjaxResult editSave(Product product){return toAjax(productService.updateProduct(product));}/*** 删除商品管理*/@RequiresPermissions("system:product:remove")@Log(title = "商品管理", businessType = BusinessType.DELETE)@PostMapping( "/remove")@ResponseBodypublic AjaxResult remove(String ids){return toAjax(productService.deleteProductByIds(ids));}
}

订单管理Controller:

/*** 订单管理Controller*/
@Controller
@RequestMapping("/system/order")
public class OrderController extends BaseController
{private String prefix = "system/order";@Autowiredprivate IOrderService orderService;@Autowiredprivate IRoleService roleService;@Autowiredprivate IProductService productService;@Autowiredprivate IUserService userService;@Autowiredprivate ICartService cartService;@RequiresPermissions("system:order:view")@GetMapping()public String order(ModelMap mmap){User user = ShiroUtils.getSysUser();String roleString = roleService.selectRoleKeys(user.getUserId()).toString();if(roleString.contains("admin")){mmap.put("loginRole", "admin");}else	if(roleString.contains("seller")){mmap.put("loginRole", "seller");}else{mmap.put("loginRole", "buyer");}return prefix + "/order";}/*** 查询订单管理列表*/@RequiresPermissions("system:order:list")@PostMapping("/list")@ResponseBodypublic TableDataInfo list(Order order){User user = ShiroUtils.getSysUser();String roleString = roleService.selectRoleKeys(user.getUserId()).toString();startPage();List<Order> list;if(roleString.contains("admin")){list = orderService.selectOrderList(order);}else	if(roleString.contains("seller")){list = orderService.selectOrderBySellerId(user.getUserId());List<Order> queryList = new ArrayList<Order>();if(StringUtils.isNotEmpty(order.getOrderStatus())){for(int i = 0 ; i < list.size();i++){if(list.get(i).getOrderStatus().equals(order.getOrderStatus())){queryList.add(list.get(i));}}list = queryList;}}else{order.setUserId(user.getUserId());list = orderService.selectOrderList(order);}return getDataTable(list);}/*** 导出订单管理列表*/@RequiresPermissions("system:order:export")@Log(title = "订单管理", businessType = BusinessType.EXPORT)@PostMapping("/export")@ResponseBodypublic AjaxResult export(Order order){List<Order> list = orderService.selectOrderList(order);ExcelUtil<Order> util = new ExcelUtil<Order>(Order.class);return util.exportExcel(list, "order");}/*** 新增订单管理*/@GetMapping("/add")public String add(){return prefix + "/add";}/*** 新增保存订单管理*/@RequiresPermissions("system:order:add")@Log(title = "订单管理", businessType = BusinessType.INSERT)@PostMapping("/add")@ResponseBodypublic AjaxResult addSave(Order order){return toAjax(orderService.insertOrder(order));}/*** 前台创建订单*/@Log(title = "订单管理", businessType = BusinessType.INSERT)@PostMapping("/create")@ResponseBodypublic AjaxResult create(Order order){// 先判断用户积分是否充足User user = userService.selectUserById(ShiroUtils.getSysUser().getUserId());// 订单为待支付的状态order.setOrderStatus("0");order.setUserId(user.getUserId());order.setOrderTime(new Date());order.setPayWay("0");orderService.insertOrder(order);// 删除购物车数据Cart cart = new Cart();cart.setUserId(order.getUserId());cart.setProductId(order.getProductId());List<Cart> carts = cartService.selectCartList(cart);for(Cart item : carts){cartService.deleteCartById(item.getCartId());}return  AjaxResult.success(order.getOrderId());}/*** 前台创建订单*/@Log(title = "订单管理", businessType = BusinessType.INSERT)@GetMapping("/createorder/{productId}")public String createorder(@PathVariable("productId") Long productId , ModelMap mmap){Product product = productService.selectProductById(productId);mmap.put("productId", productId);mmap.put("orderPrice", product.getProductPrice());return  "front/createorder";}/*** 修改订单管理*/@GetMapping("/edit/{orderId}")public String edit(@PathVariable("orderId") Long orderId, ModelMap mmap){Order order = orderService.selectOrderById(orderId);mmap.put("order", order);return prefix + "/edit";}/*** 修改订单管理*/@GetMapping("/pay/{orderId}")public String pay(@PathVariable("orderId") Long orderId, ModelMap mmap){Order order = orderService.selectOrderById(orderId);mmap.put("order", order);return prefix + "/pay";}@GetMapping("/comment/{orderId}")public String comment(@PathVariable("orderId") Long orderId, ModelMap mmap){Order order = orderService.selectOrderById(orderId);mmap.put("order", order);return prefix + "/comment";}/*** 修改保存订单管理*/@Log(title = "订单管理", businessType = BusinessType.UPDATE)@PostMapping("/comment")@ResponseBodypublic AjaxResult commentSave(Order order){Order saveOrder = orderService.selectOrderById(order.getOrderId());saveOrder.setOrderComment(order.getOrderComment());saveOrder.setOrderCommentTime(new Date());saveOrder.setOrderStatus("5");saveOrder.setCommentUrl(order.getCommentUrl());return toAjax(orderService.updateOrder(saveOrder));}@GetMapping("/payOrder/{orderId}")@ResponseBodypublic AjaxResult payOrder(@PathVariable("orderId") Long orderId, ModelMap mmap){Order order = orderService.selectOrderById(orderId);order.setOrderStatus("1");return toAjax(orderService.updateOrder(order));}@PostMapping("/payOrder")@ResponseBodypublic AjaxResult payOrder(Order order, ModelMap mmap){order.setOrderStatus("1");return toAjax(orderService.updateOrder(order));}@GetMapping("/confirmStatus/{orderId}")@ResponseBodypublic AjaxResult confirmStatus(@PathVariable("orderId") Long orderId, ModelMap mmap){Order order = orderService.selectOrderById(orderId);order.setOrderStatus("2");return toAjax(orderService.updateOrder(order));}@GetMapping("/sendStatus/{orderId}")@ResponseBodypublic AjaxResult sendStatus(@PathVariable("orderId") Long orderId, ModelMap mmap){Order order = orderService.selectOrderById(orderId);order.setOrderStatus("3");return toAjax(orderService.updateOrder(order));}@GetMapping("/receiveStatus/{orderId}")@ResponseBodypublic AjaxResult receiveStatus(@PathVariable("orderId") Long orderId, ModelMap mmap){Order order = orderService.selectOrderById(orderId);order.setOrderStatus("4");return toAjax(orderService.updateOrder(order));}/*** 修改保存订单管理*/@RequiresPermissions("system:order:edit")@Log(title = "订单管理", businessType = BusinessType.UPDATE)@PostMapping("/edit")@ResponseBodypublic AjaxResult editSave(Order order){return toAjax(orderService.updateOrder(order));}/*** 删除订单管理*/@RequiresPermissions("system:order:remove")@Log(title = "订单管理", businessType = BusinessType.DELETE)@PostMapping( "/remove")@ResponseBodypublic AjaxResult remove(String ids){return toAjax(orderService.deleteOrderByIds(ids));}
}

 源码获取:俺的博客首页 "资源" 里下载!

这篇关于Java项目:宠物领养寄养商城系统(java+Springboot+HTML+bootstrap+mysql)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/241091

相关文章

Java中流式并行操作parallelStream的原理和使用方法

《Java中流式并行操作parallelStream的原理和使用方法》本文详细介绍了Java中的并行流(parallelStream)的原理、正确使用方法以及在实际业务中的应用案例,并指出在使用并行流... 目录Java中流式并行操作parallelStream0. 问题的产生1. 什么是parallelS

MySQL数据库双机热备的配置方法详解

《MySQL数据库双机热备的配置方法详解》在企业级应用中,数据库的高可用性和数据的安全性是至关重要的,MySQL作为最流行的开源关系型数据库管理系统之一,提供了多种方式来实现高可用性,其中双机热备(M... 目录1. 环境准备1.1 安装mysql1.2 配置MySQL1.2.1 主服务器配置1.2.2 从

Java中Redisson 的原理深度解析

《Java中Redisson的原理深度解析》Redisson是一个高性能的Redis客户端,它通过将Redis数据结构映射为Java对象和分布式对象,实现了在Java应用中方便地使用Redis,本文... 目录前言一、核心设计理念二、核心架构与通信层1. 基于 Netty 的异步非阻塞通信2. 编解码器三、

SpringBoot基于注解实现数据库字段回填的完整方案

《SpringBoot基于注解实现数据库字段回填的完整方案》这篇文章主要为大家详细介绍了SpringBoot如何基于注解实现数据库字段回填的相关方法,文中的示例代码讲解详细,感兴趣的小伙伴可以了解... 目录数据库表pom.XMLRelationFieldRelationFieldMapping基础的一些代

一篇文章彻底搞懂macOS如何决定java环境

《一篇文章彻底搞懂macOS如何决定java环境》MacOS作为一个功能强大的操作系统,为开发者提供了丰富的开发工具和框架,下面:本文主要介绍macOS如何决定java环境的相关资料,文中通过代码... 目录方法一:使用 which命令方法二:使用 Java_home工具(Apple 官方推荐)那问题来了,

Java HashMap的底层实现原理深度解析

《JavaHashMap的底层实现原理深度解析》HashMap基于数组+链表+红黑树结构,通过哈希算法和扩容机制优化性能,负载因子与树化阈值平衡效率,是Java开发必备的高效数据结构,本文给大家介绍... 目录一、概述:HashMap的宏观结构二、核心数据结构解析1. 数组(桶数组)2. 链表节点(Node

Java AOP面向切面编程的概念和实现方式

《JavaAOP面向切面编程的概念和实现方式》AOP是面向切面编程,通过动态代理将横切关注点(如日志、事务)与核心业务逻辑分离,提升代码复用性和可维护性,本文给大家介绍JavaAOP面向切面编程的概... 目录一、AOP 是什么?二、AOP 的核心概念与实现方式核心概念实现方式三、Spring AOP 的关

详解SpringBoot+Ehcache使用示例

《详解SpringBoot+Ehcache使用示例》本文介绍了SpringBoot中配置Ehcache、自定义get/set方式,并实际使用缓存的过程,文中通过示例代码介绍的非常详细,对大家的学习或者... 目录摘要概念内存与磁盘持久化存储:配置灵活性:编码示例引入依赖:配置ehcache.XML文件:配置

Java 虚拟线程的创建与使用深度解析

《Java虚拟线程的创建与使用深度解析》虚拟线程是Java19中以预览特性形式引入,Java21起正式发布的轻量级线程,本文给大家介绍Java虚拟线程的创建与使用,感兴趣的朋友一起看看吧... 目录一、虚拟线程简介1.1 什么是虚拟线程?1.2 为什么需要虚拟线程?二、虚拟线程与平台线程对比代码对比示例:三

vite搭建vue3项目的搭建步骤

《vite搭建vue3项目的搭建步骤》本文主要介绍了vite搭建vue3项目的搭建步骤,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学... 目录1.确保Nodejs环境2.使用vite-cli工具3.进入项目安装依赖1.确保Nodejs环境