import { User } from '@/modules/user/user.entity';
import {
  Column,
  Entity,
  PrimaryGeneratedColumn,
  CreateDateColumn,
  UpdateDateColumn,
  OneToOne,
  JoinColumn,
} from 'typeorm';

@Entity()
export class OperationLog {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ unique: false, default: '' })
  method: string;

  @Column({ unique: false, default: '' })
  requestUrl: string;

  @Column({ unique: false, default: '' })
  ip: string;

  @CreateDateColumn()
  createTime: Date;

  // @UpdateDateColumn()
  // updateTime: Date;

  @OneToOne(() => User, {
    createForeignKeyConstraints: false,
    onDelete: 'CASCADE',
  })
  @JoinColumn()
  user: User;

  @Column({ nullable: true })
  userId: number;
}
