Java项目:(前端vue后台java微服务)在线考试系统(java+vue+springboot+mysql+maven)
源码获取:博客首页 "资源" 里下载!
考试流程:
用户前台注册成为学生
管理员后台添加老师,系统将该用户角色上升为老师
老师登录,添加考试,添加题目,发布考试
考生登录前台参加考试,交卷
老师后台批改试卷,查看成绩
考试查看成绩
练习流程:
考生登录前台参加练习,练习完自动判分,记录错题
考生查看成绩,查看错题
角色控制层:
/*** 角色控制层*/
@RestController
@RequestMapping("/v1/authorities")
public class AuthorityController {private static Logger logger = LoggerFactory.getLogger(AuthorityController.class);@AutowiredAuthorityService authorityService;@ApiOperation(value = "获取权限列表", notes = "")@RequestMapping(value = "", method = RequestMethod.GET)@PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')")public List<Authority> getAuthorityList() {return authorityService.getAuthorityList();}@ApiOperation(value = "获取权限树列表", notes = "")@RequestMapping(value = "/tree/{id}", method = RequestMethod.GET)@PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')")public List<DtoAuthority> getAuthorityTreeList(@PathVariable String id) {return authorityService.getAuthorityTreeList(id);}@ApiOperation(value = "新增权限", notes = "新增权限")@ApiImplicitParam(name = "authority", value = "权限实体authority", required = true, dataType = "Authority")@RequestMapping(value = "", method = RequestMethod.POST)@PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')")public ResponseEntity<?> postAuthority(@RequestBody Authority authority) {authorityService.saveAuthority(authority);return new ResponseEntity(HttpStatus.CREATED);}@ApiOperation(value = "获取权限信息", notes = "根据权限id获取权限详细信息")@ApiImplicitParam(name = "id", value = "权限ID", required = true, dataType = "String", paramType = "path")@RequestMapping(value = "/{id}", method = RequestMethod.GET)@PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')")public Authority getAuthority(@PathVariable String id) {return authorityService.getAuthority(id);}@ApiOperation(value = "更新权限信息", notes = "根据权限id更新权限信息")@ApiImplicitParams({@ApiImplicitParam(name = "id", value = "权限ID", required = true, dataType = "String", paramType = "path"),@ApiImplicitParam(name = "authority", value = "权限实体", required = true, dataType = "Authority")})@RequestMapping(value = "/{id}", method = RequestMethod.PUT)@PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')")public ResponseEntity<?> putAuthority(@PathVariable String id, @RequestBody Authority authority) {authorityService.updateAuthority(authority);return new ResponseEntity(HttpStatus.OK);}@ApiOperation(value = "删除权限", notes = "根据权限id删除用户")@ApiImplicitParam(name = "id", value = "权限ID", required = true, dataType = "String", paramType = "path")@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)@PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')")public ResponseEntity<?> deleteAuthority(@PathVariable String id) {authorityService.deleteAuthority(id);return new ResponseEntity(HttpStatus.OK);}
}
联系人控制层:
/*** 联系人控制层*/
@RestController
@RequestMapping("/v1/contacts")
public class ContactController {private static Logger logger = LoggerFactory.getLogger(ContactController.class);@AutowiredContactService contactService;@RequestMapping(value = "", method = RequestMethod.GET)@PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')")public PageInfo<Grade> getContactList(@RequestParam(required = false) Integer pageIndex,@RequestParam(required = false) Integer pageSize,@RequestParam(required = false) Integer limit,@RequestParam(required = false) Integer offset) {if(pageIndex != null && pageSize != null) {PageHelper.startPage(pageIndex, pageSize);}List<Contact> contacts = contactService.getContactList();PageInfo pageInfo = new PageInfo(contacts);return pageInfo;}@RequestMapping(value = "/{id}", method = RequestMethod.GET)@PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')")public Contact getContact(@PathVariable Long id) {return contactService.getContactById(id);}@RequestMapping(value = "/user/{username}", method = RequestMethod.GET)@PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')")public Contact getContact(@PathVariable String username) {return contactService.getContactByUsername(username);}@RequestMapping(value = "/users/{username}", method = RequestMethod.GET)@PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')")public List<Contact> getContactList(@PathVariable String username) {return contactService.getContactListByUsername(username);}@RequestMapping(value = "/status", method = RequestMethod.GET)@PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')")public int getContactCount(@RequestParam String status) {return contactService.getContactCountByStatus(status);}@RequestMapping(value = "", method = RequestMethod.POST)public ResponseEntity<?> postContact(@RequestBody Contact contact) {contactService.saveContact(contact);return new ResponseEntity(HttpStatus.CREATED);}@RequestMapping(value = "", method = RequestMethod.PUT)@PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')")public ResponseEntity<?> putContact(@RequestBody Contact contact) {contactService.updateContact(contact);return new ResponseEntity(HttpStatus.OK);}@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)@PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')")public ResponseEntity<?> deleteContact(@PathVariable Long id) {Contact contact = new Contact();contact.setId(id);contactService.deleteContact(contact);return new ResponseEntity(HttpStatus.OK);}
}
用户控制层:
/*** 用户控制层*/
@RestController
@RequestMapping(value = "/v1/users")
public class UserController {private static Logger logger = LoggerFactory.getLogger(UserController.class);@Value("${my.localFilepath}")private String localFilepath;@Value("${my.fileServer}")private String fileServer;@AutowiredUserService userService;@ApiOperation(value = "获取用户列表", notes = "")@RequestMapping(value = "", method = RequestMethod.GET)@PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')")public PageInfo<MapperUser> getUserList(@RequestParam(required = false) Integer pageIndex,@RequestParam(required = false) Integer pageSize,@RequestParam(required = false) Integer limit,@RequestParam(required = false) Integer offset) {if(pageIndex != null && pageSize != null) {PageHelper.startPage(pageIndex, pageSize);}List<MapperUser> mapperUsers = userService.getUserList();PageInfo pageInfo = new PageInfo(mapperUsers);return pageInfo;}@ApiOperation(value = "创建用户", notes = "创建用户")@ApiImplicitParam(name = "user", value = "用户实体user", required = true, dataType = "MapperUser")@RequestMapping(value = "", method = RequestMethod.POST)@PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')")public ResponseEntity<?> postUser(@RequestBody MapperUser user) {userService.saveUser(user);return new ResponseEntity(HttpStatus.CREATED);}@ApiOperation(value = "获取用户信息", notes = "根据用户id获取用户详细信息")@ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "String", paramType = "path")@RequestMapping(value = "/id", method = RequestMethod.GET)@PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')")public MapperUser getUserById(@RequestParam String id) {return userService.getUserById(id);}@ApiOperation(value = "获取用户信息", notes = "根据用户name获取用户详细信息")@ApiImplicitParam(name = "name", value = "用户name", required = true, dataType = "String", paramType = "path")@RequestMapping(value = "/name", method = RequestMethod.GET)@PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')")public List<MapperUser> getUserFuzzyByName(@RequestParam String name) {//模糊查询return userService.getUserFuzzy(name);}@ApiOperation(value = "更新用户信息", notes = "根据用户id更新用户信息")@ApiImplicitParams({@ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "String", paramType = "path"),@ApiImplicitParam(name = "user", value = "用户实体", required = true, dataType = "MapperUser")})@RequestMapping(value = "/id", method = RequestMethod.PUT)@PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')")public ResponseEntity<?> putUser(@RequestBody MapperUser user) {userService.updateUser(user);return new ResponseEntity(HttpStatus.OK);}@ApiOperation(value = "删除用户", notes = "根据用户id删除用户")@ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "String", paramType = "path")@RequestMapping(value = "/id", method = RequestMethod.DELETE)@PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')")public ResponseEntity<?> deleteUser(@RequestParam String id) {userService.deleteUser(id);return new ResponseEntity(HttpStatus.OK);}@ApiOperation(value = "获取用户信息", notes = "根据用户名获取用户详细信息")@RequestMapping(value = "/me", method = RequestMethod.GET)public MapperUser getUser(Principal principal) {MapperUser user = null;if(principal != null) {user = userService.getUserByName(principal.getName());}return user;}@ApiOperation(value = "注册", notes = "用户注册")@ApiImplicitParam(name = "dtoUser", value = "用户实体", required = true, dataType = "DtoUser")@RequestMapping(value = "/register", method = RequestMethod.POST)public ResponseEntity<?> registry(@RequestBody DtoUser dtoUser) {BCryptPasswordEncoder bc=new BCryptPasswordEncoder(4);//将密码加密dtoUser.setPassword(bc.encode(dtoUser.getPassword()));userService.registry(dtoUser);return new ResponseEntity(HttpStatus.OK);}/*** 注册时验证用户名是否存在* true:用户名已存在* false:用户名不存在,可以使用此用户名注册* @param username* @return*/@ApiOperation(value = "注册时验证用户名是否存在", notes = "注册时验证用户名是否存在")@RequestMapping(value = "/register/name", method = RequestMethod.GET)public boolean getUserByName(@RequestParam String username) {if(userService.getUserByName(username) == null) {return true;}else {return false;}}@ApiOperation(value = "修改密码", notes = "修改密码")@ApiImplicitParam(name = "dtoUser", value = "用户", required = true, dataType = "DtoUser")@RequestMapping(value = "/password", method = RequestMethod.POST)@PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "') or hasAuthority('" + Role.ROLE_STUDENT + "')")public ResponseEntity<?> changePassword(@RequestBody DtoUser dtoUser, Principal principal) {String username = dtoUser.getUsername();if(username == null) {username = principal.getName();}MapperUser user = userService.getUserByName(username);if(user == null) {logger.error("修改密码->用户名不存在!");return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR);}BCryptPasswordEncoder bc=new BCryptPasswordEncoder(4);//判断旧密码是否匹配if(bc.matches(dtoUser.getOldPwd(),user.getPassword())) {//更新密码user.setPassword(bc.encode(dtoUser.getNewPwd()));userService.updateUser(user);}else {return new ResponseEntity<Object>(HttpStatus.INTERNAL_SERVER_ERROR);}return new ResponseEntity(HttpStatus.OK);}@RequestMapping(value = "/avatar", method = RequestMethod.POST)@ResponseBody@PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "') or hasAuthority('" + Role.ROLE_STUDENT + "')")public ResponseEntity<?> uploadImg(HttpServletRequest request, Principal principal) {//获取当前用户信息MapperUser user = null;if(principal != null) {user = userService.getUserByName(principal.getName());}//解析器解析request的上下文CommonsMultipartResolver multipartResolver =new CommonsMultipartResolver(request.getSession().getServletContext());//先判断request中是否包涵multipart类型的数据,if(multipartResolver.isMultipart(request)){//再将request中的数据转化成multipart类型的数据MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request;Iterator iter = multiRequest.getFileNames();while(iter.hasNext()){//这里的name为fileItem的alias属性值,相当于form表单中nameString name=(String)iter.next();//根据name值拿取文件MultipartFile file = multiRequest.getFile(name);if(file != null){String[] names = file.getOriginalFilename().split("\\.");String fileName = user.getUsername() + "." + names[1];File localFile = new File(localFilepath + fileName);if(!localFile.getParentFile().exists()) {//如果目标文件所在的目录不存在,则创建父目录localFile.getParentFile().mkdirs();}//写文件到本地try {file.transferTo(localFile);//更新用户信息user.setAvatar(fileServer + fileName);userService.updateUser(user);} catch (IOException e) {e.printStackTrace();return new ResponseEntity<Object>(HttpStatus.EXPECTATION_FAILED);}}}}else {return new ResponseEntity<Object>(HttpStatus.EXPECTATION_FAILED);}return new ResponseEntity<Object>(HttpStatus.OK);}
}
源码获取:博客首页 "资源" 里下载!
相关文章:

