订单查询
订单查询页面 order-list.jsp
Controller
@Controller
@RequestMapping("/orders")
public class OrdersController {
@Autowired
private IOrdersService ordersService;
//未分页
@RequestMapping("/findAll.do")
public ModelAndView findAll(@RequestParam(name = "page", required = true, defaultValue=
"1") Integer page, @RequestParam(name = "pageSize", required = true, defaultValue =
"10")
Integer pageSize) throws Exception {
List<Orders> ordersList = ordersService.findAllByPage(page, pageSize);
ModelAndView mv = new ModelAndView();
mv.setViewName("order-list");
mv.addObject("ordersList", ordersList);
return mv;
}
}
Dao
IOrdersDao
public interface IOrdersDao {
@Select("select * from orders")
@Results({
@Result(id=true,column = "id",property = "id"),
@Result(column = "orderNum",property = "orderNum"),
@Result(column = "orderTime",property = "orderTime"),
@Result(column = "orderStatus",property = "orderStatus"),
@Result(column = "peopleCount",property = "peopleCount"),
@Result(column = "payType",property = "payType"),
@Result(column = "orderDesc",property = "orderDesc"),
@Result(column = "productId",property = "product",one = @One(select =
"com.learn.ssm.dao.IProductDao.findById"))
})
List<Orders> findAll() throws Exception;
}
IProductDao的findById
@Select("select * from product where id=#{id}")
Product findById(String id) throws Exception;