init.sql 4.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. create database if not exists `open_api_platform`;
  2. USE `open_api_platform`;
  3. -- 创建一个名为users的表,用于存储用户信息
  4. CREATE TABLE if NOT EXISTS `user` (
  5. `id` BIGINT NOT NULL PRIMARY KEY COMMENT '用户ID',
  6. `user_account` VARCHAR(255) NOT NULL COMMENT '用户账号',
  7. `user_password` VARCHAR(255) NOT NULL COMMENT '用户密码',
  8. `user_name` VARCHAR(255) NOT NULL COMMENT '用户名称',
  9. `user_avatar` VARCHAR(1024) DEFAULT NULL COMMENT '用户头像',
  10. `user_role` CHAR(32) NOT NULL DEFAULT '用户' COMMENT '用户角色',
  11. `access_key` CHAR(32) NOT NULL COMMENT '访问接口的accessKey',
  12. `secret_key` CHAR(32) NOT NULL COMMENT '访问接口的secretKey',
  13. `create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  14. `update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  15. `delete_flag` TINYINT(1) NOT NULL DEFAULT '0' COMMENT '删除标志,0:未删除,1:已删除'
  16. ) COMMENT='用户表';
  17. -- 接口信息
  18. create table if not exists `interface_info`
  19. (
  20. `id` bigint not null auto_increment comment '主键' primary key,
  21. `name` varchar(256) not null comment '名称',
  22. `description` varchar(256) null comment '描述',
  23. `url` varchar(512) not null comment '接口地址',
  24. `request_header` text null comment '请求头',
  25. `response_header` text null comment '响应头',
  26. `status` int default 0 not null comment '接口状态(0-关闭,1-开启)',
  27. `method` varchar(256) not null comment '请求类型',
  28. `user_id` bigint not null comment '创建人',
  29. `create_time` datetime default CURRENT_TIMESTAMP not null comment '创建时间',
  30. `update_time` datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
  31. `delete_flag` tinyint default 0 not null comment '是否删除(0-未删, 1-已删)'
  32. ) comment '接口信息';
  33. -- 接口参数
  34. create table if not exists `interface_param`
  35. (
  36. `id` bigint not null comment '主键' primary key,
  37. `interface_info_id` bigint not null comment '接口信息id',
  38. `name` varchar(256) not null comment '参数名称(参数类型为body时,名称使用body)',
  39. `description` varchar(256) null comment '参数描述',
  40. `type` int default 0 not null comment '参数类型(0:query,1:body)',
  41. `param_type` char(32) default 'string' not null comment '数据类型',
  42. `user_id` bigint not null comment '创建人',
  43. `create_time` datetime default CURRENT_TIMESTAMP not null comment '创建时间',
  44. `update_time` datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
  45. `delete_flag` tinyint default 0 not null comment '是否删除(0-未删, 1-已删)'
  46. ) comment '接口参数';
  47. -- 用户调用接口关系表
  48. create table if not exists `user_interface_info`
  49. (
  50. `id` bigint not null auto_increment comment '主键' primary key,
  51. `user_id` bigint not null comment '调用用户Id',
  52. `interface_info_id` bigint not null comment '接口Id',
  53. `total_num` int default 0 not null comment '总调用次数',
  54. `left_num` int default 0 not null comment '剩余调用次数',
  55. `status` int default 0 not null comment '0-正常 ,1-禁用',
  56. `create_time` datetime default CURRENT_TIMESTAMP not null comment '创建时间',
  57. `update_time` datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
  58. `delete_flag` tinyint default 0 not null comment '是否删除(0-未删, 1-已删)'
  59. ) comment '用户调用接口关系表';
  60. -- 接口调用次数sku
  61. create table if not exists `interface_invoke_sku`(
  62. `id` bigint not null comment '主键' primary key,
  63. `interface_info_id` bigint not null comment '接口Id',
  64. `title` char(64) not null comment '商品标题',
  65. `cover` varchar(256) default '' comment '封面',
  66. `price` decimal(10,2) not null comment '价格',
  67. `quantity` int not null comment '数量',
  68. `info` varchar(1024) comment '描述',
  69. `status` tinyint not null default 0 comment '状态;0:未上架,1:上架,2:下架',
  70. `create_time` datetime default CURRENT_TIMESTAMP not null comment '创建时间',
  71. `update_time` datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
  72. `delete_flag` tinyint default 0 not null comment '是否删除(0-未删, 1-已删)'
  73. )