基于SSM的学生宿舍管理系统设计与实现

末尾获取源码
开发语言:Java
Java开发工具:JDK1.8
后端框架:SSM
前端:采用JSP技术开发
数据库:MySQL5.7和Navicat管理工具结合
服务器:Tomcat8.5
开发软件:IDEA / Eclipse
是否Maven项目:是


目录

一、项目简介

二、系统设计

系统概要设计

系统功能结构设计

三、系统项目截图

学生管理

宿舍信息管理

访客管理

班级管理

四、核心代码

4.1登录相关

4.2文件上传

4.3封装


一、项目简介

现代经济快节奏发展以及不断完善升级的信息化技术,让传统数据信息的管理升级为软件存储,归纳,集中处理数据信息的管理方式。本学生宿舍管理系统就是在这样的大环境下诞生,其可以帮助管理者在短时间内处理完毕庞大的数据信息,使用这种软件工具可以帮助管理人员提高事务处理效率,达到事半功倍的效果。此学生宿舍管理系统利用当下成熟完善的SSM框架,使用跨平台的可开发大型商业网站的Java语言,以及最受欢迎的RDBMS应用软件之一的Mysql数据库进行程序开发。实现了宿舍基础数据的管理,访客管理,卫生管理。学生宿舍管理系统的开发根据操作人员需要设计的界面简洁美观,在功能模块布局上跟同类型网站保持一致,程序在实现基本要求功能时,也为数据信息面临的安全问题提供了一些实用的解决方案。可以说该程序在帮助管理者高效率地处理工作事务的同时,也实现了数据信息的整体化,规范化与自动化。


二、系统设计

学生宿舍管理系统的设计方案比如功能框架的设计,比如数据库的设计的好坏也就决定了该系统在开发层面是否高效,以及在系统维护层面是否容易维护和升级,因为在系统实现阶段是需要考虑用户的所有需求,要是在设计阶段没有经过全方位考虑,那么系统实现的部分也就无从下手,所以系统设计部分也是至关重要的一个环节,只有根据用户需求进行细致全面的考虑,才有希望开发出功能健全稳定的程序软件。

系统概要设计

本次拟开发的系统为了节约开发成本,也为了后期在维护和升级上的便利性,打算通过浏览器来实现系统功能界面的展示,让程序软件的主要事务集中在后台的服务器端处理,前端部分只用处理少量的事务逻辑。下面使用一张图(如图4.1所示)来说明程序的工作原理。

系统功能结构设计

在分析并得出使用者对程序的功能要求时,就可以进行程序设计了。如图4.2展示的就是管理员功能结构图,管理员主要负责填充宿舍和其类别信息,并对已填充的数据进行维护,包括修改与删除,访客管理,卫生管理,班级管理等。

 



三、系统项目截图

学生管理

学生管理页面,此页面提供给管理员的功能有:新增学生,删除学生,修改学生信息。

宿舍信息管理

宿舍信息管理页面,此页面提供给管理员的功能有:新增宿舍,修改宿舍,删除宿舍,添加宿舍人员,删除宿舍人员,宿舍资产信息新增,宿舍资产删除。

 

访客管理

访客管理页面,此页面提供给管理员的功能有:新增访客,删除访客。

 

班级管理

班级管理页面,此页面提供给管理员的功能有:新增班级,修改班级,删除班级。

 


四、核心代码

4.1登录相关


package com.controller;


import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.TokenEntity;
import com.entity.UserEntity;
import com.service.TokenService;
import com.service.UserService;
import com.utils.CommonUtil;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.ValidatorUtils;

/**
 * 登录相关
 */
@RequestMapping("users")
@RestController
public class UserController{
	
	@Autowired
	private UserService userService;
	
	@Autowired
	private TokenService tokenService;

