基于ssm的教务管理系统

源码获取:博客首页 “资源” 里下载!

大家好,今天给大家带来的是基于ssm的教务管理系统,整理了大概一周。

首先说下所用技术

前端:layui框架+jspjavascript的Echart可视化插件)

后端:spring+springMVC+mybatis+Shiro(权限分配)

项目介绍:

角色一共有三种:教师+学生+超级管理员(后续也可以自己定义添加或者删除)
主要实现了用户的登录注册,公告的浏览,选课操作,超级管理员可以分配权限,以及对教师和学生的所有操作。不同的管理员对不同信息的管理,教师对课程评分,教师结课等功能。使用Echart加入了可视化数据,进行简单的可视化操作。使用了流加载对通知公告进行显示。

运行环境

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

部分展示图片

用户角色的学生界面
Echart可视化数据
教师课程信息界面
管理员用户角色界面
登陆界面
登录界面

部分代码

登陆管理控制层:
@Controller
@RequestMapping("/easLogin")
public class EasLoginController {
    @Autowired
    private EasPermissionMapper easPermissionMapper;

    @RequestMapping("/main")
    public String main() throws Exception{
        return "main";
    }
//    @RequestMapping("/home")
//    public String home() throws Exception{
//        return "system/home/homePage";
//    }

    @RequestMapping("/success")
    @ResponseBody
    public Map<String,Object> success(HttpSession session) throws Exception{
        Map<String,Object> map = new HashMap<>();
        map.put("code",0);
        EasUser easUser = (EasUser) SecurityUtils.getSubject().getPrincipal();
        session.setAttribute(Constants.LOGIN_USER,easUser);

        List<EasPermission> list = easPermissionMapper.getPersByUserId(easUser.getId());
        session.setAttribute(Constants.LOGIN_USER_PERS,list);

        return map;
    }

    @RequestMapping(value = "/login",method = RequestMethod.GET)
    public String login() throws Exception{
        return "login";
    }

