|
|
@@ -30,6 +30,9 @@ export class Department {
|
|
|
@Column({ name: 'is_active', type: 'tinyint', default: 1, comment: '是否启用(0:禁用,1:启用)' })
|
|
|
isActive!: number;
|
|
|
|
|
|
+ @Column({ name: 'parent_id', type: 'int', unsigned: true, nullable: true, default: 0, comment: '父部门ID,0表示顶级部门' })
|
|
|
+ parentId?: number;
|
|
|
+
|
|
|
@ManyToOne(() => Department, dept => dept.children)
|
|
|
@JoinColumn({ name: 'parent_id' })
|
|
|
parent?: Department;
|
|
|
@@ -87,7 +90,7 @@ export const DepartmentSchema = z.object({
|
|
|
sortOrder: z.number().int().default(0).openapi({ description: '排序', example: 0 }),
|
|
|
isActive: z.number().int().min(0).max(1).default(1).openapi({ description: '是否启用', example: 1 }),
|
|
|
managerId: z.number().int().positive().nullable().openapi({ description: '部门负责人ID', example: 1 }),
|
|
|
- parentId: z.number().int().positive().nullable().openapi({ description: '父部门ID', example: 1 }),
|
|
|
+ parentId: z.number().int().nonnegative().default(0).openapi({ description: '父部门ID,0表示顶级部门', example: 0 }),
|
|
|
createdAt: z.date().openapi({ description: '创建时间' }),
|
|
|
updatedAt: z.date().openapi({ description: '更新时间' })
|
|
|
});
|
|
|
@@ -99,7 +102,7 @@ export const CreateDepartmentDto = z.object({
|
|
|
sortOrder: z.number().int().optional().default(0).openapi({ description: '排序', example: 0 }),
|
|
|
isActive: z.number().int().min(0).max(1).optional().default(1).openapi({ description: '是否启用', example: 1 }),
|
|
|
managerId: z.number().int().positive().optional().openapi({ description: '部门负责人ID', example: 1 }),
|
|
|
- parentId: z.number().int().positive().optional().openapi({ description: '父部门ID', example: 1 })
|
|
|
+ parentId: z.number().int().nonnegative().optional().default(0).openapi({ description: '父部门ID,0表示顶级部门', example: 0 })
|
|
|
});
|
|
|
|
|
|
export const UpdateDepartmentDto = z.object({
|
|
|
@@ -109,7 +112,7 @@ export const UpdateDepartmentDto = z.object({
|
|
|
sortOrder: z.number().int().optional().openapi({ description: '排序', example: 0 }),
|
|
|
isActive: z.number().int().min(0).max(1).optional().openapi({ description: '是否启用', example: 1 }),
|
|
|
managerId: z.number().int().positive().optional().openapi({ description: '部门负责人ID', example: 1 }),
|
|
|
- parentId: z.number().int().positive().optional().openapi({ description: '父部门ID', example: 1 })
|
|
|
+ parentId: z.number().int().nonnegative().optional().openapi({ description: '父部门ID,0表示顶级部门', example: 0 })
|
|
|
});
|
|
|
|
|
|
export const UserDepartmentSchema = z.object({
|