作者主页:夜未央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+H-ui+jQuery+Bootstrap
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中jdbc.properties配置文件中的数据库配置改为自己的配置;
4. 前台访问路径:http://localhost:8080/fore/foreIndex
后台访问地址:http://localhost:8080/login
前台界面

后台界面

- package com.byh.biyesheji.controller;
-
- import com.byh.biyesheji.pojo.Category;
- import com.byh.biyesheji.service.CategoryService;
- 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 java.util.List;
-
- /**
- * 商品分类模块controller
- */
- @Controller
- @RequestMapping("/category")
- public class CategoryController {
-
- @Autowired
- private CategoryService categoryService;
-
- @RequestMapping("/list")
- public String list(Model model){
- List
list = categoryService.list(); - model.addAttribute("list",list);
- model.addAttribute("size",list.size());
- return "productmodule/category-list";
- }
-
- @RequestMapping("/addCategory")
- public String add(@RequestParam(value = "name")String name){
- Category category = new Category();
- category.setName(name);
- categoryService.save(category);
- return "productmodule/category-list";
- }
-
- @RequestMapping("/delCategory")
- public String del(@RequestParam(value = "id")int id){
- categoryService.del(id);
- return "redirect:list";
- }
-
- @RequestMapping("/editCategory")
- public String edit(@RequestParam(value = "id")int id,Model model){
- Category category = categoryService.get(id);
- model.addAttribute("category",category);
- return "productmodule/category-edit";
- }
-
- @RequestMapping("/updateCategory")
- public String update(Category category,Model model){
- categoryService.update(category);
- return "redirect:list";
- }
-
- }
- package com.byh.biyesheji.controller;
-
- import com.byh.biyesheji.pojo.Customer;
- import com.byh.biyesheji.pojo.Product;
- import com.byh.biyesheji.service.CustomerService;
- import com.byh.biyesheji.util.Page;
- import com.github.pagehelper.PageHelper;
- import com.github.pagehelper.PageInfo;
- 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.ResponseBody;
-
- import java.util.List;
-
- /**
- * 用户模块controller
- */
- @Controller
- @RequestMapping("/customer")
- public class CustomerController {
-
- @Autowired
- private CustomerService customerService;
-
- @RequestMapping("/list")
- public String list(Model model, Page page){
- PageHelper.offsetPage(page.getStart(),page.getCount());//分页查询
- List
list= customerService.list(); - int total = (int) new PageInfo<>(list).getTotal();//总条数
- page.setTotal(total);
-
- model.addAttribute("list",list);
- model.addAttribute("totals",total);
- return "cstpage/cst-list";
- }
-
- /**
- * 设置会员
- * @param id
- * @return
- */
- @RequestMapping("/shezhihuiyuan")
- @ResponseBody
- public String shezhihuiyuan(int id){
- customerService.shezhihuiyuan(id);
- return "success";
- }
-
- @RequestMapping("/del")
- public String del(int id){
- customerService.del(id);
- return "redirect:list";
- }
- }
- package com.byh.biyesheji.controller;
-
- import com.byh.biyesheji.pojo.User;
- import com.byh.biyesheji.service.UserService;
- import org.apache.shiro.SecurityUtils;
- import org.apache.shiro.authc.AuthenticationException;
- import org.apache.shiro.authc.UsernamePasswordToken;
- import org.apache.shiro.session.Session;
- import org.apache.shiro.subject.Subject;
- 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.RequestMethod;
-
- import java.text.ParseException;
- import java.text.ParsePosition;
- import java.text.SimpleDateFormat;
- import java.util.Date;
-
- /**
- * 后台登陆
- */
- @Controller
- @RequestMapping("")
- public class LoginController {
-
- @Autowired
- UserService userService;
-
- @RequestMapping(value="/login",method=RequestMethod.POST)
- public String login(Model model, String name, String password){//throws ParseException
- Subject subject = SecurityUtils.getSubject();
- UsernamePasswordToken token = new UsernamePasswordToken(name,password);
- try {
- subject.login(token);
- User us = userService.getByName(name);
- String lastLoginTime = "";
- if(us!=null){
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- //上次时间
- Date time = us.getLasttime();
- lastLoginTime = sdf.format(time);
- //新时间
- String format = sdf.format(new Date());
- //string转date 不处理时间格式会不理想
- ParsePosition pos = new ParsePosition(0);
- Date strtodate = sdf.parse(format, pos);
- us.setLasttime(strtodate);
- userService.update(us);
- }
- if (us.getStatus()==1){
- Session session=subject.getSession();
- session.setAttribute("subject", subject);
- session.setAttribute("lastLoginTime",lastLoginTime);
- return "redirect:index";
- }else {
- model.addAttribute("error", "账号已被停用!");
- return "/login";
- }
-
- } catch (AuthenticationException e) {
- model.addAttribute("error", "验证失败!");
- return "/login";
- }
- }
-
-
- }
- package com.byh.biyesheji.controller;
-
-
- import com.byh.biyesheji.pojo.Order;
- import com.byh.biyesheji.service.OrderItemService;
- import com.byh.biyesheji.service.OrderService;
- import com.byh.biyesheji.util.Page;
- import com.github.pagehelper.PageHelper;
- import com.github.pagehelper.PageInfo;
- 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.ResponseBody;
-
- import java.util.List;
-
- /**
- * 订单模块controller
- */
- @Controller
- @RequestMapping("/order")
- public class OrderController {
-
- @Autowired
- OrderService orderService;
- @Autowired
- OrderItemService orderItemService;
-
- /**
- * 所有订单
- * @param model
- * @param page
- * @return
- */
- @RequestMapping("/list")
- public String list(Model model, Page page){
- PageHelper.offsetPage(page.getStart(),page.getCount());
-
- List
os= orderService.list(); -
- int total = (int) new PageInfo<>(os).getTotal();
- page.setTotal(total);
- //为订单添加订单项数据
- orderItemService.fill(os);
-
- model.addAttribute("os", os);
- model.addAttribute("page", page);
- model.addAttribute("totals", total);
-
- return "ordermodule/order-list";
- }
-
- /**
- * 订单发货
- * @param o
- * @return
- */
- @RequestMapping("/orderDelivery")
- public String delivery(Order o){
- o.setStatus(2);
- orderService.update(o);
- return "redirect:list";
- }
-
- /**
- * 查看当前订单的订单项
- * @param oid
- * @param model
- * @return
- */
- @RequestMapping("/seeOrderItem")
- public String seeOrderItem(int oid,Model model){
- Order o = orderService.get(oid);
- orderItemService.fill(o);
- model.addAttribute("orderItems",o.getOrderItems());
- model.addAttribute("total",o.getOrderItems().size());
- model.addAttribute("totalPrice",o.getTotal());
- return "ordermodule/orderItem-list";
- }
-
- }
如果也想学习本系统,下面领取。回复:181ssm