feat: 3.5版本规划
This commit is contained in:
@@ -36,13 +36,26 @@ exports.main = async (event) => {
|
||||
|
||||
async function handleAdd(userId, event) {
|
||||
const { worksheetId } = event;
|
||||
const exportId = String(event.exportId || '').trim();
|
||||
if (!worksheetId) return { code: -1, message: 'worksheetId 不能为空' };
|
||||
|
||||
const collection = db.collection('download_logs');
|
||||
|
||||
// 同一次成功导出重试时只能计一次,避免网络重试抬高下载量。
|
||||
if (exportId) {
|
||||
const { data: existing } = await collection
|
||||
.where({ userId, exportId })
|
||||
.limit(1)
|
||||
.get();
|
||||
if (existing.length > 0) {
|
||||
return { code: 0, data: { ...existing[0], duplicate: true } };
|
||||
}
|
||||
}
|
||||
|
||||
const record = {
|
||||
userId,
|
||||
worksheetId,
|
||||
...(exportId && { exportId }),
|
||||
createdAt: db.serverDate(),
|
||||
};
|
||||
const { _id } = await collection.add({ data: record });
|
||||
|
||||
Reference in New Issue
Block a user