基于javaweb的SpringBoot宿舍管理系统(java+springboot+thymeleaf+html+layui+mysql)

运行环境

Java≥8、MySQL≥5.7

开发工具

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

适用

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

功能说明

440023062402

450023062402

470023062402

480023062402

490023062402

500023062402

基于javaweb的SpringBoot宿舍管理系统(java+springboot+thymeleaf+html+layui+mysql)

项目介绍

宿舍管理系统,分为系统管理员与学生两种角色; 系统管理员主要功能包括: 系统管理:用户列表、角色与权限; 学生管理:学生列表、教学班级; 宿舍管理:寝室列表、寝室类型; 入住管理:住宿申请、宿舍分配详情; 学生主要功能包括:

申请入住、个人信息管理;

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。

2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;

3.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;

4.数据库:MySql 5.7版本;

技术栈

(1)Spring Boot v2.3.1 (2)Spring Data JPA 的 hibernate实现 (3)shiro 用于授权与认证 (4)Thymeleaf+html 服务器端模板引擎 (5)layui 布局前端界面

(6)jQuery 简化Dom操作与Ajax请求

使用说明
运行项目,输入localhost:8080/
管理员账户:admin  密码:123
学生账户:0123  密码:123

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
        }
try {
multipartFile.transferTo(dest);
} catch (Exception e) {
log.error("文件上传失败: error = " + e.getMessage());
return result(1, "failure:文件保存失败", null);
}
return result(0, "success", "/sdms-images/" + originalFilename);
}

private LayuiResult<Object> result(Integer code, String msg, String pictureURL) {
val m = new HashMap<String, Object>();
m.put("pictureURL", pictureURL);
return new LayuiResult<>(code, msg, null, Collections.singletonList(m));
}

}
package com.demo.controller;




@Controller
public class AllocationController {

@Resource
private RoomAllocationService allocationService;

@GetMapping(value = {"/admin/allocation-list"})
public String toAdminAllocationList() {
return "admin/allocation-list"; // Thymeleaf模板的名字,表示 templates/admin/allocation-list.html
}

@ApiOperation("ajax:分页查询学生住宿信息")
@RequestMapping(value = "/admin/allocations", method = {RequestMethod.POST})
@ResponseBody
public Page<Student> fetchPage(@RequestBody PageRequest pageRequest) {
return allocationService.fetchPage(pageRequest);
}

@ApiOperation("ajax:根据若干学号为学生完成解约")
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
    return "admin/student-list"; // Thymeleaf模板的名字,表示 templates/admin/student-list.html
}

@ApiOperation("ajax:分页查询学生信息")
@RequestMapping(value = "/admin/students", method = {RequestMethod.POST})
@ResponseBody
public Page<Student> fetchPage(@RequestBody PageRequest pageRequest) {
return studentService.fetchPage(pageRequest);
}

@ApiOperation("ajax:根据id查询学生")
@GetMapping("/admin/student")
@ResponseBody
public Student getStudentById(String id) {
return studentService.getStudentById(id);
}

@ApiOperation("跳转到学生详情界面")
@GetMapping("/admin/student/detail")
public String toDisplayStudentDetailById(@RequestParam(defaultValue = "") String id, Model model) {
val student = studentService.getStudentById(id);
if (student != null) {
model.addAttribute("student", student);
return "admin/student-detail";// Thymeleaf模板的名字,表示 templates/admin/student-detail.html
} else {
return "redirect:/admin/student-list";
}
}

@ApiOperation("跳转到学生编辑界面")
@GetMapping("/admin/student/edit")
public String toEditStudentById(@RequestParam(defaultValue = "") String id, Model model) {
val student = studentService.getStudentById(id);
if (student != null) {
model.addAttribute("operation", "编辑学生");
model.addAttribute("student", student);
model.addAttribute("teachingClasses", teachingClassService.listAllTeachingClasses());
return "admin/student-input";// Thymeleaf模板的名字,表示 templates/admin/student-input.html
} else {
return "redirect:/admin/student-list";
}
}
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
    @ResponseBody
public LayuiResult<String> deleteUserByIds(String ids) {
val idList = parseLongList(ids);
if (userService.deleteUserByIds(idList).isSuccess()) {
return new LayuiResult<>(SUCCESS, null, null);
} else {
return new LayuiResult<>(FAILED, null, null);
}
}

