Java项目:宠物商城带后台管理系统(java+SSM+JSP+jQuery+Ajax+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. 后端:Spring+SpringMVC+Mybatis
2. 前端:JSP+jQuery+Ajax


使用说明

1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中jdbc.properties配置文件中的数据库配置改为自己的配置;
4. 运行项目,在浏览器中输入http://localhost:8080/ 登录
用户账号/密码: user/123456
管理员账号/密码:admin/admin


 

 

 

 

 

购物车Controller:

/**
 * 购物车Controller
 * 
 */
@Controller
@RequestMapping("/system/cart")
public class CartController extends BaseController
{
    private String prefix = "system/cart";

    @Autowired
    private ICartService cartService;

    @RequiresPermissions("system:cart:view")
    @GetMapping()
    public String cart()
    {
        return prefix + "/cart";
    }

    /**
     * 查询购物车列表
     */
    @RequiresPermissions("system:cart:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(Cart cart)
    {
    	Long userId = ShiroUtils.getSysUser().getUserId();
    	cart.setUserId(userId);
        startPage();
        List<Cart> list = cartService.selectCartList(cart);
        return getDataTable(list);
    }

    /**
     * 导出购物车列表
     */
    @RequiresPermissions("system:cart:export")
    @Log(title = "购物车", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Cart cart)
    {
        List<Cart> list = cartService.selectCartList(cart);
        ExcelUtil<Cart> util = new ExcelUtil<Cart>(Cart.class);
        return util.exportExcel(list, "cart");
    }

    /**
     * 新增购物车
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存购物车
     */
    @RequiresPermissions("system:cart:add")
    @Log(title = "购物车", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(Cart cart)
    {
        return toAjax(cartService.insertCart(cart));
    }
    
    /**
     * 新增保存购物车
     */
    @Log(title = "购物车", businessType = BusinessType.INSERT)
    @GetMapping("/addcart/{productId}")
    @ResponseBody
    public AjaxResult addcart(@PathVariable("productId") Long productId,Cart cart)
    {
    	Long userId = ShiroUtils.getSysUser().getUserId();
    	cart.setProductId(productId);
    	cart.setUserId(userId);
    	cartService.insertCart(cart);
    	return AjaxResult.success("加入购物车成功!");
    }

    /**
     * 修改购物车
     */
    @GetMapping("/edit/{cartId}")
    public String edit(@PathVariable("cartId") Long cartId, ModelMap mmap)
    {
        Cart cart = cartService.selectCartById(cartId);
        mmap.put("cart", cart);
        return prefix + "/edit";
    }

    /**
     * 修改保存购物车
     */
    @RequiresPermissions("system:cart:edit")
    @Log(title = "购物车", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(Cart cart)
    {
        return toAjax(cartService.updateCart(cart));
    }

    /**
     * 删除购物车
     */
    @RequiresPermissions("system:cart:remove")
    @Log(title = "购物车", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(cartService.deleteCartByIds(ids));
    }
}

订单管理Controller:

/**
 * 订单管理Controller
 * 
 */
@Controller
@RequestMapping("/system/order")
public class OrderController extends BaseController
{
    private String prefix = "system/order";

    @Autowired
    private IOrderService orderService;
    @Autowired
    private IRoleService roleService;
    @Autowired
    private IProductService productService;

    @Autowired
    private IUserService userService;

    @Autowired
    private 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")
    @ResponseBody
    public 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")
    @ResponseBody
    public 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")
    @ResponseBody
    public AjaxResult addSave(Order order)
    {
        return toAjax(orderService.insertOrder(order));
    }
    
    
    /**
     * 前台创建订单
     */
    @Log(title = "订单管理", businessType = BusinessType.INSERT)
    @PostMapping("/create")
    @ResponseBody
    public 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")
    @ResponseBody
    public 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}")
    @ResponseBody
    public AjaxResult payOrder(@PathVariable("orderId") Long orderId, ModelMap mmap)
    {
        Order order = orderService.selectOrderById(orderId);
        order.setOrderStatus("1");
        return toAjax(orderService.updateOrder(order));
    }
    
    @PostMapping("/payOrder")
    @ResponseBody
    public AjaxResult payOrder(Order order, ModelMap mmap)
    {
        order.setOrderStatus("1");
        return toAjax(orderService.updateOrder(order));
    }
    @GetMapping("/confirmStatus/{orderId}")
    @ResponseBody
    public AjaxResult confirmStatus(@PathVariable("orderId") Long orderId, ModelMap mmap)
    {
    	Order order = orderService.selectOrderById(orderId);
    	order.setOrderStatus("2");
    	return toAjax(orderService.updateOrder(order));
    }
    @GetMapping("/sendStatus/{orderId}")
    @ResponseBody
    public AjaxResult sendStatus(@PathVariable("orderId") Long orderId, ModelMap mmap)
    {
    	Order order = orderService.selectOrderById(orderId);
    	order.setOrderStatus("3");
    	return toAjax(orderService.updateOrder(order));
    }

    @GetMapping("/receiveStatus/{orderId}")
    @ResponseBody
    public 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")
    @ResponseBody
    public AjaxResult editSave(Order order)
    {
        return toAjax(orderService.updateOrder(order));
    }

    /**
     * 删除订单管理
     */
    @RequiresPermissions("system:order:remove")
    @Log(title = "订单管理", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(orderService.deleteOrderByIds(ids));
    }
}

用户信息管理控制层: 

/**
 * 用户信息
 * 
 */
@Controller
@RequestMapping("/system/user")
public class UserController extends BaseController
{
    private String prefix = "system/user";

    @Autowired
    private IUserService userService;

    @Autowired
    private IRoleService roleService;

    @Autowired
    private IPostService postService;

    @RequiresPermissions("system:user:view")
    @GetMapping()
    public String user()
    {
        return prefix + "/user";
    }

    @RequiresPermissions("system:user:list")
    @PostMapping("/list")
    @ResponseBody
    public 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")
    @ResponseBody
    public 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")
    @ResponseBody
    public 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")
    @ResponseBody
    public 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")
    @ResponseBody
    public 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")
    @ResponseBody
    public 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")
    @ResponseBody
    public 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")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        try
        {
            return toAjax(userService.deleteUserByIds(ids));
        }
        catch (Exception e)
        {
            return error(e.getMessage());
        }
    }

    /**
     * 校验用户名
     */
    @PostMapping("/checkLoginNameUnique")
    @ResponseBody
    public String checkLoginNameUnique(User user)
    {
        return userService.checkLoginNameUnique(user.getLoginName());
    }

    /**
     * 校验手机号码
     */
    @PostMapping("/checkPhoneUnique")
    @ResponseBody
    public String checkPhoneUnique(User user)
    {
        return userService.checkPhoneUnique(user);
    }

    /**
     * 校验email邮箱
     */
    @PostMapping("/checkEmailUnique")
    @ResponseBody
    public String checkEmailUnique(User user)
    {
        return userService.checkEmailUnique(user);
    }

    /**
     * 用户状态修改
     */
    @Log(title = "用户管理", businessType = BusinessType.UPDATE)
    @RequiresPermissions("system:user:edit")
    @PostMapping("/changeStatus")
    @ResponseBody
    public AjaxResult changeStatus(User user)
    {
        userService.checkUserAllowed(user);
        return toAjax(userService.changeStatus(user));
    }
}

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

这是基于JAVAweb的宠物管理系统。 资源包里包含了所有完整源码、包含环境安装包、环境搭建运行测试视频。 一、设计需求 本系统主要是由RFID自动识别技术,通过无线射频方式对宠物的电子标签进行读取,获取宠物的基本信息和在店内的所有消费,然后将数据通过网络传输至服务器。在应用层开发一个管理系统,对宠物信息、店内消费等各种行为进行管理。同时系统需有登录注册功能,宠物信息管理,店内消费管理等功能。 宠物店管理系统主要分为以下模块: 1.RFID模块:由天线和射频电路组成,通过自动识别电子标签,采集数据,采用RFID封装技术将其封装,并传输给服务器。 2.电子标签模块:接收外部信号和发送信号 3.店铺管理模块:管理员可以对店铺商品进行增删改操作,修改、删除顾客宠物信息以及店内消费行为。 4.登录注册模块:新用户可以进行注册和登录5.用户管理模块:对注册用户进行管理 二、设计需求总结 整个系统的设计: (1). 宠物店每来一个新的宠物,就在软件端进行注册、注册时填入宠物的名称,宠物的类型,主人的电话号码、选择一张宠物的图片方便后面展示(图片可以预存几张猫、狗即可)、如果宠物后面在店里有消费也会记录包含时间,这些数据都保存在软件端的数据库里。 (2). 开卡: 新宠物注册之后,需要为这个宠物办理一张电子标签卡,这个卡里存放着这个宠物主人的电话号码,后面要查询这个宠物的信息,就读取整个电子标签里的电话号码,到数据库里查询。 (3). 开卡和查询的数据传输: 设备端与软件端采用 TCP网络方式进行通信;设备端当做TCP客户端,软件端当做TCP服务器;当设备端查询宠物的电子标签时,设备端读取电话号码之后,会通过约定的数据格式通过网络传递给软件端。 当软件端开卡注册时,也会用约定好的数据格式传递给设备端,如果设备端收到数据,开发板上的LED会点亮;这时把IC拿到RC522射频模块上刷一下即可;如果成功写入LED灯就会关闭。 (4). 软件端的设计(这个软件是给店家用的,功能都是针对店家这边方向开发): 有注册界面、登录界面; 主界面上显示店内有所有注册过的宠物信息,每个宠物有图片进行显示、宠物图片下面就显示宠物的名称; 商品界面: 展示一些狗粮、猫粮、药剂、一些宠物周边物品。 用于演示消费功能。 可以预定几个商品即可。 用户可以自己动态添加修改。 管理员界面: 可以对店内的商品进行添加、设计价格、修改宠物的信息等。 查询页面: 输入宠物信息可以查询这个宠物在店里的所有详细信息。
评论 8
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

OldWinePot

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值