package com.controller;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import com.utils.ValidatorUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.annotation.IgnoreAuth;
import com.entity.JiaoshiEntity;
import com.entity.view.JiaoshiView;
import com.service.JiaoshiService;
import com.service.TokenService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.CommonUtil;
/**
* 教师
* 后端接口
* @author
* @email
* @date 2021-04-29 17:56:24
*/
@RestController
@RequestMapping("/jiaoshi")
public class JiaoshiController {
@Autowired
private JiaoshiService jiaoshiService;
@Autowired
private TokenService tokenService;
/**
* 登录
*/
@IgnoreAuth
@RequestMapping(value = "/login")
public R login(String username, String password, String captcha, HttpServletRequest request) {
JiaoshiEntity user = jiaoshiService.selectOne(new EntityWrapper<JiaoshiEntity>().eq("gonghao", username));
if(user==null || !user.getMima().equals(password)) {
return R.error("账号或密码不正确");
}
String token = tokenService.generateToken(user.getId(), username,"jiaoshi", "教师" );
return R.ok().put("token", token);
}
/**
* 注册
*/
@IgnoreAuth
@RequestMapping("/register")
public R register(@RequestBody JiaoshiEntity jiaoshi){
//ValidatorUtils.validateEntity(jiaoshi);
JiaoshiEntity user = jiaoshiService.selectOne(new EntityWrapper<JiaoshiEntity>().eq("gonghao", jiaoshi.getGonghao()));
if(user!=null) {
return R.error("注册用户已存在");
}
Long uId = new Date().getTime();
jiaoshi.setId(uId);
jiaoshiService.insert(jiaoshi);
return R.ok();
}
/**
* 退出
*/
@RequestMapping("/logout")
public R logout(HttpServletRequest request) {
request.getSession().invalidate();
return R.ok("退出成功");
}
/**
* 获取用户的session用户信息
*/
@RequestMapping("/session")
public R getCurrUser(HttpServletRequest request){
Long id = (Long)request.getSession().getAttribute("userId");
JiaoshiEntity user = jiaoshiService.selectById(id);
return R.ok().put("data", user);
}
/**
* 密码重置
*/
@IgnoreAuth
@RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request){
JiaoshiEntity user = jiaoshiService.selectOne(new EntityWrapper<JiaoshiEntity>().eq("gonghao", username));
if(user==null) {
return R.error("账号不存在");
}
user.setMima("123456");
jiaoshiService.updateById(user);
return R.ok("密码已重置为:123456");
}
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,JiaoshiEntity jiaoshi,
HttpServletRequest request){
EntityWrapper<JiaoshiEntity> ew = new EntityWrapper<JiaoshiEntity>();
PageUtils page = jiaoshiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, jiaoshi), params), params));
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,JiaoshiEntity jiaoshi,
HttpServletRequest request){
EntityWrapper<JiaoshiEntity> ew = new EntityWrapper<JiaoshiEntity>();
PageUtils page = jiaoshiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, jiaoshi), params), params));
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/lists")
public R list( JiaoshiEntity jiaoshi){
EntityWrapper<JiaoshiEntity> ew = new EntityWrapper<JiaoshiEntity>();
ew.allEq(MPUtil.allEQMapPre( jiaoshi, "jiaoshi"));
return R.ok().put("data", jiaoshiService.selectListView(ew));
}
/**
* 查询
*/
@RequestMapping("/query")
public R query(JiaoshiEntity jiaoshi){
EntityWrapper< JiaoshiEntity> ew = new EntityWrapper< JiaoshiEntity>();
ew.allEq(MPUtil.allEQMapPre( jiaoshi, "jiaoshi"));
JiaoshiView jiaoshiView = jiaoshiService.selectView(ew);
return R.ok("查询教师成功").put("data", jiaoshiView);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
JiaoshiEntity jiaoshi = jiaoshiService.selectById(id);
return R.ok().put("data", jiaoshi);
}
/**
* 前端详情
*/
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
JiaoshiEntity jiaoshi = jiaoshiService.selectById(id);
return R.ok().put("data", jiaoshi);
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody JiaoshiEntity jiaoshi, HttpServletRequest request){
jiaoshi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(jiaoshi);
JiaoshiEntity user = jiaoshiService.selectOne(new EntityWrapper<JiaoshiEntity>().eq("gonghao", jiaoshi.getGonghao()));
if(user!=null) {
return R.error("用户已存在");
}
jiaoshi.setId(new Date().getTime());
jiaoshiService.insert(jiaoshi);
return R.ok();
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody JiaoshiEntity jiaoshi, HttpServletRequest request){
jiaoshi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(jiaoshi);
JiaoshiEntity user = jiaoshiService.selectOne(new EntityWrapper<JiaoshiEntity>().eq("gonghao", jiaoshi.getGonghao()));
if(user!=null) {
return R.error("用户已存在");
}
jiaoshi.setId(new Date().getTime());
jiaoshiService.insert(jiaoshi);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody JiaoshiEntity jiaoshi, HttpServletRequest request){
//ValidatorUtils.validateEntity(jiaoshi);
jiaoshiService.updateById(jiaoshi);//全部更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
jiaoshiService.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.
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
Java毕业设计-基于SSM框架的数据结构课程网络学习平台.rar 【项目技术】 开发语言:Java 框架:ssm+vue 架构:B/S 数据库:mysql 【演示视频-编号:326】 https://pan.quark.cn/s/b3a97032fae7 【实现功能】 本数据结构课程网络学习平台有管理员,教师,用户。管理员功能有个人中心,用户管理,教师管理,课程资料管理,课程类型管理,试题管理,试卷管理,考试管理。教师可以发布课程资料,考试信息。用户可以查看考试资料,可以参加考试。
资源推荐
资源详情
资源评论
收起资源包目录
Java毕业设计-基于SSM框架的数据结构课程网络学习平台.rar (458个子文件)
update-password.vue.bak 3KB
IndexAsideStatic.vue.bak 2KB
BreadCrumbs.vue.bak 2KB
IndexHeader.vue.bak 2KB
3-build.bat 15B
2-run.bat 14B
1-install.bat 12B
.classpath 1KB
org.eclipse.wst.common.component 689B
org.eclipse.wst.jsdt.ui.superType.container 49B
app.0ea88516.css 252KB
bootstrap.css 143KB
bootstrap.min.css 118KB
chunk-vendors.0fdd4e14.css 37KB
glyphicons-halflings-regular.eot 20KB
.gitignore 10B
index.html 924B
index.html 552B
favicon.ico 4KB
favicon.ico 4KB
JiaoshiController.java 9KB
YonghuController.java 9KB
CommonController.java 8KB
ExamrecordController.java 8KB
ZuoyedianpingController.java 7KB
KechengyiwenController.java 7KB
KechengdayiController.java 7KB
ZuoyetijiaoController.java 7KB
KechengzuoyeController.java 7KB
KechengziliaokuController.java 7KB
KechengleixingController.java 7KB
ExamquestionController.java 7KB
ExampaperController.java 6KB
UserController.java 5KB
MPUtil.java 5KB
ZuoyetijiaoEntity.java 5KB
ExamrecordEntity.java 5KB
KechengyiwenEntity.java 5KB
ZuoyedianpingEntity.java 5KB
KechengzuoyeEntity.java 5KB
ExamquestionEntity.java 4KB
KechengziliaokuEntity.java 4KB
KechengdayiEntity.java 4KB
ZuoyetijiaoModel.java 4KB
ZuoyetijiaoVO.java 4KB
ExamrecordModel.java 4KB
KechengyiwenModel.java 4KB
ExamrecordVO.java 4KB
YonghuEntity.java 4KB
KechengyiwenVO.java 4KB
BaiduUtil.java 4KB
JiaoshiEntity.java 3KB
ZuoyedianpingModel.java 3KB
ZuoyedianpingVO.java 3KB
KechengzuoyeModel.java 3KB
ExamquestionModel.java 3KB
KechengdayiModel.java 3KB
KechengzuoyeVO.java 3KB
KechengziliaokuModel.java 3KB
ExamquestionVO.java 3KB
KechengdayiVO.java 3KB
KechengziliaokuVO.java 3KB
ConfigController.java 3KB
AuthorizationInterceptor.java 3KB
FileController.java 3KB
Query.java 3KB
YonghuModel.java 3KB
ExampaperEntity.java 2KB
YonghuVO.java 2KB
TokenServiceImpl.java 2KB
JiaoshiModel.java 2KB
ExamrecordServiceImpl.java 2KB
JiaoshiVO.java 2KB
TokenEntity.java 2KB
KechengziliaokuServiceImpl.java 2KB
KechengleixingServiceImpl.java 2KB
KechengleixingEntity.java 2KB
ZuoyedianpingServiceImpl.java 2KB
KechengyiwenServiceImpl.java 2KB
ExamquestionServiceImpl.java 2KB
KechengzuoyeServiceImpl.java 2KB
PageUtils.java 2KB
KechengdayiServiceImpl.java 2KB
ZuoyetijiaoServiceImpl.java 2KB
ExampaperServiceImpl.java 2KB
JiaoshiServiceImpl.java 2KB
YonghuServiceImpl.java 2KB
UserServiceImpl.java 1KB
CommonServiceImpl.java 1KB
ExampaperModel.java 1KB
UserEntity.java 1KB
ExampaperVO.java 1KB
SpringContextUtils.java 1KB
ExamrecordService.java 1KB
ValidatorUtils.java 1KB
KechengziliaokuService.java 1KB
ExamrecordDao.java 1KB
KechengleixingService.java 1KB
SQLFilter.java 1KB
ZuoyedianpingService.java 1KB
共 458 条
- 1
- 2
- 3
- 4
- 5
资源评论
岛上程序猿
- 粉丝: 2445
- 资源: 4154
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 驱动代码驱动代码驱动代码驱动代码
- SVID_20240523_141155_1.mp4
- Code for the complete guide to tkinter tutorial
- 关于百货中心供应链管理系统.zip
- SimpleFolderIcon-master 修改Unity的Project下的文件夹图标
- A python Tkinter widget to display tile based maps
- A pure Python library for adding tables to a Tkinter application
- Vector资源文件.zip
- MobaXterm-Installer
- MicroMsg.xlsx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功