forked from wangziqi/gongxue-base
feat: 增加宿舍查寝功能
This commit is contained in:
@@ -19,6 +19,8 @@ import { RoomsService } from './rooms.service';
|
||||
import { CreateRoomDto, UpdateRoomDto } from './dto/room.dto';
|
||||
import { CreateBedDto, UpdateBedDto, BatchCreateBedDto } from './dto/bed.dto';
|
||||
import { CreateLockerDto, UpdateLockerDto, BatchCreateLockerDto } from './dto/locker.dto';
|
||||
import { UpdateRoomInspectionDto } from './dto/room-inspection.dto';
|
||||
import { RoomInspectionsService } from './room-inspections.service';
|
||||
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
|
||||
import { OperationLogsService } from '../operation-logs/operation-logs.service';
|
||||
import { extractRequestInfo } from '../common/request-utils';
|
||||
@@ -31,6 +33,7 @@ export class RoomsController {
|
||||
constructor(
|
||||
private service: RoomsService,
|
||||
private logService: OperationLogsService,
|
||||
private inspectionsService: RoomInspectionsService,
|
||||
) {}
|
||||
|
||||
@Get()
|
||||
@@ -54,6 +57,35 @@ export class RoomsController {
|
||||
return this.service.getRoomVisual(asOf);
|
||||
}
|
||||
|
||||
@Put(':roomId/inspections/:date')
|
||||
@RequirePermission('room:inspect')
|
||||
async updateInspection(
|
||||
@Param('roomId') roomId: string,
|
||||
@Param('date') date: string,
|
||||
@Body() dto: UpdateRoomInspectionDto,
|
||||
@Request() req: any,
|
||||
) {
|
||||
const { ipAddress, userAgent } = extractRequestInfo(req);
|
||||
const result = await this.inspectionsService.submit(
|
||||
+roomId,
|
||||
date,
|
||||
dto.presentOccupancyIds,
|
||||
{ id: req.user?.id, username: req.user?.username },
|
||||
);
|
||||
await this.logService.log({
|
||||
userId: req.user?.id,
|
||||
username: req.user?.username,
|
||||
module: '宿舍查寝',
|
||||
action: result.isUpdate ? '修改查寝记录' : '提交查寝记录',
|
||||
targetId: +roomId,
|
||||
targetType: 'room',
|
||||
detail: `查寝日期: ${date}, 宿舍: ${result.roomNumber}, 在寝: ${result.presentNames.join('、') || '无'}, 缺勤: ${result.absentNames.join('、') || '无'}`,
|
||||
ipAddress,
|
||||
userAgent,
|
||||
});
|
||||
return result.inspection;
|
||||
}
|
||||
|
||||
@Get('template')
|
||||
@RequirePermission('room:view')
|
||||
async downloadTemplate(@Res() res: Response) {
|
||||
|
||||
Reference in New Issue
Block a user