初始化
This commit is contained in:
@@ -1,19 +1,20 @@
|
||||
module.exports = {
|
||||
doc: "消息表",
|
||||
api: true,//是否需要生成api接口
|
||||
doc : "消息表",
|
||||
api : true,//是否需要生成api接口
|
||||
model: {
|
||||
uid: {type: "STRING", comment: '发送人用户id'},
|
||||
name: {type: "STRING", comment: '发送人名称'},
|
||||
avatar: {type: "STRING", comment: '发送人头像'},
|
||||
to_uid: {type: "STRING", comment: '接收人用户id'},
|
||||
to_name: {type: "STRING", comment: '接收人名称'},
|
||||
oid : {type: "INTEGER", comment: '发送人用户机构id'},
|
||||
uid : {type: "INTEGER", comment: '发送人用户id'},
|
||||
name : {type: "STRING", comment: '发送人名称'},
|
||||
avatar : {type: "STRING", comment: '发送人头像'},
|
||||
to_uid : {type: "STRING", comment: '接收人用户id'},
|
||||
to_name : {type: "STRING", comment: '接收人名称'},
|
||||
to_avatar: {type: "STRING", comment: '接收人头像'},
|
||||
status: {type: "STRING", comment: '状态:已读/未读:y/n'},
|
||||
type: {type: "STRING", comment: '消息类型:file / image / text / event'},
|
||||
sendTime: {type: "STRING", comment: '消息发送时间'},
|
||||
content: {type: "STRING", comment: '消息内容,如果type=file,此属性表示文件的URL地址'},
|
||||
fileSize: {type: "STRING", comment: '文件大小'},
|
||||
fileName: {type: "STRING", comment: '文件名称'},
|
||||
status : {type: "STRING", comment: '状态:已读/未读:y/n'},
|
||||
type : {type: "STRING", comment: '消息类型:file / image / text / event'},
|
||||
sendTime : {type: "STRING", comment: '消息发送时间'},
|
||||
content : {type: "STRING", fieldNameCus: '消息内容', comment: '消息内容,如果type=file,此属性表示文件的URL地址'},
|
||||
fileSize : {type: "STRING", comment: '文件大小'},
|
||||
fileName : {type: "STRING", comment: '文件名称'},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -1,39 +1,6 @@
|
||||
module.exports = {
|
||||
describe_name: "permission/权限管理",
|
||||
describe_name: "message/消息中心",
|
||||
testList : [
|
||||
{
|
||||
test_name: "账号密码注册",
|
||||
fun : async (request, server) => {
|
||||
const response = await request(server)
|
||||
.post('/permission/api/registered')
|
||||
.send({
|
||||
type: "accountPassword",
|
||||
data: {
|
||||
account : "test",
|
||||
password: "123456",
|
||||
},
|
||||
})
|
||||
// expect(response.status).toEqual(200)
|
||||
expect(response.body.status).toEqual(200)
|
||||
expect(response.body.data).toHaveProperty('token')
|
||||
}
|
||||
},
|
||||
{
|
||||
test_name: "账号密码登录",
|
||||
fun : async (request, server) => {
|
||||
const response = await request(server)
|
||||
.post('/permission/api/login')
|
||||
.send({
|
||||
type: "accountPassword",
|
||||
data: {
|
||||
account : "test",
|
||||
password: "123456",
|
||||
},
|
||||
})
|
||||
// expect(response.status).toEqual(200)
|
||||
expect(response.body.status).toEqual(200)
|
||||
expect(response.body.data).toHaveProperty('token')
|
||||
}
|
||||
},
|
||||
|
||||
]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
params: {
|
||||
"uid": "string",//数据
|
||||
"general_management": "string",//数据
|
||||
},
|
||||
fun : async (ctx, app) => {
|
||||
const {name, general_management} = ctx.params
|
||||
if (await $components.registered[type](data)) {
|
||||
return $res.success({
|
||||
token: await $components.jwt.sign({})
|
||||
}, "注册成功")
|
||||
}
|
||||
|
||||
return $res.error({}, "登录失败")
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
params: {
|
||||
"name": "string",//数据
|
||||
"general_management": "string",//数据
|
||||
},
|
||||
fun : async (ctx, app) => {
|
||||
const {name, general_management} = ctx.params
|
||||
if (await $components.registered[type](data)) {
|
||||
return $res.success({
|
||||
token: await $components.jwt.sign({})
|
||||
}, "注册成功")
|
||||
}
|
||||
|
||||
return $res.error({}, "登录失败")
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
const crypto = require('crypto');
|
||||
const shortid = require('shortid');
|
||||
module.exports = {
|
||||
// 随机数(盐值)
|
||||
getRandomSalt() {
|
||||
@@ -20,4 +21,8 @@ module.exports = {
|
||||
cryptPwdVerification(password, salt, user_password_md5) {
|
||||
return this.cryptPwd(password, salt) === user_password_md5;
|
||||
},
|
||||
// 返回随机短uuid
|
||||
shortid() {
|
||||
return shortid.generate()
|
||||
},
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
module.exports = {
|
||||
//添加机构
|
||||
async add(name, general_management) {
|
||||
$db.table('Organization').data({
|
||||
oid: $components.encrypt.shortid(),
|
||||
name,
|
||||
general_management
|
||||
}).save()
|
||||
},
|
||||
}
|
||||
@@ -7,9 +7,9 @@
|
||||
* @return {boolean} 注册 是否 成功.
|
||||
*/
|
||||
module.exports = async (data) => {
|
||||
const {account, password} = data
|
||||
const {account, password, oid} = data
|
||||
const salt = app.components.encrypt.getRandomSalt()
|
||||
const md5 = app.components.encrypt.cryptPwd(password, salt)
|
||||
await app.db.table("User").data({account, password: md5, salt}).save()
|
||||
await app.db.table("User").data({account, password: md5, salt, to_oid: oid}).save()
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
module.exports = {
|
||||
doc: "组织表",
|
||||
api: true,//是否需要生成api接口
|
||||
doc : "机构表",
|
||||
api : true,//是否需要生成api接口
|
||||
model: {
|
||||
oid: {type: "STRING", comment: '组织id'},
|
||||
name: {type: "STRING", comment: '组织名称'},
|
||||
general_management: {type: "STRING", comment: '是否为总管理平台(可以管理所有组织)'},
|
||||
oid : {type: "INTEGER", comment: '机构id', primaryKey: true},
|
||||
name : {type: "STRING", comment: '机构名称'},
|
||||
general_management: {type: "STRING", comment: '是否为总管理平台(可以管理所有机构):y/n'},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
doc: "组织配置表",
|
||||
api: true,//是否需要生成api接口
|
||||
model: {
|
||||
oid: {type: "STRING", comment: '组织id'},
|
||||
name: {type: "STRING", comment: '名称'},
|
||||
type: {type: "STRING", comment: '类型:string/number/json'},
|
||||
code: {type: "STRING", comment: '识别码'},
|
||||
value: {type: "STRING", comment: '权限值'},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ module.exports = {
|
||||
doc: "权限列表",
|
||||
api: true,//是否需要生成api接口
|
||||
model: {
|
||||
pid: {type: "STRING", comment: '权限id'},
|
||||
pid: {type: "INTEGER", comment: '权限id', primaryKey: true},
|
||||
name: {type: "STRING", comment: '权限名称'},
|
||||
type: {type: "STRING", comment: '权限类型:接口/字段/表格/按钮:jk/zd/bg/an'},
|
||||
code: {type: "STRING", comment: '权限识别码'},
|
||||
|
||||
@@ -2,7 +2,7 @@ module.exports = {
|
||||
doc: "角色表",
|
||||
api: true,//是否需要生成api接口
|
||||
model: {
|
||||
rid: {type: "STRING", comment: '角色id'},
|
||||
rid: {type: "INTEGER", comment: '角色id', primaryKey: true},
|
||||
name: {type: "STRING", comment: '角色名称'},
|
||||
to_oid: {type: "STRING", comment: '所属组织id'},
|
||||
},
|
||||
|
||||
@@ -2,12 +2,10 @@ module.exports = {
|
||||
doc: "用户表",
|
||||
api: true,//是否需要生成api接口
|
||||
model: {
|
||||
uid: {type: "STRING", comment: '用户id'},
|
||||
uid: {type: "INTEGER", comment: '用户id', primaryKey: true},
|
||||
account: {type: "STRING", comment: '用户账号'},
|
||||
password: {type: "STRING", comment: '用户加密密码'},
|
||||
salt: {type: "STRING", comment: '用户加密随机数'},
|
||||
to_oid: {type: "STRING", comment: '所属组织id'},
|
||||
to_rid: {type: "STRING", comment: '所属角色id'},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -2,13 +2,15 @@ module.exports = {
|
||||
doc: "用户资料表",
|
||||
api: true,//是否需要生成api接口
|
||||
model: {
|
||||
uid: {type: "STRING", comment: '用户id'},
|
||||
uid: {type: "INTEGER", comment: '用户id'},
|
||||
to_oid: {type: "INTEGER", comment: '所属组织id'},
|
||||
to_rid: {type: "INTEGER", comment: '所属角色id'},
|
||||
account: {type: "STRING", comment: '用户账号'},
|
||||
name: {type: "STRING", comment: '名称'},
|
||||
avatar: {type: "STRING", comment: '头像'},
|
||||
wechat_openid: {type: "STRING", comment: '微信openid'},
|
||||
phone_number: {type: "STRING", comment: '手机号'},
|
||||
age: {type: "STRING", comment: '年龄'},
|
||||
age: {type: "INTEGER", comment: '年龄'},
|
||||
sex: {type: "STRING", comment: '性别'},
|
||||
province: {type: "STRING", comment: '省份'},
|
||||
city: {type: "STRING", comment: '城市'},
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
//获取数据库模型列表
|
||||
module.exports = {
|
||||
params: {},
|
||||
fun : async (ctx, app) => {
|
||||
const {} = ctx.params
|
||||
const data = Object.keys($db.models).map(item => {
|
||||
let tableAttributes = $db.models[item].tableAttributes
|
||||
let ta = {}
|
||||
Object.keys(tableAttributes).forEach(ta_item => {
|
||||
ta[ta_item] = {
|
||||
fieldName: tableAttributes[ta_item].fieldName,//字段名
|
||||
field : tableAttributes[ta_item].field,//字段
|
||||
headName : tableAttributes[ta_item].fieldNameCus,//字段自定义名
|
||||
comment : tableAttributes[ta_item].comment,//注释
|
||||
|
||||
}
|
||||
})
|
||||
return {
|
||||
tableName : $db.models[item].tableName,
|
||||
tableAttributes: ta,
|
||||
primaryKeyField: $db.models[item].primaryKeyField,
|
||||
}
|
||||
})
|
||||
return data
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
params: {
|
||||
"taskList": "array",
|
||||
},
|
||||
fun : async (ctx, app) => {
|
||||
const {taskList} = ctx.params
|
||||
const data = await $db.jsonTasks(taskList)
|
||||
return data
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
module.exports = {
|
||||
doc : "数据库模型映射到前端目录表",
|
||||
api : true,//是否需要生成api接口
|
||||
model: {
|
||||
// id : {type: "INTEGER", comment: '导航id', primaryKey: true},
|
||||
name: {type: "STRING", comment: '导航名称'},
|
||||
path: {type: "STRING", comment: '导航路径'},
|
||||
index: {type: "INTEGER", comment: '权重,越大越靠前'},
|
||||
icon : {type: "STRING", comment: '图标'},
|
||||
group: {type: "STRING", comment: '导航分组'},
|
||||
table: {type: "STRING", comment: '绑定的表名'},
|
||||
table_key: {type: "STRING", comment: '表的主键名称,一般是id'},
|
||||
search: {type: "STRING", comment: '模糊查询的字段用/分割'},
|
||||
table_field: {type: "JSON", comment: '表格字段'},
|
||||
table_field_key: {type: "JSON", comment: '已选择的字段'},
|
||||
user: {type: "JSON", comment: '查询表字段的时候,默认带上的用户数据,比如["oid"],这样用户就只能看到自己机构的数据'},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user