DROP TABLE autofan_account ;
DROP TABLE autofan_act ;
DROP TABLE autofan_act_apply;
DROP TABLE autofan_act_detail;
DROP TABLE autofan_act_member;
DROP TABLE autofan_act_pay;
DROP TABLE autofan_act_real_route;
DROP TABLE autofan_act_route;
DROP TABLE autofan_club;
DROP TABLE autofan_comment;
DROP TABLE autofan_follow_club;
DROP TABLE autofan_img;


create table autofan_account (
id                 bigint(20)   comment '太平洋公共帐号ID            ',
nickname           varchar(100) comment '昵称                        ',
faceUrl            varchar(255) comment '头像                        ',
faceUrlLarge       varchar(255) comment '头像                        ',
loginType          smallint     comment '登录类型:sina、tencent      ',
openId             bigint(20)   comment '开放平台ID                  ',
mobile             varchar(20)  comment '手机                        ',
licensePlate       varchar(20)  comment '车牌                        ',
areaId             int          comment '地区                        ',
censor             bigint(20)   comment 'CENSOR                      ',
censorDate         datetime     comment 'CENSOR_DATE                 ',
censorStatus       smallint     comment 'CENSOR_STATUS               ',
pendingTime        int          comment 'PENDING_TIME                ',
hasAudit           smallint     comment 'HAS_AUDIT                   ',
PRIMARY KEY (id)
)ENGINE = InnoDB; 


create table autofan_act (
id                bigint(20)    comment '活动ID       ',    
name              varchar(100)  comment '活动名称     ',      
startDate         datetime      comment '开始时间     ', 
endDate           datetime      comment '结束时间     ', 
status            smallint      comment '状态         ',    
clubId            bigint(20)    comment '             ',    
areaId            int           comment '地区         ',       
hasRecommend      smallint      comment '是否推荐     ',      
recommendDate     datetime      comment '推荐时间     ',     
createdBy         bigint(20)    comment 'uid          ',       
createDate        datetime      comment '创建时间     ',      
updateBy          bigint(20)    comment 'uid          ',         
lastUpdateDate    datetime      comment '最后修改时间 ',        
censor            bigint(20)    comment 'CENSOR       ',         
censorDate        datetime      comment 'CENSOR_DATE  ',          
censorStatus      smallint      comment 'CENSOR_STATUS',            
pendingTime       int           comment 'PENDING_TIME ',             
hasAudit          smallint      comment 'HAS_AUDIT    ',     
PRIMARY KEY (id)
)ENGINE = InnoDB; 

create table autofan_actDetail(
id                bigint(20)    comment 'ID       ',    
actId             bigint(20)    comment '活动ID       ',    
detail            varchar(4000) comment '活动详情     ',
PRIMARY KEY (id)
)ENGINE = InnoDB; 


create table autofan_actMember (
id                 bigint(20)    comment 'ID                    ',    
actId              bigint(20)    comment '活动ID                ',        
uid                bigint(20)    comment '用户ID                ',        
type               smallint      comment '身份(manager,member)  ',                      
mobile             varchar(20)   comment '手机                  ',      
licensePlate       varchar(20)   comment '车牌                  ',      
status             smallint      comment '状态：1：正常、0：删除',                        
createdBy          bigint(20)    comment 'ACCOUNT_ID            ',            
createDate         datetime      comment '创建时间              ',          
updateBy           bigint(20)    comment 'ACCOUNT_ID            ',            
lastUpdateDate     datetime      comment '最后修改时间          ',              
PRIMARY KEY (id)
)ENGINE = InnoDB; 



create table autofan_actPay (
id                bigint(20)    comment '费用ID  ', 
actId             bigint(20)    comment '活动ID  ', 
pay               smallint      comment '费用    ', 
memo              varchar(100)  comment '费用描述', 
createDate        datetime      comment '创建时间', 
uid               bigint(20)    comment '创建人  ',
PRIMARY KEY (id)
)ENGINE = InnoDB; 

create table autofan_actRoute (
id                bigint(20)    comment '活动ID                                            ',    
actId             bigint(20)    comment '活动ID                                            ',    
seq               smallint      comment '顺序号                                            ',    
routeName         varchar(100)  comment '地点名称                                          ',  
preLongitude      double(15,10) comment '手机设备GPS经度                                   ',  
preLatitude       double(15,10) comment '手机设备GPS纬度                                   ',      
longitude         double(15,10) comment '百度地图经度                                      ',  
latitude          double(15,10) comment '百度地图纬度                                      ',  
addr              varchar(100)  comment '地址名称                                          ',      
province          varchar(50)   comment '省份名称                                          ',      
city              varchar(50)   comment '城市名称                                          ',      
distict           varchar(50)   comment '区县名称                                          ',      
areaId            int           comment '地区id                                            ',    
type              varchar(10)   comment '类型：start, end, pass 分别代表起点，经停点，终点 ',  
memo              varchar(100)  comment '备注                                              ',  
PRIMARY KEY (id)
)ENGINE = InnoDB; 

