diff --git a/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-message-readMessage/index.js b/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-message-readMessage/index.js new file mode 100644 index 0000000000000000000000000000000000000000..fe595aa433750bb8f0590f924e72e9ce0dc09e21 --- /dev/null +++ b/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-message-readMessage/index.js @@ -0,0 +1,49 @@ +'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 diff --git a/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-message-readMessage/package.json b/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-message-readMessage/package.json new file mode 100644 index 0000000000000000000000000000000000000000..383557f6740543a91e854c28e0dfae428a3bfe25 --- /dev/null +++ b/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-message-readMessage/package.json @@ -0,0 +1,7 @@ +{ + "name": "fe-message-readMessage", + "dependencies": {}, + "extensions": { + "uni-cloud-jql": {} + } +} \ No newline at end of file diff --git a/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-team-cancelActivity/index.js b/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-team-cancelActivity/index.js new file mode 100644 index 0000000000000000000000000000000000000000..dbd3ac97d27fae56a7cbd8c609e1b5458df33c49 --- /dev/null +++ b/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-team-cancelActivity/index.js @@ -0,0 +1,36 @@ +'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 diff --git a/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-team-cancelActivity/package.json b/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-team-cancelActivity/package.json new file mode 100644 index 0000000000000000000000000000000000000000..0c703a8eb8ef5b0744125c24ae15b2bc4f78a176 --- /dev/null +++ b/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-team-cancelActivity/package.json @@ -0,0 +1,7 @@ +{ + "name": "fe-team-cancelActivity", + "dependencies": {}, + "extensions": { + "uni-cloud-jql": {} + } +} \ No newline at end of file diff --git a/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-team-joinTeam/index.js b/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-team-joinTeam/index.js index 43b1ae87a1965da4bcb25f9c6994dc7dbee7b149..dcff0eca62f25a59b3dfb7ba6aa3955dd1c7cc91 100644 --- a/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-team-joinTeam/index.js +++ b/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-team-joinTeam/index.js @@ -38,4 +38,4 @@ exports.main = async (event, context) => { "message": "加入小队失败", "data": {} } -}; +}; \ No newline at end of file diff --git a/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-team-leaveTeam/index.js b/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-team-leaveTeam/index.js index bc1184b320e795769320d97819091897be9e7837..08955847b15652cc3d3cbaae11a0c8ca71d81297 100644 --- a/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-team-leaveTeam/index.js +++ b/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-team-leaveTeam/index.js @@ -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 {