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.ShangjiaEntity;
import com.entity.view.ShangjiaView;
import com.service.ShangjiaService;
import com.service.TokenService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.MPUtil;
import com.utils.CommonUtil;
/**
* 商家
* 后端接口
* @author
* @email
* @date 2020-09-23 18:00:25
*/
@RestController
@RequestMapping("/shangjia")
public class ShangjiaController {
@Autowired
private ShangjiaService shangjiaService;
@Autowired
private TokenService tokenService;
/**
* 登录
*/
@IgnoreAuth
@RequestMapping(value = "/login")
public R login(String username, String password, String captcha, HttpServletRequest request) {
ShangjiaEntity user = shangjiaService.selectOne(new EntityWrapper<ShangjiaEntity>().eq("shangjiabianhao", username));
if(user==null || !user.getMima().equals(password)) {
return R.error("账号或密码不正确");
}
String token = tokenService.generateToken(user.getId(), username,"shangjia", "商家" );
return R.ok().put("token", token);
}
/**
* 注册
*/
@IgnoreAuth
@RequestMapping("/register")
public R register(@RequestBody ShangjiaEntity shangjia){
//ValidatorUtils.validateEntity(shangjia);
ShangjiaEntity user = shangjiaService.selectOne(new EntityWrapper<ShangjiaEntity>().eq("shangjiabianhao", shangjia.getShangjiabianhao()));
if(user!=null) {
return R.error("注册用户已存在");
}
Long uId = new Date().getTime();
shangjia.setId(uId);
shangjiaService.insert(shangjia);
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");
ShangjiaEntity user = shangjiaService.selectById(id);
return R.ok().put("data", user);
}
/**
* 密码重置
*/
@IgnoreAuth
@RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request){
ShangjiaEntity user = shangjiaService.selectOne(new EntityWrapper<ShangjiaEntity>().eq("shangjiabianhao", username));
if(user==null) {
return R.error("账号不存在");
}
user.setMima("123456");
shangjiaService.updateById(user);
return R.ok("密码已重置为:123456");
}
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,ShangjiaEntity shangjia, HttpServletRequest request){
EntityWrapper<ShangjiaEntity> ew = new EntityWrapper<ShangjiaEntity>();
PageUtils page = shangjiaService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, shangjia), params), params));
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,ShangjiaEntity shangjia, HttpServletRequest request){
EntityWrapper<ShangjiaEntity> ew = new EntityWrapper<ShangjiaEntity>();
PageUtils page = shangjiaService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, shangjia), params), params));
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/lists")
public R list( ShangjiaEntity shangjia){
EntityWrapper<ShangjiaEntity> ew = new EntityWrapper<ShangjiaEntity>();
ew.allEq(MPUtil.allEQMapPre( shangjia, "shangjia"));
return R.ok().put("data", shangjiaService.selectListView(ew));
}
/**
* 查询
*/
@RequestMapping("/query")
public R query(ShangjiaEntity shangjia){
EntityWrapper< ShangjiaEntity> ew = new EntityWrapper< ShangjiaEntity>();
ew.allEq(MPUtil.allEQMapPre( shangjia, "shangjia"));
ShangjiaView shangjiaView = shangjiaService.selectView(ew);
return R.ok("查询商家成功").put("data", shangjiaView);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") String id){
ShangjiaEntity shangjia = shangjiaService.selectById(id);
return R.ok().put("data", shangjia);
}
/**
* 前端详情
*/
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") String id){
ShangjiaEntity shangjia = shangjiaService.selectById(id);
return R.ok().put("data", shangjia);
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody ShangjiaEntity shangjia, HttpServletRequest request){
shangjia.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(shangjia);
ShangjiaEntity user = shangjiaService.selectOne(new EntityWrapper<ShangjiaEntity>().eq("shangjiabianhao", shangjia.getShangjiabianhao()));
if(user!=null) {
return R.error("用户已存在");
}
shangjia.setId(new Date().getTime());
shangjiaService.insert(shangjia);
return R.ok();
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody ShangjiaEntity shangjia, HttpServletRequest request){
shangjia.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(shangjia);
ShangjiaEntity user = shangjiaService.selectOne(new EntityWrapper<ShangjiaEntity>().eq("shangjiabianhao", shangjia.getShangjiabianhao()));
if(user!=null) {
return R.error("用户已存在");
}
shangjia.setId(new Date().getTime());
shangjiaService.insert(shangjia);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody ShangjiaEntity shangjia, HttpServletRequest request){
//ValidatorUtils.validateEntity(shangjia);
shangjiaService.updateById(shangjia);//全部更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
shangjiaService.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 remindEnd
没有合适的资源?快使用搜索试试~ 我知道了~
课设毕设基于SpringBoot+Vue的外卖点餐系统 LW+PPT+源码可运行.zip
共638个文件
java:121个
jpg:84个
vue:79个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 129 浏览量
2024-05-18
15:33:19
上传
评论
收藏 27.8MB ZIP 举报
温馨提示
课设毕设基于SpringBoot+Vue的外卖点餐系统 LW+PPT+源码可运行.zip
资源推荐
资源详情
资源评论
收起资源包目录
课设毕设基于SpringBoot+Vue的外卖点餐系统 LW+PPT+源码可运行.zip (638个子文件)
2-run.bat 14B
1-install.bat 12B
UserController.class 6KB
CommonController.class 4KB
FileController.class 3KB
MPUtil.class 3KB
UserServiceImpl.class 3KB
SpringContextUtils.class 2KB
PageUtils.class 2KB
Query.class 2KB
AuthorizationInterceptor.class 2KB
R.class 2KB
UserEntity.class 2KB
CommonServiceImpl.class 2KB
EIException.class 1KB
JQPageInfo.class 1KB
ValidatorUtils.class 1KB
UserDao.class 1KB
UserService.class 1KB
MybatisPlusConfig.class 1KB
InterceptorConfig.class 1KB
CommonUtil.class 1KB
SpringbootSchemaApplication.class 980B
SQLFilter.class 909B
SpringbootSchemaApplicationTests.class 828B
CommonService.class 793B
CommonDao.class 781B
IgnoreAuth.class 428B
APPLoginUser.class 395B
LoginUser.class 389B
.classpath 2KB
mvnw.cmd 7KB
app.f3a0c719.css 236KB
elementui.css 227KB
bootstrap.min.css 108KB
style.css 83KB
layui.css 73KB
animate.css 72KB
chunk-vendors.1f0a25b2.css 37KB
font-awesome.min.css 34KB
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
meanmenu.min.css 3KB
slick.css 2KB
xuanzuo.css 2KB
code.css 1KB
page_common.css 1015B
index.css 105B
fontawesome-webfont.eot 69KB
iconfont.eot 46KB
.factorypath 15KB
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
45.gif 3KB
7.gif 3KB
12.gif 3KB
26.gif 3KB
60.gif 3KB
2.gif 3KB
40.gif 3KB
25.gif 3KB
19.gif 3KB
66.gif 3KB
18.gif 3KB
46.gif 3KB
共 638 条
- 1
- 2
- 3
- 4
- 5
- 6
- 7
资源评论
Link_Zero
- 粉丝: 2353
- 资源: 1045
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功