Source code acquisition : Blog home page " resources " Download in !
one , Project brief
Function list Examination front desk / System login : student , teacher , Administrator login / Portal home page : Access without authentication / Online examination : You can view the current test items without certification / Question bank center : To view the question bank
/ Score query : Query results requiring certification / Message Board : Authentication message required Management background / Test : Acting : Release exam , Exam list , course management , Item bank management reason , Achievement management , Achievements
/ Authority management : College Management , Class management , user management , Role management reason , resource management 4 Website management : Basic information , Friend chain management , Comment management , Label management / system management : Online users
/ Upload management : Cloud storage configuration / Mocha ITOM : Data monitoring
two , Project operation
Environment configuration : Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ
IDEA,Eclispe,MyEclispe,Sts All support )
Project technology : JSP +SpringBoot + MyBatis + Redis+ Thymeleaf+ Druid+ JQuery + SLF4J+
Fileupload + maven wait
Class information controller :
@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<Classes> classesList =
classesService.findByCondition(classesConditionVo); PageInfo<Classes> pages =
new PageInfo<>(classesList); return ResultUtil.table(classesList,
pages.getTotal(), pages); } /** * New class * @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(" Class information added successfully "); }else { return ResultUtil.error(" Failed to add class information "); }
} /** * Update class information * @param model * @param id * @return */ @GetMapping("/edit")
public String edit(Model model,Integer id) { Classes classes =
classesService.selectById(id); List<Institute> 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(" Class information updated successfully "); }else { return ResultUtil.error(" Failed to update class information "); }
} /** * Delete class information * @param id * @return */ @PostMapping("/delete") @ResponseBody
public ResponseVo delete(Integer id) { // Verify whether there are students in the class int i =
classesService.validateByClassIds(new Integer[] {id}); if(i > 0) { return
ResultUtil.error(" Cannot delete , There are also students in the class "); }else { int j =
classesService.deleteBatch(new Integer[] {id}); if(j > 0) { return
ResultUtil.success(" Class information deleted successfully "); }else { return ResultUtil.error(" Delete class information fail "); }
} } /** * Batch delete * @param ids * @return */ @PostMapping("/batch/delete")
@ResponseBody public ResponseVo deleteBatch(@RequestParam("ids[]")
Integer[]ids) { // Verify that there are students in the class int i = classesService.validateByClassIds(ids);
if(i > 0) { return ResultUtil.error(" Cannot batch delete , There are also students in the class "); }else { int j =
classesService.deleteBatch(ids); if(j > 0) { return
ResultUtil.success(" Class information deleted in batch successfully "); }else { return
ResultUtil.error(" Failed to delete class information in batch "); } } } }
Comment control layer :
@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<Comment> comments = commentService.selectComments(comment);
PageInfo<Comment> 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(" Reply to comment succeeded "); }else{ return ResultUtil.error(" Failed to reply to comment "); } }
@PostMapping("/delete") public ResponseVo delete(Integer id){
Integer[]ids={id}; int i = commentService.deleteBatch(ids); if(i>0){ return
ResultUtil.success(" Delete comment succeeded "); }else{ return ResultUtil.error(" Failed to delete comment "); } }
@PostMapping("/batch/delete") public ResponseVo
deleteBatch(@RequestParam("ids[]") Integer[]ids){ int i =
commentService.deleteBatch(ids); if(i>0){ return ResultUtil.success(" Delete comment succeeded ");
}else{ return ResultUtil.error(" Failed to delete comment "); } } @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(" Audit successful "); } catch (Exception e) { return
ResultUtil.success(" Audit failed "); } } 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); } }
User information control layer :
@Controller @RequestMapping("/online/user") public class OnlineUserController
{ @Autowired private UserService userService; // Online user list @PostMapping("/list")
@ResponseBody public PageResultVo onlineUsers(UserOnlineVo user, Integer limit,
Integer offset){ List<UserOnlineVo> userList =
userService.selectOnlineUsers(user); PageInfo<UserOnlineVo> 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);
} // Force users to be kicked out @PostMapping("/kickout") @ResponseBody public ResponseVo
kickout(String sessionId,String username) { try {
if(SecurityUtils.getSubject().getSession().getId().equals(sessionId)){ return
ResultUtil.error(" You can't kick yourself out "); } userService.kickout(sessionId,username); return
ResultUtil.success(" Successfully kicked out the user "); } catch (Exception e) { return
ResultUtil.error(" Failed to kick out user "); } } // Batch forced kick out of users @PostMapping("/batch/kickout")
@ResponseBody public ResponseVo kickout(@RequestBody List<UserSessionVo>
sessions) { try { // Are there any users to kick out 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(" You can't kick yourself out "); } return
ResultUtil.success(" Successfully kicked out the user "); } catch (Exception e) { return
ResultUtil.error(" Failed to kick out user "); } } }
Source code acquisition : Blog home page " resources " Download in !
Technology