JAVA-MYSQL-SSH酒店民宿客房管理系统

基于SSH的2022精修版,修复了大量bug,

核心功能:用户管理,日志管理,人员权限管理,客房预订管理,预定转入住,客房管理,卫生管理,物品采购,商品管理,建议管理,换房管理,客房类型管理,文件上传下载,自定义文件目录。

开发环境:mysql5.7,tomcat9,jdk8,eclipse,(MyEclipse或者IDEA也可以)

框架技术:Struts2 + Spring + Hibernate

上传文件的目录可以设置,独立于项目之外,这样每次部署以及迁移的时候就不会受到影响。

运行截图

JAVA-MYSQL-SSH酒店民宿客房管理系统_第1张图片

管理员首页

JAVA-MYSQL-SSH酒店民宿客房管理系统_第2张图片

用户管理

JAVA-MYSQL-SSH酒店民宿客房管理系统_第3张图片

日志管理

JAVA-MYSQL-SSH酒店民宿客房管理系统_第4张图片

客服预定管理

JAVA-MYSQL-SSH酒店民宿客房管理系统_第5张图片

工作人员权限分配

JAVA-MYSQL-SSH酒店民宿客房管理系统_第6张图片

客房管理

JAVA-MYSQL-SSH酒店民宿客房管理系统_第7张图片

卫生管理

JAVA-MYSQL-SSH酒店民宿客房管理系统_第8张图片

物品采购

JAVA-MYSQL-SSH酒店民宿客房管理系统_第9张图片

商品管理

JAVA-MYSQL-SSH酒店民宿客房管理系统_第10张图片

换房管理

JAVA-MYSQL-SSH酒店民宿客房管理系统_第11张图片

客房类型管理

JAVA-MYSQL-SSH酒店民宿客房管理系统_第12张图片

源码分享:

ItemCatAction

package com.hotel.action;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import com.hotel.model.Item_cat;
import com.hotel.model.Room_cat;
import com.hotel.service.ItemCatService;
import com.hotel.service.LogService;
import com.hotel.utils.Pager;
import com.hotel.utils.UUIDUtils;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

@Controller("itemCatAction")
@Scope("prototype")
public class ItemCatAction extends ActionSupport implements ModelDriven{
   private Item_cat item_cat;
   private int itemCatId;

   @Autowired
   private LogService logService;
   
    public int getItemCatId() {
	return itemCatId;
}

	public void setItemCatId(int itemCatId) {
		this.itemCatId = itemCatId;
	}

	//========================图片上传
    private File file;
    
    //提交过来的file的名字
    private String fileFileName;
    
    //提交过来的file的MIME类型
    private String fileContentType;
    

    
    public File getFile() {
        return file;
    }
    public void setFile(File file) {
        this.file = file;
    }
    public String getFileFileName() {
        return fileFileName;
    }
    public void setFileFileName(String fileFileName) {
        this.fileFileName = fileFileName;
    }
    public String getFileContentType() {
        return fileContentType;
    }
    public void setFileContentType(String fileContentType) {
        this.fileContentType = fileContentType;
    }
    //========================图片上传

	@Override
	public Item_cat getModel() {
		if(item_cat==null) item_cat = new Item_cat();
		return item_cat;
	}
	@Autowired
	private ItemCatService itemCatService;
	
	/**
     * 获取类别信息列表
     * @return
     */
    public String itemCatList(){
      Pager pagers = itemCatService.listAll();
    ActionContext.getContext().put("pagers", pagers);
    return SUCCESS;
    }
	
    /**
     * 删除商品类别信息
     * @return
     */
    public String delItemCat(){
    	itemCatService.delItemCat(itemCatId);
        ActionContext.getContext().put("url", "/itemCat_itemCatList.do");
        return "redirect";
    }
    
    /**
     * 新增商品类别页面
     * @Description (TODO这里用一句话描述这个方法的作用)
     * @return
     */
    public String addItemCat() {
        return "success";
    }
    
