基于javaweb+mysql的springboot宿舍管理系统(java+springboot+maven+vue+elementui+axios+js+mysql)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7、Node.js≥10
开发工具
后端:eclipse/idea/myeclipse/sts等均可配置运行
前端:WebStorm/VSCode/HBuilderX等均可
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SpringBoot宿舍管理系统(java+springboot+maven+vue+elementui+axios+js+mysql)
Springboot+vue的宿舍管理系统
管理员
admin 123456
宿管员
dorm1 123456
dorm2 123456
dorm3 123456
dorm4 123456
学生
stu01 123456
stu02 123456
stu03 123456
stu04 123456
stu05 123456
stu06 123456
stu07 123456
stu08 123456
stu09 123456
stu10 123456
stu11 123456
stu12 123456
stu13 123456
stu14 123456
stu15 123456
stu16 123456
stu17 123456
stu18 123456
stu19 123456
stu20 123456
stu21 123456
stu22 123456
项目介绍
Springboot+vue的宿舍管理系统 系统用户主要包含三类:管理员、学生、宿舍管理员简称为宿管。
管理员:
用户管理:主要包含学生管理和宿舍管理员管理
宿舍管理:主要包含楼宇管理和宿舍房间管理
信息管理:主要包含公告管理和宿舍报修管理
申请管理:主要包含学生调剂宿舍管理
访客管理:主要包含外人到访宿舍的管理
个人管理:管理当前用户的个人信息
学生:
我的宿舍:查看当前学生自己所在的宿舍信息
申请调宿舍:申请调剂宿舍,等待宿舍管理员审批
报修申请:宿舍内有损坏的物品可以申请维修
个人信息:管理当前用户的个人信息
宿舍管理员:
用户管理:主要包含学生管理
宿舍管理:主要包含楼宇管理和宿舍房间管理
信息管理:主要包含公告管理和宿舍报修管理
申请管理:主要包含学生调剂宿舍管理
访客管理:主要包含外人到访宿舍的管理
个人管理:管理当前用户的个人信息
后端框架:Springboot
前端技术:ElementUI、vue、css、JavaScript、axios
}
}
/**
* 主页 住宿人数
*/
@GetMapping("/selectHaveRoomStuNum")
public Result<?> selectHaveRoomStuNum() {
Long count = dormRoomService.selectHaveRoomStuNum();
if (count >= 0) {
return Result.success(count);
} else {
return Result.error("-1", "查询首页住宿人数失败");
}
}
/**
* 住宿分布人数
*/
@GetMapping("/getEachBuildingStuNum/{num}")
public Result<?> getEachBuildingStuNum(@PathVariable int num) {
ArrayList<Long> arrayList = new ArrayList();
for (int i = 1; i <= num; i++) {
Long eachBuildingStuNum = dormRoomService.getEachBuildingStuNum(i);
arrayList.add(eachBuildingStuNum);
}
if (!arrayList.isEmpty()) {
return Result.success(arrayList);
} else {
return Result.error("-1", "获取人数失败");
}
}
/**
* 学生功能: 我的宿舍
*/
@GetMapping("/getMyRoom/{name}")
public Result<?> getMyRoom(@PathVariable String name) {
DormRoom dormRoom = dormRoomService.judgeHadBed(name);
if (dormRoom != null) {
return Result.success(dormRoom);
} else {
return Result.error("-1", "不存在该生");
public class AdminController {
String uid = new UID().produceUID();
@Resource
private AdminService adminService;
/**
* 管理员登录
*/
@PostMapping("/login")
public Result<?> login(@RequestBody User user, HttpSession session) {
Object o = adminService.adminLogin(user.getUsername(), user.getPassword());
if (o != null) {
System.out.println(o);
//存入session
session.setAttribute("Identity", "admin");
session.setAttribute("User", o);
return Result.success(o);
} else {
return Result.error("-1", "用户名或密码错误");
}
}
/**
* 管理员信息更新
*/
@PutMapping("/update")
public Result<?> update(@RequestBody Admin admin) {
int i = adminService.updateAdmin(admin);
if (i == 1) {
return Result.success();
} else {
return Result.error("-1", "更新失败");
}
}
}
@RestController
@RequestMapping("/main")
public class MainController {
return Result.error("-1", "更新失败");
}
}
/**
* 删除房间
*/
@DeleteMapping("/delete/{dormRoomId}")
public Result<?> delete(@PathVariable Integer dormRoomId) {
int i = dormRoomService.deleteRoom(dormRoomId);
if (i == 1) {
return Result.success();
} else {
return Result.error("-1", "删除失败");
}
}
/**
* 查找房间
*/
@GetMapping("/find")
public Result<?> findPage(@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "10") Integer pageSize,
@RequestParam(defaultValue = "") String search) {
Page page = dormRoomService.find(pageNum, pageSize, search);
if (page != null) {
return Result.success(page);
} else {
return Result.error("-1", "查询失败");
}
}
/**
* 首页顶部:空宿舍统计
*/
@GetMapping("/noFullRoom")
public Result<?> noFullRoom() {
int num = dormRoomService.notFullRoom();
if (num >= 0) {
return Result.success(num);
} else {
return Result.error("-1", "空宿舍查询失败");
}
}
/**
* 删除床位学生信息
return Result.error("-1", "查询失败");
}
}
/**
* 学生登录
*/
@PostMapping("/login")
public Result<?> login(@RequestBody User user, HttpSession session) {
System.out.println(user.getUsername());
System.out.println(user.getPassword());
Object o = studentService.stuLogin(user.getUsername(), user.getPassword());
if (o != null) {
System.out.println(o);
//存入session
session.setAttribute("Identity", "stu");
session.setAttribute("User", o);
return Result.success(o);
} else {
return Result.error("-1", "用户名或密码错误");
}
}
/**
* 主页顶部:学生统计
*/
@GetMapping("/stuNum")
public Result<?> stuNum() {
int num = studentService.stuNum();
if (num > 0) {
return Result.success(num);
} else {
return Result.error("-1", "查询失败");
}
}
/**
* 床位信息,查询是否存在该学生
* 床位信息,查询床位上的学生信息
*/
@GetMapping("/exist/{value}")
public Result<?> exist(@PathVariable String value) {
Student student = studentService.stuInfo(value);
if (student != null) {
return Result.success(student);
} else {
return Result.error("-1", "不存在该学生");
}
}
*/
@DeleteMapping("/delete/{username}")
public Result<?> delete(@PathVariable String username) {
int i = studentService.deleteStudent(username);
if (i == 1) {
return Result.success();
} else {
return Result.error("-1", "删除失败");
}
}
/**
* 查找学生信息
*/
@GetMapping("/find")
public Result<?> findPage(@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "10") Integer pageSize,
@RequestParam(defaultValue = "") String search) {
Page page = studentService.find(pageNum, pageSize, search);
if (page != null) {
return Result.success(page);
} else {
return Result.error("-1", "查询失败");
}
}
/**
* 学生登录
*/
@PostMapping("/login")
public Result<?> login(@RequestBody User user, HttpSession session) {
System.out.println(user.getUsername());
System.out.println(user.getPassword());
Object o = studentService.stuLogin(user.getUsername(), user.getPassword());
if (o != null) {
System.out.println(o);
//存入session
session.setAttribute("Identity", "stu");
session.setAttribute("User", o);
return Result.success(o);
} else {
return Result.error("-1", "用户名或密码错误");
}
}
/**
* 楼宇查找
*/
@GetMapping("/find")
public Result<?> findPage(@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "10") Integer pageSize,
@RequestParam(defaultValue = "") String search) {
Page page = dormBuildService.find(pageNum, pageSize, search);
if (page != null) {
return Result.success(page);
} else {
return Result.error("-1", "查询失败");
}
}
/**
* 首页Echarts 获取楼宇信息
*/
@GetMapping("/getBuildingName")
public Result<?> getBuildingName() {
List<DormBuild> buildingName = dormBuildService.getBuildingId();
List<Integer> buildingId = buildingName.stream().map(dormBuildId -> dormBuildId.getDormBuildId()).collect(Collectors.toList());
if (!buildingId.isEmpty()) {
return Result.success(buildingId);
} else {
return Result.error("-1", "查询失败");
}
}
}
@RestController
@RequestMapping("/adjustRoom")
public class AdjustRoomController {
@Resource
/**
* 管理员信息更新
*/
@PutMapping("/update")
public Result<?> update(@RequestBody Admin admin) {
int i = adminService.updateAdmin(admin);
if (i == 1) {
return Result.success();
} else {
return Result.error("-1", "更新失败");
}
}
}
@RestController
@RequestMapping("/main")
public class MainController {
/**
* 获取身份信息
*/
@GetMapping("/loadIdentity")
public Result<?> loadIdentity(HttpSession session) {
Object identity = session.getAttribute("Identity");
if (identity != null) {
return Result.success(identity);
} else {
return Result.error("-1", "加载失败");
}
}
/**
* 获取个人信息
*/
@GetMapping("/loadUserInfo")
public Result<?> loadUserInfo(HttpSession session) {
Object User = session.getAttribute("User");
if (User != null) {
return Result.success(User);
} else {
return Result.error("-1", "加载失败");
}
}
*/
@DeleteMapping("/delete/{id}")
public Result<?> delete(@PathVariable Integer id) {
int i = repairService.deleteOrder(id);
if (i == 1) {
return Result.success();
} else {
return Result.error("-1", "删除失败");
}
}
/**
* 查找订单
*/
@GetMapping("/find")
public Result<?> findPage(@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "10") Integer pageSize,
@RequestParam(defaultValue = "") String search) {
Page page = repairService.find(pageNum, pageSize, search);
if (page != null) {
return Result.success(page);
} else {
return Result.error("-1", "查询失败");
}
}
/**
* 个人申报报修 分页查询
*/
@GetMapping("/find/{name}")
public Result<?> individualFind(@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "10") Integer pageSize,
@RequestParam(defaultValue = "") String search,
@PathVariable String name) {
System.out.println(name);
Page page = repairService.individualFind(pageNum, pageSize, search, name);
if (page != null) {
return Result.success(page);
} else {
return Result.error("-1", "查询失败");
}
}
/**
@RestController
@RequestMapping("/admin")
public class AdminController {
String uid = new UID().produceUID();
@Resource
private AdminService adminService;
/**
* 管理员登录
*/
@PostMapping("/login")
public Result<?> login(@RequestBody User user, HttpSession session) {
Object o = adminService.adminLogin(user.getUsername(), user.getPassword());
if (o != null) {
System.out.println(o);
//存入session
session.setAttribute("Identity", "admin");
session.setAttribute("User", o);
return Result.success(o);
} else {
return Result.error("-1", "用户名或密码错误");
}
}
/**
* 管理员信息更新
*/
@PutMapping("/update")
public Result<?> update(@RequestBody Admin admin) {
int i = adminService.updateAdmin(admin);
if (i == 1) {
return Result.success();
} else {
/**
* 床位信息,查询该学生是否已由床位
*/
@GetMapping("/judgeHadBed/{value}")
public Result<?> judgeHadBed(@PathVariable String value) {
DormRoom dormRoom = dormRoomService.judgeHadBed(value);
if (dormRoom == null) {
return Result.success();
} else {
return Result.error("-1", "该学生已有宿舍");
}
}
/**
* 主页 住宿人数
*/
@GetMapping("/selectHaveRoomStuNum")
public Result<?> selectHaveRoomStuNum() {
Long count = dormRoomService.selectHaveRoomStuNum();
if (count >= 0) {
return Result.success(count);
} else {
return Result.error("-1", "查询首页住宿人数失败");
}
}
/**
* 住宿分布人数
*/
@GetMapping("/getEachBuildingStuNum/{num}")
public Result<?> getEachBuildingStuNum(@PathVariable int num) {
ArrayList<Long> arrayList = new ArrayList();
for (int i = 1; i <= num; i++) {
Long eachBuildingStuNum = dormRoomService.getEachBuildingStuNum(i);
arrayList.add(eachBuildingStuNum);
}
if (!arrayList.isEmpty()) {
return Result.success(arrayList);
} else {
return Result.error("-1", "获取人数失败");
}
}
/**
* 学生功能: 我的宿舍
*/
@GetMapping("/getMyRoom/{name}")
public Result<?> getMyRoom(@PathVariable String name) {
DormRoom dormRoom = dormRoomService.judgeHadBed(name);
if (dormRoom != null) {
return Result.success(dormRoom);
} else {
return Result.success();
} else {
return Result.error("-1", "删除失败");
}
}
/**
* 访客查询
*/
@GetMapping("/find")
public Result<?> findPage(@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "10") Integer pageSize,
@RequestParam(defaultValue = "") String search) {
Page page = visitorService.find(pageNum, pageSize, search);
if (page != null) {
return Result.success(page);
} else {
return Result.error("-1", "查询失败");
}
}
}
@RestController
@RequestMapping("/admin")
public class AdminController {
String uid = new UID().produceUID();
@Resource
private AdminService adminService;
if (page != null) {
return Result.success(page);
} else {
return Result.error("-1", "查询失败");
}
}
/**
* 首页Echarts 获取楼宇信息
*/
@GetMapping("/getBuildingName")
public Result<?> getBuildingName() {
List<DormBuild> buildingName = dormBuildService.getBuildingId();
List<Integer> buildingId = buildingName.stream().map(dormBuildId -> dormBuildId.getDormBuildId()).collect(Collectors.toList());
if (!buildingId.isEmpty()) {
return Result.success(buildingId);
} else {
return Result.error("-1", "查询失败");
}
}
}
@RestController
@RequestMapping("/adjustRoom")
public class AdjustRoomController {
@Resource
private AdjustRoomService adjustRoomService;
@Resource
private DormRoomService dormRoomService;
/**
* 添加订单
*/
@PostMapping("/add")
public Result<?> add(@RequestBody AdjustRoom adjustRoom) {
return Result.error("-1", "rootFilePath为空");
}
return Result.error("-1", "设置头像失败");
}
@PostMapping("/uploadAvatar/admin")
public Result<?> uploadAdminAvatar(@RequestBody Admin admin) {
if (originalFilename != null) {
admin.setAvatar(originalFilename);
int i = adminService.updateAdmin(admin);
if (i == 1) {
return Result.success(originalFilename);
}
} else {
return Result.error("-1", "rootFilePath为空");
}
return Result.error("-1", "设置头像失败");
}
@PostMapping("/uploadAvatar/dormManager")
public Result<?> uploadDormManagerAvatar(@RequestBody DormManager dormManager) {
if (originalFilename != null) {
dormManager.setAvatar(originalFilename);
int i = dormManagerService.updateNewDormManager(dormManager);
if (i == 1) {
return Result.success(originalFilename);
}
} else {
return Result.error("-1", "rootFilePath为空");
}
return Result.error("-1", "设置头像失败");
}
/**
* 前端调用接口,后端查询存储与本地的头像,进行Base64编码 发送到前端
*/
@GetMapping("/initAvatar/{filename}")
public Result<?> initAvatar(@PathVariable String filename) throws IOException {
System.out.println(filename);
String path = rootFilePath + filename;
System.out.println(path);
return Result.success(getImage(path));
}
private Result<?> getImage(String path) throws IOException {
//读取图片变成字节数组
FileInputStream fileInputStream = new FileInputStream(path);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] b = new byte[1024];
int len = -1;
}
/**
* 公告删除
*/
@DeleteMapping("/delete/{id}")
public Result<?> delete(@PathVariable Integer id) {
int i = noticeService.deleteNotice(id);
if (i == 1) {
return Result.success();
} else {
return Result.error("-1", "删除失败");
}
}
/**
* 公告查找
*/
@GetMapping("/find")
public Result<?> findPage(@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "10") Integer pageSize,
@RequestParam(defaultValue = "") String search) {
Page page = noticeService.find(pageNum, pageSize, search);
if (page != null) {
return Result.success(page);
} else {
return Result.error("-1", "查询失败");
}
}
/**
* 首页公告展示
*/
@GetMapping("/homePageNotice")
public Result<?> homePageNotice() {
List<?> list = noticeService.homePageNotice();
if (list != null) {
return Result.success(list);
} else {
return Result.error("-1", "首页公告查询失败");
}
}
}
/**
* 删除房间
*/
@DeleteMapping("/delete/{dormRoomId}")
public Result<?> delete(@PathVariable Integer dormRoomId) {
int i = dormRoomService.deleteRoom(dormRoomId);
if (i == 1) {
return Result.success();
} else {
return Result.error("-1", "删除失败");
}
}
/**
* 查找房间
*/
@GetMapping("/find")
public Result<?> findPage(@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "10") Integer pageSize,
@RequestParam(defaultValue = "") String search) {
Page page = dormRoomService.find(pageNum, pageSize, search);
if (page != null) {
return Result.success(page);
} else {
return Result.error("-1", "查询失败");
}
}
/**
* 首页顶部:空宿舍统计
*/
@GetMapping("/noFullRoom")
public Result<?> noFullRoom() {
int num = dormRoomService.notFullRoom();
if (num >= 0) {
return Result.success(num);
} else {
return Result.error("-1", "空宿舍查询失败");
}
}
/**
* 删除床位学生信息
*/
@DeleteMapping("/delete/{bedName}/{dormRoomId}/{calCurrentNum}")
public Result<?> deleteBedInfo(@PathVariable String bedName, @PathVariable Integer dormRoomId, @PathVariable int calCurrentNum) {
int i = dormRoomService.deleteBedInfo(bedName, dormRoomId, calCurrentNum);
return Result.success();
} else {
return Result.error("-1", "添加失败");
}
}
/**
* 更新订单
*/
@PutMapping("/update")
public Result<?> update(@RequestBody Repair repair) {
int i = repairService.updateNewOrder(repair);
if (i == 1) {
return Result.success();
} else {
return Result.error("-1", "更新失败");
}
}
/**
* 删除订单
*/
@DeleteMapping("/delete/{id}")
public Result<?> delete(@PathVariable Integer id) {
int i = repairService.deleteOrder(id);
if (i == 1) {
return Result.success();
} else {
return Result.error("-1", "删除失败");
}
}
/**
* 查找订单
*/
@GetMapping("/find")
public Result<?> findPage(@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "10") Integer pageSize,
@RequestParam(defaultValue = "") String search) {
Page page = repairService.find(pageNum, pageSize, search);
@Resource
private DormRoomService dormRoomService;
/**
* 添加订单
*/
@PostMapping("/add")
public Result<?> add(@RequestBody AdjustRoom adjustRoom) {
int result = adjustRoomService.addApply(adjustRoom);
if (result == 1) {
return Result.success();
} else {
return Result.error("-1", "查询失败");
}
}
/**
* 更新订单
*/
@PutMapping("/update/{state}")
public Result<?> update(@RequestBody AdjustRoom adjustRoom, @PathVariable Boolean state) {
if (state) {
// 更新房间表信息
int i = dormRoomService.adjustRoomUpdate(adjustRoom);
if (i == -2) {
return Result.error("-1", "重复操作");
}
}
//更新调宿表信息
int i = adjustRoomService.updateApply(adjustRoom);
if (i == 1) {
return Result.success();
} else {
return Result.error("-1", "更新失败");
}
}
/**
* 删除订单
*/
@DeleteMapping("/delete/{id}")
public Result<?> delete(@PathVariable Integer id) {