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.ZhuhuEntity;
import com.entity.view.ZhuhuView;
import com.service.ZhuhuService;
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;
import com.service.EmailregistercodeService;
import com.entity.EmailregistercodeEntity;
/**
* 住户
* 后端接口
* @author
* @email
* @date 2022-03-15 15:27:22
*/
@RestController
@RequestMapping("/zhuhu")
public class ZhuhuController {
@Autowired
private ZhuhuService zhuhuService;
@Autowired
private EmailregistercodeService emailregistercodeService;
@Autowired
private TokenService tokenService;
/**
* 登录
*/
@IgnoreAuth
@RequestMapping(value = "/login")
public R login(String username, String password, String captcha, HttpServletRequest request) {
ZhuhuEntity user = zhuhuService.selectOne(new EntityWrapper<ZhuhuEntity>().eq("zhuhuzhanghao", username));
if(user==null || !user.getMima().equals(password)) {
return R.error("账号或密码不正确");
}
String token = tokenService.generateToken(user.getId(), username,"zhuhu", "住户" );
return R.ok().put("token", token);
}
/**
* 注册
*/
@IgnoreAuth
@RequestMapping("/register")
public R register(@RequestBody ZhuhuEntity zhuhu, @RequestParam(required = false) String emailcode){
//ValidatorUtils.validateEntity(zhuhu);
ZhuhuEntity user = zhuhuService.selectOne(new EntityWrapper<ZhuhuEntity>().eq("zhuhuzhanghao", zhuhu.getZhuhuzhanghao()));
if(user!=null) {
return R.error("注册用户已存在");
}
//校验邮箱验证码
user =zhuhuService.selectOne(new EntityWrapper<ZhuhuEntity>().eq("email", zhuhu.getEmail()));
if(user!=null) {
return R.error("邮箱已被注册");
}
List<EmailregistercodeEntity> emailregistercodeList = emailregistercodeService.selectList(
new EntityWrapper<EmailregistercodeEntity>().eq("role", "用户")
.eq("email", zhuhu.getEmail()).orderBy("addtime", false));
boolean emailValidate = false;
if(emailregistercodeList!=null && emailregistercodeList.size()>0) {
if(emailregistercodeList.get(0).getCode().equals(emailcode)) {
emailValidate = true;
}
}
if(!emailValidate) return R.error("邮箱验证码不正确");
Long uId = new Date().getTime();
zhuhu.setId(uId);
zhuhuService.insert(zhuhu);
return R.ok();
}
/**
* 发送邮件
*/
@IgnoreAuth
@RequestMapping("/sendemail")
public R sendemail(@RequestParam String email){
String code = CommonUtil.getRandomNumber(4);
EmailregistercodeEntity emailregistercode = new EmailregistercodeEntity();
emailregistercode.setCode(code);
emailregistercode.setRole("用户");
emailregistercode.setEmail(email);
emailregistercodeService.insert(emailregistercode);
CommonUtil.sendEmail(email, "用户注册","您的注册验证码是【"+code+"】,请不要把验证码泄漏给其他人,如非本人请勿操作。");
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");
ZhuhuEntity user = zhuhuService.selectById(id);
return R.ok().put("data", user);
}
/**
* 密码重置
*/
@IgnoreAuth
@RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request){
ZhuhuEntity user = zhuhuService.selectOne(new EntityWrapper<ZhuhuEntity>().eq("zhuhuzhanghao", username));
if(user==null) {
return R.error("账号不存在");
}
user.setMima("123456");
zhuhuService.updateById(user);
return R.ok("密码已重置为:123456");
}
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,ZhuhuEntity zhuhu,
HttpServletRequest request){
EntityWrapper<ZhuhuEntity> ew = new EntityWrapper<ZhuhuEntity>();
PageUtils page = zhuhuService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, zhuhu), params), params));
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,ZhuhuEntity zhuhu,
HttpServletRequest request){
EntityWrapper<ZhuhuEntity> ew = new EntityWrapper<ZhuhuEntity>();
PageUtils page = zhuhuService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, zhuhu), params), params));
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/lists")
public R list( ZhuhuEntity zhuhu){
EntityWrapper<ZhuhuEntity> ew = new EntityWrapper<ZhuhuEntity>();
ew.allEq(MPUtil.allEQMapPre( zhuhu, "zhuhu"));
return R.ok().put("data", zhuhuService.selectListView(ew));
}
/**
* 查询
*/
@RequestMapping("/query")
public R query(ZhuhuEntity zhuhu){
EntityWrapper< ZhuhuEntity> ew = new EntityWrapper< ZhuhuEntity>();
ew.allEq(MPUtil.allEQMapPre( zhuhu, "zhuhu"));
ZhuhuView zhuhuView = zhuhuService.selectView(ew);
return R.ok("查询住户成功").put("data", zhuhuView);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
ZhuhuEntity zhuhu = zhuhuService.selectById(id);
return R.ok().put("data", zhuhu);
}
/**
* 前端详情
*/
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
ZhuhuEntity zhuhu = zhuhuService.selectById(id);
return R.ok().put("data", zhuhu);
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody ZhuhuEntity zhuhu, HttpServletRequest request){
zhuhu.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(zhuhu);
ZhuhuEntity user = zhuhuService.selectOne(new EntityWrapper<ZhuhuEntity>().eq("zhuhuzhanghao", zhuhu.getZhuhuzhanghao()));
if(user!=null) {
return R.error("用户已存在");
}
zhuhu.setId(new Date().getTime());
zhuhuService.insert(zhuhu);
return
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
本项目是一款基于Vue和Java开发的公寓报修管理系统源码,包含451个文件,其中包含161个SVG矢量图形、122个Java类文件、51个Vue组件文件、29个PNG图片、20个JavaScript文件、18个JPG图片、17个XML配置文件、5个CSS样式文件、5个备份文件、4个批处理文件。该系统采用前后端分离架构,旨在为用户提供便捷、高效的报修服务。
资源推荐
资源详情
资源评论
收起资源包目录
基于Vue和Java的公寓报修管理系统设计源码 (453个子文件)
update-password.vue.bak 3KB
IndexMain.vue.bak 2KB
IndexAsideStatic.vue.bak 2KB
BreadCrumbs.vue.bak 2KB
IndexHeader.vue.bak 1KB
update.bat 92B
3-build.bat 15B
2-run.bat 14B
1-install.bat 12B
app.ab9c3f30.css 267KB
chunk-vendors.a48a7cc1.css 37KB
canvas-bg-1.css 379B
canvas-bg-2.css 79B
canvas-bg-3.css 57B
.gitignore 333B
index.html 924B
index.html 552B
favicon.ico 4KB
favicon.ico 4KB
ZhuhuController.java 10KB
CommonController.java 9KB
WeixiurenyuanController.java 9KB
WeixiufenpeiEntity.java 7KB
WeixiujiluEntity.java 7KB
GaipaishenqingEntity.java 7KB
WeixiupingjiaController.java 7KB
GaipaishenqingController.java 7KB
WeixiujiluController.java 7KB
WeixiushenqingController.java 7KB
FangjianxinxiController.java 7KB
QingjiaxinxiController.java 7KB
WeixiufenpeiController.java 7KB
EmailregistercodeController.java 7KB
WeixiufenleiController.java 6KB
WupinxinxiController.java 6KB
WeixiushenqingEntity.java 6KB
WeixiufenpeiModel.java 6KB
WeixiujiluModel.java 6KB
GaipaishenqingModel.java 6KB
WeixiufenpeiVO.java 6KB
WeixiujiluVO.java 6KB
GaipaishenqingVO.java 6KB
WeixiushenqingModel.java 5KB
MPUtil.java 5KB
UserController.java 5KB
WeixiushenqingVO.java 5KB
WeixiupingjiaEntity.java 5KB
FileController.java 4KB
QingjiaxinxiEntity.java 4KB
FangjianxinxiEntity.java 4KB
WeixiurenyuanEntity.java 4KB
ZhuhuEntity.java 4KB
BaiduUtil.java 4KB
WeixiupingjiaModel.java 3KB
WupinxinxiEntity.java 3KB
WeixiupingjiaVO.java 3KB
AuthorizationInterceptor.java 3KB
ConfigController.java 3KB
QingjiaxinxiModel.java 3KB
FangjianxinxiModel.java 3KB
CommonUtil.java 3KB
QingjiaxinxiVO.java 3KB
FangjianxinxiVO.java 3KB
WeixiurenyuanModel.java 3KB
Query.java 3KB
WeixiurenyuanVO.java 2KB
ZhuhuModel.java 2KB
ZhuhuVO.java 2KB
EmailregistercodeEntity.java 2KB
WupinxinxiModel.java 2KB
WupinxinxiVO.java 2KB
TokenEntity.java 2KB
WeixiufenleiEntity.java 2KB
PageUtils.java 2KB
InterceptorConfig.java 1KB
UserEntity.java 1KB
EmailregistercodeModel.java 1KB
SpringContextUtils.java 1KB
EmailregistercodeService.java 1KB
EmailregistercodeDao.java 1KB
ValidatorUtils.java 1KB
EmailregistercodeVO.java 1KB
GaipaishenqingService.java 1KB
WeixiushenqingService.java 1KB
GaipaishenqingDao.java 1024B
WeixiushenqingDao.java 1024B
SQLFilter.java 1019B
WeixiupingjiaService.java 1019B
WeixiurenyuanService.java 1019B
FangjianxinxiService.java 1019B
WeixiurenyuanDao.java 1009B
FangjianxinxiDao.java 1009B
WeixiupingjiaDao.java 1009B
QingjiaxinxiService.java 1005B
WeixiufenpeiService.java 1005B
WeixiufenleiService.java 1005B
QingjiaxinxiDao.java 994B
WeixiufenleiDao.java 994B
WeixiufenpeiDao.java 994B
WeixiujiluService.java 977B
共 453 条
- 1
- 2
- 3
- 4
- 5
资源评论
csbysj2020
- 粉丝: 2752
- 资源: 5571
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 毕设和企业适用springboot汽车管理类及教育评价系统源码+论文+视频.zip
- 毕设和企业适用springboot汽车管理类及基因数据分析平台源码+论文+视频.zip
- 毕设和企业适用springboot区域电商平台类及电力系统优化平台源码+论文+视频.zip
- 毕设和企业适用springboot区域电商平台类及个性化推荐系统源码+论文+视频.zip
- 毕设和企业适用springboot区域电商平台类及国际贸易平台源码+论文+视频.zip
- 毕设和企业适用springboot人工智能客服系统类及视频监控平台源码+论文+视频.zip
- 毕设和企业适用springboot人工智能客服系统类及旅游规划平台源码+论文+视频.zip
- 毕设和企业适用springboot人工智能客服系统类及市场营销自动化平台源码+论文+视频.zip
- 毕设和企业适用springboot汽车管理类及企业管理平台源码+论文+视频.zip
- 毕设和企业适用springboot汽车管理类及气象数据管理系统源码+论文+视频.zip
- 毕设和企业适用springboot汽车管理类及数字内容管理平台源码+论文+视频.zip
- 毕设和企业适用springboot区域电商平台类及跨境物流平台源码+论文+视频.zip
- 毕设和企业适用springboot区域电商平台类及互联网金融平台源码+论文+视频.zip
- 毕设和企业适用springboot区域电商平台类及活动管理平台源码+论文+视频.zip
- 毕设和企业适用springboot人工智能客服系统类及视频监控系统源码+论文+视频.zip
- 毕设和企业适用springboot人工智能客服系统类及数字内容管理平台源码+论文+视频.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功