——————————DescriptionStart——————————
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明






基于javaweb的SSM+Maven民宿管理系统(java+ssm+jsp+bootstrap+jquery+mysql)
项目介绍
游客功能:用户注册、登录、登录权限拦截、按名称搜索房间、支付流程、查看订单信息和状态、评论预定过的房间,并自动修改订单状态、查看统计剩余房间数量,数量为0时不可预定 管理员功能:房间分类管理、房间管理、订单管理
高级功能:各种列表清单的导出和打印功能、订单组合条件查询
功能清单
游客功能
管理员功能
房间分类管理 + 类型的删除、修改、查询(准备添加增添功能,即图片上传功能) + 类型所含属性的增删改查 + 房间分类图片上传 > 房间管理 + 房间增删改导印统 + 查询已上传房间的所有照片 + 房间的配套设施属性设置 + 房间价格(原价、活动价)、名称、描述等属性设置 + 房间存量统计 > 订单管理 + 订单信息修改、删除 + 订单组合条件查询
高级功能 + 各种列表清单的导出和打印功能
环境需要
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.是否Maven项目: 是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目 6.数据库:MySql 5.7版本;
技术栈
后端:Spring SpringMVC MyBatis
前端:JSP+bootstrap+jQuery
使用说明
使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 将项目中applicationContext.xml配置文件中的数据库配置改为自己的配置; 3. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行;
运行项目,输入localhost:8080/ 登录
——————————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
| @RequestMapping(value = "/admin_category_add",produces = "text/html;charset=UTF-8") @ResponseBody public ModelAndView admin_category_add(@RequestParam("name") String name, @RequestParam("filepath") MultipartFile filepath) throws IOException { Category category = new Category(); category.setName(name); Integer cid = categoryService.insert(category); String path1 = imgPath+"src\\main\\webapp\\img\\category\\"+cid.toString()+".jpg"; String path2 = imgPath+"target\\db-1.0-SNAPSHOT\\img\\category\\"+cid.toString()+".jpg"; filepath.transferTo(new File(path1)); FileUtils.copyFile(new File(path1),new File(path2)); mav = listCategory(); return mav; }
@RequestMapping(value = "/admin_order_list",produces = "text/html;charset=UTF-8") @ResponseBody public ModelAndView listOrder(){ List<Order> orders = orderService.listAll(); for(Order order:orders){ order.setOrderItems(orderItemService.getOrderItem(order.getId())); } mav.addObject("os",orders); mav.setViewName("/admin/listOrder"); return mav; }
@RequestMapping(value = "/admin_print_order_list",produces = "text/html;charset=UTF-8") @ResponseBody public ModelAndView printListOrder(){ mav = listOrder(); mav.setViewName("/admin/printListOrder"); return mav; }
@RequestMapping(value = "/admin_export_order_list",produces = "text/html;charset=UTF-8") @ResponseBody public void exportListOrder(HttpServletRequest request, HttpServletResponse response) throws Exception{
|
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
|
@RequestMapping(value = "/admin_product_add",produces = "text/html;charset=UTF-8") @ResponseBody public ModelAndView admin_product_add(Product product,HttpServletRequest request){ productService.insert(product); List<Product> products = productService.listProducts(product.getCid()); mav.addObject("ps",products); mav.addObject("c",categoryService.getCategory(product.getCid())); mav.setViewName("/admin/listProduct"); return mav; }
@RequestMapping(value = "/admin_product_delete",produces = "text/html;charset=UTF-8") @ResponseBody public ModelAndView admin_product_delete(Integer id,Integer cid, HttpServletRequest request){ productService.delete(id); return listProduct(cid); }
@RequestMapping(value = "/admin_productImage_list",produces = "text/html;charset=UTF-8") @ResponseBody public ModelAndView admin_productImage_list(Integer pid, HttpServletRequest request){ Product product = productService.getProduct(pid); product.setCategory(categoryService.getCategory(product.getCid())); List<Productimage> productimages = productService.listProductImage(product.getId()); mav.addObject("p",product); mav.addObject("pisSingle",productimages.stream().filter(e -> e.getType().equals("type_single")).collect(Collectors.toList())); mav.addObject("pisDetail",productimages.stream().filter(e -> e.getType().equals("type_detail")).collect(Collectors.toList())); mav.setViewName("/admin/listProductImage"); return mav; }
@RequestMapping(value = "/admin_productImage_delete",produces = "text/html;charset=UTF-8") @ResponseBody public ModelAndView admin_productImage_delete(Integer id,Integer pid, HttpServletRequest request, HttpServletResponse response) throws Exception { try { productService.deleteProductImage(id); } catch (Exception e) { e.getMessage(); } return admin_productImage_list(pid,request); }
@RequestMapping(value = "/admin_productImage_add",produces = "text/html;charset=UTF-8") @ResponseBody
|
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
| modelAndView.addObject("ps",ps); modelAndView.setViewName("/searchResult"); return modelAndView; }
@RequestMapping(value = "/foreproduct",produces = "text/html;charset=UTF-8") @ResponseBody public ModelAndView product(Integer pid) throws Exception{ Product p = productService.getProduct(pid); List<Propertyvalue> pvs = productService.listProprotyValue(p.getId()); List<Review> reviews = reviewService.listReview(p.getId()); modelAndView.addObject("pvs",productService.getPropertyvalues(pvs)); modelAndView.addObject("p", p); modelAndView.addObject("reviews",reviewService.getReviews(reviews)); modelAndView.setViewName("/product"); return modelAndView; }
@RequestMapping(value = "/forecheckLogin", produces = "text/html;charset=UTF-8") @ResponseBody public int check(HttpServletRequest request) throws Exception{ User user = (User) request.getSession().getAttribute("user"); if(user != null) return 1; return 0; }
@RequestMapping(value = "/forebuyone",produces = "text/html;charset=UTF-8") @ResponseBody public ModelAndView forebuyone(HttpServletRequest request, Orderitem orderitem) throws Exception{ User user = (User) request.getSession().getAttribute("user"); Map map = orderItemService.buyOne(user, orderitem); request.getSession(true).setAttribute("order",map.get("order")); request.getSession(true).setAttribute("pid",orderitem.getPid()); Product product = productService.getProduct(orderitem.getPid()); product.setSaleCount(product.getSaleCount()+orderitem.getNumber()); product.setStock(product.getStock()-orderitem.getNumber()); productService.update(product); modelAndView.addObject("ois",map.get("ois"));
|
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
| private OrderItemService orderItemService; @Autowired private OrderService orderService; @Autowired private ProductService productService;
private static Logger logger = Logger.getLogger(AdminController.class); private ModelAndView mav = new ModelAndView();
private static String imgPath = "C:\\Users\\51414\\Desktop\\ssm民宿管理系统\\db\\";
private ModelAndView listProduct(Integer cid) { List<Product> products = productService.listProducts(cid); mav.addObject("ps",products); mav.addObject("c",categoryService.getCategory(cid)); mav.setViewName("/admin/listProduct"); return mav; }
@RequestMapping(value = "/admin_category_list",produces = "text/html;charset=UTF-8") @ResponseBody public ModelAndView listCategory(){ List<Category> categories = categoryService.listAll(); mav.addObject("thecs", categories); mav.setViewName("admin/listCategory"); return mav; }
@RequestMapping(value = "/admin_print_category_list",produces = "text/html;charset=UTF-8") @ResponseBody public ModelAndView printListCategory(){ List<Category> categories = categoryService.listAll(); mav.addObject("thecs", categories); mav.setViewName("admin/printListCategory"); return mav; }
@RequestMapping(value = "/admin_export_category_list",produces = "text/html;charset=UTF-8") @ResponseBody public void exportListCategory(HttpServletRequest request, HttpServletResponse response) throws Exception{ List<Category> categories = categoryService.listAll();
|
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
| String path2 = ""; if (type.equals("type_detail")){ path1 = imgPath+"src\\main\\webapp\\img\\productDetail\\"+imageId.toString()+".jpg"; path2 = imgPath+"target\\db-1.0-SNAPSHOT\\img\\productDetail\\"+imageId.toString()+".jpg"; filepath.transferTo(new File(path1)); FileUtils.copyFile(new File(path1),new File(path2)); } if (type.equals("type_single")){ path1 = imgPath+"src\\main\\webapp\\img\\productSingle\\"+imageId.toString()+".jpg"; path2 = imgPath+"target\\db-1.0-SNAPSHOT\\img\\productSingle\\"+imageId.toString()+".jpg"; String path3 = imgPath+"src\\main\\/webapp\\img\\productSingle_middle\\"+imageId.toString()+".jpg";; String path4 = imgPath+"target\\db-1.0-SNAPSHOT\\img\\productSingle_middle\\"+imageId.toString()+".jpg"; String path5 = imgPath+"src\\main\\webapp\\img\\productSingle_small\\"+imageId.toString()+".jpg";; String path6 = imgPath+"target\\db-1.0-SNAPSHOT\\img\\productSingle_small\\"+imageId.toString()+".jpg"; filepath.transferTo(new File(path1)); FileUtils.copyFile(new File(path1),new File(path2)); FileUtils.copyFile(new File(path1),new File(path3)); FileUtils.copyFile(new File(path1),new File(path4)); FileUtils.copyFile(new File(path1),new File(path5)); FileUtils.copyFile(new File(path1),new File(path6)); }
return admin_productImage_list(pid,request); }
@RequestMapping(value = "/admin_product_editPropertyValue",produces = "text/html;charset=UTF-8") @ResponseBody public ModelAndView admin_product_editPropertyValue(Integer id, HttpServletRequest request){ Product product = productService.getProduct(id); List<Propertyvalue> values = productService.listProprotyValue(id); for(Propertyvalue p: values){ p.setProperty(productService.getProperty(p.getPtid())); } mav.addObject("p",product); mav.addObject("pvs",values); mav.setViewName("/admin/editProductValue"); return mav; }
@RequestMapping(value = "/admin_product_updatePropertyValue",produces = "text/html;charset=UTF-8") @ResponseBody public String admin_product_updatePropertyValue(Integer id, Integer pvid, String value){ productService.updatePropertyValue(pvid, value); return "success";
|
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
|
public class ExportExcel { public static final String FILE_SEPARATOR = System.getProperties().getProperty("file.separator");
@SuppressWarnings("deprecation") public static HSSFWorkbook exportExcel(HttpServletRequest request,HttpServletResponse response,String fileName, String[] headers, List<Object[]> dataset, String pattern) { String docsPath = request.getSession().getServletContext().getRealPath("docs"); String filePath = docsPath + FILE_SEPARATOR + fileName+"-任意名.xls"; HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet("Excel"); HSSFCellStyle style = getColumnTopStyle(workbook); HSSFCellStyle style2 = getColumnStyle(workbook); HSSFRow row = sheet.createRow(0); for (short i = 0; i < headers.length; i++) { HSSFCell cell = row.createCell(i);
|
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=041422322105200jn
https://javayms.pages.dev?id=041422322105200jn