	/**
	 * 登录
	 */
	@IgnoreAuth
	@PostMapping(value = "/login")
	public R login(String username, String password, String captcha, HttpServletRequest request) {
		UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
		if(user==null || !user.getPassword().equals(password)) {
			return R.error("账号或密码不正确");
		}
		String token = tokenService.generateToken(user.getId(),username, "users", user.getRole());
		return R.ok().put("token", token);
	}
	
	/**
	 * 注册
	 */
	@IgnoreAuth
	@PostMapping(value = "/register")
	public R register(@RequestBody UserEntity user){
//    	ValidatorUtils.validateEntity(user);
    	if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
    		return R.error("用户已存在");
    	}
        userService.insert(user);
        return R.ok();
    }

	/**
	 * 退出
	 */
	@GetMapping(value = "logout")
	public R logout(HttpServletRequest request) {
		request.getSession().invalidate();
		return R.ok("退出成功");
	}
	
	/**
     * 密码重置
     */
    @IgnoreAuth
	@RequestMapping(value = "/resetPass")
    public R resetPass(String username, HttpServletRequest request){
    	UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
    	if(user==null) {
    		return R.error("账号不存在");
    	}
    	user.setPassword("123456");
        userService.update(user,null);
        return R.ok("密码已重置为:123456");
    }
	
	/**
     * 列表
     */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params,UserEntity user){
        EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
    	PageUtils page = userService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.allLike(ew, user), params), params));
        return R.ok().put("data", page);
    }

	/**
     * 列表
     */
    @RequestMapping("/list")
    public R list( UserEntity user){
       	EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
      	ew.allEq(MPUtil.allEQMapPre( user, "user")); 
        return R.ok().put("data", userService.selectListView(ew));
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") String id){
        UserEntity user = userService.selectById(id);
        return R.ok().put("data", user);
    }
    
    /**
     * 获取用户的session用户信息
     */
    @RequestMapping("/session")
    public R getCurrUser(HttpServletRequest request){
    	Long id = (Long)request.getSession().getAttribute("userId");
        UserEntity user = userService.selectById(id);
        return R.ok().put("data", user);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody UserEntity user){
//    	ValidatorUtils.validateEntity(user);
    	if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
    		return R.error("用户已存在");
    	}
        userService.insert(user);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody UserEntity user){
//        ValidatorUtils.validateEntity(user);
        userService.updateById(user);//全部更新
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
        userService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }
}

4.2文件上传

package com.controller;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.UUID;

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.ConfigEntity;
import com.entity.EIException;
import com.service.ConfigService;
import com.utils.R;

/**
 * 上传文件映射表
 */
@RestController
@RequestMapping("file")
@SuppressWarnings({"unchecked","rawtypes"})
public class FileController{
	@Autowired
    private ConfigService configService;
	/**
	 * 上传文件
	 */
	@RequestMapping("/upload")
	public R upload(@RequestParam("file") MultipartFile file,String type) throws Exception {
		if (file.isEmpty()) {
			throw new EIException("上传文件不能为空");
		}
		String fileExt = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1);
		File path = new File(ResourceUtils.getURL("classpath:static").getPath());
		if(!path.exists()) {
		    path = new File("");
		}
		File upload = new File(path.getAbsolutePath(),"/upload/");
		if(!upload.exists()) {
		    upload.mkdirs();
		}
		String fileName = new Date().getTime()+"."+fileExt;
		File dest = new File(upload.getAbsolutePath()+"/"+fileName);
		file.transferTo(dest);
		FileUtils.copyFile(dest, new File("C:\\Users\\Desktop\\jiadian\\springbootl7own\\src\\main\\resources\\static\\upload"+"/"+fileName));
		if(StringUtils.isNotBlank(type) && type.equals("1")) {
			ConfigEntity configEntity = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile"));
			if(configEntity==null) {
				configEntity = new ConfigEntity();
				configEntity.setName("faceFile");
				configEntity.setValue(fileName);
			} else {
				configEntity.setValue(fileName);
			}
			configService.insertOrUpdate(configEntity);
		}
		return R.ok().put("file", fileName);
	}
	
	/**
	 * 下载文件
	 */
	@IgnoreAuth
	@RequestMapping("/download")
	public ResponseEntity<byte[]> download(@RequestParam String fileName) {
		try {
			File path = new File(ResourceUtils.getURL("classpath:static").getPath());
			if(!path.exists()) {
			    path = new File("");
			}
			File upload = new File(path.getAbsolutePath(),"/upload/");
			if(!upload.exists()) {
			    upload.mkdirs();
			}
			File file = new File(upload.getAbsolutePath()+"/"+fileName);
			if(file.exists()){
				/*if(!fileService.canRead(file, SessionManager.getSessionUser())){
					getResponse().sendError(403);
				}*/
				HttpHeaders headers = new HttpHeaders();
			    headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);    
			    headers.setContentDispositionFormData("attachment", fileName);    
			    return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file),headers, HttpStatus.CREATED);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		return new ResponseEntity<byte[]>(HttpStatus.INTERNAL_SERVER_ERROR);
	}
	
}

