欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Java畢業(yè)設計實戰(zhàn)之在線高中考試系統的實現

 更新時間:2022年02月05日 14:21:55   作者:qq_1334611189  
這是一個使用了java+SSM+Jsp+Mysql+Maven開發(fā)的在線高中考試系統,是一個畢業(yè)設計的實戰(zhàn)練習,具有考試系統該有的所有功能,感興趣的朋友快來看看吧

項目分為前臺和后臺,前臺主要為學生角色、后臺主要為管理員角色。

管理員添加試題和發(fā)布試卷,學生負責在線考試、在線查看成績和錯題記錄列表等。

管理員功能有:年級管理、課程管理、試題管理、試卷管理、學生管理等。

運行環(huán)境:jdk1.8、mysql5.x、eclipse、tomcat8.5\7.0、maven3.5\3.6。

統一管理學生 教師 管理員信息:

/**
 * 統一管理學生 教師 管理員信息
 */
@RestController
public class UserController {
 
    @Resource(name = "userService")
    private IUserService userService;
 
    /**
     * 查詢用戶信息
     * 先判斷用戶類型 在查詢用戶信息
     */
    @RequestMapping(value = "/user/qryUserInfo", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    public Result<User> qryUserInfo() {
        return userService.qryUserInfo();
    }
 
    /**
     * 更新用戶信息
     */
    @RequestMapping(value = "/user/update", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    public Result<User> update(HttpRequest request) {
        User user = new User();
        user.setUserId(request.getString("user_id"));
        user.setName(request.getString("name"));
        user.setSex(request.getInteger("sex"));
        user.setType(User.UserType.get(request.getInteger("type")));
        return userService.update(user, ImageUtil.stringToBytes(request.getString("user_image")));
    }
 
    /**
     * 更新用戶密碼
     */
    @RequestMapping(value = "/user/updatePwd", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    public Result<User> updatePwd(HttpRequest request) {
        return userService.updatePwd(request.getString("old_pwd"), request.getString("pwd"));
    }
}

管理員控制器:

/**
 * 管理員控制器
 */
@RestController
public class AdminController {
 
    @Resource(name = "adminService")
    private IAdminService adminService;
 
    /**
     * 管理員 查詢管理員列表
     */
    @RequestMapping(value = "/admin/qryPage", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.admin})
    public ListResult<Admin> qryPage(HttpRequest request) {
        Map<String, Object> param = new HashMap<>();
        int pageNo = request.containsKey("page_no") ? request.getInteger("page_no") : 1;
        int pageSize = request.containsKey("page_size") ? request.getInteger("page_size") : 20;
        if (request.containsKey("login_name")) {
            param.put("login_name", request.getString("login_name"));
        }
        if (request.containsKey("name")) {
            param.put("name", request.getString("name"));
        }
        return adminService.qryPage(param, pageNo, pageSize);
    }
 
    /**
     * 管理員 添加管理員
     */
    @RequestMapping(value = "/admin/add", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.admin})
    public Result<Admin> insert(HttpRequest request) {
        Admin admin = new Admin();
        admin.setLoginName(request.getString("login_name"));
        admin.setName(request.getString("admin_name"));
        admin.setPwd(request.getString("login_name"));
        admin.setSex(request.getInteger("sex"));
        admin.setUpdateTime(new Date());
        return adminService.insert(admin, ImageUtil.stringToBytes(request.getString("admin_image")));
    }
 
    /**
     * 管理員 更新管理員
     */
    @RequestMapping(value = "/admin/update", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.admin})
    public Result<Admin> update(HttpRequest request) {
        Admin admin = new Admin();
        admin.setLoginName(request.getString("login_name"));
        admin.setName(request.getString("admin_name"));
        admin.setPwd(request.getString("login_name"));
        admin.setSex(request.getInteger("sex"));
        admin.setUpdateTime(new Date());
        return adminService.update(admin, ImageUtil.stringToBytes(request.getString("admin_image")));
    }
 
