实体类创建与表解析
整体类别
区域
public class Area {
// ID
private Integer AreaId;
// 名称
private String AreaName;
// 权重
private String priority;
// 创建时间
private Date createTime;
// 修改时间
private Date lastEditTime;
建表:
create table 'tb_area' (
'area_id' int(3) not null auto_increment,
'area_name' varchar(200) not null ,
'priority' int(3) 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')
)engin = INNODB auto_increment=1 DEFAULT CHARSET = utf8;
用户
public class PersionInfo {
private Long userId;
private String name;
private String profileImg;
private String email;
private String gender;
private Integer enableStatus;
private Integer userType;
private Date createTime;
private Date lastEditTime;
CREATE TABLE `o2o`.`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,
`user_type` int(2) NOT NULL DEFAULT 1 ,
`create_time` datetime,
`last_edit_time` datetime,
PRIMARY KEY (`user_id`)
) ENGINE=`InnoDB` AUTO_INCREMENT=1 ;
账号:
public class WechatAuth {
private Long wechatAuthId;
private String openId;
private Date createTime;
private PersonInfo personInfo;
public class LocalAuth {
private Long localAuthId;
private String username;
private String password;
private Date createTime;
private Date lastEditTIme;
private 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 ;
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 ;
头条
public class HeadLine {
private Long lineId;
private String lineName;
private String lineLink;
private String lineImg;
private Integer priority;
private Integer enableStatus;
private Date createTime;
private Date lastEditTime;
create table tb_head_line(
line_id int(10) not null auto_increment,
line_name VARCHAR(1024) DEFAULT null,
line_link varchar(2000) not null ,
line_img varchar(2000) not null ,
priority 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 ;
店铺类别:
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;
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
店铺
public class Shop {
private Long shopId;
private String shopName;
private String shopDesv;
private String shopAddr;
private String phone;
private String shopImg;
private Integer priovity;
private Date createTime;
private Date lastEditTime;
private Integer enableStatus;
private String advice;
private Area area;
private PersonInfo owner;
private ShopCategory shopCategory;
create table tb_shop(
shop_id int(11) not null auto_increment,
owner_id int(10) not null,
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
商品类别
public class ProductCategory {
private Long productCategoryId;
private Long shopId;
private String productCategoryName;
private Integer priority;
private Date 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
详情图片:
public class ProductImg {
private Long productImgId;
private String imgAddr;
private String imgDesc;
private Integer priority;
private Date createTime;
private Long 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 0,
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
商品:
public class Product {
private Long productId;
private String productName;
private String productDesc;
private String imgAddr;
private String normalPrice;
private String promotionPrive;
private Integer priority;
private Date createTime;
private Date lastEditTime;
private Integer enableStatus;
private List<ProductImg> productImgList;
private ProductCategory productCategory;
private 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
表关系: