|
|
@@ -13,12 +13,12 @@ exports.main = async (event, context) => {
|
|
|
const code_check = await db.collection('invite').where({
|
|
|
code: event.code
|
|
|
}).get()
|
|
|
- if (code_check.length === 0) {
|
|
|
+ if (code_check.data.length === 0) {
|
|
|
return {
|
|
|
errMsg: '邀请码不存在'
|
|
|
}
|
|
|
}
|
|
|
- if (code_check[0].pub_id !== '') {
|
|
|
+ if (code_check.data[0].pub_id !== '') {
|
|
|
return {
|
|
|
errMsg: '邀请码已被使用'
|
|
|
}
|
|
|
@@ -26,12 +26,12 @@ exports.main = async (event, context) => {
|
|
|
const name_check = await db.collection('publisher').where({
|
|
|
name: event.name
|
|
|
}).get()
|
|
|
- if (name_check.length !== 0) {
|
|
|
+ if (name_check.data.length !== 0) {
|
|
|
return {
|
|
|
errMsg: '名称已存在'
|
|
|
}
|
|
|
}
|
|
|
- const pub_id = await db.collection('publisher').add({
|
|
|
+ const publisher = await db.collection('publisher').add({
|
|
|
data: {
|
|
|
name: event.name,
|
|
|
type: event.type,
|
|
|
@@ -45,17 +45,17 @@ exports.main = async (event, context) => {
|
|
|
code: event.code
|
|
|
}).update({
|
|
|
data: {
|
|
|
- pub_id: pub_id,
|
|
|
+ pub_id: publisher._id,
|
|
|
use_time: new Date()
|
|
|
}
|
|
|
})
|
|
|
await db.collection('manager').add({
|
|
|
data: {
|
|
|
- pub_id: pub_id,
|
|
|
+ pub_id: publisher._id,
|
|
|
user_id: OPENID,
|
|
|
title: '',
|
|
|
role: '拥有者'
|
|
|
}
|
|
|
})
|
|
|
- return pub_id
|
|
|
+ return publisher
|
|
|
}
|