create table autofan_actApply (
id                bigint(20)    comment 'ID                    ',    
actId             bigint(20)   comment '活动ID                 ',  
uid               bigint(20)   comment '用户ID                 ',  
verifyStr         varchar(100) comment '活动验证密码           ',        
mobile            varchar(20)  comment '手机                   ',
licensePlate      varchar(20)  comment '车牌                   ',
status            smallint     comment '状态：1：正常、0：删除 ',                  
createdBy         bigint(20)   comment 'ACCOUNT_ID             ',      
createDate        datetime     comment '创建时间               ',    
updateBy          bigint(20)   comment 'ACCOUNT_ID             ',      
lastUpdateDate    datetime     comment '最后修改时间           ',        
PRIMARY KEY (id)
)ENGINE = InnoDB; 

create table autofan_actRealRoute (
id                 bigint(20)    comment 'ID        ',    
actId              bigint(20)    comment '活动ID    ',  
uid                bigint(20)    comment '用户ID    ',  
preLongitude      double(15,10) comment '手机设备GPS经度  ',  
preLatitude       double(15,10) comment '手机设备GPS纬度  ',      
longitude         double(15,10) comment '百度地图经度     ',  
latitude          double(15,10) comment '百度地图纬度     ',  
location           varchar(100)  comment '位置说明  ',
createdBy          bigint(20)    comment 'ACCOUNT_ID',      
createDate         datetime      comment '创建时间  ',    
PRIMARY KEY (id)
)ENGINE = InnoDB; 



create table autofan_club (
id                 bigint(20)   comment '车友会ID                      ',
name               varchar(100) comment '车友会名称                    ',
prefix             varchar(10)  comment '拼音首字母                    ',
logo               varchar(255) comment '车友会LOGO                    ',
logoUrl            varchar(255) comment '车友会LOGO大图                ',
uid                bigint(20)   comment '创建者                        ',
createDate         datetime     comment '创建时间                      ',
PRIMARY KEY (id)
)ENGINE = InnoDB; 


create table autofan_followClub (
id                 bigint(20)   comment '',
uid                bigint(20)   comment 'ACCOUNT_ID                   ',
clubId             bigint(20)   comment '车友会ID                     ',
createDate         datetime     comment '                             ',
PRIMARY KEY (id)
)ENGINE = InnoDB; 



create table autofan_img  (
id                bigint(20)    comment '图片ID                        ',
actId             bigint(20)    comment '活动ID                        ',
imgUrl            varchar(255)  comment '原图URL                       ',
imgUrlMiddle      varchar(255)  comment '中图URL                       ',
imgUrlSmall       varchar(255)  comment '小图URL                       ',
memo              varchar(255)  comment '图片描述                      ',
createDate        datetime      comment '创建时间                      ',
uid               bigint(20)    comment 'ACCOUNT_ID                    ',
censor            bigint(20)    comment 'CENSOR                        ',
censorDate        datetime      comment 'CENSOR_DATE                   ',
censorStatus      smallint      comment 'CENSOR_STATUS                 ',
pendingTime       int           comment 'PENDING_TIME                  ',
hasAudit          smallint      comment 'HAS_AUDIT                     ',
PRIMARY KEY (id)
)ENGINE = InnoDB; 



create table autofan_comment (
id                 bigint(20)   comment '评论ID                        ',
type               smallint     comment '评论类型                      ',
ownerId            bigint(20)   comment '评论对象ID                    ',
content            varchar(500) comment '评论正文                      ',
createDate         datetime     comment '创建时间                      ',
uid                bigint(20)   comment '发表者                        ',
lastUpdateDate     datetime     comment '最后修改时间                  ',
censor             bigint(20)   comment 'CENSOR                        ',
censorDate         datetime     comment 'CENSOR_DATE                   ',
censorStatus       smallint     comment 'CENSOR_STATUS                 ',
pendingTime        int          comment 'PENDING_TIME                  ',
hasAudit           smallint     comment 'HAS_AUDIT                     ',
PRIMARY KEY (id)
)ENGINE = InnoDB; 

CREATE UNIQUE INDEX actMemberActUid ON autofan_actMember (actId, uid)   ;


/*Table structure for table `autofan_keygen` */

DROP TABLE IF EXISTS `autofan_keygen`;