    public String itemCatAdd() throws Exception{
        //图片上传
        String root  = "D:/my/upload";
        InputStream is = new FileInputStream(file);
        fileFileName = UUIDUtils.create()+fileFileName;
        OutputStream os = new FileOutputStream(new File(root, fileFileName));
        System.out.println("fileFileName: " + fileFileName);
        System.out.println("file: " + file.getName());
        System.out.println("file: " + file.getPath());
        byte[] buffer = new byte[500];
        int length = 0;
        while(-1 != (length = is.read(buffer, 0, buffer.length)))
        {
            os.write(buffer);
        }
        os.close();
        is.close();
        item_cat.setImage("\\upload\\"+fileFileName);
        itemCatService.add(item_cat);
        String content="新增商品类型";
        HttpSession session =ServletActionContext.getRequest().getSession();
        int userId = Integer.parseInt( session.getAttribute("userId").toString());
        //插入日志
        logService.addLog(content,userId);
        ActionContext.getContext().put("url", "/itemCat_itemCatList.do");
      return "redirect";
     }
    
    /**
     * 初始化修改页面
     * @Description (TODO这里用一句话描述这个方法的作用)
     * @return
     */
    public String updateItemCat(){
    	Item_cat item_cat =itemCatService.itemCatDetail(itemCatId);
        ActionContext.getContext().put("item_cat", item_cat);
         return "success";
     }
    
    /**
     * 修改商品类别
     * @Description (TODO这里用一句话描述这个方法的作用)
     * @return
     * @throws Exception 
     */
    public String ItemCatUpdate() throws Exception{
        if(file!=null){
            //图片上传
          String root  = "D:/my/upload";
          InputStream is = new FileInputStream(file);
          fileFileName = UUIDUtils.create()+fileFileName;
          OutputStream os = new FileOutputStream(new File(root, fileFileName));
          System.out.println("fileFileName: " + fileFileName);
          System.out.println("file: " + file.getName());
          System.out.println("file: " + file.getPath());
          byte[] buffer = new byte[500];
          int length = 0;
          while(-1 != (length = is.read(buffer, 0, buffer.length)))
          {
              os.write(buffer);
          }
          os.close();
          is.close();
          item_cat.setImage("\\upload\\"+fileFileName);
          }else{
              Item_cat  i =itemCatService.itemCatDetail(item_cat.getCid());
              item_cat.setImage(i.getImage());
          }
          itemCatService.update(item_cat);
          String content="修改商品类型";
          HttpSession session =ServletActionContext.getRequest().getSession();
          int userId = Integer.parseInt( session.getAttribute("userId").toString());
          //插入日志
          logService.addLog(content,userId);
          ActionContext.getContext().put("url", "/itemCat_itemCatList.do");
          return "redirect";
     }
}

ManageAction

package com.hotel.action;

import java.lang.reflect.InvocationTargetException;
import java.util.Date;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.hotel.model.Manage;
import com.hotel.model.Suggest;
import com.hotel.model.User;
import com.hotel.service.LogService;
import com.hotel.service.ManageService;
import com.hotel.service.SuggestService;
import com.hotel.service.UserService;
import com.hotel.utils.Pager;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

@Controller("manageAction")
@Scope("prototype")
public class ManageAction extends ActionSupport implements ModelDriven{

   private Manage manage;
   private int userId;
   private int manageId;
    public int getUserId() {
        return userId;
    }
    
    public void setUserId(int userId) {
        this.userId = userId;
    }

    public int getManageId() {
        return manageId;
    }

    
    public void setManageId(int manageId) {
        this.manageId = manageId;
    }

    @Override
	public Manage getModel() {
		if(manage==null) manage = new Manage();
		return manage;
	}
	
	@Autowired
	private ManageService manageService;
	
	@Autowired
	private UserService  userService;
	
	@Autowired
	private LogService logService;
	/**
	 * 登陆以后进入首页
	 * @return
	 */
	public String index(){
		Manage ma =	manageService.login(manage);
		if(ma == null){
			return "login";
		}
		HttpSession session =ServletActionContext.getRequest().getSession();
		session.setAttribute("userName", ma.getName());
		session.setAttribute("userId", ma.getId());
		session.setAttribute("type1", ma.getType());
	    return SUCCESS;  //返回成功后默认为你提交需要跳转的方法中去
	}
	
	
	/**    
     * 获取用户列表
     * @return
     */
    public String userList(){
      Pager pagers = userService.listAll();
    ActionContext.getContext().put("pagers", pagers);
    return SUCCESS;
    }
	
