SSM到Spring Boot-從零開發校園商鋪平臺一(實體類設計與表的創建)

系統功能模塊劃分

實體類設計與表的創建

區域實體類與數據表

package com.imooc.o2o.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;
    }
}

創建數據表

create table tb_area(
    area_id int(2) NOT NULL AUTO_INCREMENT,
    area_name varchar(200) NOT NULL,
    priority int(2) NOT NULL DEFAULT '0',
    create_time datetime DEFAULT NULL,
    last_edit_time datetime DEFAULT NULL,
    primary key(area_id),
    unique key UK_AREA(area_name)
    )ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

 

用戶實體類與數據表

PersonInfo

package com.imooc.o2o.entity;

import java.util.Date;

public class PersonInfo {

    private Long userId;
    private String name;
    private String profileImg;
    private String email;
    private String gender;
    private Integer enableStatus;
    //1.顧客 2.店家 3.超級管理員
    private Integer userType;
    private Date createTime;
    private Date lastEditTime;
    public Long getUserId() {
        return userId;
    }
    public void setUserId(Long userId) {
        this.userId = userId;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getProfileImg() {
        return profileImg;
    }
    public void setProfileImg(String profileImg) {
        this.profileImg = profileImg;
    }
    public String getEmail() {
        return email;
    }
    public void setEmail(String email) {
        this.email = email;
    }
    public String getGender() {
        return gender;
    }
    public void setGender(String gender) {
        this.gender = gender;
    }
    public Integer getEnableStatus() {
        return enableStatus;
    }
    public void setEnableStatus(Integer enableStatus) {
        this.enableStatus = enableStatus;
    }
    public Integer getUserType() {
        return userType;
    }
    public void setUserType(Integer userType) {
        this.userType = userType;
    }
    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;
    }

}

創建對應的 ta_person_info表

 create table tb_person_info(
 user_id int(10) NOT NULL AUTO_INCREMENT,
 name varchar(32) DEFAULT NULL,
 profile_img varchar(1024) DEFAULT NULL,
 email varchar(1024) DEFAULT NULL,
 gender varchar(2) DEFAULT NULL,
 enable_status int(2) NOT NULL DEFAULT 0 COMMENT '0:禁止使用本商城,1:  許使用本商場',
 user_type int(2) NOT NULL DEFAULT 1 COMMENT '1.顧客,2:店家,3:超級管理員',
 create_time datetime DEFAULT NULL,
 last_edit_time datetime DEFAULT NULL,
 primary key (user_id)
 )ENGINE=InnoDB AUTO_INCREMENT 1 DEFAULT CHARSET=utf8;

微信賬號和本地賬號實體類與數據表

在com.imooc.o2o.entity包下新建WechatAuth.java類

package com.imooc.o2o.entity;

import java.util.Date;

public class WechatAuth {

    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;
    }
}

在com.imooc.o2o.entity包下新建LocalAuth.java類 

package com.imooc.o2o.entity;

import java.util.Date;

public class LocalAuth {

    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;
    }

}

創建對應的數據表

