SSM项目之商铺系统-实体类的创建(一)

今天是第一天

我们需要准备所需要操作的实体类,我们来看看我们需要哪些实体类?

SSM项目之商铺系统-实体类的创建(一)_第1张图片

o2o就是我们的商铺系统

我们看下我创建的实体类:

区域类:店铺所属的区域详情都在这个类里面:

package storepro.entity;

import java.util.Date;

public class Area {//区域类型,比如那些商铺在哪些区域等
    //使用包装类型是因为基础类型会默认赋值。影响操作
    //ID
    private Integer areaId;
    //名称
    private String areaName;
    //权重
    private Integer priority;
    //创建时间
    private Date createTime;
    //更新时间
    private Date lastEditTime;

    public Integer getAreaId() {
        return areaId;
    }

    public void setAreaId(Integer areaId) {
        this.areaId = areaId;
    }

    public String getAreaName() {
        return areaName;
    }

    public void setAreaName(String areaName) {
        this.areaName = areaName;
    }

    public Integer getPriority() {
        return priority;
    }

    public void setPriority(Integer priority) {
        this.priority = priority;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getLastEditTime() {
        return lastEditTime;
    }

    public void setLastEditTime(Date lastEditTime) {
        this.lastEditTime = lastEditTime;
    }
}

t头条类:每次打开商铺,都会有轮播图推荐头条内容。头条的内容就是通过这个类完善

package storepro.entity;

import java.util.Date;

public class HeadLine {//头条类
    private Long lineId;//头条id
    private String lineName;//头条名称
    private String lineLink;//头条链接(点一下链接到哪里)
    private String lineImg;//头条图片
    private Integer priority;//权重(决定先显示那些头条)
    private Integer enableStatus;//头条是否可用0不可用,1可用
    private Date createTime;//创建时间
    private Date lastEditTime;//最后修改时间

    public Long getLineId() {
        return lineId;
    }

    public void setLineId(Long lineId) {
        this.lineId = lineId;
    }

    public String getLineName() {
        return lineName;
    }

    public void setLineName(String lineName) {
        this.lineName = lineName;
    }

    public String getLineLink() {
        return lineLink;
    }

    public void setLineLink(String lineLink) {
        this.lineLink = lineLink;
    }

    public String getLineImg() {
        return lineImg;
    }

    public void setLineImg(String lineImg) {
        this.lineImg = lineImg;
    }

    public Integer getPriority() {
        return priority;
    }

    public void setPriority(Integer priority) {
        this.priority = priority;
    }

    public Integer getEnableStatus() {
        return enableStatus;
    }

    public void setEnableStatus(Integer enableStatus) {
        this.enableStatus = enableStatus;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getLastEditTime() {
        return lastEditTime;
    }

    public void setLastEditTime(Date lastEditTime) {
        this.lastEditTime = lastEditTime;
    }
}

因为我们的系统实现了微信登录和本系统账户登录,那么我们需要两个类,一个存储本地信息账号,还有一个存储微信信息账号

本地账号类:完成本地注册的账号信息类

package storepro.entity;

import java.util.Date;

public class LocalAuth {//本地账号类
    //本地账号的id
    private Long localAuthId;
    //用户名
    private String userName;
    //密码
    private String password;
    //创建时间
    private Date createTime;
    //更新时间
    private Date lastEditTime;
    //用户信息
    private PersonInfo personInfo;

    public Long getLocalAuthId() {
        return localAuthId;
    }

    public void setLocalAuthId(Long localAuthId) {
        this.localAuthId = localAuthId;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getLastEditTime() {
        return lastEditTime;
    }

    public void setLastEditTime(Date lastEditTime) {
        this.lastEditTime = lastEditTime;
    }

    public PersonInfo getPersonInfo() {
        return personInfo;
    }

    public void setPersonInfo(PersonInfo personInfo) {
        this.personInfo = personInfo;
    }
}

微信账号类:通过微信账号登录,这个类还要包含和本地账号的关联

package storepro.entity;

import java.util.Date;

public class WechatAuth {//微信账号类
    //微信账号的id
    private Long wechatAuthId;
    //微信账号和项目账号绑定的标识,就是用户的id
    private String openId;
    //创建时间
    private Date createTime;
    //用户信息
    private PersonInfo personInfo;

    public Long getWechatAuthId() {
        return wechatAuthId;
    }

    public void setWechatAuthId(Long wechatAuthId) {
        this.wechatAuthId = wechatAuthId;
    }

    public String getOpenId() {
        return openId;
    }

    public void setOpenId(String openId) {
        this.openId = openId;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public PersonInfo getPersonInfo() {
        return personInfo;
    }

    public void setPersonInfo(PersonInfo personInfo) {
        this.personInfo = personInfo;
    }
}

个人信息类:用户信息通过这个类存储。

package storepro.entity;

import java.util.Date;

public class WechatAuth {//微信账号类
    //微信账号的id
    private Long wechatAuthId;
    //微信账号和项目账号绑定的标识
    private String openId;
    //创建时间
    private Date createTime;
    //用户信息
    private PersonInfo personInfo;

