JDK1.8
数据库mysql 5.7
开发工具 idea 2017.1.2
maven版本3.3.9
docker 最新版本
centos7(资料中有已经安装好的虚拟机,直接导入VMWare中,将内存调整到8G,该虚拟机中已经安装好docker,并且已经设置开机启动,并且已经安装好项目中所用到的所有docker镜像)
docker run -di --name=tensquare_mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 centos/mysql-57-centos7
说明:以上创建命令创建出来的docker的mysql环境可以使用本地的mysql连接工具进行连接,端口号是3306,密码是123456
db_articlesql
/*
SQLyog v10.2
MySQL - 5.5.49 : Database - tensquare_article
*********************************************************************
*/
/*!40101 SET NAMES utf8 */;
/*!40101 SET SQL_MODE=''*/;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/`tensquare_article` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `tensquare_article`;
/*Table structure for table `tb_article` */
DROP TABLE IF EXISTS `tb_article`;
CREATE TABLE `tb_article` (
`id` varchar(20) NOT NULL COMMENT 'ID',
`columnid` varchar(20) DEFAULT NULL COMMENT '专栏ID',
`userid` varchar(20) DEFAULT NULL COMMENT '用户ID',
`title` varchar(100) DEFAULT NULL COMMENT '标题',
`content` text COMMENT '文章正文',
`image` varchar(100) DEFAULT NULL COMMENT '文章封面',
`createtime` datetime DEFAULT NULL COMMENT '发表日期',
`updatetime` datetime DEFAULT NULL COMMENT '修改日期',
`ispublic` varchar(1) DEFAULT NULL COMMENT '是否公开',
`istop` varchar(1) DEFAULT NULL COMMENT '是否置顶',
`visits` int(20) DEFAULT NULL COMMENT '浏览量',
`thumbup` int(20) DEFAULT NULL COMMENT '点赞数',
`comment` int(20) DEFAULT NULL COMMENT '评论数',
`state` varchar(1) DEFAULT NULL COMMENT '审核状态',
`channelid` varchar(20) DEFAULT NULL COMMENT '所属频道',
`url` varchar(100) DEFAULT NULL COMMENT 'URL',
`type` varchar(1) DEFAULT NULL COMMENT '类型',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='文章';
/*Data for the table `tb_article` */
/*Table structure for table `tb_channel` */
DROP TABLE IF EXISTS `tb_channel`;
CREATE TABLE `tb_channel` (
`id` varchar(20) NOT NULL COMMENT 'ID',
`name` varchar(100) DEFAULT NULL COMMENT '频道名称',
`state` varchar(1) DEFAULT NULL COMMENT '状态',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='频道';
/*Data for the table `tb_channel` */
/*Table structure for table `tb_column` */
DROP TABLE IF EXISTS `tb_column`;
CREATE TABLE `tb_column` (
`id` varchar(20) NOT NULL COMMENT 'ID',
`name` varchar(100) DEFAULT NULL COMMENT '专栏名称',
`summary` varchar(1000) DEFAULT NULL COMMENT '专栏简介',
`userid` varchar(20) DEFAULT NULL COMMENT '用户ID',
`createtime` datetime DEFAULT NULL COMMENT '申请日期',
`checktime` datetime DEFAULT NULL COMMENT '审核日期',
`state` varchar(1) DEFAULT NULL COMMENT '状态',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='专栏';
/*Data for the table `tb_column` */
/*!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 */;
db_base.sql
/*
SQLyog Ultimate v12.3.1 (64 bit)
MySQL - 5.5.49 : Database - tensquare_base
*********************************************************************
*/
/*!40101 SET NAMES utf8 */;
/*!40101 SET SQL_MODE=''*/;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/`tensquare_base` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `tensquare_base`;
/*Table structure for table `tb_city` */
DROP TABLE IF EXISTS `tb_city`;
CREATE TABLE `tb_city` (
`id` varchar(20) NOT NULL COMMENT 'ID',
`name` varchar(20) DEFAULT NULL COMMENT '城市名称',
`ishot` varchar(1) DEFAULT NULL COMMENT '是否热门',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='城市';
/*Data for the table `tb_city` */
insert into `tb_city`(`id`,`name`,`ishot`) values
('1','北京','1'),
('2','上海','1'),
('3','广州','1'),
('4','深圳','1'),
('5','天津','0'),
('6','重庆','0'),
('7','西安','0');
/*Table structure for table `tb_label` */
DROP TABLE IF EXISTS `tb_label`;
CREATE TABLE `tb_label` (
`id` varchar(20) NOT NULL COMMENT '标签ID',
`labelname` varchar(100) DEFAULT NULL COMMENT '标签名称',
`state` varchar(1) DEFAULT NULL COMMENT '状态',
`count` bigint(20) DEFAULT NULL COMMENT '使用数量',
`recommend` varchar(1) DEFAULT NULL COMMENT '是否推荐',
`fans` bigint(20) DEFAULT NULL COMMENT '粉丝数',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='标签';
/*Data for the table `tb_label` */
insert into `tb_label`(`id`,`labelname`,`state`,`count`,`recommend`) values
('1','java','1',NULL,NULL),
('2','PHP','1',NULL,NULL),
('3','C++','1',NULL,NULL),
('4','python','1',NULL,NULL);
/*Table structure for table `tb_ul` */
DROP TABLE IF EXISTS `tb_ul`;
CREATE TABLE `tb_ul` (
`userid` varchar(20) NOT NULL,
`labelid` varchar(20) NOT NULL,
PRIMARY KEY (`userid`,`labelid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*Data for the table `tb_ul` */
insert into `tb_ul`(`userid`,`labelid`) values
('1','1'),
('1','2'),
('1','3');
/*!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 */;
db_friend.sql
/*
SQLyog v10.2
MySQL - 5.5.49 : Database - tensquare_friend
*********************************************************************
*/
/*!40101 SET NAMES utf8 */;
/*!40101 SET SQL_MODE=''*/;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/`tensquare_friend` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `tensquare_friend`;
/*Table structure for table `tb_friend` */
DROP TABLE IF EXISTS `tb_friend`;
CREATE TABLE `tb_friend` (
`userid` varchar(20) NOT NULL COMMENT '用户ID',
`friendid` varchar(20) NOT NULL COMMENT '好友ID',
`islike` varchar(1) DEFAULT NULL COMMENT '是否互相喜欢',
PRIMARY KEY (`userid`,`friendid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*Data for the table `tb_friend` */
DROP TABLE IF EXISTS `tb_nofriend`;
CREATE TABLE `tb_nofriend` (
`userid` varchar(20) NOT NULL COMMENT '用户ID',
`friendid` varchar(20) NOT NULL COMMENT '好友ID',
PRIMARY KEY (`userid`,`friendid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
insert into `tb_friend`(`userid`,`friendid`,`islike`) values ('1','100','1');
/*!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 */;
db_gathering.sql
/*
SQLyog v10.2
MySQL - 5.5.49 : Database - tensquare_gathering
*********************************************************************
*/
/*!40101 SET NAMES utf8 */;
/*!40101 SET SQL_MODE=''*/;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/`tensquare_gathering` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `tensquare_gathering`;
/*Table structure for table `tb_gathering` */
DROP TABLE IF EXISTS `tb_gathering`;
CREATE TABLE `tb_gathering` (
`id` varchar(20) NOT NULL COMMENT '编号',
`name` varchar(100) DEFAULT NULL COMMENT '活动名称',
`summary` text COMMENT '大会简介',
`detail` text COMMENT '详细说明',
`sponsor` varchar(100) DEFAULT NULL COMMENT '主办方',
`image` varchar(100) DEFAULT NULL COMMENT '活动图片',
`starttime` datetime DEFAULT NULL COMMENT '开始时间',
`endtime` datetime DEFAULT NULL COMMENT '截止时间',
`address` varchar(100) DEFAULT NULL COMMENT '举办地点',
`enrolltime` datetime DEFAULT NULL COMMENT '报名截止',
`state` varchar(1) DEFAULT NULL COMMENT '是否可见',
`city` varchar(20) DEFAULT NULL COMMENT '城市',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='活动';
/*Data for the table `tb_gathering` */
insert into `tb_gathering`(`id`,`name`,`summary`,`detail`,`sponsor`,`image`,`starttime`,`endtime`,`address`,`enrolltime`,`state`,`city`) values ('1','测试活动','喝茶看电影,不亦乐乎','喝茶看电影,不亦乐乎','黑马程序员',NULL,'2017-12-14 15:39:32','2017-12-21 15:39:36',NULL,NULL,'1','1');
insert into `tb_gathering`(`id`,`name`,`summary`,`detail`,`sponsor`,`image`,`starttime`,`endtime`,`address`,`enrolltime`,`state`,`city`) values ('94377594140','aaaa',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'1','1');
insert into `tb_gathering`(`id`,`name`,`summary`,`detail`,`sponsor`,`image`,`starttime`,`endtime`,`address`,`enrolltime`,`state`,`city`) values ('943776146707845','aaaa',NULL,NULL,'ssss',NULL,NULL,NULL,'cccc',NULL,'1','1');
insert into `tb_gathering`(`id`,`name`,`summary`,`detail`,`sponsor`,`image`,`starttime`,`endtime`,`address`,`enrolltime`,`state`,`city`) values ('943776663576121344','aaaa',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'1','2');
insert into `tb_gathering`(`id`,`name`,`summary`,`detail`,`sponsor`,`image`,`starttime`,`endtime`,`address`,`enrolltime`,`state`,`city`) values ('943783521749700608','2342423',NULL,NULL,'23454534',NULL,NULL,NULL,'545435435',NULL,'1','2');
insert into `tb_gathering`(`id`,`name`,`summary`,`detail`,`sponsor`,`image`,`starttime`,`endtime`,`address`,`enrolltime`,`state`,`city`) values ('944085821768732672','JAVAEE茶话会',NULL,NULL,'传智',NULL,NULL,NULL,'金燕龙',NULL,'1','2');
insert into `tb_gathering`(`id`,`name`,`summary`,`detail`,`sponsor`,`image`,`starttime`,`endtime`,`address`,`enrolltime`,`state`,`city`) values ('944086086991351808','是',NULL,NULL,'11',NULL,NULL,NULL,'11',NULL,'1','3');
insert into `tb_gathering`(`id`,`name`,`summary`,`detail`,`sponsor`,`image`,`starttime`,`endtime`,`address`,`enrolltime`,`state`,`city`) values ('944090372710207488','大讨论',NULL,NULL,'小马',NULL,NULL,NULL,'消息',NULL,'1','3');
insert into `tb_gathering`(`id`,`name`,`summary`,`detail`,`sponsor`,`image`,`starttime`,`endtime`,`address`,`enrolltime`,`state`,`city`) values ('944105652622594048','测试测试',NULL,NULL,'测试者',NULL,NULL,NULL,'测试地址',NULL,'1','4');
insert into `tb_gathering`(`id`,`name`,`summary`,`detail`,`sponsor`,`image`,`starttime`,`endtime`,`address`,`enrolltime`,`state`,`city`) values ('945227340642914304','111',NULL,NULL,'222',NULL,NULL,NULL,'333',NULL,'1','5');
insert into `tb_gathering`(`id`,`name`,`summary`,`detail`,`sponsor`,`image`,`starttime`,`endtime`,`address`,`enrolltime`,`state`,`city`) values ('945227678527655936','111',NULL,NULL,'222',NULL,NULL,NULL,'333',NULL,'1','5');
insert into `tb_gathering`(`id`,`name`,`summary`,`detail`,`sponsor`,`image`,`starttime`,`endtime`,`address`,`enrolltime`,`state`,`city`) values ('945235087564345344','啊啊',NULL,NULL,'1',NULL,NULL,NULL,'1',NULL,'1','1');
insert into `tb_gathering`(`id`,`name`,`summary`,`detail`,`sponsor`,`image`,`starttime`,`endtime`,`address`,`enrolltime`,`state`,`city`) values ('945235534329024512','1',NULL,NULL,'1',NULL,NULL,NULL,'1',NULL,'1','2');
insert into `tb_gathering`(`id`,`name`,`summary`,`detail`,`sponsor`,`image`,`starttime`,`endtime`,`address`,`enrolltime`,`state`,`city`) values ('945235859786043392','1',NULL,NULL,'1',NULL,NULL,NULL,'1',NULL,'1','3');
insert into `tb_gathering`(`id`,`name`,`summary`,`detail`,`sponsor`,`image`,`starttime`,`endtime`,`address`,`enrolltime`,`state`,`city`) values ('951384896167874560','??',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
/*Table structure for table `tb_usergath` */
DROP TABLE IF EXISTS `tb_usergath`;
CREATE TABLE `tb_usergath` (
`userid` varchar(20) NOT NULL COMMENT '用户ID',
`gathid` varchar(20) NOT NULL COMMENT '活动ID',
`exetime` datetime DEFAULT NULL COMMENT '点击时间',
PRIMARY KEY (`userid`,`gathid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户关注活动';
/*Data for the table `tb_usergath` */
insert into `tb_usergath`(`userid`,`gathid`,`exetime`) values ('1','200','2018-01-06 15:44:04');
/*!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 */;
db_qa.sql
/*
SQLyog v10.2
MySQL - 5.5.49 : Database - tensquare_qa
*********************************************************************
*/
/*!40101 SET NAMES utf8 */;
/*!40101 SET SQL_MODE=''*/;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/`tensquare_qa` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `tensquare_qa`;
/*Table structure for table `tb_pl` */
DROP TABLE IF EXISTS `tb_pl`;
CREATE TABLE `tb_pl` (
`problemid` varchar(20) NOT NULL COMMENT '问题ID',
`labelid` varchar(20) NOT NULL COMMENT '标签ID',
PRIMARY KEY (`problemid`,`labelid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*Data for the table `tb_pl` */
insert into `tb_pl`(`problemid`,`labelid`) values ('1','1');
/*Table structure for table `tb_problem` */
DROP TABLE IF EXISTS `tb_problem`;
CREATE TABLE `tb_problem` (
`id` varchar(20) NOT NULL COMMENT 'ID',
`title` varchar(100) DEFAULT NULL COMMENT '标题',
`content` text COMMENT '内容',
`createtime` datetime DEFAULT NULL COMMENT '创建日期',
`updatetime` datetime DEFAULT NULL COMMENT '修改日期',
`userid` varchar(20) DEFAULT NULL COMMENT '用户ID',
`nickname` varchar(100) DEFAULT NULL COMMENT '昵称',
`visits` bigint(20) DEFAULT NULL COMMENT '浏览量',
`thumbup` bigint(20) DEFAULT NULL COMMENT '点赞数',
`reply` bigint(20) DEFAULT NULL COMMENT '回复数',
`solve` varchar(1) DEFAULT NULL COMMENT '是否解决',
`replyname` varchar(100) DEFAULT NULL COMMENT '回复人昵称',
`replytime` datetime DEFAULT NULL COMMENT '回复日期',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='问题';
/*Data for the table `tb_problem` */
insert into `tb_problem`(`id`,`title`,`content`,`createtime`,`updatetime`,`userid`,`nickname`,`visits`,`thumbup`,`reply`,`solve`) values
('1','这是个问题','代码调试不通咋办?','2018-01-08 11:50:50','2018-01-09 11:50:54','2',NULL,101,NULL,NULL,NULL);
/*Table structure for table `tb_reply` */
DROP TABLE IF EXISTS `tb_reply`;
CREATE TABLE `tb_reply` (
`id` varchar(20) NOT NULL COMMENT '编号',
`problemid` varchar(20) DEFAULT NULL COMMENT '问题ID',
`content` text COMMENT '回答内容',
`createtime` datetime DEFAULT NULL COMMENT '创建日期',
`updatetime` datetime DEFAULT NULL COMMENT '更新日期',
`userid` varchar(20) DEFAULT NULL COMMENT '回答人ID',
`nickname` varchar(100) DEFAULT NULL COMMENT '回答人昵称',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='回答';
/*Data for the table `tb_reply` */
insert into `tb_reply`(`id`,`problemid`,`content`,`createtime`,`updatetime`,`userid`,`nickname`) values
('','1',NULL,NULL,NULL,NULL,NULL);
insert into `tb_reply`(`id`,`problemid`,`content`,`createtime`,`updatetime`,`userid`,`nickname`) values
('2','1','问老师呗','2018-01-10 14:14:06',NULL,'1',NULL);
insert into `tb_reply`(`id`,`problemid`,`content`,`createtime`,`updatetime`,`userid`,`nickname`) values
('3','2','明天再调','2018-01-07 14:14:13',NULL,'1',NULL);
/*Table structure for table `tb_ul` */
DROP TABLE IF EXISTS `tb_ul`;
CREATE TABLE `tb_ul` (
`uid` varchar(20) NOT NULL COMMENT '用户ID',
`lid` varchar(20) NOT NULL COMMENT '标签ID',
PRIMARY KEY (`uid`,`lid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*Data for the table `tb_ul` */
/*!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 */;
db_reruit.sql
/*
SQLyog v10.2
MySQL - 5.5.49 : Database - tensquare_recruit
*********************************************************************
*/
/*!40101 SET NAMES utf8 */;
/*!40101 SET SQL_MODE=''*/;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/`tensquare_recruit` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `tensquare_recruit`;
/*Table structure for table `tb_enterprise` */
DROP TABLE IF EXISTS `tb_enterprise`;
CREATE TABLE `tb_enterprise` (
`id` varchar(20) NOT NULL COMMENT 'ID',
`name` varchar(100) DEFAULT NULL COMMENT '企业名称',
`summary` varchar(1000) DEFAULT NULL COMMENT '企业简介',
`address` varchar(100) DEFAULT NULL COMMENT '企业地址',
`labels` varchar(100) DEFAULT NULL COMMENT '标签列表',
`coordinate` varchar(100) DEFAULT NULL COMMENT '坐标',
`ishot` varchar(1) DEFAULT NULL COMMENT '是否热门',
`logo` varchar(100) DEFAULT NULL COMMENT 'LOGO',
`jobcount` int DEFAULT NULL COMMENT '职位数',
`url` varchar(100) DEFAULT NULL COMMENT 'URL',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='企业';
/*Data for the table `tb_enterprise` */
insert into `tb_enterprise`(`id`,`name`,`summary`,`address`,`labels`,`coordinate`,`ishot`)
values ('','传智播客','国内著名IT教育机构','金燕龙办公楼','IT 培训','1019,2223','1');
insert into `tb_enterprise`(`id`,`name`,`summary`,`address`,`labels`,`coordinate`,`ishot`)
values ('2','小米','手机厂商','中关村软件园','手机','0211,3333','0');
/*Table structure for table `tb_recruit` */
DROP TABLE IF EXISTS `tb_recruit`;
CREATE TABLE `tb_recruit` (
`id` varchar(20) NOT NULL COMMENT 'ID',
`jobname` varchar(100) DEFAULT NULL COMMENT '职位名称',
`salary` varchar(100) DEFAULT NULL COMMENT '薪资范围',
`condition` varchar(100) DEFAULT NULL COMMENT '经验要求',
`education` varchar(100) DEFAULT NULL COMMENT '学历要求',
`type` varchar(1) DEFAULT NULL COMMENT '任职方式',
`address` varchar(100) DEFAULT NULL COMMENT '办公地址',
`eid` varchar(20) DEFAULT NULL COMMENT '企业ID',
`createtime` datetime DEFAULT NULL COMMENT '创建日期',
`state` varchar(1) DEFAULT NULL COMMENT '状态',
`url` varchar(100) DEFAULT NULL COMMENT '网址',
`label` varchar(100) DEFAULT NULL COMMENT '标签',
`content1` varchar(100) DEFAULT NULL COMMENT '职位描述',
`content2` varchar(100) DEFAULT NULL COMMENT '职位要求',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='职位';
/*Data for the table `tb_recruit` */
insert into `tb_recruit`(`id`,`jobname`,`salary`,`condition`,`education`,`type`,`address`,`eid`,`createtime`,`state`,`url`)
values ('','大数据工程师','20000-30000','八年以上开发经验','本科','1','国贸','1','2018-01-06 16:21:12','1',NULL);
insert into `tb_recruit`(`id`,`jobname`,`salary`,`condition`,`education`,`type`,`address`,`eid`,`createtime`,`state`,`url`)
values ('1','java开发工程师','15000-20000','五年以上开发经验','本科','1','中关村软件园','1','2018-01-05 15:38:05','1','http://www.baidu.com');
insert into `tb_recruit`(`id`,`jobname`,`salary`,`condition`,`education`,`type`,`address`,`eid`,`createtime`,`state`,`url`)
values ('2','php开发工程师','4000-6000','一年以上开发经验','专科','1','王府街宏福创业园','1','2018-01-07 16:10:20','1','http://www.baidu.com');
insert into `tb_recruit`(`id`,`jobname`,`salary`,`condition`,`education`,`type`,`address`,`eid`,`createtime`,`state`,`url`)
values ('3','.net开发工程师','2000-3000','一年以上开发经验','专科','1','大望路','1','2018-01-06 16:20:27','2',NULL);
insert into `tb_recruit`(`id`,`jobname`,`salary`,`condition`,`education`,`type`,`address`,`eid`,`createtime`,`state`,`url`)
values ('5','前端开发工程师','8000-12000','三年以上开发经验','本科','1','上地','1','2018-01-18 16:22:11','2',NULL);
/*!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 */;
db_user.sql
/*
SQLyog v10.2
MySQL - 5.5.49 : Database - tensquare_user
*********************************************************************
*/
/*!40101 SET NAMES utf8 */;
/*!40101 SET SQL_MODE=''*/;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/`tensquare_user` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `tensquare_user`;
/*Table structure for table `tb_admin` */
DROP TABLE IF EXISTS `tb_admin`;
CREATE TABLE `tb_admin` (
`id` varchar(20) NOT NULL COMMENT 'ID',
`loginname` varchar(100) DEFAULT NULL COMMENT '登陆名称',
`password` varchar(100) DEFAULT NULL COMMENT '密码',
`state` varchar(1) DEFAULT NULL COMMENT '状态',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='管理员';
/*Data for the table `tb_admin` */
/*Table structure for table `tb_follow` */
DROP TABLE IF EXISTS `tb_follow`;
CREATE TABLE `tb_follow` (
`userid` varchar(20) NOT NULL COMMENT '用户ID',
`targetuser` varchar(20) NOT NULL COMMENT '被关注用户ID',
PRIMARY KEY (`userid`,`targetuser`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*Data for the table `tb_follow` */
insert into `tb_follow`(`userid`,`targetuser`) values ('1','1');
insert into `tb_follow`(`userid`,`targetuser`) values ('1','10');
/*Table structure for table `tb_user` */
DROP TABLE IF EXISTS `tb_user`;
CREATE TABLE `tb_user` (
`id` varchar(20) NOT NULL COMMENT 'ID',
`loginname` varchar(100) DEFAULT NULL COMMENT '登录名',
`mobile` varchar(100) DEFAULT NULL COMMENT '手机号码',
`password` varchar(100) DEFAULT NULL COMMENT '密码',
`nickname` varchar(100) DEFAULT NULL COMMENT '昵称',
`sex` varchar(2) DEFAULT NULL COMMENT '性别',
`birthday` datetime DEFAULT NULL COMMENT '出生年月日',
`avatar` varchar(100) DEFAULT NULL COMMENT '头像',
`email` varchar(100) DEFAULT NULL COMMENT 'E-Mail',
`regdate` datetime DEFAULT NULL COMMENT '注册日期',
`updatedate` datetime DEFAULT NULL COMMENT '修改日期',
`lastdate` datetime DEFAULT NULL COMMENT '最后登陆日期',
`online` bigint(20) DEFAULT NULL COMMENT '在线时长(分钟)',
`interest` varchar(100) DEFAULT NULL COMMENT '兴趣',
`personality` varchar(100) DEFAULT NULL COMMENT '个性',
`fanscount` int(20) DEFAULT NULL COMMENT '粉丝数',
`followcount` int(20) DEFAULT NULL COMMENT '关注数',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户';
/*Data for the table `tb_user` */
insert into `tb_user`(`id`,`loginname`,`password`,`nickname`,`sex`,`birthday`,`avatar`,`mobile`,`email`,`regdate`,
`updatedate`,`lastdate`,`online`,`interest`,`personality`,`fanscount`,`followcount`) values
('1','testuser','111111','小白','男','2018-01-08 15:39:19',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,1,0);
/*!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 */;
软件下载地址:https://download.csdn.net/download/wingzhezhe/10530924
父工程中的src文件夹无用,将其删除
4.0.0
com.scf
scf_parent
1.0-SNAPSHOT
pom
scf_parent
十次方项目
org.springframework.boot
spring-boot-starter-parent
2.0.1.RELEASE
UTF-8
UTF-8
1.8
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-test
test
spring-snapshots
Spring Snapshots
https://repo.spring.io/snapshot
true
spring-milestones
Spring Milestones
https://repo.spring.io/milestone
false
spring-snapshots
Spring Snapshots
https://repo.spring.io/snapshot
true
spring-milestones
Spring Milestones
https://repo.spring.io/milestone
false
StatusCode.java
package entity;
/**
* 返回结果状态码实体类
*/
public class StatusCode {
public static final int OK = 20000;
public static final int ERROR = 20001;
public static final int LOGINERROR = 20002; //用户名或密码错误
public static final int ACCESSERROR = 20003; //权限不足
public static final int REMOTEERROR = 20004; //远程调用失败
public static final int REPEERROR = 20005; //重复操作
}
Result.java
package entity;
import jdk.nashorn.internal.objects.annotations.Setter;
/**
* 通用返回结果实体类
*/
public class Result {
private boolean flag; //是否成功
private Integer code; //返回码
private String message; //返回结果信息
private Object data; //返回数据
public Result(Object data) {
}
public Result(boolean flag, Integer code, String message, Object data) {
this.flag = flag;
this.code = code;
this.message = message;
this.data = data;
}
getter/Setter
@Override
public String toString() {
return "Result{" +
"flag=" + flag +
", code=" + code +
", message='" + message + '\'' +
", data=" + data +
'}';
}
}
PageResult.java
package entity;
import java.util.List;
/**
* 分页数据返回结果实体类
*/
public class PageResult {
private Long total;
private List rows;
setter/Getter
}
package util;
import java.lang.management.ManagementFactory;
import java.net.InetAddress;
import java.net.NetworkInterface;
/**
* 名称:IdWorker.java
* 描述:分布式自增长ID
*
* Twitter的 Snowflake JAVA实现方案
*
* 核心代码为其IdWorker这个类实现,其原理结构如下,我分别用一个0表示一位,用—分割开部分的作用:
* 1||0---0000000000 0000000000 0000000000 0000000000 0 --- 00000 ---00000 ---000000000000
* 在上面的字符串中,第一位为未使用(实际上也可作为long的符号位),接下来的41位为毫秒级时间,
* 然后5位datacenter标识位,5位机器ID(并不算标识符,实际是为线程标识),
* 然后12位该毫秒内的当前毫秒内的计数,加起来刚好64位,为一个Long型。
* 这样的好处是,整体上按照时间自增排序,并且整个分布式系统内不会产生ID碰撞(由datacenter和机器ID作区分),
* 并且效率较高,经测试,snowflake每秒能够产生26万ID左右,完全满足需要。
*
* 64位ID (42(毫秒)+5(机器ID)+5(业务编码)+12(重复累加))
*
* @author Polim
*/
public class IdWorker {
// 时间起始标记点,作为基准,一般取系统的最近时间(一旦确定不能变动)
private final static long twepoch = 1288834974657L;
// 机器标识位数
private final static long workerIdBits = 5L;
// 数据中心标识位数
private final static long datacenterIdBits = 5L;
// 机器ID最大值
private final static long maxWorkerId = -1L ^ (-1L << workerIdBits);
// 数据中心ID最大值
private final static long maxDatacenterId = -1L ^ (-1L << datacenterIdBits);
// 毫秒内自增位
private final static long sequenceBits = 12L;
// 机器ID偏左移12位
private final static long workerIdShift = sequenceBits;
// 数据中心ID左移17位
private final static long datacenterIdShift = sequenceBits + workerIdBits;
// 时间毫秒左移22位
private final static long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits;
private final static long sequenceMask = -1L ^ (-1L << sequenceBits);
/* 上次生产id时间戳 */
private static long lastTimestamp = -1L;
// 0,并发控制
private long sequence = 0L;
private final long workerId;
// 数据标识id部分
private final long datacenterId;
public IdWorker() {
this.datacenterId = getDatacenterId(maxDatacenterId);
this.workerId = getMaxWorkerId(datacenterId, maxWorkerId);
}
/**
* @param workerId 工作机器ID
* @param datacenterId 序列号
*/
public IdWorker(long workerId, long datacenterId) {
if (workerId > maxWorkerId || workerId < 0) {
throw new IllegalArgumentException(String.format("worker Id can't be greater than %d or less than 0", maxWorkerId));
}
if (datacenterId > maxDatacenterId || datacenterId < 0) {
throw new IllegalArgumentException(String.format("datacenter Id can't be greater than %d or less than 0", maxDatacenterId));
}
this.workerId = workerId;
this.datacenterId = datacenterId;
}
/**
* 获取下一个ID
*
* @return
*/
public synchronized long nextId() {
long timestamp = timeGen();
if (timestamp < lastTimestamp) {
throw new RuntimeException(String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp));
}
if (lastTimestamp == timestamp) {
// 当前毫秒内,则+1
sequence = (sequence + 1) & sequenceMask;
if (sequence == 0) {
// 当前毫秒内计数满了,则等待下一秒
timestamp = tilNextMillis(lastTimestamp);
}
} else {
sequence = 0L;
}
lastTimestamp = timestamp;
// ID偏移组合生成最终的ID,并返回ID
long nextId = ((timestamp - twepoch) << timestampLeftShift)
| (datacenterId << datacenterIdShift)
| (workerId << workerIdShift) | sequence;
return nextId;
}
private long tilNextMillis(final long lastTimestamp) {
long timestamp = this.timeGen();
while (timestamp <= lastTimestamp) {
timestamp = this.timeGen();
}
return timestamp;
}
private long timeGen() {
return System.currentTimeMillis();
}
/**
*
* 获取 maxWorkerId
*
*/
protected static long getMaxWorkerId(long datacenterId, long maxWorkerId) {
StringBuffer mpid = new StringBuffer();
mpid.append(datacenterId);
String name = ManagementFactory.getRuntimeMXBean().getName();
if (!name.isEmpty()) {
/*
* GET jvmPid
*/
mpid.append(name.split("@")[0]);
}
/*
* MAC + PID 的 hashcode 获取16个低位
*/
return (mpid.toString().hashCode() & 0xffff) % (maxWorkerId + 1);
}
/**
*
* 数据标识id部分
*
*/
protected static long getDatacenterId(long maxDatacenterId) {
long id = 0L;
try {
InetAddress ip = InetAddress.getLocalHost();
NetworkInterface network = NetworkInterface.getByInetAddress(ip);
if (network == null) {
id = 1L;
} else {
byte[] mac = network.getHardwareAddress();
id = ((0x000000FF & (long) mac[mac.length - 1])
| (0x0000FF00 & (((long) mac[mac.length - 2]) << 8))) >> 6;
id = id % (maxDatacenterId + 1);
}
} catch (Exception e) {
System.out.println(" getDatacenterId: " + e.getMessage());
}
return id;
}
}
scf_parent
com.scf
1.0-SNAPSHOT
4.0.0
scf_base
org.springframework.boot
spring-boot-starter-data-jpa
mysql
mysql-connector-java
com.scf
scf_common
1.0-SNAPSHOT
package com.scf.base;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import util.IdWorker;
/**
* springboot启动类
*/
@SpringBootApplication
public class BaseApplication {
public static void main(String[] args) {
SpringApplication.run(BaseApplication.class);
}
/**
* 初始ID的雪花生成器
*/
@Bean
public IdWorker idWorker(){
return new IdWorker(1, 1);
}
}
# 配置tomcat端口号
server:
port: 9001
# 配置注册中心中当前应用名称,名称不要有下划线_
spring:
application:
name: scf-base
datasource:
url: jdbc:mysql://192.168.37.133:3306/tensquare_base?characterEncoding=utf-8
driver-class-name: com.mysql.jdbc.Driver
username: root
password: 123456
jpa:
show-sql: true
database: mysql
Label.java
package com.scf.base.pojo;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
/**
* 标签实体类,对应数据库tensquare_base中的tb_label表
*/
@Entity
@Table(name = "tb_label")
public class Label implements Serializable {
@Id
private String id; //主键
private String labelname; //标签名称
private String state; //状态
private Long count; //使用数量
private String recommend; //是否推荐
private Long fans; //关注数
public Label(String id, String labelname, String state, Long count, String recommend, Long fans) {
this.id = id;
this.labelname = labelname;
this.state = state;
this.count = count;
this.recommend = recommend;
this.fans = fans;
}
public Label() {
}
setter/getter
@Override
public String toString() {
return "Label{" +
"id='" + id + '\'' +
", labelname='" + labelname + '\'' +
", state='" + state + '\'' +
", count=" + count +
", recommend='" + recommend + '\'' +
", fans=" + fans +
'}';
}
}
LabelDao.java
package com.scf.base.dao;
import com.scf.base.pojo.Label;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* 标签的数据访问层接口
*/
public interface LabelDao extends JpaRepository
LabelService.java
package com.scf.base.service;
import com.scf.base.dao.LabelDao;
import com.scf.base.pojo.Label;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import util.IdWorker;
import java.util.List;
/**
* 标签业务层
*/
@Service
public class LabelService {
@Autowired
private LabelDao labelDao;
@Autowired
private IdWorker idWorker;
/**
* 查询所有标签列表
* @return
*/
public List findAll(){
return labelDao.findAll();
}
/**
* 根据id查询标签对象
* @param id
* @return
*/
public Label findById(String id){
return labelDao.findById(id).get();
}
/**
* 添加标签
* @param label
*/
public void addLabel(Label label){
label.setId(idWorker.nextId() + "");
labelDao.save(label);
}
/**
* 更新标签
* @param label
*/
public void updateLabel(Label label){
labelDao.save(label);
}
/**
* 根据id删除标签
* @param id
*/
public void delLabelById(String id){
labelDao.deleteById(id);
}
}
LabelController.java
package com.scf.base.controller;
import com.scf.base.pojo.Label;
import com.scf.base.service.LabelService;
import entity.Result;
import entity.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 标签web层
*/
@RestController
@RequestMapping("/label")
@CrossOrigin //解决跨域请求问题
public class LabelController {
@Autowired
private LabelService labelService;
/**
* get请求查询所有标签列表
*
* @return
*/
@RequestMapping(method = RequestMethod.GET)
public Result findAll() {
List labelList = labelService.findAll();
return new Result(true, StatusCode.OK, "查询成功", labelList);
}
/**
* get请求的根据id查询
*
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public Result findById(@PathVariable String id) {
Label label = labelService.findById(id);
return new Result(true, StatusCode.OK, "查询成功", label);
}
/**
* POST方式的增加
*
* @param label
* @return
*/
@RequestMapping(method = RequestMethod.POST)
public Result add(@RequestBody Label label) {
labelService.addLabel(label);
return new Result(true, StatusCode.OK, "添加成功", null);
}
/**
* 根据ID修改的PUT提交方式
* @param label
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
public Result update(@RequestBody Label label, @PathVariable String id) {
label.setId(id);
labelService.updateLabel(label);
return new Result(true, StatusCode.OK, "修改成功", null);
}
/**
* 根据id删除
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
public Result deleteById(@PathVariable String id){
labelService.delLabelById(id);
return new Result(true, StatusCode.OK, "删除成功", null);
}
}
BaseExceptionHandler.java
package com.scf.base.controller;
import entity.Result;
import entity.StatusCode;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* 公共异常处理类
*/
@ControllerAdvice
public class BaseExceptionHandler {
@ResponseBody
@ExceptionHandler(value = Exception.class) //value对应的是要处理的异常类型
public Result error(Exception e){
e.printStackTrace();
return new Result(false, StatusCode.ERROR, e.getMessage(), null);
}
}
/**
* 带条件查询标签列表
* @param searchMap
* @return
*/
@RequestMapping(value = "/search",method = RequestMethod.POST)
public Result findSpecification(@RequestBody Map searchMap){
List labelList = labelService.findLabelBySpecification(searchMap);
return new Result(true, StatusCode.OK, "查询成功", labelList);
}
/**
* 带条件查询标签列表
*
* @param searchMap :条件集合
* @return
*/
public List findLabelBySpecification(Map searchMap) {
Specification specification = this.createSpec(searchMap);
return labelDao.findAll(specification);
}
/**
* 封装查询条件
*
* @param searchMap
* @return
*/
private Specification createSpec(Map searchMap) {
return new Specification() {
@Override
public Predicate toPredicate(Root root, CriteriaQuery> criteriaQuery, CriteriaBuilder cb) {
//创建查询条件集合
List predList = new ArrayList();
if (searchMap != null) {
//封装查询条件
if (searchMap.get("labelname") != null && !"".equals(searchMap.get("labelname"))) {
predList.add(cb.like(root.get("labelname").as(String.class), "%" + (String) searchMap.get("labelname") + "%"));
}
if (searchMap.get("state") != null && !"".equals(searchMap.get("state"))) {
predList.add(cb.equal(root.get("state").as(String.class), (String) searchMap.get("state")));
}
if (searchMap.get("recommend") != null && !"".equals(searchMap.get("recommend"))) {
predList.add(cb.equal(root.get("recommend").as(String.class), (String) searchMap.get("recommend")));
}
}
return cb.and(predList.toArray(new Predicate[predList.size()]));
}
};
}
/**
* 带条件的分页查询
*
* @param searchMap
* @param page 当前页
* @param size 每页显示条数
* @return
*/
@RequestMapping(value = "/search/{page}/{size}", method = RequestMethod.POST)
public Result findByPage(@RequestBody Map searchMap, @PathVariable(name = "page") int page, @PathVariable int size) {
Page pageList = labelService.findByPage(searchMap, page, size);
PageResult pageResult = new PageResult(pageList.getTotalElements(), pageList.getContent());
return new Result(true, StatusCode.OK, "查询成功", pageResult);
}
/**
* 带条件的分页查询方法
* @param searchMap
* @param page 当前页
* @param size 每页显示条数
* @return
*/
public Page findByPage(Map searchMap, int page, int size) {
Specification specification = this.createSpec(searchMap);
PageRequest pageRequest = PageRequest.of(page - 1, size);
return labelDao.findAll(specification, pageRequest);
}