create table tb_wechat_auth(
  wechat_auth_id int(10) NOT NULL AUTO_INCREMENT,
  user_id int(10) NOT NULL,
  open_id varchar(1024) NOT NULL,
  create_time datetime DEFAULT NULL,
  primary key(wechat_auth_id),
  constraint fk_wechatauth_profile foreign key(user_id) references tb_person_info(user_id)
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

create table tb_local_auth(
  local_auth_id int(10) NOT NULL AUTO_INCREMENT,
  user_id int(10) NOT NULL,
  username varchar(128) NOT NULL,
  password varchar(128) NOT NULL,
  create_time datetime DEFAULT NULL,
  last_edit_time datetime DEFAULT NULL,
  PRIMARY KEY(local_auth_id),
  UNIQUE KEY uk_local_profile(username),
  constraint fk_localauth_profile foreign key(user_id) references tb_person_info(user_id)
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

 忘記給open_id添加唯一索引,添加上去

alter table tb_wechat_auth add unique index(open_id);

 

頭條實體類與數據表

創建對應的數據表

CREATE TABLE tb_head_line(
  line_id int(100) NOT NULL AUTO_INCREMENT,
  line_name varchar(1000) DEFAULT NULL,
  line_link varchar(2000) NOT NULL,
  line_img varchar(2000) NOT NULL,
  priority int(2) DEFAULT NULL,
  enable_status int(2) NOT NULL DEFAULT 0,
  create_time datetime DEFAULT NULL,
  last_edit_time datetime DEFAULT NULL,
  PRIMARY KEY(line_id)
)ENGINE = InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

 創建對應實體類HeadLine.java

package com.imooc.o2o.entity;

import java.util.Date;

public class HeadLine {

    private Long lineId;
    private String lineName;
    private String lineLink;
    private String lineImg;
    private String priority;
    //0.不可用 1.可用
    private Integer enableStatus;
    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 String getPriority() {
        return priority;
    }
    public void setPriority(String 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 com.imooc.o2o.entity;

import java.util.Date;

public class ShopCategory {

    private Long shopCategoryId;
    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;
    }

}

創建對應的數據表

CREATE TABLE tb_shop_category(
    shop_category_id int(11) NOT NULL AUTO_INCREMENT,
    shop_category_name varchar(100) NOT NULL DEFAULT '',
    shop_category_desc varchar(1000) DEFAULT '',
    shop_category_img varchar(2000) DEFAULT NULL,
    priority int(2) NOT NULL DEFAULT 0,
    create_time datetime DEFAULT NULL,
    last_edit_time datetime DEFAULT NULL,
    parent_id int(11)  DEFAULT NULL,
    PRIMARY KEY(shop_category_id),
    CONSTRAINT fk_shop_category_self FOREIGN KEY(parent_id) REFERENCES tb_shop_category(shop_category_id)
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

 

店鋪實體類與數據表

創建實體類

package com.imooc.o2o.entity;

import java.util.Date;

public class Shop {

    private Long shopId;
    private Long ownerId;
    private Long shopCategoryId;//店鋪分類Id
    private String shopName;
    private String shopDesc;//店鋪描述
    private String shopAddr;//店鋪具體地址
    private String phone;
    private String shopImg;
    private Double longitude;
    private Double latitude;
    private Integer priority;
    private Date createTime;
    private Date lastEditTime;
    //-1.不可用 0.審覈中 1.可用
    private Integer enableStatus;
    //超級管理員給店家的提醒
    private String advice;

    //區域實體類:表示店鋪屬於哪一塊區域
    private Area area;
    //店鋪類別實體類
    private ShopCategory shopCategory;
    //用戶信息實體類:表示店鋪由誰創建
    private PersonInfo owner;
    public Long getShopId() {
        return shopId;
    }
    public void setShopId(Long shopId) {
        this.shopId = shopId;
    }
    public Long getOwnerId() {
        return ownerId;
    }
    public void setOwnerId(Long ownerId) {
        this.ownerId = ownerId;
    }
    public Long getShopCategoryId() {
        return shopCategoryId;
    }
    public void setShopCategoryId(Long shopCategoryId) {
        this.shopCategoryId = shopCategoryId;
    }
    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 Double getLongitude() {
        return longitude;
    }
    public void setLongitude(Double longitude) {
        this.longitude = longitude;
    }
    public Double getLatitude() {
        return latitude;
    }
    public void setLatitude(Double latitude) {
        this.latitude = latitude;
    }
    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 String getAdvice() {
        return advice;
    }
    public void setAdvice(String advice) {
        this.advice = advice;
    }
    public Area getArea() {
        return area;
    }
    public void setArea(Area area) {
        this.area = area;
    }
    public ShopCategory getShopCategory() {
        return shopCategory;
    }
    public void setShopCategory(ShopCategory shopCategory) {
        this.shopCategory = shopCategory;
    }
    public PersonInfo getOwner() {
        return owner;
    }
    public void setOwner(PersonInfo owner) {
        this.owner = owner;
    }
}

創建對應的數據表 

CREATE TABLE tb_shop(
    shop_id int(10) NOT NULL AUTO_INCREMENT,
    owner_id int(10) NOT NULL COMMENT '店鋪創建人',
    area_id int(5) DEFAULT NULL,
    shop_category_id int(11) DEFAULT NULL,
    shop_name varchar(256) NOT NULL,
    shop_desc varchar(1024) DEFAULT NULL,
    shop_addr varchar(200) DEFAULT NULL,
    phone varchar(128) DEFAULT NULL,
    shop_img varchar(1024) DEFAULT NULL,
    priority int(3) DEFAULT 0,
    create_time datetime DEFAULT NULL,
    last_edit_time datetime DEFAULT NULL,
    enable_status int(2) NOT NULL DEFAULT 0,
    advice varchar(255) DEFAULT NULL,
    PRIMARY KEY(shop_id),
    CONSTRAINT fk_shop_area FOREIGN KEY(area_id) REFERENCES tb_area(area_id),
    CONSTRAINT fk_shop_profile FOREIGN KEY(owner_id) REFERENCES tb_person_info(user_id),
    CONSTRAINT fk_shop_shopcate FOREIGN KEY(shop_category_id) REFERENCES tb_shop_category(shop_category_id)
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

商品類別實體類與數據表

創建實體類ProductCategory.java

package com.imooc.o2o.entity;

import java.util.Date;

public class ProductCategory {

    private Long productCategoryId;
    private Long shopId;
    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;
    }

}

 創建對應數據表

CREATE TABLE tb_product_category(
  product_category_id int(11) NOT NULL AUTO_INCREMENT,
  product_category_name varchar(100) NOT NULL,
  priority int(2) DEFAULT 0,
  create_time datetime DEFAULT NULL,
  shop_id int(20) NOT NULL DEFAULT 0,
  PRIMARY KEY (product_category_id),
  CONSTRAINT fk_procate_shop FOREIGN KEY(shop_id)REFERENCES tb_shop(shop_id)
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

商品圖片實體類與數據表 

創建實體類ProductImg.java

package com.imooc.o2o.entity;

import java.util.Date;

public class ProductImg {

    private Long productImgId;
    private String imgAddr;
    private String imgDesc;
    private Integer priority;
    private Date createTime;
    private Long productId;

    public Long getProductImgId() {
        return productImgId;
    }
    public void setProductImgId(Long productImgId) {
        this.productImgId = productImgId;
    }
    public String getImgAddr() {
        return imgAddr;
    }
    public void setImgAddr(String imgAddr) {
        this.imgAddr = imgAddr;
    }
    public String getImgDesc() {
        return imgDesc;
    }
    public void setImgDesc(String imgDesc) {
        this.imgDesc = imgDesc;
    }
    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 Long getProductId() {
        return productId;
    }
    public void setProductId(Long productId) {
        this.productId = productId;
    }

}

創建對應數據表 

CREATE TABLE tb_product_img(
  product_img_id int(20) NOT NULL AUTO_INCREMENT,
  img_addr varchar(2000) NOT NULL,
  img_desc varchar(2000) DEFAULT NULL,
  priority int(2) DEFAULT 0,
  create_time  datetime DEFAULT NULL,
  product_id int(20) DEFAULT NULL,
  PRIMARY KEY(product_img_id),
  CONSTRAINT fk_proimg_product FOREIGN KEY(product_id) REFERENCES tb_product(product_id)
)ENGINE =InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

 

商品實體類與數據表 

package com.imooc.o2o.entity;

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

public class Product {

    private Long productId;
    private String productName;
    private String productDesc;
    //簡略圖
    private String imgAddr;
    private String normalPrice;
    private String promotionPrice;
    private Integer priority;
    private Date createTime;
    private Date lastEditTime;
    //-1.不可用 ,0.下架 1.在前端展示系統展示
    private Integer enableStatus;
    private List<ProductImg> 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<ProductImg> getProductImgList() {
        return productImgList;
    }
    public void setProductImgList(List<ProductImg> 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;
    }
}
CREATE TABLE tb_product(
    product_id int(100) NOT NULL AUTO_INCREMENT,
    product_name varchar(100) NOT NULL,
    product_desc varchar(2000) DEFAULT NULL,
    img_addr varchar(2000) DEFAULT '',
    normal_price varchar(100) DEFAULT NULL,
    promotion_price varchar(100) DEFAULT NULL,
    priority int(2) NOT NULL DEFAULT 0,
    create_time  datetime DEFAULT NULL,
    last_edit_time datetime DEFAULT NULL,
    enable_status int(2) NOT NULL DEFAULT 0,
    product_category_id int(11) DEFAULT NULL,
    shop_id int(20) NOT NULL DEFAULT 0,
    PRIMARY KEY(product_id),
    CONSTRAINT fk_product_procate FOREIGN KEY(product_category_id) REFERENCES tb_product_category(product_category_id),
    CONSTRAINT fk_product_shop FOREIGN KEY(shop_id) REFERENCES tb_shop(shop_id)
 )ENGINE =InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章