    /**
     * 删除用户
     * @return
     */
    public String delUser(){
        userService.delUse(userId);
        String content="删除用户";
        HttpSession session =ServletActionContext.getRequest().getSession();
        int userId = Integer.parseInt( session.getAttribute("userId").toString());
        //插入日志
        logService.addLog(content,userId);
        ActionContext.getContext().put("url", "/manage_userList.do");
        return "redirect";
    }
    
    /**
     * 用户详情
     * @return
     */
    public String userDetail(){
        User user =userService.userDetail(userId);
        ActionContext.getContext().put("user", user);
        return SUCCESS;
    }
    
    /**
     * 获取权限管理员列表
     * @return
     */
    public String authList(){
      Pager pagers = manageService.listAll();
    ActionContext.getContext().put("pagers", pagers);
    return SUCCESS;
    }
    
    /**
     * 删除管理员
     * @return
     */
    public String delManage(){
        manageService.delManage(manageId);
        String content="删除管理员";
        HttpSession session =ServletActionContext.getRequest().getSession();
        int userId = Integer.parseInt( session.getAttribute("userId").toString());
        //插入日志
        logService.addLog(content,userId);
        ActionContext.getContext().put("url", "/manage_authList.do");
        return "redirect";
    }
    
    /**
     * 管理员详情
     * @return
     */
    public String authDetail(){
        Manage manage =manageService.manageDetail(manageId);
        ActionContext.getContext().put("manage", manage);
        return SUCCESS;
    }
    
    /**
     * 管理员新增页面
     * @Description (TODO这里用一句话描述这个方法的作用)
     * @return
     */
    public String addAuth() {
        return "success";
    }
    
    
    /**
     * 新增管理员
     * @Description (TODO这里用一句话描述这个方法的作用)
     * @return
     */
    public String addManage(){
       manage.setCreateTime(new Date());
       manage.setIsDelete(2);
        manageService.add(manage);
        String content="新增管理员";
        HttpSession session =ServletActionContext.getRequest().getSession();
        int userId = Integer.parseInt( session.getAttribute("userId").toString());
        //插入日志
        logService.addLog(content,userId);
        ActionContext.getContext().put("url", "/manage_authList.do");
        return "redirect";
    }
    
    /**
     * 初始化修改页面
     * @Description (TODO这里用一句话描述这个方法的作用)
     * @return
     */
    public String updateManage(){
        Manage manage =manageService.manageDetail(manageId);
        ActionContext.getContext().put("manage", manage);
         return "success";
     }
    
    /**
     * 修改管理员
     * @Description (TODO这里用一句话描述这个方法的作用)
     * @return
     */
    public String updateAuth(){
        manageService.update(manage);
        String content="修改管理员";
        HttpSession session =ServletActionContext.getRequest().getSession();
        int userId = Integer.parseInt( session.getAttribute("userId").toString());
        //插入日志
        logService.addLog(content,userId);
        ActionContext.getContext().put("url", "/manage_authList.do");
        return "redirect";
     }
    
    

    @Autowired
    private SuggestService suggestService;
     /**
     * 获取建议信息列表
     * @return
     */
    public String suggestList() {
      Pager pagers = suggestService.listAll();
      ActionContext.getContext().put("pagers", pagers);
    return SUCCESS;
    }
}

RoomCatAction

package com.hotel.action;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import com.hotel.model.Room_cat;
import com.hotel.service.LogService;
import com.hotel.service.RoomCatService;
import com.hotel.utils.Pager;
import com.hotel.utils.UUIDUtils;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

@Controller("roomCatAction")
@Scope("prototype")
public class RoomCatAction extends ActionSupport implements ModelDriven{
   private Room_cat room_cat;
   private String rName2;
   private int roomCatId;

    
public String getrName2() {
    return rName2;
}

public void setrName2(String rName2) {
    this.rName2 = rName2;
}
    @Override
	public Room_cat getModel() {
		if(room_cat==null) room_cat = new Room_cat();
		return room_cat;
	}
	
	@Autowired
	private RoomCatService roomCatService;
	
	@Autowired
	private LogService logService;
	//========================图片上传
    private File file;
    
    //提交过来的file的名字
    private String fileFileName;
    
