feat: integrate CampusScope.filter() into all business services (12 services + 12 modules)

This commit is contained in:
2026-07-05 23:58:51 +08:00
parent eeae06fe30
commit cd6364268d
40 changed files with 949 additions and 172 deletions

View File

@@ -63,15 +63,17 @@ export class RoomsController {
{ header: '楼层', key: 'floor', width: 8 },
{ header: '额定人数', key: 'capacity', width: 10 },
{ header: '宿舍类型', key: 'roomType', width: 12 },
{ header: '租赁类型(long/short)', key: 'rentalCategory', width: 18 },
{ header: '月租金', key: 'monthlyRate', width: 10 },
];
ws.getRow(1).font = { bold: true };
ws.getRow(1).fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FFE0E0E0' } };
ws.addRow({
roomNumber: '4-102',
building: '4号楼',
floor: 1,
capacity: 4,
roomType: '四人间',
rentalCategory: 'long',
monthlyRate: 800,
});
ws.addRow({
roomNumber: '2-201',
@@ -79,6 +81,8 @@ export class RoomsController {
floor: 2,
capacity: 1,
roomType: '单人间',
rentalCategory: 'short',
monthlyRate: 0,
});
res.setHeader(
'Content-Type',
@@ -106,6 +110,8 @@ export class RoomsController {
{ header: '当前入住', key: 'currentCount', width: 10 },
{ header: '性别', key: 'gender', width: 8 },
{ header: '状态', key: 'status', width: 10 },
{ header: '租赁类型', key: 'rentalCategory', width: 12 },
{ header: '月租金', key: 'monthlyRate', width: 10 },
];
ws.getRow(1).font = { bold: true };
ws.getRow(1).fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FFE0E0E0' } };
@@ -125,6 +131,8 @@ export class RoomsController {
currentCount: r.currentCount,
gender: r.gender || '',
status: statusMap[r.status] || r.status,
rentalCategory: r.rentalCategory === 'long' ? '长租' : '短租',
monthlyRate: r.monthlyRate ?? '',
});
}
res!.setHeader(
@@ -245,15 +253,26 @@ export class RoomsController {
floor?: number;
capacity?: number;
roomType?: string;
rentalCategory?: string;
monthlyRate?: number;
}[] = [];
ws.eachRow((row, idx) => {
if (idx === 1) return;
const rentalCategoryRaw = String(row.getCell(6).value || '').trim().toLowerCase();
const rentalCategory =
rentalCategoryRaw === 'long' || rentalCategoryRaw === 'short'
? rentalCategoryRaw
: undefined;
const monthlyRateRaw = Number(row.getCell(7).value);
const monthlyRate = isNaN(monthlyRateRaw) ? undefined : monthlyRateRaw;
rows.push({
roomNumber: String(row.getCell(1).value || ''),
building: String(row.getCell(2).value || '') || undefined,
floor: Number(row.getCell(3).value) || undefined,
capacity: Number(row.getCell(4).value) || 4,
roomType: String(row.getCell(5).value || '').trim() || undefined,
rentalCategory,
monthlyRate,
});
});
const result = await this.service.batchImport(rows);