import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm';
import * as dayjs from 'dayjs';
@Entity('opera', { comment: '操作日志' })
export class Opera {
  @PrimaryGeneratedColumn({ type: 'integer' })
  id: number;
  @Column({ type: 'integer', nullable: true, comment: '操作人id' })
  operator_id: number;
  @Column({ type: 'character varying', nullable: true, comment: '操作人名称' })
  operator_name: string;
  @Column({ type: 'character varying', nullable: true, comment: 'ip' })
  ip: string;
  @Column({ type: 'character varying', nullable: true, comment: '设备' })
  device: string;
  @Column({ type: 'timestamp without time zone', nullable: true, comment: '时间', transformer: { from: value => dayjs(value).format('YYYY-MM-DD HH:mm:ss'), to: value => value } })
  time: Date;
  @Column({ type: 'character varying', nullable: true, comment: '操作地址' })
  referer: string;
  @Column({ type: 'character varying', nullable: true, comment: '请求路由' })
  path: string;
  @Column({ type: 'jsonb', nullable: true, comment: '地址参数' })
  params: object;
  @Column({ type: 'jsonb', nullable: true, comment: '请求参数' })
  query: object;
  @Column({ type: 'jsonb', nullable: true, comment: '方法体' })
  body: object;
  @Column({ type: 'character varying', nullable: true, comment: '操作业务' })
  opera: string;
  @Column({ type: 'jsonb', nullable: true, comment: '原数据' })
  origin_data: Array<any>;
  @Column({ type: 'jsonb', nullable: true, comment: '新数据' })
  new_data: Array<any>;
}
