package com.ctgu.controller;
import com.ctgu.common.Const;
import com.ctgu.enums.AccountEnum;
import com.ctgu.model.*;
import com.ctgu.service.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
import java.util.stream.Collectors;
import static com.ctgu.common.Const.TeacherLevel;
@Controller
@RequestMapping(value = "/manage")
public class ManageController {
private static Log LOG = LogFactory.getLog(ManageController.class);
@Autowired
private AccountService accountService;
@Autowired
private SubjectService subjectService;
@Autowired
private ContestService contestService;
@Autowired
private QuestionService questionService;
@Autowired
private GradeService gradeService;
@Autowired
private PostService postService;
@Autowired
private CommentService commentService;
@Autowired
private ClassService classService;
@Autowired
private QuestionnaireService questionnaireService;
/**
* 管理员登录页
*/
@RequestMapping(value = "/login", method = RequestMethod.GET)
public String login(HttpServletRequest request, Model model) {
Account currentAccount = (Account) request.getSession().getAttribute(Const.CURRENT_ACCOUNT);
model.addAttribute(Const.CURRENT_ACCOUNT, currentAccount);
if (currentAccount == null) {
return "manage/manage-login";
} else {
return "redirect:/manage/contest/list";
}
}
/**
* 用户管理
*/
@RequestMapping(value = "/account/list", method = RequestMethod.GET)
public String accountList(HttpServletRequest request,
@RequestParam(value = "page", defaultValue = "1") int page,
Model model) {
Account currentAccount = (Account) request.getSession().getAttribute(Const.CURRENT_ACCOUNT);
//TODO::处理
//currentAccount = accountService.getAccountByUsername("admin");
model.addAttribute(Const.CURRENT_ACCOUNT, currentAccount);
if (currentAccount == null || currentAccount.getLevel() < 1) {
//return "redirect:/";
return "error/404";
} else {
//Map<String, Object> data = accountService.getAccounts(page, Const.accountPageSize);
Map<String, Object> data = accountService.getAccountsByLevel(page, Const.accountPageSize, 1);
model.addAttribute(Const.DATA, data);
return "manage/manage-accountList";
}
}
/**
* 用户管理
*/
@RequestMapping(value="/account/{level}/list", method= RequestMethod.GET)
public String accountLevelList(HttpServletRequest request,
@RequestParam(value = "page", defaultValue = "1") int page,
@PathVariable("level") Integer level,
Model model) {
Account currentAccount = (Account) request.getSession().getAttribute(Const.CURRENT_ACCOUNT);
//TODO::处理
//currentAccount = accountService.getAccountByUsername("admin");
model.addAttribute(Const.CURRENT_ACCOUNT, currentAccount);
if (currentAccount == null || currentAccount.getLevel() < 1) {
//return "redirect:/";
return "error/404";
} else {
//Map<String, Object> data = accountService.getAccounts(page, Const.accountPageSize);
Map<String, Object> data = accountService.getAccountsByLevel(page, Const.accountPageSize, level);
data.put("subjects", subjectService.getSubjects());
model.addAttribute(Const.DATA, data);
return "manage/manage-account" + AccountEnum.getAccountEnum(level).getName() + "List";
}
}
/**
* 考试管理
*/
@RequestMapping(value = "/contest/list", method = RequestMethod.GET)
public String contestList(HttpServletRequest request,
@RequestParam(value = "page", defaultValue = "1") int page,
Model model) {
Account currentAccount = (Account) request.getSession().getAttribute(Const.CURRENT_ACCOUNT);
//TODO::处理
//currentAccount = accountService.getAccountByUsername("admin");
model.addAttribute(Const.CURRENT_ACCOUNT, currentAccount);
if (currentAccount == null || currentAccount.getLevel() < 1) {
//return "redirect:/";
return "error/404";
} else {
Map<String, Object> data = null;
if (currentAccount.getLevel() == AccountEnum.ADMIN.getLevel()) {
data = contestService.getContests(page, Const.contestPageSize);
} else {
data = contestService.getContestsByAccountId(page, Const.subjectPageSize, currentAccount.getId());
}
List<Subject> subjects = subjectService.getSubjects();
data.put("subjects", subjects);
model.addAttribute(Const.DATA, data);
return "manage/manage-contestBoard";
}
}
/**
* 考试管理-查看试题
*/
@RequestMapping(value = "/contest/{contestId}/problems", method = RequestMethod.GET)
public String contestProblemList(HttpServletRequest request,
@PathVariable("contestId") Integer contestId, Model model) {
Account currentAccount = (Account) request.getSession().getAttribute(Const.CURRENT_ACCOUNT);
//TODO::处理
//currentAccount = accountService.getAccountByUsername("admin");
model.addAttribute(Const.CURRENT_ACCOUNT, currentAccount);
if (currentAccount == null || currentAccount.getLevel() < 1) {
//return "redirect:/";
return "error/404";
} else {
Map<String, Object> data = new HashMap<>();
List<Question> questions = questionService.getQuestionsByContestId(contestId);
Contest contest = contestService.getContestById(contestId);
data.put("questionsSize", questions.size());
data.put("questions", questions);
data.put("contest", contest);
model.addAttribute(Const.DATA, data);
return "manage/manage-editContestProblem";
}
}
/**
* 題目管理
*/
@RequestMapping(value = "/question/list", method = RequestMethod.GET)
public String questionList(HttpServletRequest request,
@RequestParam(value = "page", defaultValue = "1") int page,
@RequestParam(value = "content", defaultValue = "") String content,
Model model) {
Account currentAccount = (Account) request.getSession().getAttribute(Const.CURRENT_ACCOUNT);
//TODO::处理
//currentAccount = accountService.getAccountByUsername("admin");
model.addAttribute(Const.CURRENT_ACCOUNT, currentAccount);
if (currentAccount == null || currentAccount.getLevel() < 1) {
//return "redirect:/";
return "error/404";
} else {
Map<String, Object> data = questionService.getQuestionsByContent(page,
Const.questionPageSize, content);
List<Question> questions = (List<Question>) data.get("questions");
List<Subject> subjects = subjectService.getSubjects();
Map<Integer, String> subjectId2name = subjects.stream().
collect(Collectors.toMap(Subject::getId, Subj
没有合适的资源?快使用搜索试试~ 我知道了~
基于springboot的题库管理系统源码+数据库脚本(毕业设计).zip

共1087个文件
js:410个
xml:171个
class:113个

1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉

温馨提示
基于springboot的题库管理系统源码+数据库脚本(毕业设计)。已获高分通过项目。项目简介 本项目是一套基于springboot的题库管理系统,主要针对计算机相关专业的正在做毕设的学生和需要项目实战练习的Java学习者。也可作为课程设计、期末大作业 包含:项目源码、数据库脚本、软件工具、项目说明等,该项目可以直接作为毕设使用。 项目都经过严格调试,确保可以运行! 功能实现 1. 在线考试模块 考试倒计时、考试安排表 答题卡、作答区 批改完试卷后查看成绩情况以及参考答案 2. 题库系统模块 课程分类 题目列表、题目难度 题目描述、参考答案等 题目标签 在线编程 3. 讨论区模块 发布帖子、回帖、评论 浏览帖子 帖子编辑、删除 点赞、浏览统计 帖子分类 4. 个人中心模块 更新个人信息、上传头像等 考试记录 发帖记录 考试统计分析 5. 后台管理模块 用户信息及权限管理 考试管理 教学大纲管理 题目管理 课程管理 班级管理 问卷调查管理 成绩管理 帖子管理 评论管理
资源推荐
资源详情
资源评论














收起资源包目录





































































































共 1087 条
- 1
- 2
- 3
- 4
- 5
- 6
- 11

张小妍的博客
- 粉丝: 1w+
- 资源: 1773
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


安全验证
文档复制为VIP权益,开通VIP直接复制

- 1
- 2
- 3
前往页