Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Server/src/routes/donor.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
excluded,
deceased,
tags,
min_donation,

Check warning on line 117 in Server/src/routes/donor.js

View workflow job for this annotation

GitHub Actions / lint

'min_donation' is assigned a value but never used
search
} = req.query;

Expand Down Expand Up @@ -160,8 +160,8 @@
// Get total count for pagination
const total = await prisma.donor.count({ where });

// 转换下划线格式的排序字段为驼峰命名
// 映射查询参数中的蛇形命名到数据库模型的驼峰命名
// Convert underscore format sort field to camelCase
// Map snake_case in query parameters to camelCase in database model
const sortMapping = {
'first_name': 'firstName',
'last_name': 'lastName',
Expand All @@ -171,7 +171,7 @@
'last_gift_date': 'lastGiftDate'
};

// 使用映射表或直接使用字段名(如果已经是驼峰命名)
// Use mapping table or directly use field name (if already in camelCase)
const sortField = sortMapping[sort] || sort;

// Get donors with pagination, sorting, and filtering
Expand Down
18 changes: 9 additions & 9 deletions Server/src/routes/donorList.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,13 +341,13 @@ router.post('/:id/donors', protect, async (req, res) => {
return res.status(400).json({ message: 'Invalid donor IDs array' });
}

// 确保所有 ID 都是数字类型
// Ensure all IDs are numeric
const numericDonorIds = donorIds.map(id => Number(id));
if (numericDonorIds.some(isNaN)) {
return res.status(400).json({ message: 'Invalid donor ID format' });
}

// Check if list exists
// Verify if the donor list exists
const list = await prisma.eventDonorList.findUnique({
where: { id: listId }
});
Expand Down Expand Up @@ -780,7 +780,7 @@ router.get('/:id/donors', protect, async (req, res) => {
const limitNum = parseInt(limit);
const skip = (pageNum - 1) * limitNum;

// 验证捐赠者列表是否存在
// Verify if the donor list exists
const list = await prisma.eventDonorList.findUnique({
where: { id: listId }
});
Expand All @@ -789,17 +789,17 @@ router.get('/:id/donors', protect, async (req, res) => {
return res.status(404).json({ message: 'Donor list not found' });
}

// 构建查询条件
// Build query conditions
const where = {
donorListId: listId
};

// 添加状态过滤
// Add status filter
if (status) {
where.status = status;
}

// 添加名称搜索过滤(搜索关联的捐赠者的名称)
// Add name search filter (search for associated donor names)
if (search) {
where.donor = {
OR: [
Expand All @@ -810,10 +810,10 @@ router.get('/:id/donors', protect, async (req, res) => {
};
}

// 获取总记录数
// Get total record count
const total = await prisma.eventDonor.count({ where });

// 获取捐赠者数据
// Get donor data
const eventDonors = await prisma.eventDonor.findMany({
where,
skip,
Expand All @@ -834,7 +834,7 @@ router.get('/:id/donors', protect, async (req, res) => {
}
});

// 转换数据为API期望的格式
// Convert data to API expected format
const formattedDonors = eventDonors.map(ed => ({
id: ed.id,
donor_id: ed.donorId,
Expand Down
Loading
Loading