mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-17 03:05:13 +00:00
add client entity
This commit is contained in:
@ -42,6 +42,7 @@ import { SpaceLinkEntity } from '../modules/space/entities/space-link.entity';
|
|||||||
import { SubspaceProductAllocationEntity } from '../modules/space/entities/subspace/subspace-product-allocation.entity';
|
import { SubspaceProductAllocationEntity } from '../modules/space/entities/subspace/subspace-product-allocation.entity';
|
||||||
import { SubspaceEntity } from '../modules/space/entities/subspace/subspace.entity';
|
import { SubspaceEntity } from '../modules/space/entities/subspace/subspace.entity';
|
||||||
import { TagEntity } from '../modules/space/entities/tag.entity';
|
import { TagEntity } from '../modules/space/entities/tag.entity';
|
||||||
|
import { ClientEntity } from '../modules/client/entities';
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
TypeOrmModule.forRootAsync({
|
TypeOrmModule.forRootAsync({
|
||||||
@ -93,6 +94,7 @@ import { TagEntity } from '../modules/space/entities/tag.entity';
|
|||||||
SubspaceModelProductAllocationEntity,
|
SubspaceModelProductAllocationEntity,
|
||||||
SpaceProductAllocationEntity,
|
SpaceProductAllocationEntity,
|
||||||
SubspaceProductAllocationEntity,
|
SubspaceProductAllocationEntity,
|
||||||
|
ClientEntity,
|
||||||
],
|
],
|
||||||
namingStrategy: new SnakeNamingStrategy(),
|
namingStrategy: new SnakeNamingStrategy(),
|
||||||
synchronize: Boolean(JSON.parse(configService.get('DB_SYNC'))),
|
synchronize: Boolean(JSON.parse(configService.get('DB_SYNC'))),
|
||||||
|
20
libs/common/src/modules/client/dtos/client.dto.ts
Normal file
20
libs/common/src/modules/client/dtos/client.dto.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import { IsArray, IsNotEmpty, IsString } from 'class-validator';
|
||||||
|
|
||||||
|
export class ClientDto {
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
public uuid: string;
|
||||||
|
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
public clientId: string;
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
public clientSecret: string;
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
public redirectUri: string;
|
||||||
|
@IsArray()
|
||||||
|
@IsNotEmpty()
|
||||||
|
public scopes: string[];
|
||||||
|
}
|
1
libs/common/src/modules/client/dtos/index.ts
Normal file
1
libs/common/src/modules/client/dtos/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export * from './client.dto';
|
42
libs/common/src/modules/client/entities/client.entity.ts
Normal file
42
libs/common/src/modules/client/entities/client.entity.ts
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
import { Entity, Column, Unique } from 'typeorm';
|
||||||
|
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||||
|
import { ClientDto } from '../dtos';
|
||||||
|
|
||||||
|
@Entity({ name: 'clients' })
|
||||||
|
@Unique(['clientId'])
|
||||||
|
export class ClientEntity extends AbstractEntity<ClientDto> {
|
||||||
|
@Column({
|
||||||
|
type: 'uuid',
|
||||||
|
default: () => 'gen_random_uuid()',
|
||||||
|
nullable: false,
|
||||||
|
})
|
||||||
|
public uuid: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
length: 255,
|
||||||
|
nullable: false,
|
||||||
|
})
|
||||||
|
name: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
length: 255,
|
||||||
|
nullable: false,
|
||||||
|
unique: true,
|
||||||
|
})
|
||||||
|
clientId: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
length: 255,
|
||||||
|
nullable: false,
|
||||||
|
})
|
||||||
|
clientSecret: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
length: 255,
|
||||||
|
nullable: false,
|
||||||
|
})
|
||||||
|
redirectUri: string;
|
||||||
|
|
||||||
|
@Column('simple-array')
|
||||||
|
scopes: string[];
|
||||||
|
}
|
1
libs/common/src/modules/client/entities/index.ts
Normal file
1
libs/common/src/modules/client/entities/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export * from './client.entity';
|
@ -0,0 +1,10 @@
|
|||||||
|
import { DataSource, Repository } from 'typeorm';
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { ClientEntity } from '../entities';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class ClientRepository extends Repository<ClientEntity> {
|
||||||
|
constructor(private dataSource: DataSource) {
|
||||||
|
super(ClientEntity, dataSource.createEntityManager());
|
||||||
|
}
|
||||||
|
}
|
1
libs/common/src/modules/client/repositories/index.ts
Normal file
1
libs/common/src/modules/client/repositories/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export * from './client.repository';
|
Reference in New Issue
Block a user