|
|
@@ -56,6 +56,12 @@ export class UserEntity {
|
|
|
@UpdateDateColumn({ name: 'updated_at', type: 'timestamp' })
|
|
|
updatedAt!: Date;
|
|
|
|
|
|
+ @Column({ name: 'created_by', type: 'int', nullable: true, comment: '创建用户ID' })
|
|
|
+ createdBy?: number;
|
|
|
+
|
|
|
+ @Column({ name: 'updated_by', type: 'int', nullable: true, comment: '更新用户ID' })
|
|
|
+ updatedBy?: number;
|
|
|
+
|
|
|
constructor(partial?: Partial<UserEntity>) {
|
|
|
Object.assign(this, partial);
|
|
|
}
|
|
|
@@ -108,5 +114,81 @@ export const UserSchema = z.object({
|
|
|
defaultDepartmentId: z.number().int().positive().nullable().openapi({ description: '默认部门ID', example: 1 }),
|
|
|
dataScopeType: z.enum([DataScopeType.PERSONAL, DataScopeType.DEPARTMENT, DataScopeType.SUB_DEPARTMENT, DataScopeType.COMPANY, DataScopeType.CUSTOM]).default(DataScopeType.PERSONAL).openapi({ description: '数据范围类型', example: DataScopeType.PERSONAL }),
|
|
|
createdAt: z.date().openapi({ description: '创建时间' }),
|
|
|
- updatedAt: z.date().openapi({ description: '更新时间' })
|
|
|
+ updatedAt: z.date().openapi({ description: '更新时间' }),
|
|
|
+ createdBy: z.number().int().positive().nullable().openapi({ description: '创建用户ID', example: 1 }),
|
|
|
+ updatedBy: z.number().int().positive().nullable().openapi({ description: '更新用户ID', example: 1 })
|
|
|
+});
|
|
|
+
|
|
|
+export const CreateUserDto = z.object({
|
|
|
+ username: z.string().min(3).max(255).openapi({
|
|
|
+ example: 'admin',
|
|
|
+ description: '用户名,3-255个字符'
|
|
|
+ }),
|
|
|
+ password: z.string().min(6).max(255).openapi({
|
|
|
+ example: 'password123',
|
|
|
+ description: '密码,最少6位'
|
|
|
+ }),
|
|
|
+ phone: z.string().max(255).nullable().openapi({
|
|
|
+ example: '13800138000',
|
|
|
+ description: '手机号'
|
|
|
+ }),
|
|
|
+ email: z.string().email().max(255).nullable().openapi({
|
|
|
+ example: 'user@example.com',
|
|
|
+ description: '邮箱'
|
|
|
+ }),
|
|
|
+ nickname: z.string().max(255).nullable().openapi({
|
|
|
+ example: '昵称',
|
|
|
+ description: '用户昵称'
|
|
|
+ }),
|
|
|
+ name: z.string().max(255).nullable().openapi({
|
|
|
+ example: '张三',
|
|
|
+ description: '真实姓名'
|
|
|
+ }),
|
|
|
+ avatar: z.string().max(255).nullable().openapi({
|
|
|
+ example: 'https://example.com/avatar.jpg',
|
|
|
+ description: '用户头像'
|
|
|
+ }),
|
|
|
+ isDisabled: z.coerce.number().int().min(0).max(1).default(DisabledStatus.ENABLED).openapi({
|
|
|
+ example: DisabledStatus.ENABLED,
|
|
|
+ description: '是否禁用(0:启用,1:禁用)'
|
|
|
+ }),
|
|
|
+ defaultDepartmentId: z.coerce.number().int().positive().nullable().openapi({ description: '默认部门ID', example: 1 }),
|
|
|
+ dataScopeType: z.enum([DataScopeType.PERSONAL, DataScopeType.DEPARTMENT, DataScopeType.SUB_DEPARTMENT, DataScopeType.COMPANY, DataScopeType.CUSTOM]).default(DataScopeType.PERSONAL).openapi({ description: '数据范围类型', example: DataScopeType.PERSONAL })
|
|
|
+});
|
|
|
+
|
|
|
+export const UpdateUserDto = z.object({
|
|
|
+ username: z.string().min(3).max(255).optional().openapi({
|
|
|
+ example: 'admin',
|
|
|
+ description: '用户名,3-255个字符'
|
|
|
+ }),
|
|
|
+ password: z.string().min(6).max(255).optional().openapi({
|
|
|
+ example: 'password123',
|
|
|
+ description: '密码,最少6位'
|
|
|
+ }),
|
|
|
+ phone: z.string().max(255).nullable().optional().openapi({
|
|
|
+ example: '13800138000',
|
|
|
+ description: '手机号'
|
|
|
+ }),
|
|
|
+ email: z.string().email().max(255).nullable().optional().openapi({
|
|
|
+ example: 'user@example.com',
|
|
|
+ description: '邮箱'
|
|
|
+ }),
|
|
|
+ nickname: z.string().max(255).nullable().optional().openapi({
|
|
|
+ example: '昵称',
|
|
|
+ description: '用户昵称'
|
|
|
+ }),
|
|
|
+ name: z.string().max(255).nullable().optional().openapi({
|
|
|
+ example: '张三',
|
|
|
+ description: '真实姓名'
|
|
|
+ }),
|
|
|
+ avatar: z.string().max(255).nullable().optional().openapi({
|
|
|
+ example: 'https://example.com/avatar.jpg',
|
|
|
+ description: '用户头像'
|
|
|
+ }),
|
|
|
+ isDisabled: z.coerce.number().int().min(0).max(1).optional().openapi({
|
|
|
+ example: DisabledStatus.ENABLED,
|
|
|
+ description: '是否禁用(0:启用,1:禁用)'
|
|
|
+ }),
|
|
|
+ defaultDepartmentId: z.coerce.number().int().positive().nullable().optional().openapi({ description: '默认部门ID', example: 1 }),
|
|
|
+ dataScopeType: z.enum([DataScopeType.PERSONAL, DataScopeType.DEPARTMENT, DataScopeType.SUB_DEPARTMENT, DataScopeType.COMPANY, DataScopeType.CUSTOM]).optional().openapi({ description: '数据范围类型', example: DataScopeType.PERSONAL })
|
|
|
});
|