Java实战项目 健身管理系统
主要技术:springmvc、 springboot 、mybatis、mysql 、jQuery、layui、css、jsp shiro权限控制
主要功能截图如下:
用户登录、首页主要功能有:会员信息管理、会员到期续费管理、充值管理、教练课程管理、私教管理、器材管理、小商品售卖管理、信息统计、修改密码等主要功能:
会员管理、续卡、会员卡类型管理:
教练列表展示和添加修改删除教练信息:
会员私教课程管理:
添加私教信息:
健身课程列表展示查询和添加修改:
健身器材列表展示查询和添加修改:
物品遗失管理、归还、添加丢失物品、查询、取回丢失物品等:
健身房小商品售卖管理:列表数据展示、查询、进货、售卖 退货等操作
简单的树状图统计:
代码:
数据库表:
管理员登录代码如下:
/** * @Description: 管理员登录Controller控制层 * xiaoc * @Date: 2020/4/4 */ @Controller @RequestMapping("/") public class AdminuserConntroller { @Autowired private AdminuserDao adminuserDao; /** * @Description: 输入端口号直接跳转登录界面 * xiaoc * @Date: 2020/4/29 */ @RequestMapping("/") public String beforeLogin(){ return "login"; } /** * @Description: 管理员登录验证方法 * xiaoc * @Date: 2020/4/4 */ @RequestMapping("/dl/yz") public String login(String username, String password,HttpSession httpSession,Model model){ Subject subject= SecurityUtils.getSubject(); UsernamePasswordToken userToken=new UsernamePasswordToken(username,DigestUtils.md5Hex(password)); try{ subject.login(userToken); Adminuser a= adminuserDao.findByAdminNameAndAdminPassword(username,DigestUtils.md5Hex(password)); httpSession.setAttribute("user",a); return "WEB-INF/jsp/index"; }catch (UnknownAccountException e){ model.addAttribute("msg","用户名或密码错误,请重新输入"); return "login"; } /*Adminuser a= adminuserDao.findByAdminNameAndAdminmima(username,password); if(a!=null){ httpSession.setAttribute("user",a); return "WEB-INF/jsp/index" ; } model.addAttribute("mag","账号或密码错误"); return "login";*/ } /** * @Description: 退出登录后清楚session * xiaoc * @Date: 2020/5/1 */ @RequestMapping("/logout") public String logout(){ Subject subject = SecurityUtils.getSubject(); subject.logout(); return "redirect:/login"; } /** * @Description: 跳转到修改密码界面 * xiaoc * @Date: 2020/5/1 */ @RequestMapping("/updPassword") public String updPassword(){ return "WEB-INF/jsp/updPassword"; } /** * @Description: 修改密码 * xiaoc * @Date: 2020/5/1 */ @RequestMapping("/upd/updPassword") public String updPasswordConfirm(String oldPassword,String newPassword,String newPasswordAgain,HttpSession httpSession,Model model){ Pattern p = Pattern.compile("^(?=.*[A-Za-z])(?=.*\\d)(?=.*[$@$!.%*#?&])[A-Za-z\\d$@$!.%*#?&]{8,}$"); Matcher m = p.matcher(newPassword); if(!m.matches()){ model.addAttribute("msg","新密码最少为8位并为字母+数字+特殊字符"); return "WEB-INF/jsp/updPassword"; } if(!newPassword.equals(newPasswordAgain)){ model.addAttribute("msg","两次输入新密码不一致,请重新输入"); return "WEB-INF/jsp/updPassword"; } Adminuser adminuser=(Adminuser) httpSession.getAttribute("user"); if(null != adminuser){ if(!adminuser.getAdminPassword().equals(DigestUtils.md5Hex(oldPassword))){ model.addAttribute("msg","原密码不正确,请重新输入"); return "WEB-INF/jsp/updPassword"; } adminuserDao.updPassword(adminuser.getAdminId(), DigestUtils.md5Hex(newPassword)); } Subject subject = SecurityUtils.getSubject(); subject.logout(); return "redirect:/login.jsp"; } }
密码加密方式:
@Configuration public class ShiroConfig { /** * 密码校验规则HashedCredentialsMatcher * 这个类是为了对密码进行编码的 , * 防止密码在数据库里明码保存 , 当然在登陆认证的时候 , * 这个类也负责对form里输入的密码进行编码 * 处理认证匹配处理器:如果自定义需要实现继承HashedCredentialsMatcher */ // @Bean("hashedCredentialsMatcher") // public HashedCredentialsMatcher getHashedCredentialsMatcher() { // HashedCredentialsMatcher credentialsMatcher = new HashedCredentialsMatcher(); // //指定加密方式为MD5 // credentialsMatcher.setHashAlgorithmName("MD5"); // //加密次数 // credentialsMatcher.setHashIterations(1024); // credentialsMatcher.setStoredCredentialsHexEncoded(true); // return credentialsMatcher; // } @Bean public MyRealm getMyRealm(){ MyRealm myRealm = new MyRealm() ; // myRealm.setCredentialsMatcher(getHashedCredentialsMatcher()); return myRealm ; } @Bean public SimpleCookie rememberMeCookie() { //System.out.println("ShiroConfiguration.rememberMeCookie()"); //这个参数是cookie的名称,对应前端的checkbox的name = rememberMe SimpleCookie simpleCookie = new SimpleCookie("ckbox"); //<!-- 记住我cookie生效时间30天 ,单位秒;--> simpleCookie.setMaxAge(259200); return simpleCookie; } @Bean public EhCacheManager getEhCacheManager(){ EhCacheManager ehCacheManager = new EhCacheManager() ; ehCacheManager.setCacheManagerConfigFile("classpath:ehcache-shiro.xml"); return ehCacheManager ; } @Bean public CookieRememberMeManager rememberMeManager() { //System.out.println("ShiroConfiguration.rememberMeManager()"); CookieRememberMeManager cookieRememberMeManager = new CookieRememberMeManager(); cookieRememberMeManager.setCookie(rememberMeCookie()); //rememberMe cookie加密的密钥 建议每个项目都不一样 默认AES算法 密钥长度(128 256 512 位) // cookieRememberMeManager.setCipherKey(Base64.decode("2AvVhdsgUs0FSA3SDFAdag==")); return cookieRememberMeManager; } @Bean public DefaultWebSecurityManager getDefaultWebSecurityManager(){ DefaultWebSecurityManager defaultWebSecurityManager = new DefaultWebSecurityManager() ; defaultWebSecurityManager.setRealm(getMyRealm()); //注册记住我 defaultWebSecurityManager.setRememberMeManager(rememberMeManager()); //注册缓存 defaultWebSecurityManager.setCacheManager(getEhCacheManager()); return defaultWebSecurityManager ; } @Bean public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(){ System.out.println("开启了Shiro注解支持"); AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor = new AuthorizationAttributeSourceAdvisor(); authorizationAttributeSourceAdvisor.setSecurityManager(getDefaultWebSecurityManager()); return authorizationAttributeSourceAdvisor; } @Bean @ConditionalOnMissingBean public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() { DefaultAdvisorAutoProxyCreator defaultAAP = new DefaultAdvisorAutoProxyCreator(); defaultAAP.setProxyTargetClass(true); return defaultAAP; } @Bean public ShiroFilterFactoryBean getShiroFilterFactoryBean(){ ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean() ; //设置网页安全管理器 shiroFilterFactoryBean.setSecurityManager(getDefaultWebSecurityManager()); Map<String,String> map = new LinkedHashMap<String,String>() ; //定义可以直接访问的资源 map.put("/login.jsp","anon") ; map.put("/vcode.jsp","anon"); map.put("/dl/yz","anon") ; map.put("/static/**","anon") ; //取消认证 map.put("/logout","logout") ; // // map.put("/add.jsp","perms[user:*]") ; map.put("/**","user") ; shiroFilterFactoryBean.setFilterChainDefinitionMap(map); shiroFilterFactoryBean.setLoginUrl("/login.jsp"); shiroFilterFactoryBean.setUnauthorizedUrl("/unauth.jsp"); return shiroFilterFactoryBean ; } }
到此这篇关于Java实战项目 健身管理系统的文章就介绍到这了,更多相关Java 健身管理内容请搜索我们以前的文章或继续浏览下面的相关文章希望大家以后多多支持我们!
赞 (0)