源码获取:俺的博客首页 "资源" 里下载!

项目介绍

Springboot银行柜面管理系统主要分为管理员与用户两种角色。
管理员角色主要功能如下:
系统用户管理:管理员用户、修改密码;
用户管理:用户查询、新增、编辑、删除等;
取款管理:用户查询、新增、编辑、删除等;
存款管理:用户查询、新增、编辑、删除等;
转账管理:用户查询、新增、编辑、删除等;

普通用户主要功能如下:
个人资料管理:修改个人资料、修改密码;
取款管理:用户查询、新增、编辑、删除等;
存款管理:用户查询、新增、编辑、删除等;
转账管理:用户查询、新增、编辑、删除等;


环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
4.数据库:MySql 5.7/8.0版本均可;
5.是否Maven项目:是;


技术栈

后端:SpringBoot+Mybaits

前端:Html+css+element+jquery+bootstrap+vue


使用说明

项目运行:
1. 使用Navicat或者其它工具,在mysql中创建对应sql文件名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中application.yml配置文件中的数据库配置改为自己的配置;
4. 运行项目,在浏览器中输入地址:http://localhost:8888/end/page/login.html
管理员账号、密码:hsg/hsg
普通用户账号、密码:001/001

 

 

 用户管理控制层:

@Controller
public class UserInfoController {

    @Resource
    private UserInfoService userInfoService;
    @Resource
    private PrivilegeService privilegeService;

    @RequestMapping(value = {"/", "login.html"})
    public String toLogin(HttpServletRequest request, HttpServletResponse response){
        HttpSession session = request.getSession();
        if(session.getAttribute(Config.CURRENT_USERNAME)==null){
            return "login";
        }else {
            try {
                response.sendRedirect("/pages/index");
            } catch (IOException e) {
                e.printStackTrace();
                return "login";
            }
            return null;
        }

    }

//    @RequestMapping(value = "/login.do",method = RequestMethod.POST)
    @RequestMapping(value = "/login.do")
    @ResponseBody
    public Result getUserInfo(UserInfo userInfo, HttpServletRequest request, HttpServletResponse response){
        boolean userIsExisted = userInfoService.userIsExisted(userInfo);
        System.out.println(userIsExisted + " - " + request.getHeader("token"));
        userInfo = getUserInfo(userInfo);
        if("client".equals(request.getHeader("token")) && !userIsExisted){
            //用户不存在
            return  ResultUtil.success(-1);
        }
        if (userIsExisted && userInfo == null){
            return  ResultUtil.unSuccess("用户名或密码错误!");
        }else {
            //将用户信息存入session
            userInfo = setSessionUserInfo(userInfo,request.getSession());
            //将当前用户信息存入cookie
            setCookieUser(request,response);
            return ResultUtil.success("登录成功", userInfo);
        }
    }

    @RequestMapping("/users/getUsersByWhere/{pageNo}/{pageSize}")
    public @ResponseBody Result getUsersByWhere(UserInfo userInfo, @PathVariable int pageNo, @PathVariable int pageSize, HttpSession session){
        if ("".equals(userInfo.getHouseid())){
            userInfo.setHouseid(null);
        }
        if (userInfo.getRoleid() == -1){
            userInfo.setRoleid(Config.getSessionUser(session).getRoleid());
        }
        Utils.log(userInfo.toString());
        PageModel model = new PageModel<>(pageNo,userInfo);
        model.setPageSize(pageSize);
        return userInfoService.getUsersByWhere(model);
    }

    @RequestMapping("/user/add")
    public @ResponseBody Result addUser(UserInfo userInfo){
        System.out.println(userInfo);
        try {
            int num = userInfoService.add(userInfo);
            if(num>0){
                return ResultUtil.success();
            }else {
                return ResultUtil.unSuccess();
            }
        }catch (Exception e){
            return ResultUtil.error(e);
        }
    }

    @RequestMapping("/user/update")
    public @ResponseBody Result updateUser(UserInfo userInfo){
        try {
            int num = userInfoService.update(userInfo);
            if(num>0){
                return ResultUtil.success();
            }else {
                return ResultUtil.unSuccess();
            }
        }catch (Exception e){
            return ResultUtil.error(e);
        }
    }

