feat: label category
This commit is contained in:
parent
cf79216a6e
commit
1a22bd3836
|
@ -1,4 +1,4 @@
|
|||
import { baseRoutes } from "./router.config";
|
||||
import { baseRoutes, commonRoutes } from "./router.config";
|
||||
import { Route, RouteObject, Routes, useLocation } from "react-router-dom";
|
||||
import { RouteGuard } from "./AuthGuard";
|
||||
import { pathToRegexp } from "path-to-regexp";
|
||||
|
@ -16,7 +16,7 @@ export const RouterElements = () => {
|
|||
/**
|
||||
* document.title
|
||||
*/
|
||||
const currentRoute = [...baseRoutes].find((r) =>
|
||||
const currentRoute = [...baseRoutes, ...commonRoutes].find((r) =>
|
||||
pathToRegexp(location.pathname).test(r.path!)
|
||||
);
|
||||
document.title = currentRoute?.title ?? defaultTitle;
|
||||
|
@ -32,9 +32,9 @@ export const RouterElements = () => {
|
|||
));
|
||||
|
||||
return (
|
||||
<RouteGuard ignorePaths={[]}>
|
||||
<RouteGuard ignorePaths={baseRoutes.map((r) => r.path!)}>
|
||||
<Routes>
|
||||
{generateRoutes(baseRoutes)}
|
||||
{generateRoutes([...baseRoutes, ...commonRoutes])}
|
||||
<Route key="notfound" path="*" element={<span>404</span>} />
|
||||
</Routes>
|
||||
</RouteGuard>
|
||||
|
|
|
@ -17,6 +17,9 @@ export const baseRoutes: (RouteObject & ExpandRouteProps)[] = [
|
|||
element: <Login />,
|
||||
title: "登录 - CVPILOT Viewer",
|
||||
},
|
||||
];
|
||||
|
||||
export const commonRoutes: (RouteObject & ExpandRouteProps)[] = [
|
||||
{
|
||||
path: "/",
|
||||
element: <Layout />,
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
@Entity()
|
||||
export class LabelCategory {
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
|
||||
@Column()
|
||||
name: string;
|
||||
|
||||
@CreateDateColumn({ type: 'timestamp' })
|
||||
createAt: Date;
|
||||
|
||||
@UpdateDateColumn({ type: 'timestamp' })
|
||||
updateAt: Date;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
import { LabelSource } from 'src/app.constant';
|
||||
import { LabelSource } from '../../app.constant';
|
||||
import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
|
|
|
@ -6,6 +6,11 @@ import { LabelService } from './label.service';
|
|||
export class LabelController {
|
||||
constructor(private readonly labelService: LabelService) {}
|
||||
|
||||
@EventPattern({ cmd: 'dicom.label.category.create' })
|
||||
async createLabelCategory(payload) {
|
||||
return await this.labelService.createLabelCategory(payload);
|
||||
}
|
||||
|
||||
@EventPattern({ cmd: 'dicom.label.create' })
|
||||
async createLabel(payload) {
|
||||
return await this.labelService.createLabel(payload);
|
||||
|
|
|
@ -3,6 +3,7 @@ import { LabelController } from './label.controller';
|
|||
import { LabelService } from './label.service';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { Label } from './entity/label.entity';
|
||||
import { LabelCategory } from './entity/label.category.entity';
|
||||
|
||||
@Module({
|
||||
controllers: [LabelController],
|
||||
|
@ -18,7 +19,7 @@ import { Label } from './entity/label.entity';
|
|||
synchronize: true,
|
||||
timezone: 'Asia/Shanghai', // 这里设置了时区
|
||||
}),
|
||||
TypeOrmModule.forFeature([Label]),
|
||||
TypeOrmModule.forFeature([Label, LabelCategory]),
|
||||
],
|
||||
providers: [LabelService],
|
||||
})
|
||||
|
|
|
@ -2,13 +2,24 @@ import { Injectable } from '@nestjs/common';
|
|||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Label } from './entity/label.entity';
|
||||
import { Repository } from 'typeorm';
|
||||
import { LabelCategory } from './entity/label.category.entity';
|
||||
|
||||
@Injectable()
|
||||
export class LabelService {
|
||||
constructor(
|
||||
@InjectRepository(Label)
|
||||
private readonly labelRepository: Repository<Label>,
|
||||
@InjectRepository(LabelCategory)
|
||||
private readonly labelCategoryRepository: Repository<LabelCategory>,
|
||||
) {}
|
||||
|
||||
async createLabelCategory(payload) {
|
||||
console.log(payload);
|
||||
return await this.labelCategoryRepository.save({
|
||||
name: '默认',
|
||||
});
|
||||
}
|
||||
|
||||
async createLabel(payload) {
|
||||
console.log(payload);
|
||||
return await this.labelRepository.save({
|
||||
|
|
Loading…
Reference in New Issue
Block a user