4.3封装

package com.utils;

import java.util.HashMap;
import java.util.Map;

/**
 * 返回数据
 */
public class R extends HashMap<String, Object> {
	private static final long serialVersionUID = 1L;
	
	public R() {
		put("code", 0);
	}
	
	public static R error() {
		return error(500, "未知异常,请联系管理员");
	}
	
	public static R error(String msg) {
		return error(500, msg);
	}
	
	public static R error(int code, String msg) {
		R r = new R();
		r.put("code", code);
		r.put("msg", msg);
		return r;
	}

	public static R ok(String msg) {
		R r = new R();
		r.put("msg", msg);
		return r;
	}
	
	public static R ok(Map<String, Object> map) {
		R r = new R();
		r.putAll(map);
		return r;
	}
	
	public static R ok() {
		return new R();
	}

	public R put(String key, Object value) {
		super.put(key, value);
		return this;
	}
}

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 基于SSM学生宿舍管理系统是一种基于Java技术的Web应用程序,它采用了SpringSpringMVC和MyBatis三个框架来实现。该系统主要用于管理学生宿舍的信息,包括学生信息、宿舍信息、宿舍楼信息、宿舍管理员信息等。系统的设计实现需要考虑到数据的安全性、可靠性和易用性等方面,同时还需要满足用户的需求和操作习惯。系统的实现需要涉及到数据库设计、前端页面设计、后端代码编写等多个方面,需要具备一定的技术水平和经验。 ### 回答2: 随着信息化的快速发展,各个行业的管理都逐渐数字化,学生宿舍的管理也不例外。基于SSM学生宿舍管理系统将帮助学生宿舍管理部门更快、更方便地管理学生宿舍信息,减轻管理负担,提高管理效率。 一、需求分析 学生宿舍管理系统主要需要实现以下基本功能: 1. 学生信息管理:包括学生的基本信息、所属宿舍和宿舍的分配信息。此外,还要记录学生的出入记录,以及借用设备等信息。 2. 宿舍楼管理:包括宿舍楼基本信息和宿舍楼得分情况等内容。 3. 宿舍床位管理:包括宿舍床位的分配、空床位的查询等功能。 4. 设备管理:维护学生宿舍的设备设施,包括设备的借用、归还和维修信息。 5. 统计分析:对于学生宿舍楼的得分情况、设备使用情况、借用记录等信息进行统计和分析。 二、系统设计 1. 系统架构设计 考虑到系统的易用性和可维护性,本系统采用了基于SSM框架的设计思路。 SSM框架基于SpringSpringMVC和MyBatis三大开源框架,Spring提供核心的IOC和AOP功能,SpringMVC提供MVC框架的整体架构,MyBatis提供ORM框架。 2. 数据库设计 本系统的数据库采用MySQL数据库,根据需求分析,建立了以下实体的关系模型: 学生表(Student):包括学生编号(id)、学生姓名(name)、班级编号(class_id)、宿舍编号(dorm_id)等字段。 宿舍楼表(Dormitory_building):包括宿舍楼编号(id)、宿舍楼名称(name)、宿舍楼得分(score)等字段。 宿舍床位表(Dorm_bed):包括床位编号(id)、宿舍编号(dorm_id)、床位号(bed_number)、是否空闲(is_empty)等字段。 设备表(Equipment):包括设备编号(id)、设备名称(name)、设备数量(number)、设备状态(state)等字段。 三、系统实现 根据上述需求分析和系统设计,采用Java语言和SSM框架来实现学生宿舍管理系统。 1. 系统界面设计 在系统界面的设计上,要注重界面美观性和易用性。本系统采用了基于Bootstrap前端框架的设计,使得系统界面美观简洁且易于操作。 2. 系统功能实现 系统功能实现主要分为以下几个模块: (1)学生信息管理模块:实现对学生信息的录入、修改和删除等功能。 (2)宿舍楼管理模块:实现对宿舍楼信息的录入、修改和删除等功能。 (3)宿舍床位管理模块:实现对床位信息的录入、修改和查询等功能。 (4)设备管理模块:实现对设备借用、归还、维修等功能。 (5)统计分析模块:对系统中所采集的数据进行分析和统计,帮助管理人员更好地了解宿舍楼和设备的使用情况。 四、总结 基于SSM学生宿舍管理系统设计实现的过程中,主要考虑到了系统功能、系统架构和用户界面等因素。通过对需求分析的上述实现, 系统可以更好、更快地管理学生宿舍信息,减轻了管理人员的负担,提高了管理效率。 ### 回答3: 随着信息化进程的不断推进,学生宿舍的管理也逐渐地数字化和网络化。基于ssm学生宿舍管理系统适应了现代化管理的要求,能够实现对学生宿舍的实时监控、预警和数据管理,方便快捷、高效精准地进行宿舍管理。 一、系统设计 1. 系统架构 基于ssm学生宿舍管理系统主要由前端页面、前端控制器、服务层、dao层、数据库等模块组成。前端页面使用html、css、js等技术实现,在页面中调用前端控制器的api接口,然后由服务层进行数据处理和业务逻辑的实现,dao层负责与数据库的交互,从而实现对数据的增删改查等操作。 2. 功能模块 该系统包含学生信息管理、宿舍信息管理、宿舍报修、宿舍卫生检查、宿舍保修等功能模块。学生信息管理模块包含学生个人信息、宿舍号、床位号、联络信息等;宿舍信息管理模块包含宿舍房间号、楼层号、宿舍类型等;宿舍报修模块包含宿舍报修单的提交、审核、受理、处理等流程;宿舍卫生检查模块包含宿舍卫生检查的提交、审核、评定等流程;宿舍保修模块包含宿舍保修单的提交、审核、受理、处理等流程。 二、系统实现 1. 技术选型 前端采用了html、css、js、bootstrap等技术;前端控制器选用了SpringMVC,服务层选用了Spring框架,dao层采用Mybatis框架;数据库使用MySQL。 2. 实现细节 在具体的实现过程中,需要通过Spring的IoC机制来实现类之间的依赖控制,通过Spring AOP来实现事务控制等;同时,为了保证系统的安全性,需要对用户的身份进行验证和权限控制,采用Shiro进行身份验证和权限控制;再对数据进行保障,需要加密传输,这里使用了https协议。 三、总结 基于ssm学生宿舍管理系统是一款十分实用的宿舍管理软件,通过采用先进的技术,结合实际需求,能够满足学生宿舍管理的需求。在今后的使用中,应该不断地优化它的功能和性能,使其在更多的学校中应用,为宿舍管理带来更多的便捷和高效性。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值