refactor: resolve remaining field audit issues
This commit is contained in:
@@ -67,6 +67,7 @@ export class RoomsController {
|
||||
{ header: '宿舍类型', key: 'roomType', width: 12 },
|
||||
{ header: '租赁类型(long/short)', key: 'rentalCategory', width: 18 },
|
||||
{ header: '月租金', key: 'monthlyRate', width: 10 },
|
||||
{ header: '宿舍性别(男/女)', key: 'gender', width: 18 },
|
||||
];
|
||||
ws.addRow({
|
||||
roomNumber: '4-102',
|
||||
@@ -76,6 +77,7 @@ export class RoomsController {
|
||||
roomType: '四人间',
|
||||
rentalCategory: 'long',
|
||||
monthlyRate: 800,
|
||||
gender: '男',
|
||||
});
|
||||
ws.addRow({
|
||||
roomNumber: '2-201',
|
||||
@@ -85,6 +87,7 @@ export class RoomsController {
|
||||
roomType: '单人间',
|
||||
rentalCategory: 'short',
|
||||
monthlyRate: 0,
|
||||
gender: '女',
|
||||
});
|
||||
res.setHeader(
|
||||
'Content-Type',
|
||||
@@ -168,11 +171,7 @@ export class RoomsController {
|
||||
|
||||
@Put(':roomId/beds/:id')
|
||||
@RequirePermission('room:edit')
|
||||
updateBed(
|
||||
@Param('roomId') roomId: string,
|
||||
@Param('id') id: string,
|
||||
@Body() dto: UpdateBedDto,
|
||||
) {
|
||||
updateBed(@Param('roomId') roomId: string, @Param('id') id: string, @Body() dto: UpdateBedDto) {
|
||||
return this.service.updateBed(+roomId, +id, dto);
|
||||
}
|
||||
|
||||
@@ -340,16 +339,26 @@ export class RoomsController {
|
||||
roomType?: string;
|
||||
rentalCategory?: string;
|
||||
monthlyRate?: number;
|
||||
gender?: '男' | '女';
|
||||
}[] = [];
|
||||
ws.eachRow((row, idx) => {
|
||||
if (idx === 1) return;
|
||||
const rentalCategoryRaw = String(row.getCell(6).value || '').trim().toLowerCase();
|
||||
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;
|
||||
const genderRaw = String(row.getCell(8).value || '').trim();
|
||||
const gender =
|
||||
genderRaw === '男' || genderRaw === '男生'
|
||||
? '男'
|
||||
: genderRaw === '女' || genderRaw === '女生'
|
||||
? '女'
|
||||
: undefined;
|
||||
rows.push({
|
||||
roomNumber: String(row.getCell(1).value || ''),
|
||||
building: String(row.getCell(2).value || '') || undefined,
|
||||
@@ -358,6 +367,7 @@ export class RoomsController {
|
||||
roomType: String(row.getCell(5).value || '').trim() || undefined,
|
||||
rentalCategory,
|
||||
monthlyRate,
|
||||
gender,
|
||||
});
|
||||
});
|
||||
const result = await this.service.batchImport(rows);
|
||||
|
||||
Reference in New Issue
Block a user