提交 af9c2ab2 编写于 作者: M MicroMilo

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

'use strict';
exports.main = async (event, context) => {
const db = uniCloud.database()
const collection = db.collection('mustgo-message')
const usercollection = db.collection('mustgo-user')
const postcollection = db.collection('mustgo-post')
let res = await collection.where({
to_id: event.userId
}).get()
var list = new Array;
var arr = new Array;
arr = res.data;
if (res.affectedDocs >= 0) {
for (var i = arr.length - 1; i >= 0; i--) {
let userres = await usercollection.where({
_id: arr[i]["from_id"]
}).get()
let postres = await postcollection.where({
_id: arr[i]["post_id"]
}).get()
var message = {
id: arr[i]["_id"],
types: arr[i]["types"],
content: arr[i]["content"],
time: arr[i]["time"],
user_icon: userres.data[0]["icon"],
user_name: userres.data[0]["name"],
picture: postres.data[0]["url"][0]
}
list.push(message);
}
return {
code: 200,
message: "成功返回消息列表",
data: {
messages: list
}
}
}
return {
code: 400,
message: "返回消息列表失败",
data: {}
}
};
\ No newline at end of file
{
"name": "fe-message-readMessage",
"dependencies": {},
"extensions": {
"uni-cloud-jql": {}
}
}
\ No newline at end of file
'use strict';
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
}).remove()
let result = await activitycollection.where({
_id: event.activityId
}).get()
if (result.affectedDocs == 1) {
const res = await activitycollection.doc(event.activityId).update({
enrollment: result.data[0]["enrollment"] - 1
})
if (regres.affectedDocs == 1 && res.affectedDocs == 1) {
return {
"code": 200,
"message": "取消报名成功",
"data": {}
}
}
}
return {
"code": 400,
"message": "取消报名失败",
"data": {}
}
};
\ No newline at end of file
{
"name": "fe-team-cancelActivity",
"dependencies": {},
"extensions": {
"uni-cloud-jql": {}
}
}
\ No newline at end of file
......@@ -2,11 +2,8 @@
exports.main = async (event, context) => {
const db = uniCloud.database()
const collection = db.collection('mustgo-user')
<<<<<<< HEAD
=======
const activitycollection = db.collection('mustgo-team-activity')
>>>>>>> 23cd157a5405ab804c346a27b655ccf7564925eb
let res1 = await collection.where({
_id: event.userId
......@@ -58,13 +55,6 @@ exports.main = async (event, context) => {
arr = res2.data
const registration = db.collection('mustgo-registration')
for (var i = 0; i < arr.length; i++) {
<<<<<<< HEAD
const tmp = await registration.where({
team_activity_id: arr[i]["_id"]
}).remove()
// doc(`${id}`).update({team_activity_id:{name:dbCmd.remove()}})
=======
const res = await activitycollection.doc(arr[i]["_id"]).update({
enrollment: arr[i]["enrollment"]-1
})
......@@ -72,7 +62,6 @@ exports.main = async (event, context) => {
const tmp = await registration.where({
team_activity_id: arr[i]["_id"]
}).remove()
>>>>>>> 23cd157a5405ab804c346a27b655ccf7564925eb
}
return {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册