C++实现stack【栈】
要求: //****file: stack.h/*对stack进行初始化检查stack为空,或已满将整数压入到stack中从stack里弹出整数 不移除任何袁术,讲过stack的内容输出到标准输出Stack类的私有成员如下:一个用于打印错误信息的私有哦成员函数三个私有数…

c#操作Excel整理总结
大家好,这是我在工作中总结的关于C#操作Excel的帮助类,欢迎大家批评指正! using System; using System.Collections.Generic; using System.Data; using System.Data.OleDb; using System.IO; using Aspose.Cells;namespace MusicgrabTool {p…

C++ std::function<void(int)> 和 std::function<void()> 作为函数参数的注意事项
前言 std::function 作为标准库提供的函数指针,使用起来还是比较方便的,不过在使用过程中有一些需要注意的细节,这里做一个简单的记录。 基本使用 头文件: #include <functional>语法:std::function<return_type(args…

Java项目:网上电商系统(java+SSM+mysql+maven+tomcat)
源码获取:博客首页 "资源" 里下载! 一、项目简述 功能:本系统分用户前台和管理员后台。 前台展示后台管理,前台界面可实现用户登录,用户注 册,商品展示,商品明细展示,用户…

C# SQLiteHelper
1 public class SQLiteHelpers2 {3 /// <summary> 4 /// ConnectionString样例:DatasourceTest.db3;Poolingtrue;FailIfMissingfalse 5 /// </summary> 6 public static string ConnectionStri…

[Git] 拉开发分支的代码报错
Git拉开发分支的代码报错: fatal: The remote end hung up unexpectedly fatal: early EOF fatal: index-pack failed 解决办法: git config --global core.compression -1 转载于:https://www.cnblogs.com/MasterMonkInTemple/p/10754596.html

C++ 通过模版工厂实现 简单反射机制
前言 我们知道Java/Python这种语言能够很好得 支持反射。反射机制 就是一种用户输入的字符串到对应实现方法的映射,比如http接口中 用户传入了url,我们需要调用该url对应的方法/函数对象 从而做出对应的操作。 而C 并没有友好得支持这样的操作…

计算机世界的“十六进制”为什么如此重要
在计算机世界中,十六进制扮演着不可或缺的角色。它以其紧凑的表示形式、与二进制的天然对应关系以及在各个领域的广泛应用,成为了计算机科学中的一把重要工具。总体而言,计算机需要十六进制并非偶然,它是一种为了更好地满足人类理解和处理数据的需求而产生的工具,为计算机科学的发展和应用提供了便利和支持。

面试官:如何实现10亿数据判重?
以 Java 中的 int 为例,来对比观察 BitMap 的优势,在 Java 中,int 类型通常需要 32 位(4 字节*8),而 BitMap 使用 1 位就可以来标识此元素是否存在,所以可以认为 BitMap 占用的空间大小,只有 int 类型的 1/32,所以有大数据量判重时,使用 BitMap 也可以实现。所以数据库去重显然是不行的。而使用集合也是不合适的,因为数据量太大,使用集合会导致内存不够用或内存溢出和 Full GC 频繁等问题,所以此时我们的解决方案通常是采用布隆过滤器来实现判重。

Java项目:校园二手市场系统(java+SSM+mysql+maven+tomcat)
源码获取:博客首页 "资源" 里下载! 一、项目简述( IW文档) 功能:本系统分用户前台和管理员后台。 本系统用例模型有三种,分别是游客、注册用户和系统管 理员。下面分别对这三个角色的功能进行描…

php中$_REQUEST、$_POST、$_GET的区别和联系小结
php中$_REQUEST、$_POST、$_GET的区别和联系小结 作者: 字体:[增加 减小] 类型:转载php中有$_request与$_post、$_get用于接受表单数据,当时他们有何种区别,什么时候用那种最好。1. $_REQUEST php中$_REQUEST可以获取以…

uva 315 (poj 1144 求割点)
题意:给你一张无向图,求割点的个数。 思路:输入稍微处理一下接着直接套模版。 1 #include <iostream>2 #include <cstdio>3 #include <cstring>4 #include <cstdlib>5 #include <cmath>6 #include <algorit…

SQL学习之计算字段的用法与解析
一、计算字段 1、存储在数据库表中的数据一般不是应用程序所需要的格式。大多数情况下,数据表中的数据都需要进行二次处理。下面举几个例子。 (1)、我们需要一个字段同时显示公司名和公司地址,但这两个信息存储在不同表的列中。 (2)、省份、城市、邮政编码存储在不同…

手把手教你 用C++实现一个 可持久化 的http_server
前言 本文介绍一个有趣的 通过C实现的 持久化的http_server demo,这样我们通过http通信之后的数据可以持久化存储,即使server挂了,数据也不会丢失。我们的http_sever 也就能够真正得作为一个后端server了。 本身持久化这个能力是数据库提供…

【SVN多用户开发】代码冲突解决办法
SVN是一款集中式的代码存储工具,可以帮助多个用户协同开发同一应用程序。 但是SVN不能完全代替人工操作,有时也需要程序员自己进行沟通确认有效的代码。 下面就简单的看一下,常见的代码冲突以及解决方法。 总结起来,无非是&#x…

Java项目:在线宠物商店系统(java+SSM+mysql+maven+tomcat)
源码获取:博客首页 "资源" 里下载! 一、项目简述 功能:本系统分用户前台和管理员后台。 系统包括用户的注册登录,狗狗的展示购物车添加以及下 单支付购买,后台有管理员用户,可以操作狗狗的品种&…

字符串中的数字排序
2019独角兽企业重金招聘Python工程师标准>>> public static String getBusiScope(String busiScope){ String regex "\\d{1,2}"; String busiStr""; Pattern pattern Pattern.compile(regex); Matcher matcher pattern.matcher(busiScope…

oo第二单元总结
第二单元总结 第一次作业 一、设计策略 本次作业采用FAFS算法,可直接用输入线程与电梯线程交互,调度器暂时不需要参与,故一共设计三个类三线程:Main类、elevator类及input类,main线程、elevator线程及input线程。main线…

Rocksdb iterator 的 Forward-scan 和 Reverse-scan 的性能差异
前言 最近在读 MyRocks 存储引擎2020年的论文,因为这个存储引擎是在Rocksdb之上进行封装的,并且作为Facebook 内部MySQL的底层引擎,用来解决Innodb的空间利用率低下 和 压缩效率低下的问题。而且MyRocks 在接入他们UDB 之后成功达成了他们的…

Java知多少(29)覆盖和重载
在类继承中,子类可以修改从父类继承来的方法,也就是说子类能创建一个与父类方法有不同功能的方法,但具有相同的名称、返回值类型、参数列表。如果在新类中定义一个方法,其名称、返回值类型和参数列表正好与父类中的相同࿰…

Java项目:清新论坛系统(java+SSM+mysql+maven+tomcat)
源码获取:博客首页 "资源" 里下载! 一、项目简述 功能:本系统分用户前台和管理员后台。 用户前台主要功能有: 用户注册 用户登录 浏览帖子 回复帖子 修改个人资料 管理员后台的功能有: 管理论坛版块 用户管…

JUnit4.11 理论机制 @Theory 完整解读
最近在研究JUnit4,大部分基础技术都是通过百度和JUnit的官方wiki学习的,目前最新的发布版本是4.11,结合代码实践,发现官方wiki的内容或多或少没有更新,Theory理论机制章节情况尤为严重,不知道这章wiki对应的…

树链剖分——线段树区间合并bzoj染色
线段树区间合并就挺麻烦了,再套个树链就更加鬼畜,不过除了代码量大就没什么其他的了。。 一些细节:线段树每个结点用结构体保存,pushup等合并函数改成返回一个结构体,这样好写一些 struct Seg{int lc,rc,tot;Seg(){lcr…

MyRocks: 为facebool 的社交图谱服务的LSM-tree存储引擎
文章目录概览1. UDB 架构2. UDB 表格式3. Rocksdb:针对flash存储优化过的第三方库3.1 Rocksdb架构3.2 为什么选择Rocksdb4. MyRocks / Rocksdb 开发历程4.1 设计目标4.2 性能挑战4.2.1 降低CPU的消耗4.2.2 降低range-scan 的延时消耗4.2.3 磁盘空间和Compaction 的一…

Java项目:精品酒店管理系统(java+SSM+mysql+maven+tomcat)
源码获取:博客首页 "资源" 里下载! 一、项目简述 功能:主要功能主要功能会员管理,住客管理,房间管 理,系统管理,以及一些重要数据的展示导出维护等等; 二、项目运行 环境配置&…

iOS自动布局一
Align: Pin: 转载于:https://www.cnblogs.com/123qw/p/4404167.html

C#实现路由器断开连接,更改公网ip
publicstaticvoidDisconnect(){stringurl "断 线"; stringuri "http://192.168.1.1/userRpm/StatusRpm.htm?Disconnect"System.Web.HttpUtility.UrlEncode(url, System.Text.Encoding.GetEncoding("gb2312")) "&wan1"; str…

Go中的iota
当时在学习Iota这个知识点的时候仅仅是一笔掠过,比如这种 const(aiotab c) 一眼看出他怎么使用的时候就觉得自己已经懂得了 再到后来看到这样的例子 const(a 5*iotab c )以及 const(a 1<<(10*iota)bc ) 第一…

从 SSLTLS 的底层实现来看 网络安全的庞大复杂体系
文章目录前言1. HTTP协议通信的问题1.1 tcpdump 抓取http 请求包1.2 报文分析1.3 HTTP 协议问题2. SSL & TLS 协议的基本介绍和历史演进3. TLS 1.2 实现加密传输的过程3.1 TLS HandShake 协议概览3.2 第一次握手:ClientHello3.3 第二次握手:从Server…

UICollectionView
UICollectionView 多列的UITableView,最简单的形式,类似于iBooks中书架的布局,书架中放着你下载的和购买的电子书。 最简单的UICollectionView是一个GridView,可以多列的方式进行展示。 包含三部分,都是UIView的子类: …