﻿/*
Navicat MySQL Data Transfer

Source Server         : 192.168.17.250
Source Server Version : 50718
Source Host           : 192.168.17.250:3306
Source Database       : platform

Target Server Type    : MYSQL
Target Server Version : 50718
File Encoding         : 65001

Date: 2017-09-15 10:21:09
*/

SET FOREIGN_KEY_CHECKS=0;

-- ----------------------------
-- Table structure for tr_perm
-- ----------------------------
DROP TABLE IF EXISTS `tr_perm`;
CREATE TABLE `tr_perm` (
  `perm_id` varchar(50) NOT NULL COMMENT '权限ID',
  `perm_name` varchar(50) NOT NULL COMMENT '权限名',
  `perm_div` char(2) NOT NULL COMMENT '权限区分',
  `perm_code` varchar(100) NOT NULL COMMENT '权限码',
  `create_user_id` varchar(50) NOT NULL COMMENT '创建用户ID',
  `create_timestamp` timestamp(6) NULL DEFAULT NULL COMMENT '创建时间戳',
  `update_user_id` varchar(50) DEFAULT NULL COMMENT '更新用户ID',
  `update_timestamp` timestamp(6) NULL DEFAULT NULL COMMENT '更新时间戳',
  PRIMARY KEY (`perm_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='权限表';

-- ----------------------------
-- Records of tr_perm
-- ----------------------------
INSERT INTO `tr_perm` VALUES ('P15D63DC0BEBV3700', '查看权限', '02', 'view', 'U188E17B55DFTXXF8', '2017-07-21 14:35:51.659000', 'U188E17B55DFTXXF8', '2017-07-21 14:35:51.659000');
INSERT INTO `tr_perm` VALUES ('P15D63DC58C59PY72', '开关权限', '02', 'switch', 'U188E17B55DFTXXF8', '2017-07-21 14:36:11.333000', 'U188E17B55DFTXXF8', '2017-07-21 14:36:11.333000');
INSERT INTO `tr_perm` VALUES ('P15D63DCC157IC5YD', '添加权限', '02', 'add', 'U188E17B55DFTXXF8', '2017-07-21 14:36:38.103000', 'U188E17B55DFTXXF8', '2017-07-21 14:36:38.103000');
INSERT INTO `tr_perm` VALUES ('P15D63DD113DD7GZS', '使能权限', '02', 'enable', 'U188E17B55DFTXXF8', '2017-07-21 14:36:58.557000', 'U188E17B55DFTXXF8', '2017-07-21 14:36:58.557000');
INSERT INTO `tr_perm` VALUES ('P15D63DD57CFULSJH', '删除权限', '02', 'delete', 'U188E17B55DFTXXF8', '2017-07-21 14:37:16.623000', 'U188E17B55DFTXXF8', '2017-07-21 14:37:16.623000');
INSERT INTO `tr_perm` VALUES ('P15D63DD8FF12IAJU', '编辑权限', '02', 'edit', 'U188E17B55DFTXXF8', '2017-07-21 14:37:30.993000', 'U188E17B55DFTXXF8', '2017-07-21 14:37:30.993000');

-- ----------------------------
-- Table structure for tr_perm_group
-- ----------------------------
DROP TABLE IF EXISTS `tr_perm_group`;
CREATE TABLE `tr_perm_group` (
  `perm_group_id` varchar(50) NOT NULL COMMENT '权限组ID',
  `perm_id` varchar(50) NOT NULL COMMENT '权限ID',
  PRIMARY KEY (`perm_group_id`,`perm_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='权限组表';

-- ----------------------------
-- Records of tr_perm_group
-- ----------------------------
INSERT INTO `tr_perm_group` VALUES ('PG15D63DE3E1E7JRF9', 'P15D63DC0BEBV3700');
INSERT INTO `tr_perm_group` VALUES ('PG15D63DE9356KPY50', 'P15D63DC58C59PY72');
INSERT INTO `tr_perm_group` VALUES ('PG15D63DE9356KPY50', 'P15D63DCC157IC5YD');
INSERT INTO `tr_perm_group` VALUES ('PG15D63DE9356KPY50', 'P15D63DD113DD7GZS');
INSERT INTO `tr_perm_group` VALUES ('PG15D63DE9356KPY50', 'P15D63DD57CFULSJH');
INSERT INTO `tr_perm_group` VALUES ('PG15D63DE9356KPY50', 'P15D63DD8FF12IAJU');

-- ----------------------------
-- Table structure for tr_user
-- ----------------------------
DROP TABLE IF EXISTS `tr_user`;
CREATE TABLE `tr_user` (
  `user_id` varchar(50) NOT NULL COMMENT '用户ID',
  `user_div` char(2) NOT NULL COMMENT '用户区分',
  `user_account` varchar(50) NOT NULL COMMENT '用户账户',
  `password` varchar(50) NOT NULL COMMENT '登录密码',
  `cookie_password` varchar(50) DEFAULT NULL COMMENT 'cookie密码',
  `farm_id` varchar(50) DEFAULT NULL COMMENT '农场ID',
  `pwd_update_div` char(2) NOT NULL COMMENT '密码修改区分',
  `create_user_id` varchar(50) NOT NULL COMMENT '创建用户ID',
  `create_timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间戳',
  `update_user_id` varchar(50) NOT NULL COMMENT '更新用户ID',
  `update_timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT   '更新时间戳',
  `delete_user_id` varchar(50) DEFAULT NULL COMMENT '删除用户ID',
  `delete_timestamp` timestamp NULL DEFAULT NULL COMMENT '删除时间戳',
  PRIMARY KEY (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户表';

-- ----------------------------
-- Records of tr_user
-- ----------------------------

INSERT INTO `tr_user` VALUES ('U188E17B55DFTXXF8', '01', '10000000001', '17052D0434P8D50QFD05', '39DPV0ZE8S', '', '02', '10000000001', '2017-07-21 15:18:47', 'U188E17B55DFTXXF8', '2017-07-21 15:18:47', null, null);

-- ----------------------------
-- Table structure for tr_user_create_perm_group
-- ----------------------------
DROP TABLE IF EXISTS `tr_user_create_perm_group`;
CREATE TABLE `tr_user_create_perm_group` (
  `user_id` varchar(50) NOT NULL COMMENT '用户ID',
  `perm_group_id` varchar(50) NOT NULL COMMENT '权限组ID',
  `perm_group_name` varchar(50) NOT NULL COMMENT '权限组名',
  `create_user_id` varchar(50) NOT NULL COMMENT '创建用户ID',
  `create_timestamp` timestamp(6) NULL DEFAULT NULL COMMENT '创建时间戳',
  `update_user_id` varchar(50) DEFAULT NULL COMMENT '更新用户ID',
  `update_timestamp` timestamp(6) NULL DEFAULT NULL COMMENT '更新时间戳',
  PRIMARY KEY (`user_id`,`perm_group_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户创建权限组表';

-- ----------------------------
-- Records of tr_user_create_perm_group
-- ----------------------------
INSERT INTO `tr_user_create_perm_group` VALUES ('U188E17B55DFTXXF8', 'PG15D63DE3E1E7JRF9', '普通用户', 'U188E17B55DFTXXF8', '2017-07-21 14:38:15.583000', 'U188E17B55DFTXXF8', '2017-07-21 14:38:15.583000');
INSERT INTO `tr_user_create_perm_group` VALUES ('U188E17B55DFTXXF8', 'PG15D63DE9356KPY50', '农场主', 'U188E17B55DFTXXF8', '2017-07-21 14:38:37.398000', 'U188E17B55DFTXXF8', '2017-07-21 14:38:37.398000');

-- ----------------------------
-- Table structure for tr_user_detail
-- ----------------------------
DROP TABLE IF EXISTS `tr_user_detail`;
CREATE TABLE `tr_user_detail` (
  `user_id` varchar(50) NOT NULL COMMENT '用户ID',
  `mobile_no` varchar(11) NOT NULL COMMENT '手机号',
  `real_name` varchar(50) NOT NULL COMMENT '真实姓名',
  `id_card_no` varchar(18) DEFAULT NULL COMMENT '身份证号',
  PRIMARY KEY (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户详细表';

-- ----------------------------
-- Table structure for tr_user_farm
-- ----------------------------
DROP TABLE IF EXISTS `tr_user_farm`;
CREATE TABLE `tr_user_farm` (
  `user_id` varchar(50) NOT NULL COMMENT '用户ID',
  `farm_id` varchar(50) NOT NULL COMMENT '农场ID',
  PRIMARY KEY (`user_id`,`farm_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户农场表';



-- ----------------------------
-- Table structure for tr_user_login
-- ----------------------------
DROP TABLE IF EXISTS `tr_user_login`;
CREATE TABLE `tr_user_login` (
  `login_user_name` varchar(50) NOT NULL COMMENT '登录用户名:手机号',
  `user_id` varchar(50) NOT NULL COMMENT '用户ID:自动生成',
  PRIMARY KEY (`login_user_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户登录表';


-- ----------------------------
-- Table structure for tr_user_perm_group
-- ----------------------------
DROP TABLE IF EXISTS `tr_user_perm_group`;
CREATE TABLE `tr_user_perm_group` (
  `user_id` varchar(50) NOT NULL COMMENT '用户ID',
  `perm_group_id` varchar(50) NOT NULL COMMENT '权限组ID',
  PRIMARY KEY (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户权限组';



-- ----------------------------
-- Table structure for tr_use_login_record
-- ----------------------------
DROP TABLE IF EXISTS `tr_use_login_record`;
CREATE TABLE `tr_use_login_record` (
  `user_id` varchar(50) NOT NULL COMMENT '用户ID',
  `login_timestamp` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6) COMMENT '登录时间戳',
  `plan_div` char(2) NOT NULL COMMENT '平台区分',
  PRIMARY KEY (`user_id`,`login_timestamp`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户登录记录表';

INSERT INTO `tr_user_login` VALUES ('10000000001', 'U188E17B55DFTXXF8');
INSERT INTO `tr_user_detail` VALUES ('U188E17B55DFTXXF8', '10000000001', '超级管理员', null);