    public Long getWechatAuthId() {
        return wechatAuthId;
    }

    public void setWechatAuthId(Long wechatAuthId) {
        this.wechatAuthId = wechatAuthId;
    }

    public String getOpenId() {
        return openId;
    }

    public void setOpenId(String openId) {
        this.openId = openId;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public PersonInfo getPersonInfo() {
        return personInfo;
    }

    public void setPersonInfo(PersonInfo personInfo) {
        this.personInfo = personInfo;
    }
}

商品类别类:通过这个类完成对商品进行分类

package storepro.entity;

import java.util.Date;

public class ProductCategory {//商品类别类
    private Long productCategoryId; //商品类别id
    private Long shopId;//商铺id,判断这个商品类别是哪个商铺品下的类别
    private String productCategoryName;//商品类别名称
    private Integer priority;//权重
    private Date createTime;

    public Long getProductCategoryId() {
        return productCategoryId;
    }

    public void setProductCategoryId(Long productCategoryId) {
        this.productCategoryId = productCategoryId;
    }

    public Long getShopId() {
        return shopId;
    }

    public void setShopId(Long shopId) {
        this.shopId = shopId;
    }

    public String getProductCategoryName() {
        return productCategoryName;
    }

    public void setProductCategoryName(String productCategoryName) {
        this.productCategoryName = productCategoryName;
    }

    public Integer getPriority() {
        return priority;
    }

