基于javaweb的SpringBoot+JPA学生宿舍学生住宿申请管理系统(管理员、学生)(java+springboot+jpa+thymeleaf+html+mysql+maven)

运行环境

Java≥8、MySQL≥5.7

开发工具

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

适用

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

功能说明

后台管理员:管理用户、学生、班级、宿舍、处理住宿申请、分配宿舍

前台学生:查询宿舍、申请宿舍

460123202502

450123202502

440123202502

后台管理员:

310123202502

320123202502

330123202502

340123202502

350123202502

360123202502

370123202502

380123202502

400123202502

前台学生:

410123202502

420123202502

430123202502

技术框架

JSP JavaScript SpringBoot SpringDataJPA thymeleaf MySQL HTML

基于javaweb的SpringBoot+JPA学生宿舍学生住宿申请管理系统(管理员、学生)(java+springboot+jpa+thymeleaf+html+mysql+maven)

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
43
44
45
     * @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()) {
return result(1, "failure:服务器存储路径创建失败", null);
}
}
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;

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
    }

@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 {

@Resource
private RoomRequestService roomRequestService;

@Resource
private RoomService roomService;

@Resource
private StudentService studentService;

@GetMapping(value = {"/admin/room-request-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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
public String toAdminCategoryList() {
return "admin/category-list"; // Thymeleaf模板的名字,表示 templates/admin/category-list.html
}

@ApiOperation("ajax:分页查询寝室类型信息")
@RequestMapping(value = "/admin/categories", method = {RequestMethod.POST})
@ResponseBody
public Page<Category> fetchPage(@RequestBody PageRequest pageRequest) {
return categoryService.fetchPage(pageRequest);
}

@ApiOperation("ajax:根据id查询寝室类型")
@GetMapping("/admin/category/{id}")
@ResponseBody
public Category getCategoryById(@PathVariable Long id) {
return categoryService.getCategoryById(id);
}

@ApiOperation("跳转到寝室类型编辑界面")
@GetMapping("/admin/category/edit")
public String toEditCategoryById(@RequestParam(defaultValue = "-1") long id, Model model) {
val category = categoryService.getCategoryById(id);
if (category != null) {
model.addAttribute("operation", "编辑寝室类型");
model.addAttribute("category", category);
return "admin/category-input";// Thymeleaf模板的名字,表示 templates/admin/category-input.html
} else {
return "redirect:/admin/category-list";
}
}

@ApiOperation("跳转到寝室类型添加界面")
@GetMapping("/admin/category/create")
public String toCreateCategory(Model model) {
model.addAttribute("operation", "添加寝室类型");
model.addAttribute("category", new Category());
return "admin/category-input";
}

@ApiOperation("保存寝室类型")
@GetMapping("/admin/category/save")
public String saveCategory(Category category, RedirectAttributes attributes) {
val result = categoryService.saveCategory(category);
if (result.isSuccess()) {
attributes.addFlashAttribute("info", "操作成功");
} else {
attributes.addFlashAttribute("error", result.getMsg() + ",保存寝室类型失败");
}
return "redirect:/admin/category-list";
}

@ApiOperation("ajax:根据若干id删除寝室类型")
@RequestMapping(value = "/admin/category/delete", method = {RequestMethod.POST})
@ResponseBody
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



@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:根据若干学号为学生完成解约")
@RequestMapping(value = "/admin/allocation/release", method = {RequestMethod.POST})
@ResponseBody
public LayuiResult<String> releaseStudentByIds(String ids) {
val idList = parseStringList(ids);
if (allocationService.releaseStudentByIds(idList).isSuccess()) {
return new LayuiResult<>(SUCCESS, null, null);
} else {
return new LayuiResult<>(FAILED, null, null);
}
}
}
package com.demo.service.impl;



@Service
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



@Api("寝室类型相关api")
@Controller
public class CategoryController {

@Resource
private CategoryService categoryService;

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

@ApiOperation("ajax:分页查询寝室类型信息")
@RequestMapping(value = "/admin/categories", method = {RequestMethod.POST})
@ResponseBody
public Page<Category> fetchPage(@RequestBody PageRequest pageRequest) {
return categoryService.fetchPage(pageRequest);
}

@ApiOperation("ajax:根据id查询寝室类型")
@GetMapping("/admin/category/{id}")
@ResponseBody
public Category getCategoryById(@PathVariable Long id) {
return categoryService.getCategoryById(id);
}

@ApiOperation("跳转到寝室类型编辑界面")
@GetMapping("/admin/category/edit")
public String toEditCategoryById(@RequestParam(defaultValue = "-1") long id, Model model) {
val category = categoryService.getCategoryById(id);
if (category != null) {
model.addAttribute("operation", "编辑寝室类型");
model.addAttribute("category", category);
return "admin/category-input";// Thymeleaf模板的名字,表示 templates/admin/category-input.html
} else {


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