    /**
     * 管理員 刪除管理員
     */
    @RequestMapping(value = "/admin/del", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.admin})
    public Result<Admin> del(HttpRequest request) {
        List<String> adminIdList = new ArrayList<>();
        JSONArray array = request.getJSONArray("admin_id_list");
        for (int i = 0; i < array.size(); i++) {
            adminIdList.add(array.getString(i));
        }
        return adminService.del(adminIdList);
    }
}

考試管理控制器:

/**
 * 考試管理控制器
 */
@RestController
public class ExamInfoController {
 
    @Resource(name = "examInfoService")
    private IExamInfoService examInfoService;
 
    /**
     * 教師 查詢考試列表
     */
    @RequestMapping(value = "/examinfo/qryPage", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.teacher})
    public ListResult<ExamInfo> exam(HttpRequest request) {
        Map<String, Object> param = new HashMap<>();
        int pageNo = request.containsKey("page_no") ? request.getInteger("page_no") : 1;
        int pageSize = request.containsKey("page_size") ? request.getInteger("page_size") : 20;
        return examInfoService.qryPage(param, pageNo, pageSize);
    }
 
    /**
     * 教師 添加新的考試信息
     */
    @RequestMapping(value = "/examinfo/add", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.teacher})
    public Result<ExamInfo> insert(HttpRequest request) {
        ExamInfo exam = new ExamInfo();
        exam.setTestPaperId(request.getInteger("test_paper_id"));
        exam.setClassId(request.getString("class_id"));
        exam.setState(1);
        exam.setTime(request.getInteger("time"));
        exam.setEffTime(DateUtils.toDate(request.getString("eff_time"), DateConst.DATE_TIME_FORMAT_YYYY_MM_DD_HH_MI));
        exam.setExpTime(DateUtils.toDate(request.getString("exp_time"), DateConst.DATE_TIME_FORMAT_YYYY_MM_DD_HH_MI));
        exam.setUpdateTime(new Date());
        return examInfoService.insert(exam);
    }
 
    /**
     * 教師 更新考試信息
     */
    @RequestMapping(value = "/examinfo/update", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.teacher})
    public Result<ExamInfo> update(HttpRequest request) {
        ExamInfo exam = new ExamInfo();
        exam.setExamId(request.getInteger("exam_id"));
        exam.setTestPaperId(request.getInteger("test_paper_id"));
        exam.setClassId(request.getString("class_id"));
        exam.setState(1);
        exam.setTime(request.getInteger("time"));
        exam.setEffTime(DateUtils.toDate(request.getString("eff_time"), DateConst.DATE_TIME_FORMAT_YYYY_MM_DD_HH_MI));
        exam.setExpTime(DateUtils.toDate(request.getString("exp_time"), DateConst.DATE_TIME_FORMAT_YYYY_MM_DD_HH_MI));
        exam.setUpdateTime(new Date());
        exam.setUpdateTime(new Date());
        return examInfoService.update(exam);
    }
 
    /**
     * 教師 新建狀態(tài)的考試信息可以刪除
     */
    @RequestMapping(value = "/examinfo/del", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.teacher})
    public Result<ExamInfo> del(HttpRequest request) {
        List<Integer> examIdList = new ArrayList<>();
        JSONArray array = request.getJSONArray("exam_id_list");
        for (int i = 0; i < array.size(); i++) {
            examIdList.add(array.getInteger(i));
        }
        return examInfoService.del(examIdList);
    }
 
    /**
     * 教師 發(fā)布考試信息
     */
    @RequestMapping(value = "/examinfo/release", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.teacher})
    public Result<ExamInfo> updateState(HttpRequest request) {
        return examInfoService.release(request.getInteger("exam_id"));
    }
 
    /**
     * 學生 查詢考試試題分組列表
     */
    @RequestMapping(value = "/examinfo/qryExamQueGroupList", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.student, RoleEnum.teacher})
    public Result<TestPaperQuestionGroup> qryExamQueGroupList(HttpRequest request) {
        return examInfoService.qryExamQueGroupList(request.getInteger("exam_id"));
    }
 
    /**
     * 學生 查詢考試試題列表
     */
    @RequestMapping(value = "/examinfo/qryExamQuestionList", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.student})
    public Result<StudentExamQuestionRecord> qryExamQuestionList(HttpRequest request) {
        return examInfoService.qryExamQuestionList(request.getInteger("exam_id"), request.getString("student_id"), request.getInteger("question_group_id"));
    }
 
    /**
     * 教師 判卷查詢試題列表
     */
    @RequestMapping(value = "/examinfo/qryMarkQueList", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.teacher})
    public Result<StudentExamQuestionRecord> qryMarkQueList(HttpRequest request) {
        return examInfoService.qryMarkQueList(request.getInteger("exam_id"), request.getString("student_id"), request.getInteger("question_group_id"));
    }
 
    /**
     * 教師 記錄學生考試分數 complete
     */
    @RequestMapping(value = "/examinfo/updateQueScore", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.teacher})
    public Result<ExamInfo> updateQueScore(HttpRequest request) {
        StudentExamQuestionRecord record = new StudentExamQuestionRecord();
        record.setExamId(request.getInteger("exam_id"));
        record.setStudentId(request.getString("student_id"));
        record.setQuestionGroupId(request.getInteger("question_group_id"));
        record.setQuestionId(request.getLong("question_id"));
        record.setScore(request.getFloat("score"));
        record.setCorrect(request.getBoolean("correct"));
        return examInfoService.updateQueScore(record);
    }
 
    /**
     * 教師 完成評分
     */
    @RequestMapping(value = "/examinfo/complete", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @RoleAnnotation(types = {RoleEnum.teacher})
    public Result<ExamInfo> complete(HttpRequest request) {
        return examInfoService.complete(request.getInteger("exam_id"),
                request.getString("student_id"));
    }
 
}

