作者主页:舒克日记
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文中获取源码
项目介绍
主要功能包括:
1.前台模块
(1)普通用户登录/注册。
(2)分类查看商品(普通商品与促销商品)
(3)查看商品详细信息
(4)查看秒杀商品
(5)查看竞拍商品
(6)将商品加入购物车
(7)购买,结算功能
(8)留言
2.后台模块
(1)修改密码
(2)商品管理:
– 编辑/删除
– 设置/取消促销
(3)秒杀商品:设置/取消秒杀
(4)竞拍商品:设置/取消竞拍
(5)订单管理:查看订单
(5)留言管理:查看/删除留言
点击查看演示视频
环境要求
1.运行环境:最好是java jdk1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat7.x,8.X,9.x版本均可
4.硬件环境:windows7/8/10 4G内存以上;或者Mac OS;
5.是否Maven项目:是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven.项目
6.数据库:MySql5.7/8.0等版本均可;
技术栈
运行环境:jdk8 + tomcat9 + mysql5.7 + windows10
服务端技术:javaWeb + jsp + Jquery + Layui
使用说明
1.使用Navicati或者其它工具,在mysql中创建对应sq文件名称的数据库,并导入项目的sql文件;
2.使用IDEA/Eclipse/MyEclipse导入项目,修改配置,运行项目;
3.将项目中config-propertiesi配置文件中的数据库配置改为自己的配置,然后运行;
运行指导
idea导入源码空间站顶目教程说明(Vindows版)-ssm篇:
http://mtw.so/5MHvZq
源码地址:http://codegym.top。
运行截图
文档截图
前端界面
后台界面
代码
IndexAction
package cn.itbaizhan.action;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.View;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.view.JspView;
import cn.itbaizhan.bean.Order;
import cn.itbaizhan.bean.Product;
import cn.itbaizhan.bean.User;
import cn.itbaizhan.service.OrderService;
import cn.itbaizhan.service.ProductService;
import cn.itbaizhan.service.UserService;
@IocBean
@At("/index")
public class IndexAction {
@Inject("refer:productService")
private ProductService productService;
@Inject("refer:orderService")
private OrderService orderService;
@Inject("refer:userService")
private UserService userService;
/**
* 跳转到首页
* @param request
* @return
*/
@At("/toIndex")
public View toIndex(HttpServletRequest request){
//新品上市
List<Product> newlist = productService.findNewProduct();
request.setAttribute("newlist", newlist);
//促销
List<Product> cxlist = productService.findCxProduct();
request.setAttribute("cxlist", cxlist);
return new JspView("jsp.index");
}
/**
* 跳转到促销
* @param request
* @return
*/
@At("/toPromotions")
public View toPromotions(HttpServletRequest request){
//促销
List<Product> cxlist = productService.findCxProduct();
request.setAttribute("cxlist", cxlist);
//新品上市
List<Product> newlist = productService.findNewProduct();
request.setAttribute("newlist", newlist);
return new JspView("jsp.promotions");
}
/**
* 跳转到秒杀
* @param request
* @return
*/
@At("/toSpike")
public View toSpike(HttpServletRequest request){
//促销
List<Product> cxlist = productService.findCxProduct();
request.setAttribute("cxlist", cxlist);
//新品上市
List<Product> newlist = productService.findNewProduct();
request.setAttribute("newlist", newlist);
//秒杀
List<Product> mslist = productService.findMsList();
request.setAttribute("mslist", mslist);
return new JspView("jsp.spike");
}
/**
* 跳转到竞拍
* @param request
* @return
*/
@At("/toAuction")
public View toAuction(HttpServletRequest request){
//促销
List<Product> cxlist = productService.findCxProduct();
request.setAttribute("cxlist", cxlist);
//新品上市
List<Product> newlist = productService.findNewProduct();
request.setAttribute("newlist", newlist);
//竞拍
List<Product> jplist = productService.findJpList();
request.setAttribute("jplist", jplist);
return new JspView("jsp.auction");
}
/**
* 跳转到留言
* @param request
* @return
*/
@At("/toMessage")
public View toMessage(HttpServletRequest request){
return new JspView("jsp.message");
}
/**
* 跳转到产品详细
* @param request
* @return
*/
@At("/toDetail")
public View toDetail(HttpServletRequest request){
String id = request.getParameter("id");
Product product = productService.findProductById(Integer.parseInt(id));
//新品上市
List<Product> newlist = productService.findNewProduct();
request.setAttribute("newlist", newlist);
request.setAttribute("product", product);
return new JspView("jsp.detail");
}
/**
* 跳转到促销产品详细
* @param request
* @return
*/
@At("/tocxDetail")
public View tocxDetail(HttpServletRequest request){
String id = request.getParameter("id");
Product product = productService.findProductById(Integer.parseInt(id));
//促销
List<Product> cxlist = productService.findCxProduct();
request.setAttribute("cxlist", cxlist);
request.setAttribute("product", product);
return new JspView("jsp.cxdetail");
}
/**
* 跳转到秒杀产品详细
* @param request
* @return
*/
@At("/tomsDetail")
public View tomsDetail(HttpServletRequest request){
String id = request.getParameter("id");
Product product = productService.findProductById(Integer.parseInt(id));
//促销
List<Product> cxlist = productService.findCxProduct();
request.setAttribute("cxlist", cxlist);
request.setAttribute("product", product);
Calendar c =Calendar.getInstance();
try{
c.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(product.getMsdate()));
}catch (ParseException e) {
e.printStackTrace();
}
long current_time=System.currentTimeMillis();
long end_time=c.getTimeInMillis();
long time=end_time-current_time;
request.setAttribute("time", time/1000);
return new JspView("jsp.msdetail");
}
/**
* 跳转到竞拍产品详细
* @param request
* @return
*/
@At("/tojpDetail")
public View tojpDetail(HttpServletRequest request){
String id = request.getParameter("id");
Product product = productService.findProductById(Integer.parseInt(id));
//促销
List<Product> cxlist = productService.findCxProduct();
request.setAttribute("cxlist", cxlist);
request.setAttribute("product", product);
Calendar c =Calendar.getInstance();
try{
c.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(product.getJpdate()));
}catch (ParseException e) {
e.printStackTrace();
}
long current_time=System.currentTimeMillis();
long end_time=c.getTimeInMillis();
long time=end_time-current_time;
request.setAttribute("time", time/1000);
return new JspView("jsp.jpdetail");
}
/**
* 跳转到购物车
* @param request
* @return
*/
@At("/toCart")
public View toCart(HttpServletRequest request){
User user = (User)request.getSession().getAttribute("user");
List<Order> list = orderService.getCartList(user.getId());
request.setAttribute("list", list);
int sumprice = 0;
for(int i=0;i<list.size();i++){
list.get(i).setUser(userService.findUserById(list.get(i).getUserid()));
list.get(i).setProduct(productService.findProductById(list.get(i).getProid()));
if(sumprice==0){
sumprice = Integer.parseInt(list.get(i).getPrice());
}else{
sumprice += Integer.parseInt(list.get(i).getPrice());
}
}
request.setAttribute("sumprice", sumprice);
request.setAttribute("count", list.size());
return new JspView("jsp.cart");
}
/**
* 跳转到后台登录页
* @param request
* @return
*/
@At("/toAdmin")
public View toAdmin(HttpServletRequest request){
return new JspView("jsp.admin.login");
}
}