    //提交过来的file的MIME类型
    private String fileContentType;

    
    public File getFile() {
        return file;
    }
    public void setFile(File file) {
        this.file = file;
    }
    public String getFileFileName() {
        return fileFileName;
    }
    public void setFileFileName(String fileFileName) {
        this.fileFileName = fileFileName;
    }
    public String getFileContentType() {
        return fileContentType;
    }
    public void setFileContentType(String fileContentType) {
        this.fileContentType = fileContentType;
    }
    //========================图片上传

    
    public int getRoomCatId() {
        return roomCatId;
    }
    
    public void setRoomCatId(int roomCatId) {
        this.roomCatId = roomCatId;
    }
    
	/**
     * 获取客房类型信息列表
     * @return
     */
    public String roomCatList(){
      Pager pagers = roomCatService.listAll();
    ActionContext.getContext().put("pagers", pagers);
    return SUCCESS;
    }
    
  
    /**
     * 初始化客房类型新增页面
     * @return
     */
    public String addRoomCat(){
       return SUCCESS;
    }
    
    /**
     * 新增类型
     * @return
     */
    public String roomAddCat()throws Exception{
        //图片上传
        String root  = "D:/my/upload";
        InputStream is = new FileInputStream(file);
        fileFileName = UUIDUtils.create()+fileFileName;
        OutputStream os = new FileOutputStream(new File(root, fileFileName));
        System.out.println("fileFileName: " + fileFileName);
        System.out.println("file: " + file.getName());
        System.out.println("file: " + file.getPath());
        byte[] buffer = new byte[500];
        int length = 0;
        while(-1 != (length = is.read(buffer, 0, buffer.length)))
        {
            os.write(buffer);
        }
        os.close();
        is.close();
        room_cat.setImage("\\upload\\"+fileFileName);
        roomCatService.add(room_cat);
        String content="新增客房类型";
        HttpSession session =ServletActionContext.getRequest().getSession();
        int userId = Integer.parseInt( session.getAttribute("userId").toString());
        //插入日志
        logService.addLog(content,userId);
      ActionContext.getContext().put("url", "/roomCat_roomCatList.do");
      return "redirect";
    }
    
    /**
     * 初始化修改页面
     * @Description (TODO这里用一句话描述这个方法的作用)
     * @return
     */
    public String updateRoomCat(){
        Room_cat  room_cat =roomCatService.roomCatDetail(roomCatId);
        ActionContext.getContext().put("room_cat", room_cat);
         return "success";
     }
    
    /**
     * 修改客房类别
     * @return
     */
    public String roomCatUpdate()throws Exception{
        if(file!=null){
          //图片上传
        String root  = "D:/my/upload";
        InputStream is = new FileInputStream(file);
        fileFileName = UUIDUtils.create()+fileFileName;
        OutputStream os = new FileOutputStream(new File(root, fileFileName));
        System.out.println("fileFileName: " + fileFileName);
        System.out.println("file: " + file.getName());
        System.out.println("file: " + file.getPath());
        byte[] buffer = new byte[500];
        int length = 0;
        while(-1 != (length = is.read(buffer, 0, buffer.length)))
        {
            os.write(buffer);
        }
        os.close();
        is.close();
        room_cat.setImage("\\upload\\"+fileFileName);
        }else{
            Room_cat  r =roomCatService.roomCatDetail(room_cat.getId());
            room_cat.setImage(r.getImage());
        }
        roomCatService.update(room_cat);
        String content="修改客房类型";
        HttpSession session =ServletActionContext.getRequest().getSession();
        int userId = Integer.parseInt( session.getAttribute("userId").toString());
        //插入日志
        logService.addLog(content,userId);
        ActionContext.getContext().put("url", "/roomCat_roomCatList.do");
      return "redirect";
    }
    
}

 完整源码 :JAVA-MYSQL-SSH酒店客房管理系统毕业设计全套源码-Java文档类资源-CSDN下载基于SSH的毕业设计全套源码,2022精修版,修复了大量bug,用户管理,日志管理,人员权限管理更多下载资源、学习资料请访问CSDN下载频道.https://download.csdn.net/download/xia15000506007/85122484

你可能感兴趣的:(java,后端开发,编程开发,java,ssm,ssh,毕业设计,毕设)