@ApiOperation("修改个人信息")
@GetMapping("/user/update-info")
public String updateUserInfo(User user, RedirectAttributes attributes) {
val result = userService.updateUser(user);
if (result.isSuccess()) {
attributes.addFlashAttribute("info", "操作成功");
} else {
attributes.addFlashAttribute("error", result.getMsg() + ",更新信息失败");
}
return "redirect:/login";
}
}
package com.demo.controller;




@Api("住宿申请相关api")
@Controller
public class RoomRequestController {
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
@ResponseBody
public Page<Student> fetchPage(@RequestBody PageRequest pageRequest) {
return studentService.fetchPage(pageRequest);
}

@ApiOperation("ajax:根据id查询学生")
@GetMapping("/admin/student")
@ResponseBody
public Student getStudentById(String id) {
return studentService.getStudentById(id);
}

@ApiOperation("跳转到学生详情界面")
@GetMapping("/admin/student/detail")
public String toDisplayStudentDetailById(@RequestParam(defaultValue = "") String id, Model model) {
val student = studentService.getStudentById(id);
if (student != null) {
model.addAttribute("student", student);
return "admin/student-detail";// Thymeleaf模板的名字,表示 templates/admin/student-detail.html
} else {
return "redirect:/admin/student-list";
}
}

@ApiOperation("跳转到学生编辑界面")
@GetMapping("/admin/student/edit")
public String toEditStudentById(@RequestParam(defaultValue = "") String id, Model model) {
val student = studentService.getStudentById(id);
if (student != null) {
model.addAttribute("operation", "编辑学生");
model.addAttribute("student", student);
model.addAttribute("teachingClasses", teachingClassService.listAllTeachingClasses());
return "admin/student-input";// Thymeleaf模板的名字,表示 templates/admin/student-input.html
} else {
return "redirect:/admin/student-list";
}
}

@ApiOperation("跳转到学生添加界面")
@GetMapping("/admin/student/create")
public String toCreateStudent(Model model) {
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


@Api("图片文件上传api")
@Controller
@Slf4j
public class FileUploadController {

private final static String NAME = "file";

@Resource
private PictureConfig pictureConfig;

/**
* 本地图片文件上传接口 "/upload"
*
* @param request 图片文件上传请求,要求参数名是 file, (例如:用原生form提交,input标签需要添加 name="file" )
* @return JSON格式的对象, code == 0 表示上传成功 , code == 1 表示上传失败
*/
@ApiOperation("ajax:本地图片文件上传")
@PostMapping("/upload")
@ResponseBody
public LayuiResult<Object> upload(HttpServletRequest request) {
MultipartHttpServletRequest mRequest;
if (request instanceof MultipartHttpServletRequest) {
mRequest = (MultipartHttpServletRequest) request;
} else {
return result(1, "failure:请求异常", null);
}
val multipartFile = mRequest.getFile(NAME);
if (null == multipartFile) {
return result(1, "failure:参数异常,请检查参数名是否为" + NAME, null);
}
val originalFilename = multipartFile.getOriginalFilename();
if (StringUtils.isEmpty(originalFilename)) {
return result(1, "failure:文件名为空", null);
}
val path = pictureConfig.getPath();
val dest = new File(path + originalFilename);
if (!dest.getParentFile().exists()) {
if (!dest.getParentFile().mkdirs()) {
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
    }

@ApiOperation("新增住宿申请")
@GetMapping("/room-request/new")
@ResponseBody
public LayuiResult<String> addNewRoomRequest(String studentId, Long roomId) {
if (roomRequestService.newRoomRequest(studentId, roomId).isSuccess()) {
return new LayuiResult<>(SUCCESS, null, null);
} else {
return new LayuiResult<>(FAILED, null, null);
}
}
}
package com.demo.controller;




@Api("学生相关api")
@Controller
public class StudentController {

@Resource
private StudentService studentService;

@Resource
private TeachingClassService teachingClassService;

@GetMapping(value = {"/admin/student-list"})
public String toAdminStudentList(Model model) {
model.addAttribute("teachingClasses", teachingClassService.listAllTeachingClasses());
return "admin/student-list"; // Thymeleaf模板的名字,表示 templates/admin/student-list.html
}

@ApiOperation("ajax:分页查询学生信息")
@RequestMapping(value = "/admin/students", method = {RequestMethod.POST})
@ResponseBody


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