From f9022549094c33fac8c284db69e75b9bc1ff2cb7 Mon Sep 17 00:00:00 2001 From: mozzie Date: Thu, 14 Sep 2023 16:49:41 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=A0=87=E7=AD=BE=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/Label/entities/labelCategory.ts | 10 ++ apps/dmp/core/domain/Label/labelRepository.ts | 8 ++ apps/dmp/core/domain/Label/labelService.ts | 13 +++ apps/dmp/core/infra/api/dto.ts | 36 ++++++ apps/dmp/core/infra/api/index.ts | 44 +++----- apps/dmp/src/context/domainService.tsx | 4 + apps/dmp/src/modules/Admin/Label/index.less | 37 ++++++ apps/dmp/src/modules/Admin/Label/index.tsx | 105 +++++++++++++----- ....category.entity.ts => category.entity.ts} | 0 apps/services/dicom/src/label/label.module.ts | 5 +- .../services/dicom/src/label/label.service.ts | 9 +- .../dmp/gateway/src/dicom/dicom.controller.ts | 9 ++ 12 files changed, 212 insertions(+), 68 deletions(-) create mode 100644 apps/dmp/core/domain/Label/entities/labelCategory.ts create mode 100644 apps/dmp/core/domain/Label/labelRepository.ts create mode 100644 apps/dmp/core/domain/Label/labelService.ts create mode 100644 apps/dmp/core/infra/api/dto.ts rename apps/services/dicom/src/label/entity/{label.category.entity.ts => category.entity.ts} (100%) diff --git a/apps/dmp/core/domain/Label/entities/labelCategory.ts b/apps/dmp/core/domain/Label/entities/labelCategory.ts new file mode 100644 index 0000000..abc4587 --- /dev/null +++ b/apps/dmp/core/domain/Label/entities/labelCategory.ts @@ -0,0 +1,10 @@ +export type LabelCategoryType = { + name: string; +}; + +export class LabelCategory { + name: string; + constructor(props: LabelCategoryType) { + this.name = props.name; + } +} diff --git a/apps/dmp/core/domain/Label/labelRepository.ts b/apps/dmp/core/domain/Label/labelRepository.ts new file mode 100644 index 0000000..4e69087 --- /dev/null +++ b/apps/dmp/core/domain/Label/labelRepository.ts @@ -0,0 +1,8 @@ +import { Apis } from "@@/infra/api"; +import { LabelCategory } from "./entities/labelCategory"; + +export class LabelRepository { + async createNewLabelCategory(labelCategory: LabelCategory) { + return await Apis.createNewLabelCategory(labelCategory); + } +} diff --git a/apps/dmp/core/domain/Label/labelService.ts b/apps/dmp/core/domain/Label/labelService.ts new file mode 100644 index 0000000..f0c9777 --- /dev/null +++ b/apps/dmp/core/domain/Label/labelService.ts @@ -0,0 +1,13 @@ +import { LabelCategory } from "./entities/labelCategory"; +import { LabelRepository } from "./labelRepository"; + +export class LabelService { + constructor(private labelRepository: LabelRepository) {} + + async createNewLabelCategory(labelCategory: LabelCategory) { + const { code } = await this.labelRepository.createNewLabelCategory( + labelCategory + ); + return { code }; + } +} diff --git a/apps/dmp/core/infra/api/dto.ts b/apps/dmp/core/infra/api/dto.ts new file mode 100644 index 0000000..8ca05b3 --- /dev/null +++ b/apps/dmp/core/infra/api/dto.ts @@ -0,0 +1,36 @@ +import { Study } from "@/modules/Admin/Dicom/Upload/DicomUploader/util"; +import { User } from "@@/domain/User/entities/User"; + +export type ResponseType = Promise<{ + code?: number | string; + data?: unknown; + msg?: string; +}>; + +export type ResponsePacsType = Promise<{ + ID: string; + ParentPatient: string; + ParentSeries: string; + ParentStudy: string; + Path: string; + Status: string; +}>; + +export type ExistInPacsDTO = { + StudyInstanceUID: string; + SeriesInstanceUID: string; +}; + +export type ArchiveTaskCreateDto = { + user: User; + study: Study[]; +}; + +export type DownloadArchiveDTO = { + ID: string; + Type: "study" | "series" | "Study" | "Series"; +}; + +export type labelCategoryDTO = { + name: string; +}; diff --git a/apps/dmp/core/infra/api/index.ts b/apps/dmp/core/infra/api/index.ts index c44932c..1e2600f 100644 --- a/apps/dmp/core/infra/api/index.ts +++ b/apps/dmp/core/infra/api/index.ts @@ -1,43 +1,20 @@ import { User } from "@@/domain/User/entities/User"; import { Request } from "./Request"; -import { Study } from "@/modules/Admin/Dicom/Upload/DicomUploader/util"; import axios from "axios"; import { saveAs } from "file-saver"; +import { + ArchiveTaskCreateDto, + DownloadArchiveDTO, + ExistInPacsDTO, + ResponsePacsType, + ResponseType, + labelCategoryDTO, +} from "./dto"; const PREFIX = "/api/dmp"; const PREFIX_CERT = "/cert"; const PREFIX_PACS = "/dicom-web"; -type ResponseType = Promise<{ - code?: number | string; - data?: unknown; - msg?: string; -}>; - -type ResponsePacsType = Promise<{ - ID: string; - ParentPatient: string; - ParentSeries: string; - ParentStudy: string; - Path: string; - Status: string; -}>; - -export type ExistInPacsDTO = { - StudyInstanceUID: string; - SeriesInstanceUID: string; -}; - -export type ArchiveTaskCreateDto = { - user: User; - study: Study[]; -}; - -export type DownloadArchiveDTO = { - ID: string; - Type: "study" | "series" | "Study" | "Series"; -}; - export const Apis = { /** * 用户登录 @@ -105,4 +82,9 @@ export const Apis = { .catch((error) => { console.error("Download error:", error); }), + /** + * 创建新的标签分类 + */ + createNewLabelCategory: (p: labelCategoryDTO): ResponseType => + Request.post(PREFIX + "/dicom/label/category/create", p), }; diff --git a/apps/dmp/src/context/domainService.tsx b/apps/dmp/src/context/domainService.tsx index ca6eeec..f4768d3 100644 --- a/apps/dmp/src/context/domainService.tsx +++ b/apps/dmp/src/context/domainService.tsx @@ -1,5 +1,7 @@ import { DicomRepository } from "@@/domain/Dicom/DicomRepository"; import { DicomService } from "@@/domain/Dicom/DicomService"; +import { LabelRepository } from "@@/domain/Label/labelRepository"; +import { LabelService } from "@@/domain/Label/labelService"; import { UserRepository } from "@@/domain/User/UserRepository"; import { UserService } from "@@/domain/User/UserService"; import { createContext } from "react"; @@ -7,11 +9,13 @@ import { createContext } from "react"; export type Services = { userDomainService: UserService; dicomDomainService: DicomService; + labelDomainService: LabelService; }; const defaultServiceMap = { userDomainService: new UserService(new UserRepository()), dicomDomainService: new DicomService(new DicomRepository()), + labelDomainService: new LabelService(new LabelRepository()), }; export const DomainServiceContext = createContext(defaultServiceMap); diff --git a/apps/dmp/src/modules/Admin/Label/index.less b/apps/dmp/src/modules/Admin/Label/index.less index 7e61553..71ec265 100644 --- a/apps/dmp/src/modules/Admin/Label/index.less +++ b/apps/dmp/src/modules/Admin/Label/index.less @@ -6,5 +6,42 @@ aside { padding: 20px 20px 0 20px; border-right: 1px solid rgba(5, 5, 5, 0.06); + + .label-category-header { + padding: 6px !important; + background: transparent !important; + user-select: none; + } + + .label-category-item { + margin-bottom: 10px; + border: none; + background: transparent; + + // &.ant-collapse-item-active { + // background: rgba(204, 204, 204, .1); + // } + } + + .label-catalog { + margin: 0; + padding: 0; + list-style: none; + + li { + margin-bottom: 2px; + padding: 6px 0 6px 10px; + border-radius: 6px; + cursor: pointer; + + &:hover { + background: rgba(204, 204, 204, .1); + } + + &.active { + background: rgba(204, 204, 204, .2); + } + } + } } } \ No newline at end of file diff --git a/apps/dmp/src/modules/Admin/Label/index.tsx b/apps/dmp/src/modules/Admin/Label/index.tsx index 7994ab3..59e9c4e 100644 --- a/apps/dmp/src/modules/Admin/Label/index.tsx +++ b/apps/dmp/src/modules/Admin/Label/index.tsx @@ -1,56 +1,105 @@ -import { CSSProperties } from "react"; +import { useState } from "react"; import "./index.less"; -import { Collapse, CollapseProps, theme } from "antd"; -import { CaretRightOutlined } from "@ant-design/icons"; +import { + Button, + Collapse, + CollapseProps, + Form, + Input, + Modal, + theme, + Typography, +} from "antd"; +import { CaretRightOutlined, PlusOutlined } from "@ant-design/icons"; +import { useDomain } from "@/hook/useDomain"; + +const { Text } = Typography; interface LabelProps { children?: JSX.Element; } const content = ( -