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

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

学生主要功能包括:

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

环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
5.是否Maven项目: 是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目

6.数据库: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请求

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
  2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行;
  3. 将项目中application.yml配置文件中的数据库配置改为自己的配置
  4. 运行项目,输入localhost:8080/ 登录
  5. 管理员账户:admin 密码:123

学生账户:0123 密码:123请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

适用

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

	public Result<Boolean> edit(User user){
		//用统一验证实体方法验证是否合法
		CodeMsg validate = ValidateEntityUtil.validate(user);
		if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
			return Result.error(validate);
		}
		if(user.getRole() == null || user.getRole().getId() == null){
			return Result.error(CodeMsg.ADMIN_USER_ROLE_EMPTY);
		}
		if(user.getId() == null || user.getId().longValue() <= 0){
			return Result.error(CodeMsg.ADMIN_USE_NO_EXIST);
		}
		if(userService.isExistUsername(user.getUsername(), user.getId())){
			return Result.error(CodeMsg.ADMIN_USERNAME_EXIST);
		}
        List<Coach> all1 = coachDao.findAll();
        model.addAttribute("coachs",all1);
        model.addAttribute("dormitorys",byBuilding_id);
        model.addAttribute("buildings",all2);
        model.addAttribute("student",byID );
        return "admin/student/edit";
    }
    @Autowired
   private BuildingService buildingService;
    /**
     * 角色添加页面
     * @param
     * @return
     */
    @RequestMapping(value="/add",method= RequestMethod.GET)
    public String add(Model model){
        //查出所有的宿舍
        List<Dormitory> all = dormitoryService.findAll();
        //查出所有辅导员
        List<Building> all2 = buildingService.findAll();
        List<Coach> all1 = coachDao.findAll();
        //model.addAttribute("dormitorys",all);
        model.addAttribute("coachs",all1);
        model.addAttribute("buildings",all2);
        return "admin/student/add";
    }
    @RequestMapping(value="delete",method= RequestMethod.POST)
 * @author yy
 *
 */
@RequestMapping("/user")
@Controller
public class UserController {
	@Autowired
	private UserService userService;
	@Autowired
	private RoleService roleService;
	@Autowired
	private OperaterLogService operaterLogService;
	/**
	 * 用户列表页面
	 * @param model
	 * @param user
	 * @param pageBean
	 * @return
	 */
	@RequestMapping(value="/list")
	public String list(Model model,User user,PageBean<User> pageBean){
		model.addAttribute("title", "用户列表");
		model.addAttribute("username", user.getUsername());
		model.addAttribute("pageBean", userService.findList(user, pageBean));
		return "admin/user/list";
	@Autowired
	private OperaterLogService operaterLogService;
	/**
	 * 用户列表页面
	 * @param model
	 * @param user
	 * @param pageBean
	 * @return
	 */
	@RequestMapping(value="/list")
	public String list(Model model,User user,PageBean<User> pageBean){
		model.addAttribute("title", "用户列表");
		model.addAttribute("username", user.getUsername());
		model.addAttribute("pageBean", userService.findList(user, pageBean));
		return "admin/user/list";
     */
    @RequestMapping(value="/add",method= RequestMethod.GET)
    public String add(Model model){
        //查出所有的宿舍
        List<Dormitory> all = dormitoryService.findAll();
        //查出所有辅导员
        List<Building> all2 = buildingService.findAll();
        List<Coach> all1 = coachDao.findAll();
        //model.addAttribute("dormitorys",all);
        model.addAttribute("coachs",all1);
        model.addAttribute("buildings",all2);
        return "admin/student/add";
    }
    @RequestMapping(value="delete",method= RequestMethod.POST)
    @ResponseBody
    public Result delete(long id){
        try {
            studentService.delete(id);
        } catch (Exception e) {
            return Result.error(CodeMsg.ADMIN_ROLE_DELETE_ERROR);
        }
        return Result.success(true);
    }
        operaterLogService.add("编辑楼栋,楼栋校区和楼号:" + building.getCampus()+building.getBno());
        return Result.success(true);
    }
    /**
     * 删除楼栋
     * @param id
     * @return
     */
    @RequestMapping(value="/delete",method=RequestMethod.POST)
    @ResponseBody
    public Result<Boolean> delete(@RequestParam(name="id",required=true)Long id){
        try {
            buildingService.delete(id);
        } catch (Exception e) {
     */
    @RequestMapping(value="/delete",method=RequestMethod.POST)
    @ResponseBody
    public Result<Boolean> delete(@RequestParam(name="id",required=true)Long id){
        try {
            buildingService.delete(id);
        } catch (Exception e) {
            return Result.error(CodeMsg.ADMIN_BUILDING_DELETE_ERROR);
        }
        operaterLogService.add("添加用户,用户ID:" + id);
        return Result.success(true);
    }
}
@RequestMapping("/stu")
@Controller
            //讲提交的用户信息指定字段复制到已存在的user对象中,该方法会覆盖新字段内容
            BeanUtils.copyProperties(student,byID, "id","createTime","updateTime","studentNo","role","password");
            studentService.save(byID);
        }else {
           if (!StringUtil.emailFormat(student.getEmail())){
            return   Result.error(CodeMsg.ADMIN_STUDENT_EMAIL);
           }
            if (!StringUtil.isMobile(student.getMobile())){
                return   Result.error(CodeMsg.ADMIN_STUDENT_MOBILE);
            }
            student.setRole(roleService.findByRoleType(RoleType.STUDENT));
            String s = StringUtil.generateSn("S", "");
            student.setStudentNo(s);
            student.setPassword(s);
            studentService.save(student);
        }
        return Result.success(true);
    }
    @Autowired
    private OperaterLogService operaterLogService;
	public String add(Model model){
		model.addAttribute("roles", roleService.findAll());
		return "admin/user/add";
	}
	
	/**
	 * 用户添加表单提交处理
	 * @param user
	 * @return
	 */
	@RequestMapping(value="/add",method=RequestMethod.POST)
	@ResponseBody
	public Result<Boolean> add(User user){
		//用统一验证实体方法验证是否合法
		CodeMsg validate = ValidateEntityUtil.validate(user);
		if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
			return Result.error(validate);
		}
		if(user.getRole() == null || user.getRole().getId() == null){
	
	/**
	 * 用户编辑页面
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/edit",method=RequestMethod.GET)
	public String edit(Model model,@RequestParam(name="id",required=true)Long id){
		model.addAttribute("roles", roleService.findAll());
		model.addAttribute("user", userService.find(id));
		return "admin/user/edit";
	}
	
	/**
	 * 编辑用户信息表单提交处理
	 * @param user
	 * @return
	 */
	@RequestMapping(value="/edit",method=RequestMethod.POST)
	@ResponseBody
	public Result<Boolean> edit(User user){
		//用统一验证实体方法验证是否合法
		CodeMsg validate = ValidateEntityUtil.validate(user);
		if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
			return Result.error(validate);
		}
	 * @return
	 */
	@RequestMapping(value="/add",method=RequestMethod.GET)
	public String add(Model model){
		model.addAttribute("roles", roleService.findAll());
		return "admin/user/add";
	}
	
	/**
	 * 用户添加表单提交处理
	 * @param user
	 * @return
	 */
	@RequestMapping(value="/add",method=RequestMethod.POST)
	@ResponseBody
	public Result<Boolean> add(User user){
		//用统一验证实体方法验证是否合法

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值