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.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.HuiyuanEntity;
import com.entity.view.HuiyuanView;
import com.service.HuiyuanService;
import com.service.TokenService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.MPUtil;
import com.utils.CommonUtil;
/**
* 会员
* 后端接口
* @author
* @email
* @date 2020-10-24 18:10:15
*/
@RestController
@RequestMapping("/huiyuan")
public class HuiyuanController {
@Autowired
private HuiyuanService huiyuanService;
@Autowired
private TokenService tokenService;
/**
* 登录
*/
@IgnoreAuth
@RequestMapping(value = "/login")
public R login(String username, String password, String captcha, HttpServletRequest request) {
HuiyuanEntity user = huiyuanService.selectOne(new EntityWrapper<HuiyuanEntity>().eq("zhanghao", username));
if(user==null || !user.getMima().equals(password)) {
return R.error("账号或密码不正确");
}
String token = tokenService.generateToken(user.getId(), username,"huiyuan", "会员" );
return R.ok().put("token", token);
}
/**
* 注册
*/
@IgnoreAuth
@RequestMapping("/register")
public R register(@RequestBody HuiyuanEntity huiyuan){
//ValidatorUtils.validateEntity(huiyuan);
HuiyuanEntity user = huiyuanService.selectOne(new EntityWrapper<HuiyuanEntity>().eq("zhanghao", huiyuan.getZhanghao()));
if(user!=null) {
return R.error("注册用户已存在");
}
Long uId = new Date().getTime();
huiyuan.setId(uId);
huiyuanService.insert(huiyuan);
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");
HuiyuanEntity user = huiyuanService.selectById(id);
return R.ok().put("data", user);
}
/**
* 密码重置
*/
@IgnoreAuth
@RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request){
HuiyuanEntity user = huiyuanService.selectOne(new EntityWrapper<HuiyuanEntity>().eq("zhanghao", username));
if(user==null) {
return R.error("账号不存在");
}
user.setMima("123456");
huiyuanService.updateById(user);
return R.ok("密码已重置为:123456");
}
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,HuiyuanEntity huiyuan, HttpServletRequest request){
EntityWrapper<HuiyuanEntity> ew = new EntityWrapper<HuiyuanEntity>();
PageUtils page = huiyuanService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huiyuan), params), params));
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,HuiyuanEntity huiyuan, HttpServletRequest request){
EntityWrapper<HuiyuanEntity> ew = new EntityWrapper<HuiyuanEntity>();
PageUtils page = huiyuanService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, huiyuan), params), params));
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/lists")
public R list( HuiyuanEntity huiyuan){
EntityWrapper<HuiyuanEntity> ew = new EntityWrapper<HuiyuanEntity>();
ew.allEq(MPUtil.allEQMapPre( huiyuan, "huiyuan"));
return R.ok().put("data", huiyuanService.selectListView(ew));
}
/**
* 查询
*/
@RequestMapping("/query")
public R query(HuiyuanEntity huiyuan){
EntityWrapper< HuiyuanEntity> ew = new EntityWrapper< HuiyuanEntity>();
ew.allEq(MPUtil.allEQMapPre( huiyuan, "huiyuan"));
HuiyuanView huiyuanView = huiyuanService.selectView(ew);
return R.ok("查询会员成功").put("data", huiyuanView);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") String id){
HuiyuanEntity huiyuan = huiyuanService.selectById(id);
return R.ok().put("data", huiyuan);
}
/**
* 前端详情
*/
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") String id){
HuiyuanEntity huiyuan = huiyuanService.selectById(id);
return R.ok().put("data", huiyuan);
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody HuiyuanEntity huiyuan, HttpServletRequest request){
huiyuan.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(huiyuan);
HuiyuanEntity user = huiyuanService.selectOne(new EntityWrapper<HuiyuanEntity>().eq("zhanghao", huiyuan.getZhanghao()));
if(user!=null) {
return R.error("用户已存在");
}
huiyuan.setId(new Date().getTime());
huiyuanService.insert(huiyuan);
return R.ok();
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody HuiyuanEntity huiyuan, HttpServletRequest request){
huiyuan.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(huiyuan);
HuiyuanEntity user = huiyuanService.selectOne(new EntityWrapper<HuiyuanEntity>().eq("zhanghao", huiyuan.getZhanghao()));
if(user!=null) {
return R.error("用户已存在");
}
huiyuan.setId(new Date().getTime());
huiyuanService.insert(huiyuan);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody HuiyuanEntity huiyuan, HttpServletRequest request){
//ValidatorUtils.validateEntity(huiyuan);
huiyuanService.updateById(huiyuan);//全部更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
huiyuanService.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 && !map.get("remindstart").toString().equals("")) {
Integer remindStart = Integer.parseInt(map.get("remindstart").toSt
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
本系统主要针对计算机相关专业的正在做毕业设计的学生和需要项目实战练习的学习者,可作为毕业设计、课程设计、期末大作业。本系统主要针对计算机相关专业的正在做毕业设计的学生和需要项目实战练习的学习者,可作为毕业设计、课程设计、期末大作业。本系统主要针对计算机相关专业的正在做毕业设计的学生和需要项目实战练习的学习者,可作为毕业设计、课程设计、期末大作业。本系统主要针对计算机相关专业的正在做毕业设计的学生和需要项目实战练习的学习者,可作为毕业设计、课程设计、期末大作业。本系统主要针对计算机相关专业的正在做毕业设计的学生和需要项目实战练习的学习者,可作为毕业设计、课程设计、期末大作业。本系统主要针对计算机相关专业的正在做毕业设计的学生和需要项目实战练习的学习者,可作为毕业设计、课程设计、期末大作业。
资源推荐
资源详情
资源评论
收起资源包目录
3969-SSM农业商品信息管理权限后台子系统(源码+数据库+lun文).zip (800个子文件)
2-run.bat 14B
1-install.bat 12B
UserController.class 5KB
CommonController.class 3KB
MPUtil.class 3KB
FileController.class 3KB
UserServiceImpl.class 3KB
SpringContextUtils.class 2KB
PageUtils.class 2KB
Query.class 2KB
AuthorizationInterceptor.class 2KB
R.class 2KB
CommonServiceImpl.class 2KB
UserEntity.class 1KB
ValidatorUtils.class 1KB
JQPageInfo.class 1KB
EIException.class 1KB
MyMetaObjectHandler.class 1KB
TypeEnum.class 1KB
UserDao.class 1KB
CommonUtil.class 1KB
UserService.class 917B
SQLFilter.class 873B
CommonService.class 710B
CommonDao.class 698B
IgnoreAuth.class 428B
APPLoginUser.class 395B
LoginUser.class 389B
.classpath 1KB
org.eclipse.wst.common.component 689B
org.eclipse.wst.jsdt.ui.superType.container 49B
app.cfa97989.css 242KB
elementui.css 227KB
icons.css 159KB
bootstrap.css 143KB
bootstrap.min.css 138KB
tableft.css 135KB
style.css 125KB
bootstrap.min.css 118KB
icofont.min.css 113KB
bootstrap.min.css 108KB
style.css 83KB
animate.css 79KB
layui.css 73KB
animate.css 72KB
all.min.css 45KB
chunk-vendors.1f0a25b2.css 37KB
font-awesome.min.css 34KB
swiper.min.css 19KB
lightcase.css 17KB
jquery-ui.min.css 16KB
layer.css 14KB
swiper.min.css 13KB
layui.mobile.css 10KB
owl.carousel.css 8KB
responsive.css 8KB
laydate.css 7KB
style.css 4KB
meanmenu.min.css 3KB
login.css 2KB
slick.css 2KB
xuanzuo.css 2KB
xuanzuo.css 2KB
style.css 2KB
style.css 1KB
code.css 1KB
iconfont.eot 46KB
glyphicons-halflings-regular.eot 20KB
59.gif 10KB
22.gif 10KB
24.gif 8KB
13.gif 7KB
16.gif 7KB
39.gif 6KB
64.gif 6KB
63.gif 6KB
50.gif 6KB
loading-0.gif 6KB
4.gif 6KB
1.gif 5KB
42.gif 5KB
71.gif 5KB
21.gif 5KB
20.gif 5KB
29.gif 5KB
70.gif 4KB
5.gif 4KB
17.gif 4KB
27.gif 4KB
9.gif 4KB
44.gif 4KB
11.gif 4KB
8.gif 4KB
3.gif 4KB
23.gif 4KB
34.gif 4KB
41.gif 4KB
38.gif 4KB
65.gif 3KB
32.gif 3KB
共 800 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
资源评论
Java旅途
- 粉丝: 1w+
- 资源: 3050
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Spring Cloud商城项目专栏 049 支付
- sensors-18-03721.pdf
- Facebook.apk
- 推荐一款JTools的call-this-method插件
- json的合法基色来自红包东i请各位
- 项目采用YOLO V4算法模型进行目标检测,使用Deep SORT目标跟踪算法 .zip
- 针对实时视频流和静态图像实现的对象检测和跟踪算法 .zip
- 部署 yolox 算法使用 deepstream.zip
- 基于webmagic、springboot和mybatis的MagicToe Java爬虫设计源码
- 通过实时流协议 (RTSP) 使用 Yolo、OpenCV 和 Python 进行深度学习的对象检测.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功