实战SSM_O2O商铺_02数据模型设计及实体类的创建
生活随笔
收集整理的這篇文章主要介紹了
实战SSM_O2O商铺_02数据模型设计及实体类的创建
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
文章目錄
- 模塊介紹
- 建立o2o數據庫(MySql)
- 數據模型及對象設計
- 總覽
- 區域
- 分析
- 實體類
- 數據庫表
- 用戶信息
- 分析
- 實體類
- 數據庫表
- 微信賬號與本地賬號
- 分析
- 微信賬號-實體類
- 微信賬號-數據庫表
- 本地賬號-實體類
- 本地賬號-數據庫表
- 頭條
- 分析
- 實體類
- 數據庫表
- 店鋪類別
- 分析
- 實體類
- 數據庫表
- 實體類
- 數據庫表
- 商品類別
- 實體類
- 數據庫表
- 商品詳情圖片
- 實體類
- 數據庫表
- 商品
- 分析
- 實體類
- 數據庫表
- 總結回顧
- 用戶信息關聯
- 店鋪信息關聯
- 商品信息關聯
- Github地址
模塊介紹
主要分為3個大模塊
- 前端展示模塊
- 店家模塊
- 后臺管理模塊
建立o2o數據庫(MySql)
數據模型及對象設計
總覽
根據上述劃分的功能模塊,設計出主要的實體類(10個)以及實體類對應的表(10個)
下面來拆分逐個解析,創建實體類和庫表
區域
分析
主要屬性:
- 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;}@Overridepublic 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;用戶信息
分析
實體類
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;}@Overridepublic 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與對應的用戶建立聯系 ,這樣才能確定是哪個用戶。
微信賬號-實體類
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;}@Overridepublic 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;}@Overridepublic 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;頭條
分析
實體類
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;}@Overridepublic 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;店鋪類別
分析
實體類
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;}@Overridepublic 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;##店鋪
###分析
實體類
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;商品
分析
實體類
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關聯
店鋪信息關聯
商品信息關聯
Github地址
代碼地址: https://github.com/yangshangwei/o2o
總結
以上是生活随笔為你收集整理的实战SSM_O2O商铺_02数据模型设计及实体类的创建的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: SSM-Spring+SpringMVC
- 下一篇: 实战SSM_O2O商铺_03项目结构规划