    /**
     * post方式的login方式什么时候调用?
     * 身份认证失败的时候会自动调用
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/login", method = RequestMethod.POST)
    @ResponseBody
    public Map<String,Object> login(HttpServletRequest request) throws Exception{
        Map<String,Object> map = new HashMap<>();
//        System.out.println("认证失败了吧!来我这了吧");
        String exceptionName = request.getAttribute("shiroLoginFailure").toString();

        if (exceptionName.equals(UnknownAccountException.class.getName())){
            map.put("code",1);
            map.put("msg","用户名不正确");
            return map;
        }else if(exceptionName.equals(IncorrectCredentialsException.class.getName())){
            map.put("code",2);
            map.put("msg","密码不正确");
            return map;
        }else if (exceptionName.equals("randomCodeError")){
            map.put("code",3);
            map.put("msg","验证码不正确");
            return map;
        }
        return null;
    }


}

注册管理控制层:
@RequestMapping("/easRegister")
@Controller
public class EasRegisterController {
    @Autowired
    private EasRegisterService easRegisterService;

    @Autowired
    private EasUserService easUserService;

    @RequestMapping("/registerForm")
    public String registerForm(){
        return "registerForm";
    }

    @RequestMapping(value = "/registerUser",method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> registerUser(HttpServletRequest request) throws Exception{
        Map<String, Object> map = new HashMap<>();
        //获取页面输入的新旧密码
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        String password2 = request.getParameter("password2");

        String regex = "^(?!([a-zA-Z]+|\\d+)$)[a-zA-Z\\d]{6,20}$";

        boolean matches = password.matches(regex);

//        System.out.println("页面输入的用户名为:"+username);
//        System.out.println("页面输入的密码为:"+password);

        List<EasUser> list = easUserService.findUserName(username);
        if(list.size() > 0){
            map.put("code",1);
            map.put("msg","用户名已存在,请重新输入");
        }else if(password.length() <= 0 || password2.length() <= 0 || username.length() <= 0){
            map.put("code",1);
            map.put("msg","用户名密码不能为空,请重新输入");
        }else if(!password.equals(password2)){
            map.put("code",1);
            map.put("msg","两次输入密码不一致,请重新输入");
        }else if(!matches){
            map.put("code",1);
            map.put("msg","密码必须包含字母、数字且长度为6-20位");
        }else if(matches){
            //由密码和用户名组成MD5加密  用户名为盐值
//            Md5Hash Md5Hash = new Md5Hash(password, username);
//            System.out.println("我是MD5Hash"+Md5Hash);
            String algorithmName = "MD5";//加密算法
            Object source = password;//要加密的密码
            Object salt = username;//盐值,一般都是用户名或者userid,要保证唯一
            int hashIterations = 1;//加密次数

            SimpleHash simpleHash = new SimpleHash(algorithmName,source,salt,hashIterations);
//            System.out.println("我是SimpleHash:"+simpleHash);

            EasUser easUser = new EasUser();
            easUser.setUsername(username);
            easUser.setPassword(simpleHash.toString());
            easUser.setSalt(username);
            easUser.setLocked("0");

            easUserService.addUser(easUser);

            map.put("code",0);
        }else{
            map.put("code",1);
            map.put("msg","注册失败,请联系管理员邮箱1260298750@qq.com!!!");
        }

        return map;
    }


}

角色管理层:
@Controller
@RequestMapping("/easRole")
public class EasRoleController {
    @Autowired
    private EasRoleMapper easRoleMapper;

    @RequestMapping("/search")
    @ResponseBody
    public List<EasRole> search() throws Exception{
        return easRoleMapper.getAll();
    }

    @RequestMapping("/index")
    @RequiresPermissions("role:query")
    public String index() throws Exception{
        return "system/role/index";
    }

    @RequestMapping("/rolePers")
    @ResponseBody
    public List<Long> rolePers(Integer id) throws Exception {
        return easRoleMapper.getPerIdsByRoleId(id);
    }

    @RequestMapping("/assignPers")
    @ResponseBody
    public Map<String,Object> assignPers(Integer roleId, String persIds) throws Exception{
        Map<String,Object> map = new HashMap<>();
        easRoleMapper.deleteRolePermissions(roleId);
        easRoleMapper.addRolePermissions(roleId,persIds.split(","));
        return map;
    }

    @RequestMapping("/list")
    @ResponseBody
    public Map<String,Object> list(@RequestParam(defaultValue = "1") Integer page,
                                   @RequestParam(defaultValue = "10") Integer limit,
                                   EasRole easRole) throws Exception {
        Map<String,Object> map = new HashMap<>();

        int count = easRoleMapper.getCount();
        PageUtil pageUtil = new  PageUtil(page,limit);

        map.put("code",0);
        map.put("msg",null);
        map.put("data",easRoleMapper.getList(easRole,pageUtil));
        map.put("count",count);

        return map;
    }


    @RequestMapping("/roleForm")
    public String roleForm() throws Exception {
        return "system/role/roleForm";
    }

    @RequestMapping(value = "/addRole",method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> addRole(EasRole easRole) throws Exception{
        Map<String,Object> map = new HashMap<>();

//        System.out.println("角色名称:"+easRole.getName());
//        System.out.println("角色是否可用:"+easRole.getAvailable());

        List<EasRole> list = easRoleMapper.findRoleName(easRole.getName());

        if (list.size() != 0){
            map.put("msg","角色已存在");
            map.put("result",false);
        }else if(easRole.getName().length() <= 0){
            map.put("msg","角色名称不能为空");
            map.put("result",false);
        }else{
            //课程为null也可以添加 待完善
            easRoleMapper.addRole(easRole);
            map.put("msg","添加成功");
            map.put("result",true);
        }
        return map;
    }

    @RequestMapping("/batchDeleteRole")
    @ResponseBody
    @RequiresPermissions("role:delete")
    public Map<String, Object> batchDeleteRole(Integer[] ids) throws Exception{
        Map<String,Object> map = new HashMap<String,Object>();
        easRoleMapper.batchDeleteRole(ids);
        map.put("msg","删除成功");
        map.put("result",true);
        return map;
    }

    @RequestMapping(value = "/getRoleView")
    @ResponseBody
    public EasRole getRoleView(Integer id) throws Exception {
        return easRoleMapper.getRoleView(id);
    }

    @RequestMapping(value = "/editRole",method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> editRole(EasRole easRole) throws Exception{
        Map<String, Object> map = new HashMap<>();

        easRoleMapper.updateBaseCourse(easRole);

        map.put("result",true);
        return map;
    }
}

源码获取:博客首页 “资源” 里下载!

  • 2
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

Java学习使我快乐

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

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

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

打赏作者

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

抵扣说明:

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

余额充值