test-user.entity.ts 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import { Entity, PrimaryGeneratedColumn, Column, ManyToMany, JoinTable, CreateDateColumn, UpdateDateColumn } from 'typeorm';
  2. import { Role } from '../../src/entities/role.entity';
  3. import { DeleteStatus, DisabledStatus } from '@d8d/shared-types';
  4. @Entity({ name: 'users_mt' })
  5. export class TestUserEntity {
  6. @PrimaryGeneratedColumn({ unsigned: true, comment: '用户ID' })
  7. id!: number;
  8. @Column({ name: 'tenant_id', type: 'int', unsigned: true, comment: '租户ID' })
  9. tenantId!: number;
  10. @Column({ name: 'username', type: 'varchar', length: 255, comment: '用户名' })
  11. username!: string;
  12. @Column({ name: 'password', type: 'varchar', length: 255, comment: '密码' })
  13. password!: string;
  14. @Column({ name: 'phone', type: 'varchar', length: 255, nullable: true, comment: '手机号' })
  15. phone!: string | null;
  16. @Column({ name: 'email', type: 'varchar', length: 255, nullable: true, comment: '邮箱' })
  17. email!: string | null;
  18. @Column({ name: 'nickname', type: 'varchar', length: 255, nullable: true, comment: '昵称' })
  19. nickname!: string | null;
  20. @Column({ name: 'name', type: 'varchar', length: 255, nullable: true, comment: '真实姓名' })
  21. name!: string | null;
  22. @Column({ name: 'is_disabled', type: 'int', default: DisabledStatus.ENABLED, comment: '是否禁用(0:启用,1:禁用)' })
  23. isDisabled!: DisabledStatus;
  24. @Column({ name: 'is_deleted', type: 'int', default: DeleteStatus.NOT_DELETED, comment: '是否删除(0:未删除,1:已删除)' })
  25. isDeleted!: DeleteStatus;
  26. @Column({ name: 'openid', type: 'varchar', length: 255, nullable: true, unique: true, comment: '微信小程序openid' })
  27. openid!: string | null;
  28. @Column({ name: 'unionid', type: 'varchar', length: 255, nullable: true, comment: '微信unionid' })
  29. unionid!: string | null;
  30. @Column({ name: 'registration_source', type: 'varchar', length: 20, default: 'web', comment: '注册来源: web, miniapp' })
  31. registrationSource!: string;
  32. @ManyToMany(() => Role)
  33. @JoinTable()
  34. roles!: Role[];
  35. @CreateDateColumn({ name: 'created_at', type: 'timestamp' })
  36. createdAt!: Date;
  37. @UpdateDateColumn({ name: 'updated_at', type: 'timestamp' })
  38. updatedAt!: Date;
  39. constructor(partial?: Partial<TestUserEntity>) {
  40. Object.assign(this, partial);
  41. }
  42. }