Java实战项目-健身管理系统

主要技术:springmvc、 springboot 、mybatis、mysql 、jQuery、layui、css、jsp shiro权限控制

主要功能截图如下:

用户登录、首页主要功能有:会员信息管理、会员到期续费管理、充值管理、教练课程管理、私教管理、器材管理、小商品售卖管理、信息统计、修改密码等主要功能:

71C154FC-4B51-C0F7-A9E2-2FC6B494E303.png

C01B14A7-BE4F-9A16-67D0-E64C249F1A86.png

会员管理、续卡、会员卡类型管理:

9DC3EAA6-519E-0A9E-8B93-911B6BDD7B19.png

F8D4F87F-D7AD-E247-BD29-AD438C268646.png

FA408ECA-EAFE-0224-88E4-B7D0F1B2CA64.png

教练列表展示和添加修改删除教练信息:

E3317031-D9EE-5165-CA72-7315AFB695D1.png

会员私教课程管理:

6ED16B34-8C52-1092-DC1F-17D90DA46BE1.png

添加私教信息:

5FB6BF5C-4699-1DCA-F3E0-81C1B5D12CCB.png

5F900684-1A1F-9432-3D89-4A23AE265312.png

健身课程列表展示查询和添加修改:

0A2DDE5A-A361-67E9-51E5-0C6FDEB4B846.png

健身器材列表展示查询和添加修改:

ACC22F59-F3F2-ECB7-6621-B3AC5CC55414.png

物品遗失管理、归还、添加丢失物品、查询、取回丢失物品等:

A9CED126-B412-1994-D076-3C25A62F7FF4.png

健身房小商品售卖管理:列表数据展示、查询、进货、售卖 退货等操作

FEFDBC81-0781-E724-0869-CCB144B88A84.png

80E96400-D116-2A87-58C4-8F0E9FE3FB5C.png

简单的树状图统计:

80239125-2A7F-C315-116D-9366F1AE8B12.png

代码:

C7EE2C12-A57B-19C7-DBB4-C8D881908D3D.png

数据库表:

67777367-04F4-EB10-B54F-46F1B621B81D.png

管理员登录代码如下:
/**
 * @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 ;
    }

}
 
收藏 (0)
评论列表
正在载入评论列表...
我是有底线的
为您推荐
    暂时没有数据