登錄控制層:

@RestController
public class LoginController {
 
    @Resource(name = "loginService")
    private ILoginService loginService;
 
    /**
     * 用戶登錄調用 在登陸成功生成兩個token 同時返回各自首頁
     * * 學生 student/student
     * * 老師 teacher/teacher
     * * 管理員 admin/admin
     */
    @RequestMapping(value = "/login/login", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    public Result<Token> login(HttpRequest request) {
        return loginService.login(request.getString("login_name"), request.getString("pwd"));
    }
 
    /**
     * 登錄檢查
     */
    @RequestMapping(value = "/login/check", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    public Result<Token> check() {
        return new Result<>();
    }
 
    /**
     * token 續(xù)約
     */
    @RequestMapping(value = "/login/refresh", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    public Result<Token> refresh(HttpRequest request) {
        String refreshToken = request.getString("refresh_token");
        String urlId = request.getString("url_id");
        Token token = TokenCache.getInstance().get(urlId);
        if(token == null){
            ExceptionHelper.error(ErrorCode.ERROR_CODE_0003);
        }
        try {
            Claims claims = TokenUtils.parseToken(refreshToken);
            if (StringUtils.isNotEmpty((String.valueOf(claims.getOrDefault("student_id", ""))))) {
                claims.put("student_id", SessionContext.get("student_id"));
            }
            if (StringUtils.isNotEmpty((String.valueOf(claims.getOrDefault("teacher_id", ""))))) {
                claims.put("teacher_id", SessionContext.get("teacher_id"));
            }
            if (StringUtils.isNotEmpty((String.valueOf(claims.getOrDefault("login_name", ""))))) {
                claims.put("login_name", SessionContext.get("login_name"));
            }
            claims.put("name", claims.get("name"));
            token.setToken(TokenUtils.createToken(claims, TokenUtils.expireTime));
            token.setRefreshToken(TokenUtils.createToken(claims, TokenUtils.long_expireTime));
            TokenCache.getInstance().add(token);
        } catch (Exception e) {
            ExceptionHelper.error(ErrorCode.ERROR_CODE_0003);
        }
        return new Result<>(token);
    }
 
    /**
     * 退出系統
     */
    @RequestMapping(value = "/login/exit", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    public Result<Token> exit(HttpRequest request) {
        String urlId = request.getString("url_id");
        if (StringUtils.isNotEmpty(urlId)) {
            TokenCache.getInstance().remove(urlId);
        }
        return new Result<>();
    }
}

到此這篇關于Java畢業(yè)設計實戰(zhàn)之在線高中考試系統的實現的文章就介紹到這了,更多相關Java 考試系統內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

相關文章

  • HashSet如何保證元素不重復(面試必問)

    HashSet如何保證元素不重復(面試必問)

    HashSet 不保證集合的迭代順序,但允許插入 null 值,也就是說它可以將集合中的重復元素自動過濾掉,保證存儲在 HashSet 中的元素都是唯一的,這篇文章主要介紹了HashSet如何保證元素不重復(面試必問),需要的朋友可以參考下
    2021-12-12
  • Java語言描述二叉樹的深度和寬度

    Java語言描述二叉樹的深度和寬度

    這篇文章主要介紹了Java語言描述二叉樹的深度和寬度,具有一定借鑒價值,需要的朋友可以參考下。
    2017-11-11
  • @Transactional跟@DS動態(tài)數據源注解沖突的解決

    @Transactional跟@DS動態(tài)數據源注解沖突的解決

    這篇文章主要介紹了@Transactional跟@DS動態(tài)數據源注解沖突的解決,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2021-09-09
  • Java詳解IO流創(chuàng)建讀取與寫入操作

    Java詳解IO流創(chuàng)建讀取與寫入操作

    這篇文章主要介紹了Java IO流,同時也介紹了流中的一些相關的內容,并且通過大量的案例供大家理解。最后通過一些經典的案例幫助大家對前面所學的知識做了一個綜合的應用,需要的朋友可以參考一下
    2022-05-05
  • Spring+SpringMVC+Hibernate整合實例講解

    Spring+SpringMVC+Hibernate整合實例講解

    在本篇文章里小編給大家整理的是關于Spring+SpringMVC+Hibernate整合實例講解,需要的朋友們可以學習下。
    2020-03-03
  • java Timer 定時每天凌晨1點執(zhí)行任務

    java Timer 定時每天凌晨1點執(zhí)行任務

    這篇文章主要介紹了java Timer 定時每天凌晨1點執(zhí)行任務的代碼,代碼簡單易懂,非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下
    2019-09-09
  • Java中Date時區(qū)的轉換代碼示例

    Java中Date時區(qū)的轉換代碼示例

    這篇文章主要給大家介紹了關于Java中Date時區(qū)轉換的相關資料,當在不同的時區(qū)使用相同程序,時間的值只會為當地時間,這樣就會造成時間混亂,需要的朋友可以參考下
    2023-07-07
  • Java中的關鍵字_動力節(jié)點Java學院整理

    Java中的關鍵字_動力節(jié)點Java學院整理

    關鍵字也稱為保留字,是指Java語言中規(guī)定了特定含義的標示符。對于保留字,用戶只能按照系統規(guī)定的方式使用,不能自行定義
    2017-04-04
  • IDEA安裝阿里巴巴編碼規(guī)范插件的兩種方式詳解(在線安裝和離線安裝)

    IDEA安裝阿里巴巴編碼規(guī)范插件的兩種方式詳解(在線安裝和離線安裝)

    這篇文章主要介紹了IDEA安裝阿里巴巴編碼規(guī)范插件的兩種方式詳解(在線安裝和離線安裝),本文通過截圖給大家展示的非常詳細,需要的朋友可以參考下
    2021-09-09
  • Java中HashMap和HashTable區(qū)別

    Java中HashMap和HashTable區(qū)別

    HashMap和Hashtable都是Java常見的基于哈希表實現的Map接口的實現類,本文主要介紹了Java中HashMap和HashTable區(qū)別,具有一定的參考價值,感興趣的可以了解一下
    2023-11-11

最新評論