-
Notifications
You must be signed in to change notification settings - Fork 1
/
snut_tdms.sql
237 lines (210 loc) · 8.65 KB
/
snut_tdms.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
/*
Navicat MySQL Data Transfer
Source Server : localhost
Source Server Version : 50549
Source Host : localhost:3306
Source Database : snut_tdms
Target Server Type : MYSQL
Target Server Version : 50549
File Encoding : 65001
Date: 2018-04-27 10:35:10
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for backup_data
-- ----------------------------
DROP TABLE IF EXISTS `backup_data`;
CREATE TABLE `backup_data` (
`id` varchar(255) NOT NULL,
`type` varchar(255) DEFAULT NULL,
`user` varchar(255) DEFAULT NULL,
`time` datetime DEFAULT NULL,
`flag` int(1) unsigned zerofill DEFAULT '0' COMMENT '0表示正常,1表示已被覆盖',
PRIMARY KEY (`id`),
KEY `user` (`user`),
CONSTRAINT `backup_data_ibfk_1` FOREIGN KEY (`user`) REFERENCES `user` (`username`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Table structure for class_type
-- ----------------------------
DROP TABLE IF EXISTS `class_type`;
CREATE TABLE `class_type` (
`id` varchar(255) NOT NULL,
`name` varchar(255) DEFAULT NULL,
`department` varchar(255) DEFAULT NULL,
`user` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `department` (`department`),
KEY `class_type_ibfk_2` (`user`),
CONSTRAINT `class_type_ibfk_1` FOREIGN KEY (`department`) REFERENCES `department` (`code`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `class_type_ibfk_2` FOREIGN KEY (`user`) REFERENCES `user` (`username`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Table structure for data
-- ----------------------------
DROP TABLE IF EXISTS `data`;
CREATE TABLE `data` (
`id` varchar(255) NOT NULL,
`content` varchar(255) DEFAULT NULL,
`file_name` varchar(255) DEFAULT NULL,
`src` varchar(255) DEFAULT NULL,
`data_class` varchar(255) DEFAULT NULL,
`type_contents` varchar(255) DEFAULT NULL,
`user` varchar(255) DEFAULT NULL,
`submit_time` datetime DEFAULT NULL,
`delete_time` datetime DEFAULT NULL,
`flag` int(255) DEFAULT '0' COMMENT '''0''表示正常,''1''表示被逻辑删除,''2''表示被彻底删除',
PRIMARY KEY (`id`) USING BTREE,
KEY `data_ibfk_1` (`data_class`),
KEY `data_ibfk_2` (`user`),
CONSTRAINT `data_ibfk_1` FOREIGN KEY (`data_class`) REFERENCES `data_class` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE,
CONSTRAINT `data_ibfk_2` FOREIGN KEY (`user`) REFERENCES `user` (`username`) ON DELETE NO ACTION ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
-- ----------------------------
-- Table structure for data_class
-- ----------------------------
DROP TABLE IF EXISTS `data_class`;
CREATE TABLE `data_class` (
`id` varchar(255) NOT NULL,
`name` varchar(255) DEFAULT NULL,
`role` varchar(255) DEFAULT NULL,
`user` varchar(255) DEFAULT NULL,
`department` varchar(255) DEFAULT NULL,
`class_types` varchar(255) DEFAULT NULL,
`flag` int(255) DEFAULT '0' COMMENT '0表示公共类型未审核,1表示公共类型已审核,2表示私人类型,3表示已被删除',
PRIMARY KEY (`id`),
KEY `role` (`role`),
KEY `data_class_ibfk_2` (`user`),
KEY `department` (`department`),
CONSTRAINT `data_class_ibfk_1` FOREIGN KEY (`role`) REFERENCES `role` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `data_class_ibfk_2` FOREIGN KEY (`user`) REFERENCES `user` (`username`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `data_class_ibfk_3` FOREIGN KEY (`department`) REFERENCES `department` (`code`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Table structure for data_sequence
-- ----------------------------
DROP TABLE IF EXISTS `data_sequence`;
CREATE TABLE `data_sequence` (
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
-- ----------------------------
-- Table structure for department
-- ----------------------------
DROP TABLE IF EXISTS `department`;
CREATE TABLE `department` (
`code` varchar(255) NOT NULL,
`name` varchar(255) DEFAULT NULL,
PRIMARY KEY (`code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Table structure for log
-- ----------------------------
DROP TABLE IF EXISTS `log`;
CREATE TABLE `log` (
`id` varchar(255) NOT NULL,
`content` varchar(255) DEFAULT NULL,
`action` varchar(255) DEFAULT NULL,
`time` datetime DEFAULT NULL,
`operation_user` varchar(255) DEFAULT NULL COMMENT '操作者',
`operated_id` varchar(255) DEFAULT NULL COMMENT '被操作对象ID',
`operated_type` varchar(255) DEFAULT NULL COMMENT '被操作对象类型',
`description` varchar(255) DEFAULT NULL COMMENT '选填项',
PRIMARY KEY (`id`),
KEY `log_ibfk_1` (`operation_user`),
CONSTRAINT `log_ibfk_1` FOREIGN KEY (`operation_user`) REFERENCES `user` (`username`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Table structure for role
-- ----------------------------
DROP TABLE IF EXISTS `role`;
CREATE TABLE `role` (
`id` varchar(255) NOT NULL,
`name` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Table structure for system_notice
-- ----------------------------
DROP TABLE IF EXISTS `system_notice`;
CREATE TABLE `system_notice` (
`id` varchar(255) NOT NULL,
`name` varchar(255) DEFAULT NULL,
`content` varchar(255) DEFAULT NULL,
`date` datetime DEFAULT NULL,
`user` varchar(255) DEFAULT NULL,
`role` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `system_notice_ibfk_1` (`user`),
KEY `system_notice_ibfk_2` (`role`),
CONSTRAINT `system_notice_ibfk_1` FOREIGN KEY (`user`) REFERENCES `user` (`username`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `system_notice_ibfk_2` FOREIGN KEY (`role`) REFERENCES `role` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Table structure for type_content
-- ----------------------------
DROP TABLE IF EXISTS `type_content`;
CREATE TABLE `type_content` (
`id` varchar(255) NOT NULL,
`name` varchar(255) DEFAULT NULL,
`class_type` varchar(255) DEFAULT NULL,
`user` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `class_type` (`class_type`),
KEY `user` (`user`),
CONSTRAINT `type_content_ibfk_1` FOREIGN KEY (`class_type`) REFERENCES `class_type` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `type_content_ibfk_2` FOREIGN KEY (`user`) REFERENCES `user` (`username`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`username` varchar(255) NOT NULL,
`password` varchar(255) DEFAULT '123456',
`id_card` varchar(255) DEFAULT NULL,
`first_login` int(2) DEFAULT '0' COMMENT '0表示第一次登陆',
PRIMARY KEY (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Table structure for user_info
-- ----------------------------
DROP TABLE IF EXISTS `user_info`;
CREATE TABLE `user_info` (
`user` varchar(255) NOT NULL,
`name` varchar(255) DEFAULT NULL,
`sex` varchar(255) DEFAULT NULL,
`phone` varchar(255) DEFAULT NULL,
`email` varchar(255) DEFAULT NULL,
`department` varchar(255) DEFAULT NULL,
PRIMARY KEY (`user`),
KEY `department` (`department`),
CONSTRAINT `user_info_ibfk_1` FOREIGN KEY (`user`) REFERENCES `user` (`username`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `user_info_ibfk_2` FOREIGN KEY (`department`) REFERENCES `department` (`code`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Table structure for user_role
-- ----------------------------
DROP TABLE IF EXISTS `user_role`;
CREATE TABLE `user_role` (
`user` varchar(255) DEFAULT NULL,
`role` varchar(255) DEFAULT NULL,
KEY `user` (`user`),
KEY `role` (`role`),
CONSTRAINT `user_role_ibfk_1` FOREIGN KEY (`user`) REFERENCES `user` (`username`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `user_role_ibfk_2` FOREIGN KEY (`role`) REFERENCES `role` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Procedure structure for aa
-- ----------------------------
DROP PROCEDURE IF EXISTS `aa`;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `aa`()
BEGIN
SET @tablename = (SELECT log.user_type FROM log WHERE log.`user` = '888');
SET @sqlStr = CONCAT('select department from ',@tablename,' where id=','888');
PREPARE stmt FROM @sqlStr;
execute stmt;
END
;;
DELIMITER ;