基于javaweb的SSM+Maven民宿管理系统(java+ssm+jsp+bootstrap+jquery+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

050023292402

060023292402

070023292402

090023292402

100023292402

110023292402

基于javaweb的SSM+Maven民宿管理系统(java+ssm+jsp+bootstrap+jquery+mysql)

项目介绍

游客功能:用户注册、登录、登录权限拦截、按名称搜索房间、支付流程、查看订单信息和状态、评论预定过的房间,并自动修改订单状态、查看统计剩余房间数量,数量为0时不可预定 管理员功能:房间分类管理、房间管理、订单管理

高级功能:各种列表清单的导出和打印功能、订单组合条件查询

功能清单

游客功能

  • 用户注册、登录 + 登录权限拦截 + 按名称搜索房间 + 支付流程 + 查看订单信息和状态 + 评论预定过的房间,并自动修改订单状态

  • 查看统计剩余房间数量,数量为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版本;

技术栈

  1. 后端:Spring SpringMVC MyBatis

  2. 前端:JSP+bootstrap+jQuery

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 将项目中applicationContext.xml配置文件中的数据库配置改为自己的配置; 3. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行;

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

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);
// windows系统参考路径 注:此处必须为本地src及target下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;
}

/**
* 预定房间按钮点击后的操作,此时便创建了order,订单状态:waitConfirm
* @param request
* @param orderitem
* @return
* @throws Exception
*/
@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();

// windows系统参考路径 注:此处必须为项目路径
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;
}

//导出分类EXCEL文件
@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")){
// windows系统参考路径 注:此处必须为本地src及target下productDetail的路径
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")){
// windows系统参考路径
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


/**
* 利用开源组件POI3.13动态导出EXCEL文档
*
* @version v1.0
* @param
* */
public class ExportExcel {
public static final String FILE_SEPARATOR = System.getProperties().getProperty("file.separator");

/**
* 这是一个通用的方法
* @param fileName 文件名
* @param headers 表格属性列名数组
* @param dataset 需要显示的数据集合
* @param pattern 如果有时间数据,设定输出格式。默认为"yyy-MM-dd"
*/
@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");//docs文件夹目录
String filePath = docsPath + FILE_SEPARATOR + fileName+"-任意名.xls";
// 声明一个工作薄
HSSFWorkbook workbook = new HSSFWorkbook();
// 生成一个表格
HSSFSheet sheet = workbook.createSheet("Excel");
// 设置表格默认列宽度为15个字节
//sheet.setDefaultColumnWidth((short) 15);
// 生成一个表格标题行样式
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);


项目链接:
https://javayms.github.io?id=041422322105200jn
https://javayms.pages.dev?id=041422322105200jn