文末获取源码
开发语言:Java
框架:ssm
JDK版本:JDK1.8
服务器:tomcat7
数据库:mysql 5.7/8.0
数据库工具:Navicat11
开发软件:eclipse/myeclipse/idea
Maven包:Maven3.3.9
浏览器:谷歌浏览器
前言介绍
对于本教资考前指导系统的设计来说,系统开发主要是采用java语言技术,在整个系统的设计中应用MySQL数据库来完成数据存储,具体根据教资考前指导系统的现状来进行开发的,具体根据现实的需求来实现四六级在线考试系统网络化的管理,各类信息有序地进行存储,进入教资考前指导系统页面之后,方可开始操作主控界面,主要功能包括:
(1)前台:首页、教师问题、信息教资信息、复习资料、教学视频、在线练习、个人中心、后台管理
(2)管理员:首页、个人中心、学生管理、教师管理、学院名称管理、问题信息管理、教资信息管理、资料类型管理、复习资料管理、教学视频管理、资质面试管理、点评信息管理、系统管理。
(3)学生:首页、个人中心、问题信息管理、资质面试管理、点评信息管理
(4)教师:首页、个人中心、问题信息管理、资质面试管理、点评信息管理、练习题库管理、在线练习管理、练习管理
系统展示
前台
登录页面
问题信息
教资信息
复习资料
管理员页面
教师管理
复习资料管理
教学视频管理
学生页面
教师页面
部分核心代码
在线练习表
/**
* 在线练习表
* 后端接口
* @author
* @email
* @date 2022-04-23 22:53:50
*/
@RestController
@RequestMapping("/exampaper")
public class ExampaperController {
@Autowired
private ExampaperService exampaperService;
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,ExampaperEntity exampaper,
HttpServletRequest request){
EntityWrapper<ExampaperEntity> ew = new EntityWrapper<ExampaperEntity>();
PageUtils page = exampaperService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, exampaper), params), params));
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,ExampaperEntity exampaper,
HttpServletRequest request){
EntityWrapper<ExampaperEntity> ew = new EntityWrapper<ExampaperEntity>();
PageUtils page = exampaperService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, exampaper), params), params));
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/lists")
public R list( ExampaperEntity exampaper){
EntityWrapper<ExampaperEntity> ew = new EntityWrapper<ExampaperEntity>();
ew.allEq(MPUtil.allEQMapPre( exampaper, "exampaper"));
return R.ok().put("data", exampaperService.selectListView(ew));
}
/**
* 查询
*/
@RequestMapping("/query")
public R query(ExampaperEntity exampaper){
EntityWrapper< ExampaperEntity> ew = new EntityWrapper< ExampaperEntity>();
ew.allEq(MPUtil.allEQMapPre( exampaper, "exampaper"));
ExampaperView exampaperView = exampaperService.selectView(ew);
return R.ok("查询在线练习表成功").put("data", exampaperView);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
ExampaperEntity exampaper = exampaperService.selectById(id);
return R.ok().put("data", exampaper);
}
/**
* 前端详情
*/
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
ExampaperEntity exampaper = exampaperService.selectById(id);
return R.ok().put("data", exampaper);
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody ExampaperEntity exampaper, HttpServletRequest request){
exampaper.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(exampaper);
exampaperService.insert(exampaper);
return R.ok();
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody ExampaperEntity exampaper, HttpServletRequest request){
exampaper.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(exampaper);
exampaperService.insert(exampaper);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
@Transactional
public R update(@RequestBody ExampaperEntity exampaper, HttpServletRequest request){
//ValidatorUtils.validateEntity(exampaper);
exampaperService.updateById(exampaper);//全部更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
exampaperService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
/**
* 提醒接口
*/
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type,@RequestParam Map<String, Object> map) {
map.put("column", columnName);
map.put("type", type);
if(type.equals("2")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
Date remindStartDate = null;
Date remindEndDate = null;
if(map.get("remindstart")!=null) {
Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindStart);
remindStartDate = c.getTime();
map.put("remindstart", sdf.format(remindStartDate));
}
if(map.get("remindend")!=null) {
Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindEnd);
remindEndDate = c.getTime();
map.put("remindend", sdf.format(remindEndDate));
}
}
Wrapper<ExampaperEntity> wrapper = new EntityWrapper<ExampaperEntity>();
if(map.get("remindstart")!=null) {
wrapper.ge(columnName, map.get("remindstart"));
}
if(map.get("remindend")!=null) {
wrapper.le(columnName, map.get("remindend"));
}
int count = exampaperService.selectCount(wrapper);
return R.ok().put("count", count);
}
}
entity层
/**
* 点评信息
* 数据库通用操作实体类(普通增删改查)
* @author
* @email
* @date 2022-04-23 22:53:50
*/
@TableName("dianpingxinxi")
public class DianpingxinxiEntity<T> implements Serializable {
private static final long serialVersionUID = 1L;
public DianpingxinxiEntity() {
}
public DianpingxinxiEntity(T t) {
try {
BeanUtils.copyProperties(this, t);
} catch (IllegalAccessException | InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
* 主键id
*/
@TableId
private Long id;
/**
* 标题
*/
private String biaoti;
/**
* 学号
*/
private String xuehao;
/**
* 姓名
*/
private String xingming;
/**
* 点评内容
*/
private String dianpingneirong;
/**
* 意见
*/
private String yijian;
/**
* 点评时间
*/
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
@DateTimeFormat
private Date dianpingshijian;
/**
* 工号
*/
private String gonghao;
/**
* 教师姓名
*/
private String jiaoshixingming;
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
@DateTimeFormat
private Date addtime;
public Date getAddtime() {
return addtime;
}
public void setAddtime(Date addtime) {
this.addtime = addtime;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
/**
* 设置:标题
*/
public void setBiaoti(String biaoti) {
this.biaoti = biaoti;
}
/**
* 获取:标题
*/
public String getBiaoti() {
return biaoti;
}
/**
* 设置:学号
*/
public void setXuehao(String xuehao) {
this.xuehao = xuehao;
}
/**
* 获取:学号
*/
public String getXuehao() {
return xuehao;
}
/**
* 设置:姓名
*/
public void setXingming(String xingming) {
this.xingming = xingming;
}
/**
* 获取:姓名
*/
public String getXingming() {
return xingming;
}
/**
* 设置:点评内容
*/
public void setDianpingneirong(String dianpingneirong) {
this.dianpingneirong = dianpingneirong;
}
/**
* 获取:点评内容
*/
public String getDianpingneirong() {
return dianpingneirong;
}
/**
* 设置:意见
*/
public void setYijian(String yijian) {
this.yijian = yijian;
}
/**
* 获取:意见
*/
public String getYijian() {
return yijian;
}
/**
* 设置:点评时间
*/
public void setDianpingshijian(Date dianpingshijian) {
this.dianpingshijian = dianpingshijian;
}
/**
* 获取:点评时间
*/
public Date getDianpingshijian() {
return dianpingshijian;
}
/**
* 设置:工号
*/
public void setGonghao(String gonghao) {
this.gonghao = gonghao;
}
/**
* 获取:工号
*/
public String getGonghao() {
return gonghao;
}
/**
* 设置:教师姓名
*/
public void setJiaoshixingming(String jiaoshixingming) {
this.jiaoshixingming = jiaoshixingming;
}
/**
* 获取:教师姓名
*/
public String getJiaoshixingming() {
return jiaoshixingming;
}
}
登陆拦截功能
/**
* 权限(Token)验证
*/
@Component
public class AuthorizationInterceptor implements HandlerInterceptor {
public static final String LOGIN_TOKEN_KEY = "Token";
@Autowired
private TokenService tokenService;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//支持跨域请求
response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
response.setHeader("Access-Control-Max-Age", "3600");
response.setHeader("Access-Control-Allow-Credentials", "true");
response.setHeader("Access-Control-Allow-Headers", "x-requested-with,request-source,Token, Origin,imgType, Content-Type, cache-control,postman-token,Cookie, Accept,authorization");
response.setHeader("Access-Control-Allow-Origin", request.getHeader("Origin"));
IgnoreAuth annotation;
if (handler instanceof HandlerMethod) {
annotation = ((HandlerMethod) handler).getMethodAnnotation(IgnoreAuth.class);
} else {
return true;
}
//从header中获取token
String token = request.getHeader(LOGIN_TOKEN_KEY);
/**
* 不需要验证权限的方法直接放过
*/
if(annotation!=null) {
return true;
}
TokenEntity tokenEntity = null;
if(StringUtils.isNotBlank(token)) {
tokenEntity = tokenService.getTokenEntity(token);
}
if(tokenEntity != null) {
request.getSession().setAttribute("userId", tokenEntity.getUserid());
request.getSession().setAttribute("role", tokenEntity.getRole());
request.getSession().setAttribute("tableName", tokenEntity.getTablename());
request.getSession().setAttribute("username", tokenEntity.getUsername());
return true;
}
PrintWriter writer = null;
response.setCharacterEncoding("UTF-8");
response.setContentType("application/json; charset=utf-8");
try {
writer = response.getWriter();
writer.print(JSONObject.toJSONString(R.error(401, "请先登录")));
} finally {
if(writer != null){
writer.close();
}
}
// throw new EIException("请先登录", 401);
return false;
}
}