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.XiaoyuanmeishiEntity;
import com.entity.view.XiaoyuanmeishiView;
import com.service.XiaoyuanmeishiService;
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-02 12:41:47
*/
@RestController
@RequestMapping("/xiaoyuanmeishi")
public class XiaoyuanmeishiController {
@Autowired
private XiaoyuanmeishiService xiaoyuanmeishiService;
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,XiaoyuanmeishiEntity xiaoyuanmeishi, HttpServletRequest request){
String tableName = request.getSession().getAttribute("tableName").toString();
if(tableName.equals("shangjia")) {
xiaoyuanmeishi.setShangjiahao((String)request.getSession().getAttribute("username"));
}
EntityWrapper<XiaoyuanmeishiEntity> ew = new EntityWrapper<XiaoyuanmeishiEntity>();
PageUtils page = xiaoyuanmeishiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, xiaoyuanmeishi), params), params));
request.setAttribute("data", page);
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,XiaoyuanmeishiEntity xiaoyuanmeishi, HttpServletRequest request){
EntityWrapper<XiaoyuanmeishiEntity> ew = new EntityWrapper<XiaoyuanmeishiEntity>();
PageUtils page = xiaoyuanmeishiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, xiaoyuanmeishi), params), params));
request.setAttribute("data", page);
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/lists")
public R list( XiaoyuanmeishiEntity xiaoyuanmeishi){
EntityWrapper<XiaoyuanmeishiEntity> ew = new EntityWrapper<XiaoyuanmeishiEntity>();
ew.allEq(MPUtil.allEQMapPre( xiaoyuanmeishi, "xiaoyuanmeishi"));
return R.ok().put("data", xiaoyuanmeishiService.selectListView(ew));
}
/**
* 查询
*/
@RequestMapping("/query")
public R query(XiaoyuanmeishiEntity xiaoyuanmeishi){
EntityWrapper< XiaoyuanmeishiEntity> ew = new EntityWrapper< XiaoyuanmeishiEntity>();
ew.allEq(MPUtil.allEQMapPre( xiaoyuanmeishi, "xiaoyuanmeishi"));
XiaoyuanmeishiView xiaoyuanmeishiView = xiaoyuanmeishiService.selectView(ew);
return R.ok("查询校园美食成功").put("data", xiaoyuanmeishiView);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
XiaoyuanmeishiEntity xiaoyuanmeishi = xiaoyuanmeishiService.selectById(id);
xiaoyuanmeishi.setClicknum(xiaoyuanmeishi.getClicknum()+1);
xiaoyuanmeishi.setClicktime(new Date());
xiaoyuanmeishiService.updateById(xiaoyuanmeishi);
return R.ok().put("data", xiaoyuanmeishi);
}
/**
* 前端详情
*/
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
XiaoyuanmeishiEntity xiaoyuanmeishi = xiaoyuanmeishiService.selectById(id);
xiaoyuanmeishi.setClicknum(xiaoyuanmeishi.getClicknum()+1);
xiaoyuanmeishi.setClicktime(new Date());
xiaoyuanmeishiService.updateById(xiaoyuanmeishi);
return R.ok().put("data", xiaoyuanmeishi);
}
/**
* 赞或踩
*/
@RequestMapping("/thumbsup/{id}")
public R vote(@PathVariable("id") String id,String type){
XiaoyuanmeishiEntity xiaoyuanmeishi = xiaoyuanmeishiService.selectById(id);
if(type.equals("1")) {
xiaoyuanmeishi.setThumbsupnum(xiaoyuanmeishi.getThumbsupnum()+1);
} else {
xiaoyuanmeishi.setCrazilynum(xiaoyuanmeishi.getCrazilynum()+1);
}
xiaoyuanmeishiService.updateById(xiaoyuanmeishi);
return R.ok("投票成功");
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody XiaoyuanmeishiEntity xiaoyuanmeishi, HttpServletRequest request){
xiaoyuanmeishi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(xiaoyuanmeishi);
xiaoyuanmeishiService.insert(xiaoyuanmeishi);
return R.ok();
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody XiaoyuanmeishiEntity xiaoyuanmeishi, HttpServletRequest request){
xiaoyuanmeishi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(xiaoyuanmeishi);
xiaoyuanmeishiService.insert(xiaoyuanmeishi);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody XiaoyuanmeishiEntity xiaoyuanmeishi, HttpServletRequest request){
//ValidatorUtils.validateEntity(xiaoyuanmeishi);
xiaoyuanmeishiService.updateById(xiaoyuanmeishi);//全部更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
xiaoyuanmeishiService.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) {
Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindStart);
remindStartDate = c.getTime();
map.put("remindstart", sdf.format(remindStartDate));
}
if(map.get("remindend")!=null) {
Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindEnd);
remindEndDate = c.getTime();
map.put("remindend", sdf.format(remindEndDate));
}
}
Wrapper<XiaoyuanmeishiEntity> wrapper = new EntityWrapper<XiaoyuanmeishiEntity>();
if(map.get("remindstart")!=null) {
wrapper.ge(columnName, map.get("remindstart"));
}
if(map.get("remindend")!=null) {
wrapper.le(columnName, map.get("remindend"));
}
String tableName = request.getSession().getAttribute("tableName").toString();
if(tableName.equals("shangjia")) {
wrapper.eq("shangjiahao", (String)request.getSession().getAttribute("username
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
javaweb课程设计基于SpringBoot校园美食管理系统-毕业设计-源代码+初始化数据库脚本.zipjavaweb课程设计基于SpringBoot校园美食管理系统-毕业设计-源代码+初始化数据库脚本.zipjavaweb课程设计基于SpringBoot校园美食管理系统-毕业设计-源代码+初始化数据库脚本.zipjavaweb课程设计基于SpringBoot校园美食管理系统-毕业设计-源代码+初始化数据库脚本.zipjavaweb课程设计基于SpringBoot校园美食管理系统-毕业设计-源代码+初始化数据库脚本.zip
资源推荐
资源详情
资源评论
收起资源包目录
javaweb课程设计基于SpringBoot校园美食管理系统-毕业设计-源代码+初始化数据库脚本.zip (397个子文件)
index.jsp.bak 4KB
topNav.jsp.bak 1KB
elementui.css 227KB
bootstrap.min.css 139KB
util.css 85KB
layui.css 73KB
style.css 40KB
font-awesome.min.css 30KB
style.css 11KB
layui.mobile.css 10KB
main.css 9KB
theme.css 5KB
common.css 407B
校园美食管理系统.db 26KB
iconfont.eot 46KB
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
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
10.gif 3KB
28.gif 3KB
51.gif 3KB
57.gif 3KB
67.gif 3KB
0.gif 3KB
48.gif 3KB
43.gif 3KB
30.gif 2KB
61.gif 2KB
33.gif 2KB
69.gif 2KB
14.gif 2KB
47.gif 2KB
36.gif 2KB
49.gif 2KB
58.gif 2KB
6.gif 2KB
54.gif 2KB
53.gif 2KB
56.gif 2KB
62.gif 2KB
31.gif 2KB
55.gif 2KB
35.gif 2KB
15.gif 2KB
37.gif 1KB
68.gif 1KB
52.gif 777B
XiaoyuanmeishiController.java 9KB
ShangjiaController.java 9KB
YonghuController.java 9KB
CommonController.java 8KB
ChatController.java 7KB
ForumController.java 7KB
ZaixianxiadanController.java 7KB
DiscussxiaoyuanmeishiController.java 7KB
StoreupController.java 7KB
CaixileibieController.java 6KB
NewsController.java 6KB
ZaixianxiadanEntity.java 6KB
XiaoyuanmeishiEntity.java 5KB
共 397 条
- 1
- 2
- 3
- 4
资源评论
- 霜莹2023-12-13资源内容详细,总结地很全面,与描述的内容一致,对我启发很大,学习了。
- qq_340146082023-04-03资源中能够借鉴的内容很多,值得学习的地方也很多,大家一起进步!
- m0_581536202023-03-10发现一个宝藏资源,赶紧冲冲冲!支持大佬~
老帽爬新坡
- 粉丝: 79
- 资源: 2万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功