目录
模仿天猫商城的J2EE商城网站项目后端4—util包https://blog.csdn.net/qq_37154145/article/details/122481793模仿天猫商城的J2EE商城网站项目后端6—dao包https://blog.csdn.net/qq_37154145/article/details/122478301User类不省略get、set方法,除此之后的所有实体类均省略。
User.java
package tmall.bean;
public class User {
private String password;
private String name;
private int id;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
Product.java
package tmall.bean;
import java.util.Date;
import java.util.List;
public class Product {
private int id;
private String name;
private String subTitle; // 标题
private float originalPrice; // 原价
private float promotePrice; // 促销价
private int stock; // 库存
private Date createDate;
private Category category;
private ProductImage firstProductImage; // 封面/第一张图片
private List<ProductImage> productImages; // 产品图片
private List<ProductImage> productSingleImages; // 展示图片
private List<ProductImage> productDetailImages; // 详情图片
private int reviewCount;
private int saleCount;
}
Category.java
package tmall.bean;
import java.util.List;
public class Category {
private int id;
private String name;
List<Product> products;
List<List<Product>> productsByRow; // 按行的product
@Override
public String toString() {
return "Category [name=" + name + "]";
}
}
productsByRow如下图所示,一个红圈内的商品为一行,每行为一个List<Product>,所有的List<Product>组成的List,就是productsByRow。接下来所有的XXByRow都是这个含义。
ProductImage.java
package tmall.bean;
public class ProductImage {
private int id;
private String type;
private Product product;
}
Property.java
package tmall.bean;
public class Property {
private int id;
private String name;
private Category category;
}
PropertyValue.java
package tmall.bean;
public class PropertyValue {
private int id;
private String value;
private Product product;
private Property property;
}
OrderItem.java
package tmall.bean;
/**
* 订单项
* 可以理解为天猫、淘宝加入购物车后的商品。(即在购物车里面了,但是还没有下单)
* @author LSB
*/
public class OrderItem {
private int id;
private int number;
private Product product;
private Order order;
private User user;
}
Order.java
package tmall.bean;
import tmall.dao.OrderDAO;
import java.util.Date;
import java.util.List;
public class Order {
private int id;
private String orderCode;
private String address;
private String post;
private String receiver;
private String mobile;
private String userMessage; // 用户消息/买家备注
private Date createDate;
private Date payDate;
private Date deliveryDate; // 发货日期
private Date confirmDate; // 确认收货日期
private User user;
private List<OrderItem> orderItems;
private float total; // 订单总价
private int totalNumber; // 商品总件数
private String status; // 订单状态(已发货、待发货、已支付、待支付这种)
// 获取订单的状态描述(已发货、待发货、已支付、待支付这种)
public String getStatusDesc() {
String desc = "未知";
switch (status) {
case OrderDAO.waitPay:
desc = "待付款";
break;
case OrderDAO.waitDelivery:
desc = "待发货";
break;
case OrderDAO.waitConfirm:
desc = "待收货";
break;
case OrderDAO.waitReview:
desc = "等评价";
break;
case OrderDAO.finish:
desc = "完成";
break;
case OrderDAO.delete:
desc = "刪除";
break;
default:
desc = "未知";
}
return desc;
}
}
Review.java
package tmall.bean;
import java.util.Date;
public class Review {
private int id;
private String content; // 评价内容
private Date createDate;
private User user;
private Product product;
}