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.transaction.annotation.Transactional;
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.XueshengEntity;
import com.entity.view.XueshengView;
import com.service.XueshengService;
import com.service.TokenService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.CommonUtil;
import java.io.IOException;
/**
* 学生
* 后端接口
* @author
* @email
* @date 2022-05-09 16:05:16
*/
@RestController
@RequestMapping("/xuesheng")
public class XueshengController {
@Autowired
private XueshengService xueshengService;
@Autowired
private TokenService tokenService;
/**
* 登录
*/
@IgnoreAuth
@RequestMapping(value = "/login")
public R login(String username, String password, String captcha, HttpServletRequest request) {
XueshengEntity user = xueshengService.selectOne(new EntityWrapper<XueshengEntity>().eq("xuehao", username));
if(user==null || !user.getMima().equals(password)) {
return R.error("账号或密码不正确");
}
String token = tokenService.generateToken(user.getId(), username,"xuesheng", "学生" );
return R.ok().put("token", token);
}
/**
* 注册
*/
@IgnoreAuth
@RequestMapping("/register")
public R register(@RequestBody XueshengEntity xuesheng){
//ValidatorUtils.validateEntity(xuesheng);
XueshengEntity user = xueshengService.selectOne(new EntityWrapper<XueshengEntity>().eq("xuehao", xuesheng.getXuehao()));
if(user!=null) {
return R.error("注册用户已存在");
}
Long uId = new Date().getTime();
xuesheng.setId(uId);
xueshengService.insert(xuesheng);
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");
XueshengEntity user = xueshengService.selectById(id);
return R.ok().put("data", user);
}
/**
* 密码重置
*/
@IgnoreAuth
@RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request){
XueshengEntity user = xueshengService.selectOne(new EntityWrapper<XueshengEntity>().eq("xuehao", username));
if(user==null) {
return R.error("账号不存在");
}
user.setMima("123456");
xueshengService.updateById(user);
return R.ok("密码已重置为:123456");
}
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,XueshengEntity xuesheng,
HttpServletRequest request){
String tableName = request.getSession().getAttribute("tableName").toString();
if(tableName.equals("jiaoshi")) {
xuesheng.setJiaoshigonghao((String)request.getSession().getAttribute("username"));
}
if(tableName.equals("yuanxifuzeren")) {
xuesheng.setYuanxizhanghao((String)request.getSession().getAttribute("username"));
}
EntityWrapper<XueshengEntity> ew = new EntityWrapper<XueshengEntity>();
PageUtils page = xueshengService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, xuesheng), params), params));
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,XueshengEntity xuesheng,
HttpServletRequest request){
EntityWrapper<XueshengEntity> ew = new EntityWrapper<XueshengEntity>();
PageUtils page = xueshengService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, xuesheng), params), params));
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/lists")
public R list( XueshengEntity xuesheng){
EntityWrapper<XueshengEntity> ew = new EntityWrapper<XueshengEntity>();
ew.allEq(MPUtil.allEQMapPre( xuesheng, "xuesheng"));
return R.ok().put("data", xueshengService.selectListView(ew));
}
/**
* 查询
*/
@RequestMapping("/query")
public R query(XueshengEntity xuesheng){
EntityWrapper< XueshengEntity> ew = new EntityWrapper< XueshengEntity>();
ew.allEq(MPUtil.allEQMapPre( xuesheng, "xuesheng"));
XueshengView xueshengView = xueshengService.selectView(ew);
return R.ok("查询学生成功").put("data", xueshengView);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
XueshengEntity xuesheng = xueshengService.selectById(id);
return R.ok().put("data", xuesheng);
}
/**
* 前端详情
*/
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
XueshengEntity xuesheng = xueshengService.selectById(id);
return R.ok().put("data", xuesheng);
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody XueshengEntity xuesheng, HttpServletRequest request){
xuesheng.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(xuesheng);
XueshengEntity user = xueshengService.selectOne(new EntityWrapper<XueshengEntity>().eq("xuehao", xuesheng.getXuehao()));
if(user!=null) {
return R.error("用户已存在");
}
xuesheng.setId(new Date().getTime());
xueshengService.insert(xuesheng);
return R.ok();
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody XueshengEntity xuesheng, HttpServletRequest request){
xuesheng.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(xuesheng);
XueshengEntity user = xueshengService.selectOne(new EntityWrapper<XueshengEntity>().eq("xuehao", xuesheng.getXuehao()));
if(user!=null) {
return R.error("用户已存在");
}
xuesheng.setId(new Date().getTime());
xueshengService.insert(xuesheng);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
@Transactional
public R update(@RequestBody XueshengEntity xuesheng, HttpServletRequest request){
//ValidatorUtils.validateEntity(xuesheng);
xueshengService.updateById(xuesheng);//全部更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
xueshengService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
/**
* 提醒�
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
Java基于spring boot的高校专业实习管理系统的设计与实现 本次开发的高校专业实习管理系统有管理员,院系负责人,教师,实习单位,学生五个角色。功能模块主要有个人中心,院系管理,专业管理,院系负责人管理,教师管理,实习单位管理,学生管理,实习流程管理,实习公告管理,实习内容管理,实习申请管理,实习安排管理,单位反馈管理,学生反馈管理,实习保障管理,成绩评定管理,实习综合成绩管理。开发本程序后台用到了Spring Boot开发技术,页面设计采用VUE框架和layui样式。数据库采用关系数据库市场占有率最高的MySQL作为本程序使用的数据库,完全符合程序使用并且有丰富的拓展余地。
资源推荐
资源详情
资源评论
收起资源包目录
基于springboot高校专业实习管理系统的设计和开发(毕业论文) (526个子文件)
update-password.vue.bak 3KB
IndexMain.vue.bak 2KB
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 2KB
mvnw.cmd 7KB
app.09495242.css 276KB
chunk-vendors.a72b0961.css 37KB
canvas-bg-1.css 391B
canvas-bg-2.css 83B
canvas-bg-3.css 61B
.factorypath 15KB
.gitignore 364B
index.html 936B
index.html 565B
favicon.ico 4KB
favicon.ico 4KB
maven-wrapper.jar 50KB
XueshengController.java 10KB
YuanxifuzerenController.java 9KB
ShixidanweiController.java 9KB
JiaoshiController.java 9KB
CommonController.java 9KB
ShixizonghechengjiController.java 9KB
ChengjipingdingController.java 9KB
XueshengfankuiController.java 8KB
ShixianpaiController.java 8KB
ShixishenqingController.java 8KB
DanweifankuiController.java 8KB
ShixibaozhangController.java 8KB
ShixianpaiEntity.java 7KB
ShixiliuchengController.java 7KB
ShixineirongController.java 7KB
ShixigonggaoController.java 7KB
ZhuanyeController.java 6KB
YuanxiController.java 6KB
ChengjipingdingEntity.java 6KB
ShixianpaiModel.java 6KB
ShixianpaiVO.java 6KB
ShixizonghechengjiEntity.java 6KB
MPUtil.java 5KB
UserController.java 5KB
ShixishenqingEntity.java 5KB
ShixibaozhangEntity.java 5KB
ChengjipingdingModel.java 5KB
MavenWrapperDownloader.java 5KB
ChengjipingdingVO.java 5KB
XueshengfankuiEntity.java 5KB
ShixineirongEntity.java 5KB
ShixizonghechengjiModel.java 5KB
ShixidanweiEntity.java 5KB
ShixizonghechengjiVO.java 5KB
XueshengEntity.java 5KB
JiaoshiEntity.java 4KB
DanweifankuiEntity.java 4KB
FileController.java 4KB
ShixishenqingModel.java 4KB
ShixibaozhangModel.java 4KB
ShixishenqingVO.java 4KB
ShixibaozhangVO.java 4KB
XueshengfankuiModel.java 4KB
ShixigonggaoEntity.java 4KB
ShixiliuchengEntity.java 4KB
BaiduUtil.java 4KB
XueshengfankuiVO.java 4KB
YuanxifuzerenEntity.java 4KB
ShixineirongModel.java 4KB
ShixineirongVO.java 3KB
XueshengModel.java 3KB
AuthorizationInterceptor.java 3KB
ShixidanweiModel.java 3KB
XueshengVO.java 3KB
ShixidanweiVO.java 3KB
JiaoshiModel.java 3KB
ConfigController.java 3KB
JiaoshiVO.java 3KB
DanweifankuiModel.java 3KB
DanweifankuiVO.java 3KB
Query.java 3KB
TokenServiceImpl.java 2KB
ShixigonggaoModel.java 2KB
ShixiliuchengModel.java 2KB
YuanxifuzerenModel.java 2KB
ShixigonggaoVO.java 2KB
ShixiliuchengVO.java 2KB
YuanxifuzerenVO.java 2KB
TokenEntity.java 2KB
CommonUtil.java 2KB
ShixizonghechengjiServiceImpl.java 2KB
ChengjipingdingServiceImpl.java 2KB
XueshengfankuiServiceImpl.java 2KB
ShixibaozhangServiceImpl.java 2KB
ShixishenqingServiceImpl.java 2KB
YuanxifuzerenServiceImpl.java 2KB
ShixiliuchengServiceImpl.java 2KB
DanweifankuiServiceImpl.java 2KB
共 526 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
code.song
- 粉丝: 982
- 资源: 1138
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功