接口测试环境搭建
一、下载项目包
1.下载最新的小幺鸡安装包,传送门:http://git.oschina.net/zhoujingjie/apiManager/releases
2.将小幺鸡的war包上传至/usr/local/tomcat/webapps目录下,不需要解压
3.上传apiManager/xiaoyaoji-web/src/main/resources目录下的config.properties、log4j.properties至/usr/local/tomcat/conf
4.新建MySQL数据库,编码格式是utf-8
1 create database `xiaoyaoji` character set utf-8;
5.创建表结构,直接拷贝到Navicat中运行即可
1 SET FOREIGN_KEY_CHECKS=0; 2 3 -- ---------------------------- 4 -- Table structure for attach 5 -- ---------------------------- 6 DROP TABLE IF EXISTS `attach`; 7 CREATE TABLE `attach` ( 8 `id` char(12) NOT NULL, 9 `url` varchar(1000) DEFAULT NULL, 10 `type` varchar(45) DEFAULT NULL, 11 `sort` int(11) DEFAULT NULL, 12 `relatedId` char(12) DEFAULT NULL, 13 `fileName` varchar(1000) DEFAULT NULL, 14 `createTime` datetime DEFAULT NULL, 15 `projectId` char(12) DEFAULT NULL, 16 PRIMARY KEY (`id`), 17 KEY `normal` (`relatedId`) 18 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 19 20 -- ---------------------------- 21 -- Table structure for doc 22 -- ---------------------------- 23 DROP TABLE IF EXISTS `doc`; 24 CREATE TABLE `doc` ( 25 `id` char(12) NOT NULL, 26 `name` varchar(200) DEFAULT NULL, 27 `sort` int(11) DEFAULT '100', 28 `type` varchar(100) DEFAULT NULL, 29 `content` longtext, 30 `createTime` datetime DEFAULT NULL, 31 `lastUpdateTime` datetime DEFAULT NULL, 32 `parentId` char(12) DEFAULT NULL, 33 `projectId` char(12) DEFAULT NULL, 34 PRIMARY KEY (`id`), 35 KEY `parentId` (`parentId`) USING BTREE, 36 KEY `projectId` (`projectId`) USING BTREE 37 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 38 39 -- ---------------------------- 40 -- Table structure for doc_history 41 -- ---------------------------- 42 DROP TABLE IF EXISTS `doc_history`; 43 CREATE TABLE `doc_history` ( 44 `id` int(11) NOT NULL AUTO_INCREMENT, 45 `name` varchar(200) DEFAULT NULL, 46 `sort` int(11) DEFAULT '100', 47 `type` varchar(100) DEFAULT NULL, 48 `content` longtext, 49 `createTime` datetime DEFAULT NULL, 50 `parentId` char(12) DEFAULT NULL, 51 `projectId` char(12) DEFAULT NULL, 52 `comment` varchar(1000) DEFAULT NULL, 53 `userId` char(12) DEFAULT NULL, 54 `docId` char(12) DEFAULT NULL, 55 PRIMARY KEY (`id`) 56 ) ENGINE=InnoDB AUTO_INCREMENT=51473 DEFAULT CHARSET=utf8mb4; 57 58 -- ---------------------------- 59 -- Table structure for email_token 60 -- ---------------------------- 61 DROP TABLE IF EXISTS `email_token`; 62 CREATE TABLE `email_token` ( 63 `id` char(12) NOT NULL, 64 `email` varchar(45) NOT NULL, 65 `isUsed` tinyint(1) NOT NULL DEFAULT '0', 66 `createtime` datetime NOT NULL, 67 `token` char(32) NOT NULL, 68 PRIMARY KEY (`id`) 69 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 70 71 -- ---------------------------- 72 -- Table structure for find_password 73 -- ---------------------------- 74 DROP TABLE IF EXISTS `find_password`; 75 CREATE TABLE `find_password` ( 76 `id` char(12) NOT NULL DEFAULT '', 77 `email` varchar(45) DEFAULT NULL, 78 `isUsed` tinyint(1) DEFAULT '0', 79 `createTime` datetime DEFAULT NULL, 80 PRIMARY KEY (`id`) 81 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 82 83 -- ---------------------------- 84 -- Table structure for interface 85 -- ---------------------------- 86 DROP TABLE IF EXISTS `interface`; 87 CREATE TABLE `interface` ( 88 `id` char(14) NOT NULL DEFAULT '', 89 `name` varchar(50) DEFAULT NULL, 90 `description` text, 91 `folderId` char(14) DEFAULT NULL, 92 `url` varchar(300) DEFAULT NULL, 93 `requestMethod` varchar(50) DEFAULT NULL, 94 `contentType` varchar(50) DEFAULT NULL, 95 `requestHeaders` text, 96 `requestArgs` text, 97 `responseArgs` text, 98 `example` mediumtext, 99 `moduleId` varchar(50) DEFAULT NULL, 100 `projectId` char(14) DEFAULT NULL, 101 `lastUpdateTime` datetime DEFAULT NULL, 102 `createTime` datetime DEFAULT NULL, 103 `dataType` varchar(30) DEFAULT NULL, 104 `protocol` varchar(30) DEFAULT NULL, 105 `status` char(10) DEFAULT 'ENABLE', 106 `sort` int(11) DEFAULT NULL, 107 PRIMARY KEY (`id`), 108 KEY `projectid` (`projectId`) USING BTREE 109 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 110 111 -- ---------------------------- 112 -- Table structure for interface_folder 113 -- ---------------------------- 114 DROP TABLE IF EXISTS `interface_folder`; 115 CREATE TABLE `interface_folder` ( 116 `id` char(14) NOT NULL DEFAULT '', 117 `name` varchar(50) DEFAULT NULL, 118 `createTime` datetime DEFAULT NULL, 119 `moduleId` char(14) DEFAULT NULL, 120 `projectId` char(14) DEFAULT NULL, 121 `sort` int(11) DEFAULT '100', 122 PRIMARY KEY (`id`), 123 KEY `projectid` (`projectId`) USING BTREE 124 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 125 126 -- ---------------------------- 127 -- Table structure for module 128 -- ---------------------------- 129 DROP TABLE IF EXISTS `module`; 130 CREATE TABLE `module` ( 131 `id` char(14) NOT NULL DEFAULT '', 132 `name` varchar(50) DEFAULT NULL, 133 `host` varchar(255) DEFAULT NULL, 134 `description` mediumtext, 135 `lastUpdateTime` datetime DEFAULT NULL, 136 `projectId` char(14) DEFAULT NULL, 137 `createTime` datetime DEFAULT NULL, 138 `requestHeaders` text, 139 `requestArgs` text, 140 `sort` int(11) DEFAULT NULL, 141 PRIMARY KEY (`id`), 142 KEY `projectid` (`projectId`) USING BTREE 143 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 144 145 -- ---------------------------- 146 -- Table structure for project 147 -- ---------------------------- 148 DROP TABLE IF EXISTS `project`; 149 CREATE TABLE `project` ( 150 `id` char(14) NOT NULL, 151 `name` varchar(50) DEFAULT NULL, 152 `description` varchar(300) DEFAULT NULL COMMENT 'test', 153 `teamId` char(14) DEFAULT NULL, 154 `createTime` datetime DEFAULT NULL, 155 `userId` char(14) DEFAULT NULL, 156 `status` varchar(20) DEFAULT 'VALID', 157 `permission` varchar(20) DEFAULT 'PRIVATE', 158 `environments` text, 159 `details` text, 160 `lastUpdateTime` datetime DEFAULT NULL, 161 PRIMARY KEY (`id`) 162 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 163 164 -- ---------------------------- 165 -- Table structure for project_global 166 -- ---------------------------- 167 DROP TABLE IF EXISTS `project_global`; 168 CREATE TABLE `project_global` ( 169 `id` char(12) NOT NULL DEFAULT '', 170 `environment` mediumtext, 171 `http` mediumtext, 172 `projectId` char(12) NOT NULL DEFAULT '', 173 `status` mediumtext 174 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 175 176 -- ---------------------------- 177 -- Table structure for project_log 178 -- ---------------------------- 179 DROP TABLE IF EXISTS `project_log`; 180 CREATE TABLE `project_log` ( 181 `id` char(14) NOT NULL DEFAULT '', 182 `userId` char(14) DEFAULT NULL, 183 `createTime` datetime DEFAULT NULL, 184 `log` text, 185 `projectId` char(14) DEFAULT NULL, 186 `action` varchar(50) DEFAULT NULL, 187 PRIMARY KEY (`id`), 188 KEY `projectid` (`projectId`) USING BTREE 189 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 190 191 -- ---------------------------- 192 -- Table structure for project_user 193 -- ---------------------------- 194 DROP TABLE IF EXISTS `project_user`; 195 CREATE TABLE `project_user` ( 196 `id` char(14) NOT NULL, 197 `projectId` char(14) DEFAULT NULL, 198 `userId` char(14) DEFAULT NULL, 199 `createTime` datetime DEFAULT NULL, 200 `status` char(255) DEFAULT 'PENDING', 201 `editable` char(3) DEFAULT 'YES', 202 `commonlyUsed` char(3) DEFAULT 'NO', 203 PRIMARY KEY (`id`), 204 KEY `project_user` (`projectId`,`userId`) USING BTREE 205 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 206 207 -- ---------------------------- 208 -- Table structure for share 209 -- ---------------------------- 210 DROP TABLE IF EXISTS `share`; 211 CREATE TABLE `share` ( 212 `id` char(12) NOT NULL DEFAULT '', 213 `name` varchar(50) DEFAULT NULL, 214 `createTime` datetime DEFAULT NULL, 215 `userId` char(12) DEFAULT NULL, 216 `shareAll` char(3) DEFAULT NULL, 217 `password` varchar(20) DEFAULT NULL, 218 `moduleIds` varchar(2000) DEFAULT NULL, 219 `projectId` char(12) DEFAULT NULL, 220 `docIds` varchar(2000) DEFAULT NULL, 221 PRIMARY KEY (`id`) 222 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 223 224 -- ---------------------------- 225 -- Table structure for sys 226 -- ---------------------------- 227 DROP TABLE IF EXISTS `sys`; 228 CREATE TABLE `sys` ( 229 `version` varchar(10) DEFAULT NULL 230 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 231 232 -- ---------------------------- 233 -- Table structure for team 234 -- ---------------------------- 235 DROP TABLE IF EXISTS `team`; 236 CREATE TABLE `team` ( 237 `id` char(14) NOT NULL DEFAULT '', 238 `name` varchar(50) DEFAULT NULL, 239 `description` varchar(300) DEFAULT NULL, 240 `userId` char(14) DEFAULT NULL, 241 `createTime` datetime DEFAULT NULL, 242 `status` varchar(20) DEFAULT 'VALID', 243 PRIMARY KEY (`id`) 244 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 245 246 -- ---------------------------- 247 -- Table structure for team_user 248 -- ---------------------------- 249 DROP TABLE IF EXISTS `team_user`; 250 CREATE TABLE `team_user` ( 251 `id` char(14) NOT NULL, 252 `teamId` char(14) DEFAULT NULL, 253 `userId` char(14) DEFAULT NULL, 254 `createTime` datetime DEFAULT NULL, 255 PRIMARY KEY (`id`) 256 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 257 258 -- ---------------------------- 259 -- Table structure for user 260 -- ---------------------------- 261 DROP TABLE IF EXISTS `user`; 262 CREATE TABLE `user` ( 263 `id` char(12) NOT NULL, 264 `email` varchar(45) DEFAULT NULL, 265 `createtime` datetime DEFAULT NULL, 266 `password` char(32) DEFAULT NULL, 267 `type` varchar(5) DEFAULT 'USER', 268 `nickname` varchar(30) DEFAULT NULL, 269 `avatar` varchar(200) DEFAULT NULL, 270 `status` char(10) DEFAULT NULL, 271 PRIMARY KEY (`id`), 272 UNIQUE KEY `id_UNIQUE` (`id`), 273 UNIQUE KEY `username` (`email`) USING BTREE 274 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 275 276 -- ---------------------------- 277 -- Table structure for user_third 278 -- ---------------------------- 279 DROP TABLE IF EXISTS `user_third`; 280 CREATE TABLE `user_third` ( 281 `id` varchar(60) NOT NULL, 282 `userid` char(12) NOT NULL, 283 `type` varchar(100) DEFAULT NULL, 284 PRIMARY KEY (`id`), 285 KEY `userId` (`userid`) 286 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 287 288 -- ---------------------------- 289 -- Procedure structure for trans_module 290 -- ---------------------------- 291 DROP PROCEDURE IF EXISTS `trans_module`; 292 DELIMITER ;; 293 CREATE DEFINER=`root`@`%` PROCEDURE `trans_module`() 294 begin 295 DECLARE done INT DEFAULT FALSE; 296 declare id varchar(100); 297 declare name,host,projectId varchar(100); 298 declare lastUpdateTime,createTime datetime; 299 declare description MEDIUMTEXT; 300 301 declare cur1 cursor for select id from module limit 100; 302 DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; 303 304 open cur1; 305 read_loop: LOOP 306 307 FETCH cur1 into id; 308 309 if done 310 then leave read_loop; 311 end if; 312 313 select id; 314 315 end LOOP; 316 close cur1; 317 318 end 319 ;; 320 DELIMITER ;
6.修改Tomcat文件的配置,修改MySQL地址,用户名、密码信息如下:
7.浏览器输入网址,进行访问 http://192.168.14.206:8080/xiaoyaoji-2.1.63/