基于javaweb的在线考试平台(java+springboot+ssm+mysql)

基于javaweb的在线考试平台(java+springboot+ssm+mysql)

运行环境

Java≥8、MySQL≥5.7

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

20220519002714

20220519002715

20220519002716

20220519002718

20220519002719

基于javaweb+springboot的在线考试平台(java+Springboot+ssm+mysql+maven)

一、项目简述

功能列表 考试前台 /系统登录:学生、教师、管理员登录 /门户首页:无需认证访问 /在线考试:需认证即可查看当前考除目 /题库中心:需认证查看题库 /成绩查询:需认证查询成绩 /留言板:需认证留言 管理后台 /考:署理:发布考试,考试列表,课程管理,题库管 理,成绩管理,成绩情况 /权限管理:学院管理,班级管理,用户管理,角色管 理,资源管理 4网站管理:基础信息,友链管理,评论管理,标签管理 /系统管理:在线用户 /上传管理:云存储配置 /运维管理:数据监控

二、项目运行

环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)

项目技术: JSP +SpringBoot + MyBatis + Redis+ Thymeleaf+ Druid+ JQuery + SLF4J+ Fileupload + maven等等

班级信息控制器:

@Controller

@RequestMapping(“classes”)

public class ClassesController {

@Autowired

private ClassesService classesService;

@Autowired

private InstituteService instituteService;

@PostMapping(“list”)

@ResponseBody

public PageResultVo loadClasses(ClassesConditionVo classesConditionVo, Integer limit, Integer offset) {

PageHelper.startPage(PageUtil.getPageNo(limit, offset),limit);

List classesList = classesService.findByCondition(classesConditionVo);

PageInfo pages = new PageInfo<>(classesList);

return ResultUtil.table(classesList, pages.getTotal(), pages);

/**

  • 新增班级

  • @param classes

  • @return

*/

@PostMapping(“/add”)

@ResponseBody

public ResponseVo add(Classes classes) {

User user = (User)SecurityUtils.getSubject().getPrincipal();

classes.setAuthor(user.getNickname());

Date date = new Date();

classes.setCreateTime(date);

classes.setUpdateTime(date);

classes.setStatus(CoreConst.STATUS_INVALID);

int i = classesService.insert(classes);

if(i > 0) {

return ResultUtil.success(“新增班级信息成功”);

}else {

return ResultUtil.error(“新增班级信息失败”);

/**

  • 更新班级信息

  • @param model

  • @param id

  • @return

*/

@GetMapping(“/edit”)

public String edit(Model model,Integer id) {

Classes classes = classesService.selectById(id);

List institutes = instituteService.selectAll();

model.addAttribute(“institutes”,institutes);

model.addAttribute(“classes”, classes);

return “classes/detail”;

@PostMapping(“/edit”)

@ResponseBody

public ResponseVo edit(Classes classes) {

int i = classesService.updateNotNull(classes);

if(i > 0) {

return ResultUtil.success(“更新班级信息成功”);

}else {

return ResultUtil.error(“更新班级信息失败”);

/**

  • 删除班级信息

  • @param id

  • @return

*/

@PostMapping(“/delete”)

@ResponseBody

public ResponseVo delete(Integer id) {

//验证班级下是否有学生

int i = classesService.validateByClassIds(new Integer[] {id});

if(i > 0) {

return ResultUtil.error(“无法删除,该班级中还有学生”);

}else {

int j = classesService.deleteBatch(new Integer[] {id});

if(j > 0) {

return ResultUtil.success(“删除班级信息成功”);

}else {

return ResultUtil.error(“删除班级信息 失败”);

/**

  • 批量删除

  • @param ids

  • @return

*/

@PostMapping(“/batch/delete”)

@ResponseBody

public ResponseVo deleteBatch(@RequestParam(“ids[]”) Integer[]ids) {

//验证该班级中是否有学生

int i = classesService.validateByClassIds(ids);

if(i > 0) {

return ResultUtil.error(“无法批量删除,该班级中还有学生”);

}else {

int j = classesService.deleteBatch(ids);

if(j > 0) {

return ResultUtil.success(“批量删除班级信息成功”);

}else {

return ResultUtil.error(“批量删除班级信息失败”);

评论控制层:

@RestController

@RequestMapping(“comment”)

public class CommentController {

@Autowired

private CommentService commentService;

@PostMapping(“list”)

public PageResultVo loadNotify(CommentConditionVo comment, Integer limit, Integer offset){

PageHelper.startPage(PageUtil.getPageNo(limit, offset),limit);

List comments = commentService.selectComments(comment);

PageInfo pages = new PageInfo<>(comments);

return ResultUtil.table(comments,pages.getTotal(),pages);

@PostMapping(“/reply”)

public ResponseVo edit(Comment comment){

completeComment(comment);

int i = commentService.insertSelective(comment);

if(i>0){

return ResultUtil.success(“回复评论成功”);

}else{

return ResultUtil.error(“回复评论失败”);

@PostMapping(“/delete”)

public ResponseVo delete(Integer id){

Integer[]ids={id};

int i = commentService.deleteBatch(ids);

if(i>0){

return ResultUtil.success(“删除评论成功”);

}else{

return ResultUtil.error(“删除评论失败”);

@PostMapping(“/batch/delete”)

public ResponseVo deleteBatch(@RequestParam(“ids[]”) Integer[]ids){

int i = commentService.deleteBatch(ids);

if(i>0){

return ResultUtil.success(“删除评论成功”);

}else{

return ResultUtil.error(“删除评论失败”);

@PostMapping(“/audit”)

public ResponseVo audit(Comment bizComment, String replyContent){

try {

commentService.updateNotNull(bizComment);

if(StringUtils.isNotBlank(replyContent)){

Comment replyComment = new Comment();

replyComment.setPid(bizComment.getId());

replyComment.setSid(bizComment.getSid());

replyComment.setContent(replyContent);

completeComment(replyComment);

commentService.insertSelective(replyComment);

return ResultUtil.success(“审核成功”);

} catch (Exception e) {

return ResultUtil.success(“审核失败”);

private void completeComment(Comment comment){

HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();

User user = (User)SecurityUtils.getSubject().getPrincipal();

comment.setUserId(user.getUserId());

comment.setNickname(user.getNickname());

comment.setEmail(user.getEmail());

comment.setAvatar(user.getImg());

comment.setIp(IpUtil.getIpAddr(request));

comment.setStatus(CoreConst.STATUS_VALID);

用户信息控制层:

@Controller

@RequestMapping(“/online/user”)

public class OnlineUserController {

@Autowired

private UserService userService;

// 在线用户列表

@PostMapping(“/list”)

@ResponseBody

public PageResultVo onlineUsers(UserOnlineVo user, Integer limit, Integer offset){

List userList = userService.selectOnlineUsers(user);

PageInfo pages = new PageInfo<>(userList);

int endIndex = (offset+limit) > userList.size() ? userList.size() : (offset+limit);

return ResultUtil.table(userList.subList(offset,endIndex),(long)userList.size(),pages);

// 强制踢出用户

@PostMapping(“/kickout”)

@ResponseBody

public ResponseVo kickout(String sessionId,String username) {

try {

if(SecurityUtils.getSubject().getSession().getId().equals(sessionId)){

return ResultUtil.error(“不能踢出自己”);

userService.kickout(sessionId,username);

return ResultUtil.success(“踢出用户成功”);

} catch (Exception e) {

return ResultUtil.error(“踢出用户失败”);

// 批量强制踢出用户

@PostMapping(“/batch/kickout”)

@ResponseBody

public ResponseVo kickout(@RequestBody List sessions) {

try {

//要踢出的用户中是否有自己

boolean hasOwn=false;

Serializable sessionId = SecurityUtils.getSubject().getSession().getId();

for (UserSessionVo sessionVo : sessions) {

if(sessionVo.getSessionId().equals(sessionId)){

hasOwn=true;

}else{

userService.kickout(sessionVo.getSessionId(),sessionVo.getUsername());

if(hasOwn){

return ResultUtil.success(“不能踢出自己”);

return ResultUtil.success(“踢出用户成功”);

} catch (Exception e) {

return ResultUtil.error(“踢出用户失败”);


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值