This commit is contained in:
robin
2022-07-07 22:16:39 +08:00
parent 264ab8d979
commit a9a4bd0981
86 changed files with 1198 additions and 310 deletions
+22
View File
@@ -0,0 +1,22 @@
'use strict';
module.exports = {
name:"加入房间",
doc:``,
params: {
"type": ["accountPassword"],//登录类型
"data": "object",//数据
},
fun : async (ctx, app) => {
const {type, data} = ctx.params
if (await $components.login[type](data)) {
return $res.success({
token: await $components.jwt.sign({})
}, "登录成功")
}
return $res.error({}, "登录失败")
}
}
+12
View File
@@ -0,0 +1,12 @@
module.exports = {
name : "离开房间",
doc : ``,
params: {
// "room_name": 'string',//房间
// "uid" : 'string',//用户id
},
fun : (socket, {msg, onname, callback}) => {
console.log('断线:', socket.id);
}
}
+20
View File
@@ -0,0 +1,20 @@
module.exports = {
name : "加入房间",
doc : ``,
params: {
"room_name": 'string',//房间
"uid" : 'string',//用户id
},
fun : (socket, {msg, onname, callback}) => {
console.log('加入房间:', msg);
socket.join(msg.room_name)//加入房间
socket.emit('success', {
event: onname,
res : app.res.success(""),
})
socket.to(msg.room_name).emit('success', {
event: onname,
res : app.res.success(msg, "有人加入房间"),
})
}
}
+12
View File
@@ -0,0 +1,12 @@
module.exports = {
name : "离开房间",
doc : ``,
params: {
// "room_name": 'string',//房间
// "uid" : 'string',//用户id
},
fun : (socket, {msg, onname, callback}) => {
console.log('离开房间:', socket.id);
}
}
-3
View File
@@ -1,3 +0,0 @@
module.exports = (app, msg, callback) => {
console.log('接收到的消息:', msg);
}
+12
View File
@@ -0,0 +1,12 @@
module.exports = {
doc: "联系人表",
api: true,//是否需要生成api接口
model: {
uid: {type: "STRING", comment: '用户id/群id'},
to_uid: {type: "STRING", comment: '接收人用户id'},
type: {type: "STRING", comment: '类型,单人/群:one/group'},
status: {type: "STRING", comment: '状态:已结束/未结束:y/n'},
},
}
+20
View File
@@ -0,0 +1,20 @@
module.exports = {
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: '接收人名称'},
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: '文件名称'},
},
}
+10
View File
@@ -0,0 +1,10 @@
module.exports = {
doc: "自动回复表",
api: true,//是否需要生成api接口
model: {
type: {type: "STRING", comment: '类型,自动回复/问候语:auto/hello'},
status: {type: "STRING", comment: '状态:显示/隐藏:y/n'},
},
}
+39
View File
@@ -0,0 +1,39 @@
module.exports = {
describe_name: "permission/权限管理",
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')
}
},
]
}