本系统实现了高校宿舍管理系统源码,管理端实现了管理员登录、 宿舍列表、 预分配宿舍、 宿舍分配信息、 留校管理、 报修管理、 留言管理、 卫生管理,学生端实现了我的宿舍、我的报修、卫生检查记录、离校登记、留校申请、返校登记、留言板、我的留言
JDK版本:1.8
Mysql:5.7
登录用户名密码:19970805 123456
package com.usc.lzh.doms.mapper;
import com.usc.lzh.doms.entity.Users;
import org.apache.catalina.User;
import org.apache.ibatis.annotations.Param;
public interface IndexMapper {
/**
* 查找学生用户
*
* @param uid 学号
* @return
*/
public Users findStudentUserByUid(String uid);
/**
* 查找教师或宿管员用户
*
* @param uid 工号
* @return
*/
public Users findOtherUserByUid(String uid);
/**
* 查找学生用户表里是否存在用户名为uid,密码为upwd的用户
*
* @param uid 用户的id
* @param upwd 密码
* @return
*/
public int isExistSUserForUidAndPwd(@Param("uid") String uid, @Param("upwd") String upwd);
/**
* 查找管理员用户表里是否存在用户名为uid,密码为upwd的用户
*
* @param uid 用户的id
* @param upwd 密码
* @param utype 用户类型
* @return
*/
public int isExistDUserForUidAndPwd(@Param("uid") String uid, @Param("upwd") String upwd, @Param("utype") Integer utype);
/**
* 更新密码
*
* @param uid
* @param newPassword
* @return
*/
public int updateSUserPassword(String uid, String newPassword);
/**
* 更新密码
*
* @param uid
* @param newPassword
* @return
*/
public int updateDUserPassword(String uid, String newPassword);
}
package com.usc.lzh.doms.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.usc.lzh.doms.entity.Users;
import com.usc.lzh.doms.service.IndexService;
import com.usc.lzh.doms.service.MenuService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;
@Controller
@RequestMapping("/")
public class IndexController {
@Resource
private IndexService indexService;
@Resource
private MenuService menuService;
public String index() {
return "index";
}
@RequestMapping(value = "/login.html")
public String toLogin() {
return "/login";
}
@RequestMapping(value = "/home.html")
public String home() {
return "/home";
}
/**
* 验证登录
*
* @param re 前端返回的参数
* @param session 将用户信息添加到session中
* @return
*/
@ResponseBody
@RequestMapping(value = "/login.action")
public String loginAction(@RequestBody Map<String, String> re, HttpSession session) {
String uid = re.get("username");
String upwd = re.get("password");
Integer utype = Integer.parseInt(re.get("type"));
System.out.println(utype);
Users user = indexService.findUserByuId(uid, upwd, utype);
Map<String, Object> map = new HashMap<>();
if (user != null) {
session.setAttribute("uid", uid);
session.setAttribute("uname", user.getUname());
session.setAttribute("utype", utype);
// 如果是教师或宿管员,还要把他们负责的部门(专业年级/宿舍楼)记下
if (utype == 1) {
session.setAttribute("dept", user.getDept());
session.setAttribute("grade", user.getGrade());
} else if (utype == 2) {
session.setAttribute("brarea", user.getBrarea());
session.setAttribute("brbid", user.getBrbid());
}
map.put("type", "success");
} else {
map.put("type", "error");
}
return JSON.toJSONString(map);
}
/**
* 退出登录
*
* @param session
* @return 返回到登录界面
*/
@RequestMapping(value = "/logout.action")
public String logout(HttpSession session) {
// 清空session中的属性
session.removeAttribute("uid");
session.removeAttribute("uname");
session.removeAttribute("utype");
//让session无效
session.invalidate();
return "redirect:/login";
}
@ResponseBody
@RequestMapping(value = "/api/loadMenuList")
public String loadMenuList(HttpSession session) {
Integer utype = (Integer) session.getAttribute("utype");
String initJson = menuService.loadMenuList(utype);
System.out.println(initJson);
return initJson;
}
/**
* 基本资料
*
* @param session
* @return
*/
@RequestMapping(value = "/basic-info.html")
public String setBasicInfo(HttpSession session) {
Integer utype = (Integer) session.getAttribute("utype");
// 是学生则返回学生的界面
if (utype == 0) {
return "/student/basic-info";
} else {
return "/basic-info";
}
}
/**
* 修改密码
*
* @return
*/
@RequestMapping(value = "/password-setting.html")
public String setPassword() {
return "/password-setting";
}
@ResponseBody
@RequestMapping(value = "/updatePassword.action")
public String updatePassword(HttpServletRequest request) {
HashMap<String, Object> map = new HashMap<>();
String uid = (String) request.getSession().getAttribute("uid");
Integer utype = (Integer) request.getSession().getAttribute("utype");
String param = request.getParameter("param");
System.out.println(param);
try {
if (StringUtils.isNotBlank(param)) {
JSONObject obj = JSONObject.parseObject(param);
String old_password = (String) obj.get("old_password");
String new_password = (String) obj.get("new_password");
int result = indexService.updatePassword(uid, utype, old_password, new_password);
switch (result) {
case -1:
map.put("success", false);
map.put("msg", "系统出错,修改失败!");
break;
case 0:
map.put("success", false);
map.put("msg", "旧密码不正确!");
break;
case 1:
map.put("success", true);
map.put("msg", "修改成功!");
}
return JSON.toJSONString(map);
}
} catch (Exception e) {
e.printStackTrace();
map.put("success", false);
map.put("msg", "系统出错,修改失败!");
}
return JSON.toJSONString(map);
}
}
package com.usc.lzh.doms.entity;
public class Users {
private String uid;
private String uname;
private String upwd;
private Integer utype;
// 教师负责的专业
private String dept;
// 教师负责的年级
private String grade;
// 宿管员负责的宿舍区
private String brarea;
// 宿管员负责的宿舍楼
private String brbid;
private String utel;
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
public String getDept() {
return dept;
}
public void setDept(String dept) {
this.dept = dept;
}
public String getUname() {
return uname;
}
public void setUname(String uname) {
this.uname = uname;
}
public String getUpwd() {
return upwd;
}
public void setUpwd(String upwd) {
this.upwd = upwd;
}
public Integer getUtype() {
return utype;
}
public void setUtype(Integer utype) {
this.utype = utype;
}
public String getUtel() {
return utel;
}
public void setUtel(String utel) {
this.utel = utel;
}
public String getGrade() {
return grade;
}
public void setGrade(String grade) {
this.grade = grade;
}
public String getBrarea() {
return brarea;
}
public void setBrarea(String brarea) {
this.brarea = brarea;
}
public String getBrbid() {
return brbid;
}
public void setBrbid(String brbid) {
this.brbid = brbid;
}
@Override
public String toString() {
return "Users{" +
"uid='" + uid + '\'' +
", uname='" + uname + '\'' +
", upwd='" + upwd + '\'' +
", utype=" + utype +
", dept='" + dept + '\'' +
", grade='" + grade + '\'' +
", brarea='" + brarea + '\'' +
", brbid='" + brbid + '\'' +
", utel='" + utel + '\'' +
'}';
}
}
点击以下链接获取源码。
IDEA+springboot+ssm+layui+mysql高校宿舍管理系统源码
IDEA+springboot + ssm +shiro+ easyui +mysql实现的进销存系统
IDEA+springboot+mybatis+shiro+bootstrap+Mysql网上书店管理系统
IDEA+springboot+mybatis+shiro+bootstrap+Mysql WMS仓库管理系统
IDEA+spring+spring mvc+mybatis+bootstrap+jquery+Mysql运动会管理系统源码
IDEA+SpringBoot+mybatis+bootstrap+jquery+Mysql车险理赔管理系统源码
IDEA+Spring Boot + MyBatis + Layui+Mysql垃圾回收管理系统源码
IDEA+SpringBoot+mybatis+SSM+layui+Mysql学生就业信息管理系统源码
IDEA+springboot+jpa+Layui+Mysql销售考评系统源码
IDEA+Spring + Spring MVC + MyBatis+Bootstrap+Mysql酒店管理系统源码
IDEA+spring boot+mybatis+spring mvc+bootstrap+Mysql停车位管理系统源码
Java+Swing+Mysql实现学生宿舍管理系统
Java+Swing+Txt实现自助款机系统
Java+Swing+Mysql自助存取款机系统
Java+Swing+mysql5实现学生成绩管理系统(带分页)
Java+Swing+Mysql实现超市商品管理系统源码
Java+Swing+Mysql实现通讯录管理系统源码
Java+Swing+Mysql实现图书管理系统源码