package com.example.controller;
import com.alibaba.fastjson.JSON;
import com.example.mapper.BathMapper;
import com.example.mapper.MyLogMapper;
import com.example.pojo.Bath;
import com.example.pojo.MyLog;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.core.MessageDeliveryMode;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
@RestController
@RequestMapping("bath")
public class BathController extends BaseController{
@Autowired
private BathMapper bathMapper;
@Autowired
private MyLogMapper logMapper;
@Autowired
private RabbitTemplate rabbitTemplate;
@Value("${sunspring.order.exchange}")
private String orderExchange;
@Value("${sunspring.order.queue}")
private String orderQueue;
@Value("${sunspring.order.routingKey}")
private String orderRoutingKey;
@RequestMapping("add")
@Transactional
public Object add(HttpServletRequest request){
Map<String, Object> map = getParameterMap(request);
Bath bath = new Bath();
bath.setOpenId(String.valueOf(map.get("openId")));
bath.setStatus("使用中");
int role = bathMapper.selectByPrimaryKey(bath);
if (role>0) {
return 1;
}
map.put("date", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
bathMapper.insertSelective(map);
return 0;
}
@RequestMapping("sel")
public Object sel(HttpServletRequest request){
Map<String, Object> map = getParameterMap(request);
map.put("status","使用中");
return bathMapper.sel(map);
}
@RequestMapping("getList")
public Object getList(HttpServletRequest request){
Map<String, Object> map = getParameterMap(request);
return bathMapper.getList(map);
}
@RequestMapping("edit")
public Object edit(HttpServletRequest request){
Map<String, Object> map = getParameterMap(request);
return bathMapper.edit(map);
}
@RequestMapping("authority")
public Object authority(HttpServletRequest request) throws ParseException {
Map<String, Object> map = getParameterMap(request);
Bath bath = bathMapper.sel(map);
if (null != bath){
if (!bath.getOpenId().equals(map.get("openId"))){
long time = getTime(bath.getDate(), new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
if (40*1000*60<time){
return 1;
}
}
}
return 0;
}
// 获取两个时间相差分钟数
public static long getTime(String oldTime,String newTime) throws ParseException {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
long NTime =df.parse(newTime).getTime();
//从对象中拿到时间
long OTime = df.parse(oldTime).getTime();
long diff=(NTime-OTime);
return diff;
}
@RequestMapping("reservation")
public Object reservation(HttpServletRequest request){
Map<String, Object> map = getParameterMap(request);
String orderNo = generateWord();
map.put("orderNo",orderNo);
map.put("status","预约");
Map map1 = new HashMap();
map1.put("openId",map.get("openId"));
map1.put("status","预约");
Bath bath = bathMapper.sel(map1);
if (bath != null){
return 1;
}
Map map2 = new HashMap();
map2.put("openId",map.get("openId"));
map2.put("status","使用中");
Bath bath1 = bathMapper.sel(map2);
if (bath1 != null){
return 2;
}
bathMapper.insertSelective(map);
return 0;
}
private String generateWord() {
String[] beforeShuffle = new String[] { "2", "3", "4", "5", "6", "7",
"8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
"K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V",
"W", "X", "Y", "Z" };
List list = Arrays.asList(beforeShuffle);
Collections.shuffle(list);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < list.size(); i++) {
sb.append(list.get(i));
}
String afterShuffle = sb.toString();
String result = afterShuffle.substring(5, 9);
return result;
}
@RequestMapping("queue")
public Object queue(HttpServletRequest request){
Map<String, Object> map = getParameterMap(request);
Bath bath = bathMapper.selectMap(map);
if (null!=bath) {
bathMapper.deleteByPrimaryKey(bath.getId());
MyLog log = new MyLog();
log.setOrderNo(bath.getOrderNo());
log.setStatus(bath.getStatus());
log.setTypesId(bath.getTypesId());
log.setType(bath.getType());
rabbitTemplate.setExchange("basic.exchange.name");
rabbitTemplate.setRoutingKey("basic.routing.key.name");
rabbitTemplate.convertAndSend("basic.exchange.name","basic.routing.key.name",JSON.toJSONString(log));
logMapper.insertSelective(log);
}
return 0;
}
@RequestMapping("queue1")
public Object queue1(HttpServletRequest request){
Map<String, Object> map = getParameterMap(request);
Bath bath = bathMapper.selectMap(map);
if (null!=bath) {
bathMapper.deleteByPrimaryKey(bath.getId());
MyLog log = new MyLog();
log.setOrderNo(bath.getOrderNo());
log.setStatus(bath.getStatus());
log.setTypesId(bath.getTypesId());
log.setType(bath.getType());
logMapper.del(log);
}
return 0;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
校园洗澡排号小程序+后台.zip
共1137个文件
gif:300个
js:179个
xml:129个
需积分: 50 11 下载量 47 浏览量
2020-12-11
12:45:03
上传
评论 3
收藏 98.06MB ZIP 举报
温馨提示
校园洗澡排号小程序+后台.zip
资源详情
资源评论
资源推荐
收起资源包目录
校园洗澡排号小程序+后台.zip (1137个子文件)
$PROJECT_FILE$ 364B
BathController.class 7KB
BathController.class 7KB
UserController.class 4KB
UserController.class 4KB
HttpUtil.class 3KB
HttpUtil.class 3KB
BaseController.class 3KB
BaseController.class 3KB
TypesController.class 3KB
TypesController.class 3KB
RabbitmqListener.class 3KB
RabbitConfig.class 3KB
RabbitConfig.class 3KB
RabbitmqListener.class 2KB
AesCbcUtil.class 2KB
AesCbcUtil.class 2KB
User.class 2KB
User.class 2KB
Bath.class 2KB
Bath.class 2KB
Types.class 2KB
Types.class 2KB
AdminController.class 2KB
AdminController.class 2KB
MyLog.class 1KB
MyLog.class 1KB
Admin.class 1KB
Admin.class 1KB
BathMapper.class 845B
BathMapper.class 845B
LogController.class 816B
LogController.class 816B
DemoApplication.class 809B
DemoApplication.class 809B
UserMapper.class 734B
UserMapper.class 734B
MyLogMapper.class 620B
MyLogMapper.class 620B
DemoApplicationTests.class 521B
TypesMapper.class 521B
TypesMapper.class 521B
AdminMapper.class 505B
AdminMapper.class 505B
WxUtil.class 460B
WxUtil.class 460B
Config.class 370B
mvnw.cmd 6KB
layui.css 73KB
layui.css 73KB
layui.css 68KB
layui.css 68KB
layer.css 14KB
layer.css 14KB
layer.css 14KB
layer.css 14KB
style.css 11KB
style.css 11KB
layui.mobile.css 10KB
layui.mobile.css 10KB
layui.mobile.css 10KB
layui.mobile.css 10KB
laydate.css 7KB
laydate.css 7KB
laydate.css 7KB
laydate.css 7KB
style.css 4KB
style.css 4KB
reset.css 1KB
reset.css 1KB
code.css 1KB
code.css 1KB
code.css 1KB
code.css 1KB
iconfont.eot 46KB
iconfont.eot 46KB
iconfont.eot 40KB
iconfont.eot 40KB
59.gif 10KB
59.gif 10KB
59.gif 10KB
59.gif 10KB
22.gif 10KB
22.gif 10KB
22.gif 10KB
22.gif 10KB
24.gif 8KB
24.gif 8KB
24.gif 8KB
24.gif 8KB
13.gif 7KB
13.gif 7KB
13.gif 7KB
13.gif 7KB
16.gif 7KB
16.gif 7KB
16.gif 7KB
16.gif 7KB
39.gif 6KB
39.gif 6KB
共 1137 条
- 1
- 2
- 3
- 4
- 5
- 6
- 12
最清晰的脚印
- 粉丝: 59
- 资源: 103
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0