提交 b6528eb8 编写于 作者: L ljw

修改完善部分接口

上级 1f8e06ea
......@@ -6,10 +6,24 @@ exports.main = async (event, context) => {
_id: event.activityId
}).get()
if (res.affectedDocs == 1) {
const usercollection = db.collection('mustgo-user')
let res1 = await usercollection.where({
_id: res.data[0]["owner_id"]
}).get()
let username
let icon
if (res1.affectedDocs == 1) {
username = res1.data[0]["name"]
icon = res1.data[0]["icon"]
}
return {
code: 200,
message: "成功返回活动详情",
data: {
"username":username,
"icon":icon,
"content": res.data[0]["content"],
"startDate": res.data[0]["start_date"],
"endDate": res.data[0]["end_date"],
......
'use strict';
exports.main = async (event, context) => {
const db = uniCloud.database()
let teamid
const usercollection = db.collection('mustgo-user')
let userres = await usercollection.where({
......@@ -14,19 +14,20 @@ exports.main = async (event, context) => {
"data": {}
}
}
if(userres.data[0]["team_id"] == "") {
if (userres.data[0]["team_id"] == "") {
return {
code: 200,
message: "成功返回小队活动列表",
join:false,
join: false,
data: {
username: userres.data[0]["name"],
icon: userres.data[0]["icon"],
activityList: []
}
}
}
teamid = userres.data[0]["team_id"]
const collection = db.collection('mustgo-team-activity')
let res = await collection.where({
team_id: teamid
......@@ -48,6 +49,7 @@ exports.main = async (event, context) => {
message: "成功返回小队活动列表",
data: {
username: userres.data[0]["name"],
icon: userres.data[0]["icon"],
activityList: list
}
}
......
......@@ -3,10 +3,22 @@ exports.main = async (event, context) => {
const db = uniCloud.database()
const collection = db.collection('mustgo-registration')
const activitycollection = db.collection('mustgo-team-activity')
let regres = await collection.where({
team_activity_id: event.activityId,
owner_id:event.userId
}).get()
if (regres.affectedDocs == 1) {
return {
"code": 400,
"message": "报名小队活动失败",
"data": {}
}
}
let activityres = await activitycollection.where({
_id: event.activityId
}).get()
if (activityres.affectedDocs == 1) {
const res = await collection.add({
team_activity_id: event.activityId,
......
......@@ -2,9 +2,32 @@
exports.main = async (event, context) => {
const db = uniCloud.database()
const collection = db.collection('mustgo-user')
let res1 = await collection.where({
_id: event.userId
}).get()
if (res1.affectedDocs <= 0) {
return {
"code": 400,
"message": "退出小队失败",
"data": {}
}
}
let teamid
if (res1.affectedDocs == 1) {
teamid = res1.data[0]["team_id"]
}
if(teamid == "") {
return {
"code": 400,
"message": "退出小队失败",
"data": {}
}
}
let res = await collection.where({
_id: event.userId,
team_id: event.teamId
team_id: teamid
}).get()
if (res.affectedDocs == 1) {
......
......@@ -2,8 +2,32 @@
exports.main = async (event, context) => {
const db = uniCloud.database()
const collection = db.collection('mustgo-user')
let res1 = await collection.where({
_id: event.userId
}).get()
if (res1.affectedDocs <= 0) {
return {
"code": 400,
"message": "返回小队成员列表失败",
"data": {}
}
}
let teamid
if (res1.affectedDocs == 1) {
teamid = res1.data[0]["team_id"]
}
if(teamid == "") {
return {
"code": 400,
"message": "返回小队成员列表失败",
"data": {}
}
}
let res = await collection.where({
team_id: event.teamId
team_id: teamid
}).get()
var list = new Array;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册