新增 B 端上传接口与列表接口,统一文件上传和分页查询能力 上传能力支持医院级数据隔离:系统管理员需显式指定医院,院内角色按登录医院自动隔离 图片上传自动压缩并转为 webp,视频上传自动转码并压缩为 mp4,普通文件按原始类型存储 增加上传目录与公开访问能力,统一输出可直接预览的访问地址 前端新增影像库页面,支持按类型筛选、关键字检索、分页浏览、在线预览与原文件访问 前端新增通用上传组件,支持在页面内复用并返回上传结果 管理后台新增影像库菜单与路由,并补充页面级角色权限控制 患者手术相关表单接入上传复用能力,支持术前资料与设备标签上传回填 新增上传模块 e2e 用例,覆盖成功路径、权限矩阵与关键失败场景 补充上传模块文档与安装依赖说明,完善工程内使用说明
121 lines
3.0 KiB
TypeScript
121 lines
3.0 KiB
TypeScript
import {
|
|
Body,
|
|
Controller,
|
|
Delete,
|
|
Get,
|
|
Param,
|
|
ParseIntPipe,
|
|
Patch,
|
|
Post,
|
|
Query,
|
|
UseGuards,
|
|
} from '@nestjs/common';
|
|
import {
|
|
ApiBearerAuth,
|
|
ApiOperation,
|
|
ApiParam,
|
|
ApiQuery,
|
|
ApiTags,
|
|
} from '@nestjs/swagger';
|
|
import type { ActorContext } from '../common/actor-context.js';
|
|
import { AccessTokenGuard } from '../auth/access-token.guard.js';
|
|
import { CurrentActor } from '../auth/current-actor.decorator.js';
|
|
import { Roles } from '../auth/roles.decorator.js';
|
|
import { RolesGuard } from '../auth/roles.guard.js';
|
|
import { Role } from '../generated/prisma/enums.js';
|
|
import { DepartmentsService } from './departments.service.js';
|
|
import { CreateDepartmentDto } from './dto/create-department.dto.js';
|
|
import { UpdateDepartmentDto } from './dto/update-department.dto.js';
|
|
import { OrganizationQueryDto } from '../organization-common/dto/organization-query.dto.js';
|
|
|
|
/**
|
|
* 科室管理控制器:拆分自组织大控制器,专注科室资源。
|
|
*/
|
|
@ApiTags('科室管理(B端)')
|
|
@ApiBearerAuth('bearer')
|
|
@Controller('b/organization/departments')
|
|
@UseGuards(AccessTokenGuard, RolesGuard)
|
|
export class DepartmentsController {
|
|
constructor(private readonly departmentsService: DepartmentsService) {}
|
|
|
|
/**
|
|
* 创建科室。
|
|
*/
|
|
@Post()
|
|
@Roles(Role.SYSTEM_ADMIN, Role.HOSPITAL_ADMIN)
|
|
@ApiOperation({ summary: '创建科室' })
|
|
create(
|
|
@CurrentActor() actor: ActorContext,
|
|
@Body() dto: CreateDepartmentDto,
|
|
) {
|
|
return this.departmentsService.create(actor, dto);
|
|
}
|
|
|
|
/**
|
|
* 查询科室列表。
|
|
*/
|
|
@Get()
|
|
@Roles(
|
|
Role.SYSTEM_ADMIN,
|
|
Role.HOSPITAL_ADMIN,
|
|
Role.DIRECTOR,
|
|
Role.LEADER,
|
|
Role.DOCTOR,
|
|
)
|
|
@ApiOperation({ summary: '查询科室列表' })
|
|
@ApiQuery({ name: 'hospitalId', required: false, description: '医院 ID' })
|
|
findAll(
|
|
@CurrentActor() actor: ActorContext,
|
|
@Query() query: OrganizationQueryDto,
|
|
) {
|
|
return this.departmentsService.findAll(actor, query);
|
|
}
|
|
|
|
/**
|
|
* 查询科室详情。
|
|
*/
|
|
@Get(':id')
|
|
@Roles(
|
|
Role.SYSTEM_ADMIN,
|
|
Role.HOSPITAL_ADMIN,
|
|
Role.DIRECTOR,
|
|
Role.LEADER,
|
|
Role.DOCTOR,
|
|
)
|
|
@ApiOperation({ summary: '查询科室详情' })
|
|
@ApiParam({ name: 'id', description: '科室 ID' })
|
|
findOne(
|
|
@CurrentActor() actor: ActorContext,
|
|
@Param('id', ParseIntPipe) id: number,
|
|
) {
|
|
return this.departmentsService.findOne(actor, id);
|
|
}
|
|
|
|
/**
|
|
* 更新科室。
|
|
*/
|
|
@Patch(':id')
|
|
@Roles(Role.SYSTEM_ADMIN, Role.HOSPITAL_ADMIN)
|
|
@ApiOperation({ summary: '更新科室' })
|
|
update(
|
|
@CurrentActor() actor: ActorContext,
|
|
@Param('id', ParseIntPipe) id: number,
|
|
@Body() dto: UpdateDepartmentDto,
|
|
) {
|
|
return this.departmentsService.update(actor, id, dto);
|
|
}
|
|
|
|
/**
|
|
* 删除科室。
|
|
*/
|
|
@Delete(':id')
|
|
@Roles(Role.SYSTEM_ADMIN, Role.HOSPITAL_ADMIN)
|
|
@ApiOperation({ summary: '删除科室' })
|
|
remove(
|
|
@CurrentActor() actor: ActorContext,
|
|
@Param('id', ParseIntPipe) id: number,
|
|
) {
|
|
return this.departmentsService.remove(actor, id);
|
|
}
|
|
}
|