Java项目:springboot访客管理系统

作者主页:夜未央5788

 简介:Java领域优质创作者、Java项目、学习资料、技术互助

文末获取源码

项目介绍

springboot搭建的访客管理系统,针对高端基地做严格把控来访人员信息管理,用户后端可以设置多个管理员帐号,给予不同部门的管理层使用,用户管理可以增加/修改内部成员的基本信息,需要到访的人员必须通过进入程序,在访客预约里面提交预约申请,预约后管理员可查询预约记录以及访客出入记录。

使用人群:

正在做毕设的学生,或者需要项目实战练习的Java学习者

环境需要

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.数据库:MySql 8.0/5.7版本;

6.是否Maven项目:是;

技术栈

1. springboot
2. mybatis
3. layUi 

4. JSP

使用说明

1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中application.properties配置文件中的数据库配置改为自己的配置;
4. 运行项目,在浏览器中输入http://localhost:8090 登录

帐号:admin 密码:admin

用户:zhangsan 密码:123456

运行截图

 

 

 

 

 

 

 

 

代码相关

管理端控制器

@Api(tags="管理员")
@Controller
@RequestMapping(value = "adminManager")
public class AdminController {
	@Autowired
	private AdminService adminService;


	@ApiOperation(value="添加子管理员",notes="添加子管理员")
	@ResponseBody
	@PostMapping("/addAdmin")
	public Response<String> addAdmin(Admin admin){
		return adminService.saveOrUpdate(admin);
	}

	@ApiOperation(value="按照编号删除子管理员信息",notes="按照编号删除子管理员信息")
	@ApiImplicitParam(name="id",value="子管理员编号",paramType="path",required=true)
	@ResponseBody
	@PostMapping("/delAdmin/{id}")
	public Response<String> delAdmin(@PathVariable("id")Long id){
		adminService.deleteUserById(id);
		return Response.ok("success");
	}

	@ApiOperation(value="按照编号删除子管理员信息",notes="按照编号删除子管理员信息")
	@ApiImplicitParam(name="id",value="子管理员编号",paramType="path",required=true)
	@ResponseBody
	@PostMapping("/updateAdmin")
	public Response<String> updateAdmin(Admin admin, HttpSession session) {
		session.setAttribute("loginAdmin",admin);
		return adminService.saveOrUpdate(admin);
	}

	@ApiOperation(value="分页查找所有子管理员",notes="分页查找所有子管理员")
	@ApiImplicitParams({
		@ApiImplicitParam(name="pageNum",value="当前页码",required=false,defaultValue="1"),
		@ApiImplicitParam(name="pageSize",value="每页显示数据个数(0是全部)",required=false,defaultValue="2")
	})
	@GetMapping("/adminList")
	public ModelAndView adminList(@RequestParam(name = "pageNum",defaultValue = "1") int pageNum,
								  @RequestParam(name = "pageSize", defaultValue = "10") int pageSize,Admin  admin,ModelAndView modelAndView) {
		PageInfo<Admin> data= adminService.getAllByPage(pageNum, pageSize,admin);
		modelAndView.addObject("page",data);
		modelAndView.setViewName("admin/admin-list");
		return modelAndView;
	}


	//跳转添加子管理员页面
	@GetMapping("/admin-add")
	public ModelAndView adminAddHtml(ModelAndView modelAndView) {
		modelAndView.setViewName("admin/admin-add");
		return modelAndView;
	}	//跳转添加子管理员页面
	@GetMapping("/admin-edit")
	public ModelAndView adminEditHtml(Long id,ModelAndView modelAndView) {
		Admin admin=adminService.findUserById(id);
		modelAndView.addObject("admin",admin);
		modelAndView.setViewName("admin/admin-edit");
		return modelAndView;
	}

	//个人信息修改
	@GetMapping("/admin-update")
	public ModelAndView adminUpdateHtml(Long id,ModelAndView modelAndView) {
		Admin admin=adminService.findUserById(id);
		modelAndView.addObject("admin",admin);
		modelAndView.setViewName("admin/admin-update");
		return modelAndView;
	}


}

 登录控制器

@Api(tags="登录管理")
@Controller
@RequestMapping()
public class LoginController {
	@Autowired
	private AdminService adminService;
	@Autowired
	private SmartUserService userService;

	@Autowired
	private VisitorService visitorService;


	@GetMapping("/userIndex")
	public ModelAndView userIndex(HttpSession session,ModelAndView modelAndView){
		SmartUser user=(SmartUser) session.getAttribute("loginUser");
		if(user!=null){
			modelAndView.setViewName("userIndex");
		}else{
			modelAndView.setViewName("login");
		}
		return modelAndView;
	}

	@GetMapping({"index","/"})
	public ModelAndView index(HttpSession session,ModelAndView modelAndView){
		Admin user=(Admin) session.getAttribute("loginAdmin");
		if(user!=null){
			modelAndView.setViewName("index");
			int num=visitorService.getNewVisitor();
			modelAndView.addObject("num",num);
		}else{
			modelAndView.setViewName("login");
		}
		return modelAndView;
	}
	/**
	 * @Description(功能描述): 登录
	 **/
	@GetMapping({"login","logout"})
	public ModelAndView login(HttpSession session,ModelAndView modelAndView){
		modelAndView.setViewName("login");
		return modelAndView;
	}

	@ResponseBody
	@PostMapping("/uploadImg")
	public Response<String> uploadImg(){
		return Response.ok();
	}

	@ResponseBody
	@PostMapping("/doLogin")
	public Response<String> doLogin(HttpSession session, Admin admin){
		if("admin".equalsIgnoreCase(admin.getRole())){
			Admin result= adminService.login(admin);
			if(null!=result){
				session.setAttribute("loginAdmin",result);
				return Response.ok("index");
			}else {
				return  Response.error(300);
			}
		}else{
			SmartUser user=new SmartUser();
			user.setAccount(admin.getAccount());
			user.setPassword(admin.getPasswd());
			user=userService.login(user);
			if(null!=user){
				session.setAttribute("loginUser",user);
				return Response.ok("userIndex");
			}else {
				return  Response.error(300);
			}
		}
	}
}

如果也想学习本系统,下面领取。回复:093springboot

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

夜未央5788

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值