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.DefaultuserEntity;
import com.entity.view.DefaultuserView;
import com.service.DefaultuserService;
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-03-18 15:04:01
*/
@RestController
@RequestMapping("/defaultuser")
public class DefaultuserController {
@Autowired
private DefaultuserService defaultuserService;
@Autowired
private TokenService tokenService;
/**
* 登录
*/
@IgnoreAuth
@RequestMapping(value = "/login")
public R login(String username, String password, String captcha, HttpServletRequest request) {
DefaultuserEntity user = defaultuserService.selectOne(new EntityWrapper<DefaultuserEntity>().eq("username", username));
if(user==null || !user.getMima().equals(password)) {
return R.error("账号或密码不正确");
}
String token = tokenService.generateToken(user.getId(), username,"defaultuser", "注册用户" );
return R.ok().put("token", token);
}
/**
* 注册
*/
@IgnoreAuth
@RequestMapping("/register")
public R register(@RequestBody DefaultuserEntity defaultuser){
//ValidatorUtils.validateEntity(defaultuser);
DefaultuserEntity user = defaultuserService.selectOne(new EntityWrapper<DefaultuserEntity>().eq("username", defaultuser.getUsername()));
if(user!=null) {
return R.error("注册用户已存在");
}
Long uId = new Date().getTime();
defaultuser.setId(uId);
defaultuserService.insert(defaultuser);
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");
DefaultuserEntity user = defaultuserService.selectById(id);
return R.ok().put("data", user);
}
/**
* 密码重置
*/
@IgnoreAuth
@RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request){
DefaultuserEntity user = defaultuserService.selectOne(new EntityWrapper<DefaultuserEntity>().eq("username", username));
if(user==null) {
return R.error("账号不存在");
}
user.setMima("123456");
defaultuserService.updateById(user);
return R.ok("密码已重置为:123456");
}
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,DefaultuserEntity defaultuser,
HttpServletRequest request){
EntityWrapper<DefaultuserEntity> ew = new EntityWrapper<DefaultuserEntity>();
PageUtils page = defaultuserService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, defaultuser), params), params));
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,DefaultuserEntity defaultuser, HttpServletRequest request){
EntityWrapper<DefaultuserEntity> ew = new EntityWrapper<DefaultuserEntity>();
PageUtils page = defaultuserService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, defaultuser), params), params));
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/lists")
public R list( DefaultuserEntity defaultuser){
EntityWrapper<DefaultuserEntity> ew = new EntityWrapper<DefaultuserEntity>();
ew.allEq(MPUtil.allEQMapPre( defaultuser, "defaultuser"));
return R.ok().put("data", defaultuserService.selectListView(ew));
}
/**
* 查询
*/
@RequestMapping("/query")
public R query(DefaultuserEntity defaultuser){
EntityWrapper< DefaultuserEntity> ew = new EntityWrapper< DefaultuserEntity>();
ew.allEq(MPUtil.allEQMapPre( defaultuser, "defaultuser"));
DefaultuserView defaultuserView = defaultuserService.selectView(ew);
return R.ok("查询注册用户成功").put("data", defaultuserView);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
DefaultuserEntity defaultuser = defaultuserService.selectById(id);
return R.ok().put("data", defaultuser);
}
/**
* 前端详情
*/
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
DefaultuserEntity defaultuser = defaultuserService.selectById(id);
return R.ok().put("data", defaultuser);
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody DefaultuserEntity defaultuser, HttpServletRequest request){
defaultuser.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(defaultuser);
DefaultuserEntity user = defaultuserService.selectOne(new EntityWrapper<DefaultuserEntity>().eq("username", defaultuser.getUsername()));
if(user!=null) {
return R.error("用户已存在");
}
defaultuser.setId(new Date().getTime());
defaultuserService.insert(defaultuser);
return R.ok();
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody DefaultuserEntity defaultuser, HttpServletRequest request){
defaultuser.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(defaultuser);
DefaultuserEntity user = defaultuserService.selectOne(new EntityWrapper<DefaultuserEntity>().eq("username", defaultuser.getUsername()));
if(user!=null) {
return R.error("用户已存在");
}
defaultuser.setId(new Date().getTime());
defaultuserService.insert(defaultuser);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody DefaultuserEntity defaultuser, HttpServletRequest request){
//ValidatorUtils.validateEntity(defaultuser);
defaultuserService.updateById(defaultuser);//全部更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
defaultuserService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
/**
* 提醒接口
*/
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
Java 毕业设计,SSM 课程设计,基于SSM +Vue开发的,含有代码注释,新手也可看懂。毕业设计、期末大作业、课程设计、高分必看,下载下来,简单部署,就可以使用。 包含:项目源码、数据库脚本、软件工具等,该项目可以作为毕设、课程设计使用,前后端代码都在里面。 该系统功能完善、界面美观、操作简单、功能齐全、管理便捷,具有很高的实际应用价值。 项目都经过严格调试,确保可以运行! 1. 技术组成 前端:Vue 后台框架:SSM 开发环境:idea 数据库:MySql(建议用 5.7,8.0 有时候会有坑) 部署环境:Tomcat(建议用 7.x 或者 8.x 的版本),maven 2. 部署 后台路径地址:localhost:8080/项目名称/admin/dist/index.html 前台路径地址:localhost:8080/项目名称/front/index.html (无前台不需要输入)
资源推荐
资源详情
资源评论
收起资源包目录
Java项目-SpringBoot+Vue的幼儿园管理系统.zip (517个子文件)
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 2KB
mvnw.cmd 7KB
app.ddec048e.css 256KB
chunk-vendors.6d894868.css 37KB
.factorypath 15KB
.gitignore 364B
index.html 924B
index.html 552B
favicon.ico 4KB
favicon.ico 4KB
maven-wrapper.jar 50KB
DefaultuserController.java 9KB
JiaoshiController.java 9KB
YonghuController.java 9KB
CommonController.java 8KB
YouerqingjiaController.java 7KB
JiaofeixinxiController.java 7KB
ErtongtijianController.java 7KB
DaibanshixiangController.java 7KB
YouerxinxiController.java 7KB
GongzuorizhiController.java 7KB
ZhigongkaoheController.java 7KB
QingjiaxinxiController.java 7KB
BanjixinxiController.java 7KB
HuiyijiluController.java 7KB
YuanliaoxinxiController.java 7KB
ZiyuanxinxiController.java 6KB
CaipuxinxiController.java 6KB
ErtongtijianEntity.java 5KB
MPUtil.java 5KB
UserController.java 5KB
MavenWrapperDownloader.java 5KB
JiaofeixinxiEntity.java 5KB
YouerqingjiaEntity.java 5KB
YouerxinxiEntity.java 4KB
ErtongtijianModel.java 4KB
ErtongtijianVO.java 4KB
QingjiaxinxiEntity.java 4KB
YonghuEntity.java 4KB
ZhigongkaoheEntity.java 4KB
JiaofeixinxiModel.java 4KB
JiaofeixinxiVO.java 4KB
BaiduUtil.java 4KB
DefaultuserEntity.java 4KB
FileController.java 4KB
HuiyijiluEntity.java 4KB
ZiyuanxinxiEntity.java 4KB
JiaoshiEntity.java 3KB
YouerqingjiaModel.java 3KB
GongzuorizhiEntity.java 3KB
YouerqingjiaVO.java 3KB
YuanliaoxinxiEntity.java 3KB
AuthorizationInterceptor.java 3KB
YouerxinxiModel.java 3KB
YouerxinxiVO.java 3KB
DaibanshixiangEntity.java 3KB
CaipuxinxiEntity.java 3KB
BanjixinxiEntity.java 3KB
ConfigController.java 3KB
QingjiaxinxiModel.java 3KB
QingjiaxinxiVO.java 3KB
YonghuModel.java 3KB
ZhigongkaoheModel.java 3KB
Query.java 3KB
YonghuVO.java 3KB
ZhigongkaoheVO.java 3KB
TokenServiceImpl.java 2KB
DefaultuserModel.java 2KB
JiaoshiModel.java 2KB
DefaultuserVO.java 2KB
HuiyijiluModel.java 2KB
ZiyuanxinxiModel.java 2KB
JiaoshiVO.java 2KB
GongzuorizhiModel.java 2KB
HuiyijiluVO.java 2KB
ZiyuanxinxiVO.java 2KB
TokenEntity.java 2KB
GongzuorizhiVO.java 2KB
YuanliaoxinxiModel.java 2KB
DaibanshixiangServiceImpl.java 2KB
YuanliaoxinxiVO.java 2KB
YuanliaoxinxiServiceImpl.java 2KB
ErtongtijianServiceImpl.java 2KB
GongzuorizhiServiceImpl.java 2KB
ZhigongkaoheServiceImpl.java 2KB
YouerqingjiaServiceImpl.java 2KB
JiaofeixinxiServiceImpl.java 2KB
QingjiaxinxiServiceImpl.java 2KB
DaibanshixiangModel.java 2KB
PageUtils.java 2KB
DefaultuserServiceImpl.java 2KB
ZiyuanxinxiServiceImpl.java 2KB
CaipuxinxiModel.java 2KB
共 517 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
程序猿徐师兄
- 粉丝: 645
- 资源: 2287
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功