• Java项目:ssm校园在线点餐系统源码


    作者主页:夜未央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

    运行截图

    前台界面

     

     

     

     

     

     

    后台界面

     

     

     

     

     

     

     

    相关代码

    分类控制器

    1. package com.byh.biyesheji.controller;
    2. import com.byh.biyesheji.pojo.Category;
    3. import com.byh.biyesheji.service.CategoryService;
    4. import org.springframework.beans.factory.annotation.Autowired;
    5. import org.springframework.stereotype.Controller;
    6. import org.springframework.ui.Model;
    7. import org.springframework.web.bind.annotation.RequestMapping;
    8. import org.springframework.web.bind.annotation.RequestParam;
    9. import java.util.List;
    10. /**
    11. * 商品分类模块controller
    12. */
    13. @Controller
    14. @RequestMapping("/category")
    15. public class CategoryController {
    16. @Autowired
    17. private CategoryService categoryService;
    18. @RequestMapping("/list")
    19. public String list(Model model){
    20. List list = categoryService.list();
    21. model.addAttribute("list",list);
    22. model.addAttribute("size",list.size());
    23. return "productmodule/category-list";
    24. }
    25. @RequestMapping("/addCategory")
    26. public String add(@RequestParam(value = "name")String name){
    27. Category category = new Category();
    28. category.setName(name);
    29. categoryService.save(category);
    30. return "productmodule/category-list";
    31. }
    32. @RequestMapping("/delCategory")
    33. public String del(@RequestParam(value = "id")int id){
    34. categoryService.del(id);
    35. return "redirect:list";
    36. }
    37. @RequestMapping("/editCategory")
    38. public String edit(@RequestParam(value = "id")int id,Model model){
    39. Category category = categoryService.get(id);
    40. model.addAttribute("category",category);
    41. return "productmodule/category-edit";
    42. }
    43. @RequestMapping("/updateCategory")
    44. public String update(Category category,Model model){
    45. categoryService.update(category);
    46. return "redirect:list";
    47. }
    48. }

    用户模块controller

    1. package com.byh.biyesheji.controller;
    2. import com.byh.biyesheji.pojo.Customer;
    3. import com.byh.biyesheji.pojo.Product;
    4. import com.byh.biyesheji.service.CustomerService;
    5. import com.byh.biyesheji.util.Page;
    6. import com.github.pagehelper.PageHelper;
    7. import com.github.pagehelper.PageInfo;
    8. import org.springframework.beans.factory.annotation.Autowired;
    9. import org.springframework.stereotype.Controller;
    10. import org.springframework.ui.Model;
    11. import org.springframework.web.bind.annotation.RequestMapping;
    12. import org.springframework.web.bind.annotation.ResponseBody;
    13. import java.util.List;
    14. /**
    15. * 用户模块controller
    16. */
    17. @Controller
    18. @RequestMapping("/customer")
    19. public class CustomerController {
    20. @Autowired
    21. private CustomerService customerService;
    22. @RequestMapping("/list")
    23. public String list(Model model, Page page){
    24. PageHelper.offsetPage(page.getStart(),page.getCount());//分页查询
    25. List list= customerService.list();
    26. int total = (int) new PageInfo<>(list).getTotal();//总条数
    27. page.setTotal(total);
    28. model.addAttribute("list",list);
    29. model.addAttribute("totals",total);
    30. return "cstpage/cst-list";
    31. }
    32. /**
    33. * 设置会员
    34. * @param id
    35. * @return
    36. */
    37. @RequestMapping("/shezhihuiyuan")
    38. @ResponseBody
    39. public String shezhihuiyuan(int id){
    40. customerService.shezhihuiyuan(id);
    41. return "success";
    42. }
    43. @RequestMapping("/del")
    44. public String del(int id){
    45. customerService.del(id);
    46. return "redirect:list";
    47. }
    48. }

    登录控制器

    1. package com.byh.biyesheji.controller;
    2. import com.byh.biyesheji.pojo.User;
    3. import com.byh.biyesheji.service.UserService;
    4. import org.apache.shiro.SecurityUtils;
    5. import org.apache.shiro.authc.AuthenticationException;
    6. import org.apache.shiro.authc.UsernamePasswordToken;
    7. import org.apache.shiro.session.Session;
    8. import org.apache.shiro.subject.Subject;
    9. import org.springframework.beans.factory.annotation.Autowired;
    10. import org.springframework.stereotype.Controller;
    11. import org.springframework.ui.Model;
    12. import org.springframework.web.bind.annotation.RequestMapping;
    13. import org.springframework.web.bind.annotation.RequestMethod;
    14. import java.text.ParseException;
    15. import java.text.ParsePosition;
    16. import java.text.SimpleDateFormat;
    17. import java.util.Date;
    18. /**
    19. * 后台登陆
    20. */
    21. @Controller
    22. @RequestMapping("")
    23. public class LoginController {
    24. @Autowired
    25. UserService userService;
    26. @RequestMapping(value="/login",method=RequestMethod.POST)
    27. public String login(Model model, String name, String password){//throws ParseException
    28. Subject subject = SecurityUtils.getSubject();
    29. UsernamePasswordToken token = new UsernamePasswordToken(name,password);
    30. try {
    31. subject.login(token);
    32. User us = userService.getByName(name);
    33. String lastLoginTime = "";
    34. if(us!=null){
    35. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    36. //上次时间
    37. Date time = us.getLasttime();
    38. lastLoginTime = sdf.format(time);
    39. //新时间
    40. String format = sdf.format(new Date());
    41. //string转date 不处理时间格式会不理想
    42. ParsePosition pos = new ParsePosition(0);
    43. Date strtodate = sdf.parse(format, pos);
    44. us.setLasttime(strtodate);
    45. userService.update(us);
    46. }
    47. if (us.getStatus()==1){
    48. Session session=subject.getSession();
    49. session.setAttribute("subject", subject);
    50. session.setAttribute("lastLoginTime",lastLoginTime);
    51. return "redirect:index";
    52. }else {
    53. model.addAttribute("error", "账号已被停用!");
    54. return "/login";
    55. }
    56. } catch (AuthenticationException e) {
    57. model.addAttribute("error", "验证失败!");
    58. return "/login";
    59. }
    60. }
    61. }

    订单模块controller

    1. package com.byh.biyesheji.controller;
    2. import com.byh.biyesheji.pojo.Order;
    3. import com.byh.biyesheji.service.OrderItemService;
    4. import com.byh.biyesheji.service.OrderService;
    5. import com.byh.biyesheji.util.Page;
    6. import com.github.pagehelper.PageHelper;
    7. import com.github.pagehelper.PageInfo;
    8. import org.springframework.beans.factory.annotation.Autowired;
    9. import org.springframework.stereotype.Controller;
    10. import org.springframework.ui.Model;
    11. import org.springframework.web.bind.annotation.RequestMapping;
    12. import org.springframework.web.bind.annotation.ResponseBody;
    13. import java.util.List;
    14. /**
    15. * 订单模块controller
    16. */
    17. @Controller
    18. @RequestMapping("/order")
    19. public class OrderController {
    20. @Autowired
    21. OrderService orderService;
    22. @Autowired
    23. OrderItemService orderItemService;
    24. /**
    25. * 所有订单
    26. * @param model
    27. * @param page
    28. * @return
    29. */
    30. @RequestMapping("/list")
    31. public String list(Model model, Page page){
    32. PageHelper.offsetPage(page.getStart(),page.getCount());
    33. List os= orderService.list();
    34. int total = (int) new PageInfo<>(os).getTotal();
    35. page.setTotal(total);
    36. //为订单添加订单项数据
    37. orderItemService.fill(os);
    38. model.addAttribute("os", os);
    39. model.addAttribute("page", page);
    40. model.addAttribute("totals", total);
    41. return "ordermodule/order-list";
    42. }
    43. /**
    44. * 订单发货
    45. * @param o
    46. * @return
    47. */
    48. @RequestMapping("/orderDelivery")
    49. public String delivery(Order o){
    50. o.setStatus(2);
    51. orderService.update(o);
    52. return "redirect:list";
    53. }
    54. /**
    55. * 查看当前订单的订单项
    56. * @param oid
    57. * @param model
    58. * @return
    59. */
    60. @RequestMapping("/seeOrderItem")
    61. public String seeOrderItem(int oid,Model model){
    62. Order o = orderService.get(oid);
    63. orderItemService.fill(o);
    64. model.addAttribute("orderItems",o.getOrderItems());
    65. model.addAttribute("total",o.getOrderItems().size());
    66. model.addAttribute("totalPrice",o.getTotal());
    67. return "ordermodule/orderItem-list";
    68. }
    69. }

    如果也想学习本系统,下面领取。回复:181ssm

  • 相关阅读:
    openresty安装配置,执行shell脚本
    脚手架原理之webpack处理html文件和模块打包
    解决Nacos配置刷新问题: 如何启用配置刷新功能以及与`@RefreshScope`注解的关联问题
    中间件漏洞 | Apache-路径穿越/任意命令执行
    升级Win11后Office无法验证此产品的许可证怎么办?
    string字符串类
    高等数学(第七版)同济大学 习题4-3 个人解答
    hdu7207-Find different【burnside引理】
    针对遗留系统采取的不同演化策略
    测试排版样式
  • 原文地址:https://blog.csdn.net/hanyunlong1989/article/details/126397871