    @RequestMapping("/user/del/{id}")
    public @ResponseBody Result deleteUser(@PathVariable String id){
        try {
            int num = userInfoService.delete(id);
            if(num>0){
                return ResultUtil.success();
            }else {
                return ResultUtil.unSuccess();
            }
        }catch (Exception e){
            return ResultUtil.error(e);
        }
    }

    @RequestMapping("/getSessionUser")
    @ResponseBody
    public UserInfo getSessionUser(HttpSession session){
        UserInfo sessionUser = (UserInfo) session.getAttribute(Config.CURRENT_USERNAME);
        sessionUser.setPassword(null);
        return sessionUser;
    }

    @RequestMapping("/logout")
    public String logout(HttpServletRequest request, HttpServletResponse response){
        delCookieUser(request, response);
        request.getSession().removeAttribute(Config.CURRENT_USERNAME);
        return "login";
    }

    @RequestMapping("/getAllRoles")
    public @ResponseBody Result<Role> getAllRoles(){
        try {
            List<Role> roles = userInfoService.getAllRoles();
            if (roles.size()>0){
                return ResultUtil.success(roles);
            }else {
                return ResultUtil.unSuccess();
            }
        }catch (Exception e){
            return ResultUtil.error(e);
        }
    }

    @RequestMapping("/role/add")
    public @ResponseBody Result addRole(Role role){
        try {
            int num = userInfoService.addRole(role);
            if(num>0){
                privilegeService.addDefaultPrivilegesWhenAddRole(role.getRoleid().toString());
                return ResultUtil.success();
            }else {
                return ResultUtil.unSuccess();
            }
        }catch (Exception e){
            return ResultUtil.error(e);
        }
    }

    @RequestMapping("/role/update")
    public @ResponseBody Result updateRole(Role role){
        try {
            int num = userInfoService.updateRole(role);
            if(num>0){
                return ResultUtil.success();
            }else {
                return ResultUtil.unSuccess();
            }
        }catch (Exception e){
            return ResultUtil.error(e);
        }
    }

    @RequestMapping("/role/del/{roleid}")
    public @ResponseBody Result deleteRole(@PathVariable String roleid){
        try {
            privilegeService.delPrivilegesWenDelRole(roleid);
            int num = userInfoService.deleteRole(roleid);
            if(num>0){
                return ResultUtil.success();
            }else {
                privilegeService.addDefaultPrivilegesWhenAddRole(roleid);
                return ResultUtil.unSuccess();
            }
        }catch (Exception e){
            return ResultUtil.error(e);
        }
    }

    @RequestMapping("/getRole/{id}")
    public @ResponseBody Result getRoleById(@PathVariable String id){
        try {
            Role role = userInfoService.getRoleById(id);
            if(role != null){
                return ResultUtil.success(role);
            }else {
                return ResultUtil.unSuccess();
            }
        }catch (Exception e){
            return ResultUtil.error(e);
        }
    }

    /**
     * 登录时将用户信息加入cookie中
     * @param response
     */
    private void setCookieUser(HttpServletRequest request, HttpServletResponse response){
        UserInfo user = getSessionUser(request.getSession());
        Cookie cookie = new Cookie(Config.CURRENT_USERNAME,user.getUsername()+"_"+user.getId());
        //cookie 保存7天
        cookie.setMaxAge(60*60*24*7);
        response.addCookie(cookie);
    }

    /**
     * 注销时删除cookie信息
     * @param request
     * @param response
     */
    private void delCookieUser(HttpServletRequest request, HttpServletResponse response){
        UserInfo user = getSessionUser(request.getSession());
        Cookie cookie = new Cookie(Config.CURRENT_USERNAME,user.getUsername()+"_"+user.getId());
        cookie.setMaxAge(-1);
        response.addCookie(cookie);
    }

    /**
     * 通过用户信息获取用户权限信息,并存入session中
     * @param userInfo
     * @param session
     * @return
     */
    public UserInfo setSessionUserInfo(UserInfo userInfo, HttpSession session){
        List<Privilege> privileges = privilegeService.getPrivilegeByRoleid(userInfo.getRoleid());
        userInfo.setPrivileges(privileges);
        session.setAttribute(Config.CURRENT_USERNAME,userInfo);
        return userInfo;

    }

    public UserInfo getUserInfo(UserInfo userInfo){
       return userInfoService.getUserInfo(userInfo);
    }
}

费用记录管理控制层:

@Controller
@RequestMapping("/costtotal")
public class CostTotalController {
	
	@Autowired
	private DataDetailService datadetailservice;
	
