Java项目:SSM在线个人PC电脑商城平台网站系统

作者主页:夜未央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. 后端: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. 运行项目,输入localhost:8080/ 登录

运行截图

前台界面

 

 

 

 

 

 

 

后台界面

 

 

 

 

 

 

相关代码

注册控制器

package com.shop.controller;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.validation.ObjectError;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.shop.exception.zdyException;
import com.shop.po.User;
import com.shop.service.UserService;


@Controller
public class registController {
	@Autowired
	private UserService userService;

	@RequestMapping("regist")
	public String regist() {
		return "regist";
	}

	@RequestMapping("/userRegist")
	public String userRegist(Model model, HttpServletRequest request,
			@Validated User user, BindingResult bindingResult,
			@RequestParam String checkImg) throws Exception {
		if (bindingResult.hasErrors()) {
			List<ObjectError> errors =bindingResult.getAllErrors();
			List<String> list = new ArrayList<>();
			for (ObjectError objectError : errors) {
				String str = new String(objectError.getDefaultMessage()
						.getBytes("ISO-8859-1"), "gbk");
				list.add(str);
			}
			model.addAttribute("errors", list);
			return "regist";
		}
		// 查看验证码
		String sessionCode = (String) request.getSession().getAttribute(
				"checkcode");
//		System.out.println("adadadad" + sessionCode);
		if (!sessionCode.equalsIgnoreCase(checkImg)) {
//			model.addAttribute("message", "验证码错误请重新注册");
			throw new zdyException("验证码错误请重新注册");
		}
		// 开始写入数据库
		userService.saveUser(user);
		//model.addAttribute("message", "注册成功请去邮箱激活");
		model.addAttribute("message", "注册成功请登录");
		return "msg";
	}

	@RequestMapping("/activeUser")
	public String activeUser(@RequestParam String code,Model model) throws zdyException,Exception  {
		/*
		 * 根据传递激活码进行用户查询. 如果用户不为空: 修改用户状态 改为1 如果用户为空: 激活码被篡改了.
		 */
			User activeUser = userService.findByCode(code);
			if(activeUser==null){
//				model.addAttribute("message", "激活码被篡改了,请重新注册");
				throw new zdyException("激活码被篡改了,请重新注册");
			}
			activeUser.setState(1);
			activeUser.setCode(null);
			userService.activeUser(activeUser);
			model.addAttribute("message", "激活码成功");
		return "msg";
	}
}

产品控制器

package com.shop.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.shop.po.Product;
import com.shop.service.ProductService;

@Controller
public class ProductController {
	@Autowired
	private ProductService prodcutService;

	@RequestMapping("/productFindByPid")
	public String productFindByPid(@RequestParam int pid,Model model) throws Exception {
			Product product = prodcutService.productFindByPid(pid);
			model.addAttribute("product", product);
		return "product";
	}
}

订单控制器

package com.shop.controller;

import java.util.Date;
import java.util.Map;
import java.util.Map.Entry;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.shop.Utils.PageBean;
import com.shop.po.Cart;
import com.shop.po.CartItem;
import com.shop.po.Orderitem;
import com.shop.po.Orders;
import com.shop.po.User;
import com.shop.service.OrderService;


@Controller
public class orderController {
	@Autowired
	private OrderService orderService;

	@RequestMapping("/toOrder")
	public String toOrder(HttpServletRequest request,Model model) throws Exception {
		Orders orders = new Orders();
		Cart cart = (Cart) request.getSession().getAttribute("cart");
		User loginUser = (User) request.getSession().getAttribute("loginUser");
		if(loginUser==null){
			model.addAttribute("message", "对不起您还没有登录");
			return "msg";
		}
//		0表示没有付款、1表示已付款即将发货 2表示确认收货 3表示交易成功
		orders.setState(0);
		orders.setOrderTime(new Date());
		orders.setUid(loginUser.getUid());
		orders.setMoney(cart.getTotale());

		orderService.toOrder(orders);

		Map<Integer, CartItem> cartItems = cart.getCartItem();
		for (Entry<Integer, CartItem> entry : cartItems.entrySet()) {
			CartItem cartItem = entry.getValue();
			Orderitem orderitem = new Orderitem();
			orderitem.setProduct(cartItem.getProduct());
			orderitem.setCount(cartItem.getCount());
			orderitem.setPid(cartItem.getProduct().getPid());
			orderitem.setSubtotal(cartItem.getSubtotle());
			orderitem.setOid(orders.getOid());
			orders.getOiList().add(orderitem);
			orderService.toOrderItem(orderitem);
		}
		cart.clearCart();
		request.getSession().setAttribute("orders", orders);
		return "order";
	}

	// 为定单付款
	@RequestMapping("/payOrder")
	public String payOrder(Orders orders,@RequestParam String receiveInfo,@RequestParam String phoNum,@RequestParam String accepter) throws Exception {
		orders.setReceiveinfo(receiveInfo);
		orders.setPhonum(phoNum);
		orders.setAccepter(accepter);
		orderService.payOrder(orders);
		return "redirect:myOrder.action?page=1";
	}
   //payOrderAganin
	@RequestMapping("/payOrderAganin")
	public String payOrderAganin(@RequestParam int oid,HttpServletRequest request){
		Orders noPayOrder = orderService.findOrderByOid(oid);
		request.getSession().setAttribute("orders", noPayOrder);
		return "order";
	}
	// 查询myOrder
	@RequestMapping("/myOrder")
	public String myOrder(@RequestParam int page, Model model,
			HttpServletRequest request) throws Exception {
		User loginUser = (User) request.getSession().getAttribute("loginUser");
		PageBean<Orders> pageBean = orderService.findOrderByUidAndPage(page,loginUser.getUid());
		model.addAttribute("pageBean", pageBean);
		return "orderList";
	}
	
	// 确认收货
		@RequestMapping("/updateState")
		public String updateState(@RequestParam int oid ) throws Exception {
			orderService.updateOrderStatus(oid, 3);
			return "redirect:myOrder.action?page=1";
		}
}

留言控制器

package com.shop.controller;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.shop.Utils.PageBean;
import com.shop.po.Message;
import com.shop.po.User;
import com.shop.service.MessageService;


@Controller
public class messageController {
	@Autowired
	private MessageService messageService;

	@RequestMapping("/saveMessage")
	public String saveMessage(@RequestParam String messageinfo,HttpServletRequest request,Model model) throws Exception {
		Message Message = new Message();
		 
		User loginUser = (User) request.getSession().getAttribute("loginUser");
		if(loginUser==null){
			model.addAttribute("message", "对不起您还没有登录");
			return "msg";
		}
 
		java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		
		Message.setMessage(messageinfo);
		Message.setUid(loginUser.getUid());
		Message.setMessagedate(sdf.format(new Date()));

		messageService.insertMessage(Message);
		 
		request.getSession().setAttribute("Message", Message);
		return "redirect:/messageList.action?page=1";
	}

	 
	// 显示留言板全部留言
	@RequestMapping("/messageList")
	public String messageList(@RequestParam int page, Model model,
			HttpServletRequest request) throws Exception {
		PageBean<Message> pageBean = messageService.findAllMessageByPage(page);
		model.addAttribute("pageBean", pageBean);
		return "messageList";
	} 
}

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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

夜未央5788

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

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

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

打赏作者

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

抵扣说明:

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

余额充值