基于是SSM Controller 的 “/** * 我的预约 */ @RequestMapping(value = "/myOrder") @ResponseBody public Object myOrder(DbOrder order) { HashMap<String, Object> result = new HashMap<>(); EntityWrapper<DbOrder> wrapper = new EntityWrapper<>(); wrapper.eq("username",order.getUsername()); List<DbOrder> orderList = dbOrderService.selectList(wrapper); for (DbOrder item:orderList){ //两个时间段具体的时差是否超时 if (item.getStatus()==0){ Boolean time=getDistanceTime(item.getCreateTime(),new Date()); if (time){ item.setStatus(2); dbOrderService.updateAllColumnById(item); } } } result.put("code", 200); result.put("list", orderList); return result; }”预约厨师 Controller “@RequestMapping(value = "/addOrder", method = RequestMethod.POST) public Object addDiy(DbOrder order) { HashMap<String, Object> result = new HashMap<>(); String chushi=order.getDesiger(); String time=order.getYtime(); //预约时间和当前时间判断 DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Date date = new Date(); String nowtime = sdf.format(date);//当前时间 try { if(sdf.parse(nowtime).getTime()>sdf.parse(time).getTime()){ System.out.println("时间错误"); result.put("message","时间不能大于当前"); result.put("code","1"); return result; } } catch (ParseException e) { e.printStackTrace(); } //预约时间是否被预约判断 Wrapper<DbOrder> wapper=new EntityWrapper<>(); wapper.eq("desiger",chushi); List<DbOrder> csorderlist=dbOrderService.selectList(wapper); for (DbOrder item:csorderlist){ if(item.getYtime().equals(order.getYtime())&&item.getShijian().equals(order.getShijian())){ System.out.println("时间已经被预约"); result.put("message","时间已经被预约"); result.put("code","1"); return result; } } dbOrderService.insert(order); return SUCCESS_TIP; }”判断预约时间是否被预约,的带代码的用户预约厨师流程的文字描述
时间: 2024-03-14 18:49:34 浏览: 19
这两个Controller是一个基于SSM框架开发的预约系统的一部分。第一个Controller是“我的预约”,用于查询当前用户的预约列表,并且对于已经过期的预约进行状态更新。第二个Controller是“预约厨师”,用于用户发起预约请求,其中会判断当前时间是否合法以及所选预约时间是否已经被其他用户预约。如果预约成功,会将预约信息插入数据库中。
具体流程如下:
1. 用户进入预约厨师页面,选择预约日期和时间段,填写其他预约信息。
2. 用户提交预约请求,请求会被发送到“预约厨师”Controller进行处理。
3. Controller会判断用户选择的预约时间是否合法,即不能早于当前时间。
4. Controller会查询数据库,判断所选预约时间是否已经被其他用户预约。
5. 如果预约时间已经被预约,将返回错误信息;如果预约时间可用,则将预约信息插入数据库中。
6. 用户可以通过“我的预约”页面查看自己的预约列表,系统会对已经过期的预约进行状态更新。
相关问题
package com.ssm.controller; import com.ssm.pojo.Record; import com.ssm.service.RecordService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.format.annotation.DateTimeFormat; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import java.util.Date; import java.util.List; @Controller public class recordController { @Autowired private RecordService recordService; @RequestMapping(value = "/toAllRecord",method = RequestMethod.GET) public String toAllRecord(){ return "allrecord"; } @RequestMapping(value = "/allrecord",method = RequestMethod.GET) public String getAllRecord(Model model){ List<Record> transactions = recordService.selectAll(); System.out.println(transactions); model.addAttribute("transactions", transactions); return "allrecord"; } @GetMapping("/recordByNum") public String getRecordByCardNum(@RequestParam("accountNumber") String accountNumber,Model model) { List<Record> transactions = recordService.selectRecordByAccountNumber(accountNumber); System.out.println(transactions); model.addAttribute("transactions", transactions); return "recordByNum"; } @RequestMapping(value = "/toRecordByNum",method = RequestMethod.GET) public String toRecordByNum(){ return "recordByNum"; } @RequestMapping(value = "/toIndex",method = RequestMethod.GET) public String toIndex(){ return "index"; } }
这是一个基于Spring框架的Java web应用的Controller类,用于处理与账户交易记录相关的HTTP请求。其中包括以下方法:
1. toAllRecord():处理访问“/toAllRecord”路径的GET请求,返回字符串“allrecord”,用于跳转到账户交易记录页面。
2. getAllRecord():处理访问“/allrecord”路径的GET请求,调用RecordService服务层的selectAll()方法获取所有的交易记录,将其存储在Model对象中,返回字符串“allrecord”,用于展示所有的账户交易记录。
3. getRecordByCardNum():处理访问“/recordByNum”路径的GET请求,通过@RequestParam注解获取请求中的accountNumber参数,调用RecordService服务层的selectRecordByAccountNumber()方法获取指定账户的交易记录,将其存储在Model对象中,返回字符串“recordByNum”,用于展示指定账户的所有交易记录。
4. toRecordByNum():处理访问“/toRecordByNum”路径的GET请求,返回字符串“recordByNum”,用于跳转到指定账户的交易记录页面。
5. toIndex():处理访问“/toIndex”路径的GET请求,返回字符串“index”,用于跳转到网站首页。
ssm中的@RequestMapping怎么使用和代码
@RequestMapping是Spring MVC框架中的注解,用于将HTTP请求映射到相应的处理方法上。它可以用在类级别和方法级别上。
在类级别上,@RequestMapping可以用来定义一个控制器类的根路径,表示该控制器下的所有请求都会被映射到该路径下。例如:
```java
@Controller
@RequestMapping("/user")
public class UserController {
// ...
}
```
上述代码中,UserController类被映射到了"/user"路径下,即所有以"/user"开头的请求都会交给该控制器处理。
在方法级别上,@RequestMapping可以用来定义具体的请求路径和请求方法。例如:
```java
@Controller
@RequestMapping("/user")
public class UserController {
@RequestMapping(value = "/login", method = RequestMethod.POST)
public String login() {
// 处理登录逻辑
return "success";
}
}
```
上述代码中,login()方法被映射到了"/user/login"路径下,并且只接受POST请求。当用户发送POST请求到"/user/login"时,该方法会被调用。
除了value和method属性外,@RequestMapping还支持其他属性,如params、headers等,用于进一步限制请求的条件。