    public void setPriority(Integer priority) {
        this.priority = priority;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

商品图片:商品的图片描述存储在这里。

package storepro.entity;

import java.util.Date;

public class ProductCategory {//商品类别类
    private Long productCategoryId; //商品类别id
    private Long shopId;//商铺id,判断这个商品类别是哪个商品下的类别
    private String productCategoryName;//商品类别名称
    private Integer priority;//权重
    private Date createTime;

    public Long getProductCategoryId() {
        return productCategoryId;
    }

    public void setProductCategoryId(Long productCategoryId) {
        this.productCategoryId = productCategoryId;
    }

    public Long getShopId() {
        return shopId;
    }

    public void setShopId(Long shopId) {
        this.shopId = shopId;
    }

    public String getProductCategoryName() {
        return productCategoryName;
    }

    public void setProductCategoryName(String productCategoryName) {
        this.productCategoryName = productCategoryName;
    }

    public Integer getPriority() {
        return priority;
    }

    public void setPriority(Integer priority) {
        this.priority = priority;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

商品类:商品的具体信息全部存储在里面。

package storepro.entity;

import java.util.Date;
import java.util.List;

public class Product {//商品类
    private Long productId;//商品id
    private String productName;//商品姓名
    private String productDesc;//商品描述
    private String imgAddr;//地址简略图
    private String normalPrice;//原价
    private String promotionPrice;//折扣价
    private Integer priority;//权重
    private Date createTime;//创建时间
    private Date lastEditTime;//最后修改时间
    //商品状态
    //0:下架 1:在售
    private Integer enableStatus;
    private List productImgList;//商品图片列表
    private ProductCategory productCategory;//商品类别
    private Shop shop;//商品属于哪个店铺

    public Long getProductId() {
        return productId;
    }

    public void setProductId(Long productId) {
        this.productId = productId;
    }

    public String getProductName() {
        return productName;
    }

    public void setProductName(String productName) {
        this.productName = productName;
    }

    public String getProductDesc() {
        return productDesc;
    }

    public void setProductDesc(String productDesc) {
        this.productDesc = productDesc;
    }

    public String getImgAddr() {
        return imgAddr;
    }

    public void setImgAddr(String imgAddr) {
        this.imgAddr = imgAddr;
    }

    public String getNormalPrice() {
        return normalPrice;
    }

    public void setNormalPrice(String normalPrice) {
        this.normalPrice = normalPrice;
    }

    public String getPromotionPrice() {
        return promotionPrice;
    }

    public void setPromotionPrice(String promotionPrice) {
        this.promotionPrice = promotionPrice;
    }

    public Integer getPriority() {
        return priority;
    }

    public void setPriority(Integer priority) {
        this.priority = priority;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getLastEditTime() {
        return lastEditTime;
    }

    public void setLastEditTime(Date lastEditTime) {
        this.lastEditTime = lastEditTime;
    }

    public Integer getEnableStatus() {
        return enableStatus;
    }

    public void setEnableStatus(Integer enableStatus) {
        this.enableStatus = enableStatus;
    }

    public List getProductImgList() {
        return productImgList;
    }

    public void setProductImgList(List productImgList) {
        this.productImgList = productImgList;
    }

    public ProductCategory getProductCategory() {
        return productCategory;
    }

    public void setProductCategory(ProductCategory productCategory) {
        this.productCategory = productCategory;
    }

    public Shop getShop() {
        return shop;
    }

    public void setShop(Shop shop) {
        this.shop = shop;
    }
}

店铺类别类:通过这个类来区分店铺的类别,parent意思是如果你是奶茶店那么你的父类别就是饮品店,当你的父类别为空那么当前类别就是父类别 

package storepro.entity;

import java.util.Date;

public class ShopCategory {//店铺类别
    private Long shopCategoryId;//店铺id
    private String shopCategoryName;//店铺名称
    private String shopCategoryDesc;//店铺描述
    private String shopCategoryImg;//店铺图片
    private Integer priority;//权重
    private Date createTime;
    private Date lastEditTime;
    private ShopCategory parent;//父类别

    public Long getShopCategoryId() {
        return shopCategoryId;
    }

    public void setShopCategoryId(Long shopCategoryId) {
        this.shopCategoryId = shopCategoryId;
    }

    public String getShopCategoryName() {
        return shopCategoryName;
    }

    public void setShopCategoryName(String shopCategoryName) {
        this.shopCategoryName = shopCategoryName;
    }

    public String getShopCategoryDesc() {
        return shopCategoryDesc;
    }

    public void setShopCategoryDesc(String shopCategoryDesc) {
        this.shopCategoryDesc = shopCategoryDesc;
    }

    public String getShopCategoryImg() {
        return shopCategoryImg;
    }

    public void setShopCategoryImg(String shopCategoryImg) {
        this.shopCategoryImg = shopCategoryImg;
    }

    public Integer getPriority() {
        return priority;
    }

    public void setPriority(Integer priority) {
        this.priority = priority;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getLastEditTime() {
        return lastEditTime;
    }

    public void setLastEditTime(Date lastEditTime) {
        this.lastEditTime = lastEditTime;
    }

    public ShopCategory getParent() {
        return parent;
    }

    public void setParent(ShopCategory parent) {
        this.parent = parent;
    }
}

店铺类:店铺的基本信息都存储在内。

package storepro.entity;

import java.util.Date;

public class Shop {//商铺
    private Long shopId;//商铺id
    private String shopName;
    private String shopDesc;//商铺描述
    private String shopAddr;//商铺地址
    private String phone;//联系方式
    private String shopImg;
    private Integer priority;
    private Date createTime;
    private Date lastEditTime;
    //商铺状态
    //-1:不可用 0:审核中 1:可用
    private Integer enableStatus;
    //管理员给商铺的建议
    private Integer advice;
    //商铺地区
    private Area area;
    //商铺拥有者
    private PersonInfo owner;
    //商铺类别
    private ShopCategory shopCategory;

    public Long getShopId() {
        return shopId;
    }

    public void setShopId(Long shopId) {
        this.shopId = shopId;
    }

    public String getShopName() {
        return shopName;
    }

    public void setShopName(String shopName) {
        this.shopName = shopName;
    }

    public String getShopDesc() {
        return shopDesc;
    }

    public void setShopDesc(String shopDesc) {
        this.shopDesc = shopDesc;
    }

    public String getShopAddr() {
        return shopAddr;
    }

    public void setShopAddr(String shopAddr) {
        this.shopAddr = shopAddr;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getShopImg() {
        return shopImg;
    }

    public void setShopImg(String shopImg) {
        this.shopImg = shopImg;
    }

    public Integer getPriority() {
        return priority;
    }

    public void setPriority(Integer priority) {
        this.priority = priority;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getLastEditTime() {
        return lastEditTime;
    }

    public void setLastEditTime(Date lastEditTime) {
        this.lastEditTime = lastEditTime;
    }

    public Integer getEnableStatus() {
        return enableStatus;
    }

    public void setEnableStatus(Integer enableStatus) {
        this.enableStatus = enableStatus;
    }

    public Integer getAdvice() {
        return advice;
    }

    public void setAdvice(Integer advice) {
        this.advice = advice;
    }

    public Area getArea() {
        return area;
    }

    public void setArea(Area area) {
        this.area = area;
    }

    public PersonInfo getOwner() {
        return owner;
    }

    public void setOwner(PersonInfo owner) {
        this.owner = owner;
    }

    public ShopCategory getShopCategory() {
        return shopCategory;
    }

    public void setShopCategory(ShopCategory shopCategory) {
        this.shopCategory = shopCategory;
    }
}

我们来看下他们是通过什么联系起来里的。

微信账号和本地账号通过用户id联系在一起。我们在sql表中也设了外键约束,如果两个账号指向同一个信息则证明是同一个账号,而mysql中不能传入对象,我们在数据库中通过两表的用户id字段来判断是否为同一个账户

SSM项目之商铺系统-实体类的创建(一)_第2张图片

店铺信息和这些信息关联起来:

店铺类别:通过店铺信息类private ShopCategory shopCategory的字段来链接

区域信息:private Area are通过店铺信息类中区域字段来辨别店铺的区域信息。

商品信息:通过商品信息类中的private Shop shop;中的字段来确定是哪个店铺的

商品类别:通过商品类别类中的private Long shopId;字段来确定商品类别是哪个商铺的

SSM项目之商铺系统-实体类的创建(一)_第3张图片

商品信息的相关联。

商品类别:通过商品信息类中的private ProductCategory productCategory;来确定商品的类别

详情图片:通过商品图片类中的private Long productId;来确定图片是哪个商品的图片

SSM项目之商铺系统-实体类的创建(一)_第4张图片

你可能感兴趣的:(SSM项目之商铺系统-实体类的创建(一))