• 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+CSS+JavaScript+jquery+easyui+echarts+h-ui

    使用说明

    1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;

    2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;

    若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;

    3. 将项目中db.properties配置文件中的数据库配置改为自己的配置;

    4. 运行项目,输入localhost:8080/ssm_zxmarketsys 登录

    运行截图

    前台界面-用户角色

     

     

     

     

     

    后台界面-管理员角色 

     

     

     

     

     

     

    相关代码

    1. /**
    2. * 前台首页控制器
    3. * @author Administrator
    4. *
    5. */
    6. @RequestMapping("/home")
    7. @Controller
    8. public class IndexController {
    9. @Autowired
    10. private AccountService accountService;
    11. @Autowired
    12. private ProductCategoryService productCategoryService;
    13. @Autowired
    14. private ProductService productService;
    15. /**
    16. * 前台首页页面
    17. * @param model
    18. * @return
    19. */
    20. @RequestMapping(value = "/index",method = RequestMethod.GET)
    21. public ModelAndView index(ModelAndView model){
    22. model.addObject("productCategoryList", MenuUtil.getTreeCategory(productCategoryService.findList(new HashMap<String, Object>())));
    23. Map<String, Object> queryMap = new HashMap<String, Object>();
    24. queryMap.put("offset", 0);
    25. queryMap.put("pageSize", 5);
    26. queryMap.put("orderBy", "createTime");
    27. queryMap.put("sort", "desc");
    28. model.addObject("lastProductList", productService.findList(queryMap));
    29. queryMap.put("orderBy", "sellNum");
    30. model.addObject("sellProductList", productService.findList(queryMap));
    31. model.addObject("allCategoryClass","shop_hd_menu_hover");
    32. model.addObject("currentHome", "current_");
    33. model.setViewName("home/index/index");
    34. return model;
    35. }
    36. /**
    37. * 用户登录页面
    38. * @param model
    39. * @return
    40. */
    41. @RequestMapping(value = "/login",method = RequestMethod.GET)
    42. public ModelAndView login(ModelAndView model){
    43. model.addObject("title", "用户登录");
    44. model.setViewName("home/index/login");
    45. return model;
    46. }
    47. /**
    48. * 用户登录页面
    49. * @param model
    50. * @return
    51. */
    52. @RequestMapping(value = "/register",method = RequestMethod.GET)
    53. public ModelAndView register(ModelAndView model){
    54. model.addObject("title", "用户注册");
    55. model.setViewName("home/index/register");
    56. return model;
    57. }
    58. /**
    59. * 提交注册信息
    60. * @param account
    61. * @return
    62. */
    63. @RequestMapping(value = "/register",method = RequestMethod.POST)
    64. @ResponseBody
    65. public Map<String, String> register(Account account,String code,HttpServletRequest request){
    66. Map<String, String> ret = new HashMap<String, String>();
    67. ret.put("type", "error");
    68. if(account == null){
    69. ret.put("msg", "请填写正确的用户信息");
    70. return ret;
    71. }
    72. if(StringUtils.isEmpty(account.getName())){
    73. ret.put("msg", "请填写用户名");
    74. return ret;
    75. }
    76. if(StringUtils.isEmpty(account.getPassword())){
    77. ret.put("msg", "请填写密码");
    78. return ret;
    79. }
    80. if(StringUtils.isEmpty(account.getEmail())){
    81. ret.put("msg", "请填写邮箱");
    82. return ret;
    83. }
    84. if(StringUtils.isEmpty(code)){
    85. ret.put("msg", "请填写验证码");
    86. return ret;
    87. }
    88. Object codeObject = request.getSession().getAttribute("userRegisterCpacha");
    89. if(codeObject == null){
    90. ret.put("msg", "验证码已过期,请刷新页面后重试!");
    91. return ret;
    92. }
    93. if(!code.equalsIgnoreCase((String)codeObject)){
    94. ret.put("msg", "验证码错误!");
    95. return ret;
    96. }
    97. Account findByName = accountService.findByName(account.getName());
    98. if(findByName != null){
    99. ret.put("msg", "该用户名已存在!");
    100. return ret;
    101. }
    102. account.setStatus(1);
    103. account.setCreateTime(new Date());
    104. if(accountService.add(account) <= 0){
    105. ret.put("msg", "注册失败,请联系管理员!");
    106. return ret;
    107. }
    108. ret.put("type", "success");
    109. return ret;
    110. }
    111. /**
    112. * 提交注册信息
    113. * @param account
    114. * @return
    115. */
    116. @RequestMapping(value = "/login",method = RequestMethod.POST)
    117. @ResponseBody
    118. public Map<String, String> login(Account account,String code,HttpServletRequest request){
    119. Map<String, String> ret = new HashMap<String, String>();
    120. ret.put("type", "error");
    121. if(account == null){
    122. ret.put("msg", "请填写正确的用户信息");
    123. return ret;
    124. }
    125. if(StringUtils.isEmpty(account.getName())){
    126. ret.put("msg", "请填写用户名");
    127. return ret;
    128. }
    129. if(StringUtils.isEmpty(account.getPassword())){
    130. ret.put("msg", "请填写密码");
    131. return ret;
    132. }
    133. if(StringUtils.isEmpty(code)){
    134. ret.put("msg", "请填写验证码");
    135. return ret;
    136. }
    137. Object codeObject = request.getSession().getAttribute("userLoginCpacha");
    138. if(codeObject == null){
    139. ret.put("msg", "验证码已过期,请刷新页面后重试!");
    140. return ret;
    141. }
    142. if(!code.equalsIgnoreCase((String)codeObject)){
    143. ret.put("msg", "验证码错误!");
    144. return ret;
    145. }
    146. Account findByName = accountService.findByName(account.getName());
    147. if(findByName == null){
    148. ret.put("msg", "该用户名不存在!");
    149. return ret;
    150. }
    151. if(!account.getPassword().equals(findByName.getPassword())){
    152. ret.put("msg", "密码错误!");
    153. return ret;
    154. }
    155. if(findByName.getStatus() == 0){
    156. ret.put("msg", "该用户已被冻结,请联系管理员!");
    157. return ret;
    158. }
    159. request.getSession().setAttribute("userLoginCpacha", null);
    160. request.getSession().setAttribute("account", findByName);
    161. ret.put("type", "success");
    162. return ret;
    163. }
    164. }

    前台用户中心控制器

    1. /**
    2. * 前台用户中心控制器
    3. * @author Administrator
    4. *
    5. */
    6. @RequestMapping("/user")
    7. @Controller
    8. public class HomeUserController {
    9. @Autowired
    10. private AccountService accountService;
    11. @Autowired
    12. private ProductCategoryService productCategoryService;
    13. @Autowired
    14. private ProductService productService;
    15. @Autowired
    16. private OrderService orderService;
    17. @Autowired
    18. private CartService cartService;
    19. @Autowired
    20. private AddressService addressService;
    21. /**
    22. * 用户中心页面
    23. * @param model
    24. * @return
    25. */
    26. @RequestMapping(value = "/info",method = RequestMethod.GET)
    27. public ModelAndView info(ModelAndView model,HttpServletRequest request){
    28. model.addObject("productCategoryList", MenuUtil.getTreeCategory(productCategoryService.findList(new HashMap<String, Object>())));
    29. model.addObject("allCategoryId","shop_hd_menu_all_category");
    30. Account onlineAccount = (Account)request.getSession().getAttribute("account");
    31. model.addObject("user", onlineAccount);
    32. model.addObject("currentUser", "current_");
    33. model.setViewName("home/user/info");
    34. return model;
    35. }
    36. /**
    37. * 修改密码页面
    38. * @param model
    39. * @return
    40. */
    41. @RequestMapping(value = "/update_pwd",method = RequestMethod.GET)
    42. public ModelAndView updatePwd(ModelAndView model){
    43. model.addObject("productCategoryList", MenuUtil.getTreeCategory(productCategoryService.findList(new HashMap<String, Object>())));
    44. model.addObject("allCategoryId","shop_hd_menu_all_category");
    45. model.addObject("currentUser", "current_");
    46. model.setViewName("home/user/update_pwd");
    47. return model;
    48. }
    49. /**
    50. * 修改密码提交
    51. * @param password
    52. * @param newPassword
    53. * @param request
    54. * @return
    55. */
    56. @RequestMapping(value = "/update_pwd",method = RequestMethod.POST)
    57. @ResponseBody
    58. public Map<String, String> updatePassword(String password,String newPassword,
    59. HttpServletRequest request){
    60. Map<String, String> ret = new HashMap<String, String>();
    61. Account onlineAccount = (Account)request.getSession().getAttribute("account");
    62. ret.put("type", "error");
    63. if(StringUtils.isEmpty(password)){
    64. ret.put("msg", "旧密码不能为空!");
    65. return ret;
    66. }
    67. if(StringUtils.isEmpty(newPassword)){
    68. ret.put("msg", "新密码不能为空!");
    69. return ret;
    70. }
    71. if(!onlineAccount.getPassword().equals(password)){
    72. ret.put("msg", "旧密码错误!");
    73. return ret;
    74. }
    75. onlineAccount.setPassword(newPassword);
    76. if(accountService.edit(onlineAccount) <= 0){
    77. ret.put("msg", "修改失败,请联系管理员!");
    78. return ret;
    79. }
    80. ret.put("type", "success");
    81. return ret;
    82. }
    83. /**
    84. * 更新资料
    85. * @param account
    86. * @return
    87. */
    88. @RequestMapping(value = "/update_info",method = RequestMethod.POST)
    89. @ResponseBody
    90. public Map<String, String> updateInfo(Account account,
    91. HttpServletRequest request){
    92. Map<String, String> ret = new HashMap<String, String>();
    93. Account onlineAccount = (Account)request.getSession().getAttribute("account");
    94. ret.put("type", "error");
    95. if(account == null){
    96. ret.put("msg", "请填写正确的信息");
    97. return ret;
    98. }
    99. if(StringUtils.isEmpty(account.getEmail())){
    100. ret.put("msg", "邮箱地址不能为空!");
    101. return ret;
    102. }
    103. if(StringUtils.isEmpty(account.getTrueName())){
    104. ret.put("msg", "真实姓名不能为空!");
    105. return ret;
    106. }
    107. onlineAccount.setEmail(account.getEmail());
    108. onlineAccount.setTrueName(account.getTrueName());
    109. onlineAccount.setSex(account.getSex());
    110. if(accountService.edit(onlineAccount) <= 0){
    111. ret.put("msg", "修改失败,请联系管理员!");
    112. return ret;
    113. }
    114. ret.put("type", "success");
    115. return ret;
    116. }
    117. /**
    118. * 下单成功展示页面
    119. * @param model
    120. * @param request
    121. * @return
    122. */
    123. @RequestMapping(value = "/order_success",method = RequestMethod.GET)
    124. public ModelAndView orderSuccess(ModelAndView model,Long orderId,HttpServletRequest request){
    125. model.addObject("productCategoryList", MenuUtil.getTreeCategory(productCategoryService.findList(new HashMap<String, Object>())));
    126. model.addObject("allCategoryId","shop_hd_menu_all_category");
    127. model.addObject("currentCart", "current_");
    128. model.addObject("order", orderService.findById(orderId));
    129. model.setViewName("home/cart/order_success");
    130. return model;
    131. }
    132. }

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

  • 相关阅读:
    那些年,我们写过的无效单元测试
    【天衍系列 01】深入理解Flink的 FileSource 组件:实现大规模数据文件处理
    十一、Spring Boot 整合 WebSocket(1)
    AWS启示录:创新作帆,云计算的征途是汪洋大海
    Java实现操作阿里云OSS云存储详解,含配置和完整代码
    AI 绘画整体认知
    前端环境 本机可切换node多版本 问题源头是node使用的高版本
    低代码之JeecgBoot
    FastAPI 学习之路(十七)上传文件
    Java架构师缓存架构设计
  • 原文地址:https://blog.csdn.net/hanyunlong1989/article/details/125478536