基于SpringBoot框架完成下列程序代码。实现点击超链接“删除订单”,发送请求,从数据库表order按Id删除对应订单信息的功能。 OrderList.html 文件信息如下: <div class="row" > <a th:href="@{'/delete/'+${orderId}}" > 删除订单 </a> </div> OrderController.java 文件信息如下: package order.controller; import … _______1______ public class OrderController { private OrderService orderService; @GetMapping("/__2__/{orderId}") public Order deleteOrder(@PathVariable("____3_____") Integer id) { Order order = orderService.deleteById(_______4_____); return order; } } OrderServiceImpl.java 文件信息如下: Package order.service.impl; import … ____5_____ public class OrderServiceImpl implements OrderService { ______6________ private OrderDao orderDao; @Override public Article deleteById(Integer orderId) { return______7____.deleteById(orderId); } } OrderDao.java 文件信息如下: package order.dao; import … ____8______ public interface OrderDao { Article deleteById(Integer orderId); } OrderMapper.xml 文件信息如下: <?xml version="1.0" encoding="UTF-8"?> <mapper namespace="____9_____"> <delete id="_____10_______" > delete from order where id = #{id} </select> </mapper>
时间: 2024-04-28 18:18:44 浏览: 143
package order.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import order.model.Order;
import order.service.OrderService;
@Controller
public class OrderController {
@Autowired
private OrderService orderService;
@GetMapping("/delete/{orderId}")
public Order deleteOrder(@PathVariable("orderId") Integer id) {
Order order = orderService.deleteById(id);
return order;
}
}
package order.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import order.dao.OrderDao;
import order.model.Order;
import order.service.OrderService;
@Service
public class OrderServiceImpl implements OrderService {
@Autowired
private OrderDao orderDao;
@Override
public Order deleteById(Integer orderId) {
return orderDao.deleteById(orderId);
}
}
package order.dao;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import order.model.Order;
@Mapper
public interface OrderDao {
@Delete("DELETE FROM order WHERE id = #{id}")
Order deleteById(@Param("id") Integer orderId);
}
阅读全文