——————————DescriptionStart——————————
运行环境 Java≥8、MySQL≥5.7、Tomcat≥8
开发工具 eclipse/idea/myeclipse/sts等均可配置运行
适用 课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SSM+Maven在线社区药品销售商城(java+ssm+jsp+bootstrap+mysql)
项目介绍
本项目为前后台项目,前台为普通用户登录,后台为管理员登录; 管理员角色包含以下功能: 管理员登录,分类管理,用户管理,订单管理等功能。
用户角色包含以下功能: 按分类查看药品,用户登录,查看商品详情,加入购物车,提交订单,查看订单等功能。
环境需要
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项目:是;
技术栈
后端:Spring+SpringMVC+Mybatis 2. 前端:JSP+CSS+JavaScript+jQuery+Bootstrap
使用说明
使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中db.properties配置文件中的数据库配置改为自己的配置; 4. 运行项目,在浏览器中输入http://localhost:8080/ssm_sqyp_shop/ 登录 注:Tomcat中配置项目路径必须为ssm_sqyp_shop 用户账号/密码: user/123456 管理员账号/密码:admin/admin
——————————CodeStart——————————
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 orderItemService.add(oi); } return "success" ; } @RequestMapping("/cart") public String cart (Model model, HttpSession session) { User user = (User)session.getAttribute("user" ); List<OrderItem> orderItems = orderItemService.findForCart(user.getId()); model.addAttribute("orderItems" ,orderItems); return "cart" ; } @RequestMapping("/checkLogin") @ResponseBody public String checkLogin (HttpSession session) { User user = (User)session.getAttribute("user" ); if (null != user) return "success" ; return "fail" ; } @RequestMapping("/changeOrderItem") @ResponseBody public String changeOrderItem (Model model,HttpSession session,int product_id,int number) { User user = (User)session.getAttribute("user" ); if (null == user) return "fail" ; List<OrderItem> ois = orderItemService.findByUserId(user.getId()); for (OrderItem oi : ois) { if (oi.getProduct().getId().intValue() == product_id) { oi.setNumber(number); orderItemService.update(oi); break ; } } return "success" ; } @RequestMapping("deleteOrderItem") @ResponseBody public String deleteOrderItem (Model model,HttpSession session,Integer orderItemId) { User user = (User) session.getAttribute("user" ); if (null == user) return "fail" ; orderItemService.delete(orderItemId);
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 @RequestMapping("/addPropertyValue") public String add (PropertyValue propertyValue ) { int product_id = propertyValue.getProduct_id(); int category_id = productService.get(product_id).getCategory_id(); propertyValueService.add(propertyValue); return "redirect:listPropertyValue?product_id=" + product_id + "&category_id=" + category_id; } @RequestMapping("/deletePropertyValue") public String delete (Integer id) { int product_id = propertyValueService.get(id).getProduct_id(); int category_id = productService.get(product_id).getCategory_id(); propertyValueService.delete(id); return "redirect:listPropertyValue?product_id=" + product_id + "&category_id=" + category_id; } @RequestMapping("/editPropertyValue") public String edit (Integer id ,Model model) { PropertyValue propertyValue = propertyValueService.get(id); model.addAttribute("propertyValue" ,propertyValue); Product product = productService.get(propertyValue.getProperty_id()); model.addAttribute("product" ,product); return "admin/editPropertyValue" ; } @RequestMapping("/updatePropertyValue") public String update (PropertyValue propertyValue) { Integer product_id = propertyValue.getProduct_id(); Integer category_id = productService.get(product_id).getCategory_id(); propertyValueService.update(propertyValue); return "redirect:listPropertyValue?product_id=" + product_id + "&category_id=" + category_id; } } package com.smzy.controller;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 @Controller @RequestMapping("/admin") public class PropertyController { @Autowired private PropertyService propertyService; @Autowired private CategoryService categoryService; @RequestMapping("/listProperty") public String findAll (Model model , Integer category_id) { List<Property> properties = propertyService.findAll(category_id); model.addAttribute("properties" ,properties); Category category = categoryService.get(category_id); model.addAttribute("category" ,category); return "admin/listProperty" ; } @RequestMapping("/addPropertyView") public String addPropertyView (Model model,Integer category_id) { Category category = categoryService.get(category_id); model.addAttribute("category" , category); return "admin/addPropertyView" ; } @RequestMapping("/addProperty") public String add (Property property) { propertyService.add(property); return "redirect:listProperty?category_id=" + property.getCategory_id(); } @RequestMapping("/deleteProperty") public String delete (Integer id) { Integer category_id = propertyService.get(id).getCategory_id(); propertyService.delete(id); return "redirect:listProperty?category_id=" + category_id; } @RequestMapping("/editProperty") public String edit (Integer id,Model model) { Property property = propertyService.get(id); model.addAttribute("property" ,property); Category category = categoryService.get(property.getCategory_id()); model.addAttribute("category" ,category); return "admin/editProperty" ; } @RequestMapping("/updateProperty") public String update (Property property) { propertyService.update(property);
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 review.setContent(content); review.setProduct_id(product_id); review.setCreateDate(new Date()); review.setUser_id(user.getId()); reviewService.add(review); return "redirect:review?order_id=" + order_id + "&showonly=true" ; } } package com.smzy.controller;@Controller @RequestMapping("/admin") public class PropertyValueController { @Autowired private PropertyValueService propertyValueService; @Autowired private PropertyService propertyService; @Autowired private ProductService productService; @RequestMapping("/listPropertyValue") public String findAll (Model model ,Integer product_id ,Integer category_id) { List<PropertyValue> propertyValues = propertyValueService.findByProductId(product_id); model.addAttribute("propertyValues" ,propertyValues);
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 return "redirect:listPropertyValue?product_id=" + product_id + "&category_id=" + category_id; } @RequestMapping("/editPropertyValue") public String edit (Integer id ,Model model) { PropertyValue propertyValue = propertyValueService.get(id); model.addAttribute("propertyValue" ,propertyValue); Product product = productService.get(propertyValue.getProperty_id()); model.addAttribute("product" ,product); return "admin/editPropertyValue" ; } @RequestMapping("/updatePropertyValue") public String update (PropertyValue propertyValue) { Integer product_id = propertyValue.getProduct_id(); Integer category_id = productService.get(product_id).getCategory_id(); propertyValueService.update(propertyValue); return "redirect:listPropertyValue?product_id=" + product_id + "&category_id=" + category_id; } } package com.smzy.controller;@Controller @RequestMapping("/admin") public class ProductController { @Autowired private ProductService productService; @Autowired private CategoryService categoryService;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 List<OrderItem> orderItems = orderItemService.findForCart(user.getId()); model.addAttribute("orderItems" ,orderItems); return "cart" ; } @RequestMapping("/checkLogin") @ResponseBody public String checkLogin (HttpSession session) { User user = (User)session.getAttribute("user" ); if (null != user) return "success" ; return "fail" ; } @RequestMapping("/changeOrderItem") @ResponseBody public String changeOrderItem (Model model,HttpSession session,int product_id,int number) { User user = (User)session.getAttribute("user" ); if (null == user) return "fail" ; List<OrderItem> ois = orderItemService.findByUserId(user.getId()); for (OrderItem oi : ois) { if (oi.getProduct().getId().intValue() == product_id) { oi.setNumber(number); orderItemService.update(oi); break ; } } return "success" ; } @RequestMapping("deleteOrderItem") @ResponseBody public String deleteOrderItem (Model model,HttpSession session,Integer orderItemId) { User user = (User) session.getAttribute("user" ); if (null == user) return "fail" ; orderItemService.delete(orderItemId); return "success" ; } @RequestMapping("bought") public String bought (Model model,HttpSession session) { User user =(User) session.getAttribute("user" ); List<Order> orders = orderService.list(user.getId(),OrderService.delete); orderItemService.fill(orders);
——————————PayStart——————————
项目链接: https://javayms.github.io?id=381122572008200tt https://javayms.pages.dev?id=381122572008200tt