提交 d69b41f4 编写于 作者: M MicroMilo

Merge branch 'backend' of https://gitcode.net/qq_50679803/great-teamwork into backend

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