实战SSM_O2O商铺_02数据模型设计及实体类的创建

简介: 实战SSM_O2O商铺_02数据模型设计及实体类的创建

20191208102256370.png

模块介绍

主要分为3个大模块

  • 前端展示模块


20180514040218390.png

  • 店家模块


20180514040304976.png

  • 后台管理模块



20180514040407364.png


建立o2o数据库(MySql)


20180514070254226.png


数据模型及对象设计

总览

根据上述划分的功能模块,设计出主要的实体类(10个)以及实体类对应的表(10个)



20180514051055371.png


下面来拆分逐个解析,创建实体类和库表


区域

分析


20180514051301588.png



主要属性:

  • areaId
  • areaName
  • priority (权重,数值越大页面展示越靠前)
  • createTime
  • lastEditTime


实体类

/src/main/java新建包com.artisan.o2o.entity,新建Area.java

package com.artisan.o2o.entity;
import java.util.Date;
/**
 * 
 * 
 * @ClassName: Area
 * 
 * @Description: 区域实体列,对应数据库中的tb_area.属性采用引用类型(Integer\Long等),
 *               不建议使用基本类型(基本类型有默认值) ,以免mybatis动态sql出现莫名其妙的问题
 * 
 * @author: Mr.Yang
 * 
 * @date: 2018年5月13日 下午5:15:39
 */
public class Area {
  /**
   * 区域Id
   */
  private Integer areaId;
  /**
   * 区域名称
   */
  private String areaName;
  /**
   * 区域描述
   */
  private String areaDesc;
  /**
   * 权重,数值越大页面展示越靠前
   */
  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;
  }
  public String getAreaDesc() {
    return areaDesc;
  }
  public void setAreaDesc(String areaDesc) {
    this.areaDesc = areaDesc;
  }
  @Override
  public String toString() {
    return "Area [areaId=" + areaId + ", areaName=" + areaName + ", areaDesc=" + areaDesc + ", priority=" + priority + ", createTime=" + createTime + ", lastEditTime=" + lastEditTime + "]";
  }
}


数据库表

CREATE TABLE `tb_area` (
  `area_id` INT (5) NOT NULL AUTO_INCREMENT,
  `area_name` VARCHAR (200) NOT NULL,
  `area_desc` VARCHAR (1000) DEFAULT 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;



用户信息

分析


20180514071607924.png



实体类

package com.artisan.o2o.entity;
import java.util.Date;
/**
 * 
 * 
 * @ClassName: PersonInfo
 * 
 * @Description: tb_person_info对应的实体类.属性采用引用类型(Integer\Long等),
 *               不建议使用基本类型(基本类型有默认值) ,以免mybatis动态sql出现莫名其妙的问题
 * 
 * @author: Mr.Yang
 * 
 * @date: 2018年5月13日 下午7:20:44
 */
public class PersonInfo {
  /**
   * 用户Id
   */
  private Long userId;
  /**
   * 用户姓名
   */
  private String name;
  /**
   * 头像图片地址
   */
  private String profileImg;
  /**
   * 性别
   */
  private String gender;
  /**
   * 邮箱
   */
  private String email;
  /**
   * 用户状态
   */
  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 getGender() {
    return gender;
  }
  public void setGender(String gender) {
    this.gender = gender;
  }
  public String getEmail() {
    return email;
  }
  public void setEmail(String email) {
    this.email = email;
  }
  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;
  }
  @Override
  public String toString() {
    return "PersonInfo [userId=" + userId + ", name=" + name + ", profileImg=" + profileImg + ", gender=" + gender + ", email=" + email + ", enableStatus=" + enableStatus + ", userType="
        + userType + ", createTime=" + createTime + ", lastEditTime=" + lastEditTime + "]";
  }
}


数据库表

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 (128) 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;



微信账号与本地账号

分析


这两个表与实体类的设计,要通过外键用户ID与对应的用户建立联系 ,这样才能确定是哪个用户。



20180514103008348.png


微信账号-实体类

package com.artisan.o2o.entity;
import java.util.Date;
/**
 * 
 * 
 * @ClassName: WechatAuth
 * 
 * @Description: tb_wechat_auth对应的实体类
 * 
 * @author: Mr.Yang
 * 
 * @date: 2018年5月13日 下午10:38:08
 */
