列表
ID | 订单编号 | 产品名称 | 金额 | 下单时间 | 订单状态 | 操作 | |
---|---|---|---|---|---|---|---|
${orders.id } | ${orders.orderNum } | ${orders.product.productName } | ${orders.product.productPrice } | ${orders.orderTimeStr } | ${orders.orderStatusStr } |
订单查询流程
order-list.jsp界面
创建实体类
package com.itheima.ssm.domain;
import com.itheima.ssm.utils.DateUtils;
import java.util.Date;
import java.util.List;
//订单
public class Orders {
private String id;
private String orderNum;
private Date orderTime;
private String orderTimeStr;
private int orderStatus;
private String orderStatusStr;
private int peopleCount;
private Product product;
private List travellers;
private Member member;
private Integer payType;
private String payTypeStr;
private String orderDesc;
public String getOrderStatusStr() {
//订单状态(0 未支付 1 已支付)
if(orderStatus==0){
orderStatusStr="未支付";
}else if(orderStatus==1){
orderStatusStr="已支付";
}
return orderStatusStr;
}
public void setOrderStatusStr(String orderStatusStr) {
this.orderStatusStr = orderStatusStr;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getOrderNum() {
return orderNum;
}
public void setOrderNum(String orderNum) {
this.orderNum = orderNum;
}
public Date getOrderTime() {
return orderTime;
}
public void setOrderTime(Date orderTime) {
this.orderTime = orderTime;
}
public String getOrderTimeStr() {
if(orderTime!=null){
orderTimeStr= DateUtils.date2String(orderTime,"yyyy-MM-dd HH:mm");
}
return orderTimeStr;
}
public void setOrderTimeStr(String orderTimeStr) {
this.orderTimeStr = orderTimeStr;
}
public int getOrderStatus() {
return orderStatus;
}
public void setOrderStatus(int orderStatus) {
this.orderStatus = orderStatus;
}
public int getPeopleCount() {
return peopleCount;
}
public void setPeopleCount(int peopleCount) {
this.peopleCount = peopleCount;
}
public Product getProduct() {
return product;
}
public void setProduct(Product product) {
this.product = product;
}
public List getTravellers() {
return travellers;
}
public void setTravellers(List travellers) {
this.travellers = travellers;
}
public Member getMember() {
return member;
}
public void setMember(Member member) {
this.member = member;
}
public Integer getPayType() {
return payType;
}
public void setPayType(Integer payType) {
this.payType = payType;
}
public String getPayTypeStr() {
//支付方式(0 支付宝 1 微信 2其它)
if(payType==0){
payTypeStr="支付宝";
}else if(payType==1){
payTypeStr="微信";
}else if(payType==2){
payTypeStr="其它";
}
return payTypeStr;
}
public void setPayTypeStr(String payTypeStr) {
this.payTypeStr = payTypeStr;
}
public String getOrderDesc() {
return orderDesc;
}
public void setOrderDesc(String orderDesc) {
this.orderDesc = orderDesc;
}
}
package com.itheima.ssm.domain;
//旅客
public class Traveller {
private String id;
private String name;
private String sex;
private String phoneNum;
private Integer credentialsType; //证件类型 0身份证 1护照 2军官证
private String credentialsTypeStr;
private String credentialsNum;
private Integer travellerType; //旅客类型(人群) 0 成人 1 儿童
private String travellerTypeStr;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getPhoneNum() {
return phoneNum;
}
public void setPhoneNum(String phoneNum) {
this.phoneNum = phoneNum;
}
public Integer getCredentialsType() {
return credentialsType;
}
public void setCredentialsType(Integer credentialsType) {
this.credentialsType = credentialsType;
}
public String getCredentialsTypeStr() {
//证件类型 0身份证 1护照 2军官证
if (credentialsType != null) {
if (credentialsType == 0) {
credentialsTypeStr = "身份证";
} else if (credentialsType == 1) {
credentialsTypeStr = "护照";
} else if (credentialsType == 2) {
credentialsTypeStr = "军官证";
}
}
return credentialsTypeStr;
}
public void setCredentialsTypeStr(String credentialsTypeStr) {
this.credentialsTypeStr = credentialsTypeStr;
}
public String getCredentialsNum() {
return credentialsNum;
}
public void setCredentialsNum(String credentialsNum) {
this.credentialsNum = credentialsNum;
}
public Integer getTravellerType() {
return travellerType;
}
public void setTravellerType(Integer travellerType) {
this.travellerType = travellerType;
}
public String getTravellerTypeStr() {
旅客类型(人群) 0 成人 1 儿童
if (travellerType != null) {
if (travellerType == 0) {
travellerTypeStr = "成人";
} else if (travellerType == 1) {
travellerTypeStr = "儿童";
}
}
return travellerTypeStr;
}
public void setTravellerTypeStr(String travellerTypeStr) {
this.travellerTypeStr = travellerTypeStr;
}
}
package com.itheima.ssm.domain;
//会员
public class Member {
private String id;
private String name;
private String nickname;
private String phoneNum;
private String email;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public String getPhoneNum() {
return phoneNum;
}
public void setPhoneNum(String phoneNum) {
this.phoneNum = phoneNum;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
}
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@taglib prefix="security" uri="http://www.springframework.org/security/tags" %>
订单管理
import java.util.List;
@Controller
@RequestMapping("/orders")
public class OrdersController {
@Autowired
private IOrdersService ordersService;
//查询全部不分页
@RequestMapping("/findAll.do")
public ModelAndView findAll() throws Exception {
ModelAndView mv=new ModelAndView();
List ordersList = ordersService.findAll();
mv.addObject("ordersList",ordersList);
mv.setViewName("orders-list");
return mv;
}
package com.itheima.ssm.service.impl;
import com.itheima.ssm.dao.IOrdersDao;
import com.itheima.ssm.domain.Orders;
import com.itheima.ssm.service.IOrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
@Transactional
public class OrdersServiceImpl implements IOrdersService {
@Autowired
private IOrdersDao ordersDao;
@Override
public List findAll() throws Exception{
return ordersDao.findAll();
}
}
package com.itheima.ssm.dao;
import com.itheima.ssm.domain.Orders;
import com.itheima.ssm.domain.Product;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import java.util.List;
public interface IOrdersDao {
@Select("select * from orders")
@Results({
@Result(id=true,property = "id",column = "id"),
@Result(property = "orderNum",column = "orderNum"),
@Result(property = "orderTime",column = "orderTime"),
@Result(property = "orderStatus",column = "orderStatus"),
@Result(property = "peopleCount",column = "peopleCount"),
@Result(property = "peopleCount",column = "peopleCount"),
@Result(property = "payType",column = "payType"),
@Result(property = "orderDesc",column = "orderDesc"),
@Result(property = "product",column = "productId",javaType = Product.class,one = @One(select = "com.itheima.ssm.dao.IProductDao.findById")),
})
public List findAll() throws Exception;
}
//根据id查询产品
@Select("select * from product where id=#{id}")
public Product findById(String id) throws Exception;
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
数据 - AdminLTE2定制版
src="${pageContext.request.contextPath}/${pageContext.request.contextPath}/${pageContext.request.contextPath}/plugins/timepicker/bootstrap-timepicker.min.js">-->
数据管理 数据列表
列表
ID
订单编号
产品名称
金额
下单时间
订单状态
操作
${orders.id }
${orders.orderNum }
${orders.product.productName }
${orders.product.productPrice }
${orders.orderTimeStr }
${orders.orderStatusStr }