peng.peng
1 year ago
10 changed files with 378 additions and 86 deletions
@ -0,0 +1,89 @@ |
|||||
|
/* eslint-disable*/ |
||||
|
|
||||
|
'use strict'; |
||||
|
|
||||
|
module.exports = dc => { |
||||
|
const DataTypes = dc.ORM; |
||||
|
const sequelize = dc.orm; |
||||
|
const RestfulApi = sequelize.define("restfulApi", { |
||||
|
id: { |
||||
|
type: DataTypes.INTEGER, |
||||
|
allowNull: false, |
||||
|
defaultValue: null, |
||||
|
comment: "唯一标识", |
||||
|
primaryKey: true, |
||||
|
field: "id", |
||||
|
autoIncrement: true, |
||||
|
unique: "t_restful_api_id_uindex" |
||||
|
}, |
||||
|
name: { |
||||
|
type: DataTypes.STRING, |
||||
|
allowNull: false, |
||||
|
defaultValue: null, |
||||
|
comment: "接口名称", |
||||
|
primaryKey: false, |
||||
|
field: "name", |
||||
|
autoIncrement: false |
||||
|
}, |
||||
|
url: { |
||||
|
type: DataTypes.STRING, |
||||
|
allowNull: false, |
||||
|
defaultValue: null, |
||||
|
comment: "接口路由", |
||||
|
primaryKey: false, |
||||
|
field: "url", |
||||
|
autoIncrement: false |
||||
|
}, |
||||
|
method: { |
||||
|
type: DataTypes.STRING, |
||||
|
allowNull: false, |
||||
|
defaultValue: null, |
||||
|
comment: "请求方法", |
||||
|
primaryKey: false, |
||||
|
field: "method", |
||||
|
autoIncrement: false |
||||
|
}, |
||||
|
table: { |
||||
|
type: DataTypes.STRING, |
||||
|
allowNull: true, |
||||
|
defaultValue: null, |
||||
|
comment: "数据库表名称", |
||||
|
primaryKey: false, |
||||
|
field: "table", |
||||
|
autoIncrement: false |
||||
|
}, |
||||
|
conditions: { |
||||
|
type: DataTypes.JSONB, |
||||
|
allowNull: true, |
||||
|
defaultValue: null, |
||||
|
comment: "数据库表查询条件", |
||||
|
primaryKey: false, |
||||
|
field: "conditions", |
||||
|
autoIncrement: false |
||||
|
}, |
||||
|
enabled: { |
||||
|
type: DataTypes.BOOLEAN, |
||||
|
allowNull: true, |
||||
|
defaultValue: null, |
||||
|
comment: "是否已启用", |
||||
|
primaryKey: false, |
||||
|
field: "enabled", |
||||
|
autoIncrement: false |
||||
|
}, |
||||
|
fields: { |
||||
|
type: DataTypes.STRING, |
||||
|
allowNull: false, |
||||
|
defaultValue: null, |
||||
|
comment: '数据库表字段', |
||||
|
primaryKey: false, |
||||
|
field: "fields", |
||||
|
autoIncrement: false |
||||
|
} |
||||
|
}, { |
||||
|
tableName: "t_restful_api", |
||||
|
comment: "", |
||||
|
indexes: [] |
||||
|
}); |
||||
|
dc.models.RestfulApi = RestfulApi; |
||||
|
return RestfulApi; |
||||
|
}; |
@ -0,0 +1,53 @@ |
|||||
|
/* eslint-disable*/ |
||||
|
|
||||
|
'use strict'; |
||||
|
|
||||
|
module.exports = dc => { |
||||
|
const DataTypes = dc.ORM; |
||||
|
const sequelize = dc.orm; |
||||
|
const RestfulApiRecord = sequelize.define("restfulApiRecord", { |
||||
|
id: { |
||||
|
type: DataTypes.INTEGER, |
||||
|
allowNull: false, |
||||
|
defaultValue: null, |
||||
|
comment: "唯一标识", |
||||
|
primaryKey: true, |
||||
|
field: "id", |
||||
|
autoIncrement: true, |
||||
|
unique: "t_restful_api_record_id_uindex" |
||||
|
}, |
||||
|
name: { |
||||
|
type: DataTypes.STRING, |
||||
|
allowNull: false, |
||||
|
defaultValue: null, |
||||
|
comment: "接口名称", |
||||
|
primaryKey: false, |
||||
|
field: "name", |
||||
|
autoIncrement: false |
||||
|
}, |
||||
|
visitTime: { |
||||
|
type: DataTypes.DATE, |
||||
|
allowNull: false, |
||||
|
defaultValue: null, |
||||
|
comment: "访问时间", |
||||
|
primaryKey: false, |
||||
|
field: "visit_time", |
||||
|
autoIncrement: false |
||||
|
}, |
||||
|
token: { |
||||
|
type: DataTypes.STRING, |
||||
|
allowNull: false, |
||||
|
defaultValue: null, |
||||
|
comment: "令牌", |
||||
|
primaryKey: false, |
||||
|
field: "token", |
||||
|
autoIncrement: false |
||||
|
}, |
||||
|
}, { |
||||
|
tableName: "t_restful_api_record", |
||||
|
comment: "", |
||||
|
indexes: [] |
||||
|
}); |
||||
|
dc.models.RestfulApiRecord = RestfulApiRecord; |
||||
|
return RestfulApiRecord; |
||||
|
}; |
@ -0,0 +1,65 @@ |
|||||
|
create table t_restful_api |
||||
|
( |
||||
|
id serial not null, |
||||
|
"table" varchar(255) not null, |
||||
|
fields varchar(255) not null, |
||||
|
conditions jsonb not null, |
||||
|
name varchar(255) not null, |
||||
|
method varchar(10) not null, |
||||
|
url varchar(255) not null, |
||||
|
enabled boolean default true not null |
||||
|
); |
||||
|
|
||||
|
comment on table t_restful_api is 'REST服务'; |
||||
|
|
||||
|
comment on column t_restful_api.id is 'ID唯一标识'; |
||||
|
|
||||
|
comment on column t_restful_api."table" is '数据库表名称'; |
||||
|
|
||||
|
comment on column t_restful_api.fields is '数据库表字段'; |
||||
|
|
||||
|
comment on column t_restful_api.conditions is '数据库表查询条件'; |
||||
|
|
||||
|
comment on column t_restful_api.name is '接口名称'; |
||||
|
|
||||
|
comment on column t_restful_api.method is '请求方法'; |
||||
|
|
||||
|
comment on column t_restful_api.url is '接口路由'; |
||||
|
|
||||
|
comment on column t_restful_api.enabled is '是否已启用'; |
||||
|
|
||||
|
create unique index t_restful_api_id_uindex |
||||
|
on t_restful_api (id); |
||||
|
|
||||
|
alter table t_restful_api |
||||
|
add constraint t_restful_api_pk |
||||
|
primary key (id); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
create table t_restful_api_record |
||||
|
( |
||||
|
id serial not null, |
||||
|
rest_service_id int not null, |
||||
|
visit_time timestamp not null, |
||||
|
token varchar(255) not null |
||||
|
); |
||||
|
|
||||
|
comment on table t_restful_api_record is 'REST服务访问记录'; |
||||
|
|
||||
|
comment on column t_restful_api_record.rest_service_id is 'rest服务id'; |
||||
|
|
||||
|
comment on column t_restful_api_record.visit_time is '访问时间'; |
||||
|
|
||||
|
comment on column t_restful_api_record.token is '令牌'; |
||||
|
|
||||
|
create unique index t_restful_api_record_id_uindex |
||||
|
on t_restful_api_record (id); |
||||
|
|
||||
|
alter table t_restful_api_record |
||||
|
add constraint t_restful_api_record_pk |
||||
|
primary key (id); |
||||
|
|
||||
|
|
Loading…
Reference in new issue