You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.3 KiB
41 lines
1.3 KiB
// 云函数入口文件
|
|
const cloud = require('wx-server-sdk')
|
|
cloud.init({ env: 'yz-7g23c92hf3223f1d' }) // 使用当前云环境
|
|
|
|
const db = cloud.database()
|
|
const _ = db.command
|
|
|
|
// 云函数入口函数
|
|
exports.main = async (event, context) => {
|
|
console.log(event.filename);
|
|
const wxContext = cloud.getWXContext()
|
|
if(event.type == 0) {
|
|
//增序返回所有学生
|
|
return await db.collection('namelist').where({
|
|
filename : _.eq(event.filename)
|
|
}).orderBy('student_ID', 'asc').limit(500).get();
|
|
} else if(event.type == 1) {
|
|
console.log(event.student_ID);
|
|
console.log(event.name);
|
|
console.log(event.state);
|
|
//修改对应学生的状态
|
|
return await db.collection('namelist').where({
|
|
filename : _.eq(event.filename),
|
|
student_ID : _.eq(event.student_ID),
|
|
name : _.eq(event.name)
|
|
}).update({
|
|
data : {
|
|
state : event.state,
|
|
attendance_count : event.attendance_count,
|
|
score : event.score
|
|
}
|
|
});
|
|
} else {
|
|
//增序查询对应状态的所有学生
|
|
return await db.collection('namelist').where({
|
|
filename : _.eq(event.filename),
|
|
state : _.eq(event.state)
|
|
}).orderBy('student_ID', 'asc').limit(500).get();
|
|
}
|
|
}
|