Browse Source

FEATURE | log entity

merge-requests/17/head
andrew_bashliy 3 years ago
parent
commit
30928741b9
  1. 1
      .gitignore
  2. 3
      src/config/entities.config.ts
  3. 1
      src/core/namespaces/index.ts
  4. 29
      src/core/namespaces/logs.namespace.ts
  5. 5
      src/domain/logs/entities/index.ts
  6. 26
      src/domain/logs/entities/log.entity.ts

1
.gitignore vendored

@ -4,7 +4,6 @@
/documentation /documentation
# Logs # Logs
logs
*.log *.log
npm-debug.log* npm-debug.log*
yarn-debug.log* yarn-debug.log*

3
src/config/entities.config.ts

@ -1,5 +1,6 @@
import { SESSIONS_ENTITIES } from 'src/domain/sessions/entities' import { SESSIONS_ENTITIES } from 'src/domain/sessions/entities'
import { USERS_ENTITIES } from 'src/domain/users/entities' import { USERS_ENTITIES } from 'src/domain/users/entities'
import { IPS_ENTITIES } from 'src/domain/ips/entities' import { IPS_ENTITIES } from 'src/domain/ips/entities'
import { LOG_ENTITIES } from 'src/domain/logs/entities'
export const ENTITIES = [...USERS_ENTITIES, ...SESSIONS_ENTITIES, ...IPS_ENTITIES] export const ENTITIES = [...USERS_ENTITIES, ...SESSIONS_ENTITIES, ...IPS_ENTITIES, ...LOG_ENTITIES]

1
src/core/namespaces/index.ts

@ -2,3 +2,4 @@ export * from './sessions.namespace'
export * from './users.namespace' export * from './users.namespace'
export * from './ips.namespace' export * from './ips.namespace'
export * from './sms.namespace' export * from './sms.namespace'
export * from './logs.namespace'

29
src/core/namespaces/logs.namespace.ts

@ -0,0 +1,29 @@
export namespace Logs {
export enum Type {
Black = 'b',
White = 'w',
}
export interface ILog {
/** Унікальний ідентифікатор */
id?: number
/** IP адреса */
ip?: string
/** Ідентифіктор користувача */
userId?: number
/** Дата створення */
createdAt?: string
/** Дата останньої зміни */
updatedAt?: string
/** Опис */
description?: string
/** Тип */
type?: Type
}
}

5
src/domain/logs/entities/index.ts

@ -0,0 +1,5 @@
import { Log } from './log.entity'
export const LOG_ENTITIES = [Log]
export { Log }

26
src/domain/logs/entities/log.entity.ts

@ -0,0 +1,26 @@
import { Logs } from 'src/core'
import { Column, CreateDateColumn, Entity, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm'
@Entity('logs')
export class Log implements Logs.ILog {
@PrimaryGeneratedColumn()
id: number
@Column({ nullable: true })
userId?: number
@Column({ nullable: true })
ip?: string
@CreateDateColumn({ type: 'timestamp', default: () => 'LOCALTIMESTAMP' })
createdAt: string
@UpdateDateColumn({ type: 'timestamp', default: () => 'LOCALTIMESTAMP' })
updatedAt: string
@Column({ type: 'char', nullable: true })
type?: Logs.Type
@Column({ nullable: true })
description?: string
}
Loading…
Cancel
Save