mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-11 07:38:49 +00:00
Add TimeZone module
This commit is contained in:
1
libs/common/src/modules/timezone/dtos/index.ts
Normal file
1
libs/common/src/modules/timezone/dtos/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export * from './timezone.dto';
|
15
libs/common/src/modules/timezone/dtos/timezone.dto.ts
Normal file
15
libs/common/src/modules/timezone/dtos/timezone.dto.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import { IsNotEmpty, IsString } from 'class-validator';
|
||||||
|
|
||||||
|
export class TimeZoneDto {
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
public uuid: string;
|
||||||
|
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
public cityName: string;
|
||||||
|
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
public timeZoneOffset: string;
|
||||||
|
}
|
1
libs/common/src/modules/timezone/entities/index.ts
Normal file
1
libs/common/src/modules/timezone/entities/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export * from './timezone.entity';
|
23
libs/common/src/modules/timezone/entities/timezone.entity.ts
Normal file
23
libs/common/src/modules/timezone/entities/timezone.entity.ts
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import { Column, Entity, OneToMany } from 'typeorm';
|
||||||
|
import { TimeZoneDto } from '../dtos';
|
||||||
|
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||||
|
import { UserEntity } from '../../user/entities';
|
||||||
|
|
||||||
|
@Entity({ name: 'timezone' })
|
||||||
|
export class TimeZoneEntity extends AbstractEntity<TimeZoneDto> {
|
||||||
|
@Column({
|
||||||
|
nullable: false,
|
||||||
|
})
|
||||||
|
cityName: string;
|
||||||
|
@Column({
|
||||||
|
nullable: false,
|
||||||
|
})
|
||||||
|
timeZoneOffset: string;
|
||||||
|
@OneToMany(() => UserEntity, (user) => user.timezone)
|
||||||
|
users: UserEntity[];
|
||||||
|
|
||||||
|
constructor(partial: Partial<TimeZoneEntity>) {
|
||||||
|
super();
|
||||||
|
Object.assign(this, partial);
|
||||||
|
}
|
||||||
|
}
|
1
libs/common/src/modules/timezone/repositories/index.ts
Normal file
1
libs/common/src/modules/timezone/repositories/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export * from './timezone.repository';
|
@ -0,0 +1,10 @@
|
|||||||
|
import { DataSource, Repository } from 'typeorm';
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { TimeZoneEntity } from '../entities';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class TimeZoneRepository extends Repository<TimeZoneEntity> {
|
||||||
|
constructor(private dataSource: DataSource) {
|
||||||
|
super(TimeZoneEntity, dataSource.createEntityManager());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||||
|
import { TimeZoneEntity } from './entities/timezone.entity';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
providers: [],
|
||||||
|
exports: [],
|
||||||
|
controllers: [],
|
||||||
|
imports: [TypeOrmModule.forFeature([TimeZoneEntity])],
|
||||||
|
})
|
||||||
|
export class TimeZoneRepositoryModule {}
|
Reference in New Issue
Block a user