提交 ba1515e0 编写于 作者: 0 052004122温宸杰

后台管理系统优化

......@@ -6,7 +6,7 @@ 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"]
......@@ -17,21 +17,70 @@ exports.main = async (event, context) => {
username = res1.data[0]["name"]
icon = res1.data[0]["icon"]
}
const reg = db.collection('mustgo-registration')
let res2 = await reg.where({
team_activity_id: event.activityId,
owner_id: event.userId
}).get()
if (res2.affectedDocs == 1) {
return {
code: 200,
message: "成功返回活动详情",
qualification: "取消报名",
data: {
"username": username,
"icon": icon,
"content": res.data[0]["content"],
"startDate": res.data[0]["start_date"],
"endDate": res.data[0]["end_date"],
"place": res.data[0]["place"],
"participants": res.data[0]["participants"],
"contact": res.data[0]["contact"],
"enrollment":res.data[0]["enrollment"]
}
}
}
// console.log(res.date[0]["participants"])
// console.log(res.date[0]["enrollment"])
if (res.data[0]["participants"] <= res.data[0]["enrollment"]) {
return {
code: 200,
message: "成功返回活动详情",
qualification: "报名停止",
data: {
"username": username,
"icon": icon,
"content": res.data[0]["content"],
"startDate": res.data[0]["start_date"],
"endDate": res.data[0]["end_date"],
"place": res.data[0]["place"],
"participants": res.data[0]["participants"],
"contact": res.data[0]["contact"],
"enrollment":res.data[0]["enrollment"]
}
}
}
return {
code: 200,
message: "成功返回活动详情",
qualification: "报名",
data: {
"username":username,
"icon":icon,
"username": username,
"icon": icon,
"content": res.data[0]["content"],
"startDate": res.data[0]["start_date"],
"endDate": res.data[0]["end_date"],
"place": res.data[0]["place"],
"participants": res.data[0]["participants"],
"contact": res.data[0]["contact"]
"contact": res.data[0]["contact"],
"enrollment":res.data[0]["enrollment"]
}
}
}
return {
"code": 400,
......
......@@ -3,10 +3,10 @@ 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
owner_id: event.userId
}).get()
if (regres.affectedDocs == 1) {
return {
......@@ -15,7 +15,7 @@ exports.main = async (event, context) => {
"data": {}
}
}
let activityres = await activitycollection.where({
_id: event.activityId
}).get()
......@@ -24,12 +24,19 @@ exports.main = async (event, context) => {
team_activity_id: event.activityId,
owner_id: event.userId
})
if (res.id.length > 0)
if (res.id.length > 0) {
const res = await activitycollection.doc(event.activityId).update({
enrollment: activityres.data[0]["enrollment"]+1
})
return {
"code": 200,
"message": "报名小队活动成功",
"data": {}
}
}
}
return {
"code": 400,
......
......@@ -29,7 +29,8 @@ exports.main = async (event, context) => {
status: 0,
participants: event.participants,
contact: event.contact,
team_id: teamid
team_id: teamid,
enrollment:0
})
if (res.id.length > 0)
return {
......
......@@ -2,6 +2,11 @@
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
......@@ -53,11 +58,21 @@ 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
})
const tmp = await registration.where({
team_activity_id: arr[i]["_id"]
}).remove()
>>>>>>> 23cd157a5405ab804c346a27b655ccf7564925eb
}
return {
......
......@@ -56,8 +56,13 @@
},
"participants": {
"bsonType": "int",
"title": "参与人数",
"description": "小队活动参与人数"
"title": "限制人数",
"description": "小队活动限制人数"
},
"enrollment": {
"bsonType": "int",
"title": "报名人数",
"description": "小队活动报名人数"
},
"contact": {
"bsonType": "string",
......
{
"name": "uni-id-co",
"version": "1.0.38",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"buffer-equal-constant-time": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz",
"integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA=="
},
"ecdsa-sig-formatter": {
"version": "1.0.11",
"resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz",
"integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==",
"requires": {
"safe-buffer": "^5.0.1"
}
},
"jsonwebtoken": {
"version": "8.5.1",
"resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-8.5.1.tgz",
"integrity": "sha512-XjwVfRS6jTMsqYs0EsuJ4LGxXV14zQybNd4L2r0UvbVnSF9Af8x7p5MzbJ90Ioz/9TI41/hTCvznF/loiSzn8w==",
"requires": {
"jws": "^3.2.2",
"lodash.includes": "^4.3.0",
"lodash.isboolean": "^3.0.3",
"lodash.isinteger": "^4.0.4",
"lodash.isnumber": "^3.0.3",
"lodash.isplainobject": "^4.0.6",
"lodash.isstring": "^4.0.1",
"lodash.once": "^4.0.0",
"ms": "^2.1.1",
"semver": "^5.6.0"
}
},
"jwa": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz",
"integrity": "sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==",
"requires": {
"buffer-equal-constant-time": "1.0.1",
"ecdsa-sig-formatter": "1.0.11",
"safe-buffer": "^5.0.1"
}
},
"jws": {
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz",
"integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==",
"requires": {
"jwa": "^1.4.1",
"safe-buffer": "^5.0.1"
}
},
"lodash.includes": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz",
"integrity": "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w=="
},
"lodash.isboolean": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz",
"integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg=="
},
"lodash.isinteger": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz",
"integrity": "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA=="
},
"lodash.isnumber": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz",
"integrity": "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw=="
},
"lodash.isplainobject": {
"version": "4.0.6",
"resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz",
"integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA=="
},
"lodash.isstring": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz",
"integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw=="
},
"lodash.merge": {
"version": "4.6.2",
"resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz",
"integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ=="
},
"lodash.once": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz",
"integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg=="
},
"ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
},
"safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ=="
},
"semver": {
"version": "5.7.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
"integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ=="
},
"uni-captcha": {
"version": "file:../../../../uni-captcha/uniCloud/cloudfunctions/common/uni-captcha",
"requires": {
"uni-config-center": "file:../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
},
"dependencies": {
"uni-config-center": {
"version": "file:../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
}
}
},
"uni-config-center": {
"version": "file:../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
},
"uni-id-common": {
"version": "file:../../../../uni-id-common/uniCloud/cloudfunctions/common/uni-id-common",
"requires": {
"uni-config-center": "file:../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
},
"dependencies": {
"uni-config-center": {
"version": "file:../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
}
}
},
"uni-open-bridge-common": {
"version": "file:../../../../uni-open-bridge-common/uniCloud/cloudfunctions/common/uni-open-bridge-common",
"requires": {
"uni-config-center": "file:../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
},
"dependencies": {
"uni-config-center": {
"version": "file:../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
}
}
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册