public class WechatAuth {
  /**
   * 主键
   */
  private Long wechatAuthId;
  /**
   * Wechat唯一标示
   */
  private String openId;
  /**
   * 创建时间
   */
  private Date createTime;
  /**
   * 关联的用户信息(通过用户id)
   */
  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;
  }
  @Override
  public String toString() {
    return "WechatAuth [wechatAuthId=" + wechatAuthId + ", openId=" + openId + ", createTime=" + createTime + ", 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(512)  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;
-- add index for COLUMN open_id
alter table  tb_wechat_auth add unique index(open_id);


本地账号-实体类

package com.artisan.o2o.entity;
import java.util.Date;
/**
 * 
 * 
 * @ClassName: LocalAuth
 * 
 * @Description: tb_local_auth对应的实体类
 * 
 * @author: Mr.Yang
 * 
 * @date: 2018年5月13日 下午10:41:21
 */
public class LocalAuth {
  /**
   * 主键
   */
  private Integer localAuthId;
  /**
   * 用户名
   */
  private String userName;
  /**
   * 密码
   */
  private String password;
  /**
   * 创建时间
   */
  private Date createTime;
  /**
   * 修改时间
   */
  private Date lastEditTime;
  /**
   * 关联的用户信息(通过用户id)
   */
  private PersonInfo personInfo;
  public Integer getLocalAuthId() {
    return localAuthId;
  }
  public void setLocalAuthId(Integer 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;
  }
  @Override
  public String toString() {
    return "LocalAuth [localAuthId=" + localAuthId + ", userName=" + userName + ", password=" + password + ", createTime=" + createTime + ", lastEditTime=" + lastEditTime + ", personInfo="
        + personInfo + "]";
  }
}

本地账号-数据库表

CREATE TABLE `tb_local_auth` (
  `local_auth_id` int(10) NOT NULL AUTO_INCREMENT,
  `user_id` int(10) DEFAULT NULL,
  `user_name` 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` (`user_name`),
  CONSTRAINT `fk_local_profile` FOREIGN KEY (`user_id`) REFERENCES `tb_person_info` (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;



头条

分析

2018051411180131.png



实体类

package com.artisan.o2o.entity;
import java.util.Date;
/**
 * 
 * 
 * @ClassName: HeadLine
 * 
 * @Description: tb_head_line对应的实体类
 * 
 * @author: Mr.Yang
 * 
 * @date: 2018年5月13日 下午11:01:57
 */
public class HeadLine {
  /**
   * 
   */
  private Long lineId;
  /**
   * 头条名
   */
  private String lineName;
  /**
   * 头条链接
   */
  private String lineLink;
  /**
   * 图片地址
   */
  private String lineImg;
  /**
   * 权重,数值越大,优先展示
   */
  private Integer 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 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;
  }
  @Override
  public String toString() {
    return "HeadLine [lineId=" + lineId + ", lineName=" + lineName + ", lineLink=" + lineLink + ", lineImg=" + lineImg + ", priority=" + priority + ", enableStatus=" + enableStatus
        + ", createTime=" + createTime + ", lastEditTime=" + lastEditTime + "]";
  }
}


数据库表

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' comment '0:不可用,1:可用',
  `create_time` datetime DEFAULT NULL,
  `last_edit_time` datetime DEFAULT NULL,
  PRIMARY KEY (`line_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;



店铺类别

分析

20180514112514493.png


实体类

package com.artisan.o2o.entity;
import java.util.Date;
/**
 * 
 * 
 * @ClassName: ShopCategory
 * 
 * @Description: tb_shop_category对应的实体类
 * 
 * @author: Mr.Yang
 * 
 * @date: 2018年5月13日 下午11:26:19
 */
public class ShopCategory {
  /**
   * 主键
   */
  private Long shopCategoryId;
  /**
   * 店铺目录名称
   */
  private String shopCategoryName;
  /**
   * 店铺目录描述
   */
  private String shopCategoryDesc;
  /**
   * 店铺目录对应的图片地址
   */
  private String shopCategoryImg;
  /**
   * 权重,值越大,越优先展示
   */
  private Integer priority;
  /**
   * 创建时间
   */
  private Date createTime;
  /**
   * 修改时间
   */
  private Date lastEditTime;
  /**
   * 上级Id,用于店铺目录的分层展示
   */
  private ShopCategory parentId;
  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 getParentId() {
    return parentId;
  }
  public void setParentId(ShopCategory parentId) {
    this.parentId = parentId;
  }
  @Override
  public String toString() {
    return "ShopCategory [shopCategoryId=" + shopCategoryId + ", shopCategoryName=" + shopCategoryName + ", shopCategoryDesc=" + shopCategoryDesc + ", shopCategoryImg=" + shopCategoryImg
        + ", priority=" + priority + ", createTime=" + createTime + ", lastEditTime=" + lastEditTime + ", parentId=" + parentId + "]";
  }
}


数据库表

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;


##店铺

###分析


20180514120852470.png

实体类

package com.artisan.o2o.entity;
import java.util.Date;
/**
 * 
 * 
 * @ClassName: Shop
 * 
 * @Description: tb_shop对应的实体类
 * 
 * @author: Mr.Yang
 * 
 * @date: 2018年5月14日 上午12:04:32
 */
public class Shop {
  private Long shopId;
  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 String advice;
  /**
   * 店铺所属店主
   */
  private PersonInfo owner;
  /**
   * 店铺所在区月
   */
  private Area area;
  /**
   * 店铺类别
   */
  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 String getAdvice() {
    return advice;
  }
  public void setAdvice(String advice) {
    this.advice = advice;
  }
  public PersonInfo getOwner() {
    return owner;
  }
  public void setOwner(PersonInfo owner) {
    this.owner = owner;
  }
  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;
  }
}



数据库表

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 ;


商品类别


实体类

package com.artisan.o2o.entity;
import java.util.Date;
/**
 * 
 * 
 * @ClassName: ProductCategory
 * 
 * @Description: tb_product_category对应的实体类
 * 
 * @author: Mr.Yang
 * 
 * @date: 2018年5月14日 上午12:26:43
 */
public class ProductCategory {
  private Long productCategoryId;
  /**
   * 店铺id,表名该产品目录是哪个店铺下的
   */
  private Long shopId;
  private String productCategoryName;
  private String productCategoryDesc;
  private Integer priority;
  private Date createTime;
  private Date lastEditTime;
  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 String getProductCategoryDesc() {
    return productCategoryDesc;
  }
  public void setProductCategoryDesc(String productCategoryDesc) {
    this.productCategoryDesc = productCategoryDesc;
  }
  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_product_category` (
  `product_category_id` int(11) NOT NULL AUTO_INCREMENT,
  `product_category_name` varchar(100) NOT NULL,
  `product_category_desc` varchar(500) DEFAULT NULL,
  `priority` int(2) DEFAULT '0',
  `create_time` datetime DEFAULT NULL,
  `last_edit_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;


商品详情图片

实体类

package com.artisan.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`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;


商品

分析


2018051412415497.png


实体类

package com.artisan.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;


总结回顾

总结回顾下数据模型


用户信息关联

通过用户Id关联


20180514125052164.png


店铺信息关联


2018051412520553.png


商品信息关联


20180514125341363.png


Github地址


代码地址: https://github.com/yangshangwei/o2o

相关文章
|
6月前
|
搜索推荐 JavaScript Java
计算机Java项目|基于SSM的个性化商铺系统
计算机Java项目|基于SSM的个性化商铺系统
|
6月前
|
JavaScript Java 测试技术
基于ssm+vue.js+uniapp小程序的商铺租赁管理系统附带文章和源代码部署视频讲解等
基于ssm+vue.js+uniapp小程序的商铺租赁管理系统附带文章和源代码部署视频讲解等
71 7
|
7月前
ssm(Spring+Spring mvc+mybatis)实体类——Dept
ssm(Spring+Spring mvc+mybatis)实体类——Dept
|
7月前
|
SQL 测试技术
实战SSM_O2O商铺_32【商品】商品编辑之Dao层的实现
实战SSM_O2O商铺_32【商品】商品编辑之Dao层的实现
66 0
|
7月前
|
前端开发 数据库
实战SSM_O2O商铺_31【商品】商品添加之View层的实现
实战SSM_O2O商铺_31【商品】商品添加之View层的实现
51 0
|
7月前
|
前端开发 fastjson 测试技术
实战SSM_O2O商铺_30【商品】商品添加之Controller层的实现
实战SSM_O2O商铺_30【商品】商品添加之Controller层的实现
48 0
|
7月前
|
前端开发 Java 数据库连接
实战SSM_O2O商铺_29【商品】商品添加之Service层的实现及重构
实战SSM_O2O商铺_29【商品】商品添加之Service层的实现及重构
41 0
|
7月前
|
测试技术
实战SSM_O2O商铺_28【商品】商品添加之Dao层的实现
实战SSM_O2O商铺_28【商品】商品添加之Dao层的实现
61 0
|
7月前
|
SQL 前端开发 测试技术
实战SSM_O2O商铺_27【商品类别】删除商品类别从Dao到View层的开发
实战SSM_O2O商铺_27【商品类别】删除商品类别从Dao到View层的开发
52 0
|
7月前
|
SQL 前端开发 测试技术
实战SSM_O2O商铺_26【商品类别】批量新增商品类别从Dao到View层的开发
实战SSM_O2O商铺_26【商品类别】批量新增商品类别从Dao到View层的开发
56 0