CREATE TABLE `autofan_keygen` (
  `TABLE_NAME` varchar(50) NOT NULL,
  `LAST_USED_ID` bigint(20) DEFAULT NULL,
  PRIMARY KEY (`TABLE_NAME`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

/*Data for the table `autofan_keygen` */

insert  into `autofan_keygen`(`TABLE_NAME`,`LAST_USED_ID`) values ('autofan_act',40),('autofan_actapply',0),('autofan_actdetail',40),('autofan_actmember',0),('autofan_actpay',0),('autofan_actrealroute',30),('autofan_actroute',30),('autofan_comment',0),('autofan_img',0);

/*Table structure for table `sec_acl` */

DROP TABLE IF EXISTS `sec_acl`;

CREATE TABLE `sec_acl` (
  `RESOURCE_ID` varchar(50) NOT NULL DEFAULT '',
  `ROLE_ID` bigint(20) NOT NULL DEFAULT '0',
  `USER_ID` bigint(20) NOT NULL DEFAULT '0',
  `APPLICATION` varchar(50) NOT NULL DEFAULT '',
  `ACCOUNT_ID` bigint(20) DEFAULT NULL,
  PRIMARY KEY (`RESOURCE_ID`,`ROLE_ID`,`USER_ID`,`APPLICATION`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

/*Data for the table `sec_acl` */

/*Table structure for table `sec_function` */

DROP TABLE IF EXISTS `sec_function`;

CREATE TABLE `sec_function` (
  `ID` bigint(20) NOT NULL DEFAULT '0',
  `NAME` varchar(50) DEFAULT NULL,
  `RANK` bigint(20) DEFAULT NULL,
  `APPLICATION` varchar(50) DEFAULT NULL,
  `DISPLAY_ORDER` bigint(20) DEFAULT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

/*Data for the table `sec_function` */

/*Table structure for table `sec_role` */

DROP TABLE IF EXISTS `sec_role`;

CREATE TABLE `sec_role` (
  `ID` bigint(20) NOT NULL DEFAULT '0',
  `NAME` varchar(50) DEFAULT NULL,
  `DESCRIPTION` varchar(200) DEFAULT NULL,
  `RANK` bigint(20) DEFAULT NULL,
  `APPLICATION` varchar(50) DEFAULT NULL,
  `DISPLAY_ORDER` bigint(20) DEFAULT '0',
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

/*Data for the table `sec_role` */

/*Table structure for table `sec_role_function` */

DROP TABLE IF EXISTS `sec_role_function`;

CREATE TABLE `sec_role_function` (
  `ROLE_ID` bigint(20) NOT NULL DEFAULT '0',
  `FUNCTION_ID` bigint(20) NOT NULL DEFAULT '0',
  `APPLICATION` varchar(50) NOT NULL DEFAULT '',
  PRIMARY KEY (`ROLE_ID`,`FUNCTION_ID`,`APPLICATION`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

/*Data for the table `sec_role_function` */

/*Table structure for table `sec_session` */

DROP TABLE IF EXISTS `sec_session`;

CREATE TABLE `sec_session` (
  `SESSIONID` varchar(100) NOT NULL,
  `USERID` varchar(20) NOT NULL,
  `IP` varchar(100) DEFAULT NULL,
  `LOGINTIME` date DEFAULT NULL,
  `APPLICATION` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`SESSIONID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

/*Data for the table `sec_session` */

insert  into `sec_session`(`SESSIONID`,`USERID`,`IP`,`LOGINTIME`,`APPLICATION`) values ('41b6d86db1e97df5:f20434:1359eb0d0e2:-703f','2','127.0.0.1','2012-03-09','magicube'),('41b6d86db1e97df5:f20434:1359eb0d0e2:-7052','2','127.0.0.1','2012-03-09','magicube'),('41b6d86db1e97df5:f20434:1359eb0d0e2:-705f','2','127.0.0.1','2012-03-09','magicube'),('41b6d86db1e97df5:f20434:1359eb0d0e2:-7071','2','127.0.0.1','2012-03-09','magicube'),('41b6d86db1e97df5:f20434:1359eb0d0e2:-7080','2','127.0.0.1','2012-03-09','magicube'),('41b6d86db1e97df5:f20434:1359eb0d0e2:-70d8','2','127.0.0.1','2012-03-08','magicube'),('41b6d86db1e97df5:f20434:1359eb0d0e2:-776e','2','127.0.0.1','2012-02-28','magicube'),('41b6d86db1e97df5:f20434:1359eb0d0e2:-77e5','2','192.168.11.254/192.168.20.50','2012-02-27','magicube'),('41b6d86db1e97df5:f20434:1359eb0d0e2:-79b3','2','192.168.11.254/192.168.20.50','2012-02-24','magicube'),('41b6d86db1e97df5:f20434:1359eb0d0e2:-79b4','2','192.168.11.254/192.168.20.50','2012-02-24','magicube'),('41b6d86db1e97df5:f20434:1359eb0d0e2:-79c4','2','192.168.11.254/192.168.20.50','2012-02-24','magicube'),('41b6d86db1e97df5:f20434:1359eb0d0e2:-7a7a','2','192.168.20.243','2012-02-23','magicube'),('41b6d86db1e97df5:f20434:1359eb0d0e2:-7aad','2','192.168.11.254/192.168.20.50','2012-02-23','magicube'),('41b6d86db1e97df5:f20434:1359eb0d0e2:-7b46','2','192.168.11.254/192.168.20.243','2012-02-23','magicube'),('41b6d86db1e97df5:f20434:1359eb0d0e2:-7bb1','2','192.168.20.243','2012-02-22','magicube');

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;


DROP TABLE IF EXISTS `autofan_admin`;

CREATE TABLE `autofan_admin` (
  `ID` bigint(20) NOT NULL,
  `ACCOUNT` varchar(255) NOT NULL,
  `CREATEAT` date DEFAULT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

/*Data for the table `autofan_admin` */

insert  into `autofan_admin`(`ID`,`ACCOUNT`,`CREATEAT`) values (2,'admin','2012-02-22');