	@Autowired
	private DeptService deptservice;
	
	/**
	 * 费用汇总展示页面
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping("/show.do")
	public ModelAndView show(HttpServletRequest request,HttpServletResponse response){
		ModelAndView mav = new ModelAndView("main_total");
		
		List<Dept> depts = deptservice.loadAllDepts();
		
		mav.addObject("depts", depts);
		
		//默认先加载当前月所有数据
		//获取当前月份
		Date now = new Date();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
		String date = sdf.format(now);
		
		mav.addObject("now", date);
		
		return mav;
	}
	
	/**
	 * 获取给定月份下各个部门的数据
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping("/queryByMonth.do")
	@ResponseBody
	public DataResult queryByMonth(HttpServletRequest request,HttpServletResponse response){
		DataResult result = new DataResult();
		
		String date = request.getParameter("date");
		System.out.println("date:"+date);
		Map<String, String> map = new HashMap<String, String>();
		map.put("date", date);
		
		List<DataDetailModel> datas = datadetailservice.queryByMonth(map);
		
		result.setData(datas);
		return result;
	}
	
	/**
	 * 点击表格加载详细数据--跳转子页面
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping("/detail_show.do")
	public ModelAndView detail(HttpServletRequest request,HttpServletResponse response){
		ModelAndView mav = new ModelAndView("dept_detail");
		
		String ym = request.getParameter("ym");
		String date = request.getParameter("date");
		String deptno = request.getParameter("deptno");
		
		System.out.println(date+"-----");
		System.out.println(deptno);
		
		Map<String, String> map = new HashMap<String, String>();
		map.put("date", date);
		map.put("deptno", deptno);
		
		if("0".equals(ym)){//月度
			List<DataDetailModel> lists = datadetailservice.queryByDeptnoAndMonth(map);
			mav.addObject("items", lists);
		}
		return mav;
	}
	
	/**
	 * 查询一年数据
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping("/queryByYear.do")
	@ResponseBody
	public DataResult queryByYear(HttpServletRequest request,HttpServletResponse response){
		DataResult result = new DataResult();
		
		String date = request.getParameter("date");
		System.out.println("date:"+date);
		Map<String, String> map = new HashMap<String, String>();
		map.put("date", date);
		
		List<DataDetailModel> lists = datadetailservice.queryByYear(map);
		result.setData(lists);
		
		return result;
	}
}

用户登录管理控制层:

@Controller
@RequestMapping("/user")
public class UserController {

	@Resource
	private UserService userService;
	
	@RequestMapping("/show.do")
	public ModelAndView show(HttpServletRequest request,HttpServletResponse response){
		ModelAndView mav = new ModelAndView("show");
		return mav;
	}
	
	/**
	 * 登录页面检查
	 * @param request
	 * @param response
	 */
	@RequestMapping("/login.do")
	@ResponseBody
	public DataResult login(HttpServletRequest request,
			HttpServletResponse response){
		String username = request.getParameter("username");
		String password = request.getParameter("password");
		DataResult result = userService.checkLogin(username, password);
		request.getSession().setAttribute("user", (User)result.getData());
		
		return result;
	}
	
	/**
	 * 退出登录
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping("/logout.do")
	public ModelAndView log(HttpServletRequest request,HttpServletResponse response){
		ModelAndView mav = new ModelAndView();
		mav.setViewName("login");
		return mav;
	}
	
	/**
	 * 修改密码页面请求
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping("/changepwd.do")
	public ModelAndView changePwd(HttpServletRequest request,HttpServletResponse response){
		ModelAndView mav = new ModelAndView("pwd_change");
		return mav;
	}
	
	/**
	 * 修改密码
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping("/updatepwd.do")
	@ResponseBody
	public DataResult updatePwd(HttpServletRequest request,HttpServletResponse response){
		DataResult result = new DataResult();
		
		String username = request.getParameter("username");
		String password = request.getParameter("password");
		Map<String, String> map = new HashMap<String, String>();
		map.put("username", username);
		map.put("password", password);
		
		try {
			userService.modifyPwd(map);
			result.setMsg("修改成功");
			result.setStatus(0);
		} catch (Exception e) {
			e.printStackTrace();
			result.setMsg("修改失败");
			result.setStatus(1);
		}
		return result;
	}
}

源码获取:俺的博客首页 "资源" 里下载!

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